@pie-players/pie-players-shared 0.2.0

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.
Files changed (233) hide show
  1. package/dist/config/profile.d.ts +15 -0
  2. package/dist/config/profile.d.ts.map +1 -0
  3. package/dist/config/profile.js +27 -0
  4. package/dist/config/profile.js.map +1 -0
  5. package/dist/i18n/index.d.ts +13 -0
  6. package/dist/i18n/index.d.ts.map +1 -0
  7. package/dist/i18n/index.js +12 -0
  8. package/dist/i18n/index.js.map +1 -0
  9. package/dist/i18n/loader.d.ts +36 -0
  10. package/dist/i18n/loader.d.ts.map +1 -0
  11. package/dist/i18n/loader.js +133 -0
  12. package/dist/i18n/loader.js.map +1 -0
  13. package/dist/i18n/scripts/check-coverage.d.ts +16 -0
  14. package/dist/i18n/scripts/check-coverage.d.ts.map +1 -0
  15. package/dist/i18n/scripts/check-coverage.js +262 -0
  16. package/dist/i18n/scripts/check-coverage.js.map +1 -0
  17. package/dist/i18n/scripts/scan-hardcoded.d.ts +16 -0
  18. package/dist/i18n/scripts/scan-hardcoded.d.ts.map +1 -0
  19. package/dist/i18n/scripts/scan-hardcoded.js +266 -0
  20. package/dist/i18n/scripts/scan-hardcoded.js.map +1 -0
  21. package/dist/i18n/simple-i18n.d.ts +69 -0
  22. package/dist/i18n/simple-i18n.d.ts.map +1 -0
  23. package/dist/i18n/simple-i18n.js +199 -0
  24. package/dist/i18n/simple-i18n.js.map +1 -0
  25. package/dist/i18n/translations/ar/common.json +36 -0
  26. package/dist/i18n/translations/ar/toolkit.json +48 -0
  27. package/dist/i18n/translations/ar/tools.json +109 -0
  28. package/dist/i18n/translations/en/common.json +36 -0
  29. package/dist/i18n/translations/en/toolkit.json +48 -0
  30. package/dist/i18n/translations/en/tools.json +109 -0
  31. package/dist/i18n/translations/es/common.json +36 -0
  32. package/dist/i18n/translations/es/toolkit.json +48 -0
  33. package/dist/i18n/translations/es/tools.json +109 -0
  34. package/dist/i18n/translations/zh/common.json +36 -0
  35. package/dist/i18n/translations/zh/toolkit.json +48 -0
  36. package/dist/i18n/translations/zh/tools.json +109 -0
  37. package/dist/i18n/types.d.ts +58 -0
  38. package/dist/i18n/types.d.ts.map +1 -0
  39. package/dist/i18n/types.js +8 -0
  40. package/dist/i18n/types.js.map +1 -0
  41. package/dist/i18n/use-i18n-standalone.svelte.d.ts +87 -0
  42. package/dist/i18n/use-i18n-standalone.svelte.d.ts.map +1 -0
  43. package/dist/i18n/use-i18n-standalone.svelte.js +151 -0
  44. package/dist/i18n/use-i18n-standalone.svelte.js.map +1 -0
  45. package/dist/i18n/use-i18n.svelte.d.ts +67 -0
  46. package/dist/i18n/use-i18n.svelte.d.ts.map +1 -0
  47. package/dist/i18n/use-i18n.svelte.js +144 -0
  48. package/dist/i18n/use-i18n.svelte.js.map +1 -0
  49. package/dist/index.d.ts +11 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +11 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/instrumentation/index.d.ts +53 -0
  54. package/dist/instrumentation/index.d.ts.map +1 -0
  55. package/dist/instrumentation/index.js +53 -0
  56. package/dist/instrumentation/index.js.map +1 -0
  57. package/dist/instrumentation/providers/BaseInstrumentationProvider.d.ts +197 -0
  58. package/dist/instrumentation/providers/BaseInstrumentationProvider.d.ts.map +1 -0
  59. package/dist/instrumentation/providers/BaseInstrumentationProvider.js +267 -0
  60. package/dist/instrumentation/providers/BaseInstrumentationProvider.js.map +1 -0
  61. package/dist/instrumentation/providers/ConsoleInstrumentationProvider.d.ts +106 -0
  62. package/dist/instrumentation/providers/ConsoleInstrumentationProvider.d.ts.map +1 -0
  63. package/dist/instrumentation/providers/ConsoleInstrumentationProvider.js +182 -0
  64. package/dist/instrumentation/providers/ConsoleInstrumentationProvider.js.map +1 -0
  65. package/dist/instrumentation/providers/DataDogInstrumentationProvider.d.ts +170 -0
  66. package/dist/instrumentation/providers/DataDogInstrumentationProvider.d.ts.map +1 -0
  67. package/dist/instrumentation/providers/DataDogInstrumentationProvider.js +183 -0
  68. package/dist/instrumentation/providers/DataDogInstrumentationProvider.js.map +1 -0
  69. package/dist/instrumentation/providers/NewRelicInstrumentationProvider.d.ts +86 -0
  70. package/dist/instrumentation/providers/NewRelicInstrumentationProvider.d.ts.map +1 -0
  71. package/dist/instrumentation/providers/NewRelicInstrumentationProvider.js +135 -0
  72. package/dist/instrumentation/providers/NewRelicInstrumentationProvider.js.map +1 -0
  73. package/dist/instrumentation/providers/index.d.ts +12 -0
  74. package/dist/instrumentation/providers/index.d.ts.map +1 -0
  75. package/dist/instrumentation/providers/index.js +12 -0
  76. package/dist/instrumentation/providers/index.js.map +1 -0
  77. package/dist/instrumentation/types.d.ts +348 -0
  78. package/dist/instrumentation/types.d.ts.map +1 -0
  79. package/dist/instrumentation/types.js +9 -0
  80. package/dist/instrumentation/types.js.map +1 -0
  81. package/dist/loader-config.d.ts +76 -0
  82. package/dist/loader-config.d.ts.map +1 -0
  83. package/dist/loader-config.js +12 -0
  84. package/dist/loader-config.js.map +1 -0
  85. package/dist/loaders/ElementLoader.d.ts +72 -0
  86. package/dist/loaders/ElementLoader.d.ts.map +1 -0
  87. package/dist/loaders/ElementLoader.js +52 -0
  88. package/dist/loaders/ElementLoader.js.map +1 -0
  89. package/dist/loaders/EsmElementLoader.d.ts +67 -0
  90. package/dist/loaders/EsmElementLoader.d.ts.map +1 -0
  91. package/dist/loaders/EsmElementLoader.js +71 -0
  92. package/dist/loaders/EsmElementLoader.js.map +1 -0
  93. package/dist/loaders/IifeElementLoader.d.ts +61 -0
  94. package/dist/loaders/IifeElementLoader.d.ts.map +1 -0
  95. package/dist/loaders/IifeElementLoader.js +63 -0
  96. package/dist/loaders/IifeElementLoader.js.map +1 -0
  97. package/dist/loaders/index.d.ts +28 -0
  98. package/dist/loaders/index.d.ts.map +1 -0
  99. package/dist/loaders/index.js +25 -0
  100. package/dist/loaders/index.js.map +1 -0
  101. package/dist/object/index.d.ts +12 -0
  102. package/dist/object/index.d.ts.map +1 -0
  103. package/dist/object/index.js +40 -0
  104. package/dist/object/index.js.map +1 -0
  105. package/dist/pie/asset-handler.d.ts +64 -0
  106. package/dist/pie/asset-handler.d.ts.map +1 -0
  107. package/dist/pie/asset-handler.js +238 -0
  108. package/dist/pie/asset-handler.js.map +1 -0
  109. package/dist/pie/component-context.d.ts +22 -0
  110. package/dist/pie/component-context.d.ts.map +1 -0
  111. package/dist/pie/component-context.js +30 -0
  112. package/dist/pie/component-context.js.map +1 -0
  113. package/dist/pie/config.d.ts +39 -0
  114. package/dist/pie/config.d.ts.map +1 -0
  115. package/dist/pie/config.js +174 -0
  116. package/dist/pie/config.js.map +1 -0
  117. package/dist/pie/configure-initialization.d.ts +35 -0
  118. package/dist/pie/configure-initialization.d.ts.map +1 -0
  119. package/dist/pie/configure-initialization.js +141 -0
  120. package/dist/pie/configure-initialization.js.map +1 -0
  121. package/dist/pie/esm-loader.d.ts +93 -0
  122. package/dist/pie/esm-loader.d.ts.map +1 -0
  123. package/dist/pie/esm-loader.js +308 -0
  124. package/dist/pie/esm-loader.js.map +1 -0
  125. package/dist/pie/iife-loader.d.ts +76 -0
  126. package/dist/pie/iife-loader.d.ts.map +1 -0
  127. package/dist/pie/iife-loader.js +303 -0
  128. package/dist/pie/iife-loader.js.map +1 -0
  129. package/dist/pie/index.d.ts +31 -0
  130. package/dist/pie/index.d.ts.map +1 -0
  131. package/dist/pie/index.js +34 -0
  132. package/dist/pie/index.js.map +1 -0
  133. package/dist/pie/initialization.d.ts +40 -0
  134. package/dist/pie/initialization.d.ts.map +1 -0
  135. package/dist/pie/initialization.js +349 -0
  136. package/dist/pie/initialization.js.map +1 -0
  137. package/dist/pie/logger.d.ts +64 -0
  138. package/dist/pie/logger.d.ts.map +1 -0
  139. package/dist/pie/logger.js +45 -0
  140. package/dist/pie/logger.js.map +1 -0
  141. package/dist/pie/math-rendering.d.ts +69 -0
  142. package/dist/pie/math-rendering.d.ts.map +1 -0
  143. package/dist/pie/math-rendering.js +98 -0
  144. package/dist/pie/math-rendering.js.map +1 -0
  145. package/dist/pie/overrides.d.ts +43 -0
  146. package/dist/pie/overrides.d.ts.map +1 -0
  147. package/dist/pie/overrides.js +146 -0
  148. package/dist/pie/overrides.js.map +1 -0
  149. package/dist/pie/player-initializer.d.ts +55 -0
  150. package/dist/pie/player-initializer.d.ts.map +1 -0
  151. package/dist/pie/player-initializer.js +123 -0
  152. package/dist/pie/player-initializer.js.map +1 -0
  153. package/dist/pie/registry.d.ts +11 -0
  154. package/dist/pie/registry.d.ts.map +1 -0
  155. package/dist/pie/registry.js +21 -0
  156. package/dist/pie/registry.js.map +1 -0
  157. package/dist/pie/resource-monitor.d.ts +208 -0
  158. package/dist/pie/resource-monitor.d.ts.map +1 -0
  159. package/dist/pie/resource-monitor.js +969 -0
  160. package/dist/pie/resource-monitor.js.map +1 -0
  161. package/dist/pie/scoring.d.ts +17 -0
  162. package/dist/pie/scoring.d.ts.map +1 -0
  163. package/dist/pie/scoring.js +84 -0
  164. package/dist/pie/scoring.js.map +1 -0
  165. package/dist/pie/types.d.ts +136 -0
  166. package/dist/pie/types.d.ts.map +1 -0
  167. package/dist/pie/types.js +52 -0
  168. package/dist/pie/types.js.map +1 -0
  169. package/dist/pie/updates.d.ts +20 -0
  170. package/dist/pie/updates.d.ts.map +1 -0
  171. package/dist/pie/updates.js +175 -0
  172. package/dist/pie/updates.js.map +1 -0
  173. package/dist/pie/use-resource-monitor.svelte.d.ts +56 -0
  174. package/dist/pie/use-resource-monitor.svelte.d.ts.map +1 -0
  175. package/dist/pie/use-resource-monitor.svelte.js +117 -0
  176. package/dist/pie/use-resource-monitor.svelte.js.map +1 -0
  177. package/dist/pie/utils.d.ts +44 -0
  178. package/dist/pie/utils.d.ts.map +1 -0
  179. package/dist/pie/utils.js +74 -0
  180. package/dist/pie/utils.js.map +1 -0
  181. package/dist/types/custom-elements.d.ts +183 -0
  182. package/dist/types/custom-elements.d.ts.map +1 -0
  183. package/dist/types/custom-elements.js +8 -0
  184. package/dist/types/custom-elements.js.map +1 -0
  185. package/dist/types/index.d.ts +761 -0
  186. package/dist/types/index.d.ts.map +1 -0
  187. package/dist/types/index.js +120 -0
  188. package/dist/types/index.js.map +1 -0
  189. package/dist/types/search.d.ts +105 -0
  190. package/dist/types/search.d.ts.map +1 -0
  191. package/dist/types/search.js +12 -0
  192. package/dist/types/search.js.map +1 -0
  193. package/dist/types/transform.d.ts +48 -0
  194. package/dist/types/transform.d.ts.map +1 -0
  195. package/dist/types/transform.js +21 -0
  196. package/dist/types/transform.js.map +1 -0
  197. package/dist/ui/focus-trap.d.ts +10 -0
  198. package/dist/ui/focus-trap.d.ts.map +1 -0
  199. package/dist/ui/focus-trap.js +30 -0
  200. package/dist/ui/focus-trap.js.map +1 -0
  201. package/dist/ui/safe-storage.d.ts +3 -0
  202. package/dist/ui/safe-storage.d.ts.map +1 -0
  203. package/dist/ui/safe-storage.js +21 -0
  204. package/dist/ui/safe-storage.js.map +1 -0
  205. package/package.json +118 -0
  206. package/src/components/PieItemPlayer.svelte +604 -0
  207. package/src/components/PiePreviewLayout.svelte +144 -0
  208. package/src/components/PiePreviewToggle.svelte +110 -0
  209. package/src/components/PieSpinner.svelte +85 -0
  210. package/src/components/ToolSettingsButton.svelte +31 -0
  211. package/src/components/ToolSettingsPanel.svelte +90 -0
  212. package/src/components/index.ts +6 -0
  213. package/src/i18n/README.md +223 -0
  214. package/src/i18n/index.ts +26 -0
  215. package/src/i18n/loader.ts +156 -0
  216. package/src/i18n/scripts/check-coverage.ts +345 -0
  217. package/src/i18n/scripts/scan-hardcoded.ts +342 -0
  218. package/src/i18n/simple-i18n.ts +236 -0
  219. package/src/i18n/translations/ar/common.json +36 -0
  220. package/src/i18n/translations/ar/toolkit.json +48 -0
  221. package/src/i18n/translations/ar/tools.json +109 -0
  222. package/src/i18n/translations/en/common.json +36 -0
  223. package/src/i18n/translations/en/toolkit.json +48 -0
  224. package/src/i18n/translations/en/tools.json +109 -0
  225. package/src/i18n/translations/es/common.json +36 -0
  226. package/src/i18n/translations/es/toolkit.json +48 -0
  227. package/src/i18n/translations/es/tools.json +109 -0
  228. package/src/i18n/translations/zh/common.json +36 -0
  229. package/src/i18n/translations/zh/toolkit.json +48 -0
  230. package/src/i18n/translations/zh/tools.json +109 -0
  231. package/src/i18n/types.ts +66 -0
  232. package/src/i18n/use-i18n-standalone.svelte.ts +184 -0
  233. package/src/i18n/use-i18n.svelte.ts +163 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Shared loader configuration for PIE custom elements.
