@aegis-framework/pandora 0.6.3 → 0.8.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.
@@ -1,6 +1,5 @@
1
- import { TemplateResult, nothing } from 'lit-html';
2
- import type { SubscribeHandler } from './Types';
3
- import { Style, TemplateValue, TemplateFunction } from './Types';
1
+ import { nothing, type TemplateResult } from 'lit-html';
2
+ import type { Style, SubscribeHandler, TemplateFunction, TemplateValue } from './Types.js';
4
3
  /**
5
4
  * The base class every Pandora component extends.
6
5
  *
@@ -31,6 +30,27 @@ import { Style, TemplateValue, TemplateFunction } from './Types';
31
30
  * // <my-greeting></my-greeting>
32
31
  */
33
32
  declare class Component extends HTMLElement {
33
+ /**
34
+ * Values the element was given before its class was defined. Declared
35
+ * first, so it's taken before any field initializer can hide them.
36
+ *
37
+ * @internal
38
+ */
39
+ private _valuesBeforeUpgrade;
40
+ /**
41
+ * The elements inside the component that have been scrolled, so a string
42
+ * render can scroll their replacements back to the same place.
43
+ *
44
+ * @internal
45
+ */
46
+ protected _scrolledElements: Set<Element>;
47
+ /**
48
+ * The class this instance was counted under in `connectedInstances()`
49
+ * while it's connected.
50
+ *
51
+ * @internal
52
+ */
53
+ private _connectedAs?;
34
54
  /**
35
55
  * The inner HTML the component was mounted with, captured before the first
36
56
  * render runs. Exposed publicly as `slotContent`.
@@ -137,6 +157,25 @@ declare class Component extends HTMLElement {
137
157
  * @internal
138
158
  */
139
159
  protected static _template?: string | TemplateFunction;
160
+ /**
161
+ * Whether a string render gives back focus and scroll positions.
162
+ *
163
+ * A `render()` that returns a string replaces every element inside the
164
+ * component, so the browser loses which one had focus and how far each
165
+ * was scrolled. Turn this on and Pandora finds the replacement of the
166
+ * focused element and of each scrolled one, by its `data-key`, its `id`
167
+ * or its position, and restores them. lit-html renders keep their
168
+ * elements and don't need it.
169
+ *
170
+ * It's off by default because components that already move focus
171
+ * themselves after a render (in `didRender()`) expect it to be lost.
172
+ *
173
+ * @example
174
+ * class TrackList extends Component {
175
+ * static override keepFocusAndScroll = true;
176
+ * }
177
+ */
178
+ static keepFocusAndScroll: boolean;
140
179
  /**
141
180
  * Backing storage for attributes registered manually through the
142
181
  * `observedAttributes` setter. Merged with `@Attribute` / `@Property`
@@ -331,6 +370,45 @@ declare class Component extends HTMLElement {
331
370
  * }
332
371
  */
333
372
  constructor();
373
+ /**
374
+ * The instances of this class that are in the document right now, in the
375
+ * order they connected. Only instances of exactly this class: a subclass
376
+ * has its own set. Use it to reach every live instance without searching
377
+ * the DOM, including the ones inside other components' shadow roots.
378
+ *
379
+ * The set is live: it changes as instances connect and disconnect. Copy it
380
+ * (`[...Dialog.connectedInstances()]`) before iterating if what you do can
381
+ * add or remove components.
382
+ *
383
+ * @returns A read-only view of the connected instances.
384
+ *
385
+ * @example
386
+ * for (const dialog of Dialog.connectedInstances()) {
387
+ * dialog.close();
388
+ * }
389
+ */
390
+ static connectedInstances<T extends typeof Component>(this: T): ReadonlySet<InstanceType<T>>;
391
+ /**
392
+ * Where the component renders: the element itself. `ShadowComponent`
393
+ * returns its shadow root.
394
+ *
395
+ * @internal
396
+ */
397
+ protected _renderRoot(): ParentNode;
398
+ /**
399
+ * Notes the elements under `root` that the user (or code) scrolls. Scroll
400
+ * events don't bubble, so this listens in the capture phase.
401
+ *
402
+ * @internal
403
+ */
404
+ protected _trackScrolling(root: EventTarget): void;
405
+ /**
406
+ * Assigns the values the element was given before its class was defined,
407
+ * through the class's own setters and reactive fields.
408
+ *
409
+ * @internal
410
+ */
411
+ private _assignValuesBeforeUpgrade;
334
412
  /**
335
413
  * The original inner HTML the component was mounted with.
336
414
  *
@@ -354,8 +432,9 @@ declare class Component extends HTMLElement {
354
432
  /**
355
433
  * Whether the component is currently attached to the DOM.
356
434
  *
357
- * Flips to `true` inside `connectedCallback()` and back to `false` during
358
- * `disconnectedCallback()`. Useful if you're running async work that
435
+ * Flips to `true` at the start of `connectedCallback()` and back to
436
+ * `false` at the start of `disconnectedCallback()`, matching the native
437
+ * `Node.isConnected` it shadows. Useful if you're running async work that
359
438
  * should stop once the element is removed.
360
439
  *
361
440
  * @returns `true` while the element is in the document.
@@ -375,9 +454,11 @@ declare class Component extends HTMLElement {
375
454
  * Prefer `ready()` when you want to run code once the component is ready;
376
455
  * this getter is handy when you need a synchronous check — for example
377
456
  * inside a parent component that wants to talk to a freshly inserted
378
- * child.
457
+ * child. It drops back to `false` as soon as the element is removed, and
458
+ * turns `true` again once a reconnect finishes.
379
459
  *
380
- * @returns `true` after `didMount()` and the initial render have run.
460
+ * @returns `true` after `didMount()` (or `didReconnect()`) and the render
461
+ * before it have run.
381
462
  *
382
463
  * @example
383
464
  * if (avatar.isReady) {
@@ -751,7 +832,7 @@ declare class Component extends HTMLElement {
751
832
  * this.data = await fetch('/api/profile').then(r => r.json());
752
833
  * }
753
834
  */
754
- willMount(): Promise<void>;
835
+ willMount(): void | Promise<void>;
755
836
  /**
756
837
  * Runs after the component's first mount completes.
757
838
  *
@@ -766,7 +847,7 @@ declare class Component extends HTMLElement {
766
847
  * this.query('input')?.focus();
767
848
  * }
768
849
  */
769
- didMount(): Promise<void>;
850
+ didMount(): void | Promise<void>;
770
851
  /**
771
852
  * Runs after every render cycle.
772
853
  *
@@ -782,7 +863,7 @@ declare class Component extends HTMLElement {
782
863
  * this._chart = createChart(this.query('canvas'));
783
864
  * }
784
865
  */
785
- didRender(): Promise<void>;
866
+ didRender(): void | Promise<void>;
786
867
  /**
787
868
  * Runs when the component is re-attached to the DOM after being
788
869
  * disconnected.
@@ -796,7 +877,7 @@ declare class Component extends HTMLElement {
796
877
  * this._timer = setInterval(() => this.tick(), 1000);
797
878
  * }
798
879
  */
799
- didReconnect(): Promise<void>;
880
+ didReconnect(): void | Promise<void>;
800
881
  /**
801
882
  * Runs just before the component is removed from the DOM.
802
883
  *
@@ -809,7 +890,7 @@ declare class Component extends HTMLElement {
809
890
  * this._abort.abort();
810
891
  * }
811
892
  */
812
- willUnmount(): Promise<void>;
893
+ willUnmount(): void | Promise<void>;
813
894
  /**
814
895
  * Runs after the component has been removed from the DOM.
815
896
  *
@@ -821,7 +902,7 @@ declare class Component extends HTMLElement {
821
902
  * analytics.track('card-removed', { id: this.id });
822
903
  * }
823
904
  */
824
- didUnmount(): Promise<void>;
905
+ didUnmount(): void | Promise<void>;
825
906
  /**
826
907
  * Runs every time one of the component's reactive fields changes.
827
908
  *
@@ -848,6 +929,19 @@ declare class Component extends HTMLElement {
848
929
  * }
849
930
  */
850
931
  didChange(_property: string, _oldValue: unknown, _newValue: unknown, _source?: string): void;
932
+ /**
933
+ * Adds the instance to its class's `connectedInstances()`.
934
+ *
935
+ * @internal
936
+ */
937
+ private _countAsConnected;
938
+ /**
939
+ * Removes the instance from the `connectedInstances()` it was added to,
940
+ * even if `evolve()` has changed its class since.
941
+ *
942
+ * @internal
943
+ */
944
+ private _stopCountingAsConnected;
851
945
  /**
852
946
  * The standard custom-elements hook Pandora uses to drive mounting.
853
947
  *
@@ -869,11 +963,11 @@ declare class Component extends HTMLElement {
869
963
  /**
870
964
  * The standard custom-elements hook Pandora uses to drive unmounting.
871
965
  *
872
- * Pandora tears down `@Subscribe` subscriptions and `@Listen` handlers,
873
- * then calls `willUnmount()` and `didUnmount()` before flipping the
874
- * component's ready and connected flags back to `false`. Override the
875
- * lifecycle methods in preference to this hook; if you do override,
876
- * remember to call `super.disconnectedCallback()`.
966
+ * Pandora flips the component's connected and ready flags to `false`
967
+ * right away, tears down `@Subscribe` subscriptions and `@Listen` handlers,
968
+ * then calls `willUnmount()` and `didUnmount()`. Override the lifecycle
969
+ * methods in preference to this hook; if you do override, remember to call
970
+ * `super.disconnectedCallback()`.
877
971
  *
878
972
  * @example
879
973
  * async disconnectedCallback() {
@@ -1 +1 @@
1
- {"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/Component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAcxE,OAAO,KA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;YAAE,MAAM,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,OAAO,CAAC;YAAC,OAAO,CAAC,EAAE,OAAO,CAAC;YAAC,IAAI,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,EACvJ,KAAK,EAAE,MAAM,GACZ,OAAO,CA8ET;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,gBAAgB,IAAI,IAAI,CAQjC;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,wBAAwB,IAAI,IAAI,CAwBzC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,yBAAyB,IAAI,IAAI,CAO1C;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,gBAAgB,IAAI,IAAI,CAQjC;CACF;eAEc,SAAS"}
@@ -1,10 +1,11 @@
1
- import Component from './Component';
2
- import { Style } from './Types';
1
+ import Component from './Component.js';
2
+ import type * as Types from './Types.js';
3
3
  type ComponentConstructor = typeof Component & {
4
4
  tag: string;
5
5
  _registered?: boolean;
6
6
  };
7
- interface RegisterOptions {
7
+ export interface RegisterOptions {
8
+ /** Skip `customElements.define()`; call `Registry.define()` when ready. */
8
9
  defer?: boolean;
9
10
  }
