storybook-builder-rsbuild 0.1.1 → 0.1.2
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/index.js
    CHANGED
    
    | 
         @@ -122,10 +122,9 @@ module.exports = __toCommonJS(src_exports); 
     | 
|
| 
       122 
122 
     | 
    
         
             
            var import_node_net = require("net");
         
     | 
| 
       123 
123 
     | 
    
         
             
            var import_node_path5 = require("path");
         
     | 
| 
       124 
124 
     | 
    
         
             
            var rsbuildReal = __toESM(require("@rsbuild/core"));
         
     | 
| 
       125 
     | 
    
         
            -
            var import_core2 = require("@rsbuild/core");
         
     | 
| 
       126 
     | 
    
         
            -
            var import_express = __toESM(require("express"));
         
     | 
| 
       127 
125 
     | 
    
         
             
            var import_fs_extra = __toESM(require("fs-extra"));
         
     | 
| 
       128 
126 
     | 
    
         
             
            var import_pretty_hrtime = __toESM(require_pretty_hrtime());
         
     | 
| 
      
 127 
     | 
    
         
            +
            var import_sirv = __toESM(require("sirv"));
         
     | 
| 
       129 
128 
     | 
    
         
             
            var import_core_path = require("storybook/core-path");
         
     | 
| 
       130 
129 
     | 
    
         
             
            var import_common3 = require("storybook/internal/common");
         
     | 
| 
       131 
130 
     | 
    
         
             
            var import_server_errors = require("storybook/internal/server-errors");
         
     | 
| 
         @@ -162,7 +161,15 @@ var import_ts_dedent = require("ts-dedent"); 
     | 
|
| 
       162 
161 
     | 
    
         
             
            var getVirtualModules = async (options) => {
         
     | 
| 
       163 
162 
     | 
    
         
             
              const virtualModules = {};
         
     | 
| 
       164 
163 
     | 
    
         
             
              const cwd = process.cwd();
         
     | 
| 
       165 
     | 
    
         
            -
              const workingDir = options.cache 
     | 
| 
      
 164 
     | 
    
         
            +
              const workingDir = options.cache ? import_node_path.default.resolve(
         
     | 
| 
      
 165 
     | 
    
         
            +
                process.cwd(),
         
     | 
| 
      
 166 
     | 
    
         
            +
                // TODO: This is a hard code cache dir, as Rspack doesn't support virtual modules now.
         
     | 
| 
      
 167 
     | 
    
         
            +
                // Remove this when Rspack supports virtual modules.
         
     | 
| 
      
 168 
     | 
    
         
            +
                "./node_modules/.cache/storybook/storybook-rsbuild-builder"
         
     | 
| 
      
 169 
     | 
    
         
            +
              ) : process.cwd();
         
     | 
| 
      
 170 
     | 
    
         
            +
              if (!import_node_fs.default.existsSync(workingDir)) {
         
     | 
| 
      
 171 
     | 
    
         
            +
                import_node_fs.default.mkdirSync(workingDir, { recursive: true });
         
     | 
| 
      
 172 
     | 
    
         
            +
              }
         
     | 
| 
       166 
173 
     | 
    
         
             
              const isProd = options.configType === "PRODUCTION";
         
     | 
| 
       167 
174 
     | 
    
         
             
              const nonNormalizedStories = await options.presets.apply("stories", []);
         
     | 
| 
       168 
175 
     | 
    
         
             
              const entries = [];
         
     | 
| 
         @@ -192,15 +199,14 @@ var getVirtualModules = async (options) => { 
     | 
|
| 
       192 
199 
     | 
    
         
             
                needPipelinedImport
         
     | 
| 
       193 
200 
     | 
    
         
             
              });
         
     | 
| 
       194 
201 
     | 
    
         
             
              const configEntryPath = (0, import_node_path2.resolve)((0, import_node_path2.join)(workingDir, "storybook-config-entry.js"));
         
     | 
