@glassly/miniapp-cli 0.1.3 → 0.1.4-dev.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/package.json +1 -1
- package/schema/miniapp.schema.json +4 -7
- package/src/manifest.test.ts +11 -7
- package/src/manifest.ts +18 -11
- package/src/schema.test.ts +4 -3
- package/src/schema.ts +5 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glassly/miniapp-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-dev.0",
|
|
4
4
|
"description": "Build tooling for Glassly miniapps: dev server, packer, manifest validation, and JSON Schema. The `glassly` command that drives it ships in @glassly/cli.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -212,10 +212,11 @@
|
|
|
212
212
|
"XSM",
|
|
213
213
|
"SM",
|
|
214
214
|
"MD",
|
|
215
|
-
"LG"
|
|
215
|
+
"LG",
|
|
216
|
+
"EX"
|
|
216
217
|
]
|
|
217
218
|
},
|
|
218
|
-
"description": "The sizes the widget draws at, smallest first."
|
|
219
|
+
"description": "The card sizes the widget draws at, smallest first, plus EX when a tap may expand it to the full screen."
|
|
219
220
|
},
|
|
220
221
|
"defaultSize": {
|
|
221
222
|
"type": "string",
|
|
@@ -226,11 +227,7 @@
|
|
|
226
227
|
"MD",
|
|
227
228
|
"LG"
|
|
228
229
|
],
|
|
229
|
-
"description": "The size it takes when turned on; defaults to the first of sizes."
|
|
230
|
-
},
|
|
231
|
-
"expandable": {
|
|
232
|
-
"type": "boolean",
|
|
233
|
-
"description": "A tap on the selected widget expands it to the full screen instead of activating the card."
|
|
230
|
+
"description": "The card size it takes when turned on; defaults to the first of sizes."
|
|
234
231
|
}
|
|
235
232
|
}
|
|
236
233
|
}
|
package/src/manifest.test.ts
CHANGED
|
@@ -375,28 +375,32 @@ describe('validateManifest', () => {
|
|
|
375
375
|
});
|
|
376
376
|
|
|
377
377
|
describe('widgets', () => {
|
|
378
|
-
test('accepts XSM and
|
|
378
|
+
test('accepts XSM and EX', () => {
|
|
379
379
|
const {valid, errors} = validateManifest({
|
|
380
380
|
...minimalValid,
|
|
381
381
|
widgets: [
|
|
382
|
-
{id: 'now_playing', name: 'Now Playing', sizes: ['XSM', 'SM', 'MD'], defaultSize: 'XSM'
|
|
383
|
-
{id: 'chip', name: 'Chip', sizes: ['XS']
|
|
382
|
+
{id: 'now_playing', name: 'Now Playing', sizes: ['XSM', 'SM', 'MD', 'EX'], defaultSize: 'XSM'},
|
|
383
|
+
{id: 'chip', name: 'Chip', sizes: ['XS']},
|
|
384
384
|
],
|
|
385
385
|
});
|
|
386
386
|
expect(valid).toBe(true);
|
|
387
387
|
expect(errors).toEqual([]);
|
|
388
388
|
});
|
|
389
389
|
|
|
390
|
-
test('rejects an unknown size and
|
|
390
|
+
test('rejects an unknown size, EX alone or as the default, and the old expandable flag', () => {
|
|
391
391
|
const {errors} = validateManifest({
|
|
392
392
|
...minimalValid,
|
|
393
393
|
widgets: [
|
|
394
394
|
{id: 'a', name: 'A', sizes: ['XL']},
|
|
395
|
-
{id: 'b', name: 'B', sizes: ['SM'], expandable:
|
|
395
|
+
{id: 'b', name: 'B', sizes: ['SM'], expandable: true},
|
|
396
|
+
{id: 'c', name: 'C', sizes: ['EX']},
|
|
397
|
+
{id: 'd', name: 'D', sizes: ['SM', 'EX'], defaultSize: 'EX'},
|
|
396
398
|
],
|
|
397
399
|
});
|
|
398
|
-
expect(errors.some((e) => e.includes('widgets[0].sizes must be a non-empty array of XS | XSM | SM | MD | LG'))).toBe(true);
|
|
399
|
-
expect(errors.some((e) => e.includes('widgets[1].expandable
|
|
400
|
+
expect(errors.some((e) => e.includes('widgets[0].sizes must be a non-empty array of XS | XSM | SM | MD | LG | EX'))).toBe(true);
|
|
401
|
+
expect(errors.some((e) => e.includes('widgets[1].expandable is gone'))).toBe(true);
|
|
402
|
+
expect(errors.some((e) => e.includes('widgets[2].sizes needs a card size besides EX'))).toBe(true);
|
|
403
|
+
expect(errors.some((e) => e.includes('widgets[3].defaultSize must be one of its card sizes'))).toBe(true);
|
|
400
404
|
});
|
|
401
405
|
});
|
|
402
406
|
});
|
package/src/manifest.ts
CHANGED
|
@@ -68,8 +68,10 @@ export interface ManifestAction {
|
|
|
68
68
|
outputSchema?: Record<string, unknown>;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export const WIDGET_SIZES = ['XS', 'XSM', 'SM', 'MD', 'LG'] as const;
|
|
71
|
+
export const WIDGET_SIZES = ['XS', 'XSM', 'SM', 'MD', 'LG', 'EX'] as const;
|
|
72
72
|
export type WidgetSize = (typeof WIDGET_SIZES)[number];
|
|
73
|
+
/** `EX` is the full-screen view a tap expands the widget to, not a card size. */
|
|
74
|
+
export const CARD_WIDGET_SIZES = WIDGET_SIZES.filter((size) => size !== 'EX');
|
|
73
75
|
|
|
74
76
|
/**
|
|
75
77
|
* A dashboard widget this miniapp provides through session.widgets. The
|
|
@@ -81,12 +83,15 @@ export interface ManifestWidget {
|
|
|
81
83
|
id: string;
|
|
82
84
|
/** Shown on the dashboard's Widgets page. */
|
|
83
85
|
name: string;
|
|
84
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* The card sizes the widget draws at, smallest first, at least one; plus
|
|
88
|
+
* `EX` when a tap may expand it to the full screen. The wearer can turn
|
|
89
|
+
* expansion off on the miniapp's settings page, the miniapp with
|
|
90
|
+
* `setExpandable`.
|
|
91
|
+
*/
|
|
85
92
|
sizes: WidgetSize[];
|
|
86
|
-
/** The size it takes when turned on; defaults to the first of `sizes`. */
|
|
87
|
-
defaultSize?: WidgetSize
|
|
88
|
-
/** A tap on the selected widget expands it to the full screen instead of activating the card. */
|
|
89
|
-
expandable?: boolean;
|
|
93
|
+
/** The card size it takes when turned on; defaults to the first of `sizes`. */
|
|
94
|
+
defaultSize?: Exclude<WidgetSize, 'EX'>;
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
export interface MiniappManifestV1 {
|
|
@@ -399,7 +404,7 @@ export function validateManifest(manifest: unknown): { valid: boolean; errors: s
|
|
|
399
404
|
// widgets the miniapp serves through session.widgets.provide.
|
|
400
405
|
if (m.widgets !== undefined) {
|
|
401
406
|
if (!Array.isArray(m.widgets)) {
|
|
402
|
-
errors.push('widgets must be an array of {id, name, sizes, defaultSize
|
|
407
|
+
errors.push('widgets must be an array of {id, name, sizes, defaultSize?} objects');
|
|
403
408
|
} else {
|
|
404
409
|
const seenIds = new Set<string>();
|
|
405
410
|
m.widgets.forEach((widget, i) => {
|
|
@@ -427,11 +432,13 @@ export function validateManifest(manifest: unknown): { valid: boolean; errors: s
|
|
|
427
432
|
errors.push(`widgets[${i}].sizes must be a non-empty array of ${WIDGET_SIZES.join(' | ')}`);
|
|
428
433
|
} else if (new Set(sizes).size !== sizes.length) {
|
|
429
434
|
errors.push(`widgets[${i}].sizes must not repeat a size`);
|
|
430
|
-
} else if (
|
|
431
|
-
errors.push(`widgets[${i}].
|
|
435
|
+
} else if (!sizes.some((size) => size !== 'EX')) {
|
|
436
|
+
errors.push(`widgets[${i}].sizes needs a card size besides EX`);
|
|
437
|
+
} else if (w.defaultSize !== undefined && (w.defaultSize === 'EX' || !sizes.includes(w.defaultSize))) {
|
|
438
|
+
errors.push(`widgets[${i}].defaultSize must be one of its card sizes`);
|
|
432
439
|
}
|
|
433
|
-
if (w.expandable !== undefined
|
|
434
|
-
errors.push(`widgets[${i}].expandable
|
|
440
|
+
if (w.expandable !== undefined) {
|
|
441
|
+
errors.push(`widgets[${i}].expandable is gone: list "EX" in sizes instead`);
|
|
435
442
|
}
|
|
436
443
|
});
|
|
437
444
|
}
|
package/src/schema.test.ts
CHANGED
|
@@ -47,11 +47,12 @@ describe('generateSchema', () => {
|
|
|
47
47
|
expect(re.test('Productivity')).toBe(false);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
test('widgets offer XSM and a
|
|
50
|
+
test('widgets offer XSM and EX; EX is never a default', () => {
|
|
51
51
|
const schema = generateSchema() as any;
|
|
52
52
|
const props = schema.properties.widgets.items.properties;
|
|
53
|
-
expect(props.sizes.items.enum).toEqual(['XS', 'XSM', 'SM', 'MD', 'LG']);
|
|
54
|
-
expect(props.
|
|
53
|
+
expect(props.sizes.items.enum).toEqual(['XS', 'XSM', 'SM', 'MD', 'LG', 'EX']);
|
|
54
|
+
expect(props.defaultSize.enum).toEqual(['XS', 'XSM', 'SM', 'MD', 'LG']);
|
|
55
|
+
expect(props.expandable).toBeUndefined();
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
test('top-level allows extras for forward-compat', () => {
|
package/src/schema.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
ALLOWED_HARDWARE_TYPES,
|
|
23
23
|
ALLOWED_HARDWARE_LEVELS,
|
|
24
24
|
ALLOWED_ACTION_PARAM_TYPES,
|
|
25
|
+
CARD_WIDGET_SIZES,
|
|
25
26
|
KNOWN_TAGS,
|
|
26
27
|
TAGLINE_MAX_LENGTH,
|
|
27
28
|
TAGS_MAX_COUNT,
|
|
@@ -190,16 +191,13 @@ export function generateSchema(): Record<string, unknown> {
|
|
|
190
191
|
minItems: 1,
|
|
191
192
|
uniqueItems: true,
|
|
192
193
|
items: {type: 'string', enum: [...WIDGET_SIZES]},
|
|
193
|
-
description:
|
|
194
|
+
description:
|
|
195
|
+
'The card sizes the widget draws at, smallest first, plus EX when a tap may expand it to the full screen.',
|
|
194
196
|
},
|
|
195
197
|
defaultSize: {
|
|
196
198
|
type: 'string',
|
|
197
|
-
enum: [...
|
|
198
|
-
description: 'The size it takes when turned on; defaults to the first of sizes.',
|
|
199
|
-
},
|
|
200
|
-
expandable: {
|
|
201
|
-
type: 'boolean',
|
|
202
|
-
description: 'A tap on the selected widget expands it to the full screen instead of activating the card.',
|
|
199
|
+
enum: [...CARD_WIDGET_SIZES],
|
|
200
|
+
description: 'The card size it takes when turned on; defaults to the first of sizes.',
|
|
203
201
|
},
|
|
204
202
|
},
|
|
205
203
|
},
|