@abide/abide 0.100.0 → 0.102.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/bin/abide.ts +227 -163
  3. package/docs/REGISTRY.md +726 -0
  4. package/docs/RULEBOOK.md +2753 -0
  5. package/docs/abide.md +12878 -0
  6. package/package.json +10 -3
  7. package/scaffold/AGENTS.md +31 -0
  8. package/scaffold/CLAUDE.md +1 -0
  9. package/scaffold/src/layout.abide +18 -0
  10. package/src/compiler/Lowering.ts +78 -9
  11. package/src/compiler/ShadowMap.ts +2 -2
  12. package/src/compiler/TypeSession.ts +262 -67
  13. package/src/compiler/argsSchemaOf.ts +1 -1
  14. package/src/compiler/checkApp.ts +43 -15
  15. package/src/compiler/checkedShadow.ts +39 -5
  16. package/src/compiler/classifyRead.ts +6 -4
  17. package/src/compiler/classifyTemplate.ts +1 -1
  18. package/src/compiler/compileApp.ts +433 -193
  19. package/src/compiler/compiledEntry.ts +43 -39
  20. package/src/compiler/componentGraph.ts +58 -71
  21. package/src/compiler/declaredExports.ts +24 -7
  22. package/src/compiler/emitClient.ts +141 -71
  23. package/src/compiler/emitComponent.ts +37 -8
  24. package/src/compiler/emitSource.ts +106 -13
  25. package/src/compiler/handlersUnder.ts +106 -56
  26. package/src/compiler/index.ts +7 -0
  27. package/src/compiler/mountsOf.ts +138 -0
  28. package/src/compiler/nearest.ts +14 -0
  29. package/src/compiler/parseAbide.ts +157 -20
  30. package/src/compiler/projectShadow.ts +213 -7
  31. package/src/compiler/reactiveTypes.ts +20 -7
  32. package/src/compiler/readSources.ts +15 -2
  33. package/src/compiler/readsIn.ts +61 -7
  34. package/src/compiler/renderMarkup.ts +3 -3
  35. package/src/compiler/scaffold.ts +30 -11
  36. package/src/compiler/serveLanguage.ts +125 -34
  37. package/src/compiler/sourceMapOf.ts +193 -0
  38. package/src/compiler/splitImports.ts +205 -83
  39. package/src/compiler/syncTypes.ts +32 -0
  40. package/src/compiler/tokenize.ts +14 -0
  41. package/src/compiler/writeDefaultProject.ts +1 -1
  42. package/src/compiler/writeTypes.ts +82 -0
  43. package/src/server/CLIENT_BUILD.ts +11 -13
  44. package/src/server/DEFAULT_PORT.ts +1 -1
  45. package/src/server/LAUNCHER_FILES.ts +9 -0
  46. package/src/server/MODULE_QUERIES.ts +18 -0
  47. package/src/server/TABLES.ts +7 -0
  48. package/src/server/VIRTUAL_DIRECTORY.ts +4 -5
  49. package/src/server/abideModules.ts +391 -0
  50. package/src/server/answerFailure.ts +16 -6
  51. package/src/server/answerRequest.ts +235 -106
  52. package/src/server/answerRpc.ts +124 -39
  53. package/src/server/answerSocket.ts +141 -48
  54. package/src/server/answerValue.ts +22 -9
  55. package/src/server/appDirectories.ts +1 -1
  56. package/src/server/appPlugins.ts +1 -1
  57. package/src/server/appTree.ts +179 -0
  58. package/src/server/argsFor.ts +2 -2
  59. package/src/server/assistant.ts +2 -2
  60. package/src/server/bridgeRelay.ts +6 -8
  61. package/src/server/claudeCode.ts +0 -6
  62. package/src/server/clientBuildOptions.ts +8 -3
  63. package/src/server/coerceArgs.ts +1 -1
  64. package/src/server/commands.ts +37 -37
  65. package/src/server/componentModules.d.ts +3 -1
  66. package/src/server/compressAnswer.ts +48 -14
  67. package/src/server/config.ts +25 -29
  68. package/src/server/configFields.ts +31 -25
  69. package/src/server/createApp.ts +59 -73
  70. package/src/server/devWorker.ts +144 -183
  71. package/src/server/executableName.ts +4 -0
  72. package/src/server/fenceServer.ts +37 -35
  73. package/src/server/generatedSurfaces.ts +99 -66
  74. package/src/server/hooks.ts +124 -52
  75. package/src/server/iconAccent.ts +191 -0
  76. package/src/server/index.ts +11 -7
  77. package/src/server/installSourceMaps.ts +88 -0
  78. package/src/server/launcherOptions.ts +34 -31
  79. package/src/server/launcherPage.ts +107 -64
  80. package/src/server/manifestOf.ts +16 -13
  81. package/src/server/namesUnder.ts +2 -2
  82. package/src/server/nativeMenu.ts +5 -5
  83. package/src/server/negotiateEncoding.ts +1 -1
  84. package/src/server/principal.ts +10 -5
  85. package/src/server/realOrAsGiven.ts +10 -0
  86. package/src/server/refuseAddressCollision.ts +21 -14
  87. package/src/server/remote.ts +49 -52
  88. package/src/server/render.ts +65 -94
  89. package/src/server/renderComponent.ts +5 -0
  90. package/src/server/reportHealth.ts +2 -2
  91. package/src/server/requestScope.ts +12 -1
  92. package/src/server/runBuild.ts +24 -0
  93. package/src/server/runCompiled.ts +5 -5
  94. package/src/server/runDesktop.ts +52 -27
  95. package/src/server/serveBuild.ts +43 -52
  96. package/src/server/serveDev.ts +81 -39
  97. package/src/server/shell.ts +7 -22
  98. package/src/server/sourceMappings.ts +139 -0
  99. package/src/server/surfaceOf.ts +18 -3
  100. package/src/server/testBuild.ts +1 -19
  101. package/src/server/withAbideSources.ts +117 -0
  102. package/src/shared/ADDRESSES.ts +7 -18
  103. package/src/shared/APP_META.ts +7 -0
  104. package/src/shared/CopyOptions.ts +1 -1
  105. package/src/shared/DEBUG_META.ts +1 -1
  106. package/src/shared/GLOBAL_GETS.ts +9 -3
  107. package/src/shared/RESERVED_DIRECTORIES.ts +15 -0
  108. package/src/shared/RPC_SERVER.ts +2 -2
  109. package/src/shared/cookies.ts +2 -2
  110. package/src/shared/csp.ts +1 -1
  111. package/src/shared/escapeText.ts +1 -1
  112. package/src/shared/filledPath.ts +85 -0
  113. package/src/shared/framing.ts +79 -6
  114. package/src/shared/headKeyOf.ts +2 -0
  115. package/src/shared/index.ts +1 -1
  116. package/src/shared/log.ts +27 -13
  117. package/src/shared/matchRoute.ts +23 -4
  118. package/src/shared/menuItem.ts +3 -3
  119. package/src/shared/reactive/Cursor.ts +3 -9
  120. package/src/shared/reactive/Keyed.ts +4 -3
  121. package/src/shared/reactive/NotLanded.ts +1 -1
  122. package/src/shared/reactive/Reactive.ts +81 -60
  123. package/src/shared/reactive/argsContract.ts +4 -4
  124. package/src/shared/reactive/canonicalKey.ts +4 -4
  125. package/src/shared/reactive/chunksOfStream.ts +6 -0
  126. package/src/shared/reactive/index.ts +1 -1
  127. package/src/shared/reactive/recordWrites.ts +103 -5
  128. package/src/shared/reactive/structural.ts +1 -1
  129. package/src/shared/reactive/tracking.ts +155 -21
  130. package/src/shared/reactive/watch.ts +10 -6
  131. package/src/shared/refuse.ts +1 -1
  132. package/src/shared/routePattern.ts +82 -46
  133. package/src/shared/rpc.ts +47 -13
  134. package/src/shared/rpcRequest.ts +27 -3
  135. package/src/shared/url.ts +4 -44
  136. package/src/shared/writePath.ts +1 -1
  137. package/src/ui/LAYER_NAMES.ts +1 -1
  138. package/src/ui/List.ts +3 -3
  139. package/src/ui/MOUNTING_LEVEL.ts +18 -0
  140. package/src/ui/Mismatch.ts +1 -1
  141. package/src/ui/RawRun.ts +1 -1
  142. package/src/ui/Router.ts +38 -31
  143. package/src/ui/Scope.ts +1 -1
  144. package/src/ui/TryRegion.ts +2 -2
  145. package/src/ui/applyHead.ts +33 -0
  146. package/src/ui/index.ts +1 -1
  147. package/src/ui/menuBridge.ts +1 -1
  148. package/src/ui/moveNode.ts +1 -1
  149. package/src/ui/reconcile.ts +2 -2
  150. package/src/ui/reportMenu.ts +2 -2
  151. package/src/ui/routing.ts +2 -2
  152. package/src/ui/setAttribute.ts +1 -1
  153. package/src/ui/setText.ts +1 -1
  154. package/src/ui/socketWire.ts +9 -7
  155. package/src/ui/wire.ts +1 -1
  156. package/scaffold/src/server/app.ts +0 -6
  157. package/scaffold/src/shared/.gitkeep +0 -0
  158. package/scaffold/src/ui/app.html +0 -8
  159. package/src/server/componentImports.ts +0 -56
  160. /package/scaffold/src/{ui/pages/page.abide → page.abide} +0 -0
