@storybook/nextjs 10.1.0-alpha.9 → 10.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/_browser-chunks/{chunk-KX5HHFXV.js → chunk-2SBZPHE7.js} +50 -100
  2. package/dist/_browser-chunks/chunk-RDMFII4N.js +22 -0
  3. package/dist/_browser-chunks/{chunk-L5NVL7MD.js → chunk-SL3VIQZ3.js} +7 -13
  4. package/dist/_browser-chunks/react-18-PYSEDAWB.js +43 -0
  5. package/dist/_node-chunks/chunk-AU547LNK.js +76 -0
  6. package/dist/_node-chunks/chunk-EONFLREF.js +57 -0
  7. package/dist/_node-chunks/chunk-NVHRUSN5.js +211 -0
  8. package/dist/_node-chunks/configureNextFont-3RPVM2N7.js +28 -0
  9. package/dist/_node-chunks/{loader-7OJQICYP.js → loader-PBLFQE7I.js} +15 -25
  10. package/dist/_node-chunks/{loader-OFLGZQCU.js → loader-UX42M74F.js} +11 -16
  11. package/dist/_node-chunks/{utils-NVB3HGRH.js → utils-MPWEOWV4.js} +8 -9
  12. package/dist/_node-chunks/webpack-5IZRQF33.js +23 -0
  13. package/dist/_node-chunks/{webpack-E2OB2ZPW.js → webpack-C4DEBGCG.js} +13 -19
  14. package/dist/_node-chunks/webpack-EFCFZKO7.js +97 -0
  15. package/dist/_node-chunks/{webpack-VD3FKUZZ.js → webpack-KW7MEY7C.js} +9 -12
  16. package/dist/_node-chunks/webpack-TVYIGXMK.js +24 -0
  17. package/dist/_node-chunks/webpack-UAKFJEYJ.js +30 -0
  18. package/dist/_node-chunks/webpack-WL4FYVO5.js +23 -0
  19. package/dist/_node-chunks/webpack-WZC6ZANM.js +60 -0
  20. package/dist/compatibility/draft-mode.compat.js +1 -1
  21. package/dist/export-mocks/cache/index.js +3 -6
  22. package/dist/export-mocks/headers/index.js +6 -29
  23. package/dist/export-mocks/index.js +9 -10
  24. package/dist/export-mocks/navigation/index.js +17 -41
  25. package/dist/export-mocks/router/index.d.ts +4 -7
  26. package/dist/export-mocks/router/index.js +20 -54
  27. package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +38 -80
  28. package/dist/image-context.js +1 -1
  29. package/dist/images/next-image.js +5 -11
  30. package/dist/images/next-legacy-image.js +3 -6
  31. package/dist/index.js +2865 -8413
  32. package/dist/next-image-loader-stub.js +9 -16
  33. package/dist/node/index.js +6 -10
  34. package/dist/preset.js +183 -462
  35. package/dist/preview.js +2 -2
  36. package/dist/rsc/server-only.js +1 -1
  37. package/dist/swc/next-swc-loader-patch.js +46 -84
  38. package/package.json +6 -6
  39. package/dist/_browser-chunks/chunk-I5RFHXDS.js +0 -40
  40. package/dist/_browser-chunks/react-18-G7Q4PNHD.js +0 -71
  41. package/dist/_node-chunks/chunk-PWZWGY6W.js +0 -17
  42. package/dist/_node-chunks/chunk-UHO3ELD2.js +0 -475
  43. package/dist/_node-chunks/chunk-WR63XCFA.js +0 -74
  44. package/dist/_node-chunks/chunk-X47EC6DB.js +0 -102
  45. package/dist/_node-chunks/configureNextFont-ZL3UHKQ4.js +0 -36
  46. package/dist/_node-chunks/webpack-3J2WBZ2E.js +0 -30
  47. package/dist/_node-chunks/webpack-7PUWUCNJ.js +0 -27
  48. package/dist/_node-chunks/webpack-JVSODHFI.js +0 -38
  49. package/dist/_node-chunks/webpack-O36IRAFL.js +0 -77
  50. package/dist/_node-chunks/webpack-SNP77BVT.js +0 -107
  51. package/dist/_node-chunks/webpack-THQBX5DA.js +0 -26
