@glassly/miniapp-cli 0.1.2 → 0.1.3-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 +6 -0
- package/src/manifest.test.ts +26 -0
- package/src/manifest.ts +7 -2
- package/src/schema.test.ts +7 -0
- package/src/schema.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glassly/miniapp-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3-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": {
|
|
@@ -209,6 +209,7 @@
|
|
|
209
209
|
"type": "string",
|
|
210
210
|
"enum": [
|
|
211
211
|
"XS",
|
|
212
|
+
"XSM",
|
|
212
213
|
"SM",
|
|
213
214
|
"MD",
|
|
214
215
|
"LG"
|
|
@@ -220,11 +221,16 @@
|
|
|
220
221
|
"type": "string",
|
|
221
222
|
"enum": [
|
|
222
223
|
"XS",
|
|
224
|
+
"XSM",
|
|
223
225
|
"SM",
|
|
224
226
|
"MD",
|
|
225
227
|
"LG"
|
|
226
228
|
],
|
|
227
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."
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
}
|
package/src/manifest.test.ts
CHANGED
|
@@ -373,4 +373,30 @@ describe('validateManifest', () => {
|
|
|
373
373
|
expect(errors.some((e) => e.includes('tags must be an array'))).toBe(true);
|
|
374
374
|
});
|
|
375
375
|
});
|
|
376
|
+
|
|
377
|
+
describe('widgets', () => {
|
|
378
|
+
test('accepts XSM and a boolean expandable', () => {
|
|
379
|
+
const {valid, errors} = validateManifest({
|
|
380
|
+
...minimalValid,
|
|
381
|
+
widgets: [
|
|
382
|
+
{id: 'now_playing', name: 'Now Playing', sizes: ['XSM', 'SM', 'MD'], defaultSize: 'XSM', expandable: true},
|
|
383
|
+
{id: 'chip', name: 'Chip', sizes: ['XS'], expandable: false},
|
|
384
|
+
],
|
|
385
|
+
});
|
|
386
|
+
expect(valid).toBe(true);
|
|
387
|
+
expect(errors).toEqual([]);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
test('rejects an unknown size and a non-boolean expandable', () => {
|
|
391
|
+
const {errors} = validateManifest({
|
|
392
|
+
...minimalValid,
|
|
393
|
+
widgets: [
|
|
394
|
+
{id: 'a', name: 'A', sizes: ['XL']},
|
|
395
|
+
{id: 'b', name: 'B', sizes: ['SM'], expandable: 'yes'},
|
|
396
|
+
],
|
|
397
|
+
});
|
|
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 must be a boolean'))).toBe(true);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
376
402
|
});
|
package/src/manifest.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface ManifestAction {
|
|
|
68
68
|
outputSchema?: Record<string, unknown>;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export const WIDGET_SIZES = ['XS', 'SM', 'MD', 'LG'] as const;
|
|
71
|
+
export const WIDGET_SIZES = ['XS', 'XSM', 'SM', 'MD', 'LG'] as const;
|
|
72
72
|
export type WidgetSize = (typeof WIDGET_SIZES)[number];
|
|
73
73
|
|
|
74
74
|
/**
|
|
@@ -85,6 +85,8 @@ export interface ManifestWidget {
|
|
|
85
85
|
sizes: WidgetSize[];
|
|
86
86
|
/** The size it takes when turned on; defaults to the first of `sizes`. */
|
|
87
87
|
defaultSize?: WidgetSize;
|
|
88
|
+
/** A tap on the selected widget expands it to the full screen instead of activating the card. */
|
|
89
|
+
expandable?: boolean;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
export interface MiniappManifestV1 {
|
|
@@ -397,7 +399,7 @@ export function validateManifest(manifest: unknown): { valid: boolean; errors: s
|
|
|
397
399
|
// widgets the miniapp serves through session.widgets.provide.
|
|
398
400
|
if (m.widgets !== undefined) {
|
|
399
401
|
if (!Array.isArray(m.widgets)) {
|
|
400
|
-
errors.push('widgets must be an array of {id, name, sizes, defaultSize?} objects');
|
|
402
|
+
errors.push('widgets must be an array of {id, name, sizes, defaultSize?, expandable?} objects');
|
|
401
403
|
} else {
|
|
402
404
|
const seenIds = new Set<string>();
|
|
403
405
|
m.widgets.forEach((widget, i) => {
|
|
@@ -428,6 +430,9 @@ export function validateManifest(manifest: unknown): { valid: boolean; errors: s
|
|
|
428
430
|
} else if (w.defaultSize !== undefined && !sizes.includes(w.defaultSize)) {
|
|
429
431
|
errors.push(`widgets[${i}].defaultSize must be one of its sizes`);
|
|
430
432
|
}
|
|
433
|
+
if (w.expandable !== undefined && typeof w.expandable !== 'boolean') {
|
|
434
|
+
errors.push(`widgets[${i}].expandable must be a boolean`);
|
|
435
|
+
}
|
|
431
436
|
});
|
|
432
437
|
}
|
|
433
438
|
}
|
package/src/schema.test.ts
CHANGED
|
@@ -47,6 +47,13 @@ describe('generateSchema', () => {
|
|
|
47
47
|
expect(re.test('Productivity')).toBe(false);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
test('widgets offer XSM and a boolean expandable', () => {
|
|
51
|
+
const schema = generateSchema() as any;
|
|
52
|
+
const props = schema.properties.widgets.items.properties;
|
|
53
|
+
expect(props.sizes.items.enum).toEqual(['XS', 'XSM', 'SM', 'MD', 'LG']);
|
|
54
|
+
expect(props.expandable.type).toBe('boolean');
|
|
55
|
+
});
|
|
56
|
+
|
|
50
57
|
test('top-level allows extras for forward-compat', () => {
|
|
51
58
|
const schema = generateSchema() as any;
|
|
52
59
|
expect(schema.additionalProperties).toBe(true);
|
package/src/schema.ts
CHANGED
|
@@ -197,6 +197,10 @@ export function generateSchema(): Record<string, unknown> {
|
|
|
197
197
|
enum: [...WIDGET_SIZES],
|
|
198
198
|
description: 'The size it takes when turned on; defaults to the first of sizes.',
|
|
199
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.',
|
|
203
|
+
},
|
|
200
204
|
},
|
|
201
205
|
},
|
|
202
206
|
},
|