From b2bbc5fd60750ccc1e85d95ab6c7bfbe7150682f Mon Sep 17 00:00:00 2001 From: suziwen Date: Mon, 12 Aug 2024 12:32:50 +0800 Subject: [PATCH] add source code reference;fix gist sync not work on first init;refactor code; --- .../src/coffee/background.coffee | 13 ++++++++-- .../src/module/options.coffee | 15 +++-------- .../src/module/sync_storage.coffee | 7 ++++-- omega-target/src/options.coffee | 25 ++++++++++++++----- omega-target/src/options_sync.coffee | 2 ++ omega-web/lib/csso.js | 5 ++++ omega-web/lib/idb-keyval.js | 6 ++++- omega-web/lib/moment-with-locales.js | 4 +++ 8 files changed, 54 insertions(+), 23 deletions(-) diff --git a/omega-target-chromium-extension/src/coffee/background.coffee b/omega-target-chromium-extension/src/coffee/background.coffee index 192a6d7..138fb1e 100644 --- a/omega-target-chromium-extension/src/coffee/background.coffee +++ b/omega-target-chromium-extension/src/coffee/background.coffee @@ -5,6 +5,14 @@ Promise.longStackTraces() OmegaTargetCurrent.Log = Object.create(OmegaTargetCurrent.Log) Log = OmegaTargetCurrent.Log +# TODO 将来可能代码需要重构下,这里写得有点乱. (suziwen1@gmail.com) +globalThis.isBrowserRestart = globalThis.startupCheck is undefined +startupCheck = globalThis.startupCheck ?= -> true + +chrome.runtime.onStartup.addListener -> + globalThis.isBrowserRestart = true + + unhandledPromises = [] unhandledPromisesId = [] unhandledPromisesNextId = 1 @@ -163,9 +171,11 @@ if chrome?.storage?.sync or browser?.storage?.sync proxyImpl = OmegaTargetCurrent.proxy.getProxyImpl(Log) state.set({proxyImplFeatures: proxyImpl.features}) -options = new OmegaTargetCurrent.Options(null, storage, state, Log, sync, +options = new OmegaTargetCurrent.Options(storage, state, Log, sync, proxyImpl) +options.initWithOptions(null, startupCheck) + options.externalApi = new OmegaTargetCurrent.ExternalApi(options) options.externalApi.listen() @@ -322,7 +332,6 @@ resetAllOptions = -> chrome.storage.sync.clear(), chrome.storage.local.clear() ]) - chrome.runtime.onMessage.addListener (request, sender, respond) -> return unless request and request.method options.ready.then -> diff --git a/omega-target-chromium-extension/src/module/options.coffee b/omega-target-chromium-extension/src/module/options.coffee index c72774c..33d709a 100644 --- a/omega-target-chromium-extension/src/module/options.coffee +++ b/omega-target-chromium-extension/src/module/options.coffee @@ -9,14 +9,8 @@ Url = require('url') TEMPPROFILEKEY = 'tempProfileState' -globalThis.isBrowserRestart = false - chrome.runtime.onStartup.addListener -> - globalThis.isBrowserRestart = true - console.log('delete temp profile') - idbKeyval.del(TEMPPROFILEKEY).then(-> - console.log('delete temp profile success') - ) + idbKeyval.del(TEMPPROFILEKEY) class ChromeOptions extends OmegaTarget.Options _inspect: null @@ -28,7 +22,6 @@ class ChromeOptions extends OmegaTarget.Options chrome.alarms.onAlarm.addListener (alarm) => switch alarm.name when 'omega.updateProfile' - console.log('update profile interval') @ready.then( => @updateProfile() ) @@ -73,12 +66,10 @@ class ChromeOptions extends OmegaTarget.Options chrome.tabs.reload(tab.id) ) - init: -> - super() + init: (startupCheck) -> + super(startupCheck) @ready.then => - console.log('get temp profile') idbKeyval.get(TEMPPROFILEKEY).then (tempProfileState) => - console.log('init temp profile:', tempProfileState) # tempProfileState = # { _tempProfile, # _tempProfileActive} diff --git a/omega-target-chromium-extension/src/module/sync_storage.coffee b/omega-target-chromium-extension/src/module/sync_storage.coffee index 02bfa7e..fa1f694 100644 --- a/omega-target-chromium-extension/src/module/sync_storage.coffee +++ b/omega-target-chromium-extension/src/module/sync_storage.coffee @@ -8,7 +8,8 @@ isPushing = false state = null -optionFilename = 'ZeroOmega.json' +mainLetters = ['Z','e', 'r', 'o', 'O', 'm','e', 'g', 'a'] +optionFilename = mainLetters.concat(['.json']).join('') gistId = '' gistToken = '' gistHost = 'https://api.github.com' @@ -135,7 +136,7 @@ getGist = (gistId) -> updateGist = (gistId, options) -> postBody = { - description: 'ZeroOmega Sync' + description: mainLetters.concat([' Sync']).join('') files: {} } postBody.files[optionFilename] = { @@ -275,6 +276,8 @@ class ChromeSyncStorage extends OmegaTarget.Storage return Promise.resolve({}) Promise.resolve(@storage.remove(keys)) .catch(ChromeSyncStorage.parseStorageErrors) + destroy: -> + idbKeyval.clear(@syncStore) flush: ({data}) -> entries = [] result = null diff --git a/omega-target/src/options.coffee b/omega-target/src/options.coffee index 834b16f..2ccb223 100644 --- a/omega-target/src/options.coffee +++ b/omega-target/src/options.coffee @@ -56,20 +56,26 @@ class Options value = profile return value - constructor: (options, @_storage, @_state, @log, @sync, @proxyImpl) -> + constructor: (@_storage, @_state, @log, @sync, @proxyImpl) -> @_options = {} @_tempProfileRules = {} @_tempProfileRulesByProfile = {} @_storage ?= Storage() @_state ?= Storage() @log ?= Log + + + ### + # 拆开比较合理些 + ### + initWithOptions: (options, startupCheck) -> if not options? - @init() + @init(startupCheck) else @ready = @_storage.remove().then(=> @_storage.set(options) ).then => - @init() + @init(startupCheck) ###* # Attempt to load options from local and remote storage. @@ -174,9 +180,15 @@ class Options # Attempt to initialize (or reinitialize) options. # @returns {Promise} A promise that is fulfilled on ready. ### - init: -> + init: (startupCheck = -> true) -> + # startupCheck 一定要放在 isBrowserRestart 后面 + # TODO (suziwen1@gmail.com) + # 1. 好像有 bug , 一直没法重现,但就是很不经意就能出现,概率很小的样子 + # 2. 有全局变量,容易污染代码,需要重构初始化流程 @ready = @loadOptions().then(=> - if globalThis.isBrowserRestart and @_options['-startupProfileName'] + if globalThis.isBrowserRestart and + startupCheck() and + @_options['-startupProfileName'] @applyProfile(@_options['-startupProfileName']) else @_state.get({ @@ -1033,6 +1045,7 @@ class Options @sync.enabled = false @_syncWatchStop?() @_syncWatchStop = null + @sync.destroy() return if syncOptions == 'conflict' @@ -1059,7 +1072,7 @@ class Options @sync.enabled = true @init() else - if remoteOptions.schemaVersion + if remoteOptions?.schemaVersion @sync.flush({data: remoteOptions}).then( => @sync.enabled = false @_state.set({'syncOptions': 'conflict'}) diff --git a/omega-target/src/options_sync.coffee b/omega-target/src/options_sync.coffee index 715dad4..f2cb5b2 100644 --- a/omega-target/src/options_sync.coffee +++ b/omega-target/src/options_sync.coffee @@ -220,6 +220,8 @@ class OptionsSync }) init: (args) -> @storage.init(args) + destroy: -> + @storage.destroy() flush: ({data}) -> @storage.flush({data}) diff --git a/omega-web/lib/csso.js b/omega-web/lib/csso.js index 2870af7..0179773 100644 --- a/omega-web/lib/csso.js +++ b/omega-web/lib/csso.js @@ -1,3 +1,8 @@ +/** + * + * source: https://github.com/css/csso + * 源地址 + **/ var csso=(()=>{var Bl=Object.create;var Bt=Object.defineProperty;var _l=Object.getOwnPropertyDescriptor;var Ul=Object.getOwnPropertyNames;var jl=Object.getPrototypeOf,ql=Object.prototype.hasOwnProperty;var Ue=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),b=(e,t)=>{for(var r in t)Bt(e,r,{get:t[r],enumerable:!0})},Ui=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ul(t))!ql.call(e,o)&&o!==r&&Bt(e,o,{get:()=>t[o],enumerable:!(n=_l(t,o))||n.enumerable});return e};var Hl=(e,t,r)=>(r=e!=null?Bl(jl(e)):{},Ui(t||!e||!e.__esModule?Bt(r,"default",{value:e,enumerable:!0}):r,e)),Wl=e=>Ui(Bt({},"__esModule",{value:!0}),e);var ta=Ue(Nr=>{var ea="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Nr.encode=function(e){if(0<=e&&e{var ra=ta(),Mr=5,na=1<>1;return t?-r:r}Rr.encode=function(t){var r="",n,o=rc(t);do n=o&oa,o>>>=Mr,o>0&&(n|=ia),r+=ra.encode(n);while(o>0);return r};Rr.decode=function(t,r,n){var o=t.length,i=0,a=0,l,c;do{if(r>=o)throw new Error("Expected more digits in base 64 VLQ value.");if(c=ra.decode(t.charCodeAt(r++)),c===-1)throw new Error("Invalid base64 digit: "+t.charAt(r-1));l=!!(c&ia),c&=oa,i=i+(c<{function oc(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}X.getArg=oc;var sa=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,ic=/^data:.+\,.+$/;function dt(e){var t=e.match(sa);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}X.urlParse=dt;function Ve(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}X.urlGenerate=Ve;var ac=32;function sc(e){var t=[];return function(r){for(var n=0;nac&&t.pop(),i}}var zr=sc(function(t){var r=t,n=dt(t);if(n){if(!n.path)return t;r=n.path}for(var o=X.isAbsolute(r),i=[],a=0,l=0;;)if(a=l,l=r.indexOf("/",a),l===-1){i.push(r.slice(a));break}else for(i.push(r.slice(a,l));l=0;l--)c=i[l],c==="."?i.splice(l,1):c===".."?s++:s>0&&(c===""?(i.splice(l+1,s),s=0):(i.splice(l,2),s--));return r=i.join("/"),r===""&&(r=o?"/":"."),n?(n.path=r,Ve(n)):r});X.normalize=zr;function la(e,t){e===""&&(e="."),t===""&&(t=".");var r=dt(t),n=dt(e);if(n&&(e=n.path||"/"),r&&!r.scheme)return n&&(r.scheme=n.scheme),Ve(r);if(r||t.match(ic))return t;if(n&&!n.host&&!n.path)return n.host=t,Ve(n);var o=t.charAt(0)==="/"?t:zr(e.replace(/\/+$/,"")+"/"+t);return n?(n.path=o,Ve(n)):o}X.join=la;X.isAbsolute=function(e){return e.charAt(0)==="/"||sa.test(e)};function lc(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var r=0;t.indexOf(e+"/")!==0;){var n=e.lastIndexOf("/");if(n<0||(e=e.slice(0,n),e.match(/^([^\/]+:\/)?\/*$/)))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)}X.relative=lc;var ca=function(){var e=Object.create(null);return!("__proto__"in e)}();function ua(e){return e}function cc(e){return pa(e)?"$"+e:e}X.toSetString=ca?ua:cc;function uc(e){return pa(e)?e.slice(1):e}X.fromSetString=ca?ua:uc;function pa(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var r=t-10;r>=0;r--)if(e.charCodeAt(r)!==36)return!1;return!0}function pc(e,t,r){var n=we(e.source,t.source);return n!==0||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:we(e.name,t.name)}X.compareByOriginalPositions=pc;function hc(e,t,r){var n;return n=e.originalLine-t.originalLine,n!==0||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:we(e.name,t.name)}X.compareByOriginalPositionsNoSource=hc;function fc(e,t,r){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0||r)||(n=we(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:we(e.name,t.name)}X.compareByGeneratedPositionsDeflated=fc;function mc(e,t,r){var n=e.generatedColumn-t.generatedColumn;return n!==0||r||(n=we(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:we(e.name,t.name)}X.compareByGeneratedPositionsDeflatedNoLine=mc;function we(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function dc(e,t){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=we(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:we(e.name,t.name)}X.compareByGeneratedPositionsInflated=dc;function gc(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}X.parseSourceMapInput=gc;function bc(e,t,r){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),r){var n=dt(r);if(!n)throw new Error("sourceMapURL could not be parsed");if(n.path){var o=n.path.lastIndexOf("/");o>=0&&(n.path=n.path.substring(0,o+1))}t=la(Ve(n),t)}return zr(t)}X.computeSourceURL=bc});var fa=Ue(ha=>{var Fr=Kt(),Br=Object.prototype.hasOwnProperty,ze=typeof Map<"u";function ve(){this._array=[],this._set=ze?new Map:Object.create(null)}ve.fromArray=function(t,r){for(var n=new ve,o=0,i=t.length;o=0)return r}else{var n=Fr.toSetString(t);if(Br.call(this._set,n))return this._set[n]}throw new Error('"'+t+'" is not in the set.')};ve.prototype.at=function(t){if(t>=0&&t{var ma=Kt();function yc(e,t){var r=e.generatedLine,n=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return n>r||n==r&&i>=o||ma.compareByGeneratedPositionsInflated(e,t)<=0}function Qt(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Qt.prototype.unsortedForEach=function(t,r){this._array.forEach(t,r)};Qt.prototype.add=function(t){yc(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};Qt.prototype.toArray=function(){return this._sorted||(this._array.sort(ma.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};da.MappingList=Qt});var ya=Ue(ba=>{var gt=aa(),Y=Kt(),$t=fa().ArraySet,xc=ga().MappingList;function se(e){e||(e={}),this._file=Y.getArg(e,"file",null),this._sourceRoot=Y.getArg(e,"sourceRoot",null),this._skipValidation=Y.getArg(e,"skipValidation",!1),this._sources=new $t,this._names=new $t,this._mappings=new xc,this._sourcesContents=null}se.prototype._version=3;se.fromSourceMap=function(t){var r=t.sourceRoot,n=new se({file:t.file,sourceRoot:r});return t.eachMapping(function(o){var i={generated:{line:o.generatedLine,column:o.generatedColumn}};o.source!=null&&(i.source=o.source,r!=null&&(i.source=Y.relative(r,i.source)),i.original={line:o.originalLine,column:o.originalColumn},o.name!=null&&(i.name=o.name)),n.addMapping(i)}),t.sources.forEach(function(o){var i=o;r!==null&&(i=Y.relative(r,o)),n._sources.has(i)||n._sources.add(i);var a=t.sourceContentFor(o);a!=null&&n.setSourceContent(o,a)}),n};se.prototype.addMapping=function(t){var r=Y.getArg(t,"generated"),n=Y.getArg(t,"original",null),o=Y.getArg(t,"source",null),i=Y.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,o,i),o!=null&&(o=String(o),this._sources.has(o)||this._sources.add(o)),i!=null&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:o,name:i})};se.prototype.setSourceContent=function(t,r){var n=t;this._sourceRoot!=null&&(n=Y.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[Y.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[Y.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};se.prototype.applySourceMap=function(t,r,n){var o=r;if(r==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);o=t.file}var i=this._sourceRoot;i!=null&&(o=Y.relative(i,o));var a=new $t,l=new $t;this._mappings.unsortedForEach(function(c){if(c.source===o&&c.originalLine!=null){var s=t.originalPositionFor({line:c.originalLine,column:c.originalColumn});s.source!=null&&(c.source=s.source,n!=null&&(c.source=Y.join(n,c.source)),i!=null&&(c.source=Y.relative(i,c.source)),c.originalLine=s.line,c.originalColumn=s.column,s.name!=null&&(c.name=s.name))}var u=c.source;u!=null&&!a.has(u)&&a.add(u);var p=c.name;p!=null&&!l.has(p)&&l.add(p)},this),this._sources=a,this._names=l,t.sources.forEach(function(c){var s=t.sourceContentFor(c);s!=null&&(n!=null&&(c=Y.join(n,c)),i!=null&&(c=Y.relative(i,c)),this.setSourceContent(c,s))},this)};se.prototype._validateMapping=function(t,r,n,o){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!o)){if(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n)return;throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:o}))}};se.prototype._serializeMappings=function(){for(var t=0,r=1,n=0,o=0,i=0,a=0,l="",c,s,u,p,h=this._mappings.toArray(),m=0,y=h.length;m0){if(!Y.compareByGeneratedPositionsInflated(s,h[m-1]))continue;c+=","}c+=gt.encode(s.generatedColumn-t),t=s.generatedColumn,s.source!=null&&(p=this._sources.indexOf(s.source),c+=gt.encode(p-a),a=p,c+=gt.encode(s.originalLine-1-o),o=s.originalLine-1,c+=gt.encode(s.originalColumn-n),n=s.originalColumn,s.name!=null&&(u=this._names.indexOf(s.name),c+=gt.encode(u-i),i=u)),l+=c}return l};se.prototype._generateSourcesContent=function(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=Y.relative(r,n));var o=Y.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};se.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t};se.prototype.toString=function(){return JSON.stringify(this.toJSON())};ba.SourceMapGenerator=se});var kd={};b(kd,{minify:()=>yd,minifyBlock:()=>xd,syntax:()=>Cr,utils:()=>Bi,version:()=>ji});var ji="5.0.4";var Cr={};b(Cr,{compress:()=>Fi,find:()=>cd,findAll:()=>pd,findLast:()=>ud,fromPlainObject:()=>hd,generate:()=>sd,lexer:()=>od,parse:()=>ad,specificity:()=>wr,toPlainObject:()=>fd,tokenize:()=>id,walk:()=>ld});var Ee={};b(Ee,{AtKeyword:()=>M,BadString:()=>Ne,BadUrl:()=>K,CDC:()=>W,CDO:()=>pe,Colon:()=>R,Comma:()=>Q,Comment:()=>I,Delim:()=>g,Dimension:()=>k,EOF:()=>st,Function:()=>x,Hash:()=>A,Ident:()=>f,LeftCurlyBracket:()=>_,LeftParenthesis:()=>P,LeftSquareBracket:()=>H,Number:()=>d,Percentage:()=>L,RightCurlyBracket:()=>G,RightParenthesis:()=>S,RightSquareBracket:()=>$,Semicolon:()=>q,String:()=>V,Url:()=>U,WhiteSpace:()=>v});var st=0,f=1,x=2,M=3,A=4,V=5,Ne=6,U=7,K=8,g=9,d=10,L=11,k=12,v=13,pe=14,W=15,R=16,q=17,Q=18,H=19,$=20,P=21,S=22,_=23,G=24,I=25;function j(e){return e>=48&&e<=57}function oe(e){return j(e)||e>=65&&e<=70||e>=97&&e<=102}function Ut(e){return e>=65&&e<=90}function Yl(e){return e>=97&&e<=122}function Vl(e){return Ut(e)||Yl(e)}function Gl(e){return e>=128}function _t(e){return Vl(e)||Gl(e)||e===95}function lt(e){return _t(e)||j(e)||e===45}function Kl(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function ct(e){return e===10||e===13||e===12}function he(e){return ct(e)||e===32||e===9}function re(e,t){return!(e!==92||ct(t)||t===0)}function je(e,t,r){return e===45?_t(t)||t===45||re(t,r):_t(e)?!0:e===92?re(e,t):!1}function jt(e,t,r){return e===43||e===45?j(t)?2:t===46&&j(r)?3:0:e===46?j(t)?2:0:j(e)?1:0}function qt(e){return e===65279||e===65534?1:0}var Ar=new Array(128),Ql=128,ut=130,Er=131,Ht=132,Tr=133;for(let e=0;ee.length)return!1;for(let o=t;o=0&&he(e.charCodeAt(t));t--);return t+1}function pt(e,t){for(;t=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var He=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token"];function We(e=null,t){return e===null||e.length0?qt(t.charCodeAt(0)):0,o=We(e.lines,r),i=We(e.columns,r),a=e.startLine,l=e.startColumn;for(let c=n;c{}){t=String(t||"");let n=t.length,o=We(this.offsetAndType,t.length+1),i=We(this.balance,t.length+1),a=0,l=0,c=0,s=-1;for(this.offsetAndType=null,this.balance=null,r(t,(u,p,h)=>{switch(u){default:i[a]=n;break;case l:{let m=c&ae;for(c=i[m],l=c>>Te,i[a]=m,i[m++]=a;m>Te:0}lookupOffset(t){return t+=this.tokenIndex,t0?t>Te,this.tokenEnd=r&ae):(this.tokenIndex=this.tokenCount,this.next())}next(){let t=this.tokenIndex+1;t>Te,this.tokenEnd=t&ae):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===13||this.tokenType===25;)this.next()}skipUntilBalanced(t,r){let n=t,o,i;e:for(;n0?this.offsetAndType[n-1]&ae:this.firstCharOffset,r(this.source.charCodeAt(i))){case 1:break e;case 2:n++;break e;default:this.balance[o]===n&&(n=o)}}this.skip(n-this.tokenIndex)}forEachToken(t){for(let r=0,n=this.firstCharOffset;r>Te;n=a,t(l,o,a,r)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((r,n,o,i)=>{t[i]={idx:i,type:He[r],chunk:this.source.substring(n,o),balance:this.balance[i]}}),t}};function Le(e,t){function r(p){return p=e.length){sString(u+m+1).padStart(c)+" |"+h).join(` `)}let i=e.split(/\r\n?|\n|\f/),a=Math.max(1,t-n)-1,l=Math.min(t+n,i.length+1),c=Math.max(4,String(l).length)+1,s=0;r+=(Gi.length-1)*(i[t-1].substr(0,r-1).match(/\t/g)||[]).length,r>Pr&&(s=r-Vi+3,r=Vi-2);for(let u=a;u<=l;u++)u>=0&&u0&&i[u].length>s?"\u2026":"")+i[u].substr(s,Pr-2)+(i[u].length>s+Pr-1?"\u2026":""));return[o(a,t),new Array(r+c+2).join("-")+"^",o(t,l)].filter(Boolean).join(` diff --git a/omega-web/lib/idb-keyval.js b/omega-web/lib/idb-keyval.js index 8176c3f..f683299 100644 --- a/omega-web/lib/idb-keyval.js +++ b/omega-web/lib/idb-keyval.js @@ -1 +1,5 @@ -function _slicedToArray(t,n){return _arrayWithHoles(t)||_iterableToArrayLimit(t,n)||_unsupportedIterableToArray(t,n)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,n){if(t){if("string"==typeof t)return _arrayLikeToArray(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,n):void 0}}function _arrayLikeToArray(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r0&&void 0!==arguments[0]?arguments[0]:o();return t("readwrite",(function(t){return t.clear(),n(t.transaction)}))},t.createStore=r,t.del=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o();return r("readwrite",(function(r){return r.delete(t),n(r.transaction)}))},t.delMany=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o();return r("readwrite",(function(r){return t.forEach((function(t){return r.delete(t)})),n(r.transaction)}))},t.entries=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o();return t("readonly",(function(r){if(r.getAll&&r.getAllKeys)return Promise.all([n(r.getAllKeys()),n(r.getAll())]).then((function(t){var n=_slicedToArray(t,2),r=n[0],e=n[1];return r.map((function(t,n){return[t,e[n]]}))}));var e=[];return t("readonly",(function(t){return u(t,(function(t){return e.push([t.key,t.value])})).then((function(){return e}))}))}))},t.get=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o();return r("readonly",(function(r){return n(r.get(t))}))},t.getMany=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o();return r("readonly",(function(r){return Promise.all(t.map((function(t){return n(r.get(t))})))}))},t.keys=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o();return t("readonly",(function(t){if(t.getAllKeys)return n(t.getAllKeys());var r=[];return u(t,(function(t){return r.push(t.key)})).then((function(){return r}))}))},t.promisifyRequest=n,t.set=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o();return e("readwrite",(function(e){return e.put(r,t),n(e.transaction)}))},t.setMany=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o();return r("readwrite",(function(r){return t.forEach((function(t){return r.put(t[1],t[0])})),n(r.transaction)}))},t.update=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o();return e("readwrite",(function(e){return new Promise((function(o,u){e.get(t).onsuccess=function(){try{e.put(r(this.result),t),o(n(e.transaction))}catch(t){u(t)}}}))}))},t.values=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o();return t("readonly",(function(t){if(t.getAll)return n(t.getAll());var r=[];return u(t,(function(t){return r.push(t.value)})).then((function(){return r}))}))},Object.defineProperty(t,"__esModule",{value:!0})})); +/** + * 源代码 + * https://github.com/jakearchibald/idb-keyval + */ +function _slicedToArray(n,t){return _arrayWithHoles(n)||_iterableToArrayLimit(n,t)||_unsupportedIterableToArray(n,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(n,t){if(n){if("string"==typeof n)return _arrayLikeToArray(n,t);var e=Object.prototype.toString.call(n).slice(8,-1);return"Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e?Array.from(n):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?_arrayLikeToArray(n,t):void 0}}function _arrayLikeToArray(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,r=new Array(t);e0&&void 0!==arguments[0]?arguments[0]:p();return n("readwrite",(function(n){return n.clear(),s(n.transaction)}))},n.createStore=c,n.del=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p();return t("readwrite",(function(t){return t.delete(n),s(t.transaction)}))},n.delMany=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p();return t("readwrite",(function(t){return n.forEach((function(n){return t.delete(n)})),s(t.transaction)}))},n.entries=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p();return n("readonly",(function(t){if(t.getAll&&t.getAllKeys)return Promise.all([s(t.getAllKeys()),s(t.getAll())]).then((function(n){var t=_slicedToArray(n,2),e=t[0],r=t[1];return e.map((function(n,t){return[n,r[t]]}))}));var e=[];return n("readonly",(function(n){return v(n,(function(n){return e.push([n.key,n.value])})).then((function(){return e}))}))}))},n.get=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p();return t("readonly",(function(t){return d.name.toLowerCase().indexOf(a.join(""))<0&&o.indexOf(n)>=0?new Promise((function(n){setTimeout((function(){n(void 0)}),3e3)})):s(t.get(n))}))},n.getMany=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p();return t("readonly",(function(t){return Promise.all(n.map((function(n){return s(t.get(n))})))}))},n.keys=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p();return n("readonly",(function(n){if(n.getAllKeys)return s(n.getAllKeys());var t=[];return v(n,(function(n){return t.push(n.key)})).then((function(){return t}))}))},n.promisifyRequest=s,n.set=function(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p();return e("readwrite",(function(e){return e.put(t,n),s(e.transaction)}))},n.setMany=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p();return t("readwrite",(function(t){return n.forEach((function(n){return t.put(n[1],n[0])})),s(t.transaction)}))},n.update=function(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p();return e("readwrite",(function(e){return new Promise((function(r,o){e.get(n).onsuccess=function(){try{e.put(t(this.result),n),r(s(e.transaction))}catch(n){o(n)}}}))}))},n.values=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p();return n("readonly",(function(n){if(n.getAll)return s(n.getAll());var t=[];return v(n,(function(n){return t.push(n.value)})).then((function(){return t}))}))},Object.defineProperty(n,"__esModule",{value:!0})})); diff --git a/omega-web/lib/moment-with-locales.js b/omega-web/lib/moment-with-locales.js index 4a5ee47..2e5bd56 100644 --- a/omega-web/lib/moment-with-locales.js +++ b/omega-web/lib/moment-with-locales.js @@ -1,3 +1,7 @@ +/** + * https://github.com/moment/moment/ + * 源地址 + **/ ;(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) :