@storybook/react-dom-shim 9.2.0-alpha.3 → 10.0.0-beta.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/README.md CHANGED
@@ -1,3 +1,5 @@
1
1
  # React Dom Shim
2
2
 
3
3
  A shim for `react-dom` that provides a single API that will work whether the user is on `react-dom@17` or `react-dom@18`, as well as webpack/vite config necessary to make that work.
4
+
5
+ Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=readme).
@@ -0,0 +1,6 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ export {
5
+ __name
6
+ };
package/dist/preset.js CHANGED
@@ -1 +1,221 @@
1
- "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var preset_exports={};__export(preset_exports,{viteFinal:()=>viteFinal,webpackFinal:()=>webpackFinal});module.exports=__toCommonJS(preset_exports);var import_promises=require("fs/promises"),import_node_path=require("path"),getIsReactVersion18or19=async options=>{let{legacyRootApi}=await options.presets.apply("frameworkOptions")||{};if(legacyRootApi)return!1;let reactDom=(await options.presets.apply("resolvedReact",{})).reactDom||(0,import_node_path.dirname)(require.resolve("react-dom/package.json"));if(!(0,import_node_path.isAbsolute)(reactDom))return!1;let{version}=JSON.parse(await(0,import_promises.readFile)((0,import_node_path.join)(reactDom,"package.json"),"utf-8"));return version.startsWith("18")||version.startsWith("19")||version.startsWith("0.0.0")},webpackFinal=async(config,options)=>await getIsReactVersion18or19(options)?config:{...config,resolve:{...config.resolve,alias:{...config.resolve?.alias,"@storybook/react-dom-shim":"@storybook/react-dom-shim/dist/react-16"}}},viteFinal=async(config,options)=>{if(await getIsReactVersion18or19(options))return config;let alias=Array.isArray(config.resolve?.alias)?config.resolve.alias.concat({find:/^@storybook\/react-dom-shim$/,replacement:"@storybook/react-dom-shim/dist/react-16"}):{...config.resolve?.alias,"@storybook/react-dom-shim":"@storybook/react-dom-shim/dist/react-16"};return{...config,resolve:{...config.resolve,alias}}};0&&(module.exports={viteFinal,webpackFinal});
1
+ import CJS_COMPAT_NODE_URL_rwxqpo2vsur from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_rwxqpo2vsur from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_rwxqpo2vsur from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_rwxqpo2vsur.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_rwxqpo2vsur.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_rwxqpo2vsur.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 { readFile } from "node:fs/promises";
17
+ import { isAbsolute as isAbsolute2, join as join2 } from "node:path";
18
+
19
+ // ../../core/src/shared/utils/module.ts
20
+ import { fileURLToPath, pathToFileURL } from "node:url";
21
+
22
+ // ../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
23
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
24
+ function normalizeWindowsPath(input = "") {
25
+ if (!input) {
26
+ return input;
27
+ }
28
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
29
+ }
30
+ __name(normalizeWindowsPath, "normalizeWindowsPath");
31
+ var _UNC_REGEX = /^[/\\]{2}/;
32
+ var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
33
+ var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
34
+ var normalize = /* @__PURE__ */ __name(function(path2) {
35
+ if (path2.length === 0) {
36
+ return ".";
37
+ }
38
+ path2 = normalizeWindowsPath(path2);
39
+ const isUNCPath = path2.match(_UNC_REGEX);
40
+ const isPathAbsolute = isAbsolute(path2);
41
+ const trailingSeparator = path2[path2.length - 1] === "/";
42
+ path2 = normalizeString(path2, !isPathAbsolute);
43
+ if (path2.length === 0) {
44
+ if (isPathAbsolute) {
45
+ return "/";
46
+ }
47
+ return trailingSeparator ? "./" : ".";
48
+ }
49
+ if (trailingSeparator) {
50
+ path2 += "/";
51
+ }
52
+ if (_DRIVE_LETTER_RE.test(path2)) {
53
+ path2 += "/";
54
+ }
55
+ if (isUNCPath) {
56
+ if (!isPathAbsolute) {
57
+ return `//./${path2}`;
58
+ }
59
+ return `//${path2}`;
60
+ }
61
+ return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
62
+ }, "normalize");
63
+ var join = /* @__PURE__ */ __name(function(...arguments_) {
64
+ if (arguments_.length === 0) {
65
+ return ".";
66
+ }
67
+ let joined;
68
+ for (const argument of arguments_) {
69
+ if (argument && argument.length > 0) {
70
+ if (joined === void 0) {
71
+ joined = argument;
72
+ } else {
73
+ joined += `/${argument}`;
74
+ }
75
+ }
76
+ }
77
+ if (joined === void 0) {
78
+ return ".";
79
+ }
80
+ return normalize(joined.replace(/\/\/+/g, "/"));
81
+ }, "join");
82
+ function normalizeString(path2, allowAboveRoot) {
83
+ let res = "";
84
+ let lastSegmentLength = 0;
85
+ let lastSlash = -1;
86
+ let dots = 0;
87
+ let char = null;
88
+ for (let index = 0; index <= path2.length; ++index) {
89
+ if (index < path2.length) {
90
+ char = path2[index];
91
+ } else if (char === "/") {
92
+ break;
93
+ } else {
94
+ char = "/";
95
+ }
96
+ if (char === "/") {
97
+ if (lastSlash === index - 1 || dots === 1) ;
98
+ else if (dots === 2) {
99
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
100
+ if (res.length > 2) {
101
+ const lastSlashIndex = res.lastIndexOf("/");
102
+ if (lastSlashIndex === -1) {
103
+ res = "";
104
+ lastSegmentLength = 0;
105
+ } else {
106
+ res = res.slice(0, lastSlashIndex);
107
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
108
+ }
109
+ lastSlash = index;
110
+ dots = 0;
111
+ continue;
112
+ } else if (res.length > 0) {
113
+ res = "";
114
+ lastSegmentLength = 0;
115
+ lastSlash = index;
116
+ dots = 0;
117
+ continue;
118
+ }
119
+ }
120
+ if (allowAboveRoot) {
121
+ res += res.length > 0 ? "/.." : "..";
122
+ lastSegmentLength = 2;
123
+ }
124
+ } else {
125
+ if (res.length > 0) {
126
+ res += `/${path2.slice(lastSlash + 1, index)}`;
127
+ } else {
128
+ res = path2.slice(lastSlash + 1, index);
129
+ }
130
+ lastSegmentLength = index - lastSlash - 1;
131
+ }
132
+ lastSlash = index;
133
+ dots = 0;
134
+ } else if (char === "." && dots !== -1) {
135
+ ++dots;
136
+ } else {
137
+ dots = -1;
138
+ }
139
+ }
140
+ return res;
141
+ }
142
+ __name(normalizeString, "normalizeString");
143
+ var isAbsolute = /* @__PURE__ */ __name(function(p) {
144
+ return _IS_ABSOLUTE_RE.test(p);
145
+ }, "isAbsolute");
146
+ var dirname = /* @__PURE__ */ __name(function(p) {
147
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
148
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
149
+ segments[0] += "/";
150
+ }
151
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
152
+ }, "dirname");
153
+
154
+ // ../../core/src/shared/utils/module.ts
155
+ var importMetaResolve = /* @__PURE__ */ __name((...args) => {
156
+ if (typeof import.meta.resolve !== "function" && process.env.VITEST === "true") {
157
+ console.warn(
158
+ "importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
159
+ );
160
+ return pathToFileURL(args[0]).href;
161
+ }
162
+ return import.meta.resolve(...args);
163
+ }, "importMetaResolve");
164
+ var resolvePackageDir = /* @__PURE__ */ __name((pkg, parent) => {
165
+ return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"), parent)));
166
+ }, "resolvePackageDir");
167
+
168
+ // src/preset.ts
169
+ var getIsReactVersion18or19 = /* @__PURE__ */ __name(async (options) => {
170
+ const { legacyRootApi } = await options.presets.apply("frameworkOptions") || {};
171
+ if (legacyRootApi) {
172
+ return false;
173
+ }
174
+ const resolvedReact = await options.presets.apply("resolvedReact", {});
175
+ const reactDom = resolvedReact.reactDom || resolvePackageDir("react-dom");
176
+ if (!isAbsolute2(reactDom)) {
177
+ return false;
178
+ }
179
+ const { version } = JSON.parse(await readFile(join2(reactDom, "package.json"), "utf-8"));
180
+ return version.startsWith("18") || version.startsWith("19") || version.startsWith("0.0.0");
181
+ }, "getIsReactVersion18or19");
182
+ var webpackFinal = /* @__PURE__ */ __name(async (config, options) => {
183
+ const isReactVersion18 = await getIsReactVersion18or19(options);
184
+ if (isReactVersion18) {
185
+ return config;
186
+ }
187
+ return {
188
+ ...config,
189
+ resolve: {
190
+ ...config.resolve,
191
+ alias: {
192
+ ...config.resolve?.alias,
193
+ "@storybook/react-dom-shim": "@storybook/react-dom-shim/react-16"
194
+ }
195
+ }
196
+ };
197
+ }, "webpackFinal");
198
+ var viteFinal = /* @__PURE__ */ __name(async (config, options) => {
199
+ const isReactVersion18 = await getIsReactVersion18or19(options);
200
+ if (isReactVersion18) {
201
+ return config;
202
+ }
203
+ const alias = Array.isArray(config.resolve?.alias) ? config.resolve.alias.concat({
204
+ find: /^@storybook\/react-dom-shim$/,
205
+ replacement: "@storybook/react-dom-shim/react-16"
206
+ }) : {
207
+ ...config.resolve?.alias,
208
+ "@storybook/react-dom-shim": "@storybook/react-dom-shim/react-16"
209
+ };
210
+ return {
211
+ ...config,
212
+ resolve: {
213
+ ...config.resolve,
214
+ alias
215
+ }
216
+ };
217
+ }, "viteFinal");
218
+ export {
219
+ viteFinal,
220
+ webpackFinal
221
+ };
package/dist/react-16.js CHANGED
@@ -1 +1,18 @@
1
- "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var react_16_exports={};__export(react_16_exports,{renderElement:()=>renderElement,unmountElement:()=>unmountElement});module.exports=__toCommonJS(react_16_exports);var ReactDOM=__toESM(require("react-dom")),renderElement=async(node,el)=>new Promise(resolve=>{ReactDOM.render(node,el,()=>resolve(null))}),unmountElement=el=>{ReactDOM.unmountComponentAtNode(el)};0&&(module.exports={renderElement,unmountElement});
1
+ import {
2
+ __name
3
+ } from "./_browser-chunks/chunk-JK72E6FR.js";
4
+
5
+ // src/react-16.tsx
6
+ import * as ReactDOM from "react-dom";
7
+ var renderElement = /* @__PURE__ */ __name(async (node, el) => {
8
+ return new Promise((resolve) => {
9
+ ReactDOM.render(node, el, () => resolve(null));
10
+ });
11
+ }, "renderElement");
12
+ var unmountElement = /* @__PURE__ */ __name((el) => {
13
+ ReactDOM.unmountComponentAtNode(el);
14
+ }, "unmountElement");
15
+ export {
16
+ renderElement,
17
+ unmountElement
18
+ };
@@ -1,7 +1,3 @@
1
- import { ReactElement } from 'react';
2
- import { RootOptions } from 'react-dom/client';
3
-
4
- declare const renderElement: (node: ReactElement, el: Element, rootOptions?: RootOptions) => Promise<void>;
5
- declare const unmountElement: (el: Element, shouldUseNewRootApi?: boolean) => void;
6
-
7
- export { renderElement, unmountElement };
1
+ // auto generated file from file:///home/runner/work/storybook/storybook/scripts/build/utils/generate-type-mappers.ts, do not edit
2
+ export * from '../src/react-18.tsx';
3
+ export type * from '../src/react-18.tsx';
@@ -0,0 +1,7 @@
1
+ import { ReactElement } from 'react';
2
+ import { RootOptions } from 'react-dom/client';
3
+
4
+ declare const renderElement: (node: ReactElement, el: Element, rootOptions?: RootOptions) => Promise<void>;
5
+ declare const unmountElement: (el: Element, shouldUseNewRootApi?: boolean) => void;
6
+
7
+ export { renderElement, unmountElement };
package/dist/react-18.js CHANGED
@@ -1 +1,66 @@
1
- "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var react_18_exports={};__export(react_18_exports,{renderElement:()=>renderElement,unmountElement:()=>unmountElement});module.exports=__toCommonJS(react_18_exports);var React=__toESM(require("react")),ReactDOM=__toESM(require("react-dom/client")),nodes=new Map;function getIsReactActEnvironment(){return globalThis.IS_REACT_ACT_ENVIRONMENT}var WithCallback=({callback,children})=>{let once=React.useRef();return React.useLayoutEffect(()=>{once.current!==callback&&(once.current=callback,callback())},[callback]),children};typeof Promise.withResolvers>"u"&&(Promise.withResolvers=()=>{let resolve=null,reject=null;return{promise:new Promise((res,rej)=>{resolve=res,reject=rej}),resolve,reject}});var renderElement=async(node,el,rootOptions)=>{let root=await getReactRoot(el,rootOptions);if(getIsReactActEnvironment()){root.render(node);return}let{promise,resolve}=Promise.withResolvers();return root.render(React.createElement(WithCallback,{callback:resolve},node)),promise},unmountElement=(el,shouldUseNewRootApi)=>{let root=nodes.get(el);root&&(root.unmount(),nodes.delete(el))},getReactRoot=async(el,rootOptions)=>{let root=nodes.get(el);return root||(root=ReactDOM.createRoot(el,rootOptions),nodes.set(el,root)),root};0&&(module.exports={renderElement,unmountElement});
1
+ import {
2
+ __name
3
+ } from "./_browser-chunks/chunk-JK72E6FR.js";
4
+
5
+ // src/react-18.tsx
6
+ import * as React from "react";
7
+ import * as ReactDOM from "react-dom/client";
8
+ var nodes = /* @__PURE__ */ new Map();
9
+ function getIsReactActEnvironment() {
10
+ return globalThis.IS_REACT_ACT_ENVIRONMENT;
11
+ }
12
+ __name(getIsReactActEnvironment, "getIsReactActEnvironment");
13
+ var WithCallback = /* @__PURE__ */ __name(({
14
+ callback,
15
+ children
16
+ }) => {
17
+ const once = React.useRef();
18
+ React.useLayoutEffect(() => {
19
+ if (once.current === callback) {
20
+ return;
21
+ }
22
+ once.current = callback;
23
+ callback();
24
+ }, [callback]);
25
+ return children;
26
+ }, "WithCallback");
27
+ if (typeof Promise.withResolvers === "undefined") {
28
+ Promise.withResolvers = () => {
29
+ let resolve = null;
30
+ let reject = null;
31
+ const promise = new Promise((res, rej) => {
32
+ resolve = res;
33
+ reject = rej;
34
+ });
35
+ return { promise, resolve, reject };
36
+ };
37
+ }
38
+ var renderElement = /* @__PURE__ */ __name(async (node, el, rootOptions) => {
39
+ const root = await getReactRoot(el, rootOptions);
40
+ if (getIsReactActEnvironment()) {
41
+ root.render(node);
42
+ return;
43
+ }
44
+ const { promise, resolve } = Promise.withResolvers();
45
+ root.render(React.createElement(WithCallback, { callback: resolve }, node));
46
+ return promise;
47
+ }, "renderElement");
48
+ var unmountElement = /* @__PURE__ */ __name((el, shouldUseNewRootApi) => {
49
+ const root = nodes.get(el);
50
+ if (root) {
51
+ root.unmount();
52
+ nodes.delete(el);
53
+ }
54
+ }, "unmountElement");
55
+ var getReactRoot = /* @__PURE__ */ __name(async (el, rootOptions) => {
56
+ let root = nodes.get(el);
57
+ if (!root) {
58
+ root = ReactDOM.createRoot(el, rootOptions);
59
+ nodes.set(el, root);
60
+ }
61
+ return root;
62
+ }, "getReactRoot");
63
+ export {
64
+ renderElement,
65
+ unmountElement
66
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-dom-shim",
3
- "version": "9.2.0-alpha.3",
3
+ "version": "10.0.0-beta.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "storybook"
@@ -20,28 +20,16 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "sideEffects": false,
23
+ "type": "module",
23
24
  "exports": {
24
25
  ".": {
25
26
  "types": "./dist/react-18.d.ts",
26
- "import": "./dist/react-18.mjs",
27
- "require": "./dist/react-18.js",
28
- "node": "./dist/react-18.js"
27
+ "default": "./dist/react-18.js"
29
28
  },
30
- "./dist/react-16": {
31
- "types": "./dist/react-16.d.ts",
32
- "import": "./dist/react-16.mjs",
33
- "require": "./dist/react-16.js",
34
- "node": "./dist/react-16.js"
35
- },
36
- "./dist/preset": {
37
- "types": "./dist/preset.d.ts",
38
- "require": "./dist/preset.js"
39
- },
40
- "./package.json": "./package.json"
29
+ "./package.json": "./package.json",
30
+ "./preset": "./dist/preset.js",
31
+ "./react-16": "./dist/react-16.js"
41
32
  },
42
- "main": "dist/react-18.js",
43
- "module": "dist/react-18.mjs",
44
- "types": "dist/react-18.d.ts",
45
33
  "files": [
46
34
  "dist/**/*",
47
35
  "README.md",
@@ -50,26 +38,19 @@
50
38
  "!src/**/*"
51
39
  ],
52
40
  "scripts": {
53
- "check": "jiti ../../../scripts/prepare/check.ts",
54
- "prep": "jiti ../../../scripts/prepare/bundle.ts"
41
+ "check": "jiti ../../../scripts/check/check-package.ts",
42
+ "prep": "jiti ../../../scripts/build/build-package.ts"
55
43
  },
56
44
  "devDependencies": {
57
45
  "typescript": "^5.8.3"
58
46
  },
59
47
  "peerDependencies": {
60
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
61
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
62
- "storybook": "^9.2.0-alpha.3"
48
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
49
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
50
+ "storybook": "^10.0.0-beta.0"
63
51
  },
64
52
  "publishConfig": {
65
53
  "access": "public"
66
54
  },
67
- "bundler": {
68
- "entries": [
69
- "./src/preset.ts",
70
- "./src/react-16.tsx",
71
- "./src/react-18.tsx"
72
- ]
73
- },
74
- "gitHead": "ce6a1e4a8d5ad69c699021a0b183df89cfc7b684"
55
+ "gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae16"
75
56
  }
