@delurio/cli 0.10.0 → 0.12.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/NOTICE +7 -0
  3. package/README.md +38 -22
  4. package/SPEC.md +8 -1
  5. package/js/changes.d.ts +17 -0
  6. package/js/cli.js +6 -0
  7. package/{dist → js}/edges.d.ts +2 -2
  8. package/js/edges.js +40 -0
  9. package/js/expr.js +25 -0
  10. package/{dist → js}/graph.d.ts +3 -0
  11. package/js/graph.js +73 -0
  12. package/{dist → js}/html.d.ts +6 -6
  13. package/js/html.js +13 -0
  14. package/js/internal.js +408 -0
  15. package/js/kit.js +54 -0
  16. package/{dist → js}/model.d.ts +2 -2
  17. package/js/model.js +136 -0
  18. package/js/native.cjs +46 -0
  19. package/js/native.d.cts +328 -0
  20. package/{dist → js}/nav.d.ts +1 -1
  21. package/js/nav.js +70 -0
  22. package/js/needs.js +30 -0
  23. package/{dist → js}/spine.d.ts +3 -3
  24. package/js/spine.js +22 -0
  25. package/{dist → js}/starts.d.ts +1 -3
  26. package/{dist → js}/story.d.ts +2 -2
  27. package/js/story.js +22 -0
  28. package/{dist → js}/wireframe.d.ts +2 -2
  29. package/js/wireframe.js +29 -0
  30. package/js/yaml.d.ts +20 -0
  31. package/js/yaml.js +40 -0
  32. package/package.json +40 -24
  33. package/schemas/binding.schema.json +2211 -0
  34. package/schemas/ui.schema.json +6 -0
  35. package/dist/anchors.d.ts +0 -29
  36. package/dist/anchors.js +0 -160
  37. package/dist/changes.d.ts +0 -25
  38. package/dist/changes.js +0 -101
  39. package/dist/check.d.ts +0 -23
  40. package/dist/check.js +0 -649
  41. package/dist/cli.d.ts +0 -2
  42. package/dist/cli.js +0 -194
  43. package/dist/compare.d.ts +0 -34
  44. package/dist/compare.js +0 -143
  45. package/dist/diff-flow.d.ts +0 -33
  46. package/dist/diff-flow.js +0 -547
  47. package/dist/diff-nav.d.ts +0 -20
  48. package/dist/diff-nav.js +0 -401
  49. package/dist/diff.d.ts +0 -25
  50. package/dist/diff.js +0 -331
  51. package/dist/domain-names.d.ts +0 -18
  52. package/dist/domain-names.js +0 -124
  53. package/dist/domain.d.ts +0 -25
  54. package/dist/domain.js +0 -110
  55. package/dist/edges.js +0 -120
  56. package/dist/expr.js +0 -157
  57. package/dist/graph.js +0 -236
  58. package/dist/html.js +0 -311
  59. package/dist/index-page.d.ts +0 -12
  60. package/dist/index-page.js +0 -50
  61. package/dist/invokes.d.ts +0 -10
  62. package/dist/invokes.js +0 -67
  63. package/dist/kit.js +0 -711
  64. package/dist/mermaid.d.ts +0 -3
  65. package/dist/mermaid.js +0 -50
  66. package/dist/model.js +0 -608
  67. package/dist/nav-page.d.ts +0 -15
  68. package/dist/nav-page.js +0 -283
  69. package/dist/nav.js +0 -578
  70. package/dist/needs.js +0 -335
  71. package/dist/pan.d.ts +0 -2
  72. package/dist/pan.js +0 -252
  73. package/dist/schemas.d.ts +0 -15
  74. package/dist/schemas.js +0 -316
  75. package/dist/spine.js +0 -156
  76. package/dist/starts.js +0 -88
  77. package/dist/story.js +0 -109
  78. package/dist/tutorial-check.d.ts +0 -9
  79. package/dist/tutorial-check.js +0 -297
  80. package/dist/ui-check.d.ts +0 -8
  81. package/dist/ui-check.js +0 -142
  82. package/dist/watch.d.ts +0 -5
  83. package/dist/watch.js +0 -114
  84. package/dist/wireframe.js +0 -276
  85. package/dist/yaml.d.ts +0 -19
  86. package/dist/yaml.js +0 -134
  87. /package/{dist → js}/expr.d.ts +0 -0
  88. /package/{dist → js}/kit.d.ts +0 -0
  89. /package/{dist → js}/needs.d.ts +0 -0
