@praxisjs/storybook 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Mateus Martins
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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=preset.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/preset.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,104 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ const mockPraxisPlugin = vi.hoisted(() => vi.fn(() => ({ name: "praxisjs" })));
3
+ vi.mock("@praxisjs/vite-plugin", () => ({ default: mockPraxisPlugin }));
4
+ const mockReadFileSync = vi.hoisted(() => vi.fn());
5
+ vi.mock("node:fs", () => ({ readFileSync: mockReadFileSync }));
6
+ import { viteFinal, core, managerEntries } from "../preset";
7
+ beforeEach(() => {
8
+ vi.clearAllMocks();
9
+ mockPraxisPlugin.mockReturnValue({ name: "praxisjs" });
10
+ });
11
+ // ── viteFinal ─────────────────────────────────────────────────────────────────
12
+ describe("viteFinal()", () => {
13
+ it("returns the config object", () => {
14
+ const config = {};
15
+ expect(viteFinal(config)).toBe(config);
16
+ });
17
+ it("adds the praxisjs vite plugin", () => {
18
+ const config = {};
19
+ viteFinal(config);
20
+ expect(mockPraxisPlugin).toHaveBeenCalledWith({ hmr: true });
21
+ const plugins = config.plugins;
22
+ expect(plugins.some((p) => p.name === "praxisjs")).toBe(true);
23
+ });
24
+ it("adds the story-source plugin", () => {
25
+ const config = {};
26
+ viteFinal(config);
27
+ const plugins = config.plugins;
28
+ expect(plugins.some((p) => p.name === "praxisjs-story-source")).toBe(true);
29
+ });
30
+ it("preserves existing plugins", () => {
31
+ const existing = { name: "existing" };
32
+ const config = { plugins: [existing] };
33
+ viteFinal(config);
34
+ const plugins = config.plugins;
35
+ expect(plugins[0]).toBe(existing);
36
+ });
37
+ it("handles missing plugins array gracefully", () => {
38
+ expect(() => viteFinal({})).not.toThrow();
39
+ expect(() => viteFinal({ plugins: null })).not.toThrow();
40
+ });
41
+ });
42
+ // ── core ──────────────────────────────────────────────────────────────────────
43
+ describe("core", () => {
44
+ it("specifies @storybook/builder-vite as the builder", () => {
45
+ expect(core.builder).toBe("@storybook/builder-vite");
46
+ });
47
+ });
48
+ // ── managerEntries ────────────────────────────────────────────────────────────
49
+ describe("managerEntries()", () => {
50
+ it("appends the manager entry to the default empty array", () => {
51
+ const result = managerEntries();
52
+ expect(result).toHaveLength(1);
53
+ expect(result[0]).toContain("manager.jsx");
54
+ });
55
+ it("prepends existing entries before the manager entry", () => {
56
+ const result = managerEntries(["/some/entry.js"]);
57
+ expect(result[0]).toBe("/some/entry.js");
58
+ expect(result[1]).toContain("manager.jsx");
59
+ });
60
+ });
61
+ // ── storySourcePlugin transform ───────────────────────────────────────────────
62
+ describe("storySourcePlugin — transform()", () => {
63
+ function getTransform() {
64
+ const config = {};
65
+ viteFinal(config);
66
+ const plugins = config.plugins;
67
+ return plugins.find((p) => p.name === "praxisjs-story-source").transform;
68
+ }
69
+ it("returns null for non-story files", () => {
70
+ const transform = getTransform();
71
+ expect(transform("const x = 1;", "/src/app.ts")).toBeNull();
72
+ expect(transform("const x = 1;", "/src/component.tsx")).toBeNull();
73
+ });
74
+ it("returns null when readFileSync throws", () => {
75
+ mockReadFileSync.mockImplementation(() => { throw new Error("ENOENT"); });
76
+ const transform = getTransform();
77
+ const result = transform("code", "/src/foo.stories.tsx");
78
+ expect(result).toBeNull();
79
+ });
80
+ it("returns null when there is no `export default` statement", () => {
81
+ mockReadFileSync.mockReturnValue("const x = 1;");
82
+ const transform = getTransform();
83
+ const result = transform("const x = 1;", "/src/foo.stories.tsx");
84
+ expect(result).toBeNull();
85
+ });
86
+ it("injects storySource metadata for a valid story file", () => {
87
+ const source = "const MyStories = {};\nexport default MyStories;";
88
+ mockReadFileSync.mockReturnValue(source);
89
+ const transform = getTransform();
90
+ const result = transform(source, "/src/foo.stories.tsx");
91
+ expect(result).not.toBeNull();
92
+ expect(result.map).toBeNull();
93
+ expect(result.code).toContain("storySource");
94
+ expect(result.code).toContain("export default MyStories;");
95
+ });
96
+ it("matches story files with query strings (e.g. Vite HMR)", () => {
97
+ const source = "const S = {};\nexport default S;";
98
+ mockReadFileSync.mockReturnValue(source);
99
+ const transform = getTransform();
100
+ const result = transform(source, "/src/foo.stories.ts?t=123");
101
+ expect(result).not.toBeNull();
102
+ });
103
+ });
104
+ //# sourceMappingURL=preset.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.test.js","sourceRoot":"","sources":["../../src/__tests__/preset.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MA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CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,MAAM,MAAM,GAAG,kCAAkC,CAAC;QAClD,gBAAgB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;QAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=render.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/render.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,73 @@
1
+ // @vitest-environment jsdom
2
+ import { describe, it, expect, vi, beforeEach } from "vitest";
3
+ vi.mock("@praxisjs/runtime", () => ({
4
+ render: vi.fn(() => vi.fn()), // returns a no-op cleanup
5
+ }));
6
+ import { render as praxisRender } from "@praxisjs/runtime";
7
+ import { renderToCanvas } from "../render";
8
+ const mockRender = vi.mocked(praxisRender);
9
+ function makeContext(overrides = {}) {
10
+ return {
11
+ storyFn: vi.fn(() => document.createTextNode("story")),
12
+ showMain: vi.fn(),
13
+ forceRemount: false,
14
+ ...overrides,
15
+ };
16
+ }
17
+ beforeEach(() => {
18
+ vi.clearAllMocks();
19
+ mockRender.mockReturnValue(vi.fn());
20
+ });
21
+ describe("renderToCanvas()", () => {
22
+ it("calls showMain()", async () => {
23
+ const ctx = makeContext();
24
+ const el = document.createElement("div");
25
+ await renderToCanvas(ctx, el);
26
+ expect(ctx.showMain).toHaveBeenCalledOnce();
27
+ });
28
+ it("calls praxisRender with a thunk and the canvas element", async () => {
29
+ const ctx = makeContext();
30
+ const el = document.createElement("div");
31
+ await renderToCanvas(ctx, el);
32
+ expect(mockRender).toHaveBeenCalledOnce();
33
+ expect(mockRender).toHaveBeenCalledWith(expect.any(Function), el);
34
+ });
35
+ it("the thunk passed to praxisRender invokes storyFn", async () => {
36
+ const ctx = makeContext();
37
+ const el = document.createElement("div");
38
+ await renderToCanvas(ctx, el);
39
+ const thunk = mockRender.mock.calls[0][0];
40
+ thunk();
41
+ expect(ctx.storyFn).toHaveBeenCalledOnce();
42
+ });
43
+ it("returns a resolved Promise", async () => {
44
+ const ctx = makeContext();
45
+ const el = document.createElement("div");
46
+ const result = renderToCanvas(ctx, el);
47
+ expect(result).toBeInstanceOf(Promise);
48
+ await expect(result).resolves.toBeUndefined();
49
+ });
50
+ it("forceRemount=false does not call the previous cleanup", async () => {
51
+ const cleanup = vi.fn();
52
+ mockRender.mockReturnValue(cleanup);
53
+ const el = document.createElement("div");
54
+ await renderToCanvas(makeContext({ forceRemount: false }), el);
55
+ await renderToCanvas(makeContext({ forceRemount: false }), el);
56
+ expect(cleanup).not.toHaveBeenCalled();
57
+ });
58
+ it("forceRemount=true calls and clears the previous cleanup", async () => {
59
+ const cleanup = vi.fn();
60
+ mockRender.mockReturnValue(cleanup);
61
+ const el = document.createElement("div");
62
+ // First render — establishes a cleanup
63
+ await renderToCanvas(makeContext({ forceRemount: false }), el);
64
+ // Second render with forceRemount — should call the previous cleanup
65
+ await renderToCanvas(makeContext({ forceRemount: true }), el);
66
+ expect(cleanup).toHaveBeenCalledOnce();
67
+ });
68
+ it("forceRemount=true with no prior cleanup does not throw", async () => {
69
+ const el = document.createElement("div");
70
+ await expect(renderToCanvas(makeContext({ forceRemount: true }), el)).resolves.toBeUndefined();
71
+ });
72
+ });
73
+ //# sourceMappingURL=render.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.test.js","sourceRoot":"","sources":["../../src/__tests__/render.test.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE9D,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;IAClC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,0BAA0B;CACzD,CAAC,CAAC,CAAC;AAEJ,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,UAAU,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAE3C,SAAS,WAAW,CAAC,YAIhB,EAAE;IACL,OAAO;QACL,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACtD,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;QACjB,YAAY,EAAE,KAAK;QACnB,GAAG,SAAS;KAC2B,CAAC;AAC5C,CAAC;AAED,UAAU,CAAC,GAAG,EAAE;IACd,EAAE,CAAC,aAAa,EAAE,CAAC;IACnB,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QAChC,MAAM,GAAG,G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C,oBAAoB,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,MAAM,CACV,cAAc,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACxD,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { renderToCanvas } from "./render";
2
+ export type { PraxisRenderer, Meta, StoryObj, StorybookConfig } from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { renderToCanvas } from "./render";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function viteFinal(config: Record<string, any>): Record<string, any>;
2
+ export declare const core: {
3
+ builder: string;
4
+ };
5
+ export declare function managerEntries(entries?: string[]): string[];
6
+ //# sourceMappingURL=preset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AA+BA,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAO1E;AAED,eAAO,MAAM,IAAI;;CAEhB,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE,CAE/D"}
package/dist/preset.js ADDED
@@ -0,0 +1,46 @@
1
+ import { readFileSync } from "node:fs";
2
+ import praxisjs from "@praxisjs/vite-plugin";
3
+ function storySourcePlugin() {
4
+ return {
5
+ name: "praxisjs-story-source",
6
+ enforce: "post",
7
+ transform(code, id) {
8
+ if (!(/\.stories\.(tsx?|jsx?)($|\?)/.exec(id)))
9
+ return null;
10
+ const filePath = id.split("?")[0];
11
+ let originalSource;
12
+ try {
13
+ originalSource = readFileSync(filePath, "utf-8");
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ const source = JSON.stringify(originalSource);
19
+ const exportMatch = /export default (\w+);/.exec(code);
20
+ if (!exportMatch)
21
+ return null;
22
+ const metaVar = exportMatch[1];
23
+ const injection = `\n${metaVar}.parameters = {\n ...${metaVar}.parameters,\n storySource: { source: ${source} },\n};`;
24
+ return {
25
+ code: code.replace(`export default ${metaVar};`, `${injection}\nexport default ${metaVar};`),
26
+ map: null,
27
+ };
28
+ },
29
+ };
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
+ export function viteFinal(config) {
33
+ config.plugins = [
34
+ ...(config.plugins ?? []),
35
+ praxisjs({ hmr: true }),
36
+ storySourcePlugin(),
37
+ ];
38
+ return config;
39
+ }
40
+ export const core = {
41
+ builder: "@storybook/builder-vite",
42
+ };
43
+ export function managerEntries(entries = []) {
44
+ return [...entries, new URL("../manager.jsx", import.meta.url).pathname];
45
+ }
46
+ //# sourceMappingURL=preset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,QAAQ,MAAM,u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M,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,OAAO,EAAE,yBAAyB;CACnC,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,UAAoB,EAAE;IACnD,OAAO,CAAC,GAAG,OAAO,EAAE,IAAI,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { RenderContext } from "@storybook/core/types";
2
+ export declare function renderToCanvas({ storyFn, showMain, forceRemount }: RenderContext, canvasElement: HTMLElement): Promise<void>;
3
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,wBAAgB,cAAc,CAC5B,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,aAAa,EAClD,aAAa,EAAE,WAAW,GACzB,OAAO,CAAC,IAAI,CAAC,CAcf"}
package/dist/render.js ADDED
@@ -0,0 +1,12 @@
1
+ import { render as praxisRender } from "@praxisjs/runtime";
2
+ let cleanup;
3
+ export function renderToCanvas({ storyFn, showMain, forceRemount }, canvasElement) {
4
+ if (forceRemount) {
5
+ cleanup?.();
6
+ cleanup = undefined;
7
+ }
8
+ showMain();
9
+ cleanup = praxisRender(() => storyFn(), canvasElement);
10
+ return Promise.resolve();
11
+ }
12
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAK3D,IAAI,OAAiC,CAAC;AAEtC,MAAM,UAAU,cAAc,CAC5B,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAiB,EAClD,aAA0B;IAE1B,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO,GAAG,SAAS,CAAC;IACtB,CAAC;IAED,QAAQ,EAAE,CAAC;IAEX,OAAO,GAAG,YAAY,CACpB,GAAG,EAAE,CAAC,OAAO,EAAqB,EAClC,aAAa,CACd,CAAC;IAEF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { ComponentAnnotations, StoryAnnotations } from "@storybook/core/csf";
2
+ import type { WebRenderer } from "@storybook/core/types";
3
+ export interface PraxisRenderer extends WebRenderer {
4
+ canvasElement: HTMLElement;
5
+ component: new (...args: any[]) => unknown;
6
+ storyResult: Node | Node[] | null | undefined;
7
+ }
8
+ export type Meta<T = any> = ComponentAnnotations<PraxisRenderer, T>;
9
+ export type StoryObj<T = any> = StoryAnnotations<PraxisRenderer, T>;
10
+ export interface StorybookConfig {
11
+ stories: string[];
12
+ addons?: string[];
13
+ framework: {
14
+ name: string;
15
+ options?: Record<string, unknown>;
16
+ };
17
+ docs?: Record<string, unknown>;
18
+ }
19
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,aAAa,EAAE,WAAW,CAAC;IAE3B,SAAS,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;IAC3C,WAAW,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;CAC/C;AAGD,MAAM,MAAM,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,oBAAoB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;AAGpE,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,GAAG,IAAI,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;AAEpE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/manager.jsx ADDED
@@ -0,0 +1,178 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import { addons, types, useParameter } from "storybook/internal/manager-api";
3
+
4
+ // ─── One Dark theme ──────────────────────────────────────────────────────────
5
+
6
+ const CSS = `
7
+ .prax-panel {
8
+ background: #282c34;
9
+ color: #abb2bf;
10
+ font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
11
+ font-size: 13px;
12
+ line-height: 1.65;
13
+ margin: 0;
14
+ padding: 20px 24px;
15
+ white-space: pre;
16
+ tab-size: 2;
17
+ box-sizing: border-box;
18
+ }
19
+ .prax-panel .kw { color: #c678dd; }
20
+ .prax-panel .dc { color: #e5c07b; font-weight: 600; }
21
+ .prax-panel .st { color: #98c379; }
22
+ .prax-panel .cm { color: #5c6370; font-style: italic; }
23
+ .prax-panel .nm { color: #e5c07b; }
24
+ .prax-panel .fn { color: #61afef; }
25
+ .prax-panel .nb { color: #d19a66; }
26
+ .prax-panel .rx { color: #56b6c2; }
27
+ .prax-panel .op { color: #abb2bf; }
28
+ .prax-panel .no-src {
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ height: 100%;
33
+ color: #5c6370;
34
+ font-family: sans-serif;
35
+ font-size: 13px;
36
+ }
37
+ `;
38
+
39
+ // ─── Tokenizer ────────────────────────────────────────────────────────────────
40
+
41
+ const KEYWORDS = new Set([
42
+ "import","export","from","default","class","extends","implements",
43
+ "interface","type","enum","const","let","var","function","async","await",
44
+ "return","if","else","for","while","do","switch","case","break","continue",
45
+ "new","this","super","static","public","private","protected","readonly",
46
+ "abstract","declare","namespace","module","as","typeof","instanceof","in",
47
+ "of","null","undefined","true","false","void","never","any","unknown",
48
+ "string","number","boolean","object","infer","keyof","satisfies",
49
+ ]);
50
+
51
+ const PATTERNS = [
52
+ // multi-line comment
53
+ { type: "cm", re: /^(\/\*[\s\S]*?\*\/)/ },
54
+ // single-line comment
55
+ { type: "cm", re: /^(\/\/[^\n]*)/ },
56
+ // template literal
57
+ { type: "st", re: /^(`(?:\\[\s\S]|[^`\\])*`)/ },
58
+ // string
59
+ { type: "st", re: /^((?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'))/ },
60
+ // decorator
61
+ { type: "dc", re: /^(@[A-Za-z_$][A-Za-z0-9_$]*)/ },
62
+ // identifier — classified below
63
+ { type: "id", re: /^([A-Za-z_$][A-Za-z0-9_$]*)/ },
64
+ // number
65
+ { type: "nb", re: /^(0x[\da-fA-F]+|\d+(?:\.\d+)?)/ },
66
+ // single char fallback
67
+ { type: null, re: /^([\s\S])/ },
68
+ ];
69
+
70
+ function esc(s) {
71
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
72
+ }
73
+
74
+ function tokenize(code) {
75
+ let out = "";
76
+ let i = 0;
77
+ while (i < code.length) {
78
+ const slice = code.slice(i);
79
+ let matched = false;
80
+ for (const { type, re } of PATTERNS) {
81
+ const m = slice.match(re);
82
+ if (!m) continue;
83
+ const text = m[1];
84
+ i += text.length;
85
+ if (type === null) { out += esc(text); matched = true; break; }
86
+ if (type === "id") {
87
+ if (KEYWORDS.has(text)) {
88
+ out += `<span class="kw">${esc(text)}</span>`;
89
+ } else if (/^[A-Z]/.test(text)) {
90
+ out += `<span class="nm">${esc(text)}</span>`;
91
+ } else if (code[i] === "(") {
92
+ out += `<span class="fn">${esc(text)}</span>`;
93
+ } else {
94
+ out += esc(text);
95
+ }
96
+ matched = true;
97
+ break;
98
+ }
99
+ out += `<span class="${type}">${esc(text)}</span>`;
100
+ matched = true;
101
+ break;
102
+ }
103
+ if (!matched) { out += esc(code[i]); i++; }
104
+ }
105
+ return out;
106
+ }
107
+
108
+ // ─── Panel component ──────────────────────────────────────────────────────────
109
+
110
+ const PANEL_ID = "praxisjs/source";
111
+
112
+ function SourcePanel({ active }) {
113
+ const storySource = useParameter("storySource", {});
114
+ const source = storySource?.source ?? "";
115
+ const rootRef = useRef(null);
116
+ const [height, setHeight] = useState(0);
117
+
118
+ useEffect(() => {
119
+ if (document.getElementById("prax-panel-css")) return;
120
+ const el = document.createElement("style");
121
+ el.id = "prax-panel-css";
122
+ el.textContent = CSS;
123
+ document.head.appendChild(el);
124
+ }, []);
125
+
126
+ // Observe the parent panel container to get its height
127
+ useEffect(() => {
128
+ const el = rootRef.current;
129
+ if (!el) return;
130
+ const parent = el.parentElement;
131
+ if (!parent) return;
132
+ const ro = new ResizeObserver(([entry]) => {
133
+ setHeight(entry.contentRect.height);
134
+ });
135
+ ro.observe(parent);
136
+ setHeight(parent.getBoundingClientRect().height);
137
+ return () => ro.disconnect();
138
+ }, [active]);
139
+
140
+ if (!active) return null;
141
+
142
+ const wrapperStyle = {
143
+ width: "100%",
144
+ height: height || "auto",
145
+ overflow: "auto",
146
+ };
147
+
148
+ if (!source) {
149
+ return (
150
+ <div ref={rootRef} style={wrapperStyle}>
151
+ <pre className="prax-panel">
152
+ <span className="no-src">No source available for this story.</span>
153
+ </pre>
154
+ </div>
155
+ );
156
+ }
157
+
158
+ return (
159
+ <div ref={rootRef} style={wrapperStyle}>
160
+ <pre
161
+ className="prax-panel"
162
+ dangerouslySetInnerHTML={{ __html: tokenize(source) }}
163
+ />
164
+ </div>
165
+ );
166
+ }
167
+
168
+ // ─── Register ─────────────────────────────────────────────────────────────────
169
+
170
+ addons.register(PANEL_ID, () => {
171
+ addons.add(`${PANEL_ID}/panel`, {
172
+ type: types.PANEL,
173
+ title: "Code",
174
+ render: ({ active }) => (
175
+ <SourcePanel key={PANEL_ID} active={active} />
176
+ ),
177
+ });
178
+ });
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@praxisjs/storybook",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Storybook framework adapter for PraxisJS",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./preset": {
14
+ "types": "./dist/preset.d.ts",
15
+ "import": "./dist/preset.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "manager.jsx"
21
+ ],
22
+ "dependencies": {
23
+ "@praxisjs/runtime": "0.2.16",
24
+ "@praxisjs/vite-plugin": "0.1.1"
25
+ },
26
+ "peerDependencies": {
27
+ "@storybook/builder-vite": ">=8.0.0",
28
+ "@storybook/core": ">=8.0.0",
29
+ "storybook": ">=8.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@storybook/builder-vite": "^10.4.0",
33
+ "@storybook/core": "^8.6.0",
34
+ "storybook": "^10.4.0",
35
+ "typescript": "^5.9.3",
36
+ "vite": "^6.0.0"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "dev": "tsc --watch"
41
+ }
42
+ }