@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.
- package/Comp.js +469 -0
- package/Comp.js.map +1 -0
- package/Comp.ts +471 -0
- package/Effect.js +136 -0
- package/Effect.js.map +1 -0
- package/Effect.ts +142 -0
- package/Entity.js +112 -0
- package/Entity.js.map +1 -0
- package/Entity.ts +137 -0
- package/Facts.js +143 -0
- package/Facts.js.map +1 -0
- package/Facts.ts +150 -0
- package/Head.js +196 -0
- package/Head.js.map +1 -0
- package/Head.ts +195 -0
- package/Held.js +144 -0
- package/Held.js.map +1 -0
- package/Held.ts +172 -0
- package/History.js +157 -0
- package/History.js.map +1 -0
- package/History.ts +215 -0
- package/Home.js +482 -0
- package/Home.js.map +1 -0
- package/Home.ts +550 -0
- package/LICENSE +202 -0
- package/Links.js +197 -0
- package/Links.js.map +1 -0
- package/Links.ts +212 -0
- package/Package.js +195 -0
- package/Package.js.map +1 -0
- package/Package.ts +191 -0
- package/Past.js +163 -0
- package/Past.js.map +1 -0
- package/Past.ts +181 -0
- package/Prop.js +225 -0
- package/Prop.js.map +1 -0
- package/Prop.ts +208 -0
- package/Query.js +207 -0
- package/Query.js.map +1 -0
- package/Query.ts +229 -0
- package/README.md +141 -2
- package/Words.js +43 -0
- package/Words.js.map +1 -0
- package/Words.ts +70 -0
- package/_dist/Entity.d.ts +7 -0
- package/_dist/Entity.d.ts.map +1 -0
- package/_dist/Facts.d.ts +7 -0
- package/_dist/Facts.d.ts.map +1 -0
- package/_dist/Head.d.ts +22 -0
- package/_dist/Head.d.ts.map +1 -0
- package/_dist/Held.d.ts +37 -0
- package/_dist/Held.d.ts.map +1 -0
- package/_dist/Links.d.ts +9 -0
- package/_dist/Links.d.ts.map +1 -0
- package/_dist/Past.d.ts +65 -0
- package/_dist/Past.d.ts.map +1 -0
- package/_dist/Words.d.ts +27 -0
- package/_dist/Words.d.ts.map +1 -0
- package/_dist/census.d.ts +10 -0
- package/_dist/census.d.ts.map +1 -0
- package/_dist/door.d.ts +28 -0
- package/_dist/door.d.ts.map +1 -0
- package/_dist/front.d.ts +4 -0
- package/_dist/front.d.ts.map +1 -0
- package/_dist/host.d.ts +94 -0
- package/_dist/host.d.ts.map +1 -0
- package/_dist/mod.d.ts +24 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/notes.d.ts +38 -0
- package/_dist/notes.d.ts.map +1 -0
- package/_dist/read.d.ts +59 -0
- package/_dist/read.d.ts.map +1 -0
- package/_dist/reading.d.ts +21 -0
- package/_dist/reading.d.ts.map +1 -0
- package/_dist/registry.d.ts +12 -0
- package/_dist/registry.d.ts.map +1 -0
- package/_dist/schema.d.ts +4 -0
- package/_dist/schema.d.ts.map +1 -0
- package/_dist/state.d.ts +22 -0
- package/_dist/state.d.ts.map +1 -0
- package/_dist/value.d.ts +20 -0
- package/_dist/value.d.ts.map +1 -0
- package/_dist/views.d.ts +3 -0
- package/_dist/views.d.ts.map +1 -0
- package/census.js +50 -0
- package/census.js.map +1 -0
- package/census.ts +76 -0
- package/deno.json +1 -0
- package/door.js +54 -0
- package/door.js.map +1 -0
- package/door.ts +59 -0
- package/front.js +12 -0
- package/front.js.map +1 -0
- package/front.json +76 -0
- package/front.ts +13 -0
- package/grid.js +249 -0
- package/grid.js.map +1 -0
- package/grid.ts +395 -0
- package/host.js +20 -0
- package/host.js.map +1 -0
- package/host.ts +134 -0
- package/mod.js +20 -0
- package/mod.js.map +1 -0
- package/mod.ts +45 -0
- package/notes.js +184 -0
- package/notes.js.map +1 -0
- package/notes.ts +288 -0
- package/package.json +35 -4
- package/read.js +300 -0
- package/read.js.map +1 -0
- package/read.ts +386 -0
- package/reading.js +64 -0
- package/reading.js.map +1 -0
- package/reading.ts +73 -0
- package/registry.js +89 -0
- package/registry.js.map +1 -0
- package/registry.ts +89 -0
- package/rows.js +12 -0
- package/rows.js.map +1 -0
- package/rows.ts +26 -0
- package/schema.js +47 -0
- package/schema.js.map +1 -0
- package/schema.ts +70 -0
- package/state.js +85 -0
- package/state.js.map +1 -0
- package/state.ts +128 -0
- package/terminal-links.ts +16 -0
- package/value.js +67 -0
- package/value.js.map +1 -0
- package/value.ts +79 -0
- package/views.js +4 -0
- package/views.js.map +1 -0
- package/views.ts +6 -0
package/Facts.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an entity states (`Inspect.Facts`): each component it carries that the
|
|
3
|
+
* head and the body do not already say, in the order they mean (./read.ts
|
|
4
|
+
* `facts`): the kinds it is, what else it carries, then what happened to it.
|
|
5
|
+
*
|
|
6
|
+
* Read, each component is a line: its name, linked to its page and telling
|
|
7
|
+
* what it is where the pointer rests, then the values it holds, each as a
|
|
8
|
+
* person reads it; one that holds nothing says what it means instead. Edited,
|
|
9
|
+
* each is a table of every property it stores or declares, each value typed
|
|
10
|
+
* over where it stands, and removed by its ×; the title and the body are
|
|
11
|
+
* among them, since editing is where they change.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, Fragment, type JSX } from 'react'
|
|
17
|
+
import { Button, Pairs, Rows, Section, Value } from '@yaks/ui'
|
|
18
|
+
import type { Bundle, Io, Props, View } from './host.ts'
|
|
19
|
+
import { Cell, reads } from './value.js'
|
|
20
|
+
import { Grid } from './grid.js'
|
|
21
|
+
import { chip } from './schema.js'
|
|
22
|
+
import { about, Part, Said, useNamed } from './notes.js'
|
|
23
|
+
import { comp, comps, facts, line, named, writable } from './read.js'
|
|
24
|
+
import { edited, key, write } from './state.js'
|
|
25
|
+
|
|
26
|
+
/** What the facts are drawn with besides the entity: components the page
|
|
27
|
+
* says in a part of its own, and the notes by heading. */
|
|
28
|
+
export type FactsCtx = { skip?: string[]; notes?: Map<string, Bundle[]> }
|
|
29
|
+
|
|
30
|
+
/** One component of an entity, edited: a row per property it stores or
|
|
31
|
+
* declares, so a component just added shows what it can be given. */
|
|
32
|
+
export let CompTable = (
|
|
33
|
+
{ e, io, name, notes }: {
|
|
34
|
+
e: Bundle
|
|
35
|
+
io: Io
|
|
36
|
+
name: string
|
|
37
|
+
notes?: Map<string, Bundle[]>
|
|
38
|
+
},
|
|
39
|
+
): JSX.Element => {
|
|
40
|
+
let eid = e.entity.eid
|
|
41
|
+
let row = comp(e, name)
|
|
42
|
+
let props = [...new Set([...Object.keys(row), ...io.vocab.props(name)])]
|
|
43
|
+
let refs = props.filter((p) => io.vocab.prop(name, p)?.category == 'ref')
|
|
44
|
+
useNamed(io, refs.map((p) => row[p] as string))
|
|
45
|
+
let remove = writable(io, name)
|
|
46
|
+
? h(Button, {
|
|
47
|
+
type: 'button',
|
|
48
|
+
mod: ['quiet', 'danger'],
|
|
49
|
+
'aria-label': `remove ${name}`,
|
|
50
|
+
title: `remove ${name}`,
|
|
51
|
+
onClick: () => write(io, eid, [{ entity: { eid }, [name]: null }]),
|
|
52
|
+
}, '×')
|
|
53
|
+
: null
|
|
54
|
+
return h(
|
|
55
|
+
Part,
|
|
56
|
+
{
|
|
57
|
+
io,
|
|
58
|
+
eid,
|
|
59
|
+
subject: about(io, e),
|
|
60
|
+
heading: name,
|
|
61
|
+
title: chip(io, name),
|
|
62
|
+
act: remove,
|
|
63
|
+
sub: io.vocab.comp(name)?.description,
|
|
64
|
+
notes,
|
|
65
|
+
},
|
|
66
|
+
props.length
|
|
67
|
+
? h(Grid, {
|
|
68
|
+
io,
|
|
69
|
+
id: key(eid, name),
|
|
70
|
+
pick: false,
|
|
71
|
+
local: true,
|
|
72
|
+
rows: props.map((prop): Bundle => ({ entity: { eid: prop } })),
|
|
73
|
+
columns: [
|
|
74
|
+
{ name: 'property', mod: 'key', cell: (p) => p.entity.eid },
|
|
75
|
+
{
|
|
76
|
+
name: 'value',
|
|
77
|
+
cell: (p) => h(Cell, { io, e, name, prop: p.entity.eid }),
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
})
|
|
81
|
+
: h(Rows.More, {}, 'no properties: it is there, or not'),
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// One component, read: the values it holds, or what it means; and the notes
|
|
86
|
+
// left under it.
|
|
87
|
+
let stated = (
|
|
88
|
+
io: Io,
|
|
89
|
+
e: Bundle,
|
|
90
|
+
name: string,
|
|
91
|
+
notes?: Map<string, Bundle[]>,
|
|
92
|
+
) => {
|
|
93
|
+
let held = Object.entries(comp(e, name)).filter(([, v]) =>
|
|
94
|
+
v != null && v !== ''
|
|
95
|
+
)
|
|
96
|
+
let what = io.vocab.comp(name)?.description
|
|
97
|
+
let eid = e.entity.eid
|
|
98
|
+
return [
|
|
99
|
+
h(Pairs.Key, { key: `${name} k`, 'data-tip': what }, chip(io, name)),
|
|
100
|
+
h(
|
|
101
|
+
Pairs.Value,
|
|
102
|
+
{ key: `${name} v` },
|
|
103
|
+
held.length
|
|
104
|
+
? held.flatMap(([p, v], i) => [
|
|
105
|
+
i ? ' · ' : null,
|
|
106
|
+
h(Value, { key: p, mod: 'id' }, p),
|
|
107
|
+
' ',
|
|
108
|
+
reads(io, v, io.vocab.prop(name, p)),
|
|
109
|
+
])
|
|
110
|
+
: h(Value, { mod: 'nil' }, line(what ?? 'there', 120)),
|
|
111
|
+
h(Said, {
|
|
112
|
+
io,
|
|
113
|
+
eid,
|
|
114
|
+
subject: about(io, e),
|
|
115
|
+
heading: name,
|
|
116
|
+
notes: notes?.get(name),
|
|
117
|
+
}),
|
|
118
|
+
),
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** What an entity states. */
|
|
123
|
+
export let Facts = ({ e, io, ctx }: Props): JSX.Element | null => {
|
|
124
|
+
let { skip = [], notes } = ctx as FactsCtx
|
|
125
|
+
let editing = edited(io, e.entity.eid)
|
|
126
|
+
let names = editing
|
|
127
|
+
? comps(e).map(([n]) => n).filter((n) => !skip.includes(n))
|
|
128
|
+
: facts(io.vocab, e, skip)
|
|
129
|
+
useNamed(
|
|
130
|
+
io,
|
|
131
|
+
names.flatMap((n) => Object.values(comp(e, n)).filter(named)),
|
|
132
|
+
)
|
|
133
|
+
if (!names.length) return null
|
|
134
|
+
return editing
|
|
135
|
+
? h(
|
|
136
|
+
Fragment,
|
|
137
|
+
{},
|
|
138
|
+
names.map((name) => h(CompTable, { key: name, e, io, name, notes })),
|
|
139
|
+
)
|
|
140
|
+
: h(
|
|
141
|
+
Section,
|
|
142
|
+
{ 'data-facts': '' },
|
|
143
|
+
h(Pairs, {}, names.flatMap((n) => stated(io, e, n, notes))),
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The facts of any entity. */
|
|
148
|
+
export let factViews: View[] = [
|
|
149
|
+
{ view: 'Inspect.Facts', match: true, Render: Facts },
|
|
150
|
+
]
|
package/Head.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The top of an entity's page (`Inspect.Head`): what it is called, its id
|
|
3
|
+
* where that says more, and its kind; under them, in the head's `Sub`, what
|
|
4
|
+
* the page that drew it says about it (a belief's subject, a component's
|
|
5
|
+
* description); and last, one quiet line, where it came from: who made it and
|
|
6
|
+
* when, what built it, when it last changed (`Provenance`).
|
|
7
|
+
*
|
|
8
|
+
* A page is read until the reader asks to edit it. Where the host's controls
|
|
9
|
+
* take input the head offers a note on the whole thing and `edit`; editing, it
|
|
10
|
+
* also offers a component to add and the entity's delete, and every part of
|
|
11
|
+
* the page shows its controls (./state.ts `edited`).
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, Fragment } from "react";
|
|
15
|
+
import * as ui from "@yaks/ui";
|
|
16
|
+
import { about, NoteButton, Said, useNamed } from "./notes.js";
|
|
17
|
+
import { comp, comps, str, writable } from "./read.js";
|
|
18
|
+
import { mention } from "./value.js";
|
|
19
|
+
import { edited, me, put, refusal, write } from "./state.js";
|
|
20
|
+
// The components a client may add that the entity lacks.
|
|
21
|
+
let addable = (io, e)=>{
|
|
22
|
+
let has = new Set(comps(e).map(([n])=>n));
|
|
23
|
+
return io.vocab.comps.filter((n)=>!has.has(n) && writable(io, n));
|
|
24
|
+
};
|
|
25
|
+
let Add = ({ e, io })=>/*#__PURE__*/ h(ui.Edit.Choice, {
|
|
26
|
+
mod: 'fit',
|
|
27
|
+
'aria-label': 'add a component',
|
|
28
|
+
value: '',
|
|
29
|
+
onChange: (ev)=>{
|
|
30
|
+
let name = ev.currentTarget.value;
|
|
31
|
+
let eid = e.entity.eid;
|
|
32
|
+
if (name) write(io, eid, [
|
|
33
|
+
{
|
|
34
|
+
entity: {
|
|
35
|
+
eid
|
|
36
|
+
},
|
|
37
|
+
[name]: {}
|
|
38
|
+
}
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
}, /*#__PURE__*/ h('option', {
|
|
42
|
+
value: ''
|
|
43
|
+
}, '+ component'), addable(io, e).map((n)=>/*#__PURE__*/ h('option', {
|
|
44
|
+
key: n,
|
|
45
|
+
value: n
|
|
46
|
+
}, n)));
|
|
47
|
+
// Deleting takes two presses: the first arms it, in the page's own graph.
|
|
48
|
+
let Delete = ({ e, io })=>{
|
|
49
|
+
let eid = e.entity.eid;
|
|
50
|
+
let press = (mod, onClick, said)=>/*#__PURE__*/ h(ui.Button, {
|
|
51
|
+
type: 'button',
|
|
52
|
+
mod,
|
|
53
|
+
onClick
|
|
54
|
+
}, said);
|
|
55
|
+
return me(io).armed == eid ? /*#__PURE__*/ h('span', {}, press('danger', ()=>{
|
|
56
|
+
io.set(put({
|
|
57
|
+
armed: null
|
|
58
|
+
}));
|
|
59
|
+
write(io, eid, [
|
|
60
|
+
{
|
|
61
|
+
entity: {
|
|
62
|
+
eid
|
|
63
|
+
},
|
|
64
|
+
$delete: true
|
|
65
|
+
}
|
|
66
|
+
]);
|
|
67
|
+
}, `delete ${io.id(e)}`), press('quiet', ()=>io.set(put({
|
|
68
|
+
armed: null
|
|
69
|
+
})), 'keep')) : press([
|
|
70
|
+
'quiet',
|
|
71
|
+
'danger'
|
|
72
|
+
], ()=>io.set(put({
|
|
73
|
+
armed: eid
|
|
74
|
+
})), 'delete');
|
|
75
|
+
};
|
|
76
|
+
// The press that turns a page's controls on, and off again.
|
|
77
|
+
let Edit = ({ io, eid })=>{
|
|
78
|
+
let on = edited(io, eid);
|
|
79
|
+
return /*#__PURE__*/ h(ui.Button, {
|
|
80
|
+
type: 'button',
|
|
81
|
+
mod: 'quiet',
|
|
82
|
+
'aria-pressed': on,
|
|
83
|
+
onClick: ()=>io.set(put({
|
|
84
|
+
editing: on ? null : eid,
|
|
85
|
+
armed: null
|
|
86
|
+
}))
|
|
87
|
+
}, on ? 'done' : 'edit');
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Where an entity came from, in one quiet line: what built it (a builder's
|
|
91
|
+
* output, @yaks/builders), who made it and when, and through which session;
|
|
92
|
+
* when it last changed, and by whom where that was somebody else; when it was
|
|
93
|
+
* checked; the file a transcript entry was read from. Each entity named, and
|
|
94
|
+
* linked.
|
|
95
|
+
*/ export let Provenance = ({ e, io })=>{
|
|
96
|
+
let made = comp(e, 'created');
|
|
97
|
+
let changed = comp(e, 'updated');
|
|
98
|
+
let built = comp(e, 'built');
|
|
99
|
+
let build = str(e, 'built', 'build');
|
|
100
|
+
let at = (v)=>typeof v == 'string' && v ? io.when(v) : '';
|
|
101
|
+
let who = (v)=>typeof v == 'string' && v ? v : '';
|
|
102
|
+
// A build is called by the builder that made it: two hops, the second
|
|
103
|
+
// once the first is in.
|
|
104
|
+
let builder = str(io.get(build), 'build', 'builder');
|
|
105
|
+
let by = who(made.by);
|
|
106
|
+
let via = who(made.via) != by ? who(made.via) : '';
|
|
107
|
+
let other = who(changed.by) != by ? who(changed.by) : '';
|
|
108
|
+
let read = str(e, 'lines', 'file');
|
|
109
|
+
useNamed(io, [
|
|
110
|
+
by,
|
|
111
|
+
via,
|
|
112
|
+
other,
|
|
113
|
+
build,
|
|
114
|
+
builder,
|
|
115
|
+
str(e, 'built', 'call'),
|
|
116
|
+
read
|
|
117
|
+
]);
|
|
118
|
+
let parts = [
|
|
119
|
+
build ? /*#__PURE__*/ h('span', {
|
|
120
|
+
key: 'built'
|
|
121
|
+
}, 'built by ', /*#__PURE__*/ h('a', {
|
|
122
|
+
href: io.link(build)
|
|
123
|
+
}, builder ? io.name(builder) : 'a build'), built.slot ? ` (${built.slot})` : '', built.current === false ? ', since gone stale' : '') : null,
|
|
124
|
+
made.at || by ? /*#__PURE__*/ h('span', {
|
|
125
|
+
key: 'made'
|
|
126
|
+
}, build ? '' : 'made ', at(made.at), by && !build ? [
|
|
127
|
+
' by ',
|
|
128
|
+
mention(io, by)
|
|
129
|
+
] : '', via ? [
|
|
130
|
+
' via ',
|
|
131
|
+
mention(io, via)
|
|
132
|
+
] : '') : null,
|
|
133
|
+
changed.at && changed.at != made.at ? /*#__PURE__*/ h('span', {
|
|
134
|
+
key: 'changed'
|
|
135
|
+
}, 'changed ', at(changed.at), other ? [
|
|
136
|
+
' by ',
|
|
137
|
+
mention(io, other)
|
|
138
|
+
] : '') : null,
|
|
139
|
+
e.verified ? /*#__PURE__*/ h('span', {
|
|
140
|
+
key: 'checked'
|
|
141
|
+
}, 'checked ', at(comp(e, 'verified').at)) : null,
|
|
142
|
+
built.call ? /*#__PURE__*/ h('a', {
|
|
143
|
+
key: 'call',
|
|
144
|
+
href: io.link(String(built.call))
|
|
145
|
+
}, 'the call') : null,
|
|
146
|
+
read ? /*#__PURE__*/ h('span', {
|
|
147
|
+
key: 'from'
|
|
148
|
+
}, 'read from ', mention(io, read), comp(e, 'lines').start != null ? `:${comp(e, 'lines').start}` : '') : null
|
|
149
|
+
];
|
|
150
|
+
return /*#__PURE__*/ h(ui.Head.Facts, {}, ...parts.filter(Boolean));
|
|
151
|
+
};
|
|
152
|
+
/** An entity's head. */ export let EntityHead = ({ e, io, ctx })=>{
|
|
153
|
+
let eid = e.entity.eid;
|
|
154
|
+
let { sub, notes, subject = about(io, e) } = ctx;
|
|
155
|
+
let name = io.name(eid);
|
|
156
|
+
let id = io.id(e);
|
|
157
|
+
let said = refusal(io, eid);
|
|
158
|
+
let editing = edited(io, eid);
|
|
159
|
+
return /*#__PURE__*/ h(Fragment, null, /*#__PURE__*/ h(ui.Head, {}, /*#__PURE__*/ h(ui.Head.Title, {}, name, name != id ? /*#__PURE__*/ h(ui.Head.Id, {}, id) : null, /*#__PURE__*/ h(ui.Head.Kind, {}, io.kind(e)), /*#__PURE__*/ h(NoteButton, {
|
|
160
|
+
io,
|
|
161
|
+
eid,
|
|
162
|
+
heading: '',
|
|
163
|
+
subject
|
|
164
|
+
}), io.edits ? /*#__PURE__*/ h(Edit, {
|
|
165
|
+
io,
|
|
166
|
+
eid
|
|
167
|
+
}) : null, ...editing ? [
|
|
168
|
+
/*#__PURE__*/ h(Add, {
|
|
169
|
+
e,
|
|
170
|
+
io
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ h(Delete, {
|
|
173
|
+
e,
|
|
174
|
+
io
|
|
175
|
+
})
|
|
176
|
+
] : []), sub ? /*#__PURE__*/ h(ui.Head.Sub, {}, sub) : null, said ? /*#__PURE__*/ h(ui.Head.Sub, {
|
|
177
|
+
mod: 'refused'
|
|
178
|
+
}, said) : null, /*#__PURE__*/ h(Provenance, {
|
|
179
|
+
e,
|
|
180
|
+
io
|
|
181
|
+
})), /*#__PURE__*/ h(Said, {
|
|
182
|
+
io,
|
|
183
|
+
eid,
|
|
184
|
+
subject,
|
|
185
|
+
heading: '',
|
|
186
|
+
notes
|
|
187
|
+
}));
|
|
188
|
+
};
|
|
189
|
+
/** The head of any entity's page. */ export let headViews = [
|
|
190
|
+
{
|
|
191
|
+
view: 'Inspect.Head',
|
|
192
|
+
match: true,
|
|
193
|
+
Render: EntityHead
|
|
194
|
+
}
|
|
195
|
+
];
|
|
196
|
+
//# sourceMappingURL=Head.js.map
|
package/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CAAC,GAAG,EAAE;IAAE,KAAK;EAAU,GAAG,QAAQ,oBAClD,EAAE,YAAY;IAAE;IAAG;EAAG,mBAExB,EAAE,MAAM;IAAE;IAAI;IAAK;IAAS,SAAS;IAAI;EAAM;AAEnD,EAAC;AAED,mCAAmC,GACnC,OAAO,IAAI,YAAoB;EAC7B;IAAE,MAAM;IAAgB,OAAO;IAAM,QAAQ;EAAW;CACzD,CAAA"}
|
package/Head.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The top of an entity's page (`Inspect.Head`): what it is called, its id
|
|
3
|
+
* where that says more, and its kind; under them, in the head's `Sub`, what
|
|
4
|
+
* the page that drew it says about it (a belief's subject, a component's
|
|
5
|
+
* description); and last, one quiet line, where it came from: who made it and
|
|
6
|
+
* when, what built it, when it last changed (`Provenance`).
|
|
7
|
+
*
|
|
8
|
+
* A page is read until the reader asks to edit it. Where the host's controls
|
|
9
|
+
* take input the head offers a note on the whole thing and `edit`; editing, it
|
|
10
|
+
* also offers a component to add and the entity's delete, and every part of
|
|
11
|
+
* the page shows its controls (./state.ts `edited`).
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, Fragment, type JSX, type ReactNode } from 'react'
|
|
17
|
+
import * as ui from '@yaks/ui'
|
|
18
|
+
import type { Bundle, Io, Props, View } from './host.ts'
|
|
19
|
+
import { about, NoteButton, Said, useNamed } from './notes.js'
|
|
20
|
+
import { comp, comps, str, writable } from './read.js'
|
|
21
|
+
import { mention } from './value.js'
|
|
22
|
+
import { edited, me, put, refusal, write } from './state.js'
|
|
23
|
+
|
|
24
|
+
/** What a head is drawn with besides its entity: what the page says about
|
|
25
|
+
* it, under its name, and the notes left on it as a whole. */
|
|
26
|
+
export type HeadCtx = {
|
|
27
|
+
sub?: ReactNode
|
|
28
|
+
notes?: Bundle[]
|
|
29
|
+
/** what a note on it calls it (its id, or a component's name) */
|
|
30
|
+
subject?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// The components a client may add that the entity lacks.
|
|
34
|
+
let addable = (io: Io, e: Bundle): string[] => {
|
|
35
|
+
let has = new Set(comps(e).map(([n]) => n))
|
|
36
|
+
return io.vocab.comps.filter((n) => !has.has(n) && writable(io, n))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let Add = ({ e, io }: { e: Bundle; io: Io }) =>
|
|
40
|
+
h(
|
|
41
|
+
ui.Edit.Choice,
|
|
42
|
+
{
|
|
43
|
+
mod: 'fit',
|
|
44
|
+
'aria-label': 'add a component',
|
|
45
|
+
value: '',
|
|
46
|
+
onChange: (ev: Event & { currentTarget: HTMLSelectElement }) => {
|
|
47
|
+
let name = ev.currentTarget.value
|
|
48
|
+
let eid = e.entity.eid
|
|
49
|
+
if (name) write(io, eid, [{ entity: { eid }, [name]: {} }])
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
h('option', { value: '' }, '+ component'),
|
|
53
|
+
addable(io, e).map((n) => h('option', { key: n, value: n }, n)),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
// Deleting takes two presses: the first arms it, in the page's own graph.
|
|
57
|
+
let Delete = ({ e, io }: { e: Bundle; io: Io }) => {
|
|
58
|
+
let eid = e.entity.eid
|
|
59
|
+
let press = (mod: string | string[], onClick: () => void, said: string) =>
|
|
60
|
+
h(ui.Button, { type: 'button', mod, onClick }, said)
|
|
61
|
+
return me(io).armed == eid
|
|
62
|
+
? h(
|
|
63
|
+
'span',
|
|
64
|
+
{},
|
|
65
|
+
press('danger', () => {
|
|
66
|
+
io.set(put({ armed: null }))
|
|
67
|
+
write(io, eid, [{ entity: { eid }, $delete: true }])
|
|
68
|
+
}, `delete ${io.id(e)}`),
|
|
69
|
+
press('quiet', () => io.set(put({ armed: null })), 'keep'),
|
|
70
|
+
)
|
|
71
|
+
: press(['quiet', 'danger'], () => io.set(put({ armed: eid })), 'delete')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// The press that turns a page's controls on, and off again.
|
|
75
|
+
let Edit = ({ io, eid }: { io: Io; eid: string }) => {
|
|
76
|
+
let on = edited(io, eid)
|
|
77
|
+
return h(ui.Button, {
|
|
78
|
+
type: 'button',
|
|
79
|
+
mod: 'quiet',
|
|
80
|
+
'aria-pressed': on,
|
|
81
|
+
onClick: () => io.set(put({ editing: on ? null : eid, armed: null })),
|
|
82
|
+
}, on ? 'done' : 'edit')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Where an entity came from, in one quiet line: what built it (a builder's
|
|
87
|
+
* output, @yaks/builders), who made it and when, and through which session;
|
|
88
|
+
* when it last changed, and by whom where that was somebody else; when it was
|
|
89
|
+
* checked; the file a transcript entry was read from. Each entity named, and
|
|
90
|
+
* linked.
|
|
91
|
+
*/
|
|
92
|
+
export let Provenance = ({ e, io }: { e: Bundle; io: Io }): JSX.Element => {
|
|
93
|
+
let made = comp(e, 'created')
|
|
94
|
+
let changed = comp(e, 'updated')
|
|
95
|
+
let built = comp(e, 'built')
|
|
96
|
+
let build = str(e, 'built', 'build')
|
|
97
|
+
let at = (v: unknown) => typeof v == 'string' && v ? io.when(v) : ''
|
|
98
|
+
let who = (v: unknown) => typeof v == 'string' && v ? v : ''
|
|
99
|
+
// A build is called by the builder that made it: two hops, the second
|
|
100
|
+
// once the first is in.
|
|
101
|
+
let builder = str(io.get(build), 'build', 'builder')
|
|
102
|
+
let by = who(made.by)
|
|
103
|
+
let via = who(made.via) != by ? who(made.via) : ''
|
|
104
|
+
let other = who(changed.by) != by ? who(changed.by) : ''
|
|
105
|
+
let read = str(e, 'lines', 'file')
|
|
106
|
+
useNamed(io, [by, via, other, build, builder, str(e, 'built', 'call'), read])
|
|
107
|
+
let parts: ReactNode[] = [
|
|
108
|
+
build
|
|
109
|
+
? h(
|
|
110
|
+
'span',
|
|
111
|
+
{ key: 'built' },
|
|
112
|
+
'built by ',
|
|
113
|
+
h(
|
|
114
|
+
'a',
|
|
115
|
+
{ href: io.link(build) },
|
|
116
|
+
builder ? io.name(builder) : 'a build',
|
|
117
|
+
),
|
|
118
|
+
built.slot ? ` (${built.slot})` : '',
|
|
119
|
+
built.current === false ? ', since gone stale' : '',
|
|
120
|
+
)
|
|
121
|
+
: null,
|
|
122
|
+
made.at || by
|
|
123
|
+
? h(
|
|
124
|
+
'span',
|
|
125
|
+
{ key: 'made' },
|
|
126
|
+
build ? '' : 'made ',
|
|
127
|
+
at(made.at),
|
|
128
|
+
by && !build ? [' by ', mention(io, by)] : '',
|
|
129
|
+
via ? [' via ', mention(io, via)] : '',
|
|
130
|
+
)
|
|
131
|
+
: null,
|
|
132
|
+
changed.at && changed.at != made.at
|
|
133
|
+
? h(
|
|
134
|
+
'span',
|
|
135
|
+
{ key: 'changed' },
|
|
136
|
+
'changed ',
|
|
137
|
+
at(changed.at),
|
|
138
|
+
other ? [' by ', mention(io, other)] : '',
|
|
139
|
+
)
|
|
140
|
+
: null,
|
|
141
|
+
e.verified
|
|
142
|
+
? h('span', { key: 'checked' }, 'checked ', at(comp(e, 'verified').at))
|
|
143
|
+
: null,
|
|
144
|
+
built.call
|
|
145
|
+
? h('a', { key: 'call', href: io.link(String(built.call)) }, 'the call')
|
|
146
|
+
: null,
|
|
147
|
+
read
|
|
148
|
+
? h(
|
|
149
|
+
'span',
|
|
150
|
+
{ key: 'from' },
|
|
151
|
+
'read from ',
|
|
152
|
+
mention(io, read),
|
|
153
|
+
comp(e, 'lines').start != null ? `:${comp(e, 'lines').start}` : '',
|
|
154
|
+
)
|
|
155
|
+
: null,
|
|
156
|
+
]
|
|
157
|
+
return h(ui.Head.Facts, {}, ...parts.filter(Boolean))
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** An entity's head. */
|
|
161
|
+
export let EntityHead = ({ e, io, ctx }: Props): JSX.Element => {
|
|
162
|
+
let eid = e.entity.eid
|
|
163
|
+
let { sub, notes, subject = about(io, e) } = ctx as HeadCtx
|
|
164
|
+
let name = io.name(eid)
|
|
165
|
+
let id = io.id(e)
|
|
166
|
+
let said = refusal(io, eid)
|
|
167
|
+
let editing = edited(io, eid)
|
|
168
|
+
return h(
|
|
169
|
+
Fragment,
|
|
170
|
+
null,
|
|
171
|
+
h(
|
|
172
|
+
ui.Head,
|
|
173
|
+
{},
|
|
174
|
+
h(
|
|
175
|
+
ui.Head.Title,
|
|
176
|
+
{},
|
|
177
|
+
name,
|
|
178
|
+
name != id ? h(ui.Head.Id, {}, id) : null,
|
|
179
|
+
h(ui.Head.Kind, {}, io.kind(e)),
|
|
180
|
+
h(NoteButton, { io, eid, heading: '', subject }),
|
|
181
|
+
io.edits ? h(Edit, { io, eid }) : null,
|
|
182
|
+
...editing ? [h(Add, { e, io }), h(Delete, { e, io })] : [],
|
|
183
|
+
),
|
|
184
|
+
sub ? h(ui.Head.Sub, {}, sub) : null,
|
|
185
|
+
said ? h(ui.Head.Sub, { mod: 'refused' }, said) : null,
|
|
186
|
+
h(Provenance, { e, io }),
|
|
187
|
+
),
|
|
188
|
+
h(Said, { io, eid, subject, heading: '', notes }),
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** The head of any entity's page. */
|
|
193
|
+
export let headViews: View[] = [
|
|
194
|
+
{ view: 'Inspect.Head', match: true, Render: EntityHead },
|
|
195
|
+
]
|
package/Held.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an entity holds by its links, in the order they are read, put in
|
|
3
|
+
* order where it stands: `Held`. Each row is the entity a link leads to,
|
|
4
|
+
* drawn by its own renderer (the view `tile` names). Where the host takes
|
|
5
|
+
* edits, a row is picked up and dropped between two others, which writes the
|
|
6
|
+
* links' positions (`edge.ord`, @yaks/edge `placed`), and an entity dragged
|
|
7
|
+
* from elsewhere (@yaks/ux `drag`: a row of another list, of a desk) joins
|
|
8
|
+
* the list where it is dropped, linked by `tag`. Each row opens in place on
|
|
9
|
+
* the title and body of what it leads to, typed over where they stand
|
|
10
|
+
* (@yaks/ux `Edit.Text`), and read only where the host takes no edits. An
|
|
11
|
+
* open row is no drag handle: selecting its text, clicking into it and typing
|
|
12
|
+
* never pick it up.
|
|
13
|
+
*
|
|
14
|
+
* Its caller names the links and their order (the order its reader reads
|
|
15
|
+
* them in) and draws the heading around it.
|
|
16
|
+
*
|
|
17
|
+
* ```ts ignore
|
|
18
|
+
* h(Held, { io, from: eid, links, ends, tile: 'Topic.List.Tile', tag: 'contains', empty: 'nothing yet' })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h } from "react";
|
|
23
|
+
import * as ui from "@yaks/ui";
|
|
24
|
+
import { at as editAt, disclosed, disclosureAt, Edit, isOpen, Order, orderAt } from "@yaks/ux";
|
|
25
|
+
import { link, placed } from "@yaks/edge";
|
|
26
|
+
import { relation, str } from "./read.js";
|
|
27
|
+
import { relations } from "./schema.js";
|
|
28
|
+
import { refusal, write } from "./state.js";
|
|
29
|
+
import { mention } from "./value.js";
|
|
30
|
+
import { Words } from "./Words.js";
|
|
31
|
+
let far = (b)=>str(b, 'edge', 'to');
|
|
32
|
+
/** A row opened in place: the title and body of what it leads to. */ let Detail = ({ io, end, owner })=>{
|
|
33
|
+
let eid = end.entity.eid;
|
|
34
|
+
let text = (prop, more)=>/*#__PURE__*/ h(Edit.Text, {
|
|
35
|
+
e: end,
|
|
36
|
+
comp: 'doc',
|
|
37
|
+
prop,
|
|
38
|
+
at: editAt(owner, eid, 'doc', prop),
|
|
39
|
+
readOnly: !io.edits,
|
|
40
|
+
...more
|
|
41
|
+
});
|
|
42
|
+
let no = refusal(io, eid);
|
|
43
|
+
return /*#__PURE__*/ h(ui.Rows.Detail, {
|
|
44
|
+
'data-detail': eid
|
|
45
|
+
}, /*#__PURE__*/ h('strong', {}, text('title', {
|
|
46
|
+
inline: true
|
|
47
|
+
})), /*#__PURE__*/ h(Words, {
|
|
48
|
+
io,
|
|
49
|
+
e: end,
|
|
50
|
+
comp: 'doc',
|
|
51
|
+
prop: 'body',
|
|
52
|
+
at: editAt(owner, eid, 'doc', 'body')
|
|
53
|
+
}), no ? /*#__PURE__*/ h(ui.Rows.More, {
|
|
54
|
+
role: 'alert'
|
|
55
|
+
}, no) : io.edits ? /*#__PURE__*/ h(ui.Rows.More, {}, 'double-click the title or the text to type over it') : null);
|
|
56
|
+
};
|
|
57
|
+
/** What an entity holds by its links, in order, each opened in place. */ export let Held = ({ io, from, links, ends, tile, empty, tag, join })=>{
|
|
58
|
+
let held = new Map((ends?.rows ?? []).map((b)=>[
|
|
59
|
+
b.entity.eid,
|
|
60
|
+
b
|
|
61
|
+
]));
|
|
62
|
+
let rels = relations(io);
|
|
63
|
+
let seen = new Set();
|
|
64
|
+
let rows = links.filter((b)=>{
|
|
65
|
+
let to = far(b);
|
|
66
|
+
return to && !seen.has(to) && seen.add(to);
|
|
67
|
+
});
|
|
68
|
+
let named = [
|
|
69
|
+
...new Set(rows.map((b)=>relation(b, rels) ?? ''))
|
|
70
|
+
];
|
|
71
|
+
let kinds = named.length > 1;
|
|
72
|
+
let by = new Map(rows.map((b)=>[
|
|
73
|
+
far(b),
|
|
74
|
+
b
|
|
75
|
+
]));
|
|
76
|
+
let order = orderAt(`held/${from}/${tag ?? named.sort().join(' ')}`);
|
|
77
|
+
// A row put between two others, or an entity from elsewhere joining.
|
|
78
|
+
let place = (to, at)=>{
|
|
79
|
+
let had = by.get(to);
|
|
80
|
+
if (had) return void write(io, from, placed(rows, had, at));
|
|
81
|
+
let more = tag && to != from ? join ? join(to) : [] : undefined;
|
|
82
|
+
if (more) {
|
|
83
|
+
void write(io, from, [
|
|
84
|
+
...more,
|
|
85
|
+
...placed(rows, link(from, tag, to), at)
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// Whether the row leading to `to` is open, and what says so.
|
|
90
|
+
let opened = (to)=>{
|
|
91
|
+
let at = disclosureAt(`held/${by.get(to).entity.eid}`);
|
|
92
|
+
let state = io.state(at) ?? {
|
|
93
|
+
entity: {
|
|
94
|
+
eid: at
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
state,
|
|
99
|
+
open: isOpen(state) && !!held.get(to)?.doc
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
let row = (to)=>{
|
|
103
|
+
let b = by.get(to);
|
|
104
|
+
let end = held.get(to);
|
|
105
|
+
let { state, open } = opened(to);
|
|
106
|
+
return [
|
|
107
|
+
/*#__PURE__*/ h(ui.Rows.Line, {
|
|
108
|
+
'data-held': to
|
|
109
|
+
}, /*#__PURE__*/ h(ui.Rows.Toggle, {
|
|
110
|
+
type: 'button',
|
|
111
|
+
disabled: !end?.doc,
|
|
112
|
+
'aria-expanded': open,
|
|
113
|
+
'aria-label': open ? 'close it' : 'open it here',
|
|
114
|
+
onClick: ()=>io.set([
|
|
115
|
+
disclosed(state, !open)
|
|
116
|
+
])
|
|
117
|
+
}, open ? '▾' : '▸'), /*#__PURE__*/ h('div', {}, kinds ? /*#__PURE__*/ h(ui.Rows.Kind, {}, relation(b, rels)) : null, end ? io.show(end, tile, {}) : ends?.ready ? [
|
|
118
|
+
mention(io, to),
|
|
119
|
+
' is gone'
|
|
120
|
+
] : /*#__PURE__*/ h(ui.Loading, {}))),
|
|
121
|
+
open && end ? /*#__PURE__*/ h(Detail, {
|
|
122
|
+
io,
|
|
123
|
+
end,
|
|
124
|
+
owner: b.entity.eid
|
|
125
|
+
}) : null
|
|
126
|
+
];
|
|
127
|
+
};
|
|
128
|
+
return /*#__PURE__*/ h(Order, {
|
|
129
|
+
e: io.state(order) ?? {
|
|
130
|
+
entity: {
|
|
131
|
+
eid: order
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
onChange: (b)=>io.set([
|
|
135
|
+
b
|
|
136
|
+
]),
|
|
137
|
+
ids: rows.map(far),
|
|
138
|
+
row,
|
|
139
|
+
onPlace: io.edits ? place : undefined,
|
|
140
|
+
open: (to)=>opened(to).open,
|
|
141
|
+
empty
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=Held.js.map
|