meno-core 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/chunks/{chunk-J4IPTP5X.js → chunk-UOF4MCAD.js} +92 -4
  2. package/dist/chunks/chunk-UOF4MCAD.js.map +7 -0
  3. package/dist/chunks/{chunk-7ZLF4NE5.js → chunk-ZEDLSHYQ.js} +2 -2
  4. package/dist/lib/client/index.js +46 -28
  5. package/dist/lib/client/index.js.map +2 -2
  6. package/dist/lib/server/index.js +1287 -236
  7. package/dist/lib/server/index.js.map +4 -4
  8. package/dist/lib/shared/index.js +5 -1
  9. package/dist/lib/shared/index.js.map +1 -1
  10. package/lib/client/core/ComponentBuilder.test.ts +32 -0
  11. package/lib/client/core/ComponentBuilder.ts +30 -0
  12. package/lib/client/scripts/formHandler.ts +17 -0
  13. package/lib/client/theme.test.ts +2 -2
  14. package/lib/client/theme.ts +28 -26
  15. package/lib/server/createServer.ts +5 -1
  16. package/lib/server/cssAudit.test.ts +270 -0
  17. package/lib/server/cssAudit.ts +815 -0
  18. package/lib/server/deMirror.test.ts +61 -0
  19. package/lib/server/deMirror.ts +317 -0
  20. package/lib/server/fileWatcher.test.ts +23 -0
  21. package/lib/server/fileWatcher.ts +6 -1
  22. package/lib/server/index.ts +19 -0
  23. package/lib/server/middleware/cors.test.ts +1 -1
  24. package/lib/server/middleware/cors.ts +1 -1
  25. package/lib/server/routes/api/core-routes.ts +18 -0
  26. package/lib/server/routes/api/cssAudit.test.ts +101 -0
  27. package/lib/server/routes/api/cssAudit.ts +138 -0
  28. package/lib/server/routes/api/deMirror.test.ts +105 -0
  29. package/lib/server/routes/api/deMirror.ts +127 -0
  30. package/lib/server/routes/api/functions.ts +2 -2
  31. package/lib/server/routes/api/pages.ts +2 -2
  32. package/lib/server/services/componentService.test.ts +43 -0
  33. package/lib/server/services/componentService.ts +49 -12
  34. package/lib/server/services/pageService.test.ts +15 -0
  35. package/lib/server/services/pageService.ts +44 -22
  36. package/lib/server/ssr/htmlGenerator.test.ts +29 -0
  37. package/lib/server/ssr/htmlGenerator.ts +83 -3
  38. package/lib/server/themeCssCodec.test.ts +67 -0
  39. package/lib/server/themeCssCodec.ts +67 -5
  40. package/lib/server/webflow/templateWrapper.ts +54 -0
  41. package/lib/shared/cssGeneration.test.ts +28 -0
  42. package/lib/shared/interfaces/contentProvider.ts +9 -0
  43. package/lib/shared/nodeUtils.ts +18 -0
  44. package/lib/shared/types/cms.ts +1 -0
  45. package/lib/shared/utilityClassConfig.ts +2 -0
  46. package/lib/shared/utilityClassMapper.test.ts +63 -0
  47. package/lib/shared/utilityClassMapper.ts +9 -1
  48. package/lib/shared/utilityClassNames.ts +74 -0
  49. package/lib/shared/utils/fileUtils.ts +11 -0
  50. package/lib/shared/validation/schemas.test.ts +78 -0
  51. package/lib/shared/validation/schemas.ts +54 -5
  52. package/lib/shared/viewportUnits.test.ts +34 -1
  53. package/lib/shared/viewportUnits.ts +43 -0
  54. package/package.json +3 -1
  55. package/vite.config.ts +4 -1
  56. package/dist/chunks/chunk-J4IPTP5X.js.map +0 -7
  57. /package/dist/chunks/{chunk-7ZLF4NE5.js.map → chunk-ZEDLSHYQ.js.map} +0 -0
@@ -132,7 +132,19 @@ var init_schemas = __esm({
132
132
  )
133
133
  ).optional()
134
134
  }).passthrough();
