vite-plugin-storybook-nextjs 3.1.5 → 3.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4069,14 +4069,16 @@ async function getFontFaceDeclarations2(options) {
4069
4069
  if ("fontReferenceId" in localFontSrc) {
4070
4070
  return tsDedent.dedent`@font-face {
4071
4071
  font-family: ${id};
4072
- src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs${localFontSrc.fontPath}`})
4072
+ src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs/${localFontSrc.fontPath}`});
4073
+ ${weight ? `font-weight: ${weight};` : ""}
4074
+ ${style ? `font-style: ${style};` : ""}
4073
4075
  ${fontDeclarations}
4074
4076
  }`;
4075
4077
  }
4076
4078
  return localFontSrc.map((font) => {
4077
4079
  return tsDedent.dedent`@font-face {
4078
4080
  font-family: ${id};
4079
- src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs${font.path.fontPath}`});
4081
+ src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs/${font.path.fontPath}`});
4080
4082
  ${font.weight ? `font-weight: ${font.weight};` : ""}
4081
4083
  ${font.style ? `font-style: ${font.style};` : ""}
4082
4084
  ${fontDeclarations}
@@ -4104,7 +4106,7 @@ function getCSSMeta(options) {
4104
4106
  .${className} {
4105
4107
  font-family: ${options.fontFamily};
4106
4108
  ${isNextCSSPropertyValid(options.styles) ? `font-style: ${options.styles[0]};` : ""}
4107
- ${isNextCSSPropertyValid(options.weights) ? `font-weight: ${options.weights[0]};` : ""}
4109
+ ${isNextCSSPropertyValid(options.weights) && !options.weights[0]?.includes(" ") ? `font-weight: ${options.weights[0]};` : ""}
4108
4110
  }
4109
4111
 
4110
4112
  ${options.variable ? `.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }` : ""}
@@ -4121,7 +4123,7 @@ function getCSSMeta(options) {
4121
4123
  function getClassName({ styles, weights, fontFamily }) {
4122
4124
  const font = fontFamily.replaceAll(" ", "-").toLowerCase();
4123
4125
  const style = isNextCSSPropertyValid(styles) ? styles[0] : null;
4124
- const weight = isNextCSSPropertyValid(weights) ? weights[0] : null;
4126
+ const weight = isNextCSSPropertyValid(weights) ? weights[0]?.replaceAll(" ", "-") : null;
4125
4127
  return `${font}${style ? `-${style}` : ""}${weight ? `-${weight}` : ""}`;
4126
4128
  }
4127
4129
  function getStylesObj({ styles, weights, fontFamily }) {
@@ -4297,6 +4299,21 @@ function vitePluginNextFont() {
4297
4299
  }
4298
4300
  };
4299
4301
  }
4302
+ var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4303
+ var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
4304
+ var isVitestEnv = process.env.VITEST === "true";
4305
+ function getExecutionEnvironment(config) {
4306
+ return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
4307
+ }
4308
+ var getNextjsVersion = () => require2("next/package.json").version;
4309
+ var getNextjsMajorVersion = () => {
4310
+ try {
4311
+ const version = getNextjsVersion();
4312
+ return Number.parseInt(version.split(".")[0], 10);
4313
+ } catch (error) {
4314
+ return 16;
4315
+ }
4316
+ };
4300
4317
 
4301
4318
  // src/utils/swc/styles.ts
4302
4319
  function getStyledComponentsOptions(styledComponentsConfig, development) {
@@ -4339,8 +4356,8 @@ function getEmotionOptions(emotionConfig, development) {
4339
4356
  }
4340
4357
 
4341
4358
  // src/utils/swc/options.ts
4342
- var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4343
- var regeneratorRuntimePath = require2.resolve(
4359
+ var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4360
+ var regeneratorRuntimePath = require3.resolve(
4344
4361
  "next/dist/compiled/regenerator-runtime"
4345
4362
  );
4346
4363
  function getBaseSWCOptions({
@@ -4367,7 +4384,7 @@ function getBaseSWCOptions({
4367
4384
  const useDefineForClassFields = Boolean(
4368
4385
  jsConfig?.compilerOptions?.useDefineForClassFields
4369
4386
  );
4370
- const plugins = (swcPlugins ?? []).filter(Array.isArray).map(([name, options]) => [require2.resolve(name), options]);
4387
+ const plugins = (swcPlugins ?? []).filter(Array.isArray).map(([name, options]) => [require3.resolve(name), options]);
4371
4388
  return {
4372
4389
  jsc: {
4373
4390
  ...resolvedBaseUrl && paths ? {
@@ -4555,8 +4572,9 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
4555
4572
  await loadSWCBindingsEagerly(nextConfig);
4556
4573
  const serverWatchIgnored = config.server?.watch?.ignored;
4557
4574
  const isServerWatchIgnoredArray = Array.isArray(serverWatchIgnored);
4558
- if (config.test?.environment === "node" || config.test?.environment === "edge-runtime" || config.test?.browser?.enabled !== false) {
4559
- isServerEnvironment = true;
4575
+ isServerEnvironment = false;
4576
+ if (isVitestEnv) {
4577
+ isServerEnvironment = config.test?.environment === "node" || config.test?.environment === "edge-runtime" || config.test?.browser?.enabled !== true;
4560
4578
  }
4561
4579
  return {
4562
4580
  // esbuild: {
@@ -4695,21 +4713,6 @@ var reservedWords = "break case class catch const continue debugger default dele
4695
4713
  var builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
4696
4714
  var forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(" "));
4697
4715
  forbiddenIdentifiers.add("");
4698
- var require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4699
- var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
4700
- var isVitestEnv = process.env.VITEST === "true";
4701
- function getExecutionEnvironment(config) {
4702
- return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
4703
- }
4704
- var getNextjsVersion = () => require3("next/package.json").version;
4705
- var getNextjsMajorVersion = () => {
4706
- try {
4707
- const version = getNextjsVersion();
4708
- return Number.parseInt(version.split(".")[0], 10);
4709
- } catch (error) {
4710
- return 16;
4711
- }
4712
- };
4713
4716
  var require4 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4714
4717
  var getEntryPoint = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
4715
4718
  var getAlias = (env) => ({
package/dist/index.js CHANGED
@@ -4036,14 +4036,16 @@ async function getFontFaceDeclarations2(options) {
4036
4036
  if ("fontReferenceId" in localFontSrc) {
4037
4037
  return dedent`@font-face {
4038
4038
  font-family: ${id};
4039
- src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs${localFontSrc.fontPath}`})
4039
+ src: url(${localFontSrc.fontReferenceId ? getPlaceholderFontUrl(localFontSrc.fontReferenceId) : `/@fs/${localFontSrc.fontPath}`});
4040
+ ${weight ? `font-weight: ${weight};` : ""}
4041
+ ${style ? `font-style: ${style};` : ""}
4040
4042
  ${fontDeclarations}
4041
4043
  }`;
4042
4044
  }
