@univer-cli/content-execution 1.0.0-beta.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,12 +38,13 @@ The package returns only the program string. The caller remains responsible for
38
38
  | Unit type | Injected binding |
39
39
  | --------- | ---------------------------------- |
40
40
  | Sheet | `univerAPI`, `api`, `workbook` |
41
- | Doc | `univerAPI`, `api`, `document` |
41
+ | Doc | `univerAPI`, `api`, `doc` |
42
42
  | Slide | `univerAPI`, `api`, `presentation` |
43
- | Base | `univerAPI`, `api`, `database` |
43
+ | Base | `univerAPI`, `api`, `base` |
44
44
  | Board | `univerAPI`, `api`, `board` |
45
45
 
46
46
  Root Facade is obtained through `unitId` instead of relying on the current active unit, so the same code can be stably executed in the headless runtime.
47
+ If the selected Unit does not exist, the program throws `Cannot find <binding> <unitId>` before running user code.
47
48
 
48
49
  ## Validation and errors
49
50
 
package/README.zh-CN.md CHANGED
@@ -39,12 +39,13 @@ Package 只返回 program 字符串。Runtime 的获取、执行模式、lease
39
39
  | Unit 类型 | 注入的 binding |
40
40
  | --------- | ---------------------------------- |
41
41
  | Sheet | `univerAPI`、`api`、`workbook` |
42
- | Doc | `univerAPI`、`api`、`document` |
42
+ | Doc | `univerAPI`、`api`、`doc` |
43
43
  | Slide | `univerAPI`、`api`、`presentation` |
44
- | Base | `univerAPI`、`api`、`database` |
44
+ | Base | `univerAPI`、`api`、`base` |
45
45
  | Board | `univerAPI`、`api`、`board` |
46
46
 
47
47
  Root Facade 通过 `unitId` 获取,而不是依赖当前 active Unit,因此相同代码可在 headless runtime 中稳定执行。
48
+ 如果指定 Unit 不存在,program 会在执行用户代码前抛出 `Cannot find <binding> <unitId>` 错误。
48
49
 
49
50
  ## 校验与错误