135
- PropDefinitionSchema = z.union([ListPropDefinitionSchema, BasePropDefinitionSchema]);
135
+ PropDefinitionSchema = z.object({ type: z.string() }).passthrough().superRefine((val, ctx) => {
136
+ const branch = val.type === "list" ? ListPropDefinitionSchema : BasePropDefinitionSchema;
137
+ const result = branch.safeParse(val);
138
+ if (result.success) return;
139
+ if (val.type === "list") {
140
+ ctx.addIssue({
141
+ code: z.ZodIssueCode.custom,
142
+ message: "list prop requires `itemSchema` and an object-array `default` (each item is a `{ field: value }` object, not a bare string)"
143
+ });
144
+ return;
145
+ }
146
+ for (const issue of result.error.issues) ctx.addIssue(issue);
147
+ });
136
148
  StyleMappingSchema = z.object({
137
149
  _mapping: z.literal(true),
138
150
  prop: z.string(),
@@ -455,7 +467,15 @@ var init_schemas = __esm({
455
467
  _lineMap: z.record(z.string(), LineRangeSchema).optional(),
456
468
  // Marks a page whose source is outside the meno-astro dialect (read-only in the editor).
457
469
  // Explicit (not just .passthrough()) so it survives a future tightening of this schema.
458
- _unsupported: z.object({ reason: z.string() }).passthrough().optional()
470
+ _unsupported: z.object({ reason: z.string() }).passthrough().optional(),
471
+ // A component payload (`{ component: {...} }`) must NEVER validate as a page.
472
+ // Without this guard the page branch parses structurally (it's `.passthrough()`)
473
+ // and only trips the refine below — so when both branches of `PageDataSchema`
474
+ // fail, zod treats this branch as the "closest" (dirty) one and surfaces
475
+ // "JSONPage must have …root", masking the real component error (e.g. a malformed
476
+ // list prop). Rejecting a present `component` key makes this branch hard-fail on
477
+ // component payloads, so `PageDataSchema` reports the component branch instead.
478
+ component: z.undefined().optional()
459
479
  }).passthrough().refine(
460
480
  (data) => {
461
481
  return data.meta !== void 0 || data.components !== void 0 || data.root !== void 0;
@@ -495,7 +515,9 @@ var init_schemas = __esm({
495
515
  options: z.array(z.string()).optional(),
496
516
  accept: z.string().optional(),
497
517
  collection: z.string().optional(),
498
- multiple: z.boolean().optional()
518
+ multiple: z.boolean().optional(),
519
+ editor: z.enum(["basic", "extended"]).optional()
520
+ // For 'rich-text' type: selects the render helper (Basic → richText(); Extended → richTextWithComponents())
499
521
  }).passthrough();
500
522
  CMSClientDataStrategySchema = z.enum(["auto", "inline", "static"]);
501
523
  CMSClientDataConfigSchema = z.object({
@@ -3229,6 +3251,9 @@ function isComponentNode(node) {
3229
3251
  function isHtmlNode(node) {
3230
3252
  return node?.type === NODE_TYPE.NODE;
3231
3253
  }
3254
+ function isClassStylableNode(node) {
3255
+ return node?.type === NODE_TYPE.NODE || node?.type === NODE_TYPE.EMBED || node?.type === NODE_TYPE.LINK || node?.type === NODE_TYPE.MARKDOWN;
3256
+ }
3232
3257
  function getComponentName(node) {
3233
3258
  return isComponentNode(node) ? node.component : void 0;
3234
3259
  }
@@ -3933,6 +3958,8 @@ var prefixToCSSProperty = {
3933
3958
  "border-r": "border-right",
3934
3959
  "border-b": "border-bottom",
3935
3960
  "border-l": "border-left",
3961
+ "border-x": "border-inline",
3962
+ "border-y": "border-block",
3936
3963
  rounded: "border-radius",
3937
3964
  "rounded-tl": "border-top-left-radius",
3938
3965
  "rounded-tr": "border-top-right-radius",
@@ -5023,6 +5050,38 @@ function negateCssValue(root, value) {
5023
5050
  }
5024
5051
  return /^\d/.test(value) ? `-${value}` : null;
5025
5052
  }
5053
+ var BORDER_SIDE_PROPERTY = {
5054
+ border: "border",
5055
+ "border-t": "border-top",
5056
+ "border-r": "border-right",
5057
+ "border-b": "border-bottom",
5058
+ "border-l": "border-left",
5059
+ "border-x": "border-inline",
5060
+ "border-y": "border-block"
5061
+ };
5062
+ var BORDER_STYLE_KEYWORDS = /* @__PURE__ */ new Set(["solid", "dashed", "dotted", "double", "none", "hidden"]);
5063
+ var BORDER_STYLE = "solid";
5064
+ function parseBorderClass(root, rest) {
5065
+ if (root !== "border") {
5066
+ const sideProp2 = BORDER_SIDE_PROPERTY[root];
5067
+ if (sideProp2 && /^\d+$/.test(rest)) {
5068
+ return { property: sideProp2, value: `${rest}px ${BORDER_STYLE}`, root, kind: "numeric" };
5069
+ }
5070
+ return null;
5071
+ }
5072
+ const sideRoot = `border-${rest}`;
5073
+ const sideProp = BORDER_SIDE_PROPERTY[sideRoot];
5074
+ if (sideProp) {
5075
+ return { property: sideProp, value: `1px ${BORDER_STYLE}`, root: sideRoot, kind: "keyword" };
5076
+ }
5077
+ if (/^\d+$/.test(rest)) {
5078
+ return { property: "border", value: `${rest}px ${BORDER_STYLE}`, root: "border", kind: "numeric" };
5079
+ }
5080
+ if (BORDER_STYLE_KEYWORDS.has(rest)) {
5081
+ return { property: "border-style", value: rest, root: "border", kind: "keyword" };
5082
+ }
5083
+ return null;
5084
+ }
5026
5085
  function parseUtilityClass(className, knownTokens) {
5027
5086
  const stat = staticUtilityReverse[className];
5028
5087
  if (stat) {
@@ -5036,6 +5095,9 @@ function parseUtilityClass(className, knownTokens) {
5036
5095
  kind: "keyword"
5037
5096
  };
5038
5097
  }
5098
+ if (className === "border") {
5099
+ return { property: "border", value: `1px ${BORDER_STYLE}`, root: "border", kind: "keyword" };
5100
+ }
5039
5101
  if (className.startsWith("-") && className.length > 1) {
5040
5102
  const positive = parseUtilityClass(className.slice(1), knownTokens);
5041
5103
  if (positive?.root && positive.value != null && NEGATABLE_ROOTS.has(positive.root)) {
@@ -5089,6 +5151,10 @@ function parseRootValue(root, rest, knownTokens) {
5089
5151
  }
5090
5152
  return { property, value, root, kind: "var" };
5091
5153
  }
5154
+ if (root === "border" || BORDER_SIDE_PROPERTY[root]) {
5155
+ const border = parseBorderClass(root, rest);
5156
+ if (border) return border;
5157
+ }
5092
5158
  const keyword = keywordValues[root]?.[rest];
5093
5159
  if (keyword !== void 0) {
5094
5160
  return { property: resolveRootProperty(root, keyword), value: keyword, root, kind: "keyword" };
@@ -5336,6 +5402,8 @@ function propertyValueToClass(prop, value) {
5336
5402
  className = `[${camelToKebab(prop)}:${stringValue}]`;
5337
5403
  } else if (colorTokenProps.has(prop) && isBareColorTokenName(varName)) {
5338
5404
  className = `${root}-${varName}`;
5405
+ } else if (colorTokenProps.has(prop)) {
5406
+ className = `${root}-[var(${varMatch[1]})]`;
5339
5407
  } else className = `${root}-(${varMatch[1]})`;
5340
5408
  }
5341
5409
  }
@@ -5955,6 +6023,24 @@ function rewriteViewportUnits(input) {
5955
6023
  return `calc(var(--design-${unit}, 1${unit}) * ${num})`;
5956
6024
  });
5957
6025
  }
6026
+ function rewriteViewportUnitsInStylesheet(css) {
6027
+ if (!css) return css;
6028
+ let out = "";
6029
+ let seg = "";
6030
+ for (let i = 0; i < css.length; i++) {
6031
+ const ch = css[i];
6032
+ if (ch === "{") {
6033
+ out += seg + ch;
6034
+ seg = "";
6035
+ } else if (ch === "}") {
6036
+ out += rewriteViewportUnits(seg) + ch;
6037
+ seg = "";
6038
+ } else {
6039
+ seg += ch;
6040
+ }
6041
+ }
6042
+ return out + seg;
6043
+ }
5958
6044
  var DESIGN_VIEWPORT_VARS = [
5959
6045
  "--design-vh",
5960
6046
  "--design-svh",
@@ -6734,6 +6820,7 @@ export {
6734
6820
  isEmptyContainer,
6735
6821
  isComponentNode,
6736
6822
  isHtmlNode,
6823
+ isClassStylableNode,
6737
6824
  getComponentName,
6738
6825
  getTagName,
6739
6826
  getDisplayName,
@@ -6827,6 +6914,7 @@ export {
6827
6914
  normalizePath,
6828
6915
  isCurrentLink,
6829
6916
  rewriteViewportUnits,
6917
+ rewriteViewportUnitsInStylesheet,
6830
6918
  DESIGN_VIEWPORT_VARS,
6831
6919
  toFriendlyError,
6832
6920
  sortClassesByPropertyOrder,
@@ -6839,4 +6927,4 @@ export {
6839
6927
  generateInteractiveCSS,
6840
6928
  generateAllInteractiveCSS
6841
6929
  };
6842
- //# sourceMappingURL=chunk-J4IPTP5X.js.map
6930
+ //# sourceMappingURL=chunk-UOF4MCAD.js.map