@yext/visual-editor 2.0.0-beta.2 → 2.0.0-beta.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.
- package/dist/{SectionLibraryVisualEditorProvider-fUGYIhyC.js → SectionLibraryVisualEditorProvider-Dbj44frg.js} +6888 -6774
- package/dist/SectionLibraryVisualEditorProvider.css +1 -1
- package/dist/cli/yextve.js +108 -28
- package/dist/index.d.ts +3 -3
- package/dist/locales/platform/cs/visual-editor.json +3 -0
- package/dist/locales/platform/da/visual-editor.json +3 -0
- package/dist/locales/platform/de/visual-editor.json +3 -0
- package/dist/locales/platform/en/visual-editor.json +3 -0
- package/dist/locales/platform/en-GB/visual-editor.json +3 -0
- package/dist/locales/platform/es/visual-editor.json +3 -0
- package/dist/locales/platform/et/visual-editor.json +3 -0
- package/dist/locales/platform/fi/visual-editor.json +3 -0
- package/dist/locales/platform/fr/visual-editor.json +3 -0
- package/dist/locales/platform/hr/visual-editor.json +3 -0
- package/dist/locales/platform/hu/visual-editor.json +3 -0
- package/dist/locales/platform/it/visual-editor.json +3 -0
- package/dist/locales/platform/ja/visual-editor.json +3 -0
- package/dist/locales/platform/lt/visual-editor.json +3 -0
- package/dist/locales/platform/lv/visual-editor.json +3 -0
- package/dist/locales/platform/nb/visual-editor.json +3 -0
- package/dist/locales/platform/nl/visual-editor.json +3 -0
- package/dist/locales/platform/pl/visual-editor.json +3 -0
- package/dist/locales/platform/pt/visual-editor.json +3 -0
- package/dist/locales/platform/ro/visual-editor.json +3 -0
- package/dist/locales/platform/sk/visual-editor.json +3 -0
- package/dist/locales/platform/sv/visual-editor.json +3 -0
- package/dist/locales/platform/tr/visual-editor.json +3 -0
- package/dist/locales/platform/zh/visual-editor.json +3 -0
- package/dist/locales/platform/zh-TW/visual-editor.json +3 -0
- package/dist/{locatorEntityTypes-s4dmT9l5.d.ts → locatorEntityTypes-Cx069o6O.d.ts} +8 -0
- package/dist/plugin/plugin.js +154 -149
- package/dist/section-library-support.js +49 -49
- package/dist/sectionLibrarySupport.d.ts +2 -2
- package/dist/style.css +1 -1
- package/dist/{visual-editor-VcrEkFyd.js → visual-editor-09Llsq7g.js} +297 -291
- package/dist/{visual-editor-hVELayZs.js → visual-editor-2ORuu8_g.js} +293 -287
- package/dist/{visual-editor-BDozYwKy.js → visual-editor-B0RChJAU.js} +293 -287
- package/dist/{visual-editor-BuYrclmi.js → visual-editor-B2kjEXp2.js} +299 -293
- package/dist/{visual-editor-Cd8yeRID.js → visual-editor-BAapOoWM.js} +307 -301
- package/dist/{visual-editor-D96X4hBl.js → visual-editor-BHd18M8g.js} +297 -291
- package/dist/{visual-editor-BIqNAAcB.js → visual-editor-BIm0S65w.js} +305 -299
- package/dist/{visual-editor-DjN3MVkl.js → visual-editor-BYcvKUJc.js} +281 -275
- package/dist/{visual-editor-DqddYaYq.js → visual-editor-Bbydkr0I.js} +284 -278
- package/dist/{visual-editor-CCLIvOCf.js → visual-editor-BhN3aRjm.js} +281 -275
- package/dist/{visual-editor-AXgoU7J5.js → visual-editor-BiWbsaWp.js} +285 -279
- package/dist/{visual-editor-BGMk-qTN.js → visual-editor-BlP1VpUW.js} +300 -294
- package/dist/{visual-editor-bauJ9beX.js → visual-editor-C4_3sOZk.js} +285 -279
- package/dist/{visual-editor-2Y77HmqL.js → visual-editor-CKGz4dG0.js} +308 -302
- package/dist/{visual-editor-DrCmls4W.js → visual-editor-CPhXp-Gz.js} +281 -275
- package/dist/{visual-editor-CcuA4NSE.js → visual-editor-CtqYqY5l.js} +285 -279
- package/dist/{visual-editor-B-8ROr4n.js → visual-editor-DHjY21yq.js} +285 -279
- package/dist/{visual-editor-7P4U2T4q.js → visual-editor-DZxcSdwZ.js} +286 -280
- package/dist/{visual-editor-Dd-aD1iL.js → visual-editor-DdRZ_kR_.js} +286 -280
- package/dist/{visual-editor-CY2YjlX9.js → visual-editor-DjSURqT_.js} +296 -290
- package/dist/{visual-editor-CE2J5pWp.js → visual-editor-Jkut-qXP.js} +281 -275
- package/dist/{visual-editor-BPI_dyYw.js → visual-editor-Ln4QTSN0.js} +291 -285
- package/dist/{visual-editor-Bo-tmHFc.js → visual-editor-U1Pe_9_s.js} +284 -278
- package/dist/{visual-editor-CpCR_bSp.js → visual-editor-WZ5gb_gc.js} +294 -288
- package/dist/{visual-editor-Bkgub-3w.js → visual-editor-fiR-iLFH.js} +284 -278
- package/dist/visual-editor.js +10782 -10579
- package/package.json +1 -1
package/dist/plugin/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import l from "node:path";
|
|
2
2
|
import f from "fs-extra";
|
|
3
3
|
import { Project as J, Node as I, SyntaxKind as T } from "ts-morph";
|
|
4
4
|
import { fileURLToPath as Nt, pathToFileURL as Dt } from "node:url";
|
|
@@ -219,6 +219,7 @@ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = (
|
|
|
219
219
|
data
|
|
220
220
|
): HeadConfig => {
|
|
221
221
|
const { title, description } = getPageMetadata(data.document);
|
|
222
|
+
const schema = getSchema(data);
|
|
222
223
|
const faviconUrl =
|
|
223
224
|
data.document?._favicon ?? data.document?._site?.favicon?.url;
|
|
224
225
|
return {
|
|
@@ -262,7 +263,7 @@ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = (
|
|
|
262
263
|
applyAnalytics(data.document),
|
|
263
264
|
applyHeaderScript(data.document),
|
|
264
265
|
applyTheme(data.document, data.relativePrefixToRoot, defaultThemeConfig),
|
|
265
|
-
SchemaWrapper(
|
|
266
|
+
typeof schema === "string" ? schema : SchemaWrapper(schema),
|
|
266
267
|
applyCertifiedFacts(data.document),
|
|
267
268
|
].join("\\n"),
|
|
268
269
|
};
|
|
@@ -355,8 +356,8 @@ const SectionLibraryLayout: Template<TemplateRenderProps> = (props) => {
|
|
|
355
356
|
};
|
|
356
357
|
|
|
357
358
|
export default SectionLibraryLayout;
|
|
358
|
-
`, vt = /^[
|
|
359
|
-
const e =
|
|
359
|
+
`, vt = /^[a-z][a-z0-9-]{0,61}[a-z0-9](?![\s\S])/, W = 1024, Mt = (t) => {
|
|
360
|
+
const e = l.join(t, "src", "library", "library.json"), n = l.relative(t, e), o = [], r = (p, m) => {
|
|
360
361
|
o.push({ category: "api", filePath: n, message: m, rule: p });
|
|
361
362
|
};
|
|
362
363
|
if (!f.existsSync(e))
|
|
@@ -384,11 +385,15 @@ export default SectionLibraryLayout;
|
|
|
384
385
|
"field/description/length",
|
|
385
386
|
`description must be at most ${W} characters.`
|
|
386
387
|
) : s.set("description", d);
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
"
|
|
390
|
-
|
|
391
|
-
|
|
388
|
+
const c = s.get("id");
|
|
389
|
+
if (c) {
|
|
390
|
+
const p = c.startsWith("yext_") ? c.slice(5) : c;
|
|
391
|
+
(c.length > 63 || !vt.test(p)) && r(
|
|
392
|
+
"field/id/safe",
|
|
393
|
+
"id must be 2–63 characters, contain only lowercase letters, numbers, and hyphens, start with a lowercase letter, and end with a letter or number."
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
return o.length > 0 ? { issues: o } : {
|
|
392
397
|
issues: o,
|
|
393
398
|
metadata: {
|
|
394
399
|
schemaVersion: 1,
|
|
@@ -416,8 +421,8 @@ export default SectionLibraryLayout;
|
|
|
416
421
|
r[i] = a;
|
|
417
422
|
continue;
|
|
418
423
|
}
|
|
419
|
-
const
|
|
420
|
-
if (
|
|
424
|
+
const c = q(s), p = q(a);
|
|
425
|
+
if (c && p) {
|
|
421
426
|
r[i] = k(
|
|
422
427
|
s,
|
|
423
428
|
a,
|
|
@@ -426,9 +431,9 @@ export default SectionLibraryLayout;
|
|
|
426
431
|
);
|
|
427
432
|
continue;
|
|
428
433
|
}
|
|
429
|
-
|
|
434
|
+
c !== p && n?.({
|
|
430
435
|
path: d,
|
|
431
|
-
builtInType:
|
|
436
|
+
builtInType: c ? "object" : "string",
|
|
432
437
|
repoType: p ? "object" : "string"
|
|
433
438
|
}), r[i] = a;
|
|
434
439
|
}
|
|
@@ -436,11 +441,11 @@ export default SectionLibraryLayout;
|
|
|
436
441
|
}, q = (t) => typeof t == "object", D = "stream.config.ts", yt = "/__yext_visual_editor/local-editor", mt = "local-editor-data-", Ft = "src/templates/local-editor-data.tsx", Bt = "/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */", Y = (t) => {
|
|
437
442
|
const e = t.trim().replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
|
|
438
443
|
return `${mt}${e || "layout"}`;
|
|
439
|
-
}, Gt = (t) =>
|
|
444
|
+
}, Gt = (t) => l.join(
|
|
440
445
|
"src",
|
|
441
446
|
"templates",
|
|
442
447
|
`${Y(t)}.tsx`
|
|
443
|
-
), K = (t, e) =>
|
|
448
|
+
), K = (t, e) => l.isAbsolute(e) ? e : l.join(t, e), Ht = (t) => {
|
|
444
449
|
const e = K(
|
|
445
450
|
t,
|
|
446
451
|
D
|
|
@@ -517,7 +522,7 @@ export default config;
|
|
|
517
522
|
}, d = s("id");
|
|
518
523
|
if (!d || !b.test(d))
|
|
519
524
|
throw new Error(`${t} config must define a valid id`);
|
|
520
|
-
const
|
|
525
|
+
const c = a.getProperty("pageSetTypes"), p = c ? c.asKind(T.PropertyAssignment)?.getInitializer()?.asKind(T.ArrayLiteralExpression)?.getElements().map((u) => {
|
|
521
526
|
const E = u.asKind(T.StringLiteral)?.getLiteralValue(), _ = pt.find(
|
|
522
527
|
(L) => L === E
|
|
523
528
|
);
|
|
@@ -527,7 +532,7 @@ export default config;
|
|
|
527
532
|
);
|
|
528
533
|
return _;
|
|
529
534
|
}) : void 0;
|
|
530
|
-
if (
|
|
535
|
+
if (c && !p)
|
|
531
536
|
throw new Error(
|
|
532
537
|
`${t} config.pageSetTypes must be an array of page set types`
|
|
533
538
|
);
|
|
@@ -582,8 +587,8 @@ export default config;
|
|
|
582
587
|
`${t} sharedComponentMetadata must be an array literal`
|
|
583
588
|
);
|
|
584
589
|
return {
|
|
585
|
-
components: d.map((
|
|
586
|
-
const m =
|
|
590
|
+
components: d.map((c, p) => {
|
|
591
|
+
const m = c.asKind(T.ObjectLiteralExpression);
|
|
587
592
|
if (!m)
|
|
588
593
|
throw new Error(
|
|
589
594
|
`${t} sharedComponentMetadata[${p}] must be an object literal`
|
|
@@ -663,25 +668,25 @@ const Wt = (t) => {
|
|
|
663
668
|
e.forget();
|
|
664
669
|
}
|
|
665
670
|
}, ft = (t, e) => {
|
|
666
|
-
const n =
|
|
671
|
+
const n = l.dirname(Nt(import.meta.url));
|
|
667
672
|
let o;
|
|
668
673
|
if (n.endsWith(
|
|
669
|
-
|
|
674
|
+
l.join("src", "internal", "sectionLibraryValidation")
|
|
670
675
|
))
|
|
671
|
-
o =
|
|
676
|
+
o = l.resolve(
|
|
672
677
|
n,
|
|
673
678
|
"..",
|
|
674
679
|
"..",
|
|
675
680
|
"..",
|
|
676
681
|
"locales"
|
|
677
682
|
);
|
|
678
|
-
else if (
|
|
679
|
-
o =
|
|
683
|
+
else if (l.basename(l.dirname(n)) === "dist")
|
|
684
|
+
o = l.resolve(n, "..", "locales");
|
|
680
685
|
else
|
|
681
686
|
throw new Error(
|
|
682
687
|
`Cannot determine the built-in translation location from ${n}`
|
|
683
688
|
);
|
|
684
|
-
const r =
|
|
689
|
+
const r = l.join(
|
|
685
690
|
o,
|
|
686
691
|
t,
|
|
687
692
|
e,
|
|
@@ -701,15 +706,15 @@ const Wt = (t) => {
|
|
|
701
706
|
"local-editor"
|
|
702
707
|
// generated Local Editor template ID
|
|
703
708
|
]), b = /^[A-Za-z0-9_-]+$/, Zt = (t) => {
|
|
704
|
-
const e =
|
|
709
|
+
const e = l.join(t, "src", "library"), n = [], o = (u, E, _, L) => {
|
|
705
710
|
n.push({
|
|
706
711
|
category: "structure",
|
|
707
712
|
...L ? { severity: L } : {},
|
|
708
|
-
filePath:
|
|
713
|
+
filePath: l.relative(t, u) || ".",
|
|
709
714
|
message: pe(_, t),
|
|
710
715
|
rule: E
|
|
711
716
|
});
|
|
712
|
-
}, r = re(t, e, o), i =
|
|
717
|
+
}, r = re(t, e, o), i = l.join(
|
|
713
718
|
e,
|
|
714
719
|
"migrations",
|
|
715
720
|
"registry.ts"
|
|
@@ -728,21 +733,21 @@ const Wt = (t) => {
|
|
|
728
733
|
t,
|
|
729
734
|
e,
|
|
730
735
|
o
|
|
731
|
-
), d =
|
|
736
|
+
), d = l.join(
|
|
732
737
|
e,
|
|
733
738
|
"shared",
|
|
734
739
|
"componentRegistry.ts"
|
|
735
740
|
);
|
|
736
|
-
let
|
|
741
|
+
let c;
|
|
737
742
|
try {
|
|
738
|
-
|
|
743
|
+
c = Kt(d);
|
|
739
744
|
} catch (u) {
|
|
740
745
|
o(d, "shared/invalid", C(u));
|
|
741
746
|
}
|
|
742
|
-
const p =
|
|
747
|
+
const p = c?.components ?? [], m = c?.rootPageSetTypes ?? [], g = ae(e, o), y = g.map(
|
|
743
748
|
({ defaultLayoutPath: u, ...E }) => E
|
|
744
749
|
);
|
|
745
|
-
!
|
|
750
|
+
!c && !f.existsSync(d) && g.some((u) => u.metadata.pageSetType !== "ENTITY") && o(
|
|
746
751
|
d,
|
|
747
752
|
"shared/missing",
|
|
748
753
|
"A shared component registry is required for DIRECTORY and LOCATOR layouts."
|
|
@@ -781,12 +786,12 @@ const Wt = (t) => {
|
|
|
781
786
|
const o = {
|
|
782
787
|
platform: {},
|
|
783
788
|
page: {}
|
|
784
|
-
}, r =
|
|
789
|
+
}, r = l.join(e, "i18n");
|
|
785
790
|
if (!f.existsSync(r))
|
|
786
791
|
return o;
|
|
787
792
|
const i = f.readdirSync(r, { withFileTypes: !0 }).filter((a) => a.name !== ".gitkeep").sort((a, s) => a.name.localeCompare(s.name));
|
|
788
793
|
for (const a of i) {
|
|
789
|
-
const s = a.name, d =
|
|
794
|
+
const s = a.name, d = l.join(r, s);
|
|
790
795
|
if (!a.isDirectory() || !te.includes(
|
|
791
796
|
s
|
|
792
797
|
)) {
|
|
@@ -808,8 +813,8 @@ const Wt = (t) => {
|
|
|
808
813
|
return o;
|
|
809
814
|
}, oe = (t, e, n, o, r) => {
|
|
810
815
|
for (const i of f.readdirSync(e, { withFileTypes: !0 }).filter((a) => a.name !== ".gitkeep").sort((a, s) => a.name.localeCompare(s.name))) {
|
|
811
|
-
const a =
|
|
812
|
-
if (!i.isFile() ||
|
|
816
|
+
const a = l.join(e, i.name), s = l.basename(i.name, l.extname(i.name));
|
|
817
|
+
if (!i.isFile() || l.extname(i.name) !== ".json" || !ee(s)) {
|
|
813
818
|
r(
|
|
814
819
|
a,
|
|
815
820
|
"i18n/locale",
|
|
@@ -836,9 +841,9 @@ const Wt = (t) => {
|
|
|
836
841
|
);
|
|
837
842
|
continue;
|
|
838
843
|
}
|
|
839
|
-
o[n][s] =
|
|
840
|
-
const
|
|
841
|
-
|
|
844
|
+
o[n][s] = l.relative(t, a).split(l.sep).join("/");
|
|
845
|
+
const c = ft(n, s);
|
|
846
|
+
c && k(c, d, (p) => {
|
|
842
847
|
r(
|
|
843
848
|
a,
|
|
844
849
|
"i18n/shape-collision",
|
|
@@ -850,12 +855,12 @@ const Wt = (t) => {
|
|
|
850
855
|
}, gt = (t) => !t || typeof t != "object" || Array.isArray(t) ? !1 : Object.values(t).every(
|
|
851
856
|
(e) => typeof e == "string" || gt(e)
|
|
852
857
|
), re = (t, e, n) => {
|
|
853
|
-
const o =
|
|
858
|
+
const o = l.join(e, "sections");
|
|
854
859
|
if (!f.existsSync(o))
|
|
855
860
|
return [];
|
|
856
861
|
const r = [];
|
|
857
862
|
for (const i of f.readdirSync(o, { withFileTypes: !0 }).filter((a) => a.name !== ".gitkeep").sort((a, s) => a.name.localeCompare(s.name))) {
|
|
858
|
-
const a =
|
|
863
|
+
const a = l.join(o, i.name);
|
|
859
864
|
if (i.isDirectory()) {
|
|
860
865
|
n(
|
|
861
866
|
a,
|
|
@@ -864,7 +869,7 @@ const Wt = (t) => {
|
|
|
864
869
|
);
|
|
865
870
|
continue;
|
|
866
871
|
}
|
|
867
|
-
const s =
|
|
872
|
+
const s = l.extname(i.name);
|
|
868
873
|
if (!i.isFile() || ![".tsx", ".jsx"].includes(s)) {
|
|
869
874
|
n(
|
|
870
875
|
a,
|
|
@@ -873,7 +878,7 @@ const Wt = (t) => {
|
|
|
873
878
|
);
|
|
874
879
|
continue;
|
|
875
880
|
}
|
|
876
|
-
const d =
|
|
881
|
+
const d = l.basename(i.name, s);
|
|
877
882
|
if (!b.test(d)) {
|
|
878
883
|
n(
|
|
879
884
|
a,
|
|
@@ -883,14 +888,14 @@ const Wt = (t) => {
|
|
|
883
888
|
continue;
|
|
884
889
|
}
|
|
885
890
|
try {
|
|
886
|
-
const
|
|
891
|
+
const c = {
|
|
887
892
|
...Jt(a, d),
|
|
888
893
|
componentName: d,
|
|
889
|
-
sourcePath:
|
|
894
|
+
sourcePath: l.relative(t, a)
|
|
890
895
|
};
|
|
891
|
-
b.test(
|
|
892
|
-
} catch (
|
|
893
|
-
const p = C(
|
|
896
|
+
b.test(c.id) ? r.push(c) : n(a, "sections/id", "config must define a valid id");
|
|
897
|
+
} catch (c) {
|
|
898
|
+
const p = C(c), m = p.includes("config must define a valid id");
|
|
894
899
|
n(
|
|
895
900
|
a,
|
|
896
901
|
m ? "sections/id" : "sections/frontmatter",
|
|
@@ -900,12 +905,12 @@ const Wt = (t) => {
|
|
|
900
905
|
}
|
|
901
906
|
return r;
|
|
902
907
|
}, ae = (t, e) => {
|
|
903
|
-
const n =
|
|
908
|
+
const n = l.join(t, "layouts");
|
|
904
909
|
if (!f.existsSync(n))
|
|
905
910
|
return e(n, "layouts/missing", "Missing layouts directory."), [];
|
|
906
911
|
const o = f.readdirSync(n, { withFileTypes: !0 }).filter((i) => i.isDirectory()).sort((i, a) => i.name.localeCompare(a.name)), r = o.flatMap((i) => {
|
|
907
912
|
const a = se(
|
|
908
|
-
|
|
913
|
+
l.join(n, i.name),
|
|
909
914
|
e
|
|
910
915
|
);
|
|
911
916
|
return a ? [a] : [];
|
|
@@ -913,26 +918,26 @@ const Wt = (t) => {
|
|
|
913
918
|
if (r.length === o.length) {
|
|
914
919
|
const i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
|
|
915
920
|
for (const d of r) {
|
|
916
|
-
const
|
|
917
|
-
if (i.has(
|
|
921
|
+
const c = d.metadata.id;
|
|
922
|
+
if (i.has(c) ? e(
|
|
918
923
|
n,
|
|
919
924
|
"layouts/duplicate-id",
|
|
920
|
-
`Layout ID is not unique: ${
|
|
921
|
-
) : i.add(
|
|
925
|
+
`Layout ID is not unique: ${c}`
|
|
926
|
+
) : i.add(c), d.metadata.pageSetType !== "ENTITY" && d.metadata.pageSetType !== "DIRECTORY")
|
|
922
927
|
continue;
|
|
923
|
-
const p = Y(
|
|
924
|
-
m && m !==
|
|
928
|
+
const p = Y(c), m = a.get(p);
|
|
929
|
+
m && m !== c ? e(
|
|
925
930
|
n,
|
|
926
931
|
"layouts/local-editor-template-collision",
|
|
927
|
-
`Layout IDs ${m} and ${
|
|
928
|
-
) : a.set(p,
|
|
932
|
+
`Layout IDs ${m} and ${c} generate the same Local Editor id: ${p}`
|
|
933
|
+
) : a.set(p, c);
|
|
929
934
|
}
|
|
930
935
|
const s = /* @__PURE__ */ new Map();
|
|
931
936
|
for (const d of r) {
|
|
932
|
-
const
|
|
937
|
+
const c = d.metadata.pageSetType;
|
|
933
938
|
s.set(
|
|
934
|
-
|
|
935
|
-
(s.get(
|
|
939
|
+
c,
|
|
940
|
+
(s.get(c) ?? 0) + 1
|
|
936
941
|
);
|
|
937
942
|
}
|
|
938
943
|
(s.get("ENTITY") ?? 0) === 0 && e(
|
|
@@ -951,7 +956,7 @@ const Wt = (t) => {
|
|
|
951
956
|
DIRECTORY: 1,
|
|
952
957
|
LOCATOR: 2
|
|
953
958
|
}, ie = (t, e) => Q[t.metadata.pageSetType] - Q[e.metadata.pageSetType] || t.metadata.id.localeCompare(e.metadata.id), se = (t, e) => {
|
|
954
|
-
const n =
|
|
959
|
+
const n = l.join(t, "metadata.json"), o = l.join(t, "defaultLayout.json"), r = tt(
|
|
955
960
|
n,
|
|
956
961
|
"layout metadata",
|
|
957
962
|
e
|
|
@@ -970,7 +975,7 @@ const Wt = (t) => {
|
|
|
970
975
|
"vertical",
|
|
971
976
|
jt,
|
|
972
977
|
n
|
|
973
|
-
),
|
|
978
|
+
), c = et(
|
|
974
979
|
r,
|
|
975
980
|
"purpose",
|
|
976
981
|
Yt,
|
|
@@ -984,7 +989,7 @@ const Wt = (t) => {
|
|
|
984
989
|
"displayName"
|
|
985
990
|
),
|
|
986
991
|
...d === void 0 ? {} : { vertical: d },
|
|
987
|
-
...
|
|
992
|
+
...c === void 0 ? {} : { purpose: c },
|
|
988
993
|
pageSetType: a
|
|
989
994
|
};
|
|
990
995
|
} else if (a === "DIRECTORY" || a === "LOCATOR")
|
|
@@ -1016,11 +1021,11 @@ const Wt = (t) => {
|
|
|
1016
1021
|
["Component", e]
|
|
1017
1022
|
])
|
|
1018
1023
|
for (const s of a) {
|
|
1019
|
-
const d = i === "Section" && "sourcePath" in s ?
|
|
1024
|
+
const d = i === "Section" && "sourcePath" in s ? l.join(
|
|
1020
1025
|
n,
|
|
1021
1026
|
"sections",
|
|
1022
|
-
s.sourcePath.split(
|
|
1023
|
-
) :
|
|
1027
|
+
s.sourcePath.split(l.sep).at(-1) ?? ""
|
|
1028
|
+
) : l.join(n, "shared", "componentRegistry.ts");
|
|
1024
1029
|
b.test(s.id) || o(
|
|
1025
1030
|
d,
|
|
1026
1031
|
"components/id",
|
|
@@ -1105,7 +1110,7 @@ const Wt = (t) => {
|
|
|
1105
1110
|
);
|
|
1106
1111
|
return r;
|
|
1107
1112
|
}
|
|
1108
|
-
}, C = (t) => t instanceof Error ? t.message : String(t), pe = (t, e) => t.split(`${e}${
|
|
1113
|
+
}, C = (t) => t instanceof Error ? t.message : String(t), pe = (t, e) => t.split(`${e}${l.sep}`).join(""), nt = ["api", "structure", "code"], ye = (t) => [...t].sort((e, n) => nt.indexOf(e.category) - nt.indexOf(n.category) || ot(e.filePath, n.filePath) || (e.line ?? 0) - (n.line ?? 0) || (e.column ?? 0) - (n.column ?? 0) || ot(e.rule, n.rule)), ot = (t, e) => t === e ? 0 : t < e ? -1 : 1, me = (t) => {
|
|
1109
1114
|
const e = t.line ? `:${t.line}${t.column ? `:${t.column}` : ""}` : "";
|
|
1110
1115
|
return `${t.filePath}${e}: ${t.message}`;
|
|
1111
1116
|
};
|
|
@@ -1150,7 +1155,7 @@ const fe = [
|
|
|
1150
1155
|
throw new Error(
|
|
1151
1156
|
"Section Library builds require SECTION_LIBRARY_REVISION_ID"
|
|
1152
1157
|
);
|
|
1153
|
-
if (!f.existsSync(
|
|
1158
|
+
if (!f.existsSync(l.join(t, "src", "library", "library.json")))
|
|
1154
1159
|
return { generatedFiles: [], layouts: [] };
|
|
1155
1160
|
const n = Mt(t), o = Zt(t), r = ye([
|
|
1156
1161
|
...n.issues,
|
|
@@ -1166,11 +1171,11 @@ const fe = [
|
|
|
1166
1171
|
throw new Error(
|
|
1167
1172
|
"Section Library metadata and structure validation did not run."
|
|
1168
1173
|
);
|
|
1169
|
-
const a = n.metadata, s = o.structure, d = Ce(t),
|
|
1174
|
+
const a = n.metadata, s = o.structure, d = Ce(t), c = l.join(t, "src", "library", ".generated"), p = Te(
|
|
1170
1175
|
t,
|
|
1171
|
-
|
|
1176
|
+
c,
|
|
1172
1177
|
s.translationResources
|
|
1173
|
-
), m =
|
|
1178
|
+
), m = l.join(c, "i18n.ts"), g = [...p.generatedFiles];
|
|
1174
1179
|
return A(
|
|
1175
1180
|
m,
|
|
1176
1181
|
Ee(
|
|
@@ -1179,8 +1184,8 @@ const fe = [
|
|
|
1179
1184
|
)
|
|
1180
1185
|
) && g.push(m), g.push(
|
|
1181
1186
|
...s.layouts.flatMap((y) => {
|
|
1182
|
-
const u =
|
|
1183
|
-
|
|
1187
|
+
const u = l.join(
|
|
1188
|
+
c,
|
|
1184
1189
|
`libraryConfig-${y.metadata.id}.tsx`
|
|
1185
1190
|
);
|
|
1186
1191
|
return A(
|
|
@@ -1196,7 +1201,7 @@ const fe = [
|
|
|
1196
1201
|
})
|
|
1197
1202
|
), g.push(
|
|
1198
1203
|
...s.layouts.flatMap((y) => {
|
|
1199
|
-
const u =
|
|
1204
|
+
const u = l.join(
|
|
1200
1205
|
t,
|
|
1201
1206
|
"src",
|
|
1202
1207
|
"templates",
|
|
@@ -1209,7 +1214,7 @@ const fe = [
|
|
|
1209
1214
|
})
|
|
1210
1215
|
), g.push(
|
|
1211
1216
|
...s.layouts.flatMap((y) => {
|
|
1212
|
-
const u =
|
|
1217
|
+
const u = l.join(
|
|
1213
1218
|
t,
|
|
1214
1219
|
"src",
|
|
1215
1220
|
"templates",
|
|
@@ -1246,7 +1251,7 @@ const fe = [
|
|
|
1246
1251
|
};
|
|
1247
1252
|
}, Ee = (t, e) => {
|
|
1248
1253
|
const n = (o) => Object.entries(o).sort(([r], [i]) => r.localeCompare(i)).map(([r, i]) => {
|
|
1249
|
-
const a =
|
|
1254
|
+
const a = l.relative(l.dirname(t), i).split(l.sep).join("/"), s = a.startsWith(".") ? a : `./${a}`;
|
|
1250
1255
|
return ` ${JSON.stringify(r)}: () => import(${JSON.stringify(s)}).then(({ default: translations }) => translations),`;
|
|
1251
1256
|
}).join(`
|
|
1252
1257
|
`);
|
|
@@ -1280,9 +1285,9 @@ const fe = [
|
|
|
1280
1285
|
throw new Error(
|
|
1281
1286
|
`Could not find built-in ${a} translations for ${i}.`
|
|
1282
1287
|
);
|
|
1283
|
-
const
|
|
1284
|
-
f.readFileSync(
|
|
1285
|
-
) : void 0, m = p ? k(d, p) : d, g =
|
|
1288
|
+
const c = n[a][i], p = c ? JSON.parse(
|
|
1289
|
+
f.readFileSync(l.join(t, c), "utf8")
|
|
1290
|
+
) : void 0, m = p ? k(d, p) : d, g = l.join(
|
|
1286
1291
|
e,
|
|
1287
1292
|
"i18n",
|
|
1288
1293
|
s,
|
|
@@ -1310,9 +1315,9 @@ const fe = [
|
|
|
1310
1315
|
const e = /* @__PURE__ */ new Set();
|
|
1311
1316
|
for (const n of t) {
|
|
1312
1317
|
f.removeSync(n);
|
|
1313
|
-
let o =
|
|
1314
|
-
for (e.add(o); o.includes(`${
|
|
1315
|
-
o =
|
|
1318
|
+
let o = l.dirname(n);
|
|
1319
|
+
for (e.add(o); o.includes(`${l.sep}.generated${l.sep}`) && l.basename(o) !== ".generated"; )
|
|
1320
|
+
o = l.dirname(o), e.add(o);
|
|
1316
1321
|
n.endsWith(".tsx") && f.removeSync(n.replace(/\.tsx$/, ".client.tsx"));
|
|
1317
1322
|
}
|
|
1318
1323
|
for (const n of [...e].sort(
|
|
@@ -1320,7 +1325,7 @@ const fe = [
|
|
|
1320
1325
|
))
|
|
1321
1326
|
f.existsSync(n) && f.readdirSync(n).length === 0 && f.removeSync(n);
|
|
1322
1327
|
}, _e = (t, e) => {
|
|
1323
|
-
const n =
|
|
1328
|
+
const n = l.join(t, ".template-manifest.json"), o = JSON.stringify(
|
|
1324
1329
|
{
|
|
1325
1330
|
templates: e.map((r) => ({
|
|
1326
1331
|
name: r.metadata.id,
|
|
@@ -1335,21 +1340,21 @@ const fe = [
|
|
|
1335
1340
|
);
|
|
1336
1341
|
(!f.existsSync(n) || f.readFileSync(n, "utf8") !== o) && f.writeFileSync(n, o);
|
|
1337
1342
|
}, Ie = (t, e, n, o, r) => {
|
|
1338
|
-
const i = e.metadata.id, a =
|
|
1343
|
+
const i = e.metadata.id, a = l.join(
|
|
1339
1344
|
t,
|
|
1340
1345
|
"src",
|
|
1341
1346
|
"library",
|
|
1342
1347
|
".generated",
|
|
1343
1348
|
`libraryConfig-${i}.tsx`
|
|
1344
1349
|
), s = n.filter((g) => g.pageSetTypes.includes(e.metadata.pageSetType)), d = s.map((g, y) => {
|
|
1345
|
-
const u =
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
).replace(/\.(tsx|jsx)$/, "").split(
|
|
1350
|
+
const u = l.relative(
|
|
1351
|
+
l.dirname(a),
|
|
1352
|
+
l.join(t, g.sourcePath)
|
|
1353
|
+
).replace(/\.(tsx|jsx)$/, "").split(l.sep).join("/"), E = u.startsWith(".") ? u : `./${u}`;
|
|
1349
1354
|
return `import { ${g.componentName} as Section${y}, config as sectionConfig${y} } from ${JSON.stringify(E)};`;
|
|
1350
|
-
}),
|
|
1355
|
+
}), c = s.map((g, y) => ` { id: ${JSON.stringify(g.id)}, component: Section${y}, config: sectionConfig${y} },`), p = Le(s), m = o.some((g) => g.pageSetTypes.includes(e.metadata.pageSetType)) || r.includes(e.metadata.pageSetType);
|
|
1351
1356
|
return xt.replace("/* SECTION_LIBRARY_GENERATED_FILE */", O).replace("/* SECTION_LIBRARY_IMPORTS */", d.join(`
|
|
1352
|
-
`)).replace("/* SECTION_LIBRARY_ENTRIES */",
|
|
1357
|
+
`)).replace("/* SECTION_LIBRARY_ENTRIES */", c.join(`
|
|
1353
1358
|
`)).replace("/* SECTION_LIBRARY_CATEGORIES */", p).replace(
|
|
1354
1359
|
"/* SECTION_LIBRARY_SHARED_COMPONENT_REGISTRY */",
|
|
1355
1360
|
m ? 'import { sharedComponentConfigs, sharedComponentMetadata, sharedRootAllowedComponentIds, sharedRootConfigs } from "../shared/componentRegistry";' : `const sharedComponentMetadata: { id: string; pageSetTypes: string[] }[] = [];
|
|
@@ -1399,7 +1404,7 @@ const sharedRootConfigs: Partial<Record<string, NonNullable<Config["root"]>>> =
|
|
|
1399
1404
|
o
|
|
1400
1405
|
).replace("/* SECTION_LIBRARY_COMPONENT_REGISTRY */", r).replace('"__SECTION_LIBRARY_EDITOR_PATH__"', JSON.stringify(e)).replace('"__SECTION_LIBRARY_EDITOR_NAME__"', JSON.stringify(n));
|
|
1401
1406
|
}, Ce = (t) => {
|
|
1402
|
-
const e =
|
|
1407
|
+
const e = l.join(
|
|
1403
1408
|
t,
|
|
1404
1409
|
"src",
|
|
1405
1410
|
"library",
|
|
@@ -1409,7 +1414,7 @@ const sharedRootConfigs: Partial<Record<string, NonNullable<Config["root"]>>> =
|
|
|
1409
1414
|
return f.existsSync(e) ? `import { migrationRegistry as repoMigrationRegistry } from "../library/migrations/registry";
|
|
1410
1415
|
const sectionLibraryMigrationRegistry: MigrationRegistry = repoMigrationRegistry;` : "const sectionLibraryMigrationRegistry: MigrationRegistry = [];";
|
|
1411
1416
|
}, A = (t, e) => {
|
|
1412
|
-
if (f.ensureDirSync(
|
|
1417
|
+
if (f.ensureDirSync(l.dirname(t)), f.existsSync(t)) {
|
|
1413
1418
|
const n = f.readFileSync(t, "utf8");
|
|
1414
1419
|
if (!n.startsWith(O))
|
|
1415
1420
|
return !1;
|
|
@@ -1594,7 +1599,7 @@ export default LocalEditorData;
|
|
|
1594
1599
|
return JSON.parse(f.readFileSync(t, "utf8"));
|
|
1595
1600
|
} catch (n) {
|
|
1596
1601
|
throw new Error(
|
|
1597
|
-
`Failed to parse ${e} at ${
|
|
1602
|
+
`Failed to parse ${e} at ${l.relative(process.cwd(), t)}: ${j(n)}`
|
|
1598
1603
|
);
|
|
1599
1604
|
}
|
|
1600
1605
|
}, j = (t) => t instanceof Error ? t.message : String(t), be = (t, e) => {
|
|
@@ -1604,7 +1609,7 @@ export default LocalEditorData;
|
|
|
1604
1609
|
localEditorDataTemplateSource: e
|
|
1605
1610
|
}) => ({
|
|
1606
1611
|
cleanupGeneratedLocalEditorArtifacts: (i = process.cwd()) => {
|
|
1607
|
-
const a =
|
|
1612
|
+
const a = l.join(
|
|
1608
1613
|
i,
|
|
1609
1614
|
"src",
|
|
1610
1615
|
"templates",
|
|
@@ -1614,37 +1619,37 @@ export default LocalEditorData;
|
|
|
1614
1619
|
},
|
|
1615
1620
|
syncLocalEditorDataTemplates: (i, a = process.cwd()) => {
|
|
1616
1621
|
const s = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map();
|
|
1617
|
-
for (const
|
|
1618
|
-
if (
|
|
1622
|
+
for (const c of i) {
|
|
1623
|
+
if (c.metadata.pageSetType !== "ENTITY" && c.metadata.pageSetType !== "DIRECTORY")
|
|
1619
1624
|
continue;
|
|
1620
|
-
const p =
|
|
1625
|
+
const p = l.join(
|
|
1621
1626
|
a,
|
|
1622
|
-
Gt(
|
|
1627
|
+
Gt(c.metadata.id)
|
|
1623
1628
|
), m = d.get(p);
|
|
1624
1629
|
m ? console.warn(
|
|
1625
|
-
`Local Editor layouts "${m}" and "${
|
|
1626
|
-
) : d.set(p,
|
|
1627
|
-
const g =
|
|
1628
|
-
|
|
1630
|
+
`Local Editor layouts "${m}" and "${c.metadata.id}" generate the same data template at ${l.relative(a, p)}. The later layout will overwrite the earlier layout's template.`
|
|
1631
|
+
) : d.set(p, c.metadata.id);
|
|
1632
|
+
const g = l.relative(
|
|
1633
|
+
l.dirname(p),
|
|
1629
1634
|
K(
|
|
1630
1635
|
a,
|
|
1631
1636
|
D
|
|
1632
1637
|
)
|
|
1633
|
-
).split(
|
|
1638
|
+
).split(l.sep).join("/");
|
|
1634
1639
|
rt(
|
|
1635
1640
|
p,
|
|
1636
1641
|
Vt(
|
|
1637
1642
|
e,
|
|
1638
1643
|
g.startsWith(".") ? g : `./${g}`,
|
|
1639
|
-
|
|
1640
|
-
|
|
1644
|
+
c.metadata.id,
|
|
1645
|
+
c.metadata.pageSetType
|
|
1641
1646
|
)
|
|
1642
1647
|
), s.add(p);
|
|
1643
1648
|
}
|
|
1644
1649
|
at(a, s);
|
|
1645
1650
|
},
|
|
1646
1651
|
syncLocalEditorTemplate: (i, a = process.cwd()) => {
|
|
1647
|
-
const s =
|
|
1652
|
+
const s = l.join(
|
|
1648
1653
|
a,
|
|
1649
1654
|
"src",
|
|
1650
1655
|
"templates",
|
|
@@ -1660,42 +1665,42 @@ export default LocalEditorData;
|
|
|
1660
1665
|
Pe(a)
|
|
1661
1666
|
).replace(
|
|
1662
1667
|
"/* LOCAL_EDITOR_CONFIG_IMPORTS */",
|
|
1663
|
-
i.map((d,
|
|
1668
|
+
i.map((d, c) => `import { sectionLibraryConfig as LayoutConfig${c} } from ${JSON.stringify(`../library/.generated/libraryConfig-${d.metadata.id}`)};`).join(`
|
|
1664
1669
|
`)
|
|
1665
1670
|
).replace(
|
|
1666
1671
|
"/* LOCAL_EDITOR_COMPONENT_REGISTRY */",
|
|
1667
|
-
i.map((d,
|
|
1672
|
+
i.map((d, c) => ` ${JSON.stringify(d.metadata.id)}: LayoutConfig${c},`).join(`
|
|
1668
1673
|
`)
|
|
1669
1674
|
)
|
|
1670
1675
|
);
|
|
1671
1676
|
}
|
|
1672
1677
|
}), Pe = (t) => f.existsSync(
|
|
1673
|
-
|
|
1678
|
+
l.join(t, "src", "library", "migrations", "registry.ts")
|
|
1674
1679
|
) ? `import { migrationRegistry as repoMigrationRegistry } from "../library/migrations/registry";
|
|
1675
1680
|
const sectionLibraryMigrationRegistry: MigrationRegistry = repoMigrationRegistry;` : "const sectionLibraryMigrationRegistry: MigrationRegistry = [];", rt = (t, e) => {
|
|
1676
|
-
if (f.ensureDirSync(
|
|
1681
|
+
if (f.ensureDirSync(l.dirname(t)), f.existsSync(t) && !v(t))
|
|
1677
1682
|
throw new Error(
|
|
1678
1683
|
`Refusing to overwrite hand-authored local editor template at ${t}`
|
|
1679
1684
|
);
|
|
1680
1685
|
be(t, e);
|
|
1681
1686
|
}, at = (t, e) => {
|
|
1682
|
-
const n =
|
|
1687
|
+
const n = l.join(t, "src", "templates");
|
|
1683
1688
|
if (!f.existsSync(n))
|
|
1684
1689
|
return;
|
|
1685
1690
|
for (const r of f.readdirSync(n, {
|
|
1686
1691
|
withFileTypes: !0
|
|
1687
1692
|
})) {
|
|
1688
|
-
const i =
|
|
1689
|
-
!r.isFile() || !r.name.startsWith(mt) ||
|
|
1693
|
+
const i = l.join(n, r.name);
|
|
1694
|
+
!r.isFile() || !r.name.startsWith(mt) || l.extname(r.name) !== ".tsx" || e?.has(i) || !v(i) || f.removeSync(i);
|
|
1690
1695
|
}
|
|
1691
|
-
const o =
|
|
1696
|
+
const o = l.join(
|
|
1692
1697
|
t,
|
|
1693
1698
|
Ft
|
|
1694
1699
|
);
|
|
1695
1700
|
!e?.has(o) && v(o) && f.removeSync(o);
|
|
1696
1701
|
}, xe = (t) => {
|
|
1697
|
-
const e =
|
|
1698
|
-
return f.existsSync(e) ? f.readdirSync(e, { withFileTypes: !0 }).filter((n) => n.isFile() &&
|
|
1702
|
+
const e = l.join(t, "public", "y-fonts");
|
|
1703
|
+
return f.existsSync(e) ? f.readdirSync(e, { withFileTypes: !0 }).filter((n) => n.isFile() && l.extname(n.name) === ".css").map((n) => `/y-fonts/${n.name}`).sort((n, o) => n.localeCompare(o)) : [];
|
|
1699
1704
|
};
|
|
1700
1705
|
let B;
|
|
1701
1706
|
const Tt = async (t, e, n) => {
|
|
@@ -1705,7 +1710,7 @@ const Tt = async (t, e, n) => {
|
|
|
1705
1710
|
);
|
|
1706
1711
|
if (!f.existsSync(o))
|
|
1707
1712
|
return n.push(
|
|
1708
|
-
`Missing local editor config at ${
|
|
1713
|
+
`Missing local editor config at ${l.relative(process.cwd(), o)}.`
|
|
1709
1714
|
), G(e, {});
|
|
1710
1715
|
try {
|
|
1711
1716
|
return G(
|
|
@@ -1716,9 +1721,9 @@ const Tt = async (t, e, n) => {
|
|
|
1716
1721
|
return n.push(j(r)), G(e, {});
|
|
1717
1722
|
}
|
|
1718
1723
|
}, we = async (t) => {
|
|
1719
|
-
if (
|
|
1724
|
+
if (l.extname(t) === ".json")
|
|
1720
1725
|
throw new Error(
|
|
1721
|
-
`Unsupported local editor config at ${
|
|
1726
|
+
`Unsupported local editor config at ${l.relative(process.cwd(), t)}: use ${D}.`
|
|
1722
1727
|
);
|
|
1723
1728
|
if (B?.filePath === t)
|
|
1724
1729
|
return B.config;
|
|
@@ -1732,7 +1737,7 @@ const Tt = async (t, e, n) => {
|
|
|
1732
1737
|
n = n.default;
|
|
1733
1738
|
if (!n || typeof n != "object")
|
|
1734
1739
|
throw new Error(
|
|
1735
|
-
`Failed to parse local editor stream config at ${
|
|
1740
|
+
`Failed to parse local editor stream config at ${l.relative(process.cwd(), t)}: expected a default-exported object.`
|
|
1736
1741
|
);
|
|
1737
1742
|
const o = n;
|
|
1738
1743
|
return B = {
|
|
@@ -1741,18 +1746,18 @@ const Tt = async (t, e, n) => {
|
|
|
1741
1746
|
}, o;
|
|
1742
1747
|
}, G = (t, e) => {
|
|
1743
1748
|
const n = t.flatMap((o) => {
|
|
1744
|
-
const r = o.metadata.id, i = o.metadata.pageSetType, a = e.pageSetTypes?.[i], s = e.layouts?.[r], d = s?.stream ?? a?.stream,
|
|
1745
|
-
return
|
|
1749
|
+
const r = o.metadata.id, i = o.metadata.pageSetType, a = e.pageSetTypes?.[i], s = e.layouts?.[r], d = s?.stream ?? a?.stream, c = i === "ENTITY" || i === "DIRECTORY" && d ? "stream" : "fixture";
|
|
1750
|
+
return c === "stream" && !d ? [] : [
|
|
1746
1751
|
{
|
|
1747
1752
|
layoutId: r,
|
|
1748
1753
|
dataTemplateName: Y(r),
|
|
1749
1754
|
pageSetType: i,
|
|
1750
|
-
dataSource:
|
|
1755
|
+
dataSource: c,
|
|
1751
1756
|
defaults: {
|
|
1752
1757
|
entityId: s?.defaults?.entityId ?? a?.defaults?.entityId,
|
|
1753
1758
|
locale: s?.defaults?.locale ?? a?.defaults?.locale ?? e.defaults?.locale
|
|
1754
1759
|
},
|
|
1755
|
-
stream:
|
|
1760
|
+
stream: c === "stream" ? d : void 0,
|
|
1756
1761
|
defaultLayoutData: o.defaultLayout
|
|
1757
1762
|
}
|
|
1758
1763
|
];
|
|
@@ -1990,7 +1995,7 @@ const Tt = async (t, e, n) => {
|
|
|
1990
1995
|
a(o, "dm_addressRegionDisplayName"),
|
|
1991
1996
|
[h("Locations Directory", "index.html")],
|
|
1992
1997
|
{ dm_addressCountryDisplayName: "United States" }
|
|
1993
|
-
),
|
|
1998
|
+
), c = w(
|
|
1994
1999
|
String(o.id),
|
|
1995
2000
|
"VA",
|
|
1996
2001
|
"us/va",
|
|
@@ -2020,7 +2025,7 @@ const Tt = async (t, e, n) => {
|
|
|
2020
2025
|
dm_addressRegionDisplayName: "Virginia"
|
|
2021
2026
|
}
|
|
2022
2027
|
);
|
|
2023
|
-
return [s, d,
|
|
2028
|
+
return [s, d, c, p].map(
|
|
2024
2029
|
(m) => ({ layoutId: t, document: m })
|
|
2025
2030
|
);
|
|
2026
2031
|
}, Ue = (t) => ({
|
|
@@ -2072,7 +2077,7 @@ const Tt = async (t, e, n) => {
|
|
|
2072
2077
|
t,
|
|
2073
2078
|
e,
|
|
2074
2079
|
i
|
|
2075
|
-
), s = n ?? a.defaults.layoutId ?? a.layouts[0], d = s ? a.entitiesByLayout[s] ?? [] : [],
|
|
2080
|
+
), s = n ?? a.defaults.layoutId ?? a.layouts[0], d = s ? a.entitiesByLayout[s] ?? [] : [], c = s ? a.layoutDefaults[s] : void 0, p = o ?? c?.entityId ?? a.defaults.entityId ?? d[0]?.entityId, m = d.find((S) => S.entityId === p), g = r ?? c?.locale ?? a.defaults.locale ?? m?.locales[0], y = a.documents.find((S) => S.layoutId === s && S.entityId === p && S.locale === g);
|
|
2076
2081
|
if (!y)
|
|
2077
2082
|
return {
|
|
2078
2083
|
document: null,
|
|
@@ -2161,7 +2166,7 @@ const Tt = async (t, e, n) => {
|
|
|
2161
2166
|
return t;
|
|
2162
2167
|
}
|
|
2163
2168
|
}, Ct = async (t, e, n = 4) => {
|
|
2164
|
-
const o = [], r =
|
|
2169
|
+
const o = [], r = l.join(t, "localData");
|
|
2165
2170
|
e.length === 0 && o.push("Missing src/library/library.json.");
|
|
2166
2171
|
const i = await Tt(
|
|
2167
2172
|
t,
|
|
@@ -2172,7 +2177,7 @@ const Tt = async (t, e, n) => {
|
|
|
2172
2177
|
a,
|
|
2173
2178
|
o,
|
|
2174
2179
|
n
|
|
2175
|
-
),
|
|
2180
|
+
), c = qe(s, d), p = Object.fromEntries(
|
|
2176
2181
|
a.map((y) => [
|
|
2177
2182
|
y.layoutId,
|
|
2178
2183
|
{
|
|
@@ -2203,7 +2208,7 @@ const Tt = async (t, e, n) => {
|
|
|
2203
2208
|
dataSourceByLayout: Object.fromEntries(
|
|
2204
2209
|
a.map((y) => [y.layoutId, y.dataSource])
|
|
2205
2210
|
),
|
|
2206
|
-
entitiesByLayout:
|
|
2211
|
+
entitiesByLayout: c,
|
|
2207
2212
|
documents: d
|
|
2208
2213
|
};
|
|
2209
2214
|
}, Ot = (t) => {
|
|
@@ -2213,24 +2218,24 @@ const Tt = async (t, e, n) => {
|
|
|
2213
2218
|
const r = He(
|
|
2214
2219
|
e,
|
|
2215
2220
|
o
|
|
2216
|
-
).map(({ layoutId:
|
|
2217
|
-
layoutId:
|
|
2221
|
+
).map(({ layoutId: c, document: p }) => ({
|
|
2222
|
+
layoutId: c,
|
|
2218
2223
|
entityId: H(p, "fixture.json"),
|
|
2219
2224
|
displayName: typeof p.name == "string" && p.name.length > 0 ? p.name : H(p, "fixture.json"),
|
|
2220
2225
|
locale: dt(p, "fixture.json"),
|
|
2221
2226
|
fileName: "built-in fixture",
|
|
2222
2227
|
document: p
|
|
2223
|
-
})), i = e.filter((
|
|
2228
|
+
})), i = e.filter((c) => c.dataSource === "stream");
|
|
2224
2229
|
if (i.length === 0)
|
|
2225
2230
|
return r;
|
|
2226
2231
|
if (!f.existsSync(t))
|
|
2227
2232
|
return n.push(
|
|
2228
|
-
`Missing localData snapshots at ${
|
|
2233
|
+
`Missing localData snapshots at ${l.relative(process.cwd(), t)}. Run your existing Pages local data generation flow first.`
|
|
2229
2234
|
), r;
|
|
2230
|
-
const a =
|
|
2235
|
+
const a = l.join(t, "mapping.json");
|
|
2231
2236
|
if (!f.existsSync(a))
|
|
2232
2237
|
return n.push(
|
|
2233
|
-
`Missing local editor snapshot mapping at ${
|
|
2238
|
+
`Missing local editor snapshot mapping at ${l.relative(process.cwd(), a)}. Run yext pages generate-test-data to populate local editor snapshots.`
|
|
2234
2239
|
), r;
|
|
2235
2240
|
let s;
|
|
2236
2241
|
try {
|
|
@@ -2238,25 +2243,25 @@ const Tt = async (t, e, n) => {
|
|
|
2238
2243
|
a,
|
|
2239
2244
|
"local data mapping"
|
|
2240
2245
|
);
|
|
2241
|
-
} catch (
|
|
2242
|
-
return n.push(j(
|
|
2246
|
+
} catch (c) {
|
|
2247
|
+
return n.push(j(c)), r;
|
|
2243
2248
|
}
|
|
2244
2249
|
const d = [...r];
|
|
2245
|
-
for (const
|
|
2250
|
+
for (const c of i) {
|
|
2246
2251
|
const p = new Set(
|
|
2247
|
-
s[
|
|
2252
|
+
s[c.dataTemplateName] ?? []
|
|
2248
2253
|
);
|
|
2249
2254
|
if (p.size === 0) {
|
|
2250
2255
|
n.push(
|
|
2251
|
-
`Missing local editor snapshot mapping for layout "${
|
|
2256
|
+
`Missing local editor snapshot mapping for layout "${c.layoutId}" in ${l.relative(process.cwd(), a)}. Expected generated mapping key "${c.dataTemplateName}". Run yext pages generate-test-data after enabling localEditor.`
|
|
2252
2257
|
);
|
|
2253
2258
|
continue;
|
|
2254
2259
|
}
|
|
2255
2260
|
Array.from(p).sort((m, g) => m.localeCompare(g)).forEach((m) => {
|
|
2256
|
-
const g =
|
|
2261
|
+
const g = l.join(t, m);
|
|
2257
2262
|
if (!f.existsSync(g)) {
|
|
2258
2263
|
n.push(
|
|
2259
|
-
`Snapshot file ${
|
|
2264
|
+
`Snapshot file ${l.join("localData", m)} is referenced but missing.`
|
|
2260
2265
|
);
|
|
2261
2266
|
return;
|
|
2262
2267
|
}
|
|
@@ -2266,7 +2271,7 @@ const Tt = async (t, e, n) => {
|
|
|
2266
2271
|
`local editor snapshot ${m}`
|
|
2267
2272
|
), u = dt(y, m), E = H(y, m);
|
|
2268
2273
|
d.push({
|
|
2269
|
-
layoutId:
|
|
2274
|
+
layoutId: c.layoutId,
|
|
2270
2275
|
entityId: E,
|
|
2271
2276
|
displayName: typeof y.name == "string" && y.name.length > 0 ? y.name : E,
|
|
2272
2277
|
locale: u,
|
|
@@ -2344,7 +2349,7 @@ const Tt = async (t, e, n) => {
|
|
|
2344
2349
|
process.env.SECTION_LIBRARY_REVISION_ID
|
|
2345
2350
|
);
|
|
2346
2351
|
o = g.generatedFiles, r = g.manifestSource, i = g.layouts, a = g.manifestSource !== void 0;
|
|
2347
|
-
},
|
|
2352
|
+
}, c = async () => {
|
|
2348
2353
|
Ht(process.cwd()), await Tt(process.cwd(), i, []), s.syncLocalEditorDataTemplates(i), s.syncLocalEditorTemplate(i);
|
|
2349
2354
|
}, p = () => {
|
|
2350
2355
|
Se(o), o = [];
|
|
@@ -2358,10 +2363,10 @@ const Tt = async (t, e, n) => {
|
|
|
2358
2363
|
})), {
|
|
2359
2364
|
name: "vite-plugin-yext-visual-editor",
|
|
2360
2365
|
async config(g, { command: y }) {
|
|
2361
|
-
e = y === "build", y === "serve" && t.localEditor?.enabled && (d(), a ? await
|
|
2366
|
+
e = y === "build", y === "serve" && t.localEditor?.enabled && (d(), a ? await c() : s.cleanupGeneratedLocalEditorArtifacts(), n = !0);
|
|
2362
2367
|
},
|
|
2363
2368
|
async buildStart() {
|
|
2364
|
-
n || d(), !e && t.localEditor?.enabled && !n && a ? await
|
|
2369
|
+
n || d(), !e && t.localEditor?.enabled && !n && a ? await c() : n || s.cleanupGeneratedLocalEditorArtifacts();
|
|
2365
2370
|
},
|
|
2366
2371
|
generateBundle() {
|
|
2367
2372
|
r && this.emitFile({
|