@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
package/keybindings.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// The keybinding cards shown by the web and terminal. The handlers stay with
|
|
2
|
+
// their platforms, but for vim's walk, which both share (@yaks/ux/keys); this
|
|
3
|
+
// is the shared, human-facing vocabulary they teach.
|
|
4
|
+
import { walkKeys } from "@yaks/ux/keys";
|
|
5
|
+
export let webKeys = [
|
|
6
|
+
{
|
|
7
|
+
keys: [
|
|
8
|
+
'?'
|
|
9
|
+
],
|
|
10
|
+
about: 'show or close keybindings'
|
|
11
|
+
},
|
|
12
|
+
...walkKeys,
|
|
13
|
+
{
|
|
14
|
+
keys: [
|
|
15
|
+
'/'
|
|
16
|
+
],
|
|
17
|
+
about: 'search the graph'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
keys: [
|
|
21
|
+
'n'
|
|
22
|
+
],
|
|
23
|
+
about: 'new entity'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
keys: [
|
|
27
|
+
':'
|
|
28
|
+
],
|
|
29
|
+
about: 'open the command line'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
keys: [
|
|
33
|
+
'Esc'
|
|
34
|
+
],
|
|
35
|
+
about: 'leave insert mode, the cursor on the field'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
plugin: 'canvas',
|
|
39
|
+
keys: [
|
|
40
|
+
'Space'
|
|
41
|
+
],
|
|
42
|
+
about: 'frame a canvas card'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
plugin: 'canvas',
|
|
46
|
+
keys: [
|
|
47
|
+
'0'
|
|
48
|
+
],
|
|
49
|
+
about: 'reset canvas zoom'
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
export let tuiKeys = [
|
|
53
|
+
{
|
|
54
|
+
keys: [
|
|
55
|
+
'?'
|
|
56
|
+
],
|
|
57
|
+
about: 'show or close keybindings'
|
|
58
|
+
},
|
|
59
|
+
...walkKeys,
|
|
60
|
+
{
|
|
61
|
+
keys: [
|
|
62
|
+
'Ctrl-O',
|
|
63
|
+
'Ctrl-F'
|
|
64
|
+
],
|
|
65
|
+
about: 'go back or forward'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
keys: [
|
|
69
|
+
'Tab',
|
|
70
|
+
'Shift-Tab'
|
|
71
|
+
],
|
|
72
|
+
about: 'move to the next or previous control'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
keys: [
|
|
76
|
+
'Shift-Enter'
|
|
77
|
+
],
|
|
78
|
+
about: 'add a reply line while typing'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
keys: [
|
|
82
|
+
'1–4'
|
|
83
|
+
],
|
|
84
|
+
about: 'answer a decision with a listed choice'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
keys: [
|
|
88
|
+
'a'
|
|
89
|
+
],
|
|
90
|
+
about: 'write a custom decision answer; Enter sends, Esc keeps it'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
keys: [
|
|
94
|
+
'/'
|
|
95
|
+
],
|
|
96
|
+
about: 'search the graph'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
keys: [
|
|
100
|
+
'f'
|
|
101
|
+
],
|
|
102
|
+
about: 'search'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
keys: [
|
|
106
|
+
'n'
|
|
107
|
+
],
|
|
108
|
+
about: 'new entity'
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
keys: [
|
|
112
|
+
'Esc'
|
|
113
|
+
],
|
|
114
|
+
about: 'leave insert mode, the cursor on the field'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
keys: [
|
|
118
|
+
'y'
|
|
119
|
+
],
|
|
120
|
+
about: 'yank'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
keys: [
|
|
124
|
+
':'
|
|
125
|
+
],
|
|
126
|
+
about: 'open the command line'
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
keys: [
|
|
130
|
+
'q',
|
|
131
|
+
'Ctrl-C'
|
|
132
|
+
],
|
|
133
|
+
about: 'quit, with nothing in front to close'
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
//# sourceMappingURL=keybindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keybindings.js","sources":["./keybindings.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,qDAAqD;AACrD,SAAS,QAAQ,6BAAkC;AAInD,OAAO,IAAI,UAAwB;EACjC;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAA4B;KAC/C;EACH;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAAmB;EACzC;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAAa;EACnC;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAAwB;EAC9C;IAAE,MAAM;MAAC;KAAM;IAAE,OAAO;EAA6C;EACrE;IAAE,QAAQ;IAAU,MAAM;MAAC;KAAQ;IAAE,OAAO;EAAsB;EAClE;IAAE,QAAQ;IAAU,MAAM;MAAC;KAAI;IAAE,OAAO;EAAoB;CAC7D,CAAA;AAED,OAAO,IAAI,UAAwB;EACjC;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAA4B;KAC/C;EACH;IAAE,MAAM;MAAC;MAAU;KAAS;IAAE,OAAO;EAAqB;EAC1D;IAAE,MAAM;MAAC;MAAO;KAAY;IAAE,OAAO;EAAuC;EAC5E;IAAE,MAAM;MAAC;KAAc;IAAE,OAAO;EAAgC;EAChE;IAAE,MAAM;MAAC;KAAM;IAAE,OAAO;EAAyC;EACjE;IACE,MAAM;MAAC;KAAI;IACX,OAAO;EACT;EACA;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAAmB;EACzC;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAAS;EAC/B;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAAa;EACnC;IAAE,MAAM;MAAC;KAAM;IAAE,OAAO;EAA6C;EACrE;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAAO;EAC7B;IAAE,MAAM;MAAC;KAAI;IAAE,OAAO;EAAwB;EAC9C;IAAE,MAAM;MAAC;MAAK;KAAS;IAAE,OAAO;EAAuC;CACxE,CAAA"}
|
package/keybindings.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The keybinding cards shown by the web and terminal. The handlers stay with
|
|
2
|
+
// their platforms, but for vim's walk, which both share (@yaks/ux/keys); this
|
|
3
|
+
// is the shared, human-facing vocabulary they teach.
|
|
4
|
+
import { walkKeys } from '@yaks/ux/keys'
|
|
5
|
+
|
|
6
|
+
export type Keybinding = { keys: string[]; about: string; plugin?: string }
|
|
7
|
+
|
|
8
|
+
export let webKeys: Keybinding[] = [
|
|
9
|
+
{ keys: ['?'], about: 'show or close keybindings' },
|
|
10
|
+
...walkKeys,
|
|
11
|
+
{ keys: ['/'], about: 'search the graph' },
|
|
12
|
+
{ keys: ['n'], about: 'new entity' },
|
|
13
|
+
{ keys: [':'], about: 'open the command line' },
|
|
14
|
+
{ keys: ['Esc'], about: 'leave insert mode, the cursor on the field' },
|
|
15
|
+
{ plugin: 'canvas', keys: ['Space'], about: 'frame a canvas card' },
|
|
16
|
+
{ plugin: 'canvas', keys: ['0'], about: 'reset canvas zoom' },
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
export let tuiKeys: Keybinding[] = [
|
|
20
|
+
{ keys: ['?'], about: 'show or close keybindings' },
|
|
21
|
+
...walkKeys,
|
|
22
|
+
{ keys: ['Ctrl-O', 'Ctrl-F'], about: 'go back or forward' },
|
|
23
|
+
{ keys: ['Tab', 'Shift-Tab'], about: 'move to the next or previous control' },
|
|
24
|
+
{ keys: ['Shift-Enter'], about: 'add a reply line while typing' },
|
|
25
|
+
{ keys: ['1–4'], about: 'answer a decision with a listed choice' },
|
|
26
|
+
{
|
|
27
|
+
keys: ['a'],
|
|
28
|
+
about: 'write a custom decision answer; Enter sends, Esc keeps it',
|
|
29
|
+
},
|
|
30
|
+
{ keys: ['/'], about: 'search the graph' },
|
|
31
|
+
{ keys: ['f'], about: 'search' },
|
|
32
|
+
{ keys: ['n'], about: 'new entity' },
|
|
33
|
+
{ keys: ['Esc'], about: 'leave insert mode, the cursor on the field' },
|
|
34
|
+
{ keys: ['y'], about: 'yank' },
|
|
35
|
+
{ keys: [':'], about: 'open the command line' },
|
|
36
|
+
{ keys: ['q', 'Ctrl-C'], about: 'quit, with nothing in front to close' },
|
|
37
|
+
]
|
package/kit.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** `yak open`: a kit-built yaks app in this terminal. The app's view is
|
|
2
|
+
* loaded from the app (@yaks/native/remote, as the iOS shell loads it),
|
|
3
|
+
* rendered into @yaks/tui's in-memory DOM and painted by its painter, over
|
|
4
|
+
* the app's own store on yaks.app. Tab walks its controls, a field takes what
|
|
5
|
+
* is typed, Enter and Space press, as @yaks/tui/interaction does for any
|
|
6
|
+
* page; `q` outside a field quits. */ import { bundle } from "@yaks/cli/page";
|
|
7
|
+
import { aliases, modules, paint } from "@yaks/preact/renderer";
|
|
8
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import * as react from "react";
|
|
9
|
+
/* @ts-types="npm:@types/react@19.3.0/jsx-runtime" */ import * as jsx from "react/jsx-runtime";
|
|
10
|
+
import * as ui from "@yaks/ui";
|
|
11
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, useLayoutEffect, useRef } from "react";
|
|
12
|
+
import { quit, run, Scroll, useKeys } from "@yaks/tui";
|
|
13
|
+
import { interaction } from "@yaks/tui/interaction";
|
|
14
|
+
import { composition, sheet } from "@yaks/ui";
|
|
15
|
+
import { nativeOf, prepareView, store } from "@yaks/native/remote";
|
|
16
|
+
/** What a view loaded into this process imports its platform packages as:
|
|
17
|
+
* the copies @yaks/tui renders by. */ export let carried = {
|
|
18
|
+
...modules,
|
|
19
|
+
react,
|
|
20
|
+
'react/jsx-runtime': jsx,
|
|
21
|
+
'@yaks/ui': ui
|
|
22
|
+
};
|
|
23
|
+
let legacy = async ()=>{
|
|
24
|
+
let code = await bundle(new URL(import.meta.resolve('@yaks/ui')), undefined, {
|
|
25
|
+
alias: aliases,
|
|
26
|
+
external: Object.keys(modules).filter((name)=>name.startsWith('preact')),
|
|
27
|
+
format: 'cjs'
|
|
28
|
+
});
|
|
29
|
+
let module = {
|
|
30
|
+
exports: {}
|
|
31
|
+
};
|
|
32
|
+
new Function('require', 'module', 'exports', code)((name)=>modules[name], module, module.exports);
|
|
33
|
+
return {
|
|
34
|
+
...modules,
|
|
35
|
+
'@yaks/ui': module.exports
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
let legacyKits;
|
|
39
|
+
export let appAt = async (at, go)=>{
|
|
40
|
+
let app = await prepareView(at, go);
|
|
41
|
+
if (!app.imports.some((name)=>name == 'preact' || name.startsWith('preact/'))) {
|
|
42
|
+
return app.open(carried);
|
|
43
|
+
}
|
|
44
|
+
let View = app.open(await (legacyKits ??= legacy().catch((error)=>{
|
|
45
|
+
legacyKits = undefined;
|
|
46
|
+
throw error;
|
|
47
|
+
})));
|
|
48
|
+
return ({ store })=>{
|
|
49
|
+
let root = useRef(null);
|
|
50
|
+
useLayoutEffect(()=>paint(View, {
|
|
51
|
+
store
|
|
52
|
+
}, root.current), [
|
|
53
|
+
store
|
|
54
|
+
]);
|
|
55
|
+
return /*#__PURE__*/ h('div', {
|
|
56
|
+
ref: root
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/** The app's view over its store, its controls walked by the keyboard, the
|
|
61
|
+
* first field in focus. */ export let Kit = ({ view, store })=>{
|
|
62
|
+
let at = useRef(null);
|
|
63
|
+
let keys = useRef(null);
|
|
64
|
+
useLayoutEffect(()=>{
|
|
65
|
+
let root = at.current;
|
|
66
|
+
keys.current = interaction(root, ()=>{});
|
|
67
|
+
let field = root.querySelector('input,textarea');
|
|
68
|
+
if (field) keys.current.focus(field);
|
|
69
|
+
}, []);
|
|
70
|
+
useKeys((k)=>{
|
|
71
|
+
let typing = keys.current?.active()?.matches('input,textarea');
|
|
72
|
+
if (!typing && k.name == 'char' && k.text == 'q' && !k.ctrl && !k.alt) {
|
|
73
|
+
quit();
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return keys.current?.press(k) ?? false;
|
|
77
|
+
});
|
|
78
|
+
return /*#__PURE__*/ h(Scroll, {
|
|
79
|
+
id: 'kit',
|
|
80
|
+
follow: false,
|
|
81
|
+
keyboard: false,
|
|
82
|
+
grow: '1'
|
|
83
|
+
}, /*#__PURE__*/ h('div', {
|
|
84
|
+
ref: at
|
|
85
|
+
}, /*#__PURE__*/ h(view, {
|
|
86
|
+
store
|
|
87
|
+
})));
|
|
88
|
+
};
|
|
89
|
+
/** Open the app at `page` (`https://yourname.yaks.app/packing/`), its store
|
|
90
|
+
* at `api`, every request through `go`, until the person quits. */ export let open = async (page, api, go = fetch)=>{
|
|
91
|
+
let at = await nativeOf(page, go);
|
|
92
|
+
if (!at) {
|
|
93
|
+
throw new Error(`${page} is not built on the kits: its page names no native view`);
|
|
94
|
+
}
|
|
95
|
+
let view = await appAt(at, go);
|
|
96
|
+
await run(()=>/*#__PURE__*/ h(Kit, {
|
|
97
|
+
view,
|
|
98
|
+
store: store(api, go)
|
|
99
|
+
}), {
|
|
100
|
+
sheet: sheet(composition)
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=kit.js.map
|
package/kit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kit.js","sources":["./kit.ts"],"names":[],"mappings":"AAAA;;;;;oCAKoC,GACpC,SAAS,MAAM,8BAAmC;AAClD,SAAS,OAAO,EAAE,OAAO,EAAE,KAAK,qCAA0C;AAC1E,uCAAuC,GAAG,YAAY,mBAA6B;AACnF,mDAAmD,GAAG,YAAY,6BAAuC;AACzG,YAAY,wBAA6B;AACzC,uCAAuC,GAAG,SAAS,iBAAiB,CAAC,EAAE,eAAe,EAAE,MAAM,gBAA0B;AACxH,SAAS,IAAI,EAAE,GAAG,EAAE,MAAM,EAAiB,OAAO,yBAA8B;AAChF,SAAS,WAAW,qCAA0C;AAC9D,SAAS,WAAW,EAAE,KAAK,wBAA6B;AACxD,SAEE,QAAQ,EAER,WAAW,EAEX,KAAK,mCACgC;AAEvC;oCACoC,GACpC,OAAO,IAAI,UAAmB;EAC5B,GAAG,OAAO;EACV;EACA,qBAAqB;EACrB,YAAY;AACd,EAAC;AAED,IAAI,SAAS;EACX,IAAI,OAAO,MAAM,OAAO,IAAI,IAAI,YAAY,OAAO,CAAC,cAAc,WAAW;IAC3E,OAAO;IACP,UAAU,OAAO,IAAI,CAAC,SAAS,MAAM,CAAC,CAAC,OAAS,KAAK,UAAU,CAAC;IAChE,QAAQ;EACV;EACA,IAAI,SAAS;IAAE,SAAS,CAAC;EAAE;EAC3B,IAAI,SAAS,WAAW,UAAU,WAAW,MAC3C,CAAC,OAAiB,OAAO,CAAC,KAAK,EAC/B,QACA,OAAO,OAAO;EAEhB,OAAO;IACL,GAAG,OAAO;IACV,YAAY,OAAO,OAAO;EAC5B;AACF;AAEA,IAAI;AACJ,OAAO,IAAI,QAAQ,OACjB,IACA;EAEA,IAAI,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AO,OAChB,MACA,KACA,KAAmB,KAAK;EAExB,IAAI,KAAK,MAAM,SAAS,MAAM;EAC9B,IAAI,CAAC,IAAI;IACP,MAAM,IAAI,MACR,GAAG,KAAK,wDAAwD,CAAC;EAErE;EACA,IAAI,OAAO,MAAM,MAAM,IAAI;EAC3B,MAAM,IAAI,kBAAM,EAAE,KAAK;MAAE;MAAM,OAAO,MAAM,KAAK;IAAI,IAAI;IACvD,OAAO,MAAM;EACf;AACF,EAAC"}
|
package/kit.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/** `yak open`: a kit-built yaks app in this terminal. The app's view is
|
|
2
|
+
* loaded from the app (@yaks/native/remote, as the iOS shell loads it),
|
|
3
|
+
* rendered into @yaks/tui's in-memory DOM and painted by its painter, over
|
|
4
|
+
* the app's own store on yaks.app. Tab walks its controls, a field takes what
|
|
5
|
+
* is typed, Enter and Space press, as @yaks/tui/interaction does for any
|
|
6
|
+
* page; `q` outside a field quits. */
|
|
7
|
+
import { bundle } from '@yaks/cli/page'
|
|
8
|
+
import { aliases, modules, paint } from '@yaks/preact/renderer'
|
|
9
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import * as react from 'react'
|
|
10
|
+
/* @ts-types="npm:@types/react@19.3.0/jsx-runtime" */ import * as jsx from 'react/jsx-runtime'
|
|
11
|
+
import * as ui from '@yaks/ui'
|
|
12
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, useLayoutEffect, useRef } from 'react'
|
|
13
|
+
import { quit, run, Scroll, type TElement, useKeys } from '@yaks/tui'
|
|
14
|
+
import { interaction } from '@yaks/tui/interaction'
|
|
15
|
+
import { composition, sheet } from '@yaks/ui'
|
|
16
|
+
import {
|
|
17
|
+
type Carried,
|
|
18
|
+
nativeOf,
|
|
19
|
+
type NativeView,
|
|
20
|
+
prepareView,
|
|
21
|
+
type Store,
|
|
22
|
+
store,
|
|
23
|
+
} from '@yaks/native/remote'
|
|
24
|
+
|
|
25
|
+
/** What a view loaded into this process imports its platform packages as:
|
|
26
|
+
* the copies @yaks/tui renders by. */
|
|
27
|
+
export let carried: Carried = {
|
|
28
|
+
...modules,
|
|
29
|
+
react,
|
|
30
|
+
'react/jsx-runtime': jsx,
|
|
31
|
+
'@yaks/ui': ui,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let legacy = async (): Promise<Carried> => {
|
|
35
|
+
let code = await bundle(new URL(import.meta.resolve('@yaks/ui')), undefined, {
|
|
36
|
+
alias: aliases,
|
|
37
|
+
external: Object.keys(modules).filter((name) => name.startsWith('preact')),
|
|
38
|
+
format: 'cjs',
|
|
39
|
+
})
|
|
40
|
+
let module = { exports: {} }
|
|
41
|
+
new Function('require', 'module', 'exports', code)(
|
|
42
|
+
(name: string) => modules[name],
|
|
43
|
+
module,
|
|
44
|
+
module.exports,
|
|
45
|
+
)
|
|
46
|
+
return {
|
|
47
|
+
...modules,
|
|
48
|
+
'@yaks/ui': module.exports,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let legacyKits: Promise<Carried> | undefined
|
|
53
|
+
export let appAt = async (
|
|
54
|
+
at: string,
|
|
55
|
+
go: typeof fetch,
|
|
56
|
+
): Promise<NativeView> => {
|
|
57
|
+
let app = await prepareView(at, go)
|
|
58
|
+
if (
|
|
59
|
+
!app.imports.some((name) => name == 'preact' || name.startsWith('preact/'))
|
|
60
|
+
) {
|
|
61
|
+
return app.open(carried)
|
|
62
|
+
}
|
|
63
|
+
let View = app.open(
|
|
64
|
+
await (legacyKits ??= legacy().catch((error) => {
|
|
65
|
+
legacyKits = undefined
|
|
66
|
+
throw error
|
|
67
|
+
})),
|
|
68
|
+
)
|
|
69
|
+
return ({ store }) => {
|
|
70
|
+
let root = useRef<HTMLDivElement>(null)
|
|
71
|
+
useLayoutEffect(() => paint(View, { store }, root.current!), [store])
|
|
72
|
+
return h('div', { ref: root })
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The app's view over its store, its controls walked by the keyboard, the
|
|
77
|
+
* first field in focus. */
|
|
78
|
+
export let Kit = ({ view, store }: { view: NativeView; store: Store }) => {
|
|
79
|
+
let at = useRef<TElement>(null)
|
|
80
|
+
let keys = useRef<ReturnType<typeof interaction> | null>(null)
|
|
81
|
+
useLayoutEffect(() => {
|
|
82
|
+
let root = at.current!
|
|
83
|
+
keys.current = interaction(root, () => {})
|
|
84
|
+
let field = root.querySelector('input,textarea')
|
|
85
|
+
if (field) keys.current.focus(field)
|
|
86
|
+
}, [])
|
|
87
|
+
useKeys((k) => {
|
|
88
|
+
let typing = keys.current?.active()?.matches('input,textarea')
|
|
89
|
+
if (!typing && k.name == 'char' && k.text == 'q' && !k.ctrl && !k.alt) {
|
|
90
|
+
quit()
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
93
|
+
return keys.current?.press(k) ?? false
|
|
94
|
+
})
|
|
95
|
+
return h(
|
|
96
|
+
Scroll,
|
|
97
|
+
{ id: 'kit', follow: false, keyboard: false, grow: '1' },
|
|
98
|
+
h('div', { ref: at }, h(view, { store })),
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Open the app at `page` (`https://yourname.yaks.app/packing/`), its store
|
|
103
|
+
* at `api`, every request through `go`, until the person quits. */
|
|
104
|
+
export let open = async (
|
|
105
|
+
page: string,
|
|
106
|
+
api: string,
|
|
107
|
+
go: typeof fetch = fetch,
|
|
108
|
+
): Promise<void> => {
|
|
109
|
+
let at = await nativeOf(page, go)
|
|
110
|
+
if (!at) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`${page} is not built on the kits: its page names no native view`,
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
let view = await appAt(at, go)
|
|
116
|
+
await run(() => h(Kit, { view, store: store(api, go) }), {
|
|
117
|
+
sheet: sheet(composition),
|
|
118
|
+
})
|
|
119
|
+
}
|
package/layout.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// Tiling layout gestures (D-14718), pure: each op reads the panes the
|
|
2
|
+
// caller already has and returns ONE flat Change[] — apply() runs it
|
|
3
|
+
// atomically, so a multi-pane edit never tears. No door talks to a cache
|
|
4
|
+
// or a socket here; the web view and the future TUI share this seam.
|
|
5
|
+
// Within a batch, reparents come BEFORE deletes: the reaper's doom-walk
|
|
6
|
+
// reads current rows, so a child moved first escapes its old parent's
|
|
7
|
+
// cascade.
|
|
8
|
+
import { uuid } from "./types.js";
|
|
9
|
+
let by = (panes, eid)=>panes.find((p)=>p.eid == eid);
|
|
10
|
+
// Siblings in paint order. The eid tiebreak keeps two panes minted with
|
|
11
|
+
// one order value stable across renders.
|
|
12
|
+
/// kids([{eid: 'b', parent: 'r', order: 1},
|
|
13
|
+
/// {eid: 'a', parent: 'r', order: 0}], 'r').map(p => p.eid)
|
|
14
|
+
/// -> ['a', 'b']
|
|
15
|
+
export let kids = (panes, parent)=>panes.filter((p)=>p.parent == parent).sort((a, b)=>(a.order ?? 0) - (b.order ?? 0) || (a.eid < b.eid ? -1 : 1));
|
|
16
|
+
let mint = (eid, comp)=>({
|
|
17
|
+
eid,
|
|
18
|
+
name: 'pane',
|
|
19
|
+
comp
|
|
20
|
+
});
|
|
21
|
+
// Split a pane. Along the surrounding dir it is ONE change — a new empty
|
|
22
|
+
// sibling at the pane's own weight, ordered between it and the next
|
|
23
|
+
// (weights renormalize at render, so nothing else moves). Across, the
|
|
24
|
+
// pane BECOMES the container: its content (or its old-dir children,
|
|
25
|
+
// hoisted under a new intermediate) moves down, an empty pane joins as
|
|
26
|
+
// the second child. The new pane is empty on purpose — it renders the
|
|
27
|
+
// palette.
|
|
28
|
+
export let split = (panes, eid, dir)=>{
|
|
29
|
+
let p = by(panes, eid);
|
|
30
|
+
if (!p) return [];
|
|
31
|
+
let parent = p.parent ? by(panes, p.parent) : undefined;
|
|
32
|
+
if (parent?.dir == dir) {
|
|
33
|
+
let sibs = kids(panes, parent.eid);
|
|
34
|
+
let next = sibs[sibs.findIndex((s)=>s.eid == eid) + 1];
|
|
35
|
+
let order = next ? ((p.order ?? 0) + (next.order ?? 0)) / 2 : (p.order ?? 0) + 1;
|
|
36
|
+
return [
|
|
37
|
+
mint(uuid(), {
|
|
38
|
+
layout: p.layout,
|
|
39
|
+
parent: parent.eid,
|
|
40
|
+
size: p.size ?? 1,
|
|
41
|
+
order
|
|
42
|
+
})
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
if (p.dir == dir) {
|
|
46
|
+
// A container split along its own axis: one more child at the end.
|
|
47
|
+
let last = kids(panes, eid).at(-1);
|
|
48
|
+
return [
|
|
49
|
+
mint(uuid(), {
|
|
50
|
+
layout: p.layout,
|
|
51
|
+
parent: eid,
|
|
52
|
+
size: last?.size ?? 1,
|
|
53
|
+
order: (last?.order ?? 0) + 1
|
|
54
|
+
})
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
let held = p.dir ? kids(panes, eid) : [];
|
|
58
|
+
let a = uuid();
|
|
59
|
+
return [
|
|
60
|
+
{
|
|
61
|
+
eid,
|
|
62
|
+
name: 'pane',
|
|
63
|
+
comp: {
|
|
64
|
+
dir,
|
|
65
|
+
content: null,
|
|
66
|
+
view: null
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
...held.map((k)=>mint(k.eid, {
|
|
70
|
+
parent: a
|
|
71
|
+
})),
|
|
72
|
+
mint(a, {
|
|
73
|
+
layout: p.layout,
|
|
74
|
+
parent: eid,
|
|
75
|
+
size: 1,
|
|
76
|
+
order: 0,
|
|
77
|
+
...p.dir ? {
|
|
78
|
+
dir: p.dir
|
|
79
|
+
} : {
|
|
80
|
+
content: p.content ?? null,
|
|
81
|
+
view: p.view ?? null
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
mint(uuid(), {
|
|
85
|
+
layout: p.layout,
|
|
86
|
+
parent: eid,
|
|
87
|
+
size: 1,
|
|
88
|
+
order: 1
|
|
89
|
+
})
|
|
90
|
+
];
|
|
91
|
+
};
|
|
92
|
+
// Close a pane: delete its entity — descendants cascade server-side, and
|
|
93
|
+
// the siblings' weights renormalize at render with no splice. When the
|
|
94
|
+
// parent goes unary the survivor hoists into it (content up, or dir +
|
|
95
|
+
// children up) and is deleted, so no container ever holds one child. The
|
|
96
|
+
// root never deletes — a layout always has a pane — it clears to empty.
|
|
97
|
+
export let close = (panes, eid)=>{
|
|
98
|
+
let p = by(panes, eid);
|
|
99
|
+
if (!p) return [];
|
|
100
|
+
if (!p.parent) {
|
|
101
|
+
return [
|
|
102
|
+
...kids(panes, eid).map((k)=>({
|
|
103
|
+
eid: k.eid,
|
|
104
|
+
name: 'entity',
|
|
105
|
+
comp: null
|
|
106
|
+
})),
|
|
107
|
+
{
|
|
108
|
+
eid,
|
|
109
|
+
name: 'pane',
|
|
110
|
+
comp: {
|
|
111
|
+
dir: null,
|
|
112
|
+
content: null,
|
|
113
|
+
view: null
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
let del = {
|
|
119
|
+
eid,
|
|
120
|
+
name: 'entity',
|
|
121
|
+
comp: null
|
|
122
|
+
};
|
|
123
|
+
let sibs = kids(panes, p.parent).filter((s)=>s.eid != eid);
|
|
124
|
+
if (sibs.length != 1) return [
|
|
125
|
+
del
|
|
126
|
+
];
|
|
127
|
+
let s = sibs[0];
|
|
128
|
+
let parent = p.parent;
|
|
129
|
+
return [
|
|
130
|
+
del,
|
|
131
|
+
...s.dir ? [
|
|
132
|
+
...kids(panes, s.eid).map((k)=>mint(k.eid, {
|
|
133
|
+
parent: parent
|
|
134
|
+
})),
|
|
135
|
+
mint(parent, {
|
|
136
|
+
dir: s.dir
|
|
137
|
+
})
|
|
138
|
+
] : [
|
|
139
|
+
mint(parent, {
|
|
140
|
+
dir: null,
|
|
141
|
+
content: s.content ?? null,
|
|
142
|
+
view: s.view ?? null
|
|
143
|
+
})
|
|
144
|
+
],
|
|
145
|
+
{
|
|
146
|
+
eid: s.eid,
|
|
147
|
+
name: 'entity',
|
|
148
|
+
comp: null
|
|
149
|
+
}
|
|
150
|
+
];
|
|
151
|
+
};
|
|
152
|
+
// The smallest weight a drag can leave — a pane never resizes to nothing
|
|
153
|
+
// (close is the gesture for that).
|
|
154
|
+
let MIN = 0.05;
|
|
155
|
+
// Transfer weight between two adjacent siblings: a grows by delta, b
|
|
156
|
+
// shrinks. Delta is in WEIGHT units — the caller converts pixels against
|
|
157
|
+
// the siblings' total. One batch on settle, never per pixel.
|
|
158
|
+
/// resize([{eid: 'a', parent: 'r', size: 1},
|
|
159
|
+
/// {eid: 'b', parent: 'r', size: 1}], 'a', 'b', 0.5)
|
|
160
|
+
/// -> [{eid: 'a', name: 'pane', comp: {size: 1.5}},
|
|
161
|
+
/// {eid: 'b', name: 'pane', comp: {size: 0.5}}]
|
|
162
|
+
export let resize = (panes, a, b, delta)=>{
|
|
163
|
+
let pa = by(panes, a);
|
|
164
|
+
let pb = by(panes, b);
|
|
165
|
+
if (!pa || !pb || pa.parent != pb.parent) return [];
|
|
166
|
+
let wa = pa.size ?? 1;
|
|
167
|
+
let wb = pb.size ?? 1;
|
|
168
|
+
let d = Math.max(Math.min(delta, wb - MIN), MIN - wa);
|
|
169
|
+
if (!d) return [];
|
|
170
|
+
// Rounded so a drag stores tidy weights, and a clamped edge lands ON
|
|
171
|
+
// the floor instead of a float hair above it.
|
|
172
|
+
let r4 = (n)=>Math.round(n * 1e4) / 1e4;
|
|
173
|
+
return [
|
|
174
|
+
mint(a, {
|
|
175
|
+
size: r4(wa + d)
|
|
176
|
+
}),
|
|
177
|
+
mint(b, {
|
|
178
|
+
size: r4(wb - d)
|
|
179
|
+
})
|
|
180
|
+
];
|
|
181
|
+
};
|
|
182
|
+
// Fill a leaf: what it shows and how. null clears back to empty.
|
|
183
|
+
export let setContent = (panes, eid, target, view)=>by(panes, eid) ? [
|
|
184
|
+
mint(eid, {
|
|
185
|
+
content: target,
|
|
186
|
+
view: view ?? null
|
|
187
|
+
})
|
|
188
|
+
] : [];
|
|
189
|
+
// Exchange two leaves' content — the panes keep their place and size.
|
|
190
|
+
export let swap = (panes, a, b)=>{
|
|
191
|
+
let pa = by(panes, a);
|
|
192
|
+
let pb = by(panes, b);
|
|
193
|
+
if (!pa || !pb) return [];
|
|
194
|
+
return [
|
|
195
|
+
mint(a, {
|
|
196
|
+
content: pb.content ?? null,
|
|
197
|
+
view: pb.view ?? null
|
|
198
|
+
}),
|
|
199
|
+
mint(b, {
|
|
200
|
+
content: pa.content ?? null,
|
|
201
|
+
view: pa.view ?? null
|
|
202
|
+
})
|
|
203
|
+
];
|
|
204
|
+
};
|
|
205
|
+
// A fresh layout in one batch: doc + layout + root. One leaf (or none)
|
|
206
|
+
// IS the root; more make the root an h-container with equal children.
|
|
207
|
+
export let mintLayout = (title, leaves = [])=>{
|
|
208
|
+
let eid = uuid();
|
|
209
|
+
let root = uuid();
|
|
210
|
+
let changes = [
|
|
211
|
+
{
|
|
212
|
+
eid,
|
|
213
|
+
name: 'doc',
|
|
214
|
+
comp: {
|
|
215
|
+
title,
|
|
216
|
+
body: ''
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
eid,
|
|
221
|
+
name: 'layout',
|
|
222
|
+
comp: {
|
|
223
|
+
root: root
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
...leaves.length < 2 ? [
|
|
227
|
+
mint(root, {
|
|
228
|
+
layout: eid,
|
|
229
|
+
...leaves[0] ?? {}
|
|
230
|
+
})
|
|
231
|
+
] : [
|
|
232
|
+
mint(root, {
|
|
233
|
+
layout: eid,
|
|
234
|
+
dir: 'h'
|
|
235
|
+
}),
|
|
236
|
+
...leaves.map((leaf, i)=>mint(uuid(), {
|
|
237
|
+
layout: eid,
|
|
238
|
+
parent: root,
|
|
239
|
+
size: 1,
|
|
240
|
+
order: i,
|
|
241
|
+
...leaf
|
|
242
|
+
}))
|
|
243
|
+
]
|
|
244
|
+
];
|
|
245
|
+
return {
|
|
246
|
+
eid,
|
|
247
|
+
changes
|
|
248
|
+
};
|
|
249
|
+
} // Deliberately absent: fork (the shared-layout copy is data the model
|
|
250
|
+
// already supports — the gesture lands with the palette phase, D-14718
|
|
251
|
+
// rollout 3) and any tree normalizer — every op above leaves the tree
|
|
252
|
+
// well-formed, so no renderer defends against a malformed one.
|
|
253
|
+
;
|
|
254
|
+
//# sourceMappingURL=layout.js.map
|
package/layout.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sources":["./layout.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,qEAAqE;AACrE,yEAAyE;AACzE,qEAAqE;AACrE,wEAAwE;AACxE,sEAAsE;AACtE,WAAW;AACX,SAAiC,IAAI,qBAAoB;AAIzD,IAAI,KAAK,CAAC,OAAe,MAAgB,MAAM,IAAI,CAAC,CAAC,IAAM,EAAE,GAAG,IAAI;AAEpE,wEAAwE;AACxE,yCAAyC;AACzC,4CAA4C;AAC5C,kEAAkE;AAClE,mBAAmB;AACnB,OAAO,IAAI,OAAO,CAAC,OAAe,SAChC,MAAM,MAAM,CAAC,CAAC,IAAM,EAAE,MAAM,IAAI,QAC7B,IAAI,CAAC,CAAC,GAAG,IAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,GAAE;AAEhF,IAAI,OAAO,CAAC,KAAa,OAA0C,CAAC;IAClE;IACA,MAAM;IACN;EACF,CAAC;AAED,yEAAyE;AACzE,oEAAoE;AACpE,sEAAsE;AACtE,oEAAoE;AACpE,uEAAuE;AACvE,sEAAsE;AACtE,WAAW;AACX,OAAO,IAAI,QAAQ,CAAC,OAAe,KAAa;EAC9C,IAAI,IAAI,GAAG,OAAO;EAClB,IAAI,CAAC,GAAG,OAAO,EAAE;EACjB,IAAI,SAAS,EAAE,MAAM,GAAG,GAAG,OAAO,EAAE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