template-replacement 3.2.1 → 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 +791 -771
- package/dist/main/sign.js +797 -777
- package/dist/replace/general.js +1 -1
- package/dist/replace/sign.js +1 -1
- package/index.ts +14 -2
- package/package.json +1 -1
- package/dist/base-Bcdx0Hdl.js +0 -217
- package/dist/index-BmnvEKaL.js +0 -46
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
var m = (n) => {
|
|
2
|
+
throw TypeError(n);
|
|
3
|
+
};
|
|
4
|
+
var f = (n, e, t) => e.has(n) || m("Cannot " + t);
|
|
5
|
+
var c = (n, e, t) => (f(n, e, "read from private field"), t ? t.call(n) : e.get(n)), _ = (n, e, t) => e.has(n) ? m("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), y = (n, e, t, s) => (f(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
|
|
6
|
+
class p {
|
|
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((e, t) => {
|
|
14
|
+
const s = indexedDB.open(this._dbName, this._dbversion);
|
|
15
|
+
s.onsuccess = (a) => {
|
|
16
|
+
if (this._db = s.result, this._isInitFinish = !0, this._initFinishCallBackFuns) {
|
|
17
|
+
try {
|
|
18
|
+
for (const i of this._initFinishCallBackFuns)
|
|
19
|
+
i();
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
this._initFinishCallBackFuns = void 0;
|
|
23
|
+
}
|
|
24
|
+
e(a);
|
|
25
|
+
}, s.onerror = (a) => {
|
|
26
|
+
console.error(a), t(a);
|
|
27
|
+
}, s.onupgradeneeded = (a) => {
|
|
28
|
+
let i = s.result;
|
|
29
|
+
i.objectStoreNames.contains(this._cacheTableName) || i.createObjectStore(this._cacheTableName, {
|
|
30
|
+
keyPath: "url"
|
|
31
|
+
// 设置主键
|
|
32
|
+
}), e(a);
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async awaitInit() {
|
|
37
|
+
this._isInitFinish || !this._initFinishCallBackFuns || await new Promise((e, t) => {
|
|
38
|
+
var s;
|
|
39
|
+
(s = this._initFinishCallBackFuns) == null || s.push(e);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
closeDB() {
|
|
43
|
+
var e;
|
|
44
|
+
(e = this._db) == null || e.close();
|
|
45
|
+
}
|
|
46
|
+
async store(e) {
|
|
47
|
+
return await this.awaitInit(), this._db.transaction(this._cacheTableName, e).objectStore(this._cacheTableName);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @description : 更新数据
|
|
51
|
+
* @param {Object} params 添加到数据库中的数据 { url: 文件地址, data: 文件blob }
|
|
52
|
+
* @return {*}
|
|
53
|
+
*/
|
|
54
|
+
putData(e) {
|
|
55
|
+
return new Promise(async (t, s) => {
|
|
56
|
+
const a = (await this.store("readwrite")).put(e);
|
|
57
|
+
a.onsuccess = (i) => {
|
|
58
|
+
t(i);
|
|
59
|
+
}, a.onerror = (i) => {
|
|
60
|
+
s(i);
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// 通过主键读取数据
|
|
65
|
+
getDataByKey(e) {
|
|
66
|
+
return new Promise(async (t, s) => {
|
|
67
|
+
const a = (await this.store()).get(e);
|
|
68
|
+
a.onsuccess = () => {
|
|
69
|
+
t(a.result);
|
|
70
|
+
}, a.onerror = (i) => {
|
|
71
|
+
s(i);
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// 通过主键移除数据
|
|
76
|
+
deleteDataByKey(e) {
|
|
77
|
+
return new Promise(async (t, s) => {
|
|
78
|
+
const a = (await this.store()).delete(e);
|
|
79
|
+
a.onsuccess = () => {
|
|
80
|
+
t();
|
|
81
|
+
}, a.onerror = (i) => {
|
|
82
|
+
s(i);
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// 清空数据库数据
|
|
87
|
+
clearDB() {
|
|
88
|
+
return new Promise(async (e, t) => {
|
|
89
|
+
const s = (await this.store("readwrite")).clear();
|
|
90
|
+
s.onsuccess = (a) => {
|
|
91
|
+
e(a);
|
|
92
|
+
}, s.onerror = (a) => {
|
|
93
|
+
t(a);
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
new p();
|
|
99
|
+
var w = /* @__PURE__ */ ((n) => (n.word = "word", n.excel = "excel", n.unknown = "unknown", n))(w || {}), h, u;
|
|
100
|
+
class D {
|
|
101
|
+
constructor(e) {
|
|
102
|
+
_(this, h, []);
|
|
103
|
+
_(this, u);
|
|
104
|
+
y(this, u, e);
|
|
105
|
+
}
|
|
106
|
+
addTempFile(e) {
|
|
107
|
+
c(this, h).push(e);
|
|
108
|
+
}
|
|
109
|
+
clear() {
|
|
110
|
+
c(this, h).length = 0;
|
|
111
|
+
}
|
|
112
|
+
async extractVariables(e) {
|
|
113
|
+
e || (e = c(this, h));
|
|
114
|
+
const t = {}, s = [];
|
|
115
|
+
for (const a of e)
|
|
116
|
+
s.push(new Promise(async (i, r) => {
|
|
117
|
+
const o = await a.getBuffer();
|
|
118
|
+
o && (a.isDecode || await a.type() !== w.unknown) && (t[a.name] = await c(this, u).extract_one_file_variable_names(o, a.isDecode)), i();
|
|
119
|
+
}));
|
|
120
|
+
return await Promise.all(s), t;
|
|
121
|
+
}
|
|
122
|
+
async extractMedias(e) {
|
|
123
|
+
e || (e = c(this, h));
|
|
124
|
+
const t = {}, s = [];
|
|
125
|
+
for (const a of e)
|
|
126
|
+
s.push(new Promise(async (i, r) => {
|
|
127
|
+
const o = await a.getBuffer();
|
|
128
|
+
if (o && (a.isDecode || await a.type() !== w.unknown)) {
|
|
129
|
+
let l = await c(this, u).extract_one_file_medias(o, a.isDecode);
|
|
130
|
+
t[a.name] = [], l && Array.isArray(l) && l.forEach((d) => {
|
|
131
|
+
d.id && d.data && t[a.name].push({
|
|
132
|
+
id: d.id,
|
|
133
|
+
data: new Uint8Array(d.data)
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
i();
|
|
138
|
+
}));
|
|
139
|
+
return await Promise.all(s), t;
|
|
140
|
+
}
|
|
141
|
+
async handle(e, t, s = !1) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
async sign(e) {
|
|
145
|
+
return "";
|
|
146
|
+
}
|
|
147
|
+
async execute(e, t) {
|
|
148
|
+
t || (t = c(this, h));
|
|
149
|
+
const s = [];
|
|
150
|
+
for (const r of t)
|
|
151
|
+
s.push(r.getBuffer());
|
|
152
|
+
await Promise.all(s);
|
|
153
|
+
const a = {
|
|
154
|
+
//需要解密的文件
|
|
155
|
+
decode: {
|
|
156
|
+
names: [],
|
|
157
|
+
uint8Arrays: []
|
|
158
|
+
},
|
|
159
|
+
//不需要解密的文件
|
|
160
|
+
noDecode: {
|
|
161
|
+
names: [],
|
|
162
|
+
uint8Arrays: []
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
for (const r of t)
|
|
166
|
+
r.uint8Array && (r.isDecode ? (a.decode.names.push(r.name), a.decode.uint8Arrays.push(r.uint8Array)) : (a.noDecode.names.push(r.name), a.noDecode.uint8Arrays.push(r.uint8Array)));
|
|
167
|
+
const i = await Promise.all([
|
|
168
|
+
this._execute(e, a.noDecode.names, a.noDecode.uint8Arrays, !1),
|
|
169
|
+
this._execute(e, a.decode.names, a.decode.uint8Arrays, !0)
|
|
170
|
+
]);
|
|
171
|
+
return {
|
|
172
|
+
...i[0],
|
|
173
|
+
...i[1]
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
async _execute(e, t, s, a = !1) {
|
|
177
|
+
const i = {};
|
|
178
|
+
return s.length && (await this.handle(e, s, a)).forEach((o, l) => {
|
|
179
|
+
o.length && (i[t[l]] = o);
|
|
180
|
+
}), i;
|
|
181
|
+
}
|
|
182
|
+
async fileEncrypt(e) {
|
|
183
|
+
return await c(this, u).file_encrypt(e);
|
|
184
|
+
}
|
|
185
|
+
async filesEncrypt(e) {
|
|
186
|
+
return await c(this, u).files_encrypt(e);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
h = new WeakMap(), u = new WeakMap();
|
|
190
|
+
class x {
|
|
191
|
+
constructor(e, t) {
|
|
192
|
+
this.awaitInit = e, this.module = t;
|
|
193
|
+
}
|
|
194
|
+
async await() {
|
|
195
|
+
return await this.awaitInit, this;
|
|
196
|
+
}
|
|
197
|
+
async add_template(e, t) {
|
|
198
|
+
return await this.awaitInit, this.module.add_template(e, t);
|
|
199
|
+
}
|
|
200
|
+
async add_media(e) {
|
|
201
|
+
return await this.awaitInit, this.module.add_media(e);
|
|
202
|
+
}
|
|
203
|
+
async extract_one_file_variable_names(e, t) {
|
|
204
|
+
return await this.awaitInit, this.module.extract_one_file_variable_names(e, t);
|
|
205
|
+
}
|
|
206
|
+
async extract_variable_names(e, t) {
|
|
207
|
+
return await this.awaitInit, this.module.extract_variable_names(e, t);
|
|
208
|
+
}
|
|
209
|
+
async extract_one_file_medias(e, t) {
|
|
210
|
+
return await this.awaitInit, this.module.extract_one_file_medias(e, t);
|
|
211
|
+
}
|
|
212
|
+
async extract_medias(e, t) {
|
|
213
|
+
return await this.awaitInit, this.module.extract_medias(e, t);
|
|
214
|
+
}
|
|
215
|
+
async file_encrypt(e) {
|
|
216
|
+
return await this.awaitInit, this.module.file_encrypt(e);
|
|
217
|
+
}
|
|
218
|
+
async files_encrypt(e) {
|
|
219
|
+
return await this.awaitInit, this.module.files_encrypt(e);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
export {
|
|
223
|
+
D as B,
|
|
224
|
+
x as b
|
|
225
|
+
};
|
|
@@ -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
|
+
};
|