@aegis-framework/pandora 0.6.3 → 0.7.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.
- package/README.md +224 -27
- package/dist/pandora.browser.js +15 -26
- package/dist/pandora.browser.js.map +38 -37
- package/dist/pandora.js +15 -26
- package/dist/pandora.js.map +37 -36
- package/dist/types/Component.d.ts +112 -18
- package/dist/types/Component.d.ts.map +1 -1
- package/dist/types/Decorators.d.ts +47 -33
- package/dist/types/Decorators.d.ts.map +1 -1
- package/dist/types/Registry.d.ts +51 -13
- package/dist/types/Registry.d.ts.map +1 -1
- package/dist/types/RenderState.d.ts +29 -0
- package/dist/types/RenderState.d.ts.map +1 -0
- package/dist/types/ShadowComponent.d.ts +8 -3
- package/dist/types/ShadowComponent.d.ts.map +1 -1
- package/dist/types/Testing.d.ts +6 -6
- package/dist/types/Testing.d.ts.map +1 -1
- package/dist/types/TypedState.d.ts +1 -1
- package/dist/types/TypedState.d.ts.map +1 -1
- package/dist/types/Types.d.ts +4 -2
- package/dist/types/Types.d.ts.map +1 -1
- package/dist/types/Util.d.ts +119 -62
- package/dist/types/Util.d.ts.map +1 -1
- package/dist/types/browser.d.ts +1 -1
- package/dist/types/browser.d.ts.map +1 -1
- package/dist/types/index.d.ts +20 -17
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +31 -24
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
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`
|
|
358
|
-
* `
|
|
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
|
|
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
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
*
|
|
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,
|
|
1
|
+
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/Component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAG7E,OAAO,KAAK,EAAe,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA+CxG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,cAAM,SAAU,SAAQ,WAAW;IACjC;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB,CAAmE;IAE/F;;;;;OAKG;IACH,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EAAE,OAAO,CAAC;YAAC,OAAO,CAAC,EAAE,OAAO,CAAC;YAAC,IAAI,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,EACvJ,KAAK,EAAE,MAAM,GACZ,OAAO,CA4ET;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
|
|
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
|
|
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
|
|
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`,
|
|
63
|
-
* `@Property
|
|
64
|
-
* the
|
|
65
|
-
*
|
|
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
|
|
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
|
|
111
|
-
interface PropertyOptions {
|
|
112
|
-
|
|
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
|
|
123
|
-
* primitives, or provide a custom `equals`
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
274
|
-
*
|
|
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,17 @@ export declare function QueryAll(selector: string): (_target: undefined, context
|
|
|
285
294
|
* }
|
|
286
295
|
* }
|
|
287
296
|
*/
|
|
288
|
-
export declare
|
|
289
|
-
interface ListenOptions {
|
|
290
|
-
|
|
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
|
+
/** Only fire when the event comes from a descendant matching this selector. */
|
|
291
302
|
delegate?: string;
|
|
303
|
+
/** Listen during the capture phase. */
|
|
292
304
|
capture?: boolean;
|
|
305
|
+
/** Mark the listener as passive. */
|
|
293
306
|
passive?: boolean;
|
|
307
|
+
/** Remove the listener after it first fires (after the first match, with `delegate`). */
|
|
294
308
|
once?: boolean;
|
|
295
309
|
}
|
|
296
310
|
/**
|
|
@@ -320,7 +334,7 @@ interface ListenOptions {
|
|
|
320
334
|
* }
|
|
321
335
|
* }
|
|
322
336
|
*/
|
|
323
|
-
export declare
|
|
337
|
+
export declare const Listen: (event: string, options?: ListenOptions) => <T extends (...args: any[]) => any>(_target: T, context: ClassMethodDecoratorContext) => void;
|
|
324
338
|
/**
|
|
325
339
|
* Turns a getter into a cached derived value. The result is computed once,
|
|
326
340
|
* reused on every read, and invalidated automatically whenever any of the
|
|
@@ -348,8 +362,8 @@ export declare function Listen(event: string, options?: ListenOptions): <T exten
|
|
|
348
362
|
* }
|
|
349
363
|
* }
|
|
350
364
|
*/
|
|
351
|
-
export declare
|
|
352
|
-
type ClassListMap = Record<string, string | ((instance: any) => boolean)>;
|
|
365
|
+
export declare const Computed: (...dependencies: string[]) => <T>(_target: T, context: ClassGetterDecoratorContext) => T;
|
|
366
|
+
export type ClassListMap = Record<string, string | ((instance: any) => boolean)>;
|
|
353
367
|
/**
|
|
354
368
|
* Declaratively toggles classes on the host element based on reactive state.
|
|
355
369
|
* Map a class name to a reactive field name (truthy → class on, falsy →
|
|
@@ -379,7 +393,7 @@ type ClassListMap = Record<string, string | ((instance: any) => boolean)>;
|
|
|
379
393
|
* }
|
|
380
394
|
* }
|
|
381
395
|
*/
|
|
382
|
-
export declare
|
|
396
|
+
export declare const ClassList: (map: ClassListMap) => <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext) => T;
|
|
383
397
|
/**
|
|
384
398
|
* Installs a function on the component that dispatches a bubbling custom
|
|
385
399
|
* event with the given name. Call the field like a method, passing any
|
|
@@ -408,6 +422,6 @@ export declare function ClassList(map: ClassListMap): <T extends ComponentConstr
|
|
|
408
422
|
* // In a parent:
|
|
409
423
|
* // el.addEventListener('button-pressed', (e) => console.log(e.detail.at));
|
|
410
424
|
*/
|
|
411
|
-
export declare
|
|
425
|
+
export declare const Emitter: (eventName: string) => (_target: undefined, context: ClassFieldDecoratorContext) => void;
|
|
412
426
|
export {};
|
|
413
427
|
//# 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,
|
|
1
|
+
{"version":3,"file":"Decorators.d.ts","sourceRoot":"","sources":["../../src/Decorators.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAGvC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAmEzC,KAAK,oBAAoB,GAAG,OAAO,SAAS,GAAG;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AA4BF,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,QAAQ,YAAa,MAAM,YAAY,eAAe,MACzD,CAAC,SAAS,oBAAoB,eAAe,CAAC,WAAW,qBAAqB,KAA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;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"}
|
package/dist/types/Registry.d.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
type
|
|
12
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Registry.d.ts","sourceRoot":"","sources":["../../src/Registry.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"Registry.d.ts","sourceRoot":"","sources":["../../src/Registry.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAYvC,2GAA2G;AAC3G,eAAO,MAAM,OAAO,EAAE,MAAsF,CAAC;AAE7G,KAAK,cAAc,GAAG,OAAO,SAAS,GAAG;IACvC,GAA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