@pebble-software/bonsai 0.0.3 → 0.0.5
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/index.css +453 -0
- package/dist/index.d.ts +316 -4
- package/dist/index.js +1877 -1378
- package/package.json +31 -19
- package/dist/components/core/bonsai.d.ts +0 -17
- package/dist/components/ui/a.d.ts +0 -3
- package/dist/components/ui/accordion.d.ts +0 -17
- package/dist/components/ui/alert-dialog.d.ts +0 -23
- package/dist/components/ui/alert.d.ts +0 -12
- package/dist/components/ui/avatar.d.ts +0 -21
- package/dist/components/ui/badge.d.ts +0 -10
- package/dist/components/ui/breadcrumb.d.ts +0 -10
- package/dist/components/ui/button.d.ts +0 -14
- package/dist/components/ui/calendar.d.ts +0 -9
- package/dist/components/ui/card.d.ts +0 -15
- package/dist/components/ui/chart.d.ts +0 -44
- package/dist/components/ui/checkbox.d.ts +0 -7
- package/dist/components/ui/collapsible.d.ts +0 -5
- package/dist/components/ui/combobox.d.ts +0 -31
- package/dist/components/ui/command.d.ts +0 -23
- package/dist/components/ui/dialog.d.ts +0 -23
- package/dist/components/ui/drawer.d.ts +0 -22
- package/dist/components/ui/dropdown-menu.d.ts +0 -29
- package/dist/components/ui/form.d.ts +0 -24
- package/dist/components/ui/h.d.ts +0 -10
- package/dist/components/ui/input-group.d.ts +0 -18
- package/dist/components/ui/input-otp.d.ts +0 -11
- package/dist/components/ui/input.d.ts +0 -3
- package/dist/components/ui/label.d.ts +0 -10
- package/dist/components/ui/loader.d.ts +0 -14
- package/dist/components/ui/map.d.ts +0 -30
- package/dist/components/ui/p.d.ts +0 -11
- package/dist/components/ui/popover.d.ts +0 -9
- package/dist/components/ui/progress.d.ts +0 -31
- package/dist/components/ui/scroll-area.d.ts +0 -13
- package/dist/components/ui/select.d.ts +0 -17
- package/dist/components/ui/separator.d.ts +0 -8
- package/dist/components/ui/sidebar.d.ts +0 -70
- package/dist/components/ui/signature-pad.d.ts +0 -7
- package/dist/components/ui/skeleton.d.ts +0 -7
- package/dist/components/ui/switch.d.ts +0 -8
- package/dist/components/ui/table.d.ts +0 -14
- package/dist/components/ui/tabs.d.ts +0 -15
- package/dist/components/ui/textarea.d.ts +0 -5
- package/dist/components/ui/toast.d.ts +0 -46
- package/dist/components/ui/tooltip.d.ts +0 -15
- package/dist/hooks/haptics.d.ts +0 -8
- package/dist/hooks/use-mobile.d.ts +0 -1
- package/dist/lib/ast/cache.d.ts +0 -8
- package/dist/lib/ast/evaluator.d.ts +0 -2
- package/dist/lib/ast/helpers.d.ts +0 -2
- package/dist/lib/ast/index.d.ts +0 -4
- package/dist/lib/ast/setup.d.ts +0 -2
- package/dist/lib/ast/types.d.ts +0 -1
- package/dist/lib/ast/utils.d.ts +0 -3
- package/dist/lib/haptics.d.ts +0 -8
- package/dist/lib/ui/registry.d.ts +0 -8
- package/dist/lib/utils.d.ts +0 -3
- package/dist/tests/ast.bugs.test.d.ts +0 -1
- package/dist/tests/ast.engine.test.d.ts +0 -1
- package/dist/tests/ast.helpers.test.d.ts +0 -1
- package/dist/tests/fixtures/examples.d.ts +0 -8
- package/dist/tests/helpers.d.ts +0 -4
- package/dist/tests/render.bindings.test.d.ts +0 -1
- package/dist/tests/render.controlled.test.d.ts +0 -1
- package/dist/tests/render.examples.test.d.ts +0 -1
- package/dist/tests/render.granularity.test.d.ts +0 -1
- package/dist/tests/render.ssr-client.test.d.ts +0 -1
- package/dist/tests/render.structural.test.d.ts +0 -1
- package/dist/tests/schema.contract.test.d.ts +0 -1
- package/dist/tests/schema.examples.test.d.ts +0 -1
- package/dist/tests/schema.kitchen-sink.test.d.ts +0 -1
- package/dist/tests/setup.d.ts +0 -1
- package/dist/tests/store.paths.test.d.ts +0 -1
- package/dist/tests/ui.contracts.test.d.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,316 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { JSX } from 'react';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { ZodType } from 'zod';
|
|
5
|
+
|
|
6
|
+
export declare function assertNoFailingDrift(issues: DriftIssue[]): void;
|
|
7
|
+
|
|
8
|
+
export declare function Bonsai(props: BonsaiProps): JSX.Element;
|
|
9
|
+
|
|
10
|
+
declare interface BonsaiProps {
|
|
11
|
+
captureUrl: string;
|
|
12
|
+
expiry: string;
|
|
13
|
+
template: Config;
|
|
14
|
+
data?: any;
|
|
15
|
+
status?: "pending" | "captured" | "completed" | "error" | "revoked";
|
|
16
|
+
render?: "web" | "pdf" | "preview";
|
|
17
|
+
registry?: BonsaiRegistry;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export declare interface BonsaiRegistry {
|
|
21
|
+
id: string;
|
|
22
|
+
version: string;
|
|
23
|
+
namespace?: string;
|
|
24
|
+
manifestHash?: string;
|
|
25
|
+
components: Record<string, ComponentDefinition>;
|
|
26
|
+
fallback?: RegistryFallback;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare function checkArtifactDrift(input: DriftCheckInput): DriftIssue[];
|
|
30
|
+
|
|
31
|
+
export declare function clearManifestCache(): void;
|
|
32
|
+
|
|
33
|
+
declare enum COMPONENT {
|
|
34
|
+
A = "a",
|
|
35
|
+
P = "p",
|
|
36
|
+
H = "h",
|
|
37
|
+
OL = "ol",
|
|
38
|
+
UL = "ul",
|
|
39
|
+
LI = "li",
|
|
40
|
+
MAP = "map",
|
|
41
|
+
DIV = "div",
|
|
42
|
+
SPAN = "span",
|
|
43
|
+
ACCORDION = "accordion",
|
|
44
|
+
ACCORDION_ITEM = "accordion-item",
|
|
45
|
+
ACCORDION_TRIGGER = "accordion-trigger",
|
|
46
|
+
ACCORDION_CONTENT = "accordion-content",
|
|
47
|
+
ALERT = "alert",
|
|
48
|
+
AVATAR = "avatar",
|
|
49
|
+
BADGE = "badge",
|
|
50
|
+
BUTTON = "button",
|
|
51
|
+
CARD = "card",
|
|
52
|
+
CARD_HEADER = "card-header",
|
|
53
|
+
CARD_TITLE = "card-title",
|
|
54
|
+
CARD_DESCRIPTION = "card-description",
|
|
55
|
+
CARD_CONTENT = "card-content",
|
|
56
|
+
CARD_FOOTER = "card-footer",
|
|
57
|
+
CARD_ACTION = "card-action",
|
|
58
|
+
CARD_ICON = "card-icon",
|
|
59
|
+
CALENDAR = "calendar",
|
|
60
|
+
CHECKBOX = "checkbox",
|
|
61
|
+
COLLAPSIBLE = "collapsible",
|
|
62
|
+
COLLAPSIBLE_TRIGGER = "collapsible-trigger",
|
|
63
|
+
COLLAPSIBLE_CONTENT = "collapsible-content",
|
|
64
|
+
IMAGE = "image",
|
|
65
|
+
OTP = "otp",
|
|
66
|
+
INPUT = "input",
|
|
67
|
+
INPUT_GROUP = "input-group",
|
|
68
|
+
INPUT_GROUP_TEXT = "input-group-text",
|
|
69
|
+
INPUT_GROUP_ADDON = "input-group-addon",
|
|
70
|
+
INPUT_GROUP_BUTTON = "input-group-button",
|
|
71
|
+
INPUT_GROUP_INPUT = "input-group-input",
|
|
72
|
+
INPUT_GROUP_TEXTAREA = "input-group-textarea",
|
|
73
|
+
LABEL = "label",
|
|
74
|
+
LOADER = "loader",
|
|
75
|
+
PROGRESS = "progress",
|
|
76
|
+
SEPARATOR = "separator",
|
|
77
|
+
SKELETON = "skeleton",
|
|
78
|
+
SWITCH = "switch",
|
|
79
|
+
TABLE = "table",
|
|
80
|
+
TABLE_HEADER = "table-header",
|
|
81
|
+
TABLE_BODY = "table-body",
|
|
82
|
+
TABLE_FOOTER = "table-footer",
|
|
83
|
+
TABLE_HEAD = "table-head",
|
|
84
|
+
TABLE_ROW = "table-row",
|
|
85
|
+
TABLE_CELL = "table-cell",
|
|
86
|
+
TABLE_CAPTION = "table-caption",
|
|
87
|
+
TEXTAREA = "textarea",
|
|
88
|
+
SIGNATURE = "signature",
|
|
89
|
+
EACH = "each",
|
|
90
|
+
IF = "if",
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export declare type ComponentCapability = "children" | "bindings" | "events" | "formField" | "ssr" | "pdf";
|
|
94
|
+
|
|
95
|
+
export declare interface ComponentDefinition {
|
|
96
|
+
component: ComponentType<any> | string;
|
|
97
|
+
propsSchema?: ZodType<any>;
|
|
98
|
+
capabilities?: ComponentCapability[];
|
|
99
|
+
controlled?: ControlledFieldSpec | Record<string, ControlledFieldSpec>;
|
|
100
|
+
assets?: {
|
|
101
|
+
css?: string[];
|
|
102
|
+
fonts?: string[];
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export declare const componentMap: Record<COMPONENT[number], any>;
|
|
107
|
+
|
|
108
|
+
export declare function composePropsSchema(baseSchema: z.ZodType<unknown> | undefined, tenantSchema: z.ZodType<unknown> | undefined): z.ZodType<unknown> | undefined;
|
|
109
|
+
|
|
110
|
+
export declare function computeManifestHash(raw: string): Promise<string>;
|
|
111
|
+
|
|
112
|
+
export declare const Config = pebbleTemplateSchema.Node;
|
|
113
|
+
|
|
114
|
+
export declare type Config = z.infer<typeof pebbleTemplateSchema.Node>;
|
|
115
|
+
|
|
116
|
+
export declare interface ControlledFieldSpec {
|
|
117
|
+
valueProp: string;
|
|
118
|
+
changeProp: string;
|
|
119
|
+
extract: (eventOrValue: unknown) => unknown;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare interface ControlledInput {
|
|
123
|
+
valueProp: string;
|
|
124
|
+
changeProp: string;
|
|
125
|
+
extractor: (eventOrValue: any) => any;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export declare const controlledInputMap: Record<COMPONENT[number], Record<string, ControlledInput> | ControlledInput>;
|
|
129
|
+
|
|
130
|
+
export declare function defineBonsaiRegistry(registry: BonsaiRegistry): BonsaiRegistry;
|
|
131
|
+
|
|
132
|
+
export declare function defineComponent(def: ComponentDefinition): ComponentDefinition;
|
|
133
|
+
|
|
134
|
+
export declare interface DriftCheckInput {
|
|
135
|
+
artifactRegistries: RegistrySource[];
|
|
136
|
+
configRegistries: RegistrySource[];
|
|
137
|
+
artifactBaseUiVersion: string;
|
|
138
|
+
installedBaseUiVersion: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export declare interface DriftIssue {
|
|
142
|
+
check: "stale-artifact" | "baseui-drift";
|
|
143
|
+
level: "warn" | "fail";
|
|
144
|
+
message: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export declare const EXTRACTOR_ALLOWLIST: Record<string, (eventOrValue: unknown) => unknown>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Compiles the JSON Schema subset a manifest's `propsSchema` is allowed to use into a
|
|
151
|
+
* Zod validator (REGISTRY_SPIKE.md, "Registry manifests": "JSON Schema on the wire;
|
|
152
|
+
* compiled to a Zod validator at load"). Deliberately a subset, not a general JSON
|
|
153
|
+
* Schema implementation — enough to express prop narrowing (type, enum, required,
|
|
154
|
+
* string/number bounds), which is the only thing a Case A manifest is allowed to do
|
|
155
|
+
* to a prop schema in the first place.
|
|
156
|
+
*/
|
|
157
|
+
export declare type JsonSchema = Record<string, unknown>;
|
|
158
|
+
|
|
159
|
+
export declare function jsonSchemaToZod(schema: JsonSchema): z.ZodType<unknown>;
|
|
160
|
+
|
|
161
|
+
export declare interface LoadManifestOptions extends ResolveManifestOptions {
|
|
162
|
+
allowedOrigins?: string[];
|
|
163
|
+
fetchImpl?: typeof fetch;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export declare function loadRegistryManifest(source: RegistryManifest | string, options: LoadManifestOptions): Promise<BonsaiRegistry>;
|
|
167
|
+
|
|
168
|
+
export declare type ManifestComponent = z.infer<typeof ManifestComponentSchema>;
|
|
169
|
+
|
|
170
|
+
declare const ManifestComponentSchema: z.ZodObject<{
|
|
171
|
+
name: z.ZodString;
|
|
172
|
+
canonicalName: z.ZodOptional<z.ZodString>;
|
|
173
|
+
entry: z.ZodString;
|
|
174
|
+
propsSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
175
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
176
|
+
children: "children";
|
|
177
|
+
pdf: "pdf";
|
|
178
|
+
bindings: "bindings";
|
|
179
|
+
events: "events";
|
|
180
|
+
formField: "formField";
|
|
181
|
+
ssr: "ssr";
|
|
182
|
+
}>>>;
|
|
183
|
+
controlled: z.ZodOptional<z.ZodObject<{
|
|
184
|
+
valueProp: z.ZodString;
|
|
185
|
+
changeProp: z.ZodString;
|
|
186
|
+
extract: z.ZodString;
|
|
187
|
+
}, z.core.$strict>>;
|
|
188
|
+
css: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
189
|
+
}, z.core.$strict>;
|
|
190
|
+
|
|
191
|
+
export declare class ManifestLoadError extends Error {
|
|
192
|
+
constructor(message: string);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export declare function mergeGeneratedWithOverrides(generated: ObjectPropsSchema | undefined, overrides: Partial<ObjectPropsSchema> | undefined): ObjectPropsSchema;
|
|
196
|
+
|
|
197
|
+
export declare interface ObjectPropsSchema {
|
|
198
|
+
type?: "object";
|
|
199
|
+
properties: Record<string, JsonSchema>;
|
|
200
|
+
required?: string[];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export declare const pebbleRegistry: BonsaiRegistry;
|
|
204
|
+
|
|
205
|
+
declare const pebbleTemplateSchema = createTemplateSchema(PEBBLE_COMPONENT_SCHEMAS);
|
|
206
|
+
|
|
207
|
+
export declare type PinResolution = {
|
|
208
|
+
action: "render";
|
|
209
|
+
reason: "no-pin";
|
|
210
|
+
} | {
|
|
211
|
+
action: "render";
|
|
212
|
+
reason: "match";
|
|
213
|
+
} | {
|
|
214
|
+
action: "render";
|
|
215
|
+
reason: "version-skew";
|
|
216
|
+
warning: string;
|
|
217
|
+
} | {
|
|
218
|
+
action: "fail";
|
|
219
|
+
reason: "id-mismatch";
|
|
220
|
+
error: string;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
declare type RegistryFallback = "error" | "div" | ComponentType<any>;
|
|
224
|
+
|
|
225
|
+
export declare interface RegistryIdentity {
|
|
226
|
+
id: string;
|
|
227
|
+
version: string;
|
|
228
|
+
manifestHash?: string;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export declare type RegistryManifest = z.infer<typeof RegistryManifestSchema>;
|
|
232
|
+
|
|
233
|
+
export declare const RegistryManifestSchema: z.ZodObject<{
|
|
234
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
235
|
+
id: z.ZodString;
|
|
236
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
237
|
+
version: z.ZodString;
|
|
238
|
+
engine: z.ZodObject<{
|
|
239
|
+
name: z.ZodLiteral<"bonsai">;
|
|
240
|
+
api: z.ZodString;
|
|
241
|
+
}, z.core.$strict>;
|
|
242
|
+
components: z.ZodArray<z.ZodObject<{
|
|
243
|
+
name: z.ZodString;
|
|
244
|
+
canonicalName: z.ZodOptional<z.ZodString>;
|
|
245
|
+
entry: z.ZodString;
|
|
246
|
+
propsSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
247
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
248
|
+
children: "children";
|
|
249
|
+
pdf: "pdf";
|
|
250
|
+
bindings: "bindings";
|
|
251
|
+
events: "events";
|
|
252
|
+
formField: "formField";
|
|
253
|
+
ssr: "ssr";
|
|
254
|
+
}>>>;
|
|
255
|
+
controlled: z.ZodOptional<z.ZodObject<{
|
|
256
|
+
valueProp: z.ZodString;
|
|
257
|
+
changeProp: z.ZodString;
|
|
258
|
+
extract: z.ZodString;
|
|
259
|
+
}, z.core.$strict>>;
|
|
260
|
+
css: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
261
|
+
}, z.core.$strict>>;
|
|
262
|
+
integrity: z.ZodOptional<z.ZodObject<{
|
|
263
|
+
algorithm: z.ZodLiteral<"sha256">;
|
|
264
|
+
manifestHash: z.ZodString;
|
|
265
|
+
}, z.core.$strict>>;
|
|
266
|
+
}, z.core.$strict>;
|
|
267
|
+
|
|
268
|
+
export declare interface RegistrySource {
|
|
269
|
+
url: string;
|
|
270
|
+
registryHash: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export declare interface RegistryValidationError {
|
|
274
|
+
path: string;
|
|
275
|
+
message: string;
|
|
276
|
+
componentType?: string;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export declare interface RegistryValidationResult {
|
|
280
|
+
valid: boolean;
|
|
281
|
+
errors: RegistryValidationError[];
|
|
282
|
+
warnings: string[];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export declare function resolveManifest(manifest: RegistryManifest, options: ResolveManifestOptions): BonsaiRegistry;
|
|
286
|
+
|
|
287
|
+
export declare interface ResolveManifestOptions {
|
|
288
|
+
base: BonsaiRegistry;
|
|
289
|
+
engineApi?: string;
|
|
290
|
+
maxComponents?: number;
|
|
291
|
+
maxManifestBytes?: number;
|
|
292
|
+
rawManifestSize?: number;
|
|
293
|
+
manifestHash?: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export declare function resolveRegistryPin(pin: RegistryIdentity | undefined, registry: Pick<BonsaiRegistry, "id" | "version"> & {
|
|
297
|
+
manifestHash?: string;
|
|
298
|
+
}): PinResolution;
|
|
299
|
+
|
|
300
|
+
export declare type SignatureProps = {
|
|
301
|
+
value?: string | null;
|
|
302
|
+
onChange?: (value: string | null) => void;
|
|
303
|
+
canvasClassname?: string;
|
|
304
|
+
imageType?: "image/png" | "image/jpeg" | "image/webp";
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
export declare function useUpdateData(): (path: string, value: any) => void;
|
|
308
|
+
|
|
309
|
+
export declare function validateTemplate(template: Config, registry: BonsaiRegistry, options?: ValidateTemplateOptions): RegistryValidationResult;
|
|
310
|
+
|
|
311
|
+
export declare interface ValidateTemplateOptions {
|
|
312
|
+
mode?: "web" | "pdf";
|
|
313
|
+
pin?: RegistryIdentity;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export { }
|