@pie-players/pie-players-shared 0.3.30 → 0.3.31
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/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/loaders/ElementLoader.d.ts +6 -34
- package/dist/loaders/ElementLoader.d.ts.map +1 -1
- package/dist/loaders/ElementLoader.js +21 -9
- package/dist/loaders/ElementLoader.js.map +1 -1
- package/dist/loaders/element-loader-types.d.ts +91 -0
- package/dist/loaders/element-loader-types.d.ts.map +1 -0
- package/dist/loaders/element-loader-types.js +26 -0
- package/dist/loaders/element-loader-types.js.map +1 -0
- package/dist/loaders/element-loader.d.ts +92 -0
- package/dist/loaders/element-loader.d.ts.map +1 -0
- package/dist/loaders/element-loader.js +391 -0
- package/dist/loaders/element-loader.js.map +1 -0
- package/dist/loaders/esm-adapter.d.ts +40 -0
- package/dist/loaders/esm-adapter.d.ts.map +1 -0
- package/dist/loaders/esm-adapter.js +274 -0
- package/dist/loaders/esm-adapter.js.map +1 -0
- package/dist/loaders/iife-adapter.d.ts +86 -0
- package/dist/loaders/iife-adapter.d.ts.map +1 -0
- package/dist/loaders/iife-adapter.js +365 -0
- package/dist/loaders/iife-adapter.js.map +1 -0
- package/dist/loaders/index.d.ts +30 -17
- package/dist/loaders/index.d.ts.map +1 -1
- package/dist/loaders/index.js +26 -14
- package/dist/loaders/index.js.map +1 -1
- package/dist/pie/index.d.ts +4 -4
- package/dist/pie/index.d.ts.map +1 -1
- package/dist/pie/index.js +7 -2
- package/dist/pie/index.js.map +1 -1
- package/dist/pie/initialization.d.ts +26 -1
- package/dist/pie/initialization.d.ts.map +1 -1
- package/dist/pie/initialization.js +72 -15
- package/dist/pie/initialization.js.map +1 -1
- package/dist/pie/instrumentation-event-map.d.ts.map +1 -1
- package/dist/pie/instrumentation-event-map.js +27 -16
- package/dist/pie/instrumentation-event-map.js.map +1 -1
- package/dist/pie/stage-tracker.d.ts +51 -0
- package/dist/pie/stage-tracker.d.ts.map +1 -0
- package/dist/pie/stage-tracker.js +106 -0
- package/dist/pie/stage-tracker.js.map +1 -0
- package/dist/pie/stages.d.ts +75 -0
- package/dist/pie/stages.d.ts.map +1 -0
- package/dist/pie/stages.js +58 -0
- package/dist/pie/stages.js.map +1 -0
- package/dist/pie/use-resource-monitor.svelte.d.ts.map +1 -1
- package/dist/pie/use-resource-monitor.svelte.js +88 -75
- package/dist/pie/use-resource-monitor.svelte.js.map +1 -1
- package/dist/ui/use-promise.svelte.ts +109 -0
- package/package.json +6 -1
- package/dist/loaders/EsmElementLoader.d.ts +0 -69
- package/dist/loaders/EsmElementLoader.d.ts.map +0 -1
- package/dist/loaders/EsmElementLoader.js +0 -72
- package/dist/loaders/EsmElementLoader.js.map +0 -1
- package/dist/loaders/IifeElementLoader.d.ts +0 -61
- package/dist/loaders/IifeElementLoader.d.ts.map +0 -1
- package/dist/loaders/IifeElementLoader.js +0 -63
- package/dist/loaders/IifeElementLoader.js.map +0 -1
- package/dist/pie/esm-loader.d.ts +0 -104
- package/dist/pie/esm-loader.d.ts.map +0 -1
- package/dist/pie/esm-loader.js +0 -358
- package/dist/pie/esm-loader.js.map +0 -1
- package/dist/pie/iife-loader.d.ts +0 -116
- package/dist/pie/iife-loader.d.ts.map +0 -1
- package/dist/pie/iife-loader.js +0 -561
- package/dist/pie/iife-loader.js.map +0 -1
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* </script>
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
import { onDestroy } from "svelte";
|
|
25
|
+
import { onDestroy, untrack } from "svelte";
|
|
26
26
|
import { isInstrumentationProvider } from "../instrumentation/provider-guards.js";
|
|
27
27
|
import { DEFAULT_LOADER_CONFIG } from "../loader-config.js";
|
|
28
28
|
import { createPieLogger } from "./logger.js";
|
|
@@ -45,85 +45,98 @@ export function useResourceMonitor(getHostElement, getLoaderConfig, getDebugEnab
|
|
|
45
45
|
let activeHostElement = $state(null);
|
|
46
46
|
let monitorConfigKey = $state("");
|
|
47
47
|
let activeProvider = $state(undefined);
|
|
48
|
-
// Initialize resource monitor when conditions are met
|
|
48
|
+
// Initialize resource monitor when conditions are met.
|
|
49
|
+
//
|
|
50
|
+
// The body of this effect both reads and writes the local `$state`
|
|
51
|
+
// latches (`monitor`, `isInitialized`, `activeHostElement`,
|
|
52
|
+
// `monitorConfigKey`, `activeProvider`) — those latches exist so the
|
|
53
|
+
// public `instance`/`isActive` getters stay reactive for downstream
|
|
54
|
+
// consumers, but the same-effect read+write would otherwise trip
|
|
55
|
+
// `effect_update_depth_exceeded` on every host/config/provider change
|
|
56
|
+
// (observed in the assessment-player smoke flow during instrumentation
|
|
57
|
+
// provider rebinding). Per `.cursor/rules/svelte-subscription-safety.mdc`,
|
|
58
|
+
// we explicitly track only the input getters and run the body inside
|
|
59
|
+
// `untrack(...)` so the self-mutations don't re-trigger the effect.
|
|
49
60
|
$effect(() => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
loaderConfig?.instrumentationProvider
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
const providerChanged = activeProvider !== resolvedInstrumentationProvider;
|
|
73
|
-
const hostChanged = activeHostElement !== hostElement;
|
|
74
|
-
const configChanged = monitorConfigKey !== nextConfigKey;
|
|
75
|
-
const shouldReinitialize = hostElement && isInitialized && (hostChanged || configChanged || providerChanged);
|
|
76
|
-
// Clean up existing monitor if host element becomes null
|
|
77
|
-
if (!hostElement && monitor) {
|
|
78
|
-
logger.debug(`Host element removed, stopping resource monitor for ${componentName}`);
|
|
79
|
-
monitor.stop();
|
|
80
|
-
monitor = null;
|
|
81
|
-
isInitialized = false;
|
|
82
|
-
activeHostElement = null;
|
|
83
|
-
activeProvider = undefined;
|
|
84
|
-
monitorConfigKey = "";
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (shouldReinitialize && monitor) {
|
|
88
|
-
logger.debug(`Reinitializing resource monitor for ${componentName}`, {
|
|
89
|
-
hostChanged,
|
|
90
|
-
configChanged,
|
|
91
|
-
providerChanged,
|
|
92
|
-
});
|
|
93
|
-
monitor.stop();
|
|
94
|
-
monitor = null;
|
|
95
|
-
isInitialized = false;
|
|
96
|
-
}
|
|
97
|
-
// Initialize if we have a host element (retry logic works independently of trackPageActions)
|
|
98
|
-
if (hostElement && !isInitialized) {
|
|
99
|
-
logger.debug(`Initializing resource monitor for ${componentName}`, {
|
|
61
|
+
void getHostElement();
|
|
62
|
+
void getLoaderConfig();
|
|
63
|
+
void getDebugEnabled();
|
|
64
|
+
untrack(() => {
|
|
65
|
+
const hostElement = getHostElement();
|
|
66
|
+
const loaderConfig = getLoaderConfig();
|
|
67
|
+
const debugEnabled = getDebugEnabled();
|
|
68
|
+
const resolvedTrackPageActions = loaderConfig?.trackPageActions ?? false;
|
|
69
|
+
const resolvedMaxRetries = loaderConfig?.maxResourceRetries ??
|
|
70
|
+
DEFAULT_LOADER_CONFIG.maxResourceRetries;
|
|
71
|
+
const resolvedRetryDelay = loaderConfig?.resourceRetryDelay ??
|
|
72
|
+
DEFAULT_LOADER_CONFIG.resourceRetryDelay;
|
|
73
|
+
const resolvedInstrumentationProvider = isInstrumentationProvider(loaderConfig?.instrumentationProvider)
|
|
74
|
+
? loaderConfig?.instrumentationProvider
|
|
75
|
+
: undefined;
|
|
76
|
+
if (debugEnabled &&
|
|
77
|
+
loaderConfig?.instrumentationProvider &&
|
|
78
|
+
!resolvedInstrumentationProvider) {
|
|
79
|
+
logger.warn(`Ignoring invalid instrumentation provider for ${componentName}; expected InstrumentationProvider contract`);
|
|
80
|
+
}
|
|
81
|
+
const nextConfigKey = JSON.stringify({
|
|
100
82
|
trackPageActions: resolvedTrackPageActions,
|
|
101
83
|
maxRetries: resolvedMaxRetries,
|
|
102
84
|
retryDelay: resolvedRetryDelay,
|
|
103
|
-
|
|
104
|
-
hasContainer: !!hostElement,
|
|
85
|
+
debugEnabled,
|
|
105
86
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
87
|
+
const providerChanged = activeProvider !== resolvedInstrumentationProvider;
|
|
88
|
+
const hostChanged = activeHostElement !== hostElement;
|
|
89
|
+
const configChanged = monitorConfigKey !== nextConfigKey;
|
|
90
|
+
const shouldReinitialize = hostElement && isInitialized && (hostChanged || configChanged || providerChanged);
|
|
91
|
+
if (!hostElement && monitor) {
|
|
92
|
+
logger.debug(`Host element removed, stopping resource monitor for ${componentName}`);
|
|
93
|
+
monitor.stop();
|
|
94
|
+
monitor = null;
|
|
95
|
+
isInitialized = false;
|
|
96
|
+
activeHostElement = null;
|
|
97
|
+
activeProvider = undefined;
|
|
98
|
+
monitorConfigKey = "";
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (shouldReinitialize && monitor) {
|
|
102
|
+
logger.debug(`Reinitializing resource monitor for ${componentName}`, {
|
|
103
|
+
hostChanged,
|
|
104
|
+
configChanged,
|
|
105
|
+
providerChanged,
|
|
106
|
+
});
|
|
107
|
+
monitor.stop();
|
|
108
|
+
monitor = null;
|
|
109
|
+
isInitialized = false;
|
|
110
|
+
}
|
|
111
|
+
if (hostElement && !isInitialized) {
|
|
112
|
+
logger.debug(`Initializing resource monitor for ${componentName}`, {
|
|
113
|
+
trackPageActions: resolvedTrackPageActions,
|
|
114
|
+
maxRetries: resolvedMaxRetries,
|
|
115
|
+
retryDelay: resolvedRetryDelay,
|
|
116
|
+
hasCustomProvider: !!resolvedInstrumentationProvider,
|
|
117
|
+
hasContainer: !!hostElement,
|
|
118
|
+
});
|
|
119
|
+
monitor = new ResourceMonitor({
|
|
120
|
+
trackPageActions: resolvedTrackPageActions,
|
|
121
|
+
instrumentationProvider: resolvedInstrumentationProvider,
|
|
122
|
+
maxRetries: resolvedMaxRetries,
|
|
123
|
+
initialRetryDelay: resolvedRetryDelay,
|
|
124
|
+
maxRetryDelay: DEFAULT_MAX_RETRY_DELAY,
|
|
125
|
+
debug: debugEnabled,
|
|
126
|
+
});
|
|
127
|
+
monitor.start(hostElement);
|
|
128
|
+
isInitialized = true;
|
|
129
|
+
activeHostElement = hostElement;
|
|
130
|
+
activeProvider = resolvedInstrumentationProvider;
|
|
131
|
+
monitorConfigKey = nextConfigKey;
|
|
132
|
+
logger.info(`✅ Resource monitoring enabled for ${componentName}` +
|
|
133
|
+
(resolvedTrackPageActions
|
|
134
|
+
? resolvedInstrumentationProvider
|
|
135
|
+
? " (with custom instrumentation provider)"
|
|
136
|
+
: " (with New Relic tracking)"
|
|
137
|
+
: " (retry only)"));
|
|
138
|
+
}
|
|
139
|
+
});
|
|
127
140
|
});
|
|
128
141
|
// Cleanup on component destroy
|
|
129
142
|
onDestroy(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-resource-monitor.svelte.js","sourceRoot":"","sources":["../../src/pie/use-resource-monitor.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"use-resource-monitor.svelte.js","sourceRoot":"","sources":["../../src/pie/use-resource-monitor.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ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C/B,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,OAAO,EAAE,CAAC;YACb,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;YACjC,MAAM,CAAC,KAAK,CACX,yCAAyC,aAAa,GAAG,EACzD,KAAK,CACL,CAAC;YACF,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,GAAG,IAAI,CAAC;YACf,aAAa,GAAG,KAAK,CAAC;YACtB,iBAAiB,GAAG,IAAI,CAAC;YACzB,cAAc,GAAG,SAAS,CAAC;YAC3B,gBAAgB,GAAG,EAAE,CAAC;QACvB,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,0BAA0B;IAC1B,OAAO;QACN;;WAEG;QACH,IAAI,QAAQ;YACX,OAAO,OAAO,CAAC;QAChB,CAAC;QAED;;WAEG;QACH,QAAQ;YACP,OAAO,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;QACzE,CAAC;QAED;;WAEG;QACH,IAAI,QAAQ;YACX,OAAO,aAAa,IAAI,OAAO,KAAK,IAAI,CAAC;QAC1C,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte 5 composable that turns a promise factory into a reactive lifecycle
|
|
3
|
+
* value with four explicit states. Consumers read `handle.current` in a
|
|
4
|
+
* `$derived`/template and get race-free status transitions.
|
|
5
|
+
*
|
|
6
|
+
* Why this exists
|
|
7
|
+
* ---------------
|
|
8
|
+
*
|
|
9
|
+
* Svelte 5's reactivity is runes-based, and placing a promise directly inside
|
|
10
|
+
* a `$derived` is awkward: the derived value is the promise itself, and the
|
|
11
|
+
* component needs to await it indirectly, usually via an ad-hoc `$state` flag
|
|
12
|
+
* set from a `$effect`. That pattern is the root cause of the section-swap
|
|
13
|
+
* readiness race fixed as part of the deep ElementLoader architecture work:
|
|
14
|
+
*
|
|
15
|
+
* let ready = $state(false);
|
|
16
|
+
* $effect(() => { loader(args).then(() => ready = true); });
|
|
17
|
+
* {#if ready} <Items /> {/if}
|
|
18
|
+
*
|
|
19
|
+
* When `args` change under a live component, `ready` can be stale while the
|
|
20
|
+
* template has already re-rendered with the new inputs. The fix is to treat
|
|
21
|
+
* the loader call as a lifecycle value that (a) carries its own status,
|
|
22
|
+
* (b) invalidates instantly when its inputs change, and (c) ignores late
|
|
23
|
+
* resolutions from stale invocations.
|
|
24
|
+
*
|
|
25
|
+
* Contract
|
|
26
|
+
* --------
|
|
27
|
+
*
|
|
28
|
+
* - The factory is called reactively; every tracked read inside the factory
|
|
29
|
+
* participates in the effect's dependencies.
|
|
30
|
+
* - When the factory returns `null`, the handle moves back to `idle`.
|
|
31
|
+
* - Each invocation is tagged with a monotonic token; only the most-recent
|
|
32
|
+
* invocation can transition the handle out of `pending`. Earlier
|
|
33
|
+
* resolutions are silently dropped.
|
|
34
|
+
* - `handle.current` is the single read surface; the underlying `$state` is
|
|
35
|
+
* not exposed. Templates use `{#if handle.current.status === "resolved"}`.
|
|
36
|
+
*
|
|
37
|
+
* Example
|
|
38
|
+
* -------
|
|
39
|
+
*
|
|
40
|
+
* ```svelte
|
|
41
|
+
* <script lang="ts">
|
|
42
|
+
* import { usePromise } from "@pie-players/pie-players-shared/ui";
|
|
43
|
+
*
|
|
44
|
+
* let { items } = $props();
|
|
45
|
+
*
|
|
46
|
+
* const readiness = usePromise(() =>
|
|
47
|
+
* items.length === 0 ? null : loader.ensureRegistered(aggregate(items)),
|
|
48
|
+
* );
|
|
49
|
+
* </script>
|
|
50
|
+
*
|
|
51
|
+
* {#if readiness.current.status === "resolved"}
|
|
52
|
+
* {#each items as item}<item-card {item} />{/each}
|
|
53
|
+
* {:else if readiness.current.status === "rejected"}
|
|
54
|
+
* <ErrorBanner error={readiness.current.error} />
|
|
55
|
+
* {:else}
|
|
56
|
+
* <LoadingSpinner />
|
|
57
|
+
* {/if}
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
export type PromiseState<T> =
|
|
62
|
+
| { status: "idle" }
|
|
63
|
+
| { status: "pending" }
|
|
64
|
+
| { status: "resolved"; data: T }
|
|
65
|
+
| { status: "rejected"; error: unknown };
|
|
66
|
+
|
|
67
|
+
export type PromiseHandle<T> = {
|
|
68
|
+
readonly current: PromiseState<T>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Reactive promise lifecycle helper.
|
|
73
|
+
*
|
|
74
|
+
* @param factory Function that returns the promise to track, or `null` to
|
|
75
|
+
* return to `idle`. Called inside a `$effect`, so every reactive read
|
|
76
|
+
* participates in the invalidation graph.
|
|
77
|
+
*/
|
|
78
|
+
export function usePromise<T>(
|
|
79
|
+
factory: () => Promise<T> | null | undefined,
|
|
80
|
+
): PromiseHandle<T> {
|
|
81
|
+
let state = $state<PromiseState<T>>({ status: "idle" });
|
|
82
|
+
let token = 0;
|
|
83
|
+
|
|
84
|
+
$effect(() => {
|
|
85
|
+
const promise = factory();
|
|
86
|
+
if (!promise) {
|
|
87
|
+
state = { status: "idle" };
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const thisToken = ++token;
|
|
91
|
+
state = { status: "pending" };
|
|
92
|
+
promise.then(
|
|
93
|
+
(data) => {
|
|
94
|
+
if (thisToken !== token) return;
|
|
95
|
+
state = { status: "resolved", data };
|
|
96
|
+
},
|
|
97
|
+
(error) => {
|
|
98
|
+
if (thisToken !== token) return;
|
|
99
|
+
state = { status: "rejected", error };
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
get current() {
|
|
106
|
+
return state;
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-players/pie-players-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared runtime + UI utilities for PIE players",
|
|
6
6
|
"license": "MIT",
|
|
@@ -101,6 +101,11 @@
|
|
|
101
101
|
"types": "./dist/i18n/use-i18n-standalone.svelte.ts",
|
|
102
102
|
"import": "./dist/i18n/use-i18n-standalone.svelte.ts",
|
|
103
103
|
"svelte": "./dist/i18n/use-i18n-standalone.svelte.ts"
|
|
104
|
+
},
|
|
105
|
+
"./ui/use-promise": {
|
|
106
|
+
"types": "./dist/ui/use-promise.svelte.ts",
|
|
107
|
+
"import": "./dist/ui/use-promise.svelte.ts",
|
|
108
|
+
"svelte": "./dist/ui/use-promise.svelte.ts"
|
|
104
109
|
}
|
|
105
110
|
},
|
|
106
111
|
"files": [
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ESM Element Loader
|
|
3
|
-
*
|
|
4
|
-
* Wraps EsmPieLoader to provide element-level loading abstraction.
|
|
5
|
-
* Aggregates elements from multiple items and loads them once using ESM modules.
|
|
6
|
-
*/
|
|
7
|
-
import type { ItemEntity } from "../types/index.js";
|
|
8
|
-
import { type ElementLoaderInterface, type ElementMap, type LoadOptions } from "./ElementLoader.js";
|
|
9
|
-
/**
|
|
10
|
-
* Configuration for ESM element loader
|
|
11
|
-
*/
|
|
12
|
-
export interface EsmElementLoaderConfig {
|
|
13
|
-
/** Base URL for ESM CDN (e.g., "https://esm.sh") */
|
|
14
|
-
esmCdnUrl: string;
|
|
15
|
-
/** Module resolution mode (default: "url") */
|
|
16
|
-
moduleResolution?: "url" | "import-map";
|
|
17
|
-
/** Optional function to check if debug mode is enabled */
|
|
18
|
-
debugEnabled?: () => boolean;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Element loader for ESM (ES Modules) bundles
|
|
22
|
-
*
|
|
23
|
-
* This loader wraps EsmPieLoader and provides element aggregation capabilities.
|
|
24
|
-
* It eliminates duplicate bundle loads when multiple items use the same PIE elements.
|
|
25
|
-
* ESM is the modern, preferred loading mechanism with better browser support and features.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const loader = new EsmElementLoader({
|
|
30
|
-
* esmCdnUrl: 'https://esm.sh'
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // Load elements from multiple items at once
|
|
34
|
-
* await loader.loadFromItems(section.items, {
|
|
35
|
-
* view: 'delivery',
|
|
36
|
-
* needsControllers: true
|
|
37
|
-
* });
|
|
38
|
-
*
|
|
39
|
-
* // Or load specific elements directly
|
|
40
|
-
* await loader.loadElements({
|
|
41
|
-
* 'pie-multiple-choice': '@pie-element/multiple-choice@11.0.1',
|
|
42
|
-
* 'pie-hotspot': '@pie-element/hotspot@9.0.0'
|
|
43
|
-
* }, {
|
|
44
|
-
* view: 'author' // Load author view for editing
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare class EsmElementLoader implements ElementLoaderInterface {
|
|
49
|
-
private loader;
|
|
50
|
-
constructor(config: EsmElementLoaderConfig);
|
|
51
|
-
/**
|
|
52
|
-
* Load elements directly from an element map
|
|
53
|
-
*
|
|
54
|
-
* @param elements - Map of element tag names to package versions
|
|
55
|
-
* @param options - Loading options
|
|
56
|
-
*/
|
|
57
|
-
loadElements(elements: ElementMap, options?: LoadOptions): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Extract and load elements from items
|
|
60
|
-
*
|
|
61
|
-
* Automatically aggregates unique elements from all items and loads them once.
|
|
62
|
-
*
|
|
63
|
-
* @param items - Array of items to extract elements from
|
|
64
|
-
* @param options - Loading options
|
|
65
|
-
* @throws Error if element version conflicts are detected
|
|
66
|
-
*/
|
|
67
|
-
loadFromItems(items: ItemEntity[], options?: LoadOptions): Promise<void>;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=EsmElementLoader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EsmElementLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/EsmElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAElB,8CAA8C;IAC9C,gBAAgB,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC;IAExC,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,gBAAiB,YAAW,sBAAsB;IAC9D,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,sBAAsB;IAQ1C;;;;;OAKG;IACG,YAAY,CACjB,QAAQ,EAAE,UAAU,EACpB,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;IAOhB;;;;;;;;OAQG;IACG,aAAa,CAClB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;CAIhB"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ESM Element Loader
|
|
3
|
-
*
|
|
4
|
-
* Wraps EsmPieLoader to provide element-level loading abstraction.
|
|
5
|
-
* Aggregates elements from multiple items and loads them once using ESM modules.
|
|
6
|
-
*/
|
|
7
|
-
import { EsmPieLoader } from "../pie/esm-loader.js";
|
|
8
|
-
import { aggregateElements, } from "./ElementLoader.js";
|
|
9
|
-
/**
|
|
10
|
-
* Element loader for ESM (ES Modules) bundles
|
|
11
|
-
*
|
|
12
|
-
* This loader wraps EsmPieLoader and provides element aggregation capabilities.
|
|
13
|
-
* It eliminates duplicate bundle loads when multiple items use the same PIE elements.
|
|
14
|
-
* ESM is the modern, preferred loading mechanism with better browser support and features.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const loader = new EsmElementLoader({
|
|
19
|
-
* esmCdnUrl: 'https://esm.sh'
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // Load elements from multiple items at once
|
|
23
|
-
* await loader.loadFromItems(section.items, {
|
|
24
|
-
* view: 'delivery',
|
|
25
|
-
* needsControllers: true
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // Or load specific elements directly
|
|
29
|
-
* await loader.loadElements({
|
|
30
|
-
* 'pie-multiple-choice': '@pie-element/multiple-choice@11.0.1',
|
|
31
|
-
* 'pie-hotspot': '@pie-element/hotspot@9.0.0'
|
|
32
|
-
* }, {
|
|
33
|
-
* view: 'author' // Load author view for editing
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export class EsmElementLoader {
|
|
38
|
-
loader;
|
|
39
|
-
constructor(config) {
|
|
40
|
-
this.loader = new EsmPieLoader({
|
|
41
|
-
cdnBaseUrl: config.esmCdnUrl,
|
|
42
|
-
moduleResolution: config.moduleResolution,
|
|
43
|
-
debugEnabled: config.debugEnabled,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Load elements directly from an element map
|
|
48
|
-
*
|
|
49
|
-
* @param elements - Map of element tag names to package versions
|
|
50
|
-
* @param options - Loading options
|
|
51
|
-
*/
|
|
52
|
-
async loadElements(elements, options) {
|
|
53
|
-
await this.loader.load({ elements }, document, {
|
|
54
|
-
view: options?.view || "delivery",
|
|
55
|
-
loadControllers: options?.needsControllers ?? true,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Extract and load elements from items
|
|
60
|
-
*
|
|
61
|
-
* Automatically aggregates unique elements from all items and loads them once.
|
|
62
|
-
*
|
|
63
|
-
* @param items - Array of items to extract elements from
|
|
64
|
-
* @param options - Loading options
|
|
65
|
-
* @throws Error if element version conflicts are detected
|
|
66
|
-
*/
|
|
67
|
-
async loadFromItems(items, options) {
|
|
68
|
-
const elements = aggregateElements(items);
|
|
69
|
-
await this.loadElements(elements, options);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=EsmElementLoader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EsmElementLoader.js","sourceRoot":"","sources":["../../src/loaders/EsmElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EACN,iBAAiB,GAIjB,MAAM,oBAAoB,CAAC;AAgB5B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,gBAAgB;IACpB,MAAM,CAAe;IAE7B,YAAY,MAA8B;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,YAAY,CAAC;YAC9B,UAAU,EAAE,MAAM,CAAC,SAAS;YAC5B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,YAAY,EAAE,MAAM,CAAC,YAAY;SACjC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CACjB,QAAoB,EACpB,OAAqB;QAErB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE;YAC9C,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,UAAU;YACjC,eAAe,EAAE,OAAO,EAAE,gBAAgB,IAAI,IAAI;SAClD,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,aAAa,CAClB,KAAmB,EACnB,OAAqB;QAErB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;CACD"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IIFE Element Loader
|
|
3
|
-
*
|
|
4
|
-
* Wraps IifePieLoader to provide element-level loading abstraction.
|
|
5
|
-
* Aggregates elements from multiple items and loads them once using IIFE bundles.
|
|
6
|
-
*/
|
|
7
|
-
import type { ItemEntity } from "../types/index.js";
|
|
8
|
-
import { type ElementLoaderInterface, type ElementMap, type LoadOptions } from "./ElementLoader.js";
|
|
9
|
-
/**
|
|
10
|
-
* Configuration for IIFE element loader
|
|
11
|
-
*/
|
|
12
|
-
export interface IifeElementLoaderConfig {
|
|
13
|
-
/** Base URL for bundle service (e.g., "https://bundles.pie.org") */
|
|
14
|
-
bundleHost: string;
|
|
15
|
-
/** Optional function to check if debug mode is enabled */
|
|
16
|
-
debugEnabled?: () => boolean;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Element loader for IIFE (Immediately Invoked Function Expression) bundles
|
|
20
|
-
*
|
|
21
|
-
* This loader wraps IifePieLoader and provides element aggregation capabilities.
|
|
22
|
-
* It eliminates duplicate bundle loads when multiple items use the same PIE elements.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* const loader = new IifeElementLoader({
|
|
27
|
-
* bundleHost: 'https://bundles.pie.org'
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Load elements from multiple items at once
|
|
31
|
-
* await loader.loadFromItems(section.items);
|
|
32
|
-
*
|
|
33
|
-
* // Or load specific elements directly
|
|
34
|
-
* await loader.loadElements({
|
|
35
|
-
* 'pie-multiple-choice': '@pie-element/multiple-choice@11.0.1',
|
|
36
|
-
* 'pie-hotspot': '@pie-element/hotspot@9.0.0'
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare class IifeElementLoader implements ElementLoaderInterface {
|
|
41
|
-
private loader;
|
|
42
|
-
constructor(config: IifeElementLoaderConfig);
|
|
43
|
-
/**
|
|
44
|
-
* Load elements directly from an element map
|
|
45
|
-
*
|
|
46
|
-
* @param elements - Map of element tag names to package versions
|
|
47
|
-
* @param options - Loading options
|
|
48
|
-
*/
|
|
49
|
-
loadElements(elements: ElementMap, options?: LoadOptions): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Extract and load elements from items
|
|
52
|
-
*
|
|
53
|
-
* Automatically aggregates unique elements from all items and loads them once.
|
|
54
|
-
*
|
|
55
|
-
* @param items - Array of items to extract elements from
|
|
56
|
-
* @param options - Loading options
|
|
57
|
-
* @throws Error if element version conflicts are detected
|
|
58
|
-
*/
|
|
59
|
-
loadFromItems(items: ItemEntity[], options?: LoadOptions): Promise<void>;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=IifeElementLoader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IifeElementLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/IifeElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IAEnB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,iBAAkB,YAAW,sBAAsB;IAC/D,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,uBAAuB;IAO3C;;;;;OAKG;IACG,YAAY,CACjB,QAAQ,EAAE,UAAU,EACpB,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;IAShB;;;;;;;;OAQG;IACG,aAAa,CAClB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC;CAIhB"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IIFE Element Loader
|
|
3
|
-
*
|
|
4
|
-
* Wraps IifePieLoader to provide element-level loading abstraction.
|
|
5
|
-
* Aggregates elements from multiple items and loads them once using IIFE bundles.
|
|
6
|
-
*/
|
|
7
|
-
import { IifePieLoader } from "../pie/iife-loader.js";
|
|
8
|
-
import { BundleType } from "../pie/types.js";
|
|
9
|
-
import { aggregateElements, } from "./ElementLoader.js";
|
|
10
|
-
/**
|
|
11
|
-
* Element loader for IIFE (Immediately Invoked Function Expression) bundles
|
|
12
|
-
*
|
|
13
|
-
* This loader wraps IifePieLoader and provides element aggregation capabilities.
|
|
14
|
-
* It eliminates duplicate bundle loads when multiple items use the same PIE elements.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const loader = new IifeElementLoader({
|
|
19
|
-
* bundleHost: 'https://bundles.pie.org'
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // Load elements from multiple items at once
|
|
23
|
-
* await loader.loadFromItems(section.items);
|
|
24
|
-
*
|
|
25
|
-
* // Or load specific elements directly
|
|
26
|
-
* await loader.loadElements({
|
|
27
|
-
* 'pie-multiple-choice': '@pie-element/multiple-choice@11.0.1',
|
|
28
|
-
* 'pie-hotspot': '@pie-element/hotspot@9.0.0'
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export class IifeElementLoader {
|
|
33
|
-
loader;
|
|
34
|
-
constructor(config) {
|
|
35
|
-
this.loader = new IifePieLoader({
|
|
36
|
-
bundleHost: config.bundleHost,
|
|
37
|
-
debugEnabled: config.debugEnabled,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Load elements directly from an element map
|
|
42
|
-
*
|
|
43
|
-
* @param elements - Map of element tag names to package versions
|
|
44
|
-
* @param options - Loading options
|
|
45
|
-
*/
|
|
46
|
-
async loadElements(elements, options) {
|
|
47
|
-
await this.loader.load({ elements }, document, options?.bundleType || BundleType.clientPlayer, options?.needsControllers ?? true);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Extract and load elements from items
|
|
51
|
-
*
|
|
52
|
-
* Automatically aggregates unique elements from all items and loads them once.
|
|
53
|
-
*
|
|
54
|
-
* @param items - Array of items to extract elements from
|
|
55
|
-
* @param options - Loading options
|
|
56
|
-
* @throws Error if element version conflicts are detected
|
|
57
|
-
*/
|
|
58
|
-
async loadFromItems(items, options) {
|
|
59
|
-
const elements = aggregateElements(items);
|
|
60
|
-
await this.loadElements(elements, options);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=IifeElementLoader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IifeElementLoader.js","sourceRoot":"","sources":["../../src/loaders/IifeElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EACN,iBAAiB,GAIjB,MAAM,oBAAoB,CAAC;AAa5B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,iBAAiB;IACrB,MAAM,CAAgB;IAE9B,YAAY,MAA+B;QAC1C,IAAI,CAAC,MAAM,GAAG,IAAI,aAAa,CAAC;YAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,YAAY,EAAE,MAAM,CAAC,YAAY;SACjC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CACjB,QAAoB,EACpB,OAAqB;QAErB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,EAAE,QAAQ,EAAE,EACZ,QAAQ,EACR,OAAO,EAAE,UAAU,IAAI,UAAU,CAAC,YAAY,EAC9C,OAAO,EAAE,gBAAgB,IAAI,IAAI,CACjC,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,aAAa,CAClB,KAAmB,EACnB,OAAqB;QAErB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;CACD"}
|