@pebble-software/bonsai 0.3.0 → 0.4.0
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/README.md +30 -14
- package/dist/ast.js +1 -1
- package/dist/chunks/{builder.meta-B7Y9M7Ab.js → builder.meta-DKq-ggkn.js} +3 -3
- package/dist/chunks/{builder.meta-B7Y9M7Ab.js.map → builder.meta-DKq-ggkn.js.map} +1 -1
- package/dist/chunks/class-names-CoKRVvWM.js +66 -0
- package/dist/chunks/class-names-CoKRVvWM.js.map +1 -0
- package/dist/chunks/{create-renderer-kgClEYyp.js → create-renderer-CSFyNcqr.js} +2 -2
- package/dist/chunks/{create-renderer-kgClEYyp.js.map → create-renderer-CSFyNcqr.js.map} +1 -1
- package/dist/chunks/{index-CD5pykpk.js → index-df-PhUtD.js} +2 -2
- package/dist/chunks/{index-CD5pykpk.js.map → index-df-PhUtD.js.map} +1 -1
- package/dist/chunks/{render-shared-CrG0OFhJ.js → render-shared-DSYQFhTh.js} +2 -2
- package/dist/chunks/{render-shared-CrG0OFhJ.js.map → render-shared-DSYQFhTh.js.map} +1 -1
- package/dist/classes.d.ts +28 -10
- package/dist/classes.js +21 -12
- package/dist/classes.js.map +1 -1
- package/dist/classes.json +1 -1
- package/dist/components/ui/signature-pad.d.ts +2 -2
- package/dist/constants.js +7 -2
- package/dist/constants.js.map +1 -1
- package/dist/core.js +3 -3
- package/dist/css.d.ts +42 -0
- package/dist/css.js +7483 -0
- package/dist/css.js.map +1 -0
- package/dist/index.js +200 -245
- package/dist/index.js.map +1 -1
- package/dist/lib/ast/class-names.d.ts +18 -3
- package/dist/library/constants/src/components.d.ts +1 -0
- package/dist/presets/signature.js +2 -2
- package/dist/presets/signature.js.map +1 -1
- package/dist/schemas.js +1 -1
- package/dist/styles/presets.json +2 -1
- package/package.json +6 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { u as
|
|
3
|
-
import
|
|
4
|
-
import { createErrorMap as
|
|
5
|
-
import { a as
|
|
6
|
-
import { c as
|
|
7
|
-
import { u as
|
|
8
|
-
import { calendarPreset as
|
|
9
|
-
import { signaturePreset as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { c as R } from "./chunks/create-renderer-CSFyNcqr.js";
|
|
2
|
+
import { u as ke } from "./chunks/create-renderer-CSFyNcqr.js";
|
|
3
|
+
import T, { z as e } from "zod";
|
|
4
|
+
import { createErrorMap as z } from "zod-validation-error";
|
|
5
|
+
import { a as u, P as D } from "./chunks/builder.meta-DKq-ggkn.js";
|
|
6
|
+
import { c as $, a as C, d as P, e as j, f as B, b as U } from "./chunks/render-shared-DSYQFhTh.js";
|
|
7
|
+
import { u as je } from "./chunks/render-shared-DSYQFhTh.js";
|
|
8
|
+
import { calendarPreset as A } from "./presets/calendar.js";
|
|
9
|
+
import { signaturePreset as I } from "./presets/signature.js";
|
|
10
|
+
import { STRUCTURAL_COMPONENTS as q } from "./constants.js";
|
|
11
|
+
import { i as N, a as M } from "./chunks/class-names-CoKRVvWM.js";
|
|
12
12
|
const c = e.string().length(24).meta({
|
|
13
13
|
description: "MongoDB ObjectId (24-character hex string)",
|
|
14
14
|
example: "67e091ab2c4d3f22001a2b3c"
|
|
@@ -99,7 +99,7 @@ e.object({
|
|
|
99
99
|
role: e.string().min(2).meta({ description: "Updated role", example: "viewer" }),
|
|
100
100
|
permissions: e.string().min(1).meta({ description: "Updated permission set", example: '{"templates":"r"}' })
|
|
101
101
|
}).strict().meta({ description: "Update an organization user's role or permissions" });
|
|
102
|
-
const
|
|
102
|
+
const x = e.looseObject({
|
|
103
103
|
version: e.number().int().positive().meta({ description: "Builder document format version" })
|
|
104
104
|
}).meta({ description: "Builder source document the config was compiled from (editor-only)" });
|
|
105
105
|
e.object({
|
|
@@ -109,7 +109,7 @@ e.object({
|
|
|
109
109
|
name: e.string().min(1).meta({ description: "Template name (unique within the organization)", example: "Neural_NDA_v3" }),
|
|
110
110
|
description: e.string().default("").meta({ description: "Human-readable description of the template's purpose", example: "Standard non-disclosure agreement with neural implant data clause" }),
|
|
111
111
|
config: e.any().meta({ description: "The Bonsai component tree defining the template layout and fields" }),
|
|
112
|
-
source:
|
|
112
|
+
source: x.optional(),
|
|
113
113
|
header: e.string().optional().meta({ description: "A small Bonsai component tree used for page headers in PDF rendering output" }),
|
|
114
114
|
footer: e.string().optional().meta({ description: "A small Bonsai component tree used for page footers in PDF rendering output" }),
|
|
115
115
|
contentHash: e.string().optional().meta({ description: "SHA-256 hash of the serialized config, used for deduplication", example: "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1" }),
|
|
@@ -128,22 +128,22 @@ e.object({
|
|
|
128
128
|
ou: c.meta({ description: "OrganizationUser ID of the user creating the template" }),
|
|
129
129
|
name: e.string().min(1).meta({ description: "Template name (must be unique within the organization)", example: "Neural_NDA_v3" }),
|
|
130
130
|
description: e.string().optional().meta({ description: "Optional description of the template's purpose", example: "Standard NDA with neural implant clause" }),
|
|
131
|
-
config:
|
|
132
|
-
source:
|
|
131
|
+
config: u.meta({ description: "The Bonsai component tree that defines the template layout" }),
|
|
132
|
+
source: x.optional(),
|
|
133
133
|
pdf: e.object({
|
|
134
|
-
header:
|
|
135
|
-
footer:
|
|
134
|
+
header: u.optional().meta({ description: "PDF header Bonsai component tree" }),
|
|
135
|
+
footer: u.optional().meta({ description: "PDF footer Bonsai component tree" })
|
|
136
136
|
}).optional(),
|
|
137
137
|
tags: e.array(e.string()).optional().meta({ description: "Tags for organizing and filtering templates", example: ["nda", "legal"] })
|
|
138
138
|
}).strict().meta({ description: "Create a new reusable signature template" });
|
|
139
139
|
e.object({
|
|
140
140
|
name: e.string().min(1).optional().meta({ description: "New template name (must be unique within the organization)" }),
|
|
141
141
|
description: e.string().optional().meta({ description: "New description" }),
|
|
142
|
-
config:
|
|
143
|
-
source:
|
|
142
|
+
config: u.optional().meta({ description: "Replacement Bonsai component tree; CSS and content hash are recomputed" }),
|
|
143
|
+
source: x.optional(),
|
|
144
144
|
pdf: e.object({
|
|
145
|
-
header:
|
|
146
|
-
footer:
|
|
145
|
+
header: u.optional().meta({ description: "PDF header Bonsai component tree" }),
|
|
146
|
+
footer: u.optional().meta({ description: "PDF footer Bonsai component tree" })
|
|
147
147
|
}).optional(),
|
|
148
148
|
tags: e.array(e.string()).optional().meta({ description: "Replacement tags" })
|
|
149
149
|
}).strict().refine((t) => Object.keys(t).length > 0, { message: "Provide at least one field to update" }).meta({ description: "Update an existing template" });
|
|
@@ -158,7 +158,7 @@ e.object({
|
|
|
158
158
|
name: e.string().meta({ description: "Template name", example: "Neural_NDA_v3" }),
|
|
159
159
|
contentHash: e.string().optional().meta({ description: "SHA-256 hash of the config, useful for deduplication" })
|
|
160
160
|
}).strict().meta({ description: "Created template summary" });
|
|
161
|
-
const
|
|
161
|
+
const F = e.enum([
|
|
162
162
|
"pending",
|
|
163
163
|
"captured",
|
|
164
164
|
"completed",
|
|
@@ -182,7 +182,7 @@ e.object({
|
|
|
182
182
|
header: e.any().meta({ description: "Snapshot of the (small) Bonsai component tree config used for the output PDF page header rendering", readOnly: !0 }),
|
|
183
183
|
footer: e.any().meta({ description: "Snapshot of the (small) Bonsai component tree config used for the output PDF page footer rendering", readOnly: !0 }),
|
|
184
184
|
css: e.string().meta({ description: "Tailwind CSS generated from the template at the time of form creation", readOnly: !0 }),
|
|
185
|
-
status:
|
|
185
|
+
status: F.meta({ description: "Current lifecycle status of the form request", example: "pending" }),
|
|
186
186
|
organization: c.meta({ description: "Organization that owns this form request", readOnly: !0 }),
|
|
187
187
|
createdAt: d.meta({ description: "When the form request was created", readOnly: !0 }),
|
|
188
188
|
updatedAt: d.meta({ description: "When the form request was last updated", readOnly: !0 })
|
|
@@ -192,7 +192,7 @@ e.object({
|
|
|
192
192
|
e.object({
|
|
193
193
|
name: e.string().min(1).meta({ description: "Recipient's display name (used in the email greeting and form header)", example: "Razor Jack" }),
|
|
194
194
|
email: e.string().email().meta({ description: "Recipient email address where the signature link will be sent", example: "jack@datahaven.net" }),
|
|
195
|
-
template: e.union([
|
|
195
|
+
template: e.union([u, e.string()]).meta({
|
|
196
196
|
description: "Either an inline Bonsai component tree config, or a saved template MongoDB ObjectId to use as the form layout"
|
|
197
197
|
}),
|
|
198
198
|
expiry: e.coerce.date().optional().meta({ description: "When the signature request link expires (ISO 8601 date)", example: "2077-12-25T23:59:59Z" }),
|
|
@@ -202,8 +202,8 @@ e.object({
|
|
|
202
202
|
metadata: e.any().optional().meta({ description: "Arbitrary metadata to associate with the form request", example: { department: "Legal", priority: "high" } }),
|
|
203
203
|
data: e.any().optional().meta({ description: "Pre-filled form field data to populate the form on load", example: { full_name: "Razor Jack", badge_id: "RJ-7741" } }),
|
|
204
204
|
pdf: e.union([e.boolean(), e.object({
|
|
205
|
-
header: e.union([
|
|
206
|
-
footer: e.union([
|
|
205
|
+
header: e.union([u, e.string()]).optional().meta({ description: "A (small) Bonsai component tree config used for the output PDF page header rendering" }),
|
|
206
|
+
footer: e.union([u, e.string()]).optional().meta({ description: "A (small) Bonsai component tree config used for the output PDF page footer rendering" })
|
|
207
207
|
})]).optional().meta({ description: "PDF file config object (header||footer) or `true/false` boolean to trigger PDF file generation after form capture" })
|
|
208
208
|
}).strict().meta({ description: "Create a new signature request targeting a recipient" });
|
|
209
209
|
e.object({
|
|
@@ -303,7 +303,7 @@ e.object({
|
|
|
303
303
|
mimeType: W.meta({ description: "MIME type (for Content-Type)", example: "application/pdf" }),
|
|
304
304
|
size: e.number().int().meta({ description: "File size in bytes", example: 245760 })
|
|
305
305
|
}).strict().meta({ description: "Signed download URL for secure file access" });
|
|
306
|
-
const
|
|
306
|
+
const _ = e.enum([
|
|
307
307
|
"pending",
|
|
308
308
|
"generating",
|
|
309
309
|
"completed",
|
|
@@ -322,7 +322,7 @@ e.object({
|
|
|
322
322
|
header: e.any().meta({ description: "Snapshot of the (small) Bonsai component tree config used for the output PDF page header rendering" }),
|
|
323
323
|
footer: e.any().meta({ description: "Snapshot of the (small) Bonsai component tree config used for the output PDF page footer rendering" }),
|
|
324
324
|
css: e.string().meta({ description: "Tailwind CSS generated from the template at the time of PDF generation request", readOnly: !0 }),
|
|
325
|
-
status:
|
|
325
|
+
status: _.meta({ description: "Current lifecycle status of the PDF request", example: "pending" }),
|
|
326
326
|
organization: c.meta({ description: "Organization that owns this PDF request", readOnly: !0 }),
|
|
327
327
|
createdAt: d.meta({ description: "When the PDF request was created", readOnly: !0 }),
|
|
328
328
|
updatedAt: d.meta({ description: "When the PDF request was last updated", readOnly: !0 })
|
|
@@ -330,90 +330,42 @@ e.object({
|
|
|
330
330
|
description: "A PDF request used to trigger the generation of a custom PDF file. Tracks the full lifecycle and alerts sends results via webhook."
|
|
331
331
|
});
|
|
332
332
|
e.object({
|
|
333
|
-
template: e.union([
|
|
333
|
+
template: e.union([u, e.string()]).meta({
|
|
334
334
|
description: "Either an inline Bonsai component tree config, or a saved template MongoDB ObjectId to use as the PDF content layout"
|
|
335
335
|
}),
|
|
336
336
|
webhooks: e.array(e.string()).min(1).meta({ description: "Array of webhook ObjectIds to notify on form lifecycle events", example: ["67e091ab2c4d3f22001a2b3c"] }),
|
|
337
337
|
metadata: e.any().optional().meta({ description: "Arbitrary metadata to associate with the PDF request", example: { department: "Legal", priority: "high" } }),
|
|
338
338
|
data: e.any().optional().meta({ description: "Pre-filled template field data to populate the PDF with", example: { full_name: "Razor Jack", badge_id: "RJ-7741" } }),
|
|
339
|
-
header: e.union([
|
|
340
|
-
footer: e.union([
|
|
339
|
+
header: e.union([u, e.string()]).optional().meta({ description: "A (small) Bonsai component tree config used for the output PDF page header rendering" }),
|
|
340
|
+
footer: e.union([u, e.string()]).optional().meta({ description: "A (small) Bonsai component tree config used for the output PDF page footer rendering" })
|
|
341
341
|
}).strict().meta({ description: "Create a new PDF request to generate a PDF file from a Bonsai template" });
|
|
342
342
|
e.object({
|
|
343
343
|
pdfId: e.string().meta({ description: "MongoDB ObjectId of the newly created PDF request (this is NOT the rendered pdf file - a file ID is returned after async pdf generation via webhook)", example: "67e091ab2c4d3f22001a2b3c", readOnly: !0 })
|
|
344
344
|
}).strict().meta({ description: "Created form request identifier" });
|
|
345
|
-
|
|
346
|
-
customError:
|
|
345
|
+
T.config({
|
|
346
|
+
customError: z()
|
|
347
347
|
});
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
...
|
|
351
|
-
...
|
|
352
|
-
},
|
|
353
|
-
...
|
|
354
|
-
...
|
|
355
|
-
...
|
|
356
|
-
},
|
|
357
|
-
components:
|
|
358
|
-
controlledInputs:
|
|
359
|
-
}),
|
|
360
|
-
...
|
|
348
|
+
const E = {
|
|
349
|
+
...$,
|
|
350
|
+
...A.components,
|
|
351
|
+
...I.components
|
|
352
|
+
}, H = {
|
|
353
|
+
...C,
|
|
354
|
+
...A.controlledInputs,
|
|
355
|
+
...I.controlledInputs
|
|
356
|
+
}, v = B(U, {
|
|
357
|
+
components: E,
|
|
358
|
+
controlledInputs: H
|
|
359
|
+
}), L = P({
|
|
360
|
+
...v,
|
|
361
361
|
components: Object.fromEntries(
|
|
362
|
-
Object.entries(
|
|
362
|
+
Object.entries(v.components).map(([t, i]) => [
|
|
363
363
|
t,
|
|
364
|
-
|
|
364
|
+
j({ ...i, propsSchema: D[t]?.argsSchema })
|
|
365
365
|
])
|
|
366
366
|
)
|
|
367
|
-
})
|
|
368
|
-
function
|
|
369
|
-
return t && i ? [.../* @__PURE__ */ new Set([...t, ...i])] : null;
|
|
370
|
-
}
|
|
371
|
-
function Z(t, i) {
|
|
372
|
-
return !t || !i || t.length * i.length > G ? null : [...new Set(t.flatMap((n) => i.map((r) => n + r)))];
|
|
373
|
-
}
|
|
374
|
-
function h(t, i) {
|
|
375
|
-
const n = t;
|
|
376
|
-
switch (n.type) {
|
|
377
|
-
case "Literal": {
|
|
378
|
-
const r = n.value == null || typeof n.value == "boolean" ? "" : String(n.value);
|
|
379
|
-
return i.push(r), [r];
|
|
380
|
-
}
|
|
381
|
-
case "ConditionalExpression":
|
|
382
|
-
return y(
|
|
383
|
-
h(n.consequent, i),
|
|
384
|
-
h(n.alternate, i)
|
|
385
|
-
);
|
|
386
|
-
case "BinaryExpression":
|
|
387
|
-
switch (n.operator) {
|
|
388
|
-
// A falsy left side renders no class, so only the right side is a result.
|
|
389
|
-
case "&&":
|
|
390
|
-
return y([""], h(n.right, i));
|
|
391
|
-
case "||":
|
|
392
|
-
case "??":
|
|
393
|
-
return y(h(n.left, i), h(n.right, i));
|
|
394
|
-
case "+":
|
|
395
|
-
return Z(h(n.left, i), h(n.right, i));
|
|
396
|
-
default:
|
|
397
|
-
return null;
|
|
398
|
-
}
|
|
399
|
-
default:
|
|
400
|
-
return null;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
function K(t) {
|
|
404
|
-
const i = F(t)?.ast;
|
|
405
|
-
if (!i) return null;
|
|
406
|
-
const n = [], r = h(i, n);
|
|
407
|
-
if (!r)
|
|
408
|
-
return "must evaluate to classes written in string literals (e.g. a ternary between class strings), not to data or a computed value";
|
|
409
|
-
const a = new Set(n.flatMap(j));
|
|
410
|
-
for (const o of r)
|
|
411
|
-
for (const s of j(o))
|
|
412
|
-
if (!a.has(s))
|
|
413
|
-
return `builds "${s}" by joining strings; write each class whole inside one string literal`;
|
|
414
|
-
return null;
|
|
415
|
-
}
|
|
416
|
-
function X(t, i) {
|
|
367
|
+
});
|
|
368
|
+
function J(t, i) {
|
|
417
369
|
if (!t)
|
|
418
370
|
return { action: "render", reason: "no-pin" };
|
|
419
371
|
if (t.id !== i.id)
|
|
@@ -422,95 +374,98 @@ function X(t, i) {
|
|
|
422
374
|
reason: "id-mismatch",
|
|
423
375
|
error: `Template is pinned to registry "${t.id}", but rendering registry is "${i.id}" — this is a different component library, not a version skew.`
|
|
424
376
|
};
|
|
425
|
-
const n = t.version === i.version,
|
|
426
|
-
return n &&
|
|
377
|
+
const n = t.version === i.version, o = t.manifestHash == null || i.manifestHash == null || t.manifestHash === i.manifestHash;
|
|
378
|
+
return n && o ? { action: "render", reason: "match" } : {
|
|
427
379
|
action: "render",
|
|
428
380
|
reason: "version-skew",
|
|
429
381
|
warning: n ? `Template is pinned to registry "${t.id}"@"${t.version}" (manifest ${t.manifestHash}), but the resolved manifest is now ${i.manifestHash}. Re-pin on next save.` : `Template is pinned to registry "${t.id}"@"${t.version}", but rendering registry is "${t.id}"@"${i.version}". Re-pin on next save.`
|
|
430
382
|
};
|
|
431
383
|
}
|
|
432
|
-
|
|
433
|
-
function Y(t, i) {
|
|
384
|
+
function V(t, i) {
|
|
434
385
|
return t.capabilities ? i === "pdf" ? t.capabilities.includes("pdf") : t.capabilities.includes("ssr") : !0;
|
|
435
386
|
}
|
|
436
|
-
function
|
|
387
|
+
function b(t, i, n, o, a) {
|
|
437
388
|
if (t == null || typeof t == "string") return;
|
|
438
|
-
const
|
|
439
|
-
if (!
|
|
389
|
+
const r = t.type;
|
|
390
|
+
if (!r) {
|
|
440
391
|
a.push({ path: i, message: "Node is missing a required `type` field" });
|
|
441
392
|
return;
|
|
442
393
|
}
|
|
443
|
-
if (
|
|
394
|
+
if (q.has(r)) {
|
|
444
395
|
(t.children ?? []).forEach(
|
|
445
|
-
(
|
|
396
|
+
(l, p) => b(l, `${i}.children[${p}]`, n, o, a)
|
|
446
397
|
);
|
|
447
398
|
return;
|
|
448
399
|
}
|
|
449
|
-
const s = n.components[
|
|
400
|
+
const s = n.components[r];
|
|
450
401
|
if (!s) {
|
|
451
402
|
a.push({
|
|
452
403
|
path: i,
|
|
453
|
-
componentType:
|
|
454
|
-
message: `Unknown component type "${
|
|
404
|
+
componentType: r,
|
|
405
|
+
message: `Unknown component type "${r}" in registry "${n.id}"@"${n.version}"`
|
|
455
406
|
});
|
|
456
407
|
return;
|
|
457
408
|
}
|
|
458
|
-
if (
|
|
409
|
+
if (V(s, o) || a.push({
|
|
459
410
|
path: i,
|
|
460
|
-
componentType:
|
|
461
|
-
message: `Component "${
|
|
411
|
+
componentType: r,
|
|
412
|
+
message: `Component "${r}" in registry "${n.id}"@"${n.version}" does not support "${o}" rendering`
|
|
462
413
|
}), s.propsSchema) {
|
|
463
|
-
const
|
|
464
|
-
if (!
|
|
465
|
-
for (const
|
|
466
|
-
const
|
|
467
|
-
a.push({ path:
|
|
414
|
+
const l = s.propsSchema.safeParse(t.args);
|
|
415
|
+
if (!l.success)
|
|
416
|
+
for (const p of l.error.issues) {
|
|
417
|
+
const f = p.path.length ? `${i}.args.${p.path.join(".")}` : `${i}.args`;
|
|
418
|
+
a.push({ path: f, componentType: r, message: p.message });
|
|
468
419
|
}
|
|
469
420
|
}
|
|
470
421
|
t.args?.onClick !== void 0 && s.capabilities && !s.capabilities.includes("events") && a.push({
|
|
471
422
|
path: `${i}.args.onClick`,
|
|
472
|
-
componentType:
|
|
473
|
-
message: `Component "${
|
|
423
|
+
componentType: r,
|
|
424
|
+
message: `Component "${r}" in registry "${n.id}"@"${n.version}" does not accept onClick`
|
|
474
425
|
});
|
|
475
|
-
const l
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
426
|
+
for (const [l, p] of Object.entries(t.args ?? {})) {
|
|
427
|
+
if (!N(l)) continue;
|
|
428
|
+
const { issue: f } = M(p);
|
|
429
|
+
f && a.push({
|
|
430
|
+
path: `${i}.args.${l}`,
|
|
431
|
+
componentType: r,
|
|
432
|
+
message: `${l} ${f}`
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
(t.children?.length ?? 0) > 0 && (s.capabilities && !s.capabilities.includes("children") && a.push({
|
|
481
436
|
path: i,
|
|
482
|
-
componentType:
|
|
483
|
-
message: `Component "${
|
|
437
|
+
componentType: r,
|
|
438
|
+
message: `Component "${r}" in registry "${n.id}"@"${n.version}" does not accept children`
|
|
484
439
|
}), (t.children ?? []).forEach(
|
|
485
|
-
(
|
|
440
|
+
(l, p) => b(l, `${i}.children[${p}]`, n, o, a)
|
|
486
441
|
));
|
|
487
442
|
}
|
|
488
|
-
function
|
|
489
|
-
const
|
|
443
|
+
function ge(t, i, n = {}) {
|
|
444
|
+
const o = [], a = [];
|
|
490
445
|
if (n.pin) {
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
493
|
-
return
|
|
494
|
-
|
|
446
|
+
const r = J(n.pin, i);
|
|
447
|
+
if (r.action === "fail")
|
|
448
|
+
return o.push({ path: "root", message: r.error }), { valid: !1, errors: o, warnings: a };
|
|
449
|
+
r.reason === "version-skew" && a.push(r.warning);
|
|
495
450
|
}
|
|
496
|
-
return
|
|
451
|
+
return b(t, "root", i, n.mode ?? "web", o), { valid: o.length === 0, errors: o, warnings: a };
|
|
497
452
|
}
|
|
498
|
-
const
|
|
453
|
+
const G = e.string().refine((t) => t.startsWith("{{") && t.endsWith("}}"), {
|
|
499
454
|
message: 'Expected a value of the declared type, or a "{{binding}}" expression'
|
|
500
455
|
});
|
|
501
|
-
function
|
|
502
|
-
const n = (a) => i.allowBindings ? e.union([
|
|
456
|
+
function y(t, i = {}) {
|
|
457
|
+
const n = (a) => i.allowBindings ? e.union([G, a]) : a;
|
|
503
458
|
if ("const" in t)
|
|
504
459
|
return n(e.literal(t.const));
|
|
505
460
|
if (Array.isArray(t.enum)) {
|
|
506
461
|
const a = t.enum;
|
|
507
462
|
if (a.length === 0)
|
|
508
463
|
throw new Error("jsonSchemaToZod: enum must have at least one value");
|
|
509
|
-
const [
|
|
510
|
-
return n(s.reduce((
|
|
464
|
+
const [r, ...s] = a;
|
|
465
|
+
return n(s.reduce((m, l) => e.union([m, e.literal(l)]), e.literal(r)));
|
|
511
466
|
}
|
|
512
|
-
const
|
|
513
|
-
switch (
|
|
467
|
+
const o = t.type;
|
|
468
|
+
switch (o) {
|
|
514
469
|
case "string": {
|
|
515
470
|
let a = e.string();
|
|
516
471
|
return typeof t.minLength == "number" && (a = a.min(t.minLength)), typeof t.maxLength == "number" && (a = a.max(t.maxLength)), typeof t.pattern == "string" && (a = a.regex(new RegExp(t.pattern))), n(a);
|
|
@@ -518,41 +473,41 @@ function x(t, i = {}) {
|
|
|
518
473
|
case "number":
|
|
519
474
|
case "integer": {
|
|
520
475
|
let a = e.number();
|
|
521
|
-
return
|
|
476
|
+
return o === "integer" && (a = a.int()), typeof t.minimum == "number" && (a = a.min(t.minimum)), typeof t.maximum == "number" && (a = a.max(t.maximum)), n(a);
|
|
522
477
|
}
|
|
523
478
|
case "boolean":
|
|
524
479
|
return n(e.boolean());
|
|
525
480
|
case "array": {
|
|
526
|
-
const a = t.items ?
|
|
481
|
+
const a = t.items ? y(t.items, i) : e.unknown();
|
|
527
482
|
return n(e.array(a));
|
|
528
483
|
}
|
|
529
484
|
case "object": {
|
|
530
|
-
const a = t.properties ?? {},
|
|
531
|
-
for (const [
|
|
532
|
-
const
|
|
533
|
-
s[
|
|
485
|
+
const a = t.properties ?? {}, r = new Set(t.required ?? []), s = {};
|
|
486
|
+
for (const [l, p] of Object.entries(a)) {
|
|
487
|
+
const f = y(p, i);
|
|
488
|
+
s[l] = r.has(l) ? f : f.optional();
|
|
534
489
|
}
|
|
535
|
-
let
|
|
536
|
-
return t.additionalProperties === !1 && (
|
|
490
|
+
let m = e.object(s);
|
|
491
|
+
return t.additionalProperties === !1 && (m = m.strict()), m;
|
|
537
492
|
}
|
|
538
493
|
default:
|
|
539
494
|
return e.unknown();
|
|
540
495
|
}
|
|
541
496
|
}
|
|
542
|
-
const
|
|
497
|
+
const Z = e.object({
|
|
543
498
|
valueProp: e.string().min(1),
|
|
544
499
|
changeProp: e.string().min(1),
|
|
545
500
|
extract: e.string().min(1)
|
|
546
|
-
}).strict(),
|
|
501
|
+
}).strict(), K = e.object({
|
|
547
502
|
name: e.string().min(1),
|
|
548
503
|
canonicalName: e.string().min(1).optional(),
|
|
549
504
|
// Case A: a key resolved against `base`'s exports, never a module path to import.
|
|
550
505
|
entry: e.string().min(1),
|
|
551
506
|
propsSchema: e.record(e.string(), e.unknown()).optional(),
|
|
552
507
|
capabilities: e.array(e.enum(["children", "bindings", "events", "formField", "ssr", "pdf"])).optional(),
|
|
553
|
-
controlled:
|
|
508
|
+
controlled: Z.optional(),
|
|
554
509
|
css: e.array(e.string()).optional()
|
|
555
|
-
}).strict(),
|
|
510
|
+
}).strict(), S = e.object({
|
|
556
511
|
$schema: e.string().optional(),
|
|
557
512
|
id: e.string().min(1),
|
|
558
513
|
namespace: e.string().min(1).optional(),
|
|
@@ -561,12 +516,12 @@ const te = e.object({
|
|
|
561
516
|
name: e.literal("bonsai"),
|
|
562
517
|
api: e.string().min(1)
|
|
563
518
|
}).strict(),
|
|
564
|
-
components: e.array(
|
|
519
|
+
components: e.array(K).min(1),
|
|
565
520
|
integrity: e.object({
|
|
566
521
|
algorithm: e.literal("sha256"),
|
|
567
522
|
manifestHash: e.string().min(1)
|
|
568
523
|
}).strict().optional()
|
|
569
|
-
}).strict(),
|
|
524
|
+
}).strict(), X = "1", O = {
|
|
570
525
|
identity: (t) => t,
|
|
571
526
|
targetValue: (t) => t?.target?.value,
|
|
572
527
|
targetChecked: (t) => t?.target?.checked,
|
|
@@ -577,72 +532,72 @@ class g extends Error {
|
|
|
577
532
|
super(i), this.name = "ManifestLoadError";
|
|
578
533
|
}
|
|
579
534
|
}
|
|
580
|
-
function
|
|
581
|
-
return t ? i ? e.any().superRefine((n,
|
|
535
|
+
function Q(t, i) {
|
|
536
|
+
return t ? i ? e.any().superRefine((n, o) => {
|
|
582
537
|
const a = t.safeParse(n);
|
|
583
538
|
if (!a.success)
|
|
584
539
|
for (const s of a.error.issues)
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
if (!
|
|
588
|
-
for (const s of
|
|
589
|
-
|
|
540
|
+
o.addIssue({ code: "custom", message: s.message, path: s.path });
|
|
541
|
+
const r = i.safeParse(n);
|
|
542
|
+
if (!r.success)
|
|
543
|
+
for (const s of r.error.issues)
|
|
544
|
+
o.addIssue({ code: "custom", message: s.message, path: s.path });
|
|
590
545
|
}) : t : i;
|
|
591
546
|
}
|
|
592
|
-
async function
|
|
547
|
+
async function Y(t) {
|
|
593
548
|
const i = new TextEncoder().encode(t), n = await crypto.subtle.digest("SHA-256", i);
|
|
594
549
|
return `sha256:${Array.from(new Uint8Array(n)).map((a) => a.toString(16).padStart(2, "0")).join("")}`;
|
|
595
550
|
}
|
|
596
|
-
function
|
|
597
|
-
const i =
|
|
551
|
+
function ee(t) {
|
|
552
|
+
const i = O[t];
|
|
598
553
|
if (!i)
|
|
599
554
|
throw new g(
|
|
600
|
-
`Registry manifest: unknown extractor "${t}" — must be one of: ${Object.keys(
|
|
555
|
+
`Registry manifest: unknown extractor "${t}" — must be one of: ${Object.keys(O).join(", ")}`
|
|
601
556
|
);
|
|
602
557
|
return i;
|
|
603
558
|
}
|
|
604
|
-
function
|
|
605
|
-
const
|
|
606
|
-
if (!
|
|
559
|
+
function te(t, i, n) {
|
|
560
|
+
const o = i.components[t.entry];
|
|
561
|
+
if (!o)
|
|
607
562
|
throw new g(
|
|
608
563
|
`Registry manifest "${n}": component "${t.name}" resolves entry "${t.entry}", which is not exported by base registry "${i.id}"@"${i.version}"`
|
|
609
564
|
);
|
|
610
|
-
const a = t.propsSchema ?
|
|
565
|
+
const a = t.propsSchema ? y(t.propsSchema) : void 0, r = t.controlled ? {
|
|
611
566
|
valueProp: t.controlled.valueProp,
|
|
612
567
|
changeProp: t.controlled.changeProp,
|
|
613
|
-
extract:
|
|
614
|
-
} :
|
|
568
|
+
extract: ee(t.controlled.extract)
|
|
569
|
+
} : o.controlled;
|
|
615
570
|
return [
|
|
616
571
|
t.canonicalName ?? t.name,
|
|
617
|
-
|
|
618
|
-
component:
|
|
619
|
-
propsSchema:
|
|
620
|
-
capabilities: t.capabilities ??
|
|
621
|
-
controlled:
|
|
622
|
-
assets: t.css ? { css: t.css } :
|
|
572
|
+
j({
|
|
573
|
+
component: o.component,
|
|
574
|
+
propsSchema: Q(o.propsSchema, a),
|
|
575
|
+
capabilities: t.capabilities ?? o.capabilities,
|
|
576
|
+
controlled: r,
|
|
577
|
+
assets: t.css ? { css: t.css } : o.assets
|
|
623
578
|
})
|
|
624
579
|
];
|
|
625
580
|
}
|
|
626
|
-
function
|
|
627
|
-
const n =
|
|
628
|
-
if (n.engine.api !==
|
|
581
|
+
function ie(t, i) {
|
|
582
|
+
const n = S.parse(t), o = i.engineApi ?? X;
|
|
583
|
+
if (n.engine.api !== o)
|
|
629
584
|
throw new g(
|
|
630
|
-
`Registry manifest "${n.id}" targets engine.api "${n.engine.api}", but this build supports "${
|
|
585
|
+
`Registry manifest "${n.id}" targets engine.api "${n.engine.api}", but this build supports "${o}"`
|
|
631
586
|
);
|
|
632
587
|
const a = i.maxComponents ?? 500;
|
|
633
588
|
if (n.components.length > a)
|
|
634
589
|
throw new g(
|
|
635
590
|
`Registry manifest "${n.id}" declares ${n.components.length} components, exceeding the limit of ${a}`
|
|
636
591
|
);
|
|
637
|
-
const
|
|
638
|
-
if (i.rawManifestSize != null && i.rawManifestSize >
|
|
592
|
+
const r = i.maxManifestBytes ?? 5 * 1024 * 1024;
|
|
593
|
+
if (i.rawManifestSize != null && i.rawManifestSize > r)
|
|
639
594
|
throw new g(
|
|
640
|
-
`Registry manifest "${n.id}" is ${i.rawManifestSize} bytes, exceeding the limit of ${
|
|
595
|
+
`Registry manifest "${n.id}" is ${i.rawManifestSize} bytes, exceeding the limit of ${r}`
|
|
641
596
|
);
|
|
642
597
|
const s = Object.fromEntries(
|
|
643
|
-
n.components.map((
|
|
598
|
+
n.components.map((m) => te(m, i.base, n.id))
|
|
644
599
|
);
|
|
645
|
-
return
|
|
600
|
+
return P({
|
|
646
601
|
id: n.id,
|
|
647
602
|
version: n.version,
|
|
648
603
|
namespace: n.namespace,
|
|
@@ -651,11 +606,11 @@ function ce(t, i) {
|
|
|
651
606
|
components: s
|
|
652
607
|
});
|
|
653
608
|
}
|
|
654
|
-
const
|
|
655
|
-
function
|
|
656
|
-
|
|
609
|
+
const w = /* @__PURE__ */ new Map();
|
|
610
|
+
function fe() {
|
|
611
|
+
w.clear();
|
|
657
612
|
}
|
|
658
|
-
function
|
|
613
|
+
function ne(t, i) {
|
|
659
614
|
if (!t.integrity)
|
|
660
615
|
throw new g(
|
|
661
616
|
`Registry manifest "${t.id}" has no integrity block — a manifest hash is required before use`
|
|
@@ -665,7 +620,7 @@ function de(t, i) {
|
|
|
665
620
|
`Registry manifest "${t.id}" failed its integrity check: expected "${t.integrity.manifestHash}", computed "${i}"`
|
|
666
621
|
);
|
|
667
622
|
}
|
|
668
|
-
async function
|
|
623
|
+
async function he(t, i) {
|
|
669
624
|
let n;
|
|
670
625
|
if (typeof t == "string") {
|
|
671
626
|
const p = new URL(t);
|
|
@@ -673,86 +628,86 @@ async function Oe(t, i) {
|
|
|
673
628
|
throw new g(
|
|
674
629
|
`Registry manifest origin "${p.origin}" is not in the allowed origins list`
|
|
675
630
|
);
|
|
676
|
-
const
|
|
677
|
-
if (!
|
|
631
|
+
const h = await (i.fetchImpl ?? fetch)(t);
|
|
632
|
+
if (!h.ok)
|
|
678
633
|
throw new g(
|
|
679
|
-
`Registry manifest fetch failed: ${t} responded ${
|
|
634
|
+
`Registry manifest fetch failed: ${t} responded ${h.status}`
|
|
680
635
|
);
|
|
681
|
-
n = await
|
|
636
|
+
n = await h.text();
|
|
682
637
|
} else
|
|
683
638
|
n = JSON.stringify(t);
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
const
|
|
687
|
-
if (
|
|
688
|
-
const
|
|
689
|
-
return
|
|
639
|
+
const o = S.parse(JSON.parse(n)), { integrity: a, ...r } = o, s = await Y(JSON.stringify(r));
|
|
640
|
+
ne(o, s);
|
|
641
|
+
const m = w.get(s);
|
|
642
|
+
if (m) return m;
|
|
643
|
+
const l = ie(o, { ...i, rawManifestSize: n.length, manifestHash: s });
|
|
644
|
+
return w.set(s, l), l;
|
|
690
645
|
}
|
|
691
|
-
function
|
|
692
|
-
const n = { ...t?.properties ?? {}, ...i?.properties ?? {} },
|
|
693
|
-
return { type: "object", properties: n, required:
|
|
646
|
+
function be(t, i) {
|
|
647
|
+
const n = { ...t?.properties ?? {}, ...i?.properties ?? {} }, o = [.../* @__PURE__ */ new Set([...t?.required ?? [], ...i?.required ?? []])];
|
|
648
|
+
return { type: "object", properties: n, required: o };
|
|
694
649
|
}
|
|
695
|
-
function
|
|
696
|
-
const n = new Map(t.map((
|
|
697
|
-
for (const [
|
|
698
|
-
const
|
|
699
|
-
|
|
650
|
+
function ae(t, i) {
|
|
651
|
+
const n = new Map(t.map((r) => [r.url, r.registryHash])), o = new Map(i.map((r) => [r.url, r.registryHash])), a = [];
|
|
652
|
+
for (const [r, s] of o) {
|
|
653
|
+
const m = n.get(r);
|
|
654
|
+
m === void 0 ? a.push(`${r} is configured but missing from the artifact`) : m !== s && a.push(`${r}: artifact has ${m}, pebble-kit.json records ${s}`);
|
|
700
655
|
}
|
|
701
|
-
for (const
|
|
702
|
-
|
|
656
|
+
for (const r of n.keys())
|
|
657
|
+
o.has(r) || a.push(`${r} is in the artifact but no longer configured`);
|
|
703
658
|
return a.length > 0 ? a.join("; ") : void 0;
|
|
704
659
|
}
|
|
705
|
-
function
|
|
660
|
+
function k(t) {
|
|
706
661
|
const i = /(\d+)\.\d+\.\d+/.exec(t);
|
|
707
662
|
return i ? Number(i[1]) : void 0;
|
|
708
663
|
}
|
|
709
|
-
function
|
|
710
|
-
const i = [], n =
|
|
664
|
+
function ye(t) {
|
|
665
|
+
const i = [], n = ae(t.artifactRegistries, t.configRegistries);
|
|
711
666
|
if (n && i.push({
|
|
712
667
|
check: "stale-artifact",
|
|
713
668
|
level: "fail",
|
|
714
669
|
message: `bonsai.generated.json is out of date with pebble-kit.json (${n}) — run "pebble-kit generate"`
|
|
715
670
|
}), t.artifactBaseUiVersion !== t.installedBaseUiVersion) {
|
|
716
|
-
const
|
|
671
|
+
const o = k(t.artifactBaseUiVersion), a = k(t.installedBaseUiVersion), r = o !== void 0 && a !== void 0 && o !== a;
|
|
717
672
|
i.push({
|
|
718
673
|
check: "baseui-drift",
|
|
719
|
-
level:
|
|
674
|
+
level: r ? "fail" : "warn",
|
|
720
675
|
message: `generated artifact's baseline was built against @base-ui/react ${t.artifactBaseUiVersion}, but ${t.installedBaseUiVersion} is installed`
|
|
721
676
|
});
|
|
722
677
|
}
|
|
723
678
|
return i;
|
|
724
679
|
}
|
|
725
|
-
function
|
|
680
|
+
function we(t) {
|
|
726
681
|
const i = t.filter((n) => n.level === "fail");
|
|
727
682
|
if (i.length > 0)
|
|
728
683
|
throw new Error(i.map((n) => n.message).join("; "));
|
|
729
684
|
}
|
|
730
|
-
const { Bonsai:
|
|
685
|
+
const { Bonsai: xe } = R({ registry: L });
|
|
731
686
|
export {
|
|
732
|
-
|
|
733
|
-
|
|
687
|
+
xe as Bonsai,
|
|
688
|
+
O as EXTRACTOR_ALLOWLIST,
|
|
734
689
|
g as ManifestLoadError,
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
690
|
+
S as RegistryManifestSchema,
|
|
691
|
+
we as assertNoFailingDrift,
|
|
692
|
+
ye as checkArtifactDrift,
|
|
693
|
+
fe as clearManifestCache,
|
|
694
|
+
E as componentMap,
|
|
695
|
+
Q as composePropsSchema,
|
|
696
|
+
Y as computeManifestHash,
|
|
697
|
+
H as controlledInputMap,
|
|
698
|
+
U as coreRegistry,
|
|
699
|
+
R as createBonsaiRenderer,
|
|
700
|
+
P as defineBonsaiRegistry,
|
|
701
|
+
j as defineComponent,
|
|
702
|
+
B as extendRegistry,
|
|
703
|
+
y as jsonSchemaToZod,
|
|
704
|
+
he as loadRegistryManifest,
|
|
705
|
+
be as mergeGeneratedWithOverrides,
|
|
706
|
+
L as pebbleRegistry,
|
|
707
|
+
ie as resolveManifest,
|
|
708
|
+
J as resolveRegistryPin,
|
|
709
|
+
je as useBonsaiRenderMode,
|
|
710
|
+
ke as useUpdateData,
|
|
711
|
+
ge as validateTemplate
|
|
757
712
|
};
|
|
758
713
|
//# sourceMappingURL=index.js.map
|