mount-observer 0.1.38 → 0.1.40
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/Synthesizer.js +24 -13
- package/Synthesizer.ts +25 -19
- package/index.js +1 -1
- package/index.ts +1 -1
- package/package.json +2 -2
package/Synthesizer.js
CHANGED
|
@@ -216,19 +216,30 @@ export class Synthesizer extends HTMLElement {
|
|
|
216
216
|
try {
|
|
217
217
|
// Check if export property exists
|
|
218
218
|
let exportValue = scriptElement.export;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
const scriptType = scriptElement.getAttribute('type');
|
|
220
|
+
if (!exportValue && scriptType !== 'emc-parser') {
|
|
221
|
+
// Wait for the export to become available via the 'resolved' event.
|
|
222
|
+
// Use a polling check as a fallback in case the event already fired.
|
|
223
|
+
exportValue = await new Promise((resolve) => {
|
|
224
|
+
// Check immediately in case it was set between our first check and now
|
|
225
|
+
if (scriptElement.export) {
|
|
226
|
+
resolve(scriptElement.export);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const onResolved = (e) => {
|
|
230
|
+
clearInterval(poll);
|
|
231
|
+
resolve(e.export || scriptElement.export);
|
|
232
|
+
};
|
|
233
|
+
scriptElement.addEventListener('resolved', onResolved, {once: true});
|
|
234
|
+
// Poll as safety net in case event already fired
|
|
235
|
+
const poll = setInterval(() => {
|
|
236
|
+
if (scriptElement.export) {
|
|
237
|
+
scriptElement.removeEventListener('resolved', onResolved);
|
|
238
|
+
clearInterval(poll);
|
|
239
|
+
resolve(scriptElement.export);
|
|
240
|
+
}
|
|
241
|
+
}, 50);
|
|
242
|
+
});
|
|
232
243
|
}
|
|
233
244
|
// Clone the script element
|
|
234
245
|
const clonedScript = scriptElement.cloneNode(true);
|
package/Synthesizer.ts
CHANGED
|
@@ -244,25 +244,31 @@ export abstract class Synthesizer extends HTMLElement {
|
|
|
244
244
|
// Check if export property exists
|
|
245
245
|
let exportValue = (scriptElement as any).export;
|
|
246
246
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
247
|
+
const scriptType = scriptElement.getAttribute('type');
|
|
248
|
+
|
|
249
|
+
if (!exportValue && scriptType !== 'emc-parser') {
|
|
250
|
+
// Wait for the export to become available via the 'resolved' event.
|
|
251
|
+
// Use a polling check as a fallback in case the event already fired.
|
|
252
|
+
exportValue = await new Promise<any>((resolve) => {
|
|
253
|
+
// Check immediately in case it was set between our first check and now
|
|
254
|
+
if ((scriptElement as any).export) {
|
|
255
|
+
resolve((scriptElement as any).export);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const onResolved = (e: any) => {
|
|
259
|
+
clearInterval(poll);
|
|
260
|
+
resolve(e.export || (scriptElement as any).export);
|
|
261
|
+
};
|
|
262
|
+
scriptElement.addEventListener('resolved', onResolved, {once: true});
|
|
263
|
+
// Poll as safety net in case event already fired
|
|
264
|
+
const poll = setInterval(() => {
|
|
265
|
+
if ((scriptElement as any).export) {
|
|
266
|
+
scriptElement.removeEventListener('resolved', onResolved);
|
|
267
|
+
clearInterval(poll);
|
|
268
|
+
resolve((scriptElement as any).export);
|
|
269
|
+
}
|
|
270
|
+
}, 50);
|
|
271
|
+
});
|
|
266
272
|
}
|
|
267
273
|
|
|
268
274
|
// Clone the script element
|
package/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export { mountEventName, dismountEventName, disconnectEventName, loadEventName,
|
|
|
19
19
|
import './EvtRt.js';
|
|
20
20
|
import './handlers/DefineCustomElement.js';
|
|
21
21
|
import './handlers/EnhanceMountedElement.js';
|
|
22
|
-
import './handlers/GenIds.js';
|
|
22
|
+
import './handlers/GenIds.js';
|
|
23
23
|
import './handlers/ScriptExport.js';
|
|
24
24
|
import './handlers/MountObserverScript.js';
|
|
25
25
|
import './handlers/EMCScript.js';
|
package/index.ts
CHANGED
|
@@ -39,7 +39,7 @@ export {
|
|
|
39
39
|
import './EvtRt.js';
|
|
40
40
|
import './handlers/DefineCustomElement.js';
|
|
41
41
|
import './handlers/EnhanceMountedElement.js';
|
|
42
|
-
import './handlers/GenIds.js';
|
|
42
|
+
import './handlers/GenIds.js';
|
|
43
43
|
import './handlers/ScriptExport.js';
|
|
44
44
|
import './handlers/MountObserverScript.js';
|
|
45
45
|
import './handlers/EMCScript.js';
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mount-observer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"description": "Observe and act on css matches.",
|
|
5
5
|
"main": "MountObserver.js",
|
|
6
6
|
"module": "MountObserver.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"assign-gingerly": "0.0.51",
|
|
9
|
-
"id-generation": "0.0.
|
|
9
|
+
"id-generation": "0.0.5"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@playwright/test": "1.60.0",
|