@altnovatrail/widgets 0.1.3 → 0.2.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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/kinds/cells/cells.handles.json +3 -3
  3. package/kinds/cells/cells.schema.json +69 -9
  4. package/kinds/cells/vectors/knight-after-no-parity.json +31 -0
  5. package/kinds/cells/vectors/knight-par-56-d2-2.json +61 -6
  6. package/kinds/cells/vectors/paper-drawn-lines.json +36 -1
  7. package/kinds/cells/vectors/polyomino-one-pieces.json +28 -0
  8. package/kinds/line/line.handles.json +195 -0
  9. package/kinds/line/line.schema.json +321 -0
  10. package/kinds/line/vectors/cases.json +213 -0
  11. package/kinds/line/vectors/gaps-12-d1-1.json +140 -0
  12. package/kinds/line/vectors/gaps-12-d1-2.json +95 -0
  13. package/kinds/line/vectors/gaps-12-d1-3.json +122 -0
  14. package/kinds/line/vectors/gaps-12-d1-4.json +121 -0
  15. package/kinds/line/vectors/gaps-12-d1-5.json +87 -0
  16. package/kinds/line/vectors/gaps-12-d2-1.json +173 -0
  17. package/kinds/line/vectors/gaps-12-d2-6.json +87 -0
  18. package/kinds/line/vectors/gaps-12-d3-2.json +173 -0
  19. package/kinds/line/vectors/gaps-12-d4-4.json +168 -0
  20. package/kinds/line/vectors/gaps-12-d5-3.json +99 -0
  21. package/kinds/line/vectors/gaps-12-d5-4.json +215 -0
  22. package/kinds/line/vectors/gaps-34-d1-1.json +37 -0
  23. package/kinds/line/vectors/gaps-34-d1-2.json +130 -0
  24. package/kinds/line/vectors/gaps-34-d1-4.json +155 -0
  25. package/kinds/line/vectors/gaps-34-d1-5.json +43 -0
  26. package/kinds/line/vectors/gaps-34-d3-2.json +38 -0
  27. package/kinds/line/vectors/gaps-34-d3-5.json +177 -0
  28. package/kinds/line/vectors/gaps-34-d5-3.json +39 -0
  29. package/kinds/line/vectors/invalid-line.json +34 -0
  30. package/kinds/line/vectors/invalid-ring.json +34 -0
  31. package/kinds/line/vectors/invalid.json +43 -0
  32. package/kinds/line/vectors/jump-unreachable.json +104 -0
  33. package/kinds/line/vectors/limit.json +40 -0
  34. package/kinds/line/vectors/op-not-in-scene.json +47 -0
  35. package/kinds/line/vectors/ring-cut.json +104 -0
  36. package/kinds/line/vectors/ring-every.json +107 -0
  37. package/kinds/line/vectors/ring-jump.json +135 -0
  38. package/lib/cores/arith.d.ts +62 -0
  39. package/lib/cores/arith.js +197 -0
  40. package/lib/cores/enumerate.js +2 -2
  41. package/lib/cores/kind.d.ts +28 -3
  42. package/lib/cores/kind.js +2 -2
  43. package/lib/cores/registry.d.ts +43 -0
  44. package/lib/cores/registry.js +87 -0
  45. package/lib/cores/search.d.ts +21 -3
  46. package/lib/cores/search.js +80 -17
  47. package/lib/kinds/cells/bishop.d.ts +1 -1
  48. package/lib/kinds/cells/index.d.ts +8 -0
  49. package/lib/kinds/cells/index.js +10 -2
  50. package/lib/kinds/cells/kind.d.ts +3 -2
  51. package/lib/kinds/cells/kind.js +26 -66
  52. package/lib/kinds/cells/knight.d.ts +1 -1
  53. package/lib/kinds/cells/operation.d.ts +21 -1
  54. package/lib/kinds/cells/paper.js +27 -13
  55. package/lib/kinds/cells/piece.d.ts +17 -6
  56. package/lib/kinds/cells/piece.js +119 -38
  57. package/lib/kinds/cells/polyomino.d.ts +14 -0
  58. package/lib/kinds/cells/polyomino.js +122 -35
  59. package/lib/kinds/cells/registry.js +1 -1
  60. package/lib/kinds/cells/schema.js +4 -1
  61. package/lib/kinds/cells/step.d.ts +1 -1
  62. package/lib/kinds/line/cut.d.ts +2 -0
  63. package/lib/kinds/line/cut.js +63 -0
  64. package/lib/kinds/line/goals.d.ts +22 -0
  65. package/lib/kinds/line/goals.js +137 -0
  66. package/lib/kinds/line/index.d.ts +13 -0
  67. package/lib/kinds/line/index.js +17 -0
  68. package/lib/kinds/line/jump.d.ts +10 -0
  69. package/lib/kinds/line/jump.js +95 -0
  70. package/lib/kinds/line/kind.d.ts +25 -0
  71. package/lib/kinds/line/kind.js +125 -0
  72. package/lib/kinds/line/line.d.ts +63 -0
  73. package/lib/kinds/line/line.js +157 -0
  74. package/lib/kinds/line/operation.d.ts +69 -0
  75. package/lib/kinds/line/operation.js +1 -0
  76. package/lib/kinds/line/posts.d.ts +11 -0
  77. package/lib/kinds/line/posts.js +85 -0
  78. package/lib/kinds/line/registry.d.ts +2 -0
  79. package/lib/kinds/line/registry.js +11 -0
  80. package/lib/kinds/line/schema.d.ts +4 -0
  81. package/lib/kinds/line/schema.js +157 -0
  82. package/package.json +9 -2