@@ -55,8 +55,18 @@ function walk(
55
55
  if (index === segments.length)
56
56
  return prefix || at === parts.length ? {} : null
57
57
  const segment = segments[index] as Segment
58
- // 30.5 — A REST TAKES WHAT IS LEFT, including nothing, and it is last by construction.
59
- if (segment.kind === 'rest') return { [segment.name]: parts.slice(at) }
58
+ // 30.5 — A REST TAKES THE MOST THE SEGMENTS AFTER IT LEAVE, nothing included, so a handler's
59
+ // name after one (`/docs/[...path]/save`) is reached rather than spent on the rest.
60
+ if (segment.kind === 'rest') {
61
+ for (let end = parts.length; end >= at; end -= 1) {
62
+ const params = walk(segments, index + 1, parts, end, prefix)
63
+ if (params !== null) {
64
+ params[segment.name] = parts.slice(at, end)
65
+ return params
66
+ }
67
+ }
68
+ return null
69
+ }
60
70
  const part = parts[at]
61
71
  if (segment.kind === 'optional') {
62
72
  if (part !== undefined) {
@@ -80,8 +90,9 @@ function walk(
80
90
  * The first route whose pattern matches `parts`, with its params, or `undefined`.
81
91
  *
82
92
  * 30.9 — THE FIRST PATTERN THAT MATCHES WINS, over a table already ranked most-specific-first.
83
- * BOTH SEAMS WALK THIS ONE. The server resolving an address and the client router resolving the
84
- * same one is the isomorphism 30.8 rests on.
93
+ * The client router resolves through this, and the server walks the same ranked table with
94
+ * `matchOf`, passing a route with no answer for the method asked. The two resolving one address
95
+ * alike is the isomorphism 30.8 rests on.
85
96
  *
86
97
  * Walked rather than compiled to a regex: a route table is matched once per navigation, so the
87
98
  * walk is never the cost, and a regex would have to encode three segment kinds in a grammar nobody
@@ -97,3 +108,11 @@ export function firstMatch<T extends { segments: Segment[] }>(
97
108
  }
98
109
  return undefined
99
110
  }
111
+
112
+ /** The params `segments` match the whole of `parts` with, or `undefined` where they do not. */
113
+ export function matchOf(
114
+ segments: Segment[],
115
+ parts: string[],
116
+ ): Params | undefined {
117
+ return walk(segments, 0, parts, 0, false) ?? undefined
118
+ }
@@ -1,8 +1,8 @@
1
- // 38.89 — THE DESKTOP APP'S MENU BAR IS THE ROUTE'S: a layout or a page exports `menu` from its
1
+ // 38.88 — THE DESKTOP APP'S MENU BAR IS THE ROUTE'S: a layout or a page exports `menu` from its
2
2
  // `<script module>`, and the window shows what the route it stands on exports. An item made by
3
3
  // `menuItem` is one a page answers; the rest are an address or a role, which need no page.
4
4
 
5
- /** What a menu item does natively, where an address or a page's own answer could not. 38.90. */
5
+ /** What a menu item does natively, where an address or a page's own answer could not. 38.89. */
6
6
  export type MenuRole =
7
7
  | 'about'
8
8
  | 'hide'
@@ -37,7 +37,7 @@ export type MenuItem =
37
37
  items?: MenuItem[]
38
38
  }
39
39
 
40
- /** An item a page answers: each function `on` filed runs when it is picked. 38.92. */
40
+ /** An item a page answers: each function `on` filed runs when it is picked. 38.91. */
41
41
  export class MenuEntry {
42
42
  label: string
43
43
  key: string | undefined
@@ -8,13 +8,13 @@
8
8
  // cursor reads is a handful of fields, and naming them keeps the cell's internals out of a
9
9
  // second file.
10
10
 
11
+ import { PATCHES } from './PATCHES.ts'
11
12
  import {
12
13
  dropReader,
13
14
  newSubscriber,
14
15
  type Subscriber,
15
16
  type Tracked,
16
17
  } from './tracking.ts'
17
- import { PATCHES } from './PATCHES.ts'
18
18
 
19
19
  /**
20
20
  * What a cursor reads, and all of a cell the server is handed (`servedCellOf`).
@@ -22,15 +22,10 @@ import { PATCHES } from './PATCHES.ts'
22
22
  * `ring[index]` carries ordinal `ringBase + index + 1`, so a cursor holding an ordinal finds its
23
23
  * place in a stream's chunk buffer without the buffer having to hold one.
24
24
  */
25
- export type Retained = {
25
+ export type Retained = Tracked & {
26
26
  /** The window a `throttle` or a `debounce` holds open, `holding` while a production waits on it. */
27
27
  cap: { holding: boolean } | null
28
28
  ordinal: number
29
- /**
30
- * Unused by a cursor and declared so a `Cell` still satisfies `Tracked`, which a cursor's
31
- * subscriber is registered through.
32
- */
33
- probeReaders: Subscriber[]
34
29
  ring: unknown[]
35
30
  ringBase: number
36
31
  servable: boolean
@@ -41,7 +36,6 @@ export type Retained = {
41
36
  */
42
37
  stream: object | null
43
38
  value: unknown
44
- readers: Subscriber[]
45
39
  }
46
40
 
47
41
  // The cursors standing over each source, for a patch to keep the place of the ones behind (5.7).
@@ -118,7 +112,7 @@ export class Cursor implements AsyncIterator<unknown> {
118
112
  // reader in the graph carries for the sake of the few that are cursors.
119
113
  // Registered outside the tracking protocol, so the source it waits on is declared
120
114
  // rather than discovered — see the same shape in `Reactive`'s `settled`.
121
- this.reader = newSubscriber([source as unknown as Tracked], null)
115
+ this.reader = newSubscriber([source], null)
122
116
  // One production per waiting turn, in the order they were asked for: a burst that
123
117
  // lands three productions on a consumer holding two turns answers both.
124
118
  this.reader.notify = (): void => {
@@ -12,7 +12,7 @@ import type { Schema } from '../Schema.ts'
12
12
  import {
13
13
  ARGS_GATE,
14
14
  type Gated,
15
- normalised,
15
+ normalized,
16
16
  PARAMETER_DEFAULTS,
17
17
  } from './argsContract.ts'
18
18
  import { CELL } from './CELL.ts'
@@ -40,6 +40,7 @@ import {
40
40
  detachProbes,
41
41
  dropReader,
42
42
  newSubscriber,
43
+ newTracked,
43
44
  type Subscriber,
44
45
  TRACKING,
45
46
  type Tracked,
@@ -332,7 +333,7 @@ export function createKeyed<
332
333
  // entry's probe carries it: a guard asked before a key was reached subscribed to the entries
333
334
  // there were, so the key that starts loading next — search-as-you-type — never woke it. One
334
335
  // signal per `Keyed`, moved where an entry is reached and where one is released.
335
- const membership: Tracked = { readers: [], probeReaders: [] }
336
+ const membership = newTracked()
336
337
 
337
338
  function askMembership(): void {
338
339
  const reader = TRACKING.reader
@@ -351,7 +352,7 @@ export function createKeyed<
351
352
  }
352
353
 
353
354
  function reach(given: Args): Reactive<Stored, Accepted, Failures> {
354
- const args = normalised(self, given)
355
+ const args = normalized(self, given)
355
356
  const key = canonicalKey(args)
356
357
  const standing = entries.get(key)
357
358
  // 1.8: reaching an instance that exists joins the standing work — 15.19, unless that work
@@ -2,7 +2,7 @@
2
2
  * What a read throws where nothing has landed.
3
3
  *
4
4
  * RULEBOOK 2.2. It carries the value it was thrown FOR, and that is the whole mechanism behind the
5
- * abort: a tracked body that meets one subscribes to `source` and re-runs when it lands, so the
5
+ * abort: a tracked body that meets one subscribes to `source` and reruns when it lands, so the
6
6
  * body never computes against an absent value and never takes the wrong branch. The
7
7
  * privileged-call hazard is what that buys — a body run to completion against an unlanded read
8
8
  * issues the else arm's call for a caller nothing has authenticated.