@designos/renderer-svelte 0.1.0 → 1.0.1
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/LICENSE +21 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 relacloud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ interface SvelteComponentInput {
|
|
|
14
14
|
component: unknown;
|
|
15
15
|
/** Authored PageNode props. */
|
|
16
16
|
props: Record<string, unknown>;
|
|
17
|
+
design: RenderNodeView<unknown>["design"];
|
|
17
18
|
/** Rendered default children, kept separate from named slots. */
|
|
18
19
|
children: unknown[];
|
|
19
20
|
/** Rendered named slot contents keyed by slot name. */
|
|
@@ -41,7 +42,7 @@ interface SvelteRendererOptions extends RendererOptions {
|
|
|
41
42
|
* Build a runtime tree with the host's Svelte runtime. No Svelte package is loaded here:
|
|
42
43
|
* Svelte component creation APIs differ by major version and execution environment.
|
|
43
44
|
*/
|
|
44
|
-
declare function createSvelteRenderer<T>(runtime: SvelteHostRuntime<T>, options: SvelteRendererOptions): (
|
|
45
|
+
declare function createSvelteRenderer<T>(runtime: SvelteHostRuntime<T>, options: SvelteRendererOptions): (page: _designos_core.PageDocument, design?: _designos_core.DesignDocument) => T;
|
|
45
46
|
/** Alias for callers that prefer the package-level renderer naming. */
|
|
46
47
|
declare const createRenderer: typeof createSvelteRenderer;
|
|
47
48
|
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createRenderer as createSharedRenderer } from \"@designos/renderer-core\";\nimport type { RenderNodeView, RendererOptions } from \"@designos/renderer-core\";\n\n/** Compiler target paired with this renderer package. */\nexport const rendererTarget = { id: \"svelte\", kind: \"runtime\" } as const;\nexport type { RendererAdapter, RendererOptions, RenderNodeView, NodeComposition } from \"@designos/renderer-core\";\nexport { renderPageDocument, resolveNodeComposition } from \"@designos/renderer-core\";\n\n/** Values a host renderer needs to create one instance of a mapped component. */\nexport interface SvelteComponentInput {\n /** Resolved host component constructor/definition, or undefined when missing. */\n component: unknown;\n /** Authored PageNode props. */\n props: Record<string, unknown>;\n /** Rendered default children, kept separate from named slots. */\n children: unknown[];\n /** Rendered named slot contents keyed by slot name. */\n slots: Record<string, unknown[]>;\n /** Stable PageDocument identity and location metadata. */\n node: RenderNodeView<unknown>[\"node\"];\n parentId?: string;\n slotName?: string;\n /** True only for an unresolved mapping rendered through missingComponent. */\n missing: boolean;\n}\n\n/** Host-runtime integration contract; implement with the Svelte version/runtime used by the host. */\nexport interface SvelteHostRuntime<T> {\n createComponent(input: SvelteComponentInput): T;\n /** Optional deterministic fallback for unknown component types. */\n missingComponent?(type: string, input: SvelteComponentInput): T;\n}\n\nexport interface SvelteRendererOptions extends RendererOptions {\n /** Mapping from PageNode.type to Svelte component definitions/constructors. */\n components: Readonly<Record<string, unknown>> | ReadonlyMap<string, unknown>;\n /** Throw on unmapped nodes if no host missingComponent fallback is supplied. Defaults to true. */\n throwOnMissing?: boolean;\n}\n\nfunction lookupComponent(components: SvelteRendererOptions[\"components\"], type: string): unknown {\n if (\"get\" in components && typeof components.get === \"function\") return components.get(type);\n return (components as Readonly<Record<string, unknown>>)[type];\n}\n\n/**\n * Build a runtime tree with the host's Svelte runtime. No Svelte package is loaded here:\n * Svelte component creation APIs differ by major version and execution environment.\n */\nexport function createSvelteRenderer<T>(runtime: SvelteHostRuntime<T>, options: SvelteRendererOptions) {\n const { components, throwOnMissing = true, registry } = options;\n return createSharedRenderer<T>({\n renderNode(view) {\n const component = lookupComponent(components, view.node.type);\n const missing = component === undefined;\n const input: SvelteComponentInput = {\n component,\n props: view.props,\n children: view.children,\n slots: view.slots,\n node: view.node,\n parentId: view.parentId,\n slotName: view.slotName,\n missing,\n };\n if (missing) {\n if (runtime.missingComponent) return runtime.missingComponent(view.node.type, input);\n if (throwOnMissing) throw new Error(`No Svelte component mapped for PageNode type \"${view.node.type}\"`);\n }\n return runtime.createComponent(input);\n },\n }, { registry });\n}\n/** Alias for callers that prefer the package-level renderer naming. */\nexport const createRenderer = createSvelteRenderer;\n"],"mappings":";AAAA,SAAS,kBAAkB,4BAA4B;AAMvD,SAAS,oBAAoB,8BAA8B;AAFpD,IAAM,iBAAiB,EAAE,IAAI,UAAU,MAAM,UAAU;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createRenderer as createSharedRenderer } from \"@designos/renderer-core\";\nimport type { RenderNodeView, RendererOptions } from \"@designos/renderer-core\";\n\n/** Compiler target paired with this renderer package. */\nexport const rendererTarget = { id: \"svelte\", kind: \"runtime\" } as const;\nexport type { RendererAdapter, RendererOptions, RenderNodeView, NodeComposition } from \"@designos/renderer-core\";\nexport { renderPageDocument, resolveNodeComposition } from \"@designos/renderer-core\";\n\n/** Values a host renderer needs to create one instance of a mapped component. */\nexport interface SvelteComponentInput {\n /** Resolved host component constructor/definition, or undefined when missing. */\n component: unknown;\n /** Authored PageNode props. */\n props: Record<string, unknown>;\n design: RenderNodeView<unknown>[\"design\"];\n /** Rendered default children, kept separate from named slots. */\n children: unknown[];\n /** Rendered named slot contents keyed by slot name. */\n slots: Record<string, unknown[]>;\n /** Stable PageDocument identity and location metadata. */\n node: RenderNodeView<unknown>[\"node\"];\n parentId?: string;\n slotName?: string;\n /** True only for an unresolved mapping rendered through missingComponent. */\n missing: boolean;\n}\n\n/** Host-runtime integration contract; implement with the Svelte version/runtime used by the host. */\nexport interface SvelteHostRuntime<T> {\n createComponent(input: SvelteComponentInput): T;\n /** Optional deterministic fallback for unknown component types. */\n missingComponent?(type: string, input: SvelteComponentInput): T;\n}\n\nexport interface SvelteRendererOptions extends RendererOptions {\n /** Mapping from PageNode.type to Svelte component definitions/constructors. */\n components: Readonly<Record<string, unknown>> | ReadonlyMap<string, unknown>;\n /** Throw on unmapped nodes if no host missingComponent fallback is supplied. Defaults to true. */\n throwOnMissing?: boolean;\n}\n\nfunction lookupComponent(components: SvelteRendererOptions[\"components\"], type: string): unknown {\n if (\"get\" in components && typeof components.get === \"function\") return components.get(type);\n return (components as Readonly<Record<string, unknown>>)[type];\n}\n\n/**\n * Build a runtime tree with the host's Svelte runtime. No Svelte package is loaded here:\n * Svelte component creation APIs differ by major version and execution environment.\n */\nexport function createSvelteRenderer<T>(runtime: SvelteHostRuntime<T>, options: SvelteRendererOptions) {\n const { components, throwOnMissing = true, registry } = options;\n return createSharedRenderer<T>({\n renderNode(view) {\n const component = lookupComponent(components, view.node.type);\n const missing = component === undefined;\n const input: SvelteComponentInput = {\n component,\n props: view.props,\n design: view.design,\n children: view.children,\n slots: view.slots,\n node: view.node,\n parentId: view.parentId,\n slotName: view.slotName,\n missing,\n };\n if (missing) {\n if (runtime.missingComponent) return runtime.missingComponent(view.node.type, input);\n if (throwOnMissing) throw new Error(`No Svelte component mapped for PageNode type \"${view.node.type}\"`);\n }\n return runtime.createComponent(input);\n },\n }, { registry });\n}\n/** Alias for callers that prefer the package-level renderer naming. */\nexport const createRenderer = createSvelteRenderer;\n"],"mappings":";AAAA,SAAS,kBAAkB,4BAA4B;AAMvD,SAAS,oBAAoB,8BAA8B;AAFpD,IAAM,iBAAiB,EAAE,IAAI,UAAU,MAAM,UAAU;AAqC9D,SAAS,gBAAgB,YAAiD,MAAuB;AAC/F,MAAI,SAAS,cAAc,OAAO,WAAW,QAAQ,WAAY,QAAO,WAAW,IAAI,IAAI;AAC3F,SAAQ,WAAiD,IAAI;AAC/D;AAMO,SAAS,qBAAwB,SAA+B,SAAgC;AACrG,QAAM,EAAE,YAAY,iBAAiB,MAAM,SAAS,IAAI;AACxD,SAAO,qBAAwB;AAAA,IAC7B,WAAW,MAAM;AACf,YAAM,YAAY,gBAAgB,YAAY,KAAK,KAAK,IAAI;AAC5D,YAAM,UAAU,cAAc;AAC9B,YAAM,QAA8B;AAAA,QAClC;AAAA,QACA,OAAO,KAAK;AAAA,QACZ,QAAQ,KAAK;AAAA,QACb,UAAU,KAAK;AAAA,QACf,OAAO,KAAK;AAAA,QACZ,MAAM,KAAK;AAAA,QACX,UAAU,KAAK;AAAA,QACf,UAAU,KAAK;AAAA,QACf;AAAA,MACF;AACA,UAAI,SAAS;AACX,YAAI,QAAQ,iBAAkB,QAAO,QAAQ,iBAAiB,KAAK,KAAK,MAAM,KAAK;AACnF,YAAI,eAAgB,OAAM,IAAI,MAAM,iDAAiD,KAAK,KAAK,IAAI,GAAG;AAAA,MACxG;AACA,aAAO,QAAQ,gBAAgB,KAAK;AAAA,IACtC;AAAA,EACF,GAAG,EAAE,SAAS,CAAC;AACjB;AAEO,IAAM,iBAAiB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designos/renderer-svelte",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"private": false,
|
|
5
6
|
"type": "module",
|
|
6
7
|
"exports": {
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
}
|
|
11
12
|
},
|
|
12
13
|
"dependencies": {
|
|
13
|
-
"@designos/renderer-core": "0.1
|
|
14
|
+
"@designos/renderer-core": "1.0.1"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"tsup": "^8.5.0",
|