@ecopages/radiant 0.3.0-beta.2 → 0.3.0-beta.3
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 +11 -7
- package/client/app-bootstrap.js +2 -2
- package/client/app-bootstrap.js.map +2 -2
- package/client/hydrator.js +2 -2
- package/client/hydrator.js.map +2 -2
- package/client/install-hydrator.js +2 -2
- package/client/install-hydrator.js.map +2 -2
- package/context/context-consumer-bootstrap.js +2 -2
- package/context/context-consumer-bootstrap.js.map +4 -4
- package/context/context-consumer-runtime.js +2 -2
- package/context/context-consumer-runtime.js.map +4 -4
- package/context/context-host.js +2 -2
- package/context/context-host.js.map +2 -2
- package/context/context-provider.js +2 -2
- package/context/context-provider.js.map +2 -2
- package/context/context-ssr-bridge.d.ts +1 -1
- package/context/context-ssr-bridge.js +2 -2
- package/context/context-ssr-bridge.js.map +3 -3
- package/context/create-context.js +2 -2
- package/context/create-context.js.map +2 -2
- package/context/decorators/consume-context.js +2 -2
- package/context/decorators/consume-context.js.map +4 -4
- package/context/decorators/context-selection-delivery.js +2 -2
- package/context/decorators/context-selection-delivery.js.map +2 -2
- package/context/decorators/context-selector.js +2 -2
- package/context/decorators/context-selector.js.map +4 -4
- package/context/decorators/legacy/consume-context.js +2 -2
- package/context/decorators/legacy/consume-context.js.map +4 -4
- package/context/decorators/legacy/context-selector-field.js +2 -2
- package/context/decorators/legacy/context-selector-field.js.map +4 -4
- package/context/decorators/legacy/context-selector.js +2 -2
- package/context/decorators/legacy/context-selector.js.map +4 -4
- package/context/decorators/legacy/provide-context.js +2 -2
- package/context/decorators/legacy/provide-context.js.map +2 -2
- package/context/decorators/on-context-update.js +2 -2
- package/context/decorators/on-context-update.js.map +4 -4
- package/context/decorators/provide-context.js +2 -2
- package/context/decorators/provide-context.js.map +2 -2
- package/context/decorators/standard/consume-context.js +2 -2
- package/context/decorators/standard/consume-context.js.map +4 -4
- package/context/decorators/standard/context-selector-field.js +2 -2
- package/context/decorators/standard/context-selector-field.js.map +4 -4
- package/context/decorators/standard/context-selector.js +2 -2
- package/context/decorators/standard/context-selector.js.map +4 -4
- package/context/decorators/standard/provide-context.js +2 -2
- package/context/decorators/standard/provide-context.js.map +2 -2
- package/context/decorators/standard-legacy-dispatch.js +2 -2
- package/context/decorators/standard-legacy-dispatch.js.map +2 -2
- package/context/events.js +2 -2
- package/context/events.js.map +2 -2
- package/context/hydration-script.js +2 -2
- package/context/hydration-script.js.map +2 -2
- package/context/index.js +2 -2
- package/context/index.js.map +4 -4
- package/controller-registry.js +2 -2
- package/controller-registry.js.map +2 -2
- package/core/controller-metadata.js +2 -2
- package/core/controller-metadata.js.map +2 -2
- package/core/custom-element-metadata.js +2 -2
- package/core/custom-element-metadata.js.map +2 -2
- package/core/event-subscription-registry.js +2 -2
- package/core/event-subscription-registry.js.map +2 -2
- package/core/host-ssr-registry.js +2 -2
- package/core/host-ssr-registry.js.map +2 -2
- package/core/hydration-capable-host.js +2 -2
- package/core/hydration-capable-host.js.map +2 -2
- package/core/hydration-codec.js +2 -2
- package/core/hydration-codec.js.map +2 -2
- package/core/radiant-controller.js +2 -2
- package/core/radiant-controller.js.map +2 -2
- package/core/radiant-element-brand.d.ts +2 -0
- package/core/radiant-element-brand.js +3 -0
- package/core/radiant-element-brand.js.map +10 -0
- package/core/radiant-element-ssr-host-source.d.ts +32 -0
- package/core/radiant-element-ssr-host-source.js +3 -0
- package/core/radiant-element-ssr-host-source.js.map +11 -0
- package/core/radiant-element-ssr-host.d.ts +5 -6
- package/core/radiant-element-ssr-host.js +1 -2
- package/core/radiant-element-ssr-host.js.map +3 -4
- package/core/radiant-element-ssr-registry.d.ts +24 -11
- package/core/radiant-element-ssr-registry.js +2 -2
- package/core/radiant-element-ssr-registry.js.map +3 -3
- package/core/radiant-element.d.ts +5 -3
- package/core/radiant-element.js +2 -2
- package/core/radiant-element.js.map +6 -5
- package/core/radiant-hydrator-state.js +2 -2
- package/core/radiant-hydrator-state.js.map +2 -2
- package/core/reactive-binding-adapter.js +2 -2
- package/core/reactive-binding-adapter.js.map +2 -2
- package/core/reactive-host.js +2 -2
- package/core/reactive-host.js.map +2 -2
- package/core/reactive-jsx-value.js +2 -2
- package/core/reactive-jsx-value.js.map +2 -2
- package/core/reactive-prop-core.js +2 -2
- package/core/reactive-prop-core.js.map +2 -2
- package/core/reactive-prop-metadata.js +2 -2
- package/core/reactive-prop-metadata.js.map +2 -2
- package/core/reactive-property-state.js +2 -2
- package/core/reactive-property-state.js.map +2 -2
- package/core/reactivity-adapter.js +2 -2
- package/core/reactivity-adapter.js.map +2 -2
- package/core/reactivity-runtime.js +2 -2
- package/core/reactivity-runtime.js.map +2 -2
- package/core/reactivity-signals.js +2 -2
- package/core/reactivity-signals.js.map +2 -2
- package/core/render-runtime.js +2 -2
- package/core/render-runtime.js.map +2 -2
- package/core/render-scheduler.js +2 -2
- package/core/render-scheduler.js.map +2 -2
- package/core/slot-projection-runtime.js +2 -2
- package/core/slot-projection-runtime.js.map +2 -2
- package/core/ssr-preparation.js +2 -2
- package/core/ssr-preparation.js.map +2 -2
- package/decorators/attr.js +2 -2
- package/decorators/attr.js.map +2 -2
- package/decorators/bound.js +2 -2
- package/decorators/bound.js.map +2 -2
- package/decorators/bridge.js +2 -2
- package/decorators/bridge.js.map +2 -2
- package/decorators/controller.js +2 -2
- package/decorators/controller.js.map +2 -2
- package/decorators/custom-element.js +2 -2
- package/decorators/custom-element.js.map +2 -2
- package/decorators/debounce.js +2 -2
- package/decorators/debounce.js.map +2 -2
- package/decorators/event.js +2 -2
- package/decorators/event.js.map +2 -2
- package/decorators/legacy/attr.js +2 -2
- package/decorators/legacy/attr.js.map +2 -2
- package/decorators/legacy/bound.js +2 -2
- package/decorators/legacy/bound.js.map +2 -2
- package/decorators/legacy/custom-element.js +2 -2
- package/decorators/legacy/custom-element.js.map +2 -2
- package/decorators/legacy/debounce.js +2 -2
- package/decorators/legacy/debounce.js.map +2 -2
- package/decorators/legacy/event.js +2 -2
- package/decorators/legacy/event.js.map +2 -2
- package/decorators/legacy/host-readiness.js +2 -2
- package/decorators/legacy/host-readiness.js.map +2 -2
- package/decorators/legacy/instance-initializers.js +2 -2
- package/decorators/legacy/instance-initializers.js.map +2 -2
- package/decorators/legacy/member-bootstrap.js +2 -2
- package/decorators/legacy/member-bootstrap.js.map +2 -2
- package/decorators/legacy/on-event.js +2 -2
- package/decorators/legacy/on-event.js.map +2 -2
- package/decorators/legacy/on-updated.js +2 -2
- package/decorators/legacy/on-updated.js.map +2 -2
- package/decorators/legacy/query-slot.js +2 -2
- package/decorators/legacy/query-slot.js.map +2 -2
- package/decorators/legacy/query.js +2 -2
- package/decorators/legacy/query.js.map +2 -2
- package/decorators/legacy/reactive-field.js +2 -2
- package/decorators/legacy/reactive-field.js.map +2 -2
- package/decorators/legacy/reactive-prop.js +2 -2
- package/decorators/legacy/reactive-prop.js.map +2 -2
- package/decorators/legacy/signal.js +2 -2
- package/decorators/legacy/signal.js.map +2 -2
- package/decorators/on-event.js +2 -2
- package/decorators/on-event.js.map +2 -2
- package/decorators/on-updated.js +2 -2
- package/decorators/on-updated.js.map +2 -2
- package/decorators/prop.js +2 -2
- package/decorators/prop.js.map +2 -2
- package/decorators/query-slot.js +2 -2
- package/decorators/query-slot.js.map +2 -2
- package/decorators/query.js +2 -2
- package/decorators/query.js.map +2 -2
- package/decorators/shared/auto-bind.js +2 -2
- package/decorators/shared/auto-bind.js.map +2 -2
- package/decorators/shared/reactive-attr.js +2 -2
- package/decorators/shared/reactive-attr.js.map +2 -2
- package/decorators/signal.js +2 -2
- package/decorators/signal.js.map +2 -2
- package/decorators/standard/attr.js +2 -2
- package/decorators/standard/attr.js.map +2 -2
- package/decorators/standard/bound.js +2 -2
- package/decorators/standard/bound.js.map +2 -2
- package/decorators/standard/custom-element.js +2 -2
- package/decorators/standard/custom-element.js.map +2 -2
- package/decorators/standard/debounce.js +2 -2
- package/decorators/standard/debounce.js.map +2 -2
- package/decorators/standard/event.js +2 -2
- package/decorators/standard/event.js.map +2 -2
- package/decorators/standard/on-event.js +2 -2
- package/decorators/standard/on-event.js.map +2 -2
- package/decorators/standard/on-updated.js +2 -2
- package/decorators/standard/on-updated.js.map +2 -2
- package/decorators/standard/query-slot.js +2 -2
- package/decorators/standard/query-slot.js.map +2 -2
- package/decorators/standard/query.js +2 -2
- package/decorators/standard/query.js.map +2 -2
- package/decorators/standard/reactive-field.js +2 -2
- package/decorators/standard/reactive-field.js.map +2 -2
- package/decorators/standard/reactive-prop.js +2 -2
- package/decorators/standard/reactive-prop.js.map +2 -2
- package/decorators/standard/signal.js +2 -2
- package/decorators/standard/signal.js.map +2 -2
- package/decorators/state.js +2 -2
- package/decorators/state.js.map +2 -2
- package/helpers/create-event-listener.js +2 -2
- package/helpers/create-event-listener.js.map +2 -2
- package/helpers/create-event.js +2 -2
- package/helpers/create-event.js.map +2 -2
- package/helpers/create-query-slot.js +2 -2
- package/helpers/create-query-slot.js.map +2 -2
- package/helpers/create-query.js +2 -2
- package/helpers/create-query.js.map +2 -2
- package/helpers/debounce.js +2 -2
- package/helpers/debounce.js.map +2 -2
- package/helpers/index.js +2 -2
- package/helpers/index.js.map +2 -2
- package/index.js +2 -2
- package/index.js.map +6 -5
- package/package.json +13 -3
- package/server/assert-light-dom-ssr.d.ts +10 -0
- package/server/assert-light-dom-ssr.js +3 -0
- package/server/assert-light-dom-ssr.js.map +10 -0
- package/server/context-ssr.d.ts +8 -19
- package/server/context-ssr.js +2 -2
- package/server/context-ssr.js.map +5 -5
- package/server/host-attribute-serialization.js +2 -2
- package/server/host-attribute-serialization.js.map +4 -4
- package/server/host-script-composition.js +2 -2
- package/server/host-script-composition.js.map +2 -2
- package/server/html-parser.js +2 -2
- package/server/html-parser.js.map +2 -2
- package/server/install-light-dom-shim.d.ts +2 -1
- package/server/install-light-dom-shim.js +2 -2
- package/server/install-light-dom-shim.js.map +9 -8
- package/server/install-ssr-runtime.d.ts +8 -0
- package/server/install-ssr-runtime.js +3 -0
- package/server/install-ssr-runtime.js.map +21 -0
- package/server/install-ssr-scope-adapters.d.ts +1 -0
- package/server/install-ssr-scope-adapters.js +3 -0
- package/server/install-ssr-scope-adapters.js.map +11 -0
- package/server/light-dom-shim.js +2 -2
- package/server/light-dom-shim.js.map +8 -7
- package/server/minimal-dom/dataset.d.ts +2 -0
- package/server/minimal-dom/dataset.js +3 -0
- package/server/minimal-dom/dataset.js.map +10 -0
- package/server/minimal-dom/document.js +2 -2
- package/server/minimal-dom/document.js.map +5 -6
- package/server/minimal-dom/html.d.ts +1 -2
- package/server/minimal-dom/html.js +2 -2
- package/server/minimal-dom/html.js.map +6 -5
- package/server/minimal-dom/install.d.ts +1 -0
- package/server/minimal-dom/install.js +2 -2
- package/server/minimal-dom/install.js.map +8 -7
- package/server/minimal-dom/nodes.d.ts +9 -0
- package/server/minimal-dom/nodes.js +3 -0
- package/server/minimal-dom/nodes.js.map +12 -0
- package/server/project-root.js +2 -2
- package/server/project-root.js.map +4 -5
- package/server/radiant-element-ssr-bridge.d.ts +9 -9
- package/server/radiant-element-ssr-bridge.js +2 -2
- package/server/radiant-element-ssr-bridge.js.map +27 -14
- package/server/radiant-element-ssr-extractor.d.ts +5 -1
- package/server/radiant-element-ssr-extractor.js +2 -2
- package/server/radiant-element-ssr-extractor.js.map +6 -5
- package/server/radiant-element-ssr-service.d.ts +4 -1
- package/server/radiant-element-ssr-service.js +2 -2
- package/server/radiant-element-ssr-service.js.map +15 -12
- package/server/radiant-element-ssr.d.ts +1 -1
- package/server/radiant-element-ssr.js +2 -2
- package/server/radiant-element-ssr.js.map +27 -14
- package/server/render-component.d.ts +3 -5
- package/server/render-component.js +2 -2
- package/server/render-component.js.map +27 -20
- package/server/render-controller.d.ts +1 -0
- package/server/render-controller.js +2 -2
- package/server/render-controller.js.map +30 -23
- package/server/render-fragment.js +2 -2
- package/server/render-fragment.js.map +2 -2
- package/server/slot-projection-html.js +2 -2
- package/server/slot-projection-html.js.map +5 -6
- package/signals/host-resource.js +2 -2
- package/signals/host-resource.js.map +2 -2
- package/signals/host-signal.js +2 -2
- package/signals/host-signal.js.map +2 -2
- package/signals/hydration-script.js +2 -2
- package/signals/hydration-script.js.map +2 -2
- package/tools/escape-css-identifier.js +2 -2
- package/tools/escape-css-identifier.js.map +2 -2
- package/tools/escape-script-json.js +2 -2
- package/tools/escape-script-json.js.map +2 -2
- package/tools/event-emitter.js +2 -2
- package/tools/event-emitter.js.map +2 -2
- package/tools/index.js +2 -2
- package/tools/index.js.map +2 -2
- package/tools/render-jsx-template.js +2 -2
- package/tools/render-jsx-template.js.map +2 -2
- package/types.js +2 -2
- package/types.js.map +2 -2
- package/utils/attribute-utils.js +2 -2
- package/utils/attribute-utils.js.map +2 -2
- package/utils/escape-html-attribute.js +2 -2
- package/utils/escape-html-attribute.js.map +2 -2
- package/utils/index.js +2 -2
- package/utils/index.js.map +2 -2
- package/server/internal-radiant-host.d.ts +0 -2
- package/server/internal-radiant-host.js +0 -3
- package/server/internal-radiant-host.js.map +0 -9
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "AAYO,SAAS,CAA0B,CAAC,EAAkC,CAC5E,OAAQ,QACF,MACJ,MAAO,aACH,QACJ,MAAO,eACH,OACJ,MAAO,cACH,OACJ,MAAO,cACH,OACJ,MAAO,UAUH,SAAS,CAAyB,CAAC,EAAqC,CAC9E,OAAQ,OAAO,OACT,UACJ,MAAO,cACH,SACJ,MAAO,aACH,SACJ,MAAO,SAGT,GAAI,MAAM,QAAQ,CAAY,EAAG,MAAO,QACxC,GAAI,OAAO,UAAU,SAAS,KAAK,CAAY,IAAM,kBAAmB,MAAO,SASzE,SAAS,CAAmB,CAAC,EAAsC,CACzE,OAAQ,QACF,OACJ,MAAO,QACH,OACJ,MAAO,QACH,QACJ,MAAO,WAEP,OAAO,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SAAS,CAAQ,CAAC,EAAiC,CAClD,OAAO,OAAO,IAAU,SAGzB,SAAS,CAAQ,CAAC,EAAiC,CAClD,OAAO,OAAO,IAAU,SAGzB,SAAS,CAAO,CAAC,EAAyC,CACzD,OAAO,MAAM,QAAQ,CAAK,EAG3B,SAAS,CAAQ,CAAC,EAAiC,CAClD,OAAO,OAAO,IAAU,UAAY,CAAC,MAAM,QAAQ,CAAK,GAAK,IAAU,KAMjE,SAAS,CAAa,CAAC,EAA6B,EAAgC,CAC1F,OAAQ,QACF,QACJ,OAAO,EAAU,CAAY,OACzB,OACJ,OAAO,EAAS,CAAY,OACxB,OACJ,OAAO,EAAS,CAAY,OACxB,MACJ,OAAO,EAAQ,CAAY,OACvB,OACJ,OAAO,EAAS,CAAY,UAE5B,MAAO,IAIH,IAAM,EAAkB,CAC9B,EACA,EACA,EACA,IACI,CACJ,GAAI,IAAS,QAAS,CACrB,IAAM,EAAiB,EAAO,aAAa,CAAY,EACvD,GAAI,IAAmB,KACtB,OAAO,EAGR,OAAO,IAAmB,GAAK,GAAO,EAAmB,EAAgB,CAAI,EAG9E,IAAM,EAAiB,EAAO,aAAa,CAAY,EACvD,OAAO,IAAmB,KACvB,EAAmB,EAAgB,CAAI,EACtC,GAAiB,EAAoB,CAAI",
|
|
8
|
+
"debugId": "D6D6ED020FA42D9464756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
function t(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}export{t as escapeHtmlAttribute};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=DDB72A2D22C6C1DC64756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/** Escapes a string for safe interpolation inside a double-quoted HTML attribute value. */\nexport function escapeHtmlAttribute(value: string): string {\n\treturn value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "AACO,SAAS,CAAmB,CAAC,EAAuB,CAC1D,OAAO,EAAM,QAAQ,KAAM,OAAO,EAAE,QAAQ,KAAM,QAAQ,EAAE,QAAQ,KAAM,MAAM,EAAE,QAAQ,KAAM,MAAM",
|
|
8
|
+
"debugId": "DDB72A2D22C6C1DC64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/utils/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
function P(x){switch(x){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function R(x){switch(typeof x){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(x))return"array";if(Object.prototype.toString.call(x)==="[object Object]")return"object"}function U(x){switch(x){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function W(x){try{return JSON.parse(x)}catch{throw TypeError("Invalid JSON string")}}var X={array(x){let q=W(x);if(!Array.isArray(q))throw TypeError(`Expected an array but got a value of type "${typeof q}"`);return q},boolean(x){return!(x==="0"||String(x).toLowerCase()==="false")},number(x){return Number(x.replace(/_/g,""))},object(x){let q=JSON.parse(x);if(q===null||typeof q!=="object"||Array.isArray(q))throw TypeError(`expected value of type "object" but instead got value "${x}" of type "${R(q)}"`);return q},string(x){return x}},I={default:Q,array:L,object:L};function L(x){return JSON.stringify(x)}function Q(x){return`${x}`}function M(x,q){let z=P(q);if(!z)throw TypeError(`[radiant-element] Unknown type "${q}"`);return X[z](x)}function m(x,q){let z=P(q);if(!z)throw TypeError(`[radiant-element] Unknown type "${q}"`);return(I[z]??I.default??Q)(x)}function Y(x){return typeof x==="boolean"}function Z(x){return typeof x==="number"}function _(x){return typeof x==="string"}function $(x){return Array.isArray(x)}function k(x){return typeof x==="object"&&!Array.isArray(x)&&x!==null}function B(x,q){switch(x){case Boolean:return Y(q);case Number:return Z(q);case String:return _(q);case Array:return $(q);case Object:return k(q);default:return!1}}var D=(x,q,z,E)=>{if(q===Boolean){let G=x.getAttribute(z);if(G===null)return E;return G===""?!0:M(G,q)}let H=x.getAttribute(z);return H!==null?M(H,q):E??U(q)};export{m as writeAttributeValue,M as readAttributeValue,R as parseAttributeTypeDefault,P as parseAttributeTypeConstant,B as isValueOfType,D as getInitialValue,U as defaultValueForType};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=17DBD5747580687064756E2164756E21
|
package/utils/index.js.map
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "AAYO,SAAS,CAA0B,CAAC,EAAkC,CAC5E,OAAQ,QACF,MACJ,MAAO,aACH,QACJ,MAAO,eACH,OACJ,MAAO,cACH,OACJ,MAAO,cACH,OACJ,MAAO,UAUH,SAAS,CAAyB,CAAC,EAAqC,CAC9E,OAAQ,OAAO,OACT,UACJ,MAAO,cACH,SACJ,MAAO,aACH,SACJ,MAAO,SAGT,GAAI,MAAM,QAAQ,CAAY,EAAG,MAAO,QACxC,GAAI,OAAO,UAAU,SAAS,KAAK,CAAY,IAAM,kBAAmB,MAAO,SASzE,SAAS,CAAmB,CAAC,EAAsC,CACzE,OAAQ,QACF,OACJ,MAAO,QACH,OACJ,MAAO,QACH,QACJ,MAAO,WAEP,OAAO,MASV,SAAS,CAAY,CAAC,EAAkB,CACvC,GAAI,CACH,OAAO,KAAK,MAAM,CAAK,EACtB,KAAM,CACP,MAAU,UAAU,qBAAqB,GAQ3C,IAAM,EAAsC,CAC3C,KAAK,CAAC,EAA0B,CAC/B,IAAM,EAAQ,EAAqB,CAAK,EACxC,GAAI,CAAC,MAAM,QAAQ,CAAK,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U,UAAY,CAAC,MAAM,QAAQ,CAAK,GAAK,IAAU,KAMjE,SAAS,CAAa,CAAC,EAA6B,EAAgC,CAC1F,OAAQ,QACF,QACJ,OAAO,EAAU,CAAY,OACzB,OACJ,OAAO,EAAS,CAAY,OACxB,OACJ,OAAO,EAAS,CAAY,OACxB,MACJ,OAAO,EAAQ,CAAY,OACvB,OACJ,OAAO,EAAS,CAAY,UAE5B,MAAO,IAIH,IAAM,EAAkB,CAC9B,EACA,EACA,EACA,IACI,CACJ,GAAI,IAAS,QAAS,CACrB,IAAM,EAAiB,EAAO,aAAa,CAAY,EACvD,GAAI,IAAmB,KACtB,OAAO,EAGR,OAAO,IAAmB,GAAK,GAAO,EAAmB,EAAgB,CAAI,EAG9E,IAAM,EAAiB,EAAO,aAAa,CAAY,EACvD,OAAO,IAAmB,KACvB,EAAmB,EAAgB,CAAI,EACtC,GAAiB,EAAoB,CAAI",
|
|
8
|
+
"debugId": "17DBD5747580687064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var{defineProperty:k,getOwnPropertyNames:q,getOwnPropertyDescriptor:u}=Object,v=Object.prototype.hasOwnProperty;function w(b){return this[b]}var z=(b)=>{var f=(p??=new WeakMap).get(b),g;if(f)return f;if(f=k({},"__esModule",{value:!0}),b&&typeof b==="object"||typeof b==="function"){for(var j of q(b))if(!v.call(f,j))k(f,j,{get:w.bind(b,j),enumerable:!(g=u(b,j))||g.enumerable})}return p.set(b,f),f},p;var x=(b)=>b;function y(b,f){this[b]=x.bind(null,f)}var A=(b,f)=>{for(var g in f)k(b,g,{get:f[g],enumerable:!0,configurable:!0,set:y.bind(f,g)})};var B=(b,f)=>()=>(b&&(f=b(b=0)),f);var C=((b)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(b,{get:(f,g)=>(typeof require<"u"?require:f)[g]}):b)(function(b){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+b+'" is not supported')});export{G as isInternalRadiantSsrHost};
|
|
2
|
-
|
|
3
|
-
//# debugId=E6BA89028EDCE99064756E2164756E21
|