3
+ *
4
+ * Mirrors the `LoaderConfig` used by PIEOneer's custom element tags.
5
+ */
6
+ import type { InstrumentationProvider } from "./instrumentation/types";
7
+ export type LoaderConfig = {
8
+ /**
9
+ * Enable tracking page actions/events.
10
+ *
11
+ * When true, instrumentation events will be sent to the instrumentation provider.
12
+ */
13
+ trackPageActions?: boolean;
14
+ /**
15
+ * Instrumentation provider for tracking events and errors.
16
+ *
17
+ * Optional. If not provided, defaults to NewRelicInstrumentationProvider.
18
+ * The provider handles instrumentation gracefully - if New Relic (or the configured
19
+ * backend) is not available, it will simply not track events (no errors thrown).
20
+ *
21
+ * @example Using New Relic (default - no configuration needed)
22
+ * ```typescript
23
+ * // Just enable tracking - will use New Relic if window.newrelic is available
24
+ * const loaderConfig = {
25
+ * trackPageActions: true
26
+ * };
27
+ * ```
28
+ *
29
+ * @example Using DataDog
30
+ * ```typescript
31
+ * import { DataDogInstrumentationProvider } from '@pie-players/pie-players-shared';
32
+ *
33
+ * const provider = new DataDogInstrumentationProvider();
34
+ * await provider.initialize({
35
+ * providerSettings: {
36
+ * applicationId: 'abc123',
37
+ * clientToken: 'pub_xyz'
38
+ * }
39
+ * });
40
+ *
41
+ * const loaderConfig = {
42
+ * trackPageActions: true,
43
+ * instrumentationProvider: provider
44
+ * };
45
+ * ```
46
+ *
47
+ * @example Using Console provider (for development/debugging)
48
+ * ```typescript
49
+ * import { ConsoleInstrumentationProvider } from '@pie-players/pie-players-shared';
50
+ *
51
+ * const provider = new ConsoleInstrumentationProvider({ useColors: true });
52
+ * await provider.initialize({ debug: true });
53
+ *
54
+ * const loaderConfig = {
55
+ * trackPageActions: true,
56
+ * instrumentationProvider: provider
57
+ * };
58
+ * ```
59
+ */
60
+ instrumentationProvider?: InstrumentationProvider;
61
+ /**
62
+ * Maximum number of retry attempts for failed resources (images/audio/video).
63
+ */
64
+ maxResourceRetries?: number;
65
+ /**
66
+ * Initial delay in ms before first resource retry attempt (exponential backoff).
67
+ */
68
+ resourceRetryDelay?: number;
69
+ };
70
+ export declare const DEFAULT_LOADER_CONFIG: {
71
+ readonly trackPageActions: false;
72
+ readonly instrumentationProvider: undefined;
73
+ readonly maxResourceRetries: 3;
74
+ readonly resourceRetryDelay: 500;
75
+ };
76
+ //# sourceMappingURL=loader-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-config.d.ts","sourceRoot":"","sources":["../src/loader-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG;IAC1B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAElD;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared loader configuration for PIE custom elements.
3
+ *
4
+ * Mirrors the `LoaderConfig` used by PIEOneer's custom element tags.
5
+ */
6
+ export const DEFAULT_LOADER_CONFIG = {
7
+ trackPageActions: false,
8
+ instrumentationProvider: undefined,
9
+ maxResourceRetries: 3,
10
+ resourceRetryDelay: 500,
11
+ };
12
+ //# sourceMappingURL=loader-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-config.js","sourceRoot":"","sources":["../src/loader-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuEH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,gBAAgB,EAAE,KAAK;IACvB,uBAAuB,EAAE,SAAS;IAClC,kBAAkB,EAAE,CAAC;IACrB,kBAAkB,EAAE,GAAG;CACd,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Element Loader - Core types and utilities for loading PIE elements
3
+ *
4
+ * This module provides element aggregation and loading abstractions for PIE players.
5
+ * It enables loading multiple PIE elements in a single operation, eliminating duplicate
6
+ * bundle requests when multiple items use the same elements.
7
+ */
8
+ import type { BundleType } from "../pie/types";
9
+ import type { ItemEntity } from "../types";
10
+ /**
11
+ * Map of element tag names to their package versions
12
+ * Example: { "pie-multiple-choice": "@pie-element/multiple-choice@11.0.1" }
13
+ */
14
+ export type ElementMap = {
15
+ [tagName: string]: string;
16
+ };
17
+ /**
18
+ * Options for loading PIE elements
19
+ */
20
+ export interface LoadOptions {
21
+ /** Bundle type to load (player or clientPlayer) */
22
+ bundleType?: BundleType;
23
+ /** Whether to load controllers (for client-side processing) */
24
+ needsControllers?: boolean;
25
+ /** View mode (ESM only) - delivery, author, or print */
26
+ view?: "delivery" | "author" | "print";
27
+ }
28
+ /**
29
+ * Common interface for element loaders (IIFE and ESM)
30
+ */
31
+ export interface ElementLoaderInterface {
32
+ /**
33
+ * Load elements directly from an element map
34
+ * @param elements - Map of element tag names to package versions
35
+ * @param options - Loading options
36
+ */
37
+ loadElements(elements: ElementMap, options?: LoadOptions): Promise<void>;
38
+ /**
39
+ * Extract and load elements from items
40
+ * Automatically aggregates unique elements from all items
41
+ * @param items - Array of items to extract elements from
42
+ * @param options - Loading options
43
+ */
44
+ loadFromItems(items: ItemEntity[], options?: LoadOptions): Promise<void>;
45
+ }
46
+ /**
47
+ * Aggregate unique elements from multiple items
48
+ *
49
+ * Extracts elements from all item configs and deduplicates them.
50
+ * Throws an error if items require different versions of the same element.
51
+ *
52
+ * @param items - Array of items to aggregate elements from
53
+ * @returns Map of unique element tag names to package versions
54
+ * @throws Error if element version conflicts are detected
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const items = [
59
+ * { config: { elements: { "pie-mc": "@pie-element/mc@11.0.1" } } },
60
+ * { config: { elements: { "pie-mc": "@pie-element/mc@11.0.1" } } },
61
+ * { config: { elements: { "pie-hotspot": "@pie-element/hotspot@9.0.0" } } }
62
+ * ];
63
+ *
64
+ * const elements = aggregateElements(items);
65
+ * // Result: {
66
+ * // "pie-mc": "@pie-element/mc@11.0.1",
67
+ * // "pie-hotspot": "@pie-element/hotspot@9.0.0"
68
+ * // }
69
+ * ```
70
+ */
71
+ export declare function aggregateElements(items: ItemEntity[]): ElementMap;
72
+ //# sourceMappingURL=ElementLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/ElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,mDAAmD;IACnD,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,wDAAwD;IACxD,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzE;;;;;OAKG;IACH,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,CAsBjE"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Element Loader - Core types and utilities for loading PIE elements
3
+ *
4
+ * This module provides element aggregation and loading abstractions for PIE players.
5
+ * It enables loading multiple PIE elements in a single operation, eliminating duplicate
6
+ * bundle requests when multiple items use the same elements.
7
+ */
8
+ /**
9
+ * Aggregate unique elements from multiple items
10
+ *
11
+ * Extracts elements from all item configs and deduplicates them.
12
+ * Throws an error if items require different versions of the same element.
13
+ *
14
+ * @param items - Array of items to aggregate elements from
15
+ * @returns Map of unique element tag names to package versions
16
+ * @throws Error if element version conflicts are detected
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const items = [
21
+ * { config: { elements: { "pie-mc": "@pie-element/mc@11.0.1" } } },
22
+ * { config: { elements: { "pie-mc": "@pie-element/mc@11.0.1" } } },
23
+ * { config: { elements: { "pie-hotspot": "@pie-element/hotspot@9.0.0" } } }
24
+ * ];
25
+ *
26
+ * const elements = aggregateElements(items);
27
+ * // Result: {
28
+ * // "pie-mc": "@pie-element/mc@11.0.1",
29
+ * // "pie-hotspot": "@pie-element/hotspot@9.0.0"
30
+ * // }
31
+ * ```
32
+ */
33
+ export function aggregateElements(items) {
34
+ const elementMap = {};
35
+ items.forEach((item) => {
36
+ const itemElements = item.config?.elements || {};
37
+ Object.entries(itemElements).forEach(([tag, pkg]) => {
38
+ if (!elementMap[tag]) {
39
+ // First time seeing this element
40
+ elementMap[tag] = pkg;
41
+ }
42
+ else if (elementMap[tag] !== pkg) {
43
+ // Version conflict detected
44
+ throw new Error(`Element version conflict: ${tag} requires both ${elementMap[tag]} and ${pkg}. ` +
45
+ `All items in a section must use the same version of each element.`);
46
+ }
47
+ // else: Same version, no-op
48
+ });
49
+ });
50
+ return elementMap;
51
+ }
52
+ //# sourceMappingURL=ElementLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementLoader.js","sourceRoot":"","sources":["../../src/loaders/ElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA6CH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAmB;IACpD,MAAM,UAAU,GAA2B,EAAE,CAAC;IAE9C,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACtB,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC;QAEjD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;YACnD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACtB,iCAAiC;gBACjC,UAAU,CAAC,GAAG,CAAC,GAAG,GAAa,CAAC;YACjC,CAAC;iBAAM,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC;gBACpC,4BAA4B;gBAC5B,MAAM,IAAI,KAAK,CACd,6BAA6B,GAAG,kBAAkB,UAAU,CAAC,GAAG,CAAC,QAAQ,GAAG,IAAI;oBAC/E,mEAAmE,CACpE,CAAC;YACH,CAAC;YACD,4BAA4B;QAC7B,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACnB,CAAC"}
@@ -0,0 +1,67 @@
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";
8
+ import { type ElementLoaderInterface, type ElementMap, type LoadOptions } from "./ElementLoader";
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
+ /** Optional function to check if debug mode is enabled */
16
+ debugEnabled?: () => boolean;
17
+ }
18
+ /**
19
+ * Element loader for ESM (ES Modules) bundles
20
+ *
21
+ * This loader wraps EsmPieLoader and provides element aggregation capabilities.
22
+ * It eliminates duplicate bundle loads when multiple items use the same PIE elements.
23
+ * ESM is the modern, preferred loading mechanism with better browser support and features.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const loader = new EsmElementLoader({
28
+ * esmCdnUrl: 'https://esm.sh'
29
+ * });
30
+ *
31
+ * // Load elements from multiple items at once
32
+ * await loader.loadFromItems(section.items, {
33
+ * view: 'delivery',
34
+ * needsControllers: true
35
+ * });
36
+ *
37
+ * // Or load specific elements directly
38
+ * await loader.loadElements({
39
+ * 'pie-multiple-choice': '@pie-element/multiple-choice@11.0.1',
40
+ * 'pie-hotspot': '@pie-element/hotspot@9.0.0'
41
+ * }, {
42
+ * view: 'author' // Load author view for editing
43
+ * });
44
+ * ```
45
+ */
46
+ export declare class EsmElementLoader implements ElementLoaderInterface {
47
+ private loader;
48
+ constructor(config: EsmElementLoaderConfig);
49
+ /**
50
+ * Load elements directly from an element map
51
+ *
52
+ * @param elements - Map of element tag names to package versions
53
+ * @param options - Loading options
54
+ */
55
+ loadElements(elements: ElementMap, options?: LoadOptions): Promise<void>;
56
+ /**
57
+ * Extract and load elements from items
58
+ *
59
+ * Automatically aggregates unique elements from all items and loads them once.
60
+ *
61
+ * @param items - Array of items to extract elements from
62
+ * @param options - Loading options
63
+ * @throws Error if element version conflicts are detected
64
+ */
65
+ loadFromItems(items: ItemEntity[], options?: LoadOptions): Promise<void>;
66
+ }
67
+ //# sourceMappingURL=EsmElementLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EsmElementLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/EsmElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAElB,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;IAO1C;;;;;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"}
@@ -0,0 +1,71 @@
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";
8
+ import { aggregateElements, } from "./ElementLoader";
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
+ debugEnabled: config.debugEnabled,
43
+ });
44
+ }
45
+ /**
46
+ * Load elements directly from an element map
47
+ *
48
+ * @param elements - Map of element tag names to package versions
49
+ * @param options - Loading options
50
+ */
51
+ async loadElements(elements, options) {
52
+ await this.loader.load({ elements }, document, {
53
+ view: options?.view || "delivery",
54
+ loadControllers: options?.needsControllers ?? true,
55
+ });
56
+ }
57
+ /**
58
+ * Extract and load elements from items
59
+ *
60
+ * Automatically aggregates unique elements from all items and loads them once.
61
+ *
62
+ * @param items - Array of items to extract elements from
63
+ * @param options - Loading options
64
+ * @throws Error if element version conflicts are detected
65
+ */
66
+ async loadFromItems(items, options) {
67
+ const elements = aggregateElements(items);
68
+ await this.loadElements(elements, options);
69
+ }
70
+ }
71
+ //# sourceMappingURL=EsmElementLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EsmElementLoader.js","sourceRoot":"","sources":["../../src/loaders/EsmElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EACN,iBAAiB,GAIjB,MAAM,iBAAiB,CAAC;AAazB;;;;;;;;;;;;;;;;;;;;;;;;;;;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,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"}
@@ -0,0 +1,61 @@
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";
8
+ import { type ElementLoaderInterface, type ElementMap, type LoadOptions } from "./ElementLoader";
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IifeElementLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/IifeElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAEN,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,MAAM,iBAAiB,CAAC;AAEzB;;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"}
@@ -0,0 +1,63 @@
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";
8
+ import { BundleType } from "../pie/types";
9
+ import { aggregateElements, } from "./ElementLoader";
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IifeElementLoader.js","sourceRoot":"","sources":["../../src/loaders/IifeElementLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EACN,iBAAiB,GAIjB,MAAM,iBAAiB,CAAC;AAazB;;;;;;;;;;;;;;;;;;;;;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"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * PIE Element Loaders
3
+ *
4
+ * Element-level loading abstractions for PIE players.
5
+ * Provides both IIFE and ESM loaders with element aggregation capabilities.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // ESM (modern, preferred)
10
+ * import { EsmElementLoader } from '@pie-players/pie-players-shared/loaders';
11
+ *
12
+ * const loader = new EsmElementLoader({ esmCdnUrl: 'https://esm.sh' });
13
+ * await loader.loadFromItems(section.items);
14
+ *
15
+ * // IIFE (legacy compatibility)
16
+ * import { IifeElementLoader } from '@pie-players/pie-players-shared/loaders';
17
+ *
18
+ * const loader = new IifeElementLoader({ bundleHost: 'https://bundles.pie.org' });
19
+ * await loader.loadFromItems(section.items);
20
+ * ```
21
+ */
22
+ export type { ElementLoaderInterface, ElementMap, LoadOptions, } from "./ElementLoader";
23
+ export { aggregateElements } from "./ElementLoader";
24
+ export type { EsmElementLoaderConfig } from "./EsmElementLoader";
25
+ export { EsmElementLoader } from "./EsmElementLoader";
26
+ export type { IifeElementLoaderConfig } from "./IifeElementLoader";
27
+ export { IifeElementLoader } from "./IifeElementLoader";
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,YAAY,EACX,sBAAsB,EACtB,UAAU,EACV,WAAW,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * PIE Element Loaders
3
+ *
4
+ * Element-level loading abstractions for PIE players.
5
+ * Provides both IIFE and ESM loaders with element aggregation capabilities.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // ESM (modern, preferred)
10
+ * import { EsmElementLoader } from '@pie-players/pie-players-shared/loaders';
11
+ *
12
+ * const loader = new EsmElementLoader({ esmCdnUrl: 'https://esm.sh' });
13
+ * await loader.loadFromItems(section.items);
14
+ *
15
+ * // IIFE (legacy compatibility)
16
+ * import { IifeElementLoader } from '@pie-players/pie-players-shared/loaders';
17
+ *
18
+ * const loader = new IifeElementLoader({ bundleHost: 'https://bundles.pie.org' });
19
+ * await loader.loadFromItems(section.items);
20
+ * ```
21
+ */
22
+ export { aggregateElements } from "./ElementLoader";
23
+ export { EsmElementLoader } from "./EsmElementLoader";
24
+ export { IifeElementLoader } from "./IifeElementLoader";
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A problem using the spread operator merging objects is that undefined properties may override
3
+ * defined properties, which is often NOT what you want (e.g. when providing default values). This
4
+ * function merges objects, but ignores properties that are null or undefined.
5
+ * @param objects The objects to merge.
6
+ */
7
+ export declare const mergeObjectsIgnoringNullUndefined: <T extends object>(...objects: T[]) => T;
8
+ /**
9
+ * Deep clone an object.
10
+ */
11
+ export declare const cloneDeep: <T>(value: T) => T;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/object/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,GAAI,CAAC,SAAS,MAAM,EACjE,GAAG,SAAS,CAAC,EAAE,KACb,CAaF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,CAiBvC,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * A problem using the spread operator merging objects is that undefined properties may override
3
+ * defined properties, which is often NOT what you want (e.g. when providing default values). This
4
+ * function merges objects, but ignores properties that are null or undefined.
5
+ * @param objects The objects to merge.
6
+ */
7
+ export const mergeObjectsIgnoringNullUndefined = (...objects) => {
8
+ return objects.reduce((acc, obj) => {
9
+ for (const key in obj) {
10
+ if (Object.hasOwn(obj, key) &&
11
+ obj[key] !== null &&
12
+ obj[key] !== undefined) {
13
+ acc[key] = obj[key];
14
+ }
15
+ }
16
+ return acc;
17
+ }, {});
18
+ };
19
+ /**
20
+ * Deep clone an object.
21
+ */
22
+ export const cloneDeep = (value) => {
23
+ if (value === null || typeof value !== "object") {
24
+ // Primitive value (or null), just return it
25
+ return value;
26
+ }
27
+ if (Array.isArray(value)) {
28
+ // Array: clone each element recursively
29
+ return value.map(cloneDeep);
30
+ }
31
+ // Object: create a new object and clone its properties
32
+ const copy = {};
33
+ for (const key in value) {
34
+ if (Object.hasOwn(value, key)) {
35
+ copy[key] = cloneDeep(value[key]);
36
+ }
37
+ }
38
+ return copy;
39
+ };
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/object/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAChD,GAAG,OAAY,EACX,EAAE;IACN,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAClC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YACvB,IACC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;gBACtB,GAAW,CAAC,GAAG,CAAC,KAAK,IAAI;gBACzB,GAAW,CAAC,GAAG,CAAC,KAAK,SAAS,EAC9B,CAAC;gBACD,GAAW,CAAC,GAAG,CAAC,GAAI,GAAW,CAAC,GAAG,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC,EAAE,EAAO,CAAC,CAAC;AACb,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,KAAQ,EAAK,EAAE;IAC3C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACjD,4CAA4C;QAC5C,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,wCAAwC;QACxC,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAM,CAAC;IAClC,CAAC;IACD,uDAAuD;IACvD,MAAM,IAAI,GAAG,EAAO,CAAC;IACrB,KAAK,MAAM,GAAG,IAAI,KAAY,EAAE,CAAC;QAChC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YAC9B,IAAY,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,KAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QACrD,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC"}