@aegis-framework/pandora 0.4.2 → 0.6.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 +1394 -727
- package/dist/pandora.browser.js +16 -15
- package/dist/pandora.browser.js.map +11 -9
- package/dist/pandora.js +16 -15
- package/dist/pandora.js.map +10 -8
- package/dist/types/Component.d.ts +792 -209
- package/dist/types/Component.d.ts.map +1 -1
- package/dist/types/Decorators.d.ts +378 -35
- package/dist/types/Decorators.d.ts.map +1 -1
- package/dist/types/Registry.d.ts +478 -105
- package/dist/types/Registry.d.ts.map +1 -1
- package/dist/types/ShadowComponent.d.ts +128 -23
- package/dist/types/ShadowComponent.d.ts.map +1 -1
- package/dist/types/Testing.d.ts +74 -0
- package/dist/types/Testing.d.ts.map +1 -0
- package/dist/types/TypedState.d.ts +51 -0
- package/dist/types/TypedState.d.ts.map +1 -0
- package/dist/types/Types.d.ts +92 -2
- package/dist/types/Types.d.ts.map +1 -1
- package/dist/types/Util.d.ts +134 -15
- package/dist/types/Util.d.ts.map +1 -1
- package/dist/types/browser.d.ts +14 -0
- package/dist/types/browser.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +11 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Registry.d.ts","sourceRoot":"","sources":["../../src/Registry.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Registry.d.ts","sourceRoot":"","sources":["../../src/Registry.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAMpC,KAAK,cAAc,GAAG,OAAO,SAAS,GAAG;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,KAAK,eAAe,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,QAAQ,EAAE,CA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GAAG,EAAE,MAAM,GAAG,OAAO;IAUpC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI;IAuCvD;;;;;;;OAOG;WACU,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B3D;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAInC;;;;;;;;;;;;OAYG;WACU,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYhD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,IAAI;IAOpE;;;;;;;;OAQG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,OAAO;IAcrH;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO;CAGrD;AAQD,eAAe,QAAQ,CAAC"}
|
|
@@ -1,42 +1,147 @@
|
|
|
1
|
+
import { TemplateResult, nothing } from 'lit-html';
|
|
1
2
|
import Component from './Component';
|
|
2
|
-
import {
|
|
3
|
+
import { Style } from './Types';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Component subclass that renders into an open shadow root instead of the host
|
|
6
|
+
* element. Pick it when you need style isolation or slot composition;
|
|
7
|
+
* otherwise extend `Component` directly.
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* The shadow root is attached in the constructor with mode `'open'`, so you
|
|
10
|
+
* can still inspect it from outside via `element.shadowRoot`. Queries,
|
|
11
|
+
* listener targets, and adopted stylesheets all scope to the shadow root
|
|
12
|
+
* rather than the host, which means CSS you apply via `setStyle()` stays
|
|
13
|
+
* encapsulated and doesn't leak to the surrounding page.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* @Register('user-card')
|
|
17
|
+
* class UserCard extends ShadowComponent {
|
|
18
|
+
* @Property() user: { name: string; avatar: string } | null = null;
|
|
19
|
+
*
|
|
20
|
+
* render() {
|
|
21
|
+
* if (!this.user) return nothing;
|
|
22
|
+
* return html`
|
|
23
|
+
* <article>
|
|
24
|
+
* <img src=${this.user.avatar} alt="">
|
|
25
|
+
* <h1>${this.user.name}</h1>
|
|
26
|
+
* <slot></slot>
|
|
27
|
+
* </article>
|
|
28
|
+
* `;
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* async didMount() {
|
|
32
|
+
* this.setStyle({
|
|
33
|
+
* ':host': { display: 'block' },
|
|
34
|
+
* 'article': { padding: '1rem', borderRadius: '8px' }
|
|
35
|
+
* });
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
9
38
|
*/
|
|
10
|
-
declare class ShadowComponent
|
|
11
|
-
|
|
12
|
-
|
|
39
|
+
declare class ShadowComponent extends Component {
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
* The open shadow root attached to the host element. All queries, renders,
|
|
43
|
+
* and style adoption go through this root rather than the host's light DOM.
|
|
44
|
+
*/
|
|
45
|
+
protected _shadowDOM: ShadowRoot;
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
* Shared `CSSStyleSheet` adopted into the shadow root by `setStyle`. Lazily
|
|
49
|
+
* created per subclass so every instance of a component reuses the same
|
|
50
|
+
* constructed stylesheet.
|
|
51
|
+
*/
|
|
52
|
+
protected static _styleSheet: CSSStyleSheet | null;
|
|
53
|
+
/**
|
|
54
|
+
* Attaches an open shadow root to the host element and stores it for use
|
|
55
|
+
* by the query, style, and render helpers. You generally don't call this
|
|
56
|
+
* directly — the browser constructs your component when the tag appears
|
|
57
|
+
* in the DOM. Override it only if you need to run extra setup, and always
|
|
58
|
+
* call `super()` first.
|
|
59
|
+
*/
|
|
13
60
|
constructor();
|
|
14
61
|
/**
|
|
15
|
-
*
|
|
16
|
-
* and shared across all instances of the same component class.
|
|
62
|
+
* Applies styles to the component's shadow root via an adopted stylesheet.
|
|
17
63
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
64
|
+
* Behaves like `Component.setStyle`, but the stylesheet is adopted into
|
|
65
|
+
* the shadow root instead of the document — so the rules stay encapsulated
|
|
66
|
+
* and don't affect anything outside the component. Use `:host` selectors
|
|
67
|
+
* to style the host element itself.
|
|
68
|
+
*
|
|
69
|
+
* @param style - A `Style` object or a CSS string.
|
|
70
|
+
* @param reset - When `true`, replace the existing styles instead of
|
|
71
|
+
* merging on top.
|
|
72
|
+
* @returns The current object-form style after the update.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* async didMount() {
|
|
76
|
+
* this.setStyle({
|
|
77
|
+
* ':host': { display: 'block', padding: '1rem' },
|
|
78
|
+
* 'button': { cursor: 'pointer' }
|
|
79
|
+
* });
|
|
80
|
+
* }
|
|
21
81
|
*/
|
|
22
82
|
setStyle(style: Style | string, reset?: boolean): Style;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
83
|
+
/**
|
|
84
|
+
* @internal
|
|
85
|
+
* Shadow-root variant of the lit-html render hook. Scopes the render target
|
|
86
|
+
* to the shadow root and passes `host: this` so event listeners resolve
|
|
87
|
+
* against the component.
|
|
88
|
+
*/
|
|
89
|
+
protected _applyLitRender(result: TemplateResult | typeof nothing): void;
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
* Shadow-root variant of the string render hook. Wipes the existing shadow
|
|
93
|
+
* content and appends the parsed template so raw HTML strings render inside
|
|
94
|
+
* the encapsulated tree.
|
|
95
|
+
*/
|
|
96
|
+
protected _applyStringRender(html: string): void;
|
|
97
|
+
/**
|
|
98
|
+
* The open shadow root attached to this component.
|
|
99
|
+
*
|
|
100
|
+
* Convenience accessor around the built-in `element.shadowRoot` that
|
|
101
|
+
* returns a non-null `ShadowRoot` — because `ShadowComponent` always
|
|
102
|
+
* attaches one in its constructor, you can use it without a null check.
|
|
103
|
+
* The property is read-only; assigning to it throws.
|
|
104
|
+
*
|
|
105
|
+
* @returns The shadow root owned by this component.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const card = document.querySelector('my-card') as ShadowComponent;
|
|
109
|
+
* const title = card.shadowRoot.querySelector('h1');
|
|
110
|
+
*/
|
|
26
111
|
get shadowRoot(): ShadowRoot;
|
|
27
|
-
set shadowRoot(
|
|
112
|
+
set shadowRoot(_value: ShadowRoot);
|
|
28
113
|
/**
|
|
29
|
-
*
|
|
114
|
+
* Finds the first descendant of the shadow root matching the given CSS
|
|
115
|
+
* selector.
|
|
116
|
+
*
|
|
117
|
+
* Same shape as `Component.query`, but scoped to this component's shadow
|
|
118
|
+
* root instead of its light-DOM subtree. Elements rendered by `render()`
|
|
119
|
+
* live inside the shadow root, so this is the method you want for
|
|
120
|
+
* reaching into your own template.
|
|
30
121
|
*
|
|
31
|
-
* @param selector - CSS selector
|
|
32
|
-
* @returns The first matching element or null
|
|
122
|
+
* @param selector - Any valid CSS selector.
|
|
123
|
+
* @returns The first matching element, or `null` if nothing matched.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* async didMount() {
|
|
127
|
+
* this.query<HTMLInputElement>('input[name="email"]')?.focus();
|
|
128
|
+
* }
|
|
33
129
|
*/
|
|
34
130
|
query<E extends Element = Element>(selector: string): E | null;
|
|
35
131
|
/**
|
|
36
|
-
*
|
|
132
|
+
* Finds every descendant of the shadow root matching the given CSS
|
|
133
|
+
* selector.
|
|
134
|
+
*
|
|
135
|
+
* Same shape as `Component.queryAll`, but scoped to this component's
|
|
136
|
+
* shadow root instead of its light-DOM subtree.
|
|
137
|
+
*
|
|
138
|
+
* @param selector - Any valid CSS selector.
|
|
139
|
+
* @returns A `NodeList` of matching elements (possibly empty).
|
|
37
140
|
*
|
|
38
|
-
* @
|
|
39
|
-
*
|
|
141
|
+
* @example
|
|
142
|
+
* for (const item of this.queryAll('li.item')) {
|
|
143
|
+
* item.classList.add('ready');
|
|
144
|
+
* }
|
|
40
145
|
*/
|
|
41
146
|
queryAll<E extends Element = Element>(selector: string): NodeListOf<E>;
|
|
42
147
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShadowComponent.d.ts","sourceRoot":"","sources":["../../src/ShadowComponent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ShadowComponent.d.ts","sourceRoot":"","sources":["../../src/ShadowComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExE,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,cAAM,eAAgB,SAAQ,SAAS;IACrC;;;;OAIG;IACH,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;IAEjC;;;;;OAKG;IACH,iBAA0B,WAAW,EAAE,aAAa,GAAG,IAAI,CAAQ;IAEnE;;;;;;OAMG;;IAMH;;;;;;;;;;;;;;;;;;;;OAoBG;IACM,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,KAAK;IAoCvE;;;;;OAKG;cACgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,OAAO,GAAG,IAAI;IAIjF;;;;;OAKG;cACgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAezD;;;;;;;;;;;;;OAaG;IACH,IAAI,UAAU,IAAI,UAAU,CAE3B;IAED,IAAI,UAAU,CAAC,MAAM,EAAE,UAAU,EAEhC;IAED;;;;;;;;;;;;;;;;OAgBG;IACM,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAIvE;;;;;;;;;;;;;;OAcG;IACM,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC;CAGhF;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test helpers for Pandora components.
|
|
3
|
+
*
|
|
4
|
+
* These utilities are re-exported as the `testing` namespace from the main
|
|
5
|
+
* entry (`import { testing } from '@aegis-framework/pandora'`). They smooth
|
|
6
|
+
* over the async nature of component rendering so your specs can assert
|
|
7
|
+
* against stable DOM: wait for microtask renders to flush, mount a tag into
|
|
8
|
+
* the document, and reset global Registry state between cases.
|
|
9
|
+
*/
|
|
10
|
+
import Component from './Component';
|
|
11
|
+
/**
|
|
12
|
+
* Flush pending microtask renders.
|
|
13
|
+
*
|
|
14
|
+
* Pandora batches state changes into microtask-scheduled renders. Call
|
|
15
|
+
* `flush` after mutating state so the DOM reflects those changes before your
|
|
16
|
+
* assertions run. Two passes are awaited to cover renders that queue further
|
|
17
|
+
* microtasks during the first pass.
|
|
18
|
+
*
|
|
19
|
+
* @returns A promise that resolves once queued renders have settled.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const el = await mount('my-counter');
|
|
23
|
+
* el.count = 3;
|
|
24
|
+
* await flush();
|
|
25
|
+
* expect(el.textContent).toContain('3');
|
|
26
|
+
*/
|
|
27
|
+
export declare function flush(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Wait until a component reports that it is ready.
|
|
30
|
+
*
|
|
31
|
+
* Resolves immediately if `element.isReady` is already `true`. Otherwise,
|
|
32
|
+
* polls on `requestAnimationFrame` and rejects if the component does not
|
|
33
|
+
* finish its first render within `timeout` milliseconds.
|
|
34
|
+
*
|
|
35
|
+
* @param element - The component element to observe.
|
|
36
|
+
* @param timeout - How long to wait before rejecting, in milliseconds. Defaults to 5000.
|
|
37
|
+
* @returns A promise that resolves once the component is ready.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const el = document.querySelector('user-avatar')!;
|
|
41
|
+
* await whenReady(el);
|
|
42
|
+
*/
|
|
43
|
+
export declare function whenReady(element: Element, timeout?: number): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Reset Registry state between tests.
|
|
46
|
+
*
|
|
47
|
+
* Clears every state key, subscription, and middleware so each spec starts
|
|
48
|
+
* from a clean slate. Component class registrations are not touched. Call
|
|
49
|
+
* this in a `beforeEach` to isolate tests from one another.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* beforeEach(() => {
|
|
53
|
+
* resetRegistry();
|
|
54
|
+
* });
|
|
55
|
+
*/
|
|
56
|
+
export declare function resetRegistry(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Create a component, append it to the DOM, and wait for it to be ready.
|
|
59
|
+
*
|
|
60
|
+
* Wraps the tag in a throwaway container so that attributes and children
|
|
61
|
+
* are parsed in a single pass. Defaults to mounting into `document.body`
|
|
62
|
+
* when no container is provided.
|
|
63
|
+
*
|
|
64
|
+
* @param tagName - The custom element tag to mount (for example `'my-counter'`).
|
|
65
|
+
* @param container - The parent node to append into. Defaults to `document.body`.
|
|
66
|
+
* @param innerHTML - Optional markup to place inside the element's opening and closing tags.
|
|
67
|
+
* @returns The mounted component once it has finished its first render.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const el = await mount('my-greeting', document.body, '<span slot="name">Ada</span>');
|
|
71
|
+
* expect(el.textContent).toContain('Ada');
|
|
72
|
+
*/
|
|
73
|
+
export declare function mount(tagName: string, container?: Element, innerHTML?: string): Promise<Component>;
|
|
74
|
+
//# sourceMappingURL=Testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Testing.d.ts","sourceRoot":"","sources":["../../src/Testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,MAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBjF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAIpC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAYxG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed handle to a single Registry state key.
|
|
3
|
+
*
|
|
4
|
+
* The object returned by `createState` exposes the small surface you need to
|
|
5
|
+
* work with a global value: read it, write it, subscribe to changes, check
|
|
6
|
+
* whether it exists, and delete it. Everything is strongly typed against the
|
|
7
|
+
* generic parameter you pass to `createState`.
|
|
8
|
+
*/
|
|
9
|
+
export interface TypedState<T> {
|
|
10
|
+
/** The underlying Registry state key. */
|
|
11
|
+
readonly key: string;
|
|
12
|
+
/** Read the current value. Returns `undefined` if the key was never set or has been deleted. */
|
|
13
|
+
get(): T | undefined;
|
|
14
|
+
/** Write a new value. The type is checked against the state's generic parameter. */
|
|
15
|
+
set(value: T): void;
|
|
16
|
+
/**
|
|
17
|
+
* Subscribe to changes. The callback runs every time the value is updated,
|
|
18
|
+
* receiving the new and previous values. Returns an unsubscribe function.
|
|
19
|
+
*/
|
|
20
|
+
subscribe(callback: (newValue: T | undefined, oldValue: T | undefined) => void): () => void;
|
|
21
|
+
/** Return `true` if the key currently has a value in the Registry. */
|
|
22
|
+
has(): boolean;
|
|
23
|
+
/** Remove the key from the Registry. Subsequent `get()` calls return `undefined`. */
|
|
24
|
+
delete(): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a typed wrapper around a Registry global state key.
|
|
28
|
+
*
|
|
29
|
+
* Registry state is string-keyed and untyped by default. `createState` gives
|
|
30
|
+
* you a small typed handle so reads, writes, and subscriptions are checked at
|
|
31
|
+
* compile time. If you pass a `defaultValue`, it is written to the Registry
|
|
32
|
+
* immediately when the key does not yet exist, which makes it safe to call
|
|
33
|
+
* during module initialization.
|
|
34
|
+
*
|
|
35
|
+
* @param key - The Registry state key to wrap.
|
|
36
|
+
* @param defaultValue - Optional value to seed the key with if it is not already set.
|
|
37
|
+
* @returns A typed handle with `get`, `set`, `subscribe`, `has`, and `delete`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* type AppState = { theme: 'light' | 'dark'; user: { id: string } | null };
|
|
41
|
+
*
|
|
42
|
+
* const state = {
|
|
43
|
+
* theme: createState<AppState['theme']>('app.theme', 'light'),
|
|
44
|
+
* user: createState<AppState['user']>('app.user', null),
|
|
45
|
+
* };
|
|
46
|
+
*
|
|
47
|
+
* state.theme.set('dark');
|
|
48
|
+
* const unsubscribe = state.user.subscribe(user => console.log(user));
|
|
49
|
+
*/
|
|
50
|
+
export declare function createState<T>(key: string, defaultValue?: T): TypedState<T>;
|
|
51
|
+
//# sourceMappingURL=TypedState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedState.d.ts","sourceRoot":"","sources":["../../src/TypedState.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,gGAAgG;IAChG,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IAErB,oFAAoF;IACpF,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAEpB;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAE5F,sEAAsE;IACtE,GAAG,IAAI,OAAO,CAAC;IAEf,qFAAqF;IACrF,MAAM,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAuB3E"}
|
package/dist/types/Types.d.ts
CHANGED
|
@@ -1,9 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
import { TemplateResult, nothing } from 'lit-html';
|
|
2
|
+
/**
|
|
3
|
+
* A single CSS declaration value. Numbers are serialized as-is, so
|
|
4
|
+
* unitless properties (`zIndex: 2`) and explicit units (`width: '2rem'`)
|
|
5
|
+
* are both valid.
|
|
6
|
+
*/
|
|
2
7
|
export type CSSValue = string | number;
|
|
8
|
+
/**
|
|
9
|
+
* A flat map of CSS property names to values, used for the declaration
|
|
10
|
+
* block of a single selector.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const declarations: CSSProperties = { color: 'white', padding: '1rem' };
|
|
14
|
+
*/
|
|
3
15
|
export type CSSProperties = Record<string, CSSValue>;
|
|
16
|
+
/**
|
|
17
|
+
* A nested CSS object. Keys are selectors, at-rules, or nested property
|
|
18
|
+
* names; values are either individual declarations or further nested
|
|
19
|
+
* CSS objects (used for `@media`, nested rules, and so on).
|
|
20
|
+
*/
|
|
4
21
|
export interface CSSObject {
|
|
5
22
|
[key: string]: CSSValue | CSSProperties | CSSObject;
|
|
6
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* The top-level shape accepted by the `@Style` decorator. Selectors at the
|
|
26
|
+
* root map to declaration blocks; `&` in a nested key refers back to the
|
|
27
|
+
* host selector when encapsulation is enabled.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const styles: Style = {
|
|
31
|
+
* 'button': { color: 'white', background: 'blue' },
|
|
32
|
+
* 'button:hover': { background: 'darkblue' },
|
|
33
|
+
* };
|
|
34
|
+
*/
|
|
7
35
|
export type Style = CSSObject;
|
|
8
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Anything a component's `render()` is allowed to return. Strings are
|
|
38
|
+
* rendered as text, `TemplateResult` values come from `html` and `svg`
|
|
39
|
+
* tagged templates, and `nothing` or `void` render nothing.
|
|
40
|
+
*/
|
|
41
|
+
export type TemplateValue = string | TemplateResult | typeof nothing | void;
|
|
42
|
+
/**
|
|
43
|
+
* A function that produces a template from some context object. Async
|
|
44
|
+
* functions are supported so you can `await` data before returning markup.
|
|
45
|
+
*/
|
|
46
|
+
export type TemplateFunction = (context: any) => TemplateValue | Promise<TemplateValue>;
|
|
47
|
+
/**
|
|
48
|
+
* Options accepted by the imperative `reactive()` helper when turning a
|
|
49
|
+
* plain field into a tracked one.
|
|
50
|
+
*
|
|
51
|
+
* - `initialValue`: seed the field if it has no value yet.
|
|
52
|
+
* - `render`: set to `false` to opt out of auto-rerender on change.
|
|
53
|
+
* - `onChange`: callback fired after each write, with new and old values.
|
|
54
|
+
* - `equals`: custom equality check; defaults to `===` (strict identity).
|
|
55
|
+
*/
|
|
56
|
+
export interface ReactiveOptions {
|
|
57
|
+
initialValue?: unknown;
|
|
58
|
+
render?: boolean;
|
|
59
|
+
onChange?: (newValue: unknown, oldValue: unknown) => void;
|
|
60
|
+
equals?: (a: unknown, b: unknown) => boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The runtime shape a decorator sees when operating on a component
|
|
64
|
+
* instance: a DOM element with arbitrary string or symbol-keyed slots.
|
|
65
|
+
* Custom-decorator authors use this as the parameter type for their
|
|
66
|
+
* effects.
|
|
67
|
+
*/
|
|
68
|
+
export type DecoratorInstance = HTMLElement & Record<string | symbol, unknown>;
|
|
69
|
+
/**
|
|
70
|
+
* A function registered on class metadata that runs once per instance when
|
|
71
|
+
* the component connects. Use `addDecoratorEffect` to register one from a
|
|
72
|
+
* custom decorator.
|
|
73
|
+
*/
|
|
74
|
+
export type DecoratorEffect = (instance: DecoratorInstance) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Metadata entry describing a field wired up by `@Attribute` or by
|
|
77
|
+
* `@Property({ attribute })`. Used internally to sync attribute changes
|
|
78
|
+
* back to the underlying property.
|
|
79
|
+
*/
|
|
80
|
+
export interface AttrHandler {
|
|
81
|
+
attrName: string;
|
|
82
|
+
propertyKey: string;
|
|
83
|
+
valueKey: symbol;
|
|
84
|
+
settingKey: symbol;
|
|
85
|
+
shouldRender: boolean;
|
|
86
|
+
equals: (a: unknown, b: unknown) => boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Metadata entry describing a field wired up by `@Subscribe`. Records the
|
|
90
|
+
* Registry state key the field listens to and the slots used to stash the
|
|
91
|
+
* value and its unsubscribe function.
|
|
92
|
+
*/
|
|
93
|
+
export interface SubscribeHandler {
|
|
94
|
+
stateKey: string;
|
|
95
|
+
propertyKey: string;
|
|
96
|
+
unsubKey: symbol;
|
|
97
|
+
valueKey: symbol;
|
|
98
|
+
}
|
|
9
99
|
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../src/Types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../src/Types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMnD;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,M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AM,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/types/Util.d.ts
CHANGED
|
@@ -1,25 +1,144 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TemplateResult } from 'lit-html';
|
|
2
|
+
import { CSSObject, DecoratorInstance, DecoratorEffect, ReactiveOptions } from './Types';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Invokes a callback and always returns a Promise, regardless of whether the
|
|
5
|
+
* callback itself is sync or async. Lets hooks that may or may not be
|
|
6
|
+
* declared `async` be awaited uniformly without branching at each call site.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
7
9
|
*/
|
|
8
10
|
export declare function callAsync<T>(callable: (...args: any[]) => T, context: any, ...args: any[]): Promise<T>;
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* and
|
|
12
|
+
* Duck-types a value as a lit-html `TemplateResult` by looking for its
|
|
13
|
+
* `_$litType$` brand. We avoid `instanceof` so the check survives across
|
|
14
|
+
* realms and when multiple lit-html copies coexist in the same page.
|
|
13
15
|
*
|
|
14
|
-
* @
|
|
15
|
-
* @returns True if the value is a lit-html TemplateResult
|
|
16
|
+
* @internal
|
|
16
17
|
*/
|
|
17
|
-
export declare function isTemplateResult(value: unknown):
|
|
18
|
+
export declare function isTemplateResult(value: unknown): value is TemplateResult;
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* Flattens a nested `CSSObject` into a CSS string for injection at render
|
|
21
|
+
* time. When `encapsulation` is a tag selector (light-DOM mode), selectors
|
|
22
|
+
* are scoped under it — `:host` maps to the tag, `&`-prefixed rules nest
|
|
23
|
+
* inline, at-rules pass through untouched, and everything else is prefixed.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
23
26
|
*/
|
|
24
27
|
export declare function deserializeCSS(object: CSSObject, encapsulation?: string, level?: number): string;
|
|
28
|
+
/** Metadata slot: array of attribute names that `@Attribute` wants observed on the element. @internal */
|
|
29
|
+
export declare const PROP_ATTRIBUTES: unique symbol;
|
|
30
|
+
/** Metadata slot: per-instance effect functions to replay when a class is evolved or lazily registered. @internal */
|
|
31
|
+
export declare const DECORATOR_EFFECTS: unique symbol;
|
|
32
|
+
/** Metadata slot: teardown callbacks attached to an instance so the outgoing class can unwind before an evolve swap. @internal */
|
|
33
|
+
export declare const DECORATOR_TEARDOWNS: unique symbol;
|
|
34
|
+
/** Metadata slot: `@Watch` registrations pairing a watched property name with the handler method name. @internal */
|
|
35
|
+
export declare const WATCH_HANDLERS: unique symbol;
|
|
36
|
+
/** Metadata slot: set of property names declared reactive via `@State`, `@Attribute`, or `@Property` — used to validate `@Watch` targets. @internal */
|
|
37
|
+
export declare const REACTIVE_FIELDS: unique symbol;
|
|
38
|
+
/** Metadata slot: array of `@Listen` registrations describing event name, target resolver, and options. @internal */
|
|
39
|
+
export declare const LISTEN_HANDLERS: unique symbol;
|
|
40
|
+
/** Metadata slot: resolved `@Style` output (stylesheet text and encapsulation hints) attached by the style decorator. @internal */
|
|
41
|
+
export declare const STYLE_METADATA: unique symbol;
|
|
42
|
+
/** Metadata slot: map from observed attribute names to the handlers that sync them into the instance field. @internal */
|
|
43
|
+
export declare const ATTR_HANDLERS: unique symbol;
|
|
44
|
+
/** Metadata slot: per-field `@Subscribe` registrations that wire a store/observable into a property. @internal */
|
|
45
|
+
export declare const SUBSCRIBE_HANDLERS: unique symbol;
|
|
46
|
+
/**
|
|
47
|
+
* Register a per-instance effect on a class's metadata.
|
|
48
|
+
*
|
|
49
|
+
* Custom-decorator authors call this to attach work that should run once
|
|
50
|
+
* for each component instance — typically during `connectedCallback`. The
|
|
51
|
+
* Registry replays these effects when a class is evolved or lazily
|
|
52
|
+
* registered, so your decorator keeps working across hot swaps.
|
|
53
|
+
*
|
|
54
|
+
* @param meta - The decorator-context metadata object (`context.metadata`).
|
|
55
|
+
* @param effect - A function that receives the component instance.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* function LogMount(): ClassDecorator {
|
|
59
|
+
* return (target, context) => {
|
|
60
|
+
* addDecoratorEffect(context.metadata, (instance) => {
|
|
61
|
+
* console.log(`${instance.tagName} mounted`);
|
|
62
|
+
* });
|
|
63
|
+
* };
|
|
64
|
+
* }
|
|
65
|
+
*/
|
|
66
|
+
export declare function addDecoratorEffect(meta: Record<symbol, unknown>, effect: DecoratorEffect): void;
|
|
67
|
+
/**
|
|
68
|
+
* Register a teardown function for a reactive binding on a component instance.
|
|
69
|
+
*
|
|
70
|
+
* The function runs when the component's class is evolved or lazily
|
|
71
|
+
* replaced — letting the incoming implementation tear down subscriptions,
|
|
72
|
+
* observers, or listeners set up by the previous class before new decorator
|
|
73
|
+
* effects install theirs.
|
|
74
|
+
*
|
|
75
|
+
* Teardowns registered via this helper do NOT automatically run on
|
|
76
|
+
* disconnect. If your decorator installs listeners or subscriptions that
|
|
77
|
+
* must unwind on disconnect, register them in the decorator effect and
|
|
78
|
+
* handle their removal explicitly in that effect's returned cleanup, or
|
|
79
|
+
* through the component's own disconnect path.
|
|
80
|
+
*
|
|
81
|
+
* @param instance - The component instance to attach the teardown to.
|
|
82
|
+
* @param teardown - A function that releases any resources held by the decorator when the class is evolved or replaced.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* function ResizeAware(): ClassDecorator {
|
|
86
|
+
* return (target, context) => {
|
|
87
|
+
* addDecoratorEffect(context.metadata, (instance) => {
|
|
88
|
+
* const observer = new ResizeObserver(() => {});
|
|
89
|
+
* observer.observe(instance);
|
|
90
|
+
* // Runs when the class is evolved or lazily replaced, so the
|
|
91
|
+
* // incoming implementation can install its own observer cleanly.
|
|
92
|
+
* addTeardown(instance, () => observer.disconnect());
|
|
93
|
+
* });
|
|
94
|
+
* };
|
|
95
|
+
* }
|
|
96
|
+
*/
|
|
97
|
+
export declare function addTeardown(instance: DecoratorInstance, teardown: () => void): void;
|
|
98
|
+
/**
|
|
99
|
+
* Make a plain field on a component instance reactive at runtime.
|
|
100
|
+
*
|
|
101
|
+
* This is the imperative escape hatch for `@State`: use it when you cannot
|
|
102
|
+
* reach for decorators (for example, in environments without decorator
|
|
103
|
+
* support, or when wiring up a field from a constructor or custom
|
|
104
|
+
* decorator). The field keeps its current value, but writes now trigger
|
|
105
|
+
* `@Watch` handlers, `didChange`, and an auto-rerender unless you opt out.
|
|
106
|
+
*
|
|
107
|
+
* @param instance - The component instance that owns the field.
|
|
108
|
+
* @param propertyKey - The field name to make reactive.
|
|
109
|
+
* @param options - Optional initial value, change callback, equality check, or `render: false` to skip auto-rerender.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // A custom field decorator that installs reactivity at runtime, so the
|
|
113
|
+
* // author doesn't have to compose it with @State at every call site.
|
|
114
|
+
* function Counter(initialValue: number = 0): (target: undefined, context: ClassFieldDecoratorContext) => void {
|
|
115
|
+
* return (_target, context) => {
|
|
116
|
+
* const propertyKey = String(context.name);
|
|
117
|
+
* addDecoratorEffect(context.metadata, (instance) => {
|
|
118
|
+
* reactive(instance, propertyKey, { initialValue });
|
|
119
|
+
* });
|
|
120
|
+
* };
|
|
121
|
+
* }
|
|
122
|
+
*/
|
|
123
|
+
export declare function reactive(instance: DecoratorInstance, propertyKey: string, options?: ReactiveOptions): void;
|
|
124
|
+
/**
|
|
125
|
+
* Coerces a raw attribute string into its JavaScript value: `null` becomes
|
|
126
|
+
* `undefined`, the empty string and `"true"` become `true`, `"false"` becomes
|
|
127
|
+
* `false`, numeric strings become numbers, and everything else is passed
|
|
128
|
+
* through as a string. Used when `@Attribute` syncs HTML into a reactive field.
|
|
129
|
+
*
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
export declare function parseAttributeValue(value: string | null): unknown;
|
|
133
|
+
/**
|
|
134
|
+
* Resolves the `target` option of `@Listen` to an actual `EventTarget`. The
|
|
135
|
+
* strings `"window"` and `"document"` map to their globals, `"self"` (or an
|
|
136
|
+
* omitted option) returns the host element, and any other string is treated
|
|
137
|
+
* as a CSS selector. Selectors are routed through the component's own
|
|
138
|
+
* `query()` when provided so they resolve against the host's subtree (light
|
|
139
|
+
* or shadow) rather than the whole document.
|
|
140
|
+
*
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
export declare function resolveListenerTarget(host: HTMLElement, targetOption?: string, query?: (selector: string) => Element | null): EventTarget | null;
|
|
25
144
|
//# sourceMappingURL=Util.d.ts.map
|
package/dist/types/Util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../src/Util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../src/Util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEzF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAOtG;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAA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B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAiBjE;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,WAAW,EACjB,YAAY,CAAC,EAAE,MAAM,EACrB,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,GAC3C,WAAW,GAAG,IAAI,CAcpB"}
|
package/dist/types/browser.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser bundle entrypoint for non-module consumers.
|
|
3
|
+
*
|
|
4
|
+
* Load the built bundle from a plain `<script>` tag, or import from
|
|
5
|
+
* `'@aegis-framework/pandora/browser'` for its side effects: the module
|
|
6
|
+
* assigns the entire Pandora namespace to `window.Pandora` so globals like
|
|
7
|
+
* `Pandora.Component` and `Pandora.html` are available without any import
|
|
8
|
+
* statement.
|
|
9
|
+
*
|
|
10
|
+
* Module-based apps should import from the main entry
|
|
11
|
+
* (`'@aegis-framework/pandora'`) instead. This file exists purely because
|
|
12
|
+
* bundlers cannot yet expose an ESM module as a browser global on their
|
|
13
|
+
* own; once/if Bun grows that capability, the file can go away.
|
|
14
|
+
*/
|
|
1
15
|
import * as Pandora from './index';
|
|
2
16
|
declare global {
|
|
3
17
|
interface Window {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,EAAE,OAAO,OAAO,CAAC;KACzB;CACF"}
|