@@ -0,0 +1,157 @@
1
+ import { maxNumber, maxPlaces, maxSpacing } from "./line.js";
2
+ import { lineCounters } from "./posts.js";
3
+ /** The $id of the kind's schema at a version: a name, which need not resolve. */
4
+ export function schemaId(version) {
5
+ return `https://altnovatrail.github.io/widgets/kinds/line/${version}/line.schema.json`;
6
+ }
7
+ const places = (description) => ({
8
+ description,
9
+ type: "array",
10
+ items: { description: "A place, by its number.", $ref: "#/$defs/place" },
11
+ uniqueItems: true,
12
+ });
13
+ export function lineSchema(registry) {
14
+ const options = {};
15
+ const moves = {};
16
+ const state = {
17
+ posts: places("The places a post stands on now, by their numbers, in ascending order."),
18
+ };
19
+ const counters = Object.entries(lineCounters).map(([name, c]) => `${name}: ${c.description}`);
20
+ for (const op of registry.operations) {
21
+ options[op.name] = op.schema.options;
22
+ moves[op.name] = op.schema.move;
23
+ if (op.schema.state !== undefined) {
24
+ state[op.schema.state.member] = op.schema.state.schema;
25
+ }
26
+ for (const [name, c] of Object.entries(op.counters ?? {})) {
27
+ counters.push(`${name}, where the scene allows ${op.name}: ${c.description}`);
28
+ }
29
+ }
30
+ const names = counters.map((counter) => counter.slice(0, counter.search(/[,:]/)));
31
+ const goals = {};
32
+ for (const goal of registry.goals) {
33
+ goals[goal.name] = goal.schema;
34
+ }
35
+ return {
36
+ $schema: "https://json-schema.org/draft/2020-12/schema",
37
+ $id: schemaId(registry.version),
38
+ title: "A scene of the widget kind line",
39
+ description: "A line of places, the operations a learner may play on it with their parameters, and at most one goal a state may meet. Under $defs, a move and a state of the kind.",
40
+ type: "object",
41
+ properties: {
42
+ line: {
43
+ description: "The line as the scene gives it.",
44
+ $ref: "#/$defs/line",
45
+ unevaluatedProperties: false,
46
+ },
47
+ operations: {
48
+ description: "The operations a learner may play on the scene, each by its name with its parameters; none, for a line only to look at.",
49
+ type: "object",
50
+ properties: options,
51
+ unevaluatedProperties: false,
52
+ },
53
+ goal: {
54
+ description: "What a state is to meet, one goal by its name with its parameters.",
55
+ type: "object",
56
+ properties: goals,
57
+ minProperties: 1,
58
+ maxProperties: 1,
59
+ unevaluatedProperties: false,
60
+ },
61
+ },
62
+ required: ["line", "operations"],
63
+ unevaluatedProperties: false,
64
+ $defs: {
65
+ place: {
66
+ description: "A place of the line by its number: the line's first number for its first place, and each next place the next number.",
67
+ type: "integer",
68
+ minimum: 0,
69
+ maximum: maxNumber,
70
+ },
71
+ counter: {
72
+ description: `A counter, a number of a state the widget shows, by its name: ${counters.join(" ")}`,
73
+ enum: names,
74
+ },
75
+ line: {
76
+ description: "Places in a row, numbered from the first number on, each a spacing from the next, open or closed into a ring, and the posts that stand on them at the start.",
77
+ type: "object",
78
+ properties: {
79
+ places: {
80
+ description: "The count of places.",
81
+ type: "integer",
82
+ minimum: 2,
83
+ maximum: maxPlaces,
84
+ },
85
+ first: {
86
+ description: "The number of the first place, as the statement numbers it — a floor, a page, a post —, so that the last place's number is at most the greatest a place has; 0 where left out.",
87
+ type: "integer",
88
+ minimum: 0,
89
+ maximum: maxNumber,
90
+ },
91
+ spacing: {
92
+ description: "The length from a place to the next, in the statement's unit — metres, steps, minutes; 1 where left out.",
93
+ type: "integer",
94
+ minimum: 1,
95
+ maximum: maxSpacing,
96
+ },
97
+ vertical: {
98
+ description: "Whether the line is drawn upright, its first place at the bottom, as floors, stairs or a well; it changes no rule, and a ring is never upright. False where left out.",
99
+ type: "boolean",
100
+ },
101
+ closed: {
102
+ description: "Whether the line is closed into a ring, its last place next to its first, as bushes round a flowerbed or a fence round a garden: as many gaps as posts, no end to cut at, and a jumper going on round it. False where left out.",
103
+ type: "boolean",
104
+ },
105
+ sides: {
106
+ description: "A ring's sides, where it is drawn as a figure with corners, as a square flowerbed or a garden's fence: each side by its count of gaps, the first place a corner and each next corner a side on, the sides' gaps together the ring's places. A round ring where left out; it changes no rule.",
107
+ type: "array",
108
+ items: {
109
+ description: "A side's count of gaps.",
110
+ type: "integer",
111
+ minimum: 1,
112
+ maximum: maxPlaces - 1,
113
+ },
114
+ minItems: 3,
115
+ maxItems: maxPlaces,
116
+ },
117
+ posts: places("The places a post stands on at the scene's start, each once."),
118
+ },
119
+ required: ["places"],
120
+ dependentRequired: { sides: ["closed"] },
121
+ allOf: [
122
+ {
123
+ not: {
124
+ properties: {
125
+ closed: { description: "A ring.", const: true },
126
+ vertical: { description: "Upright.", const: true },
127
+ },
128
+ required: ["closed", "vertical"],
129
+ },
130
+ },
131
+ {
132
+ not: {
133
+ properties: {
134
+ closed: { description: "An open line.", const: false },
135
+ sides: { description: "Sides given." },
136
+ },
137
+ required: ["closed", "sides"],
138
+ },
139
+ },
140
+ ],
141
+ },
142
+ move: {
143
+ description: "A move: one member, named by the operation it plays, holding what a move of the operation holds.",
144
+ type: "object",
145
+ properties: moves,
146
+ minProperties: 1,
147
+ maxProperties: 1,
148
+ },
149
+ state: {
150
+ description: "A state: the posts, and a member for each operation of the scene that keeps one.",
151
+ type: "object",
152
+ properties: state,
153
+ required: ["posts"],
154
+ },
155
+ },
156
+ };
157
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altnovatrail/widgets",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "NovaTrail's widget kinds: each kind's rules and solver over its states, and the shell they share.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -46,7 +46,14 @@
46
46
  },
47
47
  "./kinds/cells/cells.schema.json": "./kinds/cells/cells.schema.json",
48
48
  "./kinds/cells/cells.handles.json": "./kinds/cells/cells.handles.json",
49
- "./kinds/cells/vectors/*": "./kinds/cells/vectors/*"
49
+ "./kinds/cells/vectors/*": "./kinds/cells/vectors/*",
50
+ "./kinds/line": {
51
+ "types": "./lib/kinds/line/index.d.ts",
52
+ "default": "./lib/kinds/line/index.js"
53
+ },
54
+ "./kinds/line/line.schema.json": "./kinds/line/line.schema.json",
55
+ "./kinds/line/line.handles.json": "./kinds/line/line.handles.json",
56
+ "./kinds/line/vectors/*": "./kinds/line/vectors/*"
50
57
  },
51
58
  "devDependencies": {
52
59
  "@biomejs/biome": "2.6.9",