@drawnagency/primitives 0.1.59 → 0.1.61

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 (95) hide show
  1. package/dist/auth/capabilities.d.ts +16 -0
  2. package/dist/auth/capabilities.d.ts.map +1 -0
  3. package/dist/auth/index.d.ts +2 -0
  4. package/dist/auth/index.d.ts.map +1 -1
  5. package/dist/auth/index.js +3 -1
  6. package/dist/auth/types.d.ts +26 -22
  7. package/dist/auth/types.d.ts.map +1 -1
  8. package/dist/chunk-4OX3Z7SB.js +1421 -0
  9. package/dist/{chunk-RFZNNCAS.js → chunk-53DKVAB6.js} +1 -61
  10. package/dist/chunk-677NTHAZ.js +27 -0
  11. package/dist/chunk-7EOSDFS3.js +10 -0
  12. package/dist/{chunk-NTGSA3TI.js → chunk-AM5LZD6Q.js} +7 -30
  13. package/dist/{chunk-ICLXLWQ5.js → chunk-BT7STGDW.js} +31 -23
  14. package/dist/{chunk-L2JJFOXD.js → chunk-CBWK3KPV.js} +5 -1
  15. package/dist/{chunk-V7JN2DDU.js → chunk-ODCJQOVO.js} +1 -1
  16. package/dist/chunk-TZQPOR5A.js +24 -0
  17. package/dist/{chunk-XTK4BR27.js → chunk-UNWNT52N.js} +13 -0
  18. package/dist/chunk-UQ4OYRW7.js +670 -0
  19. package/dist/chunk-WDSVHKAH.js +54 -0
  20. package/dist/chunk-WLMJCNU7.js +70 -0
  21. package/dist/chunk-ZGFAYZWB.js +8 -0
  22. package/dist/components/editor/DropEdgeIndicator.d.ts +8 -0
  23. package/dist/components/editor/DropEdgeIndicator.d.ts.map +1 -0
  24. package/dist/components/editor/PagesModal.d.ts.map +1 -1
  25. package/dist/components/editor/SectionOrderingModal.d.ts.map +1 -1
  26. package/dist/components/editor/index.js +640 -0
  27. package/dist/components/primitives/defineHeadingSection.d.ts +28 -0
  28. package/dist/components/primitives/defineHeadingSection.d.ts.map +1 -0
  29. package/dist/components/primitives/index.d.ts +10 -0
  30. package/dist/components/primitives/index.d.ts.map +1 -0
  31. package/dist/components/primitives/index.js +166 -0
  32. package/dist/components/sections/Colors/index.d.ts.map +1 -1
  33. package/dist/components/sections/Container/index.d.ts.map +1 -1
  34. package/dist/components/sections/IconList/IconList.d.ts +1 -6
  35. package/dist/components/sections/IconList/IconList.d.ts.map +1 -1
  36. package/dist/components/sections/IconList/index.d.ts +11 -0
  37. package/dist/components/sections/IconList/index.d.ts.map +1 -1
  38. package/dist/components/sections/LinkHeading/index.d.ts.map +1 -1
  39. package/dist/components/sections/SubHeading/index.d.ts +0 -1
  40. package/dist/components/sections/SubHeading/index.d.ts.map +1 -1
  41. package/dist/components/sections/SubSubHeading/index.d.ts +0 -1
  42. package/dist/components/sections/SubSubHeading/index.d.ts.map +1 -1
  43. package/dist/components/sections/all-sections.d.ts +0 -2
  44. package/dist/components/sections/all-sections.d.ts.map +1 -1
  45. package/dist/components/sections/register-schemas.js +376 -2453
  46. package/dist/components/shell/BugReportFAB.d.ts.map +1 -1
  47. package/dist/hooks/useEditorPublish.d.ts.map +1 -1
  48. package/dist/hooks/useMediaPipeline.d.ts.map +1 -1
  49. package/dist/hooks/useSortableRow.d.ts +25 -0
  50. package/dist/hooks/useSortableRow.d.ts.map +1 -0
  51. package/dist/index.js +46 -37
  52. package/dist/lib/image-refs.d.ts +21 -0
  53. package/dist/lib/image-refs.d.ts.map +1 -0
  54. package/dist/lib/index.js +21 -14
  55. package/dist/lib/platform-broker.d.ts +14 -0
  56. package/dist/lib/platform-broker.d.ts.map +1 -0
  57. package/dist/lib/platform-broker.js +60 -0
  58. package/dist/lib/reorder.d.ts +12 -0
  59. package/dist/lib/reorder.d.ts.map +1 -0
  60. package/dist/lib/text.d.ts +2 -0
  61. package/dist/lib/text.d.ts.map +1 -1
  62. package/dist/media/index.js +3 -2
  63. package/dist/media/utils.d.ts.map +1 -1
  64. package/dist/schemas/index.js +17 -17
  65. package/dist/schemas/link.js +13 -0
  66. package/dist/types/database.d.ts +46 -0
  67. package/dist/types/database.d.ts.map +1 -1
  68. package/package.json +14 -2
  69. package/src/auth/capabilities.ts +26 -0
  70. package/src/auth/index.ts +3 -0
  71. package/src/auth/types.ts +36 -26
  72. package/src/components/editor/DropEdgeIndicator.tsx +13 -0
  73. package/src/components/editor/PagesModal.tsx +12 -80
  74. package/src/components/editor/SectionOrderingModal.tsx +8 -78
  75. package/src/components/primitives/defineHeadingSection.tsx +56 -0
  76. package/src/components/primitives/index.ts +11 -0
  77. package/src/components/sections/Colors/index.tsx +2 -4
  78. package/src/components/sections/Container/index.tsx +2 -4
  79. package/src/components/sections/IconList/IconList.tsx +1 -7
  80. package/src/components/sections/IconList/index.tsx +11 -5
  81. package/src/components/sections/LinkHeading/index.tsx +5 -20
  82. package/src/components/sections/SubHeading/index.tsx +6 -23
  83. package/src/components/sections/SubSubHeading/index.tsx +6 -23
  84. package/src/components/shell/BugReportFAB.tsx +13 -9
  85. package/src/hooks/useEditorPublish.ts +71 -49
  86. package/src/hooks/useMediaPipeline.ts +11 -34
  87. package/src/hooks/useSortableRow.ts +99 -0
  88. package/src/lib/image-refs.ts +53 -0
  89. package/src/lib/platform-broker.ts +72 -0
  90. package/src/lib/reorder.ts +20 -0
  91. package/src/lib/text.ts +5 -0
  92. package/src/media/utils.ts +6 -1
  93. package/src/types/database.ts +41 -0
  94. package/dist/chunk-DKOUFIP6.js +0 -35
  95. /package/dist/{chunk-ZU2MKPTG.js → chunk-3DCG4DNU.js} +0 -0