10
11
  /**
@@ -28,7 +29,7 @@ interface RegisterOptions {
28
29
  *
29
30
  * // <my-greeting></my-greeting>
30
31
  */
31
- export declare function Register(tagName: string, options?: RegisterOptions): <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext) => T;
32
+ export declare const Register: (tagName: string, options?: RegisterOptions) => <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext) => T;
32
33
  /**
33
34
  * Attaches scoped CSS to the component. Accepts either a raw CSS string or
34
35
  * a structured `Style` object (selectors and declarations).
@@ -54,15 +55,16 @@ export declare function Register(tagName: string, options?: RegisterOptions): <T
54
55
  * }
55
56
  * }
56
57
  */
57
- export declare function Style(css: Style | string): <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext) => T;
58
+ export declare const Style: (css: Types.Style | string) => <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext) => T;
58
59
  /**
59
60
  * Runs the decorated method whenever the given reactive property changes,
60
61
  * receiving the new and previous values.
61
62
  *
62
- * The watched property must be declared with `@State`, `@Attribute`, or
63
- * `@Property` — otherwise you'll see a one-time dev warning explaining that
64
- * the watcher will never fire. Watchers run synchronously on assignment,
65
- * before the next render is queued.
63
+ * The watched property must be reactive — declared with `@State`,
64
+ * `@Attribute`, `@Property`, or `@Subscribe`, or made reactive with
65
+ * `reactive()` in the constructor — otherwise you'll see a one-time dev
66
+ * warning explaining that the watcher will never fire. Watchers run
67
+ * synchronously on assignment, before the next render is queued.
66
68
  *
67
69
  * @param property - The name of the reactive field to observe.
68
70
  *
@@ -81,8 +83,9 @@ export declare function Style(css: Style | string): <T extends ComponentConstruc
81
83
  * }
82
84
  * }
83
85
  */
