mount-observer 0.1.34 → 0.1.35
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 +15 -6
- package/Synthesizer.ts +17 -6
- package/package.json +1 -1
package/Synthesizer.js
CHANGED
|
@@ -215,16 +215,25 @@ export class Synthesizer extends HTMLElement {
|
|
|
215
215
|
// Check if export property exists
|
|
216
216
|
let exportValue = scriptElement.export;
|
|
217
217
|
if (!exportValue) {
|
|
218
|
-
//
|
|
219
|
-
const
|
|
220
|
-
const
|
|
218
|
+
// Determine which event to wait for based on script type
|
|
219
|
+
const scriptType = scriptElement.getAttribute('type');
|
|
220
|
+
const eventName = scriptType === 'emc-parser' ? 'parser-registered' : 'resolved';
|
|
221
|
+
// Wait for appropriate event with timeout
|
|
222
|
+
const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error(`Timeout waiting for ${eventName} event`)), 5000));
|
|
223
|
+
const eventPromise = waitForEvent(scriptElement, eventName);
|
|
221
224
|
const event = await Promise.race([eventPromise, timeoutPromise]);
|
|
222
|
-
|
|
225
|
+
// For parser scripts, we don't need an export value
|
|
226
|
+
// For other scripts, get the export from the event
|
|
227
|
+
if (scriptType !== 'emc-parser') {
|
|
228
|
+
exportValue = event.export;
|
|
229
|
+
}
|
|
223
230
|
}
|
|
224
231
|
// Clone the script element
|
|
225
232
|
const clonedScript = scriptElement.cloneNode(true);
|
|
226
|
-
// Copy the export property
|
|
227
|
-
|
|
233
|
+
// Copy the export property if it exists
|
|
234
|
+
if (exportValue !== undefined) {
|
|
235
|
+
clonedScript.export = exportValue;
|
|
236
|
+
}
|
|
228
237
|
// Append to this element's children
|
|
229
238
|
this.appendChild(clonedScript);
|
|
230
239
|
}
|
package/Synthesizer.ts
CHANGED
|
@@ -243,22 +243,33 @@ export abstract class Synthesizer extends HTMLElement {
|
|
|
243
243
|
let exportValue = (scriptElement as any).export;
|
|
244
244
|
|
|
245
245
|
if (!exportValue) {
|
|
246
|
-
//
|
|
246
|
+
// Determine which event to wait for based on script type
|
|
247
|
+
const scriptType = scriptElement.getAttribute('type');
|
|
248
|
+
const eventName = scriptType === 'emc-parser' ? 'parser-registered' : 'resolved';
|
|
249
|
+
|
|
250
|
+
// Wait for appropriate event with timeout
|
|
247
251
|
const timeoutPromise = new Promise((_, reject) =>
|
|
248
|
-
setTimeout(() => reject(new Error(
|
|
252
|
+
setTimeout(() => reject(new Error(`Timeout waiting for ${eventName} event`)), 5000)
|
|
249
253
|
);
|
|
250
254
|
|
|
251
|
-
const eventPromise = waitForEvent(scriptElement,
|
|
255
|
+
const eventPromise = waitForEvent(scriptElement, eventName);
|
|
252
256
|
|
|
253
257
|
const event = await Promise.race([eventPromise, timeoutPromise]);
|
|
254
|
-
|
|
258
|
+
|
|
259
|
+
// For parser scripts, we don't need an export value
|
|
260
|
+
// For other scripts, get the export from the event
|
|
261
|
+
if (scriptType !== 'emc-parser') {
|
|
262
|
+
exportValue = (event as any).export;
|
|
263
|
+
}
|
|
255
264
|
}
|
|
256
265
|
|
|
257
266
|
// Clone the script element
|
|
258
267
|
const clonedScript = scriptElement.cloneNode(true) as HTMLScriptElement;
|
|
259
268
|
|
|
260
|
-
// Copy the export property
|
|
261
|
-
(
|
|
269
|
+
// Copy the export property if it exists
|
|
270
|
+
if (exportValue !== undefined) {
|
|
271
|
+
(clonedScript as any).export = exportValue;
|
|
272
|
+
}
|
|
262
273
|
|
|
263
274
|
// Append to this element's children
|
|
264
275
|
this.appendChild(clonedScript);
|