canopycms-next 0.0.67-int.91 → 0.0.68-int.93
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/adapter.js +4 -1
- package/dist/config.cjs +3 -1
- package/dist/config.mjs +3 -1
- package/dist/context-wrapper.d.ts +2 -2
- package/dist/context-wrapper.js +5 -1
- package/dist/with-canopy.d.ts +1 -0
- package/dist/with-canopy.js +7 -0
- package/package.json +3 -3
package/dist/adapter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
-
import { createCanopyRequestHandler, isCanopyBinaryResponse, } from 'canopycms/http';
|
|
2
|
+
import { createCanopyRequestHandler, isCanopyBinaryResponse, workerNotReadyResponse, } from 'canopycms/http';
|
|
3
3
|
import { getErrorMessage, redactCredentials, sanitizeErrorMessage } from 'canopycms/utils/error';
|
|
4
4
|
/**
|
|
5
5
|
* Only uses standard Request methods, so any Request subclass works.
|
|
@@ -108,6 +108,9 @@ export const createCanopyCatchAllHandler = (options) => {
|
|
|
108
108
|
// but this line reaches the server log verbatim, and a git failure message can embed a
|
|
109
109
|
// token-bearing clone URL — the one thing that must not reach a log aggregator.
|
|
110
110
|
console.error('CanopyCMS: Unhandled error in Next.js catch-all handler:', redactCredentials(message));
|
|
111
|
+
const notReady = workerNotReadyResponse(err);
|
|
112
|
+
if (notReady)
|
|
113
|
+
return toNextResponse(notReady);
|
|
111
114
|
return toNextResponse({
|
|
112
115
|
status: 500,
|
|
113
116
|
body: { ok: false, status: 500, error: sanitizeErrorMessage(message) },
|
package/dist/config.cjs
CHANGED
|
@@ -399,6 +399,7 @@ function withCanopy(nextConfig = {}, options = {}) {
|
|
|
399
399
|
])
|
|
400
400
|
];
|
|
401
401
|
const generateBuildId = nextConfig.generateBuildId ?? (options.staticBuild ? resolveStaticBuildId : void 0);
|
|
402
|
+
const env = nextConfig.trailingSlash ? { CANOPY_API_TRAILING_SLASH: "true", ...nextConfig.env } : void 0;
|
|
402
403
|
return {
|
|
403
404
|
...nextConfig,
|
|
404
405
|
transpilePackages: allPackages,
|
|
@@ -409,7 +410,8 @@ function withCanopy(nextConfig = {}, options = {}) {
|
|
|
409
410
|
// Spread conditionally: emitting `generateBuildId: undefined` would be a key Next has to
|
|
410
411
|
// reason about, where absence is unambiguous.
|
|
411
412
|
...generateBuildId ? { generateBuildId } : {},
|
|
412
|
-
...answerTurbopackGuard ? { turbopack: {} } : {}
|
|
413
|
+
...answerTurbopackGuard ? { turbopack: {} } : {},
|
|
414
|
+
...env ? { env } : {}
|
|
413
415
|
};
|
|
414
416
|
}
|
|
415
417
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/config.mjs
CHANGED
|
@@ -363,6 +363,7 @@ function withCanopy(nextConfig = {}, options = {}) {
|
|
|
363
363
|
])
|
|
364
364
|
];
|
|
365
365
|
const generateBuildId = nextConfig.generateBuildId ?? (options.staticBuild ? resolveStaticBuildId : void 0);
|
|
366
|
+
const env = nextConfig.trailingSlash ? { CANOPY_API_TRAILING_SLASH: "true", ...nextConfig.env } : void 0;
|
|
366
367
|
return {
|
|
367
368
|
...nextConfig,
|
|
368
369
|
transpilePackages: allPackages,
|
|
@@ -373,7 +374,8 @@ function withCanopy(nextConfig = {}, options = {}) {
|
|
|
373
374
|
// Spread conditionally: emitting `generateBuildId: undefined` would be a key Next has to
|
|
374
375
|
// reason about, where absence is unambiguous.
|
|
375
376
|
...generateBuildId ? { generateBuildId } : {},
|
|
376
|
-
...answerTurbopackGuard ? { turbopack: {} } : {}
|
|
377
|
+
...answerTurbopackGuard ? { turbopack: {} } : {},
|
|
378
|
+
...env ? { env } : {}
|
|
377
379
|
};
|
|
378
380
|
}
|
|
379
381
|
export {
|
|
@@ -101,8 +101,8 @@ export interface NextCanopyContextResult {
|
|
|
101
101
|
*
|
|
102
102
|
* At build time this reads filesystem-direct; at request time it uses the branch-aware,
|
|
103
103
|
* **ACL-enforced** runtime context, so entries the current user cannot read are omitted.
|
|
104
|
-
*
|
|
105
|
-
*
|
|
104
|
+
* Pass the preview iframe's `?branch=` as `branch` on an index page so a content
|
|
105
|
+
* branch's entries show in preview — see `CanopyContext['listEntries']`.
|
|
106
106
|
*/
|
|
107
107
|
listEntries: CanopyContext['listEntries'];
|
|
108
108
|
/**
|
package/dist/context-wrapper.js
CHANGED
|
@@ -175,8 +175,12 @@ export async function createNextCanopyContext(options) {
|
|
|
175
175
|
//
|
|
176
176
|
// No base-branch context resolution needed here: request-time content reads
|
|
177
177
|
// (buildContentTree/listEntries/read) already provision the base/active branch via
|
|
178
|
-
// loadOrCreateBranchContext (see context.ts's
|
|
178
|
+
// loadOrCreateBranchContext (see context.ts's resolveListingSource); build-time reads never
|
|
179
179
|
// provision, they read the checkout.
|
|
180
|
+
//
|
|
181
|
+
// Failures propagate to the page's error boundary and never degrade to a user: a
|
|
182
|
+
// RemoteNotReadyError (the worker has not created the remote yet) names the cause in the
|
|
183
|
+
// server log, and only an HTTP route can answer it with a 503.
|
|
180
184
|
const extractUser = async () => {
|
|
181
185
|
const headersList = await headers();
|
|
182
186
|
const authResult = await authPlugin.authenticate(headersList);
|
package/dist/with-canopy.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface WithCanopyOptions {
|
|
|
40
40
|
* (kept under `experimental` on Next 13/14 or legacy spellings; your own includes stay), so a
|
|
41
41
|
* Turbopack `output: 'standalone'` server can load sharp — Next's tracing misses that library
|
|
42
42
|
* for sharp 0.35 (doesn't fix webpack builds); warns if the directory or version can't be found.
|
|
43
|
+
* - `trailingSlash: true` sets `env.CANOPY_API_TRAILING_SLASH`, so editor API calls skip Next's 308.
|
|
43
44
|
* - On Next 16+, sets `turbopack: {}` when your config has neither `turbopack` nor `webpack` and
|
|
44
45
|
* the Next version can be read — Next 16 defaults to Turbopack and exits when a config exports
|
|
45
46
|
* `webpack` (the React aliases above add one) with no `turbopack` key; a `turbopack` you set is
|
package/dist/with-canopy.js
CHANGED
|
@@ -337,6 +337,7 @@ function sharpTracingConfig(nextConfig, options) {
|
|
|
337
337
|
* (kept under `experimental` on Next 13/14 or legacy spellings; your own includes stay), so a
|
|
338
338
|
* Turbopack `output: 'standalone'` server can load sharp — Next's tracing misses that library
|
|
339
339
|
* for sharp 0.35 (doesn't fix webpack builds); warns if the directory or version can't be found.
|
|
340
|
+
* - `trailingSlash: true` sets `env.CANOPY_API_TRAILING_SLASH`, so editor API calls skip Next's 308.
|
|
340
341
|
* - On Next 16+, sets `turbopack: {}` when your config has neither `turbopack` nor `webpack` and
|
|
341
342
|
* the Next version can be read — Next 16 defaults to Turbopack and exits when a config exports
|
|
342
343
|
* `webpack` (the React aliases above add one) with no `turbopack` key; a `turbopack` you set is
|
|
@@ -448,6 +449,11 @@ export function withCanopy(nextConfig = {}, options = {}) {
|
|
|
448
449
|
// verbatim (`next/dist/build/generate-build-id.js`) — which is what makes a hex tree hash usable
|
|
449
450
|
// as a build id at all. Do not "helpfully" route this through the fallback.
|
|
450
451
|
const generateBuildId = nextConfig.generateBuildId ?? (options.staticBuild ? resolveStaticBuildId : undefined);
|
|
452
|
+
// Next substitutes `env` into every bundle at build time, where the API client reads it
|
|
453
|
+
// (`readApiTrailingSlashEnv` in canopycms's `api/request-url.ts`).
|
|
454
|
+
const env = nextConfig.trailingSlash
|
|
455
|
+
? { CANOPY_API_TRAILING_SLASH: 'true', ...nextConfig.env }
|
|
456
|
+
: undefined;
|
|
451
457
|
return {
|
|
452
458
|
...nextConfig,
|
|
453
459
|
transpilePackages: allPackages,
|
|
@@ -459,5 +465,6 @@ export function withCanopy(nextConfig = {}, options = {}) {
|
|
|
459
465
|
// reason about, where absence is unambiguous.
|
|
460
466
|
...(generateBuildId ? { generateBuildId } : {}),
|
|
461
467
|
...(answerTurbopackGuard ? { turbopack: {} } : {}),
|
|
468
|
+
...(env ? { env } : {}),
|
|
462
469
|
};
|
|
463
470
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canopycms-next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.68-int.93",
|
|
4
4
|
"description": "Next.js adapter for CanopyCMS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"next": "^13.5.7 || ^14.2.25 || ^15.5.21 || >=16.0.0 <16.2.0 || >=16.3.0 <17.0.0",
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0",
|
|
41
|
-
"canopycms": "0.0.
|
|
41
|
+
"canopycms": "0.0.68-int.93"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^22.9.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react": "^18.3.1",
|
|
49
49
|
"typescript": "^5.6.3",
|
|
50
50
|
"vitest": "^4.1.0",
|
|
51
|
-
"canopycms": "0.0.
|
|
51
|
+
"canopycms": "0.0.68-int.93"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "rm -rf dist && tsc -p tsconfig.build.json && node ../../scripts/add-js-extensions.mjs dist && esbuild src/config.ts --bundle --platform=node --packages=external --external:next --format=cjs --outfile=dist/config.cjs && esbuild src/config.ts --bundle --platform=node --packages=external --external:next --format=esm --outfile=dist/config.mjs",
|