@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/diff-nav.js DELETED
@@ -1,401 +0,0 @@
1
- import { GraphError } from './graph.js';
2
- import { checkGoals, findings, menuRows, pathTo, viewOf } from './nav.js';
3
- import { deepDiff, fieldChanges, joinWords, listChanges, matchOrdered, moved, otherKeys, quote, same, union } from './compare.js';
4
- const raw = (x) => (x ?? {});
5
- const opOf = (b, a) => (b === undefined ? 'added' : a === undefined ? 'removed' : 'changed');
6
- const capital = (s) => s.charAt(0).toUpperCase() + s.slice(1);
7
- const KIND_WORDS = { screen: 'built', placeholder: 'not built', missing: 'a page that does not exist', redirect: 'a redirect', external: 'another application' };
8
- const STANDING_WORDS = { ok: 'opens', placeholder: 'is not built', missing: 'does not exist', refused: 'refuses them', unreachable: 'cannot be reached' };
9
- const STANDING_NOW = { ok: 'now opens', placeholder: 'is now not built', missing: 'now does not exist', refused: 'now refuses them', unreachable: 'can no longer be reached' };
10
- const STANDING_PAST = { ok: 'opened', placeholder: 'was not built', missing: 'did not exist', refused: 'refused them', unreachable: 'could not be reached' };
11
- const word = (g, key) => g.catalog[key] ?? key;
12
- const pageName = (g, id) => (id === null ? 'no page' : g.pages[id] === undefined ? id : quote(g.pages[id].title));
13
- const fromTokens = (s) => (Array.isArray(s.from) ? s.from : [s.from]);
14
- const menuName = (g, frame) => (g.frames[frame]?.menu ?? frame).toLowerCase();
15
- function fromWords(g, s) {
16
- return joinWords(fromTokens(s).map((t) => {
17
- if (!t.startsWith('frame:'))
18
- return pageName(g, t);
19
- const frame = t.slice('frame:'.length);
20
- const f = g.frames[frame];
21
- if (f === undefined)
22
- return t;
23
- return s.how === 'menu' && f.menu !== undefined ? `the ${menuName(g, frame)}` : `every page of ${quote(f.title)}`;
24
- }));
25
- }
26
- function entryWords(g, s) {
27
- const label = s.label === undefined ? '' : quote(word(g, s.label));
28
- if (s.how === 'menu')
29
- return `menu entry ${label} in ${fromWords(g, s)}`;
30
- if (s.how === 'picker')
31
- return `scope picker entry ${label} on ${fromWords(g, s)}`;
32
- if (s.how === 'user')
33
- return `entry ${label} in the person’s corner of ${fromWords(g, s)}`;
34
- if (s.how === 'auto')
35
- return `automatic redirect from ${fromWords(g, s)}`;
36
- return `${s.how} ${label} on ${fromWords(g, s)}`;
37
- }
38
- const entryKey = (s) => `entry ${s.id ?? `${fromTokens(s).join(', ')} → ${s.to} (${s.how})`}`;
39
- const pathWords = (g, v, page) => {
40
- const words = pathTo(v.reach, page).filter((e) => e.label !== '').map((e) => e.label);
41
- // a way that starts at a page opened by its address (SPEC.md §6)
42
- const typed = v.reach.get(page)?.byAddress ?? null;
43
- if (typed !== null) {
44
- if (typed === page)
45
- return 'by its address';
46
- const at = g.pages[typed] === undefined ? typed : quote(g.pages[typed].title);
47
- return `by the address of ${at}${words.length === 0 ? '' : `, then ${words.join(' → ')}`}`;
48
- }
49
- return words.length === 0 ? 'automatic' : words.join(' → ');
50
- };
51
- function pageFields(p) {
52
- return { route: p.route, title: p.titleKey ?? p.title, kind: p.kind, frame: p.frame, opensFor: p.opensFor ?? undefined, refusal: p.refusal ?? undefined, byAddress: p.byAddress ? true : undefined, pageCodes: p.pageCodes ?? undefined, source: p.source ?? undefined, evidence: p.evidence ?? undefined };
53
- }
54
- export function navStructure(b, a) {
55
- const out = [];
56
- const gb = b.g;
57
- const ga = a.g;
58
- // the graph itself
59
- const meta = (g) => ({ id: g.id, title: g.title, status: g.status, summary: g.summary, locale: g.locale, adapter: g.adapter ?? undefined });
60
- out.push(...fieldChanges('graph', 'graph', meta(gb), meta(ga), ['title', 'summary', 'status', 'locale', 'id', 'adapter'], (f, x, y) => {
61
- if (f === 'title')
62
- return `The graph is now called ${quote(String(y))} (was ${quote(String(x))}).`;
63
- if (f === 'summary')
64
- return `New summary: ${quote(String(y))}`;
65
- if (f === 'status')
66
- return `Status: ${String(x)} → ${String(y)}.`;
67
- if (f === 'locale')
68
- return `The wording is now in ${String(y)} (was ${String(x)}).`;
69
- return null;
70
- }));
71
- deepDiff('citations', 'graph source', gb.source, ga.source, out);
72
- // frames
73
- for (const id of union(gb.frames, ga.frames)) {
74
- const x = gb.frames[id];
75
- const y = ga.frames[id];
76
- if (same(x, y))
77
- continue;
78
- const key = `frame ${id}`;
79
- if (x === undefined || y === undefined) {
80
- const f = (y ?? x);
81
- out.push({ area: 'frames', key, op: opOf(x, y), say: y === undefined ? `The frame ${quote(f.title)} was removed.` : `New frame: ${quote(f.title)}${f.menu === undefined ? '' : `, with the ${f.menu.toLowerCase()}`}.` });
82
- continue;
83
- }
84
- out.push(...fieldChanges('frames', key, raw(x), raw(y), ['title', 'menu', 'shows'], (f, p, q) => {
85
- if (f === 'title')
86
- return `The frame ${quote(x.title)} is now called ${quote(y.title)}.`;
87
- if (f === 'menu')
88
- return q === undefined ? `${quote(y.title)} no longer carries a menu.` : `${quote(y.title)} now carries the ${String(q).toLowerCase()}${p === undefined ? '' : ` (was the ${String(p).toLowerCase()})`}.`;
89
- return null;
90
- }));
91
- }
92
- // facts and named conditions: formal, listed under the exact changes; who they affect shows under behaviour
93
- for (const id of union(gb.facts, ga.facts)) {
94
- if (!same(gb.facts[id], ga.facts[id]))
95
- out.push({ area: 'facts', key: `fact ${id}`, op: opOf(gb.facts[id], ga.facts[id]), before: gb.facts[id], after: ga.facts[id], say: null });
96
- }
97
- for (const id of union(gb.guards, ga.guards)) {
98
- if (!same(gb.guards[id], ga.guards[id]))
99
- out.push({ area: 'facts', key: `guard ${id}`, op: opOf(gb.guards[id], ga.guards[id]), before: gb.guards[id], after: ga.guards[id], say: null });
100
- }
101
- // kinds of user
102
- const pb = Object.fromEntries(gb.personas.map((p) => [p.id, p]));
103
- const pa = Object.fromEntries(ga.personas.map((p) => [p.id, p]));
104
- for (const id of union(pb, pa)) {
105
- const x = pb[id];
106
- const y = pa[id];
107
- if (same(x, y))
108
- continue;
109
- const key = `persona ${id}`;
110
- if (x === undefined) {
111
- out.push({ area: 'people', key, op: 'added', say: `New kind of user: ${quote(y.title)}, ${y.say}.` });
112
- continue;
113
- }
114
- if (y === undefined) {
115
- out.push({ area: 'people', key, op: 'removed', say: `Kind of user removed: ${quote(x.title)}.` });
116
- continue;
117
- }
118
- if (x.title !== y.title)
119
- out.push({ area: 'people', key, op: 'changed', field: 'title', before: x.title, after: y.title, say: `${quote(x.title)} is now called ${quote(y.title)}.` });
120
- if (x.say !== y.say)
121
- out.push({ area: 'people', key, op: 'changed', field: 'say', before: x.say, after: y.say, say: `${quote(y.title)} is now described as: ${y.say}.` });
122
- for (const fact of union(x.facts, y.facts)) {
123
- const p = x.facts[fact];
124
- const q = y.facts[fact];
125
- if (same(p, q))
126
- continue;
127
- let say;
128
- if (Array.isArray(p) && Array.isArray(q)) {
129
- const ch = listChanges(p.map(String), q.map(String));
130
- const parts = [ch.added.length > 0 ? `now also has ${ch.added.join(', ')}` : '', ch.removed.length > 0 ? `no longer has ${ch.removed.join(', ')}` : ''].filter((s) => s !== '');
131
- say = `${quote(y.title)}: ${fact} ${parts.length > 0 ? parts.join('; ') : 'is in a new order'}.`;
132
- }
133
- else
134
- say = `${quote(y.title)}: ${fact} is now ${String(q)} (was ${String(p)}).`;
135
- out.push({ area: 'people', key, op: opOf(p, q), field: `facts.${fact}`, before: p, after: q, say });
136
- }
137
- }
138
- // pages
139
- for (const id of union(gb.pages, ga.pages)) {
140
- const x = gb.pages[id];
141
- const y = ga.pages[id];
142
- const key = `page ${id}`;
143
- if (x === undefined) {
144
- out.push({ area: 'pages', key, op: 'added', say: `New page ${pageName(ga, id)} (${y.route})${y.kind === 'screen' ? '' : `, ${KIND_WORDS[y.kind]}`}.` });
145
- continue;
146
- }
147
- if (y === undefined) {
148
- out.push({ area: 'pages', key, op: 'removed', say: `Page ${pageName(gb, id)} (${x.route}) removed.` });
149
- continue;
150
- }
151
- const name = pageName(ga, id);
152
- out.push(...fieldChanges('pages', key, pageFields(x), pageFields(y), ['route', 'title', 'kind', 'frame', 'opensFor', 'refusal', 'byAddress', 'pageCodes', 'source', 'evidence'], (f, p, q) => {
153
- if (f === 'route')
154
- return `${name} moved to ${String(q)} (was ${String(p)}).`;
155
- if (f === 'title')
156
- return `${pageName(gb, id)} is now titled ${name}.`;
157
- if (f === 'kind')
158
- return `${name} is now ${KIND_WORDS[String(q)]} (was ${KIND_WORDS[String(p)]}).`;
159
- if (f === 'frame')
160
- return `${name} is now drawn in ${quote(ga.frames[String(q)]?.title ?? String(q))} (was ${quote(gb.frames[String(p)]?.title ?? String(p))}).`;
161
- if (f === 'opensFor')
162
- return q === undefined ? `${name} now opens for everyone.` : p === undefined ? `${name} now opens only for some people.` : `Who ${name} opens for changed.`;
163
- if (f === 'refusal')
164
- return q === undefined ? `${name} no longer says how it refuses.` : `${name} now refuses with: ${quote(String(q))}.`;
165
- if (f === 'byAddress')
166
- return q === true ? `${name} is now opened by its address.` : `${name} is no longer opened by its address.`;
167
- return null;
168
- }));
169
- }
170
- // menus, links and buttons: entries are paired by their id or by where they start, where they go, how and their label;
171
- // what is left by (start, how, label) when the target changed, then by (start, target, how) when the label changed
172
- const sb = gb.specs;
173
- const sa = ga.specs;
174
- const k1 = (s) => s.id ?? `${fromTokens(s).join(',')}|${s.to}|${s.how}|${s.label ?? ''}`;
175
- const k2 = (s) => (s.id !== undefined ? null : `${fromTokens(s).join(',')}|${s.how}|${s.label ?? ''}`);
176
- const k3 = (s) => (s.id !== undefined ? null : `${fromTokens(s).join(',')}|${s.to}|${s.how}`);
177
- const pairs = matchOrdered(sb, sa, [k1, k2, k3]);
178
- const inB = new Set(pairs.map((p) => p[0]));
179
- const inA = new Set(pairs.map((p) => p[1]));
180
- sa.forEach((s, j) => {
181
- if (inA.has(j))
182
- return;
183
- out.push({ area: 'entries', key: entryKey(s), op: 'added', after: s, say: `New ${entryWords(ga, s)} → ${pageName(ga, s.to)}.` });
184
- });
185
- sb.forEach((s, i) => {
186
- if (inB.has(i))
187
- return;
188
- out.push({ area: 'entries', key: entryKey(s), op: 'removed', before: s, say: `Removed: the ${entryWords(gb, s)} → ${pageName(gb, s.to)}.` });
189
- });
190
- const ENTRY_KNOWN = ['id', 'from', 'to', 'how', 'label', 'when', 'clicks', 'data', 'back'];
191
- for (const [i, j] of pairs) {
192
- const x = sb[i];
193
- const y = sa[j];
194
- const what = `The ${entryWords(ga, y)}`;
195
- out.push(...fieldChanges('entries', entryKey(y), raw(x), raw(y), ENTRY_KNOWN, (f, p, q) => {
196
- if (f === 'to')
197
- return `${what} now opens ${pageName(ga, y.to)} (was ${pageName(gb, x.to)}).`;
198
- if (f === 'label')
199
- return `The ${entryWords(gb, x)} now reads ${quote(word(ga, y.label ?? ''))}.`;
200
- if (f === 'when')
201
- return `Who sees the ${entryWords(ga, y)} changed.`;
202
- if (f === 'clicks')
203
- return `${what} now takes ${String(q ?? 1)} clicks (was ${String(p ?? 1)}).`;
204
- if (f === 'data')
205
- return q === true ? `${what} now needs an item in a list.` : `${what} no longer needs an item in a list.`;
206
- if (f === 'back')
207
- return q === true ? `${what} now goes back.` : `${what} no longer goes back.`;
208
- return null;
209
- }));
210
- otherKeys(entryKey(y), raw(x), raw(y), ENTRY_KNOWN, out);
211
- }
212
- // the order of a menu is what people see; other entries are not ordered for them
213
- const groups = new Map();
214
- for (const [i, j] of pairs) {
215
- if (sb[i].how !== 'menu' || sa[j].how !== 'menu')
216
- continue;
217
- const g = fromTokens(sa[j]).join(',');
218
- groups.set(g, [...(groups.get(g) ?? []), [i, j]]);
219
- }
220
- for (const [g, group] of groups) {
221
- const posB = sb.map((s, i) => [s, i]).filter(([s]) => s.how === 'menu' && fromTokens(s).join(',') === g).map(([, i]) => i);
222
- const posA = sa.map((s, j) => [s, j]).filter(([s]) => s.how === 'menu' && fromTokens(s).join(',') === g).map(([, j]) => j);
223
- for (const [i, j] of moved(group)) {
224
- const s = sa[j];
225
- out.push({ area: 'entries', key: entryKey(s), op: 'moved', before: posB.indexOf(i) + 1, after: posA.indexOf(j) + 1, say: `In ${fromWords(ga, s)}, ${quote(word(ga, s.label ?? ''))} is now entry ${posA.indexOf(j) + 1} (was ${posB.indexOf(i) + 1}).` });
226
- }
227
- }
228
- // goals
229
- const goalsB = Object.fromEntries(gb.goals.map((x) => [x.id, x]));
230
- const goalsA = Object.fromEntries(ga.goals.map((x) => [x.id, x]));
231
- if (Object.keys(goalsB).length !== gb.goals.length || Object.keys(goalsA).length !== ga.goals.length)
232
- throw new GraphError('a goal id is written twice');
233
- const who = (g, ids) => joinWords(ids.map((id) => quote(g.personas.find((p) => p.id === id)?.title ?? id)));
234
- for (const id of union(goalsB, goalsA)) {
235
- const x = goalsB[id];
236
- const y = goalsA[id];
237
- if (same(x, y))
238
- continue;
239
- const key = `goal ${id}`;
240
- if (x === undefined)
241
- out.push({ area: 'goals', key, op: 'added', say: `New goal: ${quote(y.say)}, for ${who(ga, y.for)}, within ${y.within} ${y.within === 1 ? 'click' : 'clicks'}.` });
242
- else if (y === undefined)
243
- out.push({ area: 'goals', key, op: 'removed', say: `Goal dropped: ${quote(x.say)}.` });
244
- else {
245
- out.push(...fieldChanges('goals', key, raw(x), raw(y), ['say', 'page', 'for', 'within'], (f) => {
246
- if (f === 'say')
247
- return `Goal reworded: ${quote(y.say)} (was ${quote(x.say)}).`;
248
- if (f === 'page')
249
- return `The goal ${quote(y.say)} now means reaching ${pageName(ga, y.page)} (was ${pageName(gb, x.page)}).`;
250
- if (f === 'for')
251
- return `The goal ${quote(y.say)} is now checked for ${who(ga, y.for)} (was ${who(gb, x.for)}).`;
252
- return `The goal ${quote(y.say)} now allows ${y.within} ${y.within === 1 ? 'click' : 'clicks'} (was ${x.within}).`;
253
- }));
254
- otherKeys(key, raw(x), raw(y), ['id', 'say', 'page', 'for', 'within'], out);
255
- }
256
- }
257
- const nm = listChanges(gb.notModeled, ga.notModeled);
258
- for (const x of nm.added)
259
- out.push({ area: 'notModeled', key: 'notModeled', op: 'added', after: x, say: `Now listed as not modeled: ${quote(x)}.` });
260
- for (const x of nm.removed)
261
- out.push({ area: 'notModeled', key: 'notModeled', op: 'removed', before: x, say: `No longer listed as not modeled: ${quote(x)}.` });
262
- for (const k of union(gb.catalog, ga.catalog)) {
263
- const p = gb.catalog[k];
264
- const q = ga.catalog[k];
265
- if (p === q)
266
- continue;
267
- out.push({ area: 'wording', key: `catalog ${k}`, op: opOf(p, q), before: p, after: q, say: p === undefined ? `New text: ${quote(q)}.` : q === undefined ? `Text removed: ${quote(p)}.` : `${quote(p)} now reads ${quote(q)}.` });
268
- }
269
- return { changes: out, entries: pairs };
270
- }
271
- export function runNav(g, side) {
272
- try {
273
- const views = g.personas.map((p) => viewOf(g, p));
274
- const goals = checkGoals(g, views);
275
- return { g, views, goals, found: findings(g, views, goals) };
276
- }
277
- catch (err) {
278
- throw new GraphError(`${side}: ${err.message}`);
279
- }
280
- }
281
- const outcomeWords = (c) => (c === undefined ? 'not checked' : c.outcome === 'ok' ? `ok, ${c.clicks} of ${c.goal.within} ${c.goal.within === 1 ? 'click' : 'clicks'}` : c.outcome === 'too many clicks' ? `${c.clicks} clicks, the limit is ${c.goal.within}` : c.outcome);
282
- export function navBehaviour(rb, ra, s) {
283
- const out = [];
284
- const gb = rb.g;
285
- const ga = ra.g;
286
- const rowsB = menuRows(gb, rb.views);
287
- const rowsA = menuRows(ga, ra.views);
288
- const pairedA = new Map(s.entries.map(([i, j]) => [j, i]));
289
- const pairedB = new Set(s.entries.map(([i]) => i));
290
- for (const [ia, va] of ra.views.entries()) {
291
- const id = va.persona.id;
292
- const who = va.persona.title;
293
- const ib = rb.views.findIndex((v) => v.persona.id === id);
294
- const add = (topic, key, before, after, say, worse = false) => {
295
- out.push({ topic, key: `${id} ${key}`, persona: who, before, after, say, detail: [], worse });
296
- };
297
- const reached = (v, p) => v.standing[p] !== undefined && v.standing[p] !== 'unreachable';
298
- if (ib < 0) {
299
- const n = Object.keys(ga.pages).filter((p) => reached(va, p)).length;
300
- add('persona', 'new', null, va.landing, `A new kind of user: lands on ${pageName(ga, va.landing)} and reaches ${n} of ${Object.keys(ga.pages).length} pages.`);
301
- continue;
302
- }
303
- const vb = rb.views[ib];
304
- if (vb.landing !== va.landing)
305
- add('landing', 'landing', vb.landing, va.landing, `Lands on ${pageName(ga, va.landing)} (was ${pageName(gb, vb.landing)}).`);
306
- for (const page of union(gb.pages, ga.pages)) {
307
- const inB = gb.pages[page] !== undefined && reached(vb, page);
308
- const inA = ga.pages[page] !== undefined && reached(va, page);
309
- const name = ga.pages[page] === undefined ? pageName(gb, page) : pageName(ga, page);
310
- if (!inB && inA) {
311
- const st = va.standing[page];
312
- add('page', page, null, { clicks: va.reach.get(page)?.clicks, standing: st }, `Can now reach ${name}${st === 'ok' ? '' : `, which ${STANDING_WORDS[st]}`} (${va.reach.get(page)?.clicks ?? 0} clicks: ${pathWords(ga, va, page)}).`);
313
- }
314
- else if (inB && !inA) {
315
- add('page', page, { clicks: vb.reach.get(page)?.clicks, standing: vb.standing[page] }, null, `Can no longer reach ${name}${ga.pages[page] === undefined ? ' (the page was removed)' : ''}.`);
316
- }
317
- else if (inB && inA) {
318
- const stB = vb.standing[page];
319
- const stA = va.standing[page];
320
- if (stB !== stA)
321
- add('page', page, stB, stA, `${capital(name)} ${STANDING_NOW[stA]} (it ${STANDING_PAST[stB]}).`);
322
- const cb = vb.reach.get(page)?.clicks ?? 0;
323
- const ca = va.reach.get(page)?.clicks ?? 0;
324
- if (cb !== ca)
325
- add('clicks', page, cb, ca, `${capital(name)}: ${cb} → ${ca} ${ca === 1 ? 'click' : 'clicks'} (${pathWords(ga, va, page)}).`);
326
- }
327
- }
328
- // the menu they see
329
- for (const row of rowsA) {
330
- const shownA = row.cells[ia].shown;
331
- const i = pairedA.get(row.spec);
332
- const rowB = i === undefined ? undefined : rowsB.find((r) => r.spec === i);
333
- const shownB = rowB === undefined ? false : rowB.cells[ib].shown;
334
- const label = quote(row.entry.label);
335
- if (shownA && !shownB)
336
- add('menu', entryKey(ga.specs[row.spec]), false, true, `Their ${menuName(ga, row.frame)} now shows ${label}${i === undefined ? ' (a new entry)' : ''}.`);
337
- else if (!shownA && shownB)
338
- add('menu', entryKey(ga.specs[row.spec]), true, false, `Their ${menuName(ga, row.frame)} no longer shows ${label}.`);
339
- }
340
- for (const row of rowsB) {
341
- if (pairedB.has(row.spec) || !row.cells[ib].shown)
342
- continue;
343
- add('menu', entryKey(gb.specs[row.spec]), true, false, `Their ${menuName(gb, row.frame)} no longer shows ${quote(row.entry.label)} (the entry was removed).`);
344
- }
345
- // what they come to do
346
- for (const c of ra.goals.filter((x) => x.persona.id === id)) {
347
- const before = rb.goals.find((x) => x.persona.id === id && x.goal.id === c.goal.id);
348
- if (before !== undefined && before.outcome === c.outcome && before.clicks === c.clicks)
349
- continue;
350
- if (before === undefined && c.outcome === 'ok')
351
- continue;
352
- const worse = c.outcome !== 'ok' && (before === undefined || before.outcome === 'ok');
353
- add('goal', `goal ${c.goal.id}`, before?.outcome ?? null, c.outcome, `${quote(c.goal.say)}: ${outcomeWords(c)} (was ${outcomeWords(before)}).`, worse);
354
- }
355
- }
356
- // findings, compared line by line: a finding's headline carries counts, so its detail lines are what is compared. A new
357
- // line and a gone line that start the same way ("Ders nazırı: …") and are the only such pair are one case that changed.
358
- const lines = (f) => (f.detail.length > 0 ? f.detail : [f.say]);
359
- const codes = union(Object.fromEntries(rb.found.map((f) => [f.code, f])), Object.fromEntries(ra.found.map((f) => [f.code, f])));
360
- for (const code of codes) {
361
- const fb = rb.found.find((f) => f.code === code);
362
- const fa = ra.found.find((f) => f.code === code);
363
- const lb = fb === undefined ? [] : lines(fb);
364
- const la = fa === undefined ? [] : lines(fa);
365
- let added = la.filter((l) => !lb.includes(l));
366
- let resolved = lb.filter((l) => !la.includes(l));
367
- const head = (l) => (l.includes(': ') ? l.slice(0, l.indexOf(': ')) : null);
368
- const changed = [];
369
- for (const l of [...added]) {
370
- const h = head(l);
371
- if (h === null || added.filter((x) => head(x) === h).length > 1)
372
- continue;
373
- const was = resolved.filter((x) => head(x) === h);
374
- if (was.length !== 1)
375
- continue;
376
- changed.push(`${l} (was: ${was[0].slice(h.length + 2)})`);
377
- added = added.filter((x) => x !== l);
378
- resolved = resolved.filter((x) => x !== was[0]);
379
- }
380
- const level = (fa ?? fb);
381
- const push = (say, detail, worse, before, after) => {
382
- out.push({ topic: 'finding', key: code, before, after, say, detail: detail.map((d) => `- ${d}`), worse });
383
- };
384
- if (fb === undefined && fa !== undefined)
385
- push(`New ${fa.level}: ${fa.say}`, fa.detail, fa.level === 'problem', null, la);
386
- else if (fb !== undefined && fa === undefined)
387
- push(`Resolved ${fb.level}: ${fb.say}`, fb.detail, false, lb, null);
388
- else {
389
- if (added.length > 0)
390
- push(`${capital(level.level)}, new cases: ${fa.say}`, added, level.level === 'problem', null, added);
391
- if (resolved.length > 0)
392
- push(`${capital(level.level)}, cases resolved: ${fb.say}`, resolved, false, resolved, null);
393
- if (changed.length > 0)
394
- push(`${capital(level.level)}, cases that changed: ${fa.say}`, changed, false, null, changed);
395
- }
396
- }
397
- return out;
398
- }
399
- export function navSameBehaviour(r) {
400
- return `Nothing: each of the ${r.views.length} kinds of user lands on the same page, reaches the same pages in the same number of clicks and sees the same menu; goals and findings are the same.`;
401
- }
package/dist/diff.d.ts DELETED
@@ -1,25 +0,0 @@
1
- import type { Change, Shift } from './compare.ts';
2
- export declare const DIFF_USAGE: string;
3
- interface Source {
4
- where: string;
5
- rev: string | null;
6
- read: (file: string) => string;
7
- exists: (file: string) => boolean;
8
- peek: (file: string) => string;
9
- list: (dir: string) => string[];
10
- texts: Map<string, string>;
11
- }
12
- export interface Report {
13
- kind: 'flow' | 'nav';
14
- title: string;
15
- before: Source;
16
- after: Source;
17
- structure: Change[];
18
- behaviour: Shift[];
19
- same: string;
20
- }
21
- export declare function renderMarkdown(r: Report): string;
22
- export declare function renderJson(r: Report): string;
23
- export declare function compare(before: Source, after: Source, locale?: string): Report;
24
- export declare function diffMain(args: string[]): Promise<number>;
25
- export {};