@glasshome/widget-sdk 0.2.5 → 0.3.3
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/define-widget.d.ts +2 -2
- package/dist/framework/dialogs/WidgetDialog.d.ts +5 -0
- package/dist/framework/fields.d.ts +16 -0
- package/dist/framework/index.d.ts +2 -0
- package/dist/framework/to-form-schema.d.ts +16 -0
- package/dist/index.js +819 -759
- package/dist/schemas.d.ts +17 -1
- package/dist/schemas.js +33 -17
- package/dist/version.d.ts +1 -5
- package/package.json +1 -1
package/dist/schemas.d.ts
CHANGED
|
@@ -25,7 +25,23 @@ export declare const WidgetManifestSchema: z.ZodObject<{
|
|
|
25
25
|
icon: z.ZodOptional<z.ZodString>;
|
|
26
26
|
schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
27
27
|
defaultConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
28
|
-
|
|
28
|
+
version: z.ZodOptional<z.ZodString>;
|
|
29
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
30
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
31
|
+
author: z.ZodOptional<z.ZodString>;
|
|
32
|
+
license: z.ZodOptional<z.ZodString>;
|
|
33
|
+
homepage: z.ZodOptional<z.ZodString>;
|
|
34
|
+
source: z.ZodOptional<z.ZodString>;
|
|
35
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
isOfficial: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
sha256Hash: z.ZodOptional<z.ZodString>;
|
|
38
|
+
bundleUrl: z.ZodOptional<z.ZodString>;
|
|
39
|
+
_registry: z.ZodOptional<z.ZodEnum<{
|
|
40
|
+
local: "local";
|
|
41
|
+
hub: "hub";
|
|
42
|
+
}>>;
|
|
43
|
+
releaseNotes: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$loose>;
|
|
29
45
|
export declare const PublishRequestSchema: z.ZodObject<{
|
|
30
46
|
action: z.ZodLiteral<"request">;
|
|
31
47
|
scope: z.ZodString;
|
package/dist/schemas.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z as n } from "zod";
|
|
|
2
2
|
const t = n.object({
|
|
3
3
|
w: n.number().int().min(1),
|
|
4
4
|
h: n.number().int().min(1)
|
|
5
|
-
}),
|
|
5
|
+
}), p = n.object({
|
|
6
6
|
name: n.string().min(1),
|
|
7
7
|
description: n.string().optional(),
|
|
8
8
|
minSize: t,
|
|
@@ -10,10 +10,26 @@ const t = n.object({
|
|
|
10
10
|
sdkVersion: n.string().min(1),
|
|
11
11
|
icon: n.string().optional(),
|
|
12
12
|
schema: n.record(n.string(), n.unknown()).optional(),
|
|
13
|
-
defaultConfig: n.record(n.string(), n.unknown()).optional()
|
|
14
|
-
|
|
13
|
+
defaultConfig: n.record(n.string(), n.unknown()).optional(),
|
|
14
|
+
// Round-trip fields set by the Hub / widget browser when installing. These
|
|
15
|
+
// must validate so real manifests stringified from WidgetRegistryEntry
|
|
16
|
+
// pass through the canonical schema without being stripped.
|
|
17
|
+
version: n.string().optional(),
|
|
18
|
+
displayName: n.string().optional(),
|
|
19
|
+
scope: n.string().optional(),
|
|
20
|
+
author: n.string().optional(),
|
|
21
|
+
license: n.string().optional(),
|
|
22
|
+
homepage: n.string().url().optional(),
|
|
23
|
+
source: n.string().url().optional(),
|
|
24
|
+
permissions: n.array(n.string()).optional(),
|
|
25
|
+
isOfficial: n.boolean().optional(),
|
|
26
|
+
sha256Hash: n.string().optional(),
|
|
27
|
+
bundleUrl: n.string().optional(),
|
|
28
|
+
_registry: n.enum(["hub", "local"]).optional(),
|
|
29
|
+
releaseNotes: n.string().optional()
|
|
30
|
+
}).passthrough(), r = /^[a-z0-9][a-z0-9-]*$/, a = n.object({
|
|
15
31
|
action: n.literal("request"),
|
|
16
|
-
scope: n.string().regex(
|
|
32
|
+
scope: n.string().regex(r, "Must be lowercase alphanumeric with hyphens"),
|
|
17
33
|
name: n.string().min(1),
|
|
18
34
|
displayName: n.string().min(1),
|
|
19
35
|
description: n.string().optional(),
|
|
@@ -28,36 +44,36 @@ const t = n.object({
|
|
|
28
44
|
}), c = n.object({
|
|
29
45
|
action: n.literal("confirm"),
|
|
30
46
|
versionId: n.string().min(1)
|
|
31
|
-
}),
|
|
47
|
+
}), m = n.discriminatedUnion("action", [
|
|
32
48
|
a,
|
|
33
49
|
c
|
|
34
50
|
]);
|
|
35
|
-
function
|
|
51
|
+
function g(i) {
|
|
36
52
|
return JSON.stringify(i);
|
|
37
53
|
}
|
|
38
|
-
function
|
|
54
|
+
function u(i, o = { w: 1, h: 1 }) {
|
|
39
55
|
if (i != null && typeof i == "object") {
|
|
40
56
|
const s = t.safeParse(i);
|
|
41
57
|
if (s.success) return s.data;
|
|
42
58
|
}
|
|
43
59
|
if (typeof i == "string")
|
|
44
60
|
try {
|
|
45
|
-
const s = JSON.parse(i),
|
|
46
|
-
if (
|
|
61
|
+
const s = JSON.parse(i), e = t.safeParse(s);
|
|
62
|
+
if (e.success) return e.data;
|
|
47
63
|
} catch {
|
|
48
64
|
}
|
|
49
|
-
return
|
|
65
|
+
return o;
|
|
50
66
|
}
|
|
51
|
-
function
|
|
52
|
-
return i.issues.map((
|
|
67
|
+
function h(i) {
|
|
68
|
+
return i.issues.map((o) => `${o.path.length > 0 ? o.path.join(".") : "(root)"}: ${o.message}`).join("; ");
|
|
53
69
|
}
|
|
54
70
|
export {
|
|
55
71
|
t as GridSizeSchema,
|
|
56
|
-
|
|
72
|
+
m as PublishBodySchema,
|
|
57
73
|
c as PublishConfirmSchema,
|
|
58
74
|
a as PublishRequestSchema,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
p as WidgetManifestSchema,
|
|
76
|
+
h as formatSchemaError,
|
|
77
|
+
u as parseGridSize,
|
|
78
|
+
g as serializeGridSize
|
|
63
79
|
};
|
package/dist/version.d.ts
CHANGED