@@ -2,13 +2,6 @@ import {
2
2
  getSection
3
3
  } from "./chunk-VKAGMEKE.js";
4
4
 
5
- // src/lib/cn.ts
6
- import { clsx } from "clsx";
7
- import { twMerge } from "tailwind-merge";
8
- function cn(...inputs) {
9
- return twMerge(clsx(inputs));
10
- }
11
-
12
5
  // src/lib/nav.ts
13
6
  function toSectionId(text) {
14
7
  const slug = text.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/^-+|-+$/g, "");
@@ -99,62 +92,9 @@ async function ensureSanitizer() {
99
92
  if (!purifier && purifierPromise) await purifierPromise;
100
93
  }
101
94
 
102
- // src/lib/icons.ts
103
- import {
104
- Check,
105
- X,
106
- ArrowRight,
107
- Star,
108
- Info,
109
- AlertTriangle,
110
- Heart,
111
- Lightbulb,
112
- Flag,
113
- Shield,
114
- Zap,
115
- Eye,
116
- Lock,
117
- Globe,
118
- Users,
119
- Target,
120
- Bookmark,
121
- Clock,
122
- ThumbsUp,
123
- ThumbsDown
124
- } from "lucide-react";
125
- var curatedIcons = [
126
- { id: "check", label: "Check", icon: Check },
127
- { id: "x", label: "X", icon: X },
128
- { id: "arrow-right", label: "Arrow Right", icon: ArrowRight },
129
- { id: "star", label: "Star", icon: Star },
130
- { id: "info", label: "Info", icon: Info },
131
- { id: "alert-triangle", label: "Warning", icon: AlertTriangle },
132
- { id: "heart", label: "Heart", icon: Heart },
133
- { id: "lightbulb", label: "Lightbulb", icon: Lightbulb },
134
- { id: "flag", label: "Flag", icon: Flag },
135
- { id: "shield", label: "Shield", icon: Shield },
136
- { id: "zap", label: "Zap", icon: Zap },
137
- { id: "eye", label: "Eye", icon: Eye },
138
- { id: "lock", label: "Lock", icon: Lock },
139
- { id: "globe", label: "Globe", icon: Globe },
140
- { id: "users", label: "Users", icon: Users },
141
- { id: "target", label: "Target", icon: Target },
142
- { id: "bookmark", label: "Bookmark", icon: Bookmark },
143
- { id: "clock", label: "Clock", icon: Clock },
144
- { id: "thumbs-up", label: "Thumbs Up", icon: ThumbsUp },
145
- { id: "thumbs-down", label: "Thumbs Down", icon: ThumbsDown }
146
- ];
147
- var iconMap = new Map(curatedIcons.map((e) => [e.id, e]));
148
- function getIcon(id) {
149
- return iconMap.get(id);
150
- }
151
-
152
95
  export {
153
- cn,
154
96
  toSectionId,
155
97
  generateNavLinks,
156
98
  sanitizeHtml,
157
- ensureSanitizer,
158
- curatedIcons,
159
- getIcon
99
+ ensureSanitizer
160
100
  };
