@pyreon/storybook 0.6.0 → 0.8.0

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.
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
5386
5386
  </script>
5387
5387
  <script>
5388
5388
  /*<!--*/
5389
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"home/runner/work/fundamentals/fundamentals/node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js","uid":"a15c263f-1"},{"name":"src","children":[{"uid":"a15c263f-3","name":"render-impl.tsx"},{"uid":"a15c263f-5","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"a15c263f-1":{"renderedLength":1640,"gzipLength":827,"brotliLength":0,"metaUid":"a15c263f-0"},"a15c263f-3":{"renderedLength":1280,"gzipLength":673,"brotliLength":0,"metaUid":"a15c263f-2"},"a15c263f-5":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"a15c263f-4"}},"nodeMetas":{"a15c263f-0":{"id":"/home/runner/work/fundamentals/fundamentals/node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js","moduleParts":{"index.js":"a15c263f-1"},"imported":[],"importedBy":[{"uid":"a15c263f-2"}]},"a15c263f-2":{"id":"/src/render-impl.tsx","moduleParts":{"index.js":"a15c263f-3"},"imported":[{"uid":"a15c263f-9"},{"uid":"a15c263f-0"}],"importedBy":[{"uid":"a15c263f-6"}]},"a15c263f-4":{"id":"/src/index.ts","moduleParts":{"index.js":"a15c263f-5"},"imported":[{"uid":"a15c263f-6"},{"uid":"a15c263f-7"},{"uid":"a15c263f-8"},{"uid":"a15c263f-9"}],"importedBy":[],"isEntry":true},"a15c263f-6":{"id":"/src/render.ts","moduleParts":{},"imported":[{"uid":"a15c263f-2"}],"importedBy":[{"uid":"a15c263f-4"}]},"a15c263f-7":{"id":"@pyreon/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"a15c263f-4"}]},"a15c263f-8":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"a15c263f-4"}]},"a15c263f-9":{"id":"@pyreon/runtime-dom","moduleParts":{},"imported":[],"importedBy":[{"uid":"a15c263f-4"},{"uid":"a15c263f-2"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5389
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"home/runner/work/fundamentals/fundamentals/node_modules/.bun/@pyreon+core@0.7.3/node_modules/@pyreon/core/lib/jsx-runtime.js","uid":"104a5477-1"},{"name":"src","children":[{"uid":"104a5477-3","name":"render-impl.tsx"},{"uid":"104a5477-5","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"104a5477-1":{"renderedLength":1640,"gzipLength":828,"brotliLength":0,"metaUid":"104a5477-0"},"104a5477-3":{"renderedLength":1280,"gzipLength":673,"brotliLength":0,"metaUid":"104a5477-2"},"104a5477-5":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"104a5477-4"}},"nodeMetas":{"104a5477-0":{"id":"/home/runner/work/fundamentals/fundamentals/node_modules/.bun/@pyreon+core@0.7.3/node_modules/@pyreon/core/lib/jsx-runtime.js","moduleParts":{"index.js":"104a5477-1"},"imported":[],"importedBy":[{"uid":"104a5477-2"}]},"104a5477-2":{"id":"/src/render-impl.tsx","moduleParts":{"index.js":"104a5477-3"},"imported":[{"uid":"104a5477-9"},{"uid":"104a5477-0"}],"importedBy":[{"uid":"104a5477-6"}]},"104a5477-4":{"id":"/src/index.ts","moduleParts":{"index.js":"104a5477-5"},"imported":[{"uid":"104a5477-6"},{"uid":"104a5477-7"},{"uid":"104a5477-8"},{"uid":"104a5477-9"}],"importedBy":[],"isEntry":true},"104a5477-6":{"id":"/src/render.ts","moduleParts":{},"imported":[{"uid":"104a5477-2"}],"importedBy":[{"uid":"104a5477-4"}]},"104a5477-7":{"id":"@pyreon/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"104a5477-4"}]},"104a5477-8":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"104a5477-4"}]},"104a5477-9":{"id":"@pyreon/runtime-dom","moduleParts":{},"imported":[],"importedBy":[{"uid":"104a5477-4"},{"uid":"104a5477-2"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5390
5390
 
5391
5391
  const run = () => {
5392
5392
  const width = window.innerWidth;
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
5386
5386
  </script>
5387
5387
  <script>
5388
5388
  /*<!--*/
5389
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"preview.js","children":[{"name":"home/runner/work/fundamentals/fundamentals/node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js","uid":"3cdd8ae0-1"},{"name":"src","children":[{"uid":"3cdd8ae0-3","name":"render-impl.tsx"},{"uid":"3cdd8ae0-5","name":"preview-impl.tsx"},{"uid":"3cdd8ae0-7","name":"preview.ts"}]}]}],"isRoot":true},"nodeParts":{"3cdd8ae0-1":{"renderedLength":1634,"gzipLength":823,"brotliLength":0,"metaUid":"3cdd8ae0-0"},"3cdd8ae0-3":{"renderedLength":1100,"gzipLength":595,"brotliLength":0,"metaUid":"3cdd8ae0-2"},"3cdd8ae0-5":{"renderedLength":452,"gzipLength":313,"brotliLength":0,"metaUid":"3cdd8ae0-4"},"3cdd8ae0-7":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"3cdd8ae0-6"}},"nodeMetas":{"3cdd8ae0-0":{"id":"/home/runner/work/fundamentals/fundamentals/node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js","moduleParts":{"preview.js":"3cdd8ae0-1"},"imported":[],"importedBy":[{"uid":"3cdd8ae0-4"},{"uid":"3cdd8ae0-2"}]},"3cdd8ae0-2":{"id":"/src/render-impl.tsx","moduleParts":{"preview.js":"3cdd8ae0-3"},"imported":[{"uid":"3cdd8ae0-8"},{"uid":"3cdd8ae0-0"}],"importedBy":[{"uid":"3cdd8ae0-4"}]},"3cdd8ae0-4":{"id":"/src/preview-impl.tsx","moduleParts":{"preview.js":"3cdd8ae0-5"},"imported":[{"uid":"3cdd8ae0-2"},{"uid":"3cdd8ae0-0"}],"importedBy":[{"uid":"3cdd8ae0-6"}]},"3cdd8ae0-6":{"id":"/src/preview.ts","moduleParts":{"preview.js":"3cdd8ae0-7"},"imported":[{"uid":"3cdd8ae0-4"}],"importedBy":[],"isEntry":true},"3cdd8ae0-8":{"id":"@pyreon/runtime-dom","moduleParts":{},"imported":[],"importedBy":[{"uid":"3cdd8ae0-2"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5389
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"preview.js","children":[{"name":"home/runner/work/fundamentals/fundamentals/node_modules/.bun/@pyreon+core@0.7.3/node_modules/@pyreon/core/lib/jsx-runtime.js","uid":"0572966a-1"},{"name":"src","children":[{"uid":"0572966a-3","name":"render-impl.tsx"},{"uid":"0572966a-5","name":"preview-impl.tsx"},{"uid":"0572966a-7","name":"preview.ts"}]}]}],"isRoot":true},"nodeParts":{"0572966a-1":{"renderedLength":1634,"gzipLength":824,"brotliLength":0,"metaUid":"0572966a-0"},"0572966a-3":{"renderedLength":1100,"gzipLength":595,"brotliLength":0,"metaUid":"0572966a-2"},"0572966a-5":{"renderedLength":452,"gzipLength":313,"brotliLength":0,"metaUid":"0572966a-4"},"0572966a-7":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"0572966a-6"}},"nodeMetas":{"0572966a-0":{"id":"/home/runner/work/fundamentals/fundamentals/node_modules/.bun/@pyreon+core@0.7.3/node_modules/@pyreon/core/lib/jsx-runtime.js","moduleParts":{"preview.js":"0572966a-1"},"imported":[],"importedBy":[{"uid":"0572966a-4"},{"uid":"0572966a-2"}]},"0572966a-2":{"id":"/src/render-impl.tsx","moduleParts":{"preview.js":"0572966a-3"},"imported":[{"uid":"0572966a-8"},{"uid":"0572966a-0"}],"importedBy":[{"uid":"0572966a-4"}]},"0572966a-4":{"id":"/src/preview-impl.tsx","moduleParts":{"preview.js":"0572966a-5"},"imported":[{"uid":"0572966a-2"},{"uid":"0572966a-0"}],"importedBy":[{"uid":"0572966a-6"}]},"0572966a-6":{"id":"/src/preview.ts","moduleParts":{"preview.js":"0572966a-7"},"imported":[{"uid":"0572966a-4"}],"importedBy":[],"isEntry":true},"0572966a-8":{"id":"@pyreon/runtime-dom","moduleParts":{},"imported":[],"importedBy":[{"uid":"0572966a-2"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5390
5390
 
5391
5391
  const run = () => {
5392
5392
  const width = window.innerWidth;
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import { mount, mount as mount$1 } from "@pyreon/runtime-dom";
2
2
  import { Fragment, h } from "@pyreon/core";
3
3
  import { computed, effect, signal } from "@pyreon/reactivity";
4
4
 
5
- //#region ../../node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js
5
+ //#region ../../node_modules/.bun/@pyreon+core@0.7.3/node_modules/@pyreon/core/lib/jsx-runtime.js
6
6
  /**
7
7
  * Hyperscript function — the compiled output of JSX.
8
8
  * `<div class="x">hello</div>` → `h("div", { class: "x" }, "hello")`
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["h","mount"],"sources":["../../../node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js","../src/render-impl.tsx"],"sourcesContent":["//#region src/h.ts\n/** Marker for fragment nodes — renders children without a wrapper element */\nconst Fragment = Symbol(\"Pyreon.Fragment\");\n/**\n* Hyperscript function — the compiled output of JSX.\n* `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n*\n* Generic on P so TypeScript validates props match the component's signature\n* at the call site, then stores the result in the loosely-typed VNode.\n*/\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nconst EMPTY_PROPS = {};\nfunction h(type, props, ...children) {\n\treturn {\n\t\ttype,\n\t\tprops: props ?? EMPTY_PROPS,\n\t\tchildren: normalizeChildren(children),\n\t\tkey: props?.key ?? null\n\t};\n}\nfunction normalizeChildren(children) {\n\tfor (let i = 0; i < children.length; i++) if (Array.isArray(children[i])) return flattenChildren(children);\n\treturn children;\n}\nfunction flattenChildren(children) {\n\tconst result = [];\n\tfor (const child of children) if (Array.isArray(child)) result.push(...flattenChildren(child));\n\telse result.push(child);\n\treturn result;\n}\n\n//#endregion\n//#region src/jsx-runtime.ts\n/**\n* JSX automatic runtime.\n*\n* When tsconfig has `\"jsxImportSource\": \"@pyreon/core\"`, the TS/bundler compiler\n* rewrites JSX to imports from this file automatically:\n* <div class=\"x\" /> → jsx(\"div\", { class: \"x\" })\n*/\nfunction jsx(type, props, key) {\n\tconst { children, ...rest } = props;\n\tconst propsWithKey = key != null ? {\n\t\t...rest,\n\t\tkey\n\t} : rest;\n\tif (typeof type === \"function\") return h(type, children !== void 0 ? {\n\t\t...propsWithKey,\n\t\tchildren\n\t} : propsWithKey);\n\treturn h(type, propsWithKey, ...children === void 0 ? [] : Array.isArray(children) ? children : [children]);\n}\nconst jsxs = jsx;\n\n//#endregion\nexport { Fragment, jsx, jsxs };\n//# sourceMappingURL=jsx-runtime.js.map","import type { ComponentFn, VNodeChild } from '@pyreon/core'\nimport { mount } from '@pyreon/runtime-dom'\n\n/**\n * State tracked per canvas element so we can clean up between renders.\n */\nconst canvasState = new WeakMap<HTMLElement, () => void>()\n\n/**\n * Render a Pyreon story into a Storybook canvas element.\n *\n * This is the core integration point — Storybook calls this function\n * every time a story needs to be displayed or re-rendered (e.g. when\n * the user changes args via the Controls panel).\n *\n * It handles:\n * 1. Cleaning up the previous mount (disposing effects, removing DOM)\n * 2. Building the VNode from the story function or component + args\n * 3. Mounting the new VNode into the canvas\n */\nexport function renderToCanvas(\n {\n storyFn,\n showMain,\n showError,\n }: {\n storyFn: () => VNodeChild\n storyContext: {\n component?: ComponentFn<any>\n args: Record<string, unknown>\n [key: string]: unknown\n }\n showMain: () => void\n showError: (error: { title: string; description: string }) => void\n forceRemount: boolean\n },\n canvasElement: HTMLElement,\n): void {\n // Always clean up the previous render\n const prevUnmount = canvasState.get(canvasElement)\n if (prevUnmount) {\n prevUnmount()\n canvasState.delete(canvasElement)\n }\n\n try {\n const element = storyFn()\n const unmount = mount(element, canvasElement)\n canvasState.set(canvasElement, unmount)\n showMain()\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n showError({\n title: `Error rendering story`,\n description: error.message,\n })\n }\n}\n\n/**\n * Default render implementation used when no custom `render` is provided.\n */\nexport function defaultRender(\n component: ComponentFn<any>,\n args: Record<string, unknown>,\n): VNodeChild {\n const Component = component\n return <Component {...args} />\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;AAWA,MAAM,cAAc,EAAE;AACtB,SAASA,IAAE,MAAM,OAAO,GAAG,UAAU;AACpC,QAAO;EACN;EACA,OAAO,SAAS;EAChB,UAAU,kBAAkB,SAAS;EACrC,KAAK,OAAO,OAAO;EACnB;;AAEF,SAAS,kBAAkB,UAAU;AACpC,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IAAK,KAAI,MAAM,QAAQ,SAAS,GAAG,CAAE,QAAO,gBAAgB,SAAS;AAC1G,QAAO;;AAER,SAAS,gBAAgB,UAAU;CAClC,MAAM,SAAS,EAAE;AACjB,MAAK,MAAM,SAAS,SAAU,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,KAAK,GAAG,gBAAgB,MAAM,CAAC;KACzF,QAAO,KAAK,MAAM;AACvB,QAAO;;;;;;;;;AAYR,SAAS,IAAI,MAAM,OAAO,KAAK;CAC9B,MAAM,EAAE,UAAU,GAAG,SAAS;CAC9B,MAAM,eAAe,OAAO,OAAO;EAClC,GAAG;EACH;EACA,GAAG;AACJ,KAAI,OAAO,SAAS,WAAY,QAAOA,IAAE,MAAM,aAAa,KAAK,IAAI;EACpE,GAAG;EACH;EACA,GAAG,aAAa;AACjB,QAAOA,IAAE,MAAM,cAAc,GAAG,aAAa,KAAK,IAAI,EAAE,GAAG,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;;;;;;;;AC5C5G,MAAM,8BAAc,IAAI,SAAkC;;;;;;;;;;;;;AAc1D,SAAgB,eACd,EACE,SACA,UACA,aAYF,eACM;CAEN,MAAM,cAAc,YAAY,IAAI,cAAc;AAClD,KAAI,aAAa;AACf,eAAa;AACb,cAAY,OAAO,cAAc;;AAGnC,KAAI;EAEF,MAAM,UAAUC,QADA,SAAS,EACM,cAAc;AAC7C,cAAY,IAAI,eAAe,QAAQ;AACvC,YAAU;UACH,KAAK;AAEZ,YAAU;GACR,OAAO;GACP,cAHY,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC,EAG5C;GACpB,CAAC;;;;;;AAON,SAAgB,cACd,WACA,MACY;AAEZ,QAAO,oBADW,WACX,EAAW,GAAI,MAAQ"}
1
+ {"version":3,"file":"index.js","names":["h","mount"],"sources":["../../../node_modules/.bun/@pyreon+core@0.7.3/node_modules/@pyreon/core/lib/jsx-runtime.js","../src/render-impl.tsx"],"sourcesContent":["//#region src/h.ts\n/** Marker for fragment nodes — renders children without a wrapper element */\nconst Fragment = Symbol(\"Pyreon.Fragment\");\n/**\n* Hyperscript function — the compiled output of JSX.\n* `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n*\n* Generic on P so TypeScript validates props match the component's signature\n* at the call site, then stores the result in the loosely-typed VNode.\n*/\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nconst EMPTY_PROPS = {};\nfunction h(type, props, ...children) {\n\treturn {\n\t\ttype,\n\t\tprops: props ?? EMPTY_PROPS,\n\t\tchildren: normalizeChildren(children),\n\t\tkey: props?.key ?? null\n\t};\n}\nfunction normalizeChildren(children) {\n\tfor (let i = 0; i < children.length; i++) if (Array.isArray(children[i])) return flattenChildren(children);\n\treturn children;\n}\nfunction flattenChildren(children) {\n\tconst result = [];\n\tfor (const child of children) if (Array.isArray(child)) result.push(...flattenChildren(child));\n\telse result.push(child);\n\treturn result;\n}\n\n//#endregion\n//#region src/jsx-runtime.ts\n/**\n* JSX automatic runtime.\n*\n* When tsconfig has `\"jsxImportSource\": \"@pyreon/core\"`, the TS/bundler compiler\n* rewrites JSX to imports from this file automatically:\n* <div class=\"x\" /> → jsx(\"div\", { class: \"x\" })\n*/\nfunction jsx(type, props, key) {\n\tconst { children, ...rest } = props;\n\tconst propsWithKey = key != null ? {\n\t\t...rest,\n\t\tkey\n\t} : rest;\n\tif (typeof type === \"function\") return h(type, children !== void 0 ? {\n\t\t...propsWithKey,\n\t\tchildren\n\t} : propsWithKey);\n\treturn h(type, propsWithKey, ...children === void 0 ? [] : Array.isArray(children) ? children : [children]);\n}\nconst jsxs = jsx;\n\n//#endregion\nexport { Fragment, jsx, jsxs };\n//# sourceMappingURL=jsx-runtime.js.map","import type { ComponentFn, VNodeChild } from '@pyreon/core'\nimport { mount } from '@pyreon/runtime-dom'\n\n/**\n * State tracked per canvas element so we can clean up between renders.\n */\nconst canvasState = new WeakMap<HTMLElement, () => void>()\n\n/**\n * Render a Pyreon story into a Storybook canvas element.\n *\n * This is the core integration point — Storybook calls this function\n * every time a story needs to be displayed or re-rendered (e.g. when\n * the user changes args via the Controls panel).\n *\n * It handles:\n * 1. Cleaning up the previous mount (disposing effects, removing DOM)\n * 2. Building the VNode from the story function or component + args\n * 3. Mounting the new VNode into the canvas\n */\nexport function renderToCanvas(\n {\n storyFn,\n showMain,\n showError,\n }: {\n storyFn: () => VNodeChild\n storyContext: {\n component?: ComponentFn<any>\n args: Record<string, unknown>\n [key: string]: unknown\n }\n showMain: () => void\n showError: (error: { title: string; description: string }) => void\n forceRemount: boolean\n },\n canvasElement: HTMLElement,\n): void {\n // Always clean up the previous render\n const prevUnmount = canvasState.get(canvasElement)\n if (prevUnmount) {\n prevUnmount()\n canvasState.delete(canvasElement)\n }\n\n try {\n const element = storyFn()\n const unmount = mount(element, canvasElement)\n canvasState.set(canvasElement, unmount)\n showMain()\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n showError({\n title: `Error rendering story`,\n description: error.message,\n })\n }\n}\n\n/**\n * Default render implementation used when no custom `render` is provided.\n */\nexport function defaultRender(\n component: ComponentFn<any>,\n args: Record<string, unknown>,\n): VNodeChild {\n const Component = component\n return <Component {...args} />\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;AAWA,MAAM,cAAc,EAAE;AACtB,SAASA,IAAE,MAAM,OAAO,GAAG,UAAU;AACpC,QAAO;EACN;EACA,OAAO,SAAS;EAChB,UAAU,kBAAkB,SAAS;EACrC,KAAK,OAAO,OAAO;EACnB;;AAEF,SAAS,kBAAkB,UAAU;AACpC,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IAAK,KAAI,MAAM,QAAQ,SAAS,GAAG,CAAE,QAAO,gBAAgB,SAAS;AAC1G,QAAO;;AAER,SAAS,gBAAgB,UAAU;CAClC,MAAM,SAAS,EAAE;AACjB,MAAK,MAAM,SAAS,SAAU,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,KAAK,GAAG,gBAAgB,MAAM,CAAC;KACzF,QAAO,KAAK,MAAM;AACvB,QAAO;;;;;;;;;AAYR,SAAS,IAAI,MAAM,OAAO,KAAK;CAC9B,MAAM,EAAE,UAAU,GAAG,SAAS;CAC9B,MAAM,eAAe,OAAO,OAAO;EAClC,GAAG;EACH;EACA,GAAG;AACJ,KAAI,OAAO,SAAS,WAAY,QAAOA,IAAE,MAAM,aAAa,KAAK,IAAI;EACpE,GAAG;EACH;EACA,GAAG,aAAa;AACjB,QAAOA,IAAE,MAAM,cAAc,GAAG,aAAa,KAAK,IAAI,EAAE,GAAG,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;;;;;;;;AC5C5G,MAAM,8BAAc,IAAI,SAAkC;;;;;;;;;;;;;AAc1D,SAAgB,eACd,EACE,SACA,UACA,aAYF,eACM;CAEN,MAAM,cAAc,YAAY,IAAI,cAAc;AAClD,KAAI,aAAa;AACf,eAAa;AACb,cAAY,OAAO,cAAc;;AAGnC,KAAI;EAEF,MAAM,UAAUC,QADA,SAAS,EACM,cAAc;AAC7C,cAAY,IAAI,eAAe,QAAQ;AACvC,YAAU;UACH,KAAK;AAEZ,YAAU;GACR,OAAO;GACP,cAHY,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC,EAG5C;GACpB,CAAC;;;;;;AAON,SAAgB,cACd,WACA,MACY;AAEZ,QAAO,oBADW,WACX,EAAW,GAAI,MAAQ"}
package/lib/preview.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { mount } from "@pyreon/runtime-dom";
2
2
 
3
- //#region ../../node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js
3
+ //#region ../../node_modules/.bun/@pyreon+core@0.7.3/node_modules/@pyreon/core/lib/jsx-runtime.js
4
4
  /**
5
5
  * Hyperscript function — the compiled output of JSX.
6
6
  * `<div class="x">hello</div>` → `h("div", { class: "x" }, "hello")`
@@ -1 +1 @@
1
- {"version":3,"file":"preview.js","names":[],"sources":["../../../node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js","../src/render-impl.tsx","../src/preview-impl.tsx"],"sourcesContent":["//#region src/h.ts\n/** Marker for fragment nodes — renders children without a wrapper element */\nconst Fragment = Symbol(\"Pyreon.Fragment\");\n/**\n* Hyperscript function — the compiled output of JSX.\n* `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n*\n* Generic on P so TypeScript validates props match the component's signature\n* at the call site, then stores the result in the loosely-typed VNode.\n*/\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nconst EMPTY_PROPS = {};\nfunction h(type, props, ...children) {\n\treturn {\n\t\ttype,\n\t\tprops: props ?? EMPTY_PROPS,\n\t\tchildren: normalizeChildren(children),\n\t\tkey: props?.key ?? null\n\t};\n}\nfunction normalizeChildren(children) {\n\tfor (let i = 0; i < children.length; i++) if (Array.isArray(children[i])) return flattenChildren(children);\n\treturn children;\n}\nfunction flattenChildren(children) {\n\tconst result = [];\n\tfor (const child of children) if (Array.isArray(child)) result.push(...flattenChildren(child));\n\telse result.push(child);\n\treturn result;\n}\n\n//#endregion\n//#region src/jsx-runtime.ts\n/**\n* JSX automatic runtime.\n*\n* When tsconfig has `\"jsxImportSource\": \"@pyreon/core\"`, the TS/bundler compiler\n* rewrites JSX to imports from this file automatically:\n* <div class=\"x\" /> → jsx(\"div\", { class: \"x\" })\n*/\nfunction jsx(type, props, key) {\n\tconst { children, ...rest } = props;\n\tconst propsWithKey = key != null ? {\n\t\t...rest,\n\t\tkey\n\t} : rest;\n\tif (typeof type === \"function\") return h(type, children !== void 0 ? {\n\t\t...propsWithKey,\n\t\tchildren\n\t} : propsWithKey);\n\treturn h(type, propsWithKey, ...children === void 0 ? [] : Array.isArray(children) ? children : [children]);\n}\nconst jsxs = jsx;\n\n//#endregion\nexport { Fragment, jsx, jsxs };\n//# sourceMappingURL=jsx-runtime.js.map","import type { ComponentFn, VNodeChild } from '@pyreon/core'\nimport { mount } from '@pyreon/runtime-dom'\n\n/**\n * State tracked per canvas element so we can clean up between renders.\n */\nconst canvasState = new WeakMap<HTMLElement, () => void>()\n\n/**\n * Render a Pyreon story into a Storybook canvas element.\n *\n * This is the core integration point — Storybook calls this function\n * every time a story needs to be displayed or re-rendered (e.g. when\n * the user changes args via the Controls panel).\n *\n * It handles:\n * 1. Cleaning up the previous mount (disposing effects, removing DOM)\n * 2. Building the VNode from the story function or component + args\n * 3. Mounting the new VNode into the canvas\n */\nexport function renderToCanvas(\n {\n storyFn,\n showMain,\n showError,\n }: {\n storyFn: () => VNodeChild\n storyContext: {\n component?: ComponentFn<any>\n args: Record<string, unknown>\n [key: string]: unknown\n }\n showMain: () => void\n showError: (error: { title: string; description: string }) => void\n forceRemount: boolean\n },\n canvasElement: HTMLElement,\n): void {\n // Always clean up the previous render\n const prevUnmount = canvasState.get(canvasElement)\n if (prevUnmount) {\n prevUnmount()\n canvasState.delete(canvasElement)\n }\n\n try {\n const element = storyFn()\n const unmount = mount(element, canvasElement)\n canvasState.set(canvasElement, unmount)\n showMain()\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n showError({\n title: `Error rendering story`,\n description: error.message,\n })\n }\n}\n\n/**\n * Default render implementation used when no custom `render` is provided.\n */\nexport function defaultRender(\n component: ComponentFn<any>,\n args: Record<string, unknown>,\n): VNodeChild {\n const Component = component\n return <Component {...args} />\n}\n","import type { ComponentFn, VNodeChild } from '@pyreon/core'\nimport { renderToCanvas } from './render-impl'\n\n/**\n * Preview entry — Storybook loads this in the preview iframe.\n *\n * Exports the render function and default decorators/parameters\n * that apply to all stories using this renderer.\n */\n\nexport { renderToCanvas }\n\n/**\n * Default render function — if the story CSF has a `component` but no\n * explicit `render`, this is used to create the VNode.\n */\nexport function render<TArgs extends Record<string, unknown>>(\n args: TArgs,\n context: { component?: ComponentFn<any> },\n): VNodeChild {\n const Component = context.component\n if (!Component) {\n throw new Error(\n '[@pyreon/storybook] No component provided. Either set `component` in your meta or provide a `render` function.',\n )\n }\n return <Component {...args} />\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;AAWA,MAAM,cAAc,EAAE;AACtB,SAAS,EAAE,MAAM,OAAO,GAAG,UAAU;AACpC,QAAO;EACN;EACA,OAAO,SAAS;EAChB,UAAU,kBAAkB,SAAS;EACrC,KAAK,OAAO,OAAO;EACnB;;AAEF,SAAS,kBAAkB,UAAU;AACpC,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,IAAK,KAAI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7.3/node_modules/@pyreon/core/lib/jsx-runtime.js","../src/render-impl.tsx","../src/preview-impl.tsx"],"sourcesContent":["//#region src/h.ts\n/** Marker for fragment nodes — renders children without a wrapper element */\nconst Fragment = Symbol(\"Pyreon.Fragment\");\n/**\n* Hyperscript function — the compiled output of JSX.\n* `<div class=\"x\">hello</div>` → `h(\"div\", { class: \"x\" }, \"hello\")`\n*\n* Generic on P so TypeScript validates props match the component's signature\n* at the call site, then stores the result in the loosely-typed VNode.\n*/\n/** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */\nconst EMPTY_PROPS = {};\nfunction h(type, props, ...children) {\n\treturn {\n\t\ttype,\n\t\tprops: props ?? EMPTY_PROPS,\n\t\tchildren: normalizeChildren(children),\n\t\tkey: props?.key ?? null\n\t};\n}\nfunction normalizeChildren(children) {\n\tfor (let i = 0; i < children.length; i++) if (Array.isArray(children[i])) return flattenChildren(children);\n\treturn children;\n}\nfunction flattenChildren(children) {\n\tconst result = [];\n\tfor (const child of children) if (Array.isArray(child)) result.push(...flattenChildren(child));\n\telse result.push(child);\n\treturn result;\n}\n\n//#endregion\n//#region src/jsx-runtime.ts\n/**\n* JSX automatic runtime.\n*\n* When tsconfig has `\"jsxImportSource\": \"@pyreon/core\"`, the TS/bundler compiler\n* rewrites JSX to imports from this file automatically:\n* <div class=\"x\" /> → jsx(\"div\", { class: \"x\" })\n*/\nfunction jsx(type, props, key) {\n\tconst { children, ...rest } = props;\n\tconst propsWithKey = key != null ? {\n\t\t...rest,\n\t\tkey\n\t} : rest;\n\tif (typeof type === \"function\") return h(type, children !== void 0 ? {\n\t\t...propsWithKey,\n\t\tchildren\n\t} : propsWithKey);\n\treturn h(type, propsWithKey, ...children === void 0 ? [] : Array.isArray(children) ? children : [children]);\n}\nconst jsxs = jsx;\n\n//#endregion\nexport { Fragment, jsx, jsxs };\n//# sourceMappingURL=jsx-runtime.js.map","import type { ComponentFn, VNodeChild } from '@pyreon/core'\nimport { mount } from '@pyreon/runtime-dom'\n\n/**\n * State tracked per canvas element so we can clean up between renders.\n */\nconst canvasState = new WeakMap<HTMLElement, () => void>()\n\n/**\n * Render a Pyreon story into a Storybook canvas element.\n *\n * This is the core integration point — Storybook calls this function\n * every time a story needs to be displayed or re-rendered (e.g. when\n * the user changes args via the Controls panel).\n *\n * It handles:\n * 1. Cleaning up the previous mount (disposing effects, removing DOM)\n * 2. Building the VNode from the story function or component + args\n * 3. Mounting the new VNode into the canvas\n */\nexport function renderToCanvas(\n {\n storyFn,\n showMain,\n showError,\n }: {\n storyFn: () => VNodeChild\n storyContext: {\n component?: ComponentFn<any>\n args: Record<string, unknown>\n [key: string]: unknown\n }\n showMain: () => void\n showError: (error: { title: string; description: string }) => void\n forceRemount: boolean\n },\n canvasElement: HTMLElement,\n): void {\n // Always clean up the previous render\n const prevUnmount = canvasState.get(canvasElement)\n if (prevUnmount) {\n prevUnmount()\n canvasState.delete(canvasElement)\n }\n\n try {\n const element = storyFn()\n const unmount = mount(element, canvasElement)\n canvasState.set(canvasElement, unmount)\n showMain()\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n showError({\n title: `Error rendering story`,\n description: error.message,\n })\n }\n}\n\n/**\n * Default render implementation used when no custom `render` is provided.\n */\nexport function defaultRender(\n component: ComponentFn<any>,\n args: Record<string, unknown>,\n): VNodeChild {\n const Component = component\n return <Component {...args} />\n}\n","import type { ComponentFn, VNodeChild } from '@pyreon/core'\nimport { renderToCanvas } from './render-impl'\n\n/**\n * Preview entry — Storybook loads this in the preview iframe.\n *\n * Exports the render function and default decorators/parameters\n * that apply to all stories using this renderer.\n */\n\nexport { renderToCanvas }\n\n/**\n * Default render function — if the story CSF has a `component` but no\n * explicit `render`, this is used to create the VNode.\n */\nexport function render<TArgs extends Record<string, unknown>>(\n args: TArgs,\n context: { component?: ComponentFn<any> },\n): VNodeChild {\n const Component = context.component\n if (!Component) {\n throw new Error(\n '[@pyreon/storybook] No component provided. Either set `component` in your meta or provide a `render` function.',\n )\n }\n return <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P,cAHY,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC,EAG5C;GACpB,CAAC;;;;;;;;;;ACvCN,SAAgB,OACd,MACA,SACY;CACZ,MAAM,YAAY,QAAQ;AAC1B,KAAI,CAAC,UACH,OAAM,IAAI,MACR,iHACD;AAEH,QAAO,oBAAC,WAAD,EAAW,GAAI,MAAQ"}
@@ -1,6 +1,6 @@
1
- import { mount } from "@pyreon/runtime-dom";
2
1
  import { ComponentFn, ComponentFn as ComponentFn$1, Fragment, Props, Props as Props$1, VNode, VNodeChild, VNodeChild as VNodeChild$1, h } from "@pyreon/core";
3
2
  import { computed, effect, signal } from "@pyreon/reactivity";
3
+ import { mount } from "@pyreon/runtime-dom";
4
4
 
5
5
  //#region src/types.d.ts
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/types.ts","../../src/render-impl.tsx"],"mappings":";;;;;;;;;UAQiB,cAAA;EACf,SAAA,EAAW,aAAA;EACX,WAAA,EAAa,YAAA;EACb,aAAA,EAAe,WAAA;AAAA;;KAML,UAAA,MAAgB,CAAA,SAAU,aAAA,YAAuB,CAAA,GAAI,OAAA;AAAA,UAIhD,YAAA,SAAqB,OAAA;EACpC,IAAA,EAAM,KAAA;EACN,QAAA,EAAU,MAAA;EACV,OAAA,EAAS,MAAA;EACT,EAAA;EACA,IAAA;EACA,IAAA;EACA,QAAA;AAAA;AAAA,KAGU,OAAA,SAAgB,OAAA,KAC1B,IAAA,EAAM,KAAA,EACN,OAAA,EAAS,YAAA,CAAa,KAAA,MACnB,YAAA;AAAA,KAEO,WAAA,SAAoB,OAAA,KAC9B,OAAA,EAAS,OAAA,CAAQ,KAAA,GACjB,OAAA,EAAS,YAAA,CAAa,KAAA,MACnB,YAAA;AAAA,UAIY,IAAA,oBAAwB,aAAA,QAAmB,aAAA;EA1BhC;EA4B1B,SAAA,GAAY,UAAA;EA5BmD;EA8B/D,KAAA;EA9BoE;EAgCpE,UA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qC,MAAA;EA3CtB;EA6Cf,cAAA,uBAAqC,MAAA;AAAA;AAAA,UAKtB,QAAA,eAAuB,IAAA,QAAY,IAAA;EApD5C;EAsDN,IAAA,GAAO,OAAA,CAAQ,QAAA,CAAS,KAAA;EArDd;EAuDV,QAAA,GAAW,MAAA;EAtDF;EAwDT,UAAA,GAAa,WAAA,CAAY,QAAA,CAAS,KAAA;EAtDlC;EAwDA,UAAA,GAAa,MAAA;EAtDb;EAwDA,IAAA;EAxDQ;EA0DR,MAAA,IACE,IAAA,EAAM,QAAA,CAAS,KAAA,GACf,OAAA,EAAS,YAAA,CAAa,QAAA,CAAS,KAAA,OAC5B,YAAA;EA1DY;EA4DjB,IAAA;EA5D0B;EA8D1B,IAAA,IAAQ,OAAA;IACN,aAAA,EAAe,WAAA;IACf,IAAA,EAAM,QAAA,CAAS,KAAA;IACf,IAAA,GAAO,IAAA,UAAc,EAAA,QAAU,OAAA,WAAkB,OAAA;EAAA,MAC7C,OAAA;AAAA;;KAIH,QAAA,UAAkB,KAAA,SAAc,IAAA,YAAgB,UAAA,CAAW,CAAA,IAAK,OAAA;;;;;;;AA7FrE;;;;;;;;iBCYgB,cAAA,CAAA;EAEZ,OAAA;EACA,QAAA;EACA;AAAA;EAEA,OAAA,QAAe,YAAA;EACf,YAAA;IACE,SAAA,GAAY,aAAA;IACZ,IAAA,EAAM,MAAA;IAAA,CACL,GAAA;EAAA;EAEH,QAAA;EACA,SAAA,GAAY,KAAA;IAAS,KAAA;IAAe,WAAA;EAAA;EACpC,YAAA;AAAA,GAEF,aAAA,EAAe,WAAA;;;;iBA0BD,aAAA,CACd,SAAA,EAAW,aAAA,OACX,IAAA,EAAM,MAAA,oBACL,YAAA"}
@@ -1,17 +1,19 @@
1
- import { join } from "node:path";
2
-
3
- //#region src/preset.ts
1
+ //#region src/preset.d.ts
4
2
  /**
5
- * Storybook preset for @pyreon/storybook.
6
- *
7
- * This file is loaded by Storybook's server when the user sets
8
- * `framework: "@pyreon/storybook"` in their `.storybook/main.ts`.
9
- *
10
- * It tells Storybook:
11
- * - Which renderer to use (via the preview entry)
12
- * - What framework name to report
13
- */
14
-
3
+ * Storybook preset for @pyreon/storybook.
4
+ *
5
+ * This file is loaded by Storybook's server when the user sets
6
+ * `framework: "@pyreon/storybook"` in their `.storybook/main.ts`.
7
+ *
8
+ * It tells Storybook:
9
+ * - Which renderer to use (via the preview entry)
10
+ * - What framework name to report
11
+ */
12
+ declare const addons: string[];
13
+ declare const previewAnnotations: string[];
14
+ declare const core: {
15
+ renderer: string;
16
+ };
15
17
  //#endregion
16
18
  export { addons, core, previewAnnotations };
17
- //# sourceMappingURL=preset.d.ts.map
19
+ //# sourceMappingURL=preset2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preset.d.ts","names":[],"sources":["../../src/preset.ts"],"mappings":""}
1
+ {"version":3,"file":"preset2.d.ts","names":[],"sources":["../../../src/preset.ts"],"mappings":";;AAiBA;;;;;AAEA;;;;cAFa,MAAA;AAAA,cAEA,kBAAA;AAAA,cAEA,IAAA;EAEZ,QAAA;AAAA"}
@@ -1,109 +1,45 @@
1
- import { mount } from "@pyreon/runtime-dom";
1
+ import { ComponentFn, VNodeChild } from "@pyreon/core";
2
2
 
3
- //#region ../../node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js
3
+ //#region src/render-impl.d.ts
4
4
  /**
5
- * Hyperscript function the compiled output of JSX.
6
- * `<div class="x">hello</div>` → `h("div", { class: "x" }, "hello")`
7
- *
8
- * Generic on P so TypeScript validates props match the component's signature
9
- * at the call site, then stores the result in the loosely-typed VNode.
10
- */
11
- /** Shared empty props sentinel — identity-checked in mountElement to skip applyProps. */
12
-
13
- function h(type, props, ...children) {
14
- return {
15
- type,
16
- props: props ?? EMPTY_PROPS,
17
- children: normalizeChildren(children),
18
- key: props?.key ?? null
19
- };
20
- }
21
- function normalizeChildren(children) {
22
- for (let i = 0; i < children.length; i++) if (Array.isArray(children[i])) return flattenChildren(children);
23
- return children;
24
- }
25
- function flattenChildren(children) {
26
- const result = [];
27
- for (const child of children) if (Array.isArray(child)) result.push(...flattenChildren(child));else result.push(child);
28
- return result;
29
- }
30
- /**
31
- * JSX automatic runtime.
32
- *
33
- * When tsconfig has `"jsxImportSource": "@pyreon/core"`, the TS/bundler compiler
34
- * rewrites JSX to imports from this file automatically:
35
- * <div class="x" /> → jsx("div", { class: "x" })
36
- */
37
- function jsx(type, props, key) {
38
- const {
39
- children,
40
- ...rest
41
- } = props;
42
- const propsWithKey = key != null ? {
43
- ...rest,
44
- key
45
- } : rest;
46
- if (typeof type === "function") return h(type, children !== void 0 ? {
47
- ...propsWithKey,
48
- children
49
- } : propsWithKey);
50
- return h(type, propsWithKey, ...(children === void 0 ? [] : Array.isArray(children) ? children : [children]));
51
- }
52
-
53
- //#endregion
54
- //#region src/render-impl.tsx
55
- /**
56
- * State tracked per canvas element so we can clean up between renders.
57
- */
58
-
59
- /**
60
- * Render a Pyreon story into a Storybook canvas element.
61
- *
62
- * This is the core integration point — Storybook calls this function
63
- * every time a story needs to be displayed or re-rendered (e.g. when
64
- * the user changes args via the Controls panel).
65
- *
66
- * It handles:
67
- * 1. Cleaning up the previous mount (disposing effects, removing DOM)
68
- * 2. Building the VNode from the story function or component + args
69
- * 3. Mounting the new VNode into the canvas
70
- */
71
- function renderToCanvas({
5
+ * Render a Pyreon story into a Storybook canvas element.
6
+ *
7
+ * This is the core integration point — Storybook calls this function
8
+ * every time a story needs to be displayed or re-rendered (e.g. when
9
+ * the user changes args via the Controls panel).
10
+ *
11
+ * It handles:
12
+ * 1. Cleaning up the previous mount (disposing effects, removing DOM)
13
+ * 2. Building the VNode from the story function or component + args
14
+ * 3. Mounting the new VNode into the canvas
15
+ */
16
+ declare function renderToCanvas({
72
17
  storyFn,
73
18
  showMain,
74
19
  showError
75
- }, canvasElement) {
76
- const prevUnmount = canvasState.get(canvasElement);
77
- if (prevUnmount) {
78
- prevUnmount();
79
- canvasState.delete(canvasElement);
80
- }
81
- try {
82
- const unmount = mount(storyFn(), canvasElement);
83
- canvasState.set(canvasElement, unmount);
84
- showMain();
85
- } catch (err) {
86
- showError({
87
- title: `Error rendering story`,
88
- description: (err instanceof Error ? err : new Error(String(err))).message
89
- });
90
- }
91
- }
92
-
20
+ }: {
21
+ storyFn: () => VNodeChild;
22
+ storyContext: {
23
+ component?: ComponentFn<any>;
24
+ args: Record<string, unknown>;
25
+ [key: string]: unknown;
26
+ };
27
+ showMain: () => void;
28
+ showError: (error: {
29
+ title: string;
30
+ description: string;
31
+ }) => void;
32
+ forceRemount: boolean;
33
+ }, canvasElement: HTMLElement): void;
93
34
  //#endregion
94
- //#region src/preview-impl.tsx
35
+ //#region src/preview-impl.d.ts
95
36
  /**
96
- * Default render function — if the story CSF has a `component` but no
97
- * explicit `render`, this is used to create the VNode.
98
- */
99
- function render(args, context) {
100
- const Component = context.component;
101
- if (!Component) throw new Error("[@pyreon/storybook] No component provided. Either set `component` in your meta or provide a `render` function.");
102
- return /* @__PURE__ */jsx(Component, {
103
- ...args
104
- });
105
- }
106
-
37
+ * Default render function — if the story CSF has a `component` but no
38
+ * explicit `render`, this is used to create the VNode.
39
+ */
40
+ declare function render<TArgs extends Record<string, unknown>>(args: TArgs, context: {
41
+ component?: ComponentFn<any>;
42
+ }): VNodeChild;
107
43
  //#endregion
108
44
  export { render, renderToCanvas };
109
- //# sourceMappingURL=preview.d.ts.map
45
+ //# sourceMappingURL=preview2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview.d.ts","names":[],"sources":["../../../../node_modules/.bun/@pyreon+core@0.6.0/node_modules/@pyreon/core/lib/jsx-runtime.js","../../src/render-impl.tsx","../../src/preview-impl.tsx"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;AAYA,SAAS,CAAA,CAAE,IAAA,EAAM,KAAA,EAAO,GAAG,QAAA,EAAU;EACpC,OAAO;IACN,IAAA;IACA,KAAA,EAAO,KAAA,IAAS,WAAA;IAChB,QAA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;EAAW,SAAA,GAAY,WAAA;AAAA,IACtB,UAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/storybook",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Storybook renderer for Pyreon — mount, render, and interact with Pyreon components in Storybook",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -51,9 +51,9 @@
51
51
  "typecheck": "tsc --noEmit"
52
52
  },
53
53
  "peerDependencies": {
54
- "@pyreon/core": ">=0.5.0 <1.0.0",
55
- "@pyreon/reactivity": ">=0.5.0 <1.0.0",
56
- "@pyreon/runtime-dom": ">=0.5.0 <1.0.0",
54
+ "@pyreon/core": ">=0.7.0 <0.8.0",
55
+ "@pyreon/reactivity": ">=0.7.0 <0.8.0",
56
+ "@pyreon/runtime-dom": ">=0.7.0 <0.8.0",
57
57
  "storybook": ">=8.0.0"
58
58
  }
59
59
  }
@@ -27,7 +27,9 @@ function makeRenderContext(overrides: {
27
27
  return {
28
28
  storyFn: overrides.storyFn ?? (() => <div>default</div>),
29
29
  storyContext: {
30
- component: overrides.component,
30
+ ...(overrides.component != null
31
+ ? { component: overrides.component }
32
+ : {}),
31
33
  args: overrides.args ?? {},
32
34
  },
33
35
  showMain: () => {
@@ -221,7 +223,11 @@ describe('Meta and StoryObj types', () => {
221
223
  label: string
222
224
  variant?: 'primary' | 'secondary'
223
225
  }) {
224
- return <button class={props.variant}>{props.label}</button>
226
+ return (
227
+ <button type="button" class={props.variant}>
228
+ {props.label}
229
+ </button>
230
+ )
225
231
  }
226
232
 
227
233
  const meta = {
@@ -237,7 +243,12 @@ describe('Meta and StoryObj types', () => {
237
243
 
238
244
  it('StoryObj inherits args from Meta', () => {
239
245
  function Input(props: { placeholder: string; disabled?: boolean }) {
240
- return <input placeholder={props.placeholder} disabled={props.disabled} />
246
+ return (
247
+ <input
248
+ placeholder={props.placeholder}
249
+ {...(props.disabled != null ? { disabled: props.disabled } : {})}
250
+ />
251
+ )
241
252
  }
242
253
 
243
254
  const _meta = {
@@ -407,7 +418,7 @@ describe('preview render', () => {
407
418
 
408
419
  it('throws when component is undefined', () => {
409
420
  expect(() =>
410
- previewRender({ foo: 'bar' }, { component: undefined }),
421
+ previewRender({ foo: 'bar' }, { component: undefined } as any),
411
422
  ).toThrow('[@pyreon/storybook] No component provided')
412
423
  })
413
424
  })
@@ -1,19 +0,0 @@
1
- //#region src/preset.d.ts
2
- /**
3
- * Storybook preset for @pyreon/storybook.
4
- *
5
- * This file is loaded by Storybook's server when the user sets
6
- * `framework: "@pyreon/storybook"` in their `.storybook/main.ts`.
7
- *
8
- * It tells Storybook:
9
- * - Which renderer to use (via the preview entry)
10
- * - What framework name to report
11
- */
12
- declare const addons: string[];
13
- declare const previewAnnotations: string[];
14
- declare const core: {
15
- renderer: string;
16
- };
17
- //#endregion
18
- export { addons, core, previewAnnotations };
19
- //# sourceMappingURL=preset2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preset2.d.ts","names":[],"sources":["../../src/preset.ts"],"mappings":";;AAiBA;;;;;AAEA;;;;cAFa,MAAA;AAAA,cAEA,kBAAA;AAAA,cAEA,IAAA;EAEZ,QAAA;AAAA"}
@@ -1,45 +0,0 @@
1
- import { ComponentFn, VNodeChild } from "@pyreon/core";
2
-
3
- //#region src/render-impl.d.ts
4
- /**
5
- * Render a Pyreon story into a Storybook canvas element.
6
- *
7
- * This is the core integration point — Storybook calls this function
8
- * every time a story needs to be displayed or re-rendered (e.g. when
9
- * the user changes args via the Controls panel).
10
- *
11
- * It handles:
12
- * 1. Cleaning up the previous mount (disposing effects, removing DOM)
13
- * 2. Building the VNode from the story function or component + args
14
- * 3. Mounting the new VNode into the canvas
15
- */
16
- declare function renderToCanvas({
17
- storyFn,
18
- showMain,
19
- showError
20
- }: {
21
- storyFn: () => VNodeChild;
22
- storyContext: {
23
- component?: ComponentFn<any>;
24
- args: Record<string, unknown>;
25
- [key: string]: unknown;
26
- };
27
- showMain: () => void;
28
- showError: (error: {
29
- title: string;
30
- description: string;
31
- }) => void;
32
- forceRemount: boolean;
33
- }, canvasElement: HTMLElement): void;
34
- //#endregion
35
- //#region src/preview-impl.d.ts
36
- /**
37
- * Default render function — if the story CSF has a `component` but no
38
- * explicit `render`, this is used to create the VNode.
39
- */
40
- declare function render<TArgs extends Record<string, unknown>>(args: TArgs, context: {
41
- component?: ComponentFn<any>;
42
- }): VNodeChild;
43
- //#endregion
44
- export { render, renderToCanvas };
45
- //# sourceMappingURL=preview2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preview2.d.ts","names":[],"sources":["../../src/render-impl.tsx","../../src/preview-impl.tsx"],"mappings":";;;;;AAoBA;;;;;;;;;;iBAAgB,cAAA,CAAA;EAEZ,OAAA;EACA,QAAA;EACA;AAAA;EAEA,OAAA,QAAe,UAAA;EACf,YAAA;IACE,SAAA,GAAY,WAAA;IACZ,IAAA,EAAM,MAAA;IAAA,CACL,GAAA;EAAA;EAEH,QAAA;EACA,SAAA,GAAY,KAAA;IAAS,KAAA;IAAe,WAAA;EAAA;EACpC,YAAA;AAAA,GAEF,aAAA,EAAe,WAAA;;;;;;;iBCpBD,MAAA,eAAqB,MAAA,kBAAA,CACnC,IAAA,EAAM,KAAA,EACN,OAAA;EAAW,SAAA,GAAY,WAAA;AAAA,IACtB,UAAA"}