@abide/abide 0.101.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 (157) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/bin/abide.ts +223 -164
  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 +5 -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 -59
  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 +102 -30
  53. package/src/server/answerSocket.ts +65 -20
  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 +4 -4
  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 +114 -181
  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 +73 -37
  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/RESERVED_DIRECTORIES.ts +15 -0
  107. package/src/shared/cookies.ts +2 -2
  108. package/src/shared/csp.ts +1 -1
  109. package/src/shared/escapeText.ts +1 -1
  110. package/src/shared/filledPath.ts +85 -0
  111. package/src/shared/framing.ts +79 -6
  112. package/src/shared/headKeyOf.ts +2 -0
  113. package/src/shared/index.ts +1 -1
  114. package/src/shared/log.ts +27 -13
  115. package/src/shared/matchRoute.ts +23 -4
  116. package/src/shared/menuItem.ts +3 -3
  117. package/src/shared/reactive/Keyed.ts +2 -2
  118. package/src/shared/reactive/NotLanded.ts +1 -1
  119. package/src/shared/reactive/Reactive.ts +43 -43
  120. package/src/shared/reactive/argsContract.ts +4 -4
  121. package/src/shared/reactive/canonicalKey.ts +4 -4
  122. package/src/shared/reactive/chunksOfStream.ts +6 -0
  123. package/src/shared/reactive/index.ts +1 -1
  124. package/src/shared/reactive/recordWrites.ts +103 -5
  125. package/src/shared/reactive/structural.ts +1 -1
  126. package/src/shared/reactive/tracking.ts +1 -1
  127. package/src/shared/reactive/watch.ts +3 -3
  128. package/src/shared/refuse.ts +1 -1
  129. package/src/shared/routePattern.ts +82 -46
  130. package/src/shared/rpc.ts +37 -8
  131. package/src/shared/rpcRequest.ts +27 -3
  132. package/src/shared/url.ts +4 -44
  133. package/src/shared/writePath.ts +1 -1
  134. package/src/ui/LAYER_NAMES.ts +1 -1
  135. package/src/ui/List.ts +3 -3
  136. package/src/ui/MOUNTING_LEVEL.ts +18 -0
  137. package/src/ui/Mismatch.ts +1 -1
  138. package/src/ui/RawRun.ts +1 -1
  139. package/src/ui/Router.ts +38 -31
  140. package/src/ui/Scope.ts +1 -1
  141. package/src/ui/TryRegion.ts +2 -2
  142. package/src/ui/applyHead.ts +33 -0
  143. package/src/ui/index.ts +1 -1
  144. package/src/ui/menuBridge.ts +1 -1
  145. package/src/ui/moveNode.ts +1 -1
  146. package/src/ui/reconcile.ts +2 -2
  147. package/src/ui/reportMenu.ts +2 -2
  148. package/src/ui/routing.ts +2 -2
  149. package/src/ui/setAttribute.ts +1 -1
  150. package/src/ui/setText.ts +1 -1
  151. package/src/ui/socketWire.ts +9 -7
  152. package/src/ui/wire.ts +1 -1
  153. package/scaffold/src/server/app.ts +0 -6
  154. package/scaffold/src/shared/.gitkeep +0 -0
  155. package/scaffold/src/ui/app.html +0 -8
  156. package/src/server/componentImports.ts +0 -56
  157. /package/scaffold/src/{ui/pages/page.abide → page.abide} +0 -0
@@ -1,10 +1,17 @@
1
1
  import type { CheckerAnswer } from './CheckerAnswer.ts'
2
2
  import type { Finding } from './Finding.ts'
3
- import { CHECKED_VALUES, CHECKED_WRITE, Lowering } from './Lowering.ts'
3
+ import {
4
+ CHECKED_CONFIG,
5
+ CHECKED_CONFIG_OF,
6
+ CHECKED_VALUES,
7
+ CHECKED_WRITE,
8
+ Lowering,
9
+ } from './Lowering.ts'
4
10
  import { holdsReactive } from './PositionTable.ts'