package/dist/preset.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { Options } from 'storybook/internal/types';
2
-
3
- declare const webpackFinal: (config: any, options: Options) => Promise<any>;
4
- declare const viteFinal: (config: any, options: Options) => Promise<any>;
5
-
6
- export { viteFinal, webpackFinal };
@@ -1,6 +0,0 @@
1
- import { ReactElement } from 'react';
2
-
3
- declare const renderElement: (node: ReactElement, el: Element) => Promise<null>;
4
- declare const unmountElement: (el: Element) => void;
5
-
6
- export { renderElement, unmountElement };
package/dist/react-16.mjs DELETED
@@ -1,5 +0,0 @@
1
- import * as ReactDOM from 'react-dom';
2
-
3
- var renderElement=async(node,el)=>new Promise(resolve=>{ReactDOM.render(node,el,()=>resolve(null));}),unmountElement=el=>{ReactDOM.unmountComponentAtNode(el);};
4
-
5
- export { renderElement, unmountElement };
package/dist/react-18.mjs DELETED
@@ -1,6 +0,0 @@
1
- import * as React from 'react';
2
- import * as ReactDOM from 'react-dom/client';
3
-
4
- var nodes=new Map;function getIsReactActEnvironment(){return globalThis.IS_REACT_ACT_ENVIRONMENT}var WithCallback=({callback,children})=>{let once=React.useRef();return React.useLayoutEffect(()=>{once.current!==callback&&(once.current=callback,callback());},[callback]),children};typeof Promise.withResolvers>"u"&&(Promise.withResolvers=()=>{let resolve=null,reject=null;return {promise:new Promise((res,rej)=>{resolve=res,reject=rej;}),resolve,reject}});var renderElement=async(node,el,rootOptions)=>{let root=await getReactRoot(el,rootOptions);if(getIsReactActEnvironment()){root.render(node);return}let{promise,resolve}=Promise.withResolvers();return root.render(React.createElement(WithCallback,{callback:resolve},node)),promise},unmountElement=(el,shouldUseNewRootApi)=>{let root=nodes.get(el);root&&(root.unmount(),nodes.delete(el));},getReactRoot=async(el,rootOptions)=>{let root=nodes.get(el);return root||(root=ReactDOM.createRoot(el,rootOptions),nodes.set(el,root)),root};
5
-
6
- export { renderElement, unmountElement };