4043
4045
  return localFontSrc.map((font) => {
4044
4046
  return dedent`@font-face {
4045
4047
  font-family: ${id};
4046
- src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs${font.path.fontPath}`});
4048
+ src: url(${font.path.fontReferenceId ? getPlaceholderFontUrl(font.path.fontReferenceId) : `/@fs/${font.path.fontPath}`});
4047
4049
  ${font.weight ? `font-weight: ${font.weight};` : ""}
4048
4050
  ${font.style ? `font-style: ${font.style};` : ""}
4049
4051
  ${fontDeclarations}
@@ -4071,7 +4073,7 @@ function getCSSMeta(options) {
4071
4073
  .${className} {
4072
4074
  font-family: ${options.fontFamily};
4073
4075
  ${isNextCSSPropertyValid(options.styles) ? `font-style: ${options.styles[0]};` : ""}
4074
- ${isNextCSSPropertyValid(options.weights) ? `font-weight: ${options.weights[0]};` : ""}
4076
+ ${isNextCSSPropertyValid(options.weights) && !options.weights[0]?.includes(" ") ? `font-weight: ${options.weights[0]};` : ""}
4075
4077
  }
4076
4078
 
4077
4079
  ${options.variable ? `.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }` : ""}
@@ -4088,7 +4090,7 @@ function getCSSMeta(options) {
4088
4090
  function getClassName({ styles, weights, fontFamily }) {
4089
4091
  const font = fontFamily.replaceAll(" ", "-").toLowerCase();
4090
4092
  const style = isNextCSSPropertyValid(styles) ? styles[0] : null;
4091
- const weight = isNextCSSPropertyValid(weights) ? weights[0] : null;
4093
+ const weight = isNextCSSPropertyValid(weights) ? weights[0]?.replaceAll(" ", "-") : null;
4092
4094
  return `${font}${style ? `-${style}` : ""}${weight ? `-${weight}` : ""}`;
4093
4095
  }
4094
4096
  function getStylesObj({ styles, weights, fontFamily }) {
@@ -4264,6 +4266,21 @@ function vitePluginNextFont() {
4264
4266
  }
4265
4267
  };
4266
4268
  }
4269
+ var require2 = createRequire(import.meta.url);
4270
+ var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
4271
+ var isVitestEnv = process.env.VITEST === "true";
4272
+ function getExecutionEnvironment(config) {
4273
+ return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
4274
+ }
4275
+ var getNextjsVersion = () => require2("next/package.json").version;
4276
+ var getNextjsMajorVersion = () => {
4277
+ try {
4278
+ const version = getNextjsVersion();
4279
+ return Number.parseInt(version.split(".")[0], 10);
4280
+ } catch (error) {
4281
+ return 16;
4282
+ }
4283
+ };
4267
4284
 
4268
4285
  // src/utils/swc/styles.ts
4269
4286
  function getStyledComponentsOptions(styledComponentsConfig, development) {
@@ -4306,8 +4323,8 @@ function getEmotionOptions(emotionConfig, development) {
4306
4323
  }
4307
4324
 
4308
4325
  // src/utils/swc/options.ts
4309
- var require2 = createRequire(import.meta.url);
4310
- var regeneratorRuntimePath = require2.resolve(
4326
+ var require3 = createRequire(import.meta.url);
4327
+ var regeneratorRuntimePath = require3.resolve(
4311
4328
  "next/dist/compiled/regenerator-runtime"
4312
4329
  );
4313
4330
  function getBaseSWCOptions({
@@ -4334,7 +4351,7 @@ function getBaseSWCOptions({
4334
4351
  const useDefineForClassFields = Boolean(
4335
4352
  jsConfig?.compilerOptions?.useDefineForClassFields
4336
4353
  );
4337
- const plugins = (swcPlugins ?? []).filter(Array.isArray).map(([name, options]) => [require2.resolve(name), options]);
4354
+ const plugins = (swcPlugins ?? []).filter(Array.isArray).map(([name, options]) => [require3.resolve(name), options]);
4338
4355
  return {
4339
4356
  jsc: {
4340
4357
  ...resolvedBaseUrl && paths ? {
@@ -4522,8 +4539,9 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
4522
4539
  await loadSWCBindingsEagerly(nextConfig);
4523
4540
  const serverWatchIgnored = config.server?.watch?.ignored;
4524
4541
  const isServerWatchIgnoredArray = Array.isArray(serverWatchIgnored);
4525
- if (config.test?.environment === "node" || config.test?.environment === "edge-runtime" || config.test?.browser?.enabled !== false) {
4526
- isServerEnvironment = true;
4542
+ isServerEnvironment = false;
4543
+ if (isVitestEnv) {
4544
+ isServerEnvironment = config.test?.environment === "node" || config.test?.environment === "edge-runtime" || config.test?.browser?.enabled !== true;
4527
4545
  }
4528
4546
  return {
4529
4547
  // esbuild: {
@@ -4662,21 +4680,6 @@ var reservedWords = "break case class catch const continue debugger default dele
4662
4680
  var builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
4663
4681
  var forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(" "));
4664
4682
  forbiddenIdentifiers.add("");
4665
- var require3 = createRequire(import.meta.url);
4666
- var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
4667
- var isVitestEnv = process.env.VITEST === "true";
4668
- function getExecutionEnvironment(config) {
4669
- return isVitestEnv && config.test?.browser?.enabled !== true ? "node" : "browser";
4670
- }
4671
- var getNextjsVersion = () => require3("next/package.json").version;
4672
- var getNextjsMajorVersion = () => {
4673
- try {
4674
- const version = getNextjsVersion();
4675
- return Number.parseInt(version.split(".")[0], 10);
4676
- } catch (error) {
4677
- return 16;
4678
- }
4679
- };
4680
4683
  var require4 = createRequire(import.meta.url);
4681
4684
  var getEntryPoint = (subPath, env) => require4.resolve(`${VITEST_PLUGIN_NAME}/${env}/mocks/${subPath}`);
4682
4685
  var getAlias = (env) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-storybook-nextjs",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "vite-plugin",