@reidelsaltres/pureper 0.2.14 → 0.2.17

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 (65) hide show
  1. package/out/foundation/Fetcher.d.ts.map +1 -1
  2. package/out/foundation/Fetcher.js +8 -13
  3. package/out/foundation/Fetcher.js.map +1 -1
  4. package/out/foundation/Injection.d.ts +87 -0
  5. package/out/foundation/Injection.d.ts.map +1 -0
  6. package/out/foundation/Injection.js +149 -0
  7. package/out/foundation/Injection.js.map +1 -0
  8. package/out/foundation/Theme.d.ts.map +1 -1
  9. package/out/foundation/Theme.js +16 -1
  10. package/out/foundation/Theme.js.map +1 -1
  11. package/out/foundation/Triplet.d.ts +30 -25
  12. package/out/foundation/Triplet.d.ts.map +1 -1
  13. package/out/foundation/Triplet.js +96 -115
  14. package/out/foundation/Triplet.js.map +1 -1
  15. package/out/foundation/TripletDecorator.d.ts +11 -0
  16. package/out/foundation/TripletDecorator.d.ts.map +1 -1
  17. package/out/foundation/TripletDecorator.js +25 -8
  18. package/out/foundation/TripletDecorator.js.map +1 -1
  19. package/out/foundation/component_api/Component.d.ts.map +1 -1
  20. package/out/foundation/component_api/Component.js +1 -0
  21. package/out/foundation/component_api/Component.js.map +1 -1
  22. package/out/foundation/component_api/UniHtml.d.ts +6 -1
  23. package/out/foundation/component_api/UniHtml.d.ts.map +1 -1
  24. package/out/foundation/component_api/UniHtml.js +32 -7
  25. package/out/foundation/component_api/UniHtml.js.map +1 -1
  26. package/out/foundation/engine/Expression.d.ts +2 -0
  27. package/out/foundation/engine/Expression.d.ts.map +1 -1
  28. package/out/foundation/engine/Expression.js +26 -11
  29. package/out/foundation/engine/Expression.js.map +1 -1
  30. package/out/foundation/engine/StylePreprocessor.js +2 -1
  31. package/out/foundation/engine/StylePreprocessor.js.map +1 -1
  32. package/out/foundation/engine/TemplateEngine.d.ts +3 -1
  33. package/out/foundation/engine/TemplateEngine.d.ts.map +1 -1
  34. package/out/foundation/engine/TemplateEngine.js +44 -15
  35. package/out/foundation/engine/TemplateEngine.js.map +1 -1
  36. package/out/foundation/worker/Router.d.ts.map +1 -1
  37. package/out/foundation/worker/Router.js +6 -0
  38. package/out/foundation/worker/Router.js.map +1 -1
  39. package/out/foundation/worker/ServiceWorker.d.ts +48 -17
  40. package/out/foundation/worker/ServiceWorker.d.ts.map +1 -1
  41. package/out/foundation/worker/ServiceWorker.js +186 -119
  42. package/out/foundation/worker/ServiceWorker.js.map +1 -1
  43. package/out/index.d.ts +3 -2
  44. package/out/index.d.ts.map +1 -1
  45. package/out/index.js +2 -1
  46. package/out/index.js.map +1 -1
  47. package/package.json +1 -1
  48. package/src/foundation/Fetcher.ts +9 -14
  49. package/src/foundation/Injection.ts +183 -0
  50. package/src/foundation/Theme.ts +17 -3
  51. package/src/foundation/Triplet.ts +114 -141
  52. package/src/foundation/TripletDecorator.ts +32 -8
  53. package/src/foundation/component_api/Component.ts +1 -0
  54. package/src/foundation/component_api/UniHtml.ts +35 -7
  55. package/src/foundation/engine/Expression.ts +34 -20
  56. package/src/foundation/engine/StylePreprocessor.ts +1 -1
  57. package/src/foundation/engine/TemplateEngine.ts +42 -15
  58. package/src/foundation/worker/Router.ts +10 -3
  59. package/src/foundation/worker/ServiceWorker.ts +203 -129
  60. package/src/foundation/worker/serviceworker.js +191 -0
  61. package/src/index.ts +7 -4
  62. package/out/foundation/worker/serviceworker.d.ts +0 -1
  63. package/out/foundation/worker/serviceworker.d.ts.map +0 -1
  64. package/out/foundation/worker/serviceworker.js +0 -2
  65. package/out/foundation/worker/serviceworker.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Fetcher.d.ts","sourceRoot":"","sources":["../../src/foundation/Fetcher.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,OAAO,OAAO;WACX,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAqBvC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;WAoBnC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;mBAiBxB,aAAa;CAOrC"}
