@vesk/runtime 0.2.42 → 0.2.43
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/dist/index-client.d.ts +2 -0
- package/dist/index-client.d.ts.map +1 -1
- package/dist/index-client.js +1 -0
- package/dist/index-server.d.ts +2 -0
- package/dist/index-server.d.ts.map +1 -1
- package/dist/index-server.js +1 -0
- package/dist/primitive.d.ts +119 -0
- package/dist/primitive.d.ts.map +1 -0
- package/dist/primitive.js +234 -0
- package/package.json +2 -2
package/dist/index-client.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export { Experiment } from '@vesk/runtime/src/experiment';
|
|
|
20
20
|
export { Form, Field, required, email, minLength, maxLength, pattern, custom } from '@vesk/runtime/src/form';
|
|
21
21
|
export { Md } from '@vesk/runtime/src/md';
|
|
22
22
|
export { Show, For, Switch, Match } from '@vesk/runtime/src/headless';
|
|
23
|
+
export { primitive, leaf, isPrimitive, isLeaf, isVeskComponent, toDomNode, rerenderNode } from '@vesk/runtime/src/primitive';
|
|
24
|
+
export type { VeskLeafComponent, VeskPrimitiveComponent, VeskTaggedLeafComponent, VeskComponentRegistry, VeskScope } from '@vesk/types';
|
|
23
25
|
export { LoadingIndicator, useLoadingIndicator, configureLoadingIndicator, getLoadingProgress, isLoadingActive, getLoadingError, LOADING_INDICATOR_DEFAULT_COLOR, LOADING_INDICATOR_DEFAULT_ERROR_COLOR } from '@vesk/runtime/src/loading-indicator';
|
|
24
26
|
export type { LoadingIndicatorHandle, LoadingIndicatorOptions, LoadingIndicatorProps } from '@vesk/runtime/src/loading-indicator';
|
|
25
27
|
export { defineAction, getAction, clearActions, validateActionInput, issuesToFieldMap, isFormAction } from '@vesk/runtime/src/action';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-client.d.ts","sourceRoot":"","sources":["../src/index-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE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gBAAgB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,+BAA+B,EAAE,qCAAqC,EAAE,MAAM,qCAAqC,CAAC;AACrP,YAAY,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAClI,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index-client.js
CHANGED
|
@@ -16,5 +16,6 @@ export { Experiment } from '@vesk/runtime/src/experiment';
|
|
|
16
16
|
export { Form, Field, required, email, minLength, maxLength, pattern, custom } from '@vesk/runtime/src/form';
|
|
17
17
|
export { Md } from '@vesk/runtime/src/md';
|
|
18
18
|
export { Show, For, Switch, Match } from '@vesk/runtime/src/headless';
|
|
19
|
+
export { primitive, leaf, isPrimitive, isLeaf, isVeskComponent, toDomNode, rerenderNode } from '@vesk/runtime/src/primitive';
|
|
19
20
|
export { LoadingIndicator, useLoadingIndicator, configureLoadingIndicator, getLoadingProgress, isLoadingActive, getLoadingError, LOADING_INDICATOR_DEFAULT_COLOR, LOADING_INDICATOR_DEFAULT_ERROR_COLOR } from '@vesk/runtime/src/loading-indicator';
|
|
20
21
|
export { defineAction, getAction, clearActions, validateActionInput, issuesToFieldMap, isFormAction } from '@vesk/runtime/src/action';
|
package/dist/index-server.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { Experiment } from '@vesk/runtime/src/experiment';
|
|
|
13
13
|
export { Form, Field, required, email, minLength, maxLength, pattern, custom } from '@vesk/runtime/src/form';
|
|
14
14
|
export { Md } from '@vesk/runtime/src/md';
|
|
15
15
|
export { Show, For, Switch, Match } from '@vesk/runtime/src/headless';
|
|
16
|
+
export { primitive, leaf, isPrimitive, isLeaf, isVeskComponent, toDomNode, rerenderNode } from '@vesk/runtime/src/primitive';
|
|
17
|
+
export type { VeskLeafComponent, VeskPrimitiveComponent, VeskTaggedLeafComponent, VeskComponentRegistry, VeskScope } from '@vesk/types';
|
|
16
18
|
export { LoadingIndicator, useLoadingIndicator, configureLoadingIndicator, getLoadingProgress, isLoadingActive, getLoadingError } from '@vesk/runtime/src/loading-indicator';
|
|
17
19
|
export type { LoadingIndicatorHandle, LoadingIndicatorOptions, LoadingIndicatorProps } from '@vesk/runtime/src/loading-indicator';
|
|
18
20
|
export { defineAction, getAction, clearActions, validateActionInput, issuesToFieldMap, isFormAction } from '@vesk/runtime/src/action';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-server.d.ts","sourceRoot":"","sources":["../src/index-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC5S,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,sBAAsB,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC1P,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACtI,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,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oB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACxK,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC7H,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxI,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC7K,YAAY,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAClI,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index-server.js
CHANGED
|
@@ -13,5 +13,6 @@ export { Experiment } from '@vesk/runtime/src/experiment';
|
|
|
13
13
|
export { Form, Field, required, email, minLength, maxLength, pattern, custom } from '@vesk/runtime/src/form';
|
|
14
14
|
export { Md } from '@vesk/runtime/src/md';
|
|
15
15
|
export { Show, For, Switch, Match } from '@vesk/runtime/src/headless';
|
|
16
|
+
export { primitive, leaf, isPrimitive, isLeaf, isVeskComponent, toDomNode, rerenderNode } from '@vesk/runtime/src/primitive';
|
|
16
17
|
export { LoadingIndicator, useLoadingIndicator, configureLoadingIndicator, getLoadingProgress, isLoadingActive, getLoadingError } from '@vesk/runtime/src/loading-indicator';
|
|
17
18
|
export { defineAction, getAction, clearActions, validateActionInput, issuesToFieldMap, isFormAction } from '@vesk/runtime/src/action';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `primitive` / `leaf` — the two authoring wrappers for the Vesk component ABI.
|
|
3
|
+
*
|
|
4
|
+
* Every component call in Vesk, including a bare `<Badge/>` with no
|
|
5
|
+
* attributes, is invoked as `callee(props, __registry, __veskScope)`. The
|
|
6
|
+
* compiler always passes an object literal at the call site (`{}` when there
|
|
7
|
+
* are no attributes), so `props` is never nullish coming *from the framework*.
|
|
8
|
+
*
|
|
9
|
+
* The gap this module closes is the other direction: a component exported from
|
|
10
|
+
* a module is an ordinary function, and an ordinary function can be called
|
|
11
|
+
* with no arguments at all — `Badge()` from a helper, a test, a render
|
|
12
|
+
* callback, or a manual `registry.get('Badge')!(undefined, reg, scope)` probe.
|
|
13
|
+
* A hand-written `function Badge(props) { return props.children }` throws
|
|
14
|
+
* `Cannot read properties of undefined` in that case. `primitive()` removes
|
|
15
|
+
* that whole class of failure by normalizing nullish props to a frozen empty
|
|
16
|
+
* object before the wrapped function ever sees them.
|
|
17
|
+
*
|
|
18
|
+
* `leaf()` is the behavioural counterpart: stateful widgets, own click
|
|
19
|
+
* handlers, async components. They implement the `VeskLeafComponent` ABI
|
|
20
|
+
* directly — the wrapper only stamps the marker so the two kinds can be told
|
|
21
|
+
* apart at runtime.
|
|
22
|
+
*
|
|
23
|
+
* Both wrappers are pure: no `document`/`window` access, no top-level side
|
|
24
|
+
* effects, safe to import from the client and server barrels alike.
|
|
25
|
+
*/
|
|
26
|
+
import type { VeskComponentRegistry, VeskLeafComponent, VeskPrimitiveComponent, VeskScope, VeskTaggedLeafComponent } from '@vesk/types';
|
|
27
|
+
/**
|
|
28
|
+
* Wrap a presentational component so it is safe to call with no arguments.
|
|
29
|
+
*
|
|
30
|
+
* The wrapped function is *not* a copy of `fn` — it forwards `props`,
|
|
31
|
+
* `__registry` and the scope untouched, so identity-sensitive behavior
|
|
32
|
+
* (scope preference, `__veskScope`) is unchanged. Only a nullish `props` is
|
|
33
|
+
* substituted; a real props object is never cloned, merged or stripped, which
|
|
34
|
+
* matters because on the client `props.children` can be a live reactive
|
|
35
|
+
* container that must reach `fn` by reference.
|
|
36
|
+
*
|
|
37
|
+
* @param fn - The presentational component. Receives `(props, registry, scope)`.
|
|
38
|
+
* @returns A {@link VeskPrimitiveComponent} callable as `Badge()` or `<Badge/>`.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const Badge = primitive((props) => `<span class="badge">${props.label ?? ''}</span>`);
|
|
42
|
+
* Badge(); // '' — no throw
|
|
43
|
+
* Badge({ label: 'new' }); // '<span class="badge">new</span>'
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function primitive<P extends object = Record<string, unknown>>(fn: (props: P, registry?: VeskComponentRegistry, scope?: VeskScope) => unknown | Promise<unknown>): VeskPrimitiveComponent<P>;
|
|
47
|
+
/**
|
|
48
|
+
* Tag a stateful/async component as a leaf so `isLeaf()` can identify it.
|
|
49
|
+
*
|
|
50
|
+
* Behaviourally a no-op — the function is returned as-is (plus the marker) so
|
|
51
|
+
* the `__veskScope` property the SSR renderer assigns to compiled components
|
|
52
|
+
* stays writable. Use it to document intent and to let tooling distinguish a
|
|
53
|
+
* behavioural widget from a `primitive()` one; do not use it to give a
|
|
54
|
+
* primitive extra behavior it cannot support.
|
|
55
|
+
*
|
|
56
|
+
* @param fn - The leaf component implementing `(props, registry, scope)`.
|
|
57
|
+
* @returns The same function, tagged with `__veskLeaf`.
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const Tabs = leaf((props, registry, scope) => {
|
|
61
|
+
* const &[open] = track(0);
|
|
62
|
+
* return `<div>${open}</div>`;
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function leaf<P extends object = Record<string, unknown>>(fn: VeskLeafComponent<P>): VeskTaggedLeafComponent<P>;
|
|
67
|
+
/** True when `value` was produced by {@link primitive}. */
|
|
68
|
+
export declare function isPrimitive(value: unknown): value is VeskPrimitiveComponent;
|
|
69
|
+
/** True when `value` was tagged by {@link leaf}. */
|
|
70
|
+
export declare function isLeaf(value: unknown): value is VeskTaggedLeafComponent;
|
|
71
|
+
/**
|
|
72
|
+
* True when `value` is callable as a Vesk component — i.e. it is a function at
|
|
73
|
+
* all. Every registry entry satisfies this; the distinction that matters for
|
|
74
|
+
* authoring is {@link isPrimitive} vs {@link isLeaf}.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isVeskComponent(value: unknown): value is VeskLeafComponent;
|
|
77
|
+
/**
|
|
78
|
+
* Normalize a component call's return value into something the client renderer
|
|
79
|
+
* can insert.
|
|
80
|
+
*
|
|
81
|
+
* A compiled `.vsk` component returns a DOM `Node`, and the runtime components
|
|
82
|
+
* (`Image`, `Form`, `Md`, …) build one when `document` exists. A `primitive()`
|
|
83
|
+
* or `leaf()` written as a template string has no such branch — it returns a
|
|
84
|
+
* string on BOTH sides, because that is the whole point of the terse form. The
|
|
85
|
+
* server concatenates it into the HTML; the client would otherwise hand a
|
|
86
|
+
* string to `appendChild`/`replaceChild` and throw "parameter 1 is not of type
|
|
87
|
+
* 'Node'", taking the page's error boundary with it.
|
|
88
|
+
*
|
|
89
|
+
* So: a `Node` passes through untouched, a string is parsed into its root
|
|
90
|
+
* node(s), and every other value (including `null`/`undefined`/`false`, which
|
|
91
|
+
* callers test for) is returned as-is. On the server there is nothing to
|
|
92
|
+
* normalize into, so strings pass through unchanged.
|
|
93
|
+
*/
|
|
94
|
+
export declare function toDomNode<T>(value: T): T | Node | DocumentFragment;
|
|
95
|
+
/**
|
|
96
|
+
* Keep a rendered markup node in sync with the tracked values it was built
|
|
97
|
+
* from, without re-invoking the component at mount.
|
|
98
|
+
*
|
|
99
|
+
* A `primitive()` or `leaf()` written as a template string is called once and
|
|
100
|
+
* its result is converted to DOM once. Tracked values it READ (through the
|
|
101
|
+
* `reactiveProps` proxy) therefore subscribe nobody: a later write updated the
|
|
102
|
+
* cell and left the markup stale, so a leaf driven by a parent's counter never
|
|
103
|
+
* moved. Compiled components avoid this because their bindings re-run; string
|
|
104
|
+
* components have no bindings, so the runtime re-runs the call and swaps the
|
|
105
|
+
* produced nodes in place.
|
|
106
|
+
*
|
|
107
|
+
* The dep list is read by the effect purely to SUBSCRIBE. The first effect run
|
|
108
|
+
* therefore performs no re-render — it compares against the values captured at
|
|
109
|
+
* mount, which also covers a write that lands between mount and the first
|
|
110
|
+
* flush. Re-rendering is skipped when the node has been detached (its owner was
|
|
111
|
+
* torn down), so a stale effect can never graft nodes back into the document.
|
|
112
|
+
*
|
|
113
|
+
* @param node - The node (or fragment) the mount already inserted.
|
|
114
|
+
* @param deps - Tracked cells / values the markup was derived from.
|
|
115
|
+
* @param call - Re-invokes the component and returns fresh markup.
|
|
116
|
+
* @returns `node`, so the call can wrap the mount expression in place.
|
|
117
|
+
*/
|
|
118
|
+
export declare function rerenderNode<T>(node: T, deps: readonly unknown[], call: () => unknown): T;
|
|
119
|
+
//# sourceMappingURL=primitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../src/primitive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,SAAS,EACT,uBAAuB,EACvB,MAAM,aAAa,CAAC;AAmBrB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,qBAAqB,EAAE,KAAK,CAAC,EAAE,SAAS,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAC/F,sBAAsB,CAAC,CAAC,CAAC,CAS3B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9D,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,GACtB,uBAAuB,CAAC,CAAC,CAAC,CAG5B;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CAE3E;AAED,oDAAoD;AACpD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAE1E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,gBAAgB,CAwBlE;AAYD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,GAAG,CAAC,CA4CzF"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `primitive` / `leaf` — the two authoring wrappers for the Vesk component ABI.
|
|
3
|
+
*
|
|
4
|
+
* Every component call in Vesk, including a bare `<Badge/>` with no
|
|
5
|
+
* attributes, is invoked as `callee(props, __registry, __veskScope)`. The
|
|
6
|
+
* compiler always passes an object literal at the call site (`{}` when there
|
|
7
|
+
* are no attributes), so `props` is never nullish coming *from the framework*.
|
|
8
|
+
*
|
|
9
|
+
* The gap this module closes is the other direction: a component exported from
|
|
10
|
+
* a module is an ordinary function, and an ordinary function can be called
|
|
11
|
+
* with no arguments at all — `Badge()` from a helper, a test, a render
|
|
12
|
+
* callback, or a manual `registry.get('Badge')!(undefined, reg, scope)` probe.
|
|
13
|
+
* A hand-written `function Badge(props) { return props.children }` throws
|
|
14
|
+
* `Cannot read properties of undefined` in that case. `primitive()` removes
|
|
15
|
+
* that whole class of failure by normalizing nullish props to a frozen empty
|
|
16
|
+
* object before the wrapped function ever sees them.
|
|
17
|
+
*
|
|
18
|
+
* `leaf()` is the behavioural counterpart: stateful widgets, own click
|
|
19
|
+
* handlers, async components. They implement the `VeskLeafComponent` ABI
|
|
20
|
+
* directly — the wrapper only stamps the marker so the two kinds can be told
|
|
21
|
+
* apart at runtime.
|
|
22
|
+
*
|
|
23
|
+
* Both wrappers are pure: no `document`/`window` access, no top-level side
|
|
24
|
+
* effects, safe to import from the client and server barrels alike.
|
|
25
|
+
*/
|
|
26
|
+
import { get } from '@vesk/runtime/src/ripple-runtime';
|
|
27
|
+
import { effect } from '@vesk/runtime/src/ripple-blocks';
|
|
28
|
+
/**
|
|
29
|
+
* Shared stand-in for "called with no props". Frozen so a primitive that
|
|
30
|
+
* mutates `props` by mistake fails loudly in strict mode instead of leaking
|
|
31
|
+
* state between unrelated zero-arg calls.
|
|
32
|
+
*/
|
|
33
|
+
const EMPTY_PROPS = Object.freeze({});
|
|
34
|
+
/**
|
|
35
|
+
* Wrap a presentational component so it is safe to call with no arguments.
|
|
36
|
+
*
|
|
37
|
+
* The wrapped function is *not* a copy of `fn` — it forwards `props`,
|
|
38
|
+
* `__registry` and the scope untouched, so identity-sensitive behavior
|
|
39
|
+
* (scope preference, `__veskScope`) is unchanged. Only a nullish `props` is
|
|
40
|
+
* substituted; a real props object is never cloned, merged or stripped, which
|
|
41
|
+
* matters because on the client `props.children` can be a live reactive
|
|
42
|
+
* container that must reach `fn` by reference.
|
|
43
|
+
*
|
|
44
|
+
* @param fn - The presentational component. Receives `(props, registry, scope)`.
|
|
45
|
+
* @returns A {@link VeskPrimitiveComponent} callable as `Badge()` or `<Badge/>`.
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const Badge = primitive((props) => `<span class="badge">${props.label ?? ''}</span>`);
|
|
49
|
+
* Badge(); // '' — no throw
|
|
50
|
+
* Badge({ label: 'new' }); // '<span class="badge">new</span>'
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function primitive(fn) {
|
|
54
|
+
const wrapped = ((props, registry, scope) => {
|
|
55
|
+
// Nullish-only guard: any other value is the caller's business. A frozen
|
|
56
|
+
// singleton avoids an allocation per zero-arg call and keeps `Object.is`
|
|
57
|
+
// stable for the common no-props case.
|
|
58
|
+
return fn(props == null ? EMPTY_PROPS : props, registry, scope);
|
|
59
|
+
});
|
|
60
|
+
wrapped.__veskPrimitive = true;
|
|
61
|
+
return wrapped;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Tag a stateful/async component as a leaf so `isLeaf()` can identify it.
|
|
65
|
+
*
|
|
66
|
+
* Behaviourally a no-op — the function is returned as-is (plus the marker) so
|
|
67
|
+
* the `__veskScope` property the SSR renderer assigns to compiled components
|
|
68
|
+
* stays writable. Use it to document intent and to let tooling distinguish a
|
|
69
|
+
* behavioural widget from a `primitive()` one; do not use it to give a
|
|
70
|
+
* primitive extra behavior it cannot support.
|
|
71
|
+
*
|
|
72
|
+
* @param fn - The leaf component implementing `(props, registry, scope)`.
|
|
73
|
+
* @returns The same function, tagged with `__veskLeaf`.
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const Tabs = leaf((props, registry, scope) => {
|
|
77
|
+
* const &[open] = track(0);
|
|
78
|
+
* return `<div>${open}</div>`;
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export function leaf(fn) {
|
|
83
|
+
fn.__veskLeaf = true;
|
|
84
|
+
return fn;
|
|
85
|
+
}
|
|
86
|
+
/** True when `value` was produced by {@link primitive}. */
|
|
87
|
+
export function isPrimitive(value) {
|
|
88
|
+
return typeof value === 'function' && value.__veskPrimitive === true;
|
|
89
|
+
}
|
|
90
|
+
/** True when `value` was tagged by {@link leaf}. */
|
|
91
|
+
export function isLeaf(value) {
|
|
92
|
+
return typeof value === 'function' && value.__veskLeaf === true;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* True when `value` is callable as a Vesk component — i.e. it is a function at
|
|
96
|
+
* all. Every registry entry satisfies this; the distinction that matters for
|
|
97
|
+
* authoring is {@link isPrimitive} vs {@link isLeaf}.
|
|
98
|
+
*/
|
|
99
|
+
export function isVeskComponent(value) {
|
|
100
|
+
return typeof value === 'function';
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Normalize a component call's return value into something the client renderer
|
|
104
|
+
* can insert.
|
|
105
|
+
*
|
|
106
|
+
* A compiled `.vsk` component returns a DOM `Node`, and the runtime components
|
|
107
|
+
* (`Image`, `Form`, `Md`, …) build one when `document` exists. A `primitive()`
|
|
108
|
+
* or `leaf()` written as a template string has no such branch — it returns a
|
|
109
|
+
* string on BOTH sides, because that is the whole point of the terse form. The
|
|
110
|
+
* server concatenates it into the HTML; the client would otherwise hand a
|
|
111
|
+
* string to `appendChild`/`replaceChild` and throw "parameter 1 is not of type
|
|
112
|
+
* 'Node'", taking the page's error boundary with it.
|
|
113
|
+
*
|
|
114
|
+
* So: a `Node` passes through untouched, a string is parsed into its root
|
|
115
|
+
* node(s), and every other value (including `null`/`undefined`/`false`, which
|
|
116
|
+
* callers test for) is returned as-is. On the server there is nothing to
|
|
117
|
+
* normalize into, so strings pass through unchanged.
|
|
118
|
+
*/
|
|
119
|
+
export function toDomNode(value) {
|
|
120
|
+
if (typeof document === 'undefined')
|
|
121
|
+
return value;
|
|
122
|
+
if (value == null || typeof value === 'boolean')
|
|
123
|
+
return value;
|
|
124
|
+
if (typeof value.nodeType === 'number') {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
if (typeof value !== 'string')
|
|
128
|
+
return value;
|
|
129
|
+
if (value === '')
|
|
130
|
+
return document.createDocumentFragment();
|
|
131
|
+
const template = document.createElement('template');
|
|
132
|
+
template.innerHTML = value;
|
|
133
|
+
const { content } = template;
|
|
134
|
+
// A single root becomes that node; several roots stay a fragment so the
|
|
135
|
+
// caller can splice them in without inventing a wrapper element that was
|
|
136
|
+
// never in the SSR markup.
|
|
137
|
+
if (content.childNodes.length === 1) {
|
|
138
|
+
const only = content.firstChild;
|
|
139
|
+
// Detach before returning: a node still parented to the template's
|
|
140
|
+
// content fragment reads as "already mounted" to the compiler's
|
|
141
|
+
// hydrate guard (`value.parentNode == null`), so the fresh node would
|
|
142
|
+
// never be inserted and the claimed SSR node would be retired instead.
|
|
143
|
+
content.removeChild(only);
|
|
144
|
+
return only;
|
|
145
|
+
}
|
|
146
|
+
return content;
|
|
147
|
+
}
|
|
148
|
+
/** True when `value` is a tracked cell (the shape `get`/`set` operate on). */
|
|
149
|
+
function isCell(value) {
|
|
150
|
+
return typeof value === 'object' && value !== null && typeof value.f === 'number';
|
|
151
|
+
}
|
|
152
|
+
/** Read a dep as the value a render would see: cells unwrap, literals pass. */
|
|
153
|
+
function readDep(dep) {
|
|
154
|
+
return isCell(dep) ? get(dep) : dep;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Keep a rendered markup node in sync with the tracked values it was built
|
|
158
|
+
* from, without re-invoking the component at mount.
|
|
159
|
+
*
|
|
160
|
+
* A `primitive()` or `leaf()` written as a template string is called once and
|
|
161
|
+
* its result is converted to DOM once. Tracked values it READ (through the
|
|
162
|
+
* `reactiveProps` proxy) therefore subscribe nobody: a later write updated the
|
|
163
|
+
* cell and left the markup stale, so a leaf driven by a parent's counter never
|
|
164
|
+
* moved. Compiled components avoid this because their bindings re-run; string
|
|
165
|
+
* components have no bindings, so the runtime re-runs the call and swaps the
|
|
166
|
+
* produced nodes in place.
|
|
167
|
+
*
|
|
168
|
+
* The dep list is read by the effect purely to SUBSCRIBE. The first effect run
|
|
169
|
+
* therefore performs no re-render — it compares against the values captured at
|
|
170
|
+
* mount, which also covers a write that lands between mount and the first
|
|
171
|
+
* flush. Re-rendering is skipped when the node has been detached (its owner was
|
|
172
|
+
* torn down), so a stale effect can never graft nodes back into the document.
|
|
173
|
+
*
|
|
174
|
+
* @param node - The node (or fragment) the mount already inserted.
|
|
175
|
+
* @param deps - Tracked cells / values the markup was derived from.
|
|
176
|
+
* @param call - Re-invokes the component and returns fresh markup.
|
|
177
|
+
* @returns `node`, so the call can wrap the mount expression in place.
|
|
178
|
+
*/
|
|
179
|
+
export function rerenderNode(node, deps, call) {
|
|
180
|
+
if (typeof document === 'undefined')
|
|
181
|
+
return node;
|
|
182
|
+
if (deps.length === 0)
|
|
183
|
+
return node;
|
|
184
|
+
// The markup this call site owns. A component that rendered several roots
|
|
185
|
+
// hands them over as a list: the call site drains the fragment into the
|
|
186
|
+
// mount point, so by the time this runs the fragment itself is detached and
|
|
187
|
+
// useless as a handle. The list is followed as one range, which lets a
|
|
188
|
+
// later render add, drop or reorder roots.
|
|
189
|
+
let owned = null;
|
|
190
|
+
let current = null;
|
|
191
|
+
if (Array.isArray(node)) {
|
|
192
|
+
const roots = node.filter((n) => n && typeof n.nodeType === 'number');
|
|
193
|
+
owned = roots.length ? roots : null;
|
|
194
|
+
current = owned ? owned[0] : null;
|
|
195
|
+
}
|
|
196
|
+
else if (node && typeof node.nodeType === 'number') {
|
|
197
|
+
current = node;
|
|
198
|
+
}
|
|
199
|
+
if (!current)
|
|
200
|
+
return node;
|
|
201
|
+
const liveRange = () => {
|
|
202
|
+
if (owned)
|
|
203
|
+
return owned;
|
|
204
|
+
return current && current.parentNode ? [current] : null;
|
|
205
|
+
};
|
|
206
|
+
let seen = deps.map(readDep);
|
|
207
|
+
effect(() => {
|
|
208
|
+
const now = deps.map(readDep);
|
|
209
|
+
if (now.length === seen.length && now.every((v, i) => Object.is(v, seen[i])))
|
|
210
|
+
return;
|
|
211
|
+
seen = now;
|
|
212
|
+
// Detachment is checked BEFORE re-invoking: once the owner is gone the
|
|
213
|
+
// component must not run again (side effects, fetches) and its markup
|
|
214
|
+
// must never be grafted back into the document.
|
|
215
|
+
const old = liveRange();
|
|
216
|
+
if (!old || !old[0].parentNode)
|
|
217
|
+
return;
|
|
218
|
+
const next = toDomNode(call());
|
|
219
|
+
if (!next || typeof next.nodeType !== 'number')
|
|
220
|
+
return;
|
|
221
|
+
// Snapshot the children before inserting: moving them out empties the
|
|
222
|
+
// fragment, which is what tells us whether this render had several roots.
|
|
223
|
+
const fresh = next.nodeType === 11 ? Array.from(next.childNodes) : [next];
|
|
224
|
+
const parent = old[0].parentNode;
|
|
225
|
+
for (const freshNode of fresh)
|
|
226
|
+
parent.insertBefore(freshNode, old[0]);
|
|
227
|
+
for (const oldNode of old)
|
|
228
|
+
if (oldNode.parentNode)
|
|
229
|
+
oldNode.parentNode.removeChild(oldNode);
|
|
230
|
+
owned = next.nodeType === 11 ? fresh : null;
|
|
231
|
+
current = fresh[0] ?? current;
|
|
232
|
+
});
|
|
233
|
+
return node;
|
|
234
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/runtime",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.43",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk runtime — reactivity, blocks, DOM operations, hydration",
|
|
6
6
|
"main": "./dist/index-client.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vesk/compiler": "^0.2.
|
|
54
|
+
"@vesk/compiler": "^0.2.43"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"typecheck": "tsc --noEmit",
|