@univer-cli/resource-library 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 +61 -0
- package/README.zh-CN.md +64 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +149 -0
- package/dist/index.mjs +1 -0
- package/package.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @univer-cli/resource-library
|
|
2
|
+
|
|
3
|
+
English | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Provides a searchable catalog of visual assets for CLI, Agents, and content generation tools, and unified handling of SVG reading, download caching, and batch export.
|
|
6
|
+
|
|
7
|
+
Each resource has a stable `<registryId>/<resourceId>` handle. Callers depend only on the handle and structured metadata, without needing to understand the internal manifest, search index, or cache formats.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @univer-cli/resource-library
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires Node.js 22.12 or higher.
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import {
|
|
21
|
+
createResourceLibrary,
|
|
22
|
+
type ResourceCache,
|
|
23
|
+
type ResourceDownloader,
|
|
24
|
+
type ResourceOutput,
|
|
25
|
+
} from "@univer-cli/resource-library";
|
|
26
|
+
|
|
27
|
+
const library = createResourceLibrary({ manifest, cache, downloader, output });
|
|
28
|
+
const found = library.find({
|
|
29
|
+
queries: ["rocket", "startup"],
|
|
30
|
+
registries: ["icons"],
|
|
31
|
+
limit: 20,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const first = found.resources.at(0);
|
|
35
|
+
if (first !== undefined) {
|
|
36
|
+
const resource = await library.read({ handle: first.handle });
|
|
37
|
+
console.log(resource.svg);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Core operations
|
|
42
|
+
|
|
43
|
+
- `listRegistries()`: Lists available registries.
|
|
44
|
+
- `find()`: Searches by keyword and registry and returns stable handles and summaries.
|
|
45
|
+
- `read()`: Read a resource; remote content is downloaded and cached according to the adapter policy.
|
|
46
|
+
- `export()`: Writes resources to the caller-provided output and returns a structured list.
|
|
47
|
+
|
|
48
|
+
The manifest is validated when the library is constructed. Duplicate handles, invalid IDs, unsupported media types, and unsafe paths fail before any download or export.
|
|
49
|
+
|
|
50
|
+
## Node.js adapter
|
|
51
|
+
|
|
52
|
+
The package provides a filesystem cache, HTTPS downloader, filesystem output, and manifest loader. Applications can also implement `ResourceCache`, `ResourceDownloader`, and `ResourceOutput` to connect object storage, databases, or in-memory test adapters.
|
|
53
|
+
|
|
54
|
+
## Security and boundaries
|
|
55
|
+
|
|
56
|
+
Registry IDs, resource IDs, cache roots, and output paths are all validated for safety. The downloader reads only content declared in the manifest; the application determines authentication headers, network access policies, and the list of trusted registries.
|
|
57
|
+
|
|
58
|
+
Here, a resource means a visual asset—not a Workspace Resource product object or a plugin resource stored in a Unit snapshot.
|
|
59
|
+
|
|
60
|
+
For the preset command, see
|
|
61
|
+
[`@univer-cli/resource-library-command`](../resource-library-command/README.md).
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @univer-cli/resource-library
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
为 CLI、Agent 和内容生成工具提供可搜索的视觉资源目录,并统一处理 SVG 读取、下载缓存和批量导出。
|
|
6
|
+
|
|
7
|
+
每个资源使用稳定的 `<registryId>/<resourceId>` handle。调用方只依赖 handle 与结构化 metadata,不需要了解
|
|
8
|
+
manifest、搜索索引或 cache 的内部格式。
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pnpm add @univer-cli/resource-library
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
要求 Node.js 22.12 或更高版本。
|
|
17
|
+
|
|
18
|
+
## 快速开始
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import {
|
|
22
|
+
createResourceLibrary,
|
|
23
|
+
type ResourceCache,
|
|
24
|
+
type ResourceDownloader,
|
|
25
|
+
type ResourceOutput,
|
|
26
|
+
} from "@univer-cli/resource-library";
|
|
27
|
+
|
|
28
|
+
const library = createResourceLibrary({ manifest, cache, downloader, output });
|
|
29
|
+
const found = library.find({
|
|
30
|
+
queries: ["rocket", "startup"],
|
|
31
|
+
registries: ["icons"],
|
|
32
|
+
limit: 20,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const first = found.resources.at(0);
|
|
36
|
+
if (first !== undefined) {
|
|
37
|
+
const resource = await library.read({ handle: first.handle });
|
|
38
|
+
console.log(resource.svg);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 核心操作
|
|
43
|
+
|
|
44
|
+
- `listRegistries()`:查看可用 registry。
|
|
45
|
+
- `find()`:按关键词和 registry 搜索,返回稳定 handle 与摘要。
|
|
46
|
+
- `read()`:读取一个资源;远端内容按 adapter 策略下载并缓存。
|
|
47
|
+
- `export()`:把一组资源写入调用方提供的 output,并返回结构化清单。
|
|
48
|
+
|
|
49
|
+
Manifest 在构造 library 时校验。重复 handle、非法 ID、不支持的 media type 和不安全路径会在进入下载或输出前失败。
|
|
50
|
+
|
|
51
|
+
## Node.js 适配器
|
|
52
|
+
|
|
53
|
+
Package 提供 filesystem cache、HTTPS downloader、filesystem output 和 manifest loader。Application 也可以实现
|
|
54
|
+
`ResourceCache`、`ResourceDownloader` 与 `ResourceOutput`,接入对象存储、数据库或测试内存 adapter。
|
|
55
|
+
|
|
56
|
+
## 安全与边界
|
|
57
|
+
|
|
58
|
+
Registry ID、resource ID、cache root 和输出路径都会做安全校验。Downloader 只负责读取 manifest 声明的内容;
|
|
59
|
+
认证 header、网络访问策略与可信 registry 列表由 application 决定。
|
|
60
|
+
|
|
61
|
+
这里的 resource 是视觉素材,不是 Workspace Resource 产品对象,也不是 Unit snapshot 中的 plugin resource。
|
|
62
|
+
|
|
63
|
+
预设 command 见
|
|
64
|
+
[`@univer-cli/resource-library-command`](../resource-library-command/README.zh-CN.md)。
|
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,149 @@
|
|
|
1
|
+
//#region src/errors.d.ts
|
|
2
|
+
type ResourceLibraryErrorCode = "resource-cache-root-invalid" | "resource-download-failed" | "resource-download-http" | "resource-download-insecure" | "resource-download-insecure-redirect" | "resource-download-invalid-redirect" | "resource-download-invalid-svg" | "resource-download-invalid-utf8" | "resource-download-timeout" | "resource-download-too-large" | "resource-download-too-many-redirects" | "resource-export-failed" | "resource-export-filename-too-long" | "resource-invalid-handle" | "resource-invalid-registry-id" | "resource-invalid-resource-id" | "resource-invalid-svg" | "resource-limit-invalid" | "resource-manifest-invalid" | "resource-manifest-read-failed" | "resource-not-found" | "resource-query-empty" | "resource-registry-not-found";
|
|
3
|
+
declare class ResourceLibraryError extends Error {
|
|
4
|
+
readonly code: ResourceLibraryErrorCode;
|
|
5
|
+
readonly handle?: string | undefined;
|
|
6
|
+
constructor(code: ResourceLibraryErrorCode, message: string, handle?: string | undefined, options?: ErrorOptions);
|
|
7
|
+
}
|
|
8
|
+
declare function isResourceLibraryError(error: unknown): error is ResourceLibraryError;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/types.d.ts
|
|
11
|
+
interface ResourceTextValue {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly label: string;
|
|
14
|
+
}
|
|
15
|
+
interface ResourceIntrinsicSize {
|
|
16
|
+
readonly width: number;
|
|
17
|
+
readonly height: number;
|
|
18
|
+
}
|
|
19
|
+
interface ResourceSummary {
|
|
20
|
+
readonly handle: string;
|
|
21
|
+
readonly registryId: string;
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly group: ResourceTextValue | null;
|
|
25
|
+
readonly tags: readonly ResourceTextValue[];
|
|
26
|
+
readonly keywords: readonly string[];
|
|
27
|
+
readonly order: number | null;
|
|
28
|
+
readonly intrinsicSize: ResourceIntrinsicSize;
|
|
29
|
+
readonly colorEditable: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface ResourceRegistrySummary {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly resourceCount: number;
|
|
34
|
+
readonly groupCount: number;
|
|
35
|
+
readonly tagCount: number;
|
|
36
|
+
readonly colorEditableCount: number;
|
|
37
|
+
}
|
|
38
|
+
interface FindResourcesInput {
|
|
39
|
+
readonly queries: readonly string[];
|
|
40
|
+
readonly registries?: readonly string[];
|
|
41
|
+
readonly limit?: number;
|
|
42
|
+
}
|
|
43
|
+
interface ResourceFindResult {
|
|
44
|
+
readonly resources: readonly ResourceSummary[];
|
|
45
|
+
readonly total: number;
|
|
46
|
+
}
|
|
47
|
+
interface ReadResourceInput {
|
|
48
|
+
readonly handle: string;
|
|
49
|
+
}
|
|
50
|
+
interface ReadResourceResult {
|
|
51
|
+
readonly handle: string;
|
|
52
|
+
readonly svg: string;
|
|
53
|
+
}
|
|
54
|
+
interface ExportResourcesInput {
|
|
55
|
+
readonly handles: readonly string[];
|
|
56
|
+
readonly destination: string;
|
|
57
|
+
}
|
|
58
|
+
interface ResourceExportSuccess {
|
|
59
|
+
readonly handle: string;
|
|
60
|
+
readonly path: string;
|
|
61
|
+
}
|
|
62
|
+
interface ResourceExportFailure {
|
|
63
|
+
readonly handle: string;
|
|
64
|
+
readonly code: string;
|
|
65
|
+
readonly message: string;
|
|
66
|
+
}
|
|
67
|
+
interface ResourceExportResult {
|
|
68
|
+
readonly exported: readonly ResourceExportSuccess[];
|
|
69
|
+
readonly failed: readonly ResourceExportFailure[];
|
|
70
|
+
}
|
|
71
|
+
interface ResourceCacheClearResult {
|
|
72
|
+
readonly path: string;
|
|
73
|
+
readonly resourceCount: number;
|
|
74
|
+
readonly byteCount: number;
|
|
75
|
+
}
|
|
76
|
+
interface ResourceDownloader {
|
|
77
|
+
download(url: string): Promise<string>;
|
|
78
|
+
}
|
|
79
|
+
interface ResourceCache {
|
|
80
|
+
readonly location: string;
|
|
81
|
+
read(handle: string): Promise<string | undefined>;
|
|
82
|
+
write(handle: string, svg: string): Promise<void>;
|
|
83
|
+
clear(): Promise<ResourceCacheClearResult>;
|
|
84
|
+
}
|
|
85
|
+
interface ResourceOutput {
|
|
86
|
+
write(destination: string, filename: string, svg: string): Promise<string>;
|
|
87
|
+
}
|
|
88
|
+
interface ResourceLibrary {
|
|
89
|
+
readonly cacheLocation: string;
|
|
90
|
+
listRegistries(): readonly ResourceRegistrySummary[];
|
|
91
|
+
find(input: FindResourcesInput): ResourceFindResult;
|
|
92
|
+
read(input: ReadResourceInput): Promise<ReadResourceResult>;
|
|
93
|
+
export(input: ExportResourcesInput): Promise<ResourceExportResult>;
|
|
94
|
+
clearCache(): Promise<ResourceCacheClearResult>;
|
|
95
|
+
}
|
|
96
|
+
interface CreateResourceLibraryOptions {
|
|
97
|
+
readonly manifest: unknown;
|
|
98
|
+
readonly cache: ResourceCache;
|
|
99
|
+
readonly downloader: ResourceDownloader;
|
|
100
|
+
readonly output: ResourceOutput;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/resource-library.d.ts
|
|
104
|
+
declare function createResourceLibrary(options: CreateResourceLibraryOptions): ResourceLibrary;
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/node/https-downloader.d.ts
|
|
107
|
+
interface HttpsResourceDownloaderOptions {
|
|
108
|
+
readonly fetch?: typeof fetch;
|
|
109
|
+
readonly timeoutMs?: number;
|
|
110
|
+
readonly maxBytes?: number;
|
|
111
|
+
readonly maxRedirects?: number;
|
|
112
|
+
}
|
|
113
|
+
declare class HttpsResourceDownloader implements ResourceDownloader {
|
|
114
|
+
private readonly fetchImpl;
|
|
115
|
+
private readonly timeoutMs;
|
|
116
|
+
private readonly maxBytes;
|
|
117
|
+
private readonly maxRedirects;
|
|
118
|
+
constructor(options?: HttpsResourceDownloaderOptions);
|
|
119
|
+
download(value: string): Promise<string>;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/node/filesystem-cache.d.ts
|
|
123
|
+
declare function validateResourceCacheRoot(value: string): string;
|
|
124
|
+
declare class FilesystemResourceCache implements ResourceCache {
|
|
125
|
+
readonly location: string;
|
|
126
|
+
constructor(root: string);
|
|
127
|
+
private path;
|
|
128
|
+
read(handle: string): Promise<string | undefined>;
|
|
129
|
+
write(handle: string, svg: string): Promise<void>;
|
|
130
|
+
clear(): Promise<ResourceCacheClearResult>;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/node/filesystem-output.d.ts
|
|
134
|
+
declare class FilesystemResourceOutput implements ResourceOutput {
|
|
135
|
+
write(destination: string, filename: string, svg: string): Promise<string>;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/node/manifest.d.ts
|
|
139
|
+
declare function loadResourceManifestFromPath(path: string): unknown;
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/node.d.ts
|
|
142
|
+
interface CreateNodeResourceLibraryFactoryOptions {
|
|
143
|
+
readonly manifestPath: string;
|
|
144
|
+
readonly cacheRoot: string;
|
|
145
|
+
readonly downloader?: HttpsResourceDownloaderOptions;
|
|
146
|
+
}
|
|
147
|
+
declare function createNodeResourceLibraryFactory(options: CreateNodeResourceLibraryFactoryOptions): () => ResourceLibrary;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { type CreateNodeResourceLibraryFactoryOptions, type CreateResourceLibraryOptions, type ExportResourcesInput, FilesystemResourceCache, FilesystemResourceOutput, type FindResourcesInput, HttpsResourceDownloader, type HttpsResourceDownloaderOptions, type ReadResourceInput, type ReadResourceResult, type ResourceCache, type ResourceCacheClearResult, type ResourceDownloader, type ResourceExportFailure, type ResourceExportResult, type ResourceExportSuccess, type ResourceFindResult, type ResourceIntrinsicSize, type ResourceLibrary, ResourceLibraryError, type ResourceLibraryErrorCode, type ResourceOutput, type ResourceRegistrySummary, type ResourceSummary, type ResourceTextValue, createNodeResourceLibraryFactory, createResourceLibrary, isResourceLibraryError, loadResourceManifestFromPath, validateResourceCacheRoot };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function _0x17f1(){const _0x27845=['\x20must\x20be\x20a\x20non-empty\x20string.','includes','\x20must\x20be\x20a\x20boolean.','isArray','limit','colorEditable','].id','\x20ms.','213924WtSmjM','].label','resources','isInteger','registryId','Invalid\x20resource\x20ID\x20\x22','.svg','.name','get','resource-manifest-read-failed','].input','root','724100eeajHG','message','Resource\x20cache\x20root\x20must\x20be\x20an\x20absolute,\x20dedicated\x20directory\x20below\x20the\x20filesystem\x20root;\x20received\x20\x22','resource-download-invalid-redirect','output','ENOENT','Resource\x20export\x20filename\x20exceeds\x20','resource-not-found','1403036LidpzP','Downloaded\x20resource\x20\x22','.resource-','reference','download','keywords','resource-registry-not-found','order','headers','location','.intrinsicSize.height','.tmp',']\x20must\x20be\x20a\x20string.','Failed\x20to\x20download\x20\x22','registry','join','.order','push','.storagePolicy\x20must\x20be\x20\x22reference\x22.','set','globalIndex','1282666PjqtPj','Duplicate\x20resource\x20handle\x20\x22','groups','intrinsicSize','\x20without\x20a\x20Location\x20header.','cacheRoot','tags','resource-invalid-handle','manual','maxBytes','NFKC','split','.keywords','storagePolicy','.description','filter','read','Duplicate\x20','Resource\x20search\x20limit\x20must\x20be\x20a\x20positive\x20integer;\x20received\x20\x22','maxRedirects','protocol','downloader','.intrinsicSize.width','test','sourceUrl','string','10643056YumWdT','resource-download-invalid-svg','registrations','concat','signal','cancel','\x20must\x20be\x20an\x20object.','add','Resource\x20exceeds\x20the\x20maximum\x20size\x20of\x20','timeoutMs','Unknown\x20resource\x20registry\x20\x22','registrationIndex','].input.groups','https:','slice','label','isFile','localeCompare','resourceIndex','Resource\x20request\x20redirected\x20to\x20a\x20non-HTTPS\x20URL.','some','boolean','resource-query-empty','\x20ID\x20\x22','height','parse','values','isDirectory','Resource\x20download\x20timed\x20out\x20after\x20','aborted','Unknown\x20resource\x20\x22','code','clear','write','content-length','.source.type\x20must\x20be\x20\x22url\x22.','resource-invalid-svg','Invalid\x20registry\x20ID\x20\x22','defaultLocale','.groupId','type','.payload.colorEditable','.tagIds\x20references\x20unknown\x20tag\x20\x22','].input.defaultLocale','Duplicate\x20export\x20filename\x20\x22','ResourceLibraryError','byteCount','resource-download-too-many-redirects','length','Resource\x20server\x20returned\x20an\x20invalid\x20redirect\x20URL.','.id','742tLJBTQ','fetchImpl','toLowerCase','groupId','resource-download-too-large','.source','Cannot\x20read\x20resource\x20manifest\x20at\x20','url','utf8','isFinite','image','searchText','source','registrations\x20must\x20not\x20be\x20empty.','registrations[','Resource\x20response\x20is\x20not\x20valid\x20UTF-8.','group','number','entries','releaseLock','pid','catalog','map','resource-download-insecure-redirect','].input.registryId','options','resource-download-failed','queries','decode','manifest.registrations','catch','status','Invalid\x20resource\x20handle\x20\x22','path','resource-download-http','name','\x20bytes.','].input.resources','453jgnEsN','registries','Resource\x20server\x20returned\x20HTTP\x20','Invalid\x20resource\x20manifest:\x20','resource-invalid-resource-id','resource-export-filename-too-long','manifest','Resource\x20request\x20followed\x20too\x20many\x20redirects;\x20maximum\x20','Duplicate\x20registry\x20ID\x20\x22','done','byteLength','handle','.tagIds','cache','sort','.source.value\x20must\x20use\x20HTTPS.','.payload','has','destination','2616372DKypiW','size','\x22\x20is\x20not\x20an\x20SVG\x20document.','object','width','resource-invalid-registry-id','description','value','endsWith','resource','resource-download-insecure'];_0x17f1=function(){return _0x27845;};return _0x17f1();}const _0x122181=_0xdc40;(function(_0x3802ae,_0x3f3448){const _0x3d5fb7=_0xdc40,_0x381b6f=_0x3802ae();while(!![]){try{const _0x3bedab=-parseInt(_0x3d5fb7(0x1bf))/0x1+-parseInt(_0x3d5fb7(0x235))/0x2*(parseInt(_0x3d5fb7(0x199))/0x3)+-parseInt(_0x3d5fb7(0x1d3))/0x4+parseInt(_0x3d5fb7(0x1cb))/0x5+-parseInt(_0x3d5fb7(0x1ac))/0x6+-parseInt(_0x3d5fb7(0x1e8))/0x7+parseInt(_0x3d5fb7(0x202))/0x8;if(_0x3bedab===_0x3f3448)break;else _0x381b6f['push'](_0x381b6f['shift']());}catch(_0x2be24b){_0x381b6f['push'](_0x381b6f['shift']());}}}(_0x17f1,0x396be));import{randomUUID as _0x1c8bca}from'node:crypto';import{mkdir as _0x39a1a4,readFile as _0x3da128,readdir as _0x135f30,rename as _0x2e1d93,rm as _0x16f7b4,stat as _0x20e29a,unlink as _0x22e0b2,writeFile as _0x5f3f74}from'node:fs/promises';import{dirname as _0x5d4545,isAbsolute as _0x2d5484,join as _0x55ac48,parse as _0x569a81,resolve as _0x2c9d4a}from'node:path';import{readFileSync as _0x4310a8}from'node:fs';var h=class extends Error{[_0x122181(0x221)];[_0x122181(0x1a4)];constructor(_0x5e5cad,_0x1829d7,_0x2bcfc0,_0x445aca){const _0x55e5d2=_0x122181;super(_0x1829d7,_0x445aca),this['code']=_0x5e5cad,this[_0x55e5d2(0x1a4)]=_0x2bcfc0,this[_0x55e5d2(0x196)]=_0x55e5d2(0x22f);}};function g(_0xff85ec){return _0xff85ec instanceof h;}var _=/^[A-Za-z0-9._-]+$/u,v=0xff,y=0x4;function b(_0x5b3f79){return _['test'](_0x5b3f79)&&_0x5b3f79!=='.'&&_0x5b3f79!=='..';}function x(_0x3d9260){const _0x565df7=_0x122181;if(!b(_0x3d9260)||_0x3d9260['startsWith']('-')||_0x3d9260[_0x565df7(0x1b8)]('--')||_0x3d9260[_0x565df7(0x232)]>v)throw new h(_0x565df7(0x1b1),_0x565df7(0x227)+_0x3d9260+'\x22:\x20expected\x20an\x20addressable\x20filesystem-safe\x20component\x20without\x20\x22--\x22.');}function S(_0xc0c9bc){const _0x2978d1=_0x122181;if(!b(_0xc0c9bc)||_0xc0c9bc['length']+y>v)throw new h(_0x2978d1(0x19d),_0x2978d1(0x1c4)+_0xc0c9bc+'\x22:\x20expected\x20filesystem-safe\x20characters.');}function C(_0x449baa){const _0x35fb34=_0x122181;let _0x547fa9=_0x449baa[_0x35fb34(0x1f3)]('/');if(_0x547fa9[_0x35fb34(0x232)]!==0x2||_0x547fa9[0x0]===''||_0x547fa9[0x1]==='')throw new h(_0x35fb34(0x1ef),_0x35fb34(0x193)+_0x449baa+'\x22;\x20expected\x20<registryId>/<resourceId>.',_0x449baa);let _0x105c52=_0x547fa9[0x0],_0x401a36=_0x547fa9[0x1];return x(_0x105c52),S(_0x401a36),{'registryId':_0x105c52,'resourceId':_0x401a36};}function ee(_0xdf9125,_0x6f55a1){return x(_0xdf9125),S(_0x6f55a1),_0xdf9125+'/'+_0x6f55a1;}function w(_0x32832f){const _0x51f58f=_0x122181;let {registryId:_0x3ad601,resourceId:_0x5a3b74}=C(_0x32832f),_0x52998b=_0x3ad601+'--'+_0x5a3b74+'.svg';if(_0x52998b[_0x51f58f(0x232)]>v)throw new h(_0x51f58f(0x19e),_0x51f58f(0x1d1)+v+_0x51f58f(0x197),_0x32832f);return _0x52998b;}function T(_0x55b916){const _0x5c4101=_0x122181;return new h('resource-manifest-invalid',_0x5c4101(0x19c)+_0x55b916);}function E(_0x64d269,_0x36095c){const _0xb29428=_0x122181;if(typeof _0x64d269!=_0xb29428(0x1af)||!_0x64d269||Array[_0xb29428(0x1ba)](_0x64d269))throw T(_0x36095c+_0xb29428(0x208));return _0x64d269;}function D(_0xad8440,_0x2e384c,_0x28cba7=!0x1){const _0x2f2ff9=_0x122181;if(_0x28cba7&&_0xad8440===void 0x0)return[];if(!Array[_0x2f2ff9(0x1ba)](_0xad8440))throw T(_0x2e384c+'\x20must\x20be\x20an\x20array.');return _0xad8440;}function O(_0x557765,_0x580864){const _0x4ca156=_0x122181;if(typeof _0x557765!=_0x4ca156(0x201)||_0x557765==='')throw T(_0x580864+_0x4ca156(0x1b7));return _0x557765;}function k(_0x2a86a2,_0x347456,_0x1a19a1=!0x1){const _0x1b9c0c=_0x122181;return D(_0x2a86a2,_0x347456,_0x1a19a1)[_0x1b9c0c(0x189)]((_0x488a8f,_0x1e668d)=>O(_0x488a8f,_0x347456+'['+_0x1e668d+']'));}function A(_0x16a583,_0x156518){const _0x127920=_0x122181;return D(_0x16a583,_0x156518,!0x0)[_0x127920(0x189)]((_0x108957,_0x29d3ac)=>{const _0x26784e=_0x127920;if(typeof _0x108957!=_0x26784e(0x201))throw T(_0x156518+'['+_0x29d3ac+_0x26784e(0x1df));return _0x108957;})[_0x127920(0x1f7)](_0x51e1d8=>_0x51e1d8!=='');}function j(_0x23830e,_0x473cb6){const _0x12ef14=_0x122181;if(typeof _0x23830e!=_0x12ef14(0x184)||!Number[_0x12ef14(0x23e)](_0x23830e))throw T(_0x473cb6+'\x20must\x20be\x20a\x20finite\x20number.');return _0x23830e;}function M(_0x5b25b,_0x5019d7){const _0x3b939e=_0x122181;if(typeof _0x5b25b!=_0x3b939e(0x217))throw T(_0x5019d7+_0x3b939e(0x1b9));return _0x5b25b;}function N(_0x373d20,_0x54ee5b,_0x5eab82){const _0x4b2f7f=_0x122181;if(typeof _0x373d20==_0x4b2f7f(0x201)&&_0x373d20!=='')return _0x373d20;let _0x3c278d=E(_0x373d20,_0x54ee5b),_0xad768b=_0x5eab82===void 0x0?void 0x0:_0x3c278d[_0x5eab82];if(typeof _0xad768b==_0x4b2f7f(0x201)&&_0xad768b!=='')return _0xad768b;let _0x10c412=_0x3c278d['en-US'];if(typeof _0x10c412==_0x4b2f7f(0x201)&&_0x10c412!=='')return _0x10c412;let _0x33d5e1=Object[_0x4b2f7f(0x21c)](_0x3c278d)['find'](_0x43878a=>typeof _0x43878a==_0x4b2f7f(0x201)&&_0x43878a!=='');if(_0x33d5e1!==void 0x0)return _0x33d5e1;throw T(_0x54ee5b+'\x20contains\x20no\x20usable\x20localized\x20text.');}function P(_0x49e1b9,_0x165cc4,_0x51ba83){const _0x367f7c=_0x122181;try{_0x51ba83===_0x367f7c(0x1e1)?x(_0x49e1b9):S(_0x49e1b9);}catch(_0x1e3062){throw T(_0x165cc4+':\x20'+(_0x1e3062 instanceof Error?_0x1e3062['message']:String(_0x1e3062)));}}function F(_0x348a38,_0x2cf3d7,_0x1222b3){const _0x257613=_0x122181;let _0x22f2f9=new Map();for(let [_0x28a7d5,_0x60f576]of D(_0x348a38,_0x2cf3d7,!0x0)[_0x257613(0x185)]()){let _0x45556d=E(_0x60f576,_0x2cf3d7+'['+_0x28a7d5+']'),_0x3c54d0=O(_0x45556d['id'],_0x2cf3d7+'['+_0x28a7d5+_0x257613(0x1bd));if(P(_0x3c54d0,_0x2cf3d7+'['+_0x28a7d5+_0x257613(0x1bd),_0x257613(0x1b5)),_0x22f2f9[_0x257613(0x1aa)](_0x3c54d0))throw T(_0x257613(0x1f9)+_0x2cf3d7+_0x257613(0x219)+_0x3c54d0+'\x22.');_0x22f2f9[_0x257613(0x1e6)](_0x3c54d0,N(_0x45556d['label'],_0x2cf3d7+'['+_0x28a7d5+_0x257613(0x1c0),_0x1222b3));}return _0x22f2f9;}function I(_0x25498a,_0x4a1781){const _0x4ad82f=_0x122181;let _0x924842=E(_0x25498a[_0x4ad82f(0x1eb)],_0x4a1781+'.intrinsicSize'),_0x29527b=j(_0x924842[_0x4ad82f(0x1b0)],_0x4a1781+_0x4ad82f(0x1fe)),_0x33a79a=j(_0x924842[_0x4ad82f(0x21a)],_0x4a1781+_0x4ad82f(0x1dd));if(_0x29527b<=0x0||_0x33a79a<=0x0)throw T(_0x4a1781+'.intrinsicSize\x20must\x20be\x20positive.');return{'width':_0x29527b,'height':_0x33a79a};}function L(_0x56cd64,_0x10dc72){const _0x16c019=_0x122181;if(_0x56cd64[_0x16c019(0x22a)]!==_0x16c019(0x23f))throw T(_0x10dc72+'.type\x20must\x20be\x20\x22image\x22.');if(_0x56cd64[_0x16c019(0x1f5)]!==_0x16c019(0x1d6))throw T(_0x10dc72+_0x16c019(0x1e5));let _0x5a556e=E(_0x56cd64[_0x16c019(0x241)],_0x10dc72+_0x16c019(0x23a));if(_0x5a556e[_0x16c019(0x22a)]!==_0x16c019(0x23c))throw T(_0x10dc72+_0x16c019(0x225));let _0x1e8e7f=O(_0x5a556e[_0x16c019(0x1b3)],_0x10dc72+'.source.value'),_0x5b80bd;try{_0x5b80bd=new URL(_0x1e8e7f);}catch{throw T(_0x10dc72+'.source.value\x20must\x20be\x20a\x20URL.');}if(_0x5b80bd[_0x16c019(0x1fc)]!==_0x16c019(0x20f))throw T(_0x10dc72+_0x16c019(0x1a8));return _0x1e8e7f;}function R(_0x338829){const _0xed712=_0x122181;return _0x338829['normalize'](_0xed712(0x1f2))[_0xed712(0x237)]()['trim']()['replace'](/\s+/gu,'\x20');}function z(_0x421780){const _0x3b2773=_0x122181;let _0x4ded96=E(_0x421780,_0x3b2773(0x19f)),_0x5bd23b=new Map(),_0x2be1d0=new Map(),_0x7e3edd=[],_0x1b4863=[],_0x368130=new Set(),_0x3b85d8=0x0;for(let [_0x5a141b,_0x58698f]of D(_0x4ded96[_0x3b2773(0x204)],_0x3b2773(0x190))[_0x3b2773(0x185)]()){let _0x79277d=E(E(_0x58698f,'registrations['+_0x5a141b+']')['input'],'registrations['+_0x5a141b+_0x3b2773(0x1c9)),_0x5ed2c5=O(_0x79277d[_0x3b2773(0x1c3)],_0x3b2773(0x181)+_0x5a141b+_0x3b2773(0x18b));if(P(_0x5ed2c5,'registrations['+_0x5a141b+_0x3b2773(0x18b),'registry'),_0x5bd23b['has'](_0x5ed2c5))throw T(_0x3b2773(0x1a1)+_0x5ed2c5+'\x22.');let _0x1f99de=_0x79277d['defaultLocale']===void 0x0?void 0x0:O(_0x79277d[_0x3b2773(0x228)],_0x3b2773(0x181)+_0x5a141b+_0x3b2773(0x22d)),_0x3658d5=F(_0x79277d['groups'],_0x3b2773(0x181)+_0x5a141b+_0x3b2773(0x20e),_0x1f99de),_0x35c547=F(_0x79277d[_0x3b2773(0x1ee)],'registrations['+_0x5a141b+'].input.tags',_0x1f99de),_0x80ed2e=[];for(let [_0x72a6cb,_0x32daea]of D(_0x79277d['resources'],'registrations['+_0x5a141b+_0x3b2773(0x198))['entries']()){let _0x13c951=_0x3b2773(0x181)+_0x5a141b+'].input.resources['+_0x72a6cb+']',_0x391d0c=E(_0x32daea,_0x13c951),_0x3b211e=O(_0x391d0c['id'],_0x13c951+_0x3b2773(0x234));P(_0x3b211e,_0x13c951+'.id','resource');let _0xe9a1c8=ee(_0x5ed2c5,_0x3b211e);if(_0x2be1d0['has'](_0xe9a1c8))throw T(_0x3b2773(0x1e9)+_0xe9a1c8+'\x22.');let _0x3e7bd4;try{_0x3e7bd4=w(_0xe9a1c8);}catch(_0x537fd5){throw T(_0x13c951+':\x20'+(_0x537fd5 instanceof Error?_0x537fd5[_0x3b2773(0x1cc)]:String(_0x537fd5)));}if(_0x368130['has'](_0x3e7bd4))throw T(_0x3b2773(0x22e)+_0x3e7bd4+'\x22.');_0x368130[_0x3b2773(0x209)](_0x3e7bd4);let _0xc74fb4=_0x391d0c[_0x3b2773(0x238)]===void 0x0?void 0x0:O(_0x391d0c['groupId'],_0x13c951+_0x3b2773(0x229));if(_0xc74fb4!==void 0x0&&!_0x3658d5[_0x3b2773(0x1aa)](_0xc74fb4))throw T(_0x13c951+'.groupId\x20references\x20unknown\x20group\x20\x22'+_0xc74fb4+'\x22.');let _0x967853=k(_0x391d0c['tagIds'],_0x13c951+_0x3b2773(0x1a5),!0x0);for(let _0x4c2214 of _0x967853)if(!_0x35c547[_0x3b2773(0x1aa)](_0x4c2214))throw T(_0x13c951+_0x3b2773(0x22c)+_0x4c2214+'\x22.');let _0x510f47=A(_0x391d0c[_0x3b2773(0x1d8)],_0x13c951+_0x3b2773(0x1f4)),_0x198bbc=N(_0x391d0c[_0x3b2773(0x196)],_0x13c951+_0x3b2773(0x1c6),_0x1f99de),_0x5210df=_0x391d0c[_0x3b2773(0x1b2)]===void 0x0?void 0x0:N(_0x391d0c[_0x3b2773(0x1b2)],_0x13c951+_0x3b2773(0x1f6),_0x1f99de),_0x587e75=_0xc74fb4===void 0x0?null:{'id':_0xc74fb4,'label':_0x3658d5[_0x3b2773(0x1c7)](_0xc74fb4)},_0x321d60=_0x967853[_0x3b2773(0x189)](_0xcc2284=>({'id':_0xcc2284,'label':_0x35c547[_0x3b2773(0x1c7)](_0xcc2284)})),_0x298300=E(_0x391d0c['payload'],_0x13c951+_0x3b2773(0x1a9)),_0x1d3e1e=_0x391d0c[_0x3b2773(0x1da)]===void 0x0?null:j(_0x391d0c['order'],_0x13c951+_0x3b2773(0x1e3)),_0x2813e6=M(_0x298300[_0x3b2773(0x1bc)],_0x13c951+_0x3b2773(0x22b)),_0x2d2b23={'handle':_0xe9a1c8,'registryId':_0x5ed2c5,'id':_0x3b211e,'name':_0x198bbc,..._0x5210df===void 0x0?{}:{'description':_0x5210df},'group':_0x587e75,'tags':_0x321d60,'keywords':_0x510f47,'order':_0x1d3e1e,'intrinsicSize':I(_0x298300,_0x13c951+_0x3b2773(0x1a9)),'colorEditable':_0x2813e6,'sourceUrl':L(_0x298300,_0x13c951+_0x3b2773(0x1a9)),'registrationIndex':_0x5a141b,'resourceIndex':_0x72a6cb,'globalIndex':_0x3b85d8,'searchText':R([_0x198bbc,_0x5210df,_0x587e75?.['label'],..._0x321d60[_0x3b2773(0x189)](_0x9a9abf=>_0x9a9abf[_0x3b2773(0x211)]),..._0x510f47]['filter'](_0x94574a=>_0x94574a!==void 0x0)[_0x3b2773(0x1e2)]('\x20'))};_0x3b85d8++,_0x80ed2e['push'](_0x2d2b23),_0x1b4863['push'](_0x2d2b23),_0x2be1d0[_0x3b2773(0x1e6)](_0xe9a1c8,_0x2d2b23);}let _0x50c4a2={'id':_0x5ed2c5,'groups':_0x3658d5,'tags':_0x35c547,'resources':_0x80ed2e};_0x7e3edd[_0x3b2773(0x1e4)](_0x50c4a2),_0x5bd23b['set'](_0x5ed2c5,_0x50c4a2);}if(_0x7e3edd['length']===0x0)throw T(_0x3b2773(0x242));return{'registries':_0x7e3edd,'registryById':_0x5bd23b,'resourceByHandle':_0x2be1d0,'resources':_0x1b4863};}function B(_0x2385ac,_0x63e13){const _0xd680f5=_0x122181;C(_0x63e13);let _0x40cde9=_0x2385ac['resourceByHandle'][_0xd680f5(0x1c7)](_0x63e13);if(_0x40cde9===void 0x0)throw new h(_0xd680f5(0x1d2),_0xd680f5(0x220)+_0x63e13+'\x22;\x20try\x20resources\x20find\x20<query>.',_0x63e13);return _0x40cde9;}function te(_0x291ae5){const _0x42077d=_0x122181;return _0x291ae5[_0x42077d(0x19a)]['map'](_0x33d2cc=>({'id':_0x33d2cc['id'],'resourceCount':_0x33d2cc['resources'][_0x42077d(0x232)],'groupCount':_0x33d2cc[_0x42077d(0x1ea)]['size'],'tagCount':_0x33d2cc['tags']['size'],'colorEditableCount':_0x33d2cc['resources'][_0x42077d(0x1f7)](_0x287787=>_0x287787[_0x42077d(0x1bc)])[_0x42077d(0x232)]}));}function _0xdc40(_0x2beb71,_0x4218c4){_0x2beb71=_0x2beb71-0x181;const _0x17f1b8=_0x17f1();let _0xdc401=_0x17f1b8[_0x2beb71];return _0xdc401;}function ne(_0x440fb9){const _0x361a6e=_0x122181;return{'handle':_0x440fb9['handle'],'registryId':_0x440fb9[_0x361a6e(0x1c3)],'id':_0x440fb9['id'],'name':_0x440fb9['name'],'group':_0x440fb9[_0x361a6e(0x183)],'tags':_0x440fb9[_0x361a6e(0x1ee)],'keywords':_0x440fb9[_0x361a6e(0x1d8)],'order':_0x440fb9[_0x361a6e(0x1da)],'intrinsicSize':_0x440fb9[_0x361a6e(0x1eb)],'colorEditable':_0x440fb9[_0x361a6e(0x1bc)]};}function re(_0x532db9,_0x672a7f){const _0x42e887=_0x122181;let _0x1db52c=(_0x532db9[_0x42e887(0x1da)]??_0x532db9['globalIndex'])-(_0x672a7f['order']??_0x672a7f[_0x42e887(0x1e7)]);if(_0x1db52c!==0x0)return _0x1db52c;let _0x2a2757=_0x532db9[_0x42e887(0x20d)]-_0x672a7f['registrationIndex'];if(_0x2a2757!==0x0)return _0x2a2757;let _0x39efc4=_0x532db9[_0x42e887(0x214)]-_0x672a7f[_0x42e887(0x214)];return _0x39efc4===0x0?_0x532db9['handle'][_0x42e887(0x213)](_0x672a7f[_0x42e887(0x1a4)]):_0x39efc4;}function ie(_0x10fdd8,_0x1b2256){const _0x2f44fa=_0x122181;let _0x1b84bc=_0x1b2256[_0x2f44fa(0x18e)][_0x2f44fa(0x189)](R)[_0x2f44fa(0x1f7)](_0x52fc40=>_0x52fc40!=='');if(_0x1b84bc[_0x2f44fa(0x232)]===0x0)throw new h(_0x2f44fa(0x218),'Resource\x20search\x20needs\x20at\x20least\x20one\x20non-empty\x20query.');let _0x2a948c=new Set(_0x1b2256[_0x2f44fa(0x19a)]??[]);for(let _0xd67a87 of _0x2a948c)if(!_0x10fdd8['registryById'][_0x2f44fa(0x1aa)](_0xd67a87))throw new h(_0x2f44fa(0x1d9),_0x2f44fa(0x20c)+_0xd67a87+'\x22.');let _0x3af645=_0x1b2256[_0x2f44fa(0x1bb)]??_0x10fdd8[_0x2f44fa(0x1c1)][_0x2f44fa(0x232)];if(!Number[_0x2f44fa(0x1c2)](_0x3af645)||_0x3af645<0x1)throw new h('resource-limit-invalid',_0x2f44fa(0x1fa)+_0x3af645+'\x22.');let _0xf18d78=_0x10fdd8['resources'][_0x2f44fa(0x1f7)](_0x2dbff9=>_0x2a948c[_0x2f44fa(0x1ad)]===0x0||_0x2a948c[_0x2f44fa(0x1aa)](_0x2dbff9[_0x2f44fa(0x1c3)]))[_0x2f44fa(0x1f7)](_0x3e8f23=>_0x1b84bc[_0x2f44fa(0x216)](_0x54e3af=>_0x3e8f23[_0x2f44fa(0x240)][_0x2f44fa(0x1b8)](_0x54e3af)))[_0x2f44fa(0x1a7)](re);return{'resources':_0xf18d78[_0x2f44fa(0x210)](0x0,_0x3af645)[_0x2f44fa(0x189)](ne),'total':_0xf18d78['length']};}function V(_0x3b2c3a){const _0x1187ad=_0x122181;return/^\s*(?:<\?xml[^>]*>\s*)?(?:<!--[^]*?-->\s*)*<svg(?:\s|>)/iu[_0x1187ad(0x1ff)](_0x3b2c3a);}function H(_0x5120e7,_0x38f76f){const _0x50aa87=_0x122181;return g(_0x38f76f)?{'handle':_0x5120e7,'code':_0x38f76f[_0x50aa87(0x221)],'message':_0x38f76f['message']}:{'handle':_0x5120e7,'code':'resource-export-failed','message':_0x38f76f instanceof Error?_0x38f76f['message']:String(_0x38f76f)};}var U=class{[_0x122181(0x18c)];['catalog'];constructor(_0x56b4a9){const _0x32a90c=_0x122181;this['options']=_0x56b4a9,this[_0x32a90c(0x188)]=z(_0x56b4a9[_0x32a90c(0x19f)]);}get['cacheLocation'](){const _0x3a6699=_0x122181;return this[_0x3a6699(0x18c)][_0x3a6699(0x1a6)][_0x3a6699(0x1dc)];}['listRegistries'](){const _0x44c0f5=_0x122181;return te(this[_0x44c0f5(0x188)]);}['find'](_0x492e74){const _0x238532=_0x122181;return ie(this[_0x238532(0x188)],_0x492e74);}async[_0x122181(0x1f8)](_0x585915){const _0x33541e=_0x122181;let _0xa605f8=B(this[_0x33541e(0x188)],_0x585915['handle']),_0x3ad5a1=await this['options']['cache']['read'](_0x585915[_0x33541e(0x1a4)]);if(_0x3ad5a1!==void 0x0&&V(_0x3ad5a1))return{'handle':_0x585915[_0x33541e(0x1a4)],'svg':_0x3ad5a1};let _0x3abe09;try{_0x3abe09=await this['options'][_0x33541e(0x1fd)][_0x33541e(0x1d7)](_0xa605f8[_0x33541e(0x200)]);}catch(_0x360a3b){throw g(_0x360a3b)?_0x360a3b:new h(_0x33541e(0x18d),_0x33541e(0x1e0)+_0x585915[_0x33541e(0x1a4)]+'\x22:\x20'+(_0x360a3b instanceof Error?_0x360a3b[_0x33541e(0x1cc)]:String(_0x360a3b)),_0x585915[_0x33541e(0x1a4)],{'cause':_0x360a3b});}if(!V(_0x3abe09))throw new h(_0x33541e(0x226),_0x33541e(0x1d4)+_0x585915[_0x33541e(0x1a4)]+_0x33541e(0x1ae),_0x585915['handle']);return await this[_0x33541e(0x18c)]['cache'][_0x33541e(0x223)](_0x585915[_0x33541e(0x1a4)],_0x3abe09),{'handle':_0x585915[_0x33541e(0x1a4)],'svg':_0x3abe09};}async['export'](_0x28323d){const _0x2a1f8b=_0x122181;let _0x4f1dfb=[],_0x431d62=[];for(let _0x56613c of _0x28323d['handles'])try{let {svg:_0x30e191}=await this['read']({'handle':_0x56613c}),_0x20b4ca=await this[_0x2a1f8b(0x18c)][_0x2a1f8b(0x1cf)][_0x2a1f8b(0x223)](_0x28323d[_0x2a1f8b(0x1ab)],w(_0x56613c),_0x30e191);_0x4f1dfb['push']({'handle':_0x56613c,'path':_0x20b4ca});}catch(_0x2c6760){_0x431d62[_0x2a1f8b(0x1e4)](H(_0x56613c,_0x2c6760));}return{'exported':_0x4f1dfb,'failed':_0x431d62};}async['clearCache'](){const _0x13e76f=_0x122181;return await this['options'][_0x13e76f(0x1a6)][_0x13e76f(0x222)]();}};function W(_0x26c59b){return new U(_0x26c59b);}function G(_0x23df4a){const _0x5cc9f8=_0x122181;return _0x23df4a instanceof Error&&_0x5cc9f8(0x221)in _0x23df4a;}function K(_0x3a24e4){const _0xd66f80=_0x122181;let _0x4c36bc=_0x2c9d4a(_0x3a24e4);if(!_0x2d5484(_0x3a24e4)||_0x4c36bc===_0x569a81(_0x4c36bc)[_0xd66f80(0x1ca)])throw new h('resource-cache-root-invalid',_0xd66f80(0x1cd)+_0x3a24e4+'\x22.');return _0x4c36bc;}async function q(_0x27e542){const _0x14e495=_0x122181;let _0x13b257;try{_0x13b257=await _0x135f30(_0x27e542,{'withFileTypes':!0x0});}catch(_0x59026d){if(G(_0x59026d)&&_0x59026d[_0x14e495(0x221)]===_0x14e495(0x1d0))return{'resourceCount':0x0,'byteCount':0x0};throw _0x59026d;}let _0x2314b1=0x0,_0x3ceb7f=0x0;for(let _0x5f5442 of _0x13b257){let _0x3448d1=_0x55ac48(_0x27e542,_0x5f5442['name']);if(_0x5f5442[_0x14e495(0x21d)]()){let _0x5409aa=await q(_0x3448d1);_0x2314b1+=_0x5409aa['resourceCount'],_0x3ceb7f+=_0x5409aa[_0x14e495(0x230)];}else{if(_0x5f5442[_0x14e495(0x212)]()&&_0x5f5442['name'][_0x14e495(0x1b4)](_0x14e495(0x1c5))){let _0xf71c48=await _0x20e29a(_0x3448d1);_0x2314b1++,_0x3ceb7f+=_0xf71c48[_0x14e495(0x1ad)];}}}return{'resourceCount':_0x2314b1,'byteCount':_0x3ceb7f};}var J=class{['location'];constructor(_0x23a1fa){this['location']=K(_0x23a1fa);}[_0x122181(0x194)](_0x347645){const _0x181737=_0x122181;let {registryId:_0x3ad447,resourceId:_0x4549f6}=C(_0x347645);return _0x55ac48(this[_0x181737(0x1dc)],_0x3ad447,_0x4549f6+_0x181737(0x1c5));}async[_0x122181(0x1f8)](_0x28f4e0){const _0x1b3b30=_0x122181;try{return await _0x3da128(this[_0x1b3b30(0x194)](_0x28f4e0),'utf8');}catch(_0x38ce24){if(G(_0x38ce24)&&_0x38ce24['code']===_0x1b3b30(0x1d0))return;throw _0x38ce24;}}async[_0x122181(0x223)](_0x433344,_0x227a96){const _0x18bc00=_0x122181;let _0x1a28bd=this['path'](_0x433344);await _0x39a1a4(_0x5d4545(_0x1a28bd),{'recursive':!0x0});let _0x12c64d=_0x55ac48(_0x5d4545(_0x1a28bd),_0x18bc00(0x1d5)+process[_0x18bc00(0x187)]+'-'+_0x1c8bca()+_0x18bc00(0x1de));try{await _0x5f3f74(_0x12c64d,_0x227a96,{'encoding':_0x18bc00(0x23d),'mode':0x180}),await _0x2e1d93(_0x12c64d,_0x1a28bd);}catch(_0xe01c21){throw await _0x22e0b2(_0x12c64d)[_0x18bc00(0x191)](()=>void 0x0),_0xe01c21;}}async[_0x122181(0x222)](){const _0x3ec302=_0x122181;let _0x314b0d=await q(this[_0x3ec302(0x1dc)]);return await _0x16f7b4(this[_0x3ec302(0x1dc)],{'force':!0x0,'recursive':!0x0}),{'path':this[_0x3ec302(0x1dc)],..._0x314b0d};}},Y=class{async['write'](_0x36a2ea,_0x1a2f17,_0x4f86e3){const _0x2613f7=_0x122181;await _0x39a1a4(_0x36a2ea,{'recursive':!0x0});let _0x2b02f3=_0x55ac48(_0x36a2ea,_0x1a2f17);return await _0x5f3f74(_0x2b02f3,_0x4f86e3,_0x2613f7(0x23d)),_0x2b02f3;}},X=0x7530,ae=0xa00000,oe=0xa,se=new Set([0x12d,0x12e,0x12f,0x133,0x134]);function Z(_0x4613bc){const _0xddbdbf=_0x122181;return new h(_0xddbdbf(0x239),_0xddbdbf(0x20a)+_0x4613bc+'\x20bytes.');}async function ce(_0x34c2b7,_0x98761b){const _0x3d6ce5=_0x122181;let _0x3e4f78=Number(_0x34c2b7['headers'][_0x3d6ce5(0x1c7)](_0x3d6ce5(0x224)));if(Number[_0x3d6ce5(0x23e)](_0x3e4f78)&&_0x3e4f78>_0x98761b)throw Z(_0x98761b);if(_0x34c2b7['body']===null){let _0x477009=await _0x34c2b7['text']();if(Buffer['byteLength'](_0x477009)>_0x98761b)throw Z(_0x98761b);return _0x477009;}let _0x50ba84=_0x34c2b7['body']['getReader'](),_0x5091cd=[],_0x328112=0x0;try{for(;;){let _0x57bc1e=await _0x50ba84[_0x3d6ce5(0x1f8)]();if(_0x57bc1e[_0x3d6ce5(0x1a2)])break;if(_0x328112+=_0x57bc1e[_0x3d6ce5(0x1b3)][_0x3d6ce5(0x1a3)],_0x328112>_0x98761b)throw await _0x50ba84[_0x3d6ce5(0x207)]()[_0x3d6ce5(0x191)](()=>void 0x0),Z(_0x98761b);_0x5091cd[_0x3d6ce5(0x1e4)](_0x57bc1e[_0x3d6ce5(0x1b3)]);}}finally{_0x50ba84[_0x3d6ce5(0x186)]();}try{return new TextDecoder('utf-8',{'fatal':!0x0})[_0x3d6ce5(0x18f)](Buffer[_0x3d6ce5(0x205)](_0x5091cd,_0x328112));}catch{throw new h('resource-download-invalid-utf8',_0x3d6ce5(0x182));}}var Q=class{[_0x122181(0x236)];[_0x122181(0x20b)];[_0x122181(0x1f1)];['maxRedirects'];constructor(_0x3d8433={}){const _0x2d926e=_0x122181;this[_0x2d926e(0x236)]=_0x3d8433['fetch']??fetch,this[_0x2d926e(0x20b)]=_0x3d8433[_0x2d926e(0x20b)]??X,this[_0x2d926e(0x1f1)]=_0x3d8433[_0x2d926e(0x1f1)]??ae,this['maxRedirects']=_0x3d8433['maxRedirects']??oe;}async[_0x122181(0x1d7)](_0x10284a){const _0x235f0e=_0x122181;let _0x3f75b6=new URL(_0x10284a);if(_0x3f75b6[_0x235f0e(0x1fc)]!==_0x235f0e(0x20f))throw new h(_0x235f0e(0x1b6),'Resource\x20URL\x20must\x20use\x20HTTPS.');let _0x451ab1=new AbortController(),_0x4ef3c3=setTimeout(()=>_0x451ab1['abort'](),this[_0x235f0e(0x20b)]);try{let _0x46acf5=_0x3f75b6;for(let _0x34a8ec=0x0;;_0x34a8ec++){let _0x3dd46d=await this[_0x235f0e(0x236)](_0x46acf5,{'redirect':_0x235f0e(0x1f0),'signal':_0x451ab1[_0x235f0e(0x206)]});if(se[_0x235f0e(0x1aa)](_0x3dd46d['status'])){if(_0x34a8ec>=this[_0x235f0e(0x1fb)])throw new h(_0x235f0e(0x231),_0x235f0e(0x1a0)+this[_0x235f0e(0x1fb)]+'.');let _0x16a53a=_0x3dd46d[_0x235f0e(0x1db)][_0x235f0e(0x1c7)](_0x235f0e(0x1dc));if(_0x16a53a===null)throw new h(_0x235f0e(0x1ce),_0x235f0e(0x19b)+_0x3dd46d[_0x235f0e(0x192)]+_0x235f0e(0x1ec));let _0x21c98e;try{_0x21c98e=new URL(_0x16a53a,_0x46acf5);}catch{throw new h('resource-download-invalid-redirect',_0x235f0e(0x233));}if(_0x21c98e[_0x235f0e(0x1fc)]!==_0x235f0e(0x20f))throw new h(_0x235f0e(0x18a),'Resource\x20request\x20redirected\x20to\x20a\x20non-HTTPS\x20URL.');_0x46acf5=_0x21c98e;continue;}if(!_0x3dd46d['ok'])throw new h(_0x235f0e(0x195),_0x235f0e(0x19b)+_0x3dd46d['status']+'.');if(_0x3dd46d[_0x235f0e(0x23c)]!==''&&new URL(_0x3dd46d[_0x235f0e(0x23c)])[_0x235f0e(0x1fc)]!=='https:')throw new h(_0x235f0e(0x18a),_0x235f0e(0x215));let _0x4a630a=await ce(_0x3dd46d,this[_0x235f0e(0x1f1)]);if(!V(_0x4a630a))throw new h(_0x235f0e(0x203),'Resource\x20response\x20is\x20not\x20an\x20SVG\x20document.');return _0x4a630a;}}catch(_0x31ca45){throw _0x451ab1[_0x235f0e(0x206)][_0x235f0e(0x21f)]?new h('resource-download-timeout',_0x235f0e(0x21e)+this['timeoutMs']+_0x235f0e(0x1be)):_0x31ca45;}finally{clearTimeout(_0x4ef3c3);}}};function $(_0x3f391){const _0x2ec21c=_0x122181;try{return JSON[_0x2ec21c(0x21b)](_0x4310a8(_0x3f391,_0x2ec21c(0x23d)));}catch(_0x15719d){throw new h(_0x2ec21c(0x1c8),_0x2ec21c(0x23b)+_0x3f391+':\x20'+(_0x15719d instanceof Error?_0x15719d[_0x2ec21c(0x1cc)]:String(_0x15719d)),void 0x0,{'cause':_0x15719d});}}function le(_0x2b656a){const _0x392ae9=_0x122181;let _0x4cb040;return()=>(_0x4cb040??=W({'manifest':$(_0x2b656a['manifestPath']),'cache':new J(_0x2b656a[_0x392ae9(0x1ed)]),'downloader':new Q(_0x2b656a['downloader']),'output':new Y()}),_0x4cb040);}export{J as FilesystemResourceCache,Y as FilesystemResourceOutput,Q as HttpsResourceDownloader,h as ResourceLibraryError,le as createNodeResourceLibraryFactory,W as createResourceLibrary,g as isResourceLibraryError,$ as loadResourceManifestFromPath,K as validateResourceCacheRoot};
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@univer-cli/resource-library",
|
|
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
|
+
}
|