50
51
 
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- const _0x1afc5c=_0x285f;(function(_0x4e7d8c,_0x4f41e2){const _0x3a172a=_0x285f,_0x30ce9e=_0x4e7d8c();while(!![]){try{const _0x5af814=-parseInt(_0x3a172a(0x16e))/0x1+parseInt(_0x3a172a(0x174))/0x2*(parseInt(_0x3a172a(0x16b))/0x3)+-parseInt(_0x3a172a(0x161))/0x4+parseInt(_0x3a172a(0x17c))/0x5+parseInt(_0x3a172a(0x17d))/0x6+-parseInt(_0x3a172a(0x16c))/0x7+parseInt(_0x3a172a(0x166))/0x8;if(_0x5af814===_0x4f41e2)break;else _0x30ce9e['push'](_0x30ce9e['shift']());}catch(_0x3ccd02){_0x30ce9e['push'](_0x30ce9e['shift']());}}}(_0x3d2d,0xac341));var e=class extends Error{[_0x1afc5c(0x170)];[_0x1afc5c(0x15e)];constructor(_0x15fed9,_0x48b96d,_0x5dd606){const _0x22c5aa=_0x1afc5c;super(_0x48b96d),this[_0x22c5aa(0x170)]=_0x15fed9,this['details']=_0x5dd606,this[_0x22c5aa(0x175)]=_0x22c5aa(0x177);}},t=[_0x1afc5c(0x163),_0x1afc5c(0x17e),'slide',_0x1afc5c(0x168),_0x1afc5c(0x15c)];function n(_0xe18638){const _0x2c61af=_0x1afc5c;if(typeof _0xe18638[_0x2c61af(0x170)]!=_0x2c61af(0x173))throw new e(_0x2c61af(0x167),'Content\x20execution\x20code\x20must\x20be\x20a\x20string');if(typeof _0xe18638['unitId']!=_0x2c61af(0x173)||_0xe18638[_0x2c61af(0x16d)][_0x2c61af(0x15f)]()[_0x2c61af(0x160)]===0x0)throw new e('CONTENT_EXECUTION_INVALID_INPUT','Content\x20execution\x20Unit\x20ID\x20must\x20not\x20be\x20empty',{'unitId':_0xe18638[_0x2c61af(0x16d)]});if(!s(_0xe18638['unitType']))throw new e('CONTENT_EXECUTION_UNIT_TYPE_UNSUPPORTED',_0x2c61af(0x17a)+String(_0xe18638[_0x2c61af(0x172)]),{'supportedUnitTypes':t,'unitType':_0xe18638[_0x2c61af(0x172)]});let _0x35cf92=i(_0xe18638[_0x2c61af(0x172)]);return a(_0xe18638[_0x2c61af(0x170)],_0xe18638[_0x2c61af(0x172)],_0x35cf92),r(_0xe18638['unitType'],_0xe18638[_0x2c61af(0x16d)])+'\x0a'+_0xe18638['code'];}function _0x3d2d(){const _0x1bd1b6=['9216725DwQJlE','unitId','1372876aFHEcQ','const\x20api\x20=\x20univerAPI;\x0aconst\x20board\x20=\x20api.getBoard(','code','join','unitType','string','8tyIHWQ','name','presentation','ContentExecutionError','const\x20api\x20=\x20univerAPI;\x0aconst\x20doc\x20=\x20api.getDocument(','api','Content\x20execution\x20does\x20not\x20support\x20Unit\x20type\x20','univerAPI','1807160SzrsYV','6280272afMIAx','doc','const\x20api\x20=\x20univerAPI;','some','stringify','board','Cannot\x20find\x20workbook\x20','details','trim','length','5198240VzEwSY','slide','sheet','workbook','CONTENT_EXECUTION_RESERVED_BINDING','18964768aULsCB','CONTENT_EXECUTION_INVALID_INPUT','base','const\x20workbook\x20=\x20api.getWorkbook(','const\x20api\x20=\x20univerAPI;\x0aconst\x20presentation\x20=\x20api.getPresentation(','686787rNoHWD'];_0x3d2d=function(){return _0x1bd1b6;};return _0x3d2d();}function r(_0x418205,_0x12be36){const _0x22296b=_0x1afc5c;let _0x210ef7=JSON['stringify'](_0x12be36);return _0x418205==='sheet'?[_0x22296b(0x17f),_0x22296b(0x169)+_0x210ef7+');','if\x20(!workbook)\x20throw\x20new\x20Error('+JSON[_0x22296b(0x15b)](_0x22296b(0x15d)+_0x12be36)+');'][_0x22296b(0x171)]('\x0a'):_0x418205===_0x22296b(0x17e)?_0x22296b(0x178)+_0x210ef7+');':_0x418205===_0x22296b(0x162)?_0x22296b(0x16a)+_0x210ef7+');':_0x418205==='board'?_0x22296b(0x16f)+_0x210ef7+');':_0x22296b(0x17f);}function _0x285f(_0x17eeab,_0x4e66ea){_0x17eeab=_0x17eeab-0x15a;const _0x3d2d1e=_0x3d2d();let _0x285ff6=_0x3d2d1e[_0x17eeab];return _0x285ff6;}function i(_0x3507d8){const _0x893a4a=_0x1afc5c;return _0x3507d8===_0x893a4a(0x163)?[_0x893a4a(0x17b),'api',_0x893a4a(0x164)]:_0x3507d8===_0x893a4a(0x17e)?['univerAPI',_0x893a4a(0x179),_0x893a4a(0x17e)]:_0x3507d8==='slide'?[_0x893a4a(0x17b),_0x893a4a(0x179),_0x893a4a(0x176)]:_0x3507d8===_0x893a4a(0x15c)?[_0x893a4a(0x17b),_0x893a4a(0x179),_0x893a4a(0x15c)]:['univerAPI',_0x893a4a(0x179)];}function a(_0x41f350,_0x3647a5,_0x33591c){const _0x5550ae=_0x1afc5c;if(o(_0x41f350)){for(let _0x3c51a1 of _0x33591c)if(!o('const\x20'+_0x3c51a1+'\x20=\x20undefined;\x0a'+_0x41f350))throw new e(_0x5550ae(0x165),'`'+_0x3c51a1+'`\x20is\x20reserved\x20by\x20the\x20'+_0x3647a5+'\x20content\x20execution\x20prelude',{'binding':_0x3c51a1,'reservedBindings':_0x33591c,'unitType':_0x3647a5});}}function o(_0x36a23f){const _0x5efe97=_0x1afc5c;try{return Function(_0x5efe97(0x17b),'return\x20(async\x20()\x20=>\x20{\x20'+_0x36a23f+'\x0a})();'),!0x0;}catch{return!0x1;}}function s(_0x2785da){const _0x17e430=_0x1afc5c;return t[_0x17e430(0x15a)](_0x4a11fc=>_0x4a11fc===_0x2785da);}export{e as ContentExecutionError,n as prepareContentExecutionProgram};
1
+ function _0x27fe(){const _0x2a66d2=['584390JRrZxJ','unitType','doc','if\x20(!workbook)\x20throw\x20new\x20Error(','Cannot\x20find\x20presentation\x20','\x20content\x20execution\x20prelude','40lZdDQh','api','1564629TYHiLB','`\x20is\x20reserved\x20by\x20the\x20','229383ZuRNKl','unitId','22oRjWHb','name','Content\x20execution\x20Unit\x20ID\x20must\x20not\x20be\x20empty','if\x20(!doc)\x20throw\x20new\x20Error(','presentation','CONTENT_EXECUTION_UNIT_TYPE_UNSUPPORTED','string','stringify','join','const\x20base\x20=\x20api.getBase(','const\x20presentation\x20=\x20api.getPresentation(','ContentExecutionError','slide','const\x20api\x20=\x20univerAPI;','univerAPI','17389ChbYkl','board','sheet','const\x20','CONTENT_EXECUTION_INVALID_INPUT','Unexpected\x20content\x20execution\x20Unit\x20type:\x20','some','if\x20(!base)\x20throw\x20new\x20Error(','32613kElSFK','const\x20board\x20=\x20api.getBoard(','Content\x20execution\x20does\x20not\x20support\x20Unit\x20type\x20','390DFzwqA','if\x20(!board)\x20throw\x20new\x20Error(','9qFHsxr','details','Cannot\x20find\x20board\x20','Cannot\x20find\x20doc\x20','code','\x0a})();','30292FmSiaQ','const\x20doc\x20=\x20api.getDocument(','base','1788080IGlhzR'];_0x27fe=function(){return _0x2a66d2;};return _0x27fe();}const _0xe2d481=_0x598c;(function(_0x2b90e9,_0x1a0c89){const _0x251989=_0x598c,_0x450fd1=_0x2b90e9();while(!![]){try{const _0x44ef40=-parseInt(_0x251989(0x1cb))/0x1*(-parseInt(_0x251989(0x1bc))/0x2)+-parseInt(_0x251989(0x1d8))/0x3*(parseInt(_0x251989(0x1de))/0x4)+-parseInt(_0x251989(0x1b0))/0x5+parseInt(_0x251989(0x1d6))/0x6*(parseInt(_0x251989(0x1d3))/0x7)+-parseInt(_0x251989(0x1af))/0x8+-parseInt(_0x251989(0x1ba))/0x9*(parseInt(_0x251989(0x1b6))/0xa)+parseInt(_0x251989(0x1b8))/0xb;if(_0x44ef40===_0x1a0c89)break;else _0x450fd1['push'](_0x450fd1['shift']());}catch(_0x235df4){_0x450fd1['push'](_0x450fd1['shift']());}}}(_0x27fe,0x29d22));var e=class extends Error{[_0xe2d481(0x1dc)];[_0xe2d481(0x1d9)];constructor(_0x19e7c9,_0x406fb7,_0x556596){const _0x5c833f=_0xe2d481;super(_0x406fb7),this[_0x5c833f(0x1dc)]=_0x19e7c9,this[_0x5c833f(0x1d9)]=_0x556596,this[_0x5c833f(0x1bd)]=_0x5c833f(0x1c7);}},t=[_0xe2d481(0x1cd),_0xe2d481(0x1b2),_0xe2d481(0x1c8),_0xe2d481(0x1ae),_0xe2d481(0x1cc)];function n(_0x41e1ed){const _0x119981=_0xe2d481;if(typeof _0x41e1ed['code']!=_0x119981(0x1c2))throw new e(_0x119981(0x1cf),'Content\x20execution\x20code\x20must\x20be\x20a\x20string');if(typeof _0x41e1ed[_0x119981(0x1bb)]!='string'||_0x41e1ed['unitId']['trim']()['length']===0x0)throw new e(_0x119981(0x1cf),_0x119981(0x1be),{'unitId':_0x41e1ed['unitId']});if(!c(_0x41e1ed[_0x119981(0x1b1)]))throw new e(_0x119981(0x1c1),_0x119981(0x1d5)+String(_0x41e1ed[_0x119981(0x1b1)]),{'supportedUnitTypes':t,'unitType':_0x41e1ed[_0x119981(0x1b1)]});let _0xe408e5=i(_0x41e1ed[_0x119981(0x1b1)]);return o(_0x41e1ed['code'],_0x41e1ed[_0x119981(0x1b1)],_0xe408e5),r(_0x41e1ed[_0x119981(0x1b1)],_0x41e1ed[_0x119981(0x1bb)])+'\x0a'+_0x41e1ed[_0x119981(0x1dc)];}function r(_0x24419e,_0x104791){const _0x3f0bcd=_0xe2d481;let _0x54fd90=JSON[_0x3f0bcd(0x1c3)](_0x104791);return _0x24419e==='sheet'?[_0x3f0bcd(0x1c9),'const\x20workbook\x20=\x20api.getWorkbook('+_0x54fd90+');',_0x3f0bcd(0x1b3)+JSON[_0x3f0bcd(0x1c3)]('Cannot\x20find\x20workbook\x20'+_0x104791)+');'][_0x3f0bcd(0x1c4)]('\x0a'):_0x24419e===_0x3f0bcd(0x1b2)?['const\x20api\x20=\x20univerAPI;',_0x3f0bcd(0x1ad)+_0x54fd90+');',_0x3f0bcd(0x1bf)+JSON[_0x3f0bcd(0x1c3)](_0x3f0bcd(0x1db)+_0x104791)+');'][_0x3f0bcd(0x1c4)]('\x0a'):_0x24419e===_0x3f0bcd(0x1c8)?[_0x3f0bcd(0x1c9),_0x3f0bcd(0x1c6)+_0x54fd90+');','if\x20(!presentation)\x20throw\x20new\x20Error('+JSON[_0x3f0bcd(0x1c3)](_0x3f0bcd(0x1b4)+_0x104791)+');'][_0x3f0bcd(0x1c4)]('\x0a'):_0x24419e===_0x3f0bcd(0x1ae)?[_0x3f0bcd(0x1c9),_0x3f0bcd(0x1c5)+_0x54fd90+');',_0x3f0bcd(0x1d2)+JSON[_0x3f0bcd(0x1c3)]('Cannot\x20find\x20base\x20'+_0x104791)+');']['join']('\x0a'):_0x24419e==='board'?['const\x20api\x20=\x20univerAPI;',_0x3f0bcd(0x1d4)+_0x54fd90+');',_0x3f0bcd(0x1d7)+JSON[_0x3f0bcd(0x1c3)](_0x3f0bcd(0x1da)+_0x104791)+');'][_0x3f0bcd(0x1c4)]('\x0a'):a(_0x24419e);}function i(_0x5bc244){const _0x19d1d5=_0xe2d481;return _0x5bc244===_0x19d1d5(0x1cd)?[_0x19d1d5(0x1ca),_0x19d1d5(0x1b7),'workbook']:_0x5bc244===_0x19d1d5(0x1b2)?['univerAPI',_0x19d1d5(0x1b7),_0x19d1d5(0x1b2)]:_0x5bc244==='slide'?[_0x19d1d5(0x1ca),_0x19d1d5(0x1b7),_0x19d1d5(0x1c0)]:_0x5bc244===_0x19d1d5(0x1ae)?[_0x19d1d5(0x1ca),_0x19d1d5(0x1b7),_0x19d1d5(0x1ae)]:_0x5bc244===_0x19d1d5(0x1cc)?[_0x19d1d5(0x1ca),_0x19d1d5(0x1b7),_0x19d1d5(0x1cc)]:a(_0x5bc244);}function a(_0x35abf2){const _0x5acbe6=_0xe2d481;throw Error(_0x5acbe6(0x1d0)+String(_0x35abf2));}function o(_0x4c1083,_0x343240,_0x5a3cf1){const _0x409fc0=_0xe2d481;if(s(_0x4c1083)){for(let _0x245735 of _0x5a3cf1)if(!s(_0x409fc0(0x1ce)+_0x245735+'\x20=\x20undefined;\x0a'+_0x4c1083))throw new e('CONTENT_EXECUTION_RESERVED_BINDING','`'+_0x245735+_0x409fc0(0x1b9)+_0x343240+_0x409fc0(0x1b5),{'binding':_0x245735,'reservedBindings':_0x5a3cf1,'unitType':_0x343240});}}function _0x598c(_0x31bcca,_0x4dc0c1){_0x31bcca=_0x31bcca-0x1ad;const _0x27fe39=_0x27fe();let _0x598c74=_0x27fe39[_0x31bcca];return _0x598c74;}function s(_0x27310f){const _0x1e35f6=_0xe2d481;try{return Function(_0x1e35f6(0x1ca),'return\x20(async\x20()\x20=>\x20{\x20'+_0x27310f+_0x1e35f6(0x1dd)),!0x0;}catch{return!0x1;}}function c(_0x2bbf68){const _0x3e03d1=_0xe2d481;return t[_0x3e03d1(0x1d1)](_0x506df3=>_0x506df3===_0x2bbf68);}export{e as ContentExecutionError,n as prepareContentExecutionProgram};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@univer-cli/content-execution",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.2",
4
+ "version": "1.0.0",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",