template-replacement 3.2.0 → 3.2.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/dist/base-DIR-qpD-.js +225 -0
- package/dist/index-BkwrGCka.js +61 -0
- package/dist/main/general.js +4686 -15
- package/dist/main/sign.js +4708 -15
- package/dist/replace/general.js +384 -337
- package/dist/replace/sign.js +384 -339
- package/index.ts +14 -2
- package/package.json +1 -2
- package/vite.config.ts +0 -12
- package/dist/base-dj-SYiQI.js +0 -193
- package/dist/index-BlAsmv2Q.js +0 -62
package/index.ts
CHANGED
|
@@ -23,9 +23,21 @@ export function WorkerSign(concurrency?: number): ReplaceInterface {
|
|
|
23
23
|
type signFun = (data: any) => Promise<string>;
|
|
24
24
|
|
|
25
25
|
export default (concurrency?: number, signFn?: signFun): ReplaceInterface => {
|
|
26
|
+
let res = undefined
|
|
26
27
|
if (concurrency) {
|
|
27
|
-
|
|
28
|
+
if (signFn) {
|
|
29
|
+
res = workerSign(concurrency)
|
|
30
|
+
res.sign = signFn
|
|
31
|
+
}else{
|
|
32
|
+
res = workerGeneral(concurrency)
|
|
33
|
+
}
|
|
28
34
|
}else {
|
|
29
|
-
|
|
35
|
+
if (signFn) {
|
|
36
|
+
res = sign()
|
|
37
|
+
res.sign = signFn
|
|
38
|
+
}else{
|
|
39
|
+
res = general()
|
|
40
|
+
}
|
|
30
41
|
}
|
|
42
|
+
return res
|
|
31
43
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "template-replacement",
|
|
3
3
|
"description": "模板文件替换",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.2",
|
|
5
5
|
"author": "fushiliang <994301536@qq.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "index.ts",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"axios": "^1.10.0",
|
|
14
14
|
"fflate": "^0.8.2",
|
|
15
15
|
"file-type": "^19.6.0",
|
|
16
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
17
16
|
"streamsaver": "^2.0.6",
|
|
18
17
|
"template-replacement-core-wasm": "^1.1.1",
|
|
19
18
|
"template-replacement-sign-core-wasm": "^1.1.1",
|
package/vite.config.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
2
|
import wasmPack from 'vite-plugin-wasm-pack';
|
|
3
3
|
import dts from 'vite-plugin-dts';
|
|
4
|
-
import { terser } from 'rollup-plugin-terser';
|
|
5
4
|
|
|
6
5
|
export default defineConfig({
|
|
7
6
|
plugins: [
|
|
@@ -19,18 +18,7 @@ export default defineConfig({
|
|
|
19
18
|
fileName: (format, entryName) => `${entryName}.js`,
|
|
20
19
|
formats: ['es'],
|
|
21
20
|
},
|
|
22
|
-
minify:"terser",
|
|
23
21
|
rollupOptions: {
|
|
24
|
-
plugins: [terser({
|
|
25
|
-
format: {
|
|
26
|
-
// 取消代码注释
|
|
27
|
-
comments: false,
|
|
28
|
-
},
|
|
29
|
-
mangle: {
|
|
30
|
-
keep_classnames: false,
|
|
31
|
-
reserved: [],
|
|
32
|
-
},
|
|
33
|
-
})],
|
|
34
22
|
output: {
|
|
35
23
|
entryFileNames: (info: { facadeModuleId: string; }) => {
|
|
36
24
|
const modules = info.facadeModuleId?.split('/')
|
package/dist/base-dj-SYiQI.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
var __typeError = (msg) => {
|
|
2
|
-
throw TypeError(msg);
|
|
3
|
-
};
|
|
4
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
-
var _e, _t;
|
|
9
|
-
new class {
|
|
10
|
-
constructor() {
|
|
11
|
-
this._initFinishCallBackFuns = [], this._isInitFinish = false, this._dbName = "template_replacement", this._dbversion = 1, this._cacheTableName = "templates", this._tableMap = {}, this.initDB();
|
|
12
|
-
}
|
|
13
|
-
initDB() {
|
|
14
|
-
return new Promise((e2, t2) => {
|
|
15
|
-
const a2 = indexedDB.open(this._dbName, this._dbversion);
|
|
16
|
-
a2.onsuccess = (t3) => {
|
|
17
|
-
if (this._db = a2.result, this._isInitFinish = true, this._initFinishCallBackFuns) {
|
|
18
|
-
try {
|
|
19
|
-
for (const e3 of this._initFinishCallBackFuns) e3();
|
|
20
|
-
} catch (e3) {
|
|
21
|
-
}
|
|
22
|
-
this._initFinishCallBackFuns = void 0;
|
|
23
|
-
}
|
|
24
|
-
e2(t3);
|
|
25
|
-
}, a2.onerror = (e3) => {
|
|
26
|
-
console.error(e3), t2(e3);
|
|
27
|
-
}, a2.onupgradeneeded = (t3) => {
|
|
28
|
-
let i = a2.result;
|
|
29
|
-
i.objectStoreNames.contains(this._cacheTableName) || i.createObjectStore(this._cacheTableName, { keyPath: "url" }), e2(t3);
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
async awaitInit() {
|
|
34
|
-
!this._isInitFinish && this._initFinishCallBackFuns && await new Promise((e2, t2) => {
|
|
35
|
-
var _a;
|
|
36
|
-
(_a = this._initFinishCallBackFuns) == null ? void 0 : _a.push(e2);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
closeDB() {
|
|
40
|
-
var _a;
|
|
41
|
-
(_a = this._db) == null ? void 0 : _a.close();
|
|
42
|
-
}
|
|
43
|
-
async store(e2) {
|
|
44
|
-
await this.awaitInit();
|
|
45
|
-
return this._db.transaction(this._cacheTableName, e2).objectStore(this._cacheTableName);
|
|
46
|
-
}
|
|
47
|
-
putData(e2) {
|
|
48
|
-
return new Promise(async (t2, a2) => {
|
|
49
|
-
const i = (await this.store("readwrite")).put(e2);
|
|
50
|
-
i.onsuccess = (e3) => {
|
|
51
|
-
t2(e3);
|
|
52
|
-
}, i.onerror = (e3) => {
|
|
53
|
-
a2(e3);
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
getDataByKey(e2) {
|
|
58
|
-
return new Promise(async (t2, a2) => {
|
|
59
|
-
const i = (await this.store()).get(e2);
|
|
60
|
-
i.onsuccess = () => {
|
|
61
|
-
t2(i.result);
|
|
62
|
-
}, i.onerror = (e3) => {
|
|
63
|
-
a2(e3);
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
deleteDataByKey(e2) {
|
|
68
|
-
return new Promise(async (t2, a2) => {
|
|
69
|
-
const i = (await this.store()).delete(e2);
|
|
70
|
-
i.onsuccess = () => {
|
|
71
|
-
t2();
|
|
72
|
-
}, i.onerror = (e3) => {
|
|
73
|
-
a2(e3);
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
clearDB() {
|
|
78
|
-
return new Promise(async (e2, t2) => {
|
|
79
|
-
const a2 = (await this.store("readwrite")).clear();
|
|
80
|
-
a2.onsuccess = (t3) => {
|
|
81
|
-
e2(t3);
|
|
82
|
-
}, a2.onerror = (e3) => {
|
|
83
|
-
t2(e3);
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}();
|
|
88
|
-
var e = ((e2) => (e2.word = "word", e2.excel = "excel", e2.unknown = "unknown", e2))(e || {});
|
|
89
|
-
class t {
|
|
90
|
-
constructor(e2) {
|
|
91
|
-
__privateAdd(this, _e, []);
|
|
92
|
-
__privateAdd(this, _t);
|
|
93
|
-
__privateSet(this, _t, e2);
|
|
94
|
-
}
|
|
95
|
-
addTempFile(e2) {
|
|
96
|
-
__privateGet(this, _e).push(e2);
|
|
97
|
-
}
|
|
98
|
-
clear() {
|
|
99
|
-
__privateGet(this, _e).length = 0;
|
|
100
|
-
}
|
|
101
|
-
async extractVariables(t2) {
|
|
102
|
-
t2 || (t2 = __privateGet(this, _e));
|
|
103
|
-
const a2 = {}, i = [];
|
|
104
|
-
for (const s of t2) i.push(new Promise(async (t3, i2) => {
|
|
105
|
-
const n = await s.getBuffer();
|
|
106
|
-
n && (s.isDecode || await s.type() !== e.unknown) && (a2[s.name] = await __privateGet(this, _t).extract_one_file_variable_names(n, s.isDecode)), t3();
|
|
107
|
-
}));
|
|
108
|
-
return await Promise.all(i), a2;
|
|
109
|
-
}
|
|
110
|
-
async extractMedias(t2) {
|
|
111
|
-
t2 || (t2 = __privateGet(this, _e));
|
|
112
|
-
const a2 = {}, i = [];
|
|
113
|
-
for (const s of t2) i.push(new Promise(async (t3, i2) => {
|
|
114
|
-
const n = await s.getBuffer();
|
|
115
|
-
if (n && (s.isDecode || await s.type() !== e.unknown)) {
|
|
116
|
-
let e2 = await __privateGet(this, _t).extract_one_file_medias(n, s.isDecode);
|
|
117
|
-
a2[s.name] = [], e2 && Array.isArray(e2) && e2.forEach((e3) => {
|
|
118
|
-
e3.id && e3.data && a2[s.name].push({ id: e3.id, data: new Uint8Array(e3.data) });
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
t3();
|
|
122
|
-
}));
|
|
123
|
-
return await Promise.all(i), a2;
|
|
124
|
-
}
|
|
125
|
-
async handle(e2, t2, a2 = false) {
|
|
126
|
-
return [];
|
|
127
|
-
}
|
|
128
|
-
async sign(e2) {
|
|
129
|
-
return "";
|
|
130
|
-
}
|
|
131
|
-
async execute(e2, t2) {
|
|
132
|
-
t2 || (t2 = __privateGet(this, _e));
|
|
133
|
-
const a2 = [];
|
|
134
|
-
for (const e3 of t2) a2.push(e3.getBuffer());
|
|
135
|
-
await Promise.all(a2);
|
|
136
|
-
const i = { decode: { names: [], uint8Arrays: [] }, noDecode: { names: [], uint8Arrays: [] } };
|
|
137
|
-
for (const e3 of t2) e3.uint8Array && (e3.isDecode ? (i.decode.names.push(e3.name), i.decode.uint8Arrays.push(e3.uint8Array)) : (i.noDecode.names.push(e3.name), i.noDecode.uint8Arrays.push(e3.uint8Array)));
|
|
138
|
-
const s = await Promise.all([this._execute(e2, i.noDecode.names, i.noDecode.uint8Arrays, false), this._execute(e2, i.decode.names, i.decode.uint8Arrays, true)]);
|
|
139
|
-
return { ...s[0], ...s[1] };
|
|
140
|
-
}
|
|
141
|
-
async _execute(e2, t2, a2, i = false) {
|
|
142
|
-
const s = {};
|
|
143
|
-
if (!a2.length) return s;
|
|
144
|
-
return (await this.handle(e2, a2, i)).forEach((e3, a3) => {
|
|
145
|
-
e3.length && (s[t2[a3]] = e3);
|
|
146
|
-
}), s;
|
|
147
|
-
}
|
|
148
|
-
async fileEncrypt(e2) {
|
|
149
|
-
return await __privateGet(this, _t).file_encrypt(e2);
|
|
150
|
-
}
|
|
151
|
-
async filesEncrypt(e2) {
|
|
152
|
-
return await __privateGet(this, _t).files_encrypt(e2);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
_e = new WeakMap();
|
|
156
|
-
_t = new WeakMap();
|
|
157
|
-
class a {
|
|
158
|
-
constructor(e2, t2) {
|
|
159
|
-
this.awaitInit = e2, this.module = t2;
|
|
160
|
-
}
|
|
161
|
-
async await() {
|
|
162
|
-
return await this.awaitInit, this;
|
|
163
|
-
}
|
|
164
|
-
async add_template(e2, t2) {
|
|
165
|
-
return await this.awaitInit, this.module.add_template(e2, t2);
|
|
166
|
-
}
|
|
167
|
-
async add_media(e2) {
|
|
168
|
-
return await this.awaitInit, this.module.add_media(e2);
|
|
169
|
-
}
|
|
170
|
-
async extract_one_file_variable_names(e2, t2) {
|
|
171
|
-
return await this.awaitInit, this.module.extract_one_file_variable_names(e2, t2);
|
|
172
|
-
}
|
|
173
|
-
async extract_variable_names(e2, t2) {
|
|
174
|
-
return await this.awaitInit, this.module.extract_variable_names(e2, t2);
|
|
175
|
-
}
|
|
176
|
-
async extract_one_file_medias(e2, t2) {
|
|
177
|
-
return await this.awaitInit, this.module.extract_one_file_medias(e2, t2);
|
|
178
|
-
}
|
|
179
|
-
async extract_medias(e2, t2) {
|
|
180
|
-
return await this.awaitInit, this.module.extract_medias(e2, t2);
|
|
181
|
-
}
|
|
182
|
-
async file_encrypt(e2) {
|
|
183
|
-
return await this.awaitInit, this.module.file_encrypt(e2);
|
|
184
|
-
}
|
|
185
|
-
async files_encrypt(e2) {
|
|
186
|
-
await this.awaitInit;
|
|
187
|
-
return this.module.files_encrypt(e2);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
export {
|
|
191
|
-
t as B,
|
|
192
|
-
a as b
|
|
193
|
-
};
|
package/dist/index-BlAsmv2Q.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
var __typeError = (msg) => {
|
|
2
|
-
throw TypeError(msg);
|
|
3
|
-
};
|
|
4
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
10
|
-
set _(value) {
|
|
11
|
-
__privateSet(obj, member, value, setter);
|
|
12
|
-
},
|
|
13
|
-
get _() {
|
|
14
|
-
return __privateGet(obj, member, getter);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
var _r, _s, _e, _t, _r_instances, c_fn;
|
|
18
|
-
class r {
|
|
19
|
-
constructor(r2, s) {
|
|
20
|
-
__privateAdd(this, _r_instances);
|
|
21
|
-
__privateAdd(this, _r);
|
|
22
|
-
__privateAdd(this, _s, 0);
|
|
23
|
-
__privateAdd(this, _e, []);
|
|
24
|
-
__privateAdd(this, _t, []);
|
|
25
|
-
if (__privateSet(this, _r, Number(s)), !__privateGet(this, _r) || __privateGet(this, _r) < 1) try {
|
|
26
|
-
__privateSet(this, _r, navigator.hardwareConcurrency < 8 ? navigator.hardwareConcurrency : 8);
|
|
27
|
-
} catch (r3) {
|
|
28
|
-
}
|
|
29
|
-
(!__privateGet(this, _r) || __privateGet(this, _r) < 1) && __privateSet(this, _r, 1);
|
|
30
|
-
for (let s2 = 0; s2 < __privateGet(this, _r); s2++) __privateMethod(this, _r_instances, c_fn).call(this, r2);
|
|
31
|
-
}
|
|
32
|
-
concurrency() {
|
|
33
|
-
return __privateGet(this, _r);
|
|
34
|
-
}
|
|
35
|
-
postMessage(r2, s) {
|
|
36
|
-
__privateGet(this, _e)[++__privateWrapper(this, _s)._] || __privateSet(this, _s, 0), __privateGet(this, _e)[__privateGet(this, _s)].postMessage(r2, s);
|
|
37
|
-
}
|
|
38
|
-
addListener(r2) {
|
|
39
|
-
__privateGet(this, _t).push(r2);
|
|
40
|
-
}
|
|
41
|
-
removeListener(r2) {
|
|
42
|
-
for (const s in __privateGet(this, _t)) if (__privateGet(this, _t)[s] == r2) return void __privateGet(this, _t).splice(s, 1);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
_r = new WeakMap();
|
|
46
|
-
_s = new WeakMap();
|
|
47
|
-
_e = new WeakMap();
|
|
48
|
-
_t = new WeakMap();
|
|
49
|
-
_r_instances = new WeakSet();
|
|
50
|
-
c_fn = function(r2) {
|
|
51
|
-
const s = new r2();
|
|
52
|
-
s.onmessage = async (r3) => {
|
|
53
|
-
const e = [];
|
|
54
|
-
for (const s2 of __privateGet(this, _t)) e.push(s2(r3));
|
|
55
|
-
(await Promise.all(e)).forEach((r4) => {
|
|
56
|
-
r4 && s.postMessage(r4);
|
|
57
|
-
});
|
|
58
|
-
}, __privateGet(this, _e).push(s);
|
|
59
|
-
};
|
|
60
|
-
export {
|
|
61
|
-
r as w
|
|
62
|
-
};
|