@@ -0,0 +1,27 @@
1
+ // src/lib/events.ts
2
+ function createEvent(name) {
3
+ return {
4
+ dispatch(detail) {
5
+ window.dispatchEvent(new CustomEvent(name, { detail }));
6
+ },
7
+ listen(callback) {
8
+ const handler = (e) => callback(e.detail);
9
+ window.addEventListener(name, handler);
10
+ return () => window.removeEventListener(name, handler);
11
+ }
12
+ };
13
+ }
14
+ var editModeEvent = createEvent("editmodechange");
15
+ var navChangeEvent = createEvent("sitenavchange");
16
+ var darkModeEvent = createEvent("sitedarkmode");
17
+ var siteNameChangeEvent = createEvent("sitenamechange");
18
+ var historySelectEvent = createEvent("history-select");
19
+ var siteNavChangeEvent = createEvent("sitenavchange-v2");
20
+ var pageSelectEvent = createEvent("pageselect");
21
+
22
+ export {
23
+ createEvent,
24
+ editModeEvent,
25
+ navChangeEvent,
26
+ darkModeEvent
27
+ };
@@ -0,0 +1,10 @@
1
+ // src/lib/cn.ts
2
+ import { clsx } from "clsx";
3
+ import { twMerge } from "tailwind-merge";
4
+ function cn(...inputs) {
5
+ return twMerge(clsx(inputs));
6
+ }
7
+
8
+ export {
9
+ cn
10
+ };
@@ -5,16 +5,18 @@ import {
5
5
  safeNextPath
6
6
  } from "./chunk-S2L3BPLS.js";
7
7
  import {
8
- IndexSchema,
9
8
  getSectionSchema
10
- } from "./chunk-ICLXLWQ5.js";
9
+ } from "./chunk-TZQPOR5A.js";
10
+ import {
11
+ getAllSchemas
12
+ } from "./chunk-VKAGMEKE.js";
13
+ import {
14
+ IndexSchema
15
+ } from "./chunk-BT7STGDW.js";
11
16
  import {
12
17
  MAX_BLOCK_DEPTH,
13
18
  blockDepth
14
19
  } from "./chunk-NSCT3AMV.js";
