@storybook/preact 0.0.0-pr-31311-sha-927762ce → 0.0.0-pr-31819-sha-dc7e86b3
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/dist/_browser-chunks/chunk-JFJ5UJ7Q.js +11 -0
- package/dist/_browser-chunks/chunk-T4MBQD64.js +70 -0
- package/dist/entry-preview-docs.js +11 -1
- package/dist/entry-preview.js +11 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +29 -4
- package/dist/preset.js +38 -1
- package/package.json +11 -26
- package/preset.js +1 -1
- package/dist/chunk-CEH6MNVV.mjs +0 -3
- package/dist/chunk-YWXRTNBA.mjs +0 -10
- package/dist/entry-preview-docs.d.ts +0 -9
- package/dist/entry-preview-docs.mjs +0 -5
- package/dist/entry-preview.d.ts +0 -14
- package/dist/entry-preview.mjs +0 -2
- package/dist/index.mjs +0 -8
- package/dist/preset.d.ts +0 -10
- package/dist/types-57f4f889.d.ts +0 -10
@@ -0,0 +1,11 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
3
|
+
var __export = (target, all) => {
|
4
|
+
for (var name in all)
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
6
|
+
};
|
7
|
+
|
8
|
+
export {
|
9
|
+
__name,
|
10
|
+
__export
|
11
|
+
};
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import {
|
2
|
+
__export,
|
3
|
+
__name
|
4
|
+
} from "./chunk-JFJ5UJ7Q.js";
|
5
|
+
|
6
|
+
// src/entry-preview.ts
|
7
|
+
var entry_preview_exports = {};
|
8
|
+
__export(entry_preview_exports, {
|
9
|
+
parameters: () => parameters,
|
10
|
+
render: () => render2,
|
11
|
+
renderToCanvas: () => renderToCanvas
|
12
|
+
});
|
13
|
+
|
14
|
+
// src/render.tsx
|
15
|
+
import * as preact from "preact";
|
16
|
+
import { dedent } from "ts-dedent";
|
17
|
+
var { h: h2 } = preact;
|
18
|
+
var render2 = /* @__PURE__ */ __name((args, context) => {
|
19
|
+
const { id, component: Component } = context;
|
20
|
+
if (!Component) {
|
21
|
+
throw new Error(
|
22
|
+
`Unable to render story ${id} as the component annotation is missing from the default export`
|
23
|
+
);
|
24
|
+
}
|
25
|
+
return h2(Component, { ...args });
|
26
|
+
}, "render");
|
27
|
+
var renderedStory;
|
28
|
+
function preactRender(story, canvasElement) {
|
29
|
+
if (preact.Fragment) {
|
30
|
+
preact.render(story, canvasElement);
|
31
|
+
} else {
|
32
|
+
renderedStory = preact.render(story, canvasElement, renderedStory);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
__name(preactRender, "preactRender");
|
36
|
+
var StoryHarness = /* @__PURE__ */ __name(({ showError, name, title, storyFn, canvasElement }) => {
|
37
|
+
const content = preact.h(storyFn, null);
|
38
|
+
if (!content) {
|
39
|
+
showError({
|
40
|
+
title: `Expecting a Preact element from the story: "${name}" of "${title}".`,
|
41
|
+
description: dedent`
|
42
|
+
Did you forget to return the Preact element from the story?
|
43
|
+
Use "() => (<MyComp/>)" or "() => { return <MyComp/>; }" when defining the story.
|
44
|
+
`
|
45
|
+
});
|
46
|
+
return null;
|
47
|
+
}
|
48
|
+
return content;
|
49
|
+
}, "StoryHarness");
|
50
|
+
function renderToCanvas({ storyFn, title, name, showMain, showError, forceRemount }, canvasElement) {
|
51
|
+
if (forceRemount) {
|
52
|
+
preactRender(null, canvasElement);
|
53
|
+
}
|
54
|
+
showMain();
|
55
|
+
preactRender(
|
56
|
+
preact.h(StoryHarness, { name, title, showError, storyFn, canvasElement }),
|
57
|
+
canvasElement
|
58
|
+
);
|
59
|
+
}
|
60
|
+
__name(renderToCanvas, "renderToCanvas");
|
61
|
+
|
62
|
+
// src/entry-preview.ts
|
63
|
+
var parameters = { renderer: "preact" };
|
64
|
+
|
65
|
+
export {
|
66
|
+
render2 as render,
|
67
|
+
renderToCanvas,
|
68
|
+
parameters,
|
69
|
+
entry_preview_exports
|
70
|
+
};
|
@@ -1 +1,11 @@
|
|
1
|
-
|
1
|
+
import "./_browser-chunks/chunk-JFJ5UJ7Q.js";
|
2
|
+
|
3
|
+
// src/entry-preview-docs.ts
|
4
|
+
var parameters = {
|
5
|
+
docs: {
|
6
|
+
story: { inline: true }
|
7
|
+
}
|
8
|
+
};
|
9
|
+
export {
|
10
|
+
parameters
|
11
|
+
};
|
package/dist/entry-preview.js
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import {
|
2
|
+
parameters,
|
3
|
+
render,
|
4
|
+
renderToCanvas
|
5
|
+
} from "./_browser-chunks/chunk-T4MBQD64.js";
|
6
|
+
import "./_browser-chunks/chunk-JFJ5UJ7Q.js";
|
7
|
+
export {
|
8
|
+
parameters,
|
9
|
+
render,
|
10
|
+
renderToCanvas
|
11
|
+
};
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
import { Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations, StrictArgs, DecoratorFunction, LoaderFunction, StoryContext as StoryContext$1, ProjectAnnotations, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations } from 'storybook/internal/types';
|
1
|
+
import { WebRenderer, Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations, StrictArgs, DecoratorFunction, LoaderFunction, StoryContext as StoryContext$1, ProjectAnnotations, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations } from 'storybook/internal/types';
|
2
2
|
export { ArgTypes, Args, Parameters, StrictArgs } from 'storybook/internal/types';
|
3
|
-
import {
|
4
|
-
|
3
|
+
import { AnyComponent } from 'preact';
|
4
|
+
|
5
|
+
type StoryFnPreactReturnType = string | Node | preact.JSX.Element;
|
6
|
+
interface PreactRenderer extends WebRenderer {
|
7
|
+
component: AnyComponent<any, any>;
|
8
|
+
storyResult: StoryFnPreactReturnType;
|
9
|
+
}
|
5
10
|
|
6
11
|
/**
|
7
12
|
* Metadata to configure the stories for a component.
|
@@ -47,4 +52,4 @@ type Preview = ProjectAnnotations<PreactRenderer>;
|
|
47
52
|
*/
|
48
53
|
declare function setProjectAnnotations(projectAnnotations: NamedOrDefaultProjectAnnotations<any> | NamedOrDefaultProjectAnnotations<any>[]): NormalizedProjectAnnotations<PreactRenderer>;
|
49
54
|
|
50
|
-
export { Decorator, Loader, Meta, PreactRenderer, Preview, StoryContext, StoryFn, StoryObj, setProjectAnnotations };
|
55
|
+
export { type Decorator, type Loader, type Meta, type PreactRenderer, type Preview, type StoryContext, type StoryFn, type StoryObj, setProjectAnnotations };
|
package/dist/index.js
CHANGED
@@ -1,4 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import {
|
2
|
+
entry_preview_exports
|
3
|
+
} from "./_browser-chunks/chunk-T4MBQD64.js";
|
4
|
+
import {
|
5
|
+
__name
|
6
|
+
} from "./_browser-chunks/chunk-JFJ5UJ7Q.js";
|
7
|
+
|
8
|
+
// src/globals.ts
|
9
|
+
import { global } from "@storybook/global";
|
10
|
+
var { window: globalWindow } = global;
|
11
|
+
if (globalWindow) {
|
12
|
+
globalWindow.STORYBOOK_ENV = "preact";
|
13
|
+
}
|
14
|
+
|
15
|
+
// src/portable-stories.ts
|
16
|
+
import {
|
17
|
+
setProjectAnnotations as originalSetProjectAnnotations,
|
18
|
+
setDefaultProjectAnnotations
|
19
|
+
} from "storybook/preview-api";
|
20
|
+
function setProjectAnnotations(projectAnnotations) {
|
21
|
+
setDefaultProjectAnnotations(entry_preview_exports);
|
22
|
+
return originalSetProjectAnnotations(
|
23
|
+
projectAnnotations
|
24
|
+
);
|
25
|
+
}
|
26
|
+
__name(setProjectAnnotations, "setProjectAnnotations");
|
27
|
+
export {
|
28
|
+
setProjectAnnotations
|
29
|
+
};
|
package/dist/preset.js
CHANGED
@@ -1 +1,38 @@
|
|
1
|
-
|
1
|
+
import CJS_COMPAT_NODE_URL_vk2miexbrsq from 'node:url';
|
2
|
+
import CJS_COMPAT_NODE_PATH_vk2miexbrsq from 'node:path';
|
3
|
+
import CJS_COMPAT_NODE_MODULE_vk2miexbrsq from "node:module";
|
4
|
+
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_vk2miexbrsq.fileURLToPath(import.meta.url);
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_vk2miexbrsq.dirname(__filename);
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_vk2miexbrsq.createRequire(import.meta.url);
|
8
|
+
|
9
|
+
// ------------------------------------------------------------
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
11
|
+
// ------------------------------------------------------------
|
12
|
+
var __defProp = Object.defineProperty;
|
13
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
14
|
+
|
15
|
+
// src/preset.ts
|
16
|
+
import { fileURLToPath } from "node:url";
|
17
|
+
var previewAnnotations = /* @__PURE__ */ __name(async (input = [], options) => {
|
18
|
+
const docsEnabled = Object.keys(await options.presets.apply("docs", {}, options)).length > 0;
|
19
|
+
const result = [];
|
20
|
+
return result.concat(input).concat([fileURLToPath(import.meta.resolve("@storybook/preact/entry-preview"))]).concat(
|
21
|
+
docsEnabled ? [fileURLToPath(import.meta.resolve("@storybook/preact/entry-preview-docs"))] : []
|
22
|
+
);
|
23
|
+
}, "previewAnnotations");
|
24
|
+
var resolvedReact = /* @__PURE__ */ __name(async (existing) => {
|
25
|
+
try {
|
26
|
+
return {
|
27
|
+
...existing,
|
28
|
+
react: "preact/compat",
|
29
|
+
reactDom: "preact/compat"
|
30
|
+
};
|
31
|
+
} catch (e) {
|
32
|
+
return existing;
|
33
|
+
}
|
34
|
+
}, "resolvedReact");
|
35
|
+
export {
|
36
|
+
previewAnnotations,
|
37
|
+
resolvedReact
|
38
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/preact",
|
3
|
-
"version": "0.0.0-pr-
|
3
|
+
"version": "0.0.0-pr-31819-sha-dc7e86b3",
|
4
4
|
"description": "Storybook Preact renderer",
|
5
5
|
"keywords": [
|
6
6
|
"storybook"
|
@@ -19,20 +19,17 @@
|
|
19
19
|
"url": "https://opencollective.com/storybook"
|
20
20
|
},
|
21
21
|
"license": "MIT",
|
22
|
+
"type": "module",
|
22
23
|
"exports": {
|
23
24
|
".": {
|
24
25
|
"types": "./dist/index.d.ts",
|
25
|
-
"
|
26
|
-
"require": "./dist/index.js"
|
26
|
+
"default": "./dist/index.js"
|
27
27
|
},
|
28
|
-
"./
|
29
|
-
"./
|
30
|
-
"./
|
31
|
-
"./
|
28
|
+
"./entry-preview": "./dist/entry-preview.js",
|
29
|
+
"./entry-preview-docs": "./dist/entry-preview-docs.js",
|
30
|
+
"./package.json": "./package.json",
|
31
|
+
"./preset": "./dist/preset.js"
|
32
32
|
},
|
33
|
-
"main": "dist/index.js",
|
34
|
-
"module": "dist/index.mjs",
|
35
|
-
"types": "dist/index.d.ts",
|
36
33
|
"files": [
|
37
34
|
"dist/**/*",
|
38
35
|
"template/cli/**/*",
|
@@ -42,8 +39,8 @@
|
|
42
39
|
"!src/**/*"
|
43
40
|
],
|
44
41
|
"scripts": {
|
45
|
-
"check": "jiti ../../../scripts/
|
46
|
-
"prep": "jiti ../../../scripts/
|
42
|
+
"check": "jiti ../../../scripts/check/check-package.ts",
|
43
|
+
"prep": "jiti ../../../scripts/build/build-package.ts"
|
47
44
|
},
|
48
45
|
"dependencies": {
|
49
46
|
"@storybook/global": "^5.0.0",
|
@@ -55,22 +52,10 @@
|
|
55
52
|
},
|
56
53
|
"peerDependencies": {
|
57
54
|
"preact": "^8.0.0||^10.0.0",
|
58
|
-
"storybook": "^0.0.0-pr-
|
59
|
-
},
|
60
|
-
"engines": {
|
61
|
-
"node": ">=20.0.0"
|
55
|
+
"storybook": "^0.0.0-pr-31819-sha-dc7e86b3"
|
62
56
|
},
|
63
57
|
"publishConfig": {
|
64
58
|
"access": "public"
|
65
59
|
},
|
66
|
-
"
|
67
|
-
"entries": [
|
68
|
-
"./src/index.ts",
|
69
|
-
"./src/preset.ts",
|
70
|
-
"./src/entry-preview.ts",
|
71
|
-
"./src/entry-preview-docs.ts"
|
72
|
-
],
|
73
|
-
"platform": "browser"
|
74
|
-
},
|
75
|
-
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16"
|
60
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae14"
|
76
61
|
}
|
package/preset.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
export * from './dist/preset.js';
|
package/dist/chunk-CEH6MNVV.mjs
DELETED
package/dist/chunk-YWXRTNBA.mjs
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import { __export } from './chunk-CEH6MNVV.mjs';
|
2
|
-
import * as preact from 'preact';
|
3
|
-
import { dedent } from 'ts-dedent';
|
4
|
-
|
5
|
-
var entry_preview_exports={};__export(entry_preview_exports,{parameters:()=>parameters,render:()=>render2,renderToCanvas:()=>renderToCanvas});var {h:h2}=preact,render2=(args,context)=>{let{id,component:Component}=context;if(!Component)throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);return h2(Component,{...args})},renderedStory;function preactRender(story,canvasElement){preact.Fragment?preact.render(story,canvasElement):renderedStory=preact.render(story,canvasElement,renderedStory);}var StoryHarness=({showError,name,title,storyFn,canvasElement})=>{let content=preact.h(storyFn,null);return content||(showError({title:`Expecting a Preact element from the story: "${name}" of "${title}".`,description:dedent`
|
6
|
-
Did you forget to return the Preact element from the story?
|
7
|
-
Use "() => (<MyComp/>)" or "() => { return <MyComp/>; }" when defining the story.
|
8
|
-
`}),null)};function renderToCanvas({storyFn,title,name,showMain,showError,forceRemount},canvasElement){forceRemount&&preactRender(null,canvasElement),showMain(),preactRender(preact.h(StoryHarness,{name,title,showError,storyFn,canvasElement}),canvasElement);}var parameters={renderer:"preact"};
|
9
|
-
|
10
|
-
export { entry_preview_exports, parameters, render2 as render, renderToCanvas };
|
package/dist/entry-preview.d.ts
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import { ArgsStoryFn, RenderContext } from 'storybook/internal/types';
|
2
|
-
import { P as PreactRenderer } from './types-57f4f889.js';
|
3
|
-
import 'preact';
|
4
|
-
|
5
|
-
/** @jsx h */
|
6
|
-
|
7
|
-
declare const render: ArgsStoryFn<PreactRenderer>;
|
8
|
-
declare function renderToCanvas({ storyFn, title, name, showMain, showError, forceRemount }: RenderContext<PreactRenderer>, canvasElement: PreactRenderer['canvasElement']): void;
|
9
|
-
|
10
|
-
declare const parameters: {
|
11
|
-
renderer: string;
|
12
|
-
};
|
13
|
-
|
14
|
-
export { parameters, render, renderToCanvas };
|
package/dist/entry-preview.mjs
DELETED
package/dist/index.mjs
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import { entry_preview_exports } from './chunk-YWXRTNBA.mjs';
|
2
|
-
import './chunk-CEH6MNVV.mjs';
|
3
|
-
import { global } from '@storybook/global';
|
4
|
-
import { setDefaultProjectAnnotations, setProjectAnnotations as setProjectAnnotations$1 } from 'storybook/preview-api';
|
5
|
-
|
6
|
-
var{window:globalWindow}=global;globalWindow&&(globalWindow.STORYBOOK_ENV="preact");function setProjectAnnotations(projectAnnotations){return setDefaultProjectAnnotations(entry_preview_exports),setProjectAnnotations$1(projectAnnotations)}
|
7
|
-
|
8
|
-
export { setProjectAnnotations };
|
package/dist/preset.d.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import { PresetProperty } from 'storybook/internal/types';
|
2
|
-
|
3
|
-
declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
|
4
|
-
/**
|
5
|
-
* Alias react and react-dom to preact/compat similar to the preact vite preset
|
6
|
-
* https://github.com/preactjs/preset-vite/blob/main/src/index.ts#L238-L239
|
7
|
-
*/
|
8
|
-
declare const resolvedReact: (existing: any) => Promise<any>;
|
9
|
-
|
10
|
-
export { previewAnnotations, resolvedReact };
|
package/dist/types-57f4f889.d.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import { WebRenderer } from 'storybook/internal/types';
|
2
|
-
import { AnyComponent } from 'preact';
|
3
|
-
|
4
|
-
type StoryFnPreactReturnType = string | Node | preact.JSX.Element;
|
5
|
-
interface PreactRenderer extends WebRenderer {
|
6
|
-
component: AnyComponent<any, any>;
|
7
|
-
storyResult: StoryFnPreactReturnType;
|
8
|
-
}
|
9
|
-
|
10
|
-
export { PreactRenderer as P };
|