@univer-cli/svg-facade-command 1.0.0-beta.2
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 +33 -0
- package/README.zh-CN.md +37 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +1 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @univer-cli/svg-facade-command
|
|
2
|
+
|
|
3
|
+
English | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Provide a native Commander `compile-svg` preset for `@univer-cli/svg-facade`. It reads SVG and local references, writes Facade JavaScript or JSON, and sends diagnostics to the appropriate terminal stream.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add commander @univer-cli/svg-facade @univer-cli/svg-facade-command
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Add to application
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createCompileSvgCommand } from "@univer-cli/svg-facade-command";
|
|
17
|
+
import { Command } from "commander";
|
|
18
|
+
|
|
19
|
+
const program = new Command("my-cli");
|
|
20
|
+
program.addCommand(createCompileSvgCommand({ textMeasurer }));
|
|
21
|
+
await program.parseAsync();
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Command list
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
compile-svg <file.svg> [--json] [--estimate-text-size]
|
|
28
|
+
[--page <number> [--add] [--out <path>]]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
By default, JavaScript is written to stdout. When `--page` is specified, `--out` can write the result to a file. `--add` overlays content instead of clearing the page. `--json` returns code, viewport details, and diagnostics. Warnings and authoring lints go to stderr without polluting code output. Commander exits non-zero for input, asset, or compilation failures.
|
|
32
|
+
|
|
33
|
+
The package is responsible for file input, CLI presentation, and failure behavior. SVG semantics, compilation, and diagnostics belong to the capability. The factory returns a native `Command`.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @univer-cli/svg-facade-command
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
为 `@univer-cli/svg-facade` 提供原生 Commander `compile-svg` preset:读取 SVG 与本地引用,写出 Facade
|
|
6
|
+
JavaScript 或 JSON,并把 diagnostics 发送到正确的终端 stream。
|
|
7
|
+
|
|
8
|
+
## 安装
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add commander @univer-cli/svg-facade @univer-cli/svg-facade-command
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 添加到应用
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { createCompileSvgCommand } from "@univer-cli/svg-facade-command";
|
|
18
|
+
import { Command } from "commander";
|
|
19
|
+
|
|
20
|
+
const program = new Command("my-cli");
|
|
21
|
+
program.addCommand(createCompileSvgCommand({ textMeasurer }));
|
|
22
|
+
await program.parseAsync();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 命令一览
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
compile-svg <file.svg> [--json] [--estimate-text-size]
|
|
29
|
+
[--page <number> [--add] [--out <path>]]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
默认把 JavaScript 写到 stdout;指定 `--page` 后可用 `--out` 写文件,`--add` 表示叠加而不是清空页面。
|
|
33
|
+
`--json` 返回 code、viewport 与 diagnostics。Warnings 和
|
|
34
|
+
authoring lints 写 stderr,不污染 code output。输入、asset 或编译失败由 Commander 以失败退出处理。
|
|
35
|
+
|
|
36
|
+
Package 负责文件输入、CLI presentation 和 failure behavior;SVG 语义、编译与 diagnostics 属于 capability。
|
|
37
|
+
Factory 返回原生 `Command`。
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';module['exports']=require('./index.mjs');
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SvgTextMeasurer } from "@univer-cli/svg-facade";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface CompileSvgCommandDependencies {
|
|
5
|
+
readonly textMeasurer: SvgTextMeasurer;
|
|
6
|
+
}
|
|
7
|
+
declare function createCompileSvgCommand(dependencies: CompileSvgCommandDependencies): Command;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { CompileSvgCommandDependencies, createCompileSvgCommand };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _0x2a989d=_0x9a29;(function(_0x27ac20,_0x47264f){const _0x3ae3ff=_0x9a29,_0x2ff624=_0x27ac20();while(!![]){try{const _0x3b72d2=parseInt(_0x3ae3ff(0x17a))/0x1+parseInt(_0x3ae3ff(0x166))/0x2*(-parseInt(_0x3ae3ff(0x17d))/0x3)+parseInt(_0x3ae3ff(0x17f))/0x4+parseInt(_0x3ae3ff(0x18f))/0x5+-parseInt(_0x3ae3ff(0x178))/0x6+-parseInt(_0x3ae3ff(0x185))/0x7+-parseInt(_0x3ae3ff(0x17b))/0x8*(parseInt(_0x3ae3ff(0x16c))/0x9);if(_0x3b72d2===_0x47264f)break;else _0x2ff624['push'](_0x2ff624['shift']());}catch(_0x2aaec8){_0x2ff624['push'](_0x2ff624['shift']());}}}(_0x158c,0xebf2f));import{readFileSync as _0x7f8231,writeFileSync as _0xdea773}from'node:fs';import{dirname as _0x1a173f,resolve as _0xfeb99e}from'node:path';import{builtinTextMeasurer as _0x8df369,compileSvgToFacade as _0x2bb873,isSvgFacadeError as _0x5ca9a2,wrapSlideScript as _0x31cb4a}from'@univer-cli/svg-facade';import{Command as _0x3d6fae,InvalidArgumentError as _0x5c3cab}from'commander';var u=_0x2a989d(0x184);function _0x158c(){const _0x2264c3=['stringify','--estimate-text-size','length','--json','lints','warning:\x20','description','Expected\x20an\x20integer\x20>=\x201;\x20received\x20\x22','replace','4885175EdabIN','writeErr','Compile\x20SVG\x20into\x20Univer\x20Slide\x20Facade\x20code','message','SVG\x20source\x20file','--out\x20<path>','utf8','lint:\x20','12wXpOvj','textMeasurer','isInteger','add','overlay\x20onto\x20the\x20target\x20page\x20instead\x20of\x20clearing\x20it\x20first','argument','163089mRRCFj','warning\x20=\x20unsupported\x20SVG\x20feature\x20degraded;\x20lint\x20=\x20review\x20suggestion,\x20nothing\x20was\x20dropped\x0a','--add\x20and\x20--out\x20require\x20--page\x20<number>.','code','wrap\x20the\x20result\x20for\x20a\x201-based\x20target\x20Slide\x20page','option','<file.svg>','use\x20deterministic\x20text-size\x20estimation\x20instead\x20of\x20the\x20injected\x20measurer','estimateTextSize','write\x20generated\x20code\x20to\x20a\x20file','configureOutput','compile-svg','4267146eBecDB','json','739539VONYbI','152Xbyhfq','action','63162zGgGDc','out','5001584NTtAgY','writeOut','error','page','--page\x20<number>','text\x20boxes\x20were\x20sized\x20by\x20estimation\x20(--estimate-text-size),\x20not\x20by\x20real\x20font\x20metrics:\x20text\x20can\x20sit\x20off-position,\x20especially\x20centred\x20or\x20right-aligned\x20lines;\x20recompile\x20without\x20the\x20flag\x20(with\x20a\x20browser)\x20before\x20you\x20ship','5730963WhxSwm'];_0x158c=function(){return _0x2264c3;};return _0x158c();}function d(_0x33b06c){const _0xc3f8ac=_0x2a989d;let _0x50ee54=new _0x3d6fae(_0xc3f8ac(0x177))[_0xc3f8ac(0x18c)](_0xc3f8ac(0x191))[_0xc3f8ac(0x16b)](_0xc3f8ac(0x172),_0xc3f8ac(0x193))['option'](_0xc3f8ac(0x189),'write\x20structured\x20JSON')[_0xc3f8ac(0x171)](_0xc3f8ac(0x187),_0xc3f8ac(0x173))[_0xc3f8ac(0x171)](_0xc3f8ac(0x183),_0xc3f8ac(0x170),f)[_0xc3f8ac(0x171)]('--add',_0xc3f8ac(0x16a))[_0xc3f8ac(0x171)](_0xc3f8ac(0x194),_0xc3f8ac(0x175))[_0xc3f8ac(0x17c)](async(_0x12f206,_0x2123d2)=>{const _0x567348=_0xc3f8ac;p(_0x50ee54,_0x2123d2);try{let _0x45142f=_0x7f8231(_0x12f206,_0x567348(0x164)),_0x56d507=_0x2123d2[_0x567348(0x174)]===!0x0,_0x36a1b5=await _0x2bb873(_0x45142f,{'assetResolver':_0x373a04=>({'bytes':_0x7f8231(_0xfeb99e(_0x1a173f(_0x12f206),_0x373a04))}),'textMeasurer':_0x56d507?_0x8df369:_0x33b06c[_0x567348(0x167)]}),_0x206e8e=_0x56d507?[..._0x36a1b5[_0x567348(0x18a)],u]:_0x36a1b5['lints'],_0x51c308=_0x2123d2[_0x567348(0x169)]===!0x0?_0x567348(0x169):_0x567348(0x18e),_0x4b529d=_0x2123d2[_0x567348(0x182)]===void 0x0?_0x36a1b5[_0x567348(0x16f)]:_0x31cb4a(_0x36a1b5[_0x567348(0x16f)],{'page':_0x2123d2['page'],'mode':_0x51c308,..._0x36a1b5['viewport']});if(_0x2123d2[_0x567348(0x17e)]!==void 0x0&&_0xdea773(_0x2123d2[_0x567348(0x17e)],_0x4b529d+'\x0a',_0x567348(0x164)),_0x2123d2[_0x567348(0x179)]===!0x0){h(_0x50ee54,{'code':_0x4b529d,'lints':_0x206e8e,'textMeasure':_0x36a1b5['textMeasure'],'viewport':_0x36a1b5['viewport'],'warnings':_0x36a1b5['warnings'],..._0x2123d2[_0x567348(0x182)]===void 0x0?{}:{'mode':_0x51c308,'page':_0x2123d2[_0x567348(0x182)]},..._0x2123d2[_0x567348(0x17e)]===void 0x0?{}:{'out':_0x2123d2[_0x567348(0x17e)]}});return;}m(_0x50ee54,_0x36a1b5['warnings'],_0x206e8e),_0x2123d2['out']===void 0x0?g(_0x50ee54,_0x4b529d):g(_0x50ee54,'generated\x20code:\x20'+_0x2123d2[_0x567348(0x17e)]);}catch(_0x20fa26){throw _0x5ca9a2(_0x20fa26)&&_0x50ee54['error'](_0x20fa26['code']+':\x20'+_0x20fa26[_0x567348(0x192)],{'code':'compile-svg.failed','exitCode':0x1}),_0x20fa26 instanceof Error&&_0x50ee54[_0x567348(0x181)](_0x20fa26[_0x567348(0x192)],{'code':'compile-svg.failed','exitCode':0x1}),_0x20fa26;}});return _0x50ee54;}function f(_0x5dbeb6){const _0x2b6b9b=_0x2a989d;let _0x410761=Number(_0x5dbeb6);if(!Number[_0x2b6b9b(0x168)](_0x410761)||_0x410761<0x1)throw new _0x5c3cab(_0x2b6b9b(0x18d)+_0x5dbeb6+'\x22.');return _0x410761;}function p(_0x4b3983,_0x2bdac2){const _0x22a380=_0x2a989d;_0x2bdac2[_0x22a380(0x182)]===void 0x0&&(_0x2bdac2[_0x22a380(0x169)]===!0x0||_0x2bdac2['out']!==void 0x0)&&_0x4b3983[_0x22a380(0x181)](_0x22a380(0x16e),{'code':'compile-svg.invalid-input','exitCode':0x1});}function m(_0x4af713,_0x552351,_0x1031e8){const _0x4fc773=_0x2a989d;let _0x1e5392=_0x4af713[_0x4fc773(0x176)]();for(let _0x4a70eb of _0x552351)_0x1e5392[_0x4fc773(0x190)]?.(_0x4fc773(0x18b)+_0x4a70eb+'\x0a');for(let _0x21760b of _0x1031e8)_0x1e5392[_0x4fc773(0x190)]?.(_0x4fc773(0x165)+_0x21760b+'\x0a');(_0x552351[_0x4fc773(0x188)]>0x0||_0x1031e8[_0x4fc773(0x188)]>0x0)&&_0x1e5392[_0x4fc773(0x190)]?.(_0x4fc773(0x16d));}function _0x9a29(_0x5eed39,_0x1b5065){_0x5eed39=_0x5eed39-0x164;const _0x158c3c=_0x158c();let _0x9a298e=_0x158c3c[_0x5eed39];return _0x9a298e;}function h(_0x524cb,_0x3aa3b3){const _0x162ecd=_0x2a989d;_0x524cb[_0x162ecd(0x176)]()['writeOut']?.(JSON[_0x162ecd(0x186)](_0x3aa3b3,null,0x2)+'\x0a');}function g(_0x58c68e,_0x40036c){const _0x4c4bd2=_0x2a989d;_0x58c68e[_0x4c4bd2(0x176)]()[_0x4c4bd2(0x180)]?.(_0x40036c+'\x0a');}export{d as createCompileSvgCommand};
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@univer-cli/svg-facade-command",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.0-beta.2",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"README.zh-CN.md"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@univer-cli/svg-facade": "1.0.0-beta.2"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"commander": "^15.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|