@jspreadsheet/server
Version:
Create a backend for data persistence and real-time collaboration. This software requires a special license.
40 lines (39 loc) • 18.2 kB
JavaScript
'use strict';var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,d,g){if(a==Array.prototype||a==Object.prototype)return a;a[d]=g.value;return a};
$jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var d=0;d<a.length;++d){var g=a[d];if(g&&g.Math==Math)return g}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};
$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(a,d,g){if(!g||null!=a){g=$jscomp.propertyToPolyfillSymbol[d];if(null==g)return a[d];g=a[g];return void 0!==g?g:a[d]}};$jscomp.polyfill=function(a,d,g,m){d&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(a,d,g,m):$jscomp.polyfillUnisolated(a,d,g,m))};
$jscomp.polyfillUnisolated=function(a,d,g,m){g=$jscomp.global;a=a.split(".");for(m=0;m<a.length-1;m++){var r=a[m];if(!(r in g))return;g=g[r]}a=a[a.length-1];m=g[a];d=d(m);d!=m&&null!=d&&$jscomp.defineProperty(g,a,{configurable:!0,writable:!0,value:d})};
$jscomp.polyfillIsolated=function(a,d,g,m){var r=a.split(".");a=1===r.length;m=r[0];m=!a&&m in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var t=0;t<r.length-1;t++){var v=r[t];if(!(v in m))return;m=m[v]}r=r[r.length-1];g=$jscomp.IS_SYMBOL_NATIVE&&"es6"===g?m[r]:null;d=d(g);null!=d&&(a?$jscomp.defineProperty($jscomp.polyfills,r,{configurable:!0,writable:!0,value:d}):d!==g&&(void 0===$jscomp.propertyToPolyfillSymbol[r]&&(g=1E9*Math.random()>>>0,$jscomp.propertyToPolyfillSymbol[r]=$jscomp.IS_SYMBOL_NATIVE?
$jscomp.global.Symbol(r):$jscomp.POLYFILL_PREFIX+g+"$"+r),$jscomp.defineProperty(m,$jscomp.propertyToPolyfillSymbol[r],{configurable:!0,writable:!0,value:d})))};$jscomp.underscoreProtoCanBeSet=function(){var a={a:!0},d={};try{return d.__proto__=a,d.a}catch(g){}return!1};
$jscomp.setPrototypeOf=$jscomp.TRUST_ES6_POLYFILLS&&"function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(a,d){a.__proto__=d;if(a.__proto__!==d)throw new TypeError(a+" is not extensible");return a}:null;$jscomp.arrayIteratorImpl=function(a){var d=0;return function(){return d<a.length?{done:!1,value:a[d++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};
$jscomp.makeIterator=function(a){var d="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];if(d)return d.call(a);if("number"==typeof a.length)return $jscomp.arrayIterator(a);throw Error(String(a)+" is not an iterable or ArrayLike");};$jscomp.generator={};$jscomp.generator.ensureIteratorResultIsObject_=function(a){if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");};
$jscomp.generator.Context=function(){this.isRunning_=!1;this.yieldAllIterator_=null;this.yieldResult=void 0;this.nextAddress=1;this.finallyAddress_=this.catchAddress_=0;this.finallyContexts_=this.abruptCompletion_=null};$jscomp.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0};$jscomp.generator.Context.prototype.stop_=function(){this.isRunning_=!1};
$jscomp.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_};$jscomp.generator.Context.prototype.next_=function(a){this.yieldResult=a};$jscomp.generator.Context.prototype.throw_=function(a){this.abruptCompletion_={exception:a,isException:!0};this.jumpToErrorHandler_()};$jscomp.generator.Context.prototype.return=function(a){this.abruptCompletion_={return:a};this.nextAddress=this.finallyAddress_};
$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks=function(a){this.abruptCompletion_={jumpTo:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.yield=function(a,d){this.nextAddress=d;return{value:a}};$jscomp.generator.Context.prototype.yieldAll=function(a,d){a=$jscomp.makeIterator(a);var g=a.next();$jscomp.generator.ensureIteratorResultIsObject_(g);if(g.done)this.yieldResult=g.value,this.nextAddress=d;else return this.yieldAllIterator_=a,this.yield(g.value,d)};
$jscomp.generator.Context.prototype.jumpTo=function(a){this.nextAddress=a};$jscomp.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0};$jscomp.generator.Context.prototype.setCatchFinallyBlocks=function(a,d){this.catchAddress_=a;void 0!=d&&(this.finallyAddress_=d)};$jscomp.generator.Context.prototype.setFinallyBlock=function(a){this.catchAddress_=0;this.finallyAddress_=a||0};$jscomp.generator.Context.prototype.leaveTryBlock=function(a,d){this.nextAddress=a;this.catchAddress_=d||0};
$jscomp.generator.Context.prototype.enterCatchBlock=function(a){this.catchAddress_=a||0;a=this.abruptCompletion_.exception;this.abruptCompletion_=null;return a};$jscomp.generator.Context.prototype.enterFinallyBlock=function(a,d,g){g?this.finallyContexts_[g]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_];this.catchAddress_=a||0;this.finallyAddress_=d||0};
$jscomp.generator.Context.prototype.leaveFinallyBlock=function(a,d){d=this.finallyContexts_.splice(d||0)[0];if(d=this.abruptCompletion_=this.abruptCompletion_||d){if(d.isException)return this.jumpToErrorHandler_();void 0!=d.jumpTo&&this.finallyAddress_<d.jumpTo?(this.nextAddress=d.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=a};$jscomp.generator.Context.prototype.forIn=function(a){return new $jscomp.generator.Context.PropertyIterator(a)};
$jscomp.generator.Context.PropertyIterator=function(a){this.object_=a;this.properties_=[];for(var d in a)this.properties_.push(d);this.properties_.reverse()};$jscomp.generator.Context.PropertyIterator.prototype.getNext=function(){for(;0<this.properties_.length;){var a=this.properties_.pop();if(a in this.object_)return a}return null};$jscomp.generator.Engine_=function(a){this.context_=new $jscomp.generator.Context;this.program_=a};
$jscomp.generator.Engine_.prototype.next_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_.next,a,this.context_.next_);this.context_.next_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.return_=function(a){this.context_.start_();var d=this.context_.yieldAllIterator_;if(d)return this.yieldAllStep_("return"in d?d["return"]:function(g){return{value:g,done:!0}},a,this.context_.return);this.context_.return(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.throw_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_["throw"],a,this.context_.next_);this.context_.throw_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.yieldAllStep_=function(a,d,g){try{var m=a.call(this.context_.yieldAllIterator_,d);$jscomp.generator.ensureIteratorResultIsObject_(m);if(!m.done)return this.context_.stop_(),m;var r=m.value}catch(t){return this.context_.yieldAllIterator_=null,this.context_.throw_(t),this.nextStep_()}this.context_.yieldAllIterator_=null;g.call(this.context_,r);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var a=this.program_(this.context_);if(a)return this.context_.stop_(),{value:a.value,done:!1}}catch(d){this.context_.yieldResult=void 0,this.context_.throw_(d)}this.context_.stop_();if(this.context_.abruptCompletion_){a=this.context_.abruptCompletion_;this.context_.abruptCompletion_=null;if(a.isException)throw a.exception;return{value:a.return,done:!0}}return{value:void 0,done:!0}};
$jscomp.generator.Generator_=function(a){this.next=function(d){return a.next_(d)};this.throw=function(d){return a.throw_(d)};this.return=function(d){return a.return_(d)};this[Symbol.iterator]=function(){return this}};$jscomp.generator.createGenerator=function(a,d){d=new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(d));$jscomp.setPrototypeOf&&a.prototype&&$jscomp.setPrototypeOf(d,a.prototype);return d};
$jscomp.asyncExecutePromiseGenerator=function(a){function d(m){return a.next(m)}function g(m){return a.throw(m)}return new Promise(function(m,r){function t(v){v.done?m(v.value):Promise.resolve(v.value).then(d,g).then(t,r)}t(a.next())})};$jscomp.asyncExecutePromiseGeneratorFunction=function(a){return $jscomp.asyncExecutePromiseGenerator(a())};$jscomp.asyncExecutePromiseGeneratorProgram=function(a){return $jscomp.asyncExecutePromiseGenerator(new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(a)))};
function a0_0x7ab5(a,d){const g=a0_0x41c2();return a0_0x7ab5=function(m,r){return g[m-123]},a0_0x7ab5(a,d)}
function a0_0x41c2(){const a="main.json;allSettled;string;parse;143wzAEMA;createSpreadsheet;updated;worksheets;8hPnXTu;parent;file;instance;emit;change;load;object;destroySpreadsheetCache;createWorksheet;worksheet;error;The worksheet name is a mandatory field;stringify;1672464EbQGwo;loadSpreadsheet;forceRefresh;resetSpreadsheets;setLicense;16697170eSydxp;908wLqoOX;options;args;listen;undefined;5AeMbep;query;reason;connect;It was not possible to load;auth;toString;jspreadsheet;create;disconnect;Worksheet not found;5vHEGRW;destroyCache;415774MKkzVG;server;JSS;loadAsync;worksheetId;map;5895630TskeZB;length;reset;This spreadsheet has been deleted;9xhQKtv;updateSpreadsheet;handshake;4319357IzXrYQ;beforeChange;Invalid authentication;license;get;50414897LlWBei;method;getSpreadsheets;beforeLoad;Something went wrong;exports;spreadsheets;setExtensions;namespace;version;getSpreadsheet;join;function;extensions;arraybuffer;disconnectSockets;There were an error trying to save the last operation.;call;uuid;spreadsheet;beforeConnect;port;attach;11553HrkSvO;destroy;config;License is mandatory;status;@jspreadsheet/formula-pro;guid;fetchSockets;Spreadsheet not found;persistence;generateAsync;includes;message;resetBorders".split(";");a0_0x41c2=
function(){return a};return a0_0x41c2()}(function(a,d){const g=a0_0x7ab5;for(a=a();;)try{if(parseInt(g(170))/1*(parseInt(g(183))/2)+-parseInt(g(123))/3*(parseInt(g(165))/4)+parseInt(g(181))/5*(parseInt(g(189))/6)+parseInt(g(196))/7*(-parseInt(g(145))/8)+parseInt(g(193))/9*(-parseInt(g(164))/10)+parseInt(g(141))/11*(-parseInt(g(159))/12)+parseInt(g(201))/13===d)break;else a.push(a.shift())}catch(m){a.push(a.shift())}})(a0_0x41c2,927328);
(()=>{function a(t){const v=a0_0x7ab5;var w=m[t];if(void 0!==w)return w[v(206)];w=m[t]={exports:{}};return g[t].call(w.exports,w,w.exports,a),w[v(206)]}const d=a0_0x7ab5;var g={9985:function(t,v,w){const B=w(4333),F=w(5943),E=w(9856),C=w(1582),G=w(1245);(function(D,y){t[a0_0x7ab5(206)]=y()})(this,function(){const D=function(c){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){const b=a0_0x7ab5,q=new E;return q.file(b(137),JSON.stringify(c)),yield q[b(133)]({type:b(215)})})},y=function(c){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){const b=
a0_0x7ab5,q=yield(yield E[b(186)](c))[b(147)](b(137)).async("string");return JSON[b(140)](q)})},H=function(c){function b(){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){const q=a0_0x7ab5;try{var f=c[q(203)]();const e=Object.keys(f),p=e[q(190)],l=[];for(let n=0;n<p;n++){const u=e[n],x=f[u];18E5<(new Date).getTime()-x.updated&&l.push(u)}const k=yield Promise[q(138)](l[q(188)](function(n){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){0===(yield c.io["in"](n)[q(130)]())[q(190)]&&
c[q(153)](n)})})),h=k[q(190)];for(f=0;f<h;f++){const n=k[f];"rejected"===n[q(127)]&&(yield c[q(156)](n[q(172)]))}}catch(e){yield c[q(156)](e)}setTimeout(b,18E5)})}setTimeout(b,18E5)},I=function(){const c=a0_0x7ab5,b=function(f){const e=a0_0x7ab5;f[e(203)]=b[e(200)];f[e(162)]=b[e(191)];f[e(211)]=b[e(220)];f[e(160)]=b.load;f[e(142)]=b[e(178)];f.updateSpreadsheet=b[e(150)];f.destroySpreadsheet=b[e(124)];f[e(153)]=b[e(182)];f[e(156)]=b[e(156)]};b.get=function(){return this.spreadsheets};b.reset=function(){this[a0_0x7ab5(207)]=
{}};const q=function(f){const e=a0_0x7ab5;if(typeof f!==e(152)||null===f)throw Error("The worksheet must be an object");!f[e(187)]&&(f.worksheetId=B.v4());if(!f.worksheetName)throw Error(e(157));};return b.create=function(f,e,p){const l=this;return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){const k=a0_0x7ab5;e=JSON[k(140)](e);if(e[k(144)]&&e.worksheets[k(190)]){for(let h=0;h<e[k(144)][k(190)];h++)q(e[k(144)][h]);!e[k(209)]&&(e[k(209)]=B.v4());!e.version&&(e[k(210)]=B.v4())}else throw Error("Worksheets must be declared");
return l.options[k(178)](f,e,p)})},b[c(220)]=function(f){return this[c(207)][f]},b[c(151)]=function(f,e){const p=this;return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){if(typeof p[c(166)][c(204)]===c(213)&&!1===(yield p.options[c(204)](f,e)))return!1;if(typeof p[c(166)][c(151)]===c(213)){let l,k=p[c(207)][f];k&&(l=Object.assign({},k[c(148)].getConfig()));let h=yield p.options.load(f,e,l);if(h){"string"===typeof h&&(h=JSON[c(140)](h));if(!l)try{let n=C(null,h);if(n){let u=n[0][c(146)];
u[c(129)]=f;k=p[c(207)][f]={instance:u,updated:(new Date).getTime()};u[c(125)][c(132)]=(x,z,A)=>{"function"===typeof p[c(166)][c(150)]&&(x={instance:u,worksheet:x.options[c(187)],method:z,args:A?Object.values(A):[]},p.options[c(150)](f,x,e,()=>{p.io.to(f).emit(c(161),{args:[c(217)]})}))}}else return console[c(156)](c(174),f),!1}catch(n){return console[c(156)](c(174),f,n),!1}return JSON[c(158)](h)}}return!1})},b.change=function(f,e,p){const l=this;return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){if(typeof l[c(166)].beforeChange===
c(213)&&!1===(yield l[c(166)][c(197)](f,e,p)))return!1;let k=l[c(207)][f];if(k){if(e[c(202)]!==c(154))a:{var h=e.worksheet;var n=k[c(148)].worksheets;const u=a0_0x7ab5;if(typeof h===u(139)){const x=n[u(190)];for(let z=0;z<x;z++){const A=n[z];if(A.options[u(187)]===h){h=A;break a}}h=null}else h=n[h]}else h=k[c(148)][c(144)][0],q(e.args[0]);if(null===h)throw Error(c(180));return(!e[c(155)]||!e.worksheet[c(176)]()[c(134)]("-"))&&(e[c(155)]=h[c(166)].worksheetId),k[c(143)]=(new Date).getTime(),k[c(148)].config[c(210)]=
e[c(210)],h[e.method](...e[c(167)]),!0}throw Error(c(131));})},b.destroy=function(f,e){const p=this;return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){let l=!0;return typeof p[c(166)][c(124)]===c(213)&&(l=yield p.options.destroy(f,e)),l&&(b[c(182)][c(218)](p,f),p.io.to(f)[c(149)]("forceRefresh",{args:[c(192)]}),p.io["in"](f)[c(216)]()),l})},b[c(182)]=function(f){typeof this[c(207)][f]!==c(169)&&(this[c(207)][f][c(148)]&&this[c(207)][f].instance.destroy(),delete this[c(207)][f])},b.error=
function(f){const e=this;return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){typeof e.options.error===c(213)&&(yield e[c(166)][c(156)](f))})},b}();return function(c){const b=a0_0x7ab5,q=F(Object.assign({},{maxHttpBufferSize:2E8},c[b(125)])),f={io:q,options:c,spreadsheets:{},helpers:{encodeZip:D,decodeZip:y}};I(f);H(f);if(c[b(199)])C[b(163)](c[b(199)]),C[b(208)]({formula:G}),c[b(214)]&&typeof c[b(214)]===b(152)&&C.setExtensions(c[b(214)],f);else return Error(b(126));return q.use((e,p)=>
$jscomp.asyncExecutePromiseGeneratorFunction(function*(){if(typeof c[b(175)]===b(213))try{if(!(yield c[b(175)](e[b(195)][b(171)])))return p(Error(b(198)))}catch(l){yield f.error(l)}if(typeof c[b(221)]===b(213))try{if(!(yield c[b(221)](e[b(195)].query)))return p(Error(b(198)))}catch(l){yield f[b(156)](l)}return p()})),q.on("connection",function(e){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){let p=e[b(195)][b(171)].user||B.v4();if(e.handshake[b(171)][b(129)]){let l=e.handshake[b(171)][b(129)];
e[b(212)](l);e.on(b(185),function(k,h){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){try{let n,u=yield y(k);"setBorder"===u[b(202)]||"resetBorders"===u[b(202)]?n=!0:n=yield f[b(194)](l,u,e[b(195)][b(171)]);n?(e.broadcast.to(l)[b(149)](b(185),k),h({status:!0})):h({status:!1,error:1,message:"Permission Denied"})}catch(n){h({status:!1,error:1,message:"Something went wrong"}),yield f[b(156)](n)}})});e.on(b(179),function(){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){if(l){var k=
f[b(211)](l);if(k){k=k[b(148)].worksheets;const n=k.length;for(let u=0;u<n;u++){var h=k[u];h=yield D({user:p,args:[],method:b(136),worksheet:h[b(166)][b(187)]});e.broadcast.to(l)[b(149)](b(185),h)}}}if(typeof c[b(179)]===b(213))try{yield c[b(179)](e[b(195)][b(171)],p)}catch(n){yield f[b(156)](n)}})})}e.on(b(178),function(l,k){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){try{const h=yield y(l),n=yield f[b(142)](h[b(129)],h[b(125)],e.handshake[b(171)]);k(n)}catch(h){h instanceof Error?
k(h[b(135)]):(yield f[b(156)](h),k(b(205)))}})});e.on("load",function(l,k){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){try{let h=Object.assign({},e[b(195)][b(171)]);l&&(h[b(129)]=l);let n=yield f[b(160)](l,h);!1===n&&(n={error:1,message:b(131)});let u=yield D(n);k(u)}catch(h){yield f[b(156)](h)}})});e.on("destroy",function(l){return $jscomp.asyncExecutePromiseGeneratorFunction(function*(){try{yield f.destroySpreadsheet(l,e[b(195)][b(171)])}catch(k){yield f[b(156)](k)}})});if(typeof c.connect===
b(213))try{yield c[b(173)](e[b(195)].query,p)}catch(l){yield f.error(l)}})}),c.server&&typeof c.server[b(168)]===b(213)?(q[b(223)](c[b(184)]),c[b(184)].listen(c.port||3E3)):q[b(168)](c[b(222)]||3E3),f}})},1245:t=>{t.exports=require(a0_0x7ab5(128))},1582:t=>{t.exports=require(a0_0x7ab5(177))},9856:t=>{t[a0_0x7ab5(206)]=require("jszip")},5943:t=>{t.exports=require("socket.io")},4333:t=>{const v=a0_0x7ab5;t[v(206)]=require(v(219))}},m={},r=a(9985);module[d(206)]=r})();