15
- import {
16
- getAllSchemas
17
- } from "./chunk-VKAGMEKE.js";
18
20
 
19
21
  // src/lib/contrast.ts
20
22
  function deriveContrast(hex) {
@@ -79,27 +81,6 @@ function safeRedirect(url, fallback) {
79
81
  return safeNextPath(url) ?? fallback;
80
82
  }
81
83
 
82
- // src/lib/events.ts
83
- function createEvent(name) {
84
- return {
85
- dispatch(detail) {
86
- window.dispatchEvent(new CustomEvent(name, { detail }));
87
- },
88
- listen(callback) {
89
- const handler = (e) => callback(e.detail);
90
- window.addEventListener(name, handler);
91
- return () => window.removeEventListener(name, handler);
92
- }
93
- };
94
- }
95
- var editModeEvent = createEvent("editmodechange");
96
- var navChangeEvent = createEvent("sitenavchange");
97
- var darkModeEvent = createEvent("sitedarkmode");
98
- var siteNameChangeEvent = createEvent("sitenamechange");
99
- var historySelectEvent = createEvent("history-select");
100
- var siteNavChangeEvent = createEvent("sitenavchange-v2");
101
- var pageSelectEvent = createEvent("pageselect");
102
-
103
84
  // src/lib/loader.ts
104
85
  function mergeSiteContent(index, sectionFiles) {
105
86
  const sections = [];
@@ -162,10 +143,6 @@ export {
162
143
  buildGoogleFontsUrl,
163
144
  formatTimestamp,
164
145
  safeRedirect,
165
- createEvent,
166
- editModeEvent,
167
- navChangeEvent,
168
- darkModeEvent,
169
146
  mergeSiteContent,
170
147
  loadStaticSiteContent,
171
148
  loadSiteContent
@@ -1,13 +1,3 @@
1
- import {
2
- MediaConfigSchema
3
- } from "./chunk-DKOUFIP6.js";
4
- import {
5
- LayoutEnvelopeSchema
6
- } from "./chunk-NSCT3AMV.js";
7
- import {
8
- getAllSchemas
9
- } from "./chunk-VKAGMEKE.js";
10
-
11
1
  // src/schemas/shared.ts
12
2
  import { z } from "zod";
13
3
  var TextHeadingLine = z.object({
@@ -84,18 +74,34 @@ var ColorItemSchema = z.object({
84
74
  spaces: z.array(ColorSpaceSchema).min(1)
85
75
  });
86
76
 
87
- // src/schemas/sections.ts
77
+ // src/schemas/media.ts
88
78
  import { z as z2 } from "zod";
89
- function getSectionContentSchema() {
90
- const schemas = getAllSchemas();
91
- if (schemas.length < 2) {
92
- throw new Error("At least 2 section schemas must be registered before validation");
93
- }
94
- return z2.union(schemas);
95
- }
96
- function getSectionSchema() {
97
- return z2.object({ id: z2.string(), layout: LayoutEnvelopeSchema.optional() }).and(getSectionContentSchema());
98
- }
79
+ var VariantSchema = z2.object({
80
+ width: z2.number().int().positive(),
81
+ height: z2.number().int().positive(),
82
+ size: z2.number().int().nonnegative()
83
+ });
84
+ var MediaItemSchema = z2.object({
85
+ id: z2.string(),
86
+ hash: z2.string(),
87
+ kind: z2.enum(["image", "animated", "video"]),
88
+ originalName: z2.string(),
89
+ width: z2.number().int().positive(),
90
+ height: z2.number().int().positive(),
91
+ mimeType: z2.string(),
92
+ size: z2.number().int().nonnegative(),
93
+ folder: z2.string(),
94
+ variants: z2.array(VariantSchema),
95
+ alt: z2.string().default("")
96
+ });
97
+ var ImageManifestSchema = z2.object({
98
+ images: z2.record(z2.string(), MediaItemSchema)
99
+ });
100
+ var MediaConfigSchema = z2.object({
101
+ sizes: z2.array(z2.number()).default([640, 1080, 1920]),
102
+ maxFileSize: z2.number().default(5242880),
103
+ quality: z2.number().min(1).max(100).default(85)
104
+ });
99
105
 
100
106
  // src/schemas/site-config.ts
101
107
  import { z as z3 } from "zod";
@@ -226,8 +232,10 @@ export {
226
232
  FontNameSchema,
227
233
  ColorSpaceSchema,
228
234
  ColorItemSchema,
229
- getSectionContentSchema,
230
- getSectionSchema,
235
+ VariantSchema,
236
+ MediaItemSchema,
237
+ ImageManifestSchema,
238
+ MediaConfigSchema,
231
239
  SectionMetaSchema,
232
240
  RESERVED_SLUGS,
233
241
  PageStatusSchema,
@@ -1,3 +1,7 @@
1
+ import {
2
+ slugifyPageSlug
3
+ } from "./chunk-ZGFAYZWB.js";
4
+
1
5
  // src/media/utils.ts
2
6
  async function hashFileBuffer(buffer) {
3
7
  if (typeof crypto !== "undefined" && crypto.subtle) {
@@ -19,7 +23,7 @@ async function hashFileBuffer(buffer) {
19
23
  return result;
20
24
  }
21
25
  function sanitizeMediaName(name) {
22
- return name.replace(/\.[^.]+$/, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
26
+ return slugifyPageSlug(name.replace(/\.[^.]+$/, ""));
23
27
  }
24
28
  var MIME_TO_EXT = {
25
29
  "image/gif": "gif",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HexColorSchema
3
- } from "./chunk-ICLXLWQ5.js";
3
+ } from "./chunk-BT7STGDW.js";
4
4
 
5
5
  // src/schemas/audience.ts
6
6
  import { z } from "zod";
@@ -0,0 +1,24 @@
1
+ import {
2
+ getAllSchemas
3
+ } from "./chunk-VKAGMEKE.js";
4
+ import {
5
+ LayoutEnvelopeSchema
6
+ } from "./chunk-NSCT3AMV.js";
7
+
8
+ // src/schemas/sections.ts
9
+ import { z } from "zod";
10
+ function getSectionContentSchema() {
11
+ const schemas = getAllSchemas();
12
+ if (schemas.length < 2) {
13
+ throw new Error("At least 2 section schemas must be registered before validation");
14
+ }
15
+ return z.union(schemas);
16
+ }
17
+ function getSectionSchema() {
18
+ return z.object({ id: z.string(), layout: LayoutEnvelopeSchema.optional() }).and(getSectionContentSchema());
19
+ }
20
+
21
+ export {
22
+ getSectionContentSchema,
23
+ getSectionSchema
24
+ };
@@ -2,6 +2,18 @@ import {
2
2
  requireSessionSecret
3
3
  } from "./chunk-S2L3BPLS.js";
4
4
 
5
+ // src/auth/capabilities.ts
6
+ function deriveUiCapabilities(auth) {
7
+ return {
8
+ oauth: (auth.signInMethods.oauth?.length ?? 0) > 0,
9
+ emailPassword: auth.signInMethods.emailPassword ?? false,
10
+ passwordOnly: auth.signInMethods.passwordOnly ?? false,
11
+ userManagement: !!auth.userManagement,
12
+ audienceManagement: !!auth.audiences.manage,
13
+ passwordToggle: !!auth.passwordEnabled.set
14
+ };
15
+ }
16
+
5
17
  // src/auth/cookies.ts
6
18
  import * as jose from "jose";
7
19
  var SESSION_COOKIE = "bp-session";
@@ -64,6 +76,7 @@ var LastOwnerError = class extends Error {
64
76
  };
65
77
 
66
78
  export {
79
+ deriveUiCapabilities,
67
80
  SESSION_COOKIE,
68
81
  AUDIENCE_COOKIE,
69
82
  SESSION_MAX_AGE_SECONDS,