adnbn 0.2.2 → 0.2.3
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/{AbstractBuilder-CKgY_Bta.d.ts → AbstractBuilder-BN4TmNJG.d.ts} +3 -3
- package/dist/{AbstractBuilder-Ce5zNRXr.d.mts → AbstractBuilder-C81kWZzQ.d.mts} +3 -3
- package/dist/{BaseTransport-C7uEgfUu.d.mts → BaseTransport-DNZ28gFF.d.mts} +1 -1
- package/dist/{BaseTransport-BdFTZfP0.d.ts → BaseTransport-Ecy2Kzti.d.ts} +1 -1
- package/dist/{Builder-FwJAxWos.d.ts → Builder-BOLvGGqp.d.ts} +2 -2
- package/dist/{Builder-rW3fzusy.d.mts → Builder-BP8SDHO1.d.mts} +2 -2
- package/dist/{Builder-7pbnGvHK.d.ts → Builder-Bc8US0PY.d.ts} +1 -1
- package/dist/{Builder-CCyBD4hF.d.mts → Builder-Df1LUO_f.d.mts} +1 -1
- package/dist/{Message-1cYgMdsu.d.mts → Message-Bnritk3D.d.mts} +1 -1
- package/dist/{Message-DAhczRx9.d.ts → Message-DFDaS7mV.d.ts} +1 -1
- package/dist/{MountBuilder-DjnAmTI0.d.ts → MountBuilder-BTltgVF2.d.mts} +26 -7
- package/dist/{MountBuilder-CjvMOcmn.d.mts → MountBuilder-C9Q-7PeI.d.ts} +26 -7
- package/dist/{ProxyRelay-Ce-szh9p.d.ts → ProxyRelay-DDOSZE3h.d.ts} +3 -3
- package/dist/{ProxyRelay-BOBEhRET.d.mts → ProxyRelay-Uel0ATcx.d.mts} +3 -3
- package/dist/{ProxyTransport-BTVUbDxE.d.mts → ProxyTransport-35rU8xqa.d.mts} +3 -3
- package/dist/{ProxyTransport-BW63K6SU.d.ts → ProxyTransport-D4jv5SFh.d.ts} +3 -3
- package/dist/{RegisterOffscreen-BukckdvS.d.mts → RegisterOffscreen-DT0gN5xN.d.mts} +2 -2
- package/dist/{RegisterOffscreen-DmlpLqjW.d.ts → RegisterOffscreen-df3W5HqA.d.ts} +2 -2
- package/dist/{RegisterRelay-MEVSR1sP.d.mts → RegisterRelay-DCVZ2_NI.d.mts} +2 -2
- package/dist/{RegisterRelay-BaIET78I.d.ts → RegisterRelay-PFT2ac4v.d.ts} +2 -2
- package/dist/{TransportMessage-Bk0wg4rF.d.mts → TransportMessage-CIKrv3DG.d.mts} +8 -4
- package/dist/{TransportMessage-BqMzXWZR.d.ts → TransportMessage-CsObvTPq.d.ts} +8 -4
- package/dist/{background-Zjiqg60g.d.ts → background-CpVjDFHQ.d.ts} +1 -1
- package/dist/{background-CyGGjmBx.d.mts → background-cxLBji1Q.d.mts} +1 -1
- package/dist/cli/index.cjs +45 -14
- package/dist/cli/index.cjs.map +1 -1
- package/dist/{command-BFsdm7Bx.d.mts → command-S2dcqx6Q.d.mts} +4 -3
- package/dist/{command-3i_5d__K.d.ts → command-TJ2JUrVd.d.ts} +4 -3
- package/dist/{content-sdYF4W-A.d.ts → content-B0znLIjr.d.ts} +37 -4
- package/dist/{content-BYoXVO6V.d.mts → content-DrrPH4ri.d.mts} +37 -4
- package/dist/entry/background/index.d.mts +2 -2
- package/dist/entry/background/index.d.ts +2 -2
- package/dist/entry/command/index.d.mts +3 -3
- package/dist/entry/command/index.d.ts +3 -3
- package/dist/entry/content/index.d.mts +2 -2
- package/dist/entry/content/index.d.ts +2 -2
- package/dist/entry/content/react/index.cjs +104 -18
- package/dist/entry/content/react/index.cjs.map +1 -1
- package/dist/entry/content/react/index.d.mts +4 -4
- package/dist/entry/content/react/index.d.ts +4 -4
- package/dist/entry/content/react/index.js +104 -18
- package/dist/entry/content/react/index.js.map +1 -1
- package/dist/entry/content/vanilla/index.cjs +108 -18
- package/dist/entry/content/vanilla/index.cjs.map +1 -1
- package/dist/entry/content/vanilla/index.d.mts +4 -4
- package/dist/entry/content/vanilla/index.d.ts +4 -4
- package/dist/entry/content/vanilla/index.js +108 -18
- package/dist/entry/content/vanilla/index.js.map +1 -1
- package/dist/entry/offscreen/index.cjs +27 -4
- package/dist/entry/offscreen/index.cjs.map +1 -1
- package/dist/entry/offscreen/index.d.mts +11 -9
- package/dist/entry/offscreen/index.d.ts +11 -9
- package/dist/entry/offscreen/index.js +27 -4
- package/dist/entry/offscreen/index.js.map +1 -1
- package/dist/entry/relay/index.d.mts +9 -8
- package/dist/entry/relay/index.d.ts +9 -8
- package/dist/entry/service/index.cjs +31 -10
- package/dist/entry/service/index.cjs.map +1 -1
- package/dist/entry/service/index.d.mts +5 -4
- package/dist/entry/service/index.d.ts +5 -4
- package/dist/entry/service/index.js +31 -10
- package/dist/entry/service/index.js.map +1 -1
- package/dist/entry/transport/index.d.mts +8 -7
- package/dist/entry/transport/index.d.ts +8 -7
- package/dist/entry/view/index.d.mts +2 -2
- package/dist/entry/view/index.d.ts +2 -2
- package/dist/entry/view/react/index.d.mts +4 -4
- package/dist/entry/view/react/index.d.ts +4 -4
- package/dist/entry/view/vanilla/index.d.mts +4 -4
- package/dist/entry/view/vanilla/index.d.ts +4 -4
- package/dist/{helpers-DnV3N7fU.d.mts → helpers-YDFORuZz.d.mts} +2 -2
- package/dist/{helpers-DnV3N7fU.d.ts → helpers-YDFORuZz.d.ts} +2 -2
- package/dist/index.cjs +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +63 -22
- package/dist/index.d.ts +63 -22
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/message/index.cjs.map +1 -1
- package/dist/message/index.d.mts +4 -3
- package/dist/message/index.d.ts +4 -3
- package/dist/message/index.js.map +1 -1
- package/dist/message/react/index.cjs.map +1 -1
- package/dist/message/react/index.d.mts +1 -1
- package/dist/message/react/index.d.ts +1 -1
- package/dist/message/react/index.js.map +1 -1
- package/dist/{message-55r-wFjc.d.mts → message-jsmkeGHC.d.mts} +5 -1
- package/dist/{message-55r-wFjc.d.ts → message-jsmkeGHC.d.ts} +5 -1
- package/dist/offscreen/index.cjs +30 -5
- package/dist/offscreen/index.cjs.map +1 -1
- package/dist/offscreen/index.d.mts +10 -9
- package/dist/offscreen/index.d.ts +10 -9
- package/dist/offscreen/index.js +30 -5
- package/dist/offscreen/index.js.map +1 -1
- package/dist/{offscreen-B9GiglgN.d.mts → offscreen-2EP-rRfx.d.mts} +3 -3
- package/dist/{offscreen-BG5Abe8V.d.ts → offscreen-aHdkogKj.d.ts} +3 -3
- package/dist/relay/index.d.mts +8 -7
- package/dist/relay/index.d.ts +8 -7
- package/dist/{relay-DymeeDe7.d.ts → relay-DT46Ltms.d.ts} +3 -3
- package/dist/{relay-BYeTCwKO.d.mts → relay-vaJ5R2iC.d.mts} +3 -3
- package/dist/service/index.cjs +27 -4
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +8 -6
- package/dist/service/index.d.ts +8 -6
- package/dist/service/index.js +27 -4
- package/dist/service/index.js.map +1 -1
- package/dist/{service-BhJhIk-O.d.ts → service-6FdoYGNC.d.ts} +3 -3
- package/dist/{service-DsivypLQ.d.mts → service-C9HbDQPE.d.mts} +3 -3
- package/dist/{transport-B_uYwoGi.d.mts → transport-BrbirhXv.d.mts} +3 -2
- package/dist/{transport-BPmSUoEU.d.ts → transport-Co9Oxp0-.d.ts} +3 -2
- package/dist/{view-QDP2Maev.d.mts → view-Bs26Jcvi.d.mts} +1 -1
- package/dist/{view-D4dquvKl.d.ts → view-u9w7nMgw.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as ContentScriptDefinition, c as ContentScriptNode } from '../../../content-
|
|
2
|
-
import { e as export_default$1 } from '../../../MountBuilder-
|
|
1
|
+
import { a as ContentScriptDefinition, c as ContentScriptNode } from '../../../content-B0znLIjr.js';
|
|
2
|
+
import { e as export_default$1 } from '../../../MountBuilder-C9Q-7PeI.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'utility-types';
|
|
5
|
-
import '../../../helpers-
|
|
6
|
-
import '../../../Builder-
|
|
5
|
+
import '../../../helpers-YDFORuZz.js';
|
|
6
|
+
import '../../../Builder-Bc8US0PY.js';
|
|
7
7
|
|
|
8
8
|
declare class export_default extends export_default$1 {
|
|
9
9
|
constructor(definition: ContentScriptDefinition);
|
|
@@ -68,11 +68,7 @@ var contentScriptAnchorResolver = (anchor) => async () => {
|
|
|
68
68
|
}
|
|
69
69
|
} else if (typeof resolved === "string") {
|
|
70
70
|
if (resolved.startsWith("/")) {
|
|
71
|
-
|
|
72
|
-
const condition = `not(@${attr})`;
|
|
73
|
-
if (notRegex.test(resolved)) {
|
|
74
|
-
resolved = `(${resolved})[${condition}]`;
|
|
75
|
-
}
|
|
71
|
+
resolved = `(${resolved})[not(@${attr})]`;
|
|
76
72
|
const result = document.evaluate(
|
|
77
73
|
resolved,
|
|
78
74
|
document,
|
|
@@ -167,6 +163,9 @@ var contentScriptLocationResolver = (strategy) => (update, context) => {
|
|
|
167
163
|
|
|
168
164
|
// src/entry/content/core/Context.ts
|
|
169
165
|
var Context_default = class {
|
|
166
|
+
constructor(emitter) {
|
|
167
|
+
this.emitter = emitter;
|
|
168
|
+
}
|
|
170
169
|
collection = /* @__PURE__ */ new Set();
|
|
171
170
|
get nodes() {
|
|
172
171
|
return this.collection;
|
|
@@ -176,6 +175,7 @@ var Context_default = class {
|
|
|
176
175
|
if (!node.anchor.isConnected) {
|
|
177
176
|
node.unmount();
|
|
178
177
|
this.collection.delete(node);
|
|
178
|
+
this.emitter.emitRemove(node);
|
|
179
179
|
continue;
|
|
180
180
|
}
|
|
181
181
|
node.mount();
|
|
@@ -186,23 +186,72 @@ var Context_default = class {
|
|
|
186
186
|
node.unmount();
|
|
187
187
|
if (!node.anchor.isConnected) {
|
|
188
188
|
this.collection.delete(node);
|
|
189
|
+
this.emitter.emitRemove(node);
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
}
|
|
193
|
+
watch(callback) {
|
|
194
|
+
this.emitter.on(callback);
|
|
195
|
+
return () => {
|
|
196
|
+
this.emitter.off(callback);
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
unwatch() {
|
|
200
|
+
this.emitter.removeAllListeners();
|
|
201
|
+
}
|
|
192
202
|
};
|
|
193
203
|
|
|
194
204
|
// src/entry/content/core/ManagedContext.ts
|
|
195
205
|
var ManagedContext_default = class extends Context_default {
|
|
196
206
|
add(node) {
|
|
197
207
|
this.collection.add(node);
|
|
208
|
+
this.emitter.emitAdd(node);
|
|
198
209
|
return this;
|
|
199
210
|
}
|
|
200
211
|
};
|
|
201
212
|
|
|
213
|
+
// src/entry/content/core/EventEmitter.ts
|
|
214
|
+
var EventEmitter_default = class {
|
|
215
|
+
listeners = /* @__PURE__ */ new Set();
|
|
216
|
+
emit(event, node) {
|
|
217
|
+
for (const listener of this.listeners) {
|
|
218
|
+
listener(event, node);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
emitAdd(node) {
|
|
222
|
+
this.emit("add" /* Add */, node);
|
|
223
|
+
}
|
|
224
|
+
emitMount(node) {
|
|
225
|
+
this.emit("mount" /* Mount */, node);
|
|
226
|
+
}
|
|
227
|
+
emitRemove(node) {
|
|
228
|
+
this.emit("remove" /* Remove */, node);
|
|
229
|
+
}
|
|
230
|
+
emitUnmount(node) {
|
|
231
|
+
this.emit("unmount" /* Unmount */, node);
|
|
232
|
+
}
|
|
233
|
+
hasListeners() {
|
|
234
|
+
return this.listenerCount() > 0;
|
|
235
|
+
}
|
|
236
|
+
listenerCount() {
|
|
237
|
+
return this.listeners.size;
|
|
238
|
+
}
|
|
239
|
+
off(callback) {
|
|
240
|
+
this.listeners.delete(callback);
|
|
241
|
+
}
|
|
242
|
+
on(callback) {
|
|
243
|
+
this.listeners.add(callback);
|
|
244
|
+
}
|
|
245
|
+
removeAllListeners() {
|
|
246
|
+
this.listeners.clear();
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
202
250
|
// src/entry/content/core/Builder.ts
|
|
203
251
|
var Builder_default2 = class extends Builder_default {
|
|
204
252
|
definition;
|
|
205
|
-
|
|
253
|
+
emitter = new EventEmitter_default();
|
|
254
|
+
context = new ManagedContext_default(this.emitter);
|
|
206
255
|
unwatch;
|
|
207
256
|
isProcessing = false;
|
|
208
257
|
constructor(definition) {
|
|
@@ -245,6 +294,7 @@ var Builder_default2 = class extends Builder_default {
|
|
|
245
294
|
async build() {
|
|
246
295
|
await this.destroy();
|
|
247
296
|
const { render, main, anchor, container, watch, mount, ...options } = this.definition;
|
|
297
|
+
await (main == null ? void 0 : main(this.context, options));
|
|
248
298
|
if (render !== void 0) {
|
|
249
299
|
await this.processing();
|
|
250
300
|
this.unwatch = watch(() => {
|
|
@@ -253,7 +303,6 @@ var Builder_default2 = class extends Builder_default {
|
|
|
253
303
|
});
|
|
254
304
|
}, this.context);
|
|
255
305
|
}
|
|
256
|
-
await (main == null ? void 0 : main(this.context, options));
|
|
257
306
|
}
|
|
258
307
|
async destroy() {
|
|
259
308
|
var _a;
|
|
@@ -292,14 +341,18 @@ var Node_default = class {
|
|
|
292
341
|
this.mark();
|
|
293
342
|
if (!this.container && this._container) {
|
|
294
343
|
this.container = this._container.cloneNode(false);
|
|
344
|
+
return true;
|
|
295
345
|
}
|
|
346
|
+
return false;
|
|
296
347
|
}
|
|
297
348
|
unmount() {
|
|
298
349
|
this.unmark();
|
|
299
350
|
if (this.container) {
|
|
300
351
|
this.container.remove();
|
|
301
352
|
this.container = void 0;
|
|
353
|
+
return true;
|
|
302
354
|
}
|
|
355
|
+
return false;
|
|
303
356
|
}
|
|
304
357
|
mark() {
|
|
305
358
|
let id = this.anchor.getAttribute(this.attr);
|
|
@@ -327,21 +380,24 @@ var MountNode_default = class {
|
|
|
327
380
|
return this.node.container;
|
|
328
381
|
}
|
|
329
382
|
mount() {
|
|
330
|
-
var _a;
|
|
331
383
|
this.node.mount();
|
|
332
384
|
if (!this.container || this.container.isConnected) {
|
|
333
|
-
return;
|
|
385
|
+
return false;
|
|
334
386
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
387
|
+
if (this.mounter) {
|
|
388
|
+
const unmounting = this.mounter(this.anchor, this.container);
|
|
389
|
+
if (unmounting) {
|
|
390
|
+
this.unmounting = unmounting;
|
|
391
|
+
}
|
|
392
|
+
return true;
|
|
338
393
|
}
|
|
394
|
+
return false;
|
|
339
395
|
}
|
|
340
396
|
unmount() {
|
|
341
397
|
var _a;
|
|
342
398
|
(_a = this.unmounting) == null ? void 0 : _a.call(this);
|
|
343
399
|
this.unmounting = void 0;
|
|
344
|
-
this.node.unmount();
|
|
400
|
+
return !!this.node.unmount();
|
|
345
401
|
}
|
|
346
402
|
};
|
|
347
403
|
|
|
@@ -368,7 +424,8 @@ var MountBuilder_default = class extends Builder_default2 {
|
|
|
368
424
|
}
|
|
369
425
|
async createNode(anchor) {
|
|
370
426
|
let container;
|
|
371
|
-
|
|
427
|
+
const value = await this.getValue(anchor);
|
|
428
|
+
if (typeof value !== "boolean" && value !== void 0) {
|
|
372
429
|
container = await this.definition.container(this.getProps(anchor));
|
|
373
430
|
}
|
|
374
431
|
return new MountNode_default(new Node_default(anchor, container), this.definition.mount);
|
|
@@ -378,6 +435,34 @@ var MountBuilder_default = class extends Builder_default2 {
|
|
|
378
435
|
}
|
|
379
436
|
};
|
|
380
437
|
|
|
438
|
+
// src/entry/content/core/EventNode.ts
|
|
439
|
+
var EventNode_default = class {
|
|
440
|
+
constructor(node, emitter) {
|
|
441
|
+
this.node = node;
|
|
442
|
+
this.emitter = emitter;
|
|
443
|
+
}
|
|
444
|
+
get anchor() {
|
|
445
|
+
return this.node.anchor;
|
|
446
|
+
}
|
|
447
|
+
get container() {
|
|
448
|
+
return this.node.container;
|
|
449
|
+
}
|
|
450
|
+
mount() {
|
|
451
|
+
const result = this.node.mount();
|
|
452
|
+
if (result === true) {
|
|
453
|
+
this.emitter.emitMount(this.node);
|
|
454
|
+
}
|
|
455
|
+
return !!result;
|
|
456
|
+
}
|
|
457
|
+
unmount() {
|
|
458
|
+
const result = this.node.unmount();
|
|
459
|
+
if (result === true) {
|
|
460
|
+
this.emitter.emitUnmount(this.node);
|
|
461
|
+
}
|
|
462
|
+
return !!result;
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
|
|
381
466
|
// src/entry/content/vanilla/Node.ts
|
|
382
467
|
var Node_default2 = class {
|
|
383
468
|
constructor(node, value) {
|
|
@@ -394,20 +479,25 @@ var Node_default2 = class {
|
|
|
394
479
|
mount() {
|
|
395
480
|
this.node.mount();
|
|
396
481
|
if (!this.container || this.mounted) {
|
|
397
|
-
return;
|
|
482
|
+
return false;
|
|
398
483
|
}
|
|
484
|
+
let result = true;
|
|
399
485
|
if (this.value instanceof Element) {
|
|
400
486
|
this.container.appendChild(this.value);
|
|
401
487
|
} else if (typeof this.value === "string" || typeof this.value === "number") {
|
|
402
488
|
this.container.textContent = String(this.value);
|
|
403
|
-
} else if (this.value === null || this.value === void 0) {
|
|
489
|
+
} else if (this.value === null || this.value === void 0 || this.value === false) {
|
|
490
|
+
result = false;
|
|
404
491
|
console.warn("Content script vanilla value is empty");
|
|
492
|
+
} else if (this.value === true) {
|
|
493
|
+
result = false;
|
|
405
494
|
}
|
|
406
495
|
this.mounted = true;
|
|
496
|
+
return result;
|
|
407
497
|
}
|
|
408
498
|
unmount() {
|
|
409
|
-
this.node.unmount();
|
|
410
499
|
this.mounted = false;
|
|
500
|
+
return !!this.node.unmount();
|
|
411
501
|
}
|
|
412
502
|
};
|
|
413
503
|
|
|
@@ -422,7 +512,7 @@ var Builder_default3 = class extends MountBuilder_default {
|
|
|
422
512
|
value = void 0;
|
|
423
513
|
console.warn("Content script vanilla value is not a valid render value");
|
|
424
514
|
}
|
|
425
|
-
return new Node_default2(await super.createNode(anchor), value);
|
|
515
|
+
return new EventNode_default(new Node_default2(await super.createNode(anchor), value), this.emitter);
|
|
426
516
|
}
|
|
427
517
|
};
|
|
428
518
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/entry/content/core/resolvers/render.ts","../../../../src/entry/core/Builder.ts","../../../../src/entry/content/core/resolvers/mount.ts","../../../../src/entry/content/core/resolvers/anchor.ts","../../../../src/entry/content/core/resolvers/container.ts","../../../../src/entry/content/core/resolvers/watch.ts","../../../../src/entry/content/core/Context.ts","../../../../src/entry/content/core/ManagedContext.ts","../../../../src/entry/content/core/Builder.ts","../../../../src/entry/content/core/Node.ts","../../../../src/entry/content/core/MountNode.ts","../../../../src/entry/content/core/MountBuilder.ts","../../../../src/entry/content/vanilla/Node.ts","../../../../src/entry/content/vanilla/Builder.ts","../../../../src/entry/content/vanilla/index.ts"],"names":["Builder_default","Node_default"],"mappings":";;;;AAEO,IAAM,+BAAA,GAAkC,CAAC,KAAuD,KAAA;AACnG,EAAQ,OAAA,OAAO,UAAU,QAAY,IAAA,KAAA,CAAM,SAAS,CAAM,IAAA,OAAO,KAAU,KAAA,QAAA,IAAY,KAAiB,YAAA,OAAA;AAC5G,CAAA;AAGO,IAAM,2BACT,GAAA,CAAC,MACG,KAAA,OAAO,KAAyD,KAAA;AAC5D,EAAA,IAAI,iBAAiB,OAAO,MAAA,KAAW,UAAa,GAAA,MAAA,CAAO,KAAK,CAAI,GAAA,MAAA;AAEpE,EAAA,IAAI,0BAA0B,OAAS,EAAA;AACnC,IAAA,cAAA,GAAiB,MAAM,cAAA;AAAA;AAG3B,EAAA,IAAI,cAAmB,KAAA,IAAA,IAAQ,CAAC,+BAAA,CAAgC,cAAc,CAAG,EAAA;AAC7E,IAAA;AAAA;AAGJ,EAAO,OAAA,cAAA;AACX,CAAA;;;ACnBR,IAAO,kBAAP,MAA2D;AAAA,EAKvD,OAAc,QAAwE,GAAA;AAClF,IAAA,OAAO,CAAC,UAAwD,KAAA;AAC5D,MAAA,IAAI,KAAK,UAAU,CAAA,CAAE,KAAM,EAAA,CAAE,MAAM,CAAK,CAAA,KAAA;AACpC,QAAQ,OAAA,CAAA,KAAA,CAAM,+BAA+B,CAAC,CAAA;AAAA,OACjD,CAAA;AAAA,KACL;AAAA;AAER,CA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AM,UAAU,CAAA;AAAA;AACpB,EAEA,MAAgB,WAAW,MAA6C,EAAA;AACpE,IAAA,IAAI,KAAQ,GAAA,MAAM,IAAK,CAAA,QAAA,CAAS,MAAM,CAAA;AAEtC,IAAA,IAAI,KAAU,KAAA,IAAA,IAAQ,CAAC,+BAAA,CAAgC,KAAK,CAAG,EAAA;AAC3D,MAAQ,KAAA,GAAA,MAAA;AAER,MAAA,OAAA,CAAQ,KAAK,0DAA0D,CAAA;AAAA;AAG3E,IAAA,OAAO,IAAIC,aAAY,CAAA,MAAM,MAAM,UAAW,CAAA,MAAM,GAAG,KAAK,CAAA;AAAA;AAEpE;;;ACnBO,IAAA,eAAA,GAAQD,iBAAQ,QAAS","file":"index.js","sourcesContent":["import {ContentScriptRenderHandler, ContentScriptRenderValue} from \"@typing/content\";\n\nexport const isValidContentScriptRenderValue = (value: unknown): value is string | number | Element => {\n return (typeof value === \"string\" && value.length > 0) || typeof value === \"number\" || value instanceof Element;\n};\n\n// prettier-ignore\nexport const contentScriptRenderResolver =\n (render?: ContentScriptRenderValue | ContentScriptRenderHandler): ContentScriptRenderHandler =>\n async (props): Promise<undefined | ContentScriptRenderValue> => {\n let resolvedRender = typeof render === \"function\" ? render(props) : render;\n\n if (resolvedRender instanceof Promise) {\n resolvedRender = await resolvedRender;\n }\n\n if (resolvedRender !== true && !isValidContentScriptRenderValue(resolvedRender)) {\n return;\n }\n\n return resolvedRender;\n };\n","import {EntrypointBuilder, EntrypointConstructorParameter} from \"@typing/entrypoint\";\n\nexport default abstract class implements EntrypointBuilder {\n public abstract build(): Promise<void>;\n\n public abstract destroy(): Promise<void>;\n\n public static resolver<T extends new (definition: any) => EntrypointBuilder>(this: T) {\n return (definition: EntrypointConstructorParameter<T>): void => {\n new this(definition).build().catch(e => {\n console.error(\"Failed to build entrypoint:\", e);\n });\n };\n }\n}\n","import {ContentScriptAppend, ContentScriptMountFunction} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMountAppendResolver =\n (append?: ContentScriptAppend): ContentScriptMountFunction =>\n (anchor: Element, container: Element): void => {\n switch (append) {\n case ContentScriptAppend.Last:\n anchor.append(container);\n break;\n default:\n case undefined:\n case ContentScriptAppend.First:\n anchor.prepend(container);\n break;\n case ContentScriptAppend.Replace:\n anchor.replaceWith(container);\n break;\n case ContentScriptAppend.After:\n anchor.parentElement?.insertBefore(container, anchor.nextElementSibling);\n break;\n case ContentScriptAppend.Before:\n anchor.parentElement?.insertBefore(container, anchor);\n break;\n }\n };\n","import {customAlphabet} from \"nanoid\";\n\nimport {ContentScriptAnchor, ContentScriptAnchorGetter, ContentScriptAnchorResolver} from \"@typing/content\";\n\nconst generateId = customAlphabet(\"abcdefghijklmnopqrstuvwxyz\", 7);\n\nexport const contentScriptAnchorAttribute = `data-${generateId()}`;\n\n// prettier-ignore\nexport const contentScriptAnchorResolver =\n (anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver =>\n async (): Promise<Element[]> => {\n const attr = contentScriptAnchorAttribute;\n\n let resolved = typeof anchor === \"function\" ? anchor() : anchor;\n\n if (resolved instanceof Promise) {\n resolved = await resolved;\n }\n\n if (resolved === undefined || resolved === null) {\n resolved = document.body;\n }\n\n const elements: Element[] = [];\n\n if (resolved instanceof Element) {\n if (!resolved.hasAttribute(attr)) {\n elements.push(resolved);\n }\n } else if (typeof resolved === \"string\") {\n if (resolved.startsWith(\"/\")) {\n const notRegex = /not\\(\\s*[^)]+\\s*\\)/;\n const condition = `not(@${attr})`;\n\n if (notRegex.test(resolved)) {\n resolved = `(${resolved})[${condition}]`;\n }\n\n const result = document.evaluate(\n resolved,\n document,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n );\n\n for (let i = 0; i < result.snapshotLength; i++) {\n elements.push(result.snapshotItem(i) as Element);\n }\n } else {\n resolved += `:not([${attr}])`;\n\n elements.push(...Array.from(document.querySelectorAll(resolved)));\n }\n }\n\n return elements;\n };\n","import {\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptProps,\n} from \"@typing/content\";\n\nexport const contentScriptContainerResolver =\n (\n container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory\n ): ContentScriptContainerCreator =>\n async (props: ContentScriptProps): Promise<Element> => {\n let resolvedContainer = typeof container === \"function\" ? container(props) : container;\n\n if (resolvedContainer instanceof Promise) {\n resolvedContainer = await resolvedContainer;\n }\n\n if (resolvedContainer === undefined || typeof resolvedContainer === \"string\") {\n resolvedContainer = document.createElement(resolvedContainer || \"div\");\n } else if (typeof resolvedContainer === \"object\" && resolvedContainer.constructor === Object) {\n const {tagName = \"div\", ...options} = resolvedContainer as ContentScriptContainerOptions;\n\n resolvedContainer = document.createElement(tagName);\n\n Object.assign(resolvedContainer, options);\n }\n\n if (!(resolvedContainer instanceof Element)) {\n throw new Error(\"The content script container must be a valid element\");\n }\n\n return resolvedContainer;\n };\n","import debounce from \"debounce\";\n\nimport {ContentScriptWatchStrategy} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMutationObserverResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n update => {\n if (!options) {\n options = {};\n }\n\n const handle = debounce(update, 200);\n\n const observer = new MutationObserver(handle);\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n ...options,\n });\n\n return () => {\n handle.clear();\n observer.disconnect();\n };\n };\n\n// prettier-ignore\nexport const contentScriptAwaitFirstResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n (update, context) => {\n const resolver = contentScriptMutationObserverResolver({\n attributes: false,\n characterData: false,\n ...options,\n });\n\n let unwatch: { (): void } | undefined;\n\n const clear = () => {\n unwatch && unwatch();\n unwatch = undefined;\n };\n\n if (context.nodes.size === 0) {\n unwatch = resolver(() => {\n update();\n\n if (context.nodes.size > 0) {\n clear();\n }\n }, context);\n }\n\n return () => {\n clear();\n };\n };\n\n// prettier-ignore\nexport const contentScriptLocationResolver =\n (strategy: ContentScriptWatchStrategy): ContentScriptWatchStrategy =>\n (update, context) => {\n let currentUrl = location.href;\n\n const interval = setInterval(() => {\n if (currentUrl !== location.href) {\n currentUrl = location.href;\n\n context.mount();\n }\n }, 300);\n\n const unwatch = strategy(update, context);\n\n return () => {\n clearInterval(interval);\n unwatch();\n };\n };\n","import {ContentScriptContext, ContentScriptNode, ContentScriptNodeSet} from \"@typing/content\";\n\nexport default class implements ContentScriptContext {\n protected readonly collection: ContentScriptNodeSet = new Set();\n\n public get nodes(): ReadonlySet<ContentScriptNode> {\n return this.collection;\n }\n\n public mount(): void {\n for (const node of this.collection) {\n if (!node.anchor.isConnected) {\n node.unmount();\n\n this.collection.delete(node);\n\n continue;\n }\n\n node.mount();\n }\n }\n\n public unmount(): void {\n for (const node of this.collection) {\n node.unmount();\n\n if (!node.anchor.isConnected) {\n this.collection.delete(node);\n }\n }\n }\n}\n","import Context from \"./Context\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nexport default class extends Context {\n public add(node: ContentScriptNode): this {\n this.collection.add(node);\n\n return this;\n }\n}\n","import Builder from \"@entry/core/Builder\";\n\nimport {contentScriptMountAppendResolver} from \"./resolvers/mount\";\nimport {contentScriptAnchorResolver} from \"./resolvers/anchor\";\nimport {contentScriptRenderResolver} from \"./resolvers/render\";\nimport {contentScriptContainerResolver} from \"./resolvers/container\";\nimport {\n contentScriptAwaitFirstResolver,\n contentScriptLocationResolver,\n contentScriptMutationObserverResolver,\n} from \"./resolvers/watch\";\n\nimport ManagedContext from \"./ManagedContext\";\n\nimport {\n ContentScriptAnchor,\n ContentScriptAnchorGetter,\n ContentScriptAnchorResolver,\n ContentScriptBuilder,\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptContext,\n ContentScriptDefinition,\n ContentScriptMountFunction,\n ContentScriptNode,\n ContentScriptRenderHandler,\n ContentScriptRenderValue,\n ContentScriptResolvedDefinition,\n ContentScriptWatchStrategy,\n} from \"@typing/content\";\n\nimport {Awaiter} from \"@typing/helpers\";\n\nexport default abstract class extends Builder implements ContentScriptBuilder {\n protected readonly definition: ContentScriptResolvedDefinition;\n\n protected context = new ManagedContext();\n\n protected unwatch?: () => void;\n\n private isProcessing: boolean = false;\n\n protected abstract createNode(anchor: Element): Promise<ContentScriptNode>;\n\n protected abstract cleanupNode(anchor: Element): Awaiter<void>;\n\n protected constructor(definition: ContentScriptDefinition) {\n super();\n\n this.definition = {\n ...definition,\n anchor: this.resolveAnchor(definition.anchor),\n mount: this.resolveMount(definition.mount),\n container: this.resolveContainer(definition.container),\n render: this.resolveRender(definition.render),\n watch: this.resolveWatch(definition.watch),\n };\n }\n\n protected resolveAnchor(anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver {\n return contentScriptAnchorResolver(anchor);\n }\n\n protected resolveMount(mount?: ContentScriptMountFunction): ContentScriptMountFunction {\n return mount || contentScriptMountAppendResolver();\n }\n\n protected resolveContainer(\n container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory\n ): ContentScriptContainerCreator {\n return contentScriptContainerResolver(container);\n }\n\n protected resolveRender(\n render?: ContentScriptRenderValue | ContentScriptRenderHandler\n ): ContentScriptRenderHandler | undefined {\n if (render === undefined) {\n return;\n }\n\n return contentScriptRenderResolver(render);\n }\n\n protected resolveWatch(watch?: true | ContentScriptWatchStrategy): ContentScriptWatchStrategy {\n if (watch === undefined) {\n watch = contentScriptAwaitFirstResolver();\n } else if (watch === true) {\n watch = contentScriptMutationObserverResolver();\n }\n\n return contentScriptLocationResolver(watch);\n }\n\n public getContext(): ContentScriptContext {\n return this.context;\n }\n\n public async build(): Promise<void> {\n await this.destroy();\n\n const {render, main, anchor, container, watch, mount, ...options} = this.definition;\n\n if (render !== undefined) {\n await this.processing();\n\n this.unwatch = watch(() => {\n this.processing().catch(e => {\n console.error(\"Content script processing on watch error\", e);\n });\n }, this.context);\n }\n\n await main?.(this.context, options);\n }\n\n public async destroy(): Promise<void> {\n this.unwatch?.();\n this.unwatch = undefined;\n }\n\n protected async processing(): Promise<void> {\n if (this.isProcessing) {\n return;\n }\n\n this.isProcessing = true;\n\n const anchors = await this.definition.anchor();\n\n await Promise.allSettled(anchors.map(this.processAnchor.bind(this)));\n\n this.isProcessing = false;\n }\n\n protected async processAnchor(anchor: Element): Promise<void> {\n const node = await this.createNode(anchor);\n\n this.context.add(node);\n\n await this.cleanupNode(anchor);\n\n node.mount();\n }\n}\n","import {contentScriptAnchorAttribute} from \"./resolvers/anchor\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nenum NodeMark {\n Mounded = \"1\",\n Unmounted = \"0\",\n}\n\nexport default class implements ContentScriptNode {\n private readonly _container?: Element;\n\n private readonly attr = contentScriptAnchorAttribute;\n\n constructor(\n public readonly anchor: Element,\n public container?: Element\n ) {\n if (this.container) {\n this._container = this.container.cloneNode(false) as Element;\n }\n }\n\n public mount(): void {\n this.mark();\n\n if (!this.container && this._container) {\n this.container = this._container.cloneNode(false) as Element;\n }\n }\n\n public unmount(): void {\n this.unmark();\n\n if (this.container) {\n this.container.remove();\n this.container = undefined;\n }\n }\n\n protected mark(): this {\n let id = this.anchor.getAttribute(this.attr);\n\n if (typeof id !== \"string\" || id.length === 0 || id === NodeMark.Unmounted) {\n this.anchor.setAttribute(this.attr, NodeMark.Mounded);\n }\n\n return this;\n }\n\n protected unmark(): void {\n this.anchor.setAttribute(this.attr, NodeMark.Unmounted);\n }\n}\n","import {ContentScriptMountFunction, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private unmounting?: () => void;\n\n constructor(\n protected node: ContentScriptNode,\n protected mounter?: ContentScriptMountFunction\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): void {\n this.node.mount();\n\n if (!this.container || this.container.isConnected) {\n return;\n }\n\n const unmounting = this.mounter?.(this.anchor, this.container);\n\n if (unmounting) {\n this.unmounting = unmounting;\n }\n }\n\n public unmount(): void {\n this.unmounting?.();\n this.unmounting = undefined;\n\n this.node.unmount();\n }\n}\n","import Builder from \"./Builder\";\nimport Node from \"./Node\";\nimport MountNode from \"./MountNode\";\n\nimport {ContentScriptNode, ContentScriptProps, ContentScriptRenderValue} from \"@typing/content\";\n\nexport default abstract class extends Builder {\n private values = new Map<Element, null | ContentScriptRenderValue>();\n\n protected getProps(anchor: Element): ContentScriptProps {\n const {anchor: _, mount, watch, render, container, main, ...options} = this.definition;\n\n return {...options, anchor};\n }\n\n protected async getValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n if (!this.values.has(anchor)) {\n const value = await this.renderValue(anchor);\n\n this.values.set(anchor, value === undefined ? undefined : value);\n }\n\n return this.values.get(anchor);\n }\n\n protected async renderValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n const {render} = this.definition;\n\n if (render === undefined) {\n return;\n }\n\n return render(this.getProps(anchor));\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let container: Element | undefined;\n\n if (await this.getValue(anchor)) {\n container = (await this.definition.container(this.getProps(anchor))) as Element | undefined;\n }\n\n return new MountNode(new Node(anchor, container), this.definition.mount);\n }\n\n protected cleanupNode(anchor: Element): void {\n this.values.delete(anchor);\n }\n}\n","import {ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private mounted: boolean = false;\n\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly value?: null | boolean | string | number | Element\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): void {\n this.node.mount();\n\n if (!this.container || this.mounted) {\n return;\n }\n\n if (this.value instanceof Element) {\n this.container.appendChild(this.value);\n } else if (typeof this.value === \"string\" || typeof this.value === \"number\") {\n this.container.textContent = String(this.value);\n } else if (this.value === null || this.value === undefined) {\n console.warn(\"Content script vanilla value is empty\");\n }\n\n this.mounted = true;\n }\n\n public unmount(): void {\n this.node.unmount();\n\n this.mounted = false;\n }\n}\n","import {isValidContentScriptRenderValue} from \"../core/resolvers/render\";\n\nimport MountBuilder from \"../core/MountBuilder\";\nimport VanillaNode from \"./Node\";\n\nimport {ContentScriptDefinition, ContentScriptNode} from \"@typing/content\";\n\nexport default class extends MountBuilder {\n public constructor(definition: ContentScriptDefinition) {\n super(definition);\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let value = await this.getValue(anchor);\n\n if (value !== true && !isValidContentScriptRenderValue(value)) {\n value = undefined;\n\n console.warn(\"Content script vanilla value is not a valid render value\");\n }\n\n return new VanillaNode(await super.createNode(anchor), value);\n }\n}\n","import Builder from \"./Builder\";\n\nexport {Builder};\n\nexport default Builder.resolver();\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/entry/content/core/resolvers/render.ts","../../../../src/entry/core/Builder.ts","../../../../src/entry/content/core/resolvers/mount.ts","../../../../src/entry/content/core/resolvers/anchor.ts","../../../../src/entry/content/core/resolvers/container.ts","../../../../src/entry/content/core/resolvers/watch.ts","../../../../src/entry/content/core/Context.ts","../../../../src/entry/content/core/ManagedContext.ts","../../../../src/entry/content/core/EventEmitter.ts","../../../../src/entry/content/core/Builder.ts","../../../../src/entry/content/core/Node.ts","../../../../src/entry/content/core/MountNode.ts","../../../../src/entry/content/core/MountBuilder.ts","../../../../src/entry/content/core/EventNode.ts","../../../../src/entry/content/vanilla/Node.ts","../../../../src/entry/content/vanilla/Builder.ts","../../../../src/entry/content/vanilla/index.ts"],"names":["Builder_default","Node_default"],"mappings":";;;;AAEO,IAAM,+BAAA,GAAkC,CAAC,KAAuD,KAAA;AACnG,EAAQ,OAAA,OAAO,UAAU,QAAY,IAAA,KAAA,CAAM,SAAS,CAAM,IAAA,OAAO,KAAU,KAAA,QAAA,IAAY,KAAiB,YAAA,OAAA;AAC5G,CAAA;AAGO,IAAM,2BACT,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AAIC,aAAAA,CAAY,MAAM,KAAA,CAAM,UAAW,CAAA,MAAM,CAAG,EAAA,KAAK,CAAG,EAAA,IAAA,CAAK,OAAO,CAAA;AAAA;AAEjG;;;ACpBO,IAAA,eAAA,GAAQD,iBAAQ,QAAS","file":"index.js","sourcesContent":["import {ContentScriptRenderHandler, ContentScriptRenderValue} from \"@typing/content\";\n\nexport const isValidContentScriptRenderValue = (value: unknown): value is string | number | Element => {\n return (typeof value === \"string\" && value.length > 0) || typeof value === \"number\" || value instanceof Element;\n};\n\n// prettier-ignore\nexport const contentScriptRenderResolver =\n (render?: ContentScriptRenderValue | ContentScriptRenderHandler): ContentScriptRenderHandler =>\n async (props): Promise<undefined | ContentScriptRenderValue> => {\n let resolvedRender = typeof render === \"function\" ? render(props) : render;\n\n if (resolvedRender instanceof Promise) {\n resolvedRender = await resolvedRender;\n }\n\n if (resolvedRender !== true && !isValidContentScriptRenderValue(resolvedRender)) {\n return;\n }\n\n return resolvedRender;\n };\n","import {EntrypointBuilder, EntrypointConstructorParameter} from \"@typing/entrypoint\";\n\nexport default abstract class implements EntrypointBuilder {\n public abstract build(): Promise<void>;\n\n public abstract destroy(): Promise<void>;\n\n public static resolver<T extends new (definition: any) => EntrypointBuilder>(this: T) {\n return (definition: EntrypointConstructorParameter<T>): void => {\n new this(definition).build().catch(e => {\n console.error(\"Failed to build entrypoint:\", e);\n });\n };\n }\n}\n","import {ContentScriptAppend, ContentScriptMountFunction} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMountAppendResolver =\n (append?: ContentScriptAppend): ContentScriptMountFunction =>\n (anchor: Element, container: Element): void => {\n switch (append) {\n case ContentScriptAppend.Last:\n anchor.append(container);\n break;\n default:\n case undefined:\n case ContentScriptAppend.First:\n anchor.prepend(container);\n break;\n case ContentScriptAppend.Replace:\n anchor.replaceWith(container);\n break;\n case ContentScriptAppend.After:\n anchor.parentElement?.insertBefore(container, anchor.nextElementSibling);\n break;\n case ContentScriptAppend.Before:\n anchor.parentElement?.insertBefore(container, anchor);\n break;\n }\n };\n","import {customAlphabet} from \"nanoid\";\n\nimport {ContentScriptAnchor, ContentScriptAnchorGetter, ContentScriptAnchorResolver} from \"@typing/content\";\n\nconst generateId = customAlphabet(\"abcdefghijklmnopqrstuvwxyz\", 7);\n\nexport const contentScriptAnchorAttribute = `data-${generateId()}`;\n\n// prettier-ignore\nexport const contentScriptAnchorResolver =\n (anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver =>\n async (): Promise<Element[]> => {\n const attr = contentScriptAnchorAttribute;\n\n let resolved = typeof anchor === \"function\" ? anchor() : anchor;\n\n if (resolved instanceof Promise) {\n resolved = await resolved;\n }\n\n if (resolved === undefined || resolved === null) {\n resolved = document.body;\n }\n\n const elements: Element[] = [];\n\n if (resolved instanceof Element) {\n if (!resolved.hasAttribute(attr)) {\n elements.push(resolved);\n }\n } else if (typeof resolved === \"string\") {\n if (resolved.startsWith(\"/\")) {\n resolved = `(${resolved})[not(@${attr})]`;\n\n const result = document.evaluate(\n resolved,\n document,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n );\n\n for (let i = 0; i < result.snapshotLength; i++) {\n elements.push(result.snapshotItem(i) as Element);\n }\n } else {\n resolved += `:not([${attr}])`;\n\n elements.push(...Array.from(document.querySelectorAll(resolved)));\n }\n }\n\n return elements;\n };\n","import {\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptProps,\n} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptContainerResolver = (\n container?:\n ContentScriptContainerTag |\n ContentScriptContainerOptions |\n ContentScriptContainerFactory\n): ContentScriptContainerCreator =>\n async (props: ContentScriptProps): Promise<Element> => {\n let resolvedContainer = typeof container === \"function\" ? container(props) : container;\n\n if (resolvedContainer instanceof Promise) {\n resolvedContainer = await resolvedContainer;\n }\n\n if (resolvedContainer === undefined || typeof resolvedContainer === \"string\") {\n resolvedContainer = document.createElement(resolvedContainer || \"div\");\n } else if (typeof resolvedContainer === \"object\" && resolvedContainer.constructor === Object) {\n const {tagName = \"div\", ...options} = resolvedContainer as ContentScriptContainerOptions;\n\n resolvedContainer = document.createElement(tagName);\n\n Object.assign(resolvedContainer, options);\n }\n\n if (!(resolvedContainer instanceof Element)) {\n throw new Error(\"The content script container must be a valid element\");\n }\n\n return resolvedContainer;\n };\n","import debounce from \"debounce\";\n\nimport {ContentScriptWatchStrategy} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMutationObserverResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n update => {\n if (!options) {\n options = {};\n }\n\n const handle = debounce(update, 200);\n\n const observer = new MutationObserver(handle);\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n ...options,\n });\n\n return () => {\n handle.clear();\n observer.disconnect();\n };\n };\n\n// prettier-ignore\nexport const contentScriptAwaitFirstResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n (update, context) => {\n const resolver = contentScriptMutationObserverResolver({\n attributes: false,\n characterData: false,\n ...options,\n });\n\n let unwatch: { (): void } | undefined;\n\n const clear = () => {\n unwatch && unwatch();\n unwatch = undefined;\n };\n\n if (context.nodes.size === 0) {\n unwatch = resolver(() => {\n update();\n\n if (context.nodes.size > 0) {\n clear();\n }\n }, context);\n }\n\n return () => {\n clear();\n };\n };\n\n// prettier-ignore\nexport const contentScriptLocationResolver =\n (strategy: ContentScriptWatchStrategy): ContentScriptWatchStrategy =>\n (update, context) => {\n let currentUrl = location.href;\n\n const interval = setInterval(() => {\n if (currentUrl !== location.href) {\n currentUrl = location.href;\n\n context.mount();\n }\n }, 300);\n\n const unwatch = strategy(update, context);\n\n return () => {\n clearInterval(interval);\n unwatch();\n };\n };\n","import {\n ContentScriptContext,\n ContentScriptEventCallback,\n ContentScriptEventEmitter,\n ContentScriptNode,\n ContentScriptNodeSet,\n} from \"@typing/content\";\n\nexport default class implements ContentScriptContext {\n protected readonly collection: ContentScriptNodeSet = new Set();\n\n constructor(protected readonly emitter: ContentScriptEventEmitter) {}\n\n public get nodes(): ReadonlySet<ContentScriptNode> {\n return this.collection;\n }\n\n public mount(): void {\n for (const node of this.collection) {\n if (!node.anchor.isConnected) {\n node.unmount();\n\n this.collection.delete(node);\n\n this.emitter.emitRemove(node);\n\n continue;\n }\n\n node.mount();\n }\n }\n\n public unmount(): void {\n for (const node of this.collection) {\n node.unmount();\n\n if (!node.anchor.isConnected) {\n this.collection.delete(node);\n\n this.emitter.emitRemove(node);\n }\n }\n }\n\n public watch(callback: ContentScriptEventCallback): () => void {\n this.emitter.on(callback);\n\n return () => {\n this.emitter.off(callback);\n };\n }\n\n public unwatch(): void {\n this.emitter.removeAllListeners();\n }\n}\n","import Context from \"./Context\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nexport default class extends Context {\n public add(node: ContentScriptNode): this {\n this.collection.add(node);\n\n this.emitter.emitAdd(node);\n\n return this;\n }\n}\n","import {\n ContentScriptEvent,\n ContentScriptEventCallback,\n ContentScriptEventEmitter,\n ContentScriptNode,\n} from \"@typing/content\";\n\nexport default class implements ContentScriptEventEmitter {\n private readonly listeners: Set<ContentScriptEventCallback> = new Set();\n\n public emit(event: ContentScriptEvent, node: ContentScriptNode): void {\n for (const listener of this.listeners) {\n listener(event, node);\n }\n }\n\n public emitAdd(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Add, node);\n }\n\n public emitMount(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Mount, node);\n }\n\n public emitRemove(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Remove, node);\n }\n\n public emitUnmount(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Unmount, node);\n }\n\n public hasListeners(): boolean {\n return this.listenerCount() > 0;\n }\n\n public listenerCount(): number {\n return this.listeners.size;\n }\n\n public off(callback: ContentScriptEventCallback): void {\n this.listeners.delete(callback);\n }\n\n public on(callback: ContentScriptEventCallback): void {\n this.listeners.add(callback);\n }\n\n public removeAllListeners(): void {\n this.listeners.clear();\n }\n}\n","import Builder from \"@entry/core/Builder\";\n\nimport {contentScriptMountAppendResolver} from \"./resolvers/mount\";\nimport {contentScriptAnchorResolver} from \"./resolvers/anchor\";\nimport {contentScriptRenderResolver} from \"./resolvers/render\";\nimport {contentScriptContainerResolver} from \"./resolvers/container\";\nimport {\n contentScriptAwaitFirstResolver,\n contentScriptLocationResolver,\n contentScriptMutationObserverResolver,\n} from \"./resolvers/watch\";\n\nimport ManagedContext from \"./ManagedContext\";\nimport EventEmitter from \"./EventEmitter\";\n\nimport {\n ContentScriptAnchor,\n ContentScriptAnchorGetter,\n ContentScriptAnchorResolver,\n ContentScriptBuilder,\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptContext,\n ContentScriptDefinition,\n ContentScriptMountFunction,\n ContentScriptNode,\n ContentScriptRenderHandler,\n ContentScriptRenderValue,\n ContentScriptResolvedDefinition,\n ContentScriptWatchStrategy,\n} from \"@typing/content\";\n\nimport {Awaiter} from \"@typing/helpers\";\n\nexport default abstract class extends Builder implements ContentScriptBuilder {\n protected readonly definition: ContentScriptResolvedDefinition;\n\n protected readonly emitter = new EventEmitter();\n\n protected readonly context = new ManagedContext(this.emitter);\n\n protected unwatch?: () => void;\n\n private isProcessing: boolean = false;\n\n protected abstract createNode(anchor: Element): Promise<ContentScriptNode>;\n\n protected abstract cleanupNode(anchor: Element): Awaiter<void>;\n\n protected constructor(definition: ContentScriptDefinition) {\n super();\n\n this.definition = {\n ...definition,\n anchor: this.resolveAnchor(definition.anchor),\n mount: this.resolveMount(definition.mount),\n container: this.resolveContainer(definition.container),\n render: this.resolveRender(definition.render),\n watch: this.resolveWatch(definition.watch),\n };\n }\n\n protected resolveAnchor(anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver {\n return contentScriptAnchorResolver(anchor);\n }\n\n protected resolveMount(mount?: ContentScriptMountFunction): ContentScriptMountFunction {\n return mount || contentScriptMountAppendResolver();\n }\n\n protected resolveContainer(\n container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory\n ): ContentScriptContainerCreator {\n return contentScriptContainerResolver(container);\n }\n\n protected resolveRender(\n render?: ContentScriptRenderValue | ContentScriptRenderHandler\n ): ContentScriptRenderHandler | undefined {\n if (render === undefined) {\n return;\n }\n\n return contentScriptRenderResolver(render);\n }\n\n protected resolveWatch(watch?: true | ContentScriptWatchStrategy): ContentScriptWatchStrategy {\n if (watch === undefined) {\n watch = contentScriptAwaitFirstResolver();\n } else if (watch === true) {\n watch = contentScriptMutationObserverResolver();\n }\n\n return contentScriptLocationResolver(watch);\n }\n\n public getContext(): ContentScriptContext {\n return this.context;\n }\n\n public async build(): Promise<void> {\n await this.destroy();\n\n const {render, main, anchor, container, watch, mount, ...options} = this.definition;\n\n await main?.(this.context, options);\n\n if (render !== undefined) {\n await this.processing();\n\n this.unwatch = watch(() => {\n this.processing().catch(e => {\n console.error(\"Content script processing on watch error\", e);\n });\n }, this.context);\n }\n }\n\n public async destroy(): Promise<void> {\n this.unwatch?.();\n this.unwatch = undefined;\n }\n\n protected async processing(): Promise<void> {\n if (this.isProcessing) {\n return;\n }\n\n this.isProcessing = true;\n\n const anchors = await this.definition.anchor();\n\n await Promise.allSettled(anchors.map(this.processAnchor.bind(this)));\n\n this.isProcessing = false;\n }\n\n protected async processAnchor(anchor: Element): Promise<void> {\n const node = await this.createNode(anchor);\n\n this.context.add(node);\n\n await this.cleanupNode(anchor);\n\n node.mount();\n }\n}\n","import {contentScriptAnchorAttribute} from \"./resolvers/anchor\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nenum NodeMark {\n Mounded = \"1\",\n Unmounted = \"0\",\n}\n\nexport default class implements ContentScriptNode {\n private readonly _container?: Element;\n\n private readonly attr = contentScriptAnchorAttribute;\n\n constructor(\n public readonly anchor: Element,\n public container?: Element\n ) {\n if (this.container) {\n this._container = this.container.cloneNode(false) as Element;\n }\n }\n\n public mount(): boolean {\n this.mark();\n\n if (!this.container && this._container) {\n this.container = this._container.cloneNode(false) as Element;\n\n return true;\n }\n\n return false;\n }\n\n public unmount(): boolean {\n this.unmark();\n\n if (this.container) {\n this.container.remove();\n this.container = undefined;\n\n return true;\n }\n\n return false;\n }\n\n protected mark(): this {\n let id = this.anchor.getAttribute(this.attr);\n\n if (typeof id !== \"string\" || id.length === 0 || id === NodeMark.Unmounted) {\n this.anchor.setAttribute(this.attr, NodeMark.Mounded);\n }\n\n return this;\n }\n\n protected unmark(): void {\n this.anchor.setAttribute(this.attr, NodeMark.Unmounted);\n }\n}\n","import {ContentScriptMountFunction, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private unmounting?: () => void;\n\n constructor(\n protected node: ContentScriptNode,\n protected mounter?: ContentScriptMountFunction\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): boolean {\n this.node.mount();\n\n if (!this.container || this.container.isConnected) {\n return false;\n }\n\n if (this.mounter) {\n const unmounting = this.mounter(this.anchor, this.container);\n\n if (unmounting) {\n this.unmounting = unmounting;\n }\n\n return true;\n }\n\n return false;\n }\n\n public unmount(): boolean {\n this.unmounting?.();\n this.unmounting = undefined;\n\n return !!this.node.unmount();\n }\n}\n","import Builder from \"./Builder\";\nimport Node from \"./Node\";\nimport MountNode from \"./MountNode\";\n\nimport {ContentScriptNode, ContentScriptProps, ContentScriptRenderValue} from \"@typing/content\";\n\nexport default abstract class extends Builder {\n private values = new Map<Element, null | ContentScriptRenderValue>();\n\n protected getProps(anchor: Element): ContentScriptProps {\n const {anchor: _, mount, watch, render, container, main, ...options} = this.definition;\n\n return {...options, anchor};\n }\n\n protected async getValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n if (!this.values.has(anchor)) {\n const value = await this.renderValue(anchor);\n\n this.values.set(anchor, value === undefined ? undefined : value);\n }\n\n return this.values.get(anchor);\n }\n\n protected async renderValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n const {render} = this.definition;\n\n if (render === undefined) {\n return;\n }\n\n return render(this.getProps(anchor));\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let container: Element | undefined;\n\n const value = await this.getValue(anchor);\n\n if (typeof value !== \"boolean\" && value !== undefined) {\n container = (await this.definition.container(this.getProps(anchor))) as Element | undefined;\n }\n\n return new MountNode(new Node(anchor, container), this.definition.mount);\n }\n\n protected cleanupNode(anchor: Element): void {\n this.values.delete(anchor);\n }\n}\n","import {ContentScriptEventEmitter, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly emitter: ContentScriptEventEmitter\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): boolean {\n const result = this.node.mount();\n\n if (result === true) {\n this.emitter.emitMount(this.node);\n }\n\n return !!result;\n }\n\n public unmount(): boolean {\n const result = this.node.unmount();\n\n if (result === true) {\n this.emitter.emitUnmount(this.node);\n }\n\n return !!result;\n }\n}\n","import {ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private mounted: boolean = false;\n\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly value?: null | boolean | string | number | Element\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): boolean {\n this.node.mount();\n\n if (!this.container || this.mounted) {\n return false;\n }\n\n let result: boolean = true;\n\n if (this.value instanceof Element) {\n this.container.appendChild(this.value);\n } else if (typeof this.value === \"string\" || typeof this.value === \"number\") {\n this.container.textContent = String(this.value);\n } else if (this.value === null || this.value === undefined || this.value === false) {\n result = false;\n\n console.warn(\"Content script vanilla value is empty\");\n } else if (this.value === true) {\n result = false;\n }\n\n this.mounted = true;\n\n return result;\n }\n\n public unmount(): boolean {\n this.mounted = false;\n\n return !!this.node.unmount();\n }\n}\n","import {isValidContentScriptRenderValue} from \"../core/resolvers/render\";\n\nimport MountBuilder from \"../core/MountBuilder\";\nimport EventNode from \"../core/EventNode\";\nimport VanillaNode from \"./Node\";\n\nimport {ContentScriptDefinition, ContentScriptNode} from \"@typing/content\";\n\nexport default class extends MountBuilder {\n public constructor(definition: ContentScriptDefinition) {\n super(definition);\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let value = await this.getValue(anchor);\n\n if (value !== true && !isValidContentScriptRenderValue(value)) {\n value = undefined;\n\n console.warn(\"Content script vanilla value is not a valid render value\");\n }\n\n return new EventNode(new VanillaNode(await super.createNode(anchor), value), this.emitter);\n }\n}\n","import Builder from \"./Builder\";\n\nexport {Builder};\n\nexport default Builder.resolver();\n"]}
|
|
@@ -205,6 +205,7 @@ var AbstractMessage = class {
|
|
|
205
205
|
// src/types/message.ts
|
|
206
206
|
var MessageGlobalKey = "adnbnMessage";
|
|
207
207
|
var MessageTypeSeparator = ":";
|
|
208
|
+
var MessageSenderProperty = "_sender";
|
|
208
209
|
|
|
209
210
|
// src/message/MessageManager.ts
|
|
210
211
|
var MessageManager = class _MessageManager {
|
|
@@ -375,23 +376,45 @@ var RegisterTransport_default = class extends BaseTransport_default {
|
|
|
375
376
|
}
|
|
376
377
|
const instance = this.init(...args);
|
|
377
378
|
this.manager().add(this.name, instance);
|
|
378
|
-
this.message().watch(async ({ path, args: args2 }) => {
|
|
379
|
+
this.message().watch(async ({ path, args: args2 }, sender) => {
|
|
379
380
|
try {
|
|
381
|
+
this.injectSender(instance, sender);
|
|
380
382
|
const property = path == null ? instance : get__default.default(instance, path);
|
|
381
383
|
if (property === void 0) {
|
|
382
384
|
throw new Error(`Property not found at path "${path}" in "${this.name}"`);
|
|
383
385
|
}
|
|
386
|
+
let result;
|
|
384
387
|
if (typeof property === "function") {
|
|
385
|
-
|
|
388
|
+
result = await property.apply(instance, args2);
|
|
389
|
+
} else {
|
|
390
|
+
result = property;
|
|
386
391
|
}
|
|
387
|
-
|
|
392
|
+
this.clearSender(instance);
|
|
393
|
+
return result;
|
|
388
394
|
} catch (error) {
|
|
389
|
-
console.error(
|
|
395
|
+
console.error(`Error during message handler registration for transport "${this.name}"`, error);
|
|
396
|
+
this.clearSender(instance);
|
|
390
397
|
throw error;
|
|
391
398
|
}
|
|
392
399
|
});
|
|
393
400
|
return instance;
|
|
394
401
|
}
|
|
402
|
+
injectSender(instance, sender) {
|
|
403
|
+
if (!Object.getOwnPropertyDescriptor(instance, MessageSenderProperty)) {
|
|
404
|
+
Object.defineProperty(instance, MessageSenderProperty, {
|
|
405
|
+
configurable: true,
|
|
406
|
+
enumerable: false,
|
|
407
|
+
writable: true,
|
|
408
|
+
value: void 0
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
instance[MessageSenderProperty] = sender;
|
|
412
|
+
}
|
|
413
|
+
clearSender(instance) {
|
|
414
|
+
if (Object.getOwnPropertyDescriptor(instance, MessageSenderProperty)) {
|
|
415
|
+
instance[MessageSenderProperty] = void 0;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
395
418
|
};
|
|
396
419
|
|
|
397
420
|
// src/offscreen/providers/RegisterOffscreen.ts
|