@yaks/inspect 0.0.0-stage → 0.2.36

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 (133) hide show
  1. package/Comp.js +469 -0
  2. package/Comp.js.map +1 -0
  3. package/Comp.ts +471 -0
  4. package/Effect.js +136 -0
  5. package/Effect.js.map +1 -0
  6. package/Effect.ts +142 -0
  7. package/Entity.js +112 -0
  8. package/Entity.js.map +1 -0
  9. package/Entity.ts +137 -0
  10. package/Facts.js +143 -0
  11. package/Facts.js.map +1 -0
  12. package/Facts.ts +150 -0
  13. package/Head.js +196 -0
  14. package/Head.js.map +1 -0
  15. package/Head.ts +195 -0
  16. package/Held.js +144 -0
  17. package/Held.js.map +1 -0
  18. package/Held.ts +172 -0
  19. package/History.js +157 -0
  20. package/History.js.map +1 -0
  21. package/History.ts +215 -0
  22. package/Home.js +482 -0
  23. package/Home.js.map +1 -0
  24. package/Home.ts +550 -0
  25. package/LICENSE +202 -0
  26. package/Links.js +197 -0
  27. package/Links.js.map +1 -0
  28. package/Links.ts +212 -0
  29. package/Package.js +195 -0
  30. package/Package.js.map +1 -0
  31. package/Package.ts +191 -0
  32. package/Past.js +163 -0
  33. package/Past.js.map +1 -0
  34. package/Past.ts +181 -0
  35. package/Prop.js +225 -0
  36. package/Prop.js.map +1 -0
  37. package/Prop.ts +208 -0
  38. package/Query.js +207 -0
  39. package/Query.js.map +1 -0
  40. package/Query.ts +229 -0
  41. package/README.md +141 -2
  42. package/Words.js +43 -0
  43. package/Words.js.map +1 -0
  44. package/Words.ts +70 -0
  45. package/_dist/Entity.d.ts +7 -0
  46. package/_dist/Entity.d.ts.map +1 -0
  47. package/_dist/Facts.d.ts +7 -0
  48. package/_dist/Facts.d.ts.map +1 -0
  49. package/_dist/Head.d.ts +22 -0
  50. package/_dist/Head.d.ts.map +1 -0
  51. package/_dist/Held.d.ts +37 -0
  52. package/_dist/Held.d.ts.map +1 -0
  53. package/_dist/Links.d.ts +9 -0
  54. package/_dist/Links.d.ts.map +1 -0
  55. package/_dist/Past.d.ts +65 -0
  56. package/_dist/Past.d.ts.map +1 -0
  57. package/_dist/Words.d.ts +27 -0
  58. package/_dist/Words.d.ts.map +1 -0
  59. package/_dist/census.d.ts +10 -0
  60. package/_dist/census.d.ts.map +1 -0
  61. package/_dist/door.d.ts +28 -0
  62. package/_dist/door.d.ts.map +1 -0
  63. package/_dist/front.d.ts +4 -0
  64. package/_dist/front.d.ts.map +1 -0
  65. package/_dist/host.d.ts +94 -0
  66. package/_dist/host.d.ts.map +1 -0
  67. package/_dist/mod.d.ts +24 -0
  68. package/_dist/mod.d.ts.map +1 -0
  69. package/_dist/notes.d.ts +38 -0
  70. package/_dist/notes.d.ts.map +1 -0
  71. package/_dist/read.d.ts +59 -0
  72. package/_dist/read.d.ts.map +1 -0
  73. package/_dist/reading.d.ts +21 -0
  74. package/_dist/reading.d.ts.map +1 -0
  75. package/_dist/registry.d.ts +12 -0
  76. package/_dist/registry.d.ts.map +1 -0
  77. package/_dist/schema.d.ts +4 -0
  78. package/_dist/schema.d.ts.map +1 -0
  79. package/_dist/state.d.ts +22 -0
  80. package/_dist/state.d.ts.map +1 -0
  81. package/_dist/value.d.ts +20 -0
  82. package/_dist/value.d.ts.map +1 -0
  83. package/_dist/views.d.ts +3 -0
  84. package/_dist/views.d.ts.map +1 -0
  85. package/census.js +50 -0
  86. package/census.js.map +1 -0
  87. package/census.ts +76 -0
  88. package/deno.json +1 -0
  89. package/door.js +54 -0
  90. package/door.js.map +1 -0
  91. package/door.ts +59 -0
  92. package/front.js +12 -0
  93. package/front.js.map +1 -0
  94. package/front.json +76 -0
  95. package/front.ts +13 -0
  96. package/grid.js +249 -0
  97. package/grid.js.map +1 -0
  98. package/grid.ts +395 -0
  99. package/host.js +20 -0
  100. package/host.js.map +1 -0
  101. package/host.ts +134 -0
  102. package/mod.js +20 -0
  103. package/mod.js.map +1 -0
  104. package/mod.ts +45 -0
  105. package/notes.js +184 -0
  106. package/notes.js.map +1 -0
  107. package/notes.ts +288 -0
  108. package/package.json +35 -4
  109. package/read.js +300 -0
  110. package/read.js.map +1 -0
  111. package/read.ts +386 -0
  112. package/reading.js +64 -0
  113. package/reading.js.map +1 -0
  114. package/reading.ts +73 -0
  115. package/registry.js +89 -0
  116. package/registry.js.map +1 -0
  117. package/registry.ts +89 -0
  118. package/rows.js +12 -0
  119. package/rows.js.map +1 -0
  120. package/rows.ts +26 -0
  121. package/schema.js +47 -0
  122. package/schema.js.map +1 -0
  123. package/schema.ts +70 -0
  124. package/state.js +85 -0
  125. package/state.js.map +1 -0
  126. package/state.ts +128 -0
  127. package/terminal-links.ts +16 -0
  128. package/value.js +67 -0
  129. package/value.js.map +1 -0
  130. package/value.ts +79 -0
  131. package/views.js +4 -0
  132. package/views.js.map +1 -0
  133. package/views.ts +6 -0