| 
       195 
     | 
    
         
            -
              virtualModules[configEntryPath] = (0, import_common. 
     | 
| 
       196 
     | 
    
         
            -
                 
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
       198 
     | 
    
         
            -
                 
     | 
| 
       199 
     | 
    
         
            -
                {
         
     | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
                }
         
     | 
| 
       203 
     | 
    
         
            -
                // We need to double escape `\` for webpack. We may have some in windows paths
         
     | 
| 
      
 202 
     | 
    
         
            +
              virtualModules[configEntryPath] = (await (0, import_common.readTemplate)(
         
     | 
| 
      
 203 
     | 
    
         
            +
                require.resolve("storybook-builder-rsbuild/templates/virtualModuleModernEntry.js")
         
     | 
| 
      
 204 
     | 
    
         
            +
              )).replaceAll(`'{{storiesFilename}}'`, `'./${storiesFilename}'`).replaceAll(
         
     | 
| 
      
 205 
     | 
    
         
            +
                `'{{previewAnnotations}}'`,
         
     | 
| 
      
 206 
     | 
    
         
            +
                previewAnnotations.filter(Boolean).map((entry) => `'${entry}'`).join(",")
         
     | 
| 
      
 207 
     | 
    
         
            +
              ).replaceAll(
         
     | 
| 
      
 208 
     | 
    
         
            +
                `'{{previewAnnotations_requires}}'`,
         
     | 
| 
      
 209 
     | 
    
         
            +
                previewAnnotations.filter(Boolean).map((entry) => `require('${entry}')`).join(",")
         
     | 
| 
       204 
210 
     | 
    
         
             
              ).replace(/\\/g, "\\\\");
         
     | 
| 
       205 
211 
     | 
    
         
             
              entries.push(configEntryPath);
         
     | 
| 
       206 
212 
     | 
    
         
             
              for (const [key, value] of Object.entries(virtualModules)) {
         
     | 
| 
         @@ -327,7 +333,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => { 
     | 
|
| 
       327 
333 
     | 
    
         
             
                docsOptions,
         
     | 
| 
       328 
334 
     | 
    
         
             
                entries,
         
     | 
| 
       329 
335 
     | 
    
         
             
                nonNormalizedStories,
         
     | 
| 
       330 
     | 
    
         
            -
                 
     | 
| 
      
 336 
     | 
    
         
            +
                _modulesCount,
         
     | 
| 
       331 
337 
     | 
    
         
             
                build2,
         
     | 
| 
       332 
338 
     | 
    
         
             
                tagsOptions
         
     | 
| 
       333 
339 
     | 
    
         
             
              ] = await Promise.all([
         
     | 
| 
         @@ -341,8 +347,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => { 
     | 
|
| 
       341 
347 
     | 
    
         
             
                presets.apply("docs"),
         
     | 
| 
       342 
348 
     | 
    
         
             
                presets.apply("entries", []),
         
     | 
| 
       343 
349 
     | 
    
         
             
                presets.apply("stories", []),
         
     | 
| 
       344 
     | 
    
         
            -
                options.cache?.get("modulesCount") 
     | 
| 
       345 
     | 
    
         
            -
                }),
         
     | 
| 
      
 350 
     | 
    
         
            +
                options.cache?.get("modulesCount", 1e3),
         
     | 
| 
       346 
351 
     | 
    
         
             
                options.presets.apply("build"),
         
     | 
| 
       347 
352 
     | 
    
         
             
                presets.apply("tags", {})
         
     | 
| 
       348 
353 
     | 
    
         
             
              ]);
         
     | 
| 
         @@ -655,7 +660,7 @@ var rsbuild = async (_, options) => { 
     | 
|
| 
       655 
660 
     | 
    
         
             
              );
         
     | 
| 
       656 
661 
     | 
    
         
             
              let defaultConfig = await iframe_rsbuild_config_default(options, webpackAddonsConfig);
         
     | 
| 
       657 
662 
     | 
    
         
             
              const shimsConfig = await applyReactShims(defaultConfig, options);
         
     | 
| 
       658 
     | 
    
         
            -
              defaultConfig =  
     | 
| 
      
 663 
     | 
    
         
            +
              defaultConfig = rsbuildReal.mergeRsbuildConfig(
         
     | 
| 
       659 
664 
     | 
    
         
             
                defaultConfig,
         
     | 
| 
       660 
665 
     | 
    
         
             
                shimsConfig
         
     | 
| 
       661 
666 
     | 
    
         
             
              );
         
     | 
| 
         @@ -725,7 +730,7 @@ var start = async ({ 
     | 
|
| 
       725 
730 
     | 
    
         
             
              const previewDirOrigin = previewResolvedDir;
         
     | 
| 
       726 
731 
     | 
    
         
             
              router.use(
         
     | 
| 
       727 
732 
     | 
    
         
             
                "/sb-preview",
         
     | 
| 
       728 
     | 
    
         
            -
                 
     | 
| 
      
 733 
     | 
    
         
            +
                (0, import_sirv.default)(previewDirOrigin, { maxAge: 3e5, dev: true, immutable: true })
         
     | 
| 
       729 
734 
     | 
    
         
             
              );
         
     | 
| 
       730 
735 
     | 
    
         
             
              router.use(rsbuildServer.middlewares);
         
     | 
| 
       731 
736 
     | 
    
         
             
              rsbuildServer.connectWebSocket({ server: storybookServer });
         
     | 
    
        package/dist/index.mjs
    CHANGED
    
    | 
         @@ -2,11 +2,11 @@ import { __commonJS, __toESM, __require } from './chunk-TTFRSOOU.mjs'; 
     | 
|
| 
       2 
2 
     | 
    
         
             
            import { createServer } from 'net';
         
     | 
| 
       3 
3 
     | 
    
         
             
            import path, { join, resolve, parse, dirname, isAbsolute } from 'path';
         
     | 
| 
       4 
4 
     | 
    
         
             
            import * as rsbuildReal from '@rsbuild/core';
         
     | 
| 
       5 
     | 
    
         
            -
            import {  
     | 
| 
       6 
     | 
    
         
            -
            import express from 'express';
         
     | 
| 
      
 5 
     | 
    
         
            +
            import { loadConfig, mergeRsbuildConfig } from '@rsbuild/core';
         
     | 
| 
       7 
6 
     | 
    
         
             
            import fs2 from 'fs-extra';
         
     | 
| 
      
 7 
     | 
    
         
            +
            import sirv from 'sirv';
         
     | 
| 
       8 
8 
     | 
    
         
             
            import { corePath } from 'storybook/core-path';
         
     | 
| 
       9 
     | 
    
         
            -
            import { normalizeStories, loadPreviewOrConfigFile, getBuilderOptions,  
     | 
| 
      
 9 
     | 
    
         
            +
            import { normalizeStories, loadPreviewOrConfigFile, getBuilderOptions, readTemplate, resolveAddonName, getPresets, stringifyProcessEnvs, isPreservingSymlinks } from 'storybook/internal/common';
         
     | 
| 
       10 
10 
     | 
    
         
             
            import { WebpackInvocationError } from 'storybook/internal/server-errors';
         
     | 
| 
       11 
11 
     | 
    
         
             
            import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
         
     | 
| 
       12 
12 
     | 
    
         
             
            import { webpack } from '@storybook/addon-docs/dist/preset';
         
     | 
| 
         @@ -103,7 +103,15 @@ function slash(path2) { 
     | 
|
| 
       103 
103 
     | 
    
         
             
            var getVirtualModules = async (options) => {
         
     | 
| 
       104 
104 
     | 
    
         
             
              const virtualModules = {};
         
     | 
| 
       105 
105 
     | 
    
         
             
              const cwd = process.cwd();
         
     | 
| 
       106 
     | 
    
         
            -
              const workingDir = options.cache 
     | 
| 
      
 106 
     | 
    
         
            +
              const workingDir = options.cache ? path.resolve(
         
     | 
| 
      
 107 
     | 
    
         
            +
                process.cwd(),
         
     | 
| 
      
 108 
     | 
    
         
            +
                // TODO: This is a hard code cache dir, as Rspack doesn't support virtual modules now.
         
     | 
| 
      
 109 
     | 
    
         
            +
                // Remove this when Rspack supports virtual modules.
         
     | 
| 
      
 110 
     | 
    
         
            +
                "./node_modules/.cache/storybook/storybook-rsbuild-builder"
         
     | 
| 
      
 111 
     | 
    
         
            +
              ) : process.cwd();
         
     | 
| 
      
 112 
     | 
    
         
            +
              if (!fs.existsSync(workingDir)) {
         
     | 
| 
      
 113 
     | 
    
         
            +
                fs.mkdirSync(workingDir, { recursive: true });
         
     | 
| 
      
 114 
     | 
    
         
            +
              }
         
     | 
| 
       107 
115 
     | 
    
         
             
              const isProd = options.configType === "PRODUCTION";
         
     | 
| 
       108 
116 
     | 
    
         
             
              const nonNormalizedStories = await options.presets.apply("stories", []);
         
     | 
| 
       109 
117 
     | 
    
         
             
              const entries = [];
         
     | 
| 
         @@ -133,17 +141,16 @@ var getVirtualModules = async (options) => { 
     | 
|
| 
       133 
141 
     | 
    
         
             
                needPipelinedImport
         
     | 
| 
       134 
142 
     | 
    
         
             
              });
         
     | 
| 
       135 
143 
     | 
    
         
             
              const configEntryPath = resolve(join(workingDir, "storybook-config-entry.js"));
         
     | 
| 
       136 
     | 
    
         
            -
              virtualModules[configEntryPath] =  
     | 
| 
       137 
     | 
    
         
            -
                 
     | 
| 
       138 
     | 
    
         
            -
                   
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
                 
     | 
| 
       142 
     | 
    
         
            -
                {
         
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
                }
         
     | 
| 
       146 
     | 
    
         
            -
                // We need to double escape `\` for webpack. We may have some in windows paths
         
     | 
| 
      
 144 
     | 
    
         
            +
              virtualModules[configEntryPath] = (await readTemplate(
         
     | 
| 
      
 145 
     | 
    
         
            +
                __require.resolve(
         
     | 
| 
      
 146 
     | 
    
         
            +
                  "storybook-builder-rsbuild/templates/virtualModuleModernEntry.js"
         
     | 
| 
      
 147 
     | 
    
         
            +
                )
         
     | 
| 
      
 148 
     | 
    
         
            +
              )).replaceAll(`'{{storiesFilename}}'`, `'./${storiesFilename}'`).replaceAll(
         
     | 
| 
      
 149 
     | 
    
         
            +
                `'{{previewAnnotations}}'`,
         
     | 
| 
      
 150 
     | 
    
         
            +
                previewAnnotations.filter(Boolean).map((entry) => `'${entry}'`).join(",")
         
     | 
| 
      
 151 
     | 
    
         
            +
              ).replaceAll(
         
     | 
| 
      
 152 
     | 
    
         
            +
                `'{{previewAnnotations_requires}}'`,
         
     | 
| 
      
 153 
     | 
    
         
            +
                previewAnnotations.filter(Boolean).map((entry) => `require('${entry}')`).join(",")
         
     | 
| 
       147 
154 
     | 
    
         
             
              ).replace(/\\/g, "\\\\");
         
     | 
| 
       148 
155 
     | 
    
         
             
              entries.push(configEntryPath);
         
     | 
| 
       149 
156 
     | 
    
         
             
              for (const [key, value] of Object.entries(virtualModules)) {
         
     | 
| 
         @@ -270,7 +277,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => { 
     | 
|
| 
       270 
277 
     | 
    
         
             
                docsOptions,
         
     | 
| 
       271 
278 
     | 
    
         
             
                entries,
         
     | 
| 
       272 
279 
     | 
    
         
             
                nonNormalizedStories,
         
     | 
| 
       273 
     | 
    
         
            -
                 
     | 
| 
      
 280 
     | 
    
         
            +
                _modulesCount,
         
     | 
| 
       274 
281 
     | 
    
         
             
                build2,
         
     | 
| 
       275 
282 
     | 
    
         
             
                tagsOptions
         
     | 
| 
       276 
283 
     | 
    
         
             
              ] = await Promise.all([
         
     | 
| 
         @@ -284,8 +291,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => { 
     | 
|
| 
       284 
291 
     | 
    
         
             
                presets.apply("docs"),
         
     | 
| 
       285 
292 
     | 
    
         
             
                presets.apply("entries", []),
         
     | 
| 
       286 
293 
     | 
    
         
             
                presets.apply("stories", []),
         
     | 
| 
       287 
     | 
    
         
            -
                options.cache?.get("modulesCount") 
     | 
| 
       288 
     | 
    
         
            -
                }),
         
     | 
| 
      
 294 
     | 
    
         
            +
                options.cache?.get("modulesCount", 1e3),
         
     | 
| 
       289 
295 
     | 
    
         
             
                options.presets.apply("build"),
         
     | 
| 
       290 
296 
     | 
    
         
             
                presets.apply("tags", {})
         
     | 
| 
       291 
297 
     | 
    
         
             
              ]);
         
     | 
| 
         @@ -596,7 +602,7 @@ var rsbuild = async (_, options) => { 
     | 
|
| 
       596 
602 
     | 
    
         
             
              );
         
     | 
| 
       597 
603 
     | 
    
         
             
              let defaultConfig = await iframe_rsbuild_config_default(options, webpackAddonsConfig);
         
     | 
| 
       598 
604 
     | 
    
         
             
              const shimsConfig = await applyReactShims(defaultConfig, options);
         
     | 
| 
       599 
     | 
    
         
            -
              defaultConfig = mergeRsbuildConfig(
         
     | 
| 
      
 605 
     | 
    
         
            +
              defaultConfig = rsbuildReal.mergeRsbuildConfig(
         
     | 
| 
       600 
606 
     | 
    
         
             
                defaultConfig,
         
     | 
| 
       601 
607 
     | 
    
         
             
                shimsConfig
         
     | 
| 
       602 
608 
     | 
    
         
             
              );
         
     | 
| 
         @@ -666,7 +672,7 @@ var start = async ({ 
     | 
|
| 
       666 
672 
     | 
    
         
             
              const previewDirOrigin = previewResolvedDir;
         
     | 
| 
       667 
673 
     | 
    
         
             
              router.use(
         
     | 
| 
       668 
674 
     | 
    
         
             
                "/sb-preview",
         
     | 
| 
       669 
     | 
    
         
            -
                 
     | 
| 
      
 675 
     | 
    
         
            +
                sirv(previewDirOrigin, { maxAge: 3e5, dev: true, immutable: true })
         
     | 
| 
       670 
676 
     | 
    
         
             
              );
         
     | 
| 
       671 
677 
     | 
    
         
             
              router.use(rsbuildServer.middlewares);
         
     | 
| 
       672 
678 
     | 
    
         
             
              rsbuildServer.connectWebSocket({ server: storybookServer });
         
     | 
    
        package/package.json
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            {
         
     | 
| 
       2 
2 
     | 
    
         
             
              "name": "storybook-builder-rsbuild",
         
     | 
| 
       3 
     | 
    
         
            -
              "version": "0.1. 
     | 
| 
      
 3 
     | 
    
         
            +
              "version": "0.1.2",
         
     | 
| 
       4 
4 
     | 
    
         
             
              "description": "Rsbuild builder for Storybook",
         
     | 
| 
       5 
5 
     | 
    
         
             
              "keywords": [
         
     | 
| 
       6 
6 
     | 
    
         
             
                "storybook",
         
     | 
| 
         @@ -38,7 +38,7 @@ 
     | 
|
| 
       38 
38 
     | 
    
         
             
                  "node": "./dist/loaders/export-order-loader.js",
         
     | 
| 
       39 
39 
     | 
    
         
             
                  "require": "./dist/loaders/export-order-loader.js"
         
     | 
| 
       40 
40 
     | 
    
         
             
                },
         
     | 
| 
       41 
     | 
    
         
            -
                "./templates/virtualModuleModernEntry.js 
     | 
| 
      
 41 
     | 
    
         
            +
                "./templates/virtualModuleModernEntry.js": "./templates/virtualModuleModernEntry.js",
         
     | 
| 
       42 
42 
     | 
    
         
             
                "./templates/preview.ejs": "./templates/preview.ejs",
         
     | 
| 
       43 
43 
     | 
    
         
             
                "./templates/virtualModuleEntry.template.js": "./templates/virtualModuleEntry.template.js",
         
     | 
| 
       44 
44 
     | 
    
         
             
                "./templates/virtualModuleStory.template.js": "./templates/virtualModuleStory.template.js",
         
     | 
| 
         @@ -64,27 +64,26 @@ 
     | 
|
| 
       64 
64 
     | 
    
         
             
                "cjs-module-lexer": "^1.4.1",
         
     | 
| 
       65 
65 
     | 
    
         
             
                "constants-browserify": "^1.0.0",
         
     | 
| 
       66 
66 
     | 
    
         
             
                "es-module-lexer": "^1.5.4",
         
     | 
| 
       67 
     | 
    
         
            -
                "express": "^4.21.0",
         
     | 
| 
       68 
67 
     | 
    
         
             
                "fs-extra": "^11.2.0",
         
     | 
| 
       69 
     | 
    
         
            -
                "magic-string": "^0.30. 
     | 
| 
      
 68 
     | 
    
         
            +
                "magic-string": "^0.30.12",
         
     | 
| 
       70 
69 
     | 
    
         
             
                "path-browserify": "^1.0.1",
         
     | 
| 
       71 
70 
     | 
    
         
             
                "process": "^0.11.10",
         
     | 
| 
       72 
71 
     | 
    
         
             
                "rsbuild-plugin-html-minifier-terser": "^1.1.1",
         
     | 
| 
      
 72 
     | 
    
         
            +
                "sirv": "^2.0.4",
         
     | 
| 
       73 
73 
     | 
    
         
             
                "ts-dedent": "^2.2.0",
         
     | 
| 
       74 
74 
     | 
    
         
             
                "url": "^0.11.4",
         
     | 
| 
       75 
75 
     | 
    
         
             
                "util": "^0.12.5",
         
     | 
| 
       76 
76 
     | 
    
         
             
                "util-deprecate": "^1.0.2"
         
     | 
| 
       77 
77 
     | 
    
         
             
              },
         
     | 
| 
       78 
78 
     | 
    
         
             
              "devDependencies": {
         
     | 
| 
       79 
     | 
    
         
            -
                "@rsbuild/core": "1.0. 
     | 
| 
       80 
     | 
    
         
            -
                "@types/express": "^4.17.21",
         
     | 
| 
      
 79 
     | 
    
         
            +
                "@rsbuild/core": "1.0.17",
         
     | 
| 
       81 
80 
     | 
    
         
             
                "@types/fs-extra": "^11.0.4",
         
     | 
| 
       82 
81 
     | 
    
         
             
                "@types/node": "^18.0.0",
         
     | 
| 
       83 
82 
     | 
    
         
             
                "@types/pretty-hrtime": "^1.0.3",
         
     | 
| 
       84 
83 
     | 
    
         
             
                "pretty-hrtime": "^1.0.3",
         
     | 
| 
       85 
84 
     | 
    
         
             
                "slash": "^5.1.0",
         
     | 
| 
       86 
     | 
    
         
            -
                "storybook": "8.4.0-alpha. 
     | 
| 
       87 
     | 
    
         
            -
                "typescript": "^5.6. 
     | 
| 
      
 85 
     | 
    
         
            +
                "storybook": "8.4.0-alpha.7",
         
     | 
| 
      
 86 
     | 
    
         
            +
                "typescript": "^5.6.3"
         
     | 
| 
       88 
87 
     | 
    
         
             
              },
         
     | 
| 
       89 
88 
     | 
    
         
             
              "peerDependencies": {
         
     | 
| 
       90 
89 
     | 
    
         
             
                "@rsbuild/core": "^1.0.1",
         
     | 
| 
         @@ -0,0 +1,38 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import { createBrowserChannel } from 'storybook/internal/channels'
         
     | 
| 
      
 2 
     | 
    
         
            +
            import {
         
     | 
| 
      
 3 
     | 
    
         
            +
              PreviewWeb,
         
     | 
| 
      
 4 
     | 
    
         
            +
              addons,
         
     | 
| 
      
 5 
     | 
    
         
            +
              composeConfigs,
         
     | 
| 
      
 6 
     | 
    
         
            +
            } from 'storybook/internal/preview-api'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            import { global } from '@storybook/global'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            import { importFn } from '{{storiesFilename}}'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            const getProjectAnnotations = () =>
         
     | 
| 
      
 13 
     | 
    
         
            +
              composeConfigs(['{{previewAnnotations_requires}}'])
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            const channel = createBrowserChannel({ page: 'preview' })
         
     | 
| 
      
 16 
     | 
    
         
            +
            addons.setChannel(channel)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            if (global.CONFIG_TYPE === 'DEVELOPMENT') {
         
     | 
| 
      
 19 
     | 
    
         
            +
              window.__STORYBOOK_SERVER_CHANNEL__ = channel
         
     | 
| 
      
 20 
     | 
    
         
            +
            }
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            const preview = new PreviewWeb(importFn, getProjectAnnotations)
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            window.__STORYBOOK_PREVIEW__ = preview
         
     | 
| 
      
 25 
     | 
    
         
            +
            window.__STORYBOOK_STORY_STORE__ = preview.storyStore
         
     | 
| 
      
 26 
     | 
    
         
            +
            window.__STORYBOOK_ADDONS_CHANNEL__ = channel
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            if (import.meta.webpackHot) {
         
     | 
| 
      
 29 
     | 
    
         
            +
              import.meta.webpackHot.accept('{{storiesFilename}}', () => {
         
     | 
| 
      
 30 
     | 
    
         
            +
                // importFn has changed so we need to patch the new one in
         
     | 
| 
      
 31 
     | 
    
         
            +
                preview.onStoriesChanged({ importFn })
         
     | 
| 
      
 32 
     | 
    
         
            +
              })
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              import.meta.webpackHot.accept(['{{previewAnnotations}}'], () => {
         
     | 
| 
      
 35 
     | 
    
         
            +
                // getProjectAnnotations has changed so we need to patch the new one in
         
     | 
| 
      
 36 
     | 
    
         
            +
                preview.onGetProjectAnnotationsChanged({ getProjectAnnotations })
         
     | 
| 
      
 37 
     | 
    
         
            +
              })
         
     | 
| 
      
 38 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -1,34 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import { global } from '@storybook/global';
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            import { ClientApi, PreviewWeb, addons, composeConfigs } from 'storybook/internal/preview-api';
         
     | 
| 
       4 
     | 
    
         
            -
            import { createBrowserChannel } from 'storybook/internal/channels';
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            import { importFn } from './{{storiesFilename}}';
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            const getProjectAnnotations = () =>
         
     | 
| 
       9 
     | 
    
         
            -
              composeConfigs([{{#each previewAnnotations}}require('{{this}}'),{{/each}}]);
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            const channel = createBrowserChannel({ page: 'preview' });
         
     | 
| 
       12 
     | 
    
         
            -
            addons.setChannel(channel);
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            if (global.CONFIG_TYPE === 'DEVELOPMENT'){
         
     | 
| 
       15 
     | 
    
         
            -
              window.__STORYBOOK_SERVER_CHANNEL__ = channel;
         
     | 
| 
       16 
     | 
    
         
            -
            }
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            const preview = new PreviewWeb(importFn, getProjectAnnotations);
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            window.__STORYBOOK_PREVIEW__ = preview;
         
     | 
| 
       21 
     | 
    
         
            -
            window.__STORYBOOK_STORY_STORE__ = preview.storyStore;
         
     | 
| 
       22 
     | 
    
         
            -
            window.__STORYBOOK_ADDONS_CHANNEL__ = channel;
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            if (import.meta.webpackHot) {
         
     | 
| 
       25 
     | 
    
         
            -
              import.meta.webpackHot.accept('./{{storiesFilename}}', () => {
         
     | 
| 
       26 
     | 
    
         
            -
                // importFn has changed so we need to patch the new one in
         
     | 
| 
       27 
     | 
    
         
            -
                preview.onStoriesChanged({ importFn });
         
     | 
| 
       28 
     | 
    
         
            -
              });
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
              import.meta.webpackHot.accept([{{#each previewAnnotations}}'{{this}}',{{/each}}], () => {
         
     | 
| 
       31 
     | 
    
         
            -
                // getProjectAnnotations has changed so we need to patch the new one in
         
     | 
| 
       32 
     | 
    
         
            -
                preview.onGetProjectAnnotationsChanged({ getProjectAnnotations });
         
     | 
| 
       33 
     | 
    
         
            -
              });
         
     | 
| 
       34 
     | 
    
         
            -
            }
         
     |