@phtngyn/cms 0.2.0-beta.4 → 0.2.0-beta.6
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/README.md +31 -13
- package/package.json +7 -7
- package/src/ApplicationTypes.d.ts +3 -3
- package/src/Authoring.d.ts +11 -3
- package/src/{Configuration-BU-UyGoH.js → Configuration-JQ1qyaU0.js} +347 -189
- package/src/Configuration-JQ1qyaU0.js.map +1 -0
- package/src/Configuration.d.ts +1 -1
- package/src/Content.d.ts +7 -6
- package/src/Content.js +106 -47
- package/src/Content.js.map +1 -1
- package/src/ContentTransfer-BxwswWn3.js +86 -0
- package/src/ContentTransfer-BxwswWn3.js.map +1 -0
- package/src/{ContentTransfer-CRQet3QJ.d.ts → ContentTransfer-Z9FHyLez.d.ts} +33 -9
- package/src/{DocumentEngine-ClhFXW9M.js → DocumentEngine-j6Vi7nQo.js} +279 -178
- package/src/DocumentEngine-j6Vi7nQo.js.map +1 -0
- package/src/DocumentModel.d.ts +9 -2
- package/src/DocumentModel.js +17 -4
- package/src/DocumentModel.js.map +1 -1
- package/src/{Forms-DoB56hfe.js → Forms-CX-hwmJF.js} +18 -11
- package/src/Forms-CX-hwmJF.js.map +1 -0
- package/src/{Forms-BbkE7QfC.js → Forms-CfNPTiCr.js} +2 -2
- package/src/{Forms-BbkE7QfC.js.map → Forms-CfNPTiCr.js.map} +1 -1
- package/src/Media-j1bTritO.js +112 -0
- package/src/Media-j1bTritO.js.map +1 -0
- package/src/Module.js +0 -4
- package/src/Module.js.map +1 -1
- package/src/References-CCPDAPve.js +45 -0
- package/src/References-CCPDAPve.js.map +1 -0
- package/src/{S3MediaObjects-CR3p1WTg.js → S3MediaObjects-BRuPQbxl.js} +454 -516
- package/src/S3MediaObjects-BRuPQbxl.js.map +1 -0
- package/src/cli/content.js +6 -5
- package/src/cli/content.js.map +1 -1
- package/src/cli.js +16 -3
- package/src/cli.js.map +1 -1
- package/src/{connection-D5S9Iph-.js → connection-BP80q4d-.js} +2 -2
- package/src/{connection-D5S9Iph-.js.map → connection-BP80q4d-.js.map} +1 -1
- package/src/{dev-lifecycle-D3f9-upa.js → dev-lifecycle-CExksm2R.js} +27 -7
- package/src/dev-lifecycle-CExksm2R.js.map +1 -0
- package/src/{installation-fZtNxtoW.js → installation-BoG8E3nJ.js} +7982 -7155
- package/src/installation-BoG8E3nJ.js.map +1 -0
- package/src/internal/authoring-catalog.js +2 -2
- package/src/internal/authoring-compiler.js +35 -9
- package/src/internal/authoring-compiler.js.map +1 -1
- package/src/internal/authoring-metadata.js +14 -5
- package/src/internal/authoring-metadata.js.map +1 -1
- package/src/internal/configuration.js +27 -3
- package/src/internal/configuration.js.map +1 -1
- package/src/internal/dev-lifecycle.js +2 -2
- package/src/internal/document-model.js +134 -43
- package/src/internal/document-model.js.map +1 -1
- package/src/internal/field-metadata.js +2 -1
- package/src/internal/field-metadata.js.map +1 -1
- package/src/internal/form-capabilities.js +1 -1
- package/src/{location-CPX7oj0o.js → location-CMNGO3lU.js} +2 -2
- package/src/{location-CPX7oj0o.js.map → location-CMNGO3lU.js.map} +1 -1
- package/src/{metadata-BEZPWh-3.js → metadata-UzZmjwxM.js} +2 -2
- package/src/{metadata-BEZPWh-3.js.map → metadata-UzZmjwxM.js.map} +1 -1
- package/src/{models-C9kF9JlQ.js → models-5j67LMqW.js} +4 -4
- package/src/{models-C9kF9JlQ.js.map → models-5j67LMqW.js.map} +1 -1
- package/src/{models-ChRxBChy.js → models-VmGmG19-.js} +42 -130
- package/src/models-VmGmG19-.js.map +1 -0
- package/src/runtime/delivery/DocumentRenderer.js +5 -1
- package/src/runtime/delivery/DocumentRenderer.js.map +1 -1
- package/src/runtime/delivery/context.js +1 -1
- package/src/runtime/delivery/plugin.js +2 -2
- package/src/runtime/delivery/preview.d.ts +1 -1
- package/src/runtime/delivery/types.d.ts +1 -1
- package/src/runtime/delivery/useCmsDocumentSeo.d.ts +1 -1
- package/src/runtime/forms/document.js +2 -2
- package/src/runtime/forms/useCmsForm.js +2 -2
- package/src/runtime/installation.js +1 -1
- package/src/runtime/plugin.js +1 -1
- package/src/runtime/preview/CmsStudioPreviewMarker.js +18 -4
- package/src/runtime/preview/CmsStudioPreviewMarker.js.map +1 -1
- package/src/runtime/preview/connection.js +1 -1
- package/src/runtime/preview/controller.js +65 -74
- package/src/runtime/preview/controller.js.map +1 -1
- package/src/runtime/preview/overlay.js +85 -28
- package/src/runtime/preview/overlay.js.map +1 -1
- package/src/runtime/preview/plugin.client.js +4 -4
- package/src/runtime/preview/preview.css +50 -36
- package/src/runtime/preview/protocol.d.ts +11 -5
- package/src/runtime/preview/protocol.js +17 -5
- package/src/runtime/preview/protocol.js.map +1 -1
- package/src/runtime/preview/regions.js +142 -0
- package/src/runtime/preview/regions.js.map +1 -0
- package/src/runtime/preview/store.js +1 -1
- package/src/runtime/sitemap.js +9 -10
- package/src/runtime/sitemap.js.map +1 -1
- package/src/{scalars-B2lgGUnj.js → scalars-CVZqT3L0.js} +2 -6
- package/src/scalars-CVZqT3L0.js.map +1 -0
- package/src/{store-CCsjHaZm.js → store-PKKB8xa2.js} +49 -66
- package/src/store-PKKB8xa2.js.map +1 -0
- package/src/{types-DutFRtaG.d.ts → types-DZ0IV-Ow.d.ts} +14 -3
- package/studio/CreateDocumentDialog-DqvusuGU.js +335 -0
- package/studio/{documentPlanning-CDb31mnl.js → SelectMenu-BgikeouH.js} +16292 -12303
- package/studio/{editor-Bzlh3zXt.js → editor-P2rB7Csp.js} +11228 -11927
- package/studio/host.css +1 -1
- package/studio/host.js +28987 -34295
- package/studio/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/src/Configuration-BU-UyGoH.js.map +0 -1
- package/src/ContentTransfer-BhF9G56s.js +0 -57
- package/src/ContentTransfer-BhF9G56s.js.map +0 -1
- package/src/DocumentEngine-ClhFXW9M.js.map +0 -1
- package/src/Forms-DoB56hfe.js.map +0 -1
- package/src/S3MediaObjects-CR3p1WTg.js.map +0 -1
- package/src/dev-lifecycle-D3f9-upa.js.map +0 -1
- package/src/installation-fZtNxtoW.js.map +0 -1
- package/src/models-ChRxBChy.js.map +0 -1
- package/src/runtime/preview/targets.js +0 -101
- package/src/runtime/preview/targets.js.map +0 -1
- package/src/scalars-B2lgGUnj.js.map +0 -1
- package/src/store-CCsjHaZm.js.map +0 -1
- package/studio/CreateDocumentDialog-DJ8c0WZb.js +0 -256
- package/studio/dom-to-image-more.min-D6jGGdrW.js +0 -877
- package/studio/rolldown-runtime-B0aSnxlc.js +0 -20
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[data-cms-preview-decorated] {
|
|
2
|
-
cursor:
|
|
2
|
+
cursor: default;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
[data-cms-preview-overlay] {
|
|
@@ -15,12 +15,38 @@
|
|
|
15
15
|
box-sizing: border-box;
|
|
16
16
|
position: fixed;
|
|
17
17
|
pointer-events: none !important;
|
|
18
|
+
transition:
|
|
19
|
+
background-color 180ms cubic-bezier(0.23, 1, 0.32, 1),
|
|
20
|
+
border-color 140ms ease,
|
|
21
|
+
opacity 140ms ease;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
[data-cms-selection-outline] {
|
|
21
|
-
border:
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
border: 2px solid #2563eb;
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
background: rgb(37 99 235 / 6%);
|
|
28
|
+
box-shadow:
|
|
29
|
+
0 0 0 1px rgb(255 255 255 / 95%),
|
|
30
|
+
0 1px 3px rgb(0 0 0 / 18%);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[data-cms-selection-outline][data-cms-match='fallback'] {
|
|
34
|
+
border-style: dashed;
|
|
35
|
+
background: transparent;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-cms-selection-outline][data-cms-reveal] {
|
|
39
|
+
background: rgb(37 99 235 / 18%);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[data-cms-preview-overlay][data-cms-pending] [data-cms-selection-outline] {
|
|
43
|
+
opacity: 0.45;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[data-cms-hover-outline] {
|
|
47
|
+
border: 1px solid rgb(37 99 235 / 55%);
|
|
48
|
+
border-radius: 4px;
|
|
49
|
+
box-shadow: 0 0 0 1px rgb(255 255 255 / 80%);
|
|
24
50
|
}
|
|
25
51
|
|
|
26
52
|
[data-cms-selection-outline][hidden],
|
|
@@ -28,50 +54,38 @@
|
|
|
28
54
|
display: none;
|
|
29
55
|
}
|
|
30
56
|
|
|
31
|
-
[data-cms-selection-label]
|
|
32
|
-
|
|
57
|
+
[data-cms-selection-label-content] {
|
|
58
|
+
all: initial;
|
|
59
|
+
display: none;
|
|
33
60
|
position: absolute;
|
|
34
61
|
left: var(--cms-label-left, 0px);
|
|
35
62
|
top: var(--cms-label-top, -26px);
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
max-width: min(240px, calc(100vw - 8px));
|
|
65
|
+
overflow: hidden;
|
|
36
66
|
padding: 3px 7px;
|
|
37
|
-
border: 1px solid #fff;
|
|
38
67
|
border-radius: 4px;
|
|
39
|
-
background: #
|
|
68
|
+
background: #2563eb;
|
|
69
|
+
box-shadow: 0 0 0 1px rgb(255 255 255 / 95%);
|
|
40
70
|
color: #fff;
|
|
41
71
|
font:
|
|
42
72
|
500 11px/16px system-ui,
|
|
43
73
|
sans-serif;
|
|
74
|
+
text-overflow: ellipsis;
|
|
44
75
|
white-space: nowrap;
|
|
45
76
|
}
|
|
46
77
|
|
|
47
|
-
[data-cms-
|
|
48
|
-
|
|
49
|
-
box-sizing: border-box;
|
|
50
|
-
position: absolute;
|
|
51
|
-
width: min(12px, 40%);
|
|
52
|
-
height: min(12px, 40%);
|
|
53
|
-
border-top: 2px solid #fff;
|
|
54
|
-
border-left: 2px solid #fff;
|
|
55
|
-
pointer-events: none !important;
|
|
56
|
-
filter: drop-shadow(1px 0 #171717) drop-shadow(-1px 0 #171717) drop-shadow(0 1px #171717) drop-shadow(0 -1px #171717);
|
|
78
|
+
[data-cms-selection-label] > [data-cms-selection-label-content] {
|
|
79
|
+
display: block;
|
|
57
80
|
}
|
|
58
81
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
[data-cms-hover-corner='bottom-right'] {
|
|
69
|
-
bottom: 0;
|
|
70
|
-
right: 0;
|
|
71
|
-
transform: rotate(180deg);
|
|
72
|
-
}
|
|
73
|
-
[data-cms-hover-corner='bottom-left'] {
|
|
74
|
-
bottom: 0;
|
|
75
|
-
left: 0;
|
|
76
|
-
transform: rotate(270deg);
|
|
82
|
+
@media (prefers-reduced-motion: reduce) {
|
|
83
|
+
[data-cms-selection-outline],
|
|
84
|
+
[data-cms-hover-outline] {
|
|
85
|
+
transition: opacity 120ms ease;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[data-cms-selection-outline][data-cms-reveal] {
|
|
89
|
+
background: rgb(37 99 235 / 6%);
|
|
90
|
+
}
|
|
77
91
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
//#region src/runtime/preview/protocol.d.ts
|
|
2
2
|
export declare const CMS_PREVIEW_DECORATED_ATTRIBUTE = "data-cms-preview-decorated";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const CMS_PREVIEW_EDGE_PROPERTY = "edge";
|
|
4
|
+
export declare const CMS_PREVIEW_KIND_PROPERTY = "kind";
|
|
5
5
|
export declare const CMS_PREVIEW_MARKER_TAG = "cms-studio-preview-marker";
|
|
6
|
-
export declare const
|
|
7
|
-
export
|
|
8
|
-
export type
|
|
6
|
+
export declare const CMS_PREVIEW_NODE_PROPERTY = "node";
|
|
7
|
+
export type CmsPreviewTargetKind = 'component' | 'field' | 'native';
|
|
8
|
+
export type CmsPreviewMarkerEdge = 'end' | 'start';
|
|
9
|
+
export declare function previewMarkerComment(nodeId: string, kind: CmsPreviewTargetKind, edge: CmsPreviewMarkerEdge): string;
|
|
10
|
+
export declare function parsePreviewMarkerComment(value: string): {
|
|
11
|
+
readonly edge: CmsPreviewMarkerEdge;
|
|
12
|
+
readonly kind: CmsPreviewTargetKind;
|
|
13
|
+
readonly nodeId: string;
|
|
14
|
+
} | undefined;
|
|
9
15
|
//#endregion
|
|
10
16
|
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
//#region src/runtime/preview/protocol.ts
|
|
2
2
|
const CMS_PREVIEW_DECORATED_ATTRIBUTE = "data-cms-preview-decorated";
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const CMS_PREVIEW_EDGE_PROPERTY = "edge";
|
|
4
|
+
const CMS_PREVIEW_KIND_PROPERTY = "kind";
|
|
5
5
|
const CMS_PREVIEW_MARKER_TAG = "cms-studio-preview-marker";
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const CMS_PREVIEW_NODE_PROPERTY = "node";
|
|
7
|
+
const CMS_PREVIEW_COMMENT_PREFIX = "cms-preview";
|
|
8
|
+
function previewMarkerComment(nodeId, kind, edge) {
|
|
9
|
+
return `${CMS_PREVIEW_COMMENT_PREFIX}:${kind}:${edge}:${nodeId}`;
|
|
10
|
+
}
|
|
11
|
+
function parsePreviewMarkerComment(value) {
|
|
12
|
+
const [prefix, kind, edge, nodeId, extra] = value.split(":");
|
|
13
|
+
if (prefix !== CMS_PREVIEW_COMMENT_PREFIX || kind !== "component" && kind !== "field" && kind !== "native" || edge !== "end" && edge !== "start" || !nodeId || extra !== void 0) return void 0;
|
|
14
|
+
return {
|
|
15
|
+
edge,
|
|
16
|
+
kind,
|
|
17
|
+
nodeId
|
|
18
|
+
};
|
|
19
|
+
}
|
|
8
20
|
|
|
9
21
|
//#endregion
|
|
10
|
-
export { CMS_PREVIEW_DECORATED_ATTRIBUTE,
|
|
22
|
+
export { CMS_PREVIEW_DECORATED_ATTRIBUTE, CMS_PREVIEW_EDGE_PROPERTY, CMS_PREVIEW_KIND_PROPERTY, CMS_PREVIEW_MARKER_TAG, CMS_PREVIEW_NODE_PROPERTY, parsePreviewMarkerComment, previewMarkerComment };
|
|
11
23
|
//# sourceMappingURL=protocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","names":[],"sources":["../../../../../src/runtime/preview/protocol.ts"],"sourcesContent":["export const CMS_PREVIEW_DECORATED_ATTRIBUTE = 'data-cms-preview-decorated'\n\nexport const
|
|
1
|
+
{"version":3,"file":"protocol.js","names":[],"sources":["../../../../../src/runtime/preview/protocol.ts"],"sourcesContent":["export const CMS_PREVIEW_DECORATED_ATTRIBUTE = 'data-cms-preview-decorated'\n\nexport const CMS_PREVIEW_EDGE_PROPERTY = 'edge'\n\nexport const CMS_PREVIEW_KIND_PROPERTY = 'kind'\n\nexport const CMS_PREVIEW_MARKER_TAG = 'cms-studio-preview-marker'\n\nexport const CMS_PREVIEW_NODE_PROPERTY = 'node'\n\nexport type CmsPreviewTargetKind = 'component' | 'field' | 'native'\n\nexport type CmsPreviewMarkerEdge = 'end' | 'start'\n\nconst CMS_PREVIEW_COMMENT_PREFIX = 'cms-preview'\n\nexport function previewMarkerComment(nodeId: string, kind: CmsPreviewTargetKind, edge: CmsPreviewMarkerEdge): string {\n return `${CMS_PREVIEW_COMMENT_PREFIX}:${kind}:${edge}:${nodeId}`\n}\n\nexport function parsePreviewMarkerComment(value: string):\n | {\n readonly edge: CmsPreviewMarkerEdge\n readonly kind: CmsPreviewTargetKind\n readonly nodeId: string\n }\n | undefined {\n const [prefix, kind, edge, nodeId, extra] = value.split(':')\n\n if (\n prefix !== CMS_PREVIEW_COMMENT_PREFIX ||\n (kind !== 'component' && kind !== 'field' && kind !== 'native') ||\n (edge !== 'end' && edge !== 'start') ||\n !nodeId ||\n extra !== undefined\n )\n return undefined\n\n return { edge, kind, nodeId }\n}\n"],"mappings":";AAAA,MAAa,kCAAkC;AAE/C,MAAa,4BAA4B;AAEzC,MAAa,4BAA4B;AAEzC,MAAa,yBAAyB;AAEtC,MAAa,4BAA4B;AAMzC,MAAM,6BAA6B;AAEnC,SAAgB,qBAAqB,QAAgB,MAA4B,MAAoC;CACnH,OAAO,GAAG,2BAA2B,GAAG,KAAK,GAAG,KAAK,GAAG;AAC1D;AAEA,SAAgB,0BAA0B,OAM5B;CACZ,MAAM,CAAC,QAAQ,MAAM,MAAM,QAAQ,SAAS,MAAM,MAAM,GAAG;CAE3D,IACE,WAAW,8BACV,SAAS,eAAe,SAAS,WAAW,SAAS,YACrD,SAAS,SAAS,SAAS,WAC5B,CAAC,UACD,UAAU,QAEV,OAAO;CAET,OAAO;EAAE;EAAM;EAAM;CAAO;AAC9B"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { CMS_PREVIEW_DECORATED_ATTRIBUTE, parsePreviewMarkerComment } from "./protocol.js";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/preview/regions.ts
|
|
4
|
+
const TARGET_PRIORITY = {
|
|
5
|
+
component: 1,
|
|
6
|
+
field: 3,
|
|
7
|
+
native: 2
|
|
8
|
+
};
|
|
9
|
+
const COMMENT_NODE_FILTER = 128;
|
|
10
|
+
const DOCUMENT_NODE = 9;
|
|
11
|
+
/** Owns the DOM representation, hit testing and fallback resolution of semantic authoring regions. */
|
|
12
|
+
function mountPreviewRegions(root, view) {
|
|
13
|
+
const geometryCache = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
const collect = (scope = root) => {
|
|
15
|
+
const targets = /* @__PURE__ */ new Map();
|
|
16
|
+
const open = [];
|
|
17
|
+
const scopeNode = scope;
|
|
18
|
+
const ownerDocument = scopeNode.nodeType === DOCUMENT_NODE ? scopeNode : scope.ownerDocument;
|
|
19
|
+
if (!ownerDocument) return [];
|
|
20
|
+
const walker = ownerDocument.createTreeWalker(scopeNode, COMMENT_NODE_FILTER);
|
|
21
|
+
let current = walker.nextNode();
|
|
22
|
+
while (current) {
|
|
23
|
+
const comment = current;
|
|
24
|
+
const marker = parsePreviewMarkerComment(comment.data);
|
|
25
|
+
if (marker?.edge === "start") open.push({
|
|
26
|
+
comment,
|
|
27
|
+
depth: open.length,
|
|
28
|
+
kind: marker.kind,
|
|
29
|
+
nodeId: marker.nodeId
|
|
30
|
+
});
|
|
31
|
+
else if (marker?.edge === "end") {
|
|
32
|
+
const start = open.at(-1);
|
|
33
|
+
if (start?.kind === marker.kind && start.nodeId === marker.nodeId) {
|
|
34
|
+
open.pop();
|
|
35
|
+
const geometry = rangeGeometry(start.comment, comment, start.depth, geometryCache);
|
|
36
|
+
const key = `${marker.kind}:${marker.nodeId}`;
|
|
37
|
+
const target = targets.get(key);
|
|
38
|
+
targets.set(key, {
|
|
39
|
+
geometries: target ? [...target.geometries, geometry] : [geometry],
|
|
40
|
+
kind: marker.kind,
|
|
41
|
+
nodeId: marker.nodeId
|
|
42
|
+
});
|
|
43
|
+
} else open.length = 0;
|
|
44
|
+
}
|
|
45
|
+
current = walker.nextNode();
|
|
46
|
+
}
|
|
47
|
+
return [...targets.values()];
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
clear() {
|
|
51
|
+
for (const element of root.querySelectorAll(`[${CMS_PREVIEW_DECORATED_ATTRIBUTE}], [data-cms-hovered], [data-cms-selected]`)) {
|
|
52
|
+
element.removeAttribute(CMS_PREVIEW_DECORATED_ATTRIBUTE);
|
|
53
|
+
element.removeAttribute("data-cms-hovered");
|
|
54
|
+
element.removeAttribute("data-cms-selected");
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
decorate(scope) {
|
|
58
|
+
for (const target of collect(scope)) for (const geometry of target.geometries) geometry.element()?.setAttribute(CMS_PREVIEW_DECORATED_ATTRIBUTE, "");
|
|
59
|
+
},
|
|
60
|
+
hitTest(x, y, scope) {
|
|
61
|
+
const candidates = collect(scope).filter((target) => target.geometries.some((geometry) => geometry.rects().some((rect) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom)));
|
|
62
|
+
candidates.sort((left, right) => targetDepth(right) - targetDepth(left) || TARGET_PRIORITY[right.kind] - TARGET_PRIORITY[left.kind] || targetArea(left) - targetArea(right));
|
|
63
|
+
return candidates[0]?.nodeId;
|
|
64
|
+
},
|
|
65
|
+
locate(nodeId, fallbacks, scope) {
|
|
66
|
+
const visited = /* @__PURE__ */ new Set();
|
|
67
|
+
const targets = collect(scope);
|
|
68
|
+
let targetId = nodeId;
|
|
69
|
+
while (targetId && !visited.has(targetId)) {
|
|
70
|
+
visited.add(targetId);
|
|
71
|
+
const geometries = targets.filter((target) => target.nodeId === targetId).flatMap((target) => target.geometries);
|
|
72
|
+
if (geometries.length) return {
|
|
73
|
+
geometries,
|
|
74
|
+
nodeId: targetId
|
|
75
|
+
};
|
|
76
|
+
targetId = fallbacks[targetId];
|
|
77
|
+
}
|
|
78
|
+
return { geometries: [] };
|
|
79
|
+
},
|
|
80
|
+
nearest(geometries) {
|
|
81
|
+
const viewportCenter = view.innerHeight / 2;
|
|
82
|
+
return [...geometries].sort((left, right) => viewportDistance(left, viewportCenter, view) - viewportDistance(right, viewportCenter, view))[0]?.element();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function rangeGeometry(start, end, depth, cache) {
|
|
87
|
+
const cached = cache.get(start);
|
|
88
|
+
if (cached?.end === end && cached.geometry.depth === depth) return cached.geometry;
|
|
89
|
+
const geometry = {
|
|
90
|
+
depth,
|
|
91
|
+
element: () => rangeElement(start, end),
|
|
92
|
+
rects: () => rangeRectangles(start, end)
|
|
93
|
+
};
|
|
94
|
+
cache.set(start, {
|
|
95
|
+
end,
|
|
96
|
+
geometry
|
|
97
|
+
});
|
|
98
|
+
return geometry;
|
|
99
|
+
}
|
|
100
|
+
function rangeElement(start, end) {
|
|
101
|
+
if (!start.isConnected || !end.isConnected || start.parentNode !== end.parentNode) return void 0;
|
|
102
|
+
let current = start.nextSibling;
|
|
103
|
+
while (current && current !== end) {
|
|
104
|
+
if (current.nodeType === current.ELEMENT_NODE) return current;
|
|
105
|
+
current = current.nextSibling;
|
|
106
|
+
}
|
|
107
|
+
return start.parentElement ?? void 0;
|
|
108
|
+
}
|
|
109
|
+
function rangeRectangles(start, end) {
|
|
110
|
+
if (!start.isConnected || !end.isConnected) return [];
|
|
111
|
+
const range = start.ownerDocument.createRange();
|
|
112
|
+
try {
|
|
113
|
+
range.setStartAfter(start);
|
|
114
|
+
range.setEndBefore(end);
|
|
115
|
+
const rectangles = [...range.getClientRects()].filter(isVisibleRectangle);
|
|
116
|
+
if (rectangles.length) return rectangles;
|
|
117
|
+
} catch {}
|
|
118
|
+
const element = rangeElement(start, end);
|
|
119
|
+
return element ? [...element.getClientRects()].filter(isVisibleRectangle) : [];
|
|
120
|
+
}
|
|
121
|
+
function isVisibleRectangle(rectangle) {
|
|
122
|
+
return rectangle.width > 0 && rectangle.height > 0;
|
|
123
|
+
}
|
|
124
|
+
function targetDepth(target) {
|
|
125
|
+
return Math.max(0, ...target.geometries.map((geometry) => geometry.depth));
|
|
126
|
+
}
|
|
127
|
+
function targetArea(target) {
|
|
128
|
+
return Math.min(Infinity, ...target.geometries.flatMap((geometry) => geometry.rects().map((rect) => rect.width * rect.height)));
|
|
129
|
+
}
|
|
130
|
+
function viewportDistance(geometry, viewportCenter, view) {
|
|
131
|
+
const rectangles = geometry.rects();
|
|
132
|
+
const top = Math.min(Infinity, ...rectangles.map((rectangle) => rectangle.top));
|
|
133
|
+
const bottom = Math.max(-Infinity, ...rectangles.map((rectangle) => rectangle.bottom));
|
|
134
|
+
if (!Number.isFinite(top) || !Number.isFinite(bottom)) return Infinity;
|
|
135
|
+
const visible = bottom >= 0 && top <= view.innerHeight;
|
|
136
|
+
const distance = Math.abs((top + bottom) / 2 - viewportCenter);
|
|
137
|
+
return visible ? distance : view.innerHeight + distance;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { mountPreviewRegions };
|
|
142
|
+
//# sourceMappingURL=regions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regions.js","names":["element"],"sources":["../../../../../src/runtime/preview/regions.ts"],"sourcesContent":["import type { CmsPreviewTargetKind } from './protocol'\nimport { CMS_PREVIEW_DECORATED_ATTRIBUTE, parsePreviewMarkerComment } from './protocol'\n\nexport interface PreviewRegionGeometry {\n readonly depth: number\n readonly element: () => Element | undefined\n readonly rects: () => ReadonlyArray<DOMRect>\n}\n\ninterface PreviewRegionTarget {\n readonly geometries: ReadonlyArray<PreviewRegionGeometry>\n readonly kind: CmsPreviewTargetKind\n readonly nodeId: string\n}\n\nexport interface LocatedPreviewRegion {\n readonly geometries: ReadonlyArray<PreviewRegionGeometry>\n readonly nodeId?: string\n}\n\nexport interface PreviewRegionRegistry {\n readonly clear: () => void\n readonly decorate: (scope?: ParentNode) => void\n readonly hitTest: (x: number, y: number, scope?: ParentNode) => string | undefined\n readonly locate: (\n nodeId: string,\n fallbacks: Readonly<Record<string, string>>,\n scope?: ParentNode,\n ) => LocatedPreviewRegion\n readonly nearest: (geometries: ReadonlyArray<PreviewRegionGeometry>) => Element | undefined\n}\n\nconst TARGET_PRIORITY = { component: 1, field: 3, native: 2 } satisfies Record<CmsPreviewTargetKind, number>\n\nconst COMMENT_NODE_FILTER = 128\n\nconst DOCUMENT_NODE = 9\n\ninterface OpenMarker {\n readonly comment: Comment\n readonly depth: number\n readonly kind: CmsPreviewTargetKind\n readonly nodeId: string\n}\n\n/** Owns the DOM representation, hit testing and fallback resolution of semantic authoring regions. */\nexport function mountPreviewRegions(root: ParentNode, view: Window): PreviewRegionRegistry {\n const geometryCache = new WeakMap<Comment, { readonly end: Comment; readonly geometry: PreviewRegionGeometry }>()\n\n const collect = (scope: ParentNode = root): ReadonlyArray<PreviewRegionTarget> => {\n const targets = new Map<string, PreviewRegionTarget>()\n const open: Array<OpenMarker> = []\n // SAFETY: ParentNode is a DOM mixin implemented only by Document, DocumentFragment, and Element nodes.\n const scopeNode = scope as Node\n // SAFETY: A DOM node with the Document node type satisfies the Document interface.\n const ownerDocument = scopeNode.nodeType === DOCUMENT_NODE ? (scopeNode as Document) : scope.ownerDocument\n\n if (!ownerDocument) return []\n const walker = ownerDocument.createTreeWalker(scopeNode, COMMENT_NODE_FILTER)\n let current = walker.nextNode()\n\n while (current) {\n // SAFETY: The TreeWalker is restricted to comment nodes.\n const comment = current as Comment\n const marker = parsePreviewMarkerComment(comment.data)\n\n if (marker?.edge === 'start') {\n open.push({ comment, depth: open.length, kind: marker.kind, nodeId: marker.nodeId })\n } else if (marker?.edge === 'end') {\n const start = open.at(-1)\n\n if (start?.kind === marker.kind && start.nodeId === marker.nodeId) {\n open.pop()\n const geometry = rangeGeometry(start.comment, comment, start.depth, geometryCache)\n const key = `${marker.kind}:${marker.nodeId}`\n const target = targets.get(key)\n\n targets.set(key, {\n geometries: target ? [...target.geometries, geometry] : [geometry],\n kind: marker.kind,\n nodeId: marker.nodeId,\n })\n } else open.length = 0\n }\n\n current = walker.nextNode()\n }\n\n return [...targets.values()]\n }\n\n return {\n clear() {\n for (const element of root.querySelectorAll(\n `[${CMS_PREVIEW_DECORATED_ATTRIBUTE}], [data-cms-hovered], [data-cms-selected]`,\n )) {\n element.removeAttribute(CMS_PREVIEW_DECORATED_ATTRIBUTE)\n element.removeAttribute('data-cms-hovered')\n element.removeAttribute('data-cms-selected')\n }\n },\n decorate(scope) {\n for (const target of collect(scope)) {\n for (const geometry of target.geometries) geometry.element()?.setAttribute(CMS_PREVIEW_DECORATED_ATTRIBUTE, '')\n }\n },\n hitTest(x, y, scope) {\n const candidates = collect(scope).filter((target) =>\n target.geometries.some((geometry) =>\n geometry.rects().some((rect) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom),\n ),\n )\n\n candidates.sort(\n (left, right) =>\n targetDepth(right) - targetDepth(left) ||\n TARGET_PRIORITY[right.kind] - TARGET_PRIORITY[left.kind] ||\n targetArea(left) - targetArea(right),\n )\n\n return candidates[0]?.nodeId\n },\n locate(nodeId, fallbacks, scope) {\n const visited = new Set<string>()\n const targets = collect(scope)\n let targetId: string | undefined = nodeId\n\n while (targetId && !visited.has(targetId)) {\n visited.add(targetId)\n\n const geometries = targets.filter((target) => target.nodeId === targetId).flatMap((target) => target.geometries)\n\n if (geometries.length) return { geometries, nodeId: targetId }\n targetId = fallbacks[targetId]\n }\n\n return { geometries: [] }\n },\n nearest(geometries) {\n const viewportCenter = view.innerHeight / 2\n\n return [...geometries]\n .sort(\n (left, right) => viewportDistance(left, viewportCenter, view) - viewportDistance(right, viewportCenter, view),\n )[0]\n ?.element()\n },\n }\n}\n\nfunction rangeGeometry(\n start: Comment,\n end: Comment,\n depth: number,\n cache: WeakMap<Comment, { readonly end: Comment; readonly geometry: PreviewRegionGeometry }>,\n): PreviewRegionGeometry {\n const cached = cache.get(start)\n\n if (cached?.end === end && cached.geometry.depth === depth) return cached.geometry\n\n const geometry: PreviewRegionGeometry = {\n depth,\n element: () => rangeElement(start, end),\n rects: () => rangeRectangles(start, end),\n }\n\n cache.set(start, { end, geometry })\n\n return geometry\n}\n\nfunction rangeElement(start: Comment, end: Comment): Element | undefined {\n if (!start.isConnected || !end.isConnected || start.parentNode !== end.parentNode) return undefined\n let current = start.nextSibling\n\n while (current && current !== end) {\n if (current.nodeType === current.ELEMENT_NODE) {\n // SAFETY: The node type check establishes the Element representation.\n const element = current as Element\n\n return element\n }\n\n current = current.nextSibling\n }\n\n return start.parentElement ?? undefined\n}\n\nfunction rangeRectangles(start: Comment, end: Comment): ReadonlyArray<DOMRect> {\n if (!start.isConnected || !end.isConnected) return []\n const range = start.ownerDocument.createRange()\n\n try {\n range.setStartAfter(start)\n range.setEndBefore(end)\n\n const rectangles = [...range.getClientRects()].filter(isVisibleRectangle)\n\n if (rectangles.length) return rectangles\n } catch {}\n\n const element = rangeElement(start, end)\n\n return element ? [...element.getClientRects()].filter(isVisibleRectangle) : []\n}\n\nfunction isVisibleRectangle(rectangle: DOMRect): boolean {\n return rectangle.width > 0 && rectangle.height > 0\n}\n\nfunction targetDepth(target: PreviewRegionTarget): number {\n return Math.max(0, ...target.geometries.map((geometry) => geometry.depth))\n}\n\nfunction targetArea(target: PreviewRegionTarget): number {\n return Math.min(\n Infinity,\n ...target.geometries.flatMap((geometry) => geometry.rects().map((rect) => rect.width * rect.height)),\n )\n}\n\nfunction viewportDistance(geometry: PreviewRegionGeometry, viewportCenter: number, view: Window): number {\n const rectangles = geometry.rects()\n const top = Math.min(Infinity, ...rectangles.map((rectangle) => rectangle.top))\n const bottom = Math.max(-Infinity, ...rectangles.map((rectangle) => rectangle.bottom))\n\n if (!Number.isFinite(top) || !Number.isFinite(bottom)) return Infinity\n const visible = bottom >= 0 && top <= view.innerHeight\n const distance = Math.abs((top + bottom) / 2 - viewportCenter)\n\n return visible ? distance : view.innerHeight + distance\n}\n"],"mappings":";;;AAgCA,MAAM,kBAAkB;CAAE,WAAW;CAAG,OAAO;CAAG,QAAQ;AAAE;AAE5D,MAAM,sBAAsB;AAE5B,MAAM,gBAAgB;;AAUtB,SAAgB,oBAAoB,MAAkB,MAAqC;CACzF,MAAM,gCAAgB,IAAI,QAAsF;CAEhH,MAAM,WAAW,QAAoB,SAA6C;EAChF,MAAM,0BAAU,IAAI,IAAiC;EACrD,MAAM,OAA0B,CAAC;EAEjC,MAAM,YAAY;EAElB,MAAM,gBAAgB,UAAU,aAAa,gBAAiB,YAAyB,MAAM;EAE7F,IAAI,CAAC,eAAe,OAAO,CAAC;EAC5B,MAAM,SAAS,cAAc,iBAAiB,WAAW,mBAAmB;EAC5E,IAAI,UAAU,OAAO,SAAS;EAE9B,OAAO,SAAS;GAEd,MAAM,UAAU;GAChB,MAAM,SAAS,0BAA0B,QAAQ,IAAI;GAErD,IAAI,QAAQ,SAAS,SACnB,KAAK,KAAK;IAAE;IAAS,OAAO,KAAK;IAAQ,MAAM,OAAO;IAAM,QAAQ,OAAO;GAAO,CAAC;QAC9E,IA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Ac;CAE7D,OAAO,UAAU,WAAW,KAAK,cAAc;AACjD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { documentPreviewStoreKey } from "../delivery/preview.js";
|
|
2
|
-
import { t as createStudioPreviewStore } from "../../store-
|
|
2
|
+
import { t as createStudioPreviewStore } from "../../store-PKKB8xa2.js";
|
|
3
3
|
|
|
4
4
|
export { createStudioPreviewStore, documentPreviewStoreKey };
|
package/src/runtime/sitemap.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Y as SitemapEntry } from "../models-VmGmG19-.js";
|
|
2
2
|
import { i as CMS_DELIVERY_SITEMAP_PATH } from "../HttpPaths-c9nLZ9H2.js";
|
|
3
3
|
import { useCmsInstallation } from "./plugin.js";
|
|
4
4
|
import { toNuxtSitemapEntries } from "./sitemap-entries.js";
|
|
5
|
-
import {
|
|
5
|
+
import { Schema } from "effect";
|
|
6
6
|
import { createError, defineEventHandler, getRequestURL } from "h3";
|
|
7
7
|
|
|
8
8
|
//#region src/runtime/sitemap.ts
|
|
9
9
|
const SitemapDelivery = Schema.Array(SitemapEntry);
|
|
10
|
-
var sitemap_default = defineEventHandler((event) =>
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
if (!response.ok) return yield* Effect.fail(createError({
|
|
10
|
+
var sitemap_default = defineEventHandler(async (event) => {
|
|
11
|
+
const response = await (await useCmsInstallation()).fetch(new Request(new URL(CMS_DELIVERY_SITEMAP_PATH, getRequestURL(event).origin)));
|
|
12
|
+
if (!response.ok) throw createError({
|
|
14
13
|
statusCode: response.status,
|
|
15
14
|
statusMessage: "CMS sitemap delivery failed"
|
|
16
|
-
})
|
|
17
|
-
const payload =
|
|
18
|
-
const entries =
|
|
15
|
+
});
|
|
16
|
+
const payload = await response.json();
|
|
17
|
+
const entries = await Schema.decodeUnknownPromise(SitemapDelivery)(payload);
|
|
19
18
|
return toNuxtSitemapEntries(entries);
|
|
20
|
-
})
|
|
19
|
+
});
|
|
21
20
|
|
|
22
21
|
//#endregion
|
|
23
22
|
export { sitemap_default as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sitemap.js","names":[],"sources":["../../../../src/runtime/sitemap.ts"],"sourcesContent":["import { CMS_DELIVERY_SITEMAP_PATH } from '@internal/protocol/HttpPaths'\nimport { SitemapEntry } from '@internal/protocol/Seo'\nimport {
|
|
1
|
+
{"version":3,"file":"sitemap.js","names":[],"sources":["../../../../src/runtime/sitemap.ts"],"sourcesContent":["import { CMS_DELIVERY_SITEMAP_PATH } from '@internal/protocol/HttpPaths'\nimport { SitemapEntry } from '@internal/protocol/Seo'\nimport { Schema } from 'effect'\nimport { createError, defineEventHandler, getRequestURL } from 'h3'\nimport { useCmsInstallation } from './plugin'\nimport { toNuxtSitemapEntries } from './sitemap-entries'\n\nconst SitemapDelivery = Schema.Array(SitemapEntry)\n\n// oxlint-disable-next-line effecttsgo/async-function -- Nitro owns this Promise-based request lifecycle.\nexport default defineEventHandler(async (event) => {\n const installation = await useCmsInstallation()\n\n const response = await installation.fetch(\n new Request(new URL(CMS_DELIVERY_SITEMAP_PATH, getRequestURL(event).origin)),\n )\n\n if (!response.ok) {\n throw createError({\n statusCode: response.status,\n statusMessage: 'CMS sitemap delivery failed',\n })\n }\n\n const payload = await response.json()\n const entries = await Schema.decodeUnknownPromise(SitemapDelivery)(payload)\n\n return toNuxtSitemapEntries(entries)\n})\n"],"mappings":";;;;;;;;AAOA,MAAM,kBAAkB,OAAO,MAAM,YAAY;AAGjD,sBAAe,mBAAmB,OAAO,UAAU;CAGjD,MAAM,WAAW,OAAM,MAFI,mBAAmB,EAEX,CAAC,MAClC,IAAI,QAAQ,IAAI,IAAI,2BAA2B,cAAc,KAAK,CAAC,CAAC,MAAM,CAAC,CAC7E;CAEA,IAAI,CAAC,SAAS,IACZ,MAAM,YAAY;EAChB,YAAY,SAAS;EACrB,eAAe;CACjB,CAAC;CAGH,MAAM,UAAU,MAAM,SAAS,KAAK;CACpC,MAAM,UAAU,MAAM,OAAO,qBAAqB,eAAe,CAAC,CAAC,OAAO;CAE1E,OAAO,qBAAqB,OAAO;AACrC,CAAC"}
|
|
@@ -6,21 +6,17 @@ const publicPathPattern = /^\/(?!(?:[^/]+\/)*\.\.?(?:\/|$))(?:[^/?#\\]+(?:\/[^/?
|
|
|
6
6
|
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region ../protocol/src/internal/documents/scalars.ts
|
|
9
|
-
const relativeDocumentPathPattern = /^(?!(?:[^/]+\/)*\.\.?(?:\/|$))[^/?#\\]+(?:\/[^/?#\\]+)*$/u;
|
|
10
9
|
const slugPattern = /^[\p{Letter}\p{Number}][\p{Letter}\p{Number}_-]*$/u;
|
|
11
|
-
const sourcePathPattern = /^(?!\.)[^/?#\\]+(?:\/(?!\.)[^/?#\\]+)*\.(?:md|mdc)$/u;
|
|
12
10
|
const DocumentGeneration = Schema.String.check(Schema.isPattern(/^(?:0|[1-9]\d*)$/u)).pipe(Schema.brand("DocumentGeneration"));
|
|
13
11
|
const DocumentVersion = Schema.NonEmptyString.pipe(Schema.brand("DocumentVersion"));
|
|
14
12
|
const DocumentHistoryCursor = Schema.NonEmptyString.pipe(Schema.brand("DocumentHistoryCursor"));
|
|
15
13
|
const DocumentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand("DocumentId"));
|
|
16
14
|
const EditorNodeId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand("EditorNodeId"));
|
|
17
15
|
const PublicPath = Schema.String.check(Schema.isPattern(publicPathPattern)).pipe(Schema.brand("PublicPath"));
|
|
18
|
-
const RelativeDocumentPath = Schema.String.check(Schema.isPattern(relativeDocumentPathPattern)).pipe(Schema.brand("RelativeDocumentPath"));
|
|
19
16
|
const RevisionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand("RevisionId"));
|
|
20
17
|
const RevisionNumber = nonNegativeInt.pipe(Schema.brand("RevisionNumber"));
|
|
21
18
|
const Slug = Schema.String.check(Schema.isPattern(slugPattern)).pipe(Schema.brand("Slug"));
|
|
22
|
-
const SourcePath = Schema.String.check(Schema.isPattern(sourcePathPattern)).pipe(Schema.brand("SourcePath"));
|
|
23
19
|
|
|
24
20
|
//#endregion
|
|
25
|
-
export { EditorNodeId as a,
|
|
26
|
-
//# sourceMappingURL=scalars-
|
|
21
|
+
export { EditorNodeId as a, RevisionNumber as c, publicPathPattern as d, DocumentVersion as i, Slug as l, DocumentHistoryCursor as n, PublicPath as o, DocumentId as r, RevisionId as s, DocumentGeneration as t, nonNegativeInt as u };
|
|
22
|
+
//# sourceMappingURL=scalars-CVZqT3L0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalars-CVZqT3L0.js","names":[],"sources":["../../../../protocol/src/internal/scalars.ts","../../../../protocol/src/internal/documents/scalars.ts"],"sourcesContent":["import { Schema } from 'effect'\n\nexport const nonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))\n\nexport const publicPathPattern = /^\\/(?!(?:[^/]+\\/)*\\.\\.?(?:\\/|$))(?:[^/?#\\\\]+(?:\\/[^/?#\\\\]+)*)?$/u\n","import { Schema } from 'effect'\nimport { nonNegativeInt, publicPathPattern } from '../scalars'\n\nconst slugPattern = /^[\\p{Letter}\\p{Number}][\\p{Letter}\\p{Number}_-]*$/u\n\nexport const DocumentGeneration = Schema.String.check(Schema.isPattern(/^(?:0|[1-9]\\d*)$/u)).pipe(\n Schema.brand('DocumentGeneration'),\n)\n\nexport type DocumentGeneration = typeof DocumentGeneration.Type\n\nexport const DocumentVersion = Schema.NonEmptyString.pipe(Schema.brand('DocumentVersion'))\n\nexport type DocumentVersion = typeof DocumentVersion.Type\n\nexport const DocumentHistoryCursor = Schema.NonEmptyString.pipe(Schema.brand('DocumentHistoryCursor'))\n\nexport type DocumentHistoryCursor = typeof DocumentHistoryCursor.Type\n\nexport const DocumentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('DocumentId'))\n\nexport type DocumentId = typeof DocumentId.Type\n\nexport const EditorNodeId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('EditorNodeId'))\n\nexport type EditorNodeId = typeof EditorNodeId.Type\n\nexport const PublicPath = Schema.String.check(Schema.isPattern(publicPathPattern)).pipe(Schema.brand('PublicPath'))\n\nexport type PublicPath = typeof PublicPath.Type\n\nexport const RevisionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('RevisionId'))\n\nexport type RevisionId = typeof RevisionId.Type\n\nexport const RevisionNumber = nonNegativeInt.pipe(Schema.brand('RevisionNumber'))\n\nexport type RevisionNumber = typeof RevisionNumber.Type\n\nexport const Slug = Schema.String.check(Schema.isPattern(slugPattern)).pipe(Schema.brand('Slug'))\n\nexport type Slug = typeof Slug.Type\n"],"mappings":";;;AAEA,MAAa,iBAAiB,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAE/E,MAAa,oBAAoB;;;;ACDjC,MAAM,cAAc;AAEpB,MAAa,qBAAqB,OAAO,OAAO,MAAM,OAAO,UAAU,mBAAmB,CAAC,CAAC,CAAC,KAC3F,OAAO,MAAM,oBAAoB,CACnC;AAIA,MAAa,kBAAkB,OAAO,eAAe,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAIzF,MAAa,wBAAwB,OAAO,eAAe,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAIrG,MAAa,aAAa,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC;AAI9F,MAAa,eAAe,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,cAAc,CAAC;AAIlG,MAAa,aAAa,OAAO,OAAO,MAAM,OAAO,UAAU,iBAAiB,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC;AAIlH,MAAa,aAAa,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC;AAI9F,MAAa,iBAAiB,eAAe,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAIhF,MAAa,OAAO,OAAO,OAAO,MAAM,OAAO,UAAU,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,MAAM,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { o as PublicPath, r as DocumentId } from "./scalars-
|
|
2
|
-
import {
|
|
3
|
-
import { f as mutableJson, p as mutableJsonObject } from "./Forms-
|
|
4
|
-
import { n as editorMetadata } from "./metadata-
|
|
1
|
+
import { o as PublicPath, r as DocumentId } from "./scalars-CVZqT3L0.js";
|
|
2
|
+
import { it as CollectionName, n as CmsMarkdownDocument } from "./models-VmGmG19-.js";
|
|
3
|
+
import { f as mutableJson, p as mutableJsonObject } from "./Forms-CX-hwmJF.js";
|
|
4
|
+
import { n as editorMetadata } from "./metadata-UzZmjwxM.js";
|
|
5
5
|
import { prepareFormDocument } from "./runtime/forms/document.js";
|
|
6
|
-
import {
|
|
6
|
+
import { CMS_PREVIEW_EDGE_PROPERTY, CMS_PREVIEW_KIND_PROPERTY, CMS_PREVIEW_MARKER_TAG, CMS_PREVIEW_NODE_PROPERTY } from "./runtime/preview/protocol.js";
|
|
7
7
|
import { toPreviewRenderDocument } from "./runtime/preview/comark-document.js";
|
|
8
8
|
import { Predicate, Result, Schema } from "effect";
|
|
9
9
|
import { shallowRef } from "vue";
|
|
@@ -37,16 +37,6 @@ const NATIVE_BLOCK_TAGS = /* @__PURE__ */ new Set([
|
|
|
37
37
|
"tr",
|
|
38
38
|
"ul"
|
|
39
39
|
]);
|
|
40
|
-
const INLINE_TAGS = /* @__PURE__ */ new Set([
|
|
41
|
-
"a",
|
|
42
|
-
"br",
|
|
43
|
-
"code",
|
|
44
|
-
"del",
|
|
45
|
-
"em",
|
|
46
|
-
"img",
|
|
47
|
-
"strong",
|
|
48
|
-
"u"
|
|
49
|
-
]);
|
|
50
40
|
function projectPreviewDocument(body, markers) {
|
|
51
41
|
return Result.try({
|
|
52
42
|
try: () => projectPreviewDocumentUnsafe(body, markers),
|
|
@@ -59,8 +49,8 @@ function projectPreviewDocument(body, markers) {
|
|
|
59
49
|
function projectPreviewDocumentUnsafe(body, markers) {
|
|
60
50
|
const fallbacks = {};
|
|
61
51
|
let identifiedTargets = 0;
|
|
62
|
-
|
|
63
|
-
if (Predicate.isString(node) || node[0] === null) return mutableJson(node);
|
|
52
|
+
function cloneNode(node, componentId, slotId) {
|
|
53
|
+
if (Predicate.isString(node) || node[0] === null) return [mutableJson(node)];
|
|
64
54
|
const [tag, originalAttributes, ...originalChildren] = node;
|
|
65
55
|
const isSlot = tag === "template";
|
|
66
56
|
const isNative = NATIVE_BLOCK_TAGS.has(tag);
|
|
@@ -69,44 +59,33 @@ function projectPreviewDocumentUnsafe(body, markers) {
|
|
|
69
59
|
const id = metadata?.nodeId;
|
|
70
60
|
if (id) {
|
|
71
61
|
identifiedTargets++;
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
attributes[markers.nodeAttribute] = id;
|
|
75
|
-
attributes[markers.targetAttribute] = "component";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const children = [...cloneNodes(originalChildren, !isNative && !isSlot && id ? id : componentId)];
|
|
79
|
-
if (id && metadata?.implicitSlotId && !isNative && !isSlot && hasImplicitDefaultContent(originalChildren)) {
|
|
80
|
-
const slotId = metadata.implicitSlotId;
|
|
81
|
-
fallbacks[slotId] = id;
|
|
82
|
-
const markerChildren = hasInlineImplicitDefaultContent(originalChildren) ? children.splice(0) : [];
|
|
83
|
-
const markerAttributes = {
|
|
84
|
-
[markers.nodeAttribute]: slotId,
|
|
85
|
-
[markers.targetAttribute]: "slot",
|
|
86
|
-
[markers.wrapperAttribute]: ""
|
|
87
|
-
};
|
|
88
|
-
if (markerChildren.length) markerAttributes[markers.inlineHostAttribute] = "";
|
|
89
|
-
children.unshift([
|
|
90
|
-
markers.markerTag,
|
|
91
|
-
markerAttributes,
|
|
92
|
-
...markerChildren
|
|
93
|
-
]);
|
|
62
|
+
const parentId = slotId ?? componentId;
|
|
63
|
+
if (parentId) fallbacks[id] = parentId;
|
|
94
64
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
65
|
+
const nextComponentId = !isNative && !isSlot && id ? id : componentId;
|
|
66
|
+
const implicitSlotId = id && metadata?.implicitSlotId && !isNative && !isSlot && hasImplicitDefaultContent(originalChildren) ? metadata.implicitSlotId : void 0;
|
|
67
|
+
const children = originalChildren.flatMap((child) => {
|
|
68
|
+
const childSlotId = explicitSlotId(child) ?? (isSlot ? id : implicitSlotId) ?? slotId;
|
|
69
|
+
const projected = cloneNode(child, nextComponentId, childSlotId);
|
|
70
|
+
return implicitSlotId && !isSlot && !isSlotNode(child) ? previewRange(implicitSlotId, "field", projected, markers) : projected;
|
|
71
|
+
});
|
|
72
|
+
if (id && implicitSlotId) fallbacks[implicitSlotId] = id;
|
|
73
|
+
if (isSlot && id && componentId) fallbacks[id] = componentId;
|
|
100
74
|
const cloned = [
|
|
101
75
|
tag,
|
|
102
76
|
attributes,
|
|
103
77
|
...children
|
|
104
78
|
];
|
|
105
|
-
if (id &&
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
79
|
+
if (isSlot && id && componentId) return [[
|
|
80
|
+
tag,
|
|
81
|
+
attributes,
|
|
82
|
+
...previewRange(id, "field", children, markers)
|
|
83
|
+
]];
|
|
84
|
+
if (id && isNative) return previewRange(id, "native", [cloned], markers);
|
|
85
|
+
if (id && !isSlot) return previewRange(id, "component", [cloned], markers);
|
|
86
|
+
return [cloned];
|
|
87
|
+
}
|
|
88
|
+
const nodes = body.nodes.flatMap((node) => cloneNode(node));
|
|
110
89
|
if (body.nodes.length && !identifiedTargets) throw new Error("Studio preview requires an identified authoring document.");
|
|
111
90
|
return {
|
|
112
91
|
body: CmsMarkdownDocument.make({
|
|
@@ -117,23 +96,28 @@ function projectPreviewDocumentUnsafe(body, markers) {
|
|
|
117
96
|
fallbacks
|
|
118
97
|
};
|
|
119
98
|
}
|
|
120
|
-
function
|
|
99
|
+
function previewRange(nodeId, kind, children, markers) {
|
|
100
|
+
const marker = (edge) => [markers.tag, {
|
|
101
|
+
[markers.edgeProperty]: edge,
|
|
102
|
+
[markers.kindProperty]: kind,
|
|
103
|
+
[markers.nodeProperty]: nodeId
|
|
104
|
+
}];
|
|
121
105
|
return [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
[markers.targetAttribute]: kind,
|
|
126
|
-
[markers.wrapperAttribute]: ""
|
|
127
|
-
},
|
|
128
|
-
child
|
|
106
|
+
marker("start"),
|
|
107
|
+
...children,
|
|
108
|
+
marker("end")
|
|
129
109
|
];
|
|
130
110
|
}
|
|
111
|
+
function explicitSlotId(node) {
|
|
112
|
+
if (Predicate.isString(node) || node[0] !== "template") return void 0;
|
|
113
|
+
return editorMetadata(node[1])?.nodeId;
|
|
114
|
+
}
|
|
115
|
+
function isSlotNode(node) {
|
|
116
|
+
return !Predicate.isString(node) && node[0] === "template";
|
|
117
|
+
}
|
|
131
118
|
function hasImplicitDefaultContent(nodes) {
|
|
132
119
|
return !nodes.some((node) => Array.isArray(node) && node[0] === "template" && node[1].name === "default") && nodes.some((node) => Predicate.isString(node) ? Boolean(node) : node[0] !== "template");
|
|
133
120
|
}
|
|
134
|
-
function hasInlineImplicitDefaultContent(nodes) {
|
|
135
|
-
return nodes.length > 0 && nodes.every((node) => Predicate.isString(node) || Array.isArray(node) && node[0] !== null && INLINE_TAGS.has(node[0]));
|
|
136
|
-
}
|
|
137
121
|
|
|
138
122
|
//#endregion
|
|
139
123
|
//#region src/runtime/preview/store.ts
|
|
@@ -211,11 +195,10 @@ function renderedDocuments(registrations, patches) {
|
|
|
211
195
|
}
|
|
212
196
|
function createPreviewDocument(body) {
|
|
213
197
|
const projection = projectPreviewDocument(body, {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
wrapperAttribute: CMS_PREVIEW_WRAPPER_ATTRIBUTE
|
|
198
|
+
edgeProperty: CMS_PREVIEW_EDGE_PROPERTY,
|
|
199
|
+
kindProperty: CMS_PREVIEW_KIND_PROPERTY,
|
|
200
|
+
nodeProperty: CMS_PREVIEW_NODE_PROPERTY,
|
|
201
|
+
tag: CMS_PREVIEW_MARKER_TAG
|
|
219
202
|
});
|
|
220
203
|
if (Result.isFailure(projection)) throw projection.failure;
|
|
221
204
|
return projection.success;
|
|
@@ -223,4 +206,4 @@ function createPreviewDocument(body) {
|
|
|
223
206
|
|
|
224
207
|
//#endregion
|
|
225
208
|
export { createStudioPreviewStore as t };
|
|
226
|
-
//# sourceMappingURL=store-
|
|
209
|
+
//# sourceMappingURL=store-PKKB8xa2.js.map
|