@fluentui/react-storybook-addon-export-to-sandbox 0.1.1 → 0.1.3

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/CHANGELOG.md CHANGED
@@ -1,12 +1,31 @@
1
1
  # Change Log - @fluentui/react-storybook-addon-export-to-sandbox
2
2
 
3
- This log was last generated on Fri, 11 Jul 2025 15:56:57 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 04 Nov 2025 14:46:32 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [0.1.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-storybook-addon-export-to-sandbox_v0.1.3)
8
+
9
+ Tue, 04 Nov 2025 14:46:32 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-storybook-addon-export-to-sandbox_v0.1.2..@fluentui/react-storybook-addon-export-to-sandbox_v0.1.3)
11
+
12
+ ### Patches
13
+
14
+ - fix: force release ([PR #35445](https://github.com/microsoft/fluentui/pull/35445) by dmytrokirpa@microsoft.com)
15
+ - Bump @fluentui/babel-preset-storybook-full-source to v0.1.1 ([PR #35435](https://github.com/microsoft/fluentui/pull/35435) by beachball)
16
+
17
+ ## [0.1.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-storybook-addon-export-to-sandbox_v0.1.2)
18
+
19
+ Thu, 07 Aug 2025 10:03:27 GMT
20
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-storybook-addon-export-to-sandbox_v0.1.1..@fluentui/react-storybook-addon-export-to-sandbox_v0.1.2)
21
+
22
+ ### Patches
23
+
24
+ - fix: migrate to R19 compatible JSX.* namespace types ([PR #34923](https://github.com/microsoft/fluentui/pull/34923) by martinhochel@microsoft.com)
25
+
7
26
  ## [0.1.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-storybook-addon-export-to-sandbox_v0.1.1)
8
27
 
9
- Fri, 11 Jul 2025 15:56:57 GMT
28
+ Fri, 11 Jul 2025 15:59:24 GMT
10
29
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-storybook-addon-export-to-sandbox_v0.1.0..@fluentui/react-storybook-addon-export-to-sandbox_v0.1.1)
11
30
 
12
31
  ### Patches
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/custom-babel-loader.ts"],"sourcesContent":["const babelLoader = require('babel-loader');\n\n/**\n * Custom loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` that\n * is passed from a loader that uses the `sourceMap` option.\n */\nmodule.exports = function (source: string, inputSourceMap?: object | boolean | string) {\n return babelLoader.call(\n this,\n source,\n typeof inputSourceMap === 'string' ? JSON.parse(inputSourceMap) : inputSourceMap,\n );\n};\n"],"names":["babelLoader","require","module","exports","source","inputSourceMap","call","JSON","parse"],"rangeMappings":";;;;;;","mappings":"AAAA,MAAMA,cAAcC,QAAQ;AAE5B;;;CAGC,GACDC,OAAOC,OAAO,GAAG,SAAUC,MAAc,EAAEC,cAA0C;IACnF,OAAOL,YAAYM,IAAI,CACrB,IAAI,EACJF,QACA,OAAOC,mBAAmB,WAAWE,KAAKC,KAAK,CAACH,kBAAkBA;AAEtE"}
1
+ {"version":3,"sources":["../src/custom-babel-loader.ts"],"sourcesContent":["const babelLoader = require('babel-loader');\n\n/**\n * Custom loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` that\n * is passed from a loader that uses the `sourceMap` option.\n */\nmodule.exports = function (source: string, inputSourceMap?: object | boolean | string) {\n return babelLoader.call(\n this,\n source,\n typeof inputSourceMap === 'string' ? JSON.parse(inputSourceMap) : inputSourceMap,\n );\n};\n"],"names":["babelLoader","require","module","exports","source","inputSourceMap","call","JSON","parse"],"mappings":"AAAA,MAAMA,cAAcC,QAAQ;AAE5B;;;CAGC,GACDC,OAAOC,OAAO,GAAG,SAAUC,MAAc,EAAEC,cAA0C;IACnF,OAAOL,YAAYM,IAAI,CACrB,IAAI,EACJF,QACA,OAAOC,mBAAmB,WAAWE,KAAKC,KAAK,CAACH,kBAAkBA;AAEtE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/decorators/with-export-to-sandbox-button.ts"],"sourcesContent":["import { addDemoActionButton } from '../sandbox-factory';\n\nimport { StoryContext } from '../types';\n\nexport const withExportToSandboxButton = (\n storyFn: (context: StoryContext) => // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element,\n context: StoryContext,\n) => {\n if (context.viewMode === 'docs') {\n addDemoActionButton(context);\n }\n\n return storyFn(context);\n};\n"],"names":["addDemoActionButton","withExportToSandboxButton","storyFn","context","viewMode"],"rangeMappings":";;;;;;","mappings":"AAAA,SAASA,mBAAmB,QAAQ,qBAAqB;AAIzD,OAAO,MAAMC,4BAA4B,CACvCC,SAEAC;IAEA,IAAIA,QAAQC,QAAQ,KAAK,QAAQ;QAC/BJ,oBAAoBG;IACtB;IAEA,OAAOD,QAAQC;AACjB,EAAE"}
1
+ {"version":3,"sources":["../src/decorators/with-export-to-sandbox-button.ts"],"sourcesContent":["import type { JSXElement } from '@fluentui/react-utilities';\n\nimport { addDemoActionButton } from '../sandbox-factory';\nimport type { StoryContext } from '../types';\n\nexport const withExportToSandboxButton = (storyFn: (context: StoryContext) => JSXElement, context: StoryContext) => {\n if (context.viewMode === 'docs') {\n addDemoActionButton(context);\n }\n\n return storyFn(context);\n};\n"],"names":["addDemoActionButton","withExportToSandboxButton","storyFn","context","viewMode"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ,qBAAqB;AAGzD,OAAO,MAAMC,4BAA4B,CAACC,SAAgDC;IACxF,IAAIA,QAAQC,QAAQ,KAAK,QAAQ;QAC/BJ,oBAAoBG;IACtB;IAEA,OAAOD,QAAQC;AACjB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/getDependencies.ts"],"sourcesContent":["type PackageDependencies = { [dependencyName: string]: string };\n\nconst IMPORT_PATH_REGEX = /from ['\"](.*?)['\"];/g;\n\nfunction matchAll(str: string, re: RegExp) {\n let match: RegExpExecArray | null = null;\n const matches: RegExpExecArray[] = [];\n\n while ((match = re.exec(str))) {\n matches.push(match);\n }\n\n return matches;\n}\n\n/**\n *\n * @param fileContent - code\n * @param requiredDependencies - dependencies that will always be included in package.json\n * @param optionalDependencies - whose versions will override those found in the code\n * @returns - Map of dependencies and their versions to include in package.json\n */\nexport const getDependencies = (\n fileContent: string,\n requiredDependencies: PackageDependencies,\n optionalDependencies: PackageDependencies,\n) => {\n const importPaths = matchAll(fileContent, IMPORT_PATH_REGEX);\n\n const dependenciesInCode = importPaths.reduce((dependencies, match) => {\n const importPath = match[1];\n const isReactPath = importPath.startsWith('react/');\n const isRelativeImportPath = importPath.startsWith('.');\n\n if (isReactPath || isRelativeImportPath) {\n return dependencies;\n }\n\n const dependency = parsePackageName(importPath).name;\n\n if (!dependencies.hasOwnProperty(dependency)) {\n dependencies[dependency] = optionalDependencies[dependency] ?? 'latest';\n }\n\n return dependencies;\n }, {} as PackageDependencies);\n\n return { ...dependenciesInCode, ...requiredDependencies };\n};\n\n// Parsed a scoped package name into name, version, and path.\nconst RE_SCOPED = /^(@[^\\/]+\\/[^@\\/]+)(?:@([^\\/]+))?(\\/.*)?$/;\n// Parsed a non-scoped package name into name, version, path\nconst RE_NON_SCOPED = /^([^@\\/]+)(?:@([^\\/]+))?(\\/.*)?$/;\n\nfunction parsePackageName(input: string) {\n const m = RE_SCOPED.exec(input) || RE_NON_SCOPED.exec(input);\n\n if (!m) {\n throw new Error(`[parse-package-name] invalid package name: ${input}`);\n }\n\n return {\n name: m[1] || '',\n version: m[2] || 'latest',\n path: m[3] || '',\n };\n}\n"],"names":["IMPORT_PATH_REGEX","matchAll","str","re","match","matches","exec","push","getDependencies","fileContent","requiredDependencies","optionalDependencies","importPaths","dependenciesInCode","reduce","dependencies","importPath","isReactPath","startsWith","isRelativeImportPath","dependency","parsePackageName","name","hasOwnProperty","RE_SCOPED","RE_NON_SCOPED","input","m","Error","version","path"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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MH,CAAC,CAAC,EAAE,IAAI;IAChB;AACF"}
1
+ {"version":3,"sources":["../src/getDependencies.ts"],"sourcesContent":["type PackageDependencies = { [dependencyName: string]: string };\n\nconst IMPORT_PATH_REGEX = /from ['\"](.*?)['\"];/g;\n\nfunction matchAll(str: string, re: RegExp) {\n let match: RegExpExecArray | null = null;\n const matches: RegExpExecArray[] = [];\n\n while ((match = re.exec(str))) {\n matches.push(match);\n }\n\n return matches;\n}\n\n/**\n *\n * @param fileContent - code\n * @param requiredDependencies - dependencies that will always be included in package.json\n * @param optionalDependencies - whose versions will override those found in the code\n * @returns - Map of dependencies and their versions to include in package.json\n */\nexport const getDependencies = (\n fileContent: string,\n requiredDependencies: PackageDependencies,\n optionalDependencies: PackageDependencies,\n) => {\n const importPaths = matchAll(fileContent, IMPORT_PATH_REGEX);\n\n const dependenciesInCode = importPaths.reduce((dependencies, match) => {\n const importPath = match[1];\n const isReactPath = importPath.startsWith('react/');\n const isRelativeImportPath = importPath.startsWith('.');\n\n if (isReactPath || isRelativeImportPath) {\n return dependencies;\n }\n\n const dependency = parsePackageName(importPath).name;\n\n if (!dependencies.hasOwnProperty(dependency)) {\n dependencies[dependency] = optionalDependencies[dependency] ?? 'latest';\n }\n\n return dependencies;\n }, {} as PackageDependencies);\n\n return { ...dependenciesInCode, ...requiredDependencies };\n};\n\n// Parsed a scoped package name into name, version, and path.\nconst RE_SCOPED = /^(@[^\\/]+\\/[^@\\/]+)(?:@([^\\/]+))?(\\/.*)?$/;\n// Parsed a non-scoped package name into name, version, path\nconst RE_NON_SCOPED = /^([^@\\/]+)(?:@([^\\/]+))?(\\/.*)?$/;\n\nfunction parsePackageName(input: string) {\n const m = RE_SCOPED.exec(input) || RE_NON_SCOPED.exec(input);\n\n if (!m) {\n throw new Error(`[parse-package-name] invalid package name: ${input}`);\n }\n\n return {\n name: m[1] || '',\n version: m[2] || 'latest',\n path: m[3] || '',\n };\n}\n"],"names":["IMPORT_PATH_REGEX","matchAll","str","re","match","matches","exec","push","getDependencies","fileContent","requiredDependencies","optionalDependencies","importPaths","dependenciesInCode","reduce","dependencies","importPath","isReactPath","startsWith","isRelativeImportPath","dependency","parsePackageName","name","hasOwnProperty","RE_SCOPED","RE_NON_SCOPED","input","m","Error","version","path"],"mappings":"AAEA,MAAMA,oBAAoB;AAE1B,SAASC,SAASC,GAAW,EAAEC,EAAU;IACvC,IAAIC,QAAgC;IACpC,MAAMC,UAA6B,EAAE;IAErC,MAAQD,QAAQD,GAAGG,IAAI,CAACJ,KAAO;QAC7BG,QAAQE,IAAI,CAACH;IACf;IAEA,OAAOC;AACT;AAEA;;;;;;CAMC,GACD,OAAO,MAAMG,kBAAkB,CAC7BC,aACAC,sBACAC;IAEA,MAAMC,cAAcX,SAASQ,aAAaT;IAE1C,MAAMa,qBAAqBD,YAAYE,MAAM,CAAC,CAACC,cAAcX;QAC3D,MAAMY,aAAaZ,KAAK,CAAC,EAAE;QAC3B,MAAMa,cAAcD,WAAWE,UAAU,CAAC;QAC1C,MAAMC,uBAAuBH,WAAWE,UAAU,CAAC;QAEnD,IAAID,eAAeE,sBAAsB;YACvC,OAAOJ;QACT;QAEA,MAAMK,aAAaC,iBAAiBL,YAAYM,IAAI;QAEpD,IAAI,CAACP,aAAaQ,cAAc,CAACH,aAAa;gBACjBT;YAA3BI,YAAY,CAACK,WAAW,GAAGT,CAAAA,mCAAAA,oBAAoB,CAACS,WAAW,cAAhCT,8CAAAA,mCAAoC;QACjE;QAEA,OAAOI;IACT,GAAG,CAAC;IAEJ,OAAO;QAAE,GAAGF,kBAAkB;QAAE,GAAGH,oBAAoB;IAAC;AAC1D,EAAE;AAEF,6DAA6D;AAC7D,MAAMc,YAAY;AAClB,4DAA4D;AAC5D,MAAMC,gBAAgB;AAEtB,SAASJ,iBAAiBK,KAAa;IACrC,MAAMC,IAAIH,UAAUlB,IAAI,CAACoB,UAAUD,cAAcnB,IAAI,CAACoB;IAEtD,IAAI,CAACC,GAAG;QACN,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEF,OAAO;IACvE;IAEA,OAAO;QACLJ,MAAMK,CAAC,CAAC,EAAE,IAAI;QACdE,SAASF,CAAC,CAAC,EAAE,IAAI;QACjBG,MAAMH,CAAC,CAAC,EAAE,IAAI;IAChB;AACF"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {};\n"],"names":[],"rangeMappings":"","mappings":"AAAA,WAAU"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {};\n"],"names":[],"mappings":"AAAA,WAAU"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/preset/preset.ts"],"sourcesContent":["import { webpack, WebpackFinalConfig, WebpackFinalOptions } from '../webpack';\n\nexport function webpackFinal(config: WebpackFinalConfig, options: WebpackFinalOptions) {\n return webpack(config, options);\n}\n"],"names":["webpack","webpackFinal","config","options"],"rangeMappings":";;;","mappings":"AAAA,SAASA,OAAO,QAAiD,aAAa;AAE9E,OAAO,SAASC,aAAaC,MAA0B,EAAEC,OAA4B;IACnF,OAAOH,QAAQE,QAAQC;AACzB"}
1
+ {"version":3,"sources":["../src/preset/preset.ts"],"sourcesContent":["import { webpack, WebpackFinalConfig, WebpackFinalOptions } from '../webpack';\n\nexport function webpackFinal(config: WebpackFinalConfig, options: WebpackFinalOptions) {\n return webpack(config, options);\n}\n"],"names":["webpack","webpackFinal","config","options"],"mappings":"AAAA,SAASA,OAAO,QAAiD,aAAa;AAE9E,OAAO,SAASC,aAAaC,MAA0B,EAAEC,OAA4B;IACnF,OAAOH,QAAQE,QAAQC;AACzB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type { Parameters } from '@storybook/react';\nimport type { StoryContextForEnhancers } from '@storybook/csf';\n\nimport { withExportToSandboxButton } from '../decorators/with-export-to-sandbox-button';\n\nexport const decorators = [withExportToSandboxButton];\n\nexport const parameters: Parameters = {\n docs: {\n source: {\n /**\n * Override source code shown within \"Show Code\" Docs tab.\n * @see https://github.com/storybookjs/storybook/blob/release-6-5/addons/docs/docs/recipes.md#customizing-source-snippets\n */\n transform: (source: string, storyContext: StoryContextForEnhancers) => {\n // This config renders story source generated via `fullSource` parameter that is being added by @fluentui/babel-preset-storybook-full-source plugin, which is registered as part of this preset\n return storyContext.parameters.fullSource;\n },\n },\n },\n};\n"],"names":["withExportToSandboxButton","decorators","parameters","docs","source","transform","storyContext","fullSource"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,yBAAyB,QAAQ,8CAA8C;AAExF,OAAO,MAAMC,aAAa;IAACD;CAA0B,CAAC;AAEtD,OAAO,MAAME,aAAyB;IACpCC,MAAM;QACJC,QAAQ;YACN;;;OAGC,GACDC,WAAW,CAACD,QAAgBE;gBAC1B,+LAA+L;gBAC/L,OAAOA,aAAaJ,UAAU,CAACK,UAAU;YAC3C;QACF;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type { Parameters } from '@storybook/react';\nimport type { StoryContextForEnhancers } from '@storybook/csf';\n\nimport { withExportToSandboxButton } from '../decorators/with-export-to-sandbox-button';\n\nexport const decorators = [withExportToSandboxButton];\n\nexport const parameters: Parameters = {\n docs: {\n source: {\n /**\n * Override source code shown within \"Show Code\" Docs tab.\n * @see https://github.com/storybookjs/storybook/blob/release-6-5/addons/docs/docs/recipes.md#customizing-source-snippets\n */\n transform: (source: string, storyContext: StoryContextForEnhancers) => {\n // This config renders story source generated via `fullSource` parameter that is being added by @fluentui/babel-preset-storybook-full-source plugin, which is registered as part of this preset\n return storyContext.parameters.fullSource;\n },\n },\n },\n};\n"],"names":["withExportToSandboxButton","decorators","parameters","docs","source","transform","storyContext","fullSource"],"mappings":"AAGA,SAASA,yBAAyB,QAAQ,8CAA8C;AAExF,OAAO,MAAMC,aAAa;IAACD;CAA0B,CAAC;AAEtD,OAAO,MAAME,aAAyB;IACpCC,MAAM;QACJC,QAAQ;YACN;;;OAGC,GACDC,WAAW,CAACD,QAAgBE;gBAC1B,+LAA+L;gBAC/L,OAAOA,aAAaJ,UAAU,CAACK,UAAU;YAC3C;QACF;IACF;AACF,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/public-types.ts"],"sourcesContent":["/**\n * NOTE:\n * Don't import anything from source code in this file !!\n *\n * only pure API definitions of addon are allowed to live here, that are used both internal and for external storybook `Parameter` type extensions\n */\ninterface ParametersConfig {\n optionalDependencies?: Record<string, string>;\n requiredDependencies?: Record<string, string>;\n provider: 'codesandbox-cloud' | 'codesandbox-browser' | 'stackblitz-cloud';\n bundler: 'vite' | 'cra';\n}\n\nexport interface ParametersExtension {\n exportToSandbox?: ParametersConfig;\n}\n\nexport interface PresetConfig {\n importMappings: import('@fluentui/babel-preset-storybook-full-source').BabelPluginOptions;\n webpackRule?: import('webpack').RuleSetRule;\n babelLoaderOptionsUpdater?: (value: import('@babel/core').TransformOptions) => typeof value;\n}\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA;;;;;CAKC,GAYD,WAIC"}
1
+ {"version":3,"sources":["../src/public-types.ts"],"sourcesContent":["/**\n * NOTE:\n * Don't import anything from source code in this file !!\n *\n * only pure API definitions of addon are allowed to live here, that are used both internal and for external storybook `Parameter` type extensions\n */\ninterface ParametersConfig {\n optionalDependencies?: Record<string, string>;\n requiredDependencies?: Record<string, string>;\n provider: 'codesandbox-cloud' | 'codesandbox-browser' | 'stackblitz-cloud';\n bundler: 'vite' | 'cra';\n}\n\nexport interface ParametersExtension {\n exportToSandbox?: ParametersConfig;\n}\n\nexport interface PresetConfig {\n importMappings: import('@fluentui/babel-preset-storybook-full-source').BabelPluginOptions;\n webpackRule?: import('webpack').RuleSetRule;\n babelLoaderOptionsUpdater?: (value: import('@babel/core').TransformOptions) => typeof value;\n}\n"],"names":[],"mappings":"AAAA;;;;;CAKC,GAYD,WAIC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sandbox-factory.ts"],"sourcesContent":["import { getParameters } from 'codesandbox-import-utils/lib/api/define';\n\nimport { scaffold } from './sandbox-scaffold';\nimport { addHiddenInput, prepareData, prepareSandboxContainer, type Data } from './sandbox-utils';\nimport { StoryContext } from './types';\n\nconst defaultFileToPreview = encodeURIComponent('src/example.tsx');\n\nconst actionConfig = {\n 'codesandbox-cloud': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'codesandbox-browser': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'stackblitz-cloud': {\n label: 'Stackblitz',\n factory: (files: Record<string, string>, config: Data) => openStackblitz({ files, ...config }),\n },\n};\n\nexport function addDemoActionButton(context: StoryContext) {\n const { container, cssClasses } = prepareSandboxContainer(context);\n const config = prepareData(context);\n if (!config) {\n throw new Error('issues with data');\n }\n\n addActionButton(container, config, cssClasses);\n}\n\nfunction addActionButton(container: HTMLElement, config: Data, classList: string[]) {\n const files = scaffold[config.bundler](config);\n const action = actionConfig[config.provider];\n\n const button = document.createElement('button');\n button.classList.add(...classList);\n button.textContent = `Open in ${action.label}`;\n\n container?.prepend(button);\n\n button.addEventListener('click', _ev => {\n action.factory(files, config);\n });\n}\n\n/**\n *\n * @see https://developer.stackblitz.com/docs/platform/post-api/\n */\nfunction openStackblitz(data: { files: Record<string, string> } & Data) {\n const { files, description, title } = data;\n const form = document.createElement('form');\n form.method = 'post';\n form.target = '_blank';\n form.action = `https://stackblitz.com/run?file=${defaultFileToPreview}`;\n // node template - boots web-container\n addHiddenInput(form, 'project[template]', 'node');\n addHiddenInput(form, 'project[title]', title);\n addHiddenInput(form, 'project[description]', `# ${description}`);\n\n Object.keys(files).forEach(key => {\n const value = files[key];\n addHiddenInput(form, `project[files][${key}]`, value);\n });\n\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n\n/**\n *\n * @see https://codesandbox.io/docs/learn/sandboxes/cli-api#define-api\n */\nfunction openCodeSandbox({ files, provider }: { files: Record<string, string> } & Data) {\n const normalizedFilesApi = Object.entries(files).reduce((acc, current) => {\n acc[current[0]] = { isBinary: false, content: current[1] };\n return acc;\n }, {} as Record<string, { content: string; isBinary: boolean }>);\n\n const env = provider === 'codesandbox-cloud' ? 'server' : 'browser';\n const parameters = getParameters({ files: normalizedFilesApi });\n\n const form = document.createElement('form');\n form.method = 'POST';\n form.target = '_blank';\n form.action = `https://codesandbox.io/api/v1/sandboxes/define?environment=${env}`;\n\n addHiddenInput(form, 'parameters', parameters);\n addHiddenInput(form, 'query', `file=${defaultFileToPreview}`);\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n"],"names":["getParameters","scaffold","addHiddenInput","prepareData","prepareSandboxContainer","defaultFileToPreview","encodeURIComponent","actionConfig","label","factory","files","config","openCodeSandbox","openStackblitz","addDemoActionButton","context","container","cssClasses","Error","addActionButton","classList","bundler","action","provider","button","document","createElement","add","textContent","prepend","addEventListener","_ev","data","description","title","form","method","target","Object","keys","forEach","key","value","body","appendChild","submit","removeChild","normalizedFilesApi","entries","reduce","acc","current","isBinary","content","env","parameters"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,0CAA0C;AAExE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,cAAc,EAAEC,WAAW,EAAEC,uBAAuB,QAAmB,kBAAkB;AAGlG,MAAMC,uBAAuBC,mBAAmB;AAEhD,MAAMC,eAAe;IACnB,qBAAqB;QACnBC,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,uBAAuB;QACrBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,M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B,OAAO8B,OAAO,CAACC,CAAAA;QACzB,MAAMC,QAAQhC,KAAK,CAAC+B,IAAI;QACxBvC,eAAeiC,MAAM,CAAC,eAAe,EAAEM,IAAI,CAAC,CAAC,EAAEC;IACjD;IAEAjB,SAASkB,IAAI,CAACC,WAAW,CAACT;IAC1BA,KAAKU,MAAM;IACXpB,SAASkB,IAAI,CAACG,WAAW,CAACX;AAC5B;AAEA;;;CAGC,GACD,SAASvB,gBAAgB,EAAEF,KAAK,EAAEa,QAAQ,EAA4C;IACpF,MAAMwB,qBAAqBT,OAAOU,OAAO,CAACtC,OAAOuC,MAAM,CAAC,CAACC,KAAKC;QAC5DD,GAAG,CAACC,OAAO,CAAC,EAAE,CAAC,GAAG;YAAEC,UAAU;YAAOC,SAASF,OAAO,CAAC,EAAE;QAAC;QACzD,OAAOD;IACT,GAAG,CAAC;IAEJ,MAAMI,MAAM/B,aAAa,sBAAsB,WAAW;IAC1D,MAAMgC,aAAavD,cAAc;QAAEU,OAAOqC;IAAmB;IAE7D,MAAMZ,OAAOV,SAASC,aAAa,CAAC;IACpCS,KAAKC,MAAM,GAAG;IACdD,KAAKE,MAAM,GAAG;IACdF,KAAKb,MAAM,GAAG,CAAC,2DAA2D,EAAEgC,IAAI,CAAC;IAEjFpD,eAAeiC,MAAM,cAAcoB;IACnCrD,eAAeiC,MAAM,SAAS,CAAC,KAAK,EAAE9B,qBAAqB,CAAC;IAC5DoB,SAASkB,IAAI,CAACC,WAAW,CAACT;IAC1BA,KAAKU,MAAM;IACXpB,SAASkB,IAAI,CAACG,WAAW,CAACX;AAC5B"}
1
+ {"version":3,"sources":["../src/sandbox-factory.ts"],"sourcesContent":["import { getParameters } from 'codesandbox-import-utils/lib/api/define';\n\nimport { scaffold } from './sandbox-scaffold';\nimport { addHiddenInput, prepareData, prepareSandboxContainer, type Data } from './sandbox-utils';\nimport { StoryContext } from './types';\n\nconst defaultFileToPreview = encodeURIComponent('src/example.tsx');\n\nconst actionConfig = {\n 'codesandbox-cloud': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'codesandbox-browser': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'stackblitz-cloud': {\n label: 'Stackblitz',\n factory: (files: Record<string, string>, config: Data) => openStackblitz({ files, ...config }),\n },\n};\n\nexport function addDemoActionButton(context: StoryContext) {\n const { container, cssClasses } = prepareSandboxContainer(context);\n const config = prepareData(context);\n if (!config) {\n throw new Error('issues with data');\n }\n\n addActionButton(container, config, cssClasses);\n}\n\nfunction addActionButton(container: HTMLElement, config: Data, classList: string[]) {\n const files = scaffold[config.bundler](config);\n const action = actionConfig[config.provider];\n\n const button = document.createElement('button');\n button.classList.add(...classList);\n button.textContent = `Open in ${action.label}`;\n\n container?.prepend(button);\n\n button.addEventListener('click', _ev => {\n action.factory(files, config);\n });\n}\n\n/**\n *\n * @see https://developer.stackblitz.com/docs/platform/post-api/\n */\nfunction openStackblitz(data: { files: Record<string, string> } & Data) {\n const { files, description, title } = data;\n const form = document.createElement('form');\n form.method = 'post';\n form.target = '_blank';\n form.action = `https://stackblitz.com/run?file=${defaultFileToPreview}`;\n // node template - boots web-container\n addHiddenInput(form, 'project[template]', 'node');\n addHiddenInput(form, 'project[title]', title);\n addHiddenInput(form, 'project[description]', `# ${description}`);\n\n Object.keys(files).forEach(key => {\n const value = files[key];\n addHiddenInput(form, `project[files][${key}]`, value);\n });\n\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n\n/**\n *\n * @see https://codesandbox.io/docs/learn/sandboxes/cli-api#define-api\n */\nfunction openCodeSandbox({ files, provider }: { files: Record<string, string> } & Data) {\n const normalizedFilesApi = Object.entries(files).reduce((acc, current) => {\n acc[current[0]] = { isBinary: false, content: current[1] };\n return acc;\n }, {} as Record<string, { content: string; isBinary: boolean }>);\n\n const env = provider === 'codesandbox-cloud' ? 'server' : 'browser';\n const parameters = getParameters({ files: normalizedFilesApi });\n\n const form = document.createElement('form');\n form.method = 'POST';\n form.target = '_blank';\n form.action = `https://codesandbox.io/api/v1/sandboxes/define?environment=${env}`;\n\n addHiddenInput(form, 'parameters', parameters);\n addHiddenInput(form, 'query', `file=${defaultFileToPreview}`);\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n"],"names":["getParameters","scaffold","addHiddenInput","prepareData","prepareSandboxContainer","defaultFileToPreview","encodeURIComponent","actionConfig","label","factory","files","config","openCodeSandbox","openStackblitz","addDemoActionButton","context","container","cssClasses","Error","addActionButton","classList","bundler","action","provider","button","document","createElement","add","textContent","prepend","addEventListener","_ev","data","description","title","form","method","target","Object","keys","forEach","key","value","body","appendChild","submit","removeChild","normalizedFilesApi","entries","reduce","acc","current","isBinary","content","env","parameters"],"mappings":"AAAA,SAASA,aAAa,QAAQ,0CAA0C;AAExE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,cAAc,EAAEC,WAAW,EAAEC,uBAAuB,QAAmB,kBAAkB;AAGlG,MAAMC,uBAAuBC,mBAAmB;AAEhD,MAAMC,eAAe;IACnB,qBAAqB;QACnBC,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,uBAAuB;QACrBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,oBAAoB;QAClBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBE,eAAe;gBAAEH;gBAAO,GAAGC,MAAM;YAAC;IAC9F;AACF;AAEA,OAAO,SAASG,oBAAoBC,OAAqB;IACvD,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGb,wBAAwBW;IAC1D,MAAMJ,SAASR,YAAYY;IAC3B,IAAI,CAACJ,QAAQ;QACX,MAAM,IAAIO,MAAM;IAClB;IAEAC,gBA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T,OAAOU,OAAO,CAACtC,OAAOuC,MAAM,CAAC,CAACC,KAAKC;QAC5DD,GAAG,CAACC,OAAO,CAAC,EAAE,CAAC,GAAG;YAAEC,UAAU;YAAOC,SAASF,OAAO,CAAC,EAAE;QAAC;QACzD,OAAOD;IACT,GAAG,CAAC;IAEJ,MAAMI,MAAM/B,aAAa,sBAAsB,WAAW;IAC1D,MAAMgC,aAAavD,cAAc;QAAEU,OAAOqC;IAAmB;IAE7D,MAAMZ,OAAOV,SAASC,aAAa,CAAC;IACpCS,KAAKC,MAAM,GAAG;IACdD,KAAKE,MAAM,GAAG;IACdF,KAAKb,MAAM,GAAG,CAAC,2DAA2D,EAAEgC,KAAK;IAEjFpD,eAAeiC,MAAM,cAAcoB;IACnCrD,eAAeiC,MAAM,SAAS,CAAC,KAAK,EAAE9B,sBAAsB;IAC5DoB,SAASkB,IAAI,CAACC,WAAW,CAACT;IAC1BA,KAAKU,MAAM;IACXpB,SAASkB,IAAI,CAACG,WAAW,CAACX;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sandbox-scaffold.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport type { Data } from './sandbox-utils';\nimport { serializeJson } from './utils';\n\nconst commonDevDeps = { '@types/react': '^17', '@types/react-dom': '^17', typescript: '~4.7.0' };\n\nexport const scaffold = {\n vite: (data: Data): Record<string, string> => {\n if (data.provider === 'codesandbox-browser') {\n throw new Error('vite is not supported on codesandbox-browser');\n }\n\n const base = {\n 'index.html': Vite.getHTML(),\n 'src/App.tsx': Vite.getApp(data),\n 'src/index.tsx': Vite.getRootIndex(),\n 'src/example.tsx': Vite.getExample(data),\n 'tsconfig.json': Vite.getTsconfig(),\n 'tsconfig.node.json': Vite.getTsconfigNode(),\n 'vite.config.ts': Vite.getViteCfg(),\n 'package.json': Vite.getPkgJson(data),\n };\n if (data.provider === 'stackblitz-cloud') {\n Object.assign(base, getStackblitzConfig());\n }\n if (data.provider === 'codesandbox-cloud') {\n Object.assign(base, getCodesandboxConfig('vite'));\n }\n return base;\n },\n cra: (data: Data): Record<string, string> => {\n const base = {\n 'public/index.html': CRA.getHTML(),\n 'src/App.tsx': CRA.getApp(data),\n 'src/index.tsx': CRA.getRootIndex(),\n 'src/example.tsx': CRA.getExample(data),\n 'tsconfig.json': CRA.getTsconfig(),\n 'package.json': CRA.getPkgJson(data),\n };\n if (data.provider === 'stackblitz-cloud') {\n Object.assign(base, getStackblitzConfig());\n }\n if (data.provider === 'codesandbox-cloud') {\n Object.assign(base, getCodesandboxConfig('cra'));\n }\n\n return base;\n },\n};\n\nconst Vite = {\n getHTML: () => dedent`\n <!doctype html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" type=\"image/svg+xml\" href=\"/vite.svg\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Vite + React + TS</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/index.tsx\"></script>\n </body>\n </html>\n `,\n getRootIndex: getIndex,\n getExample,\n getApp,\n getViteCfg: () => {\n return dedent`\n import { defineConfig } from 'vite'\n import react from '@vitejs/plugin-react'\n\n // https://vitejs.dev/config/\n export default defineConfig({\n plugins: [react()],\n })\n `;\n },\n getTsconfigNode: () => {\n return serializeJson({\n compilerOptions: {\n composite: true,\n skipLibCheck: true,\n module: 'ESNext',\n moduleResolution: 'bundler',\n allowSyntheticDefaultImports: true,\n },\n include: ['vite.config.ts'],\n });\n },\n getTsconfig: () => {\n return serializeJson({\n compilerOptions: {\n target: 'ES2020',\n useDefineForClassFields: true,\n lib: ['ES2020', 'DOM', 'DOM.Iterable'],\n module: 'ESNext',\n skipLibCheck: true,\n\n /* Bundler mode */\n moduleResolution: 'node',\n // moduleResolution: 'bundler',\n allowImportingTsExtensions: true,\n resolveJsonModule: true,\n isolatedModules: true,\n noEmit: true,\n jsx: 'react-jsx',\n\n /* Linting */\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noFallthroughCasesInSwitch: true,\n },\n include: ['src'],\n references: [{ path: './tsconfig.node.json' }],\n });\n },\n getPkgJson: (data: Data) => {\n return serializeJson({\n name: 'vite-react-typescript-starter',\n private: true,\n version: '0.0.0',\n type: 'module',\n scripts: {\n dev: 'vite',\n build: 'tsc && vite build',\n preview: 'vite preview',\n },\n dependencies: {\n ...data.dependencies,\n },\n devDependencies: {\n ...commonDevDeps,\n '@vitejs/plugin-react': '^4.2.0',\n vite: '^5.0.0',\n },\n });\n },\n};\n\nconst CRA = {\n getHTML: () => `<div id=\"root\"></div>`,\n getRootIndex: getIndex,\n getExample,\n getApp,\n getTsconfig: () =>\n serializeJson({\n include: ['./src/**/*'],\n compilerOptions: {\n strict: true,\n esModuleInterop: true,\n lib: ['dom', 'es2015'],\n jsx: 'react-jsx',\n },\n }),\n getPkgJson: (data: Data) => {\n return serializeJson({\n main: 'src/index.tsx',\n dependencies: {\n ...data.dependencies,\n },\n devDependencies: {\n ...commonDevDeps,\n 'react-scripts': '^5.0.0',\n '@babel/plugin-proposal-private-property-in-object': 'latest',\n },\n scripts: {\n start: 'react-scripts start',\n build: 'react-scripts build',\n test: 'react-scripts test --env=jsdom',\n eject: 'react-scripts eject',\n },\n browserslist: ['>0.2%', 'not dead', 'not ie <= 11', 'not op_mini all'],\n });\n },\n};\n\nfunction getCodesandboxConfig(kind: 'cra' | 'vite') {\n const startConfig = {\n cra: { command: 'yarn start', preview: { port: 3000 } },\n vite: { command: 'yarn dev', preview: { port: 5173 } },\n };\n return {\n '.devcontainer/devcontainer.json': serializeJson({\n name: 'Devcontainer',\n build: {\n dockerfile: './Dockerfile',\n },\n }),\n '.devcontainer/Dockerfile': `FROM node:16-bullseye`,\n '.codesandbox/tasks.json': serializeJson({\n // These tasks will run in order when initializing your CodeSandbox project.\n setupTasks: [\n {\n name: 'Install Dependencies',\n command: 'yarn install',\n },\n ],\n\n // These tasks can be run from CodeSandbox. Running one will open a log in the app.\n tasks: {\n dev: {\n name: 'dev',\n runAtStart: true,\n ...startConfig[kind],\n },\n build: {\n name: 'build',\n command: 'yarn build',\n runAtStart: false,\n },\n preview: {\n name: 'preview',\n command: 'yarn preview',\n runAtStart: false,\n },\n },\n }),\n };\n}\n\nfunction getStackblitzConfig() {\n return {\n '.stackblitzrc': serializeJson({}),\n };\n}\n\nfunction getIndex() {\n return dedent`\n import * as React from 'react';\n import { createRoot } from 'react-dom/client';\n import App from './App';\n\n const root = createRoot(document.getElementById('root') as HTMLElement);\n\n root.render(\n <React.StrictMode>\n <App />\n </React.StrictMode>,\n );\n `;\n}\n\nfunction getExample(demoData: Data) {\n return demoData.storyFile;\n}\n\nfunction getApp(data: Data) {\n const code = dedent`\n import { FluentProvider, webLightTheme } from '@fluentui/react-components';\n import { ${data.storyExportToken} as Example } from './example';\n\n const App = () => {\n return (\n <FluentProvider theme={webLightTheme}>\n <Example />\n </FluentProvider>\n );\n };\n\n export default App;\n `;\n\n return code;\n}\n"],"names":["dedent","serializeJson","commonDevDeps","typescript","scaffold","vite","data","provider","Error","base","Vite","getHTML","getApp","getRootIndex","getExample","getTsconfig","getTsconfigNode","getViteCfg","getPkgJson","Object","assign","getStackblitzConfig","getCodesandboxConfig","cra","CRA","getIndex","compilerOptions","composite","skipLibCheck","module","moduleResolution","allowSyntheticDefaultImports","include","target","useDefineForClassFields","lib","allowImportingTsExtensions","resolveJsonModule","isolatedModules","noEmit","jsx","strict","noUnusedLocals","noUnusedParameters","noFallthroughCasesInSwitch","references","path","name","private","version","type","scripts","dev","build","preview","dependencies","devDependencies","esModuleInterop","main","start","test","eject","browserslist","kind","startConfig","command","port","dockerfile","setupTasks","tasks","runAtStart","demoData","storyFile","code","storyExportToken"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;EAYd,CAAC;AACH;AAEA,SAASc,WAAWyD,QAAc;IAChC,OAAOA,SAASC,SAAS;AAC3B;AAEA,SAAS5D,OAAON,IAAU;IACxB,MAAMmE,OAAOzE,MAAM,CAAC;;aAET,EAAEM,KAAKoE,gBAAgB,CAAC;;;;;;;;;;;EAWnC,CAAC;IAED,OAAOD;AACT"}
1
+ {"version":3,"sources":["../src/sandbox-scaffold.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport type { Data } from './sandbox-utils';\nimport { serializeJson } from './utils';\n\nconst commonDevDeps = { '@types/react': '^17', '@types/react-dom': '^17', typescript: '~4.7.0' };\n\nexport const scaffold = {\n vite: (data: Data): Record<string, string> => {\n if (data.provider === 'codesandbox-browser') {\n throw new Error('vite is not supported on codesandbox-browser');\n }\n\n const base = {\n 'index.html': Vite.getHTML(),\n 'src/App.tsx': Vite.getApp(data),\n 'src/index.tsx': Vite.getRootIndex(),\n 'src/example.tsx': Vite.getExample(data),\n 'tsconfig.json': Vite.getTsconfig(),\n 'tsconfig.node.json': Vite.getTsconfigNode(),\n 'vite.config.ts': Vite.getViteCfg(),\n 'package.json': Vite.getPkgJson(data),\n };\n if (data.provider === 'stackblitz-cloud') {\n Object.assign(base, getStackblitzConfig());\n }\n if (data.provider === 'codesandbox-cloud') {\n Object.assign(base, getCodesandboxConfig('vite'));\n }\n return base;\n },\n cra: (data: Data): Record<string, string> => {\n const base = {\n 'public/index.html': CRA.getHTML(),\n 'src/App.tsx': CRA.getApp(data),\n 'src/index.tsx': CRA.getRootIndex(),\n 'src/example.tsx': CRA.getExample(data),\n 'tsconfig.json': CRA.getTsconfig(),\n 'package.json': CRA.getPkgJson(data),\n };\n if (data.provider === 'stackblitz-cloud') {\n Object.assign(base, getStackblitzConfig());\n }\n if (data.provider === 'codesandbox-cloud') {\n Object.assign(base, getCodesandboxConfig('cra'));\n }\n\n return base;\n },\n};\n\nconst Vite = {\n getHTML: () => dedent`\n <!doctype html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" type=\"image/svg+xml\" href=\"/vite.svg\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Vite + React + TS</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/index.tsx\"></script>\n </body>\n </html>\n `,\n getRootIndex: getIndex,\n getExample,\n getApp,\n getViteCfg: () => {\n return dedent`\n import { defineConfig } from 'vite'\n import react from '@vitejs/plugin-react'\n\n // https://vitejs.dev/config/\n export default defineConfig({\n plugins: [react()],\n })\n `;\n },\n getTsconfigNode: () => {\n return serializeJson({\n compilerOptions: {\n composite: true,\n skipLibCheck: true,\n module: 'ESNext',\n moduleResolution: 'bundler',\n allowSyntheticDefaultImports: true,\n },\n include: ['vite.config.ts'],\n });\n },\n getTsconfig: () => {\n return serializeJson({\n compilerOptions: {\n target: 'ES2020',\n useDefineForClassFields: true,\n lib: ['ES2020', 'DOM', 'DOM.Iterable'],\n module: 'ESNext',\n skipLibCheck: true,\n\n /* Bundler mode */\n moduleResolution: 'node',\n // moduleResolution: 'bundler',\n allowImportingTsExtensions: true,\n resolveJsonModule: true,\n isolatedModules: true,\n noEmit: true,\n jsx: 'react-jsx',\n\n /* Linting */\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noFallthroughCasesInSwitch: true,\n },\n include: ['src'],\n references: [{ path: './tsconfig.node.json' }],\n });\n },\n getPkgJson: (data: Data) => {\n return serializeJson({\n name: 'vite-react-typescript-starter',\n private: true,\n version: '0.0.0',\n type: 'module',\n scripts: {\n dev: 'vite',\n build: 'tsc && vite build',\n preview: 'vite preview',\n },\n dependencies: {\n ...data.dependencies,\n },\n devDependencies: {\n ...commonDevDeps,\n '@vitejs/plugin-react': '^4.2.0',\n vite: '^5.0.0',\n },\n });\n },\n};\n\nconst CRA = {\n getHTML: () => `<div id=\"root\"></div>`,\n getRootIndex: getIndex,\n getExample,\n getApp,\n getTsconfig: () =>\n serializeJson({\n include: ['./src/**/*'],\n compilerOptions: {\n strict: true,\n esModuleInterop: true,\n lib: ['dom', 'es2015'],\n jsx: 'react-jsx',\n },\n }),\n getPkgJson: (data: Data) => {\n return serializeJson({\n main: 'src/index.tsx',\n dependencies: {\n ...data.dependencies,\n },\n devDependencies: {\n ...commonDevDeps,\n 'react-scripts': '^5.0.0',\n '@babel/plugin-proposal-private-property-in-object': 'latest',\n },\n scripts: {\n start: 'react-scripts start',\n build: 'react-scripts build',\n test: 'react-scripts test --env=jsdom',\n eject: 'react-scripts eject',\n },\n browserslist: ['>0.2%', 'not dead', 'not ie <= 11', 'not op_mini all'],\n });\n },\n};\n\nfunction getCodesandboxConfig(kind: 'cra' | 'vite') {\n const startConfig = {\n cra: { command: 'yarn start', preview: { port: 3000 } },\n vite: { command: 'yarn dev', preview: { port: 5173 } },\n };\n return {\n '.devcontainer/devcontainer.json': serializeJson({\n name: 'Devcontainer',\n build: {\n dockerfile: './Dockerfile',\n },\n }),\n '.devcontainer/Dockerfile': `FROM node:16-bullseye`,\n '.codesandbox/tasks.json': serializeJson({\n // These tasks will run in order when initializing your CodeSandbox project.\n setupTasks: [\n {\n name: 'Install Dependencies',\n command: 'yarn install',\n },\n ],\n\n // These tasks can be run from CodeSandbox. Running one will open a log in the app.\n tasks: {\n dev: {\n name: 'dev',\n runAtStart: true,\n ...startConfig[kind],\n },\n build: {\n name: 'build',\n command: 'yarn build',\n runAtStart: false,\n },\n preview: {\n name: 'preview',\n command: 'yarn preview',\n runAtStart: false,\n },\n },\n }),\n };\n}\n\nfunction getStackblitzConfig() {\n return {\n '.stackblitzrc': serializeJson({}),\n };\n}\n\nfunction getIndex() {\n return dedent`\n import * as React from 'react';\n import { createRoot } from 'react-dom/client';\n import App from './App';\n\n const root = createRoot(document.getElementById('root') as HTMLElement);\n\n root.render(\n <React.StrictMode>\n <App />\n </React.StrictMode>,\n );\n `;\n}\n\nfunction getExample(demoData: Data) {\n return demoData.storyFile;\n}\n\nfunction getApp(data: Data) {\n const code = dedent`\n import { FluentProvider, webLightTheme } from '@fluentui/react-components';\n import { ${data.storyExportToken} as Example } from './example';\n\n const App = () => {\n return (\n <FluentProvider theme={webLightTheme}>\n <Example />\n </FluentProvider>\n );\n };\n\n export default App;\n `;\n\n return code;\n}\n"],"names":["dedent","serializeJson","commonDevDeps","typescript","scaffold","vite","data","provider","Error","base","Vite","getHTML","getApp","getRootIndex","getExample","getTsconfig","getTsconfigNode","getViteCfg","getPkgJson","Object","assign","getStackblitzConfig","getCodesandboxConfig","cra","CRA","getIndex","compilerOptions","composite","skipLibCheck","module","moduleResolution","allowSyntheticDefaultImports","include","target","useDefineForClassFields","lib","allowImportingTsExtensions","resolveJsonModule","isolatedModules","noEmit","jsx","strict","noUnusedLocals","noUnusedParameters","noFallthroughCasesInSwitch","references","path","name","private","version","type","scripts","dev","build","preview","dependencies","devDependencies","esModuleInterop","main","start","test","eject","browserslist","kind","startConfig","command","port","dockerfile","setupTasks","tasks","runAtStart","demoData","storyFile","code","storyExportToken"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAG5B,SAASC,aAAa,QAAQ,UAAU;AAExC,MAAMC,gBAAgB;IAAE,gBAAgB;IAAO,oBAAoB;IAAOC,YAAY;AAAS;AAE/F,OAAO,MAAMC,WAAW;IACtBC,MAAM,CAACC;QACL,IAAIA,KAAKC,QAAQ,KAAK,uBAAuB;YAC3C,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAMC,OAAO;YACX,cAAcC,KAAKC,OAAO;YAC1B,eAAeD,KAAKE,MAAM,CAACN;YAC3B,iBAAiBI,KAAKG,YAAY;YAClC,mBAAmBH,KAAKI,UAAU,CAACR;YACnC,iBAAiBI,KAAKK,WAAW;YACjC,sBAAsBL,KAAKM,eAAe;YAC1C,kBAAkBN,KAAKO,UAAU;YACjC,gBAAgBP,KAAKQ,UAAU,CAACZ;QAClC;QACA,IAAIA,KAAKC,QAAQ,KAAK,oBAAoB;YACxCY,OAAOC,MAAM,CAACX,MAA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AqB,CAAC;QACnD,2BAA2BlE,cAAc;YACvC,4EAA4E;YAC5EmE,YAAY;gBACV;oBACErB,MAAM;oBACNkB,SAAS;gBACX;aACD;YAED,mFAAmF;YACnFI,OAAO;gBACLjB,KAAK;oBACHL,MAAM;oBACNuB,YAAY;oBACZ,GAAGN,WAAW,CAACD,KAAK;gBACtB;gBACAV,OAAO;oBACLN,MAAM;oBACNkB,SAAS;oBACTK,YAAY;gBACd;gBACAhB,SAAS;oBACPP,MAAM;oBACNkB,SAAS;oBACTK,YAAY;gBACd;YACF;QACF;IACF;AACF;AAEA,SAASjD;IACP,OAAO;QACL,iBAAiBpB,cAAc,CAAC;IAClC;AACF;AAEA,SAASwB;IACP,OAAOzB,MAAM,CAAC;;;;;;;;;;;;EAYd,CAAC;AACH;AAEA,SAASc,WAAWyD,QAAc;IAChC,OAAOA,SAASC,SAAS;AAC3B;AAEA,SAAS5D,OAAON,IAAU;IACxB,MAAMmE,OAAOzE,MAAM,CAAC;;aAET,EAAEM,KAAKoE,gBAAgB,CAAC;;;;;;;;;;;EAWnC,CAAC;IAED,OAAOD;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sandbox-utils.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport { getDependencies } from './getDependencies';\nimport { StoryContext, ParametersExtension } from './types';\n\ntype ParametersConfig = NonNullable<ParametersExtension['exportToSandbox']>;\n\nexport function addHiddenInput(form: HTMLFormElement, name: string, value: string) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n form.appendChild(input);\n}\n\nexport function prepareSandboxContainer(context: StoryContext) {\n const docsSelector = `#anchor--${context.id} .docs-story`;\n const rootElement = document.querySelector(docsSelector);\n\n if (!rootElement) {\n throw new Error(`css selector: ${docsSelector}, doesn't exist `);\n }\n\n const showCodeButton = rootElement.querySelector('.docblock-code-toggle');\n const container = showCodeButton?.parentElement;\n\n if (!container) {\n throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);\n }\n\n const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');\n\n // remove button if it already existed\n const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);\n ourButtons.forEach(node => node.remove());\n\n return {\n container,\n cssClasses: classList,\n };\n}\n\nconst addonConfigDefaults = { requiredDependencies: {}, optionalDependencies: {} };\nexport type Data = Pick<Required<ParametersConfig>, 'provider' | 'bundler'> & {\n storyFile: string;\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n storyExportToken: string;\n dependencies: Record<string, string>;\n title: string;\n description: string;\n};\n\nexport function prepareData(context: StoryContext): Data | null {\n if (!context.parameters.exportToSandbox) {\n throw new Error('exportToSandbox config parameter cannot be empty');\n }\n\n const addonConfig: Required<ParametersConfig> = {\n ...addonConfigDefaults,\n ...context.parameters.exportToSandbox,\n };\n const { provider, bundler } = addonConfig;\n const storyFile = context.parameters?.fullSource;\n\n if (!storyFile) {\n console.error(\n dedent`Export to Sandbox Addon: Couldn't find source for story ${context.title}. Did you install the babel plugin?`,\n );\n return null;\n }\n\n const { requiredDependencies, optionalDependencies } = addonConfig;\n const dependencies = getDependencies(storyFile, requiredDependencies, optionalDependencies);\n\n const title = 'FluentUI React v9';\n const description = `Story demo: ${context.title} - ${context.name}`;\n\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n const storyExportToken = context.originalStoryFn.name.split('_stories_').slice(-1).pop();\n if (!storyExportToken) {\n throw new Error('issues processing story export token');\n }\n\n const demoData = {\n storyFile,\n storyExportToken,\n provider,\n bundler,\n dependencies,\n title,\n description,\n };\n\n return demoData;\n}\n"],"names":["dedent","getDependencies","addHiddenInput","form","name","value","input","document","createElement","type","appendChild","prepareSandboxContainer","context","docsSelector","id","rootElement","querySelector","Error","showCodeButton","container","parentElement","classList","split","ourButtons","querySelectorAll","forEach","node","remove","cssClasses","addonConfigDefaults","requiredDependencies","optionalDependencies","prepareData","parameters","exportToSandbox","addonConfig","provider","bundler","storyFile","fullSource","console","error","title","dependencies","description","storyExportToken","originalStoryFn","slice","pop","demoData"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAY,SAAS;AAE5B,SAASC,eAAe,QAAQ,oBAAoB;AAKpD,OAAO,SAASC,eAAeC,IAAqB,EAAEC,IAAY,EAAEC,KAAa;IAC/E,MAAMC,QAAQC,SAASC,aAAa,CAAC;IACrCF,MAAMG,IAAI,GAAG;IACbH,MAAMF,IAAI,GAAGA;IACbE,MAAMD,KAAK,GAAGA;IACdF,KAAKO,WAAW,CAACJ;AACnB;AAEA,OAAO,SAASK,wBAAwBC,OAAqB;IAC3D,MAAMC,eAAe,CAAC,SAAS,EAAED,QAAQE,EAAE,CAAC,YAAY,CAAC;IACzD,MAAMC,cAAcR,SAASS,aAAa,CAACH;IAE3C,IAAI,CAACE,aAAa;QAChB,MAAM,IAAIE,MAAM,CAAC,cAAc,EAAEJ,aAAa,gBAAgB,CAAC;IACjE;IAEA,MAAMK,iBAAiBH,YAAYC,aAAa,CAAC;IACjD,MAAMG,YAAYD,2BAAAA,qCAAAA,eAAgBE,aAAa;IAE/C,IAAI,CAACD,WAAW;QACd,MAAM,IAAIF,MAAM,CAAC,qDAAqD,CAAC;IACzE;IAEA,MAAMI,YAAY,AAACH,CAAAA,eAAeG,SAAS,CAAChB,KAAK,GAAG,2BAA0B,EAAGiB,KAAK,CAAC;IAEvF,sCAAsC;IACtC,MAAMC,a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ACAM;QACAD;QACAE;IACF;IAEA,OAAOK;AACT"}
1
+ {"version":3,"sources":["../src/sandbox-utils.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport { getDependencies } from './getDependencies';\nimport { StoryContext, ParametersExtension } from './types';\n\ntype ParametersConfig = NonNullable<ParametersExtension['exportToSandbox']>;\n\nexport function addHiddenInput(form: HTMLFormElement, name: string, value: string) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n form.appendChild(input);\n}\n\nexport function prepareSandboxContainer(context: StoryContext) {\n const docsSelector = `#anchor--${context.id} .docs-story`;\n const rootElement = document.querySelector(docsSelector);\n\n if (!rootElement) {\n throw new Error(`css selector: ${docsSelector}, doesn't exist `);\n }\n\n const showCodeButton = rootElement.querySelector('.docblock-code-toggle');\n const container = showCodeButton?.parentElement;\n\n if (!container) {\n throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);\n }\n\n const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');\n\n // remove button if it already existed\n const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);\n ourButtons.forEach(node => node.remove());\n\n return {\n container,\n cssClasses: classList,\n };\n}\n\nconst addonConfigDefaults = { requiredDependencies: {}, optionalDependencies: {} };\nexport type Data = Pick<Required<ParametersConfig>, 'provider' | 'bundler'> & {\n storyFile: string;\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n storyExportToken: string;\n dependencies: Record<string, string>;\n title: string;\n description: string;\n};\n\nexport function prepareData(context: StoryContext): Data | null {\n if (!context.parameters.exportToSandbox) {\n throw new Error('exportToSandbox config parameter cannot be empty');\n }\n\n const addonConfig: Required<ParametersConfig> = {\n ...addonConfigDefaults,\n ...context.parameters.exportToSandbox,\n };\n const { provider, bundler } = addonConfig;\n const storyFile = context.parameters?.fullSource;\n\n if (!storyFile) {\n console.error(\n dedent`Export to Sandbox Addon: Couldn't find source for story ${context.title}. Did you install the babel plugin?`,\n );\n return null;\n }\n\n const { requiredDependencies, optionalDependencies } = addonConfig;\n const dependencies = getDependencies(storyFile, requiredDependencies, optionalDependencies);\n\n const title = 'FluentUI React v9';\n const description = `Story demo: ${context.title} - ${context.name}`;\n\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n const storyExportToken = context.originalStoryFn.name.split('_stories_').slice(-1).pop();\n if (!storyExportToken) {\n throw new Error('issues processing story export token');\n }\n\n const demoData = {\n storyFile,\n storyExportToken,\n provider,\n bundler,\n dependencies,\n title,\n description,\n };\n\n return demoData;\n}\n"],"names":["dedent","getDependencies","addHiddenInput","form","name","value","input","document","createElement","type","appendChild","prepareSandboxContainer","context","docsSelector","id","rootElement","querySelector","Error","showCodeButton","container","parentElement","classList","split","ourButtons","querySelectorAll","forEach","node","remove","cssClasses","addonConfigDefaults","requiredDependencies","optionalDependencies","prepareData","parameters","exportToSandbox","addonConfig","provider","bundler","storyFile","fullSource","console","error","title","dependencies","description","storyExportToken","originalStoryFn","slice","pop","demoData"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAE5B,SAASC,eAAe,QAAQ,oBAAoB;AAKpD,OAAO,SAASC,eAAeC,IAAqB,EAAEC,IAAY,EAAEC,KAAa;IAC/E,MAAMC,QAAQC,SAASC,aAAa,CAAC;IACrCF,MAAMG,IAAI,GAAG;IACbH,MAAMF,IAAI,GAAGA;IACbE,MAAMD,KAAK,GAAGA;IACdF,KAAKO,WAAW,CAACJ;AACnB;AAEA,OAAO,SAASK,wBAAwBC,OAAqB;IAC3D,MAAMC,eAAe,CAA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ACvD,MAAMQ,eAAe1C,gBAAgBqC,WAAWR,sBAAsBC;IAEtE,MAAMW,QAAQ;IACd,MAAME,cAAc,CAAC,YAAY,EAAEhC,QAAQ8B,KAAK,CAAC,GAAG,EAAE9B,QAAQR,IAAI,EAAE;IAEpE,2EAA2E;IAC3E,kEAAkE;IAClE,mEAAmE;IACnE,oFAAoF;IACpF,yBAAyB;IACzB,qFAAqF;IACrF,MAAMyC,mBAAmBjC,QAAQkC,eAAe,CAAC1C,IAAI,CAACkB,KAAK,CAAC,aAAayB,KAAK,CAAC,CAAC,GAAGC,GAAG;IACtF,IAAI,CAACH,kBAAkB;QACrB,MAAM,IAAI5B,MAAM;IAClB;IAEA,MAAMgC,WAAW;QACfX;QACAO;QACAT;QACAC;QACAM;QACAD;QACAE;IACF;IAEA,OAAOK;AACT"}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { StoryContext as StoryContextOrigin, Parameters } from '@storybook/react';\nimport type { ParametersExtension, PresetConfig } from './public-types';\n\nexport interface StoryContext extends StoryContextOrigin {\n parameters: Parameters & ParametersExtension;\n}\n\nexport type { ParametersExtension, PresetConfig };\n"],"names":[],"rangeMappings":"","mappings":"AAOA,WAAkD"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { StoryContext as StoryContextOrigin, Parameters } from '@storybook/react';\nimport type { ParametersExtension, PresetConfig } from './public-types';\n\nexport interface StoryContext extends StoryContextOrigin {\n parameters: Parameters & ParametersExtension;\n}\n\nexport type { ParametersExtension, PresetConfig };\n"],"names":[],"mappings":"AAOA,WAAkD"}
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts"],"sourcesContent":["export function serializeJson(value: object) {\n return JSON.stringify(value, null, 2);\n}\n"],"names":["serializeJson","value","JSON","stringify"],"rangeMappings":";;","mappings":"AAAA,OAAO,SAASA,cAAcC,KAAa;IACzC,OAAOC,KAAKC,SAAS,CAACF,OAAO,MAAM;AACrC"}
1
+ {"version":3,"sources":["../src/utils.ts"],"sourcesContent":["export function serializeJson(value: object) {\n return JSON.stringify(value, null, 2);\n}\n"],"names":["serializeJson","value","JSON","stringify"],"mappings":"AAAA,OAAO,SAASA,cAAcC,KAAa;IACzC,OAAOC,KAAKC,SAAS,CAACF,OAAO,MAAM;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/webpack.ts"],"sourcesContent":["import type { PresetConfig } from './types';\n\ntype WebpackFinalFn = NonNullable<import('@storybook/react-webpack5').StorybookConfig['webpackFinal']>;\nexport type WebpackFinalConfig = Parameters<WebpackFinalFn>[0];\nexport type WebpackFinalOptions = Parameters<WebpackFinalFn>[1];\n\nexport function webpack(config: WebpackFinalConfig, options: WebpackFinalOptions) {\n const addonPresetConfig = getAddonOptions(options);\n\n registerRules({ config, rules: [createBabelLoaderRule(addonPresetConfig)] });\n\n return config;\n}\n\nconst identity = <T extends unknown>(value: T) => value;\nconst addonFilePattern = /react-storybook-addon-export-to-sandbox\\/[a-z/]+.[jt]s$/;\nconst defaultOptions = {\n webpackRule: {},\n babelLoaderOptionsUpdater: identity,\n};\n\nconst PLUGIN_PATH =\n process.env.NODE_ENV !== 'production'\n ? '@fluentui/babel-preset-storybook-full-source/__dev'\n : '@fluentui/babel-preset-storybook-full-source';\n\nfunction createBabelLoaderRule(config: Required<PresetConfig>): import('webpack').RuleSetRule {\n const { babelLoaderOptionsUpdater, importMappings, webpackRule } = config;\n\n const plugin = [require.resolve(PLUGIN_PATH), importMappings];\n\n return {\n test: /\\.stories\\.(jsx?$|tsx?$)/,\n ...webpackRule,\n /**\n * why the usage of 'post' ? - we need to run this loader after all storybook webpack rules/loaders have been executed.\n * while we can use Array.prototype.unshift to \"override\" the indexes this approach is more declarative without additional hacks.\n */\n enforce: 'post',\n use: {\n /**\n * Custom babel loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` parameter\n * that is passed to babel-loader.\n **/\n loader: require.resolve('./custom-babel-loader'),\n options: babelLoaderOptionsUpdater({\n plugins: [plugin],\n }),\n },\n };\n}\n\n/**\n *\n * register custom Webpack Rules to webpack config\n */\nfunction registerRules(options: { rules: import('webpack').RuleSetRule[]; config: import('webpack').Configuration }) {\n const { config, rules } = options;\n config.module = config.module ?? {};\n config.module.rules = config.module.rules ?? [];\n config.module.rules.push(...rules);\n\n return config;\n}\n\nfunction getAddonOptions(options: WebpackFinalOptions): Required<PresetConfig> {\n const presetRegistration = options.presetsList?.find(preset => {\n return addonFilePattern.test(preset.name);\n });\n\n const addonOptions = presetRegistration?.options ?? {};\n\n return { ...defaultOptions, ...addonOptions };\n}\n"],"names":["webpack","config","options","addonPresetConfig","getAddonOptions","registerRules","rules","createBabelLoaderRule","identity","value","addonFilePattern","defaultOptions","webpackRule","babelLoaderOptionsUpdater","PLUGIN_PATH","process","env","NODE_ENV","importMappings","plugin","require","resolve","test","enforce","use","loader","plugins","module","push","presetRegistration","presetsList","find","preset","name","addonOptions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,OAAO,SAASA,QAAQC,MAA0B,EAAEC,OAA4B;IAC9E,MAAMC,oBAAoBC,gBAAgBF;IAE1CG,cAAc;QAAEJ;QAAQK,OAAO;YAACC,sBAAsBJ;SAAmB;IAAC;IAE1E,OAAOF;AACT;AAEA,MAAMO,WAAW,CAAoBC,QAAaA;AAClD,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;IACrBC,aAAa,CAAC;IACdC,2BAA2BL;AAC7B;AAEA,MAAMM,cACJC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eACrB,uDACA;AAEN,SAASV,sBAAsBN,MAA8B;IAC3D,MAAM,EAAEY,yBAAyB,EAAEK,cAAc,EAAEN,WAAW,EAAE,GAAGX;IAEnE,MAAMkB,SAAS;QAACC,QAAQC,OAAO,CAACP;QAAcI;KAAe;IAE7D,OAAO;QACLI,MAAM;QACN,GAAGV,WAAW;QACd;;;KAGC,GACDW,SAAS;QACTC,KAAK;YACH;;;QAGE,GACFC,QAAQL,QAAQC,OAAO,CAAC;YACxBnB,SAASW,0BAA0B;gBACjCa,SAAS;oBAACP;iBAAO;YACnB;QACF;IACF;AACF;AAEA;;;CAGC,GACD,SAASd,cAAcH,OAA4F;IACjH,MAAM,EAAED,MAAM,EAAEK,KAAK,EAAE,GAAGJ;QACVD;IAAhBA,OAAO0B,MAAM,GAAG1B,CAAAA,iBAAAA,OAAO0B,MAAM,cAAb1B,4BAAAA,iBAAiB,CAAC;QACZA;IAAtBA,OAAO0B,MAAM,CAACrB,KAAK,GAAGL,CAAAA,uBAAAA,OAAO0B,MAAM,CAACrB,KAAK,cAAnBL,kCAAAA,uBAAuB,EAAE;IAC/CA,OAAO0B,MAAM,CAACrB,KAAK,CAACsB,IAAI,IAAItB;IAE5B,OAAOL;AACT;AAEA,SAASG,gBAAgBF,OAA4B;QACxBA;IAA3B,MAAM2B,sBAAqB3B,uBAAAA,QAAQ4B,WAAW,cAAnB5B,2CAAAA,qBAAqB6B,IAAI,CAACC,CAAAA;QACnD,OAAOtB,iBAAiBY,IAAI,CAACU,OAAOC,IAAI;IAC1C;QAEqBJ;IAArB,MAAMK,eAAeL,CAAAA,8BAAAA,+BAAAA,yCAAAA,mBAAoB3B,OAAO,cAA3B2B,yCAAAA,8BAA+B,CAAC;IAErD,OAAO;QAAE,GAAGlB,cAAc;QAAE,GAAGuB,YAAY;IAAC;AAC9C"}
1
+ {"version":3,"sources":["../src/webpack.ts"],"sourcesContent":["import type { PresetConfig } from './types';\n\ntype WebpackFinalFn = NonNullable<import('@storybook/react-webpack5').StorybookConfig['webpackFinal']>;\nexport type WebpackFinalConfig = Parameters<WebpackFinalFn>[0];\nexport type WebpackFinalOptions = Parameters<WebpackFinalFn>[1];\n\nexport function webpack(config: WebpackFinalConfig, options: WebpackFinalOptions) {\n const addonPresetConfig = getAddonOptions(options);\n\n registerRules({ config, rules: [createBabelLoaderRule(addonPresetConfig)] });\n\n return config;\n}\n\nconst identity = <T extends unknown>(value: T) => value;\nconst addonFilePattern = /react-storybook-addon-export-to-sandbox\\/[a-z/]+.[jt]s$/;\nconst defaultOptions = {\n webpackRule: {},\n babelLoaderOptionsUpdater: identity,\n};\n\nconst PLUGIN_PATH =\n process.env.NODE_ENV !== 'production'\n ? '@fluentui/babel-preset-storybook-full-source/__dev'\n : '@fluentui/babel-preset-storybook-full-source';\n\nfunction createBabelLoaderRule(config: Required<PresetConfig>): import('webpack').RuleSetRule {\n const { babelLoaderOptionsUpdater, importMappings, webpackRule } = config;\n\n const plugin = [require.resolve(PLUGIN_PATH), importMappings];\n\n return {\n test: /\\.stories\\.(jsx?$|tsx?$)/,\n ...webpackRule,\n /**\n * why the usage of 'post' ? - we need to run this loader after all storybook webpack rules/loaders have been executed.\n * while we can use Array.prototype.unshift to \"override\" the indexes this approach is more declarative without additional hacks.\n */\n enforce: 'post',\n use: {\n /**\n * Custom babel loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` parameter\n * that is passed to babel-loader.\n **/\n loader: require.resolve('./custom-babel-loader'),\n options: babelLoaderOptionsUpdater({\n plugins: [plugin],\n }),\n },\n };\n}\n\n/**\n *\n * register custom Webpack Rules to webpack config\n */\nfunction registerRules(options: { rules: import('webpack').RuleSetRule[]; config: import('webpack').Configuration }) {\n const { config, rules } = options;\n config.module = config.module ?? {};\n config.module.rules = config.module.rules ?? [];\n config.module.rules.push(...rules);\n\n return config;\n}\n\nfunction getAddonOptions(options: WebpackFinalOptions): Required<PresetConfig> {\n const presetRegistration = options.presetsList?.find(preset => {\n return addonFilePattern.test(preset.name);\n });\n\n const addonOptions = presetRegistration?.options ?? {};\n\n return { ...defaultOptions, ...addonOptions };\n}\n"],"names":["webpack","config","options","addonPresetConfig","getAddonOptions","registerRules","rules","createBabelLoaderRule","identity","value","addonFilePattern","defaultOptions","webpackRule","babelLoaderOptionsUpdater","PLUGIN_PATH","process","env","NODE_ENV","importMappings","plugin","require","resolve","test","enforce","use","loader","plugins","module","push","presetRegistration","presetsList","find","preset","name","addonOptions"],"mappings":"AAMA,OAAO,SAASA,QAAQC,MAA0B,EAAEC,OAA4B;IAC9E,MAAMC,oBAAoBC,gBAAgBF;IAE1CG,cAAc;QAAEJ;QAAQK,OAAO;YAACC,sBAAsBJ;SAAmB;IAAC;IAE1E,OAAOF;AACT;AAEA,MAAMO,WAAW,CAAoBC,QAAaA;AAClD,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;IACrBC,aAAa,CAAC;IACdC,2BAA2BL;AAC7B;AAEA,MAAMM,cACJC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eACrB,uDACA;AAEN,SAASV,sBAAsBN,MAA8B;IAC3D,MAAM,EAAEY,yBAAyB,EAAEK,cAAc,EAAEN,WAAW,EAAE,GAAGX;IAEnE,MAAMkB,SAAS;QAACC,QAAQC,OAAO,CAACP;QAAcI;KAAe;IAE7D,OAAO;QACLI,MAAM;QACN,GAAGV,WAAW;QACd;;;KAGC,GACDW,SAAS;QACTC,KAAK;YACH;;;QAGE,GACFC,QAAQL,QAAQC,OAAO,CAAC;YACxBnB,SAASW,0BAA0B;gBACjCa,SAAS;oBAACP;iBAAO;YACnB;QACF;IACF;AACF;AAEA;;;CAGC,GACD,SAASd,cAAcH,OAA4F;IACjH,MAAM,EAAED,MAAM,EAAEK,KAAK,EAAE,GAAGJ;QACVD;IAAhBA,OAAO0B,MAAM,GAAG1B,CAAAA,iBAAAA,OAAO0B,MAAM,cAAb1B,4BAAAA,iBAAiB,CAAC;QACZA;IAAtBA,OAAO0B,MAAM,CAACrB,KAAK,GAAGL,CAAAA,uBAAAA,OAAO0B,MAAM,CAACrB,KAAK,cAAnBL,kCAAAA,uBAAuB,EAAE;IAC/CA,OAAO0B,MAAM,CAACrB,KAAK,CAACsB,IAAI,IAAItB;IAE5B,OAAOL;AACT;AAEA,SAASG,gBAAgBF,OAA4B;QACxBA;IAA3B,MAAM2B,sBAAqB3B,uBAAAA,QAAQ4B,WAAW,cAAnB5B,2CAAAA,qBAAqB6B,IAAI,CAACC,CAAAA;QACnD,OAAOtB,iBAAiBY,IAAI,CAACU,OAAOC,IAAI;IAC1C;QAEqBJ;IAArB,MAAMK,eAAeL,CAAAA,8BAAAA,+BAAAA,yCAAAA,mBAAoB3B,OAAO,cAA3B2B,yCAAAA,8BAA+B,CAAC;IAErD,OAAO;QAAE,GAAGlB,cAAc;QAAE,GAAGuB,YAAY;IAAC;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/custom-babel-loader.ts"],"sourcesContent":["const babelLoader = require('babel-loader');\n\n/**\n * Custom loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` that\n * is passed from a loader that uses the `sourceMap` option.\n */\nmodule.exports = function (source: string, inputSourceMap?: object | boolean | string) {\n return babelLoader.call(\n this,\n source,\n typeof inputSourceMap === 'string' ? JSON.parse(inputSourceMap) : inputSourceMap,\n );\n};\n"],"names":["babelLoader","require","module","exports","source","inputSourceMap","call","JSON","parse"],"rangeMappings":";;;;;;;","mappings":";AAAA,MAAMA,cAAcC,QAAQ;AAE5B;;;CAGC,GACDC,OAAOC,OAAO,GAAG,SAAUC,MAAc,EAAEC,cAA0C;IACnF,OAAOL,YAAYM,IAAI,CACrB,IAAI,EACJF,QACA,OAAOC,mBAAmB,WAAWE,KAAKC,KAAK,CAACH,kBAAkBA;AAEtE"}
1
+ {"version":3,"sources":["../src/custom-babel-loader.ts"],"sourcesContent":["const babelLoader = require('babel-loader');\n\n/**\n * Custom loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` that\n * is passed from a loader that uses the `sourceMap` option.\n */\nmodule.exports = function (source: string, inputSourceMap?: object | boolean | string) {\n return babelLoader.call(\n this,\n source,\n typeof inputSourceMap === 'string' ? JSON.parse(inputSourceMap) : inputSourceMap,\n );\n};\n"],"names":["babelLoader","require","module","exports","source","inputSourceMap","call","JSON","parse"],"mappings":";AAAA,MAAMA,cAAcC,QAAQ;AAE5B;;;CAGC,GACDC,OAAOC,OAAO,GAAG,SAAUC,MAAc,EAAEC,cAA0C;IACnF,OAAOL,YAAYM,IAAI,CACrB,IAAI,EACJF,QACA,OAAOC,mBAAmB,WAAWE,KAAKC,KAAK,CAACH,kBAAkBA;AAEtE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/decorators/with-export-to-sandbox-button.ts"],"sourcesContent":["import { addDemoActionButton } from '../sandbox-factory';\n\nimport { StoryContext } from '../types';\n\nexport const withExportToSandboxButton = (\n storyFn: (context: StoryContext) => // eslint-disable-next-line @typescript-eslint/no-deprecated\n JSX.Element,\n context: StoryContext,\n) => {\n if (context.viewMode === 'docs') {\n addDemoActionButton(context);\n }\n\n return storyFn(context);\n};\n"],"names":["withExportToSandboxButton","storyFn","context","viewMode","addDemoActionButton"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":";;;;+BAIaA;;;eAAAA;;;gCAJuB;AAI7B,MAAMA,4BAA4B,CACvCC,SAEAC;IAEA,IAAIA,QAAQC,QAAQ,KAAK,QAAQ;QAC/BC,IAAAA,mCAAmB,EAACF;IACtB;IAEA,OAAOD,QAAQC;AACjB"}
1
+ {"version":3,"sources":["../src/decorators/with-export-to-sandbox-button.ts"],"sourcesContent":["import type { JSXElement } from '@fluentui/react-utilities';\n\nimport { addDemoActionButton } from '../sandbox-factory';\nimport type { StoryContext } from '../types';\n\nexport const withExportToSandboxButton = (storyFn: (context: StoryContext) => JSXElement, context: StoryContext) => {\n if (context.viewMode === 'docs') {\n addDemoActionButton(context);\n }\n\n return storyFn(context);\n};\n"],"names":["withExportToSandboxButton","storyFn","context","viewMode","addDemoActionButton"],"mappings":";;;;+BAKaA;;;eAAAA;;;gCAHuB;AAG7B,MAAMA,4BAA4B,CAACC,SAAgDC;IACxF,IAAIA,QAAQC,QAAQ,KAAK,QAAQ;QAC/BC,IAAAA,mCAAmB,EAACF;IACtB;IAEA,OAAOD,QAAQC;AACjB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/getDependencies.ts"],"sourcesContent":["type PackageDependencies = { [dependencyName: string]: string };\n\nconst IMPORT_PATH_REGEX = /from ['\"](.*?)['\"];/g;\n\nfunction matchAll(str: string, re: RegExp) {\n let match: RegExpExecArray | null = null;\n const matches: RegExpExecArray[] = [];\n\n while ((match = re.exec(str))) {\n matches.push(match);\n }\n\n return matches;\n}\n\n/**\n *\n * @param fileContent - code\n * @param requiredDependencies - dependencies that will always be included in package.json\n * @param optionalDependencies - whose versions will override those found in the code\n * @returns - Map of dependencies and their versions to include in package.json\n */\nexport const getDependencies = (\n fileContent: string,\n requiredDependencies: PackageDependencies,\n optionalDependencies: PackageDependencies,\n) => {\n const importPaths = matchAll(fileContent, IMPORT_PATH_REGEX);\n\n const dependenciesInCode = importPaths.reduce((dependencies, match) => {\n const importPath = match[1];\n const isReactPath = importPath.startsWith('react/');\n const isRelativeImportPath = importPath.startsWith('.');\n\n if (isReactPath || isRelativeImportPath) {\n return dependencies;\n }\n\n const dependency = parsePackageName(importPath).name;\n\n if (!dependencies.hasOwnProperty(dependency)) {\n dependencies[dependency] = optionalDependencies[dependency] ?? 'latest';\n }\n\n return dependencies;\n }, {} as PackageDependencies);\n\n return { ...dependenciesInCode, ...requiredDependencies };\n};\n\n// Parsed a scoped package name into name, version, and path.\nconst RE_SCOPED = /^(@[^\\/]+\\/[^@\\/]+)(?:@([^\\/]+))?(\\/.*)?$/;\n// Parsed a non-scoped package name into name, version, path\nconst RE_NON_SCOPED = /^([^@\\/]+)(?:@([^\\/]+))?(\\/.*)?$/;\n\nfunction parsePackageName(input: string) {\n const m = RE_SCOPED.exec(input) || RE_NON_SCOPED.exec(input);\n\n if (!m) {\n throw new Error(`[parse-package-name] invalid package name: ${input}`);\n }\n\n return {\n name: m[1] || '',\n version: m[2] || 'latest',\n path: m[3] || '',\n };\n}\n"],"names":["getDependencies","IMPORT_PATH_REGEX","matchAll","str","re","match","matches","exec","push","fileContent","requiredDependencies","optionalDependencies","importPaths","dependenciesInCode","reduce","dependencies","importPath","isReactPath","startsWith","isRelativeImportPath","dependency","parsePackageName","name","hasOwnProperty","RE_SCOPED","RE_NON_SCOPED","input","m","Error","version","path"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAsBaA;;;eAAAA;;;AApBb,MAAMC,oBAAoB;AAE1B,SAASC,SAASC,GAAW,EAAEC,EAAU;IACvC,IAAIC,QAAgC;IACpC,MAAMC,UAA6B,EAAE;IAErC,MAAQD,QAAQD,GAAGG,IAAI,CAACJ,KAAO;QAC7BG,QAAQE,IAAI,CAACH;IACf;IAEA,OAAOC;AACT;AASO,MAAMN,kBAAkB,CAC7BS,aACAC,sBACAC;IAEA,MAAMC,cAAcV,SAASO,aAAaR;IAE1C,MAAMY,qBAAqBD,YAAYE,MAAM,CAAC,CAACC,cAAcV;QAC3D,MAAMW,aAAaX,KAAK,CAAC,EAAE;QAC3B,MAAMY,cAAcD,WAAWE,UAAU,CAAC;QAC1C,MAAMC,uBAAuBH,WAAWE,UAAU,CAAC;QAEnD,IAAID,eAAeE,sBAAsB;YACvC,OAAOJ;QACT;QAEA,MAAMK,aAAaC,iBAAiBL,YAAYM,IAAI;QAEpD,IAAI,CAACP,aAAaQ,cAAc,CAACH,aAAa;gBACjBT;YAA3BI,YAAY,CAACK,WAAW,GAAGT,CAAAA,mCAAAA,oBAAoB,CAACS,WAAW,cAAhCT,8CAAAA,mCAAoC;QACjE;QAEA,OAAOI;IACT,GAAG,CAAC;IAEJ,OAAO;QAAE,GAAGF,kBAAkB;QAAE,GAAGH,oBAAoB;IAAC;AAC1D;AAEA,6DAA6D;AAC7D,MAAMc,YAAY;AAClB,4DAA4D;AAC5D,MAAMC,gBAAgB;AAEtB,SAASJ,iBAAiBK,KAAa;IACrC,MAAMC,IAAIH,UAAUjB,IAAI,CAACmB,UAAUD,cAAclB,IAAI,CAACmB;IAEtD,IAAI,CAACC,GAAG;QACN,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEF,MAAM,CAAC;IACvE;IAEA,OAAO;QACLJ,MAAMK,CAAC,CAAC,EAAE,IAAI;QACdE,SAASF,CAAC,CAAC,EAAE,IAAI;QACjBG,MAAMH,CAAC,CAAC,EAAE,IAAI;IAChB;AACF"}
1
+ {"version":3,"sources":["../src/getDependencies.ts"],"sourcesContent":["type PackageDependencies = { [dependencyName: string]: string };\n\nconst IMPORT_PATH_REGEX = /from ['\"](.*?)['\"];/g;\n\nfunction matchAll(str: string, re: RegExp) {\n let match: RegExpExecArray | null = null;\n const matches: RegExpExecArray[] = [];\n\n while ((match = re.exec(str))) {\n matches.push(match);\n }\n\n return matches;\n}\n\n/**\n *\n * @param fileContent - code\n * @param requiredDependencies - dependencies that will always be included in package.json\n * @param optionalDependencies - whose versions will override those found in the code\n * @returns - Map of dependencies and their versions to include in package.json\n */\nexport const getDependencies = (\n fileContent: string,\n requiredDependencies: PackageDependencies,\n optionalDependencies: PackageDependencies,\n) => {\n const importPaths = matchAll(fileContent, IMPORT_PATH_REGEX);\n\n const dependenciesInCode = importPaths.reduce((dependencies, match) => {\n const importPath = match[1];\n const isReactPath = importPath.startsWith('react/');\n const isRelativeImportPath = importPath.startsWith('.');\n\n if (isReactPath || isRelativeImportPath) {\n return dependencies;\n }\n\n const dependency = parsePackageName(importPath).name;\n\n if (!dependencies.hasOwnProperty(dependency)) {\n dependencies[dependency] = optionalDependencies[dependency] ?? 'latest';\n }\n\n return dependencies;\n }, {} as PackageDependencies);\n\n return { ...dependenciesInCode, ...requiredDependencies };\n};\n\n// Parsed a scoped package name into name, version, and path.\nconst RE_SCOPED = /^(@[^\\/]+\\/[^@\\/]+)(?:@([^\\/]+))?(\\/.*)?$/;\n// Parsed a non-scoped package name into name, version, path\nconst RE_NON_SCOPED = /^([^@\\/]+)(?:@([^\\/]+))?(\\/.*)?$/;\n\nfunction parsePackageName(input: string) {\n const m = RE_SCOPED.exec(input) || RE_NON_SCOPED.exec(input);\n\n if (!m) {\n throw new Error(`[parse-package-name] invalid package name: ${input}`);\n }\n\n return {\n name: m[1] || '',\n version: m[2] || 'latest',\n path: m[3] || '',\n };\n}\n"],"names":["getDependencies","IMPORT_PATH_REGEX","matchAll","str","re","match","matches","exec","push","fileContent","requiredDependencies","optionalDependencies","importPaths","dependenciesInCode","reduce","dependencies","importPath","isReactPath","startsWith","isRelativeImportPath","dependency","parsePackageName","name","hasOwnProperty","RE_SCOPED","RE_NON_SCOPED","input","m","Error","version","path"],"mappings":";;;;+BAsBaA;;;eAAAA;;;AApBb,MAAMC,oBAAoB;AAE1B,SAASC,SAASC,GAAW,EAAEC,EAAU;IACvC,IAAIC,QAAgC;IACpC,MAAMC,UAA6B,EAAE;IAErC,MAAQD,QAAQD,GAAGG,IAAI,CAACJ,KAAO;QAC7BG,QAAQE,IAAI,CAACH;IACf;IAEA,OAAOC;AACT;AASO,MAAMN,kBAAkB,CAC7BS,aACAC,sBACAC;IAEA,MAAMC,cAAcV,SAASO,aAAaR;IAE1C,MAAMY,qBAAqBD,YAAYE,MAAM,CAAC,CAACC,cAAcV;QAC3D,MAAMW,aAAaX,KAAK,CAAC,EAAE;QAC3B,MAAMY,cAAcD,WAAWE,UAAU,CAAC;QAC1C,MAAMC,uBAAuBH,WAAWE,UAAU,CAAC;QAEnD,IAAID,eAAeE,sBAAsB;YACvC,OAAOJ;QACT;QAEA,MAAMK,aAAaC,iBAAiBL,YAAYM,IAAI;QAEpD,IAAI,CAACP,aAAaQ,cAAc,CAACH,aAAa;gBACjBT;YAA3BI,YAAY,CAACK,WAAW,GAAGT,CAAAA,mCAAAA,oBAAoB,CAACS,WAAW,cAAhCT,8CAAAA,mCAAoC;QACjE;QAEA,OAAOI;IACT,GAAG,CAAC;IAEJ,OAAO;QAAE,GAAGF,kBAAkB;QAAE,GAAGH,oBAAoB;IAAC;AAC1D;AAEA,6DAA6D;AAC7D,MAAMc,YAAY;AAClB,4DAA4D;AAC5D,MAAMC,gBAAgB;AAEtB,SAASJ,iBAAiBK,KAAa;IACrC,MAAMC,IAAIH,UAAUjB,IAAI,CAACmB,UAAUD,cAAclB,IAAI,CAACmB;IAEtD,IAAI,CAACC,GAAG;QACN,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEF,OAAO;IACvE;IAEA,OAAO;QACLJ,MAAMK,CAAC,CAAC,EAAE,IAAI;QACdE,SAASF,CAAC,CAAC,EAAE,IAAI;QACjBG,MAAMH,CAAC,CAAC,EAAE,IAAI;IAChB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"rangeMappings":"","mappings":""}
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/preset/preset.ts"],"sourcesContent":["import { webpack, WebpackFinalConfig, WebpackFinalOptions } from '../webpack';\n\nexport function webpackFinal(config: WebpackFinalConfig, options: WebpackFinalOptions) {\n return webpack(config, options);\n}\n"],"names":["webpackFinal","config","options","webpack"],"rangeMappings":";;;;;;;;;;;;;","mappings":";;;;+BAEgBA;;;eAAAA;;;yBAFiD;AAE1D,SAASA,aAAaC,MAA0B,EAAEC,OAA4B;IACnF,OAAOC,IAAAA,gBAAO,EAACF,QAAQC;AACzB"}
1
+ {"version":3,"sources":["../src/preset/preset.ts"],"sourcesContent":["import { webpack, WebpackFinalConfig, WebpackFinalOptions } from '../webpack';\n\nexport function webpackFinal(config: WebpackFinalConfig, options: WebpackFinalOptions) {\n return webpack(config, options);\n}\n"],"names":["webpackFinal","config","options","webpack"],"mappings":";;;;+BAEgBA;;;eAAAA;;;yBAFiD;AAE1D,SAASA,aAAaC,MAA0B,EAAEC,OAA4B;IACnF,OAAOC,IAAAA,gBAAO,EAACF,QAAQC;AACzB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type { Parameters } from '@storybook/react';\nimport type { StoryContextForEnhancers } from '@storybook/csf';\n\nimport { withExportToSandboxButton } from '../decorators/with-export-to-sandbox-button';\n\nexport const decorators = [withExportToSandboxButton];\n\nexport const parameters: Parameters = {\n docs: {\n source: {\n /**\n * Override source code shown within \"Show Code\" Docs tab.\n * @see https://github.com/storybookjs/storybook/blob/release-6-5/addons/docs/docs/recipes.md#customizing-source-snippets\n */\n transform: (source: string, storyContext: StoryContextForEnhancers) => {\n // This config renders story source generated via `fullSource` parameter that is being added by @fluentui/babel-preset-storybook-full-source plugin, which is registered as part of this preset\n return storyContext.parameters.fullSource;\n },\n },\n },\n};\n"],"names":["decorators","parameters","withExportToSandboxButton","docs","source","transform","storyContext","fullSource"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAKaA,UAAU;eAAVA;;IAEAC,UAAU;eAAVA;;;2CAJ6B;AAEnC,MAAMD,aAAa;IAACE,oDAAyB;CAAC;AAE9C,MAAMD,aAAyB;IACpCE,MAAM;QACJC,QAAQ;YACN;;;OAGC,GACDC,WAAW,CAACD,QAAgBE;gBAC1B,+LAA+L;gBAC/L,OAAOA,aAAaL,UAAU,CAACM,UAAU;YAC3C;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/preset/preview.ts"],"sourcesContent":["import type { Parameters } from '@storybook/react';\nimport type { StoryContextForEnhancers } from '@storybook/csf';\n\nimport { withExportToSandboxButton } from '../decorators/with-export-to-sandbox-button';\n\nexport const decorators = [withExportToSandboxButton];\n\nexport const parameters: Parameters = {\n docs: {\n source: {\n /**\n * Override source code shown within \"Show Code\" Docs tab.\n * @see https://github.com/storybookjs/storybook/blob/release-6-5/addons/docs/docs/recipes.md#customizing-source-snippets\n */\n transform: (source: string, storyContext: StoryContextForEnhancers) => {\n // This config renders story source generated via `fullSource` parameter that is being added by @fluentui/babel-preset-storybook-full-source plugin, which is registered as part of this preset\n return storyContext.parameters.fullSource;\n },\n },\n },\n};\n"],"names":["decorators","parameters","withExportToSandboxButton","docs","source","transform","storyContext","fullSource"],"mappings":";;;;;;;;;;;IAKaA,UAAU;eAAVA;;IAEAC,UAAU;eAAVA;;;2CAJ6B;AAEnC,MAAMD,aAAa;IAACE,oDAAyB;CAAC;AAE9C,MAAMD,aAAyB;IACpCE,MAAM;QACJC,QAAQ;YACN;;;OAGC,GACDC,WAAW,CAACD,QAAgBE;gBAC1B,+LAA+L;gBAC/L,OAAOA,aAAaL,UAAU,CAACM,UAAU;YAC3C;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/public-types.ts"],"sourcesContent":["/**\n * NOTE:\n * Don't import anything from source code in this file !!\n *\n * only pure API definitions of addon are allowed to live here, that are used both internal and for external storybook `Parameter` type extensions\n */\ninterface ParametersConfig {\n optionalDependencies?: Record<string, string>;\n requiredDependencies?: Record<string, string>;\n provider: 'codesandbox-cloud' | 'codesandbox-browser' | 'stackblitz-cloud';\n bundler: 'vite' | 'cra';\n}\n\nexport interface ParametersExtension {\n exportToSandbox?: ParametersConfig;\n}\n\nexport interface PresetConfig {\n importMappings: import('@fluentui/babel-preset-storybook-full-source').BabelPluginOptions;\n webpackRule?: import('webpack').RuleSetRule;\n babelLoaderOptionsUpdater?: (value: import('@babel/core').TransformOptions) => typeof value;\n}\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA;;;;;CAKC"}
1
+ {"version":3,"sources":["../src/public-types.ts"],"sourcesContent":["/**\n * NOTE:\n * Don't import anything from source code in this file !!\n *\n * only pure API definitions of addon are allowed to live here, that are used both internal and for external storybook `Parameter` type extensions\n */\ninterface ParametersConfig {\n optionalDependencies?: Record<string, string>;\n requiredDependencies?: Record<string, string>;\n provider: 'codesandbox-cloud' | 'codesandbox-browser' | 'stackblitz-cloud';\n bundler: 'vite' | 'cra';\n}\n\nexport interface ParametersExtension {\n exportToSandbox?: ParametersConfig;\n}\n\nexport interface PresetConfig {\n importMappings: import('@fluentui/babel-preset-storybook-full-source').BabelPluginOptions;\n webpackRule?: import('webpack').RuleSetRule;\n babelLoaderOptionsUpdater?: (value: import('@babel/core').TransformOptions) => typeof value;\n}\n"],"names":[],"mappings":"AAAA;;;;;CAKC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sandbox-factory.ts"],"sourcesContent":["import { getParameters } from 'codesandbox-import-utils/lib/api/define';\n\nimport { scaffold } from './sandbox-scaffold';\nimport { addHiddenInput, prepareData, prepareSandboxContainer, type Data } from './sandbox-utils';\nimport { StoryContext } from './types';\n\nconst defaultFileToPreview = encodeURIComponent('src/example.tsx');\n\nconst actionConfig = {\n 'codesandbox-cloud': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'codesandbox-browser': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'stackblitz-cloud': {\n label: 'Stackblitz',\n factory: (files: Record<string, string>, config: Data) => openStackblitz({ files, ...config }),\n },\n};\n\nexport function addDemoActionButton(context: StoryContext) {\n const { container, cssClasses } = prepareSandboxContainer(context);\n const config = prepareData(context);\n if (!config) {\n throw new Error('issues with data');\n }\n\n addActionButton(container, config, cssClasses);\n}\n\nfunction addActionButton(container: HTMLElement, config: Data, classList: string[]) {\n const files = scaffold[config.bundler](config);\n const action = actionConfig[config.provider];\n\n const button = document.createElement('button');\n button.classList.add(...classList);\n button.textContent = `Open in ${action.label}`;\n\n container?.prepend(button);\n\n button.addEventListener('click', _ev => {\n action.factory(files, config);\n });\n}\n\n/**\n *\n * @see https://developer.stackblitz.com/docs/platform/post-api/\n */\nfunction openStackblitz(data: { files: Record<string, string> } & Data) {\n const { files, description, title } = data;\n const form = document.createElement('form');\n form.method = 'post';\n form.target = '_blank';\n form.action = `https://stackblitz.com/run?file=${defaultFileToPreview}`;\n // node template - boots web-container\n addHiddenInput(form, 'project[template]', 'node');\n addHiddenInput(form, 'project[title]', title);\n addHiddenInput(form, 'project[description]', `# ${description}`);\n\n Object.keys(files).forEach(key => {\n const value = files[key];\n addHiddenInput(form, `project[files][${key}]`, value);\n });\n\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n\n/**\n *\n * @see https://codesandbox.io/docs/learn/sandboxes/cli-api#define-api\n */\nfunction openCodeSandbox({ files, provider }: { files: Record<string, string> } & Data) {\n const normalizedFilesApi = Object.entries(files).reduce((acc, current) => {\n acc[current[0]] = { isBinary: false, content: current[1] };\n return acc;\n }, {} as Record<string, { content: string; isBinary: boolean }>);\n\n const env = provider === 'codesandbox-cloud' ? 'server' : 'browser';\n const parameters = getParameters({ files: normalizedFilesApi });\n\n const form = document.createElement('form');\n form.method = 'POST';\n form.target = '_blank';\n form.action = `https://codesandbox.io/api/v1/sandboxes/define?environment=${env}`;\n\n addHiddenInput(form, 'parameters', parameters);\n addHiddenInput(form, 'query', `file=${defaultFileToPreview}`);\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n"],"names":["addDemoActionButton","defaultFileToPreview","encodeURIComponent","actionConfig","label","factory","files","config","openCodeSandbox","openStackblitz","context","container","cssClasses","prepareSandboxContainer","prepareData","Error","addActionButton","classList","scaffold","bundler","action","provider","button","document","createElement","add","textContent","prepend","addEventListener","_ev","data","description","title","form","method","target","addHiddenInput","Object","keys","forEach","key","value","body","appendChild","submit","removeChild","normalizedFilesApi","entries","reduce","acc","current","isBinary","content","env","parameters","getParameters"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAuBgBA;;;eAAAA;;;wBAvBc;iCAEL;8BACuD;AAGhF,MAAMC,uBAAuBC,mBAAmB;AAEhD,MAAMC,eAAe;IACnB,qBAAqB;QACnBC,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,uBAAuB;QACrBH,OAAO;QACPC,SAAS,CAAC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AAM,kBAAkBD;IACvCI,IAAAA,4BAAc,EAACH,MAAM,wBAAwB,CAAC,EAAE,EAAEF,YAAY,CAAC;IAE/DM,OAAOC,IAAI,CAAChC,OAAOiC,OAAO,CAACC,CAAAA;QACzB,MAAMC,QAAQnC,KAAK,CAACkC,IAAI;QACxBJ,IAAAA,4BAAc,EAACH,MAAM,CAAC,eAAe,EAAEO,IAAI,CAAC,CAAC,EAAEC;IACjD;IAEAlB,SAASmB,IAAI,CAACC,WAAW,CAACV;IAC1BA,KAAKW,MAAM;IACXrB,SAASmB,IAAI,CAACG,WAAW,CAACZ;AAC5B;AAEA;;;CAGC,GACD,SAASzB,gBAAgB,EAAEF,KAAK,EAAEe,QAAQ,EAA4C;IACpF,MAAMyB,qBAAqBT,OAAOU,OAAO,CAACzC,OAAO0C,MAAM,CAAC,CAACC,KAAKC;QAC5DD,GAAG,CAACC,OAAO,CAAC,EAAE,CAAC,GAAG;YAAEC,UAAU;YAAOC,SAASF,OAAO,CAAC,EAAE;QAAC;QACzD,OAAOD;IACT,GAAG,CAAC;IAEJ,MAAMI,MAAMhC,aAAa,sBAAsB,WAAW;IAC1D,MAAMiC,aAAaC,IAAAA,qBAAa,EAAC;QAAEjD,OAAOwC;IAAmB;IAE7D,MAAMb,OAAOV,SAASC,aAAa,CAAC;IACpCS,KAAKC,MAAM,GAAG;IACdD,KAAKE,MAAM,GAAG;IACdF,KAAKb,MAAM,GAAG,CAAC,2DAA2D,EAAEiC,IAAI,CAAC;IAEjFjB,IAAAA,4BAAc,EAACH,MAAM,cAAcqB;IACnClB,IAAAA,4BAAc,EAACH,MAAM,SAAS,CAAC,KAAK,EAAEhC,qBAAqB,CAAC;IAC5DsB,SAASmB,IAAI,CAACC,WAAW,CAACV;IAC1BA,KAAKW,MAAM;IACXrB,SAASmB,IAAI,CAACG,WAAW,CAACZ;AAC5B"}
1
+ {"version":3,"sources":["../src/sandbox-factory.ts"],"sourcesContent":["import { getParameters } from 'codesandbox-import-utils/lib/api/define';\n\nimport { scaffold } from './sandbox-scaffold';\nimport { addHiddenInput, prepareData, prepareSandboxContainer, type Data } from './sandbox-utils';\nimport { StoryContext } from './types';\n\nconst defaultFileToPreview = encodeURIComponent('src/example.tsx');\n\nconst actionConfig = {\n 'codesandbox-cloud': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'codesandbox-browser': {\n label: 'CodeSandbox',\n factory: (files: Record<string, string>, config: Data) => openCodeSandbox({ files, ...config }),\n },\n 'stackblitz-cloud': {\n label: 'Stackblitz',\n factory: (files: Record<string, string>, config: Data) => openStackblitz({ files, ...config }),\n },\n};\n\nexport function addDemoActionButton(context: StoryContext) {\n const { container, cssClasses } = prepareSandboxContainer(context);\n const config = prepareData(context);\n if (!config) {\n throw new Error('issues with data');\n }\n\n addActionButton(container, config, cssClasses);\n}\n\nfunction addActionButton(container: HTMLElement, config: Data, classList: string[]) {\n const files = scaffold[config.bundler](config);\n const action = actionConfig[config.provider];\n\n const button = document.createElement('button');\n button.classList.add(...classList);\n button.textContent = `Open in ${action.label}`;\n\n container?.prepend(button);\n\n button.addEventListener('click', _ev => {\n action.factory(files, config);\n });\n}\n\n/**\n *\n * @see https://developer.stackblitz.com/docs/platform/post-api/\n */\nfunction openStackblitz(data: { files: Record<string, string> } & Data) {\n const { files, description, title } = data;\n const form = document.createElement('form');\n form.method = 'post';\n form.target = '_blank';\n form.action = `https://stackblitz.com/run?file=${defaultFileToPreview}`;\n // node template - boots web-container\n addHiddenInput(form, 'project[template]', 'node');\n addHiddenInput(form, 'project[title]', title);\n addHiddenInput(form, 'project[description]', `# ${description}`);\n\n Object.keys(files).forEach(key => {\n const value = files[key];\n addHiddenInput(form, `project[files][${key}]`, value);\n });\n\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n\n/**\n *\n * @see https://codesandbox.io/docs/learn/sandboxes/cli-api#define-api\n */\nfunction openCodeSandbox({ files, provider }: { files: Record<string, string> } & Data) {\n const normalizedFilesApi = Object.entries(files).reduce((acc, current) => {\n acc[current[0]] = { isBinary: false, content: current[1] };\n return acc;\n }, {} as Record<string, { content: string; isBinary: boolean }>);\n\n const env = provider === 'codesandbox-cloud' ? 'server' : 'browser';\n const parameters = getParameters({ files: normalizedFilesApi });\n\n const form = document.createElement('form');\n form.method = 'POST';\n form.target = '_blank';\n form.action = `https://codesandbox.io/api/v1/sandboxes/define?environment=${env}`;\n\n addHiddenInput(form, 'parameters', parameters);\n addHiddenInput(form, 'query', `file=${defaultFileToPreview}`);\n document.body.appendChild(form);\n form.submit();\n document.body.removeChild(form);\n}\n"],"names":["addDemoActionButton","defaultFileToPreview","encodeURIComponent","actionConfig","label","factory","files","config","openCodeSandbox","openStackblitz","context","container","cssClasses","prepareSandboxContainer","prepareData","Error","addActionButton","classList","scaffold","bundler","action","provider","button","document","createElement","add","textContent","prepend","addEventListener","_ev","data","description","title","form","method","target","addHiddenInput","Object","keys","forEach","key","value","body","appendChild","submit","removeChild","normalizedFilesApi","entries","reduce","acc","current","isBinary","content","env","parameters","getParameters"],"mappings":";;;;+BAuBgBA;;;eAAAA;;;wBAvBc;iCAEL;8BACuD;AAGhF,MAAMC,uBAAuBC,mBAAmB;AAEhD,MAAMC,eAAe;IACnB,qBAAqB;QACnBC,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,uBAAuB;QACrBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBC,gBAAgB;gBAAEF;gBAAO,GAAGC,MAAM;YAAC;IAC/F;IACA,oBAAoB;QAClBH,OAAO;QACPC,SAAS,CAACC,OAA+BC,SAAiBE,eAAe;gBAAEH;gBAAO,GAAGC,MAAM;YAAC;IAC9F;AACF;AAEO,SAASP,oBAAoBU,OAAqB;IACvD,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGC,IAAAA,qCAAuB,EAACH;IAC1D,MA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1BA,KAAKW,MAAM;IACXrB,SAASmB,IAAI,CAACG,WAAW,CAACZ;AAC5B;AAEA;;;CAGC,GACD,SAASzB,gBAAgB,EAAEF,KAAK,EAAEe,QAAQ,EAA4C;IACpF,MAAMyB,qBAAqBT,OAAOU,OAAO,CAACzC,OAAO0C,MAAM,CAAC,CAACC,KAAKC;QAC5DD,GAAG,CAACC,OAAO,CAAC,EAAE,CAAC,GAAG;YAAEC,UAAU;YAAOC,SAASF,OAAO,CAAC,EAAE;QAAC;QACzD,OAAOD;IACT,GAAG,CAAC;IAEJ,MAAMI,MAAMhC,aAAa,sBAAsB,WAAW;IAC1D,MAAMiC,aAAaC,IAAAA,qBAAa,EAAC;QAAEjD,OAAOwC;IAAmB;IAE7D,MAAMb,OAAOV,SAASC,aAAa,CAAC;IACpCS,KAAKC,MAAM,GAAG;IACdD,KAAKE,MAAM,GAAG;IACdF,KAAKb,MAAM,GAAG,CAAC,2DAA2D,EAAEiC,KAAK;IAEjFjB,IAAAA,4BAAc,EAACH,MAAM,cAAcqB;IACnClB,IAAAA,4BAAc,EAACH,MAAM,SAAS,CAAC,KAAK,EAAEhC,sBAAsB;IAC5DsB,SAASmB,IAAI,CAACC,WAAW,CAACV;IAC1BA,KAAKW,MAAM;IACXrB,SAASmB,IAAI,CAACG,WAAW,CAACZ;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sandbox-scaffold.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport type { Data } from './sandbox-utils';\nimport { serializeJson } from './utils';\n\nconst commonDevDeps = { '@types/react': '^17', '@types/react-dom': '^17', typescript: '~4.7.0' };\n\nexport const scaffold = {\n vite: (data: Data): Record<string, string> => {\n if (data.provider === 'codesandbox-browser') {\n throw new Error('vite is not supported on codesandbox-browser');\n }\n\n const base = {\n 'index.html': Vite.getHTML(),\n 'src/App.tsx': Vite.getApp(data),\n 'src/index.tsx': Vite.getRootIndex(),\n 'src/example.tsx': Vite.getExample(data),\n 'tsconfig.json': Vite.getTsconfig(),\n 'tsconfig.node.json': Vite.getTsconfigNode(),\n 'vite.config.ts': Vite.getViteCfg(),\n 'package.json': Vite.getPkgJson(data),\n };\n if (data.provider === 'stackblitz-cloud') {\n Object.assign(base, getStackblitzConfig());\n }\n if (data.provider === 'codesandbox-cloud') {\n Object.assign(base, getCodesandboxConfig('vite'));\n }\n return base;\n },\n cra: (data: Data): Record<string, string> => {\n const base = {\n 'public/index.html': CRA.getHTML(),\n 'src/App.tsx': CRA.getApp(data),\n 'src/index.tsx': CRA.getRootIndex(),\n 'src/example.tsx': CRA.getExample(data),\n 'tsconfig.json': CRA.getTsconfig(),\n 'package.json': CRA.getPkgJson(data),\n };\n if (data.provider === 'stackblitz-cloud') {\n Object.assign(base, getStackblitzConfig());\n }\n if (data.provider === 'codesandbox-cloud') {\n Object.assign(base, getCodesandboxConfig('cra'));\n }\n\n return base;\n },\n};\n\nconst Vite = {\n getHTML: () => dedent`\n <!doctype html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" type=\"image/svg+xml\" href=\"/vite.svg\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Vite + React + TS</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/index.tsx\"></script>\n </body>\n </html>\n `,\n getRootIndex: getIndex,\n getExample,\n getApp,\n getViteCfg: () => {\n return dedent`\n import { defineConfig } from 'vite'\n import react from '@vitejs/plugin-react'\n\n // https://vitejs.dev/config/\n export default defineConfig({\n plugins: [react()],\n })\n `;\n },\n getTsconfigNode: () => {\n return serializeJson({\n compilerOptions: {\n composite: true,\n skipLibCheck: true,\n module: 'ESNext',\n moduleResolution: 'bundler',\n allowSyntheticDefaultImports: true,\n },\n include: ['vite.config.ts'],\n });\n },\n getTsconfig: () => {\n return serializeJson({\n compilerOptions: {\n target: 'ES2020',\n useDefineForClassFields: true,\n lib: ['ES2020', 'DOM', 'DOM.Iterable'],\n module: 'ESNext',\n skipLibCheck: true,\n\n /* Bundler mode */\n moduleResolution: 'node',\n // moduleResolution: 'bundler',\n allowImportingTsExtensions: true,\n resolveJsonModule: true,\n isolatedModules: true,\n noEmit: true,\n jsx: 'react-jsx',\n\n /* Linting */\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noFallthroughCasesInSwitch: true,\n },\n include: ['src'],\n references: [{ path: './tsconfig.node.json' }],\n });\n },\n getPkgJson: (data: Data) => {\n return serializeJson({\n name: 'vite-react-typescript-starter',\n private: true,\n version: '0.0.0',\n type: 'module',\n scripts: {\n dev: 'vite',\n build: 'tsc && vite build',\n preview: 'vite preview',\n },\n dependencies: {\n ...data.dependencies,\n },\n devDependencies: {\n ...commonDevDeps,\n '@vitejs/plugin-react': '^4.2.0',\n vite: '^5.0.0',\n },\n });\n },\n};\n\nconst CRA = {\n getHTML: () => `<div id=\"root\"></div>`,\n getRootIndex: getIndex,\n getExample,\n getApp,\n getTsconfig: () =>\n serializeJson({\n include: ['./src/**/*'],\n compilerOptions: {\n strict: true,\n esModuleInterop: true,\n lib: ['dom', 'es2015'],\n jsx: 'react-jsx',\n },\n }),\n getPkgJson: (data: Data) => {\n return serializeJson({\n main: 'src/index.tsx',\n dependencies: {\n ...data.dependencies,\n },\n devDependencies: {\n ...commonDevDeps,\n 'react-scripts': '^5.0.0',\n '@babel/plugin-proposal-private-property-in-object': 'latest',\n },\n scripts: {\n start: 'react-scripts start',\n build: 'react-scripts build',\n test: 'react-scripts test --env=jsdom',\n eject: 'react-scripts eject',\n },\n browserslist: ['>0.2%', 'not dead', 'not ie <= 11', 'not op_mini all'],\n });\n },\n};\n\nfunction getCodesandboxConfig(kind: 'cra' | 'vite') {\n const startConfig = {\n cra: { command: 'yarn start', preview: { port: 3000 } },\n vite: { command: 'yarn dev', preview: { port: 5173 } },\n };\n return {\n '.devcontainer/devcontainer.json': serializeJson({\n name: 'Devcontainer',\n build: {\n dockerfile: './Dockerfile',\n },\n }),\n '.devcontainer/Dockerfile': `FROM node:16-bullseye`,\n '.codesandbox/tasks.json': serializeJson({\n // These tasks will run in order when initializing your CodeSandbox project.\n setupTasks: [\n {\n name: 'Install Dependencies',\n command: 'yarn install',\n },\n ],\n\n // These tasks can be run from CodeSandbox. Running one will open a log in the app.\n tasks: {\n dev: {\n name: 'dev',\n runAtStart: true,\n ...startConfig[kind],\n },\n build: {\n name: 'build',\n command: 'yarn build',\n runAtStart: false,\n },\n preview: {\n name: 'preview',\n command: 'yarn preview',\n runAtStart: false,\n },\n },\n }),\n };\n}\n\nfunction getStackblitzConfig() {\n return {\n '.stackblitzrc': serializeJson({}),\n };\n}\n\nfunction getIndex() {\n return dedent`\n import * as React from 'react';\n import { createRoot } from 'react-dom/client';\n import App from './App';\n\n const root = createRoot(document.getElementById('root') as HTMLElement);\n\n root.render(\n <React.StrictMode>\n <App />\n </React.StrictMode>,\n );\n `;\n}\n\nfunction getExample(demoData: Data) {\n return demoData.storyFile;\n}\n\nfunction getApp(data: Data) {\n const code = dedent`\n import { FluentProvider, webLightTheme } from '@fluentui/react-components';\n import { ${data.storyExportToken} as Example } from './example';\n\n const App = () => {\n return (\n <FluentProvider theme={webLightTheme}>\n <Example />\n </FluentProvider>\n );\n };\n\n export default App;\n `;\n\n return code;\n}\n"],"names":["scaffold","commonDevDeps","typescript","vite","data","provider","Error","base","Vite","getHTML","getApp","getRootIndex","getExample","getTsconfig","getTsconfigNode","getViteCfg","getPkgJson","Object","assign","getStackblitzConfig","getCodesandboxConfig","cra","CRA","dedent","getIndex","serializeJson","compilerOptions","composite","skipLibCheck","module","moduleResolution","allowSyntheticDefaultImports","include","target","useDefineForClassFields","lib","allowImportingTsExtensions","resolveJsonModule","isolatedModules","noEmit","jsx","strict","noUnusedLocals","noUnusedParameters","noFallthroughCasesInSwitch","references","path","name","private","version","type","scripts","dev","build","preview","dependencies","devDependencies","esModuleInterop","main","start","test","eject","browserslist","kind","startConfig","command","port","dockerfile","setupTasks","tasks","runAtStart","demoData","storyFile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L,MAAM;oBACNuB,YAAY;oBACZ,GAAGN,WAAW,CAACD,KAAK;gBACtB;gBACAV,OAAO;oBACLN,MAAM;oBACNkB,SAAS;oBACTK,YAAY;gBACd;gBACAhB,SAAS;oBACPP,MAAM;oBACNkB,SAAS;oBACTK,YAAY;gBACd;YACF;QACF;IACF;AACF;AAEA,SAASnD;IACP,OAAO;QACL,iBAAiBM,IAAAA,oBAAa,EAAC,CAAC;IAClC;AACF;AAEA,SAASD;IACP,OAAOD,IAAAA,eAAM,CAAA,CAAC;;;;;;;;;;;;EAYd,CAAC;AACH;AAEA,SAASX,WAAW2D,QAAc;IAChC,OAAOA,SAASC,SAAS;AAC3B;AAEA,SAAS9D,OAAON,IAAU;IACxB,MAAMqE,OAAOlD,IAAAA,eAAM,CAAA,CAAC;;aAET,EAAEnB,KAAKsE,gBAAgB,CAAC;;;;;;;;;;;EAWnC,CAAC;IAED,OAAOD;AACT"}
1
+ {"version":3,"sources":["../src/sandbox-scaffold.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport type { Data } from './sandbox-utils';\nimport { serializeJson } from './utils';\n\nconst commonDevDeps = { '@types/react': '^17', '@types/react-dom': '^17', typescript: '~4.7.0' };\n\nexport const scaffold = {\n vite: (data: Data): Record<string, string> => {\n if (data.provider === 'codesandbox-browser') {\n throw new Error('vite is not supported on codesandbox-browser');\n }\n\n const base = {\n 'index.html': Vite.getHTML(),\n 'src/App.tsx': Vite.getApp(data),\n 'src/index.tsx': Vite.getRootIndex(),\n 'src/example.tsx': Vite.getExample(data),\n 'tsconfig.json': Vite.getTsconfig(),\n 'tsconfig.node.json': Vite.getTsconfigNode(),\n 'vite.config.ts': Vite.getViteCfg(),\n 'package.json': Vite.getPkgJson(data),\n };\n if (data.provider === 'stackblitz-cloud') {\n Object.assign(base, getStackblitzConfig());\n }\n if (data.provider === 'codesandbox-cloud') {\n Object.assign(base, getCodesandboxConfig('vite'));\n }\n return base;\n },\n cra: (data: Data): Record<string, string> => {\n const base = {\n 'public/index.html': CRA.getHTML(),\n 'src/App.tsx': CRA.getApp(data),\n 'src/index.tsx': CRA.getRootIndex(),\n 'src/example.tsx': CRA.getExample(data),\n 'tsconfig.json': CRA.getTsconfig(),\n 'package.json': CRA.getPkgJson(data),\n };\n if (data.provider === 'stackblitz-cloud') {\n Object.assign(base, getStackblitzConfig());\n }\n if (data.provider === 'codesandbox-cloud') {\n Object.assign(base, getCodesandboxConfig('cra'));\n }\n\n return base;\n },\n};\n\nconst Vite = {\n getHTML: () => dedent`\n <!doctype html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" type=\"image/svg+xml\" href=\"/vite.svg\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Vite + React + TS</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/index.tsx\"></script>\n </body>\n </html>\n `,\n getRootIndex: getIndex,\n getExample,\n getApp,\n getViteCfg: () => {\n return dedent`\n import { defineConfig } from 'vite'\n import react from '@vitejs/plugin-react'\n\n // https://vitejs.dev/config/\n export default defineConfig({\n plugins: [react()],\n })\n `;\n },\n getTsconfigNode: () => {\n return serializeJson({\n compilerOptions: {\n composite: true,\n skipLibCheck: true,\n module: 'ESNext',\n moduleResolution: 'bundler',\n allowSyntheticDefaultImports: true,\n },\n include: ['vite.config.ts'],\n });\n },\n getTsconfig: () => {\n return serializeJson({\n compilerOptions: {\n target: 'ES2020',\n useDefineForClassFields: true,\n lib: ['ES2020', 'DOM', 'DOM.Iterable'],\n module: 'ESNext',\n skipLibCheck: true,\n\n /* Bundler mode */\n moduleResolution: 'node',\n // moduleResolution: 'bundler',\n allowImportingTsExtensions: true,\n resolveJsonModule: true,\n isolatedModules: true,\n noEmit: true,\n jsx: 'react-jsx',\n\n /* Linting */\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noFallthroughCasesInSwitch: true,\n },\n include: ['src'],\n references: [{ path: './tsconfig.node.json' }],\n });\n },\n getPkgJson: (data: Data) => {\n return serializeJson({\n name: 'vite-react-typescript-starter',\n private: true,\n version: '0.0.0',\n type: 'module',\n scripts: {\n dev: 'vite',\n build: 'tsc && vite build',\n preview: 'vite preview',\n },\n dependencies: {\n ...data.dependencies,\n },\n devDependencies: {\n ...commonDevDeps,\n '@vitejs/plugin-react': '^4.2.0',\n vite: '^5.0.0',\n },\n });\n },\n};\n\nconst CRA = {\n getHTML: () => `<div id=\"root\"></div>`,\n getRootIndex: getIndex,\n getExample,\n getApp,\n getTsconfig: () =>\n serializeJson({\n include: ['./src/**/*'],\n compilerOptions: {\n strict: true,\n esModuleInterop: true,\n lib: ['dom', 'es2015'],\n jsx: 'react-jsx',\n },\n }),\n getPkgJson: (data: Data) => {\n return serializeJson({\n main: 'src/index.tsx',\n dependencies: {\n ...data.dependencies,\n },\n devDependencies: {\n ...commonDevDeps,\n 'react-scripts': '^5.0.0',\n '@babel/plugin-proposal-private-property-in-object': 'latest',\n },\n scripts: {\n start: 'react-scripts start',\n build: 'react-scripts build',\n test: 'react-scripts test --env=jsdom',\n eject: 'react-scripts eject',\n },\n browserslist: ['>0.2%', 'not dead', 'not ie <= 11', 'not op_mini all'],\n });\n },\n};\n\nfunction getCodesandboxConfig(kind: 'cra' | 'vite') {\n const startConfig = {\n cra: { command: 'yarn start', preview: { port: 3000 } },\n vite: { command: 'yarn dev', preview: { port: 5173 } },\n };\n return {\n '.devcontainer/devcontainer.json': serializeJson({\n name: 'Devcontainer',\n build: {\n dockerfile: './Dockerfile',\n },\n }),\n '.devcontainer/Dockerfile': `FROM node:16-bullseye`,\n '.codesandbox/tasks.json': serializeJson({\n // These tasks will run in order when initializing your CodeSandbox project.\n setupTasks: [\n {\n name: 'Install Dependencies',\n command: 'yarn install',\n },\n ],\n\n // These tasks can be run from CodeSandbox. Running one will open a log in the app.\n tasks: {\n dev: {\n name: 'dev',\n runAtStart: true,\n ...startConfig[kind],\n },\n build: {\n name: 'build',\n command: 'yarn build',\n runAtStart: false,\n },\n preview: {\n name: 'preview',\n command: 'yarn preview',\n runAtStart: false,\n },\n },\n }),\n };\n}\n\nfunction getStackblitzConfig() {\n return {\n '.stackblitzrc': serializeJson({}),\n };\n}\n\nfunction getIndex() {\n return dedent`\n import * as React from 'react';\n import { createRoot } from 'react-dom/client';\n import App from './App';\n\n const root = createRoot(document.getElementById('root') as HTMLElement);\n\n root.render(\n <React.StrictMode>\n <App />\n </React.StrictMode>,\n );\n `;\n}\n\nfunction getExample(demoData: Data) {\n return demoData.storyFile;\n}\n\nfunction getApp(data: Data) {\n const code = dedent`\n import { FluentProvider, webLightTheme } from '@fluentui/react-components';\n import { ${data.storyExportToken} as Example } from './example';\n\n const App = () => {\n return (\n <FluentProvider theme={webLightTheme}>\n <Example />\n </FluentProvider>\n );\n };\n\n export default App;\n `;\n\n return code;\n}\n"],"names":["scaffold","commonDevDeps","typescript","vite","data","provider","Error","base","Vite","getHTML","getApp","getRootIndex","getExample","getTsconfig","getTsconfigNode","getViteCfg","getPkgJson","Object","assign","getStackblitzConfig","getCodesandboxConfig","cra","CRA","dedent","getIndex","serializeJson","compilerOptions","composite","skipLibCheck","module","moduleResolution","allowSyntheticDefaultImports","include","target","useDefineForClassFields","lib","allowImportingTsExtensions","resolveJsonModule","isolatedModules","noEmit","jsx","strict","noUnusedLocals","noUnusedParameters","noFallthroughCasesInSwitch","references","path","name","private","version","type","scripts","dev","build","preview","dependencies","devDependencies","esModuleInterop","main","start","test","eject","browserslist","kind","startConfig","command","port","dockerfile","setupTasks","tasks","runAtStart","demoData","storyFile","code","storyExportToken"],"mappings":";;;;+BAOaA;;;eAAAA;;;;iEAPM;uBAGW;AAE9B,MAAMC,gBAAgB;IAAE,gBAAgB;IAAO,oBAAoB;IAAOC,YAAY;AAAS;AAExF,MAAMF,WAAW;IACtBG,MAAM,CAACC;QACL,IAAIA,KAAKC,QAAQ,KAAK,uBAAuB;YAC3C,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAMC,OAAO;YAC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Content":["import dedent from 'dedent';\n\nimport { getDependencies } from './getDependencies';\nimport { StoryContext, ParametersExtension } from './types';\n\ntype ParametersConfig = NonNullable<ParametersExtension['exportToSandbox']>;\n\nexport function addHiddenInput(form: HTMLFormElement, name: string, value: string) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n form.appendChild(input);\n}\n\nexport function prepareSandboxContainer(context: StoryContext) {\n const docsSelector = `#anchor--${context.id} .docs-story`;\n const rootElement = document.querySelector(docsSelector);\n\n if (!rootElement) {\n throw new Error(`css selector: ${docsSelector}, doesn't exist `);\n }\n\n const showCodeButton = rootElement.querySelector('.docblock-code-toggle');\n const container = showCodeButton?.parentElement;\n\n if (!container) {\n throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);\n }\n\n const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');\n\n // remove button if it already existed\n const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);\n ourButtons.forEach(node => node.remove());\n\n return {\n container,\n cssClasses: classList,\n };\n}\n\nconst addonConfigDefaults = { requiredDependencies: {}, optionalDependencies: {} };\nexport type Data = Pick<Required<ParametersConfig>, 'provider' | 'bundler'> & {\n storyFile: string;\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n storyExportToken: string;\n dependencies: Record<string, string>;\n title: string;\n description: string;\n};\n\nexport function prepareData(context: StoryContext): Data | null {\n if (!context.parameters.exportToSandbox) {\n throw new Error('exportToSandbox config parameter cannot be empty');\n }\n\n const addonConfig: Required<ParametersConfig> = {\n ...addonConfigDefaults,\n ...context.parameters.exportToSandbox,\n };\n const { provider, bundler } = addonConfig;\n const storyFile = context.parameters?.fullSource;\n\n if (!storyFile) {\n console.error(\n dedent`Export to Sandbox Addon: Couldn't find source for story ${context.title}. Did you install the babel plugin?`,\n );\n return null;\n }\n\n const { requiredDependencies, optionalDependencies } = addonConfig;\n const dependencies = getDependencies(storyFile, requiredDependencies, optionalDependencies);\n\n const title = 'FluentUI React v9';\n const description = `Story demo: ${context.title} - ${context.name}`;\n\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n const storyExportToken = context.originalStoryFn.name.split('_stories_').slice(-1).pop();\n if (!storyExportToken) {\n throw new Error('issues processing story export token');\n }\n\n const demoData = {\n storyFile,\n storyExportToken,\n provider,\n bundler,\n dependencies,\n title,\n description,\n };\n\n return demoData;\n}\n"],"names":["addHiddenInput","prepareData","prepareSandboxContainer","form","name","value","input","document","createElement","type","appendChild","context","docsSelector","id","rootElement","querySelector","Error","showCodeButton","container","parentElement","classList","split","ourButtons","querySelectorAll","forEach","node","remove","cssClasses","addonConfigDefaults","requiredDependencies","optionalDependencies","parameters","exportToSandbox","addonConfig","provider","bundler","storyFile","fullSource","console","error","dedent","title","dependencies","getDependencies","description","storyExportToken","originalStoryFn","slice","pop","demoData"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAOgBA,cAAc;eAAdA;;IAkDAC,WAAW;eAAXA;;IA1CAC,uBAAuB;eAAvBA;;;;iEAfG;iCAEa;AAKzB,SAASF,eAAeG,IAAqB,EAAEC,IAAY,EAAEC,KAAa;IAC/E,MAAMC,QAAQC,SAASC,aAAa,CAAC;IACrCF,MAAMG,IAAI,GAAG;IACbH,MAAMF,IAAI,GAAGA;IACbE,MAAMD,KAAK,GAAGA;IACdF,KAAKO,WAAW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C;QAErH,OAAO;IACT;IAEA,MAAM,EAAEZ,oBAAoB,EAAEC,oBAAoB,EAAE,GAAGG;IACvD,MAAMS,eAAeC,IAAAA,gCAAe,EAACP,WAAWP,sBAAsBC;IAEtE,MAAMW,QAAQ;IACd,MAAMG,cAAc,CAAC,YAAY,EAAEjC,QAAQ8B,KAAK,CAAC,GAAG,EAAE9B,QAAQP,IAAI,CAAC,CAAC;IAEpE,2EAA2E;IAC3E,kEAAkE;IAClE,mEAAmE;IACnE,oFAAoF;IACpF,yBAAyB;IACzB,qFAAqF;IACrF,MAAMyC,mBAAmBlC,QAAQmC,eAAe,CAAC1C,IAAI,CAACiB,KAAK,CAAC,aAAa0B,KAAK,CAAC,CAAC,GAAGC,GAAG;IACtF,IAAI,CAACH,kBAAkB;QACrB,MAAM,IAAI7B,MAAM;IAClB;IAEA,MAAMiC,WAAW;QACfb;QACAS;QACAX;QACAC;QACAO;QACAD;QACAG;IACF;IAEA,OAAOK;AACT"}
1
+ {"version":3,"sources":["../src/sandbox-utils.ts"],"sourcesContent":["import dedent from 'dedent';\n\nimport { getDependencies } from './getDependencies';\nimport { StoryContext, ParametersExtension } from './types';\n\ntype ParametersConfig = NonNullable<ParametersExtension['exportToSandbox']>;\n\nexport function addHiddenInput(form: HTMLFormElement, name: string, value: string) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n form.appendChild(input);\n}\n\nexport function prepareSandboxContainer(context: StoryContext) {\n const docsSelector = `#anchor--${context.id} .docs-story`;\n const rootElement = document.querySelector(docsSelector);\n\n if (!rootElement) {\n throw new Error(`css selector: ${docsSelector}, doesn't exist `);\n }\n\n const showCodeButton = rootElement.querySelector('.docblock-code-toggle');\n const container = showCodeButton?.parentElement;\n\n if (!container) {\n throw new Error(`css selector: '.docblock-code-toggle', doesn't exist `);\n }\n\n const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');\n\n // remove button if it already existed\n const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);\n ourButtons.forEach(node => node.remove());\n\n return {\n container,\n cssClasses: classList,\n };\n}\n\nconst addonConfigDefaults = { requiredDependencies: {}, optionalDependencies: {} };\nexport type Data = Pick<Required<ParametersConfig>, 'provider' | 'bundler'> & {\n storyFile: string;\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n storyExportToken: string;\n dependencies: Record<string, string>;\n title: string;\n description: string;\n};\n\nexport function prepareData(context: StoryContext): Data | null {\n if (!context.parameters.exportToSandbox) {\n throw new Error('exportToSandbox config parameter cannot be empty');\n }\n\n const addonConfig: Required<ParametersConfig> = {\n ...addonConfigDefaults,\n ...context.parameters.exportToSandbox,\n };\n const { provider, bundler } = addonConfig;\n const storyFile = context.parameters?.fullSource;\n\n if (!storyFile) {\n console.error(\n dedent`Export to Sandbox Addon: Couldn't find source for story ${context.title}. Did you install the babel plugin?`,\n );\n return null;\n }\n\n const { requiredDependencies, optionalDependencies } = addonConfig;\n const dependencies = getDependencies(storyFile, requiredDependencies, optionalDependencies);\n\n const title = 'FluentUI React v9';\n const description = `Story demo: ${context.title} - ${context.name}`;\n\n // use originalStoryFn because users can override the `storyName` property.\n // We need the name of the exported function, not the actual story\n // https://github.com/microsoft/fluentui-storybook-addons/issues/12\n // originalStoryFn.name someties looks like this: ProgressBarDefault_stories_Default\n // just get the \"Default\"\n // @TODO - im not sure this is still needed, wasn't able to repro. Can we remove it ?\n const storyExportToken = context.originalStoryFn.name.split('_stories_').slice(-1).pop();\n if (!storyExportToken) {\n throw new Error('issues processing story export token');\n }\n\n const demoData = {\n storyFile,\n storyExportToken,\n provider,\n bundler,\n dependencies,\n title,\n description,\n };\n\n return demoData;\n}\n"],"names":["addHiddenInput","prepareData","prepareSandboxContainer","form","name","value","input","document","createElement","type","appendChild","context","docsSelector","id","rootElement","querySelector","Error","showCodeButton","container","parentElement","classList","split","ourButtons","querySelectorAll","forEach","node","remove","cssClasses","addonConfigDefaults","requiredDependencies","optionalDependencies","parameters","exportToSandbox","addonConfig","provider","bundler","storyFile","fullSource","console","error","dedent","title","dependencies","getDependencies","description","storyExportToken","originalStoryFn","slice","pop","demoData"],"mappings":";;;;;;;;;;;IAOgBA,cAAc;eAAdA;;IAkDAC,WAAW;eAAXA;;IA1CAC,uBAAuB;eAAvBA;;;;iEAfG;iCAEa;AAKzB,SAASF,eAAeG,IAAqB,EAAEC,IAAY,EAAEC,KAAa;IAC/E,MAAMC,QAAQC,SAASC,aAAa,CAAC;IACrCF,MAAMG,IAAI,GAAG;IACbH,MAAMF,IAAI,GAAGA;IACbE,MAAMD,KAAK,GAAGA;IACdF,KAAKO,WAAW,CAACJ;AACnB;AAEO,SAASJ,wBAAwBS,OAAqB;IAC3D,MAAMC,eAAe,CAAC,SAAS,EAAED,QAAQE,EAAE,CAAC,YAAY,CAAC;IACzD,MAAMC,cAAcP,SAASQ,aAAa,CAACH;IAE3C,IAAI,CAACE,aAAa;QAChB,MAAM,IAAIE,MAAM,CAAC,cAAc,EAAEJ,aAAa,gBAAgB,CAAC;IACjE;IAEA,MAAMK,iBAAiBH,YAAYC,aAAa,CAAC;IACjD,MAAMG,YAAYD,2BAAAA,qCAAAA,eAAgBE,aAAa;IAE/C,IAAI,CAACD,WAAW;QACd,MAAM,IAAIF,MAAM,CAAC,qDAAqD,CAAC;IACzE;IAEA,MAAMI,YAAY,AAACH,CAAAA,eAAeG,SAAS,CAACf,KAAK,GAAG,2BAA0B,EAAGgB,KAAK,CAAC;IAEvF,sCAAsC;IACtC,MAAMC,aAAaJ,UAAUK,gBAAgB,CAAC,CAAC,yBAAyB,CAAC;IACzED,WAAWE,OAAO,CAACC,CAAAA,OAAQA,KAAKC,MAAM;IAEtC,OAAO;QACLR;QACAS,YAAYP;IACd;AACF;AAEA,MAAMQ,sBAA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1
- {"version":3,"sources":["../src/utils.ts"],"sourcesContent":["export function serializeJson(value: object) {\n return JSON.stringify(value, null, 2);\n}\n"],"names":["serializeJson","value","JSON","stringify"],"rangeMappings":";;;;;;;;;;;;","mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,cAAcC,KAAa;IACzC,OAAOC,KAAKC,SAAS,CAACF,OAAO,MAAM;AACrC"}
1
+ {"version":3,"sources":["../src/utils.ts"],"sourcesContent":["export function serializeJson(value: object) {\n return JSON.stringify(value, null, 2);\n}\n"],"names":["serializeJson","value","JSON","stringify"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,cAAcC,KAAa;IACzC,OAAOC,KAAKC,SAAS,CAACF,OAAO,MAAM;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/webpack.ts"],"sourcesContent":["import type { PresetConfig } from './types';\n\ntype WebpackFinalFn = NonNullable<import('@storybook/react-webpack5').StorybookConfig['webpackFinal']>;\nexport type WebpackFinalConfig = Parameters<WebpackFinalFn>[0];\nexport type WebpackFinalOptions = Parameters<WebpackFinalFn>[1];\n\nexport function webpack(config: WebpackFinalConfig, options: WebpackFinalOptions) {\n const addonPresetConfig = getAddonOptions(options);\n\n registerRules({ config, rules: [createBabelLoaderRule(addonPresetConfig)] });\n\n return config;\n}\n\nconst identity = <T extends unknown>(value: T) => value;\nconst addonFilePattern = /react-storybook-addon-export-to-sandbox\\/[a-z/]+.[jt]s$/;\nconst defaultOptions = {\n webpackRule: {},\n babelLoaderOptionsUpdater: identity,\n};\n\nconst PLUGIN_PATH =\n process.env.NODE_ENV !== 'production'\n ? '@fluentui/babel-preset-storybook-full-source/__dev'\n : '@fluentui/babel-preset-storybook-full-source';\n\nfunction createBabelLoaderRule(config: Required<PresetConfig>): import('webpack').RuleSetRule {\n const { babelLoaderOptionsUpdater, importMappings, webpackRule } = config;\n\n const plugin = [require.resolve(PLUGIN_PATH), importMappings];\n\n return {\n test: /\\.stories\\.(jsx?$|tsx?$)/,\n ...webpackRule,\n /**\n * why the usage of 'post' ? - we need to run this loader after all storybook webpack rules/loaders have been executed.\n * while we can use Array.prototype.unshift to \"override\" the indexes this approach is more declarative without additional hacks.\n */\n enforce: 'post',\n use: {\n /**\n * Custom babel loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` parameter\n * that is passed to babel-loader.\n **/\n loader: require.resolve('./custom-babel-loader'),\n options: babelLoaderOptionsUpdater({\n plugins: [plugin],\n }),\n },\n };\n}\n\n/**\n *\n * register custom Webpack Rules to webpack config\n */\nfunction registerRules(options: { rules: import('webpack').RuleSetRule[]; config: import('webpack').Configuration }) {\n const { config, rules } = options;\n config.module = config.module ?? {};\n config.module.rules = config.module.rules ?? [];\n config.module.rules.push(...rules);\n\n return config;\n}\n\nfunction getAddonOptions(options: WebpackFinalOptions): Required<PresetConfig> {\n const presetRegistration = options.presetsList?.find(preset => {\n return addonFilePattern.test(preset.name);\n });\n\n const addonOptions = presetRegistration?.options ?? {};\n\n return { ...defaultOptions, ...addonOptions };\n}\n"],"names":["webpack","config","options","addonPresetConfig","getAddonOptions","registerRules","rules","createBabelLoaderRule","identity","value","addonFilePattern","defaultOptions","webpackRule","babelLoaderOptionsUpdater","PLUGIN_PATH","process","env","NODE_ENV","importMappings","plugin","require","resolve","test","enforce","use","loader","plugins","module","push","presetRegistration","presetsList","find","preset","name","addonOptions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAMgBA;;;eAAAA;;;AAAT,SAASA,QAAQC,MAA0B,EAAEC,OAA4B;IAC9E,MAAMC,oBAAoBC,gBAAgBF;IAE1CG,cAAc;QAAEJ;QAAQK,OAAO;YAACC,sBAAsBJ;SAAmB;IAAC;IAE1E,OAAOF;AACT;AAEA,MAAMO,WAAW,CAAoBC,QAAaA;AAClD,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;IACrBC,a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["../src/webpack.ts"],"sourcesContent":["import type { PresetConfig } from './types';\n\ntype WebpackFinalFn = NonNullable<import('@storybook/react-webpack5').StorybookConfig['webpackFinal']>;\nexport type WebpackFinalConfig = Parameters<WebpackFinalFn>[0];\nexport type WebpackFinalOptions = Parameters<WebpackFinalFn>[1];\n\nexport function webpack(config: WebpackFinalConfig, options: WebpackFinalOptions) {\n const addonPresetConfig = getAddonOptions(options);\n\n registerRules({ config, rules: [createBabelLoaderRule(addonPresetConfig)] });\n\n return config;\n}\n\nconst identity = <T extends unknown>(value: T) => value;\nconst addonFilePattern = /react-storybook-addon-export-to-sandbox\\/[a-z/]+.[jt]s$/;\nconst defaultOptions = {\n webpackRule: {},\n babelLoaderOptionsUpdater: identity,\n};\n\nconst PLUGIN_PATH =\n process.env.NODE_ENV !== 'production'\n ? '@fluentui/babel-preset-storybook-full-source/__dev'\n : '@fluentui/babel-preset-storybook-full-source';\n\nfunction createBabelLoaderRule(config: Required<PresetConfig>): import('webpack').RuleSetRule {\n const { babelLoaderOptionsUpdater, importMappings, webpackRule } = config;\n\n const plugin = [require.resolve(PLUGIN_PATH), importMappings];\n\n return {\n test: /\\.stories\\.(jsx?$|tsx?$)/,\n ...webpackRule,\n /**\n * why the usage of 'post' ? - we need to run this loader after all storybook webpack rules/loaders have been executed.\n * while we can use Array.prototype.unshift to \"override\" the indexes this approach is more declarative without additional hacks.\n */\n enforce: 'post',\n use: {\n /**\n * Custom babel loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` parameter\n * that is passed to babel-loader.\n **/\n loader: require.resolve('./custom-babel-loader'),\n options: babelLoaderOptionsUpdater({\n plugins: [plugin],\n }),\n },\n };\n}\n\n/**\n *\n * register custom Webpack Rules to webpack config\n */\nfunction registerRules(options: { rules: import('webpack').RuleSetRule[]; config: import('webpack').Configuration }) {\n const { config, rules } = options;\n config.module = config.module ?? {};\n config.module.rules = config.module.rules ?? [];\n config.module.rules.push(...rules);\n\n return config;\n}\n\nfunction getAddonOptions(options: WebpackFinalOptions): Required<PresetConfig> {\n const presetRegistration = options.presetsList?.find(preset => {\n return addonFilePattern.test(preset.name);\n });\n\n const addonOptions = presetRegistration?.options ?? {};\n\n return { ...defaultOptions, ...addonOptions };\n}\n"],"names":["webpack","config","options","addonPresetConfig","getAddonOptions","registerRules","rules","createBabelLoaderRule","identity","value","addonFilePattern","defaultOptions","webpackRule","babelLoaderOptionsUpdater","PLUGIN_PATH","process","env","NODE_ENV","importMappings","plugin","require","resolve","test","enforce","use","loader","plugins","module","push","presetRegistration","presetsList","find","preset","name","addonOptions"],"mappings":";;;;+BAMgBA;;;eAAAA;;;AAAT,SAASA,QAAQC,MAA0B,EAAEC,OAA4B;IAC9E,MAAMC,oBAAoBC,gBAAgBF;IAE1CG,cAAc;QAAEJ;QAAQK,OAAO;YAACC,sBAAsBJ;SAAmB;IAAC;IAE1E,OAAOF;AACT;AAEA,MAAMO,WAAW,CAAoBC,QAAaA;AAClD,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;IACrBC,aAAa,CAAC;IACdC,2BAA2BL;AAC7B;AAEA,MAAMM,cACJC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eACrB,uDACA;AAEN,SAASV,sBAAsBN,MAA8B;IAC3D,MAAM,EAAEY,yBAAyB,EAAEK,cAAc,EAAEN,WAAW,EAAE,GAAGX;IAEnE,MAAMkB,SAAS;QAACC,QAAQC,OAAO,CAACP;QAAcI;KAAe;IAE7D,OAAO;QACLI,MAAM;QACN,GAAGV,WAAW;QACd;;;KAGC,GACDW,SAAS;QACTC,KAAK;YACH;;;QAGE,GACFC,QAAQL,QAAQC,OAAO,CAAC;YACxBnB,SAASW,0BAA0B;gBACjCa,SAAS;oBAACP;iBAAO;YACnB;QACF;IACF;AACF;AAEA;;;CAGC,GACD,SAASd,cAAcH,OAA4F;IACjH,MAAM,EAAED,MAAM,EAAEK,KAAK,EAAE,GAAGJ;QACVD;IAAhBA,OAAO0B,MAAM,GAAG1B,CAAAA,iBAAAA,OAAO0B,MAAM,cAAb1B,4BAAAA,iBAAiB,CAAC;QACZA;IAAtBA,OAAO0B,MAAM,CAACrB,KAAK,GAAGL,CAAAA,uBAAAA,OAAO0B,MAAM,CAACrB,KAAK,cAAnBL,kCAAAA,uBAAuB,EAAE;IAC/CA,OAAO0B,MAAM,CAACrB,KAAK,CAACsB,IAAI,IAAItB;IAE5B,OAAOL;AACT;AAEA,SAASG,gBAAgBF,OAA4B;QACxBA;IAA3B,MAAM2B,sBAAqB3B,uBAAAA,QAAQ4B,WAAW,cAAnB5B,2CAAAA,qBAAqB6B,IAAI,CAACC,CAAAA;QACnD,OAAOtB,iBAAiBY,IAAI,CAACU,OAAOC,IAAI;IAC1C;QAEqBJ;IAArB,MAAMK,eAAeL,CAAAA,8BAAAA,+BAAAA,yCAAAA,mBAAoB3B,OAAO,cAA3B2B,yCAAAA,8BAA+B,CAAC;IAErD,OAAO;QAAE,GAAGlB,cAAc;QAAE,GAAGuB,YAAY;IAAC;AAC9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-storybook-addon-export-to-sandbox",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Storybook addon that enables cloud/web sandbox exports for stories doc mode code examples",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -18,7 +18,7 @@
18
18
  "@swc/helpers": "^0.5.1",
19
19
  "babel-loader": "^9.1.3",
20
20
  "codesandbox-import-utils": "^2.2.3",
21
- "@fluentui/babel-preset-storybook-full-source": "^0.1.0",
21
+ "@fluentui/babel-preset-storybook-full-source": "^0.1.1",
22
22
  "dedent": "^1.2.0"
23
23
  },
24
24
  "peerDependencies": {