next 15.4.0-canary.58 → 15.4.0-canary.59

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 (46) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/collect-build-traces.js +6 -2
  3. package/dist/build/collect-build-traces.js.map +1 -1
  4. package/dist/build/index.js +7 -8
  5. package/dist/build/index.js.map +1 -1
  6. package/dist/build/preview-key-utils.d.ts +5 -0
  7. package/dist/build/preview-key-utils.js +91 -0
  8. package/dist/build/preview-key-utils.js.map +1 -0
  9. package/dist/build/swc/generated-native.d.ts +0 -1
  10. package/dist/build/swc/index.js +1 -1
  11. package/dist/build/swc/types.d.ts +0 -1
  12. package/dist/build/webpack-config.js +2 -2
  13. package/dist/client/app-bootstrap.js +1 -1
  14. package/dist/client/index.js +1 -1
  15. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +2 -2
  16. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
  17. package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js +1 -1
  18. package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js.map +1 -1
  19. package/dist/compiled/next-server/pages-turbo.runtime.prod.js +2 -2
  20. package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
  21. package/dist/esm/build/collect-build-traces.js +6 -2
  22. package/dist/esm/build/collect-build-traces.js.map +1 -1
  23. package/dist/esm/build/index.js +7 -8
  24. package/dist/esm/build/index.js.map +1 -1
  25. package/dist/esm/build/preview-key-utils.js +81 -0
  26. package/dist/esm/build/preview-key-utils.js.map +1 -0
  27. package/dist/esm/build/swc/generated-native.d.ts +0 -1
  28. package/dist/esm/build/swc/index.js +1 -1
  29. package/dist/esm/build/swc/types.js.map +1 -1
  30. package/dist/esm/build/webpack-config.js +2 -2
  31. package/dist/esm/client/app-bootstrap.js +1 -1
  32. package/dist/esm/client/index.js +1 -1
  33. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  34. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  35. package/dist/esm/server/lib/app-info-log.js +1 -1
  36. package/dist/esm/server/lib/start-server.js +1 -1
  37. package/dist/esm/shared/lib/canary-only.js +1 -1
  38. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  39. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  40. package/dist/server/lib/app-info-log.js +1 -1
  41. package/dist/server/lib/start-server.js +1 -1
  42. package/dist/shared/lib/canary-only.js +1 -1
  43. package/dist/telemetry/anonymous-meta.js +1 -1
  44. package/dist/telemetry/events/session-stopped.js +2 -2
  45. package/dist/telemetry/events/version.js +2 -2
  46. package/package.json +15 -15