@@ -1,475 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_mt98813ktw from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_mt98813ktw from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_mt98813ktw from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_mt98813ktw.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_mt98813ktw.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_mt98813ktw.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- __name
14
- } from "./chunk-PWZWGY6W.js";
15
-
16
- // ../../core/src/shared/utils/module.ts
17
- import { fileURLToPath, pathToFileURL } from "node:url";
18
-
19
- // ../../node_modules/exsolve/dist/index.mjs
20
- import assert from "node:assert";
21
- import v8 from "node:v8";
22
- import { format, inspect } from "node:util";
23
- var own$1 = {}.hasOwnProperty;
24
- var classRegExp = /^([A-Z][a-z\d]*)+$/;
25
- var kTypes = /* @__PURE__ */ new Set([
26
- "string",
27
- "function",
28
- "number",
29
- "object",
30
- // Accept 'Function' and 'Object' as alternative to the lower cased version.
31
- "Function",
32
- "Object",
33
- "boolean",
34
- "bigint",
35
- "symbol"
36
- ]);
37
- var messages = /* @__PURE__ */ new Map();
38
- var nodeInternalPrefix = "__node_internal_";
39
- var userStackTraceLimit;
40
- function formatList(array, type = "and") {
41
- return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array.at(-1)}`;
42
- }
43
- __name(formatList, "formatList");
44
- function createError(sym, value, constructor) {
45
- messages.set(sym, value);
46
- return makeNodeErrorWithCode(constructor, sym);
47
- }
48
- __name(createError, "createError");
49
- function makeNodeErrorWithCode(Base, key) {
50
- return /* @__PURE__ */ __name(function NodeError(...parameters) {
51
- const limit = Error.stackTraceLimit;
52
- if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
53
- const error = new Base();
54
- if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
55
- const message = getMessage(key, parameters, error);
56
- Object.defineProperties(error, {
57
- // Note: no need to implement `kIsNodeError` symbol, would be hard,
58
- // probably.
59
- message: {
60
- value: message,
61
- enumerable: false,
62
- writable: true,
63
- configurable: true
64
- },
65
- toString: {
66
- /** @this {Error} */
67
- value() {
68
- return `${this.name} [${key}]: ${this.message}`;
69
- },
70
- enumerable: false,
71
- writable: true,
72
- configurable: true
73
- }
74
- });
75
- captureLargerStackTrace(error);
76
- error.code = key;
77
- return error;
78
- }, "NodeError");
79
- }
80
- __name(makeNodeErrorWithCode, "makeNodeErrorWithCode");
81
- function isErrorStackTraceLimitWritable() {
82
- try {
83
- if (v8.startupSnapshot.isBuildingSnapshot()) {
84
- return false;
85
- }
86
- } catch {
87
- }
88
- const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
89
- if (desc === void 0) {
90
- return Object.isExtensible(Error);
91
- }
92
- return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
93
- }
94
- __name(isErrorStackTraceLimitWritable, "isErrorStackTraceLimitWritable");
95
- function hideStackFrames(wrappedFunction) {
96
- const hidden = nodeInternalPrefix + wrappedFunction.name;
97
- Object.defineProperty(wrappedFunction, "name", { value: hidden });
98
- return wrappedFunction;
99
- }
100
- __name(hideStackFrames, "hideStackFrames");
101
- var captureLargerStackTrace = hideStackFrames(function(error) {
102
- const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
103
- if (stackTraceLimitIsWritable) {
104
- userStackTraceLimit = Error.stackTraceLimit;
105
- Error.stackTraceLimit = Number.POSITIVE_INFINITY;
106
- }
107
- Error.captureStackTrace(error);
108
- if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
109
- return error;
110
- });
111
- function getMessage(key, parameters, self) {
112
- const message = messages.get(key);
113
- assert(message !== void 0, "expected `message` to be found");
114
- if (typeof message === "function") {
115
- assert(
116
- message.length <= parameters.length,
117
- // Default options do not count.
118
- `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
119
- );
120
- return Reflect.apply(message, self, parameters);
121
- }
122
- const regex = /%[dfijoOs]/g;
123
- let expectedLength = 0;
124
- while (regex.exec(message) !== null) expectedLength++;
125
- assert(
126
- expectedLength === parameters.length,
127
- `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
128
- );
129
- if (parameters.length === 0) return message;
130
- parameters.unshift(message);
131
- return Reflect.apply(format, null, parameters);
132
- }
133
- __name(getMessage, "getMessage");
134
- function determineSpecificType(value) {
135
- if (value === null || value === void 0) {
136
- return String(value);
137
- }
138
- if (typeof value === "function" && value.name) {
139
- return `function ${value.name}`;
140
- }
141
- if (typeof value === "object") {
142
- if (value.constructor && value.constructor.name) {
143
- return `an instance of ${value.constructor.name}`;
144
- }
145
- return `${inspect(value, { depth: -1 })}`;
146
- }
147
- let inspected = inspect(value, { colors: false });
148
- if (inspected.length > 28) {
149
- inspected = `${inspected.slice(0, 25)}...`;
150
- }
151
- return `type ${typeof value} (${inspected})`;
152
- }
153
- __name(determineSpecificType, "determineSpecificType");
154
- createError(
155
- "ERR_INVALID_ARG_TYPE",
156
- (name, expected, actual) => {
157
- assert(typeof name === "string", "'name' must be a string");
158
- if (!Array.isArray(expected)) {
159
- expected = [expected];
160
- }
161
- let message = "The ";
162
- if (name.endsWith(" argument")) {
163
- message += `${name} `;
164
- } else {
165
- const type = name.includes(".") ? "property" : "argument";
166
- message += `"${name}" ${type} `;
167
- }
168
- message += "must be ";
169
- const types = [];
170
- const instances = [];
171
- const other = [];
172
- for (const value of expected) {
173
- assert(
174
- typeof value === "string",
175
- "All expected entries have to be of type string"
176
- );
177
- if (kTypes.has(value)) {
178
- types.push(value.toLowerCase());
179
- } else if (classRegExp.exec(value) === null) {
180
- assert(
181
- value !== "object",
182
- 'The value "object" should be written as "Object"'
183
- );
184
- other.push(value);
185
- } else {
186
- instances.push(value);
187
- }
188
- }
189
- if (instances.length > 0) {
190
- const pos = types.indexOf("object");
191
- if (pos !== -1) {
192
- types.slice(pos, 1);
193
- instances.push("Object");
194
- }
195
- }
196
- if (types.length > 0) {
197
- message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
198
- types,
199
- "or"
200
- )}`;
201
- if (instances.length > 0 || other.length > 0) message += " or ";
202
- }
203
- if (instances.length > 0) {
204
- message += `an instance of ${formatList(instances, "or")}`;
205
- if (other.length > 0) message += " or ";
206
- }
207
- if (other.length > 0) {
208
- if (other.length > 1) {
209
- message += `one of ${formatList(other, "or")}`;
210
- } else {
211
- if (other[0]?.toLowerCase() !== other[0]) message += "an ";
212
- message += `${other[0]}`;
213
- }
214
- }
215
- message += `. Received ${determineSpecificType(actual)}`;
216
- return message;
217
- },
218
- TypeError
219
- );
220
- var ERR_INVALID_MODULE_SPECIFIER = createError(
221
- "ERR_INVALID_MODULE_SPECIFIER",
222
- /**
223
- * @param {string} request
224
- * @param {string} reason
225
- * @param {string} [base]
226
- */
227
- (request, reason, base) => {
228
- return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
229
- },
230
- TypeError
231
- );
232
- var ERR_INVALID_PACKAGE_CONFIG = createError(
233
- "ERR_INVALID_PACKAGE_CONFIG",
234
- (path2, base, message) => {
235
- return `Invalid package config ${path2}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
236
- },
237
- Error
238
- );
239
- var ERR_INVALID_PACKAGE_TARGET = createError(
240
- "ERR_INVALID_PACKAGE_TARGET",
241
- (packagePath, key, target, isImport = false, base) => {
242
- const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
243
- if (key === ".") {
244
- assert(isImport === false);
245
- return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
246
- }
247
- return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
248
- target
249
- )} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
250
- },
251
- Error
252
- );
253
- var ERR_MODULE_NOT_FOUND = createError(
254
- "ERR_MODULE_NOT_FOUND",
255
- (path2, base, exactUrl = false) => {
256
- return `Cannot find ${exactUrl ? "module" : "package"} '${path2}' imported from ${base}`;
257
- },
258
- Error
259
- );
260
- createError(
261
- "ERR_NETWORK_IMPORT_DISALLOWED",
262
- "import of '%s' by %s is not supported: %s",
263
- Error
264
- );
265
- var ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
266
- "ERR_PACKAGE_IMPORT_NOT_DEFINED",
267
- (specifier, packagePath, base) => {
268
- return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
269
- },
270
- TypeError
271
- );
272
- var ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
273
- "ERR_PACKAGE_PATH_NOT_EXPORTED",
274
- /**
275
- * @param {string} packagePath
276
- * @param {string} subpath
277
- * @param {string} [base]
278
- */
279
- (packagePath, subpath, base) => {
280
- if (subpath === ".")
281
- return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
282
- return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
283
- },
284
- Error
285
- );
286
- var ERR_UNSUPPORTED_DIR_IMPORT = createError(
287
- "ERR_UNSUPPORTED_DIR_IMPORT",
288
- "Directory import '%s' is not supported resolving ES modules imported from %s",
289
- Error
290
- );
291
- var ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
292
- "ERR_UNSUPPORTED_RESOLVE_REQUEST",
293
- 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
294
- TypeError
295
- );
296
- var ERR_UNKNOWN_FILE_EXTENSION = createError(
297
- "ERR_UNKNOWN_FILE_EXTENSION",
298
- (extension, path2) => {
299
- return `Unknown file extension "${extension}" for ${path2}`;
300
- },
301
- TypeError
302
- );
303
- createError(
304
- "ERR_INVALID_ARG_VALUE",
305
- (name, value, reason = "is invalid") => {
306
- let inspected = inspect(value);
307
- if (inspected.length > 128) {
308
- inspected = `${inspected.slice(0, 128)}...`;
309
- }
310
- const type = name.includes(".") ? "property" : "argument";
311
- return `The ${type} '${name}' ${reason}. Received ${inspected}`;
312
- },
313
- TypeError
314
- // Note: extra classes have been shaken out.
315
- // , RangeError
316
- );
317
- var hasOwnProperty$1 = {}.hasOwnProperty;
318
- var hasOwnProperty = {}.hasOwnProperty;
319
- var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
320
- var own = {}.hasOwnProperty;
321
- var isWindows = (() => process.platform === "win32")();
322
- var globalCache = (() => (
323
- // eslint-disable-next-line unicorn/no-unreadable-iife
324
- globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map()
325
- ))();
326
-
327
- // ../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
328
- var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
329
- function normalizeWindowsPath(input = "") {
330
- if (!input) {
331
- return input;
332
- }
333
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
334
- }
335
- __name(normalizeWindowsPath, "normalizeWindowsPath");
336
- var _UNC_REGEX = /^[/\\]{2}/;
337
- var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
338
- var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
339
- var normalize = /* @__PURE__ */ __name(function(path2) {
340
- if (path2.length === 0) {
341
- return ".";
342
- }
343
- path2 = normalizeWindowsPath(path2);
344
- const isUNCPath = path2.match(_UNC_REGEX);
345
- const isPathAbsolute = isAbsolute(path2);
346
- const trailingSeparator = path2[path2.length - 1] === "/";
347
- path2 = normalizeString(path2, !isPathAbsolute);
348
- if (path2.length === 0) {
349
- if (isPathAbsolute) {
350
- return "/";
351
- }
352
- return trailingSeparator ? "./" : ".";
353
- }
354
- if (trailingSeparator) {
355
- path2 += "/";
356
- }
357
- if (_DRIVE_LETTER_RE.test(path2)) {
358
- path2 += "/";
359
- }
360
- if (isUNCPath) {
361
- if (!isPathAbsolute) {
362
- return `//./${path2}`;
363
- }
364
- return `//${path2}`;
365
- }
366
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
367
- }, "normalize");
368
- var join = /* @__PURE__ */ __name(function(...arguments_) {
369
- if (arguments_.length === 0) {
370
- return ".";
371
- }
372
- let joined;
373
- for (const argument of arguments_) {
374
- if (argument && argument.length > 0) {
375
- if (joined === void 0) {
376
- joined = argument;
377
- } else {
378
- joined += `/${argument}`;
379
- }
380
- }
381
- }
382
- if (joined === void 0) {
383
- return ".";
384
- }
385
- return normalize(joined.replace(/\/\/+/g, "/"));
386
- }, "join");
387
- function normalizeString(path2, allowAboveRoot) {
388
- let res = "";
389
- let lastSegmentLength = 0;
390
- let lastSlash = -1;
391
- let dots = 0;
392
- let char = null;
393
- for (let index = 0; index <= path2.length; ++index) {
394
- if (index < path2.length) {
395
- char = path2[index];
396
- } else if (char === "/") {
397
- break;
398
- } else {
399
- char = "/";
400
- }
401
- if (char === "/") {
402
- if (lastSlash === index - 1 || dots === 1) ;
403
- else if (dots === 2) {
404
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
405
- if (res.length > 2) {
406
- const lastSlashIndex = res.lastIndexOf("/");
407
- if (lastSlashIndex === -1) {
408
- res = "";
409
- lastSegmentLength = 0;
410
- } else {
411
- res = res.slice(0, lastSlashIndex);
412
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
413
- }
414
- lastSlash = index;
415
- dots = 0;
416
- continue;
417
- } else if (res.length > 0) {
418
- res = "";
419
- lastSegmentLength = 0;
420
- lastSlash = index;
421
- dots = 0;
422
- continue;
423
- }
424
- }
425
- if (allowAboveRoot) {
426
- res += res.length > 0 ? "/.." : "..";
427
- lastSegmentLength = 2;
428
- }
429
- } else {
430
- if (res.length > 0) {
431
- res += `/${path2.slice(lastSlash + 1, index)}`;
432
- } else {
433
- res = path2.slice(lastSlash + 1, index);
434
- }
435
- lastSegmentLength = index - lastSlash - 1;
436
- }
437
- lastSlash = index;
438
- dots = 0;
439
- } else if (char === "." && dots !== -1) {
440
- ++dots;
441
- } else {
442
- dots = -1;
443
- }
444
- }
445
- return res;
446
- }
447
- __name(normalizeString, "normalizeString");
448
- var isAbsolute = /* @__PURE__ */ __name(function(p) {
449
- return _IS_ABSOLUTE_RE.test(p);
450
- }, "isAbsolute");
451
- var dirname = /* @__PURE__ */ __name(function(p) {
452
- const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
453
- if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
454
- segments[0] += "/";
455
- }
456
- return segments.join("/") || (isAbsolute(p) ? "/" : ".");
457
- }, "dirname");
458
-
459
- // ../../core/src/shared/utils/module.ts
460
- var importMetaResolve = /* @__PURE__ */ __name((...args) => {
461
- if (typeof import.meta.resolve !== "function" && process.env.VITEST === "true") {
462
- console.warn(
463
- "importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
464
- );
465
- return pathToFileURL(args[0]).href;
466
- }
467
- return import.meta.resolve(...args);
468
- }, "importMetaResolve");
469
- var resolvePackageDir = /* @__PURE__ */ __name((pkg, parent) => {
470
- return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"), parent)));
471
- }, "resolvePackageDir");
472
-
473
- export {
474
- resolvePackageDir
475
- };
@@ -1,74 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_mt98813ktw from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_mt98813ktw from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_mt98813ktw from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_mt98813ktw.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_mt98813ktw.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_mt98813ktw.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- addScopedAlias,
14
- getNextjsVersion,
15
- setAlias
16
- } from "./chunk-X47EC6DB.js";
17
- import {
18
- __name
19
- } from "./chunk-PWZWGY6W.js";
20
-
21
- // src/compatibility/compatibility-map.ts
22
- import semver from "semver";
23
- var mapping = {
24
- "<15.0.0": {
25
- "next/dist/server/request/headers": "next/dist/client/components/headers",
26
- // this path only exists from Next 15 onwards
27
- "next/dist/server/request/draft-mode": "@storybook/nextjs/compatibility/draft-mode.compat"
28
- }
29
- };
30
- var getCompatibilityAliases = /* @__PURE__ */ __name(() => {
31
- const version = getNextjsVersion();
32
- const result = {};
33
- Object.keys(mapping).forEach((key) => {
34
- if (semver.intersects(version, key)) {
35
- Object.assign(result, mapping[key]);
36
- }
37
- });
38
- return result;
39
- }, "getCompatibilityAliases");
40
- var configureCompatibilityAliases = /* @__PURE__ */ __name((baseConfig) => {
41
- const aliases = getCompatibilityAliases();
42
- Object.entries(aliases).forEach(([name, alias]) => {
43
- if (typeof alias === "string") {
44
- addScopedAlias(baseConfig, name, alias);
45
- } else {
46
- setAlias(baseConfig, name, alias);
47
- }
48
- });
49
- }, "configureCompatibilityAliases");
50
-
51
- // src/export-mocks/webpack.ts
52
- var mapping2 = {
53
- "next/headers": "@storybook/nextjs/headers.mock",
54
- "next/navigation": "@storybook/nextjs/navigation.mock",
55
- "next/router": "@storybook/nextjs/router.mock",
56
- "next/cache": "@storybook/nextjs/cache.mock",
57
- ...getCompatibilityAliases()
58
- };
59
- var getPackageAliases = /* @__PURE__ */ __name(() => {
60
- return mapping2;
61
- }, "getPackageAliases");
62
- var configureNextExportMocks = /* @__PURE__ */ __name((baseConfig) => {
63
- const resolve = baseConfig.resolve ?? {};
64
- resolve.alias = {
65
- ...resolve.alias,
66
- ...mapping2
67
- };
68
- }, "configureNextExportMocks");
69
-
70
- export {
71
- configureCompatibilityAliases,
72
- getPackageAliases,
73
- configureNextExportMocks
74
- };
@@ -1,102 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_mt98813ktw from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_mt98813ktw from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_mt98813ktw from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_mt98813ktw.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_mt98813ktw.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_mt98813ktw.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- resolvePackageDir
14
- } from "./chunk-UHO3ELD2.js";
15
- import {
16
- __name
17
- } from "./chunk-PWZWGY6W.js";
18
-
19
- // src/utils.ts
20
- import { readFileSync } from "node:fs";
21
- import { dirname, join, sep } from "node:path";
22
- import { fileURLToPath } from "node:url";
23
- import { getProjectRoot } from "storybook/internal/common";
24
- import { WebpackDefinePlugin } from "@storybook/builder-webpack5";
25
- import { PHASE_DEVELOPMENT_SERVER } from "next/constants.js";
26
- import nextJsLoadConfigModule from "next/dist/server/config.js";
27
- import semver from "semver";
28
- var configureRuntimeNextjsVersionResolution = /* @__PURE__ */ __name((baseConfig) => {
29
- baseConfig.plugins?.push(
30
- new WebpackDefinePlugin({
31
- "process.env.__NEXT_VERSION": JSON.stringify(getNextjsVersion())
32
- })
33
- );
34
- }, "configureRuntimeNextjsVersionResolution");
35
- var getNextjsVersion = /* @__PURE__ */ __name(() => JSON.parse(readFileSync(join(resolvePackageDir("next"), "package.json"), "utf8")).version, "getNextjsVersion");
36
- var isNextVersionGte = /* @__PURE__ */ __name((version) => {
37
- const currentVersion = getNextjsVersion();
38
- const coercedVersion = semver.coerce(currentVersion);
39
- return coercedVersion ? semver.gte(coercedVersion, version) : false;
40
- }, "isNextVersionGte");
41
- var resolveNextConfig = /* @__PURE__ */ __name(async ({
42
- nextConfigPath
43
- }) => {
44
- const dir = nextConfigPath ? dirname(nextConfigPath) : getProjectRoot();
45
- const loadConfig = nextJsLoadConfigModule.default ?? nextJsLoadConfigModule;
46
- const nextPrivateRenderWorker = process.env.__NEXT_PRIVATE_RENDER_WORKER;
47
- process.env.__NEXT_PRIVATE_RENDER_WORKER = "defined";
48
- const config = loadConfig(PHASE_DEVELOPMENT_SERVER, dir, void 0);
49
- if (typeof nextPrivateRenderWorker === "undefined") {
50
- delete process.env.__NEXT_PRIVATE_RENDER_WORKER;
51
- } else {
52
- process.env.__NEXT_PRIVATE_RENDER_WORKER = nextPrivateRenderWorker;
53
- }
54
- return config;
55
- }, "resolveNextConfig");
56
- function setAlias(baseConfig, name, alias) {
57
- baseConfig.resolve ??= {};
58
- baseConfig.resolve.alias ??= {};
59
- const aliasConfig = baseConfig.resolve.alias;
60
- if (Array.isArray(aliasConfig)) {
61
- aliasConfig.push({
62
- name,
63
- alias
64
- });
65
- } else {
66
- aliasConfig[name] = alias;
67
- }
68
- }
69
- __name(setAlias, "setAlias");
70
- var addScopedAlias = /* @__PURE__ */ __name((baseConfig, name, alias) => {
71
- const scopedAlias = scopedResolve(`${alias ?? name}`);
72
- setAlias(baseConfig, name, scopedAlias);
73
- }, "addScopedAlias");
74
- var scopedResolve = /* @__PURE__ */ __name((id) => {
75
- const scopedModulePath = fileURLToPath(import.meta.resolve(id));
76
- const idWithNativePathSep = id.replace(/\//g, sep);
77
- if (scopedModulePath.endsWith(idWithNativePathSep)) {
78
- return scopedModulePath;
79
- }
80
- const moduleFolderStrPosition = scopedModulePath.lastIndexOf(idWithNativePathSep);
81
- const beginningOfMainScriptPath = moduleFolderStrPosition + id.length;
82
- return scopedModulePath.substring(0, beginningOfMainScriptPath);
83
- }, "scopedResolve");
84
- function getNodeModulesExcludeRegex(transpilePackages) {
85
- if (!transpilePackages || transpilePackages.length === 0) {
86
- return /node_modules/;
87
- }
88
- const escaped = transpilePackages.map((pkg) => pkg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
89
- return new RegExp(`node_modules/(?!(${escaped})/)`);
90
- }
91
- __name(getNodeModulesExcludeRegex, "getNodeModulesExcludeRegex");
92
-
93
- export {
94
- configureRuntimeNextjsVersionResolution,
95
- getNextjsVersion,
96
- isNextVersionGte,
97
- resolveNextConfig,
98
- setAlias,
99
- addScopedAlias,
100
- scopedResolve,
101
- getNodeModulesExcludeRegex
102
- };
@@ -1,36 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_mt98813ktw from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_mt98813ktw from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_mt98813ktw from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_mt98813ktw.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_mt98813ktw.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_mt98813ktw.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- __name
14
- } from "./chunk-PWZWGY6W.js";
15
-
16
- // src/font/webpack/configureNextFont.ts
17
- function configureNextFont(baseConfig, isSWC) {
18
- if (isSWC) {
19
- baseConfig.module?.rules?.push({
20
- test: /next(\\|\/|\\\\).*(\\|\/|\\\\)target\.css$/,
21
- loader: "@storybook/nextjs/storybook-nextjs-font-loader"
22
- });
23
- } else {
24
- baseConfig.resolveLoader = {
25
- ...baseConfig.resolveLoader,
26
- alias: {
27
- ...baseConfig.resolveLoader?.alias,
28
- "storybook-nextjs-font-loader": "@storybook/nextjs/storybook-nextjs-font-loader"
29
- }
30
- };
31
- }
32
- }
33
- __name(configureNextFont, "configureNextFont");
34
- export {
35
- configureNextFont
36
- };