@storybook/builder-vite 10.0.0-beta.4 → 10.0.0-beta.5

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.
Files changed (2) hide show
  1. package/dist/index.js +30 -21
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_z9tbuo6b9mi from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_z9tbuo6b9mi from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_z9tbuo6b9mi from "node:module";
1
+ import CJS_COMPAT_NODE_URL_3n2ithg8g11 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_3n2ithg8g11 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_3n2ithg8g11 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_z9tbuo6b9mi.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_z9tbuo6b9mi.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_z9tbuo6b9mi.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_3n2ithg8g11.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_3n2ithg8g11.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_3n2ithg8g11.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -182,7 +182,7 @@ var require_brace_expansion = __commonJS({
182
182
  var isSequence = isNumericSequence || isAlphaSequence;
183
183
  var isOptions = m.body.indexOf(",") >= 0;
184
184
  if (!isSequence && !isOptions) {
185
- if (m.post.match(/,.*\}/)) {
185
+ if (m.post.match(/,(?!,).*\}/)) {
186
186
  str = m.pre + "{" + m.body + escClose + m.post;
187
187
  return expand2(str);
188
188
  }
@@ -424,8 +424,7 @@ function encodeInteger(builder, num, relative4) {
424
424
  do {
425
425
  let clamped = delta & 31;
426
426
  delta >>>= 5;
427
- if (delta > 0)
428
- clamped |= 32;
427
+ if (delta > 0) clamped |= 32;
429
428
  builder.write(intToChar[clamped]);
430
429
  } while (delta > 0);
431
430
  return num;
@@ -476,23 +475,18 @@ function encode(decoded) {
476
475
  let namesIndex = 0;
477
476
  for (let i = 0; i < decoded.length; i++) {
478
477
  const line = decoded[i];
479
- if (i > 0)
480
- writer.write(semicolon);
481
- if (line.length === 0)
482
- continue;
478
+ if (i > 0) writer.write(semicolon);
479
+ if (line.length === 0) continue;
483
480
  let genColumn = 0;
484
481
  for (let j = 0; j < line.length; j++) {
485
482
  const segment = line[j];
486
- if (j > 0)
487
- writer.write(comma);
483
+ if (j > 0) writer.write(comma);
488
484
  genColumn = encodeInteger(writer, segment[0], genColumn);
489
- if (segment.length === 1)
490
- continue;
485
+ if (segment.length === 1) continue;
491
486
  sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
492
487
  sourceLine = encodeInteger(writer, segment[2], sourceLine);
493
488
  sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
494
- if (segment.length === 4)
495
- continue;
489
+ if (segment.length === 4) continue;
496
490
  namesIndex = encodeInteger(writer, segment[4], namesIndex);
497
491
  }
498
492
  }
@@ -957,6 +951,9 @@ var MagicString = class _MagicString {
957
951
  }
958
952
  if (chunk.outro.length) mappings.advance(chunk.outro);
959
953
  });
954
+ if (this.outro) {
955
+ mappings.advance(this.outro);
956
+ }
960
957
  return {
961
958
  file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
962
959
  sources: [
@@ -1314,10 +1311,13 @@ var MagicString = class _MagicString {
1314
1311
  _split(index) {
1315
1312
  if (this.byStart[index] || this.byEnd[index]) return;
1316
1313
  let chunk = this.lastSearchedChunk;
1314
+ let previousChunk = chunk;
1317
1315
  const searchForward = index > chunk.end;
1318
1316
  while (chunk) {
1319
1317
  if (chunk.contains(index)) return this._splitChunk(chunk, index);
1320
1318
  chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
1319
+ if (chunk === previousChunk) return;
1320
+ previousChunk = chunk;
1321
1321
  }
1322
1322
  }
1323
1323
  _splitChunk(chunk, index) {
@@ -1466,7 +1466,12 @@ var MagicString = class _MagicString {
1466
1466
  const { original } = this;
1467
1467
  const index = original.indexOf(string);
1468
1468
  if (index !== -1) {
1469
- this.overwrite(index, index + string.length, replacement);
1469
+ if (typeof replacement === "function") {
1470
+ replacement = replacement(string, index, original);
1471
+ }
1472
+ if (string !== replacement) {
1473
+ this.overwrite(index, index + string.length, replacement);
1474
+ }
1470
1475
  }
1471
1476
  return this;
1472
1477
  }
@@ -1481,7 +1486,11 @@ var MagicString = class _MagicString {
1481
1486
  const stringLength = string.length;
1482
1487
  for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
1483
1488
  const previous = original.slice(index, index + stringLength);
1484
- if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
1489
+ let _replacement = replacement;
1490
+ if (typeof replacement === "function") {
1491
+ _replacement = replacement(previous, index, original);
1492
+ }
1493
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
1485
1494
  }
1486
1495
  return this;
1487
1496
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/builder-vite",
3
- "version": "10.0.0-beta.4",
3
+ "version": "10.0.0-beta.5",
4
4
  "description": "A Storybook builder to dev and build with Vite",
5
5
  "keywords": [
6
6
  "storybook",
@@ -48,7 +48,7 @@
48
48
  "prep": "jiti ../../../scripts/build/build-package.ts"
49
49
  },
50
50
  "dependencies": {
51
- "@storybook/csf-plugin": "10.0.0-beta.4",
51
+ "@storybook/csf-plugin": "10.0.0-beta.5",
52
52
  "ts-dedent": "^2.0.0"
53
53
  },
54
54
  "devDependencies": {
@@ -63,7 +63,7 @@
63
63
  "vite": "^7.0.4"
64
64
  },
65
65
  "peerDependencies": {
66
- "storybook": "^10.0.0-beta.4",
66
+ "storybook": "^10.0.0-beta.5",
67
67
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
68
68
  },
69
69
  "publishConfig": {