meno-core 1.0.52 → 1.0.53
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/build-astro.ts +183 -13
- package/build-next.ts +1361 -0
- package/build-static.ts +7 -5
- package/dist/bin/cli.js +2 -2
- package/dist/build-static.js +6 -6
- package/dist/chunks/{chunk-HNLUO36W.js → chunk-GZHGVVW3.js} +2 -2
- package/dist/chunks/chunk-GZHGVVW3.js.map +7 -0
- package/dist/chunks/{chunk-LPVETICS.js → chunk-H3GJ4H2U.js} +185 -1
- package/dist/chunks/chunk-H3GJ4H2U.js.map +7 -0
- package/dist/chunks/{chunk-CXCBV2M7.js → chunk-IGYR22T6.js} +76 -270
- package/dist/chunks/chunk-IGYR22T6.js.map +7 -0
- package/dist/chunks/{chunk-LHLHPYSP.js → chunk-JGP5A3Y5.js} +12 -11
- package/dist/chunks/chunk-JGP5A3Y5.js.map +7 -0
- package/dist/chunks/{chunk-7NIC4I3V.js → chunk-JGWFTO6P.js} +167 -21
- package/dist/chunks/chunk-JGWFTO6P.js.map +7 -0
- package/dist/chunks/{chunk-EDQSMAMP.js → chunk-O3NAGJP4.js} +85 -4
- package/dist/chunks/chunk-O3NAGJP4.js.map +7 -0
- package/dist/chunks/{chunk-H4JSCDNW.js → chunk-QB2LNO4W.js} +24 -1
- package/dist/chunks/chunk-QB2LNO4W.js.map +7 -0
- package/dist/chunks/{chunk-A725KYFK.js → chunk-R6XHAFBF.js} +561 -112
- package/dist/chunks/chunk-R6XHAFBF.js.map +7 -0
- package/dist/chunks/{chunk-J23ZX5AP.js → chunk-X754AHS5.js} +277 -1
- package/dist/chunks/chunk-X754AHS5.js.map +7 -0
- package/dist/chunks/{chunk-2QK6U5UK.js → chunk-YBLHKYFF.js} +12 -2
- package/dist/chunks/chunk-YBLHKYFF.js.map +7 -0
- package/dist/chunks/{constants-GWBAD66U.js → constants-STK2YBIW.js} +2 -2
- package/dist/entries/server-router.js +7 -7
- package/dist/lib/client/index.js +354 -59
- package/dist/lib/client/index.js.map +4 -4
- package/dist/lib/server/index.js +1458 -190
- package/dist/lib/server/index.js.map +4 -4
- package/dist/lib/shared/index.js +202 -34
- package/dist/lib/shared/index.js.map +4 -4
- package/dist/lib/test-utils/index.js +1 -1
- package/entries/client-router.tsx +5 -165
- package/lib/client/ErrorBoundary.test.tsx +27 -25
- package/lib/client/ErrorBoundary.tsx +34 -19
- package/lib/client/core/ComponentBuilder.ts +19 -2
- package/lib/client/core/builders/embedBuilder.ts +8 -4
- package/lib/client/core/builders/listBuilder.ts +23 -4
- package/lib/client/fontFamiliesService.test.ts +76 -0
- package/lib/client/fontFamiliesService.ts +69 -0
- package/lib/client/hmrCssReload.ts +160 -0
- package/lib/client/hooks/useColorVariables.ts +2 -0
- package/lib/client/index.ts +4 -0
- package/lib/client/meno-filter/ui.ts +2 -0
- package/lib/client/routing/RouteLoader.test.ts +2 -2
- package/lib/client/routing/RouteLoader.ts +8 -2
- package/lib/client/routing/Router.tsx +81 -15
- package/lib/client/scripts/ScriptExecutor.test.ts +143 -0
- package/lib/client/scripts/ScriptExecutor.ts +56 -2
- package/lib/client/styles/StyleInjector.ts +20 -5
- package/lib/client/styles/UtilityClassCollector.ts +7 -1
- package/lib/client/styles/cspNonce.test.ts +67 -0
- package/lib/client/styles/cspNonce.ts +63 -0
- package/lib/client/templateEngine.test.ts +80 -0
- package/lib/client/templateEngine.ts +5 -0
- package/lib/server/astro/cmsPageEmitter.ts +35 -5
- package/lib/server/astro/componentEmitter.ts +61 -5
- package/lib/server/astro/nodeToAstro.ts +149 -11
- package/lib/server/astro/normalizeOrphanTemplateProps.test.ts +264 -0
- package/lib/server/astro/normalizeOrphanTemplateProps.ts +184 -0
- package/lib/server/createServer.ts +11 -0
- package/lib/server/draftPageStore.ts +49 -0
- package/lib/server/fileWatcher.ts +62 -2
- package/lib/server/index.ts +13 -1
- package/lib/server/providers/fileSystemPageProvider.ts +8 -0
- package/lib/server/routes/api/components.ts +9 -4
- package/lib/server/routes/api/core-routes.ts +2 -2
- package/lib/server/routes/api/pages.ts +14 -22
- package/lib/server/routes/api/shared.ts +56 -0
- package/lib/server/routes/index.ts +90 -0
- package/lib/server/routes/pages.ts +13 -6
- package/lib/server/services/componentService.test.ts +199 -2
- package/lib/server/services/componentService.ts +354 -49
- package/lib/server/services/fileWatcherService.ts +4 -24
- package/lib/server/services/pageService.test.ts +23 -0
- package/lib/server/services/pageService.ts +124 -6
- package/lib/server/ssr/attributeBuilder.ts +8 -2
- package/lib/server/ssr/buildErrorOverlay.ts +1 -1
- package/lib/server/ssr/errorOverlay.test.ts +21 -2
- package/lib/server/ssr/errorOverlay.ts +38 -11
- package/lib/server/ssr/htmlGenerator.test.ts +53 -13
- package/lib/server/ssr/htmlGenerator.ts +71 -27
- package/lib/server/ssr/liveReloadIntegration.test.ts +123 -2
- package/lib/server/ssr/ssrRenderer.test.ts +67 -0
- package/lib/server/ssr/ssrRenderer.ts +94 -9
- package/lib/server/websocketManager.ts +0 -1
- package/lib/shared/componentRefs.ts +45 -0
- package/lib/shared/constants.ts +8 -0
- package/lib/shared/cssGeneration.ts +2 -0
- package/lib/shared/cssProperties.ts +184 -0
- package/lib/shared/expressionEvaluator.ts +54 -0
- package/lib/shared/fontCss.ts +101 -0
- package/lib/shared/fontLoader.ts +8 -86
- package/lib/shared/friendlyError.test.ts +87 -0
- package/lib/shared/friendlyError.ts +121 -0
- package/lib/shared/hrefRefs.test.ts +130 -0
- package/lib/shared/hrefRefs.ts +100 -0
- package/lib/shared/index.ts +52 -0
- package/lib/shared/inlineSvgStyleRules.test.ts +108 -0
- package/lib/shared/inlineSvgStyleRules.ts +134 -0
- package/lib/shared/interfaces/contentProvider.ts +13 -0
- package/lib/shared/itemTemplateUtils.test.ts +14 -0
- package/lib/shared/itemTemplateUtils.ts +4 -1
- package/lib/shared/registry/NodeTypeDefinition.ts +1 -1
- package/lib/shared/registry/nodeTypes/LinkNodeType.ts +1 -1
- package/lib/shared/slugTranslator.test.ts +24 -0
- package/lib/shared/slugTranslator.ts +24 -0
- package/lib/shared/styleNodeUtils.ts +4 -1
- package/lib/shared/tree/PathBuilder.test.ts +128 -1
- package/lib/shared/tree/PathBuilder.ts +83 -31
- package/lib/shared/types/comment.ts +99 -0
- package/lib/shared/types/index.ts +12 -0
- package/lib/shared/types/rendering.ts +8 -0
- package/lib/shared/utilityClassConfig.ts +4 -2
- package/lib/shared/utilityClassMapper.test.ts +24 -0
- package/lib/shared/validation/commentValidators.ts +69 -0
- package/lib/shared/validation/index.ts +1 -0
- package/lib/shared/viewportUnits.integration.test.ts +42 -0
- package/lib/shared/viewportUnits.test.ts +103 -0
- package/lib/shared/viewportUnits.ts +63 -0
- package/lib/test-utils/dom-setup.ts +6 -0
- package/package.json +1 -1
- package/dist/chunks/chunk-2QK6U5UK.js.map +0 -7
- package/dist/chunks/chunk-7NIC4I3V.js.map +0 -7
- package/dist/chunks/chunk-A725KYFK.js.map +0 -7
- package/dist/chunks/chunk-CXCBV2M7.js.map +0 -7
- package/dist/chunks/chunk-EDQSMAMP.js.map +0 -7
- package/dist/chunks/chunk-H4JSCDNW.js.map +0 -7
- package/dist/chunks/chunk-HNLUO36W.js.map +0 -7
- package/dist/chunks/chunk-J23ZX5AP.js.map +0 -7
- package/dist/chunks/chunk-LHLHPYSP.js.map +0 -7
- package/dist/chunks/chunk-LPVETICS.js.map +0 -7
- /package/dist/chunks/{constants-GWBAD66U.js.map → constants-STK2YBIW.js.map} +0 -0
package/dist/lib/shared/index.js
CHANGED
|
@@ -2,31 +2,49 @@ import {
|
|
|
2
2
|
extractStringValue,
|
|
3
3
|
generateFilenameFromItem,
|
|
4
4
|
generateUniqueFilename,
|
|
5
|
+
rewriteComponentRefs,
|
|
5
6
|
slugify
|
|
6
|
-
} from "../../chunks/chunk-
|
|
7
|
+
} from "../../chunks/chunk-QB2LNO4W.js";
|
|
7
8
|
import {
|
|
8
9
|
CMS_DRAFT_SUFFIX,
|
|
10
|
+
COMMENT_STATUSES,
|
|
9
11
|
PathTraversalError,
|
|
10
12
|
SAFE_IDENTIFIER_REGEX,
|
|
11
13
|
VARIABLE_GROUPS,
|
|
12
14
|
VARIABLE_GROUP_VALUES,
|
|
13
15
|
VARIABLE_TYPES,
|
|
14
16
|
VARIABLE_TYPE_VALUES,
|
|
17
|
+
buildPageUrlForLocale,
|
|
18
|
+
buildSlugIndex,
|
|
19
|
+
collectComponentLibraries,
|
|
15
20
|
createTypeSafetyError,
|
|
16
21
|
createValidationError,
|
|
22
|
+
extractFamilyName,
|
|
23
|
+
filterLibrariesByContext,
|
|
24
|
+
findPageBySlug,
|
|
25
|
+
fontFaceCss,
|
|
26
|
+
fontPreloadLinks,
|
|
27
|
+
generateInlineStyleTag,
|
|
28
|
+
generateLibraryTags,
|
|
29
|
+
generateScriptTag,
|
|
17
30
|
generateShortCssVar,
|
|
31
|
+
generateStylesheetTag,
|
|
18
32
|
getDefaultScalingType,
|
|
19
33
|
getGroupAbbreviation,
|
|
20
34
|
getGroupForProperty,
|
|
35
|
+
getLocaleLinks,
|
|
21
36
|
isBasePropDefinition,
|
|
22
37
|
isListPropDefinition,
|
|
23
38
|
isPathWithinRoot,
|
|
24
39
|
isReservedDraftFilename,
|
|
25
40
|
isSafePathSegment,
|
|
26
41
|
isValidIdentifier,
|
|
42
|
+
mergeLibraries,
|
|
27
43
|
resolvePaletteColor,
|
|
28
|
-
resolveSafePath
|
|
29
|
-
|
|
44
|
+
resolveSafePath,
|
|
45
|
+
resolveSlugToPageId,
|
|
46
|
+
translatePath
|
|
47
|
+
} from "../../chunks/chunk-X754AHS5.js";
|
|
30
48
|
import {
|
|
31
49
|
CSS_PROPERTIES,
|
|
32
50
|
CSS_PROPERTIES_DEFINITION,
|
|
@@ -45,7 +63,7 @@ import {
|
|
|
45
63
|
logNetworkError,
|
|
46
64
|
logRuntimeError,
|
|
47
65
|
setErrorHandler
|
|
48
|
-
} from "../../chunks/chunk-
|
|
66
|
+
} from "../../chunks/chunk-H3GJ4H2U.js";
|
|
49
67
|
import {
|
|
50
68
|
BaseComponentRegistry,
|
|
51
69
|
BaseNodeTypeRegistry,
|
|
@@ -61,6 +79,7 @@ import {
|
|
|
61
79
|
ComponentInstanceNodeType,
|
|
62
80
|
ComponentNodeSchema,
|
|
63
81
|
DEFAULT_PREFETCH_CONFIG,
|
|
82
|
+
DESIGN_VIEWPORT_VARS,
|
|
64
83
|
EmbedNodeType,
|
|
65
84
|
HtmlNodeType,
|
|
66
85
|
InteractiveStyleRuleSchema,
|
|
@@ -170,6 +189,7 @@ import {
|
|
|
170
189
|
isStyleMapping,
|
|
171
190
|
isStyleObject,
|
|
172
191
|
isStyleValue,
|
|
192
|
+
isSupportedTemplateExpression,
|
|
173
193
|
isTemplateContext,
|
|
174
194
|
isValidNodeType,
|
|
175
195
|
isVoidElement,
|
|
@@ -194,6 +214,7 @@ import {
|
|
|
194
214
|
resolvePropsFromDefinition,
|
|
195
215
|
resolveTemplateRawValue,
|
|
196
216
|
responsiveStylesToClasses,
|
|
217
|
+
rewriteViewportUnits,
|
|
197
218
|
richTextMarkerToHtml,
|
|
198
219
|
selectField,
|
|
199
220
|
serializeRegistry,
|
|
@@ -205,6 +226,7 @@ import {
|
|
|
205
226
|
stylesToClasses,
|
|
206
227
|
textField,
|
|
207
228
|
textareaField,
|
|
229
|
+
toFriendlyError,
|
|
208
230
|
treePathToDomPathString,
|
|
209
231
|
urlField,
|
|
210
232
|
validateCMSItem,
|
|
@@ -218,7 +240,7 @@ import {
|
|
|
218
240
|
validatePath,
|
|
219
241
|
validatePropDefinition,
|
|
220
242
|
validateStructuredComponentDefinition
|
|
221
|
-
} from "../../chunks/chunk-
|
|
243
|
+
} from "../../chunks/chunk-JGWFTO6P.js";
|
|
222
244
|
import {
|
|
223
245
|
DEFAULT_BREAKPOINTS,
|
|
224
246
|
DEFAULT_FLUID_RANGE,
|
|
@@ -289,7 +311,7 @@ import {
|
|
|
289
311
|
TREE_SCROLL_DELAY_MS,
|
|
290
312
|
WEBSOCKET_STATES,
|
|
291
313
|
init_constants
|
|
292
|
-
} from "../../chunks/chunk-
|
|
314
|
+
} from "../../chunks/chunk-YBLHKYFF.js";
|
|
293
315
|
import "../../chunks/chunk-KSBZ2L7C.js";
|
|
294
316
|
|
|
295
317
|
// lib/shared/index.ts
|
|
@@ -599,32 +621,35 @@ function calculateRenderedPath(logicalPath, currentNode, globalComponentRegistry
|
|
|
599
621
|
}
|
|
600
622
|
return renderedPath;
|
|
601
623
|
}
|
|
624
|
+
function computeCumulativeInstancePath(navigationHistory) {
|
|
625
|
+
if (!navigationHistory || navigationHistory.length === 0) return null;
|
|
626
|
+
let cumulative = navigationHistory[0].componentInstanceRenderedPath ?? navigationHistory[0].componentInstancePath;
|
|
627
|
+
if (!cumulative) return null;
|
|
628
|
+
for (let i = 1; i < navigationHistory.length; i++) {
|
|
629
|
+
const next = navigationHistory[i].componentInstanceRenderedPath ?? navigationHistory[i].componentInstancePath;
|
|
630
|
+
if (next) {
|
|
631
|
+
cumulative = [...cumulative, ...next.slice(1)];
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return cumulative;
|
|
635
|
+
}
|
|
602
636
|
function buildTreePathsWithRendered(pageData, globalComponentRegistry, navigationHistory) {
|
|
603
637
|
const rootData = getRootData(pageData);
|
|
604
638
|
if (!rootData) return [];
|
|
605
|
-
|
|
606
|
-
if (navigationHistory && navigationHistory.length > 0) {
|
|
607
|
-
cumulativeInstancePath = navigationHistory[0].componentInstanceRenderedPath ?? navigationHistory[0].componentInstancePath;
|
|
608
|
-
for (let i = 1; i < navigationHistory.length; i++) {
|
|
609
|
-
const nextPath = navigationHistory[i].componentInstanceRenderedPath ?? navigationHistory[i].componentInstancePath;
|
|
610
|
-
if (nextPath && cumulativeInstancePath) {
|
|
611
|
-
cumulativeInstancePath = [
|
|
612
|
-
...cumulativeInstancePath,
|
|
613
|
-
...nextPath.slice(1)
|
|
614
|
-
];
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
639
|
+
const cumulativeInstancePath = computeCumulativeInstancePath(navigationHistory);
|
|
618
640
|
const result = [];
|
|
641
|
+
const hostInstanceChildrenCount = navigationHistory && navigationHistory.length > 0 ? Array.isArray(navigationHistory[navigationHistory.length - 1].instanceChildren) ? navigationHistory[navigationHistory.length - 1].instanceChildren.length : 0 : 0;
|
|
619
642
|
function traverse(node, currentPath = [0]) {
|
|
620
643
|
const needsPathCalculation = globalComponentRegistry || navigationHistory && navigationHistory.length > 0;
|
|
621
644
|
const renderedPath = needsPathCalculation ? calculateRenderedPath(currentPath, rootData, globalComponentRegistry, navigationHistory) : currentPath;
|
|
622
645
|
const adjustedRenderedPath = cumulativeInstancePath ? [...cumulativeInstancePath, ...renderedPath.slice(1)] : renderedPath;
|
|
646
|
+
const slotRenderedPaths = isSlotMarker(node) && hostInstanceChildrenCount > 1 ? expandSlotRenderedPaths(adjustedRenderedPath, hostInstanceChildrenCount) : void 0;
|
|
623
647
|
result.push({
|
|
624
648
|
path: currentPath,
|
|
625
649
|
// Keep logical path component-relative
|
|
626
|
-
renderedPath: adjustedRenderedPath
|
|
650
|
+
renderedPath: adjustedRenderedPath,
|
|
627
651
|
// Adjust rendered path for page-relative queries
|
|
652
|
+
...slotRenderedPaths ? { slotRenderedPaths } : {}
|
|
628
653
|
});
|
|
629
654
|
if (hasChildren(node)) {
|
|
630
655
|
node.children.forEach((child, index) => {
|
|
@@ -638,28 +663,29 @@ function buildTreePathsWithRendered(pageData, globalComponentRegistry, navigatio
|
|
|
638
663
|
traverse(rootData);
|
|
639
664
|
return result;
|
|
640
665
|
}
|
|
666
|
+
function expandSlotRenderedPaths(slotRenderedPath, instanceChildrenCount) {
|
|
667
|
+
if (instanceChildrenCount <= 0 || slotRenderedPath.length === 0) return [];
|
|
668
|
+
const prefix = slotRenderedPath.slice(0, -1);
|
|
669
|
+
const slotIdx = slotRenderedPath[slotRenderedPath.length - 1];
|
|
670
|
+
const out = [];
|
|
671
|
+
for (let i = 0; i < instanceChildrenCount; i++) {
|
|
672
|
+
out.push([...prefix, slotIdx + i]);
|
|
673
|
+
}
|
|
674
|
+
return out;
|
|
675
|
+
}
|
|
641
676
|
function buildComponentTreePaths(componentStructure, globalComponentRegistry, navigationHistory) {
|
|
642
677
|
const result = [];
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
cumulativeInstancePath = navigationHistory[0].componentInstanceRenderedPath ?? navigationHistory[0].componentInstancePath;
|
|
646
|
-
for (let i = 1; i < navigationHistory.length; i++) {
|
|
647
|
-
const nextPath = navigationHistory[i].componentInstanceRenderedPath ?? navigationHistory[i].componentInstancePath;
|
|
648
|
-
if (nextPath && cumulativeInstancePath) {
|
|
649
|
-
cumulativeInstancePath = [
|
|
650
|
-
...cumulativeInstancePath,
|
|
651
|
-
...nextPath.slice(1)
|
|
652
|
-
];
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}
|
|
678
|
+
const cumulativeInstancePath = computeCumulativeInstancePath(navigationHistory);
|
|
679
|
+
const hostInstanceChildrenCount = navigationHistory && navigationHistory.length > 0 ? Array.isArray(navigationHistory[navigationHistory.length - 1].instanceChildren) ? navigationHistory[navigationHistory.length - 1].instanceChildren.length : 0 : 0;
|
|
656
680
|
function traverse(node, currentPath = [0]) {
|
|
657
681
|
const needsPathCalculation = globalComponentRegistry || navigationHistory && navigationHistory.length > 0;
|
|
658
682
|
const renderedPath = needsPathCalculation ? calculateRenderedPath(currentPath, componentStructure, globalComponentRegistry, navigationHistory) : currentPath;
|
|
659
683
|
const adjustedRenderedPath = cumulativeInstancePath ? [...cumulativeInstancePath, ...renderedPath.slice(1)] : renderedPath;
|
|
684
|
+
const slotRenderedPaths = isSlotMarker(node) && hostInstanceChildrenCount > 1 ? expandSlotRenderedPaths(adjustedRenderedPath, hostInstanceChildrenCount) : void 0;
|
|
660
685
|
result.push({
|
|
661
686
|
path: currentPath,
|
|
662
|
-
renderedPath: adjustedRenderedPath
|
|
687
|
+
renderedPath: adjustedRenderedPath,
|
|
688
|
+
...slotRenderedPaths ? { slotRenderedPaths } : {}
|
|
663
689
|
});
|
|
664
690
|
if (hasChildren(node)) {
|
|
665
691
|
node.children.forEach((child, index) => {
|
|
@@ -708,6 +734,60 @@ function isValidCollectionId(id) {
|
|
|
708
734
|
return CMS_COLLECTION_ID_REGEX.test(id);
|
|
709
735
|
}
|
|
710
736
|
|
|
737
|
+
// lib/shared/validation/commentValidators.ts
|
|
738
|
+
import { z as z2 } from "zod";
|
|
739
|
+
var CommentStatusSchema = z2.enum(COMMENT_STATUSES);
|
|
740
|
+
var CommentAuthorSchema = z2.object({
|
|
741
|
+
login: z2.string().min(1),
|
|
742
|
+
name: z2.string().optional(),
|
|
743
|
+
avatarUrl: z2.string().optional()
|
|
744
|
+
});
|
|
745
|
+
var CommentNodeIdentitySchema = z2.object({
|
|
746
|
+
kind: z2.enum(["component", "node"]),
|
|
747
|
+
name: z2.string().min(1),
|
|
748
|
+
label: z2.string().optional()
|
|
749
|
+
});
|
|
750
|
+
var CommentAnchorSchema = z2.object({
|
|
751
|
+
nodePath: z2.array(z2.number().int().nonnegative()),
|
|
752
|
+
nodeIdentity: CommentNodeIdentitySchema,
|
|
753
|
+
offsetXPercent: z2.number().min(0).max(1),
|
|
754
|
+
offsetYPercent: z2.number().min(0).max(1),
|
|
755
|
+
breakpoint: z2.string().optional()
|
|
756
|
+
});
|
|
757
|
+
var CommentThreadEntrySchema = z2.object({
|
|
758
|
+
id: z2.string().min(1),
|
|
759
|
+
author: CommentAuthorSchema,
|
|
760
|
+
createdAt: z2.string().min(1),
|
|
761
|
+
text: z2.string(),
|
|
762
|
+
statusChange: CommentStatusSchema.nullable()
|
|
763
|
+
});
|
|
764
|
+
var CommentSchema = z2.object({
|
|
765
|
+
_id: z2.string().min(1),
|
|
766
|
+
_filename: z2.string().min(1),
|
|
767
|
+
_pagePath: z2.string().min(1),
|
|
768
|
+
_seq: z2.number().int().nonnegative(),
|
|
769
|
+
_createdAt: z2.string().min(1),
|
|
770
|
+
_updatedAt: z2.string().min(1),
|
|
771
|
+
_commitSha: z2.string().nullable(),
|
|
772
|
+
anchor: CommentAnchorSchema,
|
|
773
|
+
status: CommentStatusSchema,
|
|
774
|
+
thread: z2.array(CommentThreadEntrySchema).min(1)
|
|
775
|
+
});
|
|
776
|
+
function zodToValidationErrors(zodError) {
|
|
777
|
+
return zodError.errors.map((err) => ({
|
|
778
|
+
path: err.path.join(".") || "root",
|
|
779
|
+
message: err.message,
|
|
780
|
+
code: "INVALID_TYPE"
|
|
781
|
+
}));
|
|
782
|
+
}
|
|
783
|
+
function validateComment(data) {
|
|
784
|
+
const result = CommentSchema.safeParse(data);
|
|
785
|
+
if (result.success) {
|
|
786
|
+
return { valid: true, data: result.data };
|
|
787
|
+
}
|
|
788
|
+
return { valid: false, errors: zodToValidationErrors(result.error) };
|
|
789
|
+
}
|
|
790
|
+
|
|
711
791
|
// lib/shared/utils.ts
|
|
712
792
|
function deepClone(obj) {
|
|
713
793
|
return structuredClone(obj);
|
|
@@ -1255,6 +1335,62 @@ function serializeValue(value) {
|
|
|
1255
1335
|
}
|
|
1256
1336
|
return String(value);
|
|
1257
1337
|
}
|
|
1338
|
+
|
|
1339
|
+
// lib/shared/hrefRefs.ts
|
|
1340
|
+
function rewriteHref(value, oldHref, newHref) {
|
|
1341
|
+
if (value === oldHref) return newHref;
|
|
1342
|
+
if (value.startsWith(oldHref + "/") || value.startsWith(oldHref + "?") || value.startsWith(oldHref + "#")) {
|
|
1343
|
+
return newHref + value.substring(oldHref.length);
|
|
1344
|
+
}
|
|
1345
|
+
return null;
|
|
1346
|
+
}
|
|
1347
|
+
function rewriteHrefRefs(node, oldHref, newHref) {
|
|
1348
|
+
if (!node || typeof node !== "object") return false;
|
|
1349
|
+
if (!oldHref || oldHref === newHref) return false;
|
|
1350
|
+
let changed = false;
|
|
1351
|
+
const n = node;
|
|
1352
|
+
if (typeof n.href === "string") {
|
|
1353
|
+
const rewritten = rewriteHref(n.href, oldHref, newHref);
|
|
1354
|
+
if (rewritten !== null) {
|
|
1355
|
+
n.href = rewritten;
|
|
1356
|
+
changed = true;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
for (const key of Object.keys(n)) {
|
|
1360
|
+
if (key === "href") continue;
|
|
1361
|
+
const v = n[key];
|
|
1362
|
+
if (Array.isArray(v)) {
|
|
1363
|
+
for (const item of v) {
|
|
1364
|
+
if (item && typeof item === "object") {
|
|
1365
|
+
if (rewriteHrefRefs(item, oldHref, newHref)) changed = true;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
} else if (v && typeof v === "object") {
|
|
1369
|
+
if (rewriteHrefRefs(v, oldHref, newHref)) changed = true;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
return changed;
|
|
1373
|
+
}
|
|
1374
|
+
function countHrefRefs(node, href) {
|
|
1375
|
+
if (!node || typeof node !== "object" || !href) return 0;
|
|
1376
|
+
let count = 0;
|
|
1377
|
+
const n = node;
|
|
1378
|
+
if (typeof n.href === "string" && rewriteHref(n.href, href, "__x__") !== null) {
|
|
1379
|
+
count++;
|
|
1380
|
+
}
|
|
1381
|
+
for (const key of Object.keys(n)) {
|
|
1382
|
+
if (key === "href") continue;
|
|
1383
|
+
const v = n[key];
|
|
1384
|
+
if (Array.isArray(v)) {
|
|
1385
|
+
for (const item of v) {
|
|
1386
|
+
if (item && typeof item === "object") count += countHrefRefs(item, href);
|
|
1387
|
+
}
|
|
1388
|
+
} else if (v && typeof v === "object") {
|
|
1389
|
+
count += countHrefRefs(v, href);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
return count;
|
|
1393
|
+
}
|
|
1258
1394
|
export {
|
|
1259
1395
|
API_ROUTES,
|
|
1260
1396
|
BaseComponentRegistry,
|
|
@@ -1267,12 +1403,19 @@ export {
|
|
|
1267
1403
|
CMSSchemaSchema,
|
|
1268
1404
|
CMS_COLLECTION_ID_REGEX,
|
|
1269
1405
|
CMS_DRAFT_SUFFIX,
|
|
1406
|
+
COMMENT_STATUSES,
|
|
1270
1407
|
CSS_NAMED_COLORS,
|
|
1271
1408
|
CSS_PROPERTIES,
|
|
1272
1409
|
CSS_PROPERTIES_DEFINITION,
|
|
1273
1410
|
CSS_PROPERTY_GROUPS,
|
|
1274
1411
|
ClientNodeTypeRegistry,
|
|
1275
1412
|
ClientRegistry,
|
|
1413
|
+
CommentAnchorSchema,
|
|
1414
|
+
CommentAuthorSchema,
|
|
1415
|
+
CommentNodeIdentitySchema,
|
|
1416
|
+
CommentSchema,
|
|
1417
|
+
CommentStatusSchema,
|
|
1418
|
+
CommentThreadEntrySchema,
|
|
1276
1419
|
ComponentDefinitionSchema,
|
|
1277
1420
|
ComponentInstanceNodeType,
|
|
1278
1421
|
ComponentNodeSchema,
|
|
@@ -1289,6 +1432,7 @@ export {
|
|
|
1289
1432
|
DEFAULT_SITE_MARGIN,
|
|
1290
1433
|
DEFAULT_TEXTAREA_STYLE,
|
|
1291
1434
|
DEFAULT_TIMEOUT,
|
|
1435
|
+
DESIGN_VIEWPORT_VARS,
|
|
1292
1436
|
EmbedNodeType,
|
|
1293
1437
|
FILE_PATTERNS,
|
|
1294
1438
|
HMR_ROUTE,
|
|
@@ -1355,8 +1499,10 @@ export {
|
|
|
1355
1499
|
buildGradientCss,
|
|
1356
1500
|
buildItemUrl,
|
|
1357
1501
|
buildLocalizedPath,
|
|
1502
|
+
buildPageUrlForLocale,
|
|
1358
1503
|
buildParentPaths,
|
|
1359
1504
|
buildSiteMarginClamp,
|
|
1505
|
+
buildSlugIndex,
|
|
1360
1506
|
buildTemplateContext,
|
|
1361
1507
|
buildTreePathsWithRendered,
|
|
1362
1508
|
builtInNodeTypes,
|
|
@@ -1368,9 +1514,12 @@ export {
|
|
|
1368
1514
|
classesToStyles,
|
|
1369
1515
|
clearRegistry,
|
|
1370
1516
|
clearStoredLocale,
|
|
1517
|
+
collectComponentLibraries,
|
|
1371
1518
|
componentHasSlot,
|
|
1519
|
+
computeCumulativeInstancePath,
|
|
1372
1520
|
convertComponentPathToPagePath,
|
|
1373
1521
|
convertPagePathToComponentPath,
|
|
1522
|
+
countHrefRefs,
|
|
1374
1523
|
createError,
|
|
1375
1524
|
createNodeType,
|
|
1376
1525
|
createStyleMappingFromProps,
|
|
@@ -1383,6 +1532,7 @@ export {
|
|
|
1383
1532
|
detectRichTextFormat,
|
|
1384
1533
|
domPathStringToTreePath,
|
|
1385
1534
|
evaluateNodeIf,
|
|
1535
|
+
extractFamilyName,
|
|
1386
1536
|
extractInteractiveStyleMappings,
|
|
1387
1537
|
extractLocaleFromPath,
|
|
1388
1538
|
extractNodeProperties,
|
|
@@ -1391,16 +1541,24 @@ export {
|
|
|
1391
1541
|
extractUtilityClassesFromHTML,
|
|
1392
1542
|
extractVariableName,
|
|
1393
1543
|
filterCSSProperties,
|
|
1544
|
+
filterLibrariesByContext,
|
|
1394
1545
|
filterPropertyValues,
|
|
1395
1546
|
findLocaleByCode,
|
|
1547
|
+
findPageBySlug,
|
|
1396
1548
|
findPathData,
|
|
1549
|
+
fontFaceCss,
|
|
1550
|
+
fontPreloadLinks,
|
|
1397
1551
|
generateAllInteractiveCSS,
|
|
1398
1552
|
generateElementClassName,
|
|
1399
1553
|
generateFilenameFromItem,
|
|
1554
|
+
generateInlineStyleTag,
|
|
1400
1555
|
generateInteractiveCSS,
|
|
1556
|
+
generateLibraryTags,
|
|
1401
1557
|
generateRuleForClass,
|
|
1558
|
+
generateScriptTag,
|
|
1402
1559
|
generateShortCssVar,
|
|
1403
1560
|
generateSingleClassCSS,
|
|
1561
|
+
generateStylesheetTag,
|
|
1404
1562
|
generateUniqueFilename,
|
|
1405
1563
|
generateUtilityCSS,
|
|
1406
1564
|
getAllBreakpointNames,
|
|
@@ -1420,6 +1578,7 @@ export {
|
|
|
1420
1578
|
getGroupAbbreviation,
|
|
1421
1579
|
getGroupForProperty,
|
|
1422
1580
|
getLocaleCodes,
|
|
1581
|
+
getLocaleLinks,
|
|
1423
1582
|
getNestedValue,
|
|
1424
1583
|
getNodeTypeDefinition,
|
|
1425
1584
|
getParentAndIndexFromPath,
|
|
@@ -1496,6 +1655,7 @@ export {
|
|
|
1496
1655
|
isStyleMapping,
|
|
1497
1656
|
isStyleObject,
|
|
1498
1657
|
isStyleValue,
|
|
1658
|
+
isSupportedTemplateExpression,
|
|
1499
1659
|
isTemplateContext,
|
|
1500
1660
|
isTiptapDocument,
|
|
1501
1661
|
isValidCollectionId,
|
|
@@ -1510,6 +1670,7 @@ export {
|
|
|
1510
1670
|
logNetworkError,
|
|
1511
1671
|
logRuntimeError,
|
|
1512
1672
|
markAsSlotContent,
|
|
1673
|
+
mergeLibraries,
|
|
1513
1674
|
mergeResponsiveStyles,
|
|
1514
1675
|
migrateI18nConfig,
|
|
1515
1676
|
normalizeBreakpointConfig,
|
|
@@ -1545,10 +1706,14 @@ export {
|
|
|
1545
1706
|
resolvePaletteColor,
|
|
1546
1707
|
resolvePropsFromDefinition,
|
|
1547
1708
|
resolveSafePath,
|
|
1709
|
+
resolveSlugToPageId,
|
|
1548
1710
|
resolveTemplateRawValue,
|
|
1549
1711
|
resolveTranslation,
|
|
1550
1712
|
resolveVariableValueAtBreakpoint,
|
|
1551
1713
|
responsiveStylesToClasses,
|
|
1714
|
+
rewriteComponentRefs,
|
|
1715
|
+
rewriteHrefRefs,
|
|
1716
|
+
rewriteViewportUnits,
|
|
1552
1717
|
rgbToCssString,
|
|
1553
1718
|
rgbToHex,
|
|
1554
1719
|
rgbToHsl,
|
|
@@ -1572,11 +1737,14 @@ export {
|
|
|
1572
1737
|
textField,
|
|
1573
1738
|
textareaField,
|
|
1574
1739
|
tiptapToHtml,
|
|
1740
|
+
toFriendlyError,
|
|
1741
|
+
translatePath,
|
|
1575
1742
|
treePathToDomPathString,
|
|
1576
1743
|
urlField,
|
|
1577
1744
|
validateCMSItem,
|
|
1578
1745
|
validateCMSSchema,
|
|
1579
1746
|
validateCollectionId,
|
|
1747
|
+
validateComment,
|
|
1580
1748
|
validateComponentDefinition,
|
|
1581
1749
|
validateComponentNode,
|
|
1582
1750
|
validateComponentProps,
|