@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.
- package/dist/auth/capabilities.d.ts +16 -0
- package/dist/auth/capabilities.d.ts.map +1 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +3 -1
- package/dist/auth/types.d.ts +26 -22
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/chunk-4OX3Z7SB.js +1421 -0
- package/dist/{chunk-RFZNNCAS.js → chunk-53DKVAB6.js} +1 -61
- package/dist/chunk-677NTHAZ.js +27 -0
- package/dist/chunk-7EOSDFS3.js +10 -0
- package/dist/{chunk-NTGSA3TI.js → chunk-AM5LZD6Q.js} +7 -30
- package/dist/{chunk-ICLXLWQ5.js → chunk-BT7STGDW.js} +31 -23
- package/dist/{chunk-L2JJFOXD.js → chunk-CBWK3KPV.js} +5 -1
- package/dist/{chunk-V7JN2DDU.js → chunk-ODCJQOVO.js} +1 -1
- package/dist/chunk-TZQPOR5A.js +24 -0
- package/dist/{chunk-XTK4BR27.js → chunk-UNWNT52N.js} +13 -0
- package/dist/chunk-UQ4OYRW7.js +670 -0
- package/dist/chunk-WDSVHKAH.js +54 -0
- package/dist/chunk-WLMJCNU7.js +70 -0
- package/dist/chunk-ZGFAYZWB.js +8 -0
- package/dist/components/editor/DropEdgeIndicator.d.ts +8 -0
- package/dist/components/editor/DropEdgeIndicator.d.ts.map +1 -0
- package/dist/components/editor/PagesModal.d.ts.map +1 -1
- package/dist/components/editor/SectionOrderingModal.d.ts.map +1 -1
- package/dist/components/editor/index.js +640 -0
- package/dist/components/primitives/defineHeadingSection.d.ts +28 -0
- package/dist/components/primitives/defineHeadingSection.d.ts.map +1 -0
- package/dist/components/primitives/index.d.ts +10 -0
- package/dist/components/primitives/index.d.ts.map +1 -0
- package/dist/components/primitives/index.js +166 -0
- package/dist/components/sections/Colors/index.d.ts.map +1 -1
- package/dist/components/sections/Container/index.d.ts.map +1 -1
- package/dist/components/sections/IconList/IconList.d.ts +1 -6
- package/dist/components/sections/IconList/IconList.d.ts.map +1 -1
- package/dist/components/sections/IconList/index.d.ts +11 -0
- package/dist/components/sections/IconList/index.d.ts.map +1 -1
- package/dist/components/sections/LinkHeading/index.d.ts.map +1 -1
- package/dist/components/sections/SubHeading/index.d.ts +0 -1
- package/dist/components/sections/SubHeading/index.d.ts.map +1 -1
- package/dist/components/sections/SubSubHeading/index.d.ts +0 -1
- package/dist/components/sections/SubSubHeading/index.d.ts.map +1 -1
- package/dist/components/sections/all-sections.d.ts +0 -2
- package/dist/components/sections/all-sections.d.ts.map +1 -1
- package/dist/components/sections/register-schemas.js +376 -2453
- package/dist/components/shell/BugReportFAB.d.ts.map +1 -1
- package/dist/hooks/useEditorPublish.d.ts.map +1 -1
- package/dist/hooks/useMediaPipeline.d.ts.map +1 -1
- package/dist/hooks/useSortableRow.d.ts +25 -0
- package/dist/hooks/useSortableRow.d.ts.map +1 -0
- package/dist/index.js +46 -37
- package/dist/lib/image-refs.d.ts +21 -0
- package/dist/lib/image-refs.d.ts.map +1 -0
- package/dist/lib/index.js +21 -14
- package/dist/lib/platform-broker.d.ts +14 -0
- package/dist/lib/platform-broker.d.ts.map +1 -0
- package/dist/lib/platform-broker.js +60 -0
- package/dist/lib/reorder.d.ts +12 -0
- package/dist/lib/reorder.d.ts.map +1 -0
- package/dist/lib/text.d.ts +2 -0
- package/dist/lib/text.d.ts.map +1 -1
- package/dist/media/index.js +3 -2
- package/dist/media/utils.d.ts.map +1 -1
- package/dist/schemas/index.js +17 -17
- package/dist/schemas/link.js +13 -0
- package/dist/types/database.d.ts +46 -0
- package/dist/types/database.d.ts.map +1 -1
- package/package.json +14 -2
- package/src/auth/capabilities.ts +26 -0
- package/src/auth/index.ts +3 -0
- package/src/auth/types.ts +36 -26
- package/src/components/editor/DropEdgeIndicator.tsx +13 -0
- package/src/components/editor/PagesModal.tsx +12 -80
- package/src/components/editor/SectionOrderingModal.tsx +8 -78
- package/src/components/primitives/defineHeadingSection.tsx +56 -0
- package/src/components/primitives/index.ts +11 -0
- package/src/components/sections/Colors/index.tsx +2 -4
- package/src/components/sections/Container/index.tsx +2 -4
- package/src/components/sections/IconList/IconList.tsx +1 -7
- package/src/components/sections/IconList/index.tsx +11 -5
- package/src/components/sections/LinkHeading/index.tsx +5 -20
- package/src/components/sections/SubHeading/index.tsx +6 -23
- package/src/components/sections/SubSubHeading/index.tsx +6 -23
- package/src/components/shell/BugReportFAB.tsx +13 -9
- package/src/hooks/useEditorPublish.ts +71 -49
- package/src/hooks/useMediaPipeline.ts +11 -34
- package/src/hooks/useSortableRow.ts +99 -0
- package/src/lib/image-refs.ts +53 -0
- package/src/lib/platform-broker.ts +72 -0
- package/src/lib/reorder.ts +20 -0
- package/src/lib/text.ts +5 -0
- package/src/media/utils.ts +6 -1
- package/src/types/database.ts +41 -0
- package/dist/chunk-DKOUFIP6.js +0 -35
- /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
|
+
};
|
|
@@ -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-
|
|
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/
|
|
77
|
+
// src/schemas/media.ts
|
|
88
78
|
import { z as z2 } from "zod";
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
230
|
-
|
|
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(/\.[^.]+$/, "")
|
|
26
|
+
return slugifyPageSlug(name.replace(/\.[^.]+$/, ""));
|
|
23
27
|
}
|
|
24
28
|
var MIME_TO_EXT = {
|
|
25
29
|
"image/gif": "gif",
|
|
@@ -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,
|