@shadow-js/web 1.0.0 → 1.0.2
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/CHANGELOG.md +29 -0
- package/dist/dev/attributes.d.ts +10 -5
- package/dist/dev/attributes.js +28 -51
- package/dist/dev/attributes.js.map +1 -1
- package/dist/dev/autofocus.d.ts +0 -2
- package/dist/dev/autofocus.js +1 -2
- package/dist/dev/class-style.d.ts +6 -4
- package/dist/dev/class-style.js +25 -9
- package/dist/dev/class-style.js.map +1 -1
- package/dist/dev/component.d.ts +0 -2
- package/dist/dev/component.js +1 -2
- package/dist/dev/control-flow/activity.d.ts +0 -2
- package/dist/dev/control-flow/activity.js +1 -2
- package/dist/dev/control-flow/branch.js +0 -1
- package/dist/dev/control-flow/client-only.d.ts +0 -2
- package/dist/dev/control-flow/client-only.js +1 -2
- package/dist/dev/control-flow/dynamic.d.ts +11 -4
- package/dist/dev/control-flow/dynamic.js +57 -41
- package/dist/dev/control-flow/dynamic.js.map +1 -1
- package/dist/dev/control-flow/error-boundary.d.ts +0 -2
- package/dist/dev/control-flow/error-boundary.js +1 -2
- package/dist/dev/control-flow/for.d.ts +0 -2
- package/dist/dev/control-flow/for.js +1 -2
- package/dist/dev/control-flow/fragment.d.ts +0 -2
- package/dist/dev/control-flow/fragment.js +1 -2
- package/dist/dev/control-flow/hot-link.js +1 -2
- package/dist/dev/control-flow/index-list.d.ts +0 -2
- package/dist/dev/control-flow/index-list.js +1 -2
- package/dist/dev/control-flow/lazy.d.ts +0 -2
- package/dist/dev/control-flow/lazy.js +1 -2
- package/dist/dev/control-flow/no-hydration.d.ts +0 -2
- package/dist/dev/control-flow/no-hydration.js +1 -2
- package/dist/dev/control-flow/portal.d.ts +0 -2
- package/dist/dev/control-flow/portal.js +3 -2
- package/dist/dev/control-flow/portal.js.map +1 -1
- package/dist/dev/control-flow/root-errors.d.ts +0 -2
- package/dist/dev/control-flow/root-errors.js +1 -2
- package/dist/dev/control-flow/show.d.ts +0 -2
- package/dist/dev/control-flow/show.js +1 -2
- package/dist/dev/control-flow/suspense-list.d.ts +0 -2
- package/dist/dev/control-flow/suspense-list.js +1 -2
- package/dist/dev/control-flow/suspense.d.ts +0 -2
- package/dist/dev/control-flow/suspense.js +1 -2
- package/dist/dev/control-flow/switch.d.ts +0 -2
- package/dist/dev/control-flow/switch.js +1 -2
- package/dist/dev/derived.d.ts +0 -2
- package/dist/dev/derived.js +1 -2
- package/dist/dev/element.d.ts +0 -2
- package/dist/dev/element.js +2 -3
- package/dist/dev/element.js.map +1 -1
- package/dist/dev/events.d.ts +0 -2
- package/dist/dev/events.js +16 -46
- package/dist/dev/events.js.map +1 -1
- package/dist/dev/head/components.d.ts +0 -2
- package/dist/dev/head/components.js +1 -2
- package/dist/dev/head/registry.js +1 -2
- package/dist/dev/head/server-head.d.ts +0 -2
- package/dist/dev/head/server-head.js +1 -2
- package/dist/dev/head/sink.js +1 -2
- package/dist/dev/head/use-head.d.ts +0 -2
- package/dist/dev/head/use-head.js +1 -2
- package/dist/dev/head/validate.d.ts +0 -2
- package/dist/dev/head/validate.js +1 -2
- package/dist/dev/hmr.d.ts +0 -2
- package/dist/dev/hmr.js +1 -2
- package/dist/dev/hydration.d.ts +0 -2
- package/dist/dev/hydration.js +1 -2
- package/dist/dev/insert.d.ts +15 -7
- package/dist/dev/insert.js +36 -15
- package/dist/dev/insert.js.map +1 -1
- package/dist/dev/internal/claim.d.ts +2 -3
- package/dist/dev/internal/claim.js +19 -4
- package/dist/dev/internal/claim.js.map +1 -1
- package/dist/dev/internal/css-units.js +1 -2
- package/dist/dev/internal/diagnostics.d.ts +7 -5
- package/dist/dev/internal/diagnostics.js +15 -6
- package/dist/dev/internal/diagnostics.js.map +1 -1
- package/dist/dev/internal/early-events.js +21 -4
- package/dist/dev/internal/early-events.js.map +1 -1
- package/dist/dev/internal/hydration-hooks.d.ts +0 -2
- package/dist/dev/internal/hydration-hooks.js +0 -1
- package/dist/dev/internal/hydration-scope.d.ts +0 -2
- package/dist/dev/internal/hydration-scope.js +1 -2
- package/dist/dev/internal/names.d.ts +0 -2
- package/dist/dev/internal/names.js +1 -2
- package/dist/dev/internal/portal-context.d.ts +0 -2
- package/dist/dev/internal/portal-context.js +1 -2
- package/dist/dev/internal/react-names.js +26 -63
- package/dist/dev/internal/react-names.js.map +1 -1
- package/dist/dev/internal/reconcile.d.ts +0 -2
- package/dist/dev/internal/reconcile.js +4 -8
- package/dist/dev/internal/reconcile.js.map +1 -1
- package/dist/dev/internal/stream-context.d.ts +0 -2
- package/dist/dev/internal/stream-context.js +1 -2
- package/dist/dev/jsx/aria.d.ts +0 -2
- package/dist/dev/jsx/component.d.ts +0 -2
- package/dist/dev/jsx/events.d.ts +0 -2
- package/dist/dev/jsx/global.d.ts +5 -4
- package/dist/dev/jsx/html.d.ts +1 -2
- package/dist/dev/jsx/intrinsic.d.ts +0 -2
- package/dist/dev/jsx/mathml.d.ts +0 -2
- package/dist/dev/jsx/svg.d.ts +0 -2
- package/dist/dev/jsx/types.d.ts +0 -2
- package/dist/dev/jsx-runtime.d.ts +0 -2
- package/dist/dev/reactive.d.ts +0 -2
- package/dist/dev/reactive.js +1 -2
- package/dist/dev/render.d.ts +0 -2
- package/dist/dev/render.js +1 -2
- package/dist/dev/resource-hints.d.ts +0 -2
- package/dist/dev/resource-hints.js +5 -4
- package/dist/dev/resource-hints.js.map +1 -1
- package/dist/dev/select-value.d.ts +0 -2
- package/dist/dev/select-value.js +6 -17
- package/dist/dev/select-value.js.map +1 -1
- package/dist/dev/server/attributes.d.ts +3 -2
- package/dist/dev/server/attributes.js +6 -3
- package/dist/dev/server/attributes.js.map +1 -1
- package/dist/dev/server/class-style.d.ts +0 -2
- package/dist/dev/server/class-style.js +1 -2
- package/dist/dev/server/component.d.ts +0 -2
- package/dist/dev/server/component.js +1 -2
- package/dist/dev/server/derived.d.ts +0 -2
- package/dist/dev/server/derived.js +1 -2
- package/dist/dev/server/element.d.ts +0 -2
- package/dist/dev/server/element.js +9 -6
- package/dist/dev/server/element.js.map +1 -1
- package/dist/dev/server/errors.js +8 -3
- package/dist/dev/server/errors.js.map +1 -1
- package/dist/dev/server/escape.d.ts +0 -2
- package/dist/dev/server/escape.js +15 -8
- package/dist/dev/server/escape.js.map +1 -1
- package/dist/dev/server/form-controls.d.ts +0 -2
- package/dist/dev/server/form-controls.js +6 -4
- package/dist/dev/server/form-controls.js.map +1 -1
- package/dist/dev/server/hydration-script.d.ts +0 -2
- package/dist/dev/server/hydration-script.js +1 -2
- package/dist/dev/server/index.d.ts +2 -1
- package/dist/dev/server/index.js +2 -1
- package/dist/dev/server/node.d.ts +0 -2
- package/dist/dev/server/node.js +1 -2
- package/dist/dev/server/portals.d.ts +0 -2
- package/dist/dev/server/portals.js +0 -1
- package/dist/dev/server/raw-text.d.ts +28 -0
- package/dist/dev/server/raw-text.js +66 -0
- package/dist/dev/server/raw-text.js.map +1 -0
- package/dist/dev/server/render.d.ts +2 -3
- package/dist/dev/server/render.js +3 -4
- package/dist/dev/server/render.js.map +1 -1
- package/dist/dev/server/serialize.d.ts +0 -2
- package/dist/dev/server/serialize.js +1 -2
- package/dist/dev/server/stream.d.ts +1 -3
- package/dist/dev/server/stream.js +3 -4
- package/dist/dev/server/stream.js.map +1 -1
- package/dist/dev/server.d.ts +2 -1
- package/dist/dev/server.js +2 -1
- package/dist/dev/spread.d.ts +0 -2
- package/dist/dev/spread.js +8 -56
- package/dist/dev/spread.js.map +1 -1
- package/dist/dev/template.d.ts +0 -2
- package/dist/dev/template.js +1 -2
- package/dist/dev/view-transition.d.ts +0 -2
- package/dist/dev/view-transition.js +1 -2
- package/dist/prod/attributes.js +1 -1
- package/dist/prod/attributes.js.map +1 -1
- package/dist/prod/class-style.js +1 -1
- package/dist/prod/class-style.js.map +1 -1
- package/dist/prod/control-flow/dynamic.js +1 -1
- package/dist/prod/control-flow/dynamic.js.map +1 -1
- package/dist/prod/control-flow/portal.js +1 -1
- package/dist/prod/control-flow/portal.js.map +1 -1
- package/dist/prod/element.js +1 -1
- package/dist/prod/element.js.map +1 -1
- package/dist/prod/events.js +1 -1
- package/dist/prod/events.js.map +1 -1
- package/dist/prod/insert.js +1 -1
- package/dist/prod/insert.js.map +1 -1
- package/dist/prod/internal/claim.js +1 -1
- package/dist/prod/internal/claim.js.map +1 -1
- package/dist/prod/internal/diagnostics.js +1 -1
- package/dist/prod/internal/diagnostics.js.map +1 -1
- package/dist/prod/internal/early-events.js +1 -1
- package/dist/prod/internal/early-events.js.map +1 -1
- package/dist/prod/internal/react-names.js +1 -1
- package/dist/prod/internal/react-names.js.map +1 -1
- package/dist/prod/internal/reconcile.js +1 -1
- package/dist/prod/internal/reconcile.js.map +1 -1
- package/dist/prod/resource-hints.js +1 -1
- package/dist/prod/resource-hints.js.map +1 -1
- package/dist/prod/select-value.js +1 -1
- package/dist/prod/select-value.js.map +1 -1
- package/dist/prod/server/attributes.js +1 -1
- package/dist/prod/server/attributes.js.map +1 -1
- package/dist/prod/server/element.js +1 -1
- package/dist/prod/server/element.js.map +1 -1
- package/dist/prod/server/errors.js +1 -1
- package/dist/prod/server/errors.js.map +1 -1
- package/dist/prod/server/escape.js +1 -1
- package/dist/prod/server/escape.js.map +1 -1
- package/dist/prod/server/form-controls.js +2 -2
- package/dist/prod/server/form-controls.js.map +1 -1
- package/dist/prod/server/index.js +1 -1
- package/dist/prod/server/raw-text.js +2 -0
- package/dist/prod/server/raw-text.js.map +1 -0
- package/dist/prod/server/render.js +1 -1
- package/dist/prod/server/render.js.map +1 -1
- package/dist/prod/server/stream.js +1 -1
- package/dist/prod/server/stream.js.map +1 -1
- package/dist/prod/server.js +1 -1
- package/dist/prod/spread.js +1 -1
- package/dist/prod/spread.js.map +1 -1
- package/dist/server/attributes.js +1 -1
- package/dist/server/attributes.js.map +1 -1
- package/dist/server/class-style.js +1 -1
- package/dist/server/class-style.js.map +1 -1
- package/dist/server/control-flow/dynamic.js +1 -1
- package/dist/server/control-flow/dynamic.js.map +1 -1
- package/dist/server/control-flow/portal.js +1 -1
- package/dist/server/control-flow/portal.js.map +1 -1
- package/dist/server/element.js +1 -1
- package/dist/server/element.js.map +1 -1
- package/dist/server/events.js +1 -1
- package/dist/server/events.js.map +1 -1
- package/dist/server/insert.js +1 -1
- package/dist/server/insert.js.map +1 -1
- package/dist/server/internal/claim.js +1 -1
- package/dist/server/internal/claim.js.map +1 -1
- package/dist/server/internal/diagnostics.js +1 -1
- package/dist/server/internal/diagnostics.js.map +1 -1
- package/dist/server/internal/early-events.js +1 -1
- package/dist/server/internal/early-events.js.map +1 -1
- package/dist/server/internal/react-names.js +1 -1
- package/dist/server/internal/react-names.js.map +1 -1
- package/dist/server/internal/reconcile.js +1 -1
- package/dist/server/internal/reconcile.js.map +1 -1
- package/dist/server/resource-hints.js +1 -1
- package/dist/server/resource-hints.js.map +1 -1
- package/dist/server/select-value.js +1 -1
- package/dist/server/select-value.js.map +1 -1
- package/dist/server/server/attributes.js +1 -1
- package/dist/server/server/attributes.js.map +1 -1
- package/dist/server/server/element.js +1 -1
- package/dist/server/server/element.js.map +1 -1
- package/dist/server/server/errors.js +1 -1
- package/dist/server/server/errors.js.map +1 -1
- package/dist/server/server/escape.js +1 -1
- package/dist/server/server/escape.js.map +1 -1
- package/dist/server/server/form-controls.js +2 -2
- package/dist/server/server/form-controls.js.map +1 -1
- package/dist/server/server/index.js +1 -1
- package/dist/server/server/raw-text.js +2 -0
- package/dist/server/server/raw-text.js.map +1 -0
- package/dist/server/server/render.js +1 -1
- package/dist/server/server/render.js.map +1 -1
- package/dist/server/server/stream.js +1 -1
- package/dist/server/server/stream.js.map +1 -1
- package/dist/server/server.js +1 -1
- package/dist/server/spread.js +1 -1
- package/dist/server/spread.js.map +1 -1
- package/dist/server-dev/attributes.js +28 -51
- package/dist/server-dev/attributes.js.map +1 -1
- package/dist/server-dev/autofocus.js +1 -2
- package/dist/server-dev/class-style.js +25 -9
- package/dist/server-dev/class-style.js.map +1 -1
- package/dist/server-dev/component.js +1 -2
- package/dist/server-dev/control-flow/activity.js +1 -2
- package/dist/server-dev/control-flow/branch.js +0 -1
- package/dist/server-dev/control-flow/client-only.js +1 -2
- package/dist/server-dev/control-flow/dynamic.js +23 -12
- package/dist/server-dev/control-flow/dynamic.js.map +1 -1
- package/dist/server-dev/control-flow/error-boundary.js +1 -2
- package/dist/server-dev/control-flow/for.js +1 -2
- package/dist/server-dev/control-flow/fragment.js +1 -2
- package/dist/server-dev/control-flow/hot-link.js +1 -2
- package/dist/server-dev/control-flow/index-list.js +1 -2
- package/dist/server-dev/control-flow/lazy.js +1 -2
- package/dist/server-dev/control-flow/no-hydration.js +1 -2
- package/dist/server-dev/control-flow/portal.js +3 -2
- package/dist/server-dev/control-flow/portal.js.map +1 -1
- package/dist/server-dev/control-flow/root-errors.js +1 -2
- package/dist/server-dev/control-flow/show.js +1 -2
- package/dist/server-dev/control-flow/suspense-list.js +1 -2
- package/dist/server-dev/control-flow/suspense.js +1 -2
- package/dist/server-dev/control-flow/switch.js +1 -2
- package/dist/server-dev/derived.js +1 -2
- package/dist/server-dev/element.js +4 -3
- package/dist/server-dev/element.js.map +1 -1
- package/dist/server-dev/events.js +16 -46
- package/dist/server-dev/events.js.map +1 -1
- package/dist/server-dev/head/components.js +1 -2
- package/dist/server-dev/head/registry.js +1 -2
- package/dist/server-dev/head/server-head.js +1 -2
- package/dist/server-dev/head/sink.js +1 -2
- package/dist/server-dev/head/use-head.js +1 -2
- package/dist/server-dev/head/validate.js +1 -2
- package/dist/server-dev/hydration.js +1 -2
- package/dist/server-dev/insert.js +36 -15
- package/dist/server-dev/insert.js.map +1 -1
- package/dist/server-dev/internal/claim.js +19 -4
- package/dist/server-dev/internal/claim.js.map +1 -1
- package/dist/server-dev/internal/css-units.js +1 -2
- package/dist/server-dev/internal/diagnostics.js +15 -6
- package/dist/server-dev/internal/diagnostics.js.map +1 -1
- package/dist/server-dev/internal/early-events.js +21 -4
- package/dist/server-dev/internal/early-events.js.map +1 -1
- package/dist/server-dev/internal/hydration-hooks.js +0 -1
- package/dist/server-dev/internal/hydration-scope.js +1 -2
- package/dist/server-dev/internal/names.js +1 -2
- package/dist/server-dev/internal/portal-context.js +1 -2
- package/dist/server-dev/internal/react-names.js +26 -63
- package/dist/server-dev/internal/react-names.js.map +1 -1
- package/dist/server-dev/internal/reconcile.js +4 -8
- package/dist/server-dev/internal/reconcile.js.map +1 -1
- package/dist/server-dev/internal/stream-context.js +1 -2
- package/dist/server-dev/reactive.js +1 -2
- package/dist/server-dev/render.js +1 -2
- package/dist/server-dev/resource-hints.js +5 -4
- package/dist/server-dev/resource-hints.js.map +1 -1
- package/dist/server-dev/select-value.js +6 -17
- package/dist/server-dev/select-value.js.map +1 -1
- package/dist/server-dev/server/attributes.js +6 -3
- package/dist/server-dev/server/attributes.js.map +1 -1
- package/dist/server-dev/server/class-style.js +1 -2
- package/dist/server-dev/server/component.js +1 -2
- package/dist/server-dev/server/derived.js +1 -2
- package/dist/server-dev/server/element.js +9 -6
- package/dist/server-dev/server/element.js.map +1 -1
- package/dist/server-dev/server/errors.js +8 -3
- package/dist/server-dev/server/errors.js.map +1 -1
- package/dist/server-dev/server/escape.js +15 -8
- package/dist/server-dev/server/escape.js.map +1 -1
- package/dist/server-dev/server/form-controls.js +6 -4
- package/dist/server-dev/server/form-controls.js.map +1 -1
- package/dist/server-dev/server/hydration-script.js +1 -2
- package/dist/server-dev/server/index.js +2 -1
- package/dist/server-dev/server/node.js +1 -2
- package/dist/server-dev/server/portals.js +0 -1
- package/dist/server-dev/server/raw-text.js +86 -0
- package/dist/server-dev/server/raw-text.js.map +1 -0
- package/dist/server-dev/server/render.js +3 -4
- package/dist/server-dev/server/render.js.map +1 -1
- package/dist/server-dev/server/serialize.js +1 -2
- package/dist/server-dev/server/stream.js +3 -4
- package/dist/server-dev/server/stream.js.map +1 -1
- package/dist/server-dev/server.js +2 -1
- package/dist/server-dev/spread.js +8 -56
- package/dist/server-dev/spread.js.map +1 -1
- package/dist/server-dev/template.js +1 -2
- package/dist/server-dev/view-transition.js +1 -2
- package/package.json +3 -2
|
@@ -1,53 +1,61 @@
|
|
|
1
|
-
import "../internal/
|
|
1
|
+
import { warnOnce } from "../internal/diagnostics.js";
|
|
2
|
+
import { MATHML_NS, SVG_NS } from "../internal/names.js";
|
|
2
3
|
import { nextKey } from "../internal/hydration-scope.js";
|
|
3
4
|
import { createComponent } from "../component.js";
|
|
4
5
|
import { claims } from "../internal/hydration-hooks.js";
|
|
5
6
|
import { bindRegion, createRegion } from "../insert.js";
|
|
6
7
|
import { spread } from "../spread.js";
|
|
7
8
|
import { mergeProps, splitProps, untrack, useMemo } from "@shadow-js/core";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
9
|
+
// src/control-flow/dynamic.ts
|
|
10
|
+
/**
|
|
11
|
+
* The SVG element names (lowercase) HTML does not define: the names a tag takes the SVG namespace for. A pattern
|
|
12
|
+
* rather than a question to the platform because it answers the same in every DOM (browsers, happy-dom, jsdom,
|
|
13
|
+
* which has no interface per SVG element) and never parses HTML, so a page that enforces Trusted Types is never
|
|
14
|
+
* asked for a sink. `fe[bcdfgimopst]...` is every filter primitive (`feBlend` to `feTurbulence`).
|
|
15
|
+
*/
|
|
16
|
+
const SVG_PATTERN = /^(svg|g|path|circle|ellipse|line|poly(gon|line)|rect|text(path)?|tspan|defs|desc|discard|metadata|use|symbol|marker|switch|view|set|mpath|image|stop|mask|pattern|clippath|filter|foreignobject|animate(motion|transform)?|(linear|radial)gradient|fe[bcdfgimopst][a-z]{3,})$/;
|
|
17
|
+
/** The MathML element names (the HTML spec's list), matched in lowercase. None of them is an HTML element. */
|
|
18
|
+
const MATHML_TAGS = /^(m(ath|[ion]|s(ub(sup)?|up|qrt|pace|tyle)?|t(ext|able|[rd])|row|frac|root|error|padded|phantom|enclose|under(over)?|over|(multi|pre)scripts|labeledtr|action)|none|semantics|annotation(-xml)?)$/;
|
|
19
|
+
/**
|
|
20
|
+
* Shape of a tag name: a letter, then letters, digits or dashes. Anything else is refused, and so is `script` in
|
|
21
|
+
* any letter case: it would bypass CSP nonces and Trusted Types.
|
|
22
|
+
*/
|
|
23
|
+
const TAG_PATTERN = /^(?!script$)[a-z][a-z0-9-]*$/i;
|
|
24
|
+
/**
|
|
25
|
+
* Warns (development only) about an SVG element name written in a case SVG does not spell it in: the namespace
|
|
26
|
+
* is case-sensitive, so a `clippath` element is not the `clipPath` that `clip-path="url(#...)"`, CSS and
|
|
27
|
+
* `querySelector` mean. Warns once per name. The table of canonical names exists only behind `__DEV__`.
|
|
28
|
+
*/
|
|
29
|
+
function warnSvgCase(tag, lower) {
|
|
30
|
+
const canonical = "animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence foreignObject linearGradient radialGradient textPath".split(" ").find((name) => name.toLowerCase() === lower);
|
|
31
|
+
if (canonical === void 0 || canonical === tag) return;
|
|
32
|
+
warnOnce("DYNAMIC_SVG_CASE", `Dynamic created the SVG element "${tag}" with the name as written, but SVG spells it "${canonical}": the name is case-sensitive, so "${tag}" is not the element SVG defines. Write "${canonical}".`, lower);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates the element of a validated tag name in its namespace. MathML names are exact (none of them is an
|
|
36
|
+
* HTML element). For the rest the platform answers first: a name HTML knows (`div`, `a`, `style`, `title`, a
|
|
37
|
+
* custom element) is an HTML element, which is all the common tags cost; only a name HTML does not know is
|
|
38
|
+
* matched against the SVG names, and it keeps the spelling the caller wrote.
|
|
39
|
+
*/
|
|
40
|
+
function createTagged(tag) {
|
|
41
|
+
const lower = tag.toLowerCase();
|
|
42
|
+
if (MATHML_TAGS.test(lower)) return document.createElementNS(MATHML_NS, lower);
|
|
43
|
+
const el = document.createElement(tag);
|
|
44
|
+
if (el.constructor !== HTMLUnknownElement && lower !== "image" || !SVG_PATTERN.test(lower)) return el;
|
|
45
|
+
warnSvgCase(tag, lower);
|
|
46
|
+
return document.createElementNS(SVG_NS, tag);
|
|
47
|
+
}
|
|
39
48
|
/**
|
|
40
49
|
* Creates an element for a validated tag name and applies the props to it, children included.
|
|
41
|
-
* The namespace comes from the tag: SVG-only names get the SVG namespace,
|
|
50
|
+
* The namespace comes from the tag: SVG-only names get the SVG namespace (named as written), MathML names the
|
|
51
|
+
* MathML namespace, the rest are HTML.
|
|
42
52
|
* On the server it renders the element as markup (with the hydration key and the children region
|
|
43
53
|
* the client adopts); while hydrating it claims that element instead of creating one.
|
|
44
54
|
*/
|
|
45
55
|
function buildElement(tag, props) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const el = claims.current.claimElement(nextKey()) ?? (svg ? document.createElementNS("http://www.w3.org/2000/svg", tag) : document.createElement(tag));
|
|
50
|
-
spread(el, props, svg, true);
|
|
56
|
+
if (!TAG_PATTERN.test(tag)) throw new TypeError("ShadowJS Dynamic: invalid tag");
|
|
57
|
+
const el = claims.current.claimElement(nextKey()) ?? createTagged(tag);
|
|
58
|
+
spread(el, props, el.namespaceURI === SVG_NS, true);
|
|
51
59
|
const region = createRegion(el, null, claims.current.takeRegion(el, null));
|
|
52
60
|
bindRegion(region, () => props.children);
|
|
53
61
|
return el;
|
|
@@ -70,8 +78,17 @@ function buildTarget(target, props) {
|
|
|
70
78
|
* `component` renders nothing.
|
|
71
79
|
*
|
|
72
80
|
* Tag names are checked against `^[a-z][a-z0-9-]*$` (case-insensitive) and `script` is refused, so
|
|
73
|
-
* data-driven tags cannot inject markup.
|
|
74
|
-
* in
|
|
81
|
+
* data-driven tags cannot inject markup. The browser decides the namespace: a name HTML knows (`div`,
|
|
82
|
+
* `a`, `style`, `title`, a custom element) is an HTML element, in any letter case. A name HTML does not
|
|
83
|
+
* know and that SVG defines (`circle`, `path`, `svg`, `image`, `foreignObject`, `clipPath`, the `fe*` filter
|
|
84
|
+
* primitives, the gradients and animation elements, ...) is created in the SVG namespace, matched against a
|
|
85
|
+
* name pattern (no HTML is parsed, so Trusted Types is never involved); any other name stays an HTML element.
|
|
86
|
+
* The element keeps the name exactly as written: `Dynamic` does not derive the canonical case, which SVG
|
|
87
|
+
* needs (`clipPath`, `linearGradient`, `feGaussianBlur`, `foreignObject`, ...), so write those names as SVG
|
|
88
|
+
* spells them. Development builds warn once per name with `DYNAMIC_SVG_CASE` when they are not.
|
|
89
|
+
* MathML names (`math`, `mi`, `mfrac`, `semantics`, `annotation-xml`, ...) are created in the MathML
|
|
90
|
+
* namespace, in lowercase. `title`, `style` and `a` stay HTML elements: `Dynamic` does not know the parent
|
|
91
|
+
* the element will be inserted into.
|
|
75
92
|
*
|
|
76
93
|
* @param props `component` and the props of what it renders.
|
|
77
94
|
* @returns An accessor of the rendered output, to be inserted by the caller.
|
|
@@ -128,7 +145,6 @@ function createDynamic(component, props = {}) {
|
|
|
128
145
|
return component();
|
|
129
146
|
} }, props));
|
|
130
147
|
}
|
|
131
|
-
//#endregion
|
|
132
148
|
export { Dynamic, createDynamic };
|
|
133
149
|
|
|
134
150
|
//# sourceMappingURL=dynamic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic.js","names":[],"sources":["../../../src/control-flow/dynamic.ts"],"sourcesContent":["import { mergeProps, splitProps, untrack, useMemo } from \"@shadow-js/core\";\nimport { createComponent } from \"../component\";\nimport { bindRegion, claims, createRegion, nextKey, SVG_NS } from \"../extend\";\nimport { ssrElement, ssrRaw } from \"../server/element\";\nimport { spread } from \"../spread\";\n\n/**\n * A component function or a tag name, as {@link Dynamic} accepts it. The props of a function are\n * checked by the caller.\n * @since 1.0.0\n */\nexport type DynamicComponent = string | ((props: never) => unknown);\n\n/**\n * Everything `component` may be: a component, a tag name, or `undefined`, `null` or `false`, which\n * render nothing.\n * @since 1.0.0\n */\nexport type DynamicTarget = DynamicComponent | undefined | null | false;\n\n/**\n * Props of {@link Dynamic}: `component` plus the props of whatever it renders. Every other prop\n * passes through, reactive getters included.\n * @since 1.0.0\n */\nexport interface DynamicProps<C extends DynamicTarget = DynamicTarget> {\n /** The component to render, a tag name, or a falsy value for nothing. */\n readonly component: C;\n /** Any other prop is passed to the rendered component or set on the element, still reactive. */\n readonly [prop: string]: unknown;\n}\n\n/** Tag names that take the SVG namespace. Anything else is HTML. */\nconst SVG_TAGS: ReadonlySet<string> = new Set([\n \"svg\",\n \"g\",\n \"path\",\n \"circle\",\n \"ellipse\",\n \"line\",\n \"polygon\",\n \"polyline\",\n \"rect\",\n \"text\",\n \"tspan\",\n \"textpath\",\n \"defs\",\n \"use\",\n \"symbol\",\n \"marker\",\n \"clippath\",\n \"mask\",\n \"pattern\",\n \"lineargradient\",\n \"radialgradient\",\n \"stop\",\n \"filter\",\n]);\n\n/** Shape of a tag name: a letter, then letters, digits or dashes. Anything else is refused. */\nconst TAG_PATTERN = /^[a-z][a-z0-9-]*$/i;\n\n/** Tags refused in any letter case: a script would bypass CSP nonces and Trusted Types. */\nconst DENIED_TAGS: ReadonlySet<string> = new Set([\"script\"]);\n\n/**\n * Creates an element for a validated tag name and applies the props to it, children included.\n * The namespace comes from the tag: SVG-only names get the SVG namespace, the rest are HTML.\n * On the server it renders the element as markup (with the hydration key and the children region\n * the client adopts); while hydrating it claims that element instead of creating one.\n */\nfunction buildElement(tag: string, props: object): unknown {\n const lower = tag.toLowerCase();\n if (!TAG_PATTERN.test(tag) || DENIED_TAGS.has(lower)) {\n throw new TypeError(__DEV__ ? \"ShadowJS Dynamic: invalid tag\" : \"SHADOW_DYNAMIC_TAG\");\n }\n if (__SERVER__) {\n // The children are read lazily, after `ssrElement` took the element's hydration key: the client\n // claims the element first and builds its children second, so the keys must be drawn in that\n // order here too, or a component inside the element and every sibling after it would miss.\n return ssrElement(\n tag,\n props,\n () => {\n const { children } = props as { children?: unknown };\n return children === undefined\n ? undefined\n : [ssrRaw(\"<!--[-->\"), children, ssrRaw(\"<!--]-->\")];\n },\n true,\n );\n }\n const svg = SVG_TAGS.has(lower);\n const claimed = claims.current.claimElement(nextKey());\n const el = claimed ?? (svg ? document.createElementNS(SVG_NS, tag) : document.createElement(tag));\n // Attributes through spread; children through insert, which adopts the server's children region.\n spread(el, props, svg, true);\n const region = createRegion(el, null, claims.current.takeRegion(el, null));\n bindRegion(region, () => (props as { children?: unknown }).children);\n return el;\n}\n\n/**\n * Renders one value of `component`: nothing for a falsy value, an element for a tag name, the\n * component's result for a function. Anything else is a TypeError.\n */\nfunction buildTarget(target: unknown, props: object): unknown {\n if (!target) return null;\n if (typeof target === \"string\") return buildElement(target, props);\n if (typeof target === \"function\") {\n return createComponent(target as (props: object) => unknown, props);\n }\n throw new TypeError(\n __DEV__\n ? \"ShadowJS Dynamic: component must be a string, a function, or a falsy value.\"\n : \"SHADOW_DYNAMIC_COMPONENT\",\n );\n}\n\n/**\n * Renders a component function or an element chosen by a tag name, and re-renders when\n * `component` changes. Only `component` is tracked: the rest of the props are passed through\n * reactive, so changing them updates the rendered output without rebuilding it. Swapping\n * `component` disposes the old subtree, cleanups included, and builds the new one once. A falsy\n * `component` renders nothing.\n *\n * Tag names are checked against `^[a-z][a-z0-9-]*$` (case-insensitive) and `script` is refused, so\n * data-driven tags cannot inject markup. SVG-only names (`circle`, `path`, `svg`, ...) are created\n * in the SVG namespace.\n *\n * @param props `component` and the props of what it renders.\n * @returns An accessor of the rendered output, to be inserted by the caller.\n * @throws TypeError for an invalid tag name or a component that is neither a string nor a function\n * (at read time, which is when the caller inserts it).\n * @example\n * import { createRoot, useSignal } from \"@shadow-js/core\";\n * import { Dynamic, insert } from \"@shadow-js/web\";\n *\n * const parent = document.createElement(\"div\");\n * createRoot(() => {\n * const [level] = useSignal(1);\n * insert(\n * parent,\n * Dynamic({\n * get component() {\n * return level() === 1 ? \"h1\" : \"h2\";\n * },\n * children: \"Title\",\n * }),\n * );\n * });\n * @see createDynamic\n * @since 1.0.0\n */\nexport function Dynamic<C extends DynamicTarget>(props: DynamicProps<C>): () => unknown {\n const [, rest] = splitProps(props, [\"component\"]);\n // The component is built inside this memo, so its setup (or a ref, or a directive) may write signals.\n return useMemo(\n (): unknown => {\n const target: unknown = props.component;\n return untrack(() => buildTarget(target, rest));\n },\n { allowWrites: true },\n );\n}\n\n/**\n * Function form of {@link Dynamic}, for code that is not JSX: renders what `component()` returns (a\n * component, a tag name or a falsy value) with `props`, and follows it when it changes.\n *\n * @param component Accessor of the target.\n * @param props The props of what it renders (reactive getters stay reactive).\n * @returns An accessor of the rendered output.\n * @example\n * import { createRoot, useSignal } from \"@shadow-js/core\";\n * import { createDynamic, insert } from \"@shadow-js/web\";\n *\n * const parent = document.createElement(\"div\");\n * createRoot(() => {\n * const [level] = useSignal(1);\n * insert(parent, createDynamic(() => (level() === 1 ? \"h1\" : \"h2\"), { children: \"Title\" }));\n * });\n * @see Dynamic\n * @since 1.0.0\n */\nexport function createDynamic<C extends DynamicTarget>(\n component: () => C,\n props: object = {},\n): () => unknown {\n return Dynamic(\n mergeProps(\n {\n get component(): C {\n return component();\n },\n },\n props,\n ) as DynamicProps<C>,\n );\n}\n"],"mappings":";;;;;;;;;AAiCA,MAAM,2BAAgC,IAAI,IAAI;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,cAAc;;AAGpB,MAAM,8BAAmC,IAAI,IAAI,CAAC,QAAQ,CAAC;;;;;;;AAQ3D,SAAS,aAAa,KAAa,OAAwB;CACzD,MAAM,QAAQ,IAAI,YAAY;CAC9B,IAAI,CAAC,YAAY,KAAK,GAAG,KAAK,YAAY,IAAI,KAAK,GACjD,MAAM,IAAI,UAAoB,+BAAsD;CAkBtF,MAAM,MAAM,SAAS,IAAI,KAAK;CAE9B,MAAM,KADU,OAAO,QAAQ,aAAa,QAAQ,CACnC,MAAM,MAAM,SAAS,gBAAA,8BAAwB,GAAG,IAAI,SAAS,cAAc,GAAG;CAE/F,OAAO,IAAI,OAAO,KAAK,IAAI;CAC3B,MAAM,SAAS,aAAa,IAAI,MAAM,OAAO,QAAQ,WAAW,IAAI,IAAI,CAAC;CACzE,WAAW,cAAe,MAAiC,QAAQ;CACnE,OAAO;AACT;;;;;AAMA,SAAS,YAAY,QAAiB,OAAwB;CAC5D,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,OAAO,WAAW,UAAU,OAAO,aAAa,QAAQ,KAAK;CACjE,IAAI,OAAO,WAAW,YACpB,OAAO,gBAAgB,QAAsC,KAAK;CAEpE,MAAM,IAAI,UAEJ,6EAEN;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,QAAiC,OAAuC;CACtF,MAAM,GAAG,QAAQ,WAAW,OAAO,CAAC,WAAW,CAAC;CAEhD,OAAO,cACU;EACb,MAAM,SAAkB,MAAM;EAC9B,OAAO,cAAc,YAAY,QAAQ,IAAI,CAAC;CAChD,GACA,EAAE,aAAa,KAAK,CACtB;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,cACd,WACA,QAAgB,CAAC,GACF;CACf,OAAO,QACL,WACE,EACE,IAAI,YAAe;EACjB,OAAO,UAAU;CACnB,EACF,GACA,KACF,CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"dynamic.js","names":[],"sources":["../../../src/control-flow/dynamic.ts"],"sourcesContent":["import { mergeProps, splitProps, untrack, useMemo } from \"@shadow-js/core\";\nimport { createComponent } from \"../component\";\nimport { bindRegion, claims, createRegion, MATHML_NS, nextKey, SVG_NS, warnOnce } from \"../extend\";\nimport { ssrElement, ssrRaw } from \"../server/element\";\nimport { isTextOnlyElement } from \"../server/raw-text\";\nimport { spread } from \"../spread\";\n\n/**\n * A component function or a tag name, as {@link Dynamic} accepts it. The props of a function are\n * checked by the caller.\n * @since 1.0.0\n */\nexport type DynamicComponent = string | ((props: never) => unknown);\n\n/**\n * Everything `component` may be: a component, a tag name, or `undefined`, `null` or `false`, which\n * render nothing.\n * @since 1.0.0\n */\nexport type DynamicTarget = DynamicComponent | undefined | null | false;\n\n/**\n * Props of {@link Dynamic}: `component` plus the props of whatever it renders. Every other prop\n * passes through, reactive getters included.\n * @since 1.0.0\n */\nexport interface DynamicProps<C extends DynamicTarget = DynamicTarget> {\n /** The component to render, a tag name, or a falsy value for nothing. */\n readonly component: C;\n /** Any other prop is passed to the rendered component or set on the element, still reactive. */\n readonly [prop: string]: unknown;\n}\n\n/**\n * The SVG element names (lowercase) HTML does not define: the names a tag takes the SVG namespace for. A pattern\n * rather than a question to the platform because it answers the same in every DOM (browsers, happy-dom, jsdom,\n * which has no interface per SVG element) and never parses HTML, so a page that enforces Trusted Types is never\n * asked for a sink. `fe[bcdfgimopst]...` is every filter primitive (`feBlend` to `feTurbulence`).\n */\nconst SVG_PATTERN =\n /^(svg|g|path|circle|ellipse|line|poly(gon|line)|rect|text(path)?|tspan|defs|desc|discard|metadata|use|symbol|marker|switch|view|set|mpath|image|stop|mask|pattern|clippath|filter|foreignobject|animate(motion|transform)?|(linear|radial)gradient|fe[bcdfgimopst][a-z]{3,})$/;\n\n/** The MathML element names (the HTML spec's list), matched in lowercase. None of them is an HTML element. */\nconst MATHML_TAGS =\n /^(m(ath|[ion]|s(ub(sup)?|up|qrt|pace|tyle)?|t(ext|able|[rd])|row|frac|root|error|padded|phantom|enclose|under(over)?|over|(multi|pre)scripts|labeledtr|action)|none|semantics|annotation(-xml)?)$/;\n\n/**\n * Shape of a tag name: a letter, then letters, digits or dashes. Anything else is refused, and so is `script` in\n * any letter case: it would bypass CSP nonces and Trusted Types.\n */\nconst TAG_PATTERN = /^(?!script$)[a-z][a-z0-9-]*$/i;\n\n/**\n * Warns (development only) about an SVG element name written in a case SVG does not spell it in: the namespace\n * is case-sensitive, so a `clippath` element is not the `clipPath` that `clip-path=\"url(#...)\"`, CSS and\n * `querySelector` mean. Warns once per name. The table of canonical names exists only behind `__DEV__`.\n */\nfunction warnSvgCase(tag: string, lower: string): void {\n const canonical =\n \"animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence foreignObject linearGradient radialGradient textPath\"\n .split(\" \")\n .find((name) => name.toLowerCase() === lower);\n if (canonical === undefined || canonical === tag) return;\n warnOnce(\n \"DYNAMIC_SVG_CASE\",\n `Dynamic created the SVG element \"${tag}\" with the name as written, but SVG spells it \"${canonical}\": the name is case-sensitive, so \"${tag}\" is not the element SVG defines. Write \"${canonical}\".`,\n lower,\n );\n}\n\n/**\n * Creates the element of a validated tag name in its namespace. MathML names are exact (none of them is an\n * HTML element). For the rest the platform answers first: a name HTML knows (`div`, `a`, `style`, `title`, a\n * custom element) is an HTML element, which is all the common tags cost; only a name HTML does not know is\n * matched against the SVG names, and it keeps the spelling the caller wrote.\n */\nfunction createTagged(tag: string): Element {\n const lower = tag.toLowerCase();\n if (MATHML_TAGS.test(lower)) return document.createElementNS(MATHML_NS, lower);\n const el = document.createElement(tag);\n // Firefox makes `image` a plain HTMLElement, where Chromium and WebKit call it unknown: it is no HTML element\n // (the parser turns it into `img`), and SVG defines it, so it takes the SVG route in every engine.\n if ((el.constructor !== HTMLUnknownElement && lower !== \"image\") || !SVG_PATTERN.test(lower)) {\n return el;\n }\n if (__DEV__) warnSvgCase(tag, lower);\n return document.createElementNS(SVG_NS, tag);\n}\n\n/**\n * Creates an element for a validated tag name and applies the props to it, children included.\n * The namespace comes from the tag: SVG-only names get the SVG namespace (named as written), MathML names the\n * MathML namespace, the rest are HTML.\n * On the server it renders the element as markup (with the hydration key and the children region\n * the client adopts); while hydrating it claims that element instead of creating one.\n */\nfunction buildElement(tag: string, props: object): unknown {\n if (!TAG_PATTERN.test(tag)) {\n throw new TypeError(__DEV__ ? \"ShadowJS Dynamic: invalid tag\" : \"SHADOW_DYNAMIC_TAG\");\n }\n if (__SERVER__) {\n // The children are read lazily, after `ssrElement` took the element's hydration key: the client\n // claims the element first and builds its children second, so the keys must be drawn in that\n // order here too, or a component inside the element and every sibling after it would miss.\n return ssrElement(\n tag,\n props,\n () => {\n const { children } = props as { children?: unknown };\n // The content of a style or a title is text the parser reads whole: no markers can go in it.\n if (children === undefined || isTextOnlyElement(tag)) return children;\n return [ssrRaw(\"<!--[-->\"), children, ssrRaw(\"<!--]-->\")];\n },\n true,\n );\n }\n const el = claims.current.claimElement(nextKey()) ?? createTagged(tag);\n // Attributes through spread; children through insert, which adopts the server's children region.\n spread(el, props, el.namespaceURI === SVG_NS, true);\n const region = createRegion(el, null, claims.current.takeRegion(el, null));\n bindRegion(region, () => (props as { children?: unknown }).children);\n return el;\n}\n\n/**\n * Renders one value of `component`: nothing for a falsy value, an element for a tag name, the\n * component's result for a function. Anything else is a TypeError.\n */\nfunction buildTarget(target: unknown, props: object): unknown {\n if (!target) return null;\n if (typeof target === \"string\") return buildElement(target, props);\n if (typeof target === \"function\") {\n return createComponent(target as (props: object) => unknown, props);\n }\n throw new TypeError(\n __DEV__\n ? \"ShadowJS Dynamic: component must be a string, a function, or a falsy value.\"\n : \"SHADOW_DYNAMIC_COMPONENT\",\n );\n}\n\n/**\n * Renders a component function or an element chosen by a tag name, and re-renders when\n * `component` changes. Only `component` is tracked: the rest of the props are passed through\n * reactive, so changing them updates the rendered output without rebuilding it. Swapping\n * `component` disposes the old subtree, cleanups included, and builds the new one once. A falsy\n * `component` renders nothing.\n *\n * Tag names are checked against `^[a-z][a-z0-9-]*$` (case-insensitive) and `script` is refused, so\n * data-driven tags cannot inject markup. The browser decides the namespace: a name HTML knows (`div`,\n * `a`, `style`, `title`, a custom element) is an HTML element, in any letter case. A name HTML does not\n * know and that SVG defines (`circle`, `path`, `svg`, `image`, `foreignObject`, `clipPath`, the `fe*` filter\n * primitives, the gradients and animation elements, ...) is created in the SVG namespace, matched against a\n * name pattern (no HTML is parsed, so Trusted Types is never involved); any other name stays an HTML element.\n * The element keeps the name exactly as written: `Dynamic` does not derive the canonical case, which SVG\n * needs (`clipPath`, `linearGradient`, `feGaussianBlur`, `foreignObject`, ...), so write those names as SVG\n * spells them. Development builds warn once per name with `DYNAMIC_SVG_CASE` when they are not.\n * MathML names (`math`, `mi`, `mfrac`, `semantics`, `annotation-xml`, ...) are created in the MathML\n * namespace, in lowercase. `title`, `style` and `a` stay HTML elements: `Dynamic` does not know the parent\n * the element will be inserted into.\n *\n * @param props `component` and the props of what it renders.\n * @returns An accessor of the rendered output, to be inserted by the caller.\n * @throws TypeError for an invalid tag name or a component that is neither a string nor a function\n * (at read time, which is when the caller inserts it).\n * @example\n * import { createRoot, useSignal } from \"@shadow-js/core\";\n * import { Dynamic, insert } from \"@shadow-js/web\";\n *\n * const parent = document.createElement(\"div\");\n * createRoot(() => {\n * const [level] = useSignal(1);\n * insert(\n * parent,\n * Dynamic({\n * get component() {\n * return level() === 1 ? \"h1\" : \"h2\";\n * },\n * children: \"Title\",\n * }),\n * );\n * });\n * @see createDynamic\n * @since 1.0.0\n */\nexport function Dynamic<C extends DynamicTarget>(props: DynamicProps<C>): () => unknown {\n const [, rest] = splitProps(props, [\"component\"]);\n // The component is built inside this memo, so its setup (or a ref, or a directive) may write signals.\n return useMemo(\n (): unknown => {\n const target: unknown = props.component;\n return untrack(() => buildTarget(target, rest));\n },\n { allowWrites: true },\n );\n}\n\n/**\n * Function form of {@link Dynamic}, for code that is not JSX: renders what `component()` returns (a\n * component, a tag name or a falsy value) with `props`, and follows it when it changes.\n *\n * @param component Accessor of the target.\n * @param props The props of what it renders (reactive getters stay reactive).\n * @returns An accessor of the rendered output.\n * @example\n * import { createRoot, useSignal } from \"@shadow-js/core\";\n * import { createDynamic, insert } from \"@shadow-js/web\";\n *\n * const parent = document.createElement(\"div\");\n * createRoot(() => {\n * const [level] = useSignal(1);\n * insert(parent, createDynamic(() => (level() === 1 ? \"h1\" : \"h2\"), { children: \"Title\" }));\n * });\n * @see Dynamic\n * @since 1.0.0\n */\nexport function createDynamic<C extends DynamicTarget>(\n component: () => C,\n props: object = {},\n): () => unknown {\n return Dynamic(\n mergeProps(\n {\n get component(): C {\n return component();\n },\n },\n props,\n ) as DynamicProps<C>,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAM,cACJ;;AAGF,MAAM,cACJ;;;;;AAMF,MAAM,cAAc;;;;;;AAOpB,SAAS,YAAY,KAAa,OAAqB;CACrD,MAAM,YACJ,+YACG,MAAM,GAAG,CAAC,CACV,MAAM,SAAS,KAAK,YAAY,MAAM,KAAK;CAChD,IAAI,cAAc,KAAA,KAAa,cAAc,KAAK;CAClD,SACE,oBACA,oCAAoC,IAAI,iDAAiD,UAAU,qCAAqC,IAAI,2CAA2C,UAAU,KACjM,KACF;AACF;;;;;;;AAQA,SAAS,aAAa,KAAsB;CAC1C,MAAM,QAAQ,IAAI,YAAY;CAC9B,IAAI,YAAY,KAAK,KAAK,GAAG,OAAO,SAAS,gBAAgB,WAAW,KAAK;CAC7E,MAAM,KAAK,SAAS,cAAc,GAAG;CAGrC,IAAK,GAAG,gBAAgB,sBAAsB,UAAU,WAAY,CAAC,YAAY,KAAK,KAAK,GACzF,OAAO;CAEI,YAAY,KAAK,KAAK;CACnC,OAAO,SAAS,gBAAgB,QAAQ,GAAG;AAC7C;;;;;;;;AASA,SAAS,aAAa,KAAa,OAAwB;CACzD,IAAI,CAAC,YAAY,KAAK,GAAG,GACvB,MAAM,IAAI,UAAoB,+BAAsD;CAkBtF,MAAM,KAAK,OAAO,QAAQ,aAAa,QAAQ,CAAC,KAAK,aAAa,GAAG;CAErE,OAAO,IAAI,OAAO,GAAG,iBAAiB,QAAQ,IAAI;CAClD,MAAM,SAAS,aAAa,IAAI,MAAM,OAAO,QAAQ,WAAW,IAAI,IAAI,CAAC;CACzE,WAAW,cAAe,MAAiC,QAAQ;CACnE,OAAO;AACT;;;;;AAMA,SAAS,YAAY,QAAiB,OAAwB;CAC5D,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,OAAO,WAAW,UAAU,OAAO,aAAa,QAAQ,KAAK;CACjE,IAAI,OAAO,WAAW,YACpB,OAAO,gBAAgB,QAAsC,KAAK;CAEpE,MAAM,IAAI,UAEJ,6EAEN;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,QAAiC,OAAuC;CACtF,MAAM,GAAG,QAAQ,WAAW,OAAO,CAAC,WAAW,CAAC;CAEhD,OAAO,cACU;EACb,MAAM,SAAkB,MAAM;EAC9B,OAAO,cAAc,YAAY,QAAQ,IAAI,CAAC;CAChD,GACA,EAAE,aAAa,KAAK,CACtB;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,cACd,WACA,QAAgB,CAAC,GACF;CACf,OAAO,QACL,WACE,EACE,IAAI,YAAe;EACjB,OAAO,UAAU;CACnB,EACF,GACA,KACF,CACF;AACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JsxChild } from "../jsx/types.js";
|
|
2
2
|
import { Accessor } from "@shadow-js/core";
|
|
3
|
-
//#region src/control-flow/error-boundary.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Props of {@link ErrorBoundary}.
|
|
6
5
|
* @since 1.0.0
|
|
@@ -68,5 +67,4 @@ export interface ErrorBoundaryLooseProps {
|
|
|
68
67
|
*/
|
|
69
68
|
export declare function ErrorBoundary(props: ErrorBoundaryProps): Accessor<unknown>;
|
|
70
69
|
export declare function ErrorBoundary(props: ErrorBoundaryLooseProps): Accessor<unknown>;
|
|
71
|
-
//#endregion
|
|
72
70
|
//# sourceMappingURL=error-boundary.d.ts.map
|
|
@@ -3,7 +3,7 @@ import { attachHotModules, createHotLink } from "./hot-link.js";
|
|
|
3
3
|
import { rootErrorsOf } from "./root-errors.js";
|
|
4
4
|
import { catchError, createRoot, getOwner, onCleanup, untrack, useMemo, useSignal } from "@shadow-js/core";
|
|
5
5
|
import { createSignalNode, handleError, readSignal, writeSignal } from "@shadow-js/core/extend";
|
|
6
|
-
|
|
6
|
+
// src/control-flow/error-boundary.ts
|
|
7
7
|
function ErrorBoundary(props) {
|
|
8
8
|
const failureCell = createSignalNode(void 0, Object.is);
|
|
9
9
|
/** Where an error of this boundary's own fallback goes: the boundary that encloses it. */
|
|
@@ -109,7 +109,6 @@ function ErrorBoundary(props) {
|
|
|
109
109
|
});
|
|
110
110
|
return body;
|
|
111
111
|
}
|
|
112
|
-
//#endregion
|
|
113
112
|
export { ErrorBoundary };
|
|
114
113
|
|
|
115
114
|
//# sourceMappingURL=error-boundary.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor } from "@shadow-js/core";
|
|
2
|
-
//#region src/control-flow/for.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Props of {@link For} without `key`: rows are matched by item reference.
|
|
5
4
|
* @since 1.0.0
|
|
@@ -76,5 +75,4 @@ export type ForProps<T> = ForUnkeyedProps<T> | ForKeyedProps<T>;
|
|
|
76
75
|
*/
|
|
77
76
|
export declare function For<T>(props: ForKeyedProps<T>): Accessor<unknown[]>;
|
|
78
77
|
export declare function For<T>(props: ForUnkeyedProps<T>): Accessor<unknown[]>;
|
|
79
|
-
//#endregion
|
|
80
78
|
//# sourceMappingURL=for.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mapArray, untrack } from "@shadow-js/core";
|
|
2
|
-
|
|
2
|
+
// src/control-flow/for.ts
|
|
3
3
|
/**
|
|
4
4
|
* Calls the row callback. `props.children` is read untracked, once per row.
|
|
5
5
|
* @internal
|
|
@@ -17,7 +17,6 @@ function For(props) {
|
|
|
17
17
|
fallback
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
20
|
export { For };
|
|
22
21
|
|
|
23
22
|
//# sourceMappingURL=for.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/control-flow/fragment.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Props of {@link Fragment}.
|
|
4
3
|
* @since 1.0.0
|
|
@@ -34,5 +33,4 @@ export interface FragmentProps {
|
|
|
34
33
|
* @since 1.0.0
|
|
35
34
|
*/
|
|
36
35
|
export declare function Fragment(props: FragmentProps): unknown;
|
|
37
|
-
//#endregion
|
|
38
36
|
//# sourceMappingURL=fragment.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/control-flow/fragment.ts
|
|
2
2
|
/**
|
|
3
3
|
* A no-op wrapper: returns `props.children` untouched, so the children are created by the caller's
|
|
4
4
|
* getter exactly as if no wrapper existed. Use it to group several children under one element.
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
function Fragment(props) {
|
|
26
26
|
return props.children;
|
|
27
27
|
}
|
|
28
|
-
//#endregion
|
|
29
28
|
export { Fragment };
|
|
30
29
|
|
|
31
30
|
//# sourceMappingURL=fragment.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getOwner } from "@shadow-js/core";
|
|
2
|
-
|
|
2
|
+
// src/control-flow/hot-link.ts
|
|
3
3
|
/**
|
|
4
4
|
* The hot-update link between an error boundary and the modules its children were built from. Dev
|
|
5
5
|
* only: the callers reach this code behind `__DEV__`, so production bundles never include it.
|
|
@@ -58,7 +58,6 @@ function createHotLink(onUpdate) {
|
|
|
58
58
|
disarm
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { attachHotModules, createHotLink, hotModulesOf };
|
|
63
62
|
|
|
64
63
|
//# sourceMappingURL=hot-link.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor } from "@shadow-js/core";
|
|
2
|
-
//#region src/control-flow/index-list.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Props of {@link Index}.
|
|
5
4
|
* @since 1.0.0
|
|
@@ -44,5 +43,4 @@ export interface IndexProps<T> {
|
|
|
44
43
|
* @since 1.0.0
|
|
45
44
|
*/
|
|
46
45
|
export declare function Index<T>(props: IndexProps<T>): Accessor<unknown[]>;
|
|
47
|
-
//#endregion
|
|
48
46
|
//# sourceMappingURL=index-list.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { indexArray, untrack } from "@shadow-js/core";
|
|
2
|
-
|
|
2
|
+
// src/control-flow/index-list.ts
|
|
3
3
|
/**
|
|
4
4
|
* Renders one row per position. Rows are created and removed only when the length changes; the
|
|
5
5
|
* row at position `i` stays, and its item accessor follows the value at `i`. Use it for
|
|
@@ -25,7 +25,6 @@ import { indexArray, untrack } from "@shadow-js/core";
|
|
|
25
25
|
function Index(props) {
|
|
26
26
|
return indexArray(() => props.each, (item, index) => untrack(() => props.children)(item, index), { fallback: () => props.fallback });
|
|
27
27
|
}
|
|
28
|
-
//#endregion
|
|
29
28
|
export { Index };
|
|
30
29
|
|
|
31
30
|
//# sourceMappingURL=index-list.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor } from "@shadow-js/core";
|
|
2
|
-
//#region src/control-flow/lazy.d.ts
|
|
3
2
|
type ComponentFunction<P> = (props: P) => unknown;
|
|
4
3
|
/**
|
|
5
4
|
* A component made by {@link lazy}: call it (or write it in JSX) like any component, and use
|
|
@@ -53,6 +52,5 @@ export interface LazyComponent<P> {
|
|
|
53
52
|
export declare function lazy<P>(loader: () => Promise<{
|
|
54
53
|
default: ComponentFunction<P>;
|
|
55
54
|
}>): LazyComponent<P>;
|
|
56
|
-
//#endregion
|
|
57
55
|
export {};
|
|
58
56
|
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { untrack, useMemo, useResource } from "@shadow-js/core";
|
|
2
|
-
|
|
2
|
+
// src/control-flow/lazy.ts
|
|
3
3
|
/**
|
|
4
4
|
* Defines a component whose code is loaded on first render. While loading, the nearest
|
|
5
5
|
* `<Suspense>` shows its fallback; a failed load throws to the nearest `<ErrorBoundary>` and the
|
|
@@ -58,7 +58,6 @@ function lazy(loader) {
|
|
|
58
58
|
Lazy.preload = load;
|
|
59
59
|
return Lazy;
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { lazy };
|
|
63
62
|
|
|
64
63
|
//# sourceMappingURL=lazy.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor } from "@shadow-js/core";
|
|
2
|
-
//#region src/control-flow/no-hydration.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Props of {@link NoHydration}.
|
|
5
4
|
* @since 1.0.0
|
|
@@ -35,5 +34,4 @@ export interface NoHydrationProps {
|
|
|
35
34
|
* @since 1.0.0
|
|
36
35
|
*/
|
|
37
36
|
export declare function NoHydration(props: NoHydrationProps): Accessor<unknown>;
|
|
38
|
-
//#endregion
|
|
39
37
|
//# sourceMappingURL=no-hydration.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nextKey } from "../internal/hydration-scope.js";
|
|
2
2
|
import { claims } from "../internal/hydration-hooks.js";
|
|
3
|
-
|
|
3
|
+
// src/control-flow/no-hydration.ts
|
|
4
4
|
/** The nodes between `<!--nh:KEY-->` and its `<!--/nh-->` in the lifted regions, or undefined when the server sent none. */
|
|
5
5
|
function findStatic(key, regions) {
|
|
6
6
|
if (key === void 0 || regions === void 0) return void 0;
|
|
@@ -52,7 +52,6 @@ function NoHydration(props) {
|
|
|
52
52
|
}
|
|
53
53
|
return () => props.children;
|
|
54
54
|
}
|
|
55
|
-
//#endregion
|
|
56
55
|
export { NoHydration };
|
|
57
56
|
|
|
58
57
|
//# sourceMappingURL=no-hydration.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/control-flow/portal.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Props of {@link Portal}.
|
|
4
3
|
* @since 1.0.0
|
|
@@ -65,5 +64,4 @@ export interface PortalProps {
|
|
|
65
64
|
* @since 1.0.0
|
|
66
65
|
*/
|
|
67
66
|
export declare function Portal(props: PortalProps): null;
|
|
68
|
-
//#endregion
|
|
69
67
|
//# sourceMappingURL=portal.d.ts.map
|
|
@@ -4,7 +4,7 @@ import { bindRegion, createRegion, removeRegion } from "../insert.js";
|
|
|
4
4
|
import { PortalContext } from "../internal/portal-context.js";
|
|
5
5
|
import { renderServerPortal } from "../server/portals.js";
|
|
6
6
|
import { createRoot, isServer, onCleanup, useContext, useRenderEffect } from "@shadow-js/core";
|
|
7
|
-
|
|
7
|
+
// src/control-flow/portal.ts
|
|
8
8
|
/** Appends `node` to `target`, moving it in place when the target supports `moveBefore`. */
|
|
9
9
|
function appendMoved(target, node) {
|
|
10
10
|
if (typeof target.moveBefore === "function") target.moveBefore(node, null);
|
|
@@ -115,6 +115,8 @@ function Portal(props) {
|
|
|
115
115
|
}, ({ host, shadow }) => {
|
|
116
116
|
if (host === null) {
|
|
117
117
|
unmount();
|
|
118
|
+
for (const node of adopted ?? []) node.parentNode?.removeChild(node);
|
|
119
|
+
adopted = void 0;
|
|
118
120
|
if (!warned) {
|
|
119
121
|
warned = true;
|
|
120
122
|
console.warn("[shadow PORTAL_TARGET_MISSING] Portal has no mount element; nothing is rendered.");
|
|
@@ -128,7 +130,6 @@ function Portal(props) {
|
|
|
128
130
|
onCleanup(unmount);
|
|
129
131
|
return null;
|
|
130
132
|
}
|
|
131
|
-
//#endregion
|
|
132
133
|
export { Portal };
|
|
133
134
|
|
|
134
135
|
//# sourceMappingURL=portal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.js","names":[],"sources":["../../../src/control-flow/portal.ts"],"sourcesContent":["import { createRoot, isServer, onCleanup, useContext, useRenderEffect } from \"@shadow-js/core\";\nimport {\n bindRegion,\n childScope,\n claims,\n createRegion,\n nextKey,\n PortalContext,\n type Region,\n removeRegion,\n withScope,\n} from \"../extend\";\nimport { renderServerPortal } from \"../server/portals\";\n\n/**\n * Props of {@link Portal}.\n * @since 1.0.0\n */\nexport interface PortalProps {\n /**\n * The element that receives the content, or a function returning it (read reactively). A null\n * target, or a function that returns null or undefined, renders nothing and warns once in\n * development (`PORTAL_TARGET_MISSING`).\n * @default document.body (when the prop is omitted)\n */\n readonly mount?: Element | null | (() => Element | null | undefined);\n /**\n * Put the content in a shadow root of the mount, created once and reused. A portal with a shadow\n * root is not server-rendered; the browser creates it.\n * @default false\n */\n readonly useShadow?: boolean;\n /**\n * Reserved for namespace handling. Nodes are inserted as they were created, so the flag does not\n * change the output yet.\n * @default false\n */\n readonly isSVG?: boolean;\n /**\n * The content: a node, text, an array, or an accessor returning them.\n * @default undefined (nothing is rendered)\n */\n readonly children?: unknown;\n}\n\n/** What the portal holds while content is mounted: where it is, its region, and its effects. */\ninterface Mounted {\n readonly host: Node;\n readonly region: Region;\n /** Stops the content's effects. The nodes stay where they are. */\n readonly stopEffects: () => void;\n}\n\n/**\n * How the content of a mount is built. `claimed`: the server markup is adopted (the templates claim\n * it). `unclaimed`: hydrating, but the server sent nothing for this portal, so it is built fresh.\n */\ntype MountMode = \"plain\" | \"claimed\" | \"unclaimed\";\n\n/** A node that can be moved in place (`Element.prototype.moveBefore`, where implemented). */\ninterface MovableNode extends Node {\n moveBefore(node: Node, child: Node | null): void;\n}\n\n/** Appends `node` to `target`, moving it in place when the target supports `moveBefore`. */\nfunction appendMoved(target: Node, node: Node): void {\n if (typeof (target as Partial<MovableNode>).moveBefore === \"function\") {\n (target as MovableNode).moveBefore(node, null);\n } else {\n target.appendChild(node);\n }\n}\n\n/** The shadow root of an element, attached once when the element has none. */\nfunction shadowRootOf(host: Element): ShadowRoot {\n return host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n}\n\n/** The mount target of a `mount` prop: the default body, the element, or the function's result. */\nfunction resolveMount(mount: PortalProps[\"mount\"]): Element | null {\n if (mount === undefined) return document.body;\n const value = typeof mount === \"function\" ? mount() : mount;\n return value ?? null;\n}\n\n/**\n * Renders `children` into another part of the document, without a wrapper: the content nodes are\n * inserted directly into the mount element (or its shadow root). Nothing is left at the call site.\n * Disposing the owner removes exactly the nodes the portal inserted; nodes that were already in the\n * mount stay. A reactive `mount` moves the content, and static nodes keep their identity while they\n * move.\n *\n * On the server the content is rendered into the render's `portals` collector (see\n * `createServerPortals`), and the document emits it at the end of `<body>`. When the browser hydrates\n * the portal it adopts that markup instead of creating it again, moving it into the mount if the mount\n * is not `body`. A portal with `useShadow` is not server-rendered; the browser creates it.\n *\n * Events follow the DOM tree. Delegated handlers inside the content fire when the mount is in the\n * document, because the document listener sees the event bubble past the mount. Handlers on\n * elements that wrap the call site do not fire.\n *\n * @param props See {@link PortalProps}.\n * @returns Always null: the portal renders nothing in place.\n * @example\n * import { Portal } from \"@shadow-js/web\";\n *\n * function Modal() {\n * return <div role=\"dialog\">Hello</div>;\n * }\n *\n * function App() {\n * return (\n * <Portal mount={document.getElementById(\"modal-root\")}>\n * <Modal />\n * </Portal>\n * );\n * }\n * @see Dynamic\n * @since 1.0.0\n */\nexport function Portal(props: PortalProps): null {\n // The key of this portal's server block, taken at the call site on the server and in the browser\n // alike. The content renders in a scope of its own (`childScope`), so the keys of the siblings do\n // not depend on whether the content rendered.\n const key = nextKey();\n // A server render provides the portal collector (`renderToString` and friends), so it is recognized\n // by the collector as well as by the build's `isServer` flag: the same server code runs in both.\n const sink = useContext(PortalContext);\n if (isServer || sink !== null) {\n if (props.useShadow !== true) renderServerPortal(key, () => props.children, sink);\n return null;\n }\n let mounted: Mounted | undefined;\n let warned = false;\n // The server block of this portal, taken out of the markers while hydrating; used by the first mount.\n let adopted: Node[] | undefined = claims.current.claimPortal(key);\n\n /** Stops the content's effects, then removes its nodes. Safe to call when nothing is mounted. */\n const unmount = (): void => {\n const current = mounted;\n if (current === undefined) return;\n mounted = undefined;\n current.stopEffects();\n removeRegion(current.region);\n };\n\n /** Creates the content region in `host`, adopting the nodes that are already there. */\n const mountInto = (host: Node, initial: Node[], mode: MountMode): Mounted => {\n const region = createRegion(host, null, initial);\n const stopEffects = createRoot((dispose) => {\n const bind = (): void => {\n bindRegion(region, () => props.children);\n };\n if (mode === \"plain\") bind();\n else if (mode === \"claimed\") withScope(childScope(key), bind);\n else claims.current.withoutClaiming(() => withScope(childScope(key), bind));\n return dispose;\n });\n return { host, region, stopEffects };\n };\n\n /** Moves the content to `target`. The nodes move first, then the children are bound again. */\n const moveTo = (target: Node): void => {\n const previous = mounted;\n if (previous === undefined) {\n const initial = adopted ?? [];\n let mode: MountMode = \"plain\";\n if (adopted !== undefined) mode = \"claimed\";\n else if (key !== undefined && claims.current.isClaiming()) mode = \"unclaimed\";\n adopted = undefined;\n for (const node of initial) {\n if (node.parentNode !== target) appendMoved(target, node);\n }\n mounted = mountInto(target, initial, mode);\n return;\n }\n const nodes = previous.region.nodes.filter((node) => node.parentNode === previous.host);\n previous.stopEffects();\n for (const node of nodes) appendMoved(target, node);\n mounted = mountInto(target, nodes, \"plain\");\n };\n\n useRenderEffect(\n () => {\n const host = resolveMount(props.mount);\n const shadow = props.useShadow === true;\n return { host, shadow };\n },\n ({ host, shadow }) => {\n if (host === null) {\n unmount();\n if (__DEV__ && !warned) {\n warned = true;\n console.warn(\n \"[shadow PORTAL_TARGET_MISSING] Portal has no mount element; nothing is rendered.\",\n );\n }\n return;\n }\n const target: Node = shadow ? shadowRootOf(host) : host;\n if (mounted !== undefined && mounted.host === target) return;\n moveTo(target);\n },\n );\n onCleanup(unmount);\n return null;\n}\n"],"mappings":";;;;;;;;AAiEA,SAAS,YAAY,QAAc,MAAkB;CACnD,IAAI,OAAQ,OAAgC,eAAe,YACzD,OAAwB,WAAW,MAAM,IAAI;MAE7C,OAAO,YAAY,IAAI;AAE3B;;AAGA,SAAS,aAAa,MAA2B;CAC/C,OAAO,KAAK,cAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAC9D;;AAGA,SAAS,aAAa,OAA6C;CACjE,IAAI,UAAU,KAAA,GAAW,OAAO,SAAS;CAEzC,QADc,OAAO,UAAU,aAAa,MAAM,IAAI,UACtC;AAClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,OAAO,OAA0B;CAI/C,MAAM,MAAM,QAAQ;CAGpB,MAAM,OAAO,WAAW,aAAa;CACrC,IAAI,YAAY,SAAS,MAAM;EAC7B,IAAI,MAAM,cAAc,MAAM,mBAAmB,WAAW,MAAM,UAAU,IAAI;EAChF,OAAO;CACT;CACA,IAAI;CACJ,IAAI,SAAS;CAEb,IAAI,UAA8B,OAAO,QAAQ,YAAY,GAAG;;CAGhE,MAAM,gBAAsB;EAC1B,MAAM,UAAU;EAChB,IAAI,YAAY,KAAA,GAAW;EAC3B,UAAU,KAAA;EACV,QAAQ,YAAY;EACpB,aAAa,QAAQ,MAAM;CAC7B;;CAGA,MAAM,aAAa,MAAY,SAAiB,SAA6B;EAC3E,MAAM,SAAS,aAAa,MAAM,MAAM,OAAO;EAU/C,OAAO;GAAE;GAAM;GAAQ,aATH,YAAY,YAAY;IAC1C,MAAM,aAAmB;KACvB,WAAW,cAAc,MAAM,QAAQ;IACzC;IACA,IAAI,SAAS,SAAS,KAAK;SACtB,IAAI,SAAS,WAAW,UAAU,WAAW,GAAG,GAAG,IAAI;SACvD,OAAO,QAAQ,sBAAsB,UAAU,WAAW,GAAG,GAAG,IAAI,CAAC;IAC1E,OAAO;GACT,CACiC;EAAE;CACrC;;CAGA,MAAM,UAAU,WAAuB;EACrC,MAAM,WAAW;EACjB,IAAI,aAAa,KAAA,GAAW;GAC1B,MAAM,UAAU,WAAW,CAAC;GAC5B,IAAI,OAAkB;GACtB,IAAI,YAAY,KAAA,GAAW,OAAO;QAC7B,IAAI,QAAQ,KAAA,KAAa,OAAO,QAAQ,WAAW,GAAG,OAAO;GAClE,UAAU,KAAA;GACV,KAAK,MAAM,QAAQ,SACjB,IAAI,KAAK,eAAe,QAAQ,YAAY,QAAQ,IAAI;GAE1D,UAAU,UAAU,QAAQ,SAAS,IAAI;GACzC;EACF;EACA,MAAM,QAAQ,SAAS,OAAO,MAAM,QAAQ,SAAS,KAAK,eAAe,SAAS,IAAI;EACtF,SAAS,YAAY;EACrB,KAAK,MAAM,QAAQ,OAAO,YAAY,QAAQ,IAAI;EAClD,UAAU,UAAU,QAAQ,OAAO,OAAO;CAC5C;CAEA,sBACQ;EAGJ,OAAO;GAAE,MAFI,aAAa,MAAM,KAEpB;GAAG,QADA,MAAM,cAAc;EACb;CACxB,IACC,EAAE,MAAM,aAAa;EACpB,IAAI,SAAS,MAAM;GACjB,QAAQ;GACR,IAAe,CAAC,QAAQ;IACtB,SAAS;IACT,QAAQ,KACN,kFACF;GACF;GACA;EACF;EACA,MAAM,SAAe,SAAS,aAAa,IAAI,IAAI;EACnD,IAAI,YAAY,KAAA,KAAa,QAAQ,SAAS,QAAQ;EACtD,OAAO,MAAM;CACf,CACF;CACA,UAAU,OAAO;CACjB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"portal.js","names":[],"sources":["../../../src/control-flow/portal.ts"],"sourcesContent":["import { createRoot, isServer, onCleanup, useContext, useRenderEffect } from \"@shadow-js/core\";\nimport {\n bindRegion,\n childScope,\n claims,\n createRegion,\n nextKey,\n PortalContext,\n type Region,\n removeRegion,\n withScope,\n} from \"../extend\";\nimport { renderServerPortal } from \"../server/portals\";\n\n/**\n * Props of {@link Portal}.\n * @since 1.0.0\n */\nexport interface PortalProps {\n /**\n * The element that receives the content, or a function returning it (read reactively). A null\n * target, or a function that returns null or undefined, renders nothing and warns once in\n * development (`PORTAL_TARGET_MISSING`).\n * @default document.body (when the prop is omitted)\n */\n readonly mount?: Element | null | (() => Element | null | undefined);\n /**\n * Put the content in a shadow root of the mount, created once and reused. A portal with a shadow\n * root is not server-rendered; the browser creates it.\n * @default false\n */\n readonly useShadow?: boolean;\n /**\n * Reserved for namespace handling. Nodes are inserted as they were created, so the flag does not\n * change the output yet.\n * @default false\n */\n readonly isSVG?: boolean;\n /**\n * The content: a node, text, an array, or an accessor returning them.\n * @default undefined (nothing is rendered)\n */\n readonly children?: unknown;\n}\n\n/** What the portal holds while content is mounted: where it is, its region, and its effects. */\ninterface Mounted {\n readonly host: Node;\n readonly region: Region;\n /** Stops the content's effects. The nodes stay where they are. */\n readonly stopEffects: () => void;\n}\n\n/**\n * How the content of a mount is built. `claimed`: the server markup is adopted (the templates claim\n * it). `unclaimed`: hydrating, but the server sent nothing for this portal, so it is built fresh.\n */\ntype MountMode = \"plain\" | \"claimed\" | \"unclaimed\";\n\n/** A node that can be moved in place (`Element.prototype.moveBefore`, where implemented). */\ninterface MovableNode extends Node {\n moveBefore(node: Node, child: Node | null): void;\n}\n\n/** Appends `node` to `target`, moving it in place when the target supports `moveBefore`. */\nfunction appendMoved(target: Node, node: Node): void {\n if (typeof (target as Partial<MovableNode>).moveBefore === \"function\") {\n (target as MovableNode).moveBefore(node, null);\n } else {\n target.appendChild(node);\n }\n}\n\n/** The shadow root of an element, attached once when the element has none. */\nfunction shadowRootOf(host: Element): ShadowRoot {\n return host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n}\n\n/** The mount target of a `mount` prop: the default body, the element, or the function's result. */\nfunction resolveMount(mount: PortalProps[\"mount\"]): Element | null {\n if (mount === undefined) return document.body;\n const value = typeof mount === \"function\" ? mount() : mount;\n return value ?? null;\n}\n\n/**\n * Renders `children` into another part of the document, without a wrapper: the content nodes are\n * inserted directly into the mount element (or its shadow root). Nothing is left at the call site.\n * Disposing the owner removes exactly the nodes the portal inserted; nodes that were already in the\n * mount stay. A reactive `mount` moves the content, and static nodes keep their identity while they\n * move.\n *\n * On the server the content is rendered into the render's `portals` collector (see\n * `createServerPortals`), and the document emits it at the end of `<body>`. When the browser hydrates\n * the portal it adopts that markup instead of creating it again, moving it into the mount if the mount\n * is not `body`. A portal with `useShadow` is not server-rendered; the browser creates it.\n *\n * Events follow the DOM tree. Delegated handlers inside the content fire when the mount is in the\n * document, because the document listener sees the event bubble past the mount. Handlers on\n * elements that wrap the call site do not fire.\n *\n * @param props See {@link PortalProps}.\n * @returns Always null: the portal renders nothing in place.\n * @example\n * import { Portal } from \"@shadow-js/web\";\n *\n * function Modal() {\n * return <div role=\"dialog\">Hello</div>;\n * }\n *\n * function App() {\n * return (\n * <Portal mount={document.getElementById(\"modal-root\")}>\n * <Modal />\n * </Portal>\n * );\n * }\n * @see Dynamic\n * @since 1.0.0\n */\nexport function Portal(props: PortalProps): null {\n // The key of this portal's server block, taken at the call site on the server and in the browser\n // alike. The content renders in a scope of its own (`childScope`), so the keys of the siblings do\n // not depend on whether the content rendered.\n const key = nextKey();\n // A server render provides the portal collector (`renderToString` and friends), so it is recognized\n // by the collector as well as by the build's `isServer` flag: the same server code runs in both.\n const sink = useContext(PortalContext);\n if (isServer || sink !== null) {\n if (props.useShadow !== true) renderServerPortal(key, () => props.children, sink);\n return null;\n }\n let mounted: Mounted | undefined;\n let warned = false;\n // The server block of this portal, taken out of the markers while hydrating; used by the first mount.\n let adopted: Node[] | undefined = claims.current.claimPortal(key);\n\n /** Stops the content's effects, then removes its nodes. Safe to call when nothing is mounted. */\n const unmount = (): void => {\n const current = mounted;\n if (current === undefined) return;\n mounted = undefined;\n current.stopEffects();\n removeRegion(current.region);\n };\n\n /** Creates the content region in `host`, adopting the nodes that are already there. */\n const mountInto = (host: Node, initial: Node[], mode: MountMode): Mounted => {\n const region = createRegion(host, null, initial);\n const stopEffects = createRoot((dispose) => {\n const bind = (): void => {\n bindRegion(region, () => props.children);\n };\n if (mode === \"plain\") bind();\n else if (mode === \"claimed\") withScope(childScope(key), bind);\n else claims.current.withoutClaiming(() => withScope(childScope(key), bind));\n return dispose;\n });\n return { host, region, stopEffects };\n };\n\n /** Moves the content to `target`. The nodes move first, then the children are bound again. */\n const moveTo = (target: Node): void => {\n const previous = mounted;\n if (previous === undefined) {\n const initial = adopted ?? [];\n let mode: MountMode = \"plain\";\n if (adopted !== undefined) mode = \"claimed\";\n else if (key !== undefined && claims.current.isClaiming()) mode = \"unclaimed\";\n adopted = undefined;\n for (const node of initial) {\n if (node.parentNode !== target) appendMoved(target, node);\n }\n mounted = mountInto(target, initial, mode);\n return;\n }\n const nodes = previous.region.nodes.filter((node) => node.parentNode === previous.host);\n previous.stopEffects();\n for (const node of nodes) appendMoved(target, node);\n mounted = mountInto(target, nodes, \"plain\");\n };\n\n useRenderEffect(\n () => {\n const host = resolveMount(props.mount);\n const shadow = props.useShadow === true;\n return { host, shadow };\n },\n ({ host, shadow }) => {\n if (host === null) {\n unmount();\n // The server block was adopted at the call site but has nowhere to live: leaving it would show\n // content the client does not render (stripLeftovers removes the blocks nobody claimed).\n for (const node of adopted ?? []) node.parentNode?.removeChild(node);\n adopted = undefined;\n if (__DEV__ && !warned) {\n warned = true;\n console.warn(\n \"[shadow PORTAL_TARGET_MISSING] Portal has no mount element; nothing is rendered.\",\n );\n }\n return;\n }\n const target: Node = shadow ? shadowRootOf(host) : host;\n if (mounted !== undefined && mounted.host === target) return;\n moveTo(target);\n },\n );\n onCleanup(unmount);\n return null;\n}\n"],"mappings":";;;;;;;;AAiEA,SAAS,YAAY,QAAc,MAAkB;CACnD,IAAI,OAAQ,OAAgC,eAAe,YACzD,OAAwB,WAAW,MAAM,IAAI;MAE7C,OAAO,YAAY,IAAI;AAE3B;;AAGA,SAAS,aAAa,MAA2B;CAC/C,OAAO,KAAK,cAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAC9D;;AAGA,SAAS,aAAa,OAA6C;CACjE,IAAI,UAAU,KAAA,GAAW,OAAO,SAAS;CAEzC,QADc,OAAO,UAAU,aAAa,MAAM,IAAI,UACtC;AAClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,OAAO,OAA0B;CAI/C,MAAM,MAAM,QAAQ;CAGpB,MAAM,OAAO,WAAW,aAAa;CACrC,IAAI,YAAY,SAAS,MAAM;EAC7B,IAAI,MAAM,cAAc,MAAM,mBAAmB,WAAW,MAAM,UAAU,IAAI;EAChF,OAAO;CACT;CACA,IAAI;CACJ,IAAI,SAAS;CAEb,IAAI,UAA8B,OAAO,QAAQ,YAAY,GAAG;;CAGhE,MAAM,gBAAsB;EAC1B,MAAM,UAAU;EAChB,IAAI,YAAY,KAAA,GAAW;EAC3B,UAAU,KAAA;EACV,QAAQ,YAAY;EACpB,aAAa,QAAQ,MAAM;CAC7B;;CAGA,MAAM,aAAa,MAAY,SAAiB,SAA6B;EAC3E,MAAM,SAAS,aAAa,MAAM,MAAM,OAAO;EAU/C,OAAO;GAAE;GAAM;GAAQ,aATH,YAAY,YAAY;IAC1C,MAAM,aAAmB;KACvB,WAAW,cAAc,MAAM,QAAQ;IACzC;IACA,IAAI,SAAS,SAAS,KAAK;SACtB,IAAI,SAAS,WAAW,UAAU,WAAW,GAAG,GAAG,IAAI;SACvD,OAAO,QAAQ,sBAAsB,UAAU,WAAW,GAAG,GAAG,IAAI,CAAC;IAC1E,OAAO;GACT,CACiC;EAAE;CACrC;;CAGA,MAAM,UAAU,WAAuB;EACrC,MAAM,WAAW;EACjB,IAAI,aAAa,KAAA,GAAW;GAC1B,MAAM,UAAU,WAAW,CAAC;GAC5B,IAAI,OAAkB;GACtB,IAAI,YAAY,KAAA,GAAW,OAAO;QAC7B,IAAI,QAAQ,KAAA,KAAa,OAAO,QAAQ,WAAW,GAAG,OAAO;GAClE,UAAU,KAAA;GACV,KAAK,MAAM,QAAQ,SACjB,IAAI,KAAK,eAAe,QAAQ,YAAY,QAAQ,IAAI;GAE1D,UAAU,UAAU,QAAQ,SAAS,IAAI;GACzC;EACF;EACA,MAAM,QAAQ,SAAS,OAAO,MAAM,QAAQ,SAAS,KAAK,eAAe,SAAS,IAAI;EACtF,SAAS,YAAY;EACrB,KAAK,MAAM,QAAQ,OAAO,YAAY,QAAQ,IAAI;EAClD,UAAU,UAAU,QAAQ,OAAO,OAAO;CAC5C;CAEA,sBACQ;EAGJ,OAAO;GAAE,MAFI,aAAa,MAAM,KAEpB;GAAG,QADA,MAAM,cAAc;EACb;CACxB,IACC,EAAE,MAAM,aAAa;EACpB,IAAI,SAAS,MAAM;GACjB,QAAQ;GAGR,KAAK,MAAM,QAAQ,WAAW,CAAC,GAAG,KAAK,YAAY,YAAY,IAAI;GACnE,UAAU,KAAA;GACV,IAAe,CAAC,QAAQ;IACtB,SAAS;IACT,QAAQ,KACN,kFACF;GACF;GACA;EACF;EACA,MAAM,SAAe,SAAS,aAAa,IAAI,IAAI;EACnD,IAAI,YAAY,KAAA,KAAa,QAAQ,SAAS,QAAQ;EACtD,OAAO,MAAM;CACf,CACF;CACA,UAAU,OAAO;CACjB,OAAO;AACT"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Owner } from "@shadow-js/core";
|
|
2
|
-
//#region src/control-flow/root-errors.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* The error reporters a root was rendered or hydrated with (see `RenderOptions` and `HydrateOptions`).
|
|
5
4
|
* @since 1.0.0
|
|
@@ -21,5 +20,4 @@ export interface RootErrorOptions {
|
|
|
21
20
|
*/
|
|
22
21
|
readonly onRecoverableError?: (error: unknown) => void;
|
|
23
22
|
}
|
|
24
|
-
//#endregion
|
|
25
23
|
//# sourceMappingURL=root-errors.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getOwner } from "@shadow-js/core";
|
|
2
|
-
|
|
2
|
+
// src/control-flow/root-errors.ts
|
|
3
3
|
/**
|
|
4
4
|
* The key the reporters are stored under in an owner's context map. A symbol the context map inherits
|
|
5
5
|
* (as a Provider's value is inherited), so every node below the root sees it, detached roots included.
|
|
@@ -27,7 +27,6 @@ function attachRootErrors(options) {
|
|
|
27
27
|
function rootErrorsOf(owner) {
|
|
28
28
|
return owner?.context?.[ROOT_ERRORS];
|
|
29
29
|
}
|
|
30
|
-
//#endregion
|
|
31
30
|
export { attachRootErrors, rootErrorsOf };
|
|
32
31
|
|
|
33
32
|
//# sourceMappingURL=root-errors.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JsxChild } from "../jsx/types.js";
|
|
2
2
|
import { Accessor } from "@shadow-js/core";
|
|
3
|
-
//#region src/control-flow/show.d.ts
|
|
4
3
|
/** What `when` accepts: the value, or any falsy stand-in (`0` and `""` count as falsy). */
|
|
5
4
|
type ShowCondition<T> = T | undefined | null | false | 0 | "";
|
|
6
5
|
/** Props shared by both forms of {@link Show}. */
|
|
@@ -96,6 +95,5 @@ export interface ShowLooseProps<T> extends ShowBaseProps<T> {
|
|
|
96
95
|
*/
|
|
97
96
|
export declare function Show<T>(props: ShowProps<T>): Accessor<unknown>;
|
|
98
97
|
export declare function Show<T>(props: ShowLooseProps<T>): Accessor<unknown>;
|
|
99
|
-
//#endregion
|
|
100
98
|
export {};
|
|
101
99
|
//# sourceMappingURL=show.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createBranches } from "./branch.js";
|
|
2
|
-
|
|
2
|
+
// src/control-flow/show.ts
|
|
3
3
|
function Show(props) {
|
|
4
4
|
return createBranches("Show", () => {
|
|
5
5
|
const when = props.when;
|
|
@@ -12,7 +12,6 @@ function Show(props) {
|
|
|
12
12
|
};
|
|
13
13
|
}, () => props.fallback);
|
|
14
14
|
}
|
|
15
|
-
//#endregion
|
|
16
15
|
export { Show };
|
|
17
16
|
|
|
18
17
|
//# sourceMappingURL=show.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor, Context } from "@shadow-js/core";
|
|
2
|
-
//#region src/control-flow/suspense-list.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Props of {@link SuspenseList}.
|
|
5
4
|
* @since 1.0.0
|
|
@@ -61,5 +60,4 @@ export interface SuspenseListProps {
|
|
|
61
60
|
* @since 1.0.0
|
|
62
61
|
*/
|
|
63
62
|
export declare function SuspenseList(props: SuspenseListProps): Accessor<unknown>;
|
|
64
|
-
//#endregion
|
|
65
63
|
//# sourceMappingURL=suspense-list.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, onCleanup, useContext } from "@shadow-js/core";
|
|
2
2
|
import { createSignalNode, readSignal, writeSignal } from "@shadow-js/core/extend";
|
|
3
|
-
|
|
3
|
+
// src/control-flow/suspense-list.ts
|
|
4
4
|
/** The enclosing list, or null. @internal */
|
|
5
5
|
const SuspenseListContext = /* @__PURE__ */ createContext(null, { name: "SuspenseList" });
|
|
6
6
|
/**
|
|
@@ -99,7 +99,6 @@ function registerInList(ready) {
|
|
|
99
99
|
const list = useContext(SuspenseListContext);
|
|
100
100
|
return list === null ? null : list.register(ready);
|
|
101
101
|
}
|
|
102
|
-
//#endregion
|
|
103
102
|
export { SuspenseList, SuspenseListContext, registerInList };
|
|
104
103
|
|
|
105
104
|
//# sourceMappingURL=suspense-list.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor } from "@shadow-js/core";
|
|
2
|
-
//#region src/control-flow/suspense.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Props of {@link Suspense}.
|
|
5
4
|
* @since 1.0.0
|
|
@@ -49,5 +48,4 @@ export interface SuspenseProps {
|
|
|
49
48
|
* @since 1.0.0
|
|
50
49
|
*/
|
|
51
50
|
export declare function Suspense(props: SuspenseProps): Accessor<unknown>;
|
|
52
|
-
//#endregion
|
|
53
51
|
//# sourceMappingURL=suspense.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { childScope, nextKey, withScope } from "../internal/hydration-scope.js";
|
|
|
2
2
|
import { registerInList } from "./suspense-list.js";
|
|
3
3
|
import { SuspenseContext, runWithOwner, useMemo } from "@shadow-js/core";
|
|
4
4
|
import { createOwner, createSignalNode, readSignal, transitionHooks, writeSignal } from "@shadow-js/core/extend";
|
|
5
|
-
|
|
5
|
+
// src/control-flow/suspense.ts
|
|
6
6
|
/**
|
|
7
7
|
* A counter the resources of one boundary report to (see {@link SuspenseTracker}), and the hold a
|
|
8
8
|
* transition takes on the boundary. A transition that reads pending data while the boundary shows
|
|
@@ -96,7 +96,6 @@ function Suspense(props) {
|
|
|
96
96
|
return slot.showFallback() ? withScope(fallbackScope, () => props.fallback) : null;
|
|
97
97
|
}, { allowWrites: true });
|
|
98
98
|
}
|
|
99
|
-
//#endregion
|
|
100
99
|
export { Suspense };
|
|
101
100
|
|
|
102
101
|
//# sourceMappingURL=suspense.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor } from "@shadow-js/core";
|
|
2
|
-
//#region src/control-flow/switch.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Props of {@link Match}. A Match descriptor is the props object itself.
|
|
5
4
|
* @since 1.0.0
|
|
@@ -81,5 +80,4 @@ export interface SwitchProps {
|
|
|
81
80
|
* @since 1.0.0
|
|
82
81
|
*/
|
|
83
82
|
export declare function Switch(props: SwitchProps): Accessor<unknown>;
|
|
84
|
-
//#endregion
|
|
85
83
|
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBranches } from "./branch.js";
|
|
2
2
|
import { children } from "@shadow-js/core";
|
|
3
|
-
|
|
3
|
+
// src/control-flow/switch.ts
|
|
4
4
|
/**
|
|
5
5
|
* Describes one branch of a {@link Switch}. It returns its props unchanged.
|
|
6
6
|
*
|
|
@@ -84,7 +84,6 @@ function Switch(props) {
|
|
|
84
84
|
};
|
|
85
85
|
}, () => props.fallback);
|
|
86
86
|
}
|
|
87
|
-
//#endregion
|
|
88
87
|
export { Match, Switch };
|
|
89
88
|
|
|
90
89
|
//# sourceMappingURL=switch.js.map
|
package/dist/dev/derived.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/derived.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* A value the compiler keeps live: the result of `const x = <expression reading signals>` inside a
|
|
4
3
|
* component. Read it as `x.value` or call it as `x()`, so `{double}` and `{double()}` both work in
|
|
@@ -48,5 +47,4 @@ export interface Derived<T> {
|
|
|
48
47
|
* @since 1.0.0
|
|
49
48
|
*/
|
|
50
49
|
export declare function derived<T>(compute: () => T): Derived<T>;
|
|
51
|
-
//#endregion
|
|
52
50
|
//# sourceMappingURL=derived.d.ts.map
|