@ecopages/radiant 0.3.0-alpha.4 → 0.3.0-alpha.5
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 +66 -56
- 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/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 +11 -12
- package/dist/index.js +2 -2
- package/dist/index.js.map +87 -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 +22 -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
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
var V=((f)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(f,{get:(L,C)=>(typeof require<"u"?require:L)[C]}):f)(function(f){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+f+'" is not supported')});function w(f){return f.replace(/&/g,"\\u0026").replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var Q="data-hydration",X="data-hydration-type",G="data-hydration-key";function z(f){let L=f.hydrationKey?` ${G}="${x(f.hydrationKey)}"`:"";return`<script type="application/json" ${Q} ${X}="${f.type}"${L}>${f.serializedValue}</script>`}function J(f){return w(f)}function O(f,L){let C=f.textContent;if(!C)return L;try{return JSON.parse(C)}catch{if(typeof console<"u")console.warn(`[@ecopages/radiant] Failed to parse hydration payload from <script ${Q}>:`,C.slice(0,120));return L}}function U(f,L,C){let P=f.children;if(!P||P.length===0){let g=f.childNodes;if(!g||g.length===0)return null;for(let j=0;j<g.length;j+=1){let m=g[j];if(m.nodeType!==1)continue;let q=m;if(W(q,L,C))return q}return null}for(let g=0;g<P.length;g+=1)if(W(P[g],L,C))return P[g];return null}function W(f,L,C){if(f.tagName!=="SCRIPT"||!f.hasAttribute(Q)||f.getAttribute(X)!==L)return!1;if(C!==void 0)return f.getAttribute(G)===C;return!f.hasAttribute(G)}function x(f){return f.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var k;((g)=>{g.SUBSCRIPTION_REQUEST="context-subscription-request";g.CONTEXT_REQUEST="context-request";g.ON_MOUNT="context-on-mount";g.MOUNTED="context-mounted"})(k||={});class B extends Event{context;callback;subscribe;handled=!1;constructor(f,L,C){super("context-request",{bubbles:!0,composed:!0});this.context=f;this.callback=L;this.subscribe=C}markHandled(){this.handled=!0}}class F extends CustomEvent{constructor(f){super("context-on-mount",{detail:{context:f},bubbles:!0,composed:!0})}}class D extends Event{context;callback;select;subscribe;onSubscribe;handled=!1;constructor(f,L,C,P,g){super("context-subscription-request",{bubbles:!0,composed:!0});this.context=f;this.callback=L;this.select=C;this.subscribe=P;this.onSubscribe=g}markHandled(){this.handled=!0}}function E(f){return z({type:"context",...f})}function M(f){return J(f)}function S(f){if(f instanceof Element)return f;if("host"in f)return f.host;if("element"in f)return f.element;return null}function H(f){if(f instanceof Element)return f;if("host"in f)return f.host;if("element"in f)return f.element;return f}import{createMarkupNodeLike as K}from"@ecopages/jsx";class Z{host;context;hydrationKey;hydrate;serialize;pendingHostHydration;value;subscriptions=[];constructor(f,L){this.host=f,this.context=L.context,this.hydrationKey=L.hydrationKey,this.hydrate=L.hydrate,this.serialize=L.serialize,this.pendingHostHydration=Boolean(L.hydrate),this.value=L.initialValue,this.tryHydrateFromHost(),this.registerEvents(),this.host.dispatchEvent(new F(this.context))}setContext=(f,L)=>{if(this.tryHydrateFromHost(),this.pendingHostHydration=!1,typeof this.value>"u"&&this.isObject(f)){let C=this.value;if(this.value={...f},L)L(this.value);this.notifySubscribers(this.value,C);return}if(this.isObject(this.value)&&this.isObject(f)){let C={...this.value};if(this.value={...this.value,...f},L)L(this.value);this.notifySubscribers(this.value,C)}};getContext=()=>{return this.tryHydrateFromHost(),this.value};getContextKey=()=>{return this.context};serializeHydrationValue=()=>{if(this.tryHydrateFromHost(),!this.hydrate||typeof this.value>"u")return;let f=this.serialize?this.serialize(this.value):this.value;if(typeof f>"u")return;let L=JSON.stringify(f);if(typeof L!=="string")return;return M(L)};renderHydrationScriptTag=()=>{let f=this.serializeHydrationValue();if(!f)return;return E({hydrationKey:this.hydrationKey,serializedValue:f})};renderHydrationScript=()=>{let f=this.renderHydrationScriptTag();if(!f)return;return K(f)};subscribe=(f)=>{let L={hasChanged:(C,P)=>{if(typeof P>"u"||!f.select)return!0;return f.select(C)!==f.select(P)},notify:(C)=>{if(f.select){f.callback(f.select(C),L.unsubscribe);return}f.callback(C,L.unsubscribe)},unsubscribe:()=>{let C=this.subscriptions.indexOf(L);if(C!==-1)this.subscriptions.splice(C,1)}};return this.subscriptions.push(L),L.unsubscribe};tryHydrateFromHost(){if(!this.pendingHostHydration)return;let f=this.findHydrationScriptElement();if(!f)return;this.value=this.mergeHydrationValue(O(f,this.value)),this.pendingHostHydration=!1}mergeHydrationValue(f){if(this.hydrate===Object&&this.isObject(f)&&(this.isObject(this.value)||typeof this.value>"u"))return{...this.value??{},...f};return f}isObject(f){return typeof f==="object"&&!Array.isArray(f)&&f!==null}findHydrationScriptElement(){return U(H(this.host),"context",this.hydrationKey)}notifySubscribers=(f,L)=>{for(let C of this.subscriptions)if(C.hasChanged(f,L))C.notify(f)};handleSubscriptionRequest=(f,{subscribe:L,onSubscribe:C})=>{this.tryHydrateFromHost();let P=L?this.subscribe(f):void 0;if(P)C?.(P);if(typeof this.value>"u")return;if(f.select)f.callback(f.select(this.value),P);else f.callback(this.value,P)};onSubscriptionRequest=(f)=>{let{context:L,callback:C,subscribe:P,select:g,target:j,onSubscribe:m}=f;if(L!==this.context)return;if(f.markHandled(),f.stopPropagation(),j instanceof EventTarget)j.dispatchEvent(new F(this.context));if(g){this.handleSubscriptionRequest({select:g,callback:C},{subscribe:P,onSubscribe:m});return}this.handleSubscriptionRequest({callback:C},{subscribe:P,onSubscribe:m})};onContextRequest=(f)=>{let{context:L,callback:C}=f;if(L!==this.context)return;f.markHandled(),f.stopPropagation(),C(this)};registerEvents=()=>{this.host.addEventListener("context-subscription-request",this.onSubscriptionRequest),this.host.addEventListener("context-request",this.onContextRequest)}}function b({context:f,initialValue:L,hydrate:C,serialize:P}){return(g,j)=>{let m=String(j.name);j.addInitializer(function(){let q=this,$=new Z(this,{context:f,hydrationKey:m,initialValue:L,hydrate:C,serialize:P});q[m]=$,this.registerContextProvider(m,$),this.connectedContextCallback(f)})}}export{b as provideContext};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=38CB6638F936059564756E2164756E21
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/tools/escape-script-json.ts", "../src/core/hydration-codec.ts", "../src/context/events.ts", "../src/context/hydration-script.ts", "../src/context/context-host.ts", "../src/context/context-provider.ts", "../src/context/decorators/standard/provide-context.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, '<').replace(/>/g, '>');\n}\n",
|
|
7
|
+
"import type { Context, ContextCallback, ContextType, UnknownContext } from './types';\n\n/**\n * List of events which can be emitted by a context provider or requester.\n */\nexport enum ContextEventsTypes {\n\tSUBSCRIPTION_REQUEST = 'context-subscription-request',\n\tCONTEXT_REQUEST = 'context-request',\n\tON_MOUNT = 'context-on-mount',\n\tMOUNTED = 'context-mounted',\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n */\nexport class ContextRequestEvent<T extends UnknownContext> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<ContextType<T>>,\n\t\tpublic readonly subscribe?: boolean,\n\t) {\n\t\tsuper(ContextEventsTypes.CONTEXT_REQUEST, { bubbles: true, composed: true });\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\n/**\n * A type which represents a subscription to a context value.\n */\ntype DirectContextSubscription<T extends UnknownContext> = {\n\tselect?: undefined;\n\tcallback: ContextCallback<ContextType<T>>;\n};\n\ntype SelectedContextSubscription<T extends UnknownContext, Selected> = {\n\tselect: (context: ContextType<T>) => Selected;\n\tcallback: ContextCallback<Selected>;\n};\n\nexport type ContextSubscription<T extends UnknownContext, Selected = ContextType<T>> =\n\t| DirectContextSubscription<T>\n\t| SelectedContextSubscription<T, Selected>;\n\n/**\n * An event fired by a context provider to signal that a context value has been mounted and is available for consumption.\n */\nexport class ContextOnMountEvent extends CustomEvent<{ context: UnknownContext }> {\n\tpublic constructor(context: UnknownContext) {\n\t\tsuper(ContextEventsTypes.ON_MOUNT, {\n\t\t\tdetail: { context },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n *\n * It accepts a `selector` property which can be used to request a specific property of the context value.\n */\nexport class ContextSubscriptionRequestEvent<T extends UnknownContext, Selected = ContextType<T>> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<Selected>,\n\t\tpublic readonly select?: (context: ContextType<T>) => Selected,\n\t\tpublic readonly subscribe?: boolean,\n\t\tpublic readonly onSubscribe?: (unsubscribe: () => void) => void,\n\t) {\n\t\tsuper(ContextEventsTypes.SUBSCRIPTION_REQUEST, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementEventMap {\n\t\t/**\n\t\t * A 'context-request-subscription' event can be emitted by any element which desires\n\t\t * a context value to be injected by an external provider.\n\t\t */\n\t\t[ContextEventsTypes.SUBSCRIPTION_REQUEST]: ContextSubscriptionRequestEvent<UnknownContext>;\n\t\t/**\n\t\t * A context-request-provider event can be emitted by a context requester to signal\n\t\t * that it desires a context value to be provided by a context provider.\n\t\t */\n\t\t[ContextEventsTypes.CONTEXT_REQUEST]: ContextRequestEvent<Context<unknown, unknown>>;\n\t\t/**\n\t\t * A 'context-mount' event can be emitted by a context provider to signal\n\t\t * that a context value has been mounted and is available for consumption.\n\t\t */\n\t\t[ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;\n\t}\n}\n",
|
|
8
|
+
"import { createHydrationScriptTag, escapeHydrationJson } from '../core/hydration-codec';\n\n/**\n * Creates the raw `<script type=\"application/json\">` tag used to hydrate a\n * serialized context provider.\n */\nexport function createContextHydrationScriptTag(options: { hydrationKey?: string; serializedValue: string }): string {\n\treturn createHydrationScriptTag({ type: 'context', ...options });\n}\n\n/**\n * Escapes serialized JSON so it remains safe when embedded inside an HTML\n * script tag.\n */\nexport function escapeContextHydrationJson(value: string): string {\n\treturn escapeHydrationJson(value);\n}\n",
|
|
9
|
+
"import type { UnknownContext } from './types';\n\ntype ContextHostApi = {\n\taddEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void;\n\tremoveEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject,\n\t\toptions?: boolean | EventListenerOptions,\n\t): void;\n\tdispatchEvent(event: Event): boolean;\n\tregisterConnectedCallback(callback: () => void): void;\n\tregisterCleanupCallback(callback: () => void): void;\n\tconnectedContextCallback(context: UnknownContext): void;\n\tregisterContextProvider(name: string, provider: unknown): void;\n};\n\ntype SsrHydrationContainer = {\n\tchildren?: ArrayLike<Element> | undefined;\n\tchildNodes?: ArrayLike<{ nodeType: number }> | undefined;\n};\n\nexport type ContextHydrationHost = Element | SsrHydrationContainer;\n\nexport type ContextHostLike =\n\t| (ContextHostApi & Element)\n\t| (ContextHostApi & { host: Element })\n\t| (ContextHostApi & { element: Element })\n\t| (ContextHostApi & SsrHydrationContainer);\n\nexport function resolveContextHostElement(host: ContextHostLike): Element | null {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\tif ('element' in host) {\n\t\treturn host.element;\n\t}\n\n\treturn null;\n}\n\nexport function resolveContextHydrationHost(host: ContextHostLike): ContextHydrationHost {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\tif ('element' in host) {\n\t\treturn host.element;\n\t}\n\n\treturn host;\n}\n",
|
|
10
|
+
"import { createMarkupNodeLike, type JsxRenderable } from '@ecopages/jsx';\nimport type { SsrSerializableHydrationBinding } from '../core/ssr-hydration-binding';\nimport type { AttributeTypeConstant } from '../utils/attribute-utils';\nimport {\n\tContextEventsTypes,\n\tContextOnMountEvent,\n\ttype ContextRequestEvent,\n\ttype ContextSubscription,\n\ttype ContextSubscriptionRequestEvent,\n} from './events';\nimport { findHydrationScript, parseHydrationPayload } from '../core/hydration-codec';\nimport { createContextHydrationScriptTag, escapeContextHydrationJson } from './hydration-script';\nimport type { Context, ContextType, UnknownContext } from './types';\nimport { resolveContextHydrationHost, type ContextHostLike } from './context-host';\n\ntype ContextProviderOptions<T extends UnknownContext> = {\n\tcontext: UnknownContext;\n\thydrationKey?: string;\n\tinitialValue?: T['__context__'];\n\thydrate?: AttributeTypeConstant;\n\tserialize?: (value: ContextType<T>) => unknown;\n};\n\ntype ActiveContextSubscription<T extends UnknownContext> = {\n\thasChanged(newContext: ContextType<T>, prevContext: ContextType<T> | undefined): boolean;\n\tnotify(context: ContextType<T>): void;\n\tunsubscribe: () => void;\n};\n\nexport interface SsrSerializableContextProvider extends SsrSerializableHydrationBinding {\n\t/** Returns the current context payload that should be visible to descendants. */\n\tgetContext(): unknown;\n\t/** Returns the context token used to match nested SSR consumers and providers. */\n\tgetContextKey(): UnknownContext;\n}\n\n/**\n * Represents a context provider that allows setting and getting the context,\n * as well as subscribing to context updates.\n *\n * @template T - The type of the context.\n */\nexport interface IContextProvider<T extends Context<unknown, unknown>> {\n\t/**\n\t * Sets the context with the provided update and invokes the optional callback function.\n\t *\n\t * @param update - The partial update to be applied to the context.\n\t * @param callback - An optional callback function that receives the updated context.\n\t */\n\tsetContext: (update: Partial<ContextType<T>>, callback?: (context: ContextType<T>) => void) => void;\n\n\t/**\n\t * Gets the current context.\n\t *\n\t * @returns The current context.\n\t */\n\tgetContext: () => ContextType<T>;\n\n\t/**\n\t * Subscribes to context updates.\n\t *\n\t * @param subscription - The subscription object that defines the callback function to be invoked on context updates.\n\t */\n\tsubscribe: <Selected = ContextType<T>>(subscription: ContextSubscription<T, Selected>) => () => void;\n}\n\n/**\n * It creates a context provider that allows setting and getting the context,\n * It will also be in charge of notifying the subscribers when the context changes.\n *\n * @template T - The type of the context.\n * @implements IContextProvider\n *\n * @example\n * ```ts\n * export class MyElement extends RadiantElement {\n * provider = new ContextProvider<typeof myContext>(this, {\n * context: myContext,\n * initialValue: {\n * value: 'Hello World',\n * },\n * });\n * ```\n */\nexport class ContextProvider<T extends Context<unknown, unknown>>\n\timplements IContextProvider<T>, SsrSerializableContextProvider\n{\n\tprivate host: ContextHostLike;\n\tprivate context: UnknownContext;\n\tprivate hydrationKey?: string;\n\tprivate hydrate?: AttributeTypeConstant;\n\tprivate serialize?: (value: ContextType<T>) => unknown;\n\tprivate pendingHostHydration: boolean;\n\tprivate value: ContextType<T> | undefined;\n\n\tsubscriptions: ActiveContextSubscription<T>[] = [];\n\n\t/**\n\t * Creates a new instance of the ContextProvider.\n\t *\n\t * @param host - The host element that will contain the context provider.\n\t * @param options - The options to configure the context provider.\n\t */\n\tconstructor(host: ContextHostLike, options: ContextProviderOptions<T>) {\n\t\tthis.host = host;\n\t\tthis.context = options.context;\n\t\tthis.hydrationKey = options.hydrationKey;\n\t\tthis.hydrate = options.hydrate;\n\t\tthis.serialize = options.serialize;\n\t\tthis.pendingHostHydration = Boolean(options.hydrate);\n\t\tthis.value = options.initialValue as ContextType<T>;\n\t\tthis.tryHydrateFromHost();\n\n\t\tthis.registerEvents();\n\t\tthis.host.dispatchEvent(new ContextOnMountEvent(this.context));\n\t}\n\n\tsetContext = (update: Partial<ContextType<T>>, callback?: (context: ContextType<T>) => void) => {\n\t\tthis.tryHydrateFromHost();\n\t\tthis.pendingHostHydration = false;\n\n\t\tif (typeof this.value === 'undefined' && this.isObject(update)) {\n\t\t\tconst oldContext = this.value;\n\t\t\tthis.value = { ...update } as ContextType<T>;\n\t\t\tif (callback) callback(this.value);\n\t\t\tthis.notifySubscribers(this.value, oldContext);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isObject(this.value) && this.isObject(update)) {\n\t\t\tconst oldContext = { ...this.value };\n\t\t\tthis.value = { ...this.value, ...update };\n\t\t\tif (callback) callback(this.value);\n\t\t\tthis.notifySubscribers(this.value, oldContext);\n\t\t}\n\t};\n\n\tgetContext = () => {\n\t\tthis.tryHydrateFromHost();\n\t\treturn this.value as ContextType<T>;\n\t};\n\n\t/**\n\t * Returns the provider's logical context token.\n\t *\n\t * SSR helpers use this token to resolve the closest matching provider while a\n\t * host subtree is being serialized.\n\t */\n\tgetContextKey = () => {\n\t\treturn this.context;\n\t};\n\n\t/**\n\t * Serializes the current provider value for inclusion in a hydration script.\n\t *\n\t * The serialized payload is JSON-escaped so it can be embedded safely inside a\n\t * `<script type=\"application/json\">` tag.\n\t */\n\tserializeHydrationValue = (): string | undefined => {\n\t\tthis.tryHydrateFromHost();\n\n\t\tif (!this.hydrate || typeof this.value === 'undefined') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst hydrationValue = this.serialize ? this.serialize(this.value) : this.value;\n\n\t\tif (typeof hydrationValue === 'undefined') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst serializedValue = JSON.stringify(hydrationValue);\n\n\t\tif (typeof serializedValue !== 'string') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn escapeContextHydrationJson(serializedValue);\n\t};\n\n\t/**\n\t * Builds the raw HTML hydration script for this provider.\n\t *\n\t * When `hydrationKey` is present, the marker is scoped so sibling or nested\n\t * providers can recover their own payloads without accidentally reading a\n\t * descendant script.\n\t */\n\trenderHydrationScriptTag = (): string | undefined => {\n\t\tconst serializedValue = this.serializeHydrationValue();\n\n\t\tif (!serializedValue) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createContextHydrationScriptTag({\n\t\t\thydrationKey: this.hydrationKey,\n\t\t\tserializedValue,\n\t\t});\n\t};\n\n\t/**\n\t * Wraps the provider hydration script in a minimal JSX node-like value.\n\t *\n\t * This lets JSX-based host renderers append the script without needing a real\n\t * DOM element instance during SSR.\n\t */\n\trenderHydrationScript = (): JsxRenderable | undefined => {\n\t\tconst outerHTML = this.renderHydrationScriptTag();\n\n\t\tif (!outerHTML) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createMarkupNodeLike(outerHTML);\n\t};\n\n\tsubscribe = <Selected = ContextType<T>>(subscriptionSpec: ContextSubscription<T, Selected>) => {\n\t\tconst subscription: ActiveContextSubscription<T> = {\n\t\t\thasChanged: (newContext, prevContext) => {\n\t\t\t\tif (typeof prevContext === 'undefined' || !subscriptionSpec.select) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn subscriptionSpec.select(newContext) !== subscriptionSpec.select(prevContext);\n\t\t\t},\n\t\t\tnotify: (context) => {\n\t\t\t\tif (subscriptionSpec.select) {\n\t\t\t\t\tsubscriptionSpec.callback(subscriptionSpec.select(context), subscription.unsubscribe);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsubscriptionSpec.callback(context, subscription.unsubscribe);\n\t\t\t},\n\t\t\tunsubscribe: () => {\n\t\t\t\tconst index = this.subscriptions.indexOf(subscription);\n\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\tthis.subscriptions.splice(index, 1);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tthis.subscriptions.push(subscription);\n\n\t\treturn subscription.unsubscribe;\n\t};\n\n\tprivate tryHydrateFromHost(): void {\n\t\tif (!this.pendingHostHydration) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst hydrationScriptElement = this.findHydrationScriptElement();\n\n\t\tif (!hydrationScriptElement) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.value = this.mergeHydrationValue(\n\t\t\tparseHydrationPayload(hydrationScriptElement, this.value) as ContextType<T>,\n\t\t);\n\t\tthis.pendingHostHydration = false;\n\t}\n\n\tprivate mergeHydrationValue(parsedHydrationValue: ContextType<T>): ContextType<T> {\n\t\tif (\n\t\t\tthis.hydrate === Object &&\n\t\t\tthis.isObject(parsedHydrationValue) &&\n\t\t\t(this.isObject(this.value) || typeof this.value === 'undefined')\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...(this.value ?? {}),\n\t\t\t\t...parsedHydrationValue,\n\t\t\t} as ContextType<T>;\n\t\t}\n\n\t\treturn parsedHydrationValue;\n\t}\n\n\tprivate isObject(value: unknown): value is Record<string, unknown> {\n\t\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n\t}\n\n\tprivate findHydrationScriptElement(): Element | null {\n\t\treturn findHydrationScript(resolveContextHydrationHost(this.host), 'context', this.hydrationKey);\n\t}\n\n\tprivate notifySubscribers = (newContext: ContextType<T>, prevContext: ContextType<T> | undefined) => {\n\t\tfor (const sub of this.subscriptions) {\n\t\t\tif (sub.hasChanged(newContext, prevContext)) {\n\t\t\t\tsub.notify(newContext);\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate handleSubscriptionRequest = (\n\t\tsubscription: ContextSubscription<T, unknown>,\n\t\t{\n\t\t\tsubscribe,\n\t\t\tonSubscribe,\n\t\t}: {\n\t\t\tsubscribe?: boolean;\n\t\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t\t},\n\t) => {\n\t\tthis.tryHydrateFromHost();\n\t\tconst unsubscribe = subscribe ? this.subscribe(subscription) : undefined;\n\n\t\tif (unsubscribe) {\n\t\t\tonSubscribe?.(unsubscribe);\n\t\t}\n\n\t\tif (typeof this.value === 'undefined') return;\n\n\t\tif (subscription.select) {\n\t\t\tsubscription.callback(subscription.select(this.value), unsubscribe);\n\t\t} else {\n\t\t\tsubscription.callback(this.value, unsubscribe);\n\t\t}\n\t};\n\n\tprivate onSubscriptionRequest = (event: ContextSubscriptionRequestEvent<UnknownContext>) => {\n\t\tconst { context, callback, subscribe, select, target, onSubscribe } = event;\n\t\tif (context !== this.context) return;\n\n\t\tevent.markHandled();\n\t\tevent.stopPropagation();\n\n\t\tif (target instanceof EventTarget) {\n\t\t\ttarget.dispatchEvent(new ContextOnMountEvent(this.context));\n\t\t}\n\n\t\tif (select) {\n\t\t\tthis.handleSubscriptionRequest({ select, callback }, { subscribe, onSubscribe });\n\t\t\treturn;\n\t\t}\n\n\t\tthis.handleSubscriptionRequest({ callback }, { subscribe, onSubscribe });\n\t};\n\n\tprivate onContextRequest = (event: ContextRequestEvent<UnknownContext>) => {\n\t\tconst { context, callback } = event;\n\t\tif (context !== this.context) return;\n\t\tevent.markHandled();\n\t\tevent.stopPropagation();\n\t\tcallback(this);\n\t};\n\n\tprivate registerEvents = () => {\n\t\tthis.host.addEventListener(\n\t\t\tContextEventsTypes.SUBSCRIPTION_REQUEST,\n\t\t\tthis.onSubscriptionRequest as EventListener,\n\t\t);\n\t\tthis.host.addEventListener(ContextEventsTypes.CONTEXT_REQUEST, this.onContextRequest as EventListener);\n\t};\n}\n",
|
|
11
|
+
"import type { ContextHostLike } from '../../context-host';\nimport { ContextProvider } from '../../context-provider';\nimport type { UnknownContext } from '../../types';\nimport type { ProvideContextOptions } from '../provide-context';\n\nexport function provideContext<T extends UnknownContext>({\n\tcontext,\n\tinitialValue,\n\thydrate,\n\tserialize,\n}: ProvideContextOptions<T>) {\n\treturn <C extends ContextHostLike, V>(target: undefined, targetContext: ClassFieldDecoratorContext<C, V>) => {\n\t\tvoid target;\n\t\tconst contextName = String(targetContext.name);\n\t\ttargetContext.addInitializer(function (this: C) {\n\t\t\tconst hostRecord = this as C & Record<string, unknown>;\n\t\t\tconst provider = new ContextProvider<T>(this, {\n\t\t\t\tcontext,\n\t\t\t\thydrationKey: contextName,\n\t\t\t\tinitialValue,\n\t\t\t\thydrate,\n\t\t\t\tserialize,\n\t\t\t});\n\t\t\thostRecord[contextName] = provider;\n\t\t\tthis.registerContextProvider(contextName, provider);\n\t\t\tthis.connectedContextCallback(context);\n\t\t});\n\t};\n}\n"
|
|
5
12
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
13
|
+
"mappings": "2PAIO,SAAS,CAAgB,CAAC,EAAuB,CACvD,OAAO,EACL,QAAQ,KAAM,SAAS,EACvB,QAAQ,KAAM,SAAS,EACvB,QAAQ,KAAM,SAAS,EACvB,QAAQ,UAAW,SAAS,EAC5B,QAAQ,UAAW,SAAS,ECPxB,IAAM,EAAsB,iBAEtB,EAA2B,sBAE3B,EAA0B,qBAUhC,SAAS,CAAwB,CAAC,EAI9B,CACV,IAAM,EAAe,EAAQ,aAC1B,IAAI,MAA4B,EAAoB,EAAQ,YAAY,KACxE,GAEH,MAAO,mCAAmC,KAAuB,MAA6B,EAAQ,QAAQ,KAAgB,EAAQ,2BAIhI,SAAS,CAAmB,CAAC,EAAuB,CAC1D,OAAO,EAAiB,CAAK,EAIvB,SAAS,CAAwB,CAAC,EAAkB,EAAgB,CAC1E,IAAM,EAAc,EAAQ,YAE5B,GAAI,CAAC,EACJ,OAAO,EAGR,GAAI,CACH,OAAO,KAAK,MAAM,CAAW,EAC5B,KAAM,CACP,GAAI,OAAO,QAAY,IACtB,QAAQ,KACP,sEAAsE,MACtE,EAAY,MAAM,EAAG,GAAG,CACzB,EAED,OAAO,GAUF,SAAS,CAAmB,CAClC,EACA,EACA,EACiB,CACjB,IAAM,EAAW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AElE,OAAa,SAAS,KAAK,MAAO,CAAW,GAIvC,sBAAwB,CAAC,IAA2D,CAC3F,IAAQ,UAAS,WAAU,YAAW,SAAQ,SAAQ,eAAgB,EACtE,GAAI,IAAY,KAAK,QAAS,OAK9B,GAHA,EAAM,YAAY,EAClB,EAAM,gBAAgB,EAElB,aAAkB,YACrB,EAAO,cAAc,IAAI,EAAoB,KAAK,OAAO,CAAC,EAG3D,GAAI,EAAQ,CACX,KAAK,0BAA0B,CAAE,SAAQ,UAAS,EAAG,CAAE,YAAW,aAAY,CAAC,EAC/E,OAGD,KAAK,0BAA0B,CAAE,UAAS,EAAG,CAAE,YAAW,aAAY,CAAC,GAGhE,iBAAmB,CAAC,IAA+C,CAC1E,IAAQ,UAAS,YAAa,EAC9B,GAAI,IAAY,KAAK,QAAS,OAC9B,EAAM,YAAY,EAClB,EAAM,gBAAgB,EACtB,EAAS,IAAI,GAGN,eAAiB,IAAM,CAC9B,KAAK,KAAK,gDAET,KAAK,qBACN,EACA,KAAK,KAAK,mCAAqD,KAAK,gBAAiC,EAEvG,CC7VO,SAAS,CAAwC,EACvD,UACA,eACA,UACA,aAC4B,CAC5B,MAAO,CAA+B,EAAmB,IAAoD,CAE5G,IAAM,EAAc,OAAO,EAAc,IAAI,EAC7C,EAAc,eAAe,QAAS,EAAU,CAC/C,IAAM,EAAa,KACb,EAAW,IAAI,EAAmB,KAAM,CAC7C,UACA,aAAc,EACd,eACA,UACA,WACD,CAAC,EACD,EAAW,GAAe,EAC1B,KAAK,wBAAwB,EAAa,CAAQ,EAClD,KAAK,yBAAyB,CAAO,EACrC",
|
|
14
|
+
"debugId": "38CB6638F936059564756E2164756E21",
|
|
8
15
|
"names": []
|
|
9
16
|
}
|
package/dist/context/events.d.ts
CHANGED
|
@@ -22,15 +22,22 @@ export declare class ContextRequestEvent<T extends UnknownContext> extends Event
|
|
|
22
22
|
readonly context: T;
|
|
23
23
|
readonly callback: ContextCallback<ContextType<T>>;
|
|
24
24
|
readonly subscribe?: boolean | undefined;
|
|
25
|
+
handled: boolean;
|
|
25
26
|
constructor(context: T, callback: ContextCallback<ContextType<T>>, subscribe?: boolean | undefined);
|
|
27
|
+
markHandled(): void;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* A type which represents a subscription to a context value.
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
|
-
select?:
|
|
32
|
-
callback:
|
|
32
|
+
type DirectContextSubscription<T extends UnknownContext> = {
|
|
33
|
+
select?: undefined;
|
|
34
|
+
callback: ContextCallback<ContextType<T>>;
|
|
33
35
|
};
|
|
36
|
+
type SelectedContextSubscription<T extends UnknownContext, Selected> = {
|
|
37
|
+
select: (context: ContextType<T>) => Selected;
|
|
38
|
+
callback: ContextCallback<Selected>;
|
|
39
|
+
};
|
|
40
|
+
export type ContextSubscription<T extends UnknownContext, Selected = ContextType<T>> = DirectContextSubscription<T> | SelectedContextSubscription<T, Selected>;
|
|
34
41
|
/**
|
|
35
42
|
* An event fired by a context provider to signal that a context value has been mounted and is available for consumption.
|
|
36
43
|
*/
|
|
@@ -51,16 +58,15 @@ export declare class ContextOnMountEvent extends CustomEvent<{
|
|
|
51
58
|
*
|
|
52
59
|
* It accepts a `selector` property which can be used to request a specific property of the context value.
|
|
53
60
|
*/
|
|
54
|
-
export declare class ContextSubscriptionRequestEvent<T extends UnknownContext
|
|
61
|
+
export declare class ContextSubscriptionRequestEvent<T extends UnknownContext, Selected = ContextType<T>> extends Event {
|
|
55
62
|
readonly context: T;
|
|
56
|
-
readonly callback:
|
|
57
|
-
|
|
58
|
-
}) => void;
|
|
59
|
-
readonly select?: ((context: ContextType<T>) => unknown) | undefined;
|
|
63
|
+
readonly callback: ContextCallback<Selected>;
|
|
64
|
+
readonly select?: ((context: ContextType<T>) => Selected) | undefined;
|
|
60
65
|
readonly subscribe?: boolean | undefined;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
readonly onSubscribe?: ((unsubscribe: () => void) => void) | undefined;
|
|
67
|
+
handled: boolean;
|
|
68
|
+
constructor(context: T, callback: ContextCallback<Selected>, select?: ((context: ContextType<T>) => Selected) | undefined, subscribe?: boolean | undefined, onSubscribe?: ((unsubscribe: () => void) => void) | undefined);
|
|
69
|
+
markHandled(): void;
|
|
64
70
|
}
|
|
65
71
|
declare global {
|
|
66
72
|
interface HTMLElementEventMap {
|
|
@@ -81,3 +87,4 @@ declare global {
|
|
|
81
87
|
[ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;
|
|
82
88
|
}
|
|
83
89
|
}
|
|
90
|
+
export {};
|
package/dist/context/events.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
var H=((j)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(j,{get:(q,w)=>(typeof require<"u"?require:q)[w]}):j)(function(j){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+j+'" is not supported')});var z;((k)=>{k.SUBSCRIPTION_REQUEST="context-subscription-request";k.CONTEXT_REQUEST="context-request";k.ON_MOUNT="context-on-mount";k.MOUNTED="context-mounted"})(z||={});class B extends Event{context;callback;subscribe;handled=!1;constructor(j,q,w){super("context-request",{bubbles:!0,composed:!0});this.context=j;this.callback=q;this.subscribe=w}markHandled(){this.handled=!0}}class D extends CustomEvent{constructor(j){super("context-on-mount",{detail:{context:j},bubbles:!0,composed:!0})}}class F extends Event{context;callback;select;subscribe;onSubscribe;handled=!1;constructor(j,q,w,G,k){super("context-subscription-request",{bubbles:!0,composed:!0});this.context=j;this.callback=q;this.select=w;this.subscribe=G;this.onSubscribe=k}markHandled(){this.handled=!0}}export{F as ContextSubscriptionRequestEvent,B as ContextRequestEvent,D as ContextOnMountEvent,z as ContextEventsTypes};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=770F94756FFF592164756E2164756E21
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/context/events.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import type { Context, ContextCallback, ContextType, UnknownContext } from './types';\n\n/**\n * List of events which can be emitted by a context provider or requester.\n */\nexport enum ContextEventsTypes {\n\tSUBSCRIPTION_REQUEST = 'context-subscription-request',\n\tCONTEXT_REQUEST = 'context-request',\n\tON_MOUNT = 'context-on-mount',\n\tMOUNTED = 'context-mounted',\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n */\nexport class ContextRequestEvent<T extends UnknownContext> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<ContextType<T>>,\n\t\tpublic readonly subscribe?: boolean,\n\t) {\n\t\tsuper(ContextEventsTypes.CONTEXT_REQUEST, { bubbles: true, composed: true });\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\n/**\n * A type which represents a subscription to a context value.\n */\ntype DirectContextSubscription<T extends UnknownContext> = {\n\tselect?: undefined;\n\tcallback: ContextCallback<ContextType<T>>;\n};\n\ntype SelectedContextSubscription<T extends UnknownContext, Selected> = {\n\tselect: (context: ContextType<T>) => Selected;\n\tcallback: ContextCallback<Selected>;\n};\n\nexport type ContextSubscription<T extends UnknownContext, Selected = ContextType<T>> =\n\t| DirectContextSubscription<T>\n\t| SelectedContextSubscription<T, Selected>;\n\n/**\n * An event fired by a context provider to signal that a context value has been mounted and is available for consumption.\n */\nexport class ContextOnMountEvent extends CustomEvent<{ context: UnknownContext }> {\n\tpublic constructor(context: UnknownContext) {\n\t\tsuper(ContextEventsTypes.ON_MOUNT, {\n\t\t\tdetail: { context },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n *\n * It accepts a `selector` property which can be used to request a specific property of the context value.\n */\nexport class ContextSubscriptionRequestEvent<T extends UnknownContext, Selected = ContextType<T>> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<Selected>,\n\t\tpublic readonly select?: (context: ContextType<T>) => Selected,\n\t\tpublic readonly subscribe?: boolean,\n\t\tpublic readonly onSubscribe?: (unsubscribe: () => void) => void,\n\t) {\n\t\tsuper(ContextEventsTypes.SUBSCRIPTION_REQUEST, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementEventMap {\n\t\t/**\n\t\t * A 'context-request-subscription' event can be emitted by any element which desires\n\t\t * a context value to be injected by an external provider.\n\t\t */\n\t\t[ContextEventsTypes.SUBSCRIPTION_REQUEST]: ContextSubscriptionRequestEvent<UnknownContext>;\n\t\t/**\n\t\t * A context-request-provider event can be emitted by a context requester to signal\n\t\t * that it desires a context value to be provided by a context provider.\n\t\t */\n\t\t[ContextEventsTypes.CONTEXT_REQUEST]: ContextRequestEvent<Context<unknown, unknown>>;\n\t\t/**\n\t\t * A 'context-mount' event can be emitted by a context provider to signal\n\t\t * that a context value has been mounted and is available for consumption.\n\t\t */\n\t\t[ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;\n\t}\n}\n"
|
|
5
6
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
7
|
+
"mappings": "2PAKO,IAAK,GAAL,CAAK,IAAL,CACN,uBAAuB,+BACvB,kBAAkB,kBAClB,WAAW,mBACX,UAAU,oBAJC,QAiBL,MAAM,UAAsD,KAAM,CAIvD,QACA,SACA,UALV,QAAU,GAEV,WAAW,CACD,EACA,EACA,EACf,CACD,MAAM,kBAAoC,CAAE,QAAS,GAAM,SAAU,EAAK,CAAC,EAJ3D,eACA,gBACA,iBAKV,WAAW,EAAS,CAC1B,KAAK,QAAU,GAEjB,CAsBO,MAAM,UAA4B,WAAyC,CAC1E,WAAW,CAAC,EAAyB,CAC3C,MAAM,mBAA6B,CAClC,OAAQ,CAAE,SAAQ,EAClB,QAAS,GACT,SAAU,EACX,CAAC,EAEH,CAcO,MAAM,UAA6F,KAAM,CAI9F,QACA,SACA,OACA,UACA,YAPV,QAAU,GAEV,WAAW,CACD,EACA,EACA,EACA,EACA,EACf,CACD,MAAM,+BAAyC,CAC9C,QAAS,GACT,SAAU,EACX,CAAC,EATe,eACA,gBACA,cACA,iBACA,mBAQV,WAAW,EAAS,CAC1B,KAAK,QAAU,GAEjB",
|
|
8
|
+
"debugId": "770F94756FFF592164756E2164756E21",
|
|
8
9
|
"names": []
|
|
9
10
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
var W=((g)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(g,{get:(q,z)=>(typeof require<"u"?require:q)[z]}):g)(function(g){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+g+'" is not supported')});function $(g){return g.replace(/&/g,"\\u0026").replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var V="data-hydration",u="data-hydration-type",Q="data-hydration-key";function w(g){let q=g.hydrationKey?` ${Q}="${J(g.hydrationKey)}"`:"";return`<script type="application/json" ${V} ${u}="${g.type}"${q}>${g.serializedValue}</script>`}function F(g){return $(g)}function S(g,q){let z=g.textContent;if(!z)return q;try{return JSON.parse(z)}catch{if(typeof console<"u")console.warn(`[@ecopages/radiant] Failed to parse hydration payload from <script ${V}>:`,z.slice(0,120));return q}}function f(g,q,z){let L=g.children;if(!L||L.length===0){let G=g.childNodes;if(!G||G.length===0)return null;for(let M=0;M<G.length;M+=1){let X=G[M];if(X.nodeType!==1)continue;let Z=X;if(j(Z,q,z))return Z}return null}for(let G=0;G<L.length;G+=1)if(j(L[G],q,z))return L[G];return null}function j(g,q,z){if(g.tagName!=="SCRIPT"||!g.hasAttribute(V)||g.getAttribute(u)!==q)return!1;if(z!==void 0)return g.getAttribute(Q)===z;return!g.hasAttribute(Q)}function J(g){return g.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function B(g){return w({type:"context",...g})}function D(g){return F(g)}export{D as escapeContextHydrationJson,B as createContextHydrationScriptTag};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=530D675E1503267864756E2164756E21
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/tools/escape-script-json.ts", "../src/core/hydration-codec.ts", "../src/context/hydration-script.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, '<').replace(/>/g, '>');\n}\n",
|
|
7
|
+
"import { createHydrationScriptTag, escapeHydrationJson } from '../core/hydration-codec';\n\n/**\n * Creates the raw `<script type=\"application/json\">` tag used to hydrate a\n * serialized context provider.\n */\nexport function createContextHydrationScriptTag(options: { hydrationKey?: string; serializedValue: string }): string {\n\treturn createHydrationScriptTag({ type: 'context', ...options });\n}\n\n/**\n * Escapes serialized JSON so it remains safe when embedded inside an HTML\n * script tag.\n */\nexport function escape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EAAS,OAAQ,GAAK,EACzC,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,EChHhG,SAAS,CAA+B,CAAC,EAAqE,CACpH,OAAO,EAAyB,CAAE,KAAM,aAAc,CAAQ,CAAC,EAOzD,SAAS,CAA0B,CAAC,EAAuB,CACjE,OAAO,EAAoB,CAAK",
|
|
10
|
+
"debugId": "530D675E1503267864756E2164756E21",
|
|
8
11
|
"names": []
|
|
9
12
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RadiantController } from './core/radiant-controller';
|
|
2
|
+
export declare const CONTROLLER_ATTRIBUTE = "data-controller";
|
|
3
|
+
export type ControllerConstructor<TController extends RadiantController = RadiantController> = new (host: Element) => TController;
|
|
4
|
+
export type ControllerRegistrationStrategy = 'keep-current' | 'replace';
|
|
5
|
+
export declare class ControllerRegistryRuntime {
|
|
6
|
+
private readonly root;
|
|
7
|
+
private readonly controllersByElement;
|
|
8
|
+
private observer?;
|
|
9
|
+
private stopped;
|
|
10
|
+
constructor(root?: ParentNode);
|
|
11
|
+
stop(): void;
|
|
12
|
+
reconcileRegisteredController(identifier: string): void;
|
|
13
|
+
replaceRegisteredController(identifier: string): void;
|
|
14
|
+
private start;
|
|
15
|
+
private reconcileElement;
|
|
16
|
+
private connectController;
|
|
17
|
+
private disconnectController;
|
|
18
|
+
private disconnectElementControllers;
|
|
19
|
+
}
|
|
20
|
+
export declare function registerController<TController extends RadiantController, TConstructor extends ControllerConstructor<TController>>(identifier: string, controller: TConstructor): TConstructor;
|
|
21
|
+
export declare function hasRegisteredController(identifier: string): boolean;
|
|
22
|
+
export declare function replaceController<TController extends RadiantController, TConstructor extends ControllerConstructor<TController>>(identifier: string, controller: TConstructor): TConstructor;
|
|
23
|
+
export declare function setControllerRegistrationStrategy(strategy: ControllerRegistrationStrategy): void;
|
|
24
|
+
export declare function enableControllerReplacementForHmr(): void;
|
|
25
|
+
export declare function disableControllerReplacementForHmr(): void;
|
|
26
|
+
export declare function registerControllerWithConfiguredStrategy<TController extends RadiantController, TConstructor extends ControllerConstructor<TController>>(identifier: string, controller: TConstructor): TConstructor;
|
|
27
|
+
export declare function startControllers(root?: ParentNode): ControllerRegistryRuntime;
|
|
28
|
+
export declare function stopControllers(): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var z=((E)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(E,{get:(C,I)=>(typeof require<"u"?require:C)[I]}):E)(function(E){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+E+'" is not supported')});var F=Symbol.for("@ecopages/radiant.controllerIdentifier");function D(E,C){E[F]=C}function B(E){return E[F]}var M="data-controller",_=Symbol.for("@ecopages/radiant.controller-registry-state");function k(){let E=globalThis,C=E[_];if(C)return C;let I={activeRuntimes:new Set,controllerRegistrationStrategy:"keep-current",controllerRegistry:new Map};return E[_]=I,I}var W=k(),h=W.controllerRegistry,T=W.activeRuntimes;function p(E){let C=E.getAttribute(M);if(!C)return[];return C.split(/\s+/).map((I)=>I.trim()).filter((I)=>I.length>0)}function u(E,C){if(E instanceof Element&&E.hasAttribute(M))C(E);for(let I of Array.from(E.querySelectorAll(`[${M}]`)))C(I)}class R{root;controllersByElement=new Map;observer;stopped=!1;constructor(E=document){this.root=E;this.start()}stop(){if(this.stopped)return;this.stopped=!0,this.observer?.disconnect(),this.observer=void 0;for(let[E,C]of this.controllersByElement)for(let[I]of C)this.disconnectController(E,I);T.delete(this)}reconcileRegisteredController(E){u(this.root,(C)=>{if(!p(C).includes(E))return;this.connectController(C,E)})}replaceRegisteredController(E){for(let[C,I]of Array.from(this.controllersByElement.entries())){if(!I.has(E))continue;this.disconnectController(C,E)}this.reconcileRegisteredController(E)}start(){if(u(this.root,(C)=>{this.reconcileElement(C)}),typeof MutationObserver>"u"){T.add(this);return}this.observer=new MutationObserver((C)=>{for(let I of C){if(I.type==="attributes"&&I.target instanceof Element){this.reconcileElement(I.target);continue}for(let L of Array.from(I.removedNodes)){if(!(L instanceof Element))continue;u(L,(O)=>{this.disconnectElementControllers(O)})}for(let L of Array.from(I.addedNodes)){if(!(L instanceof Element))continue;u(L,(O)=>{this.reconcileElement(O)})}}});let E=this.root instanceof Document?this.root.documentElement:this.root;this.observer.observe(E,{attributeFilter:[M],attributes:!0,childList:!0,subtree:!0}),T.add(this)}reconcileElement(E){let C=new Set(p(E)),I=this.controllersByElement.get(E);if(I){for(let L of I.keys())if(!C.has(L))this.disconnectController(E,L)}for(let L of C)this.connectController(E,L)}connectController(E,C){let I=h.get(C);if(!I)return;let L=this.controllersByElement.get(E);if(!L)L=new Map,this.controllersByElement.set(E,L);if(L.has(C))return;let O=new I(E);L.set(C,O),O.connect()}disconnectController(E,C){let I=this.controllersByElement.get(E);if(!I)return;let L=I.get(C);if(!L)return;if(L.disconnect(),I.delete(C),I.size===0)this.controllersByElement.delete(E)}disconnectElementControllers(E){let C=this.controllersByElement.get(E);if(!C)return;for(let I of Array.from(C.keys()))this.disconnectController(E,I)}}function q(E,C){let I=h.get(E);if(I)return I;D(C,E),h.set(E,C);for(let L of Array.from(T))L.reconcileRegisteredController(E);return C}function J(E){return h.has(E)}function w(E,C){if(h.get(E)===C)return C;D(C,E),h.set(E,C);for(let L of Array.from(T))L.replaceRegisteredController(E);return C}function j(E){W.controllerRegistrationStrategy=E}function K(){j("replace")}function N(){j("keep-current")}function P(E,C){if(W.controllerRegistrationStrategy==="replace")return w(E,C);return q(E,C)}function Q(E=document){return new R(E)}function U(){for(let E of Array.from(T))E.stop()}export{U as stopControllers,Q as startControllers,j as setControllerRegistrationStrategy,w as replaceController,P as registerControllerWithConfiguredStrategy,q as registerController,J as hasRegisteredController,K as enableControllerReplacementForHmr,N as disableControllerReplacementForHmr,R as ControllerRegistryRuntime,M as CONTROLLER_ATTRIBUTE};
|
|
2
|
+
|
|
3
|
+
//# debugId=0DF824DAB57E9F9764756E2164756E21
|
|
@@ -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(activeRuntimes)) {\n\t\truntime.stop();\n\t}\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "2PAAO,IAAM,EAAwB,OAAO,IAAI,wCAAwC,EAMjF,SAAS,CAAuB,CAAC,EAAkC,EAA0B,CAClG,EAA6C,GAAyB,EAGjE,SAAS,CAAuB,CAAC,EAAsD,CAC7F,OAAQ,EAA6C,GCR/C,IAAM,EAAuB,kBAc9B,EAAgC,OAAO,IAAI,6CAA6C,EAE9F,SAAS,CAAgC,EAAkC,CAC1E,IAAM,EAAc,WACd,EAAgB,EAAY,GAElC,GAAI,EACH,OAAO,EAGR,IAAM,EAA2C,CAChD,eAAgB,IAAI,IACpB,+BAAgC,eAChC,mBAAoB,IAAI,GACzB,EAIA,OAFA,EAAY,GAAiC,EAEtC,EAGR,IAAM,EAA0B,EAAiC,EAC3D,EAAqB,EAAwB,mBAC7C,EAAiB,EAAwB,eAE/C,SAAS,CAA0B,CAAC,EAA4B,CAC/D,IAAM,EAAQ,EAAQ,aAAa,CAAoB,EAEvD,GAAI,CAAC,EACJ,MAAO,CAAC,EAGT,OAAO,EACL,MAAM,KAAK,EACX,IAAI,CAAC,IAAe,EAAW,KAAK,CAAC,EACrC,OAAO,CAAC,IAAe,EAAW,OAAS,CAAC,EAG/C,SAAS,CAAuB,CAAC,EAAkB,EAAyC,CAC3F,GAAI,aAAgB,SAAW,EAAK,aAAa,CAAoB,EACpE,EAAM,CAAI,EAGX,QAAW,KAAW,MAAM,KAAK,EAAK,iBAAiB,IAAI,IAAuB,CAAC,EAClF,EAAM,CAAO,EAIR,MAAM,CAA0B,CAKT,KAJZ,qBAAuB,IAAI,IACpC,SACA,QAAU,GAElB,WAAW,CAAkB,EAAmB,SAAU,CAA7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K,qBAAqB,EAAS,CAAU,EAGhD,CAEO,SAAS,CAGf,CAAC,EAAoB,EAAwC,CAC7D,IAAM,EAAqB,EAAmB,IAAI,CAAU,EAE5D,GAAI,EACH,OAAO,EAGR,EAAwB,EAAmD,CAAU,EACrF,EAAmB,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, '<').replace(/>/g, '>');\n}\n"
|
|
5
7
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
8
|
+
"mappings": "2PAIO,SAAS,CAAgB,CAAC,EAAuB,CACvD,OAAO,EACL,QAAQ,KAAM,SAAS,EACvB,QAAQ,KAAM,SAAS,EACvB,QAAQ,KAAM,SAAS,EACvB,QAAQ,UAAW,SAAS,EAC5B,QAAQ,UAAW,SAAS,ECPxB,IAAM,EAAsB,iBAEtB,EAA2B,sBAE3B,EAA0B,qBAUhC,SAAS,CAAwB,CAAC,EAI9B,CACV,IAAM,EAAe,EAAQ,aAC1B,IAAI,MAA4B,EAAoB,EAAQ,YAAY,KACxE,GAEH,MAAO,mCAAmC,KAAuB,MAA6B,EAAQ,QAAQ,KAAgB,EAAQ,2BAIhI,SAAS,CAAmB,CAAC,EAAuB,CAC1D,OAAO,EAAiB,CAAK,EAIvB,SAAS,CAAwB,CAAC,EAAkB,EAAgB,CAC1E,IAAM,EAAc,EAAQ,YAE5B,GAAI,CAAC,EACJ,OAAO,EAGR,GAAI,CACH,OAAO,KAAK,MAAM,CAAW,EAC5B,KAAM,CACP,GAAI,OAAO,QAAY,IACtB,QAAQ,KACP,sEAAsE,MACtE,EAAY,MAAM,EAAG,GAAG,CACzB,EAED,OAAO,GAUF,SAAS,CAAmB,CAClC,EACA,EACA,EACiB,CACjB,IAAM,EAAW,EAAK,SAEtB,GAAI,CAAC,GAAY,EAAS,SAAW,EAAG,CACvC,IAAM,EAAc,EAAkE,WAEtF,GAAI,CAAC,GAAc,EAAW,SAAW,EACxC,OAAO,KAGR,QAAS,EAAI,EAAG,EAAI,EAAW,OAAQ,GAAK,EAAG,CAC9C,IAAM,EAAO,EAAW,GAExB,GAAI,EAAK,WAAa,EACrB,SAGD,IAAM,EAAU,EAEhB,GAAI,EAAuB,EAAS,EAAM,CAAY,EACrD,OAAO,EAIT,OAAO,KAGR,QAAS,EAAI,EAAG,EAAI,EAAS,OAAQ,GAAK,EACzC,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.ssr-context-provider-resolver");function $(){return globalThis}function f(t){$()[e]=t}function N(t){return $()[e]?.(t)}var b=Symbol.for("@ecopages/radiant.customElementTagName");function K(t,n){t[b]=n}function z(t){return t[b]}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()}f((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=z(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=16B2C294F53D386064756E2164756E21
|