@cmssy/astro 11.5.1 → 11.7.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.
- package/dist/index.d.cts +0 -49
- package/dist/index.d.ts +0 -49
- package/package.json +19 -9
package/dist/index.d.cts
CHANGED
|
@@ -4,39 +4,13 @@ import { BlockDefinition } from '@cmssy/react';
|
|
|
4
4
|
|
|
5
5
|
declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
|
|
6
6
|
interface CmssyMiddlewareOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Strip the language prefix before the app sees it, so a static route like
|
|
9
|
-
* `/shop` serves `/no/shop` too. Leave it off for a catch-all app that reads
|
|
10
|
-
* the language off the path itself.
|
|
11
|
-
*/
|
|
12
7
|
stripLocalePrefix?: boolean;
|
|
13
8
|
}
|
|
14
9
|
interface AstroContextLike {
|
|
15
10
|
url: URL;
|
|
16
11
|
request: Request;
|
|
17
12
|
}
|
|
18
|
-
/**
|
|
19
|
-
* The rewrite payload goes to `next`, not to `context.rewrite`. Both reach
|
|
20
|
-
* `applyRewriteToState`, but `context.rewrite` builds a fresh `AstroMiddleware`
|
|
21
|
-
* and runs this whole chain again on the rewritten URL - where the language
|
|
22
|
-
* prefix it just removed is gone, so a second pass resolved the default
|
|
23
|
-
* language and overwrote the first pass's answer.
|
|
24
|
-
*/
|
|
25
13
|
type CmssyNext = (payload?: string | URL | Request) => Promise<Response> | Response;
|
|
26
|
-
/**
|
|
27
|
-
* The whole middleware a cmssy Astro app needs, in the order it has to happen:
|
|
28
|
-
*
|
|
29
|
-
* 1. resolve the language and pass it on;
|
|
30
|
-
* 2. send a VERIFIED editor request to /cmssy-edit, carrying that language and
|
|
31
|
-
* the edit flag - a prerendered page never sees the query string that would
|
|
32
|
-
* put it in edit mode;
|
|
33
|
-
* 3. strip the language prefix for everything else, if asked.
|
|
34
|
-
*
|
|
35
|
-
* The order is not a detail. Resolve the locale after the rewrite and the editor
|
|
36
|
-
* preview renders in the wrong language; drop the edit flag and the header and
|
|
37
|
-
* footer become markup the editor can select but not fill. Both mistakes shipped
|
|
38
|
-
* in the Next app before this sequence existed.
|
|
39
|
-
*/
|
|
40
14
|
declare function cmssyMiddleware(config: CmssyConfig, options?: CmssyMiddlewareOptions): (context: AstroContextLike, next: CmssyNext) => Promise<Response>;
|
|
41
15
|
|
|
42
16
|
interface CmssyPageResult {
|
|
@@ -45,17 +19,7 @@ interface CmssyPageResult {
|
|
|
45
19
|
locale: string;
|
|
46
20
|
defaultLocale: string;
|
|
47
21
|
enabledLocales: string[];
|
|
48
|
-
/** True for a verified editor request. The edit route renders the bridge. */
|
|
49
22
|
isEdit: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Edit mode only, and only when `blocks` was passed: what the canvas needs,
|
|
52
|
-
* **keyed by position**. The header and the footer hold different blocks, so
|
|
53
|
-
* they resolve to different data - handing the footer the header's is the
|
|
54
|
-
* quiet version of this bug.
|
|
55
|
-
*
|
|
56
|
-
* Without `resolvedContent` a relation field shows the raw ids it stores,
|
|
57
|
-
* which is what this adapter did until now.
|
|
58
|
-
*/
|
|
59
23
|
editorData?: Record<string, CmssyLayoutEditorData>;
|
|
60
24
|
editorOrigin?: string | string[];
|
|
61
25
|
}
|
|
@@ -64,23 +28,10 @@ interface CmssyLayoutEditorData {
|
|
|
64
28
|
resolvedContent: Record<string, Record<string, unknown>>;
|
|
65
29
|
}
|
|
66
30
|
interface LoadCmssyPageOptions {
|
|
67
|
-
/**
|
|
68
|
-
* The block registry. Required to resolve the editor's layout data; omit it
|
|
69
|
-
* and the layouts still render, but the editor cannot fill them.
|
|
70
|
-
*/
|
|
71
31
|
blocks?: BlockDefinition[];
|
|
72
|
-
/** Which positions the editor renders. Defaults to the header and footer. */
|
|
73
32
|
positions?: string[];
|
|
74
33
|
appContext?: Record<string, unknown>;
|
|
75
34
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Everything a cmssy page needs, from a plain Request. No framework globals.
|
|
78
|
-
*
|
|
79
|
-
* The layout half is `resolveCmssyLayoutSlot` from `@cmssy/react` - the same
|
|
80
|
-
* function the Next adapter uses, so the preview secret, the language and the
|
|
81
|
-
* editor data are decided in one place for all three frameworks rather than
|
|
82
|
-
* three times with two of them wrong.
|
|
83
|
-
*/
|
|
84
35
|
declare function loadCmssyPage(config: CmssyConfig, request: Request, url: URL, options?: LoadCmssyPageOptions): Promise<CmssyPageResult>;
|
|
85
36
|
|
|
86
37
|
export { CMSSY_EDIT_PATH_PREFIX, type CmssyMiddlewareOptions, type CmssyPageResult, cmssyMiddleware, loadCmssyPage };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,39 +4,13 @@ import { BlockDefinition } from '@cmssy/react';
|
|
|
4
4
|
|
|
5
5
|
declare const CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
|
|
6
6
|
interface CmssyMiddlewareOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Strip the language prefix before the app sees it, so a static route like
|
|
9
|
-
* `/shop` serves `/no/shop` too. Leave it off for a catch-all app that reads
|
|
10
|
-
* the language off the path itself.
|
|
11
|
-
*/
|
|
12
7
|
stripLocalePrefix?: boolean;
|
|
13
8
|
}
|
|
14
9
|
interface AstroContextLike {
|
|
15
10
|
url: URL;
|
|
16
11
|
request: Request;
|
|
17
12
|
}
|
|
18
|
-
/**
|
|
19
|
-
* The rewrite payload goes to `next`, not to `context.rewrite`. Both reach
|
|
20
|
-
* `applyRewriteToState`, but `context.rewrite` builds a fresh `AstroMiddleware`
|
|
21
|
-
* and runs this whole chain again on the rewritten URL - where the language
|
|
22
|
-
* prefix it just removed is gone, so a second pass resolved the default
|
|
23
|
-
* language and overwrote the first pass's answer.
|
|
24
|
-
*/
|
|
25
13
|
type CmssyNext = (payload?: string | URL | Request) => Promise<Response> | Response;
|
|
26
|
-
/**
|
|
27
|
-
* The whole middleware a cmssy Astro app needs, in the order it has to happen:
|
|
28
|
-
*
|
|
29
|
-
* 1. resolve the language and pass it on;
|
|
30
|
-
* 2. send a VERIFIED editor request to /cmssy-edit, carrying that language and
|
|
31
|
-
* the edit flag - a prerendered page never sees the query string that would
|
|
32
|
-
* put it in edit mode;
|
|
33
|
-
* 3. strip the language prefix for everything else, if asked.
|
|
34
|
-
*
|
|
35
|
-
* The order is not a detail. Resolve the locale after the rewrite and the editor
|
|
36
|
-
* preview renders in the wrong language; drop the edit flag and the header and
|
|
37
|
-
* footer become markup the editor can select but not fill. Both mistakes shipped
|
|
38
|
-
* in the Next app before this sequence existed.
|
|
39
|
-
*/
|
|
40
14
|
declare function cmssyMiddleware(config: CmssyConfig, options?: CmssyMiddlewareOptions): (context: AstroContextLike, next: CmssyNext) => Promise<Response>;
|
|
41
15
|
|
|
42
16
|
interface CmssyPageResult {
|
|
@@ -45,17 +19,7 @@ interface CmssyPageResult {
|
|
|
45
19
|
locale: string;
|
|
46
20
|
defaultLocale: string;
|
|
47
21
|
enabledLocales: string[];
|
|
48
|
-
/** True for a verified editor request. The edit route renders the bridge. */
|
|
49
22
|
isEdit: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Edit mode only, and only when `blocks` was passed: what the canvas needs,
|
|
52
|
-
* **keyed by position**. The header and the footer hold different blocks, so
|
|
53
|
-
* they resolve to different data - handing the footer the header's is the
|
|
54
|
-
* quiet version of this bug.
|
|
55
|
-
*
|
|
56
|
-
* Without `resolvedContent` a relation field shows the raw ids it stores,
|
|
57
|
-
* which is what this adapter did until now.
|
|
58
|
-
*/
|
|
59
23
|
editorData?: Record<string, CmssyLayoutEditorData>;
|
|
60
24
|
editorOrigin?: string | string[];
|
|
61
25
|
}
|
|
@@ -64,23 +28,10 @@ interface CmssyLayoutEditorData {
|
|
|
64
28
|
resolvedContent: Record<string, Record<string, unknown>>;
|
|
65
29
|
}
|
|
66
30
|
interface LoadCmssyPageOptions {
|
|
67
|
-
/**
|
|
68
|
-
* The block registry. Required to resolve the editor's layout data; omit it
|
|
69
|
-
* and the layouts still render, but the editor cannot fill them.
|
|
70
|
-
*/
|
|
71
31
|
blocks?: BlockDefinition[];
|
|
72
|
-
/** Which positions the editor renders. Defaults to the header and footer. */
|
|
73
32
|
positions?: string[];
|
|
74
33
|
appContext?: Record<string, unknown>;
|
|
75
34
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Everything a cmssy page needs, from a plain Request. No framework globals.
|
|
78
|
-
*
|
|
79
|
-
* The layout half is `resolveCmssyLayoutSlot` from `@cmssy/react` - the same
|
|
80
|
-
* function the Next adapter uses, so the preview secret, the language and the
|
|
81
|
-
* editor data are decided in one place for all three frameworks rather than
|
|
82
|
-
* three times with two of them wrong.
|
|
83
|
-
*/
|
|
84
35
|
declare function loadCmssyPage(config: CmssyConfig, request: Request, url: URL, options?: LoadCmssyPageOptions): Promise<CmssyPageResult>;
|
|
85
36
|
|
|
86
37
|
export { CMSSY_EDIT_PATH_PREFIX, type CmssyMiddlewareOptions, type CmssyPageResult, cmssyMiddleware, loadCmssyPage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/astro",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.7.0",
|
|
4
4
|
"description": "Astro bindings for cmssy headless sites: middleware, page loader, sitemap and robots.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -22,14 +22,24 @@
|
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./dist/index.d.cts",
|
|
31
|
+
"default": "./dist/index.cjs"
|
|
32
|
+
}
|
|
28
33
|
},
|
|
29
34
|
"./testing": {
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/testing.d.ts",
|
|
37
|
+
"default": "./dist/testing.js"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/testing.d.cts",
|
|
41
|
+
"default": "./dist/testing.cjs"
|
|
42
|
+
}
|
|
33
43
|
}
|
|
34
44
|
},
|
|
35
45
|
"main": "./dist/index.cjs",
|
|
@@ -47,10 +57,10 @@
|
|
|
47
57
|
"tsup": "^8.3.0",
|
|
48
58
|
"typescript": "^5.6.0",
|
|
49
59
|
"vitest": "^2.1.0",
|
|
50
|
-
"@cmssy/react": "11.
|
|
60
|
+
"@cmssy/react": "11.7.0"
|
|
51
61
|
},
|
|
52
62
|
"dependencies": {
|
|
53
|
-
"@cmssy/core": "11.
|
|
63
|
+
"@cmssy/core": "11.7.0"
|
|
54
64
|
},
|
|
55
65
|
"scripts": {
|
|
56
66
|
"build": "tsup",
|