package/dist/needs.js DELETED
@@ -1,335 +0,0 @@
1
- // A flow's needs and a product's gaps (SPEC.md §13). needs.yaml, beside a flow, is a closed list of what must exist for
2
- // the flow's users: each need names the evidence that it does, or says `missing` and why. needs.gaps.yaml, at the root
3
- // of a product's graphs, lists every need of its flows that is missing. `checkNeeds` holds each piece of evidence to
4
- // what it names, each missing need to the gaps file above it, and each entry of a gaps file to a need under its folder
5
- // that is still missing, so the list only shrinks on its own. `planned` gives a tool that walks a flow on the app the
6
- // states and nodes that only missing needs are drawn as, for it to leave out.
7
- import { existsSync, readFileSync, statSync } from 'node:fs';
8
- import { basename, dirname, isAbsolute, join } from 'node:path';
9
- import { keyAt, readYaml } from './yaml.js';
10
- import { AppFiles } from './anchors.js';
11
- export const NEEDS_FILE = 'needs.yaml';
12
- export const GAPS_FILE = 'needs.gaps.yaml';
13
- const FORMAT = 'delurio-graph/0';
14
- const KINDS = ['source', 'test', 'scenario', 'state', 'node', 'setting'];
15
- // what the graph draws: it shows where a need is, and alone meets nothing
16
- const IN_GRAPH = new Set(['state', 'node']);
17
- const isMap = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
18
- const text = (v) => (typeof v === 'string' && v.trim() !== '' ? v : null);
19
- const kindOf = (e) => KINDS.find((k) => typeof e[k] === 'string');
20
- const isMissing = (n) => text(n.missing) !== null;
21
- // the value of a graph file, or null when it cannot be read: the schema rule says why
22
- function readDoc(file) {
23
- try {
24
- const raw = readFileSync(file, 'utf8');
25
- const doc = readYaml(raw);
26
- if (!isMap(doc))
27
- return null;
28
- if (typeof doc.schema === 'string' && doc.schema !== FORMAT)
29
- return null;
30
- return { text: raw, doc };
31
- }
32
- catch {
33
- return null;
34
- }
35
- }
36
- // the needs.yaml beside a flow, read; null when there is none
37
- export function readNeeds(dir) {
38
- const file = join(dir, NEEDS_FILE);
39
- if (!existsSync(file))
40
- return null;
41
- const doc = readYaml(readFileSync(file, 'utf8'));
42
- return isMap(doc) && Array.isArray(doc.needs) ? doc : null;
43
- }
44
- // what a tool that walks the flow on the app leaves out (SPEC.md §13): the states and the nodes that missing needs are
45
- // drawn as and that no met need names, each with the ids of those needs
46
- export function planned(needs) {
47
- const out = { states: new Map(), nodes: new Map() };
48
- const built = { states: new Set(), nodes: new Set() };
49
- for (const n of (needs?.needs ?? [])) {
50
- if (!isMap(n) || typeof n.id !== 'string')
51
- continue;
52
- for (const e of Array.isArray(n.evidence) ? n.evidence : []) {
53
- if (!isMap(e))
54
- continue;
55
- for (const [key, into] of [['state', 'states'], ['node', 'nodes']]) {
56
- const name = e[key];
57
- if (typeof name !== 'string')
58
- continue;
59
- if (!isMissing(n))
60
- built[into].add(name);
61
- else
62
- out[into].set(name, [...(out[into].get(name) ?? []), n.id]);
63
- }
64
- }
65
- }
66
- for (const into of ['states', 'nodes'])
67
- for (const name of built[into])
68
- out[into].delete(name);
69
- return out;
70
- }
71
- // the nearest gaps file at or above a folder, up to the repository's root (the first folder that holds .git)
72
- function nearestGaps(dir) {
73
- for (let d = dir;; d = dirname(d)) {
74
- if (existsSync(join(d, GAPS_FILE)))
75
- return join(d, GAPS_FILE);
76
- if (existsSync(join(d, '.git')) || dirname(d) === d)
77
- return null;
78
- }
79
- }
80
- const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
81
- // the text holds the name, not as a part of a longer word: an identifier, or a test's name in quotes
82
- const holds = (body, name) => new RegExp(`(?<![\\w$])${escapeRe(name)}(?![\\w$])`).test(body);
83
- // a line of the file sets the variable and is not commented out: NAME=, export NAME=, NAME: or - NAME=
84
- const sets = (body, name) => new RegExp(`^[ \\t]*(?:-[ \\t]*)?(?:export[ \\t]+)?${escapeRe(name)}[ \\t]*[=:]`, 'm').test(body);
85
- const fileAt = (ctx, path) => {
86
- const abs = isAbsolute(path) ? path : join(ctx.app, path);
87
- return existsSync(abs) && statSync(abs).isFile() ? abs : null;
88
- };
89
- // a binding's scenarios, those of the bindings it extends included (each named relative to the one that extends it)
90
- function scenariosOf(file, seen = new Set()) {
91
- const out = new Set();
92
- if (seen.has(file) || !existsSync(file))
93
- return out;
94
- seen.add(file);
95
- const read = readDoc(file);
96
- if (read === null)
97
- return out;
98
- if (isMap(read.doc.scenarios))
99
- for (const s of Object.keys(read.doc.scenarios))
100
- out.add(s);
101
- if (typeof read.doc.extends === 'string')
102
- for (const s of scenariosOf(join(dirname(file), read.doc.extends), seen))
103
- out.add(s);
104
- return out;
105
- }
106
- // whether a piece of evidence names a file of the application by its path from the repository's root: a source, a test,
107
- // the file a setting is set in, a binding named by its path (SPEC.md §13)
108
- const namesAppFile = (kind, e) => kind === 'source' || kind === 'test' || kind === 'setting' || (kind === 'scenario' && text(e.binding) !== null);
109
- // why a piece of evidence does not resolve, or null when it does (or when what it names cannot be read, which is
110
- // reported where it is)
111
- function unresolved(ctx, kind, e) {
112
- const value = e[kind];
113
- const name = text(e.name);
114
- switch (kind) {
115
- case 'source': {
116
- const why = ctx.code.unresolved(value);
117
- if (why !== null)
118
- return `source ${why.subject} ${why.reason}`;
119
- const path = /^(.*?)(?::\d+)?$/.exec(value)[1];
120
- return name !== null && !holds(readFileSync(ctx.code.abs(path), 'utf8'), name) ? `source ${path} holds no ${name}` : null;
121
- }
122
- case 'test': {
123
- const abs = fileAt(ctx, value);
124
- if (abs === null)
125
- return `test ${value} does not exist`;
126
- return name !== null && !holds(readFileSync(abs, 'utf8'), name) ? `test ${value} holds no test named "${name}"` : null;
127
- }
128
- case 'scenario': {
129
- const given = text(e.binding);
130
- const abs = given === null ? join(ctx.dir, 'binding.yaml') : fileAt(ctx, given);
131
- const said = given === null ? "the flow's own binding.yaml" : `the binding ${given}`;
132
- if (abs === null || !existsSync(abs))
133
- return `scenario ${value}: ${said} does not exist`;
134
- const read = readDoc(abs);
135
- if (read === null)
136
- return `scenario ${value}: ${said} cannot be read`;
137
- if (read.doc.kind !== 'binding')
138
- return `scenario ${value}: ${said} is not a binding (kind: binding)`;
139
- if (ctx.flowId !== null && read.doc.flow !== ctx.flowId)
140
- return `scenario ${value}: ${said} binds ${String(read.doc.flow ?? 'no flow')}, not ${ctx.flowId}`;
141
- const scenarios = scenariosOf(abs);
142
- return scenarios.has(value) ? null : `scenario ${value} is not a scenario of ${said}${scenarios.size > 0 ? ` (it has ${[...scenarios].sort().join(', ')})` : ''}`;
143
- }
144
- case 'state':
145
- return ctx.states === null || ctx.states.has(value) ? null : `state ${value} is not a state of ${ctx.flowId ?? 'the flow'}`;
146
- case 'node':
147
- if (ctx.nodes === 'none')
148
- return `node ${value}: the flow has no screens, as there is no ui.yaml beside it`;
149
- return ctx.nodes === null || ctx.nodes.has(value) ? null : `node ${value} is not a node of the flow's ui.yaml`;
150
- case 'setting': {
151
- const where = text(e.in);
152
- if (where === null)
153
- return null; // the schema says it is missing
154
- const abs = fileAt(ctx, where);
155
- if (abs === null)
156
- return `setting ${value}: ${where} does not exist`;
157
- return sets(readFileSync(abs, 'utf8'), value) ? null : `setting ${value} is not set in ${where}: no line sets it, or the one that does is commented out`;
158
- }
159
- }
160
- }
161
- // the states of a captured flow that name their code (SPEC.md §9), which are therefore built, each with its anchor
162
- function builtStates(flow) {
163
- const out = new Map();
164
- if (flow?.status !== 'captured' || !isMap(flow.states))
165
- return out;
166
- for (const [name, st] of Object.entries(flow.states))
167
- if (isMap(st) && typeof st.source === 'string')
168
- out.set(name, st.source);
169
- return out;
170
- }
171
- // the nodes of a ui.yaml, or null when it cannot be read
172
- function nodesOf(file) {
173
- const read = readDoc(file);
174
- return read === null ? null : new Set(isMap(read.doc.nodes) ? Object.keys(read.doc.nodes) : []);
175
- }
176
- // a gaps file, read once per run; null when it cannot be read (the schema rule says why)
177
- function gapsReader() {
178
- const seen = new Map();
179
- return (file) => {
180
- if (!seen.has(file)) {
181
- const read = readDoc(file);
182
- const gaps = new Map();
183
- if (read !== null && isMap(read.doc.gaps)) {
184
- for (const [flow, ids] of Object.entries(read.doc.gaps))
185
- gaps.set(flow, Array.isArray(ids) ? ids.filter((x) => typeof x === 'string') : []);
186
- }
187
- seen.set(file, read === null ? null : { id: typeof read.doc.id === 'string' ? read.doc.id : basename(dirname(file)), gaps, text: read.text });
188
- }
189
- return seen.get(file) ?? null;
190
- };
191
- }
192
- // every needs file and gaps file among `files` (the graph files under the folders checked), with the application's
193
- // repository root that evidence paths are relative to; with `app` null (--no-app), evidence that names a file of the
194
- // application is counted and not looked for, and the rest is held as before
195
- export function checkNeeds(files, app) {
196
- const out = { problems: [], files: 0, needs: 0, gaps: 0, notLookedFor: 0 };
197
- const gapsOf = gapsReader();
198
- const code = new AppFiles(app ?? '.');
199
- // each needs file's flow and the state of each of its needs, by the gaps file that covers it; null for a needs file
200
- // that cannot be read, whose entries are then not judged
201
- const covered = new Map();
202
- const cover = (gapsFile, flow, states) => {
203
- if (gapsFile === null)
204
- return;
205
- const byFlow = covered.get(gapsFile) ?? new Map();
206
- byFlow.set(flow, states);
207
- covered.set(gapsFile, byFlow);
208
- };
209
- const problem = (rule, file, body, path, message, graph, element) => {
210
- out.problems.push({ rule, file, ...keyAt(body, path), message, graph, element });
211
- };
212
- for (const file of files.filter((f) => basename(f) === NEEDS_FILE)) {
213
- const read = readDoc(file);
214
- if (read === null || !Array.isArray(read.doc.needs)) {
215
- const beside = readDoc(join(dirname(file), 'flow.yaml'))?.doc.id;
216
- if (typeof beside === 'string')
217
- cover(nearestGaps(dirname(file)), beside, null);
218
- continue;
219
- }
220
- out.files++;
221
- const { doc, text: body } = read;
222
- const dir = dirname(file);
223
- const flowFile = join(dir, 'flow.yaml');
224
- const flow = existsSync(flowFile) ? readDoc(flowFile) : null;
225
- const flowId = typeof flow?.doc.id === 'string' ? flow.doc.id : null;
226
- const ownId = typeof doc.id === 'string' ? doc.id : null;
227
- const graph = flowId ?? ownId ?? basename(dir);
228
- if (!existsSync(flowFile)) {
229
- problem('needs-place', file, body, ['id'], `needs.yaml is beside no flow: it sits in a flow's folder, beside its flow.yaml, and lists that flow's needs (SPEC.md §13)`, graph, 'needs');
230
- }
231
- else if (flowId !== null && ownId !== null && ownId !== flowId) {
232
- problem('needs-place', file, body, ['id'], `needs.yaml is the needs of ${ownId}, and the flow beside it is ${flowId}: its id is the id of the flow beside it (SPEC.md §13)`, graph, 'needs/id');
233
- }
234
- const uiFile = join(dir, 'ui.yaml');
235
- const ctx = {
236
- app: app ?? '.',
237
- code,
238
- lookFor: app !== null,
239
- dir,
240
- flowId,
241
- states: flow === null ? null : new Set(isMap(flow.doc.states) ? Object.keys(flow.doc.states) : []),
242
- built: builtStates(flow?.doc ?? null),
243
- nodes: !existsSync(flowFile) ? null : existsSync(uiFile) ? nodesOf(uiFile) : 'none',
244
- };
245
- const key = flowId ?? ownId ?? graph; // the flow, as the gaps name it
246
- const gapsFile = nearestGaps(dir);
247
- const listed = gapsFile === null ? null : gapsOf(gapsFile);
248
- const states = new Map();
249
- const firstAt = new Map();
250
- read.doc.needs.forEach((item, i) => {
251
- if (!isMap(item) || typeof item.id !== 'string')
252
- return;
253
- const id = item.id;
254
- out.needs++;
255
- const at = ['needs', String(i)];
256
- const first = firstAt.get(id);
257
- if (first !== undefined) {
258
- problem('need-twice', file, body, [...at, 'id'], `need ${id} is given twice: it is given first at line ${keyAt(body, ['needs', String(first), 'id']).line}, and a need's id comes once in its flow (SPEC.md §13)`, graph, `needs/${id}/twice`);
259
- }
260
- else
261
- firstAt.set(id, i);
262
- const evidence = Array.isArray(item.evidence) ? item.evidence : [];
263
- let outside = false;
264
- let kinds = 0;
265
- evidence.forEach((e, j) => {
266
- if (!isMap(e))
267
- return;
268
- const kind = kindOf(e);
269
- if (kind === undefined)
270
- return; // the schema says it names no kind
271
- kinds++;
272
- if (!IN_GRAPH.has(kind))
273
- outside = true;
274
- if (!ctx.lookFor && namesAppFile(kind, e)) {
275
- out.notLookedFor++;
276
- return;
277
- }
278
- const why = unresolved(ctx, kind, e);
279
- if (why !== null)
280
- problem('evidence-unresolved', file, body, [...at, 'evidence', String(j), kind], `need ${id}: ${why} (SPEC.md §13)`, graph, `needs/${id}/evidence/${kind}:${String(e[kind])}`);
281
- // a missing need names only what is not built: a walk leaves out a state that only missing needs name
282
- const built = kind === 'state' && isMissing(item) ? ctx.built.get(e.state) : undefined;
283
- if (built !== undefined) {
284
- problem('need-names-built', file, body, [...at, 'evidence', String(j), kind], `need ${id} is missing, and names state ${String(e.state)}, which is built: it names its code (source: ${built}). A walk on the app leaves out a state that only missing needs name, so a missing need names only what is not built yet; say in its note that it is about ${String(e.state)} (SPEC.md §13)`, graph, `needs/${id}/built/state:${String(e.state)}`);
285
- }
286
- });
287
- const missing = isMissing(item);
288
- const state = missing ? 'missing' : outside ? 'met' : 'unproven';
289
- if (first === undefined)
290
- states.set(id, state);
291
- if (state === 'unproven' && kinds > 0 && kinds === evidence.length) {
292
- problem('need-no-evidence', file, body, [...at, 'evidence'], `need ${id} is not missing and names no evidence outside the graph: what it is drawn as shows nothing built; name a source, a test, a scenario or a setting, or say why it is missing (SPEC.md §13)`, graph, `needs/${id}`);
293
- }
294
- if (!missing)
295
- return;
296
- out.gaps++;
297
- const why = text(item.missing);
298
- if (listed === null) {
299
- problem('need-unlisted', file, body, [...at, 'missing'], `need ${id} is missing, and there is no ${GAPS_FILE} above it: list it in the product's gaps, at the root of its graphs (SPEC.md §13)`, graph, `needs/${id}`);
300
- }
301
- else if (!(listed.gaps.get(key) ?? []).includes(id)) {
302
- problem('need-unlisted', file, body, [...at, 'missing'], `need ${id} is missing, and ${GAPS_FILE} does not list it under ${key}: list it there, or name its evidence and take out missing (SPEC.md §13)`, graph, `needs/${id}`);
303
- }
304
- else {
305
- problem('need-gap', file, body, [...at, 'missing'], `need ${id} is missing: ${why}`, graph, `needs/${id}`);
306
- }
307
- });
308
- cover(gapsFile, key, states);
309
- }
310
- // each gaps file among the files checked, held to the needs under its folder that it covers
311
- for (const file of files.filter((f) => basename(f) === GAPS_FILE)) {
312
- const listed = gapsOf(file);
313
- if (listed === null)
314
- continue;
315
- const byFlow = covered.get(file) ?? new Map();
316
- for (const [flow, ids] of listed.gaps) {
317
- const states = byFlow.get(flow);
318
- if (states === null)
319
- continue;
320
- if (states === undefined) {
321
- problem('gap-unknown', file, listed.text, ['gaps', flow], `${GAPS_FILE} lists gaps of ${flow}, which is no flow with a needs.yaml under its folder: take them out, or name the flow by its id (SPEC.md §13)`, listed.id, `gaps/${flow}`);
322
- continue;
323
- }
324
- ids.forEach((id, k) => {
325
- const state = states.get(id);
326
- const at = ['gaps', flow, String(k)];
327
- if (state === undefined)
328
- problem('gap-unknown', file, listed.text, at, `${GAPS_FILE} lists ${id} of ${flow}, which is no need of its needs.yaml: take it out, or name the need by its id (SPEC.md §13)`, listed.id, `gaps/${flow}/${id}`);
329
- else if (state === 'met')
330
- problem('gap-met', file, listed.text, at, `${GAPS_FILE} lists ${id} of ${flow}, which is met now: take it out, as the list only shrinks (SPEC.md §13)`, listed.id, `gaps/${flow}/${id}`);
331
- });
332
- }
333
- }
334
- return out;
335
- }
package/dist/pan.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const PAN_CSS = "\n.pz-on { position: relative; height: 78vh; min-height: 360px; overflow: hidden; margin-left: calc(50% - 50vw + 24px); margin-right: calc(50% - 50vw + 24px); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }\n.pz-on.pz-grabbing, .pz-on.pz-grabbing a { cursor: grabbing; }\n.pz-on:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }\n.pz-on svg.spine { width: 100%; height: 100%; max-width: none; padding: 0; margin: 0; }\n.pz-on a { cursor: pointer; -webkit-user-drag: none; }\n.pz-bar { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; cursor: default; }\n.pz-bar button { font: 13px system-ui, sans-serif; min-width: 32px; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }\n.pz-bar button:hover { border-color: var(--muted); } .pz-bar button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }\n.pz-bar .pz-pct { min-width: 58px; font-variant-numeric: tabular-nums; }\n.pz-hint { position: absolute; left: 10px; bottom: 10px; margin: 0; padding: 2px 8px; border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 12px; pointer-events: none; }\nhtml.pz-lock, html.pz-lock body { overflow: hidden; }\n.pz-host.pz-full { position: fixed; inset: 0; z-index: 100; margin: 0; padding: 10px 12px 12px; background: var(--bg); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto minmax(0, 1fr); align-items: center; }\n.pz-host.pz-full { row-gap: 10px; } .pz-host.pz-full > label { margin: 0; }\n.pz-host.pz-full > .pz-on { grid-column: 1 / -1; grid-row: 2; align-self: stretch; height: auto; min-height: 0; margin: 0; }\n.pz-on.pz-full { position: fixed; inset: 0; z-index: 100; height: auto; min-height: 0; margin: 0; border-radius: 0; }\n";
2
- export declare const PAN_SCRIPT = "<script>(() => {\n const PAD = 24, MAX = 4;\n for (const box of document.querySelectorAll('.pz')) {\n const svg = box.querySelector('svg.spine');\n if (!svg || !svg.viewBox.baseVal || !svg.viewBox.baseVal.width) continue;\n const W = svg.viewBox.baseVal.width, H = svg.viewBox.baseVal.height;\n const host = box.closest('.pz-host') || box;\n svg.removeAttribute('style');\n box.classList.add('pz-on');\n box.tabIndex = 0;\n\n let s = 1, x = 0, y = 0, vw = 0, vh = 0, fitted = true;\n const bar = document.createElement('div');\n bar.className = 'pz-bar';\n const button = (text, title, act) => {\n const b = document.createElement('button');\n b.type = 'button';\n b.textContent = text;\n b.title = title;\n b.addEventListener('click', act);\n bar.append(b);\n return b;\n };\n const fitScale = () => Math.max(Math.min((vw - 2 * PAD) / W, (vh - 2 * PAD) / H), 0.001);\n const minScale = () => Math.min(fitScale(), 1) / 2;\n // where the box's top left may be on an axis, in the diagram's units. Snug: centred when the diagram fits on it,\n // else from PAD before its start to PAD past its end. The hand may go further, until the diagram's edge reaches\n // the middle of the box, so it is never lost.\n const snug = (len, view) => {\n const p = PAD / s;\n return len + 2 * p <= view ? [(len - view) / 2, (len - view) / 2] : [-p, len + p - view];\n };\n const free = (len, view) => {\n const [lo, hi] = snug(len, view);\n return [Math.min(lo, -view / 2), Math.max(hi, len - view / 2)];\n };\n const within = (v, [lo, hi]) => Math.min(Math.max(v, lo), hi);\n const clamp = () => {\n x = within(x, free(W, vw / s));\n y = within(y, free(H, vh / s));\n };\n const draw = () => {\n clamp();\n svg.setAttribute('viewBox', x + ' ' + y + ' ' + vw / s + ' ' + vh / s);\n pct.textContent = Math.round(s * 100) + '%';\n };\n const zoomAt = (px, py, factor) => {\n const ns = Math.min(MAX, Math.max(minScale(), s * factor));\n const dx = x + px / s, dy = y + py / s;\n s = ns;\n x = dx - px / s;\n y = dy - py / s;\n fitted = false;\n draw();\n };\n const fit = () => {\n s = fitScale();\n x = (W - vw / s) / 2;\n y = (H - vh / s) / 2;\n fitted = true;\n draw();\n };\n const actual = () => zoomAt(vw / 2, vh / 2, 1 / s);\n const setFull = (on) => {\n host.classList.toggle('pz-full', on);\n document.documentElement.classList.toggle('pz-lock', on);\n for (const b of host.querySelectorAll('.pz-fs')) b.textContent = on ? 'Exit full window' : 'Full window';\n if (on) box.focus({ preventScroll: true });\n };\n\n button('\\u2212', 'Zoom out (\\u2212)', () => zoomAt(vw / 2, vh / 2, 0.8));\n const pct = button('100%', 'Show at 100% (Shift+0)', actual);\n pct.className = 'pz-pct';\n button('+', 'Zoom in (+)', () => zoomAt(vw / 2, vh / 2, 1.25));\n button('Fit', 'Fit the whole diagram (Shift+1)', fit);\n button('Full window', 'Give the diagram the whole window (F; Esc leaves it)', () => setFull(!host.classList.contains('pz-full'))).className = 'pz-fs';\n const hint = document.createElement('p');\n hint.className = 'pz-hint';\n hint.textContent = 'Drag to move \\u00b7 Ctrl or \\u2318 + scroll, or pinch, to zoom \\u00b7 Shift+1 fits';\n box.append(bar, hint);\n\n // a new size keeps a fitted diagram fitted, and keeps the centre of one zoomed by hand; a hidden box (the other\n // view) keeps its place for when it shows again\n new ResizeObserver(() => {\n const nw = box.clientWidth, nh = box.clientHeight;\n if (!nw || !nh) return;\n const first = !vw, cx = x + vw / (2 * s), cy = y + vh / (2 * s);\n vw = nw;\n vh = nh;\n if (first || fitted) return fit();\n x = cx - vw / (2 * s);\n y = cy - vh / (2 * s);\n draw();\n }).observe(box);\n\n let gesture = false;\n box.addEventListener('wheel', (e) => {\n if (!vw) return;\n const r = box.getBoundingClientRect();\n const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? vh : 1;\n if (e.ctrlKey || e.metaKey) {\n e.preventDefault();\n if (gesture) return;\n const d = Math.max(-50, Math.min(50, e.deltaY * unit));\n zoomAt(e.clientX - r.left, e.clientY - r.top, Math.exp(-d * 0.006));\n return;\n }\n let dx = e.deltaX * unit, dy = e.deltaY * unit;\n if (e.shiftKey && dx === 0) { dx = dy; dy = 0; }\n // the wheel moves the diagram only within its snug range (or back toward it); at the end of that range, or on a\n // diagram that fits, it scrolls the page instead\n const [xl, xh] = snug(W, vw / s), [yl, yh] = snug(H, vh / s);\n const nx = within(x + dx / s, [Math.min(xl, x), Math.max(xh, x)]);\n const ny = within(y + dy / s, [Math.min(yl, y), Math.max(yh, y)]);\n if (Math.abs(nx - x) * s < 0.5 && Math.abs(ny - y) * s < 0.5) return;\n e.preventDefault();\n x = nx;\n y = ny;\n fitted = false;\n draw();\n }, { passive: false });\n // Safari's pinch on a trackpad\n box.addEventListener('gesturestart', (e) => { e.preventDefault(); gesture = true; box.dataset.g = '1'; });\n box.addEventListener('gesturechange', (e) => {\n e.preventDefault();\n const r = box.getBoundingClientRect();\n zoomAt(e.clientX - r.left, e.clientY - r.top, e.scale / Number(box.dataset.g));\n box.dataset.g = String(e.scale);\n });\n box.addEventListener('gestureend', (e) => { e.preventDefault(); gesture = false; });\n\n // one pointer moves the diagram, two (a pinch on a touch screen) zoom it; a press that does not move is a click\n const pts = new Map();\n let drag = null, pinch = null, moved = false;\n const capture = (id) => {\n try { if (!box.hasPointerCapture(id)) box.setPointerCapture(id); } catch { /* the pointer is already gone */ }\n };\n const two = () => {\n const [a, b] = [...pts.values()];\n return { mx: (a.x + b.x) / 2, my: (a.y + b.y) / 2, d: Math.hypot(a.x - b.x, a.y - b.y) || 1 };\n };\n box.addEventListener('pointerdown', (e) => {\n if (e.target.closest('.pz-bar')) return;\n if (e.pointerType === 'mouse' && e.button !== 0 && e.button !== 1) return;\n if (e.button === 1) e.preventDefault();\n pts.set(e.pointerId, { x: e.clientX, y: e.clientY });\n if (pts.size === 1) {\n drag = { id: e.pointerId, sx: e.clientX, sy: e.clientY, x, y };\n moved = false;\n } else if (pts.size === 2) {\n pinch = two();\n drag = null;\n moved = true;\n for (const id of pts.keys()) capture(id);\n }\n });\n box.addEventListener('pointermove', (e) => {\n const p = pts.get(e.pointerId);\n if (!p) return;\n p.x = e.clientX;\n p.y = e.clientY;\n if (pinch && pts.size >= 2) {\n const n = two(), r = box.getBoundingClientRect();\n x -= (n.mx - pinch.mx) / s;\n y -= (n.my - pinch.my) / s;\n zoomAt(n.mx - r.left, n.my - r.top, n.d / pinch.d);\n pinch = n;\n return;\n }\n if (!drag || drag.id !== e.pointerId) return;\n const dx = e.clientX - drag.sx, dy = e.clientY - drag.sy;\n if (!moved && Math.hypot(dx, dy) < 4) return;\n if (!moved) {\n moved = true;\n capture(e.pointerId);\n box.classList.add('pz-grabbing');\n }\n x = drag.x - dx / s;\n y = drag.y - dy / s;\n fitted = false;\n draw();\n });\n const up = (e) => {\n if (!pts.delete(e.pointerId)) return;\n if (pts.size < 2) pinch = null;\n if (pts.size === 1) {\n // the finger left on the screen after a pinch carries on moving, from where it is now\n const [[id, p]] = [...pts];\n drag = { id, sx: p.x, sy: p.y, x, y };\n } else if (pts.size === 0) {\n drag = null;\n box.classList.remove('pz-grabbing');\n }\n };\n box.addEventListener('pointerup', up);\n box.addEventListener('pointercancel', up);\n box.addEventListener('dragstart', (e) => e.preventDefault());\n box.addEventListener('click', (e) => {\n if (moved) {\n e.preventDefault();\n e.stopPropagation();\n moved = false;\n return;\n }\n // a step's link leads to its section further down the page, which the full window would hide\n if (e.target.closest('a') && host.classList.contains('pz-full')) setFull(false);\n }, true);\n\n box.addEventListener('keydown', (e) => {\n moved = false;\n if (e.altKey || e.ctrlKey || e.metaKey || e.target.closest('.pz-bar') && (e.key === 'Enter' || e.key === ' ')) return;\n const step = e.shiftKey ? 240 : 60;\n if (e.shiftKey && e.code === 'Digit1') fit();\n else if (e.shiftKey && e.code === 'Digit0') actual();\n else if (e.key === '+' || e.key === '=') zoomAt(vw / 2, vh / 2, 1.25);\n else if (e.key === '-' || e.key === '_') zoomAt(vw / 2, vh / 2, 0.8);\n else if (e.key === 'ArrowLeft') { x -= step / s; fitted = false; draw(); }\n else if (e.key === 'ArrowRight') { x += step / s; fitted = false; draw(); }\n else if (e.key === 'ArrowUp') { y -= step / s; fitted = false; draw(); }\n else if (e.key === 'ArrowDown') { y += step / s; fitted = false; draw(); }\n else if (e.key === 'f' || e.key === 'F') setFull(!host.classList.contains('pz-full'));\n else if (e.key === 'Escape' && host.classList.contains('pz-full')) setFull(false);\n else return;\n e.preventDefault();\n });\n document.addEventListener('keydown', (e) => {\n if (e.key === 'Escape' && host.classList.contains('pz-full') && !box.contains(document.activeElement)) setFull(false);\n });\n }\n})();</script>";
package/dist/pan.js DELETED
@@ -1,252 +0,0 @@
1
- // The diagram as a canvas to move around, as in a design tool: it opens fitted to its box, a drag moves it (the hand),
2
- // Ctrl or ⌘ with the wheel, or a pinch, zooms at the pointer, and the wheel alone moves it until an edge, after which
3
- // the page scrolls on. Shift+1 fits it again, Shift+0 shows it at 100%, and "Full window" gives it the whole window.
4
- // Without scripts the page keeps its plain diagram, which scrolls sideways.
5
- export const PAN_CSS = `
6
- .pz-on { position: relative; height: 78vh; min-height: 360px; overflow: hidden; margin-left: calc(50% - 50vw + 24px); margin-right: calc(50% - 50vw + 24px); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
7
- .pz-on.pz-grabbing, .pz-on.pz-grabbing a { cursor: grabbing; }
8
- .pz-on:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
9
- .pz-on svg.spine { width: 100%; height: 100%; max-width: none; padding: 0; margin: 0; }
10
- .pz-on a { cursor: pointer; -webkit-user-drag: none; }
11
- .pz-bar { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; cursor: default; }
12
- .pz-bar button { font: 13px system-ui, sans-serif; min-width: 32px; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
13
- .pz-bar button:hover { border-color: var(--muted); } .pz-bar button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
14
- .pz-bar .pz-pct { min-width: 58px; font-variant-numeric: tabular-nums; }
15
- .pz-hint { position: absolute; left: 10px; bottom: 10px; margin: 0; padding: 2px 8px; border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 12px; pointer-events: none; }
16
- html.pz-lock, html.pz-lock body { overflow: hidden; }
17
- .pz-host.pz-full { position: fixed; inset: 0; z-index: 100; margin: 0; padding: 10px 12px 12px; background: var(--bg); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto minmax(0, 1fr); align-items: center; }
18
- .pz-host.pz-full { row-gap: 10px; } .pz-host.pz-full > label { margin: 0; }
19
- .pz-host.pz-full > .pz-on { grid-column: 1 / -1; grid-row: 2; align-self: stretch; height: auto; min-height: 0; margin: 0; }
20
- .pz-on.pz-full { position: fixed; inset: 0; z-index: 100; height: auto; min-height: 0; margin: 0; border-radius: 0; }
21
- `;
22
- // plain JavaScript, run as the page loads; it reads no data and sends nothing
23
- export const PAN_SCRIPT = `<script>(() => {
24
- const PAD = 24, MAX = 4;
25
- for (const box of document.querySelectorAll('.pz')) {
26
- const svg = box.querySelector('svg.spine');
27
- if (!svg || !svg.viewBox.baseVal || !svg.viewBox.baseVal.width) continue;
28
- const W = svg.viewBox.baseVal.width, H = svg.viewBox.baseVal.height;
29
- const host = box.closest('.pz-host') || box;
30
- svg.removeAttribute('style');
31
- box.classList.add('pz-on');
32
- box.tabIndex = 0;
33
-
34
- let s = 1, x = 0, y = 0, vw = 0, vh = 0, fitted = true;
35
- const bar = document.createElement('div');
36
- bar.className = 'pz-bar';
37
- const button = (text, title, act) => {
38
- const b = document.createElement('button');
39
- b.type = 'button';
40
- b.textContent = text;
41
- b.title = title;
42
- b.addEventListener('click', act);
43
- bar.append(b);
44
- return b;
45
- };
46
- const fitScale = () => Math.max(Math.min((vw - 2 * PAD) / W, (vh - 2 * PAD) / H), 0.001);
47
- const minScale = () => Math.min(fitScale(), 1) / 2;
48
- // where the box's top left may be on an axis, in the diagram's units. Snug: centred when the diagram fits on it,
49
- // else from PAD before its start to PAD past its end. The hand may go further, until the diagram's edge reaches
50
- // the middle of the box, so it is never lost.
51
- const snug = (len, view) => {
52
- const p = PAD / s;
53
- return len + 2 * p <= view ? [(len - view) / 2, (len - view) / 2] : [-p, len + p - view];
54
- };
55
- const free = (len, view) => {
56
- const [lo, hi] = snug(len, view);
57
- return [Math.min(lo, -view / 2), Math.max(hi, len - view / 2)];
58
- };
59
- const within = (v, [lo, hi]) => Math.min(Math.max(v, lo), hi);
60
- const clamp = () => {
61
- x = within(x, free(W, vw / s));
62
- y = within(y, free(H, vh / s));
63
- };
64
- const draw = () => {
65
- clamp();
66
- svg.setAttribute('viewBox', x + ' ' + y + ' ' + vw / s + ' ' + vh / s);
67
- pct.textContent = Math.round(s * 100) + '%';
68
- };
69
- const zoomAt = (px, py, factor) => {
70
- const ns = Math.min(MAX, Math.max(minScale(), s * factor));
71
- const dx = x + px / s, dy = y + py / s;
72
- s = ns;
73
- x = dx - px / s;
74
- y = dy - py / s;
75
- fitted = false;
76
- draw();
77
- };
78
- const fit = () => {
79
- s = fitScale();
80
- x = (W - vw / s) / 2;
81
- y = (H - vh / s) / 2;
82
- fitted = true;
83
- draw();
84
- };
85
- const actual = () => zoomAt(vw / 2, vh / 2, 1 / s);
86
- const setFull = (on) => {
87
- host.classList.toggle('pz-full', on);
88
- document.documentElement.classList.toggle('pz-lock', on);
89
- for (const b of host.querySelectorAll('.pz-fs')) b.textContent = on ? 'Exit full window' : 'Full window';
90
- if (on) box.focus({ preventScroll: true });
91
- };
92
-
93
- button('\\u2212', 'Zoom out (\\u2212)', () => zoomAt(vw / 2, vh / 2, 0.8));
94
- const pct = button('100%', 'Show at 100% (Shift+0)', actual);
95
- pct.className = 'pz-pct';
96
- button('+', 'Zoom in (+)', () => zoomAt(vw / 2, vh / 2, 1.25));
97
- button('Fit', 'Fit the whole diagram (Shift+1)', fit);
98
- button('Full window', 'Give the diagram the whole window (F; Esc leaves it)', () => setFull(!host.classList.contains('pz-full'))).className = 'pz-fs';
99
- const hint = document.createElement('p');
100
- hint.className = 'pz-hint';
101
- hint.textContent = 'Drag to move \\u00b7 Ctrl or \\u2318 + scroll, or pinch, to zoom \\u00b7 Shift+1 fits';
102
- box.append(bar, hint);
103
-
104
- // a new size keeps a fitted diagram fitted, and keeps the centre of one zoomed by hand; a hidden box (the other
105
- // view) keeps its place for when it shows again
106
- new ResizeObserver(() => {
107
- const nw = box.clientWidth, nh = box.clientHeight;
108
- if (!nw || !nh) return;
109
- const first = !vw, cx = x + vw / (2 * s), cy = y + vh / (2 * s);
110
- vw = nw;
111
- vh = nh;
112
- if (first || fitted) return fit();
113
- x = cx - vw / (2 * s);
114
- y = cy - vh / (2 * s);
115
- draw();
116
- }).observe(box);
117
-
118
- let gesture = false;
119
- box.addEventListener('wheel', (e) => {
120
- if (!vw) return;
121
- const r = box.getBoundingClientRect();
122
- const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? vh : 1;
123
- if (e.ctrlKey || e.metaKey) {
124
- e.preventDefault();
125
- if (gesture) return;
126
- const d = Math.max(-50, Math.min(50, e.deltaY * unit));
127
- zoomAt(e.clientX - r.left, e.clientY - r.top, Math.exp(-d * 0.006));
128
- return;
129
- }
130
- let dx = e.deltaX * unit, dy = e.deltaY * unit;
131
- if (e.shiftKey && dx === 0) { dx = dy; dy = 0; }
132
- // the wheel moves the diagram only within its snug range (or back toward it); at the end of that range, or on a
133
- // diagram that fits, it scrolls the page instead
134
- const [xl, xh] = snug(W, vw / s), [yl, yh] = snug(H, vh / s);
135
- const nx = within(x + dx / s, [Math.min(xl, x), Math.max(xh, x)]);
136
- const ny = within(y + dy / s, [Math.min(yl, y), Math.max(yh, y)]);
137
- if (Math.abs(nx - x) * s < 0.5 && Math.abs(ny - y) * s < 0.5) return;
138
- e.preventDefault();
139
- x = nx;
140
- y = ny;
141
- fitted = false;
142
- draw();
143
- }, { passive: false });
144
- // Safari's pinch on a trackpad
145
- box.addEventListener('gesturestart', (e) => { e.preventDefault(); gesture = true; box.dataset.g = '1'; });
146
- box.addEventListener('gesturechange', (e) => {
147
- e.preventDefault();
148
- const r = box.getBoundingClientRect();
149
- zoomAt(e.clientX - r.left, e.clientY - r.top, e.scale / Number(box.dataset.g));
150
- box.dataset.g = String(e.scale);
151
- });
152
- box.addEventListener('gestureend', (e) => { e.preventDefault(); gesture = false; });
153
-
154
- // one pointer moves the diagram, two (a pinch on a touch screen) zoom it; a press that does not move is a click
155
- const pts = new Map();
156
- let drag = null, pinch = null, moved = false;
157
- const capture = (id) => {
158
- try { if (!box.hasPointerCapture(id)) box.setPointerCapture(id); } catch { /* the pointer is already gone */ }
159
- };
160
- const two = () => {
161
- const [a, b] = [...pts.values()];
162
- return { mx: (a.x + b.x) / 2, my: (a.y + b.y) / 2, d: Math.hypot(a.x - b.x, a.y - b.y) || 1 };
163
- };
164
- box.addEventListener('pointerdown', (e) => {
165
- if (e.target.closest('.pz-bar')) return;
166
- if (e.pointerType === 'mouse' && e.button !== 0 && e.button !== 1) return;
167
- if (e.button === 1) e.preventDefault();
168
- pts.set(e.pointerId, { x: e.clientX, y: e.clientY });
169
- if (pts.size === 1) {
170
- drag = { id: e.pointerId, sx: e.clientX, sy: e.clientY, x, y };
171
- moved = false;
172
- } else if (pts.size === 2) {
173
- pinch = two();
174
- drag = null;
175
- moved = true;
176
- for (const id of pts.keys()) capture(id);
177
- }
178
- });
179
- box.addEventListener('pointermove', (e) => {
180
- const p = pts.get(e.pointerId);
181
- if (!p) return;
182
- p.x = e.clientX;
183
- p.y = e.clientY;
184
- if (pinch && pts.size >= 2) {
185
- const n = two(), r = box.getBoundingClientRect();
186
- x -= (n.mx - pinch.mx) / s;
187
- y -= (n.my - pinch.my) / s;
188
- zoomAt(n.mx - r.left, n.my - r.top, n.d / pinch.d);
189
- pinch = n;
190
- return;
191
- }
192
- if (!drag || drag.id !== e.pointerId) return;
193
- const dx = e.clientX - drag.sx, dy = e.clientY - drag.sy;
194
- if (!moved && Math.hypot(dx, dy) < 4) return;
195
- if (!moved) {
196
- moved = true;
197
- capture(e.pointerId);
198
- box.classList.add('pz-grabbing');
199
- }
200
- x = drag.x - dx / s;
201
- y = drag.y - dy / s;
202
- fitted = false;
203
- draw();
204
- });
205
- const up = (e) => {
206
- if (!pts.delete(e.pointerId)) return;
207
- if (pts.size < 2) pinch = null;
208
- if (pts.size === 1) {
209
- // the finger left on the screen after a pinch carries on moving, from where it is now
210
- const [[id, p]] = [...pts];
211
- drag = { id, sx: p.x, sy: p.y, x, y };
212
- } else if (pts.size === 0) {
213
- drag = null;
214
- box.classList.remove('pz-grabbing');
215
- }
216
- };
217
- box.addEventListener('pointerup', up);
218
- box.addEventListener('pointercancel', up);
219
- box.addEventListener('dragstart', (e) => e.preventDefault());
220
- box.addEventListener('click', (e) => {
221
- if (moved) {
222
- e.preventDefault();
223
- e.stopPropagation();
224
- moved = false;
225
- return;
226
- }
227
- // a step's link leads to its section further down the page, which the full window would hide
228
- if (e.target.closest('a') && host.classList.contains('pz-full')) setFull(false);
229
- }, true);
230
-
231
- box.addEventListener('keydown', (e) => {
232
- moved = false;
233
- if (e.altKey || e.ctrlKey || e.metaKey || e.target.closest('.pz-bar') && (e.key === 'Enter' || e.key === ' ')) return;
234
- const step = e.shiftKey ? 240 : 60;
235
- if (e.shiftKey && e.code === 'Digit1') fit();
236
- else if (e.shiftKey && e.code === 'Digit0') actual();
237
- else if (e.key === '+' || e.key === '=') zoomAt(vw / 2, vh / 2, 1.25);
238
- else if (e.key === '-' || e.key === '_') zoomAt(vw / 2, vh / 2, 0.8);
239
- else if (e.key === 'ArrowLeft') { x -= step / s; fitted = false; draw(); }
240
- else if (e.key === 'ArrowRight') { x += step / s; fitted = false; draw(); }
241
- else if (e.key === 'ArrowUp') { y -= step / s; fitted = false; draw(); }
242
- else if (e.key === 'ArrowDown') { y += step / s; fitted = false; draw(); }
243
- else if (e.key === 'f' || e.key === 'F') setFull(!host.classList.contains('pz-full'));
244
- else if (e.key === 'Escape' && host.classList.contains('pz-full')) setFull(false);
245
- else return;
246
- e.preventDefault();
247
- });
248
- document.addEventListener('keydown', (e) => {
249
- if (e.key === 'Escape' && host.classList.contains('pz-full') && !box.contains(document.activeElement)) setFull(false);
250
- });
251
- }
252
- })();</script>`;
package/dist/schemas.d.ts DELETED
@@ -1,15 +0,0 @@
1
- export type SchemaKind = 'flow' | 'ui' | 'domain' | 'nav' | 'catalog' | 'needs' | 'gaps';
2
- export interface SchemaFinding {
3
- line: number;
4
- column: number;
5
- message: string;
6
- graph: string | null;
7
- element: string;
8
- }
9
- export declare function schemaKindOf(file: string): SchemaKind | null;
10
- export interface AnchorPlace {
11
- path: string[];
12
- value: string;
13
- }
14
- export declare function anchorsIn(kind: SchemaKind, data: unknown): AnchorPlace[];
15
- export declare function validateFile(file: string): SchemaFinding[];