@algomotion/spec 0.0.0-stage → 1.0.0-alpha.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/LICENSE +675 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/common.d.ts +136 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +181 -0
- package/dist/common.js.map +1 -0
- package/dist/errors.d.ts +71 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +43 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema.d.ts +3 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +16 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/kinds/array.d.ts +171 -0
- package/dist/kinds/array.d.ts.map +1 -0
- package/dist/kinds/array.js +179 -0
- package/dist/kinds/array.js.map +1 -0
- package/dist/kinds/btree.d.ts +190 -0
- package/dist/kinds/btree.d.ts.map +1 -0
- package/dist/kinds/btree.js +274 -0
- package/dist/kinds/btree.js.map +1 -0
- package/dist/kinds/graph.d.ts +227 -0
- package/dist/kinds/graph.d.ts.map +1 -0
- package/dist/kinds/graph.js +229 -0
- package/dist/kinds/graph.js.map +1 -0
- package/dist/kinds/hash-table.d.ts +108 -0
- package/dist/kinds/hash-table.d.ts.map +1 -0
- package/dist/kinds/hash-table.js +133 -0
- package/dist/kinds/hash-table.js.map +1 -0
- package/dist/kinds/index.d.ts +98 -0
- package/dist/kinds/index.d.ts.map +1 -0
- package/dist/kinds/index.js +53 -0
- package/dist/kinds/index.js.map +1 -0
- package/dist/kinds/kind.d.ts +73 -0
- package/dist/kinds/kind.d.ts.map +1 -0
- package/dist/kinds/kind.js +4 -0
- package/dist/kinds/kind.js.map +1 -0
- package/dist/kinds/linear.d.ts +24 -0
- package/dist/kinds/linear.d.ts.map +1 -0
- package/dist/kinds/linear.js +26 -0
- package/dist/kinds/linear.js.map +1 -0
- package/dist/kinds/linked-list.d.ts +132 -0
- package/dist/kinds/linked-list.d.ts.map +1 -0
- package/dist/kinds/linked-list.js +95 -0
- package/dist/kinds/linked-list.js.map +1 -0
- package/dist/kinds/plane.d.ts +190 -0
- package/dist/kinds/plane.d.ts.map +1 -0
- package/dist/kinds/plane.js +206 -0
- package/dist/kinds/plane.js.map +1 -0
- package/dist/kinds/priority-queue.d.ts +120 -0
- package/dist/kinds/priority-queue.d.ts.map +1 -0
- package/dist/kinds/priority-queue.js +108 -0
- package/dist/kinds/priority-queue.js.map +1 -0
- package/dist/kinds/queue.d.ts +94 -0
- package/dist/kinds/queue.d.ts.map +1 -0
- package/dist/kinds/queue.js +59 -0
- package/dist/kinds/queue.js.map +1 -0
- package/dist/kinds/stack.d.ts +70 -0
- package/dist/kinds/stack.d.ts.map +1 -0
- package/dist/kinds/stack.js +50 -0
- package/dist/kinds/stack.js.map +1 -0
- package/dist/kinds/table.d.ts +65 -0
- package/dist/kinds/table.d.ts.map +1 -0
- package/dist/kinds/table.js +116 -0
- package/dist/kinds/table.js.map +1 -0
- package/dist/kinds/tree.d.ts +272 -0
- package/dist/kinds/tree.d.ts.map +1 -0
- package/dist/kinds/tree.js +380 -0
- package/dist/kinds/tree.js.map +1 -0
- package/dist/parse.d.ts +26 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +380 -0
- package/dist/parse.js.map +1 -0
- package/dist/result.d.ts +16 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +3 -0
- package/dist/result.js.map +1 -0
- package/dist/share.d.ts +68 -0
- package/dist/share.d.ts.map +1 -0
- package/dist/share.js +319 -0
- package/dist/share.js.map +1 -0
- package/dist/version.d.ts +108 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +167 -0
- package/dist/version.js.map +1 -0
- package/dist/visualization.d.ts +3591 -0
- package/dist/visualization.d.ts.map +1 -0
- package/dist/visualization.js +131 -0
- package/dist/visualization.js.map +1 -0
- package/package.json +45 -4
- package/schema/visualization.schema.json +5717 -0
- package/README.md +0 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `stack` kind: last in, first out. Positions count from the bottom (0).
|
|
3
|
+
*
|
|
4
|
+
* Marks: `highlight` and `peek` last one step.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { type KindSpec } from './kind.ts';
|
|
8
|
+
export declare const StackDecl: z.ZodObject<{
|
|
9
|
+
kind: z.ZodLiteral<"stack">;
|
|
10
|
+
label: z.ZodOptional<z.ZodString>;
|
|
11
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
main: "main";
|
|
13
|
+
side: "side";
|
|
14
|
+
}>>;
|
|
15
|
+
initial: z.ZodArray<z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
18
|
+
}, z.core.$strict>>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export type StackDecl = z.infer<typeof StackDecl>;
|
|
21
|
+
export declare const StackDeclInput: z.ZodObject<{
|
|
22
|
+
kind: z.ZodLiteral<"stack">;
|
|
23
|
+
label: z.ZodOptional<z.ZodString>;
|
|
24
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
main: "main";
|
|
26
|
+
side: "side";
|
|
27
|
+
}>>;
|
|
28
|
+
initial: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
31
|
+
}, z.core.$strict>>, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>]>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
export type StackDeclInput = z.infer<typeof StackDeclInput>;
|
|
34
|
+
export declare const StackAction: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<"push">;
|
|
36
|
+
element: z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
41
|
+
type: z.ZodLiteral<"pop">;
|
|
42
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<"peek">;
|
|
44
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
45
|
+
type: z.ZodLiteral<"highlight">;
|
|
46
|
+
indices: z.ZodArray<z.ZodInt>;
|
|
47
|
+
}, z.core.$strict>], "type">;
|
|
48
|
+
export type StackAction = z.infer<typeof StackAction>;
|
|
49
|
+
export declare const StackActionInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
50
|
+
type: z.ZodLiteral<"push">;
|
|
51
|
+
element: z.ZodUnion<readonly [z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
54
|
+
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>]>;
|
|
55
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"pop">;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<"peek">;
|
|
59
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"highlight">;
|
|
61
|
+
indices: z.ZodArray<z.ZodInt>;
|
|
62
|
+
}, z.core.$strict>], "type">;
|
|
63
|
+
export type StackActionInput = z.infer<typeof StackActionInput>;
|
|
64
|
+
export declare const stackSpec: KindSpec<{
|
|
65
|
+
decl: StackDecl;
|
|
66
|
+
declInput: StackDeclInput;
|
|
67
|
+
action: StackAction;
|
|
68
|
+
actionInput: StackActionInput;
|
|
69
|
+
}>;
|
|
70
|
+
//# sourceMappingURL=stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../src/kinds/stack.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAWnD,eAAO,MAAM,SAAS;;;;;;;;;;;kBAOsB,CAAC;AAC7C,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc;;;;;;;;;;;kBAA+C,CAAC;AAC3E,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAoB5D,eAAO,MAAM,WAAW;;;;;;;;;;;;;4BAAmB,CAAC;AAC5C,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACtD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;4BAAwB,CAAC;AACtD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,cAAc,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,gBAAgB,CAAC;CAC/B,CAgBA,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `stack` kind: last in, first out. Positions count from the bottom (0).
|
|
3
|
+
*
|
|
4
|
+
* Marks: `highlight` and `peek` last one step.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { Element, ElementInput, LIMITS, Place } from "../common.js";
|
|
8
|
+
import { typesOf } from "./kind.js";
|
|
9
|
+
import { elementFieldIds, elementIds, Elements, ElementsInput, Indices, normalizeElementField, normalizeElements, } from "./linear.js";
|
|
10
|
+
export const StackDecl = z
|
|
11
|
+
.strictObject({
|
|
12
|
+
kind: z.literal('stack'),
|
|
13
|
+
label: z.string().max(LIMITS.textLength).optional(),
|
|
14
|
+
place: Place.optional(),
|
|
15
|
+
initial: Elements.describe('Elements from bottom to top.'),
|
|
16
|
+
})
|
|
17
|
+
.describe('A stack (last in, first out).');
|
|
18
|
+
export const StackDeclInput = StackDecl.extend({ initial: ElementsInput });
|
|
19
|
+
const actions = (element) => z.discriminatedUnion('type', [
|
|
20
|
+
z
|
|
21
|
+
.strictObject({ type: z.literal('push'), element })
|
|
22
|
+
.describe('Push `element` on top.'),
|
|
23
|
+
z
|
|
24
|
+
.strictObject({ type: z.literal('pop') })
|
|
25
|
+
.describe('Remove the top element.'),
|
|
26
|
+
z
|
|
27
|
+
.strictObject({ type: z.literal('peek') })
|
|
28
|
+
.describe('Highlight the top element (this step only).'),
|
|
29
|
+
z
|
|
30
|
+
.strictObject({ type: z.literal('highlight'), indices: Indices })
|
|
31
|
+
.describe('Highlight positions counted from the bottom (this step only).'),
|
|
32
|
+
]);
|
|
33
|
+
export const StackAction = actions(Element);
|
|
34
|
+
export const StackActionInput = actions(ElementInput);
|
|
35
|
+
export const stackSpec = {
|
|
36
|
+
kind: 'stack',
|
|
37
|
+
decl: StackDecl,
|
|
38
|
+
declInput: StackDeclInput,
|
|
39
|
+
action: StackAction,
|
|
40
|
+
actionInput: StackActionInput,
|
|
41
|
+
actionTypes: typesOf(StackAction),
|
|
42
|
+
normalizeDecl: (input) => ({
|
|
43
|
+
...input,
|
|
44
|
+
initial: normalizeElements(input.initial),
|
|
45
|
+
}),
|
|
46
|
+
declIds: (decl) => elementIds(decl.initial),
|
|
47
|
+
normalizeAction: (action, ctx) => normalizeElementField(action, ctx),
|
|
48
|
+
introducedIds: (action) => action.type === 'push' ? elementFieldIds(action) : [],
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../src/kinds/stack.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,OAAO,EAAiB,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,aAAa,EACb,OAAO,EACP,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC;KACvB,YAAY,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;IACnD,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE;IACvB,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,8BAA8B,CAAC;CAC3D,CAAC;KACD,QAAQ,CAAC,+BAA+B,CAAC,CAAC;AAG7C,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;AAG3E,MAAM,OAAO,GAAG,CAAsB,OAAU,EAAE,EAAE,CAClD,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC3B,CAAC;SACE,YAAY,CAAC,EAAE,IAAI,EAAE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B,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;CACxD,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `table` kind: a grid of cells, for dynamic programming (LCS, edit
|
|
3
|
+
* distance, knapsack, Floyd–Warshall) and adjacency matrices.
|
|
4
|
+
*
|
|
5
|
+
* Cells are addressed as `[row, column]`. A null cell is drawn empty.
|
|
6
|
+
*
|
|
7
|
+
* Marks: `highlight` and `depend` last one step; `settle` persists until
|
|
8
|
+
* `resetMarks`.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { type KindSpec } from './kind.ts';
|
|
12
|
+
export declare const Cell: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
13
|
+
export type Cell = z.infer<typeof Cell>;
|
|
14
|
+
export declare const TableDecl: z.ZodObject<{
|
|
15
|
+
kind: z.ZodLiteral<"table">;
|
|
16
|
+
label: z.ZodOptional<z.ZodString>;
|
|
17
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
18
|
+
main: "main";
|
|
19
|
+
side: "side";
|
|
20
|
+
}>>;
|
|
21
|
+
cells: z.ZodArray<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>>;
|
|
22
|
+
rowLabels: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>>;
|
|
23
|
+
columnLabels: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>>;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export type TableDecl = z.infer<typeof TableDecl>;
|
|
26
|
+
export declare const TableDeclInput: z.ZodObject<{
|
|
27
|
+
kind: z.ZodLiteral<"table">;
|
|
28
|
+
label: z.ZodOptional<z.ZodString>;
|
|
29
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
30
|
+
main: "main";
|
|
31
|
+
side: "side";
|
|
32
|
+
}>>;
|
|
33
|
+
rows: z.ZodOptional<z.ZodInt>;
|
|
34
|
+
columns: z.ZodOptional<z.ZodInt>;
|
|
35
|
+
initial: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>>>;
|
|
36
|
+
rowLabels: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>>;
|
|
37
|
+
columnLabels: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>>;
|
|
38
|
+
cells: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>>>;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
export type TableDeclInput = z.infer<typeof TableDeclInput>;
|
|
41
|
+
export declare const TableAction: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
42
|
+
type: z.ZodLiteral<"set">;
|
|
43
|
+
cell: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
44
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
45
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
46
|
+
type: z.ZodLiteral<"highlight">;
|
|
47
|
+
cells: z.ZodArray<z.ZodTuple<[z.ZodInt, z.ZodInt], null>>;
|
|
48
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
49
|
+
type: z.ZodLiteral<"depend">;
|
|
50
|
+
cell: z.ZodTuple<[z.ZodInt, z.ZodInt], null>;
|
|
51
|
+
on: z.ZodArray<z.ZodTuple<[z.ZodInt, z.ZodInt], null>>;
|
|
52
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"settle">;
|
|
54
|
+
cells: z.ZodArray<z.ZodTuple<[z.ZodInt, z.ZodInt], null>>;
|
|
55
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"resetMarks">;
|
|
57
|
+
}, z.core.$strict>], "type">;
|
|
58
|
+
export type TableAction = z.infer<typeof TableAction>;
|
|
59
|
+
export declare const tableSpec: KindSpec<{
|
|
60
|
+
decl: TableDecl;
|
|
61
|
+
declInput: TableDeclInput;
|
|
62
|
+
action: TableAction;
|
|
63
|
+
actionInput: TableAction;
|
|
64
|
+
}>;
|
|
65
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/kinds/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAMnE,eAAO,MAAM,IAAI,wCAEmC,CAAC;AACrD,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAWxC,eAAO,MAAM,SAAS;;;;;;;;;;kBASC,CAAC;AACxB,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc;;;;;;;;;;;;;kBA4BxB,CAAC;AACJ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAqC5D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;4BAoBtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,cAAc,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAYA,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `table` kind: a grid of cells, for dynamic programming (LCS, edit
|
|
3
|
+
* distance, knapsack, Floyd–Warshall) and adjacency matrices.
|
|
4
|
+
*
|
|
5
|
+
* Cells are addressed as `[row, column]`. A null cell is drawn empty.
|
|
6
|
+
*
|
|
7
|
+
* Marks: `highlight` and `depend` last one step; `settle` persists until
|
|
8
|
+
* `resetMarks`.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { Index, LIMITS, Place, Scalar } from "../common.js";
|
|
12
|
+
import { typesOf } from "./kind.js";
|
|
13
|
+
const Labels = z
|
|
14
|
+
.array(Scalar)
|
|
15
|
+
.max(Math.max(LIMITS.tableRows, LIMITS.tableColumns));
|
|
16
|
+
export const Cell = z
|
|
17
|
+
.tuple([Index, Index])
|
|
18
|
+
.describe('A cell as [row, column], both from 0.');
|
|
19
|
+
const Cells = z
|
|
20
|
+
.array(Cell)
|
|
21
|
+
.min(1)
|
|
22
|
+
.max(LIMITS.tableRows * LIMITS.tableColumns);
|
|
23
|
+
const Grid = z
|
|
24
|
+
.array(z.array(Scalar).max(LIMITS.tableColumns))
|
|
25
|
+
.max(LIMITS.tableRows);
|
|
26
|
+
export const TableDecl = z
|
|
27
|
+
.strictObject({
|
|
28
|
+
kind: z.literal('table'),
|
|
29
|
+
label: z.string().max(LIMITS.textLength).optional(),
|
|
30
|
+
place: Place.optional(),
|
|
31
|
+
cells: Grid.describe('Rows of cells; null cells are empty.'),
|
|
32
|
+
rowLabels: Labels.optional(),
|
|
33
|
+
columnLabels: Labels.optional(),
|
|
34
|
+
})
|
|
35
|
+
.describe('A table.');
|
|
36
|
+
export const TableDeclInput = z
|
|
37
|
+
.strictObject({
|
|
38
|
+
kind: z.literal('table'),
|
|
39
|
+
label: z.string().max(LIMITS.textLength).optional(),
|
|
40
|
+
place: Place.optional(),
|
|
41
|
+
rows: z.int().min(0).max(LIMITS.tableRows).optional(),
|
|
42
|
+
columns: z.int().min(0).max(LIMITS.tableColumns).optional(),
|
|
43
|
+
initial: Grid.optional().describe('Initial rows of cells; shorter rows are padded with empty cells.'),
|
|
44
|
+
rowLabels: Labels.optional().describe('Shown left of the rows, e.g. the characters of a string; row numbers by default.'),
|
|
45
|
+
columnLabels: Labels.optional().describe('Shown above the columns; column numbers by default.'),
|
|
46
|
+
cells: Grid.optional().describe('The canonical form of `initial`: every row, all of one length. Accepted so that parsed documents can be read again.'),
|
|
47
|
+
})
|
|
48
|
+
.refine((d) => d.cells === undefined || d.initial === undefined, {
|
|
49
|
+
message: 'Give either `initial` or `cells`, not both',
|
|
50
|
+
path: ['cells'],
|
|
51
|
+
})
|
|
52
|
+
// The same rule for JSON Schema validators, which cannot run the refinement.
|
|
53
|
+
.meta({ not: { required: ['initial', 'cells'] } })
|
|
54
|
+
.describe('Give `rows` and `columns` for an empty table, `initial` for one with values, or both to pad `initial`.');
|
|
55
|
+
function normalizeTableDecl(input) {
|
|
56
|
+
const { rows, columns, cells: given, ...others } = input;
|
|
57
|
+
const { initial = given ?? [], ...rest } = others;
|
|
58
|
+
const height = Math.max(rows ?? 0, initial.length);
|
|
59
|
+
const width = Math.max(columns ?? 0, ...initial.map((row) => row.length));
|
|
60
|
+
const cells = Array.from({ length: height }, (_, r) => Array.from({ length: width }, (_, c) => initial[r]?.[c] ?? null));
|
|
61
|
+
return { ...rest, cells };
|
|
62
|
+
}
|
|
63
|
+
function validateTableDecl(decl) {
|
|
64
|
+
const issues = [];
|
|
65
|
+
const height = decl.cells.length;
|
|
66
|
+
const width = decl.cells[0]?.length ?? 0;
|
|
67
|
+
decl.cells.forEach((row, r) => {
|
|
68
|
+
if (row.length !== width)
|
|
69
|
+
issues.push({
|
|
70
|
+
path: ['cells', r],
|
|
71
|
+
message: `Row ${r} has ${row.length} cells, but row 0 has ${width}`,
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
if (decl.rowLabels !== undefined && decl.rowLabels.length !== height)
|
|
75
|
+
issues.push({
|
|
76
|
+
path: ['rowLabels'],
|
|
77
|
+
message: `There are ${decl.rowLabels.length} row labels for ${height} rows`,
|
|
78
|
+
});
|
|
79
|
+
if (decl.columnLabels !== undefined && decl.columnLabels.length !== width)
|
|
80
|
+
issues.push({
|
|
81
|
+
path: ['columnLabels'],
|
|
82
|
+
message: `There are ${decl.columnLabels.length} column labels for ${width} columns`,
|
|
83
|
+
});
|
|
84
|
+
return issues;
|
|
85
|
+
}
|
|
86
|
+
export const TableAction = z.discriminatedUnion('type', [
|
|
87
|
+
z
|
|
88
|
+
.strictObject({ type: z.literal('set'), cell: Cell, value: Scalar })
|
|
89
|
+
.describe('Write a cell; null empties it.'),
|
|
90
|
+
z
|
|
91
|
+
.strictObject({ type: z.literal('highlight'), cells: Cells })
|
|
92
|
+
.describe('Highlight cells (this step only).'),
|
|
93
|
+
z
|
|
94
|
+
.strictObject({ type: z.literal('depend'), cell: Cell, on: Cells })
|
|
95
|
+
.describe('Show that `cell` is computed from the cells `on` (this step only): every cell in `on` is marked, and each that touches `cell` gets an arrow to it.'),
|
|
96
|
+
z
|
|
97
|
+
.strictObject({ type: z.literal('settle'), cells: Cells })
|
|
98
|
+
.describe('Mark cells as part of the answer, e.g. a traced-back path (persists).'),
|
|
99
|
+
z
|
|
100
|
+
.strictObject({ type: z.literal('resetMarks') })
|
|
101
|
+
.describe('Clear every mark.'),
|
|
102
|
+
]);
|
|
103
|
+
export const tableSpec = {
|
|
104
|
+
kind: 'table',
|
|
105
|
+
decl: TableDecl,
|
|
106
|
+
declInput: TableDeclInput,
|
|
107
|
+
action: TableAction,
|
|
108
|
+
actionInput: TableAction,
|
|
109
|
+
actionTypes: typesOf(TableAction),
|
|
110
|
+
normalizeDecl: normalizeTableDecl,
|
|
111
|
+
declIds: () => [],
|
|
112
|
+
validateDecl: validateTableDecl,
|
|
113
|
+
normalizeAction: (action) => action,
|
|
114
|
+
introducedIds: () => [],
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/kinds/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAiC,MAAM,WAAW,CAAC;AAEnE,MAAM,MAAM,GAAG,CAAC;KACb,KAAK,CAAC,MAAM,CAAC;KACb,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC;KAClB,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACrB,QAAQ,CAAC,uCAAuC,CAAC,CAAC;AAGrD,MAAM,KAAK,GAAG,CAAC;KACZ,KAAK,CAAC,IAAI,CAAC;KACX,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAE/C,MAAM,IAAI,GAAG,CAAC;KACX,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;KAC/C,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAEzB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC;KACvB,YAAY,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,KAAK,E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Q,CAAC,gCAAgC,CAAC;IAC7C,CAAC;SACE,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;SAC5D,QAAQ,CAAC,mCAAmC,CAAC;IAChD,CAAC;SACE,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;SAClE,QAAQ,CACP,oJAAoJ,CACrJ;IACH,CAAC;SACE,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;SACzD,QAAQ,CACP,uEAAuE,CACxE;IACH,CAAC;SACE,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;SAC/C,QAAQ,CAAC,mBAAmB,CAAC;CACjC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,SAAS,GAKjB;IACH,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,cAAc;IACzB,MAAM,EAAE,WAAW;IACnB,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;IACjC,aAAa,EAAE,kBAAkB;IACjC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;IACjB,YAAY,EAAE,iBAAiB;IAC/B,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM;IACnC,aAAa,EAAE,GAAG,EAAE,CAAC,EAAE;CACxB,CAAC"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `tree` kind: rooted trees and forests. Nodes have ordered child
|
|
3
|
+
* slots; a slot may be empty (null), which binary trees use to tell a lone
|
|
4
|
+
* right child from a left one.
|
|
5
|
+
*
|
|
6
|
+
* Covers binary search trees (with rotations and red–black colours),
|
|
7
|
+
* n-ary trees, tries, recursion trees and union–find forests.
|
|
8
|
+
*
|
|
9
|
+
* Marks: `highlight` and `compare` last one step; `visit`, `settle`,
|
|
10
|
+
* `group`, `pointer`, `annotate`, `markEdge` and `labelEdge` persist.
|
|
11
|
+
*
|
|
12
|
+
* Protocol 0.5 (ADR 0034) adds root slots, pointers at empty child slots
|
|
13
|
+
* (NIL), named notes, edge marks and labels, and root lists.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import { type DeclIssue, type KindSpec } from './kind.ts';
|
|
17
|
+
export declare const TreeNode: z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
20
|
+
children: z.ZodOptional<z.ZodArray<z.ZodNullable<z.ZodString>>>;
|
|
21
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
22
|
+
red: "red";
|
|
23
|
+
black: "black";
|
|
24
|
+
}>>;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export type TreeNode = z.infer<typeof TreeNode>;
|
|
27
|
+
/** Canonical declaration. */
|
|
28
|
+
export declare const TreeDecl: z.ZodObject<{
|
|
29
|
+
kind: z.ZodLiteral<"tree">;
|
|
30
|
+
label: z.ZodOptional<z.ZodString>;
|
|
31
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
32
|
+
main: "main";
|
|
33
|
+
side: "side";
|
|
34
|
+
}>>;
|
|
35
|
+
binary: z.ZodBoolean;
|
|
36
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
39
|
+
children: z.ZodOptional<z.ZodArray<z.ZodNullable<z.ZodString>>>;
|
|
40
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
41
|
+
red: "red";
|
|
42
|
+
black: "black";
|
|
43
|
+
}>>;
|
|
44
|
+
}, z.core.$strict>>;
|
|
45
|
+
roots: z.ZodArray<z.ZodString>;
|
|
46
|
+
rootList: z.ZodOptional<z.ZodEnum<{
|
|
47
|
+
list: "list";
|
|
48
|
+
circular: "circular";
|
|
49
|
+
}>>;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
export type TreeDecl = z.infer<typeof TreeDecl>;
|
|
52
|
+
export declare const TreeDeclInput: z.ZodObject<{
|
|
53
|
+
kind: z.ZodLiteral<"tree">;
|
|
54
|
+
label: z.ZodOptional<z.ZodString>;
|
|
55
|
+
place: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
main: "main";
|
|
57
|
+
side: "side";
|
|
58
|
+
}>>;
|
|
59
|
+
binary: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
nodes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
63
|
+
children: z.ZodOptional<z.ZodArray<z.ZodNullable<z.ZodString>>>;
|
|
64
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
65
|
+
red: "red";
|
|
66
|
+
black: "black";
|
|
67
|
+
}>>;
|
|
68
|
+
}, z.core.$strict>>>;
|
|
69
|
+
roots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
rootList: z.ZodOptional<z.ZodEnum<{
|
|
71
|
+
list: "list";
|
|
72
|
+
circular: "circular";
|
|
73
|
+
}>>;
|
|
74
|
+
levelOrder: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>>;
|
|
75
|
+
}, z.core.$strict>;
|
|
76
|
+
export type TreeDeclInput = z.infer<typeof TreeDeclInput>;
|
|
77
|
+
/** Rules a schema cannot express: references exist, one parent each, no cycles. */
|
|
78
|
+
export declare function validateTreeDecl(decl: TreeDecl): DeclIssue[];
|
|
79
|
+
/** A named note's field, such as `size`, `max`, `deg` or `mark`. */
|
|
80
|
+
export declare const NoteField: z.ZodString;
|
|
81
|
+
export declare const TreeAction: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
82
|
+
slot: z.ZodOptional<z.ZodInt>;
|
|
83
|
+
type: z.ZodLiteral<"addNode">;
|
|
84
|
+
node: z.ZodObject<{
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
87
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
88
|
+
red: "red";
|
|
89
|
+
black: "black";
|
|
90
|
+
}>>;
|
|
91
|
+
}, z.core.$strict>;
|
|
92
|
+
parent: z.ZodNullable<z.ZodString>;
|
|
93
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
94
|
+
type: z.ZodLiteral<"removeNode">;
|
|
95
|
+
node: z.ZodString;
|
|
96
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
97
|
+
slot: z.ZodOptional<z.ZodInt>;
|
|
98
|
+
type: z.ZodLiteral<"setChild">;
|
|
99
|
+
parent: z.ZodString;
|
|
100
|
+
child: z.ZodNullable<z.ZodString>;
|
|
101
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
102
|
+
type: z.ZodLiteral<"detach">;
|
|
103
|
+
node: z.ZodString;
|
|
104
|
+
slot: z.ZodOptional<z.ZodInt>;
|
|
105
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
106
|
+
type: z.ZodLiteral<"rotate">;
|
|
107
|
+
node: z.ZodString;
|
|
108
|
+
direction: z.ZodEnum<{
|
|
109
|
+
left: "left";
|
|
110
|
+
right: "right";
|
|
111
|
+
}>;
|
|
112
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
113
|
+
type: z.ZodLiteral<"setValue">;
|
|
114
|
+
node: z.ZodString;
|
|
115
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
116
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
117
|
+
type: z.ZodLiteral<"swapValues">;
|
|
118
|
+
a: z.ZodString;
|
|
119
|
+
b: z.ZodString;
|
|
120
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
121
|
+
type: z.ZodLiteral<"setColor">;
|
|
122
|
+
node: z.ZodString;
|
|
123
|
+
color: z.ZodNullable<z.ZodEnum<{
|
|
124
|
+
red: "red";
|
|
125
|
+
black: "black";
|
|
126
|
+
}>>;
|
|
127
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
128
|
+
type: z.ZodLiteral<"highlight">;
|
|
129
|
+
nodes: z.ZodArray<z.ZodString>;
|
|
130
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
131
|
+
type: z.ZodLiteral<"compare">;
|
|
132
|
+
a: z.ZodString;
|
|
133
|
+
b: z.ZodString;
|
|
134
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
135
|
+
type: z.ZodLiteral<"visit">;
|
|
136
|
+
node: z.ZodString;
|
|
137
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
138
|
+
type: z.ZodLiteral<"settle">;
|
|
139
|
+
node: z.ZodString;
|
|
140
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
+
type: z.ZodLiteral<"group">;
|
|
142
|
+
node: z.ZodString;
|
|
143
|
+
group: z.ZodNullable<z.ZodLiteral<0 | 1 | 4 | 2 | 3 | 5>>;
|
|
144
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
145
|
+
type: z.ZodLiteral<"pointer">;
|
|
146
|
+
name: z.ZodString;
|
|
147
|
+
node: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
148
|
+
parent: z.ZodString;
|
|
149
|
+
slot: z.ZodInt;
|
|
150
|
+
}, z.core.$strict>]>>;
|
|
151
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
152
|
+
type: z.ZodLiteral<"annotate">;
|
|
153
|
+
node: z.ZodString;
|
|
154
|
+
text: z.ZodNullable<z.ZodString>;
|
|
155
|
+
field: z.ZodOptional<z.ZodString>;
|
|
156
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
157
|
+
type: z.ZodLiteral<"markEdge">;
|
|
158
|
+
node: z.ZodString;
|
|
159
|
+
mark: z.ZodNullable<z.ZodEnum<{
|
|
160
|
+
selected: "selected";
|
|
161
|
+
rejected: "rejected";
|
|
162
|
+
}>>;
|
|
163
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
164
|
+
type: z.ZodLiteral<"labelEdge">;
|
|
165
|
+
node: z.ZodString;
|
|
166
|
+
label: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
167
|
+
}, z.core.$strict>], "type">;
|
|
168
|
+
export type TreeAction = z.infer<typeof TreeAction>;
|
|
169
|
+
export declare const TreeActionInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
170
|
+
slot: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodEnum<{
|
|
171
|
+
left: "left";
|
|
172
|
+
right: "right";
|
|
173
|
+
}>]>>;
|
|
174
|
+
type: z.ZodLiteral<"addNode">;
|
|
175
|
+
node: z.ZodUnion<readonly [z.ZodObject<{
|
|
176
|
+
id: z.ZodString;
|
|
177
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
178
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
179
|
+
red: "red";
|
|
180
|
+
black: "black";
|
|
181
|
+
}>>;
|
|
182
|
+
}, z.core.$strict>, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>]>;
|
|
183
|
+
parent: z.ZodNullable<z.ZodString>;
|
|
184
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
185
|
+
type: z.ZodLiteral<"removeNode">;
|
|
186
|
+
node: z.ZodString;
|
|
187
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
188
|
+
slot: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodEnum<{
|
|
189
|
+
left: "left";
|
|
190
|
+
right: "right";
|
|
191
|
+
}>]>>;
|
|
192
|
+
type: z.ZodLiteral<"setChild">;
|
|
193
|
+
parent: z.ZodString;
|
|
194
|
+
child: z.ZodNullable<z.ZodString>;
|
|
195
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
196
|
+
type: z.ZodLiteral<"detach">;
|
|
197
|
+
node: z.ZodString;
|
|
198
|
+
slot: z.ZodOptional<z.ZodInt>;
|
|
199
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
200
|
+
type: z.ZodLiteral<"rotate">;
|
|
201
|
+
node: z.ZodString;
|
|
202
|
+
direction: z.ZodEnum<{
|
|
203
|
+
left: "left";
|
|
204
|
+
right: "right";
|
|
205
|
+
}>;
|
|
206
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
207
|
+
type: z.ZodLiteral<"setValue">;
|
|
208
|
+
node: z.ZodString;
|
|
209
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
|
|
210
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
211
|
+
type: z.ZodLiteral<"swapValues">;
|
|
212
|
+
a: z.ZodString;
|
|
213
|
+
b: z.ZodString;
|
|
214
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
215
|
+
type: z.ZodLiteral<"setColor">;
|
|
216
|
+
node: z.ZodString;
|
|
217
|
+
color: z.ZodNullable<z.ZodEnum<{
|
|
218
|
+
red: "red";
|
|
219
|
+
black: "black";
|
|
220
|
+
}>>;
|
|
221
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
222
|
+
type: z.ZodLiteral<"highlight">;
|
|
223
|
+
nodes: z.ZodArray<z.ZodString>;
|
|
224
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
225
|
+
type: z.ZodLiteral<"compare">;
|
|
226
|
+
a: z.ZodString;
|
|
227
|
+
b: z.ZodString;
|
|
228
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
229
|
+
type: z.ZodLiteral<"visit">;
|
|
230
|
+
node: z.ZodString;
|
|
231
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
232
|
+
type: z.ZodLiteral<"settle">;
|
|
233
|
+
node: z.ZodString;
|
|
234
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
235
|
+
type: z.ZodLiteral<"group">;
|
|
236
|
+
node: z.ZodString;
|
|
237
|
+
group: z.ZodNullable<z.ZodLiteral<0 | 1 | 4 | 2 | 3 | 5>>;
|
|
238
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
239
|
+
type: z.ZodLiteral<"pointer">;
|
|
240
|
+
name: z.ZodString;
|
|
241
|
+
node: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
242
|
+
parent: z.ZodString;
|
|
243
|
+
slot: z.ZodUnion<readonly [z.ZodInt, z.ZodEnum<{
|
|
244
|
+
left: "left";
|
|
245
|
+
right: "right";
|
|
246
|
+
}>]>;
|
|
247
|
+
}, z.core.$strict>]>>;
|
|
248
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
249
|
+
type: z.ZodLiteral<"annotate">;
|
|
250
|
+
node: z.ZodString;
|
|
251
|
+
text: z.ZodNullable<z.ZodString>;
|
|
252
|
+
field: z.ZodOptional<z.ZodString>;
|
|
253
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
254
|
+
type: z.ZodLiteral<"markEdge">;
|
|
255
|
+
node: z.ZodString;
|
|
256
|
+
mark: z.ZodNullable<z.ZodEnum<{
|
|
257
|
+
selected: "selected";
|
|
258
|
+
rejected: "rejected";
|
|
259
|
+
}>>;
|
|
260
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
261
|
+
type: z.ZodLiteral<"labelEdge">;
|
|
262
|
+
node: z.ZodString;
|
|
263
|
+
label: z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
264
|
+
}, z.core.$strict>], "type">;
|
|
265
|
+
export type TreeActionInput = z.infer<typeof TreeActionInput>;
|
|
266
|
+
export declare const treeSpec: KindSpec<{
|
|
267
|
+
decl: TreeDecl;
|
|
268
|
+
declInput: TreeDeclInput;
|
|
269
|
+
action: TreeAction;
|
|
270
|
+
actionInput: TreeActionInput;
|
|
271
|
+
}>;
|
|
272
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/kinds/tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,OAAO,EAAW,KAAK,SAAS,EAAc,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAI/E,eAAO,MAAM,QAAQ;;;;;;;;kBAaM,CAAC;AAC5B,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAUhD,6BAA6B;AAC7B,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;kBAckB,CAAC;AACxC,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;kBAyCtB,CAAC;AACL,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAuE1D,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,CAgE5D;AAiBD,oEAAoE;AACpE,eAAO,MAAM,SAAS,aASnB,CAAC;AA2IJ,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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