template-replacement 3.0.8
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/.workflow/publish_to_npmjs.yml +26 -0
- package/core/base.ts +54 -0
- package/core/general.ts +13 -0
- package/core/sign.ts +13 -0
- package/db/index.ts +5 -0
- package/db/indexedDBCache.ts +129 -0
- package/dispatcher/general.ts +6 -0
- package/dispatcher/sign.ts +6 -0
- package/dispatcher/workerGeneral.ts +7 -0
- package/dispatcher/workerSign.ts +7 -0
- package/dist/assets/template_replacement_core_wasm_bg.wasm +0 -0
- package/dist/assets/template_replacement_sign_core_wasm_bg.wasm +0 -0
- package/dist/base-CC-6cmrq.js +189 -0
- package/dist/general.d.ts +1 -0
- package/dist/index-BkwrGCka.js +61 -0
- package/dist/main/general.js +4543 -0
- package/dist/main/sign.js +4566 -0
- package/dist/replace/general.js +424 -0
- package/dist/replace/sign.js +428 -0
- package/dist/sign.d.ts +1 -0
- package/download/index.ts +22 -0
- package/download/stream.ts +38 -0
- package/helper/index.ts +162 -0
- package/index.ts +21 -0
- package/office/zip.ts +116 -0
- package/package.json +33 -0
- package/replace/base.ts +124 -0
- package/replace/general.ts +14 -0
- package/replace/image.ts +116 -0
- package/replace/interface.ts +29 -0
- package/replace/paramsData.ts +117 -0
- package/replace/sign.ts +31 -0
- package/task/urlDownloadTask.ts +67 -0
- package/temp/index.ts +157 -0
- package/temp/interface.ts +18 -0
- package/tsconfig.json +108 -0
- package/vite.config.ts +36 -0
- package/worker/child/agency.ts +78 -0
- package/worker/child/base.ts +89 -0
- package/worker/child/general.ts +5 -0
- package/worker/child/sign.ts +9 -0
- package/worker/index.ts +65 -0
- package/worker/interface.ts +11 -0
- package/worker/main/general.ts +8 -0
- package/worker/main/index.ts +176 -0
- package/worker/main/sign.ts +8 -0
- package/worker/type.ts +24 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
version: '1.0'
|
|
2
|
+
name: publish_to_npmjs
|
|
3
|
+
displayName: 发布到npmjs
|
|
4
|
+
triggers:
|
|
5
|
+
trigger: auto
|
|
6
|
+
push:
|
|
7
|
+
branches:
|
|
8
|
+
precise:
|
|
9
|
+
- master
|
|
10
|
+
variables:
|
|
11
|
+
global:
|
|
12
|
+
- NODE_AUTH_TOKEN
|
|
13
|
+
stages:
|
|
14
|
+
- name: compile
|
|
15
|
+
displayName: 发布
|
|
16
|
+
strategy: naturally
|
|
17
|
+
trigger: auto
|
|
18
|
+
steps:
|
|
19
|
+
- step: build@nodejs
|
|
20
|
+
name: publish_to_npmjs
|
|
21
|
+
displayName: 发布到npmjs
|
|
22
|
+
nodeVersion: 20.10.0
|
|
23
|
+
commands:
|
|
24
|
+
- echo //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} >> .npmrc
|
|
25
|
+
- npm publish
|
|
26
|
+
strategy: {}
|
package/core/base.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface Interface {
|
|
2
|
+
await(): Promise<Interface>
|
|
3
|
+
add_template(file: Uint8Array): Promise<number>
|
|
4
|
+
add_media(file: Uint8Array): Promise<string>
|
|
5
|
+
extract_one_file_variable_names(data: Uint8Array): Promise<(string)[]>
|
|
6
|
+
extract_variable_names(files: (Uint8Array)[]): Promise<(string)[]>
|
|
7
|
+
extract_one_file_medias(data: Uint8Array): Promise<any>
|
|
8
|
+
extract_medias(files: (Uint8Array)[]): Promise<any>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default class implements Interface {
|
|
12
|
+
module: any
|
|
13
|
+
awaitInit: Promise<void>
|
|
14
|
+
|
|
15
|
+
constructor(init: Promise<any>, module: any) {
|
|
16
|
+
this.awaitInit = init
|
|
17
|
+
this.module = module
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async await(): Promise<Interface> {
|
|
21
|
+
await this.awaitInit
|
|
22
|
+
return this
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async add_template(file: Uint8Array): Promise<number> {
|
|
26
|
+
await this.awaitInit
|
|
27
|
+
return this.module.add_template(file)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async add_media(file: Uint8Array): Promise<string> {
|
|
31
|
+
await this.awaitInit
|
|
32
|
+
return this.module.add_media(file)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async extract_one_file_variable_names(data: Uint8Array): Promise<(string)[]> {
|
|
36
|
+
await this.awaitInit
|
|
37
|
+
return this.module.extract_one_file_variable_names(data)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async extract_variable_names(files: (Uint8Array)[]): Promise<(string)[]> {
|
|
41
|
+
await this.awaitInit
|
|
42
|
+
return this.module.extract_variable_names(files)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async extract_one_file_medias(data: Uint8Array): Promise<any> {
|
|
46
|
+
await this.awaitInit
|
|
47
|
+
return this.module.extract_one_file_medias(data)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async extract_medias(files: (Uint8Array)[]): Promise<any> {
|
|
51
|
+
await this.awaitInit
|
|
52
|
+
return this.module.extract_medias(files)
|
|
53
|
+
}
|
|
54
|
+
}
|
package/core/general.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import init, * as core from 'template-replacement-core-wasm'
|
|
2
|
+
import base from './base'
|
|
3
|
+
export * from 'template-replacement-core-wasm'
|
|
4
|
+
|
|
5
|
+
let awaitInit: Promise<any> | undefined
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
if (!awaitInit) {
|
|
9
|
+
awaitInit = init()
|
|
10
|
+
}
|
|
11
|
+
return new base(awaitInit, core)
|
|
12
|
+
}
|
|
13
|
+
|
package/core/sign.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import init, * as core from 'template-replacement-sign-core-wasm'
|
|
2
|
+
import base from './base'
|
|
3
|
+
export * from 'template-replacement-sign-core-wasm'
|
|
4
|
+
|
|
5
|
+
let awaitInit: Promise<any> | undefined
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
if (!awaitInit) {
|
|
9
|
+
awaitInit = init()
|
|
10
|
+
}
|
|
11
|
+
return new base(awaitInit, core)
|
|
12
|
+
}
|
|
13
|
+
|
package/db/index.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
|
|
2
|
+
type templateData<T> = {
|
|
3
|
+
url: string
|
|
4
|
+
data: T
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default class indexedDBCache {
|
|
8
|
+
_initFinishCallBackFuns?: Function[] = [] //初始化完成回调
|
|
9
|
+
_isInitFinish: boolean = false //是否初始化完成
|
|
10
|
+
|
|
11
|
+
_db?: IDBDatabase //数据库
|
|
12
|
+
_dbName: string = 'template_replacement' //数据库名
|
|
13
|
+
_dbversion: number = 1 //数据库版本
|
|
14
|
+
_cacheTableName: string = 'templates' //表名
|
|
15
|
+
_tableMap: any = {} //表配置
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// 构造函数
|
|
19
|
+
constructor() {
|
|
20
|
+
this.initDB()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
initDB(): Promise<any> {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const request = indexedDB.open(this._dbName, this._dbversion) // 打开数据库
|
|
26
|
+
// 数据库初始化成功
|
|
27
|
+
request.onsuccess = (event) => {
|
|
28
|
+
this._db = request.result
|
|
29
|
+
this._isInitFinish = true
|
|
30
|
+
if (this._initFinishCallBackFuns) {
|
|
31
|
+
try {
|
|
32
|
+
for (const fun of this._initFinishCallBackFuns) {
|
|
33
|
+
fun()
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
}
|
|
37
|
+
this._initFinishCallBackFuns = undefined
|
|
38
|
+
}
|
|
39
|
+
resolve(event)
|
|
40
|
+
}
|
|
41
|
+
// 数据库初始化失败
|
|
42
|
+
request.onerror = (event) => {
|
|
43
|
+
console.error(event)
|
|
44
|
+
reject(event)
|
|
45
|
+
}
|
|
46
|
+
// 数据库初次创建或更新时会触发
|
|
47
|
+
request.onupgradeneeded = (event) => {
|
|
48
|
+
let db = request.result
|
|
49
|
+
if (!db.objectStoreNames.contains(this._cacheTableName)) {
|
|
50
|
+
db.createObjectStore(this._cacheTableName, {
|
|
51
|
+
keyPath: 'url', // 设置主键
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
resolve(event)
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async awaitInit(): Promise<void> {
|
|
60
|
+
if(this._isInitFinish || !this._initFinishCallBackFuns) {
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
await new Promise((resolve, reject) => {
|
|
64
|
+
this._initFinishCallBackFuns?.push(resolve)
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
closeDB(): void {
|
|
69
|
+
this._db?.close()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async store(mode?: IDBTransactionMode): Promise<IDBObjectStore> {
|
|
73
|
+
await this.awaitInit()
|
|
74
|
+
const db = this._db as IDBDatabase
|
|
75
|
+
const transaction = db.transaction(this._cacheTableName, mode)
|
|
76
|
+
return transaction.objectStore(this._cacheTableName)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @description : 更新数据
|
|
81
|
+
* @param {Object} params 添加到数据库中的数据 { url: 文件地址, data: 文件blob }
|
|
82
|
+
* @return {*}
|
|
83
|
+
*/
|
|
84
|
+
putData<T>(params: templateData<T>): Promise<any> {
|
|
85
|
+
return new Promise(async (resolve, reject) => {
|
|
86
|
+
const response = (await this.store('readwrite')).put(params)
|
|
87
|
+
// 操作成功
|
|
88
|
+
response.onsuccess = (event) => {
|
|
89
|
+
resolve(event)
|
|
90
|
+
}
|
|
91
|
+
// 操作失败
|
|
92
|
+
response.onerror = (event) => {
|
|
93
|
+
reject(event)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 通过主键读取数据
|
|
99
|
+
getDataByKey<T>(key: string): Promise<templateData<T>> {
|
|
100
|
+
return new Promise(async (resolve, reject) => {
|
|
101
|
+
// 通过主键读取数据
|
|
102
|
+
const request = (await this.store()).get(key)
|
|
103
|
+
// 操作成功
|
|
104
|
+
request.onsuccess = () => {
|
|
105
|
+
resolve(request.result)
|
|
106
|
+
}
|
|
107
|
+
// 操作失败
|
|
108
|
+
request.onerror = (event) => {
|
|
109
|
+
reject(event)
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 清空数据库数据
|
|
115
|
+
clearDB(): Promise<any> {
|
|
116
|
+
return new Promise(async (resolve, reject) => {
|
|
117
|
+
const response = (await this.store('readwrite')).clear()
|
|
118
|
+
// 操作成功
|
|
119
|
+
response.onsuccess = (event) => {
|
|
120
|
+
resolve(event)
|
|
121
|
+
}
|
|
122
|
+
// 操作失败
|
|
123
|
+
response.onerror = (event) => {
|
|
124
|
+
reject(event)
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
var m = (i) => {
|
|
2
|
+
throw TypeError(i);
|
|
3
|
+
};
|
|
4
|
+
var f = (i, t, a) => t.has(i) || m("Cannot " + a);
|
|
5
|
+
var c = (i, t, a) => (f(i, t, "read from private field"), a ? a.call(i) : t.get(i)), _ = (i, t, a) => t.has(i) ? m("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, a), y = (i, t, a, e) => (f(i, t, "write to private field"), e ? e.call(i, a) : t.set(i, a), a);
|
|
6
|
+
class b {
|
|
7
|
+
//表配置
|
|
8
|
+
// 构造函数
|
|
9
|
+
constructor() {
|
|
10
|
+
this._initFinishCallBackFuns = [], this._isInitFinish = !1, this._dbName = "template_replacement", this._dbversion = 1, this._cacheTableName = "templates", this._tableMap = {}, this.initDB();
|
|
11
|
+
}
|
|
12
|
+
initDB() {
|
|
13
|
+
return new Promise((t, a) => {
|
|
14
|
+
const e = indexedDB.open(this._dbName, this._dbversion);
|
|
15
|
+
e.onsuccess = (s) => {
|
|
16
|
+
if (this._db = e.result, this._isInitFinish = !0, this._initFinishCallBackFuns) {
|
|
17
|
+
try {
|
|
18
|
+
for (const n of this._initFinishCallBackFuns)
|
|
19
|
+
n();
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
this._initFinishCallBackFuns = void 0;
|
|
23
|
+
}
|
|
24
|
+
t(s);
|
|
25
|
+
}, e.onerror = (s) => {
|
|
26
|
+
console.error(s), a(s);
|
|
27
|
+
}, e.onupgradeneeded = (s) => {
|
|
28
|
+
let n = e.result;
|
|
29
|
+
n.objectStoreNames.contains(this._cacheTableName) || n.createObjectStore(this._cacheTableName, {
|
|
30
|
+
keyPath: "url"
|
|
31
|
+
// 设置主键
|
|
32
|
+
}), t(s);
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async awaitInit() {
|
|
37
|
+
this._isInitFinish || !this._initFinishCallBackFuns || await new Promise((t, a) => {
|
|
38
|
+
var e;
|
|
39
|
+
(e = this._initFinishCallBackFuns) == null || e.push(t);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
closeDB() {
|
|
43
|
+
var t;
|
|
44
|
+
(t = this._db) == null || t.close();
|
|
45
|
+
}
|
|
46
|
+
async store(t) {
|
|
47
|
+
return await this.awaitInit(), this._db.transaction(this._cacheTableName, t).objectStore(this._cacheTableName);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @description : 更新数据
|
|
51
|
+
* @param {Object} params 添加到数据库中的数据 { url: 文件地址, data: 文件blob }
|
|
52
|
+
* @return {*}
|
|
53
|
+
*/
|
|
54
|
+
putData(t) {
|
|
55
|
+
return new Promise(async (a, e) => {
|
|
56
|
+
const s = (await this.store("readwrite")).put(t);
|
|
57
|
+
s.onsuccess = (n) => {
|
|
58
|
+
a(n);
|
|
59
|
+
}, s.onerror = (n) => {
|
|
60
|
+
e(n);
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// 通过主键读取数据
|
|
65
|
+
getDataByKey(t) {
|
|
66
|
+
return new Promise(async (a, e) => {
|
|
67
|
+
const s = (await this.store()).get(t);
|
|
68
|
+
s.onsuccess = () => {
|
|
69
|
+
a(s.result);
|
|
70
|
+
}, s.onerror = (n) => {
|
|
71
|
+
e(n);
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// 清空数据库数据
|
|
76
|
+
clearDB() {
|
|
77
|
+
return new Promise(async (t, a) => {
|
|
78
|
+
const e = (await this.store("readwrite")).clear();
|
|
79
|
+
e.onsuccess = (s) => {
|
|
80
|
+
t(s);
|
|
81
|
+
}, e.onerror = (s) => {
|
|
82
|
+
a(s);
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
new b();
|
|
88
|
+
var w = /* @__PURE__ */ ((i) => (i.word = "word", i.excel = "excel", i.unknown = "unknown", i))(w || {}), o, u;
|
|
89
|
+
class x {
|
|
90
|
+
constructor(t) {
|
|
91
|
+
_(this, o, []);
|
|
92
|
+
_(this, u);
|
|
93
|
+
y(this, u, t);
|
|
94
|
+
}
|
|
95
|
+
addTempFile(t) {
|
|
96
|
+
c(this, o).push(t);
|
|
97
|
+
}
|
|
98
|
+
clear() {
|
|
99
|
+
c(this, o).length = 0;
|
|
100
|
+
}
|
|
101
|
+
async extractVariables(t) {
|
|
102
|
+
t || (t = c(this, o));
|
|
103
|
+
const a = {}, e = [];
|
|
104
|
+
for (const s of t)
|
|
105
|
+
e.push(new Promise(async (n, d) => {
|
|
106
|
+
const r = await s.getBuffer();
|
|
107
|
+
r && await s.type() !== w.unknown && (a[s.name] = await c(this, u).extract_one_file_variable_names(r)), n();
|
|
108
|
+
}));
|
|
109
|
+
return await Promise.all(e), a;
|
|
110
|
+
}
|
|
111
|
+
async extractMedias(t) {
|
|
112
|
+
t || (t = c(this, o));
|
|
113
|
+
const a = {}, e = [];
|
|
114
|
+
for (const s of t)
|
|
115
|
+
e.push(new Promise(async (n, d) => {
|
|
116
|
+
const r = await s.getBuffer();
|
|
117
|
+
if (r && await s.type() !== w.unknown) {
|
|
118
|
+
let h = await c(this, u).extract_one_file_medias(r);
|
|
119
|
+
a[s.name] = [], h && Array.isArray(h) && h.forEach((l) => {
|
|
120
|
+
l.id && l.data && a[s.name].push({
|
|
121
|
+
id: l.id,
|
|
122
|
+
data: new Uint8Array(l.data)
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
n();
|
|
127
|
+
}));
|
|
128
|
+
return await Promise.all(e), a;
|
|
129
|
+
}
|
|
130
|
+
async handle(t, a) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
async sign(t) {
|
|
134
|
+
return "";
|
|
135
|
+
}
|
|
136
|
+
async execute(t, a) {
|
|
137
|
+
a || (a = c(this, o));
|
|
138
|
+
const e = {
|
|
139
|
+
names: [],
|
|
140
|
+
uint8Arrays: []
|
|
141
|
+
}, s = [];
|
|
142
|
+
for (const r of a)
|
|
143
|
+
s.push(new Promise(async (h, l) => {
|
|
144
|
+
h(r.getBuffer());
|
|
145
|
+
}));
|
|
146
|
+
await Promise.all(s);
|
|
147
|
+
for (const r of a)
|
|
148
|
+
r.uint8Array && (e.names.push(r.name), e.uint8Arrays.push(r.uint8Array));
|
|
149
|
+
if (!e.uint8Arrays.length)
|
|
150
|
+
return {};
|
|
151
|
+
const n = await this.handle(t, e.uint8Arrays);
|
|
152
|
+
e.uint8Arrays.length;
|
|
153
|
+
const d = {};
|
|
154
|
+
return n.forEach((r, h) => {
|
|
155
|
+
r.length && (d[e.names[h]] = r);
|
|
156
|
+
}), d;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
o = new WeakMap(), u = new WeakMap();
|
|
160
|
+
class B {
|
|
161
|
+
constructor(t, a) {
|
|
162
|
+
this.awaitInit = t, this.module = a;
|
|
163
|
+
}
|
|
164
|
+
async await() {
|
|
165
|
+
return await this.awaitInit, this;
|
|
166
|
+
}
|
|
167
|
+
async add_template(t) {
|
|
168
|
+
return await this.awaitInit, this.module.add_template(t);
|
|
169
|
+
}
|
|
170
|
+
async add_media(t) {
|
|
171
|
+
return await this.awaitInit, this.module.add_media(t);
|
|
172
|
+
}
|
|
173
|
+
async extract_one_file_variable_names(t) {
|
|
174
|
+
return await this.awaitInit, this.module.extract_one_file_variable_names(t);
|
|
175
|
+
}
|
|
176
|
+
async extract_variable_names(t) {
|
|
177
|
+
return await this.awaitInit, this.module.extract_variable_names(t);
|
|
178
|
+
}
|
|
179
|
+
async extract_one_file_medias(t) {
|
|
180
|
+
return await this.awaitInit, this.module.extract_one_file_medias(t);
|
|
181
|
+
}
|
|
182
|
+
async extract_medias(t) {
|
|
183
|
+
return await this.awaitInit, this.module.extract_medias(t);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
export {
|
|
187
|
+
x as B,
|
|
188
|
+
B as b
|
|
189
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var g = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
|
+
};
|
|
4
|
+
var p = (r, s, t) => s.has(r) || g("Cannot " + t);
|
|
5
|
+
var e = (r, s, t) => (p(r, s, "read from private field"), t ? t.call(r) : s.get(r)), n = (r, s, t) => s.has(r) ? g("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(r) : s.set(r, t), a = (r, s, t, o) => (p(r, s, "write to private field"), o ? o.call(r, t) : s.set(r, t), t), k = (r, s, t) => (p(r, s, "access private method"), t);
|
|
6
|
+
var l = (r, s, t, o) => ({
|
|
7
|
+
set _(f) {
|
|
8
|
+
a(r, s, f, t);
|
|
9
|
+
},
|
|
10
|
+
get _() {
|
|
11
|
+
return e(r, s, o);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var i, c, u, h, d, y;
|
|
15
|
+
class v {
|
|
16
|
+
constructor(s, t) {
|
|
17
|
+
n(this, d);
|
|
18
|
+
n(this, i);
|
|
19
|
+
n(this, c, 0);
|
|
20
|
+
n(this, u, []);
|
|
21
|
+
n(this, h, []);
|
|
22
|
+
if (a(this, i, Number(t)), !e(this, i) || e(this, i) < 1)
|
|
23
|
+
try {
|
|
24
|
+
a(this, i, navigator.hardwareConcurrency < 8 ? navigator.hardwareConcurrency : 8);
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
(!e(this, i) || e(this, i) < 1) && a(this, i, 1);
|
|
28
|
+
for (let o = 0; o < e(this, i); o++)
|
|
29
|
+
k(this, d, y).call(this, s);
|
|
30
|
+
}
|
|
31
|
+
concurrency() {
|
|
32
|
+
return e(this, i);
|
|
33
|
+
}
|
|
34
|
+
postMessage(s, t) {
|
|
35
|
+
e(this, u)[++l(this, c)._] || a(this, c, 0), e(this, u)[e(this, c)].postMessage(s, t);
|
|
36
|
+
}
|
|
37
|
+
addListener(s) {
|
|
38
|
+
e(this, h).push(s);
|
|
39
|
+
}
|
|
40
|
+
removeListener(s) {
|
|
41
|
+
for (const t in e(this, h))
|
|
42
|
+
if (e(this, h)[t] == s) {
|
|
43
|
+
e(this, h).splice(t, 1);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
i = new WeakMap(), c = new WeakMap(), u = new WeakMap(), h = new WeakMap(), d = new WeakSet(), y = function(s) {
|
|
49
|
+
const t = new s();
|
|
50
|
+
t.onmessage = async (o) => {
|
|
51
|
+
const f = [];
|
|
52
|
+
for (const w of e(this, h))
|
|
53
|
+
f.push(w(o));
|
|
54
|
+
(await Promise.all(f)).forEach((w) => {
|
|
55
|
+
w && t.postMessage(w);
|
|
56
|
+
});
|
|
57
|
+
}, e(this, u).push(t);
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
v as w
|
|
61
|
+
};
|