1
+ {"version":3,"file":"Fetcher.d.ts","sourceRoot":"","sources":["../../src/foundation/Fetcher.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,OAAO,OAAO;WACX,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAgBvC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;WAgBnC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;mBAiBxB,aAAa;CAarC"}
@@ -1,40 +1,29 @@
1
1
  import { HOSTING_ORIGIN } from "./Hosting.js";
2
- // cache stores response bodies (text) by resolved URL so we can reuse them safely
3
- const temporaryCache = new Map();
4
2
  // keep in-flight promises to deduplicate concurrent identical requests
5
3
  const inFlightText = new Map();
6
4
  const inFlightJSON = new Map();
7
5
  export default class Fetcher {
8
6
  static async fetchText(url) {
9
7
  const resolved = this.resolveUrl(url);
10
- if (temporaryCache.has(resolved))
11
- return temporaryCache.get(resolved);
12
8
  // If a request for the same URL is already in-flight, reuse its promise
13
9
  if (inFlightText.has(resolved))
14
10
  return inFlightText.get(resolved);
15
11
  const p = (async () => {
16
12
  const response = await this.internalFetch(resolved);
17
- const text = await response.text();
18
- temporaryCache.set(resolved, text);
19
- return text;
13
+ return response.text();
20
14
  })();
21
15
  inFlightText.set(resolved, p);
22
- // cleanup entry when finished
23
16
  p.finally(() => inFlightText.delete(resolved));
24
17
  return p;
25
18
  }
26
19
  static async fetchJSON(url) {
27
20
  const resolved = this.resolveUrl(url);
28
- if (temporaryCache.has(resolved))
29
- return JSON.parse(temporaryCache.get(resolved));
30
21
  // If a request for the same URL is already in-flight, reuse its promise
31
22
  if (inFlightJSON.has(resolved))
32
23
  return inFlightJSON.get(resolved);
33
24
  const p = (async () => {
34
25
  const response = await this.internalFetch(resolved);
35
- const json = await response.json();
36
- temporaryCache.set(resolved, JSON.stringify(json));
37
- return json;
26
+ return response.json();
38
27
  })();
39
28
  inFlightJSON.set(resolved, p);
40
29
  p.finally(() => inFlightJSON.delete(resolved));
@@ -56,6 +45,12 @@ export default class Fetcher {
56
45
  return new URL(trimmed, `${HOSTING_ORIGIN}/`).href;
57
46
  }
58
47
  static async internalFetch(resolvedUrl) {
48
+ // L2: check ServiceWorker CacheStorage before hitting the network
49
+ if ('caches' in window) {
50
+ const cached = await caches.match(resolvedUrl);
51
+ if (cached)
52
+ return cached;
53
+ }
59
54
  const response = await fetch(resolvedUrl, { cache: 'default' });
60
55
  if (!response.ok) {
61
56
  throw new Error(`HTTP error! ${resolvedUrl} status: ${response.status}`);
@@ -1 +1 @@
1
- {"version":3,"file":"Fetcher.js","sourceRoot":"","sources":["../../src/foundation/Fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,cAAc,CAAC;AAEvD,kFAAkF;AAClF,MAAM,cAAc,GAAwB,IAAI,GAAG,EAAE,CAAC;AACtD,uEAAuE;AACvE,MAAM,YAAY,GAAiC,IAAI,GAAG,EAAE,CAAC;AAC7D,MAAM,YAAY,GAA8B,IAAI,GAAG,EAAE,CAAC;AAC1D,MAAM,CAAC,OAAO,OAAO,OAAO;IACxB,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAW;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC;YAC5B,OAAO,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;QAEzC,wEAAwE;QACxE,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,OAAO,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;QAEnE,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;YAClB,MAAM,QAAQ,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_api/mixin/Proto.js";
3
+ import UniHtml from "./component_api/UniHtml.js";
4
+ export type ImplementationStruct = {
5
+ markupURL?: string;
6
+ markup?: string;
7
+ cssURL?: string;
8
+ css?: string;
9
+ ltCssURL?: string;
10
+ ltCss?: string;
11
+ class?: AnyConstructor<UniHtml>;
12
+ };
13
+ /**
14
+ * Implementation — a swappable variant for a Triplet placeholder.
15
+ *
16
+ * Each placeholder (component tag or page route) can have multiple registered
17
+ * implementations. One is active at a time; switching triggers a reload on
18
+ * all live instances.
19
+ *
20
+ * ```ts
21
+ * // Register the default implementation
22
+ * @ReComponent({ markupURL: './Button.hmle', cssURL: './Button.css' }, "re-button")
23
+ * class ReButton extends Component { ... }
24
+ *
25
+ * // Register an alternative implementation
26
+ * @ReImplementation({ markupURL: './FancyButton.hmle', cssURL: './FancyButton.css' }, "re-button")
27
+ * class FancyButton extends Component { ... }
28
+ *
29
+ * // Switch all re-button instances to FancyButton
30
+ * Placeholder.switchTo("re-button", "FancyButton");
31
+ *
32
+ * // Switch a single instance manually
33
+ * const btn = document.querySelector("re-button");
34
+ * Placeholder.switchInstance(btn, "FancyButton");
35
+ * ```
36
+ */
37
+ export declare class Implementation {
38
+ readonly name: string;
39
+ readonly markup?: Promise<string>;
40
+ readonly style?: Promise<string>;
41
+ readonly globalStyle?: Promise<string>;
42
+ readonly uniClass?: AnyConstructor<UniHtml>;
43
+ constructor(name: string, struct: ImplementationStruct);
44
+ }
45
+ /**
46
+ * Placeholder — manages a named slot (tag or route) with swappable implementations.
47
+ *
48
+ * - `Placeholder.get(name)` — get or create a placeholder
49
+ * - `placeholder.addImplementation(impl)` — register an implementation
50
+ * - `Placeholder.switchTo(name, implName)` — globally switch + reload all instances
51
+ * - `Placeholder.switchInstance(instance, implName)` — switch one instance
52
+ */
53
+ export declare class Placeholder {
54
+ /** Все зарегистрированные placeholders по имени (tag / route). */
55
+ private static readonly _all;
56
+ readonly name: string;
57
+ readonly implementations: Map<string, Implementation>;
58
+ readonly activeImpl: Observable<Implementation | null>;
59
+ /** Все живые экземпляры этого placeholder для reload при смене implementation. */
60
+ private readonly _instances;
61
+ private constructor();
62
+ /** Get or create a placeholder by name. */
63
+ static get(name: string): Placeholder;
64
+ /** Check if a placeholder exists. */
65
+ static has(name: string): boolean;
66
+ /** Add an implementation. The first one added becomes active by default. */
67
+ addImplementation(impl: Implementation): void;
68
+ /** Get the currently active implementation. */
69
+ getActive(): Implementation | null;
70
+ /** Track a live instance for reload. */
71
+ trackInstance(instance: UniHtml): void;
72
+ /** Untrack a disposed instance. */
73
+ untrackInstance(instance: UniHtml): void;
74
+ /** Get all tracked live instances. */
75
+ getInstances(): Set<UniHtml>;
76
+ /**
77
+ * Switch the active implementation globally.
78
+ * All live instances of this placeholder will reload.
79
+ */
80
+ static switchTo(placeholderName: string, implName: string): Promise<void>;
81
+ /**
82
+ * Switch a single instance to a different implementation and reload it.
83
+ * Does NOT change the global active implementation.
84
+ */
85
+ static switchInstance(placeholderName: string, instance: UniHtml, implName: string): Promise<void>;
86
+ }
87
+ //# sourceMappingURL=Injection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Injection.d.ts","sourceRoot":"","sources":["../../src/foundation/Injection.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,OAAO,MAAM,4BAA4B,CAAC;AAEjD,MAAM,MAAM,oBAAoB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;CACnC,CAAA;AAED;;;;;;;;;;;;;;;;;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Q,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBtF;;;OAGG;WACiB,cAAc,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWlH"}
@@ -0,0 +1,149 @@
1
+ import Observable from "./api/Observer.js";
2
+ import Fetcher from "./Fetcher.js";
3
+ /**
4
+ * Implementation — a swappable variant for a Triplet placeholder.
5
+ *
6
+ * Each placeholder (component tag or page route) can have multiple registered
7
+ * implementations. One is active at a time; switching triggers a reload on
8
+ * all live instances.
9
+ *
10
+ * ```ts
11
+ * // Register the default implementation
12
+ * @ReComponent({ markupURL: './Button.hmle', cssURL: './Button.css' }, "re-button")
13
+ * class ReButton extends Component { ... }
14
+ *
15
+ * // Register an alternative implementation
16
+ * @ReImplementation({ markupURL: './FancyButton.hmle', cssURL: './FancyButton.css' }, "re-button")
17
+ * class FancyButton extends Component { ... }
18
+ *
19
+ * // Switch all re-button instances to FancyButton
20
+ * Placeholder.switchTo("re-button", "FancyButton");
21
+ *
22
+ * // Switch a single instance manually
23
+ * const btn = document.querySelector("re-button");
24
+ * Placeholder.switchInstance(btn, "FancyButton");
25
+ * ```
26
+ */
27
+ export class Implementation {
28
+ name;
29
+ markup;
30
+ style;
31
+ globalStyle;
32
+ uniClass;
33
+ constructor(name, struct) {
34
+ this.name = name;
35
+ if (struct.markup && struct.markupURL)
36
+ throw new Error(`[Implementation:${name}]: Both markup and markupURL provided.`);
37
+ this.markup = struct.markupURL ? Fetcher.fetchText(struct.markupURL) : Promise.resolve(struct.markup);
38
+ if (struct.css && struct.cssURL)
39
+ throw new Error(`[Implementation:${name}]: Both css and cssURL provided.`);
40
+ this.style = struct.cssURL ? Fetcher.fetchText(struct.cssURL) : Promise.resolve(struct.css);
41
+ if (struct.ltCss && struct.ltCssURL)
42
+ throw new Error(`[Implementation:${name}]: Both ltCss and ltCssURL provided.`);
43
+ this.globalStyle = struct.ltCssURL ? Fetcher.fetchText(struct.ltCssURL) : Promise.resolve(struct.ltCss);
44
+ this.uniClass = struct.class;
45
+ }
46
+ }
47
+ /**
48
+ * Placeholder — manages a named slot (tag or route) with swappable implementations.
49
+ *
50
+ * - `Placeholder.get(name)` — get or create a placeholder
51
+ * - `placeholder.addImplementation(impl)` — register an implementation
52
+ * - `Placeholder.switchTo(name, implName)` — globally switch + reload all instances
53
+ * - `Placeholder.switchInstance(instance, implName)` — switch one instance
54
+ */
55
+ export class Placeholder {
56
+ /** Все зарегистрированные placeholders по имени (tag / route). */
57
+ static _all = new Map();
58
+ name;
59
+ implementations = new Map();
60
+ activeImpl = new Observable(null);
61
+ /** Все живые экземпляры этого placeholder для reload при смене implementation. */
62
+ _instances = new Set();
63
+ constructor(name) {
64
+ this.name = name;
65
+ }
66
+ /** Get or create a placeholder by name. */
67
+ static get(name) {
68
+ let p = this._all.get(name);
69
+ if (!p) {
70
+ p = new Placeholder(name);
71
+ this._all.set(name, p);
72
+ }
73
+ return p;
74
+ }
75
+ /** Check if a placeholder exists. */
76
+ static has(name) {
77
+ return this._all.has(name);
78
+ }
79
+ /** Add an implementation. The first one added becomes active by default. */
80
+ addImplementation(impl) {
81
+ if (this.implementations.has(impl.name)) {
82
+ console.warn(`[Placeholder:${this.name}]: Implementation "${impl.name}" already registered, overwriting.`);
83
+ }
84
+ this.implementations.set(impl.name, impl);
85
+ if (!this.activeImpl.getObject()) {
86
+ this.activeImpl.setObject(impl);
87
+ console.info(`[Placeholder:${this.name}]: Default implementation set to "${impl.name}"`);
88
+ }
89
+ else {
90
+ console.info(`[Placeholder:${this.name}]: Implementation "${impl.name}" registered`);
91
+ }
92
+ }
93
+ /** Get the currently active implementation. */
94
+ getActive() {
95
+ return this.activeImpl.getObject();
96
+ }
97
+ /** Track a live instance for reload. */
98
+ trackInstance(instance) {
99
+ this._instances.add(instance);
100
+ }
101
+ /** Untrack a disposed instance. */
102
+ untrackInstance(instance) {
103
+ this._instances.delete(instance);
104
+ }
105
+ /** Get all tracked live instances. */
106
+ getInstances() {
107
+ return this._instances;
108
+ }
109
+ /**
110
+ * Switch the active implementation globally.
111
+ * All live instances of this placeholder will reload.
112
+ */
113
+ static async switchTo(placeholderName, implName) {
114
+ const p = this._all.get(placeholderName);
115
+ if (!p)
116
+ throw new Error(`[Placeholder]: "${placeholderName}" not found.`);
117
+ const impl = p.implementations.get(implName);
118
+ if (!impl)
119
+ throw new Error(`[Placeholder:${placeholderName}]: Implementation "${implName}" not found.`);
120
+ const prev = p.activeImpl.getObject();
121
+ if (prev === impl)
122
+ return;
123
+ p.activeImpl.setObject(impl);
124
+ console.info(`[Placeholder:${placeholderName}]: Switched to "${implName}"`);
125
+ // Reload all live instances
126
+ const reloads = [];
127
+ for (const instance of p._instances) {
128
+ reloads.push(instance.reload());
129
+ }
130
+ await Promise.all(reloads);
131
+ console.info(`[Placeholder:${placeholderName}]: Reloaded ${reloads.length} instance(s)`);
132
+ }
133
+ /**
134
+ * Switch a single instance to a different implementation and reload it.
135
+ * Does NOT change the global active implementation.
136
+ */
137
+ static async switchInstance(placeholderName, instance, implName) {
138
+ const p = this._all.get(placeholderName);
139
+ if (!p)
140
+ throw new Error(`[Placeholder]: "${placeholderName}" not found.`);
141
+ const impl = p.implementations.get(implName);
142
+ if (!impl)
143
+ throw new Error(`[Placeholder:${placeholderName}]: Implementation "${implName}" not found.`);
144
+ instance._activeImplementation = impl;
145
+ await instance.reload();
146
+ console.info(`[Placeholder:${placeholderName}]: Instance switched to "${implName}"`);
147
+ }
148
+ }
149
+ //# sourceMappingURL=Injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Injection.js","sourceRoot":"","sources":["../../src/foundation/Injection.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,OAAO,MAAM,cAAc,CAAC;AAiBnC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,cAAc;IACP,IAAI,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,CAAC,CAG9D;AACD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAI,OAAO,CAAC,aAAa,CAAC,CAK9E;AACD,wBAAsB,IAAI,kBAOzB;AACD,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,iBAM1C"}
1
+ {"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/foundation/Theme.ts"],"names":[],"mappings":"AAEA,eAAO,IAAI,gBAAgB,QAAU,CAAC;AAGtC,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7D;AACD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAK7E;AACD,wBAAsB,IAAI,kBAOzB;AACD,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,iBAkB1C"}
@@ -1,5 +1,6 @@
1
1
  import Fetcher from "./Fetcher.js";
2
2
  export let ACTIVE_THEME_KEY = "Empty";
3
+ let activeThemeSheet = null;
3
4
  export async function loadTheme(name) {
4
5
  // Use hosting-root absolute path so GitHub Pages subfolder deployments (e.g. /Hellper/) keep the subfolder.
5
6
  return Fetcher.fetchText(`/resources/${name}.theme.css`);
@@ -24,6 +25,20 @@ export async function setTheme(name) {
24
25
  theme = theme.replace(/\.[\w-]+-theme/g, ":root");
25
26
  const sheet = new CSSStyleSheet();
26
27
  sheet.replaceSync(theme);
27
- document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
28
+ if (activeThemeSheet) {
29
+ const index = document.adoptedStyleSheets.indexOf(activeThemeSheet);
30
+ if (index !== -1) {
31
+ const sheets = [...document.adoptedStyleSheets];
32
+ sheets[index] = sheet;
33
+ document.adoptedStyleSheets = sheets;
34
+ }
35
+ else {
36
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
37
+ }
38
+ }
39
+ else {
40
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
41
+ }
42
+ activeThemeSheet = sheet;
28
43
  }
29
44
  //# sourceMappingURL=Theme.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Theme.js","sourceRoot":"","sources":["../../src/foundation/Theme.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,MAAM,CAAC,IAAI,gBAAgB,GAAG,OAAO,CAAC;AACtC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAY;IACxC,4GAA4G;IAC5G,OAAO,OAAO,CAAC,SAAS,CAAC,cAAc,IAAI,YAAY,CAAC,CAAC;AAC7D,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACjD,IAAI,KAAK,GAAW,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,IAAI,aAAa,EAAE,CAAC;IAClC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO,KAAK,CAAC;AACjB,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,IAAI;IACtB,gBAAgB,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,gBAAgB,EAAE,CAAC;QACnB,MAAM,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACrC,CAAC;SAAM,CAAC;QACJ,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;AACL,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACvC,IAAI,KAAK,GAAW,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1C,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,IAAI,aAAa,EAAE,CAAC;IAClC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACzB,QAAQ,CAAC,kBAAkB,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,E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AQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACpE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,MAAM,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAC;YAChD,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;YACtB,QAAQ,CAAC,kBAAkB,GAAG,MAAM,CAAC;QACzC,CAAC;aAAM,CAAC;YACJ,QAAQ,CAAC,kBAAkB,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QAC1E,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,QAAQ,CAAC,kBAAkB,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IAC1E,CAAC;IACD,gBAAgB,GAAG,KAAK,CAAC;AAC7B,CAAC"}
@@ -1,37 +1,42 @@
1
- import UniHtml from "./component_api/UniHtml.js";
2
- import { AnyConstructor } from "./component_api/mixin/Proto.js";
1
+ import { ImplementationStruct } from "./Injection.js";
2
+ export declare const REGISTRY: (() => void)[];
3
3
  export declare enum AccessType {
4
4
  NONE = 0,
5
5
  OFFLINE = 1,
6
6
  ONLINE = 2,
7
7
  BOTH = 3
8
8
  }
9
- export type TripletStruct = {
10
- markupURL?: string;
11
- markup?: string;
12
- cssURL?: string;
13
- css?: string;
14
- ltCssURL?: string;
15
- ltCss?: string;
16
- jsURL?: string;
9
+ export type TripletStruct = ImplementationStruct & {
17
10
  access?: AccessType;
18
- class?: AnyConstructor<UniHtml>;
19
11
  };
12
+ /**
13
+ * Triplet — registers a placeholder with a default implementation.
14
+ *
15
+ * The placeholder is what gets registered in `customElements.define()` or `Router`.
16
+ * At runtime, the placeholder resolves the currently active {@link Implementation}
17
+ * and uses its markup, style, and class for the lifecycle.
18
+ *
19
+ * ```ts
20
+ * // Default implementation registered via @ReComponent
21
+ * @ReComponent({ markupURL: './Button.hmle', cssURL: './Button.css' }, "re-button")
22
+ * class ReButton extends Component { ... }
23
+ *
24
+ * // Alternative implementation registered via @ReImplementation
25
+ * @ReImplementation({ markupURL: './FancyButton.hmle', cssURL: './Fancy.css' }, "re-button")
26
+ * class FancyButton extends Component { ... }
27
+ *
28
+ * // Switch globally — all re-button instances reload
29
+ * Placeholder.switchTo("re-button", "FancyButton");
30
+ *
31
+ * // Switch one instance only
32
+ * Placeholder.switchInstance("re-button", myBtnInstance, "FancyButton");
33
+ * ```
34
+ */
20
35
  export default class Triplet {
21
- readonly markup?: Promise<string>;
22
- readonly css?: Promise<string>;
23
- readonly lightCss?: Promise<string>;
24
- readonly js?: Promise<string>;
25
- private readonly markupURL?;
26
- private readonly cssURL?;
27
- private readonly ltCssURL?;
28
- private readonly jsURL?;
29
36
  private readonly access;
30
- private uni?;
31
- constructor(struct: TripletStruct);
32
- init(): Promise<boolean>;
33
- cache(): Promise<void>;
34
- register(type: "router" | "markup", name: string): Promise<boolean>;
35
- private createInjectedClass;
37
+ private readonly placeholderName?;
38
+ private readonly implementation;
39
+ constructor(struct: TripletStruct, implName?: string);
40
+ register(type: "router" | "markup", name: string): Promise<void>;
36
41
  }
37
42
  //# sourceMappingURL=Triplet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Triplet.d.ts","sourceRoot":"","sources":["../../src/foundation/Triplet.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,4BAA4B,CAAC;AAKjD,OAAO,EAAE,cAAc,EAAe,MAAM,gCAAgC,CAAC;AAK7E,oBAAY,UAAU;IAClB,IAAI,IAAI;IACR,OAAO,IAAS;IAChB,MAAM,IAAS;IACf,IAAI,IAAmB;CAC1B;AACD,MAAM,MAAM,aAAa,GAAG;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,QA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