package/registry.ts ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Inspect registrations for vocabulary entities, entity readings, query rows
3
+ * and the map. A host merges them into the same registry as its domain views.
4
+ * @module
5
+ */
6
+
7
+ import { define, type Registry } from '@yaks/render'
8
+ import type { View } from './host.ts'
9
+ import { and, parse } from '@yaks/query'
10
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h } from 'react'
11
+ import { Tile } from '@yaks/ui'
12
+ import { str } from './read.js'
13
+ import { HomePage } from './Home.js'
14
+ import { QueryPage } from './Query.js'
15
+ import { Note } from './notes.js'
16
+ import { compViews } from './Comp.js'
17
+ import { effectViews } from './Effect.js'
18
+ import { entityViews } from './Entity.js'
19
+ import { packageViews } from './Package.js'
20
+ import { propViews } from './Prop.js'
21
+
22
+ // Schema names belong to inspect; every consumer asks for this renderer,
23
+ // including the query table and any inline reference.
24
+ let schemaTiles: View[] = ['_namespace', '_comp', '_kind', '_prop', '_effect']
25
+ .flatMap((
26
+ name,
27
+ ) => [
28
+ {
29
+ view: 'Tile',
30
+ match: parse(`.${name}`),
31
+ Render: ({ e, io }) =>
32
+ h(
33
+ Tile,
34
+ { href: io.link(e.entity.eid) },
35
+ h(Tile.Title, {}, str(e, name, 'name')),
36
+ h(Tile.Kind, {}, name.slice(1)),
37
+ ),
38
+ },
39
+ {
40
+ view: 'Inline',
41
+ match: parse(`.${name}`),
42
+ Render: ({ e, io }) =>
43
+ h('a', { href: io.link(e.entity.eid) }, str(e, name, 'name')),
44
+ },
45
+ ])
46
+
47
+ /** The pages for vocabulary entities. */
48
+ export let schemaPages: View[] = [
49
+ ...compViews,
50
+ ...propViews,
51
+ ...packageViews,
52
+ ...effectViews,
53
+ ]
54
+
55
+ /** Every inspector view. */
56
+ export let all: View[] = [
57
+ { view: 'Inspect.Note', match: parse('.comment'), Render: Note },
58
+ ...schemaTiles,
59
+ ...compViews,
60
+ ...propViews,
61
+ ...packageViews,
62
+ ...effectViews,
63
+ ...entityViews,
64
+ {
65
+ view: 'Inspect.Reference.Inline',
66
+ match: and(),
67
+ Render: ({ e, io }) =>
68
+ h('a', { href: io.link(e.entity.eid) }, io.name(e.entity.eid)),
69
+ },
70
+ {
71
+ view: 'Inspect.Map',
72
+ match: and(),
73
+ Render: ({ io }) => h(HomePage, { io }),
74
+ },
75
+ {
76
+ view: 'Inspect.Query',
77
+ match: and(),
78
+ Render: ({ io, ctx }) =>
79
+ h(QueryPage, { io, text: String(ctx.query ?? '') }),
80
+ },
81
+ ]
82
+
83
+ /** The inspector's views, as a registry. */
84
+ export let views: Registry<View> = define(all)
85
+
86
+ /** The inspector's views with `more` ahead of them, as a registry of its
87
+ * own. */
88
+ export let composed = (more: View[]): Registry<View> =>
89
+ more.length ? define([...more, ...all]) : views
package/rows.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * What every answer read on a page shares: its rows, and what shows in their
3
+ * place while it is out or after it was refused.
4
+ *
5
+ * @module
6
+ */ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h } from "react";
7
+ import { Loading, Rows } from "@yaks/ui";
8
+ /** The answer's rows, or none while it is out. */ export let rows = (a)=>a?.rows ?? [];
9
+ /** What shows in place of an answer that is refused or not in yet; null
10
+ * once it can be drawn. */ export let waiting = (a)=>a?.error ? /*#__PURE__*/ h(Rows.More, {}, a.error) : !a?.ready && !a?.rows.length && a?.count == null && !Object.keys(a?.tally ?? {}).length ? /*#__PURE__*/ h(Loading, {}) : null;
11
+ /** What a table with no rows says. */ export let none = ()=>/*#__PURE__*/ h(Rows.More, {}, 'none');
12
+ //# sourceMappingURL=rows.js.map
package/rows.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.js","sources":["./rows.ts"],"names":[],"mappings":"AAAA;;;;;CAKC,GAED,uCAAuC,GAAG,SAAS,iBAAiB,CAAC,gBAAoC;AACzG,SAAS,OAAO,EAAE,IAAI,wBAA6B;AAGnD,gDAAgD,GAChD,OAAO,IAAI,OAAO,CAAC,IAAyB,GAAG,QAAQ,EAAE,CAAA;AAEzD;yBACyB,GACzB,OAAO,IAAI,UAAU,CAAC,IACpB,GAAG,sBACC,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,IACxB,CAAC,GAAG,SAAS,CAAC,GAAG,KAAK,UAAU,GAAG,SAAS,QAC1C,CAAC,OAAO,IAAI,CAAC,GAAG,SAAS,CAAC,GAAG,MAAM,iBACrC,EAAE,SAAS,CAAC,KACZ,KAAI;AAEV,oCAAoC,GACpC,OAAO,IAAI,OAAO,kBAAmB,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,QAAO"}
package/rows.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * What every answer read on a page shares: its rows, and what shows in their
3
+ * place while it is out or after it was refused.
4
+ *
5
+ * @module
6
+ */
7
+
8
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, type JSX } from 'react'
9
+ import { Loading, Rows } from '@yaks/ui'
10
+ import type { Answer, Bundle } from './host.ts'
11
+
12
+ /** The answer's rows, or none while it is out. */
13
+ export let rows = (a?: Answer): Bundle[] => a?.rows ?? []
14
+
15
+ /** What shows in place of an answer that is refused or not in yet; null
16
+ * once it can be drawn. */
17
+ export let waiting = (a?: Answer): JSX.Element | null =>
18
+ a?.error
19
+ ? h(Rows.More, {}, a.error)
20
+ : !a?.ready && !a?.rows.length && a?.count == null &&
21
+ !Object.keys(a?.tally ?? {}).length
22
+ ? h(Loading, {})
23
+ : null
24
+
25
+ /** What a table with no rows says. */
26
+ export let none = (): JSX.Element => h(Rows.More, {}, 'none')
package/schema.js ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The links every page makes to the vocabulary: a namespace's page, a
3
+ * component's, a property's and an effect's, by the rows the vocabulary
4
+ * describes them in (@yaks/vocab `rowsOf`): each word's identity, or where its
5
+ * labels derive for a word without one, so a name links to its page without
6
+ * asking the graph where that is.
7
+ *
8
+ * @module
9
+ */ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, Fragment } from "react";
10
+ import { derivedEid } from "@yaks/graph/identity";
11
+ import { rowsOf } from "@yaks/vocab";
12
+ import { Body } from "@yaks/ui";
13
+ // Each vocabulary's rows, worked out once.
14
+ let held = new WeakMap();
15
+ let rows = (vocab)=>held.get(vocab) ?? held.set(vocab, rowsOf(vocab, derivedEid)).get(vocab);
16
+ /** The eid of the namespace labelled `name`. */ export let packEid = (vocab, name)=>rows(vocab).namespace(name);
17
+ /** The eid of the component named `name`. */ export let compEid = (vocab, name)=>rows(vocab).comp(name);
18
+ /** The eid of the effect named `name`. */ export let effectEid = (vocab, name)=>rows(vocab).effect(name);
19
+ /** The eid of the property `prop` of the component named `name`. */ export let propEid = (vocab, name, prop)=>rows(vocab).prop(name, prop);
20
+ /** A component's name in its hue, linked to its page. */ export let chip = (io, name)=>{
21
+ let eid = compEid(io.vocab, name);
22
+ let b = io.get(eid) ?? {
23
+ entity: {
24
+ eid
25
+ },
26
+ _comp: {
27
+ name
28
+ }
29
+ };
30
+ return io.show(b, 'Inspect.Reference.Inline');
31
+ };
32
+ /** The components a vocabulary marks as edge relations (@yaks/edge). */ export let relations = (io)=>io.vocab.all.filter((n)=>io.vocab.comp(n)?.keywords.edge != null);
33
+ /** Components' names, each in its hue and linked, joined: `doc + task`. */ export let chips = (io, names)=>/*#__PURE__*/ h('span', {}, names.flatMap((n, i)=>[
34
+ i ? ' + ' : null,
35
+ chip(io, n)
36
+ ]));
37
+ /** What a vocabulary entity's page says of it, as its head's sub: its words,
38
+ * then its facts (its package, how it is kept) on a line of their own. */ export let described = (text, facts)=>[
39
+ text,
40
+ /*#__PURE__*/ h('br', {}),
41
+ ...facts
42
+ ];
43
+ /** The same, as the body of a page another head tops (a Full page's): its
44
+ * words read in the ink, its facts a quiet line under them. */ export let Described = ({ text, facts })=>/*#__PURE__*/ h(Fragment, null, text ? /*#__PURE__*/ h(Body, {}, text) : null, /*#__PURE__*/ h(Body, {
45
+ mod: 'short'
46
+ }, ...facts));
47
+ //# sourceMappingURL=schema.js.map
package/schema.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sources":["./schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;CAQC,GAED,uCAAuC,GAAG,SAAS,iBAAiB,CAAC,EAAE,QAAQ,gBAAoD;AACnI,SAAS,UAAU,oCAAyC;AAC5D,SAAS,MAAM,2BAA4C;AAC3D,SAAS,IAAI,wBAA6B;AAG1C,2CAA2C;AAC3C,IAAI,OAAO,IAAI;AACf,IAAI,OAAO,CAAC,QACV,KAAK,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,OAAO,OAAO,OAAO,aAAa,GAAG,CAAC;AAEpE,8CAA8C,GAC9C,OAAO,IAAI,UAAU,CAAC,OAAc,OAClC,KAAK,OAAO,SAAS,CAAC,MAAK;AAE7B,2CAA2C,GAC3C,OAAO,IAAI,UAAU,CAAC,OAAc,OAClC,KAAK,OAAO,IAAI,CAAC,MAAK;AAExB,wCAAwC,GACxC,OAAO,IAAI,YAAY,CAAC,OAAc,OACpC,KAAK,OAAO,MAAM,CAAC,MAAK;AAE1B,kEAAkE,GAClE,OAAO,IAAI,UAAU,CAAC,OAAc,MAAc,OAChD,KAAK,OAAO,IAAI,CAAC,MAAM,MAAK;AAE9B,uDAAuD,GACvD,OAAO,IAAI,OAAO,CAAC,IAAQ;EACzB,IAAI,MAAM,QAAQ,GAAG,KAAK,EAAE;EAC5B,IAAI,IAAI,GAAG,GAAG,CAAC,QAAQ;IAAE,QAAQ;MAAE;IAAI;IAAG,OAAO;MAAE;IAAK;EAAE;EAC1D,OAAO,GAAG,IAAI,CAAC,GAAG;AACpB,EAAC;AAED,sEAAsE,GACtE,OAAO,IAAI,YAAY,CAAC,KACtB,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,SAAS,QAAQ,MAAK;AAErE,yEAAyE,GACzE,OAAO,IAAI,QAAQ,CAAC,IAAQ,sBAC1B,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,CAAC,GAAG,IAAM;MAAC,IAAI,QAAQ;MAAM,KAAK,IAAI;KAAG,GAAE;AAEzE;wEACwE,GACxE,OAAO,IAAI,YAAY,CACrB,MACA,QACgB;IAAC;kBAAM,EAAE,MAAM,CAAC;OAAO;GAAM,CAAA;AAE/C;6DAC6D,GAC7D,OAAO,IAAI,YAAY,CACrB,EAAE,IAAI,EAAE,KAAK,EAA2C,iBAExD,EACE,UACA,MACA,qBAAO,EAAE,MAAM,CAAC,GAAG,QAAQ,oBAC3B,EAAE,MAAM;IAAE,KAAK;EAAQ,MAAM,QAC9B"}
package/schema.ts ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The links every page makes to the vocabulary: a namespace's page, a
3
+ * component's, a property's and an effect's, by the rows the vocabulary
4
+ * describes them in (@yaks/vocab `rowsOf`): each word's identity, or where its
5
+ * labels derive for a word without one, so a name links to its page without
6
+ * asking the graph where that is.
7
+ *
8
+ * @module
9
+ */
10
+
11
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, Fragment, type JSX, type ReactNode } from 'react'
12
+ import { derivedEid } from '@yaks/graph/identity'
13
+ import { rowsOf, type Vocab } from '@yaks/vocab'
14
+ import { Body } from '@yaks/ui'
15
+ import type { Io } from './host.ts'
16
+
17
+ // Each vocabulary's rows, worked out once.
18
+ let held = new WeakMap<Vocab, ReturnType<typeof rowsOf>>()
19
+ let rows = (vocab: Vocab) =>
20
+ held.get(vocab) ?? held.set(vocab, rowsOf(vocab, derivedEid)).get(vocab)!
21
+
22
+ /** The eid of the namespace labelled `name`. */
23
+ export let packEid = (vocab: Vocab, name: string): string =>
24
+ rows(vocab).namespace(name)
25
+
26
+ /** The eid of the component named `name`. */
27
+ export let compEid = (vocab: Vocab, name: string): string =>
28
+ rows(vocab).comp(name)
29
+
30
+ /** The eid of the effect named `name`. */
31
+ export let effectEid = (vocab: Vocab, name: string): string =>
32
+ rows(vocab).effect(name)
33
+
34
+ /** The eid of the property `prop` of the component named `name`. */
35
+ export let propEid = (vocab: Vocab, name: string, prop: string): string =>
36
+ rows(vocab).prop(name, prop)
37
+
38
+ /** A component's name in its hue, linked to its page. */
39
+ export let chip = (io: Io, name: string): JSX.Element => {
40
+ let eid = compEid(io.vocab, name)
41
+ let b = io.get(eid) ?? { entity: { eid }, _comp: { name } }
42
+ return io.show(b, 'Inspect.Reference.Inline') as JSX.Element
43
+ }
44
+
45
+ /** The components a vocabulary marks as edge relations (@yaks/edge). */
46
+ export let relations = (io: Io): string[] =>
47
+ io.vocab.all.filter((n) => io.vocab.comp(n)?.keywords.edge != null)
48
+
49
+ /** Components' names, each in its hue and linked, joined: `doc + task`. */
50
+ export let chips = (io: Io, names: string[]): JSX.Element =>
51
+ h('span', {}, names.flatMap((n, i) => [i ? ' + ' : null, chip(io, n)]))
52
+
53
+ /** What a vocabulary entity's page says of it, as its head's sub: its words,
54
+ * then its facts (its package, how it is kept) on a line of their own. */
55
+ export let described = (
56
+ text: ReactNode,
57
+ facts: ReactNode[],
58
+ ): ReactNode[] => [text, h('br', {}), ...facts]
59
+
60
+ /** The same, as the body of a page another head tops (a Full page's): its
61
+ * words read in the ink, its facts a quiet line under them. */
62
+ export let Described = (
63
+ { text, facts }: { text: ReactNode; facts: ReactNode[] },
64
+ ): JSX.Element =>
65
+ h(
66
+ Fragment,
67
+ null,
68
+ text ? h(Body, {}, text) : null,
69
+ h(Body, { mod: 'short' }, ...facts),
70
+ )
package/state.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The inspector's own state, as it lives in the page's own graph
3
+ * (./front.json): read through `io.state`, changed by the patches built here
4
+ * and written through `io.set`. One entity, `inspect`, holds the page's
5
+ * (`inspector`: the page being edited, a note open, a delete armed, where a
6
+ * write was refused, the slice of the schema the map shows); each table holds
7
+ * its own (`table`: its order, its page and its open rows).
8
+ *
9
+ * @module
10
+ */ import { comp } from "./read.js";
11
+ /** The entity the page's state is on. */ export let INSPECT = 'inspect';
12
+ /** The page's state, read reactively. */ export let me = (io)=>comp(io.state(INSPECT), 'inspector');
13
+ /**
14
+ * A patch to the page's state.
15
+ *
16
+ * ```ts
17
+ * import { put } from './state.ts'
18
+ * put({ note: 'T-9 Facts' })
19
+ * // [{ entity: { eid: 'inspect' }, inspector: { note: 'T-9 Facts' } }]
20
+ * ```
21
+ */ export let put = (patch)=>[
22
+ {
23
+ entity: {
24
+ eid: INSPECT
25
+ },
26
+ inspector: patch
27
+ }
28
+ ];
29
+ /** Whether the page of the entity `eid` shows its controls: where the host's
30
+ * take input, once the reader asked to edit it. */ export let edited = (io, eid)=>io.edits && me(io).editing == eid;
31
+ /** The key of a value, a heading or a table: its parts, spaced. */ export let key = (...parts)=>parts.join(' ');
32
+ /** A table's state, by the id its page gives it. */ export let grid = (io, id)=>comp(io.state(id), 'table');
33
+ /** A patch to a table's state. */ export let turned = (id, patch)=>[
34
+ {
35
+ entity: {
36
+ eid: id
37
+ },
38
+ table: patch
39
+ }
40
+ ];
41
+ /** Why a write from `at` was refused, or nothing. */ export let refusal = (io, at)=>me(io).at == at && me(io).said ? String(me(io).said) : '';
42
+ /** Write `bundles` to the graph from `at`: a refusal is said there until a
43
+ * write from anywhere lands. A write whose outcome is unknown (the server
44
+ * away) is not refused: it waits to be sent again, and says nothing here. */ export let write = (io, at, bundles)=>Promise.resolve().then(()=>io.apply(bundles)).then(()=>io.set(put({
45
+ said: null,
46
+ at: null
47
+ })), (err)=>io.set(err?.outcome == 'unknown' ? put({
48
+ said: null,
49
+ at: null
50
+ }) : put({
51
+ said: err instanceof Error ? err.message : String(err),
52
+ at
53
+ })));
54
+ /** The UX components' host (@yaks/ux) over the inspector's: a value changed
55
+ * where it stands is written like any write here, a refusal said in the head
56
+ * of the entity it was about until a write lands, and so is input its `Edit`
57
+ * could not read (a `Refused` event). The page's graph is the inspector's
58
+ * own; `find` is the server search a picker's candidates come from, `fields`
59
+ * the page's query fields, `drafts` where what is typed waits, and `Float`
60
+ * where a picker floats. */ export let editing = (host, more)=>{
61
+ let set = (bundles)=>void host.front.mutate(bundles);
62
+ let { vocab, front, name, id, kind, when } = host;
63
+ return {
64
+ vocab,
65
+ front,
66
+ name,
67
+ id,
68
+ kind,
69
+ when,
70
+ ...more,
71
+ write: (b)=>{
72
+ let no = b.Refused;
73
+ return no ? set(put({
74
+ said: no.said ?? null,
75
+ at: b.entity.eid
76
+ })) : write({
77
+ apply: host.apply,
78
+ set
79
+ }, b.entity.eid, [
80
+ b
81
+ ]);
82
+ }
83
+ };
84
+ };
85
+ //# sourceMappingURL=state.js.map
package/state.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sources":["./state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;CASC,GAID,SAAS,IAAI,oBAAmB;AAEhC,uCAAuC,GACvC,OAAO,IAAI,UAAU,UAAS;AAoB9B,uCAAuC,GACvC,OAAO,IAAI,KAAK,CAAC,KACf,KAAK,GAAG,KAAK,CAAC,UAAU,aAAyB;AAEnD;;;;;;;;CAQC,GACD,OAAO,IAAI,MAAM,CAAC,QAA+B;IAAC;MAChD,QAAQ;QAAE,KAAK;MAAQ;MACvB,WAAW;IACb;GAAE,CAAA;AAEF;iDACiD,GACjD,OAAO,IAAI,SAAS,CAAC,IAAiC,MACpD,GAAG,KAAK,IAAI,GAAG,IAAI,OAAO,IAAI,IAAG;AAEnC,iEAAiE,GACjE,OAAO,IAAI,MAAM,CAAC,GAAG,QAA4B,MAAM,IAAI,CAAC,KAAI;AAEhE,kDAAkD,GAClD,OAAO,IAAI,OAAO,CAAC,IAAuB,KACxC,KAAK,GAAG,KAAK,CAAC,KAAK,SAAgB;AAErC,gCAAgC,GAChC,OAAO,IAAI,SAAS,CAAC,IAAY,QAA0B;IAAC;MAC1D,QAAQ;QAAE,KAAK;MAAG;MAClB,OAAO;IACT;GAAE,CAAA;AAEF,mDAAmD,GACnD,OAAO,IAAI,UAAU,CAAC,IAAuB,KAC3C,GAAG,IAAI,EAAE,IAAI,MAAM,GAAG,IAAI,IAAI,GAAG,OAAO,GAAG,IAAI,IAAI,IAAI,GAAE;AAE3D;;2EAE2E,GAC3E,OAAO,IAAI,QAAQ,CACjB,IACA,IACA,UAEA,QAAQ,OAAO,GACZ,IAAI,CAAC,IAAM,GAAG,KAAK,CAAC,UACpB,IAAI,CACH,IAAM,GAAG,GAAG,CAAC,IAAI;MAAE,MAAM;MAAM,IAAI;IAAK,KACxC,CAAC,MACC,GAAG,GAAG,CACJ,AAAC,KAA8B,WAAW,YACtC,IAAI;MAAE,MAAM;MAAM,IAAI;IAAK,KAC3B,IAAI;MACJ,MAAM,eAAe,QAAQ,IAAI,OAAO,GAAG,OAAO;MAClD;IACF,KAEP;AAEL;;;;;;0BAM0B,GAC1B,OAAO,IAAI,UAAU,CACnB,MACA;EAEA,IAAI,MAAM,CAAC,UAAsB,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC;EACxD,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG;EAC7C,OAAO;IACL;IACA;IACA;IACA;IACA;IACA;IACA,GAAG,IAAI;IACP,OAAO,CAAC;MACN,IAAI,KAAK,EAAE,OAAO;MAClB,OAAO,KACH,IAAI,IAAI;QAAE,MAAM,GAAG,IAAI,IAAI;QAAM,IAAI,EAAE,MAAM,CAAC,GAAG;MAAC,MAClD,MAAM;QAAE,OAAO,KAAK,KAAK;QAAE;MAAI,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;QAAC;OAAE;IACzD;EACF;AACF,EAAC"}
package/state.ts ADDED
@@ -0,0 +1,128 @@
1
+ /**
2
+ * The inspector's own state, as it lives in the page's own graph
3
+ * (./front.json): read through `io.state`, changed by the patches built here
4
+ * and written through `io.set`. One entity, `inspect`, holds the page's
5
+ * (`inspector`: the page being edited, a note open, a delete armed, where a
6
+ * write was refused, the slice of the schema the map shows); each table holds
7
+ * its own (`table`: its order, its page and its open rows).
8
+ *
9
+ * @module
10
+ */
11
+
12
+ import { type Host as Ux } from '@yaks/ux'
13
+ import type { Bundle, Host, Io } from './host.ts'
14
+ import { comp } from './read.js'
15
+
16
+ /** The entity the page's state is on. */
17
+ export let INSPECT = 'inspect'
18
+
19
+ /** The page's state. */
20
+ export type Inspector = {
21
+ editing?: string | null
22
+ note?: string | null
23
+ armed?: string | null
24
+ said?: string | null
25
+ at?: string | null
26
+ slice?: string | null
27
+ }
28
+
29
+ /** One table's state. */
30
+ export type Grid = {
31
+ order?: string | null
32
+ after?: string[]
33
+ open?: string[]
34
+ rank?: boolean
35
+ }
36
+
37
+ /** The page's state, read reactively. */
38
+ export let me = (io: Pick<Io, 'state'>): Inspector =>
39
+ comp(io.state(INSPECT), 'inspector') as Inspector
40
+
41
+ /**
42
+ * A patch to the page's state.
43
+ *
44
+ * ```ts
45
+ * import { put } from './state.ts'
46
+ * put({ note: 'T-9 Facts' })
47
+ * // [{ entity: { eid: 'inspect' }, inspector: { note: 'T-9 Facts' } }]
48
+ * ```
49
+ */
50
+ export let put = (patch: Inspector): Bundle[] => [{
51
+ entity: { eid: INSPECT },
52
+ inspector: patch,
53
+ }]
54
+
55
+ /** Whether the page of the entity `eid` shows its controls: where the host's
56
+ * take input, once the reader asked to edit it. */
57
+ export let edited = (io: Pick<Io, 'state' | 'edits'>, eid: string): boolean =>
58
+ io.edits && me(io).editing == eid
59
+
60
+ /** The key of a value, a heading or a table: its parts, spaced. */
61
+ export let key = (...parts: string[]): string => parts.join(' ')
62
+
63
+ /** A table's state, by the id its page gives it. */
64
+ export let grid = (io: Pick<Io, 'state'>, id: string): Grid =>
65
+ comp(io.state(id), 'table') as Grid
66
+
67
+ /** A patch to a table's state. */
68
+ export let turned = (id: string, patch: Grid): Bundle[] => [{
69
+ entity: { eid: id },
70
+ table: patch,
71
+ }]
72
+
73
+ /** Why a write from `at` was refused, or nothing. */
74
+ export let refusal = (io: Pick<Io, 'state'>, at: string): string =>
75
+ me(io).at == at && me(io).said ? String(me(io).said) : ''
76
+
77
+ /** Write `bundles` to the graph from `at`: a refusal is said there until a
78
+ * write from anywhere lands. A write whose outcome is unknown (the server
79
+ * away) is not refused: it waits to be sent again, and says nothing here. */
80
+ export let write = (
81
+ io: Pick<Io, 'apply' | 'set'>,
82
+ at: string,
83
+ bundles: Bundle[],
84
+ ): Promise<void> =>
85
+ Promise.resolve()
86
+ .then(() => io.apply(bundles))
87
+ .then(
88
+ () => io.set(put({ said: null, at: null })),
89
+ (err) =>
90
+ io.set(
91
+ (err as { outcome?: string })?.outcome == 'unknown'
92
+ ? put({ said: null, at: null })
93
+ : put({
94
+ said: err instanceof Error ? err.message : String(err),
95
+ at,
96
+ }),
97
+ ),
98
+ )
99
+
100
+ /** The UX components' host (@yaks/ux) over the inspector's: a value changed
101
+ * where it stands is written like any write here, a refusal said in the head
102
+ * of the entity it was about until a write lands, and so is input its `Edit`
103
+ * could not read (a `Refused` event). The page's graph is the inspector's
104
+ * own; `find` is the server search a picker's candidates come from, `fields`
105
+ * the page's query fields, `drafts` where what is typed waits, and `Float`
106
+ * where a picker floats. */
107
+ export let editing = (
108
+ host: Host,
109
+ more: Pick<Ux, 'find' | 'fields' | 'drafts' | 'Float'>,
110
+ ): Ux => {
111
+ let set = (bundles: Bundle[]) => void host.front.mutate(bundles)
112
+ let { vocab, front, name, id, kind, when } = host
113
+ return {
114
+ vocab,
115
+ front,
116
+ name,
117
+ id,
118
+ kind,
119
+ when,
120
+ ...more,
121
+ write: (b) => {
122
+ let no = b.Refused as { said?: string } | undefined
123
+ return no
124
+ ? set(put({ said: no.said ?? null, at: b.entity.eid }))
125
+ : write({ apply: host.apply, set }, b.entity.eid, [b])
126
+ },
127
+ }
128
+ }
@@ -0,0 +1,16 @@
1
+ // Terminal links and pickable rows, used by renderer tests without an app shell.
2
+ import { TElement } from 'jsr:@yaks/tui@0.2.36'
3
+ let elements = (el: TElement) =>
4
+ el.childNodes.filter((n): n is TElement => 'localName' in n)
5
+ export let stops = (el: TElement | undefined): TElement[] =>
6
+ !el ? [] : [
7
+ ...el.attr('data-pick') || el.localName == 'a' && el.attr('href')
8
+ ? [el]
9
+ : [],
10
+ ...elements(el).flatMap(stops),
11
+ ]
12
+ export let linkOf = (el: TElement | null | undefined): string | undefined => {
13
+ for (let n = el; n; n = n.parentNode as TElement | null) {
14
+ if (n.localName == 'a' && n.attr('href')) return n.attr('href')
15
+ }
16
+ }
package/value.js ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * A stored value on a page. Read, it is said the way a person reads it (`reads`):
3
+ * a reference as the name of what it names, linked; a moment in words; a hash
4
+ * as far as it tells one from another; a JSON value, a text cut to a line.
5
+ * Edited, it is a @yaks/ux `Edit` showing the value as it was stored (`shown`):
6
+ * pressed, it is typed over where it stands, in the shape's own type so nothing
7
+ * moves, or its choices float beside it; a reference's picker opens from a
8
+ * handle beside its link. A value the vocabulary keeps from clients is only
9
+ * shown.
10
+ *
11
+ * @module
12
+ */ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h } from "react";
13
+ import { Edit } from "@yaks/ux";
14
+ import { Value } from "@yaks/ui";
15
+ import { brief, comp, face, line, named, shape, writable } from "./read.js";
16
+ /** An entity a value names: what it is called, linked to its page, the id a
17
+ * person types where the pointer rests on it. */ export let mention = (io, eid)=>{
18
+ let b = io.get(eid);
19
+ return b ? io.show(b, 'Inspect.Reference.Inline') : /*#__PURE__*/ h('a', {
20
+ href: io.link(eid)
21
+ }, io.name(eid));
22
+ };
23
+ /** A stored value as it was stored: a reference as the entity it names;
24
+ * anything else coloured by its shape. */ export let shown = (io, v, p)=>p?.category == 'ref' && named(v) ? mention(io, v) : /*#__PURE__*/ h(Value, {
25
+ mod: shape(v)
26
+ }, face(v));
27
+ /** A stored value as a person reads it; nothing where it holds nothing. A text
28
+ * kept as a blob (@yaks/blob's `store: 'blob'`), where a journal holds its
29
+ * address rather than its words, links to the words. */ export let reads = (io, v, p)=>{
30
+ if (v == null) return /*#__PURE__*/ h(Value, {
31
+ mod: 'nil'
32
+ });
33
+ if (named(v) && (p?.category == 'ref' || !p)) return mention(io, v);
34
+ if (p?.keywords.store == 'blob' && /^[0-9a-f]{64}$/.test(String(v))) {
35
+ return /*#__PURE__*/ h('a', {
36
+ href: `/blob/${v}`
37
+ }, 'the text');
38
+ }
39
+ let s = shape(v);
40
+ let said = s == 'time' ? io.when(String(v)) : s == 'json' ? line(face(v), 100) : typeof v == 'string' ? brief(line(v, 160)) : face(v);
41
+ return /*#__PURE__*/ h(Value, {
42
+ mod: s,
43
+ title: s == 'time' ? String(v) : undefined
44
+ }, said);
45
+ };
46
+ /** One value of an entity, changed where it stands where it may be. Its
47
+ * shape is worn around the whole value, so what is typed over it keeps the
48
+ * face's type. */ export let Cell = ({ io, e, name, prop })=>{
49
+ let v = comp(e, name)[prop];
50
+ let p = io.vocab.prop(name, prop);
51
+ if (!writable(io, name, prop)) return shown(io, v, p);
52
+ let ref = p?.category == 'ref';
53
+ // A reference's face is a link, so its picker opens from a handle beside it.
54
+ let value = /*#__PURE__*/ h(Edit, {
55
+ e,
56
+ comp: name,
57
+ prop,
58
+ editable: true,
59
+ handle: ref,
60
+ show: (_, now)=>shown(io, now, p)
61
+ });
62
+ let s = shape(v);
63
+ return ref || s == 'nil' ? value : /*#__PURE__*/ h(Value, {
64
+ mod: s
65
+ }, value);
66
+ };
67
+ //# sourceMappingURL=value.js.map
package/value.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value.js","sources":["./value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,uCAAuC,GAAG,SAAS,iBAAiB,CAAC,gBAAoC;AACzG,SAAS,IAAI,wBAA6B;AAC1C,SAAS,KAAK,wBAA6B;AAG3C,SAAS,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,oBAAmB;AAE3E;+CAC+C,GAC/C,OAAO,IAAI,UAAU,CAAC,IAAQ;EAC5B,IAAI,IAAI,GAAG,GAAG,CAAC;EACf,OAAO,IACH,GAAG,IAAI,CAAC,GAAG,4CACX,EAAE,KAAK;IAAE,MAAM,GAAG,IAAI,CAAC;EAAK,GAAG,GAAG,IAAI,CAAC;AAC7C,EAAC;AAED;wCACwC,GACxC,OAAO,IAAI,QAAQ,CAAC,IAAQ,GAAY,IACtC,GAAG,YAAY,SAAS,MAAM,KAC1B,QAAQ,IAAI,mBACZ,EAAE,OAAO;IAAE,KAAK,MAAM;EAAG,GAAG,KAAK,IAAG;AAE1C;;sDAEsD,GACtD,OAAO,IAAI,QAAQ,CAAC,IAAQ,GAAY;EACtC,IAAI,KAAK,MAAM,qBAAO,EAAE,OAAO;IAAE,KAAK;EAAM;EAC5C,IAAI,MAAM,MAAM,CAAC,GAAG,YAAY,SAAS,CAAC,CAAC,GAAG,OAAO,QAAQ,IAAI;EACjE,IAAI,GAAG,SAAS,SAAS,UAAU,iBAAiB,IAAI,CAAC,OAAO,KAAK;IACnE,qBAAO,EAAE,KAAK;MAAE,MAAM,CAAC,MAAM,EAAE,GAAG;IAAC,GAAG;EACxC;EACA,IAAI,IAAI,MAAM;EACd,IAAI,OAAO,KAAK,SACZ,GAAG,IAAI,CAAC,OAAO,MACf,KAAK,SACL,KAAK,KAAK,IAAI,OACd,OAAO,KAAK,WACZ,MAAM,KAAK,GAAG,QACd,KAAK;EACT,qBAAO,EAAE,OAAO;IAAE,KAAK;IAAG,OAAO,KAAK,SAAS,OAAO,KAAK;EAAU,GAAG;AAC1E,EAAC;AAKD;;gBAEgB,GAChB,OAAO,IAAI,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAa;EACjD,IAAI,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK;EAC3B,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM;EAC5B,IAAI,CAAC,SAAS,IAAI,MAAM,OAAO,OAAO,MAAM,IAAI,GAAG;EACnD,IAAI,MAAM,GAAG,YAAY;EACzB,6EAA6E;EAC7E,IAAI,sBAAQ,EAAE,MAAM;IAClB;IACA,MAAM;IACN;IACA,UAAU;IACV,QAAQ;IACR,MAAM,CAAC,GAAG,MAAQ,MAAM,IAAI,KAAK;EACnC;EACA,IAAI,IAAI,MAAM;EACd,OAAO,OAAO,KAAK,QAAQ,sBAAQ,EAAE,OAAO;IAAE,KAAK;EAAE,GAAG;AAC1D,EAAC"}
package/value.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * A stored value on a page. Read, it is said the way a person reads it (`reads`):
3
+ * a reference as the name of what it names, linked; a moment in words; a hash
4
+ * as far as it tells one from another; a JSON value, a text cut to a line.
5
+ * Edited, it is a @yaks/ux `Edit` showing the value as it was stored (`shown`):
6
+ * pressed, it is typed over where it stands, in the shape's own type so nothing
7
+ * moves, or its choices float beside it; a reference's picker opens from a
8
+ * handle beside its link. A value the vocabulary keeps from clients is only
9
+ * shown.
10
+ *
11
+ * @module
12
+ */
13
+
14
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, type JSX } from 'react'
15
+ import { Edit } from '@yaks/ux'
16
+ import { Value } from '@yaks/ui'
17
+ import type { Prop as Declared } from 'jsr:@yaks/vocab@0.2.36'
18
+ import type { Bundle, Io } from './host.ts'
19
+ import { brief, comp, face, line, named, shape, writable } from './read.js'
20
+
21
+ /** An entity a value names: what it is called, linked to its page, the id a
22
+ * person types where the pointer rests on it. */
23
+ export let mention = (io: Io, eid: string): JSX.Element => {
24
+ let b = io.get(eid)
25
+ return b
26
+ ? io.show(b, 'Inspect.Reference.Inline') as JSX.Element
27
+ : h('a', { href: io.link(eid) }, io.name(eid))
28
+ }
29
+
30
+ /** A stored value as it was stored: a reference as the entity it names;
31
+ * anything else coloured by its shape. */
32
+ export let shown = (io: Io, v: unknown, p?: Declared): JSX.Element =>
33
+ p?.category == 'ref' && named(v)
34
+ ? mention(io, v)
35
+ : h(Value, { mod: shape(v) }, face(v))
36
+
37
+ /** A stored value as a person reads it; nothing where it holds nothing. A text
38
+ * kept as a blob (@yaks/blob's `store: 'blob'`), where a journal holds its
39
+ * address rather than its words, links to the words. */
40
+ export let reads = (io: Io, v: unknown, p?: Declared): JSX.Element => {
41
+ if (v == null) return h(Value, { mod: 'nil' })
42
+ if (named(v) && (p?.category == 'ref' || !p)) return mention(io, v)
43
+ if (p?.keywords.store == 'blob' && /^[0-9a-f]{64}$/.test(String(v))) {
44
+ return h('a', { href: `/blob/${v}` }, 'the text')
45
+ }
46
+ let s = shape(v)
47
+ let said = s == 'time'
48
+ ? io.when(String(v))
49
+ : s == 'json'
50
+ ? line(face(v), 100)
51
+ : typeof v == 'string'
52
+ ? brief(line(v, 160))
53
+ : face(v)
54
+ return h(Value, { mod: s, title: s == 'time' ? String(v) : undefined }, said)
55
+ }
56
+
57
+ /** What a cell is drawn with: the entity, and which of its values. */
58
+ export type CellProps = { io: Io; e: Bundle; name: string; prop: string }
59
+
60
+ /** One value of an entity, changed where it stands where it may be. Its
61
+ * shape is worn around the whole value, so what is typed over it keeps the
62
+ * face's type. */
63
+ export let Cell = ({ io, e, name, prop }: CellProps): JSX.Element => {
64
+ let v = comp(e, name)[prop]
65
+ let p = io.vocab.prop(name, prop)
66
+ if (!writable(io, name, prop)) return shown(io, v, p)
67
+ let ref = p?.category == 'ref'
68
+ // A reference's face is a link, so its picker opens from a handle beside it.
69
+ let value = h(Edit, {
70
+ e,
71
+ comp: name,
72
+ prop,
73
+ editable: true,
74
+ handle: ref,
75
+ show: (_, now) => shown(io, now, p),
76
+ })
77
+ let s = shape(v)
78
+ return ref || s == 'nil' ? value : h(Value, { mod: s }, value)
79
+ }
package/views.js ADDED
@@ -0,0 +1,4 @@
1
+ // Query-backed inspector views are loaded by the host that adapts them.
2
+ // A portable printer loads this facet without importing any inspector page.
3
+ export let inspectViews = ()=>import("./registry.js").then((m)=>m.all);
4
+ //# sourceMappingURL=views.js.map
package/views.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.js","sources":["./views.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAG5E,OAAO,IAAI,eAAe,IACxB,MAAM,CAAC,iBAAiB,IAAI,CAAC,CAAC,IAAM,EAAE,GAAG,EAAC"}
package/views.ts ADDED
@@ -0,0 +1,6 @@
1
+ // Query-backed inspector views are loaded by the host that adapts them.
2
+ // A portable printer loads this facet without importing any inspector page.
3
+ import type { View } from './host.ts'
4
+
5
+ export let inspectViews = (): Promise<View[]> =>
6
+ import('./registry.js').then((m) => m.all)