@yaks/browse 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/LICENSE +202 -0
- package/README.md +324 -2
- package/_dist/app.d.ts +8 -0
- package/_dist/app.d.ts.map +1 -0
- package/_dist/cli.d.ts +16 -0
- package/_dist/cli.d.ts.map +1 -0
- package/_dist/hosting.d.ts +24 -0
- package/_dist/hosting.d.ts.map +1 -0
- package/_dist/mod.d.ts +7 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/types.d.ts +5 -0
- package/_dist/types.d.ts.map +1 -0
- package/_dist/url.d.ts +2 -0
- package/_dist/url.d.ts.map +1 -0
- package/app.js +10 -0
- package/app.js.map +1 -0
- package/app.ts +10 -0
- package/browser-links.js +22 -0
- package/browser-links.js.map +1 -0
- package/browser-links.ts +28 -0
- package/cli.js +172 -0
- package/cli.js.map +1 -0
- package/cli.ts +168 -0
- package/client.js +748 -0
- package/client.js.map +1 -0
- package/client.ts +734 -0
- package/clipboard.js +18 -0
- package/clipboard.js.map +1 -0
- package/clipboard.ts +17 -0
- package/commands.js +1157 -0
- package/commands.js.map +1 -0
- package/commands.ts +1108 -0
- package/components/Ansi.tsx +160 -0
- package/components/App.tsx +446 -0
- package/components/Canvas.tsx +625 -0
- package/components/Card.tsx +276 -0
- package/components/Chat.tsx +205 -0
- package/components/Configuration.tsx +218 -0
- package/components/Decision.tsx +49 -0
- package/components/Dot.tsx +52 -0
- package/components/Entity.tsx +609 -0
- package/components/Fault.tsx +43 -0
- package/components/Filter.tsx +103 -0
- package/components/Keybindings.tsx +100 -0
- package/components/Keys.tsx +67 -0
- package/components/Markdown.tsx +90 -0
- package/components/Navigation.tsx +161 -0
- package/components/New.tsx +490 -0
- package/components/Peek.tsx +168 -0
- package/components/Prio.tsx +20 -0
- package/components/Run.tsx +263 -0
- package/components/Search.tsx +280 -0
- package/components/Stamp.tsx +44 -0
- package/components/Status.tsx +514 -0
- package/components/Sync.tsx +173 -0
- package/components/Tile.tsx +50 -0
- package/components/answered.js +23 -0
- package/components/answered.js.map +1 -0
- package/components/answered.ts +25 -0
- package/components/comp.js +11 -0
- package/components/comp.js.map +1 -0
- package/components/comp.ts +10 -0
- package/components/drag.js +173 -0
- package/components/drag.js.map +1 -0
- package/components/drag.ts +198 -0
- package/components/fields.tsx +90 -0
- package/components/fixtures/README.md +10 -0
- package/components/fixtures/archetypes.json +3646 -0
- package/components/hits.js +63 -0
- package/components/hits.js.map +1 -0
- package/components/hits.ts +84 -0
- package/components/icons.tsx +177 -0
- package/components/inspect.tsx +331 -0
- package/components/mount.ts +79 -0
- package/components/nav.tsx +479 -0
- package/components/offers.js +26 -0
- package/components/offers.js.map +1 -0
- package/components/offers.ts +54 -0
- package/components/page.js +21 -0
- package/components/page.js.map +1 -0
- package/components/page.ts +18 -0
- package/components/read.js +5 -0
- package/components/read.js.map +1 -0
- package/components/read.ts +7 -0
- package/components/registry.js +285 -0
- package/components/registry.js.map +1 -0
- package/components/registry.ts +317 -0
- package/components/session_status.tsx +115 -0
- package/components/subscriptions.js +149 -0
- package/components/subscriptions.js.map +1 -0
- package/components/subscriptions.ts +161 -0
- package/components/title.tsx +21 -0
- package/components/useQuery.js +166 -0
- package/components/useQuery.js.map +1 -0
- package/components/useQuery.ts +211 -0
- package/components/views/Board.tsx +450 -0
- package/components/views/BoardTile.tsx +65 -0
- package/components/views/Dashboard.tsx +148 -0
- package/components/views/Debug.tsx +445 -0
- package/components/views/Dependency.tsx +51 -0
- package/components/views/Entry.tsx +500 -0
- package/components/views/Gist.tsx +28 -0
- package/components/views/Inline.tsx +54 -0
- package/components/views/Json.tsx +19 -0
- package/components/views/Layout.tsx +211 -0
- package/components/views/List.tsx +238 -0
- package/components/views/Md.tsx +43 -0
- package/components/views/Media.tsx +48 -0
- package/components/views/Memory.tsx +32 -0
- package/components/views/Relate.tsx +205 -0
- package/components/views/Search.tsx +42 -0
- package/components/views/Session.tsx +850 -0
- package/components/views/SessionManage.tsx +127 -0
- package/components/views/Show.tsx +758 -0
- package/components/views/Shown.tsx +72 -0
- package/components/views/Split.tsx +58 -0
- package/components/views/TaskTile.tsx +37 -0
- package/components/views/Title.tsx +105 -0
- package/components/views/Wake.tsx +77 -0
- package/components/views/Web.tsx +49 -0
- package/components/wells.js +30 -0
- package/components/wells.js.map +1 -0
- package/components/wells.ts +33 -0
- package/configuration.js +38 -0
- package/configuration.js.map +1 -0
- package/configuration.ts +41 -0
- package/decision_sync.js +88 -0
- package/decision_sync.js.map +1 -0
- package/decision_sync.ts +93 -0
- package/deno.json +1 -0
- package/domain-host.tsx +108 -0
- package/edge.js +193 -0
- package/edge.js.map +1 -0
- package/edge.ts +196 -0
- package/entry_log.js +241 -0
- package/entry_log.js.map +1 -0
- package/entry_log.ts +214 -0
- package/failure.js +22 -0
- package/failure.js.map +1 -0
- package/failure.ts +34 -0
- package/front.json +61 -0
- package/highlight.js +143 -0
- package/highlight.js.map +1 -0
- package/highlight.ts +149 -0
- package/history.js +68 -0
- package/history.js.map +1 -0
- package/history.ts +72 -0
- package/host_commands.js +107 -0
- package/host_commands.js.map +1 -0
- package/host_commands.ts +38 -0
- package/hosting.js +53 -0
- package/hosting.js.map +1 -0
- package/hosting.ts +72 -0
- package/idb.js +14 -0
- package/idb.js.map +1 -0
- package/idb.ts +15 -0
- package/index.js +232 -0
- package/index.js.map +1 -0
- package/index.ts +252 -0
- package/keybindings.js +136 -0
- package/keybindings.js.map +1 -0
- package/keybindings.ts +37 -0
- package/kit.js +103 -0
- package/kit.js.map +1 -0
- package/kit.ts +119 -0
- package/layout.js +254 -0
- package/layout.js.map +1 -0
- package/layout.ts +210 -0
- package/legacy_outbox.js +53 -0
- package/legacy_outbox.js.map +1 -0
- package/legacy_outbox.ts +63 -0
- package/live.js +2883 -0
- package/live.js.map +1 -0
- package/live.ts +3334 -0
- package/live_archetypes.js +92 -0
- package/live_archetypes.js.map +1 -0
- package/live_archetypes.ts +113 -0
- package/live_client.js +145 -0
- package/live_client.js.map +1 -0
- package/live_client.ts +120 -0
- package/main.tsx +5 -0
- package/mod.js +7 -0
- package/mod.js.map +1 -0
- package/mod.ts +7 -0
- package/mount.tsx +50 -0
- package/navigation.js +120 -0
- package/navigation.js.map +1 -0
- package/navigation.ts +152 -0
- package/near.js +83 -0
- package/near.js.map +1 -0
- package/near.ts +83 -0
- package/new.js +295 -0
- package/new.js.map +1 -0
- package/new.ts +361 -0
- package/outbox.js +112 -0
- package/outbox.js.map +1 -0
- package/outbox.ts +129 -0
- package/owner.js +39 -0
- package/owner.js.map +1 -0
- package/owner.ts +37 -0
- package/package.json +81 -4
- package/paste.js +157 -0
- package/paste.js.map +1 -0
- package/paste.ts +122 -0
- package/props.js +303 -0
- package/props.js.map +1 -0
- package/props.ts +358 -0
- package/providers.js +136 -0
- package/providers.js.map +1 -0
- package/providers.ts +194 -0
- package/query.js +987 -0
- package/query.js.map +1 -0
- package/query.ts +1113 -0
- package/remote.js +37 -0
- package/remote.js.map +1 -0
- package/remote.ts +46 -0
- package/resolver.js +149 -0
- package/resolver.js.map +1 -0
- package/resolver.ts +213 -0
- package/rfc2047.js +37 -0
- package/rfc2047.js.map +1 -0
- package/rfc2047.ts +40 -0
- package/row_holds.js +107 -0
- package/row_holds.js.map +1 -0
- package/row_holds.ts +93 -0
- package/served.ts +42 -0
- package/session_worktree.js +7 -0
- package/session_worktree.js.map +1 -0
- package/session_worktree.ts +16 -0
- package/sessions.js +57 -0
- package/sessions.js.map +1 -0
- package/sessions.ts +53 -0
- package/sha.js +161 -0
- package/sha.js.map +1 -0
- package/sha.ts +164 -0
- package/styles.css +2823 -0
- package/subs.js +36 -0
- package/subs.js.map +1 -0
- package/subs.ts +40 -0
- package/terminal-route.js +13 -0
- package/terminal-route.js.map +1 -0
- package/terminal-route.ts +17 -0
- package/terminal.js +251 -0
- package/terminal.js.map +1 -0
- package/terminal.ts +186 -0
- package/time.js +142 -0
- package/time.js.map +1 -0
- package/time.ts +133 -0
- package/title.js +25 -0
- package/title.js.map +1 -0
- package/title.ts +50 -0
- package/tui/doc.ts +6 -0
- package/tui/testing.ts +19 -0
- package/twin.js +11 -0
- package/twin.js.map +1 -0
- package/twin.ts +13 -0
- package/types.js +456 -0
- package/types.js.map +1 -0
- package/types.ts +1370 -0
- package/url.js +77 -0
- package/url.js.map +1 -0
- package/url.ts +85 -0
- package/verb.js +82 -0
- package/verb.js.map +1 -0
- package/verb.ts +137 -0
- package/warmth.js +41 -0
- package/warmth.js.map +1 -0
- package/warmth.ts +54 -0
- package/wire.js +86 -0
- package/wire.js.map +1 -0
- package/wire.ts +63 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Renderer descriptors are content-addressed, not a global boot working set.
|
|
2
|
+
// Complete local table sets prove their identity by hash; a projection that
|
|
3
|
+
// cannot do so learns just its descriptor through the existing one-shot door.
|
|
4
|
+
import { Archetypes, descriptorOf, eidOf, namingOf } from "@yaks/archetype/sets";
|
|
5
|
+
import { config, oneShot, row } from "./live.js";
|
|
6
|
+
import { vocab } from "./types.js";
|
|
7
|
+
let sets = new Archetypes();
|
|
8
|
+
let named;
|
|
9
|
+
// The sets, named by the vocabulary the page holds now: a descriptor holds
|
|
10
|
+
// its components' identities, and a reloaded vocabulary may name them anew.
|
|
11
|
+
let current = ()=>{
|
|
12
|
+
let naming = namingOf(vocab);
|
|
13
|
+
if (naming != named) {
|
|
14
|
+
named = naming;
|
|
15
|
+
sets = new Archetypes(naming);
|
|
16
|
+
}
|
|
17
|
+
return sets;
|
|
18
|
+
};
|
|
19
|
+
let checked = new WeakSet();
|
|
20
|
+
let asked = new Set();
|
|
21
|
+
let queued = new Set();
|
|
22
|
+
let serial = 0;
|
|
23
|
+
let pending;
|
|
24
|
+
// A fresh test fixture has learned no descriptors. Production keeps immutable
|
|
25
|
+
// content across eviction and reconnect, so it never calls this reset.
|
|
26
|
+
export let resetArchetypesForTest = ()=>{
|
|
27
|
+
clearTimeout(pending);
|
|
28
|
+
pending = undefined;
|
|
29
|
+
sets = new Archetypes();
|
|
30
|
+
named = undefined;
|
|
31
|
+
checked = new WeakSet();
|
|
32
|
+
asked.clear();
|
|
33
|
+
queued.clear();
|
|
34
|
+
};
|
|
35
|
+
let request = (eid)=>{
|
|
36
|
+
if (asked.has(eid)) return;
|
|
37
|
+
asked.add(eid);
|
|
38
|
+
if (!queued.size) {
|
|
39
|
+
pending = setTimeout(()=>{
|
|
40
|
+
pending = undefined;
|
|
41
|
+
let ids = [
|
|
42
|
+
...queued
|
|
43
|
+
];
|
|
44
|
+
queued.clear();
|
|
45
|
+
oneShot(`archetypes:${++serial}`, `id=${ids.join(',')}&.fields=archetype.tables`, ()=>{
|
|
46
|
+
// A view may have unmounted while the read was in flight. Keep valid
|
|
47
|
+
// content even then; do not strand its asked marker after eviction.
|
|
48
|
+
for (let id of ids){
|
|
49
|
+
let value = row(id).peek()?.archetype?.tables;
|
|
50
|
+
if (value === undefined) continue;
|
|
51
|
+
try {
|
|
52
|
+
descriptor(id, value);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(error);
|
|
55
|
+
asked.delete(id);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, ()=>{
|
|
59
|
+
for (let id of ids)asked.delete(id);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
queued.add(eid);
|
|
64
|
+
};
|
|
65
|
+
// Use the raw cache row, never Ent's derived fields or component bodies. A
|
|
66
|
+
// partial/stale union is safe ONLY if its names hash to the authoritative spine.
|
|
67
|
+
export let rememberArchetype = (value)=>{
|
|
68
|
+
let id = value?.entity?.archetype;
|
|
69
|
+
let sets = current();
|
|
70
|
+
if (!value || !id || sets.get(id) || checked.has(value)) return;
|
|
71
|
+
checked.add(value);
|
|
72
|
+
let names = Object.keys(value).filter((n)=>n != 'entity' && value[n] != null);
|
|
73
|
+
// A store whose descriptors predate identities points at its labels' set.
|
|
74
|
+
if (eidOf(names.map(named.id)) == id) sets.intern(names);
|
|
75
|
+
else if (eidOf(names) == id) sets.decode(names);
|
|
76
|
+
};
|
|
77
|
+
let descriptor = (eid, value)=>{
|
|
78
|
+
if (eidOf(descriptorOf(value)) != eid) {
|
|
79
|
+
throw new Error(`Invalid archetype descriptor: ${eid}`);
|
|
80
|
+
}
|
|
81
|
+
return current().decode(value).tables;
|
|
82
|
+
};
|
|
83
|
+
export let archetypeTables = (eid)=>{
|
|
84
|
+
let known = current().get(eid);
|
|
85
|
+
if (known) return known.tables;
|
|
86
|
+
// This narrow signal wakes a projected renderer when its descriptor arrives.
|
|
87
|
+
// Once learned, immutable content survives eviction, retirement and reconnect.
|
|
88
|
+
let value = row(eid).value?.archetype?.tables;
|
|
89
|
+
if (value !== undefined) return descriptor(eid, value);
|
|
90
|
+
if (config.host) request(eid);
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=live_archetypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live_archetypes.js","sources":["./live_archetypes.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,SACE,UAAU,EACV,YAAY,EACZ,KAAK,EAEL,QAAQ,oCAC8B;AACxC,SAAS,MAAM,EAAE,OAAO,EAAE,GAAG,oBAAmB;AAChD,SAAS,KAAK,qBAAoB;AAElC,IAAI,OAAO,IAAI;AACf,IAAI;AAEJ,2EAA2E;AAC3E,4EAA4E;AAC5E,IAAI,UAAU;EACZ,IAAI,SAAS,SAAS;EACtB,IAAI,UAAU,OAAO;IACnB,QAAQ;IACR,OAAO,IAAI,WAAW;EACxB;EACA,OAAO;AACT;AACA,IAAI,UAAU,IAAI;AAClB,IAAI,QAAQ,IAAI;AAChB,IAAI,SAAS,IAAI;AACjB,IAAI,SAAS;AACb,IAAI;AAEJ,8EAA8E;AAC9E,uEAAuE;AACvE,OAAO,IAAI,yBAAyB;EAClC,aAAa;EACb,UAAU;EACV,OAAO,IAAI;EACX,QAAQ;EACR,UA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AM,aAAa,WAAW,KAAK;IACrC,MAAM,IAAI,MAAM,CAAC,8BAA8B,EAAE,KAAK;EACxD;EACA,OAAO,UAAU,MAAM,CAAC,OAAO,MAAM;AACvC;AAEA,OAAO,IAAI,kBAAkB,CAAC;EAC5B,IAAI,QAAQ,UAAU,GAAG,CAAC;EAC1B,IAAI,OAAO,OAAO,MAAM,MAAM;EAC9B,6EAA6E;EAC7E,+EAA+E;EAC/E,IAAI,QAAQ,IAAI,KAAK,KAAK,EAAE,WAAW;EACvC,IAAI,UAAU,WAAW,OAAO,WAAW,KAAK;EAChD,IAAI,OAAO,IAAI,EAAE,QAAQ;AAC3B,EAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Renderer descriptors are content-addressed, not a global boot working set.
|
|
2
|
+
// Complete local table sets prove their identity by hash; a projection that
|
|
3
|
+
// cannot do so learns just its descriptor through the existing one-shot door.
|
|
4
|
+
import {
|
|
5
|
+
Archetypes,
|
|
6
|
+
descriptorOf,
|
|
7
|
+
eidOf,
|
|
8
|
+
type Naming,
|
|
9
|
+
namingOf,
|
|
10
|
+
} from '@yaks/archetype/sets'
|
|
11
|
+
import { config, oneShot, row } from './live.js'
|
|
12
|
+
import { vocab } from './types.js'
|
|
13
|
+
|
|
14
|
+
let sets = new Archetypes()
|
|
15
|
+
let named: Naming | undefined
|
|
16
|
+
|
|
17
|
+
// The sets, named by the vocabulary the page holds now: a descriptor holds
|
|
18
|
+
// its components' identities, and a reloaded vocabulary may name them anew.
|
|
19
|
+
let current = () => {
|
|
20
|
+
let naming = namingOf(vocab)
|
|
21
|
+
if (naming != named) {
|
|
22
|
+
named = naming
|
|
23
|
+
sets = new Archetypes(naming)
|
|
24
|
+
}
|
|
25
|
+
return sets
|
|
26
|
+
}
|
|
27
|
+
let checked = new WeakSet<object>()
|
|
28
|
+
let asked = new Set<string>()
|
|
29
|
+
let queued = new Set<string>()
|
|
30
|
+
let serial = 0
|
|
31
|
+
let pending: ReturnType<typeof setTimeout> | undefined
|
|
32
|
+
|
|
33
|
+
// A fresh test fixture has learned no descriptors. Production keeps immutable
|
|
34
|
+
// content across eviction and reconnect, so it never calls this reset.
|
|
35
|
+
export let resetArchetypesForTest = () => {
|
|
36
|
+
clearTimeout(pending)
|
|
37
|
+
pending = undefined
|
|
38
|
+
sets = new Archetypes()
|
|
39
|
+
named = undefined
|
|
40
|
+
checked = new WeakSet()
|
|
41
|
+
asked.clear()
|
|
42
|
+
queued.clear()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let request = (eid: string) => {
|
|
46
|
+
if (asked.has(eid)) return
|
|
47
|
+
asked.add(eid)
|
|
48
|
+
if (!queued.size) {
|
|
49
|
+
pending = setTimeout(() => {
|
|
50
|
+
pending = undefined
|
|
51
|
+
let ids = [...queued]
|
|
52
|
+
queued.clear()
|
|
53
|
+
oneShot(
|
|
54
|
+
`archetypes:${++serial}`,
|
|
55
|
+
`id=${ids.join(',')}&.fields=archetype.tables`,
|
|
56
|
+
() => {
|
|
57
|
+
// A view may have unmounted while the read was in flight. Keep valid
|
|
58
|
+
// content even then; do not strand its asked marker after eviction.
|
|
59
|
+
for (let id of ids) {
|
|
60
|
+
let value = row(id).peek()?.archetype?.tables
|
|
61
|
+
if (value === undefined) continue
|
|
62
|
+
try {
|
|
63
|
+
descriptor(id, value)
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(error)
|
|
66
|
+
asked.delete(id)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
() => {
|
|
71
|
+
for (let id of ids) asked.delete(id)
|
|
72
|
+
},
|
|
73
|
+
)
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
queued.add(eid)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Use the raw cache row, never Ent's derived fields or component bodies. A
|
|
80
|
+
// partial/stale union is safe ONLY if its names hash to the authoritative spine.
|
|
81
|
+
export let rememberArchetype = (
|
|
82
|
+
value:
|
|
83
|
+
| { entity?: { archetype?: string }; [name: string]: unknown }
|
|
84
|
+
| undefined,
|
|
85
|
+
): void => {
|
|
86
|
+
let id = value?.entity?.archetype
|
|
87
|
+
let sets = current()
|
|
88
|
+
if (!value || !id || sets.get(id) || checked.has(value)) return
|
|
89
|
+
checked.add(value)
|
|
90
|
+
let names = Object.keys(value).filter((n) =>
|
|
91
|
+
n != 'entity' && value[n] != null
|
|
92
|
+
)
|
|
93
|
+
// A store whose descriptors predate identities points at its labels' set.
|
|
94
|
+
if (eidOf(names.map(named!.id)) == id) sets.intern(names)
|
|
95
|
+
else if (eidOf(names) == id) sets.decode(names)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let descriptor = (eid: string, value: unknown): readonly string[] => {
|
|
99
|
+
if (eidOf(descriptorOf(value)) != eid) {
|
|
100
|
+
throw new Error(`Invalid archetype descriptor: ${eid}`)
|
|
101
|
+
}
|
|
102
|
+
return current().decode(value).tables
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export let archetypeTables = (eid: string): readonly string[] | undefined => {
|
|
106
|
+
let known = current().get(eid)
|
|
107
|
+
if (known) return known.tables
|
|
108
|
+
// This narrow signal wakes a projected renderer when its descriptor arrives.
|
|
109
|
+
// Once learned, immutable content survives eviction, retirement and reconnect.
|
|
110
|
+
let value = row(eid).value?.archetype?.tables
|
|
111
|
+
if (value !== undefined) return descriptor(eid, value)
|
|
112
|
+
if (config.host) request(eid)
|
|
113
|
+
}
|
package/live_client.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { batch } from "@preact/signals-core";
|
|
2
|
+
// Browse's learned projection and patch adapter over generic named watches.
|
|
3
|
+
import { entire, namedClient, quiet } from "@yaks/client/named";
|
|
4
|
+
import { dead } from "@yaks/graph/bundle";
|
|
5
|
+
import { loadVocab } from "@yaks/vocab";
|
|
6
|
+
import { keywords, vocab } from "./types.js";
|
|
7
|
+
import { storageKey } from "./hosting.js";
|
|
8
|
+
export { entire, quiet };
|
|
9
|
+
// Server-derived columns are ordinary received data in a browser replica.
|
|
10
|
+
// Their derivation/writability remains the server's responsibility, and so do
|
|
11
|
+
// their values: a computed enum names what can be written, and a derivation may
|
|
12
|
+
// read wider (a claimed task's status is `wip`, contributed by the claim). A
|
|
13
|
+
// status ladder (@yaks/vocab's `status` keyword) is the server's derivation
|
|
14
|
+
// too, so its component keeps the status as a plain column, and the rungs
|
|
15
|
+
// another document adds go with it.
|
|
16
|
+
let projections = new WeakMap();
|
|
17
|
+
let browserVocab = ()=>{
|
|
18
|
+
let kept = projections.get(vocab);
|
|
19
|
+
if (kept) return kept;
|
|
20
|
+
let docs = vocab.docs.map((doc)=>({
|
|
21
|
+
...doc,
|
|
22
|
+
$defs: Object.fromEntries(Object.entries(doc.$defs ?? {}).map(([name, def])=>{
|
|
23
|
+
if (!def.component || name == 'entity') return [
|
|
24
|
+
name,
|
|
25
|
+
def
|
|
26
|
+
];
|
|
27
|
+
let { status, ...copy } = def;
|
|
28
|
+
if (def.extends) return [
|
|
29
|
+
name,
|
|
30
|
+
copy
|
|
31
|
+
];
|
|
32
|
+
return [
|
|
33
|
+
name,
|
|
34
|
+
{
|
|
35
|
+
...copy,
|
|
36
|
+
computed: false,
|
|
37
|
+
properties: {
|
|
38
|
+
...Object.fromEntries(Object.entries(def.properties ?? {}).map(([name, prop])=>{
|
|
39
|
+
let copy = {
|
|
40
|
+
...prop,
|
|
41
|
+
computed: false
|
|
42
|
+
};
|
|
43
|
+
if (prop.computed) delete copy.enum;
|
|
44
|
+
return [
|
|
45
|
+
name,
|
|
46
|
+
copy
|
|
47
|
+
];
|
|
48
|
+
})),
|
|
49
|
+
eid: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
computed: false
|
|
52
|
+
},
|
|
53
|
+
...status ? {
|
|
54
|
+
status: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
computed: false
|
|
57
|
+
}
|
|
58
|
+
} : {}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
}))
|
|
63
|
+
}));
|
|
64
|
+
let projected = loadVocab(docs, keywords);
|
|
65
|
+
projections.set(vocab, projected);
|
|
66
|
+
return projected;
|
|
67
|
+
};
|
|
68
|
+
export let liveClient = (opts)=>{
|
|
69
|
+
let core = namedClient({
|
|
70
|
+
...opts,
|
|
71
|
+
vocab: browserVocab(),
|
|
72
|
+
batch,
|
|
73
|
+
wireVault: opts.disk ? {
|
|
74
|
+
name: storageKey('tasks-client-wire')
|
|
75
|
+
} : undefined
|
|
76
|
+
});
|
|
77
|
+
// Changes as whole rows: a reset rebuilds each row from what it carries.
|
|
78
|
+
let bundles = (changes, reset = false)=>{
|
|
79
|
+
let rows = new Map();
|
|
80
|
+
for (let { eid, name, comp } of changes){
|
|
81
|
+
let row = rows.get(eid);
|
|
82
|
+
if (!row) {
|
|
83
|
+
row = reset ? {
|
|
84
|
+
entity: {
|
|
85
|
+
eid
|
|
86
|
+
}
|
|
87
|
+
} : {
|
|
88
|
+
...core.box.ent(eid),
|
|
89
|
+
entity: core.box.ent(eid)?.entity ?? {
|
|
90
|
+
eid
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
rows.set(eid, row);
|
|
94
|
+
}
|
|
95
|
+
if (name === 'entity') {
|
|
96
|
+
if (comp === null) {
|
|
97
|
+
row = {
|
|
98
|
+
entity: row.entity,
|
|
99
|
+
tombstone: {}
|
|
100
|
+
};
|
|
101
|
+
rows.set(eid, row);
|
|
102
|
+
} else row.entity = {
|
|
103
|
+
...row.entity,
|
|
104
|
+
...comp
|
|
105
|
+
};
|
|
106
|
+
} else if (comp === null) row[name] = null;
|
|
107
|
+
else row[name] = {
|
|
108
|
+
...reset ? {} : row[name],
|
|
109
|
+
...comp
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return [
|
|
113
|
+
...rows.values()
|
|
114
|
+
];
|
|
115
|
+
};
|
|
116
|
+
let receive = (f)=>{
|
|
117
|
+
let rows = bundles(f.changes ?? [], !!f.replace);
|
|
118
|
+
let frame = f.error ? {
|
|
119
|
+
refused: {
|
|
120
|
+
error: 'read',
|
|
121
|
+
message: f.error
|
|
122
|
+
}
|
|
123
|
+
} : f.agg ? {
|
|
124
|
+
tally: f.agg
|
|
125
|
+
} : {
|
|
126
|
+
reset: f.replace,
|
|
127
|
+
bundles: rows.filter((b)=>!dead(b)),
|
|
128
|
+
gone: [
|
|
129
|
+
...f.drop ?? [],
|
|
130
|
+
...rows.filter(dead).map((b)=>b.entity.eid)
|
|
131
|
+
],
|
|
132
|
+
coverage: Object.fromEntries(rows.filter((b)=>!dead(b)).map((b)=>[
|
|
133
|
+
b.entity.eid,
|
|
134
|
+
true
|
|
135
|
+
]))
|
|
136
|
+
};
|
|
137
|
+
core.receive(f.sub, frame);
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
...core,
|
|
141
|
+
receive,
|
|
142
|
+
patch: (changes)=>core.patch(bundles(changes))
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=live_client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live_client.js","sources":["./live_client.ts"],"names":[],"mappings":"AAAA,SAAS,KAAK,+BAAyC;AACvD,4EAA4E;AAC5E,SAAS,MAAM,EAAE,WAAW,EAAE,KAAK,kCAAkD;AAGrF,SAAS,IAAI,kCAAuC;AAEpD,SAAS,SAAS,2BAAgC;AAClD,SAAsB,QAAQ,EAAE,KAAK,qBAAoB;AAEzD,SAAS,UAAU,uBAAsB;AACzC,SAAS,MAAM,EAAE,KAAK,GAAE;AACxB,0EAA0E;AAC1E,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,oCAAoC;AACpC,IAAI,cAAc,IAAI;AACtB,IAAI,eAAe;EACjB,IAAI,OAAO,YAAY,GAAG,CAAC;EAC3B,IAAI,MAAM,OAAO;EACjB,IAAI,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,C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AG,CAAC,CAC/B,IACG;UAAC,EAAE,MAAM,CAAC,GAAG;UAAE;SAAiB;IAEzC;IACF,KAAK,OAAO,CAAC,EAAE,GAAG,EAAE;EACtB;EACA,OAAO;IACL,GAAG,IAAI;IACP;IACA,OAAO,CAAC,UAAsB,KAAK,KAAK,CAAC,QAAQ;EACnD;AACF,EAAC"}
|
package/live_client.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { batch } from '@preact/signals-core'
|
|
2
|
+
// Browse's learned projection and patch adapter over generic named watches.
|
|
3
|
+
import { entire, namedClient, quiet, type Told } from '@yaks/client/named'
|
|
4
|
+
import type { ClientOpts } from 'jsr:@yaks/client@0.2.36'
|
|
5
|
+
import type { Bundle, Comp } from 'jsr:@yaks/graph@0.2.36'
|
|
6
|
+
import { dead } from '@yaks/graph/bundle'
|
|
7
|
+
import type { Coverage, Frame, Socket } from 'jsr:@yaks/sync@0.2.36'
|
|
8
|
+
import { loadVocab } from '@yaks/vocab'
|
|
9
|
+
import { type Change, keywords, vocab } from './types.js'
|
|
10
|
+
import type { Sub } from './live.ts'
|
|
11
|
+
import { storageKey } from './hosting.js'
|
|
12
|
+
export { entire, quiet }
|
|
13
|
+
// Server-derived columns are ordinary received data in a browser replica.
|
|
14
|
+
// Their derivation/writability remains the server's responsibility, and so do
|
|
15
|
+
// their values: a computed enum names what can be written, and a derivation may
|
|
16
|
+
// read wider (a claimed task's status is `wip`, contributed by the claim). A
|
|
17
|
+
// status ladder (@yaks/vocab's `status` keyword) is the server's derivation
|
|
18
|
+
// too, so its component keeps the status as a plain column, and the rungs
|
|
19
|
+
// another document adds go with it.
|
|
20
|
+
let projections = new WeakMap<typeof vocab, typeof vocab>()
|
|
21
|
+
let browserVocab = () => {
|
|
22
|
+
let kept = projections.get(vocab)
|
|
23
|
+
if (kept) return kept
|
|
24
|
+
let docs = vocab.docs.map((doc) => ({
|
|
25
|
+
...doc,
|
|
26
|
+
$defs: Object.fromEntries(
|
|
27
|
+
Object.entries(doc.$defs ?? {}).map(([name, def]) => {
|
|
28
|
+
if (!def.component || name == 'entity') return [name, def]
|
|
29
|
+
let { status, ...copy } = def
|
|
30
|
+
if (def.extends) return [name, copy]
|
|
31
|
+
return [name, {
|
|
32
|
+
...copy,
|
|
33
|
+
computed: false,
|
|
34
|
+
properties: {
|
|
35
|
+
...Object.fromEntries(
|
|
36
|
+
Object.entries(def.properties ?? {}).map(([name, prop]) => {
|
|
37
|
+
let copy = { ...prop, computed: false }
|
|
38
|
+
if (prop.computed) delete copy.enum
|
|
39
|
+
return [name, copy]
|
|
40
|
+
}),
|
|
41
|
+
),
|
|
42
|
+
eid: { type: 'string', computed: false },
|
|
43
|
+
...status ? { status: { type: 'string', computed: false } } : {},
|
|
44
|
+
},
|
|
45
|
+
}]
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
48
|
+
}))
|
|
49
|
+
let projected = loadVocab(docs, keywords)
|
|
50
|
+
projections.set(vocab, projected)
|
|
51
|
+
return projected
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type LiveClient = ReturnType<typeof liveClient>
|
|
55
|
+
export let liveClient = (opts: {
|
|
56
|
+
url: string
|
|
57
|
+
fetch?: ClientOpts['fetch']
|
|
58
|
+
timer?: ClientOpts['timer']
|
|
59
|
+
report?: Told
|
|
60
|
+
connect: (url: string) => Socket
|
|
61
|
+
changed: (eids: string[]) => void
|
|
62
|
+
ready: (sub: string) => void
|
|
63
|
+
frame: (subs: string[], f: Frame, reset: boolean) => void
|
|
64
|
+
outbox?: ClientOpts['outbox']
|
|
65
|
+
disk?: boolean
|
|
66
|
+
}) => {
|
|
67
|
+
let core = namedClient({
|
|
68
|
+
...opts,
|
|
69
|
+
vocab: browserVocab(),
|
|
70
|
+
batch,
|
|
71
|
+
wireVault: opts.disk
|
|
72
|
+
? { name: storageKey('tasks-client-wire') }
|
|
73
|
+
: undefined,
|
|
74
|
+
})
|
|
75
|
+
// Changes as whole rows: a reset rebuilds each row from what it carries.
|
|
76
|
+
let bundles = (changes: Change[], reset = false): Bundle[] => {
|
|
77
|
+
let rows = new Map<string, Bundle>()
|
|
78
|
+
for (let { eid, name, comp } of changes) {
|
|
79
|
+
let row = rows.get(eid)
|
|
80
|
+
if (!row) {
|
|
81
|
+
row = reset ? { entity: { eid } } : {
|
|
82
|
+
...core.box.ent(eid),
|
|
83
|
+
entity: core.box.ent(eid)?.entity ?? { eid },
|
|
84
|
+
}
|
|
85
|
+
rows.set(eid, row)
|
|
86
|
+
}
|
|
87
|
+
if (name === 'entity') {
|
|
88
|
+
if (comp === null) {
|
|
89
|
+
row = { entity: row.entity, tombstone: {} }
|
|
90
|
+
rows.set(eid, row)
|
|
91
|
+
} else row.entity = { ...row.entity, ...comp }
|
|
92
|
+
} else if (comp === null) row[name] = null
|
|
93
|
+
else row[name] = { ...reset ? {} : row[name] as Comp, ...comp }
|
|
94
|
+
}
|
|
95
|
+
return [...rows.values()]
|
|
96
|
+
}
|
|
97
|
+
let receive = (f: Sub) => {
|
|
98
|
+
let rows = bundles(f.changes ?? [], !!f.replace)
|
|
99
|
+
let frame: Omit<Frame, 'id'> = f.error
|
|
100
|
+
? { refused: { error: 'read', message: f.error } }
|
|
101
|
+
: f.agg
|
|
102
|
+
? { tally: f.agg }
|
|
103
|
+
: {
|
|
104
|
+
reset: f.replace,
|
|
105
|
+
bundles: rows.filter((b) => !dead(b)),
|
|
106
|
+
gone: [...f.drop ?? [], ...rows.filter(dead).map((b) => b.entity.eid)],
|
|
107
|
+
coverage: Object.fromEntries(
|
|
108
|
+
rows.filter((b) => !dead(b)).map((
|
|
109
|
+
b,
|
|
110
|
+
) => [b.entity.eid, true as Coverage]),
|
|
111
|
+
),
|
|
112
|
+
}
|
|
113
|
+
core.receive(f.sub, frame)
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
...core,
|
|
117
|
+
receive,
|
|
118
|
+
patch: (changes: Change[]) => core.patch(bundles(changes)),
|
|
119
|
+
}
|
|
120
|
+
}
|
package/main.tsx
ADDED
package/mod.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The graph browsing app: domain views, editing and navigation, painted through
|
|
3
|
+
* @yaks/ui. @yaks/web serves its browser entry; @yaks/tui paints its terminal.
|
|
4
|
+
* @module
|
|
5
|
+
*/ export { learn, vocab } from "./types.js";
|
|
6
|
+
export { addressId } from "./url.js";
|
|
7
|
+
//# sourceMappingURL=mod.js.map
|
package/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA;;;;CAIC,GACD,SAAS,KAAK,EAAE,KAAK,qBAAoB;AACzC,SAAS,SAAS,mBAAkB"}
|
package/mod.ts
ADDED
package/mount.tsx
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
import './domain-host.tsx'
|
|
3
|
+
import './browser-links.ts'
|
|
4
|
+
// Mount the browsing app with the configured plugins’ shared views and home
|
|
5
|
+
// query. The door chooses the facets; domains own their queries and readings.
|
|
6
|
+
import { render } from 'jsr:@yaks/react@0.2.36/draw'
|
|
7
|
+
import { agreementProbe, boot, clientId, config } from './live.ts'
|
|
8
|
+
import { restore } from './components/nav.tsx'
|
|
9
|
+
import { App } from './components/App.tsx'
|
|
10
|
+
import { ux } from './components/registry.ts'
|
|
11
|
+
import { contribute, type Facet } from './components/inspect.tsx'
|
|
12
|
+
import { box, type Hosting } from './hosting.ts'
|
|
13
|
+
import { lone } from 'jsr:@yaks/draft@0.2.36/input'
|
|
14
|
+
import { Ux } from 'jsr:@yaks/ux@0.2.36'
|
|
15
|
+
import { selecting } from 'jsr:@yaks/ux@0.2.36/select'
|
|
16
|
+
|
|
17
|
+
export let mount = async (
|
|
18
|
+
facets: Facet[] = [],
|
|
19
|
+
home?: Hosting['home'],
|
|
20
|
+
) => {
|
|
21
|
+
if (home) {
|
|
22
|
+
let g = globalThis as { YAK_WEB?: Hosting }
|
|
23
|
+
g.YAK_WEB = { ...(g.YAK_WEB ?? box), home }
|
|
24
|
+
}
|
|
25
|
+
await contribute(facets)
|
|
26
|
+
|
|
27
|
+
// Name this tab to the socket before it opens, so its writes journal a
|
|
28
|
+
// resolved actor (T-6669). Fill the cache, open the socket, render.
|
|
29
|
+
config.client = clientId()
|
|
30
|
+
config.agreement = agreementProbe(location.search)
|
|
31
|
+
await boot()
|
|
32
|
+
// Until this browser is bound to someone, it types as the graph's lone
|
|
33
|
+
// person (components/drafts.ts).
|
|
34
|
+
void lone()
|
|
35
|
+
|
|
36
|
+
restore()
|
|
37
|
+
|
|
38
|
+
// The cursor is update-only: nav.tsx publishes where this client
|
|
39
|
+
// looks, but nothing reads it back to move the tab. Rendering answers to the
|
|
40
|
+
// URL and to gestures, never to graph state, so there is no follow to arm here.
|
|
41
|
+
|
|
42
|
+
// A Select opens the kit's list of its choices.
|
|
43
|
+
selecting(document)
|
|
44
|
+
render(
|
|
45
|
+
<Ux host={ux}>
|
|
46
|
+
<App />
|
|
47
|
+
</Ux>,
|
|
48
|
+
document.body,
|
|
49
|
+
)
|
|
50
|
+
}
|
package/navigation.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// The places the sidebar offers, as data: home, the destinations, and the
|
|
2
|
+
// schema. A destination is a page at `/?page=<key>`: a list of what a query
|
|
3
|
+
// finds, a package's page part above it, or that part alone.
|
|
4
|
+
// Browse offers the ones that read its own words (favorites, recent edits,
|
|
5
|
+
// sessions); a package offers its own from its `./views` facet as
|
|
6
|
+
// `destinations`, so a tracker lists its bugs without Browse knowing a bug.
|
|
7
|
+
// A favorite is a facet, so marking a task never changes its kind, id, or
|
|
8
|
+
// renderer.
|
|
9
|
+
import { queryAt, querySearch } from "@yaks/query";
|
|
10
|
+
export let favoriteChange = (e)=>({
|
|
11
|
+
eid: e.eid,
|
|
12
|
+
name: 'favorite',
|
|
13
|
+
comp: e.favorite ? null : {}
|
|
14
|
+
});
|
|
15
|
+
export let favoriteLabel = (e)=>e.favorite ? 'remove from favorites' : 'add to favorites';
|
|
16
|
+
/** The destinations, in the sidebar's order: Browse's own personal ones
|
|
17
|
+
* (favorites, then what this person opened lately), each package's in config
|
|
18
|
+
* order, then the sessions; a key once, the first offer kept. */ export let destinations = (vocab, _actor, sessions, contributed)=>{
|
|
19
|
+
let seen = new Set();
|
|
20
|
+
return [
|
|
21
|
+
...vocab.comp('favorite') ? [
|
|
22
|
+
{
|
|
23
|
+
key: 'favorites',
|
|
24
|
+
name: 'Favorites',
|
|
25
|
+
icon: 'star',
|
|
26
|
+
query: '.favorite *'
|
|
27
|
+
}
|
|
28
|
+
] : [],
|
|
29
|
+
...vocab.comp('updated') ? [
|
|
30
|
+
{
|
|
31
|
+
key: 'recent',
|
|
32
|
+
name: 'Recent',
|
|
33
|
+
icon: 'clock',
|
|
34
|
+
query: '.updated * .order=-updated.at .limit=50'
|
|
35
|
+
}
|
|
36
|
+
] : [],
|
|
37
|
+
...contributed,
|
|
38
|
+
...sessions ? [
|
|
39
|
+
{
|
|
40
|
+
key: 'sessions',
|
|
41
|
+
name: 'Sessions',
|
|
42
|
+
icon: 'bot',
|
|
43
|
+
query: sessions,
|
|
44
|
+
view: 'Sessions.Controls'
|
|
45
|
+
}
|
|
46
|
+
] : []
|
|
47
|
+
].filter((d)=>!seen.has(d.key) && !!seen.add(d.key));
|
|
48
|
+
};
|
|
49
|
+
/** The destination an address is: `/?page=<key>` and nothing else. */ export let destinationAt = (at, all)=>{
|
|
50
|
+
let page = pageAt(at);
|
|
51
|
+
return page ? all.find((d)=>d.key == page.get('page')) : undefined;
|
|
52
|
+
};
|
|
53
|
+
// Page selectors are plain parameters; query clauses carry a sigil.
|
|
54
|
+
// Entity-page view parameters remain on their path.
|
|
55
|
+
let pageAt = (at)=>{
|
|
56
|
+
let url = new URL(at, 'http://x');
|
|
57
|
+
let { query, state } = queryAt(url.search);
|
|
58
|
+
return url.pathname == '/' && query == null ? state : undefined;
|
|
59
|
+
};
|
|
60
|
+
export let destinationPath = (key)=>`/${querySearch('', {
|
|
61
|
+
page: key
|
|
62
|
+
})}`;
|
|
63
|
+
/** The schema: the inspector's map of how the data is made. */ export let schemaPath = destinationPath('map');
|
|
64
|
+
export let configPath = destinationPath('config');
|
|
65
|
+
export let configAt = (at)=>pageAt(at)?.get('page') == 'config';
|
|
66
|
+
export let schemaAt = (at)=>pageAt(at)?.get('page') == 'map';
|
|
67
|
+
/** New entities, made in an entity or like one, each named by human id or eid. */ /// newAt('/?page=new') -> {}
|
|
68
|
+
/// newAt('/?page=new&in=T-1&like=T-2') -> {in: 'T-1', like: 'T-2'}
|
|
69
|
+
/// newAt('/?page=map') -> undefined
|
|
70
|
+
export let newAt = (at)=>{
|
|
71
|
+
let state = pageAt(at);
|
|
72
|
+
if (state?.get('page') != 'new') return undefined;
|
|
73
|
+
return Object.fromEntries([
|
|
74
|
+
'in',
|
|
75
|
+
'like'
|
|
76
|
+
].flatMap((k)=>state.get(k) ? [
|
|
77
|
+
[
|
|
78
|
+
k,
|
|
79
|
+
state.get(k)
|
|
80
|
+
]
|
|
81
|
+
] : []));
|
|
82
|
+
};
|
|
83
|
+
/// newPath({in: 'T-1', like: undefined}) -> '/?page=new&in=T-1'
|
|
84
|
+
export let newPath = (at = {})=>`/${querySearch('', {
|
|
85
|
+
page: 'new',
|
|
86
|
+
...Object.fromEntries(Object.entries(at).filter(([, v])=>v))
|
|
87
|
+
})}`;
|
|
88
|
+
/** Every line in the sidebar: home, new, the destinations, the schema. */ export let places = (home, all, schema, configuration = false)=>[
|
|
89
|
+
home,
|
|
90
|
+
{
|
|
91
|
+
name: 'New',
|
|
92
|
+
icon: 'plus',
|
|
93
|
+
path: newPath()
|
|
94
|
+
},
|
|
95
|
+
...all.map((d)=>({
|
|
96
|
+
name: d.name,
|
|
97
|
+
icon: d.icon,
|
|
98
|
+
path: destinationPath(d.key)
|
|
99
|
+
})),
|
|
100
|
+
...schema ? [
|
|
101
|
+
{
|
|
102
|
+
name: 'Schema',
|
|
103
|
+
icon: 'database',
|
|
104
|
+
path: schemaPath
|
|
105
|
+
}
|
|
106
|
+
] : [],
|
|
107
|
+
...configuration ? [
|
|
108
|
+
{
|
|
109
|
+
name: 'Configuration',
|
|
110
|
+
icon: 'settings',
|
|
111
|
+
path: configPath
|
|
112
|
+
}
|
|
113
|
+
] : []
|
|
114
|
+
];
|
|
115
|
+
/** The sidebar line an address lights: its own, or none for a search. */ export let placeAt = (at, all)=>{
|
|
116
|
+
let url = new URL(at, 'http://x');
|
|
117
|
+
let path = url.pathname + (url.search == '?' ? '' : url.search);
|
|
118
|
+
return all.find((p)=>p.path == path);
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=navigation.js.map
|