84
- export declare function Watch(property: string): <T extends (...args: any[]) => any>(_target: T, context: ClassMethodDecoratorContext) => void;
85
- interface StateOptions {
86
+ export declare const Watch: (property: string) => <T extends (...args: any[]) => any>(_target: T, context: ClassMethodDecoratorContext) => void;
87
+ export interface StateOptions {
88
+ /** Set to `false` to keep the field reactive without re-rendering. */
86
89
  render?: boolean;
87
90
  }
88
91
  /**
@@ -107,9 +110,14 @@ interface StateOptions {
107
110
  * }
108
111
  * }
109
112
  */
110
- export declare function State(options?: StateOptions): (_target: undefined, context: ClassFieldDecoratorContext) => void;
111
- interface PropertyOptions {
112
- attribute?: string | false;
113
+ export declare const State: (options?: StateOptions) => (_target: undefined, context: ClassFieldDecoratorContext) => void;
114
+ export interface PropertyOptions {
115
+ /**
116
+ * Mirror primitive values to an attribute: `true` uses the field name,
117
+ * a string names the attribute, and `false` (the default) skips it.
118
+ */
119
+ attribute?: string | boolean;
120
+ /** Custom equality check; assignments it reports as equal are skipped. */
113
121
  equals?: (a: unknown, b: unknown) => boolean;
114
122
  }
115
123
  /**
@@ -119,9 +127,9 @@ interface PropertyOptions {
119
127
  * Properties are reactive (they fire `@Watch` handlers and run through
120
128
  * `didChange`) but do not trigger re-renders on their own, so a parent can
121
129
  * hand a child rich data without causing render thrash. Pass
122
- * `{ attribute: 'some-name' }` to mirror the value to an attribute for
123
- * primitives, or provide a custom `equals` comparator to skip updates when
124
- * a deep-equal object is assigned.
130
+ * `{ attribute: true }` (or `{ attribute: 'some-name' }`) to mirror the
131
+ * value to an attribute for primitives, or provide a custom `equals`
132
+ * comparator to skip updates when a deep-equal object is assigned.
125
133
  *
126
134
  * @param options - `{ attribute, equals }` to control attribute sync and
127
135
  * change detection.
@@ -142,8 +150,9 @@ interface PropertyOptions {
142
150
  * // const el = document.querySelector('user-avatar');
143
151
  * // el.user = { id: 'u_42', name: 'Ada Lovelace' };
144
152
  */
145
- export declare function Property(options?: PropertyOptions): (_target: undefined, context: ClassFieldDecoratorContext) => void;
146
- interface AttributeOptions {
153
+ export declare const Property: (options?: PropertyOptions) => (_target: undefined, context: ClassFieldDecoratorContext) => void;
154
+ export interface AttributeOptions {
155
+ /** Set to `false` to keep the field reactive without re-rendering. */
147
156
  render?: boolean;
148
157
  }
149
158
  /**
@@ -172,7 +181,7 @@ interface AttributeOptions {
172
181
  *
173
182
  * // <my-greeting name="Ada"></my-greeting>
174
183
  */
175
- export declare function Attribute(attributeNameOrOptions?: string | AttributeOptions): (_target: undefined, context: ClassFieldDecoratorContext) => void;
184
+ export declare const Attribute: (attributeNameOrOptions?: string | AttributeOptions) => (_target: undefined, context: ClassFieldDecoratorContext) => void;
176
185
  /**
177
186
  * Subscribes a field to a shared state key on the global `Registry`. Reading
178
187
  * the field returns the current registry value; assigning writes it back
@@ -201,7 +210,7 @@ export declare function Attribute(attributeNameOrOptions?: string | AttributeOpt
201
210
  * }
202
211
  * }
203
212
  */
204
- export declare function Subscribe(stateKey: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
213
+ export declare const Subscribe: (stateKey: string) => (_target: undefined, context: ClassFieldDecoratorContext) => void;
205
214
  /**
206
215
  * Turns a field into a live selector query against the component's rendered
207
216
  * DOM. Each access re-runs the lookup, so the reference stays correct even
@@ -228,7 +237,7 @@ export declare function Subscribe(stateKey: string): (_target: undefined, contex
228
237
  * }
229
238
  * }
230
239
  */
231
- export declare function Query(selector: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
240
+ export declare const Query: (selector: string) => (_target: undefined, context: ClassFieldDecoratorContext) => void;
232
241
  /**
233
242
  * Like `@Query`, but returns every matching element. Each access re-runs
234
243
  * the lookup, so the list reflects the current DOM on every read.
@@ -255,7 +264,7 @@ export declare function Query(selector: string): (_target: undefined, context: C
255
264
  * }
256
265
  * }
257
266
  */
258
- export declare function QueryAll(selector: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
267
+ export declare const QueryAll: (selector: string) => (_target: undefined, context: ClassFieldDecoratorContext) => void;
259
268
  /**
260
269
  * Exposes a `<slot>` element from the shadow root as a field, so you can
261
270
  * inspect projected children or call slot APIs like `assignedElements()`.
@@ -270,8 +279,8 @@ export declare function QueryAll(selector: string): (_target: undefined, context
270
279
  * class MyCard extends ShadowComponent {
271
280
  * @Slot('header') headerSlot!: HTMLSlotElement | null;
272
281
  *
273
- * connectedCallback() {
274
- * super.connectedCallback();
282
+ * async didMount() {
283
+ * // The slot exists once the first render has run.
275
284
  * console.log('header children:', this.headerSlot?.assignedElements());
276
285
  * }
277
286
  *
@@ -285,12 +294,23 @@ export declare function QueryAll(selector: string): (_target: undefined, context
285
294
  * }
286
295
  * }
287
296
  */
288
- export declare function Slot(name?: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
289
- interface ListenOptions {
290
- target?: 'self' | 'window' | 'document' | string;
297
+ export declare const Slot: (name?: string) => (_target: undefined, context: ClassFieldDecoratorContext) => void;
298
+ export interface ListenOptions {
299
+ /** Where to attach: the host (`'self'`, the default), `'window'`, `'document'`, or a CSS selector inside the component. */
300
+ target?: 'self' | 'window' | 'document' | (string & {});
301
+ /**
302
+ * Only fire when the event comes from an element matching this selector,
303
+ * which the method then gets as its second argument. The search runs from
304
+ * where the event started up to the element the listener is on (the
305
+ * component, or its `target`), including it: an ancestor outside never
306
+ * matches. A listener on a shadow component's host searches its shadow root.
307
+ */
291
308
  delegate?: string;
309
+ /** Listen during the capture phase. */
292
310
  capture?: boolean;
311
+ /** Mark the listener as passive. */
293
312
  passive?: boolean;
313
+ /** Remove the listener after it first fires (after the first match, with `delegate`). */
294
314
  once?: boolean;
295
315
  }
296
316
  /**
@@ -302,6 +322,9 @@ interface ListenOptions {
302
322
  * bubble up from a child matching a selector; `capture`, `passive`, and `once`
303
323
  * forward to the underlying `addEventListener` call.
304
324
  *
325
+ * The method gets the event. With `delegate`, it also gets the element that
326
+ * matched the selector, as its second argument.
327
+ *
305
328
  * @param event - The event name to listen for (e.g. `'click'`, `'keydown'`).
306
329
  * @param options - Optional `{ target, delegate, capture, passive, once }`.
307
330
  *
@@ -319,8 +342,17 @@ interface ListenOptions {
319
342
  * return html`<button>Pressed ${this.pressed} times</button>`;
320
343
  * }
321
344
  * }
345
+ *
346
+ * @example
347
+ * @Register('todo-list')
348
+ * class TodoList extends Component {
349
+ * @Listen('click', { delegate: '[data-remove]' })
350
+ * remove(event: MouseEvent, button: HTMLButtonElement) {
351
+ * this.items = this.items.filter((item) => item.id !== button.dataset.remove);
352
+ * }
353
+ * }
322
354
  */
323
- export declare function Listen(event: string, options?: ListenOptions): <T extends (...args: any[]) => any>(_target: T, context: ClassMethodDecoratorContext) => void;
355
+ export declare const Listen: (event: string, options?: ListenOptions) => <T extends (...args: any[]) => any>(_target: T, context: ClassMethodDecoratorContext) => void;
324
356
  /**
325
357
  * Turns a getter into a cached derived value. The result is computed once,
326
358
  * reused on every read, and invalidated automatically whenever any of the
@@ -348,8 +380,8 @@ export declare function Listen(event: string, options?: ListenOptions): <T exten
348
380
  * }
349
381
  * }
350
382
  */
351
- export declare function Computed(...dependencies: string[]): <T>(_target: T, context: ClassGetterDecoratorContext) => T;
352
- type ClassListMap = Record<string, string | ((instance: any) => boolean)>;
383
+ export declare const Computed: (...dependencies: string[]) => <T>(_target: T, context: ClassGetterDecoratorContext) => T;
384
+ export type ClassListMap = Record<string, string | ((instance: any) => boolean)>;
353
385
  /**
354
386
  * Declaratively toggles classes on the host element based on reactive state.
355
387
  * Map a class name to a reactive field name (truthy → class on, falsy →
@@ -379,7 +411,7 @@ type ClassListMap = Record<string, string | ((instance: any) => boolean)>;
379
411
  * }
380
412
  * }
381
413
  */
382
- export declare function ClassList(map: ClassListMap): <T extends ComponentConstructor>(constructor: T, _context: ClassDecoratorContext) => T;
414
+ export declare const ClassList: (map: ClassListMap) => <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext) => T;
383
415
  /**
384
416
  * Installs a function on the component that dispatches a bubbling custom
385
417
  * event with the given name. Call the field like a method, passing any
@@ -408,6 +440,6 @@ export declare function ClassList(map: ClassListMap): <T extends ComponentConstr
408
440
  * // In a parent:
409
441
  * // el.addEventListener('button-pressed', (e) => console.log(e.detail.at));
410
442
  */
411
- export declare function Emitter(eventName: string): (_target: undefined, context: ClassFieldDecoratorContext) => void;
443
+ export declare const Emitter: (eventName: string) => (_target: undefined, context: ClassFieldDecoratorContext) => void;
412
444
  export {};
413
445
  //# sourceMappingURL=Decorators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Decorators.d.ts","sourceRoot":"","sources":["../../src/Decorators.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AASpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAWhC,KAAK,oBAAoB,GAAG,OAAO,SAAS,GAAG;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAQF,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAA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AS,WAAW,0BAA0B,SAehE,CAAC;AAMF,MAAM,WAAW,aAAa;IAC5B,2HAA2H;IAC3H,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAExD;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,yFAAyF;IACzF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,MAAM,UAAW,MAAM,YAAY,aAAa,MACnD,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,WAC9B,CAAC,WACD,2BAA2B,KACnC,IAgBJ,CAAC;AAwCF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,QAAQ,oBAAqB,MAAM,EAAE,MACxC,CAAC,WACE,CAAC,WACD,2BAA2B,KACnC,CAsCJ,CAAC;AAMF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,SAAS,QAAS,YAAY,MACjC,CAAC,SAAS,oBAAoB,eAAe,CAAC,WAAW,qBAAqB,KAAG,CA8D1F,CAAC;AAwBF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,OAAO,cAAe,MAAM,eACtB,SAAS,WAAW,0BAA0B,SAchE,CAAC"}
@@ -1,18 +1,28 @@
1
- import Component from './Component';
1
+ import Component from './Component.js';
2
+ /** The version of Pandora that's running, such as `'0.7.0'` (`'development'` when it runs from source). */
3
+ export declare const VERSION: string;
2
4
  type ComponentClass = typeof Component & {
3
5
  tag: string;
4
6
  _registered?: boolean;
5
7
  };
6
- type StateSubscriber<T = unknown> = (newValue: T, oldValue: T | undefined) => void;
7
- type LifecycleCallback = (component: Component, tag: string) => void;
8
- type ErrorCallback = (error: Error, component: Component, tag: string, lifecycle: string) => void;
9
- type MiddlewareType = 'render';
10
- type RenderType = 'string' | 'lit';
11
- type Middleware = (component: Component, value: unknown, renderType?: RenderType) => unknown;
12
- type ComponentLoader = () => Promise<ComponentClass | {
8
+ /** Receives `(newValue, oldValue)` whenever a subscribed state key changes. */
9
+ export type StateSubscriber<T = unknown> = (newValue: T, oldValue: T | undefined) => void;
10
+ /** Receives every component instance (and its tag) passed to `onMount()` / `onUnmount()`. */
11
+ export type LifecycleCallback = (component: Component, tag: string) => void;
12
+ /** Receives lifecycle errors routed through `onError()`. */
13
+ export type ErrorCallback = (error: Error, component: Component, tag: string, lifecycle: string) => void;
14
+ /** The middleware pipelines `use()` accepts. */
15
+ export type MiddlewareType = 'render';
16
+ /** Whether a render value is a plain string template or a lit-html result. */
17
+ export type RenderType = 'string' | 'lit';
18
+ /** Transforms a component's render output; return the (possibly new) value. */
19
+ export type Middleware = (component: Component, value: unknown, renderType?: RenderType) => unknown;
20
+ /** Resolves a lazy component's class, directly or as a module's `default` export. */
21
+ export type ComponentLoader = () => Promise<ComponentClass | {
13
22
  default: ComponentClass;
14
23
  }>;
15
- interface ComponentStats {
24
+ /** What `stats()` reports for a tag. */
25
+ export interface ComponentStats {
16
26
  tag: string;
17
27
  instanceCount: number;
18
28
  isRegistered: boolean;
@@ -33,7 +43,7 @@ interface ComponentStats {
33
43
  * to construct.
34
44
  *
35
45
  * @example
36
- * import Registry, { Component, Register } from '@aegis-framework/pandora';
46
+ * import { Registry, Component, Register } from '@aegis-framework/pandora';
37
47
  *
38
48
  * @Register('theme-toggle')
39
49
  * class ThemeToggle extends Component {
@@ -201,13 +211,13 @@ declare class Registry {
201
211
  * @returns A detached component instance ready to attach.
202
212
  *
203
213
  * @example
204
- * const avatar = Registry.instantiate('user-avatar', {
214
+ * const avatar = Registry.instantiate<UserAvatar>('user-avatar', {
205
215
  * userId: 'u_42',
206
216
  * size: 48
207
217
  * });
208
218
  * document.body.appendChild(avatar);
209
219
  */
210
- static instantiate(tag: string, props: Record<string, any>): Component;
220
+ static instantiate<T extends Component = Component>(tag: string, props?: Record<string, any>): T;
211
221
  /**
212
222
  * Checks whether any component is registered under the given tag.
213
223
  *
@@ -436,7 +446,8 @@ declare class Registry {
436
446
  * Registry.stats();
437
447
  * // [{ tag: 'my-button', ... }, { tag: 'theme-toggle', ... }]
438
448
  */
439
- static stats(tag?: string): ComponentStats | ComponentStats[];
449
+ static stats(tag: string): ComponentStats;
450
+ static stats(): ComponentStats[];
440
451
  /**
441
452
  * Observes every component mount across your app.
442
453
  *
@@ -662,5 +673,32 @@ declare class Registry {
662
673
  */
663
674
  static _hasMiddleware(type: MiddlewareType): boolean;
664
675
  }
676
+ /** What the first copy of Pandora leaves on `globalThis`. */
677
+ export interface RegisteredCopy {
678
+ version: string;
679
+ registry: unknown;
680
+ }
681
+ /**
682
+ * Registers this copy of Pandora on `scope`, and reports a different copy
683
+ * that's already there.
684
+ *
685
+ * Everything a component connects to lives in one module: the Registry's
686
+ * tags, global state, middleware and lifecycle hooks. When a page ends up
687
+ * with two copies of Pandora (two installed versions, the browser bundle
688
+ * next to a bundled build, or one import resolved to another file), each
689
+ * copy keeps its own, so nothing fails loudly: a component registered with
690
+ * one is unknown to the other, `@Subscribe` never hears the other's state,
691
+ * and a tag both define throws. Re-importing the same module never
692
+ * evaluates it again, so only a real second copy reports. It logs an error
693
+ * instead of throwing, because the page may still work.
694
+ *
695
+ * @param registry - The Registry of the copy being evaluated.
696
+ * @param version - That copy's version.
697
+ * @param scope - Where copies register; tests pass their own object.
698
+ * @returns `true` when this is the only copy, `false` when another one was found.
699
+ *
700
+ * @internal
701
+ */
702
+ export declare const registerCopy: (registry: unknown, version: string, scope?: object) => boolean;
665
703
  export default Registry;
666
704
  //# sourceMappingURL=Registry.d.ts.map