5
11
  import type { AbideFile } from './parseAbide.ts'
6
12
  import { NO_PROPS, type Origin, type Span } from './projectShadow.ts'
7
13
  import { CHECKED_SUFFIX } from './ShadowMap.ts'
14
+ import { SERVER_SPECIFIER } from './SPECIFIERS.ts'
8
15
  import { abideImports } from './splitImports.ts'
9
16
 
10
17
  // 38.3 — A `.abide` FILE AS THE PROGRAM IT RUNS AS, for the checker to report on. The projection
@@ -18,7 +25,7 @@ import { abideImports } from './splitImports.ts'
18
25
  //
19
26
  // A `.abide` IMPORT NAMES ITS CHECKED MODULE, so a component a page imports resolves to something
20
27
  // the checker can read rather than to a file it cannot parse. What a checked module exports as its
21
- // default is a component taking what its `props` call declares, so a tag is held to it (38.41).
28
+ // default is a component taking what its `props` call declares, so a tag is held to it (38.40).
22
29
 
23
30
  /** A `.abide` lowered as the program it runs as, with its runs mapped back to the projection. */
24
31
  export type CheckedShadow = {
@@ -35,15 +42,16 @@ export type CheckedShadow = {
35
42
  export const COMPONENT_STAND_IN = '__component'
36
43
 
37
44
  /**
38
- * The whole of what a checked module exports, and so all a module importing one sees of it: a
39
- * component, called with the record its tag passes (`projectShadow`'s `invocation`).
45
+ * The component a checked module exports as its default: called with the record its tag passes
46
+ * (`projectShadow`'s `invocation`), and answering the `Component` a server module's call of it
47
+ * renders (34.16). What its blocks export by name is beside it.
40
48
  */
41
49
  function componentModule(props: string, generics?: string): string {
42
50
  // 34.13 — generic over what the file's `<script>` declares, so a caller's props infer it, the
43
51
  // signature's own parameters shadowing the opaque stand-ins the body was checked against.
44
52
  const parameters = generics === undefined ? '' : `<${generics}>`
45
53
  return `
46
- declare const ${COMPONENT_STAND_IN}: ${parameters}(record: ${props}) => void
54
+ declare const ${COMPONENT_STAND_IN}: ${parameters}(record: ${props}) => import('${SERVER_SPECIFIER}').Component
47
55
  export default ${COMPONENT_STAND_IN}
48
56
  `
49
57
  }
@@ -61,6 +69,7 @@ export function checkedShadow(
61
69
  // Every span the emitters lower, with whether it holds the `Reactive` rather than reading it.
62
70
  const units: { span: Span; holds: boolean }[] = [
63
71
  { span: projection.modules, holds: false },
72
+ { span: projection.servers, holds: false },
64
73
  { span: projection.scripts, holds: false },
65
74
  ]
66
75
  for (const span of projection.slots.values())
@@ -101,6 +110,7 @@ export function checkedShadow(
101
110
  }\n`
102
111
  text += `declare const ${CHECKED_VALUES}: {\n${values}}\n`
103
112
  text += `declare function ${CHECKED_WRITE}<Cell extends { (): unknown; set(value: never): unknown }, Value extends Parameters<Cell['set']>[0]>(cell: Cell, value: Value): Value extends ReturnType<Cell> ? Value : ReturnType<Cell>\n`
113
+ text += configDeclarations(lowering)
104
114
  return {
105
115
  ...pointAtCheckedModules(text, origins, scriptsEnd),
106
116
  refusals: lowering.refusals,
@@ -123,6 +133,30 @@ function propsOf(lowering: Lowering): string {
123
133
  .replace(/\(\s*\)$/, '')}>`
124
134
  }
125
135
 
136
+ /**
137
+ * 27.13 — WHAT EACH `onConfig` DEFAULTS IS DECLARED INTO `Config`, so `config().RETRIES` is the
138
+ * `number` its defaults return rather than the index's `unknown`. Each call is bound by the lowering
139
+ * (`CHECKED_CONFIG`) and typed by `CHECKED_CONFIG_OF` as what its defaults return; an interface can
140
+ * only extend a name, so each is aliased, and a union is narrowed to the keys every member has.
141
+ * Nothing where the file files none.
142
+ */
143
+ function configDeclarations(lowering: Lowering): string {
144
+ let aliases = ''
145
+ let names = ''
146
+ for (const read of lowering.answer.reads) {
147
+ if (read.shape !== 'config') continue
148
+ const name = `${CHECKED_CONFIG}${read.start}`
149
+ aliases += `type ${name}Type = typeof ${name}\n`
150
+ names += names === '' ? `${name}Type` : `, ${name}Type`
151
+ }
152
+ if (names === '') return ''
153
+ return `declare function ${CHECKED_CONFIG_OF}<Options>(on: (defaults: never, options?: Options) => () => void): <Defaults>(defaults: ((env: import('${SERVER_SPECIFIER}').Env) => Defaults) | null, options?: Options) => [Defaults] extends [object] ? Pick<Defaults, keyof Defaults> : {}
154
+ ${aliases}declare module '${SERVER_SPECIFIER}' {
155
+ interface Config extends ${names} {}
156
+ }
157
+ `
158
+ }
159
+
126
160
  /**
127
161
  * Points each `.abide` import in the script blocks at its checked module, and moves `origins` to
128
162
  * match.
@@ -27,10 +27,11 @@ import { REACTIVE_MEMBERS } from './REACTIVE_MEMBERS.ts'
27
27
  * statement ends and whether `{ n }` is a literal are TypeScript's answers rather than a token
28
28
  * walk's guess at them. Every offset is into the file's projection (`projectShadow`).
29
29
  *
30
- * ONE SHAPE IS NOT A REACTIVE NAME: `raw` is the callee of a template expression's bare `raw(…)`
31
- * (32.25), which lowers to the framework's own `raw`; a `<script>`'s is left as written. It rides
32
- * this list because it is a rewrite at an occurrence, which is what the splice walks; what the
33
- * checker proved about a whole position is `CheckerAnswer`'s.
30
+ * TWO SHAPES ARE NOT A REACTIVE NAME: `raw` is the callee of a template expression's bare `raw(…)`
31
+ * (32.25), which lowers to the framework's own `raw`; a `<script>`'s is left as written. `config`
32
+ * is the callee of an `onConfig(…)` statement in a `<script server>` (27.13), which only a checked
33
+ * lowering rewrites. They ride this list because each is a rewrite at an occurrence, which is what
34
+ * the splice walks; what the checker proved about a whole position is `CheckerAnswer`'s.
34
35
  *
35
36
  * THE SHAPE IS FIXED: every field on every read, so `Lowering`'s splice sees one hidden class.
36
37
  */
@@ -69,6 +70,7 @@ export type Read = {
69
70
  | 'restMember'
70
71
  | 'restWhole'
71
72
  | 'raw'
73
+ | 'config'
72
74
  /** What the rewrite replaces: the name, or a whole write or update from its first token. */
73
75
  from: number
74
76
  to: number
@@ -132,7 +132,7 @@ export function classifyAttributes(
132
132
  // 32.10, 32.19 — THE PLAIN `style={expr}` OR `class={expr}` BESIDE A DIRECTIVE IS LEFT
133
133
  // UNBOUND. `setAttribute` replaces the whole merged value and takes the directives'
134
134
  // halves with it, and the two bindings then overwrite each other in whichever order
135
- // they re-ran.
135
+ // they reran.
136
136
  //
137
137
  // ALLOWED, rather than refused. The page still RENDERS right — the server writes both
138
138
  // halves into the one merged attribute — so the only thing a build error would buy is