@ecopages/radiant 0.3.0-alpha.4 → 0.3.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -59
- package/dist/LICENSE +21 -0
- package/dist/client/hydrator.d.ts +1 -1
- package/dist/client/hydrator.js +2 -2
- package/dist/client/hydrator.js.map +5 -3
- package/dist/client/install-hydrator.js +2 -2
- package/dist/client/install-hydrator.js.map +5 -3
- package/dist/context/context-consumer-bootstrap.d.ts +7 -6
- package/dist/context/context-consumer-bootstrap.js +2 -2
- package/dist/context/context-consumer-bootstrap.js.map +8 -3
- package/dist/context/context-consumer-runtime.d.ts +21 -8
- package/dist/context/context-consumer-runtime.js +2 -2
- package/dist/context/context-consumer-runtime.js.map +6 -3
- package/dist/context/context-host.d.ts +25 -0
- package/dist/context/context-host.js +3 -0
- package/dist/context/context-host.js.map +10 -0
- package/dist/context/context-provider.d.ts +10 -6
- package/dist/context/context-provider.js +2 -2
- package/dist/context/context-provider.js.map +9 -3
- package/dist/context/context-ssr-bridge.js +2 -2
- package/dist/context/context-ssr-bridge.js.map +4 -3
- package/dist/context/create-context.js +2 -2
- package/dist/context/create-context.js.map +4 -3
- package/dist/context/decorators/consume-context.d.ts +5 -2
- package/dist/context/decorators/consume-context.js +2 -2
- package/dist/context/decorators/consume-context.js.map +13 -3
- package/dist/context/decorators/context-selection-delivery.d.ts +1 -1
- package/dist/context/decorators/context-selection-delivery.js +2 -2
- package/dist/context/decorators/context-selection-delivery.js.map +5 -3
- package/dist/context/decorators/context-selector.d.ts +6 -6
- package/dist/context/decorators/context-selector.js +2 -2
- package/dist/context/decorators/context-selector.js.map +15 -3
- package/dist/context/decorators/legacy/consume-context.d.ts +2 -2
- package/dist/context/decorators/legacy/consume-context.js +2 -2
- package/dist/context/decorators/legacy/consume-context.js.map +10 -3
- package/dist/context/decorators/legacy/context-selector-field.d.ts +2 -2
- package/dist/context/decorators/legacy/context-selector-field.js +2 -2
- package/dist/context/decorators/legacy/context-selector-field.js.map +11 -3
- package/dist/context/decorators/legacy/context-selector.d.ts +2 -2
- package/dist/context/decorators/legacy/context-selector.js +2 -2
- package/dist/context/decorators/legacy/context-selector.js.map +11 -3
- package/dist/context/decorators/legacy/provide-context.d.ts +2 -2
- package/dist/context/decorators/legacy/provide-context.js +2 -2
- package/dist/context/decorators/legacy/provide-context.js.map +11 -3
- package/dist/context/decorators/on-context-update.d.ts +5 -5
- package/dist/context/decorators/on-context-update.js +2 -2
- package/dist/context/decorators/on-context-update.js.map +14 -3
- package/dist/context/decorators/provide-context.d.ts +5 -2
- package/dist/context/decorators/provide-context.js +2 -2
- package/dist/context/decorators/provide-context.js.map +14 -3
- package/dist/context/decorators/standard/consume-context.d.ts +2 -2
- package/dist/context/decorators/standard/consume-context.js +2 -2
- package/dist/context/decorators/standard/consume-context.js.map +9 -3
- package/dist/context/decorators/standard/context-selector-field.d.ts +2 -2
- package/dist/context/decorators/standard/context-selector-field.js +2 -2
- package/dist/context/decorators/standard/context-selector-field.js.map +10 -3
- package/dist/context/decorators/standard/context-selector.d.ts +2 -3
- package/dist/context/decorators/standard/context-selector.js +2 -2
- package/dist/context/decorators/standard/context-selector.js.map +10 -3
- package/dist/context/decorators/standard/provide-context.d.ts +2 -2
- package/dist/context/decorators/standard/provide-context.js +2 -2
- package/dist/context/decorators/standard/provide-context.js.map +10 -3
- package/dist/context/events.d.ts +18 -11
- package/dist/context/events.js +2 -2
- package/dist/context/events.js.map +4 -3
- package/dist/context/hydration-script.js +2 -2
- package/dist/context/hydration-script.js.map +6 -3
- package/dist/context/index.d.ts +8 -0
- package/dist/context/index.js +3 -0
- package/dist/context/index.js.map +35 -0
- package/dist/controller-registry.d.ts +28 -0
- package/dist/controller-registry.js +3 -0
- package/dist/controller-registry.js.map +11 -0
- package/dist/core/controller-metadata.d.ts +3 -0
- package/dist/core/controller-metadata.js +3 -0
- package/dist/core/controller-metadata.js.map +10 -0
- package/dist/core/custom-element-metadata.d.ts +11 -0
- package/dist/core/custom-element-metadata.js +2 -2
- package/dist/core/custom-element-metadata.js.map +4 -3
- package/dist/core/hydration-codec.d.ts +8 -1
- package/dist/core/hydration-codec.js +2 -2
- package/dist/core/hydration-codec.js.map +5 -3
- package/dist/core/radiant-component-ssr-registry.d.ts +13 -13
- package/dist/core/radiant-component-ssr-registry.js +2 -2
- package/dist/core/radiant-component-ssr-registry.js.map +4 -3
- package/dist/core/radiant-component-ssr.d.ts +3 -3
- package/dist/core/radiant-component-ssr.js +2 -2
- package/dist/core/radiant-component-ssr.js.map +8 -3
- package/dist/core/radiant-controller.d.ts +127 -0
- package/dist/core/radiant-controller.js +3 -0
- package/dist/core/radiant-controller.js.map +13 -0
- package/dist/core/radiant-element.d.ts +43 -41
- package/dist/core/radiant-element.js +2 -2
- package/dist/core/radiant-element.js.map +13 -3
- package/dist/core/radiant-hydrator-state.d.ts +1 -1
- package/dist/core/radiant-hydrator-state.js +2 -2
- package/dist/core/radiant-hydrator-state.js.map +4 -3
- package/dist/core/reactive-host.d.ts +137 -0
- package/dist/core/reactive-host.js +3 -0
- package/dist/core/reactive-host.js.map +10 -0
- package/dist/core/reactive-jsx-value.js +2 -2
- package/dist/core/reactive-jsx-value.js.map +4 -3
- package/dist/core/reactive-prop-metadata.js +2 -2
- package/dist/core/reactive-prop-metadata.js.map +4 -3
- package/dist/core/slot-projection-runtime.js +2 -2
- package/dist/core/slot-projection-runtime.js.map +6 -3
- package/dist/core/ssr-preparation.js +2 -2
- package/dist/core/ssr-preparation.js.map +4 -3
- package/dist/decorators/attr.d.ts +6 -0
- package/dist/decorators/attr.js +3 -0
- package/dist/decorators/attr.js.map +16 -0
- package/dist/decorators/bound.d.ts +4 -2
- package/dist/decorators/bound.js +2 -2
- package/dist/decorators/bound.js.map +7 -3
- package/dist/decorators/bridge.d.ts +11 -7
- package/dist/decorators/bridge.js +2 -2
- package/dist/decorators/bridge.js.map +4 -3
- package/dist/decorators/controller.d.ts +2 -0
- package/dist/decorators/controller.js +3 -0
- package/dist/decorators/controller.js.map +12 -0
- package/dist/decorators/custom-element.d.ts +4 -2
- package/dist/decorators/custom-element.js +2 -2
- package/dist/decorators/custom-element.js.map +7 -3
- package/dist/decorators/debounce.d.ts +5 -2
- package/dist/decorators/debounce.js +2 -2
- package/dist/decorators/debounce.js.map +8 -3
- package/dist/decorators/event.d.ts +5 -2
- package/dist/decorators/event.js +2 -2
- package/dist/decorators/event.js.map +10 -3
- package/dist/decorators/legacy/attr.d.ts +2 -0
- package/dist/decorators/legacy/attr.js +3 -0
- package/dist/decorators/legacy/attr.js.map +13 -0
- package/dist/decorators/legacy/bound.js +2 -2
- package/dist/decorators/legacy/bound.js.map +4 -3
- package/dist/decorators/legacy/custom-element.js +2 -2
- package/dist/decorators/legacy/custom-element.js.map +5 -3
- package/dist/decorators/legacy/debounce.js +2 -2
- package/dist/decorators/legacy/debounce.js.map +5 -3
- package/dist/decorators/legacy/event.js +2 -2
- package/dist/decorators/legacy/event.js.map +7 -3
- package/dist/decorators/legacy/instance-initializers.d.ts +3 -4
- package/dist/decorators/legacy/instance-initializers.js +2 -2
- package/dist/decorators/legacy/instance-initializers.js.map +4 -3
- package/dist/decorators/legacy/on-event.d.ts +2 -2
- package/dist/decorators/legacy/on-event.js +2 -2
- package/dist/decorators/legacy/on-event.js.map +6 -3
- package/dist/decorators/legacy/on-updated.d.ts +7 -2
- package/dist/decorators/legacy/on-updated.js +2 -2
- package/dist/decorators/legacy/on-updated.js.map +5 -3
- package/dist/decorators/legacy/query-slot.js +2 -2
- package/dist/decorators/legacy/query-slot.js.map +7 -3
- package/dist/decorators/legacy/query.d.ts +7 -2
- package/dist/decorators/legacy/query.js +2 -2
- package/dist/decorators/legacy/query.js.map +6 -3
- package/dist/decorators/legacy/reactive-field.d.ts +2 -2
- package/dist/decorators/legacy/reactive-field.js +2 -2
- package/dist/decorators/legacy/reactive-field.js.map +5 -3
- package/dist/decorators/legacy/reactive-prop.d.ts +10 -16
- package/dist/decorators/legacy/reactive-prop.js +2 -2
- package/dist/decorators/legacy/reactive-prop.js.map +7 -3
- package/dist/decorators/legacy/signal.d.ts +4 -3
- package/dist/decorators/legacy/signal.js +2 -2
- package/dist/decorators/legacy/signal.js.map +9 -3
- package/dist/decorators/on-event.d.ts +6 -3
- package/dist/decorators/on-event.js +2 -2
- package/dist/decorators/on-event.js.map +9 -3
- package/dist/decorators/on-updated.d.ts +12 -2
- package/dist/decorators/on-updated.js +2 -2
- package/dist/decorators/on-updated.js.map +8 -3
- package/dist/decorators/prop.d.ts +19 -7
- package/dist/decorators/prop.js +2 -2
- package/dist/decorators/prop.js.map +10 -3
- package/dist/decorators/query-slot.d.ts +11 -3
- package/dist/decorators/query-slot.js +2 -2
- package/dist/decorators/query-slot.js.map +10 -3
- package/dist/decorators/query.d.ts +9 -2
- package/dist/decorators/query.js +2 -2
- package/dist/decorators/query.js.map +9 -3
- package/dist/decorators/shared/reactive-attr.d.ts +25 -0
- package/dist/decorators/shared/reactive-attr.js +3 -0
- package/dist/decorators/shared/reactive-attr.js.map +11 -0
- package/dist/decorators/signal.d.ts +10 -4
- package/dist/decorators/signal.js +2 -2
- package/dist/decorators/signal.js.map +11 -3
- package/dist/decorators/standard/attr.d.ts +2 -0
- package/dist/decorators/standard/attr.js +3 -0
- package/dist/decorators/standard/attr.js.map +12 -0
- package/dist/decorators/standard/bound.js +2 -2
- package/dist/decorators/standard/bound.js.map +4 -3
- package/dist/decorators/standard/custom-element.js +2 -2
- package/dist/decorators/standard/custom-element.js.map +5 -3
- package/dist/decorators/standard/debounce.js +2 -2
- package/dist/decorators/standard/debounce.js.map +5 -3
- package/dist/decorators/standard/event.js +2 -2
- package/dist/decorators/standard/event.js.map +6 -3
- package/dist/decorators/standard/on-event.d.ts +2 -1
- package/dist/decorators/standard/on-event.js +2 -2
- package/dist/decorators/standard/on-event.js.map +5 -3
- package/dist/decorators/standard/on-updated.d.ts +5 -1
- package/dist/decorators/standard/on-updated.js +2 -2
- package/dist/decorators/standard/on-updated.js.map +4 -3
- package/dist/decorators/standard/query-slot.d.ts +1 -1
- package/dist/decorators/standard/query-slot.js +2 -2
- package/dist/decorators/standard/query-slot.js.map +5 -3
- package/dist/decorators/standard/query.d.ts +2 -1
- package/dist/decorators/standard/query.js +2 -2
- package/dist/decorators/standard/query.js.map +5 -3
- package/dist/decorators/standard/reactive-field.d.ts +2 -2
- package/dist/decorators/standard/reactive-field.js +2 -2
- package/dist/decorators/standard/reactive-field.js.map +4 -3
- package/dist/decorators/standard/reactive-prop.d.ts +13 -2
- package/dist/decorators/standard/reactive-prop.js +2 -2
- package/dist/decorators/standard/reactive-prop.js.map +6 -3
- package/dist/decorators/standard/signal.d.ts +4 -3
- package/dist/decorators/standard/signal.js +2 -2
- package/dist/decorators/standard/signal.js.map +8 -3
- package/dist/decorators/state.d.ts +6 -5
- package/dist/decorators/state.js +2 -2
- package/dist/decorators/state.js.map +8 -3
- package/dist/helpers/create-event-listener.d.ts +11 -2
- package/dist/helpers/create-event-listener.js +2 -2
- package/dist/helpers/create-event-listener.js.map +4 -3
- package/dist/helpers/create-event.js +2 -2
- package/dist/helpers/create-event.js.map +5 -3
- package/dist/helpers/create-query-slot.js +2 -2
- package/dist/helpers/create-query-slot.js.map +4 -3
- package/dist/helpers/create-query.d.ts +14 -3
- package/dist/helpers/create-query.js +2 -2
- package/dist/helpers/create-query.js.map +4 -3
- package/dist/helpers/debounce.js +2 -2
- package/dist/helpers/debounce.js.map +4 -3
- package/dist/helpers/index.js +2 -2
- package/dist/helpers/index.js.map +9 -3
- package/dist/index.d.ts +4 -14
- package/dist/index.js +2 -2
- package/dist/index.js.map +60 -3
- package/dist/server/context-ssr.js +2 -2
- package/dist/server/context-ssr.js.map +5 -3
- package/dist/server/html-parser.js +2 -2
- package/dist/server/html-parser.js.map +4 -3
- package/dist/server/install-light-dom-shim.js +2 -2
- package/dist/server/install-light-dom-shim.js.map +5 -3
- package/dist/server/light-dom-shim.js +2 -2
- package/dist/server/light-dom-shim.js.map +5 -3
- package/dist/server/project-root.js +2 -2
- package/dist/server/project-root.js.map +2 -2
- package/dist/server/radiant-component-ssr-runtime.d.ts +2 -2
- package/dist/server/radiant-component-ssr-runtime.js +2 -2
- package/dist/server/radiant-component-ssr-runtime.js.map +11 -3
- package/dist/server/render-component.d.ts +3 -13
- package/dist/server/render-component.js +2 -2
- package/dist/server/render-component.js.map +14 -4
- package/dist/server/render-controller.d.ts +57 -0
- package/dist/server/render-controller.js +3 -0
- package/dist/server/render-controller.js.map +23 -0
- package/dist/server/slot-projection-html.js +2 -2
- package/dist/server/slot-projection-html.js.map +7 -3
- package/dist/signals/host-resource.js +2 -2
- package/dist/signals/host-resource.js.map +2 -2
- package/dist/signals/host-signal.d.ts +4 -2
- package/dist/signals/host-signal.js +2 -2
- package/dist/signals/host-signal.js.map +7 -3
- package/dist/signals/hydration-script.js +2 -2
- package/dist/signals/hydration-script.js.map +6 -3
- package/dist/tools/escape-script-json.js +2 -2
- package/dist/tools/escape-script-json.js.map +4 -3
- package/dist/tools/event-emitter.js +2 -2
- package/dist/tools/event-emitter.js.map +4 -3
- package/dist/tools/index.js +2 -2
- package/dist/tools/index.js.map +7 -3
- package/dist/tools/render-jsx-template.js +2 -2
- package/dist/tools/render-jsx-template.js.map +4 -3
- package/dist/tools/stringify-typed.js +2 -2
- package/dist/tools/stringify-typed.js.map +4 -3
- package/dist/types.js +2 -2
- package/dist/types.js.map +2 -2
- package/dist/utils/attribute-utils.js +2 -2
- package/dist/utils/attribute-utils.js.map +4 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +4 -3
- package/package.json +26 -5
- package/size-budget.json +11 -2
- package/dist/chunk-0bswvy25.js +0 -4
- package/dist/chunk-0bswvy25.js.map +0 -10
- package/dist/chunk-0btkzzyc.js +0 -4
- package/dist/chunk-0btkzzyc.js.map +0 -10
- package/dist/chunk-0g0j9re6.js +0 -4
- package/dist/chunk-0g0j9re6.js.map +0 -10
- package/dist/chunk-1x26p09c.js +0 -4
- package/dist/chunk-1x26p09c.js.map +0 -10
- package/dist/chunk-21a7jask.js +0 -4
- package/dist/chunk-21a7jask.js.map +0 -10
- package/dist/chunk-21acj2eq.js +0 -4
- package/dist/chunk-21acj2eq.js.map +0 -10
- package/dist/chunk-25zjh0kg.js +0 -4
- package/dist/chunk-25zjh0kg.js.map +0 -10
- package/dist/chunk-30x4hggg.js +0 -4
- package/dist/chunk-30x4hggg.js.map +0 -10
- package/dist/chunk-3ynk7e1e.js +0 -4
- package/dist/chunk-3ynk7e1e.js.map +0 -10
- package/dist/chunk-5b1en9vz.js +0 -4
- package/dist/chunk-5b1en9vz.js.map +0 -10
- package/dist/chunk-5bkat72n.js +0 -4
- package/dist/chunk-5bkat72n.js.map +0 -10
- package/dist/chunk-5qeaq3tj.js +0 -4
- package/dist/chunk-5qeaq3tj.js.map +0 -10
- package/dist/chunk-66e6s792.js +0 -4
- package/dist/chunk-66e6s792.js.map +0 -10
- package/dist/chunk-79jg8q67.js +0 -4
- package/dist/chunk-79jg8q67.js.map +0 -10
- package/dist/chunk-8d5ddvvf.js +0 -4
- package/dist/chunk-8d5ddvvf.js.map +0 -10
- package/dist/chunk-8e9fgtbn.js +0 -4
- package/dist/chunk-8e9fgtbn.js.map +0 -10
- package/dist/chunk-9mqtp3js.js +0 -4
- package/dist/chunk-9mqtp3js.js.map +0 -10
- package/dist/chunk-9rj2rwes.js +0 -4
- package/dist/chunk-9rj2rwes.js.map +0 -10
- package/dist/chunk-atms6yrh.js +0 -4
- package/dist/chunk-atms6yrh.js.map +0 -10
- package/dist/chunk-bk2nbmcd.js +0 -4
- package/dist/chunk-bk2nbmcd.js.map +0 -10
- package/dist/chunk-bk6qkvfp.js +0 -4
- package/dist/chunk-bk6qkvfp.js.map +0 -10
- package/dist/chunk-c0qyz98c.js +0 -4
- package/dist/chunk-c0qyz98c.js.map +0 -10
- package/dist/chunk-c52qhh0j.js +0 -4
- package/dist/chunk-c52qhh0j.js.map +0 -10
- package/dist/chunk-cnyxrh9r.js +0 -4
- package/dist/chunk-cnyxrh9r.js.map +0 -10
- package/dist/chunk-cvz9mrxa.js +0 -4
- package/dist/chunk-cvz9mrxa.js.map +0 -10
- package/dist/chunk-dabagjk6.js +0 -4
- package/dist/chunk-dabagjk6.js.map +0 -10
- package/dist/chunk-e0r6ca2g.js +0 -4
- package/dist/chunk-e0r6ca2g.js.map +0 -10
- package/dist/chunk-e5jd9h6t.js +0 -4
- package/dist/chunk-e5jd9h6t.js.map +0 -10
- package/dist/chunk-eevw1j2q.js +0 -4
- package/dist/chunk-eevw1j2q.js.map +0 -10
- package/dist/chunk-ek664x1c.js +0 -4
- package/dist/chunk-ek664x1c.js.map +0 -10
- package/dist/chunk-eyw14d6y.js +0 -4
- package/dist/chunk-eyw14d6y.js.map +0 -10
- package/dist/chunk-fs4j94bk.js +0 -4
- package/dist/chunk-fs4j94bk.js.map +0 -10
- package/dist/chunk-g2z3mm6b.js +0 -4
- package/dist/chunk-g2z3mm6b.js.map +0 -10
- package/dist/chunk-g5n3m11h.js +0 -4
- package/dist/chunk-g5n3m11h.js.map +0 -10
- package/dist/chunk-gdkte2vd.js +0 -4
- package/dist/chunk-gdkte2vd.js.map +0 -10
- package/dist/chunk-gg74gdpv.js +0 -4
- package/dist/chunk-gg74gdpv.js.map +0 -10
- package/dist/chunk-gpv1n74a.js +0 -4
- package/dist/chunk-gpv1n74a.js.map +0 -10
- package/dist/chunk-h9k7crjc.js +0 -4
- package/dist/chunk-h9k7crjc.js.map +0 -10
- package/dist/chunk-hpzgnxgq.js +0 -4
- package/dist/chunk-hpzgnxgq.js.map +0 -10
- package/dist/chunk-hrjc8b1y.js +0 -4
- package/dist/chunk-hrjc8b1y.js.map +0 -10
- package/dist/chunk-hvy4zvcc.js +0 -4
- package/dist/chunk-hvy4zvcc.js.map +0 -10
- package/dist/chunk-hztr86b4.js +0 -4
- package/dist/chunk-hztr86b4.js.map +0 -10
- package/dist/chunk-j3v7rca5.js +0 -4
- package/dist/chunk-j3v7rca5.js.map +0 -10
- package/dist/chunk-j864sv4w.js +0 -4
- package/dist/chunk-j864sv4w.js.map +0 -10
- package/dist/chunk-jkb2y7c8.js +0 -4
- package/dist/chunk-jkb2y7c8.js.map +0 -10
- package/dist/chunk-kakpjgzf.js +0 -4
- package/dist/chunk-kakpjgzf.js.map +0 -10
- package/dist/chunk-kmebacvv.js +0 -4
- package/dist/chunk-kmebacvv.js.map +0 -10
- package/dist/chunk-knqsm6v3.js +0 -4
- package/dist/chunk-knqsm6v3.js.map +0 -10
- package/dist/chunk-mp2vtrkg.js +0 -4
- package/dist/chunk-mp2vtrkg.js.map +0 -10
- package/dist/chunk-mpsj3cjs.js +0 -4
- package/dist/chunk-mpsj3cjs.js.map +0 -10
- package/dist/chunk-n4p2542b.js +0 -4
- package/dist/chunk-n4p2542b.js.map +0 -10
- package/dist/chunk-nctznxyz.js +0 -4
- package/dist/chunk-nctznxyz.js.map +0 -10
- package/dist/chunk-ndw3hc3v.js +0 -4
- package/dist/chunk-ndw3hc3v.js.map +0 -10
- package/dist/chunk-nnnb6pac.js +0 -4
- package/dist/chunk-nnnb6pac.js.map +0 -10
- package/dist/chunk-nssj2x13.js +0 -4
- package/dist/chunk-nssj2x13.js.map +0 -10
- package/dist/chunk-nvr37vma.js +0 -4
- package/dist/chunk-nvr37vma.js.map +0 -10
- package/dist/chunk-p8k4g99a.js +0 -4
- package/dist/chunk-p8k4g99a.js.map +0 -10
- package/dist/chunk-pkszgjqf.js +0 -4
- package/dist/chunk-pkszgjqf.js.map +0 -10
- package/dist/chunk-q9z6tnzw.js +0 -4
- package/dist/chunk-q9z6tnzw.js.map +0 -10
- package/dist/chunk-qdz5sncz.js +0 -4
- package/dist/chunk-qdz5sncz.js.map +0 -10
- package/dist/chunk-qe0eww1n.js +0 -4
- package/dist/chunk-qe0eww1n.js.map +0 -10
- package/dist/chunk-r33zvvda.js +0 -4
- package/dist/chunk-r33zvvda.js.map +0 -10
- package/dist/chunk-rkh1vkb9.js +0 -4
- package/dist/chunk-rkh1vkb9.js.map +0 -10
- package/dist/chunk-rrg759ht.js +0 -4
- package/dist/chunk-rrg759ht.js.map +0 -10
- package/dist/chunk-s09s5ayx.js +0 -4
- package/dist/chunk-s09s5ayx.js.map +0 -10
- package/dist/chunk-sf4a2gy5.js +0 -4
- package/dist/chunk-sf4a2gy5.js.map +0 -10
- package/dist/chunk-ssnnxzrj.js +0 -4
- package/dist/chunk-ssnnxzrj.js.map +0 -10
- package/dist/chunk-t8xtvgyg.js +0 -4
- package/dist/chunk-t8xtvgyg.js.map +0 -10
- package/dist/chunk-v3ta7hnv.js +0 -4
- package/dist/chunk-v3ta7hnv.js.map +0 -10
- package/dist/chunk-v92hp9g0.js +0 -4
- package/dist/chunk-v92hp9g0.js.map +0 -10
- package/dist/chunk-vgtggzb6.js +0 -4
- package/dist/chunk-vgtggzb6.js.map +0 -9
- package/dist/chunk-vk48hgm4.js +0 -4
- package/dist/chunk-vk48hgm4.js.map +0 -10
- package/dist/chunk-w8s5fnsq.js +0 -4
- package/dist/chunk-w8s5fnsq.js.map +0 -10
- package/dist/chunk-wd23rn4q.js +0 -4
- package/dist/chunk-wd23rn4q.js.map +0 -10
- package/dist/chunk-wds4href.js +0 -4
- package/dist/chunk-wds4href.js.map +0 -10
- package/dist/chunk-wvd1ffe4.js +0 -4
- package/dist/chunk-wvd1ffe4.js.map +0 -10
- package/dist/chunk-wwbjz9k4.js +0 -4
- package/dist/chunk-wwbjz9k4.js.map +0 -10
- package/dist/chunk-x2k0ngpz.js +0 -4
- package/dist/chunk-x2k0ngpz.js.map +0 -10
- package/dist/chunk-x457d0ap.js +0 -4
- package/dist/chunk-x457d0ap.js.map +0 -10
- package/dist/chunk-xbhtzkre.js +0 -4
- package/dist/chunk-xbhtzkre.js.map +0 -10
- package/dist/chunk-y139ycfm.js +0 -4
- package/dist/chunk-y139ycfm.js.map +0 -10
- package/dist/chunk-z9kxfckm.js +0 -4
- package/dist/chunk-z9kxfckm.js.map +0 -10
- package/dist/chunk-zx5txex8.js +0 -4
- package/dist/chunk-zx5txex8.js.map +0 -10
- package/dist/chunk-zygdebw8.js +0 -4
- package/dist/chunk-zygdebw8.js.map +0 -10
- package/dist/core/radiant-component.d.ts +0 -113
- package/dist/core/radiant-component.js +0 -3
- package/dist/core/radiant-component.js.map +0 -9
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/core/controller-metadata.ts", "../src/controller-registry.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"export const CONTROLLER_IDENTIFIER = Symbol.for('@ecopages/radiant.controllerIdentifier');\n\ntype ControllerConstructorWithMetadata = CustomElementConstructor & {\n\t[CONTROLLER_IDENTIFIER]?: string;\n};\n\nexport function setControllerIdentifier(target: CustomElementConstructor, identifier: string): void {\n\t(target as ControllerConstructorWithMetadata)[CONTROLLER_IDENTIFIER] = identifier;\n}\n\nexport function getControllerIdentifier(target: CustomElementConstructor): string | undefined {\n\treturn (target as ControllerConstructorWithMetadata)[CONTROLLER_IDENTIFIER];\n}\n",
|
|
6
|
+
"import type { RadiantController } from './core/radiant-controller';\nimport { setControllerIdentifier } from './core/controller-metadata';\n\nexport const CONTROLLER_ATTRIBUTE = 'data-controller';\n\nexport type ControllerConstructor<TController extends RadiantController = RadiantController> = new (\n\thost: Element,\n) => TController;\n\nexport type ControllerRegistrationStrategy = 'keep-current' | 'replace';\n\ntype ControllerRegistryGlobalState = {\n\tactiveRuntimes: Set<ControllerRegistryRuntime>;\n\tcontrollerRegistrationStrategy: ControllerRegistrationStrategy;\n\tcontrollerRegistry: Map<string, ControllerConstructor>;\n};\n\nconst CONTROLLER_REGISTRY_STATE_KEY = Symbol.for('@ecopages/radiant.controller-registry-state');\n\nfunction getControllerRegistryGlobalState(): ControllerRegistryGlobalState {\n\tconst globalScope = globalThis as typeof globalThis & Record<PropertyKey, unknown>;\n\tconst existingState = globalScope[CONTROLLER_REGISTRY_STATE_KEY];\n\n\tif (existingState) {\n\t\treturn existingState as ControllerRegistryGlobalState;\n\t}\n\n\tconst nextState: ControllerRegistryGlobalState = {\n\t\tactiveRuntimes: new Set<ControllerRegistryRuntime>(),\n\t\tcontrollerRegistrationStrategy: 'keep-current',\n\t\tcontrollerRegistry: new Map<string, ControllerConstructor>(),\n\t};\n\n\tglobalScope[CONTROLLER_REGISTRY_STATE_KEY] = nextState;\n\n\treturn nextState;\n}\n\nconst controllerRegistryState = getControllerRegistryGlobalState();\nconst controllerRegistry = controllerRegistryState.controllerRegistry;\nconst activeRuntimes = controllerRegistryState.activeRuntimes;\n\nfunction parseControllerIdentifiers(element: Element): string[] {\n\tconst value = element.getAttribute(CONTROLLER_ATTRIBUTE);\n\n\tif (!value) {\n\t\treturn [];\n\t}\n\n\treturn value\n\t\t.split(/\\s+/)\n\t\t.map((identifier) => identifier.trim())\n\t\t.filter((identifier) => identifier.length > 0);\n}\n\nfunction visitControllerElements(root: ParentNode, visit: (element: Element) => void): void {\n\tif (root instanceof Element && root.hasAttribute(CONTROLLER_ATTRIBUTE)) {\n\t\tvisit(root);\n\t}\n\n\tfor (const element of Array.from(root.querySelectorAll(`[${CONTROLLER_ATTRIBUTE}]`))) {\n\t\tvisit(element);\n\t}\n}\n\nexport class ControllerRegistryRuntime {\n\tprivate readonly controllersByElement = new Map<Element, Map<string, RadiantController>>();\n\tprivate observer?: MutationObserver;\n\tprivate stopped = false;\n\n\tconstructor(private readonly root: ParentNode = document) {\n\t\tthis.start();\n\t}\n\n\tpublic stop(): void {\n\t\tif (this.stopped) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.stopped = true;\n\t\tthis.observer?.disconnect();\n\t\tthis.observer = undefined;\n\n\t\tfor (const [element, controllers] of this.controllersByElement) {\n\t\t\tfor (const [identifier] of controllers) {\n\t\t\t\tthis.disconnectController(element, identifier);\n\t\t\t}\n\t\t}\n\n\t\tactiveRuntimes.delete(this);\n\t}\n\n\tpublic reconcileRegisteredController(identifier: string): void {\n\t\tvisitControllerElements(this.root, (element) => {\n\t\t\tif (!parseControllerIdentifiers(element).includes(identifier)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.connectController(element, identifier);\n\t\t});\n\t}\n\n\tpublic replaceRegisteredController(identifier: string): void {\n\t\tfor (const [element, controllers] of Array.from(this.controllersByElement.entries())) {\n\t\t\tif (!controllers.has(identifier)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.disconnectController(element, identifier);\n\t\t}\n\n\t\tthis.reconcileRegisteredController(identifier);\n\t}\n\n\tprivate start(): void {\n\t\tvisitControllerElements(this.root, (element) => {\n\t\t\tthis.reconcileElement(element);\n\t\t});\n\n\t\tif (typeof MutationObserver === 'undefined') {\n\t\t\tactiveRuntimes.add(this);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.observer = new MutationObserver((records) => {\n\t\t\tfor (const record of records) {\n\t\t\t\tif (record.type === 'attributes' && record.target instanceof Element) {\n\t\t\t\t\tthis.reconcileElement(record.target);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfor (const removedNode of Array.from(record.removedNodes)) {\n\t\t\t\t\tif (!(removedNode instanceof Element)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tvisitControllerElements(removedNode, (element) => {\n\t\t\t\t\t\tthis.disconnectElementControllers(element);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const addedNode of Array.from(record.addedNodes)) {\n\t\t\t\t\tif (!(addedNode instanceof Element)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tvisitControllerElements(addedNode, (element) => {\n\t\t\t\t\t\tthis.reconcileElement(element);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst observerRoot = this.root instanceof Document ? this.root.documentElement : this.root;\n\n\t\tthis.observer.observe(observerRoot, {\n\t\t\tattributeFilter: [CONTROLLER_ATTRIBUTE],\n\t\t\tattributes: true,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t});\n\n\t\tactiveRuntimes.add(this);\n\t}\n\n\tprivate reconcileElement(element: Element): void {\n\t\tconst nextIdentifiers = new Set(parseControllerIdentifiers(element));\n\t\tconst currentControllers = this.controllersByElement.get(element);\n\n\t\tif (currentControllers) {\n\t\t\tfor (const identifier of currentControllers.keys()) {\n\t\t\t\tif (!nextIdentifiers.has(identifier)) {\n\t\t\t\t\tthis.disconnectController(element, identifier);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const identifier of nextIdentifiers) {\n\t\t\tthis.connectController(element, identifier);\n\t\t}\n\t}\n\n\tprivate connectController(element: Element, identifier: string): void {\n\t\tconst controllerConstructor = controllerRegistry.get(identifier);\n\n\t\tif (!controllerConstructor) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet controllers = this.controllersByElement.get(element);\n\n\t\tif (!controllers) {\n\t\t\tcontrollers = new Map();\n\t\t\tthis.controllersByElement.set(element, controllers);\n\t\t}\n\n\t\tif (controllers.has(identifier)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst controller = new controllerConstructor(element);\n\t\tcontrollers.set(identifier, controller);\n\t\tcontroller.connect();\n\t}\n\n\tprivate disconnectController(element: Element, identifier: string): void {\n\t\tconst controllers = this.controllersByElement.get(element);\n\n\t\tif (!controllers) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst controller = controllers.get(identifier);\n\n\t\tif (!controller) {\n\t\t\treturn;\n\t\t}\n\n\t\tcontroller.disconnect();\n\t\tcontrollers.delete(identifier);\n\n\t\tif (controllers.size === 0) {\n\t\t\tthis.controllersByElement.delete(element);\n\t\t}\n\t}\n\n\tprivate disconnectElementControllers(element: Element): void {\n\t\tconst controllers = this.controllersByElement.get(element);\n\n\t\tif (!controllers) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const identifier of Array.from(controllers.keys())) {\n\t\t\tthis.disconnectController(element, identifier);\n\t\t}\n\t}\n}\n\nexport function registerController<\n\tTController extends RadiantController,\n\tTConstructor extends ControllerConstructor<TController>,\n>(identifier: string, controller: TConstructor): TConstructor {\n\tconst existingController = controllerRegistry.get(identifier);\n\n\tif (existingController) {\n\t\treturn existingController as TConstructor;\n\t}\n\n\tsetControllerIdentifier(controller as unknown as CustomElementConstructor, identifier);\n\tcontrollerRegistry.set(identifier, controller);\n\n\tfor (const runtime of Array.from(activeRuntimes)) {\n\t\truntime.reconcileRegisteredController(identifier);\n\t}\n\n\treturn controller;\n}\n\nexport function hasRegisteredController(identifier: string): boolean {\n\treturn controllerRegistry.has(identifier);\n}\n\nexport function replaceController<\n\tTController extends RadiantController,\n\tTConstructor extends ControllerConstructor<TController>,\n>(identifier: string, controller: TConstructor): TConstructor {\n\tconst existingController = controllerRegistry.get(identifier);\n\n\tif (existingController === controller) {\n\t\treturn controller;\n\t}\n\n\tsetControllerIdentifier(controller as unknown as CustomElementConstructor, identifier);\n\tcontrollerRegistry.set(identifier, controller);\n\n\tfor (const runtime of Array.from(activeRuntimes)) {\n\t\truntime.replaceRegisteredController(identifier);\n\t}\n\n\treturn controller;\n}\n\nexport function setControllerRegistrationStrategy(strategy: ControllerRegistrationStrategy): void {\n\tcontrollerRegistryState.controllerRegistrationStrategy = strategy;\n}\n\nexport function enableControllerReplacementForHmr(): void {\n\tsetControllerRegistrationStrategy('replace');\n}\n\nexport function disableControllerReplacementForHmr(): void {\n\tsetControllerRegistrationStrategy('keep-current');\n}\n\nexport function registerControllerWithConfiguredStrategy<\n\tTController extends RadiantController,\n\tTConstructor extends ControllerConstructor<TController>,\n>(identifier: string, controller: TConstructor): TConstructor {\n\tif (controllerRegistryState.controllerRegistrationStrategy === 'replace') {\n\t\treturn replaceController(identifier, controller);\n\t}\n\n\treturn registerController(identifier, controller);\n}\n\nexport function startControllers(root: ParentNode = document): ControllerRegistryRuntime {\n\treturn new ControllerRegistryRuntime(root);\n}\n\nexport function stopControllers(): void {\n\tfor (const runtime of Array.from(activeRuntim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mB,IAAI,EAAY,CAAU,EAE7C,QAAW,KAAW,MAAM,KAAK,CAAc,EAC9C,EAAQ,8BAA8B,CAAU,EAGjD,OAAO,EAGD,SAAS,CAAuB,CAAC,EAA6B,CACpE,OAAO,EAAmB,IAAI,CAAU,EAGlC,SAAS,CAGf,CAAC,EAAoB,EAAwC,CAG7D,GAF2B,EAAmB,IAAI,CAAU,IAEjC,EAC1B,OAAO,EAGR,EAAwB,EAAmD,CAAU,EACrF,EAAmB,IAAI,EAAY,CAAU,EAE7C,QAAW,KAAW,MAAM,KAAK,CAAc,EAC9C,EAAQ,4BAA4B,CAAU,EAG/C,OAAO,EAGD,SAAS,CAAiC,CAAC,EAAgD,CACjG,EAAwB,+BAAiC,EAGnD,SAAS,CAAiC,EAAS,CACzD,EAAkC,SAAS,EAGrC,SAAS,CAAkC,EAAS,CAC1D,EAAkC,cAAc,EAG1C,SAAS,CAGf,CAAC,EAAoB,EAAwC,CAC7D,GAAI,EAAwB,iCAAmC,UAC9D,OAAO,EAAkB,EAAY,CAAU,EAGhD,OAAO,EAAmB,EAAY,CAAU,EAG1C,SAAS,CAAgB,CAAC,EAAmB,SAAqC,CACxF,OAAO,IAAI,EAA0B,CAAI,EAGnC,SAAS,CAAe,EAAS,CACvC,QAAW,KAAW,MAAM,KAAK,CAAc,EAC9C,EAAQ,KAAK",
|
|
9
|
+
"debugId": "0DF824DAB57E9F9764756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var n=((t)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var r=Symbol.for("@ecopages/radiant.controllerIdentifier");function s(t,o){t[r]=o}function l(t){return t[r]}export{s as setControllerIdentifier,l as getControllerIdentifier,r as CONTROLLER_IDENTIFIER};
|
|
2
|
+
|
|
3
|
+
//# debugId=240DEA62DF81F58264756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/core/controller-metadata.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"export const CONTROLLER_IDENTIFIER = Symbol.for('@ecopages/radiant.controllerIdentifier');\n\ntype ControllerConstructorWithMetadata = CustomElementConstructor & {\n\t[CONTROLLER_IDENTIFIER]?: string;\n};\n\nexport function setControllerIdentifier(target: CustomElementConstructor, identifier: string): void {\n\t(target as ControllerConstructorWithMetadata)[CONTROLLER_IDENTIFIER] = identifier;\n}\n\nexport function getControllerIdentifier(target: CustomElementConstructor): string | undefined {\n\treturn (target as ControllerConstructorWithMetadata)[CONTROLLER_IDENTIFIER];\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "2PAAO,IAAM,EAAwB,OAAO,IAAI,wCAAwC,EAMjF,SAAS,CAAuB,CAAC,EAAkC,EAA0B,CAClG,EAA6C,GAAyB,EAGjE,SAAS,CAAuB,CAAC,EAAsD,CAC7F,OAAQ,EAA6C",
|
|
8
|
+
"debugId": "240DEA62DF81F58264756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
export declare const CUSTOM_ELEMENT_TAG_NAME: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* Sets the custom element tag name for a given constructor.
|
|
4
|
+
* This is used internally to associate a class with its custom element tag, which is necessary for features like hydration and SSR support.
|
|
5
|
+
* @param target The constructor of the custom element.
|
|
6
|
+
* @param tagName The tag name to associate with the custom element.
|
|
7
|
+
*/
|
|
2
8
|
export declare function setCustomElementTagName(target: CustomElementConstructor, tagName: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the custom element tag name associated with a given constructor.
|
|
11
|
+
* @param target The constructor of the custom element.
|
|
12
|
+
* @returns The tag name associated with the custom element, or `undefined` if not set.
|
|
13
|
+
*/
|
|
3
14
|
export declare function getCustomElementTagName(target: CustomElementConstructor): string | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
var x=((b)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(b,{get:(j,q)=>(typeof require<"u"?require:j)[q]}):b)(function(b){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+b+'" is not supported')});var k=Symbol.for("@ecopages/radiant.customElementTagName");function z(b,j){b[k]=j}function B(b){return b[k]}export{z as setCustomElementTagName,B as getCustomElementTagName,k as CUSTOM_ELEMENT_TAG_NAME};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=6FF28EF8DF0051FA64756E2164756E21
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/core/custom-element-metadata.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"export const CUSTOM_ELEMENT_TAG_NAME = Symbol.for('@ecopages/radiant.customElementTagName');\n\ntype CustomElementConstructorWithMetadata = CustomElementConstructor & {\n\t[CUSTOM_ELEMENT_TAG_NAME]?: string;\n};\n\n/**\n * Sets the custom element tag name for a given constructor.\n * This is used internally to associate a class with its custom element tag, which is necessary for features like hydration and SSR support.\n * @param target The constructor of the custom element.\n * @param tagName The tag name to associate with the custom element.\n */\nexport function setCustomElementTagName(target: CustomElementConstructor, tagName: string): void {\n\t(target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME] = tagName;\n}\n\n/**\n * Retrieves the custom element tag name associated with a given constructor.\n * @param target The constructor of the custom element.\n * @returns The tag name associated with the custom element, or `undefined` if not set.\n */\nexport function getCustomElementTagName(target: CustomElementConstructor): string | undefined {\n\treturn (target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME];\n}\n"
|
|
5
6
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
7
|
+
"mappings": "2PAAO,IAAM,EAA0B,OAAO,IAAI,wCAAwC,EAYnF,SAAS,CAAuB,CAAC,EAAkC,EAAuB,CAC/F,EAAgD,GAA2B,EAQtE,SAAS,CAAuB,CAAC,EAAsD,CAC7F,OAAQ,EAAgD",
|
|
8
|
+
"debugId": "6FF28EF8DF0051FA64756E2164756E21",
|
|
8
9
|
"names": []
|
|
9
10
|
}
|
|
@@ -5,6 +5,12 @@ export declare const HYDRATION_TYPE_ATTRIBUTE = "data-hydration-type";
|
|
|
5
5
|
/** Optional key that scopes a hydration payload to a specific decorated field. */
|
|
6
6
|
export declare const HYDRATION_KEY_ATTRIBUTE = "data-hydration-key";
|
|
7
7
|
export type HydrationPayloadType = 'signal' | 'context';
|
|
8
|
+
type HydrationScriptHost = {
|
|
9
|
+
children?: ArrayLike<Element> | undefined;
|
|
10
|
+
childNodes?: ArrayLike<{
|
|
11
|
+
nodeType: number;
|
|
12
|
+
}> | undefined;
|
|
13
|
+
};
|
|
8
14
|
/** Creates a `<script type="application/json">` tag for a hydration payload. */
|
|
9
15
|
export declare function createHydrationScriptTag(options: {
|
|
10
16
|
type: HydrationPayloadType;
|
|
@@ -21,4 +27,5 @@ export declare function parseHydrationPayload<T>(element: Element, fallback: T):
|
|
|
21
27
|
* When a key is provided, looks for an exact `data-hydration-key` match.
|
|
22
28
|
* Otherwise, returns the first unkeyed script matching the type.
|
|
23
29
|
*/
|
|
24
|
-
export declare function findHydrationScript(host:
|
|
30
|
+
export declare function findHydrationScript(host: HydrationScriptHost, type: HydrationPayloadType, hydrationKey?: string): Element | null;
|
|
31
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
var j=((g)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(g,{get:(u,z)=>(typeof require<"u"?require:u)[z]}):g)(function(g){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+g+'" is not supported')});function V(g){return g.replace(/&/g,"\\u0026").replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var w="data-hydration",Z="data-hydration-type",q="data-hydration-key";function P(g){let u=g.hydrationKey?` ${q}="${$(g.hydrationKey)}"`:"";return`<script type="application/json" ${w} ${Z}="${g.type}"${u}>${g.serializedValue}</script>`}function x(g){return V(g)}function C(g,u){let z=g.textContent;if(!z)return u;try{return JSON.parse(z)}catch{if(typeof console<"u")console.warn(`[@ecopages/radiant] Failed to parse hydration payload from <script ${w}>:`,z.slice(0,120));return u}}function f(g,u,z){let L=g.children;if(!L||L.length===0){let J=g.childNodes;if(!J||J.length===0)return null;for(let M=0;M<J.length;M+=1){let G=J[M];if(G.nodeType!==1)continue;let Q=G;if(X(Q,u,z))return Q}return null}for(let J=0;J<L.length;J+=1)if(X(L[J],u,z))return L[J];return null}function X(g,u,z){if(g.tagName!=="SCRIPT"||!g.hasAttribute(w)||g.getAttribute(Z)!==u)return!1;if(z!==void 0)return g.getAttribute(q)===z;return!g.hasAttribute(q)}function $(g){return g.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}export{C as parseHydrationPayload,f as findHydrationScript,x as escapeHydrationJson,P as createHydrationScriptTag,Z as HYDRATION_TYPE_ATTRIBUTE,q as HYDRATION_KEY_ATTRIBUTE,w as HYDRATION_ATTRIBUTE};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=ADF85B332FA3E82264756E2164756E21
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/tools/escape-script-json.ts", "../src/core/hydration-codec.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"/**\n * Escapes serialized JSON so it remains safe when embedded inside an HTML\n * `<script>` tag.\n */\nexport function escapeScriptJson(value: string): string {\n\treturn value\n\t\t.replace(/&/g, '\\\\u0026')\n\t\t.replace(/</g, '\\\\u003c')\n\t\t.replace(/>/g, '\\\\u003e')\n\t\t.replace(/\\u2028/g, '\\\\u2028')\n\t\t.replace(/\\u2029/g, '\\\\u2029');\n}\n",
|
|
6
|
+
"import { escapeScriptJson } from '../tools/escape-script-json';\n\n/** Attribute marker used to identify hydration payloads inside a host. */\nexport const HYDRATION_ATTRIBUTE = 'data-hydration';\n/** Discriminator that scopes a hydration payload to a specific feature. */\nexport const HYDRATION_TYPE_ATTRIBUTE = 'data-hydration-type';\n/** Optional key that scopes a hydration payload to a specific decorated field. */\nexport const HYDRATION_KEY_ATTRIBUTE = 'data-hydration-key';\n\nexport type HydrationPayloadType = 'signal' | 'context';\n\ntype HydrationScriptHost = {\n\tchildren?: ArrayLike<Element> | undefined;\n\tchildNodes?: ArrayLike<{ nodeType: number }> | undefined;\n};\n\n/** Creates a `<script type=\"application/json\">` tag for a hydration payload. */\nexport function createHydrationScriptTag(options: {\n\ttype: HydrationPayloadType;\n\thydrationKey?: string;\n\tserializedValue: string;\n}): string {\n\tconst keyAttribute = options.hydrationKey\n\t\t? ` ${HYDRATION_KEY_ATTRIBUTE}=\"${escapeHtmlAttribute(options.hydrationKey)}\"`\n\t\t: '';\n\n\treturn `<script type=\"application/json\" ${HYDRATION_ATTRIBUTE} ${HYDRATION_TYPE_ATTRIBUTE}=\"${options.type}\"${keyAttribute}>${options.serializedValue}</script>`;\n}\n\n/** Escapes serialized JSON so it remains safe inside an HTML script tag. */\nexport function escapeHydrationJson(value: string): string {\n\treturn escapeScriptJson(value);\n}\n\n/** Parses JSON from a hydration script element, returning the fallback on failure. */\nexport function parseHydrationPayload<T>(element: Element, fallback: T): T {\n\tconst textContent = element.textContent;\n\n\tif (!textContent) {\n\t\treturn fallback;\n\t}\n\n\ttry {\n\t\treturn JSON.parse(textContent) as T;\n\t} catch {\n\t\tif (typeof console !== 'undefined') {\n\t\t\tconsole.warn(\n\t\t\t\t`[@ecopages/radiant] Failed to parse hydration payload from <script ${HYDRATION_ATTRIBUTE}>:`,\n\t\t\t\ttextContent.slice(0, 120),\n\t\t\t);\n\t\t}\n\t\treturn fallback;\n\t}\n}\n\n/**\n * Finds a hydration script element inside a host by type and optional key.\n *\n * When a key is provided, looks for an exact `data-hydration-key` match.\n * Otherwise, returns the first unkeyed script matching the type.\n */\nexport function findHydrationScript(\n\thost: HydrationScriptHost,\n\ttype: HydrationPayloadType,\n\thydrationKey?: string,\n): Element | null {\n\tconst children = host.children;\n\n\tif (!children || children.length === 0) {\n\t\tconst childNodes = (host as Partial<{ childNodes: ArrayLike<{ nodeType: number }> }>).childNodes;\n\n\t\tif (!childNodes || childNodes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfor (let i = 0; i < childNodes.length; i += 1) {\n\t\t\tconst node = childNodes[i]!;\n\n\t\t\tif (node.nodeType !== 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst element = node as unknown as Element;\n\n\t\t\tif (matchesHydrationScript(element, type, hydrationKey)) {\n\t\t\t\treturn element;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfor (let i = 0; i < children.length; i += 1) {\n\t\tif (matchesHydrationScript(children[i]!, type, hydrationKey)) {\n\t\t\treturn children[i]!;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nfunction matchesHydrationScript(element: Element, type: HydrationPayloadType, hydrationKey?: string): boolean {\n\tif (\n\t\telement.tagName !== 'SCRIPT' ||\n\t\t!element.hasAttribute(HYDRATION_ATTRIBUTE) ||\n\t\telement.getAttribute(HYDRATION_TYPE_ATTRIBUTE) !== type\n\t) {\n\t\treturn false;\n\t}\n\n\tif (hydrationKey !== undefined) {\n\t\treturn element.getAttribute(HYDRATION_KEY_ATTRIBUTE) === hydrationKey;\n\t}\n\n\treturn !element.hasAttribute(HYDRATION_KEY_ATTRIBUTE);\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n\treturn value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g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zC,GAAI,EAAuB,EAAS,GAAK,EAAM,CAAY,EAC1D,OAAO,EAAS,GAIlB,OAAO,KAGR,SAAS,CAAsB,CAAC,EAAkB,EAA4B,EAAgC,CAC7G,GACC,EAAQ,UAAY,UACpB,CAAC,EAAQ,aAAa,CAAmB,GACzC,EAAQ,aAAa,CAAwB,IAAM,EAEnD,MAAO,GAGR,GAAI,IAAiB,OACpB,OAAO,EAAQ,aAAa,CAAuB,IAAM,EAG1D,MAAO,CAAC,EAAQ,aAAa,CAAuB,EAGrD,SAAS,CAAmB,CAAC,EAAuB,CACnD,OAAO,EAAM,QAAQ,KAAM,OAAO,EAAE,QAAQ,KAAM,QAAQ,EAAE,QAAQ,KAAM,MAAM,EAAE,QAAQ,KAAM,MAAM",
|
|
9
|
+
"debugId": "ADF85B332FA3E82264756E2164756E21",
|
|
8
10
|
"names": []
|
|
9
11
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import type { JsxRenderable } from '@ecopages/jsx';
|
|
2
2
|
import type { RenderToStringOptions } from '@ecopages/jsx/server';
|
|
3
3
|
/**
|
|
4
|
-
* Optional SSR hooks exposed by `
|
|
4
|
+
* Optional SSR hooks exposed by `RadiantElement` instances to the shared
|
|
5
5
|
* server runtime.
|
|
6
6
|
*
|
|
7
7
|
* The bridge lets the runtime detect whether a component is still using the
|
|
8
8
|
* inherited host SSR implementation or has taken ownership of host rendering
|
|
9
9
|
* through explicit overrides.
|
|
10
10
|
*/
|
|
11
|
-
export type
|
|
11
|
+
export type RadiantElementRenderBridge = {
|
|
12
12
|
renderHost?: () => JsxRenderable;
|
|
13
13
|
renderHostToString?: (options?: RenderToStringOptions) => string;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Runtime shape required by the shared Radiant SSR helpers.
|
|
17
17
|
*
|
|
18
|
-
* This is intentionally narrower than `
|
|
18
|
+
* This is intentionally narrower than `RadiantElement` itself so the server
|
|
19
19
|
* runtime can stay decoupled from the full client base-class implementation.
|
|
20
20
|
*/
|
|
21
|
-
export type
|
|
22
|
-
resolveSsrRenderBridge?: () =>
|
|
21
|
+
export type RadiantElementSsrCapable = HTMLElement & {
|
|
22
|
+
resolveSsrRenderBridge?: () => RadiantElementRenderBridge;
|
|
23
23
|
getHostSsrAttributes?: () => Record<string, string>;
|
|
24
24
|
renderToString(options?: RenderToStringOptions): string;
|
|
25
25
|
renderHost?(): JsxRenderable;
|
|
@@ -32,23 +32,23 @@ export type RadiantComponentSsrCapable = HTMLElement & {
|
|
|
32
32
|
* and nested JSX custom-element SSR can reuse without importing client-only
|
|
33
33
|
* internals into every call site.
|
|
34
34
|
*/
|
|
35
|
-
export type
|
|
36
|
-
getHostAttributes(component:
|
|
37
|
-
renderHost(component:
|
|
38
|
-
renderHostToString(component:
|
|
39
|
-
resolveRenderBridge(component:
|
|
40
|
-
renderView(component:
|
|
35
|
+
export type RadiantElementSsrRuntime = {
|
|
36
|
+
getHostAttributes(component: RadiantElementSsrCapable): Record<string, string>;
|
|
37
|
+
renderHost(component: RadiantElementSsrCapable): JsxRenderable;
|
|
38
|
+
renderHostToString(component: RadiantElementSsrCapable, options?: RenderToStringOptions): string;
|
|
39
|
+
resolveRenderBridge(component: RadiantElementSsrCapable): RadiantElementRenderBridge | undefined;
|
|
40
|
+
renderView(component: RadiantElementSsrCapable, options?: RenderToStringOptions): string;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* Reads the currently registered Radiant SSR runtime from `globalThis`.
|
|
44
44
|
*
|
|
45
45
|
* Returns `undefined` when no server entrypoint has installed the runtime yet.
|
|
46
46
|
*/
|
|
47
|
-
export declare function
|
|
47
|
+
export declare function getRadiantElementSsrRuntime(): RadiantElementSsrRuntime | undefined;
|
|
48
48
|
/**
|
|
49
49
|
* Registers the shared Radiant SSR runtime on `globalThis`.
|
|
50
50
|
*
|
|
51
51
|
* The latest registration wins, which keeps server adapters free to install
|
|
52
52
|
* the runtime eagerly from their own explicit entrypoint.
|
|
53
53
|
*/
|
|
54
|
-
export declare function
|
|
54
|
+
export declare function registerRadiantElementSsrRuntime(runtime: RadiantElementSsrRuntime): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
var f=((a)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(c,d)=>(typeof require<"u"?require:c)[d]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var b=Symbol.for("@ecopages/radiant.component-ssr-runtime");function h(){return globalThis[b]}function j(a){globalThis[b]=a}export{j as registerRadiantElementSsrRuntime,h as getRadiantElementSsrRuntime};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=7A43EF7E4BF0DC2964756E2164756E21
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/core/radiant-component-ssr-registry.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import type { JsxRenderable } from '@ecopages/jsx';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\n\n/**\n * Optional SSR hooks exposed by `RadiantElement` instances to the shared\n * server runtime.\n *\n * The bridge lets the runtime detect whether a component is still using the\n * inherited host SSR implementation or has taken ownership of host rendering\n * through explicit overrides.\n */\nexport type RadiantElementRenderBridge = {\n\trenderHost?: () => JsxRenderable;\n\trenderHostToString?: (options?: RenderToStringOptions) => string;\n};\n\n/**\n * Runtime shape required by the shared Radiant SSR helpers.\n *\n * This is intentionally narrower than `RadiantElement` itself so the server\n * runtime can stay decoupled from the full client base-class implementation.\n */\nexport type RadiantElementSsrCapable = HTMLElement & {\n\tresolveSsrRenderBridge?: () => RadiantElementRenderBridge;\n\tgetHostSsrAttributes?: () => Record<string, string>;\n\trenderToString(options?: RenderToStringOptions): string;\n\trenderHost?(): JsxRenderable;\n\trenderHostToString(options?: RenderToStringOptions): string;\n};\n\n/**\n * Shared SSR runtime contract registered on `globalThis`.\n *\n * Server entrypoints install one implementation that both direct component SSR\n * and nested JSX custom-element SSR can reuse without importing client-only\n * internals into every call site.\n */\nexport type RadiantElementSsrRuntime = {\n\tgetHostAttributes(component: RadiantElementSsrCapable): Record<string, string>;\n\trenderHost(component: RadiantElementSsrCapable): JsxRenderable;\n\trenderHostToString(component: RadiantElementSsrCapable, options?: RenderToStringOptions): string;\n\tresolveRenderBridge(component: RadiantElementSsrCapable): RadiantElementRenderBridge | undefined;\n\trenderView(component: RadiantElementSsrCapable, options?: RenderToStringOptions): string;\n};\n\nconst RADIANT_COMPONENT_SSR_RUNTIME_SYMBOL = Symbol.for('@ecopages/radiant.component-ssr-runtime');\n\ntype GlobalSsrRuntimeState = typeof globalThis & {\n\t[RADIANT_COMPONENT_SSR_RUNTIME_SYMBOL]?: RadiantElementSsrRuntime;\n};\n\n/**\n * Reads the currently registered Radiant SSR runtime from `globalThis`.\n *\n * Returns `undefined` when no server entrypoint has installed the runtime yet.\n */\nexport function getRadiantElementSsrRuntime(): RadiantElementSsrRuntime | undefined {\n\treturn (globalThis as GlobalSsrRuntimeState)[RADIANT_COMPONENT_SSR_RUNTIME_SYMBOL];\n}\n\n/**\n * Registers the shared Radiant SSR runtime on `globalThis`.\n *\n * The latest registration wins, which keeps server adapters free to install\n * the runtime eagerly from their own explicit entrypoint.\n */\nexport function registerRadiantElementSsrRuntime(runtime: RadiantElementSsrRuntime): void {\n\t(globalThis as GlobalSsrRuntimeState)[RADIANT_COMPONENT_SSR_RUNTIME_SYMBOL] = runtime;\n}\n"
|
|
5
6
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
7
|
+
"mappings": "2PA6CA,IAAM,EAAuC,OAAO,IAAI,yCAAyC,EAW1F,SAAS,CAA2B,EAAyC,CACnF,OAAQ,WAAqC,GASvC,SAAS,CAAgC,CAAC,EAAyC,CACxF,WAAqC,GAAwC",
|
|
8
|
+
"debugId": "7A43EF7E4BF0DC2964756E2164756E21",
|
|
8
9
|
"names": []
|
|
9
10
|
}
|
|
@@ -4,7 +4,7 @@ import type { SsrSerializableContextProvider } from '../context/context-provider
|
|
|
4
4
|
import type { ReactiveProperty } from './radiant-element';
|
|
5
5
|
import type { ReactivePropDefinition } from './reactive-prop-metadata';
|
|
6
6
|
import type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';
|
|
7
|
-
type
|
|
7
|
+
type RadiantElementSsrHost = {
|
|
8
8
|
constructor: CustomElementConstructor;
|
|
9
9
|
getAuthoredHydrationScriptMarkup?: () => string | undefined;
|
|
10
10
|
getContextProviders: () => SsrSerializableContextProvider[];
|
|
@@ -17,9 +17,9 @@ type RadiantComponentSsrHost = {
|
|
|
17
17
|
listAttributeNames: () => string[];
|
|
18
18
|
getAttributeValue: (name: string) => string | null;
|
|
19
19
|
};
|
|
20
|
-
export declare class
|
|
20
|
+
export declare class RadiantElementSsrService {
|
|
21
21
|
private readonly host;
|
|
22
|
-
constructor(host:
|
|
22
|
+
constructor(host: RadiantElementSsrHost);
|
|
23
23
|
renderHost(): JsxRenderable;
|
|
24
24
|
renderHostToString(options?: RenderToStringOptions, attributes?: Record<string, string>): string;
|
|
25
25
|
private renderHostContent;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
var x=((t)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(n,i)=>(typeof require<"u"?require:n)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});function p(t){switch(t){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function Q(t){switch(typeof t){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(t))return"array";if(Object.prototype.toString.call(t)==="[object Object]")return"object"}function W(t){switch(t){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function Z(t){try{return JSON.parse(t)}catch{throw TypeError("Invalid JSON string")}}var C={array(t){let n=Z(t);if(!Array.isArray(n))throw TypeError(`Expected an array but got a value of type "${typeof n}"`);return n},boolean(t){return!(t==="0"||String(t).toLowerCase()==="false")},number(t){return Number(t.replace(/_/g,""))},object(t){let n=JSON.parse(t);if(n===null||typeof n!=="object"||Array.isArray(n))throw TypeError(`expected value of type "object" but instead got value "${t}" of type "${Q(n)}"`);return n},string(t){return t}},c={default:H,array:h,object:h};function h(t){return JSON.stringify(t)}function H(t){return`${t}`}function d(t,n){let i=p(n);if(!i)throw TypeError(`[radiant-element] Unknown type "${n}"`);return C[i](t)}function P(t,n){let i=p(n);if(!i)throw TypeError(`[radiant-element] Unknown type "${n}"`);return(c[i]??c.default??H)(t)}function J(t){return typeof t==="boolean"}function k(t){return typeof t==="number"}function I(t){return typeof t==="string"}function U(t){return Array.isArray(t)}function y(t){return typeof t==="object"&&!Array.isArray(t)&&t!==null}function G(t,n){switch(t){case Boolean:return J(n);case Number:return k(n);case String:return I(n);case Array:return U(n);case Object:return y(n);default:return!1}}var X=(t,n,i,r)=>{if(n===Boolean){let s=t.getAttribute(i);if(s===null)return r;return s===""?!0:d(s,n)}let o=t.getAttribute(i);return o!==null?d(o,n):r??W(n)};var e=Symbol.for("@ecopages/radiant.customElementTagName");function N(t,n){t[e]=n}function $(t){return t[e]}var f=Symbol.for("@ecopages/radiant.ssr-context-provider-resolver");function b(){return globalThis}function z(t){b()[f]=t}function K(t){return b()[f]?.(t)}var g;function S(){if(g!==void 0)return g;try{let{AsyncLocalStorage:t}=(()=>{throw new Error("Cannot require module "+"node:async_hooks");})();return g=new t,g}catch{return g=null,null}}var R=Symbol.for("@ecopages/radiant.ssr-context-fallback-stack");function j(){let t=globalThis;return t[R]??=[],t[R]}function q(t){if(t.length===0)return()=>{return};let n=new Map;for(let o of t)n.set(o.getContextKey(),o);let i=S();if(i){let o=i.getStore()??[],s=[...o,n];return i.enterWith(s),()=>{i.enterWith(o)}}let r=j();return r.push(n),()=>{let o=r.lastIndexOf(n);if(o>=0)r.splice(o,1)}}function D(t){let n=S()?.getStore()??j();for(let i=n.length-1;i>=0;i-=1){let r=n[i]?.get(t);if(r)return r}return}function L(t){let n=D(t);if(!n)return;return n.getContext()}z((t)=>D(t));class B{host;constructor(t){this.host=t}renderHost(){return{nodeType:1,outerHTML:this.renderHostToString({mode:"hydrate"})}}renderHostToString(t={},n=this.getHostAttributes()){let i=this.getTagName(),r=q(this.host.getContextProviders());try{return`<${i}${F(n)}>${this.renderHostContent(t)}</${i}>`}finally{r()}}renderHostContent(t){let n=this.host.renderToString(t),i=this.host.getAuthoredHydrationScriptMarkup?.()??"",r=this.host.getSlotProjectionScriptTag?.()??"";if(!(t.mode==="hydrate"||t.mode===void 0&&t.hydrate===!0))return`${n}${i}${r}`;let s=this.host.getHydrationBindings().map((m)=>m.renderHydrationScriptTag()).filter((m)=>typeof m==="string").join("");return`${n}${r}${s}`}getHostAttributes(){let t={},n=new Set;for(let i of this.host.getReactiveProperties()){let r=this.host.getPropertyValue(i.name);if(r===void 0||r===null||r===!1)continue;t[i.attribute]=String(i.converter.toAttribute(r)),n.add(i.attribute)}for(let i of this.host.getReactivePropDefinitions()){let r=i.options.attribute??i.name;if(n.has(r))continue;let o=this.host.getPropertyValue(i.name);if(o===void 0||o===null||o===!1)continue;t[r]=String(P(o,i.options.type)),n.add(r)}for(let i of this.host.listAttributeNames()){let r=this.host.getAttributeValue(i);if(r!==null)t[i]=r}return t}getTagName(){let t=$(this.host.constructor);if(!t)throw Error(`${this.host.constructor.name} is missing @customElement metadata.`);return t}}function F(t){return Object.entries(t).map(([n,i])=>` ${n}="${w(i)}"`).join("")}function w(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}export{B as RadiantElementSsrService};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=53C9F45CFD02739C64756E2164756E21
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/utils/attribute-utils.ts", "../src/core/custom-element-metadata.ts", "../src/context/context-ssr-bridge.ts", "../src/server/context-ssr.ts", "../src/core/radiant-component-ssr.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n",
|
|
6
|
+
"export const CUSTOM_ELEMENT_TAG_NAME = Symbol.for('@ecopages/radiant.customElementTagName');\n\ntype CustomElementConstructorWithMetadata = CustomElementConstructor & {\n\t[CUSTOM_ELEMENT_TAG_NAME]?: string;\n};\n\n/**\n * Sets the custom element tag name for a given constructor.\n * This is used internally to associate a class with its custom element tag, which is necessary for features like hydration and SSR support.\n * @param target The constructor of the custom element.\n * @param tagName The tag name to associate with the custom element.\n */\nexport function setCustomElementTagName(target: CustomElementConstructor, tagName: string): void {\n\t(target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME] = tagName;\n}\n\n/**\n * Retrieves the custom element tag name associated with a given constructor.\n * @param target The constructor of the custom element.\n * @returns The tag name associated with the custom element, or `undefined` if not set.\n */\nexport function getCustomElementTagName(target: CustomElementConstructor): string | undefined {\n\treturn (target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME];\n}\n",
|
|
7
|
+
"import type { SsrSerializableContextProvider } from './context-provider';\nimport type { UnknownContext } from './types';\n\ntype SsrContextProviderResolver = (context: UnknownContext) => SsrSerializableContextProvider | undefined;\n\nconst SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL = Symbol.for('@ecopages/radiant.ssr-context-provider-resolver');\n\ntype GlobalResolverScope = typeof globalThis & {\n\t[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?: SsrContextProviderResolver;\n};\n\nfunction getGlobalResolverScope(): GlobalResolverScope {\n\treturn globalThis as GlobalResolverScope;\n}\n\n/**\n * Installs the ambient SSR provider resolver used by shared context runtime helpers.\n *\n * Server-side rendering infrastructure owns the actual provider stack storage and\n * publishes a lookup function here so client/runtime code does not need to import\n * server-oriented modules.\n */\nexport function installSsrContextProviderResolver(resolver: SsrContextProviderResolver): void {\n\tgetGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL] = resolver;\n}\n\n/**\n * Resolves an ambient SSR provider when a server render has published one.\n */\nexport function resolveAmbientSsrContextProvider(context: UnknownContext): SsrSerializableContextProvider | undefined {\n\treturn getGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?.(context);\n}\n",
|
|
8
|
+
"import type { AsyncLocalStorage } from 'node:async_hooks';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport { installSsrContextProviderResolver } from '../context/context-ssr-bridge';\nimport type { ContextType, UnknownContext } from '../context/types';\n\ntype ProviderFrame = Map<UnknownContext, SsrSerializableContextProvider>;\ntype ProviderStack = ProviderFrame[];\n\nlet resolvedAsyncLocalStorage: AsyncLocalStorage<ProviderStack> | null | undefined;\n\n/**\n * Lazily resolves `AsyncLocalStorage` from `node:async_hooks`.\n *\n * The dynamic `require` is necessary because browser-based SSR tests import\n * this server-oriented module directly. A top-level static import would break\n * those browser bundles even though normal application SSR runs on the server.\n *\n * On the server (Node.js, Bun, Cloudflare Workers) the import always succeeds.\n * In browser test environments where SSR rendering is exercised without a real\n * server, the fallback global stack is used instead.\n */\nfunction getAsyncLocalStorage(): AsyncLocalStorage<ProviderStack> | null {\n\tif (resolvedAsyncLocalStorage !== undefined) {\n\t\treturn resolvedAsyncLocalStorage;\n\t}\n\n\ttry {\n\t\tconst { AsyncLocalStorage: ALS } = require('node:async_hooks') as typeof import('node:async_hooks');\n\t\tresolvedAsyncLocalStorage = new ALS<ProviderStack>();\n\t\treturn resolvedAsyncLocalStorage;\n\t} catch {\n\t\tresolvedAsyncLocalStorage = null;\n\t\treturn null;\n\t}\n}\n\nconst SSR_CONTEXT_FALLBACK_STACK_SYMBOL = Symbol.for('@ecopages/radiant.ssr-context-fallback-stack');\n\nfunction getFallbackStack(): ProviderStack {\n\tconst g = globalThis as typeof globalThis & { [SSR_CONTEXT_FALLBACK_STACK_SYMBOL]?: ProviderStack };\n\tg[SSR_CONTEXT_FALLBACK_STACK_SYMBOL] ??= [];\n\treturn g[SSR_CONTEXT_FALLBACK_STACK_SYMBOL];\n}\n\n/**\n * Pushes a temporary provider frame onto the SSR context stack.\n *\n * On the server, each call creates an isolated `AsyncLocalStorage` context so\n * concurrent renders cannot corrupt each other.\n *\n * In browser test environments where `AsyncLocalStorage` is unavailable, a\n * synchronous global stack is used as a fallback.\n */\nexport function withSsrContextProviders(providers: readonly SsrSerializableContextProvider[]): () => void {\n\tif (providers.length === 0) {\n\t\treturn () => undefined;\n\t}\n\n\tconst frame = new Map<UnknownContext, SsrSerializableContextProvider>();\n\n\tfor (const provider of providers) {\n\t\tframe.set(provider.getContextKey(), provider);\n\t}\n\n\tconst als = getAsyncLocalStorage();\n\n\tif (als) {\n\t\tconst parentStack = als.getStore() ?? [];\n\t\tconst childStack = [...parentStack, frame];\n\t\tals.enterWith(childStack);\n\n\t\treturn () => {\n\t\t\tals.enterWith(parentStack);\n\t\t};\n\t}\n\n\tconst stack = getFallbackStack();\n\tstack.push(frame);\n\n\treturn () => {\n\t\tconst index = stack.lastIndexOf(frame);\n\t\tif (index >= 0) stack.splice(index, 1);\n\t};\n}\n\n/**\n * Resolves the nearest SSR-visible provider for a given context token.\n *\n * Lookup walks the provider frames from innermost to outermost so nested host\n * serialization behaves the same way as runtime context resolution in the DOM.\n */\nexport function resolveSsrContextProvider<T extends UnknownContext>(\n\tcontext: T,\n): SsrSerializableContextProvider | undefined {\n\tconst store = getAsyncLocalStorage()?.getStore() ?? getFallbackStack();\n\n\tfor (let index = store.length - 1; index >= 0; index -= 1) {\n\t\tconst provider = store[index]?.get(context);\n\n\t\tif (provider) {\n\t\t\treturn provider;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Resolves the current SSR-visible value for a given context token.\n *\n * This is the ergonomic helper consumed by SSR-aware decorators and component\n * render paths when they only need the context payload instead of the full\n * provider instance.\n */\nexport function resolveSsrContextValue<T extends UnknownContext>(context: T): ContextType<T> | undefined {\n\tconst provider = resolveSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn undefined;\n\t}\n\n\treturn provider.getContext() as ContextType<T>;\n}\n\ninstallSsrContextProviderResolver((context) => resolveSsrContextProvider(context));\n",
|
|
9
|
+
"import type { JsxRenderable } from '@ecopages/jsx';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport { withSsrContextProviders } from '../server/context-ssr';\nimport { getCustomElementTagName } from './custom-element-metadata';\nimport type { ReactiveProperty } from './radiant-element';\nimport type { ReactivePropDefinition } from './reactive-prop-metadata';\nimport type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';\nimport { writeAttributeValue } from '../utils/attribute-utils';\n\ntype RadiantElementSsrHost = {\n\tconstructor: CustomElementConstructor;\n\tgetAuthoredHydrationScriptMarkup?: () => string | undefined;\n\tgetContextProviders: () => SsrSerializableContextProvider[];\n\tgetHydrationBindings: () => SsrSerializableHydrationBinding[];\n\tgetSlotProjectionScriptTag?: () => string | undefined;\n\trenderToString: (options?: RenderToStringOptions) => string;\n\tgetReactiveProperties: () => ReactiveProperty[];\n\tgetReactivePropDefinitions: () => ReactivePropDefinition[];\n\tgetPropertyValue: (name: string) => unknown;\n\tlistAttributeNames: () => string[];\n\tgetAttributeValue: (name: string) => string | null;\n};\n\nexport class RadiantElementSsrService {\n\tconstructor(private readonly host: RadiantElementSsrHost) {}\n\n\tpublic renderHost(): JsxRenderable {\n\t\treturn {\n\t\t\tnodeType: 1,\n\t\t\touterHTML: this.renderHostToString({ mode: 'hydrate' }),\n\t\t};\n\t}\n\n\tpublic renderHostToString(options: RenderToStringOptions = {}, attributes = this.getHostAttributes()): string {\n\t\tconst tagName = this.getTagName();\n\t\tconst restoreSsrContexts = withSsrContextProviders(this.host.getContextProviders());\n\n\t\ttry {\n\t\t\treturn `<${tagName}${serializeHostAttributes(attributes)}>${this.renderHostContent(options)}</${tagName}>`;\n\t\t} finally {\n\t\t\trestoreSsrContexts();\n\t\t}\n\t}\n\n\tprivate renderHostContent(options: RenderToStringOptions): string {\n\t\tconst hostContent = this.host.renderToString(options);\n\t\tconst authoredHydrationMarkup = this.host.getAuthoredHydrationScriptMarkup?.() ?? '';\n\t\tconst slotProjectionScript = this.host.getSlotProjectionScriptTag?.() ?? '';\n\t\tconst hydrate = options.mode === 'hydrate' || (options.mode === undefined && options.hydrate === true);\n\n\t\tif (!hydrate) {\n\t\t\treturn `${hostContent}${authoredHydrationMarkup}${slotProjectionScript}`;\n\t\t}\n\n\t\tconst hydrationScripts = this.host\n\t\t\t.getHydrationBindings()\n\t\t\t.map((binding) => binding.renderHydrationScriptTag())\n\t\t\t.filter((markup): markup is string => typeof markup === 'string')\n\t\t\t.join('');\n\n\t\treturn `${hostContent}${slotProjectionScript}${hydrationScripts}`;\n\t}\n\n\tpublic getHostAttributes(): Record<string, string> {\n\t\tconst attributes: Record<string, string> = {};\n\t\tconst seenAttributes = new Set<string>();\n\n\t\tfor (const property of this.host.getReactiveProperties()) {\n\t\t\tconst currentValue = this.host.getPropertyValue(property.name);\n\t\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tattributes[property.attribute] = String(property.converter.toAttribute(currentValue));\n\t\t\tseenAttributes.add(property.attribute);\n\t\t}\n\n\t\tfor (const definition of this.host.getReactivePropDefinitions()) {\n\t\t\tconst attributeName = definition.options.attribute ?? definition.name;\n\n\t\t\tif (seenAttributes.has(attributeName)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst currentValue = this.host.getPropertyValue(definition.name);\n\n\t\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tattributes[attributeName] = String(writeAttributeValue(currentValue, definition.options.type));\n\t\t\tseenAttributes.add(attributeName);\n\t\t}\n\n\t\tfor (const attributeName of this.host.listAttributeNames()) {\n\t\t\tconst attributeValue = this.host.getAttributeValue(attributeName);\n\t\t\tif (attributeValue !== null) {\n\t\t\t\tattributes[attributeName] = attributeValue;\n\t\t\t}\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tprivate getTagName(): string {\n\t\tconst tagName = getCustomElementTagName(this.host.constructor);\n\n\t\tif (!tagName) {\n\t\t\tthrow new Error(`${this.host.constructor.name} is missing @customElement metadata.`);\n\t\t}\n\n\t\treturn tagName;\n\t}\n}\n\nfunction serializeHostAttributes(attributes: Record<string, string>): string {\n\treturn Object.entries(attributes)\n\t\t.map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n\t\t.join('');\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n}\n"
|
|
5
10
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
11
|
+
"mappings": "2PAYO,SAAS,CAA0B,CAAC,EAAkC,CAC5E,OAAQ,QACF,MACJ,MAAO,aACH,QACJ,MAAO,eACH,OACJ,MAAO,cACH,OACJ,MAAO,cACH,OACJ,MAAO,UAUH,SAAS,CAAyB,CAAC,EAAqC,CAC9E,OAAQ,OAAO,OACT,UACJ,MAAO,cACH,SACJ,MAAO,aACH,SACJ,MAAO,SAGT,GAAI,MAAM,QAAQ,CAAY,EAAG,MAAO,QACxC,GAAI,OAAO,UAAU,SAAS,KAAK,CAAY,IAAM,kBAAmB,MAAO,SASzE,SAAS,CAAmB,CAAC,EAAsC,CACzE,OAAQ,QACF,OACJ,MAAO,QACH,OACJ,MAAO,QACH,QACJ,MAAO,WAEP,OAAO,MASV,SAAS,CAAY,CAAC,EAAkB,CACvC,GAAI,CACH,OAAO,KAAK,MAAM,CAAK,EACtB,KAAM,CACP,MAAU,UAAU,qBAAqB,GAQ3C,IAAM,EAAsC,CAC3C,KAAK,CAAC,EAA0B,CAC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KAAK,KAAK,mBAAmB,EAAG,CAC3D,IAAM,EAAiB,KAAK,KAAK,kBAAkB,CAAa,EAChE,GAAI,IAAmB,KACtB,EAAW,GAAiB,EAI9B,OAAO,EAGA,UAAU,EAAW,CAC5B,IAAM,EAAU,EAAwB,KAAK,KAAK,WAAW,EAE7D,GAAI,CAAC,EACJ,MAAU,MAAM,GAAG,KAAK,KAAK,YAAY,0CAA0C,EAGpF,OAAO,EAET,CAEA,SAAS,CAAuB,CAAC,EAA4C,CAC5E,OAAO,OAAO,QAAQ,CAAU,EAC9B,IAAI,EAAE,EAAM,KAAW,IAAI,MAAS,EAAgB,CAAK,IAAI,EAC7D,KAAK,EAAE,EAGV,SAAS,CAAe,CAAC,EAAuB,CAC/C,OAAO,EAAM,QAAQ,KAAM,OAAO,EAAE,QAAQ,KAAM,QAAQ,EAAE,QAAQ,KAAM,MAAM,EAAE,QAAQ,KAAM,MAAM",
|
|
12
|
+
"debugId": "53C9F45CFD02739C64756E2164756E21",
|
|
8
13
|
"names": []
|
|
9
14
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type JsxRenderable, type SubscribableJsxValue } from '@ecopages/jsx';
|
|
2
|
+
import type { UnknownContext } from '../context/types';
|
|
3
|
+
import { type ReactiveHostLike } from './reactive-host';
|
|
4
|
+
import type { ReactivePropertyOptions, ReactiveBindingValue, ReactiveBindings, ReactiveFieldOptions } from './radiant-element';
|
|
5
|
+
import type { ReactiveBindingOption } from './radiant-element';
|
|
6
|
+
import type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';
|
|
7
|
+
type StringPropertyKey<Value> = Extract<keyof Value, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Attaches Radiant reactivity to an existing DOM element without defining a
|
|
10
|
+
* custom element.
|
|
11
|
+
*
|
|
12
|
+
* `RadiantController` is the controller-host counterpart to `RadiantElement`.
|
|
13
|
+
* It can enhance authored DOM, or it can take over the host's inner DOM by
|
|
14
|
+
* overriding `render()`.
|
|
15
|
+
*
|
|
16
|
+
* When used with the controller registry, the attached host is typically an
|
|
17
|
+
* element carrying `data-controller="..."`.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam Bindings - Explicit internal bindable shape. Include only the
|
|
20
|
+
* reactive keys that JSX bindings should accept.
|
|
21
|
+
*/
|
|
22
|
+
export declare class RadiantController<Bindings extends object = {}> implements ReactiveHostLike<Bindings> {
|
|
23
|
+
readonly host: Element;
|
|
24
|
+
readonly element: Element;
|
|
25
|
+
readonly bindings: ReactiveBindings<Bindings>;
|
|
26
|
+
readonly $: ReactiveBindings<Bindings>;
|
|
27
|
+
private readonly reactiveHost;
|
|
28
|
+
private connected;
|
|
29
|
+
private isRendering;
|
|
30
|
+
private isRenderScheduled;
|
|
31
|
+
private needsRender;
|
|
32
|
+
private renderSignal?;
|
|
33
|
+
private readonly renderWatcher;
|
|
34
|
+
constructor(host: Element);
|
|
35
|
+
/**
|
|
36
|
+
* Connects the controller to its host and starts reactive subscriptions.
|
|
37
|
+
*
|
|
38
|
+
* If the controller owns a render lifecycle by overriding `render()`, the
|
|
39
|
+
* first update runs immediately after connection.
|
|
40
|
+
*/
|
|
41
|
+
connect(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Connects the controller for server-side rendering without running the
|
|
44
|
+
* browser render/update lifecycle.
|
|
45
|
+
*/
|
|
46
|
+
connectForSsrRender(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Disconnects the controller from its host and tears down reactive work.
|
|
49
|
+
*/
|
|
50
|
+
disconnect(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Disconnects a controller that was attached through the SSR-only lifecycle.
|
|
53
|
+
*/
|
|
54
|
+
disconnectForSsrRender(): void;
|
|
55
|
+
get isConnected(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the JSX tree rendered into the attached host.
|
|
58
|
+
*
|
|
59
|
+
* The base implementation renders nothing. Override this method when the
|
|
60
|
+
* controller should own the host's inner DOM instead of only enhancing
|
|
61
|
+
* authored markup.
|
|
62
|
+
*/
|
|
63
|
+
render(): JsxRenderable;
|
|
64
|
+
/**
|
|
65
|
+
* Schedules a render pass for render-owning controllers.
|
|
66
|
+
*
|
|
67
|
+
* Multiple calls in the same microtask are coalesced into a single update.
|
|
68
|
+
*/
|
|
69
|
+
requestUpdate(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Flushes the current render output into the attached host element.
|
|
72
|
+
*
|
|
73
|
+
* This is a no-op unless the controller overrides `render()`.
|
|
74
|
+
*/
|
|
75
|
+
update(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Returns a subscribable JSX binding for a selected reactive member.
|
|
78
|
+
*/
|
|
79
|
+
bind<Property extends StringPropertyKey<Bindings>>(property: Property): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the cached binding object for a selected reactive member.
|
|
82
|
+
*/
|
|
83
|
+
getReactiveBinding<Property extends StringPropertyKey<Bindings>>(property: Property): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;
|
|
84
|
+
/**
|
|
85
|
+
* Defines a reactive field directly on the controller instance.
|
|
86
|
+
*/
|
|
87
|
+
createReactiveField<T>(propertyName: string, initialValue: T, options?: ReactiveFieldOptions): void;
|
|
88
|
+
/**
|
|
89
|
+
* Defines a controller prop backed by the attached host element's property
|
|
90
|
+
* channel instead of attribute serialization.
|
|
91
|
+
*
|
|
92
|
+
* This gives controller-based integrations the same reactive field surface as
|
|
93
|
+
* `@prop(...)` on `RadiantElement`, while allowing external code to assign
|
|
94
|
+
* structured values such as arrays or objects directly on `controller.host`.
|
|
95
|
+
*/
|
|
96
|
+
createReactiveProp<T = unknown>(propertyName: string, options: ReactivePropertyOptions<T>): void;
|
|
97
|
+
/**
|
|
98
|
+
* Defines a JSX binding companion such as `$count` for a reactive member.
|
|
99
|
+
*/
|
|
100
|
+
defineReactiveBinding(property: string, bind?: ReactiveBindingOption): void;
|
|
101
|
+
notifyUpdate(changedProperty: string, oldValue: unknown, value: unknown): void;
|
|
102
|
+
registerUpdateCallback(property: string, update: (...rest: any[]) => any): () => void;
|
|
103
|
+
connectedContextCallback(_contextName: UnknownContext): void;
|
|
104
|
+
registerContextProvider(_name: string, _provider: unknown): void;
|
|
105
|
+
registerHydrationBinding(_name: string, _binding: SsrSerializableHydrationBinding): void;
|
|
106
|
+
registerCleanupCallback(callback: () => void): void;
|
|
107
|
+
registerConnectedCallback(callback: () => void): void;
|
|
108
|
+
registerReactiveDependencyReader(property: string, read: () => unknown): void;
|
|
109
|
+
trackReactiveRead(property: string): void;
|
|
110
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
111
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
112
|
+
dispatchEvent(event: Event): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Finds one or more elements inside the attached host by `data-ref`.
|
|
115
|
+
*
|
|
116
|
+
* Prefer `@query(...)` for stable, decorator-backed refs and use `getRef(...)`
|
|
117
|
+
* for one-off lookups.
|
|
118
|
+
*/
|
|
119
|
+
getRef<T extends Element = Element>(ref: string, all: true): T[];
|
|
120
|
+
getRef<T extends Element = Element>(ref: string, all?: false): T | null;
|
|
121
|
+
protected shouldAutoBindReactiveMembers(): boolean;
|
|
122
|
+
protected shouldRunRenderLifecycle(): boolean;
|
|
123
|
+
private getRenderTarget;
|
|
124
|
+
private disconnectRenderWatcher;
|
|
125
|
+
private resolveTrackedRenderOutput;
|
|
126
|
+
}
|
|
127
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var m=((q)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(q,{get:(M,Q)=>(typeof require<"u"?require:M)[Q]}):q)(function(q){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+q+'" is not supported')});var Y=Symbol.for("@ecopages/radiant.legacy-instance-initializers");function N(q,M){let U=q[Y];if(Array.isArray(U)){U.push(M);return}Object.defineProperty(q,Y,{value:[M],configurable:!0})}function F(q){let M=[],Q=Object.getPrototypeOf(q);while(Q&&Q!==Object.prototype)M.push(Q),Q=Object.getPrototypeOf(Q);for(let U=M.length-1;U>=0;U-=1){let W=M[U][Y];if(!Array.isArray(W))continue;for(let $ of W)$(q)}}import{createSubscribableJsxValue as D}from"@ecopages/jsx";import{trackDependency as K}from"@ecopages/signals";class O{read;subscribers=new Set;watcherListeners=new Set;version=0;constructor(q){this.read=q}get(){return K(this),this.read()}subscribe(q){return this.subscribers.add(q),()=>{this.subscribers.delete(q)}}addWatcher(q){return this.watcherListeners.add(q),()=>{this.watcherListeners.delete(q)}}getVersion(){return this.version}notify(q){this.version+=1;let M;try{this.notifyWatchers()}catch(Q){M=Q}if(this.publish(q),M)throw M}publish(q){for(let M of this.subscribers)M(q)}notifyWatchers(){let q=[];for(let M of this.watcherListeners)try{M()}catch(Q){q.push(Q)}if(q.length===1)throw q[0];if(q.length>1)throw AggregateError(q,"Multiple reactive dependency notifications failed.")}}function P(q){return typeof q==="object"&&q!==null&&typeof q.get==="function"}class Z{host;access;shouldAutoBind;bindings;$;reactiveFields=new Map;reactiveDependencies=new Map;reactiveDependencyReaders=new Map;reactiveBindings=new Map;updateCallbacks=new Map;onConnectedCallbacks=[];onDisconnectedCallback=[];constructor(q,M,Q){this.host=q;this.access=M;this.shouldAutoBind=Q;let U=this.createReactiveBindingNamespace();this.bindings=U,this.$=U}connectHost(){for(let q of this.onConnectedCallbacks)q()}disconnectHost(){for(let q of this.onDisconnectedCallback)q()}notifyUpdate(q,M,Q){if(M===Q)return;this.reactiveDependencies.get(q)?.notify(Q);let U=this.updateCallbacks.get(q);if(U)for(let W of U)W()}registerCleanupCallback(q){this.onDisconnectedCallback.push(q)}registerConnectedCallback(q){this.onConnectedCallbacks.push(q)}registerHydrationBinding(q,M){}registerReactiveDependencyReader(q,M){this.reactiveDependencyReaders.set(q,M)}registerUpdateCallback(q,M){if(!this.updateCallbacks.has(q))this.updateCallbacks.set(q,new Set);let Q=this.updateCallbacks.get(q);return Q.add(M),()=>{if(Q.delete(M),Q.size===0)this.updateCallbacks.delete(q)}}getReactiveBinding(q){let M=this.reactiveBindings.get(q);if(M)return M;let Q=D({getValue:()=>this.readReactiveBindingValue(q),subscribe:(U)=>this.registerUpdateCallback(q,()=>{U(this.readReactiveBindingValue(q))})});return this.reactiveBindings.set(q,Q),Q}bind(q){return this.getReactiveBinding(q)}defineReactiveBinding(q,M=!0){let Q=typeof M==="string"?M:M?`$${q}`:void 0,U=this.access.getBindingTarget?.(this.host)??this.host;if(!Q||this.access.hasProperty(this.host,Q))return;this.access.defineProperty(U,Q,{get:()=>this.getReactiveBinding(q),enumerable:!1,configurable:!0})}trackReactiveRead(q){K(this.getReactiveDependency(q))}defineReactiveAccessor(q,M){let Q=M.bind??this.shouldAutoBind();if(this.defineReactiveBinding(q,Q),this.registerReactiveDependencyReader(q,M.getValue),this.access.defineProperty(this.host,q,{get:()=>{return this.trackReactiveRead(q),M.getValue()},set:(U)=>{let W=M.getValue();if(W===U)return;M.setValue(U),this.notifyUpdate(q,W,U)},enumerable:!0,configurable:!0}),M.notifyInitialValue!==void 0)this.notifyUpdate(q,void 0,M.notifyInitialValue)}createReactiveField(q,M,Q={}){let U={name:q,value:M,initialValue:M};this.reactiveFields.set(q,U),this.defineReactiveAccessor(q,{bind:Q.bind,getValue:()=>this.reactiveFields.get(q)?.value,setValue:(W)=>{this.reactiveFields.set(q,{...U,value:W})},notifyInitialValue:M})}createReactiveBindingNamespace(){return new Proxy(Object.create(null),{get:(q,M)=>{if(typeof M!=="string")return;return this.getReactiveBinding(M)}})}getReactiveDependency(q){let M=this.reactiveDependencies.get(q);if(M)return M;let Q=new O(()=>this.readReactiveDependencyValue(q));return this.reactiveDependencies.set(q,Q),Q}readReactiveDependencyValue(q){let M=this.reactiveDependencyReaders.get(q);if(M)return M();return this.readReactiveBindingValue(q)}readReactiveBindingValue(q){let M=this.access.readProperty(this.host,q);if(P(M))return M.get();return M}}function L(q){switch(q){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function x(q){switch(typeof q){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(q))return"array";if(Object.prototype.toString.call(q)==="[object Object]")return"object"}function B(q){switch(q){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function A(q){try{return JSON.parse(q)}catch{throw TypeError("Invalid JSON string")}}var k={array(q){let M=A(q);if(!Array.isArray(M))throw TypeError(`Expected an array but got a value of type "${typeof M}"`);return M},boolean(q){return!(q==="0"||String(q).toLowerCase()==="false")},number(q){return Number(q.replace(/_/g,""))},object(q){let M=JSON.parse(q);if(M===null||typeof M!=="object"||Array.isArray(M))throw TypeError(`expected value of type "object" but instead got value "${q}" of type "${x(M)}"`);return M},string(q){return q}},J={default:C,array:_,object:_};function _(q){return JSON.stringify(q)}function C(q){return`${q}`}function j(q,M){let Q=L(M);if(!Q)throw TypeError(`[radiant-element] Unknown type "${M}"`);return k[Q](q)}function y(q,M){let Q=L(M);if(!Q)throw TypeError(`[radiant-element] Unknown type "${M}"`);return(J[Q]??J.default??C)(q)}function R(q){return typeof q==="boolean"}function S(q){return typeof q==="number"}function T(q){return typeof q==="string"}function I(q){return Array.isArray(q)}function h(q){return typeof q==="object"&&!Array.isArray(q)&&q!==null}function E(q,M){switch(q){case Boolean:return R(M);case Number:return S(M);case String:return T(M);case Array:return I(M);case Object:return h(M);default:return!1}}var u=(q,M,Q,U)=>{if(M===Boolean){let $=q.getAttribute(Q);if($===null)return U;return $===""?!0:j($,M)}let W=q.getAttribute(Q);return W!==null?j(W,M):U??B(M)};import{render as w}from"@ecopages/jsx";import{Computed as g,subtle as f}from"@ecopages/signals";class z{host;element;bindings;$;reactiveHost;connected=!1;isRendering=!1;isRenderScheduled=!1;needsRender=!1;renderSignal;renderWatcher=new f.Watcher(()=>{this.requestUpdate()});constructor(q){this.host=q,this.element=q,this.reactiveHost=new Z(this,{defineProperty:(M,Q,U)=>Object.defineProperty(M,Q,U),hasProperty:(M,Q)=>(Q in M),readProperty:(M,Q)=>M[Q]},()=>this.shouldAutoBindReactiveMembers()),this.bindings=this.reactiveHost.bindings,this.$=this.reactiveHost.$,F(this)}connect(){if(this.connected=!0,this.reactiveHost.connectHost(),this.shouldRunRenderLifecycle())this.update()}connectForSsrRender(){this.connected=!0,this.reactiveHost.connectHost()}disconnect(){this.connected=!1,this.disconnectRenderWatcher(),this.reactiveHost.disconnectHost()}disconnectForSsrRender(){this.disconnectRenderWatcher(),this.reactiveHost.disconnectHost(),this.connected=!1}get isConnected(){return this.connected}render(){return null}requestUpdate(){if(!this.shouldRunRenderLifecycle())return;if(this.needsRender=!0,this.isRenderScheduled)return;this.isRenderScheduled=!0,queueMicrotask(()=>{if(this.isRenderScheduled=!1,!this.needsRender)return;this.update()})}update(){if(!this.shouldRunRenderLifecycle())return;let q=this.getRenderTarget();if(!q)return;if(this.needsRender=!0,!this.connected||this.isRendering)return;while(this.needsRender){this.needsRender=!1,this.isRendering=!0;try{w(this.resolveTrackedRenderOutput(),q)}finally{this.isRendering=!1}}}bind(q){return this.reactiveHost.bind(q)}getReactiveBinding(q){return this.reactiveHost.getReactiveBinding(q)}createReactiveField(q,M,Q={}){this.reactiveHost.createReactiveField(q,M,Q)}createReactiveProp(q,M){let{type:Q,defaultValue:U,bind:W}=M;if(U!==void 0&&!E(Q,U))throw Error(`defaultValue does not match the expected type for ${Q.name}`);let $=Object.getOwnPropertyDescriptor(this.host,q),G=this.host,H=G[q]??U??B(Q);this.reactiveHost.defineReactiveAccessor(q,{bind:W,getValue:()=>H,setValue:(X)=>{H=X},notifyInitialValue:H}),Object.defineProperty(this.host,q,{get:()=>this[q],set:(X)=>{this[q]=X},enumerable:$?.enumerable??!0,configurable:!0}),this.registerCleanupCallback(()=>{let X=this[q];if($){if(Object.defineProperty(this.host,q,$),"value"in $&&$.writable)G[q]=X;return}delete G[q];try{G[q]=X}catch{Object.defineProperty(this.host,q,{value:X,writable:!0,enumerable:!0,configurable:!0})}})}defineReactiveBinding(q,M=!0){this.reactiveHost.defineReactiveBinding(q,M)}notifyUpdate(q,M,Q){this.reactiveHost.notifyUpdate(q,M,Q)}registerUpdateCallback(q,M){return this.reactiveHost.registerUpdateCallback(q,M)}connectedContextCallback(q){}registerContextProvider(q,M){}registerHydrationBinding(q,M){}registerCleanupCallback(q){this.reactiveHost.registerCleanupCallback(q)}registerConnectedCallback(q){this.reactiveHost.registerConnectedCallback(q)}registerReactiveDependencyReader(q,M){this.reactiveHost.registerReactiveDependencyReader(q,M)}trackReactiveRead(q){this.reactiveHost.trackReactiveRead(q)}addEventListener(q,M,Q){this.host.addEventListener(q,M,Q)}removeEventListener(q,M,Q){this.host.removeEventListener(q,M,Q)}dispatchEvent(q){return this.host.dispatchEvent(q)}getRef(q,M=!1){let Q=`[data-ref="${q}"]`;if(M)return Array.from(this.host.querySelectorAll(Q));return this.host.querySelector(Q)??null}shouldAutoBindReactiveMembers(){return!0}shouldRunRenderLifecycle(){return this.render!==z.prototype.render}getRenderTarget(){return this.host instanceof HTMLElement?this.host:null}disconnectRenderWatcher(){if(!this.renderSignal)return;this.renderWatcher.unwatch(this.renderSignal),this.renderSignal=void 0}resolveTrackedRenderOutput(){let q=new g(()=>this.render()),M=q.get();if(!this.connected)return M;if(this.renderSignal)this.renderWatcher.unwatch(this.renderSignal);return this.renderSignal=q,this.renderWatcher.watch(q),M}}export{z as RadiantController};
|
|
2
|
+
|
|
3
|
+
//# debugId=479ACC6352CE9BFB64756E2164756E21
|