@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,50 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
// The Tile composition contract. A caller may adorn any tile before or
|
|
3
|
+
// after its own face, and hear its ordinary activation, without knowing which
|
|
4
|
+
// entity-specific renderer the registry chose.
|
|
5
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import type { ReactNode } from 'npm:react@19.3.0'
|
|
6
|
+
import { type Ent } from '../types.ts'
|
|
7
|
+
import { clickProps } from './nav.tsx'
|
|
8
|
+
import { title } from './title.tsx'
|
|
9
|
+
import { block, el } from 'jsr:@yaks/ui@0.2.36'
|
|
10
|
+
|
|
11
|
+
export type TileSlots = {
|
|
12
|
+
before?: ReactNode
|
|
13
|
+
title?: ReactNode
|
|
14
|
+
body?: ReactNode
|
|
15
|
+
after?: ReactNode
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type TileProps = {
|
|
19
|
+
e: Ent
|
|
20
|
+
slots?: TileSlots
|
|
21
|
+
onOpen?: () => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// A task's or a board's line, in Browse's own look: `Row`, not the kit's
|
|
25
|
+
// `Tile`, so neither restyles the other.
|
|
26
|
+
export let TileFrame = block('div', 'Row', { Head: 'span', Title: 'span' })
|
|
27
|
+
|
|
28
|
+
let Part = el('span', 'TileSlot')
|
|
29
|
+
export let TileSlot = (
|
|
30
|
+
{ name, children }: { name: keyof TileSlots; children: ReactNode },
|
|
31
|
+
) => <Part mod={name}>{children}</Part>
|
|
32
|
+
|
|
33
|
+
export let slot = (slots: TileSlots | undefined, name: keyof TileSlots) =>
|
|
34
|
+
slots?.[name] != null && <TileSlot name={name}>{slots[name]}</TileSlot>
|
|
35
|
+
|
|
36
|
+
// A face keeps ownership of its title element (and therefore its density and
|
|
37
|
+
// wrapping); a surround may replace only the words inside it.
|
|
38
|
+
export let tileTitle = (slots: TileSlots | undefined, text: string) =>
|
|
39
|
+
slots?.title != null ? { children: slots.title } : title(text)
|
|
40
|
+
|
|
41
|
+
export let tileLink = (e: Ent, onOpen?: () => void) => {
|
|
42
|
+
let link = clickProps(e)
|
|
43
|
+
return {
|
|
44
|
+
...link,
|
|
45
|
+
onClick: (ev: MouseEvent) => {
|
|
46
|
+
onOpen?.()
|
|
47
|
+
link.onClick(ev)
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// A browse read as @yaks/ux's `Answered`, for `Answer` to draw: its rows,
|
|
2
|
+
// ready as the read says, and refused with the server's reason and the query
|
|
3
|
+
// it refused. `retryOf` asks a refused subscription again on the same
|
|
4
|
+
// identity, so its answer replaces the refusal.
|
|
5
|
+
import { retrySubscription } from "../live.js";
|
|
6
|
+
// Why the server refused a subscription, and what it refused.
|
|
7
|
+
export let refusalOf = (read)=>{
|
|
8
|
+
let s = read?.state;
|
|
9
|
+
return s?.status == 'failed' ? `${s.reason} [${s.reference}]` : undefined;
|
|
10
|
+
};
|
|
11
|
+
export let answeredOf = (rows, read)=>{
|
|
12
|
+
let refused = refusalOf(read.subscription);
|
|
13
|
+
return refused === undefined ? {
|
|
14
|
+
rows,
|
|
15
|
+
ready: read.ready
|
|
16
|
+
} : {
|
|
17
|
+
rows,
|
|
18
|
+
ready: false,
|
|
19
|
+
refused
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export let retryOf = (read)=>read?.sub ? ()=>retrySubscription(read.sub) : undefined;
|
|
23
|
+
//# sourceMappingURL=answered.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answered.js","sources":["./answered.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,6EAA6E;AAC7E,sEAAsE;AACtE,gDAAgD;AAEhD,SAAS,iBAAiB,qBAA2C;AAErE,8DAA8D;AAC9D,OAAO,IAAI,YAAY,CAAC;EACtB,IAAI,IAAI,MAAM;EACd,OAAO,GAAG,UAAU,WAAW,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG;AAClE,EAAC;AAED,OAAO,IAAI,aAAa,CACtB,MACA;EAEA,IAAI,UAAU,UAAU,KAAK,YAAY;EACzC,OAAO,YAAY,YACf;IAAE;IAAM,OAAO,KAAK,KAAK;EAAC,IAC1B;IAAE;IAAM,OAAO;IAAO;EAAQ;AACpC,EAAC;AAED,OAAO,IAAI,UAAU,CAAC,OACpB,MAAM,MAAM,IAAM,kBAAkB,KAAK,GAAG,IAAI,UAAS"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// A browse read as @yaks/ux's `Answered`, for `Answer` to draw: its rows,
|
|
2
|
+
// ready as the read says, and refused with the server's reason and the query
|
|
3
|
+
// it refused. `retryOf` asks a refused subscription again on the same
|
|
4
|
+
// identity, so its answer replaces the refusal.
|
|
5
|
+
import type { Answered } from 'jsr:@yaks/ux@0.2.36'
|
|
6
|
+
import { retrySubscription, type SubscriptionRead } from '../live.js'
|
|
7
|
+
|
|
8
|
+
// Why the server refused a subscription, and what it refused.
|
|
9
|
+
export let refusalOf = (read?: SubscriptionRead): string | undefined => {
|
|
10
|
+
let s = read?.state
|
|
11
|
+
return s?.status == 'failed' ? `${s.reason} [${s.reference}]` : undefined
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export let answeredOf = <T>(
|
|
15
|
+
rows: T[],
|
|
16
|
+
read: { ready: boolean; subscription?: SubscriptionRead },
|
|
17
|
+
): Answered<T> => {
|
|
18
|
+
let refused = refusalOf(read.subscription)
|
|
19
|
+
return refused === undefined
|
|
20
|
+
? { rows, ready: read.ready }
|
|
21
|
+
: { rows, ready: false, refused }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export let retryOf = (read?: SubscriptionRead) =>
|
|
25
|
+
read?.sub ? () => retrySubscription(read.sub) : undefined
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Component names share one small colour vocabulary. Provenance reserves the
|
|
2
|
+
// warm end because it accompanies nearly every entity; other names hash into
|
|
3
|
+
// the remaining tones without a hand-kept component map to drift from types.ts.
|
|
4
|
+
export let compTone = (name)=>{
|
|
5
|
+
if (name == 'created') return '4';
|
|
6
|
+
if (name == 'updated') return '5';
|
|
7
|
+
let hash = 2166136261;
|
|
8
|
+
for (let ch of name)hash = Math.imul(hash ^ ch.charCodeAt(0), 16777619);
|
|
9
|
+
return String((hash >>> 0) % 4);
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=comp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comp.js","sources":["./comp.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,gFAAgF;AAChF,OAAO,IAAI,WAAW,CAAC;EACrB,IAAI,QAAQ,WAAW,OAAO;EAC9B,IAAI,QAAQ,WAAW,OAAO;EAC9B,IAAI,OAAO;EACX,KAAK,IAAI,MAAM,KAAM,OAAO,KAAK,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,IAAI;EAC/D,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI;AAC/B,EAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Component names share one small colour vocabulary. Provenance reserves the
|
|
2
|
+
// warm end because it accompanies nearly every entity; other names hash into
|
|
3
|
+
// the remaining tones without a hand-kept component map to drift from types.ts.
|
|
4
|
+
export let compTone = (name: string) => {
|
|
5
|
+
if (name == 'created') return '4'
|
|
6
|
+
if (name == 'updated') return '5'
|
|
7
|
+
let hash = 2166136261
|
|
8
|
+
for (let ch of name) hash = Math.imul(hash ^ ch.charCodeAt(0), 16777619)
|
|
9
|
+
return String((hash >>> 0) % 4)
|
|
10
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// The drag payload, view-free. This lives OUTSIDE Entity.tsx so nav.tsx
|
|
2
|
+
// (which every view imports for linkProps) never pulls the curated view
|
|
3
|
+
// list into a cycle: views/Inline.tsx → nav.tsx → Entity.tsx → views/Inline.tsx
|
|
4
|
+
// was a TDZ time bomb — whichever module entered the cycle first left
|
|
5
|
+
// Entity.tsx's top-level define() list reading an uninitialized view
|
|
6
|
+
// binding under hot-swap re-evaluation. Native payloads and pointer geometry
|
|
7
|
+
// belong with the interaction machinery, not the views that consume them.
|
|
8
|
+
import { drag } from "@yaks/ux";
|
|
9
|
+
import { idOf } from "../types.js";
|
|
10
|
+
import { capable, ent } from "../live.js";
|
|
11
|
+
import { resolve } from "./registry.js";
|
|
12
|
+
export let CARD_DATA = 'application/x-tasks-card';
|
|
13
|
+
export let cardData = (raw)=>{
|
|
14
|
+
try {
|
|
15
|
+
let data = JSON.parse(raw);
|
|
16
|
+
return typeof data?.target == 'string' ? {
|
|
17
|
+
target: data.target
|
|
18
|
+
} : undefined;
|
|
19
|
+
} catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export let resizeDirs = [
|
|
24
|
+
'n',
|
|
25
|
+
's',
|
|
26
|
+
'e',
|
|
27
|
+
'w',
|
|
28
|
+
'ne',
|
|
29
|
+
'nw',
|
|
30
|
+
'se',
|
|
31
|
+
'sw'
|
|
32
|
+
];
|
|
33
|
+
export let moved = (x, y, dx, dy)=>({
|
|
34
|
+
x: Math.round(x + dx),
|
|
35
|
+
y: Math.round(y + dy)
|
|
36
|
+
});
|
|
37
|
+
export let sized = (base, d, dx, dy)=>{
|
|
38
|
+
let next = {};
|
|
39
|
+
if (d.includes('e')) next.w = Math.max(160, Math.round(base.w + dx));
|
|
40
|
+
if (d.includes('w')) {
|
|
41
|
+
next.w = Math.max(160, Math.round(base.w - dx));
|
|
42
|
+
next.x = Math.round(base.x + base.w - next.w);
|
|
43
|
+
}
|
|
44
|
+
if (d.includes('s')) next.h = Math.max(60, Math.round(base.h + dy));
|
|
45
|
+
if (d.includes('n')) {
|
|
46
|
+
next.h = Math.max(60, Math.round(base.h - dy));
|
|
47
|
+
next.y = Math.round(base.y + base.h - next.h);
|
|
48
|
+
}
|
|
49
|
+
return next;
|
|
50
|
+
};
|
|
51
|
+
export let resetSize = (d)=>({
|
|
52
|
+
...d.includes('e') || d.includes('w') ? {
|
|
53
|
+
w: 0
|
|
54
|
+
} : {},
|
|
55
|
+
...d.includes('n') || d.includes('s') ? {
|
|
56
|
+
h: 0
|
|
57
|
+
} : {}
|
|
58
|
+
});
|
|
59
|
+
// Pointer geometry for a Pin and anything else dragged on a canvas. The
|
|
60
|
+
// element previews locally; its owner decides where the one settle write goes.
|
|
61
|
+
export let moveEl = (e, el, scale, start, settle, cancel = ()=>{})=>{
|
|
62
|
+
let sx = e.clientX;
|
|
63
|
+
let sy = e.clientY;
|
|
64
|
+
let dx = 0;
|
|
65
|
+
let dy = 0;
|
|
66
|
+
let px = 0;
|
|
67
|
+
let py = 0;
|
|
68
|
+
let dragging = false;
|
|
69
|
+
let move = (e)=>{
|
|
70
|
+
px = e.clientX;
|
|
71
|
+
py = e.clientY;
|
|
72
|
+
if (!dragging) {
|
|
73
|
+
if (Math.hypot(px - sx, py - sy) < 3) return;
|
|
74
|
+
dragging = true;
|
|
75
|
+
start();
|
|
76
|
+
el.setPointerCapture(e.pointerId);
|
|
77
|
+
el.style.willChange = 'transform';
|
|
78
|
+
}
|
|
79
|
+
let z = scale();
|
|
80
|
+
dx = (px - sx) / z;
|
|
81
|
+
dy = (py - sy) / z;
|
|
82
|
+
el.style.transform = `translate(${dx}px, ${dy}px)`;
|
|
83
|
+
};
|
|
84
|
+
let quit = ()=>{
|
|
85
|
+
removeEventListener('pointermove', move);
|
|
86
|
+
removeEventListener('pointerup', up);
|
|
87
|
+
removeEventListener('pointercancel', dead);
|
|
88
|
+
el.style.transform = '';
|
|
89
|
+
el.style.willChange = '';
|
|
90
|
+
};
|
|
91
|
+
let dead = ()=>{
|
|
92
|
+
quit();
|
|
93
|
+
cancel();
|
|
94
|
+
};
|
|
95
|
+
let up = ()=>{
|
|
96
|
+
quit();
|
|
97
|
+
if (dragging) settle(dx, dy, px, py);
|
|
98
|
+
};
|
|
99
|
+
addEventListener('pointermove', move);
|
|
100
|
+
addEventListener('pointerup', up);
|
|
101
|
+
addEventListener('pointercancel', dead);
|
|
102
|
+
};
|
|
103
|
+
export let resizeEl = (e, grip, el, base, d, scale, settle, cancel = ()=>{})=>{
|
|
104
|
+
let sx = e.clientX;
|
|
105
|
+
let sy = e.clientY;
|
|
106
|
+
let next = {};
|
|
107
|
+
let before = {
|
|
108
|
+
left: el.style.left,
|
|
109
|
+
top: el.style.top,
|
|
110
|
+
width: el.style.width,
|
|
111
|
+
height: el.style.height
|
|
112
|
+
};
|
|
113
|
+
grip.setPointerCapture(e.pointerId);
|
|
114
|
+
let move = (e)=>{
|
|
115
|
+
let z = scale();
|
|
116
|
+
next = sized(base, d, (e.clientX - sx) / z, (e.clientY - sy) / z);
|
|
117
|
+
if (next.x != null) el.style.left = `${next.x}px`;
|
|
118
|
+
if (next.y != null) el.style.top = `${next.y}px`;
|
|
119
|
+
if (next.w != null) el.style.width = `${next.w}px`;
|
|
120
|
+
if (next.h != null) el.style.height = `${next.h}px`;
|
|
121
|
+
};
|
|
122
|
+
let quit = ()=>{
|
|
123
|
+
removeEventListener('pointermove', move);
|
|
124
|
+
removeEventListener('pointerup', up);
|
|
125
|
+
removeEventListener('pointercancel', dead);
|
|
126
|
+
};
|
|
127
|
+
let dead = ()=>{
|
|
128
|
+
quit();
|
|
129
|
+
Object.assign(el.style, before);
|
|
130
|
+
cancel();
|
|
131
|
+
};
|
|
132
|
+
let up = ()=>{
|
|
133
|
+
quit();
|
|
134
|
+
if (Object.keys(next).length) settle(next);
|
|
135
|
+
else cancel();
|
|
136
|
+
};
|
|
137
|
+
addEventListener('pointermove', move);
|
|
138
|
+
addEventListener('pointerup', up);
|
|
139
|
+
addEventListener('pointercancel', dead);
|
|
140
|
+
};
|
|
141
|
+
let b64 = (t)=>btoa(Array.from(new TextEncoder().encode(t), (b)=>String.fromCharCode(b)).join(''));
|
|
142
|
+
// Arm a dragstart with the standard payload: the spawn card (for a canvas
|
|
143
|
+
// drop — target + view + width, plus where in the dragged element the grab
|
|
144
|
+
// happened, so the spawned card lands where the ghost was dropped), and,
|
|
145
|
+
// when the view's renderer has a file form, the serialized file (for a
|
|
146
|
+
// desktop drop) plus text for editors. `pin` rides only for an EXISTING
|
|
147
|
+
// card being relocated (a canvas List row dragged out): its presence says MOVE
|
|
148
|
+
// this pin, not clone a new card — tab drags omit it, so they still clone.
|
|
149
|
+
export let dragData = (ev, eid, view, w = 0, pin)=>{
|
|
150
|
+
if (!ev.dataTransfer || !(ev.currentTarget instanceof HTMLElement)) return;
|
|
151
|
+
// Any list a package draws takes the entity by this, whoever drew the row.
|
|
152
|
+
drag(ev, eid);
|
|
153
|
+
let e = ent(eid);
|
|
154
|
+
let box = ev.currentTarget.getBoundingClientRect();
|
|
155
|
+
if (capable('canvas')) {
|
|
156
|
+
ev.dataTransfer.setData(CARD_DATA, JSON.stringify({
|
|
157
|
+
target: eid,
|
|
158
|
+
view,
|
|
159
|
+
w,
|
|
160
|
+
ox: ev.clientX - box.left,
|
|
161
|
+
oy: ev.clientY - box.top,
|
|
162
|
+
...pin ? {
|
|
163
|
+
pin
|
|
164
|
+
} : {}
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
let f = resolve(e, view).file;
|
|
168
|
+
if (!f) return;
|
|
169
|
+
let text = f.text(e);
|
|
170
|
+
ev.dataTransfer.setData('text/plain', text);
|
|
171
|
+
ev.dataTransfer.setData('DownloadURL', `${f.mime}:${idOf(e)}.${f.ext}:data:${f.mime};base64,${b64(text)}`);
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=drag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drag.js","sources":["./drag.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wEAAwE;AACxE,gFAAgF;AAChF,sEAAsE;AACtE,qEAAqE;AACrE,6EAA6E;AAC7E,0EAA0E;AAC1E,SAAS,IAAI,wBAA6B;AAC1C,SAAS,IAAI,sBAAqB;AAClC,SAAS,OAAO,EAAE,GAAG,qBAAoB;AACzC,SAAS,OAAO,wBAAuB;AAGvC,OAAO,IAAI,YAAY,2BAA0B;AAEjD,OAAO,IAAI,WAAW,CAAC;EACrB,IAAI;IACF,IAAI,OAAO,KAAK,KAAK,CAAC;IACtB,OAAO,OAAO,MAAM,UAAU,WAAW;MAAE,QAAQ,KAAK,MAAM;IAAC,IAAI;EACrE,EAAE,OAAM;IACN,OAAO;EACT;AACF,EAAC;AAED,OAAO,IAAI,aAAa;EAAC;EAAK;EAAK;EAAK;EAAK;EAAM;EAAM;EAAM;CAAK,CAAA;AAEpE,OAAO,IAAI,QAAQ,CAAC,GAAW,GAAW,IAAY,KAAe,CAAC;IACpE,GAAG,KAAK,KAAK,CAAC,IAAI;IAClB,GAAG,KAAK,KAAK,CAAC,IAAI;EACpB,CAAC,EAAC;AAEF,OAAO,IAAI,QAAQ,CAAC,MAAW,GAAW,IAAY;EACpD,IAAI,OAAqB,CAAC;EAC1B,IAAI,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG;EAChE,IAAI,EAAE,QAAQ,CAAC,MAAM;IACnB,KAAK,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GAAG,OAAO,GAAG,IAAI,GAAG;MACxB,GAAI,MAAM;QAAE;MAAI,IAAI,CAAC,CAAC;IACxB;EAEJ;EACA,IAAI,IAAI,QAAQ,GAAG,MAAM,IAAI;EAC7B,IAAI,CAAC,GAAG;EACR,IAAI,OAAO,EAAE,IAAI,CAAC;EAClB,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc;EACtC,GAAG,YAAY,CAAC,OAAO,CACrB,eACA,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,OAAO;AAEtE,EAAC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// The drag payload, view-free. This lives OUTSIDE Entity.tsx so nav.tsx
|
|
2
|
+
// (which every view imports for linkProps) never pulls the curated view
|
|
3
|
+
// list into a cycle: views/Inline.tsx → nav.tsx → Entity.tsx → views/Inline.tsx
|
|
4
|
+
// was a TDZ time bomb — whichever module entered the cycle first left
|
|
5
|
+
// Entity.tsx's top-level define() list reading an uninitialized view
|
|
6
|
+
// binding under hot-swap re-evaluation. Native payloads and pointer geometry
|
|
7
|
+
// belong with the interaction machinery, not the views that consume them.
|
|
8
|
+
import { drag } from '@yaks/ux'
|
|
9
|
+
import { idOf } from '../types.js'
|
|
10
|
+
import { capable, ent } from '../live.js'
|
|
11
|
+
import { resolve } from './registry.js'
|
|
12
|
+
|
|
13
|
+
export type Box = { x: number; y: number; w: number; h: number }
|
|
14
|
+
export let CARD_DATA = 'application/x-tasks-card'
|
|
15
|
+
|
|
16
|
+
export let cardData = (raw: string): { target: string } | undefined => {
|
|
17
|
+
try {
|
|
18
|
+
let data = JSON.parse(raw)
|
|
19
|
+
return typeof data?.target == 'string' ? { target: data.target } : undefined
|
|
20
|
+
} catch {
|
|
21
|
+
return undefined
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export let resizeDirs = ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw']
|
|
26
|
+
|
|
27
|
+
export let moved = (x: number, y: number, dx: number, dy: number) => ({
|
|
28
|
+
x: Math.round(x + dx),
|
|
29
|
+
y: Math.round(y + dy),
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
export let sized = (base: Box, d: string, dx: number, dy: number) => {
|
|
33
|
+
let next: Partial<Box> = {}
|
|
34
|
+
if (d.includes('e')) next.w = Math.max(160, Math.round(base.w + dx))
|
|
35
|
+
if (d.includes('w')) {
|
|
36
|
+
next.w = Math.max(160, Math.round(base.w - dx))
|
|
37
|
+
next.x = Math.round(base.x + base.w - next.w)
|
|
38
|
+
}
|
|
39
|
+
if (d.includes('s')) next.h = Math.max(60, Math.round(base.h + dy))
|
|
40
|
+
if (d.includes('n')) {
|
|
41
|
+
next.h = Math.max(60, Math.round(base.h - dy))
|
|
42
|
+
next.y = Math.round(base.y + base.h - next.h)
|
|
43
|
+
}
|
|
44
|
+
return next
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export let resetSize = (d: string) => ({
|
|
48
|
+
...(d.includes('e') || d.includes('w') ? { w: 0 } : {}),
|
|
49
|
+
...(d.includes('n') || d.includes('s') ? { h: 0 } : {}),
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
// Pointer geometry for a Pin and anything else dragged on a canvas. The
|
|
53
|
+
// element previews locally; its owner decides where the one settle write goes.
|
|
54
|
+
export let moveEl = (
|
|
55
|
+
e: PointerEvent,
|
|
56
|
+
el: HTMLElement,
|
|
57
|
+
scale: () => number,
|
|
58
|
+
start: () => void,
|
|
59
|
+
settle: (dx: number, dy: number, x: number, y: number) => void,
|
|
60
|
+
cancel: () => void = () => {},
|
|
61
|
+
) => {
|
|
62
|
+
let sx = e.clientX
|
|
63
|
+
let sy = e.clientY
|
|
64
|
+
let dx = 0
|
|
65
|
+
let dy = 0
|
|
66
|
+
let px = 0
|
|
67
|
+
let py = 0
|
|
68
|
+
let dragging = false
|
|
69
|
+
let move = (e: PointerEvent) => {
|
|
70
|
+
px = e.clientX
|
|
71
|
+
py = e.clientY
|
|
72
|
+
if (!dragging) {
|
|
73
|
+
if (Math.hypot(px - sx, py - sy) < 3) return
|
|
74
|
+
dragging = true
|
|
75
|
+
start()
|
|
76
|
+
el.setPointerCapture(e.pointerId)
|
|
77
|
+
el.style.willChange = 'transform'
|
|
78
|
+
}
|
|
79
|
+
let z = scale()
|
|
80
|
+
dx = (px - sx) / z
|
|
81
|
+
dy = (py - sy) / z
|
|
82
|
+
el.style.transform = `translate(${dx}px, ${dy}px)`
|
|
83
|
+
}
|
|
84
|
+
let quit = () => {
|
|
85
|
+
removeEventListener('pointermove', move)
|
|
86
|
+
removeEventListener('pointerup', up)
|
|
87
|
+
removeEventListener('pointercancel', dead)
|
|
88
|
+
el.style.transform = ''
|
|
89
|
+
el.style.willChange = ''
|
|
90
|
+
}
|
|
91
|
+
let dead = () => {
|
|
92
|
+
quit()
|
|
93
|
+
cancel()
|
|
94
|
+
}
|
|
95
|
+
let up = () => {
|
|
96
|
+
quit()
|
|
97
|
+
if (dragging) settle(dx, dy, px, py)
|
|
98
|
+
}
|
|
99
|
+
addEventListener('pointermove', move)
|
|
100
|
+
addEventListener('pointerup', up)
|
|
101
|
+
addEventListener('pointercancel', dead)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export let resizeEl = (
|
|
105
|
+
e: PointerEvent,
|
|
106
|
+
grip: HTMLElement,
|
|
107
|
+
el: HTMLElement,
|
|
108
|
+
base: Box,
|
|
109
|
+
d: string,
|
|
110
|
+
scale: () => number,
|
|
111
|
+
settle: (box: Partial<Box>) => void,
|
|
112
|
+
cancel: () => void = () => {},
|
|
113
|
+
) => {
|
|
114
|
+
let sx = e.clientX
|
|
115
|
+
let sy = e.clientY
|
|
116
|
+
let next: Partial<Box> = {}
|
|
117
|
+
let before = {
|
|
118
|
+
left: el.style.left,
|
|
119
|
+
top: el.style.top,
|
|
120
|
+
width: el.style.width,
|
|
121
|
+
height: el.style.height,
|
|
122
|
+
}
|
|
123
|
+
grip.setPointerCapture(e.pointerId)
|
|
124
|
+
let move = (e: PointerEvent) => {
|
|
125
|
+
let z = scale()
|
|
126
|
+
next = sized(base, d, (e.clientX - sx) / z, (e.clientY - sy) / z)
|
|
127
|
+
if (next.x != null) el.style.left = `${next.x}px`
|
|
128
|
+
if (next.y != null) el.style.top = `${next.y}px`
|
|
129
|
+
if (next.w != null) el.style.width = `${next.w}px`
|
|
130
|
+
if (next.h != null) el.style.height = `${next.h}px`
|
|
131
|
+
}
|
|
132
|
+
let quit = () => {
|
|
133
|
+
removeEventListener('pointermove', move)
|
|
134
|
+
removeEventListener('pointerup', up)
|
|
135
|
+
removeEventListener('pointercancel', dead)
|
|
136
|
+
}
|
|
137
|
+
let dead = () => {
|
|
138
|
+
quit()
|
|
139
|
+
Object.assign(el.style, before)
|
|
140
|
+
cancel()
|
|
141
|
+
}
|
|
142
|
+
let up = () => {
|
|
143
|
+
quit()
|
|
144
|
+
if (Object.keys(next).length) settle(next)
|
|
145
|
+
else cancel()
|
|
146
|
+
}
|
|
147
|
+
addEventListener('pointermove', move)
|
|
148
|
+
addEventListener('pointerup', up)
|
|
149
|
+
addEventListener('pointercancel', dead)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let b64 = (t: string) =>
|
|
153
|
+
btoa(
|
|
154
|
+
Array.from(new TextEncoder().encode(t), (b) => String.fromCharCode(b))
|
|
155
|
+
.join(''),
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
// Arm a dragstart with the standard payload: the spawn card (for a canvas
|
|
159
|
+
// drop — target + view + width, plus where in the dragged element the grab
|
|
160
|
+
// happened, so the spawned card lands where the ghost was dropped), and,
|
|
161
|
+
// when the view's renderer has a file form, the serialized file (for a
|
|
162
|
+
// desktop drop) plus text for editors. `pin` rides only for an EXISTING
|
|
163
|
+
// card being relocated (a canvas List row dragged out): its presence says MOVE
|
|
164
|
+
// this pin, not clone a new card — tab drags omit it, so they still clone.
|
|
165
|
+
export let dragData = (
|
|
166
|
+
ev: DragEvent,
|
|
167
|
+
eid: string,
|
|
168
|
+
view: string,
|
|
169
|
+
w = 0,
|
|
170
|
+
pin?: string,
|
|
171
|
+
) => {
|
|
172
|
+
if (!ev.dataTransfer || !(ev.currentTarget instanceof HTMLElement)) return
|
|
173
|
+
// Any list a package draws takes the entity by this, whoever drew the row.
|
|
174
|
+
drag(ev, eid)
|
|
175
|
+
let e = ent(eid)
|
|
176
|
+
let box = ev.currentTarget.getBoundingClientRect()
|
|
177
|
+
if (capable('canvas')) {
|
|
178
|
+
ev.dataTransfer.setData(
|
|
179
|
+
CARD_DATA,
|
|
180
|
+
JSON.stringify({
|
|
181
|
+
target: eid,
|
|
182
|
+
view,
|
|
183
|
+
w,
|
|
184
|
+
ox: ev.clientX - box.left,
|
|
185
|
+
oy: ev.clientY - box.top,
|
|
186
|
+
...(pin ? { pin } : {}),
|
|
187
|
+
}),
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
let f = resolve(e, view).file
|
|
191
|
+
if (!f) return
|
|
192
|
+
let text = f.text(e)
|
|
193
|
+
ev.dataTransfer.setData('text/plain', text)
|
|
194
|
+
ev.dataTransfer.setData(
|
|
195
|
+
'DownloadURL',
|
|
196
|
+
`${f.mime}:${idOf(e)}.${f.ext}:data:${f.mime};base64,${b64(text)}`,
|
|
197
|
+
)
|
|
198
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
// The query field (@yaks/filter), bound to this page. Every query typed here
|
|
3
|
+
// (a card's filter bar, the search palette, the command line, a board's query,
|
|
4
|
+
// the inspector's bar) is a field in `front`, the page's own graph: a local
|
|
5
|
+
// @yaks/client over RAM that no server hears of, where the inspector
|
|
6
|
+
// (@yaks/inspect) and every UX component (@yaks/ux) keep their state too.
|
|
7
|
+
// What is typed in one is the person's draft (./drafts.ts), in the place the
|
|
8
|
+
// field is named for, so a reload, another tab or the terminal shows it until
|
|
9
|
+
// it is cleared. Anything on the page reads a field by reading its row.
|
|
10
|
+
//
|
|
11
|
+
// What a field cannot know is supplied here, once: the vocabulary the host
|
|
12
|
+
// taught this page (read when a field completes, since it is learned after
|
|
13
|
+
// this module loads), the entities this page holds for a reference to name,
|
|
14
|
+
// the wells a property's values come from, the rankings the host evaluates,
|
|
15
|
+
// and, in a browser, the overlay the list floats in, clear of every clipping
|
|
16
|
+
// card. The terminal binds the same fields with the list in the flow.
|
|
17
|
+
import { client } from 'jsr:@yaks/client@0.2.36'
|
|
18
|
+
import doc from '../front.json' with { type: 'json' }
|
|
19
|
+
import { filters, type Float } from 'jsr:@yaks/filter@0.2.36'
|
|
20
|
+
import { docs as filterDocs } from 'jsr:@yaks/filter@0.2.36/vocab'
|
|
21
|
+
import { docs as inspectDocs } from 'jsr:@yaks/inspect@0.2.36/front'
|
|
22
|
+
import { docs as uxDocs } from 'jsr:@yaks/ux@0.2.36/vocab'
|
|
23
|
+
import type { Cand, Source } from 'jsr:@yaks/query@0.2.36'
|
|
24
|
+
import { loadVocab } from 'jsr:@yaks/vocab@0.2.36'
|
|
25
|
+
import { cache, type Comps } from '../live.ts'
|
|
26
|
+
import { RANKS } from '../query.ts'
|
|
27
|
+
import { idIn, kindOf, vocab } from '../types.ts'
|
|
28
|
+
import { Float as Floating } from 'jsr:@yaks/ui@0.2.36'
|
|
29
|
+
import { wellOf, wells } from './wells.ts'
|
|
30
|
+
import { drafts } from 'jsr:@yaks/draft@0.2.36/input'
|
|
31
|
+
|
|
32
|
+
/** The page's own graph. */
|
|
33
|
+
export let front = client(
|
|
34
|
+
loadVocab([...filterDocs, ...uxDocs, ...inspectDocs, doc]),
|
|
35
|
+
[],
|
|
36
|
+
{ vault: false, wireVault: false },
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
let starts = (s: string, pre: string) =>
|
|
40
|
+
s.toLowerCase().startsWith(pre.toLowerCase())
|
|
41
|
+
|
|
42
|
+
// The entities this page holds, as the ids a person types: listed once per
|
|
43
|
+
// turn of the cache, not once per keystroke.
|
|
44
|
+
let listed: { of?: Record<string, Comps>; ids: Cand[] } = { ids: [] }
|
|
45
|
+
let held = () => {
|
|
46
|
+
let now = cache.peek()
|
|
47
|
+
if (listed.of != now) {
|
|
48
|
+
listed = {
|
|
49
|
+
of: now,
|
|
50
|
+
ids: Object.entries(now).map(([eid, comps]) => ({
|
|
51
|
+
text: idIn(eid, comps),
|
|
52
|
+
kind: kindOf(comps),
|
|
53
|
+
})),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return listed.ids
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** What only this page's graph can answer, as the field asks it. */
|
|
60
|
+
export let source: Source<Cand[]> = {
|
|
61
|
+
ids: (ref, pre) =>
|
|
62
|
+
held().filter((c) =>
|
|
63
|
+
(ref == 'entity' || c.kind == ref) && starts(c.text, pre)
|
|
64
|
+
),
|
|
65
|
+
values: (comp, prop, pre) => {
|
|
66
|
+
let well = wellOf(comp, prop)
|
|
67
|
+
return (wells[well]?.() ?? []).filter((v) => starts(v, pre))
|
|
68
|
+
.map((text) => ({ text, kind: well }))
|
|
69
|
+
},
|
|
70
|
+
ranks: RANKS,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The fields, with the list floating where `Float` puts it. */
|
|
74
|
+
export let bind = (Float?: Float) =>
|
|
75
|
+
filters(front, {
|
|
76
|
+
get vocab() {
|
|
77
|
+
return vocab
|
|
78
|
+
},
|
|
79
|
+
drafts,
|
|
80
|
+
source,
|
|
81
|
+
Float,
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// A browser floats the list under its field.
|
|
85
|
+
let Below: Float = ({ anchor, children }) => (
|
|
86
|
+
<Floating anchor={anchor} side='below'>{children}</Floating>
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
/** The fields as a browser shows them. */
|
|
90
|
+
export let fields = bind(Below)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Renderer archetypes
|
|
2
|
+
|
|
3
|
+
`archetypes.json` freezes 432 distinct physical table sets from the September
|
|
4
|
+
11, 2026 scratch snapshot used for T-37058, ordered by descriptor spine id and
|
|
5
|
+
taking the first 432 rows of `archetype`. It contains only table names, not
|
|
6
|
+
entity data. This is a reproducible sample at the size of D-286's September 10
|
|
7
|
+
census, not a claim to reconstruct that earlier census. The web and TUI parity
|
|
8
|
+
tests enumerate every set against every registered view and compare
|
|
9
|
+
component-based matching with archetype-based matching, including spine-only
|
|
10
|
+
projections.
|