@nisli/core 0.50.0 → 0.52.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 +15 -0
- package/dist/component.d.ts +54 -3
- package/dist/component.js +186 -8
- package/dist/component.js.map +1 -1
- package/dist/element-context.d.ts +81 -0
- package/dist/element-context.js +108 -0
- package/dist/element-context.js.map +1 -0
- package/dist/hmr/registry.d.ts +2 -2
- package/dist/hmr/registry.js +3 -3
- package/dist/hmr/transform.d.ts +1 -1
- package/dist/hmr/transform.js +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/projection.d.ts +44 -0
- package/dist/projection.js +155 -0
- package/dist/projection.js.map +1 -0
- package/dist/query.d.ts +5 -1
- package/dist/query.js +11 -4
- package/dist/query.js.map +1 -1
- package/dist/signal.d.ts +20 -0
- package/dist/signal.js +53 -3
- package/dist/signal.js.map +1 -1
- package/dist/template.d.ts +44 -0
- package/dist/template.js +159 -19
- package/dist/template.js.map +1 -1
- package/dist/vite-hmr/plugin.js +1 -1
- package/dist/vite-hmr/runtime.d.ts +1 -1
- package/dist/vite-hmr/runtime.js +1 -1
- package/package.json +2 -23
- package/dist/esbuild-hmr/plugin.d.ts +0 -154
- package/dist/esbuild-hmr/plugin.js +0 -183
- package/dist/esbuild-hmr/plugin.js.map +0 -1
- package/dist/esbuild-hmr/runtime.d.ts +0 -86
- package/dist/esbuild-hmr/runtime.js +0 -163
- package/dist/esbuild-hmr/runtime.js.map +0 -1
- package/dist/esbuild-hmr/server.d.ts +0 -51
- package/dist/esbuild-hmr/server.js +0 -87
- package/dist/esbuild-hmr/server.js.map +0 -1
package/README.md
CHANGED
|
@@ -101,6 +101,21 @@ await buildStaticSite({
|
|
|
101
101
|
`@nisli/ssg` owns static site generation; static rendering internals stay behind
|
|
102
102
|
the build tool.
|
|
103
103
|
|
|
104
|
+
## Vite HMR Plugin
|
|
105
|
+
|
|
106
|
+
`@nisli/core/vite-hmr` — a dev-only Vite plugin for granular component hot module replacement. Edit a component, it re-mounts in place with no page reload.
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
// vite.config.ts
|
|
110
|
+
import { nisliHmr } from '@nisli/core/vite-hmr';
|
|
111
|
+
|
|
112
|
+
export default defineConfig({
|
|
113
|
+
plugins: [nisliHmr()],
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Used in production by [backlog-mcp](https://github.com/gkoreli/backlog-mcp) — a single Vite process serves the SPA + API on one origin, with component edits hot-swapping via this plugin.
|
|
118
|
+
|
|
104
119
|
## Size
|
|
105
120
|
|
|
106
121
|
~2,600 lines of TypeScript. Zero dependencies.
|
package/dist/component.d.ts
CHANGED
|
@@ -15,9 +15,13 @@ import type { TemplateResult } from './template.js';
|
|
|
15
15
|
/**
|
|
16
16
|
* Maps a props interface to reactive signals.
|
|
17
17
|
* Each prop `P[K]` becomes `Signal<P[K]>`.
|
|
18
|
+
*
|
|
19
|
+
* Optionality is stripped (`-?`): the props Proxy always returns a signal,
|
|
20
|
+
* even for props never set — an optional prop `variant?: T` is
|
|
21
|
+
* `Signal<T | undefined>`, not `Signal<T> | undefined`.
|
|
18
22
|
*/
|
|
19
23
|
export type ReactiveProps<P> = {
|
|
20
|
-
readonly [K in keyof P]
|
|
24
|
+
readonly [K in keyof P]-?: Signal<P[K]>;
|
|
21
25
|
};
|
|
22
26
|
/**
|
|
23
27
|
* The setup function signature. Receives reactive props and host element.
|
|
@@ -47,10 +51,57 @@ export interface HostAttrs {
|
|
|
47
51
|
export type ComponentFactory<P> = (props: {
|
|
48
52
|
[K in keyof P]: PropInput<P[K]>;
|
|
49
53
|
}, hostAttrs?: HostAttrs) => TemplateResult;
|
|
54
|
+
/**
|
|
55
|
+
* Opt-in attribute reactivity declaration (ADR 0025 item 3).
|
|
56
|
+
*
|
|
57
|
+
* Declares how a host attribute maps onto a prop signal, subsuming userland
|
|
58
|
+
* `attr()`/`boolAttr()`/`forwardedAttr()`. Unlike those (which read the
|
|
59
|
+
* attribute once at setup), a declared attribute is `observedAttributes`-wired,
|
|
60
|
+
* so `setAttribute()` AFTER mount writes the prop signal LIVE.
|
|
61
|
+
*
|
|
62
|
+
* - `'string'` — the attribute's string value (absent → `undefined`).
|
|
63
|
+
* - `'boolean'` — OUR boolean semantics: bare/any value → `true`, literal
|
|
64
|
+
* `"false"` → `false`, absent → `false`.
|
|
65
|
+
* - `'number'` — `Number(raw)`; absent → the default (else `undefined`); a
|
|
66
|
+
* non-numeric value behaves as absent → the default (else `undefined`), so a
|
|
67
|
+
* garbage attribute never propagates `NaN` into layout math.
|
|
68
|
+
* - `{ type: 'boolean', default: true }` — as above but absent → the default
|
|
69
|
+
* (so a default-`true` flag can be opted out with `attr="false"`).
|
|
70
|
+
* - `{ type: 'string', default: '…' }` — string with an absent-value default.
|
|
71
|
+
* - `{ type: 'number', default: 0 }` — number with an absent-value default.
|
|
72
|
+
* - `'forward'` — string semantics PLUS relocation: the attribute is removed
|
|
73
|
+
* from the (layout-transparent) host so `id`/`name` live only on the inner
|
|
74
|
+
* control (native form participation), matching `forwardedAttr()`.
|
|
75
|
+
*
|
|
76
|
+
* The observed attribute name is the kebab-case of the prop key (`className` ↔
|
|
77
|
+
* `class-name`, `showOutsideDays` ↔ `show-outside-days`, `id` ↔ `id`). The
|
|
78
|
+
* object forms accept an `attr` override for props whose native attribute is
|
|
79
|
+
* NOT the kebab derivation — e.g. `readOnly: { type: 'boolean', attr: 'readonly' }`
|
|
80
|
+
* (the native boolean attribute is `readonly`, not `read-only`). (v1.1)
|
|
81
|
+
*/
|
|
82
|
+
export type AttrDecl = 'string' | 'boolean' | 'number' | 'forward' | {
|
|
83
|
+
type: 'boolean';
|
|
84
|
+
default?: boolean;
|
|
85
|
+
attr?: string;
|
|
86
|
+
} | {
|
|
87
|
+
type: 'string';
|
|
88
|
+
default?: string;
|
|
89
|
+
attr?: string;
|
|
90
|
+
} | {
|
|
91
|
+
type: 'number';
|
|
92
|
+
default?: number;
|
|
93
|
+
attr?: string;
|
|
94
|
+
};
|
|
50
95
|
/** Options for component() registration */
|
|
51
|
-
export interface ComponentOptions {
|
|
96
|
+
export interface ComponentOptions<P = unknown> {
|
|
52
97
|
/** Custom error fallback renderer */
|
|
53
98
|
onError?: (error: Error, host: HTMLElement) => TemplateResult | string;
|
|
99
|
+
/**
|
|
100
|
+
* Opt-in attribute reactivity (ADR 0025 item 3). Maps prop keys
|
|
101
|
+
* to attribute declarations. Omitted entirely → zero cost (empty
|
|
102
|
+
* `observedAttributes`, no `attributeChangedCallback` work).
|
|
103
|
+
*/
|
|
104
|
+
attrs?: Partial<Record<Extract<keyof P, string>, AttrDecl>>;
|
|
54
105
|
}
|
|
55
106
|
/**
|
|
56
107
|
* Define a web component with typed props and a setup function.
|
|
@@ -72,4 +123,4 @@ export interface ComponentOptions {
|
|
|
72
123
|
* TaskItem({ task: taskSignal, selected: isSelected })
|
|
73
124
|
* ```
|
|
74
125
|
*/
|
|
75
|
-
export declare function component<P extends
|
|
126
|
+
export declare function component<P extends object = Record<string, never>>(tagName: string, setup: SetupFunction<P>, options?: ComponentOptions<P>): ComponentFactory<P>;
|
package/dist/component.js
CHANGED
|
@@ -22,6 +22,37 @@ setContextHook(() => {
|
|
|
22
22
|
}
|
|
23
23
|
return null;
|
|
24
24
|
});
|
|
25
|
+
const camelToKebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
26
|
+
const declType = (decl) => typeof decl === 'string' ? decl : decl.type;
|
|
27
|
+
/** The observed attribute name: an explicit `attr` override, else kebab(key). */
|
|
28
|
+
const declAttrName = (key, decl) => typeof decl === 'object' && decl.attr ? decl.attr : camelToKebab(key);
|
|
29
|
+
/** Resolve a raw attribute string (or null when absent) to the prop value. */
|
|
30
|
+
function resolveAttrValue(decl, raw) {
|
|
31
|
+
const t = declType(decl);
|
|
32
|
+
if (t === 'boolean') {
|
|
33
|
+
const def = typeof decl === 'object' && 'default' in decl && decl.default !== undefined
|
|
34
|
+
? decl.default
|
|
35
|
+
: false;
|
|
36
|
+
if (raw === null)
|
|
37
|
+
return def; // absent → declared default (else false)
|
|
38
|
+
return raw !== 'false'; // bare/any → true, literal "false" → false
|
|
39
|
+
}
|
|
40
|
+
if (t === 'number') {
|
|
41
|
+
const def = typeof decl === 'object' && 'default' in decl ? decl.default : undefined;
|
|
42
|
+
if (raw === null)
|
|
43
|
+
return def; // absent → declared default (else undefined)
|
|
44
|
+
const n = Number(raw);
|
|
45
|
+
// Garbage behaves as ABSENT → the declared default (else undefined). A
|
|
46
|
+
// default exists to guarantee non-undefined; letting garbage fall to
|
|
47
|
+
// literal undefined would reintroduce exactly what the default prevents.
|
|
48
|
+
return Number.isNaN(n) ? def : n;
|
|
49
|
+
}
|
|
50
|
+
// 'string' | 'forward'
|
|
51
|
+
if (raw === null) {
|
|
52
|
+
return typeof decl === 'object' && 'default' in decl ? decl.default : undefined;
|
|
53
|
+
}
|
|
54
|
+
return raw;
|
|
55
|
+
}
|
|
25
56
|
// ── Internal component host ─────────────────────────────────────────
|
|
26
57
|
class ComponentHostImpl {
|
|
27
58
|
element;
|
|
@@ -93,16 +124,77 @@ function createPropsProxy() {
|
|
|
93
124
|
* ```
|
|
94
125
|
*/
|
|
95
126
|
export function component(tagName, setup, options) {
|
|
127
|
+
// Attribute-reactivity wiring (ADR 0025 item 3). Computed once
|
|
128
|
+
// per component definition; empty when no `attrs` declared (→ zero cost).
|
|
129
|
+
const attrEntries = new Map(); // by attrName
|
|
130
|
+
const attrEntriesByKey = new Map(); // by prop key
|
|
131
|
+
if (options?.attrs) {
|
|
132
|
+
for (const key of Object.keys(options.attrs)) {
|
|
133
|
+
const decl = options.attrs[key];
|
|
134
|
+
const attrName = declAttrName(key, decl);
|
|
135
|
+
const entry = { key, attrName, decl };
|
|
136
|
+
attrEntries.set(attrName, entry);
|
|
137
|
+
attrEntriesByKey.set(key, entry);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const observedList = Array.from(attrEntries.keys());
|
|
96
141
|
// The custom element class
|
|
97
142
|
class FrameworkComponent extends HTMLElement {
|
|
98
143
|
_host = null;
|
|
99
144
|
_propsProxy = null;
|
|
100
145
|
_mounted = false;
|
|
101
146
|
_templateResult = null;
|
|
147
|
+
_teardownScheduled = false;
|
|
148
|
+
// Props explicitly set via _setProp (factory / direct assignment) are
|
|
149
|
+
// "pinned": an explicit prop wins, so attribute writes no longer overwrite
|
|
150
|
+
// it. (Precedence ruling: prop-pins.)
|
|
151
|
+
_pinned = new Set();
|
|
152
|
+
// Guards our own removeAttribute() during 'forward' relocation from
|
|
153
|
+
// re-entering attributeChangedCallback.
|
|
154
|
+
_relocating = false;
|
|
155
|
+
/** The browser reads this once at define time. Empty → no callbacks. */
|
|
156
|
+
static get observedAttributes() {
|
|
157
|
+
return observedList;
|
|
158
|
+
}
|
|
102
159
|
constructor() {
|
|
103
160
|
super();
|
|
104
161
|
this._propsProxy = createPropsProxy();
|
|
105
162
|
}
|
|
163
|
+
/** Write one declared attribute onto its prop signal, honoring pinning. */
|
|
164
|
+
_applyAttr(entry, raw) {
|
|
165
|
+
if (declType(entry.decl) === 'forward') {
|
|
166
|
+
// Relocate off the layout-transparent host (no duplicate id/name), but
|
|
167
|
+
// only adopt the attribute's value when no explicit prop pinned it. A
|
|
168
|
+
// null `raw` here (absent OR already-relocated) is a NO-OP: the seed
|
|
169
|
+
// and attributeChangedCallback must not clobber an adopted value. The
|
|
170
|
+
// explicit unpin path (in _setProp) handles clearing.
|
|
171
|
+
if (raw !== null) {
|
|
172
|
+
if (!this._pinned.has(entry.key)) {
|
|
173
|
+
this._propsProxy.setProperty(entry.key, raw);
|
|
174
|
+
}
|
|
175
|
+
this._relocating = true;
|
|
176
|
+
this.removeAttribute(entry.attrName);
|
|
177
|
+
this._relocating = false;
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (this._pinned.has(entry.key))
|
|
182
|
+
return; // explicit prop wins
|
|
183
|
+
this._propsProxy.setProperty(entry.key, resolveAttrValue(entry.decl, raw));
|
|
184
|
+
}
|
|
185
|
+
/** Seed initial prop values from current attributes (incl. defaults). */
|
|
186
|
+
_seedAttrs() {
|
|
187
|
+
for (const entry of attrEntries.values()) {
|
|
188
|
+
this._applyAttr(entry, this.getAttribute(entry.attrName));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
attributeChangedCallback(name, _old, next) {
|
|
192
|
+
if (this._relocating)
|
|
193
|
+
return;
|
|
194
|
+
const entry = attrEntries.get(name);
|
|
195
|
+
if (entry)
|
|
196
|
+
this._applyAttr(entry, next);
|
|
197
|
+
}
|
|
106
198
|
connectedCallback() {
|
|
107
199
|
if (this._mounted)
|
|
108
200
|
return; // guard against re-connection
|
|
@@ -116,7 +208,24 @@ export function component(tagName, setup, options) {
|
|
|
116
208
|
untrack(() => {
|
|
117
209
|
const host = new ComponentHostImpl(this);
|
|
118
210
|
this._host = host;
|
|
211
|
+
// Canonical pre-setup order: SEED → CAPTURE → CONTEXT (then setup).
|
|
212
|
+
//
|
|
213
|
+
// SEED (ADR 0025 item 3): write prop signals from current
|
|
214
|
+
// attributes (incl. declared defaults and 'forward' relocation) so setup
|
|
215
|
+
// sees correct initial values. No-op when no attrs are declared.
|
|
216
|
+
if (attrEntries.size)
|
|
217
|
+
this._seedAttrs();
|
|
218
|
+
// CAPTURE (ADR 0025 item 1): snapshot the host's light-DOM
|
|
219
|
+
// children so children() can project them. Snapshot only — children()
|
|
220
|
+
// removes/projects on demand — so non-projecting components are
|
|
221
|
+
// untouched. Zero-cost when the host has no light DOM.
|
|
222
|
+
if (this.childNodes.length) {
|
|
223
|
+
this.__capturedChildren =
|
|
224
|
+
Array.from(this.childNodes);
|
|
225
|
+
}
|
|
119
226
|
try {
|
|
227
|
+
// CONTEXT is established by runWithContext(host, …) below; setup then
|
|
228
|
+
// runs with seed + capture already in place.
|
|
120
229
|
runWithContext(host, () => {
|
|
121
230
|
this._templateResult = setup(this._propsProxy.props, this);
|
|
122
231
|
});
|
|
@@ -151,22 +260,91 @@ export function component(tagName, setup, options) {
|
|
|
151
260
|
});
|
|
152
261
|
}
|
|
153
262
|
disconnectedCallback() {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
263
|
+
// A same-tick remove+reinsert is a MOVE, not a removal: per WHATWG,
|
|
264
|
+
// append-based moves fire disconnected+connected (only moveBefore()
|
|
265
|
+
// preserves state). Moves happen routinely inside the framework —
|
|
266
|
+
// each() keyed reorders, light-DOM projection of nested components —
|
|
267
|
+
// and re-running setup on them duplicates rendered output and loses
|
|
268
|
+
// state. Defer teardown one microtask and skip it if the element is
|
|
269
|
+
// connected again; connectedCallback's _mounted guard then makes the
|
|
270
|
+
// whole move a no-op. True removals still dispose, one microtask
|
|
271
|
+
// later. See ADR 0023.
|
|
272
|
+
if (this._teardownScheduled)
|
|
273
|
+
return;
|
|
274
|
+
this._teardownScheduled = true;
|
|
275
|
+
queueMicrotask(() => {
|
|
276
|
+
this._teardownScheduled = false;
|
|
277
|
+
if (this.isConnected)
|
|
278
|
+
return;
|
|
279
|
+
this._mounted = false;
|
|
280
|
+
if (this._templateResult?.dispose) {
|
|
281
|
+
this._templateResult.dispose();
|
|
282
|
+
}
|
|
283
|
+
if (this._host) {
|
|
284
|
+
this._host.dispose();
|
|
285
|
+
this._host = null;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
162
288
|
}
|
|
163
289
|
/**
|
|
164
290
|
* Set a prop value. Called by the factory and by direct property assignment.
|
|
165
291
|
* The Proxy intercepts and creates/updates backing signals.
|
|
292
|
+
*
|
|
293
|
+
* Precedence = DEFINED-write-pins (ADR 0025 item 3): a defined
|
|
294
|
+
* value pins the key so a declared attribute no longer overwrites it. An
|
|
295
|
+
* explicit `undefined` (e.g. a factory spreading an unset optional prop —
|
|
296
|
+
* `{...opts}` fires _setProp(key, undefined) per the Object.entries walk)
|
|
297
|
+
* must NOT pin; it falls back to the declared attribute/default, matching
|
|
298
|
+
* attr()'s coalesce. For a declared attribute, that fallback re-resolves
|
|
299
|
+
* from the current attribute, keeping declared-default booleans
|
|
300
|
+
* non-undefined.
|
|
166
301
|
*/
|
|
167
302
|
_setProp(key, value) {
|
|
303
|
+
if (value === undefined) {
|
|
304
|
+
this._pinned.delete(key);
|
|
305
|
+
const entry = attrEntriesByKey.get(key);
|
|
306
|
+
if (entry) {
|
|
307
|
+
const raw = this.getAttribute(entry.attrName);
|
|
308
|
+
// A 'forward' attribute is removed from the host on adoption, so an
|
|
309
|
+
// unpin can't re-read it — resolve the absent value directly to CLEAR
|
|
310
|
+
// a previously pinned id/name (rev audit fix). _applyAttr's forward
|
|
311
|
+
// branch deliberately no-ops on absent (so the seed/attr callback
|
|
312
|
+
// never clobber an adopted value); the explicit unpin does not.
|
|
313
|
+
if (raw === null && declType(entry.decl) === 'forward') {
|
|
314
|
+
this._propsProxy?.setProperty(key, resolveAttrValue(entry.decl, null));
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
this._applyAttr(entry, raw);
|
|
318
|
+
}
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
this._pinned.add(key);
|
|
324
|
+
}
|
|
168
325
|
this._propsProxy?.setProperty(key, value);
|
|
169
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Read a prop's backing signal (framework-internal). Used by children()
|
|
329
|
+
* to fold the factory `children` prop into the projection slot (ADR 0025
|
|
330
|
+
* item 1) without a new public read API.
|
|
331
|
+
*/
|
|
332
|
+
_propSignal(key) {
|
|
333
|
+
return this._propsProxy.props[key];
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Whether a prop is currently pinned by a defined factory/property write
|
|
337
|
+
* (framework-internal, like _propSignal). The attribute-as-truth open-state
|
|
338
|
+
* pattern needs this as its controlled-mode discriminator: a declared
|
|
339
|
+
* 'boolean' prop is never undefined (absent → false), so pin state is the
|
|
340
|
+
* ONLY way a component can tell "parent drives this" from "the attribute
|
|
341
|
+
* drives this" — e.g. setOpen() must not write the open attribute while a
|
|
342
|
+
* controlled parent has it pinned, or the DOM attribute diverges from the
|
|
343
|
+
* pinned state until the next prop write.
|
|
344
|
+
*/
|
|
345
|
+
_isPinned(key) {
|
|
346
|
+
return this._pinned.has(key);
|
|
347
|
+
}
|
|
170
348
|
}
|
|
171
349
|
// Register the custom element (if not already registered)
|
|
172
350
|
if (!customElements.get(tagName)) {
|
package/dist/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAoC,MAAM,aAAa,CAAC;AAClH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,mBAAmB,EAAsB,MAAM,cAAc,CAAC;AAEnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,gFAAgF;AAChF,8DAA8D;AAC9D,cAAc,CAAC,GAAG,EAAE;IAClB,IAAI,UAAU,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,mBAAmB,EAAE,CAAC;QACnC,OAAO,CAAC,QAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AAsDH,uEAAuE;AAEvE,MAAM,iBAAiB;IACrB,OAAO,CAAc;IACb,SAAS,GAAmB,EAAE,CAAC;IAC/B,aAAa,GAAG,KAAK,CAAC;IAE9B,YAAY,OAAoB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,WAAW,CAAC,EAAc;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AC,QAAQ,CAAC,GAAG,CAAC;YAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* element-context.ts — subtree-scoped context (provide / inject).
|
|
3
|
+
*
|
|
4
|
+
* The DOM-native equivalent of React/Radix context: a provider publishes a
|
|
5
|
+
* typed value on its host element, and descendant components `inject()` it by
|
|
6
|
+
* walking up the element tree. It replaces the userland `host.__uiX = state` +
|
|
7
|
+
* `host.closest('ui-x')` convention (stringly-typed, invisible to TypeScript,
|
|
8
|
+
* re-implemented per family) with an identity-keyed, end-to-end-typed primitive.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* interface TabsState { value: ReadonlySignal<string>; setValue(v: string): void }
|
|
12
|
+
* const TabsContext = createContext<TabsState>('Tabs');
|
|
13
|
+
*
|
|
14
|
+
* // provider setup:
|
|
15
|
+
* TabsContext.provide(host, state);
|
|
16
|
+
*
|
|
17
|
+
* // descendant setup:
|
|
18
|
+
* const tabs = TabsContext.inject(); // throws (error boundary) if absent
|
|
19
|
+
* const maybe = TabsContext.inject.optional(); // TabsState | undefined
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Design (see ADR 0025 §2):
|
|
23
|
+
*
|
|
24
|
+
* - **Typed, no string keys.** Each `createContext` mints a private `Symbol`
|
|
25
|
+
* used as the storage key; consumers reference the context object, never a
|
|
26
|
+
* string. Two contexts never collide even with the same `name` (name is for
|
|
27
|
+
* diagnostics only).
|
|
28
|
+
*
|
|
29
|
+
* - **Capture at setup, not at lookup.** `inject()` resolves during component
|
|
30
|
+
* setup, while the injecting host is still a DOM descendant of its provider.
|
|
31
|
+
* It returns the value *once*; because provider values carry signals,
|
|
32
|
+
* reactivity flows through them with no further tree-walks. This is what makes
|
|
33
|
+
* it **portal-safe**: after a subtree is reparented to `<body>` (dialog, menu,
|
|
34
|
+
* …) the injected value is already held, so the component keeps resolving its
|
|
35
|
+
* ORIGINAL provider — a later walk from the portaled host would find nothing.
|
|
36
|
+
* `inject()` therefore requires an active setup context when no host is passed.
|
|
37
|
+
*
|
|
38
|
+
* - **Zero cost for non-users.** Providing sets one symbol property on the host;
|
|
39
|
+
* injecting is a `parentElement` walk. Components that use neither pay nothing,
|
|
40
|
+
* and there is no global registry to maintain.
|
|
41
|
+
*/
|
|
42
|
+
export interface Inject<T> {
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the nearest provider's value by walking up from `host` (default:
|
|
45
|
+
* the current component's host, requiring a setup context). Throws if no
|
|
46
|
+
* provider is found — in a component this surfaces via the error boundary.
|
|
47
|
+
*/
|
|
48
|
+
(host?: HTMLElement): T;
|
|
49
|
+
/** Like `inject()` but returns `undefined` instead of throwing when absent. */
|
|
50
|
+
optional(host?: HTMLElement): T | undefined;
|
|
51
|
+
}
|
|
52
|
+
export interface Context<T> {
|
|
53
|
+
/** Diagnostic label (error messages); not an identity key. */
|
|
54
|
+
readonly name: string;
|
|
55
|
+
/** Publish `value` on `host` so descendants can `inject()` it. */
|
|
56
|
+
provide(host: HTMLElement, value: T): void;
|
|
57
|
+
/** Resolve this context from a descendant (see {@link Inject}). */
|
|
58
|
+
readonly inject: Inject<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Read the value provided on THIS host only — no ancestor walk. `undefined`
|
|
61
|
+
* if `host` is not a provider of this context. The low-level primitive for
|
|
62
|
+
* bespoke walks (e.g. "nearest provider of context A OR context B", which
|
|
63
|
+
* `inject` can't express in one pass); prefer `inject`/`inject.optional`
|
|
64
|
+
* for ordinary descendant resolution.
|
|
65
|
+
*/
|
|
66
|
+
peek(host: HTMLElement): T | undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a subtree-scoped context. `name` is used only in diagnostics; the
|
|
70
|
+
* context's identity (a private symbol) is what keys storage and lookup.
|
|
71
|
+
*
|
|
72
|
+
* Pass `{ providerTag }` to name the provider element so a missing-provider
|
|
73
|
+
* `inject()` produces an ACTIONABLE, element-language error —
|
|
74
|
+
* `<injecting-tag> must be used inside <provider-tag>.` — instead of naming the
|
|
75
|
+
* private context object. Set it whenever consumers are DOM elements (the whole
|
|
76
|
+
* registry): it's the difference between a message a plain-HTML user can act on
|
|
77
|
+
* and one they can't.
|
|
78
|
+
*/
|
|
79
|
+
export declare function createContext<T>(name: string, options?: {
|
|
80
|
+
providerTag?: string;
|
|
81
|
+
}): Context<T>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* element-context.ts — subtree-scoped context (provide / inject).
|
|
3
|
+
*
|
|
4
|
+
* The DOM-native equivalent of React/Radix context: a provider publishes a
|
|
5
|
+
* typed value on its host element, and descendant components `inject()` it by
|
|
6
|
+
* walking up the element tree. It replaces the userland `host.__uiX = state` +
|
|
7
|
+
* `host.closest('ui-x')` convention (stringly-typed, invisible to TypeScript,
|
|
8
|
+
* re-implemented per family) with an identity-keyed, end-to-end-typed primitive.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* interface TabsState { value: ReadonlySignal<string>; setValue(v: string): void }
|
|
12
|
+
* const TabsContext = createContext<TabsState>('Tabs');
|
|
13
|
+
*
|
|
14
|
+
* // provider setup:
|
|
15
|
+
* TabsContext.provide(host, state);
|
|
16
|
+
*
|
|
17
|
+
* // descendant setup:
|
|
18
|
+
* const tabs = TabsContext.inject(); // throws (error boundary) if absent
|
|
19
|
+
* const maybe = TabsContext.inject.optional(); // TabsState | undefined
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Design (see ADR 0025 §2):
|
|
23
|
+
*
|
|
24
|
+
* - **Typed, no string keys.** Each `createContext` mints a private `Symbol`
|
|
25
|
+
* used as the storage key; consumers reference the context object, never a
|
|
26
|
+
* string. Two contexts never collide even with the same `name` (name is for
|
|
27
|
+
* diagnostics only).
|
|
28
|
+
*
|
|
29
|
+
* - **Capture at setup, not at lookup.** `inject()` resolves during component
|
|
30
|
+
* setup, while the injecting host is still a DOM descendant of its provider.
|
|
31
|
+
* It returns the value *once*; because provider values carry signals,
|
|
32
|
+
* reactivity flows through them with no further tree-walks. This is what makes
|
|
33
|
+
* it **portal-safe**: after a subtree is reparented to `<body>` (dialog, menu,
|
|
34
|
+
* …) the injected value is already held, so the component keeps resolving its
|
|
35
|
+
* ORIGINAL provider — a later walk from the portaled host would find nothing.
|
|
36
|
+
* `inject()` therefore requires an active setup context when no host is passed.
|
|
37
|
+
*
|
|
38
|
+
* - **Zero cost for non-users.** Providing sets one symbol property on the host;
|
|
39
|
+
* injecting is a `parentElement` walk. Components that use neither pay nothing,
|
|
40
|
+
* and there is no global registry to maintain.
|
|
41
|
+
*/
|
|
42
|
+
import { getCurrentComponent, hasContext } from './context.js';
|
|
43
|
+
// ── Public API ──────────────────────────────────────────────────────
|
|
44
|
+
/**
|
|
45
|
+
* Create a subtree-scoped context. `name` is used only in diagnostics; the
|
|
46
|
+
* context's identity (a private symbol) is what keys storage and lookup.
|
|
47
|
+
*
|
|
48
|
+
* Pass `{ providerTag }` to name the provider element so a missing-provider
|
|
49
|
+
* `inject()` produces an ACTIONABLE, element-language error —
|
|
50
|
+
* `<injecting-tag> must be used inside <provider-tag>.` — instead of naming the
|
|
51
|
+
* private context object. Set it whenever consumers are DOM elements (the whole
|
|
52
|
+
* registry): it's the difference between a message a plain-HTML user can act on
|
|
53
|
+
* and one they can't.
|
|
54
|
+
*/
|
|
55
|
+
export function createContext(name, options = {}) {
|
|
56
|
+
const { providerTag } = options;
|
|
57
|
+
// Private per-context storage key. Not derived from `name`, so same-named
|
|
58
|
+
// contexts stay distinct, and it never appears in userland.
|
|
59
|
+
const KEY = Symbol(`nisli.context:${name}`);
|
|
60
|
+
const store = (el) => el;
|
|
61
|
+
const provide = (host, value) => {
|
|
62
|
+
store(host)[KEY] = value;
|
|
63
|
+
};
|
|
64
|
+
const peek = (host) => KEY in host ? store(host)[KEY] : undefined;
|
|
65
|
+
// Walk up the element tree (inclusive of `start`) to the nearest provider.
|
|
66
|
+
// `parentElement` transparently crosses `display: contents` hosts.
|
|
67
|
+
const find = (start) => {
|
|
68
|
+
let el = start;
|
|
69
|
+
while (el) {
|
|
70
|
+
if (KEY in el)
|
|
71
|
+
return store(el)[KEY];
|
|
72
|
+
el = el.parentElement;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
};
|
|
76
|
+
const startHost = (host, caller) => {
|
|
77
|
+
if (host)
|
|
78
|
+
return host;
|
|
79
|
+
if (!hasContext()) {
|
|
80
|
+
throw new Error(`${caller} for context "${name}" was called without a host and outside component ` +
|
|
81
|
+
`setup. Call it during setup (so the provider is resolved before any portal move), ` +
|
|
82
|
+
`or pass an explicit host.`);
|
|
83
|
+
}
|
|
84
|
+
return getCurrentComponent().element;
|
|
85
|
+
};
|
|
86
|
+
const inject = ((host) => {
|
|
87
|
+
const start = startHost(host, 'inject()');
|
|
88
|
+
const found = find(start);
|
|
89
|
+
if (found === undefined) {
|
|
90
|
+
const injectingTag = start.tagName.toLowerCase();
|
|
91
|
+
// With a declared provider tag, speak element-language the consumer can
|
|
92
|
+
// act on; otherwise fall back to the generic (provider named by API).
|
|
93
|
+
throw new Error(providerTag
|
|
94
|
+
? `Context "${name}": <${injectingTag}> must be used inside <${providerTag}>.`
|
|
95
|
+
: `Context "${name}" not found: <${injectingTag}> must be rendered ` +
|
|
96
|
+
`inside a provider that calls ${name}Context.provide(host, …).`);
|
|
97
|
+
}
|
|
98
|
+
return found;
|
|
99
|
+
});
|
|
100
|
+
inject.optional = (host) => {
|
|
101
|
+
// Outside setup with no host: there is nothing to resolve from — undefined.
|
|
102
|
+
if (!host && !hasContext())
|
|
103
|
+
return undefined;
|
|
104
|
+
return find(startHost(host, 'inject.optional()'));
|
|
105
|
+
};
|
|
106
|
+
return { name, provide, inject, peek };
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=element-context.js.map
|
|
@@ -0,0 +1 @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
4
4
|
* The tag→setup registry, the stable indirection thunk, and the in-place
|
|
5
5
|
* re-mount through the custom-element lifecycle. This is the part that is
|
|
6
|
-
* IDENTICAL regardless of how change notifications arrive —
|
|
6
|
+
* IDENTICAL regardless of how change notifications arrive — change
|
|
7
7
|
* (`../esbuild-hmr/*`) or Vite `import.meta.hot` (`../vite-hmr/*`) both drive
|
|
8
8
|
* the same registry. Keeping it here means one implementation, one set of
|
|
9
9
|
* correctness guarantees (ADR 0008.1 disposal), and no duplication.
|
|
@@ -17,7 +17,7 @@ export type HmrSetup = (props: unknown, host: HTMLElement) => unknown;
|
|
|
17
17
|
* Begin a caller-owned drain window: suppress auto-scheduling AND cancel any
|
|
18
18
|
* pending microtask drain, so the caller can re-evaluate a whole bundle and
|
|
19
19
|
* register ALL changed tags before a single explicit `drainRemounts()`. Used by
|
|
20
|
-
* the
|
|
20
|
+
* the Vite path drains per-module.
|
|
21
21
|
*/
|
|
22
22
|
export declare function beginManualDrain(): void;
|
|
23
23
|
/** End a caller-owned drain window (re-enable auto-scheduling). */
|
package/dist/hmr/registry.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The tag→setup registry, the stable indirection thunk, and the in-place
|
|
5
5
|
* re-mount through the custom-element lifecycle. This is the part that is
|
|
6
|
-
* IDENTICAL regardless of how change notifications arrive —
|
|
6
|
+
* IDENTICAL regardless of how change notifications arrive — change
|
|
7
7
|
* (`../esbuild-hmr/*`) or Vite `import.meta.hot` (`../vite-hmr/*`) both drive
|
|
8
8
|
* the same registry. Keeping it here means one implementation, one set of
|
|
9
9
|
* correctness guarantees (ADR 0008.1 disposal), and no duplication.
|
|
@@ -19,7 +19,7 @@ let remountScheduled = false;
|
|
|
19
19
|
/**
|
|
20
20
|
* When true, `__register` accumulates pending tags but does NOT auto-schedule a
|
|
21
21
|
* microtask drain — the caller owns the drain so it can wait for a full module
|
|
22
|
-
* re-eval to register ALL changed tags first
|
|
22
|
+
* re-eval to register ALL changed tags first.
|
|
23
23
|
* The Vite path leaves this false and drains explicitly from its accept hook.
|
|
24
24
|
*/
|
|
25
25
|
let suppressAutoDrain = false;
|
|
@@ -27,7 +27,7 @@ let suppressAutoDrain = false;
|
|
|
27
27
|
* Begin a caller-owned drain window: suppress auto-scheduling AND cancel any
|
|
28
28
|
* pending microtask drain, so the caller can re-evaluate a whole bundle and
|
|
29
29
|
* register ALL changed tags before a single explicit `drainRemounts()`. Used by
|
|
30
|
-
* the
|
|
30
|
+
* the Vite path drains per-module.
|
|
31
31
|
*/
|
|
32
32
|
export function beginManualDrain() {
|
|
33
33
|
suppressAutoDrain = true;
|
package/dist/hmr/transform.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Wraps the `component` a module imports from `@nisli/core` with the registry
|
|
5
5
|
* indirection so a rebuilt module's `component()` calls re-register their setup
|
|
6
6
|
* and trigger an in-place re-mount. Transport-agnostic and pure — used by both
|
|
7
|
-
* the
|
|
7
|
+
* the Vite `transform` hook.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Rewrite a module's source so the `component` it imports from `coreSpecifier`
|
package/dist/hmr/transform.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Wraps the `component` a module imports from `@nisli/core` with the registry
|
|
5
5
|
* indirection so a rebuilt module's `component()` calls re-register their setup
|
|
6
6
|
* and trigger an in-place re-mount. Transport-agnostic and pure — used by both
|
|
7
|
-
* the
|
|
7
|
+
* the Vite `transform` hook.
|
|
8
8
|
*/
|
|
9
9
|
function escapeRegExp(s) {
|
|
10
10
|
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|