@@ -0,0 +1,5 @@
1
+ import type { __ApiPreviewProps } from '../server/api-utils';
2
+ export declare function generatePreviewKeys({ distDir, isBuild, }: {
3
+ distDir: string;
4
+ isBuild: boolean;
5
+ }): Promise<__ApiPreviewProps>;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "generatePreviewKeys", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return generatePreviewKeys;
9
+ }
10
+ });
11
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
13
+ const _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
14
+ const _cachedir = require("../server/cache-dir");
15
+ function _interop_require_default(obj) {
16
+ return obj && obj.__esModule ? obj : {
17
+ default: obj
18
+ };
19
+ }
20
+ const CONFIG_FILE = '.previewinfo';
21
+ const PREVIEW_ID = 'previewModeId';
22
+ const PREVIEW_SIGNING_KEY = 'previewModeSigningKey';
23
+ const PREVIEW_ENCRYPTION_KEY = 'previewModeEncryptionKey';
24
+ const PREVIEW_EXPIRE_AT = 'expireAt';
25
+ const EXPIRATION = 1000 * 60 * 60 * 24 * 14 // 14 days
26
+ ;
27
+ async function writeCache(distDir, config) {
28
+ const cacheBaseDir = (0, _cachedir.getStorageDirectory)(distDir);
29
+ if (!cacheBaseDir) return;
30
+ const configPath = _path.default.join(cacheBaseDir, CONFIG_FILE);
31
+ if (!_fs.default.existsSync(cacheBaseDir)) {
32
+ await _fs.default.promises.mkdir(cacheBaseDir, {
33
+ recursive: true
34
+ });
35
+ }
36
+ await _fs.default.promises.writeFile(configPath, JSON.stringify({
37
+ [PREVIEW_ID]: config.previewModeId,
38
+ [PREVIEW_SIGNING_KEY]: config.previewModeSigningKey,
39
+ [PREVIEW_ENCRYPTION_KEY]: config.previewModeEncryptionKey,
40
+ [PREVIEW_EXPIRE_AT]: Date.now() + EXPIRATION
41
+ }));
42
+ }
43
+ function generateConfig() {
44
+ return {
45
+ previewModeId: _crypto.default.randomBytes(16).toString('hex'),
46
+ previewModeSigningKey: _crypto.default.randomBytes(32).toString('hex'),
47
+ previewModeEncryptionKey: _crypto.default.randomBytes(32).toString('hex')
48
+ };
49
+ }
50
+ async function generatePreviewKeys({ distDir, isBuild }) {
51
+ const cacheBaseDir = (0, _cachedir.getStorageDirectory)(distDir);
52
+ if (!cacheBaseDir) {
53
+ // There's no persistent storage available. We generate a new config.
54
+ // This also covers development time.
55
+ return generateConfig();
56
+ }
57
+ const configPath = _path.default.join(cacheBaseDir, CONFIG_FILE);
58
+ async function tryReadCachedConfig() {
59
+ if (!_fs.default.existsSync(configPath)) return false;
60
+ try {
61
+ const config = JSON.parse(await _fs.default.promises.readFile(configPath, 'utf8'));
62
+ if (!config) return false;
63
+ if (typeof config[PREVIEW_ID] !== 'string' || typeof config[PREVIEW_ENCRYPTION_KEY] !== 'string' || typeof config[PREVIEW_SIGNING_KEY] !== 'string' || typeof config[PREVIEW_EXPIRE_AT] !== 'number') {
64
+ return false;
65
+ }
66
+ // For build time, we need to rotate the key if it's expired. Otherwise
67
+ // (next start) we have to keep the key as it is so the runtime key matches
68
+ // the build time key.
69
+ if (isBuild && config[PREVIEW_EXPIRE_AT] < Date.now()) {
70
+ return false;
71
+ }
72
+ return {
73
+ previewModeId: config[PREVIEW_ID],
74
+ previewModeSigningKey: config[PREVIEW_SIGNING_KEY],
75
+ previewModeEncryptionKey: config[PREVIEW_ENCRYPTION_KEY]
76
+ };
77
+ } catch (e) {
78
+ // Broken config file. We should generate a new key and overwrite it.
79
+ return false;
80
+ }
81
+ }
82
+ const maybeValidConfig = await tryReadCachedConfig();
83
+ if (maybeValidConfig !== false) {
84
+ return maybeValidConfig;
85
+ }
86
+ const config = generateConfig();
87
+ await writeCache(distDir, config);
88
+ return config;
89
+ }
90
+
91
+ //# sourceMappingURL=preview-key-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/build/preview-key-utils.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport crypto from 'crypto'\nimport type { __ApiPreviewProps } from '../server/api-utils'\nimport { getStorageDirectory } from '../server/cache-dir'\n\nconst CONFIG_FILE = '.previewinfo'\nconst PREVIEW_ID = 'previewModeId'\nconst PREVIEW_SIGNING_KEY = 'previewModeSigningKey'\nconst PREVIEW_ENCRYPTION_KEY = 'previewModeEncryptionKey'\nconst PREVIEW_EXPIRE_AT = 'expireAt'\nconst EXPIRATION = 1000 * 60 * 60 * 24 * 14 // 14 days\n\nasync function writeCache(distDir: string, config: __ApiPreviewProps) {\n const cacheBaseDir = getStorageDirectory(distDir)\n if (!cacheBaseDir) return\n\n const configPath = path.join(cacheBaseDir, CONFIG_FILE)\n if (!fs.existsSync(cacheBaseDir)) {\n await fs.promises.mkdir(cacheBaseDir, { recursive: true })\n }\n await fs.promises.writeFile(\n configPath,\n JSON.stringify({\n [PREVIEW_ID]: config.previewModeId,\n [PREVIEW_SIGNING_KEY]: config.previewModeSigningKey,\n [PREVIEW_ENCRYPTION_KEY]: config.previewModeEncryptionKey,\n [PREVIEW_EXPIRE_AT]: Date.now() + EXPIRATION,\n })\n )\n}\n\nfunction generateConfig() {\n return {\n previewModeId: crypto.randomBytes(16).toString('hex'),\n previewModeSigningKey: crypto.randomBytes(32).toString('hex'),\n previewModeEncryptionKey: crypto.randomBytes(32).toString('hex'),\n }\n}\n\n// This utility is used to get a key for the cache directory. If the\n// key is not present, it will generate a new one and store it in the\n// cache directory inside dist.\n// The key will also expire after a certain amount of time. Once it\n// expires, a new one will be generated.\nexport async function generatePreviewKeys({\n distDir,\n isBuild,\n}: {\n distDir: string\n isBuild: boolean\n}): Promise<__ApiPreviewProps> {\n const cacheBaseDir = getStorageDirectory(distDir)\n\n if (!cacheBaseDir) {\n // There's no persistent storage available. We generate a new config.\n // This also covers development time.\n return generateConfig()\n }\n\n const configPath = path.join(cacheBaseDir, CONFIG_FILE)\n async function tryReadCachedConfig(): Promise<false | __ApiPreviewProps> {\n if (!fs.existsSync(configPath)) return false\n try {\n const config = JSON.parse(await fs.promises.readFile(configPath, 'utf8'))\n if (!config) return false\n if (\n typeof config[PREVIEW_ID] !== 'string' ||\n typeof config[PREVIEW_ENCRYPTION_KEY] !== 'string' ||\n typeof config[PREVIEW_SIGNING_KEY] !== 'string' ||\n typeof config[PREVIEW_EXPIRE_AT] !== 'number'\n ) {\n return false\n }\n // For build time, we need to rotate the key if it's expired. Otherwise\n // (next start) we have to keep the key as it is so the runtime key matches\n // the build time key.\n if (isBuild && config[PREVIEW_EXPIRE_AT] < Date.now()) {\n return false\n }\n\n return {\n previewModeId: config[PREVIEW_ID],\n previewModeSigningKey: config[PREVIEW_SIGNING_KEY],\n previewModeEncryptionKey: config[PREVIEW_ENCRYPTION_KEY],\n }\n } catch (e) {\n // Broken config file. We should generate a new key and overwrite it.\n return false\n }\n }\n const maybeValidConfig = await tryReadCachedConfig()\n if (maybeValidConfig !== false) {\n return maybeValidConfig\n }\n const config = generateConfig()\n await writeCache(distDir, config)\n\n return config\n}\n"],"names":["generatePreviewKeys","CONFIG_FILE","PREVIEW_ID","PREVIEW_SIGNING_KEY","PREVIEW_ENCRYPTION_KEY","PREVIEW_EXPIRE_AT","EXPIRATION","writeCache","distDir","config","cacheBaseDir","getStorageDirectory","configPath","path","join","fs","existsSync","promises","mkdir","recursive","writeFile","JSON","stringify","previewModeId","previewModeSigningKey","previewModeEncryptionKey","Date","now","generateConfig","crypto","randomBytes","toString","isBuild","tryReadCachedConfig","parse","readFile","e","maybeValidConfig"],"mappings":";;;;+BA6CsBA;;;eAAAA;;;6DA7CL;2DACF;+DACI;0BAEiB;;;;;;AAEpC,MAAMC,cAAc;AACpB,MAAMC,aAAa;AACnB,MAAMC,sBAAsB;AAC5B,MAAMC,yBAAyB;AAC/B,MAAMC,oBAAoB;AAC1B,MAAMC,aAAa,OAAO,KAAK,KAAK,KAAK,GAAG,UAAU;;AAEtD,eAAeC,WAAWC,OAAe,EAAEC,MAAyB;IAClE,MAAMC,eAAeC,IAAAA,6BAAmB,EAACH;IACzC,IAAI,CAACE,cAAc;IAEnB,MAAME,aAAaC,aAAI,CAACC,IAAI,CAACJ,cAAcT;IAC3C,IAAI,CAACc,WAAE,CAACC,UAAU,CAACN,eAAe;QAChC,MAAMK,WAAE,CAACE,QAAQ,CAACC,KAAK,CAACR,cAAc;YAAES,WAAW;QAAK;IAC1D;IACA,MAAMJ,WAAE,CAACE,QAAQ,CAACG,SAAS,CACzBR,YACAS,KAAKC,SAAS,CAAC;QACb,CAACpB,WAAW,EAAEO,OAAOc,aAAa;QAClC,CAACpB,oBAAoB,EAAEM,OAAOe,qBAAqB;QACnD,CAACpB,uBAAuB,EAAEK,OAAOgB,wBAAwB;QACzD,CAACpB,kBAAkB,EAAEqB,KAAKC,GAAG,KAAKrB;IACpC;AAEJ;AAEA,SAASsB;IACP,OAAO;QACLL,eAAeM,eAAM,CAACC,WAAW,CAAC,IAAIC,QAAQ,CAAC;QAC/CP,uBAAuBK,eAAM,CAACC,WAAW,CAAC,IAAIC,QAAQ,CAAC;QACvDN,0BAA0BI,eAAM,CAACC,WAAW,CAAC,IAAIC,QAAQ,CAAC;IAC5D;AACF;AAOO,eAAe/B,oBAAoB,EACxCQ,OAAO,EACPwB,OAAO,EAIR;IACC,MAAMtB,eAAeC,IAAAA,6BAAmB,EAACH;IAEzC,IAAI,CAACE,cAAc;QACjB,qEAAqE;QACrE,qCAAqC;QACrC,OAAOkB;IACT;IAEA,MAAMhB,aAAaC,aAAI,CAACC,IAAI,CAACJ,cAAcT;IAC3C,eAAegC;QACb,IAAI,CAAClB,WAAE,CAACC,UAAU,CAACJ,aAAa,OAAO;QACvC,IAAI;YACF,MAAMH,SAASY,KAAKa,KAAK,CAAC,MAAMnB,WAAE,CAACE,QAAQ,CAACkB,QAAQ,CAACvB,YAAY;YACjE,IAAI,CAACH,QAAQ,OAAO;YACpB,IACE,OAAOA,MAAM,CAACP,WAAW,KAAK,YAC9B,OAAOO,MAAM,CAACL,uBAAuB,KAAK,YAC1C,OAAOK,MAAM,CAACN,oBAAoB,KAAK,YACvC,OAAOM,MAAM,CAACJ,kBAAkB,KAAK,UACrC;gBACA,OAAO;YACT;YACA,uEAAuE;YACvE,2EAA2E;YAC3E,sBAAsB;YACtB,IAAI2B,WAAWvB,MAAM,CAACJ,kBAAkB,GAAGqB,KAAKC,GAAG,IAAI;gBACrD,OAAO;YACT;YAEA,OAAO;gBACLJ,eAAed,MAAM,CAACP,WAAW;gBACjCsB,uBAAuBf,MAAM,CAACN,oBAAoB;gBAClDsB,0BAA0BhB,MAAM,CAACL,uBAAuB;YAC1D;QACF,EAAE,OAAOgC,GAAG;YACV,qEAAqE;YACrE,OAAO;QACT;IACF;IACA,MAAMC,mBAAmB,MAAMJ;IAC/B,IAAII,qBAAqB,OAAO;QAC9B,OAAOA;IACT;IACA,MAAM5B,SAASmB;IACf,MAAMrB,WAAWC,SAASC;IAE1B,OAAOA;AACT","ignoreList":[0]}
@@ -347,7 +347,6 @@ export interface NapiIssue {
347
347
  detail?: any
348
348
  source?: NapiIssueSource
349
349
  documentationLink: string
350
- subIssues: Array<NapiIssue>
351
350
  }
