@westopp/windo 0.1.0 → 0.1.1
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 +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -7
- package/dist/index.d.ts +15 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/client/App.tsx +36 -3
- package/src/client/Canvas.tsx +8 -3
- package/src/client/Sidebar.tsx +13 -3
- package/src/client/TagFilter.tsx +125 -0
- package/src/client/bridge.ts +3 -0
- package/src/client/chrome.css +247 -7
- package/src/client/internal-types.ts +12 -0
- package/src/define-config.ts +12 -8
- package/src/preview/index.ts +3 -0
- package/src/protocol.ts +1 -0
- package/src/types.ts +10 -3
- package/src/descriptor.test.ts +0 -59
package/src/descriptor.test.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
import { describeSchema } from './descriptor'
|
|
4
|
-
import type { WindoControlDescriptor } from './types'
|
|
5
|
-
|
|
6
|
-
function field(fields: WindoControlDescriptor[], key: string): WindoControlDescriptor {
|
|
7
|
-
const found = fields.find(f => f.key === key)
|
|
8
|
-
if (!found) throw new Error(`no field "${key}"`)
|
|
9
|
-
return found
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
describe('describeSchema', () => {
|
|
13
|
-
it('returns no fields for a missing schema', () => {
|
|
14
|
-
expect(describeSchema(undefined).fields).toEqual([])
|
|
15
|
-
expect(describeSchema(null).fields).toEqual([])
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('describes a z.enum as kind enum with the right options', () => {
|
|
19
|
-
const { fields } = describeSchema(z.object({ variant: z.enum(['primary', 'secondary', 'ghost']) }))
|
|
20
|
-
const variant = field(fields, 'variant')
|
|
21
|
-
expect(variant.kind).toBe('enum')
|
|
22
|
-
expect(variant.options).toEqual(['primary', 'secondary', 'ghost'])
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('describes a z.boolean as kind boolean', () => {
|
|
26
|
-
const { fields } = describeSchema(z.object({ disabled: z.boolean() }))
|
|
27
|
-
expect(field(fields, 'disabled').kind).toBe('boolean')
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('describes a bounded z.number with min and max', () => {
|
|
31
|
-
const { fields } = describeSchema(z.object({ count: z.number().min(0).max(10) }))
|
|
32
|
-
const count = field(fields, 'count')
|
|
33
|
-
expect(count.kind).toBe('number')
|
|
34
|
-
expect(count.min).toBe(0)
|
|
35
|
-
expect(count.max).toBe(10)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('marks an optional field as optional', () => {
|
|
39
|
-
const { fields } = describeSchema(z.object({ label: z.string().optional() }))
|
|
40
|
-
const label = field(fields, 'label')
|
|
41
|
-
expect(label.kind).toBe('string')
|
|
42
|
-
expect(label.optional).toBe(true)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('marks a required field as not optional', () => {
|
|
46
|
-
const { fields } = describeSchema(z.object({ label: z.string() }))
|
|
47
|
-
expect(field(fields, 'label').optional).toBe(false)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('describes a z.coerce.date as kind date', () => {
|
|
51
|
-
const { fields } = describeSchema(z.object({ when: z.coerce.date() }))
|
|
52
|
-
expect(field(fields, 'when').kind).toBe('date')
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('describes a z.array as kind array', () => {
|
|
56
|
-
const { fields } = describeSchema(z.object({ tags: z.array(z.string()) }))
|
|
57
|
-
expect(field(fields, 'tags').kind).toBe('array')
|
|
58
|
-
})
|
|
59
|
-
})
|