@drawnagency/primitives 0.1.97 → 0.1.98

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 (44) hide show
  1. package/dist/{chunk-F2337B35.js → chunk-26ALJO4K.js} +1 -1
  2. package/dist/{chunk-S4L3ZFKM.js → chunk-3COSXTOY.js} +1 -1
  3. package/dist/{chunk-RHWWQV3J.js → chunk-BGHWUJFV.js} +1 -0
  4. package/dist/{chunk-YDXBJR74.js → chunk-EWNDBKYK.js} +1 -1
  5. package/dist/{chunk-XYCCXKVC.js → chunk-FOY5TF7D.js} +1 -1
  6. package/dist/{chunk-II3X7GLJ.js → chunk-GYCBWGVW.js} +1 -1
  7. package/dist/{chunk-FOEZNEF5.js → chunk-HKHEAH5F.js} +6 -6
  8. package/dist/{chunk-5BFPJWIO.js → chunk-KP4DWTPR.js} +3 -3
  9. package/dist/{chunk-KPP2CFW6.js → chunk-MUTHF2GT.js} +2 -2
  10. package/dist/{chunk-QEHPGA5N.js → chunk-NA5EJM6Z.js} +1 -1
  11. package/dist/chunk-TGNS7D4F.js +200 -0
  12. package/dist/collab/rebase.js +1 -1
  13. package/dist/components/editor/index.js +5 -5
  14. package/dist/components/primitives/index.js +6 -6
  15. package/dist/components/sections/brand-guide.js +6 -6
  16. package/dist/components/sections/register-schemas.js +9 -9
  17. package/dist/components/sections/register.js +9 -9
  18. package/dist/components/shell/EditorShell.d.ts.map +1 -1
  19. package/dist/hooks/useEditorPersistence.d.ts +7 -0
  20. package/dist/hooks/useEditorPersistence.d.ts.map +1 -1
  21. package/dist/index.js +12 -10
  22. package/dist/lib/dexie.d.ts.map +1 -1
  23. package/dist/lib/dexie.js +6 -1
  24. package/dist/lib/index-ops.d.ts +138 -2
  25. package/dist/lib/index-ops.d.ts.map +1 -1
  26. package/dist/lib/index-ops.js +176 -8
  27. package/dist/lib/index.js +4 -4
  28. package/dist/media/index.js +3 -3
  29. package/dist/media/provider.d.ts +0 -1
  30. package/dist/media/provider.d.ts.map +1 -1
  31. package/dist/schemas/index.js +4 -2
  32. package/dist/schemas/site-config.d.ts +1 -0
  33. package/dist/schemas/site-config.d.ts.map +1 -1
  34. package/dist/types/database.d.ts +0 -3
  35. package/dist/types/database.d.ts.map +1 -1
  36. package/package.json +1 -1
  37. package/src/components/shell/EditorShell.tsx +27 -8
  38. package/src/hooks/useEditorPersistence.ts +14 -0
  39. package/src/lib/dexie.ts +6 -1
  40. package/src/lib/index-ops.ts +261 -7
  41. package/src/media/provider.ts +0 -1
  42. package/src/schemas/site-config.ts +3 -1
  43. package/src/types/database.ts +0 -3
  44. package/dist/chunk-ZD6XGRQM.js +0 -85
@@ -1,85 +0,0 @@
1
- // src/lib/nav-tree.ts
2
- function reconcileNav(entries, pages) {
3
- const entryList = Array.isArray(entries) ? entries : [];
4
- const pageList = Array.isArray(pages) ? pages : [];
5
- const validIds = /* @__PURE__ */ new Set();
6
- for (const p of pageList) {
7
- if (p?.id) validIds.add(p.id);
8
- }
9
- const placed = /* @__PURE__ */ new Set();
10
- const seenGroupIds = /* @__PURE__ */ new Set();
11
- const result = [];
12
- for (const entry of entryList) {
13
- if (entry?.kind === "page") {
14
- if (!validIds.has(entry.pageId) || placed.has(entry.pageId)) continue;
15
- placed.add(entry.pageId);
16
- result.push({ ...entry });
17
- continue;
18
- }
19
- if (entry?.kind !== "group") continue;
20
- if (seenGroupIds.has(entry.id)) continue;
21
- seenGroupIds.add(entry.id);
22
- const claimed = Array.isArray(entry.pageIds) ? entry.pageIds : [];
23
- const pageIds = claimed.filter((id) => {
24
- if (!validIds.has(id) || placed.has(id)) return false;
25
- placed.add(id);
26
- return true;
27
- });
28
- const group = { ...entry, pageIds };
29
- result.push(group);
30
- }
31
- for (const p of pageList) {
32
- if (!p?.id || placed.has(p.id)) continue;
33
- placed.add(p.id);
34
- result.push({ kind: "page", pageId: p.id });
35
- }
36
- return result;
37
- }
38
- function navEntries(index) {
39
- return reconcileNav(index.nav ?? [], index.pages);
40
- }
41
- function pagesInNavOrder(index) {
42
- const byId = new Map(index.pages.map((p) => [p.id, p]));
43
- const out = [];
44
- for (const entry of navEntries(index)) {
45
- if (entry.kind === "page") {
46
- const p = byId.get(entry.pageId);
47
- if (p) out.push(p);
48
- } else {
49
- for (const id of entry.pageIds) {
50
- const p = byId.get(id);
51
- if (p) out.push(p);
52
- }
53
- }
54
- }
55
- return out;
56
- }
57
- function groupOfPage(index, pageId) {
58
- for (const entry of navEntries(index)) {
59
- if (entry.kind === "group" && entry.pageIds.includes(pageId)) return entry;
60
- }
61
- return null;
62
- }
63
- function groupDisplayLabel(label) {
64
- return label || "Untitled group";
65
- }
66
-
67
- // src/lib/pages.ts
68
- function slugifyPageSlug(input) {
69
- return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
70
- }
71
- function audiencePasses(access, audience) {
72
- if (access.length === 0) return true;
73
- if (!audience) return true;
74
- return access.includes(audience);
75
- }
76
-
77
- export {
78
- reconcileNav,
79
- navEntries,
80
- pagesInNavOrder,
81
- groupOfPage,
82
- groupDisplayLabel,
83
- slugifyPageSlug,
84
- audiencePasses
85
- };