352
351
  export interface NapiIssueSource {
353
352
  source: NapiSource
@@ -123,7 +123,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
123
123
  }
124
124
  return newObj;
125
125
  }
126
- const nextVersion = "15.4.0-canary.58";
126
+ const nextVersion = "15.4.0-canary.59";
127
127
  const ArchName = (0, _os.arch)();
128
128
  const PlatformName = (0, _os.platform)();
129
129
  function infoLog(...args) {
@@ -71,7 +71,6 @@ export interface Issue {
71
71
  };
72
72
  };
73
73
  documentationLink: string;
74
- subIssues: Issue[];
75
74
  }
76
75
  export interface Diagnostics {
77
76
  category: string;
@@ -1675,7 +1675,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
1675
1675
  isClient && new _copyfileplugin.CopyFilePlugin({
1676
1676
  // file path to build output of `@next/polyfill-nomodule`
1677
1677
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1678
- cacheKey: "15.4.0-canary.58",
1678
+ cacheKey: "15.4.0-canary.59",
1679
1679
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1680
1680
  minimize: false,
1681
1681
  info: {
@@ -1855,7 +1855,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
1855
1855
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1856
1856
  // - Next.js version
1857
1857
  // - next.config.js keys that affect compilation
1858
- version: `${__dirname}|${"15.4.0-canary.58"}|${configVars}`,
1858
+ version: `${__dirname}|${"15.4.0-canary.59"}|${configVars}`,
1859
1859
  cacheDirectory: _path.default.join(distDir, 'cache', 'webpack'),
1860
1860
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1861
1861
  // So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "appBootstrap", {
13
13
  return appBootstrap;
14
14
  }
15
15
  });
16
- const version = "15.4.0-canary.58";
16
+ const version = "15.4.0-canary.59";
17
17
  window.next = {
18
18
  version,
19
19
  appDir: true
@@ -61,7 +61,7 @@ const _hooksclientcontextsharedruntime = require("../shared/lib/hooks-client-con
61
61
  const _onrecoverableerror = require("./react-client-callbacks/on-recoverable-error");
62
62
  const _tracer = /*#__PURE__*/ _interop_require_default._(require("./tracing/tracer"));
63
63
  const _isnextroutererror = require("./components/is-next-router-error");
64
- const version = "15.4.0-canary.58";
64
+ const version = "15.4.0-canary.59";
65
65
  let router;
66
66
  const emitter = (0, _mitt.default)();
67
67
  const looseToArray = (input)=>[].slice.call(input);