@abide/abide 0.123.2 → 0.124.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 (150) hide show
  1. package/ABIDE.md +8 -5
  2. package/CHANGELOG.md +58 -0
  3. package/bin/abide.ts +36 -65
  4. package/docs/REGISTRY.md +45 -12
  5. package/docs/RULEBOOK.md +24 -14
  6. package/docs/abide.md +999 -459
  7. package/package.json +1 -1
  8. package/src/compiler/ARRAY_MUTATORS.ts +20 -0
  9. package/src/compiler/Diagnostics.ts +198 -0
  10. package/src/compiler/KeptChecker.ts +97 -0
  11. package/src/compiler/LoweredFile.ts +609 -0
  12. package/src/compiler/Lowering.ts +18 -1
  13. package/src/compiler/PositionedRefusal.ts +1 -1
  14. package/src/compiler/SHARED_NAMES.ts +2 -0
  15. package/src/compiler/ShadowHost.ts +670 -0
  16. package/src/compiler/ShadowMap.ts +1 -1
  17. package/src/compiler/TypeSession.ts +76 -1743
  18. package/src/compiler/appLayout.ts +28 -20
  19. package/src/compiler/appLints.ts +109 -0
  20. package/src/compiler/argsDefaultsIn.ts +1 -1
  21. package/src/compiler/checkApp.ts +64 -68
  22. package/src/compiler/checkedShadow.ts +2 -2
  23. package/src/compiler/classifyRead.ts +16 -1
  24. package/src/compiler/compileApp.ts +102 -71
  25. package/src/compiler/declaredExports.ts +46 -21
  26. package/src/compiler/diagnoseSources.ts +232 -0
  27. package/src/compiler/emitClient.ts +1 -1
  28. package/src/compiler/formatAbide.ts +7 -8
  29. package/src/compiler/handlersUnder.ts +32 -63
  30. package/src/compiler/lineOf.ts +0 -19
  31. package/src/compiler/matchersOf.ts +3 -3
  32. package/src/compiler/mountsOf.ts +3 -3
  33. package/src/compiler/reactiveReads.ts +235 -0
  34. package/src/compiler/reactiveTypes.ts +13 -0
  35. package/src/compiler/readSources.ts +16 -18
  36. package/src/compiler/readsIn.ts +181 -82
  37. package/src/compiler/routesDeclaration.ts +46 -0
  38. package/src/compiler/scaffold.ts +7 -2
  39. package/src/compiler/serveLanguage.ts +46 -74
  40. package/src/compiler/sharedModuleWrites.ts +1 -1
  41. package/src/compiler/splitImports.ts +2 -2
  42. package/src/compiler/templateWarnings.ts +1 -2
  43. package/src/compiler/trackingWarnings.ts +1 -1
  44. package/src/server/CLIENT_BUILD.ts +4 -32
  45. package/src/server/DesktopSession.ts +213 -0
  46. package/src/server/Followers.ts +399 -0
  47. package/src/server/MODULE_QUERIES.ts +6 -2
  48. package/src/server/PageRender.ts +201 -0
  49. package/src/server/RESUME_MILLISECONDS.ts +2 -0
  50. package/src/server/abideModules.ts +7 -7
  51. package/src/server/answerFailure.ts +3 -2
  52. package/src/server/answerRequest.ts +16 -369
  53. package/src/server/answerRpc.ts +48 -302
  54. package/src/server/answerSocket.ts +41 -490
  55. package/src/server/appBuild.ts +377 -0
  56. package/src/server/appKit.ts +1 -1
  57. package/src/server/appPlugins.ts +15 -17
  58. package/src/server/appTree.ts +6 -5
  59. package/src/server/argsContract.ts +209 -0
  60. package/src/server/bridgeRelay.ts +153 -65
  61. package/src/server/claudeCode.ts +30 -127
  62. package/src/server/config.ts +6 -7
  63. package/src/server/createApp.ts +38 -66
  64. package/src/server/csp.ts +1 -1
  65. package/src/server/deferredBuilds.ts +3 -16
  66. package/src/server/devWorker.ts +11 -15
  67. package/src/server/faceOf.ts +1 -1
  68. package/src/server/generatedSurfaces.ts +2 -1
  69. package/src/server/handlerFileMount.ts +40 -0
  70. package/src/server/index.ts +3 -3
  71. package/src/server/installServer.ts +5 -9
  72. package/src/server/invokeHandler.ts +230 -0
  73. package/src/server/mountHandlers.ts +184 -0
  74. package/src/server/openDesktopWindow.ts +308 -0
  75. package/src/server/packageDirectory.ts +14 -0
  76. package/src/server/preload.ts +21 -2
  77. package/src/server/principal.ts +5 -4
  78. package/src/server/remote.ts +2 -2
  79. package/src/server/render.ts +31 -59
  80. package/src/server/requestScope.ts +5 -36
  81. package/src/server/runCompiled.ts +1 -1
  82. package/src/server/runDesktop.ts +20 -448
  83. package/src/server/seedBuffer.ts +12 -12
  84. package/src/server/serveDev.ts +24 -58
  85. package/src/server/servedApp.ts +390 -0
  86. package/src/server/shell.ts +1 -1
  87. package/src/server/signInChanged.ts +20 -0
  88. package/src/server/surfaceOf.ts +3 -2
  89. package/src/server/versionOf.ts +7 -16
  90. package/src/shared/RPC_SERVER.ts +27 -31
  91. package/src/shared/Schema.ts +1 -2
  92. package/src/shared/applyPatch.ts +1 -1
  93. package/src/shared/index.ts +1 -1
  94. package/src/shared/{note.ts → issueReport.ts} +22 -0
  95. package/src/shared/loadCall.ts +66 -0
  96. package/src/shared/muxFrames.ts +1 -1
  97. package/src/shared/reactive/Keyed.ts +24 -16
  98. package/src/shared/reactive/Reactive.ts +37 -991
  99. package/src/shared/reactive/argsContract.ts +131 -4
  100. package/src/shared/reactive/byOf.ts +2 -5
  101. package/src/shared/reactive/callLoad.ts +8 -14
  102. package/src/shared/reactive/cellShape.ts +734 -0
  103. package/src/shared/reactive/index.ts +12 -23
  104. package/src/shared/reactive/pairReactive.ts +5 -3
  105. package/src/shared/reactive/patchLog.ts +79 -0
  106. package/src/shared/reactive/patchMarks.ts +34 -0
  107. package/src/shared/reactive/producer.ts +121 -0
  108. package/src/shared/reactive/recordWrites.ts +11 -14
  109. package/src/shared/reactive/scoped.ts +3 -2
  110. package/src/shared/reactive/selections.ts +209 -0
  111. package/src/shared/reactive/share.ts +4 -3
  112. package/src/shared/reactive/watch.ts +3 -4
  113. package/src/shared/rpc.ts +20 -24
  114. package/src/shared/validateJson.ts +1 -2
  115. package/src/shared/writePath.ts +29 -0
  116. package/src/ui/ArmRegion.ts +10 -4
  117. package/src/ui/Level.ts +11 -20
  118. package/src/ui/LevelChain.ts +272 -0
  119. package/src/ui/Router.ts +106 -313
  120. package/src/ui/Scope.ts +17 -3
  121. package/src/ui/TryRegion.ts +22 -23
  122. package/src/ui/bindSpread.ts +2 -4
  123. package/src/ui/listenForRoutes.ts +3 -10
  124. package/src/ui/outboxQueue.ts +23 -11
  125. package/src/ui/outcomeOf.ts +120 -0
  126. package/src/ui/reconcile.ts +4 -6
  127. package/src/ui/routing.ts +2 -1
  128. package/src/ui/rows.ts +2 -2
  129. package/src/ui/setAttribute.ts +12 -3
  130. package/src/ui/socketWire.ts +28 -13
  131. package/src/ui/wire.ts +9 -10
  132. package/src/compiler/Finding.ts +0 -2
  133. package/src/compiler/Refusals.ts +0 -65
  134. package/src/compiler/formatDiagnosis.ts +0 -20
  135. package/src/server/appDirectories.ts +0 -9
  136. package/src/server/argsFor.ts +0 -39
  137. package/src/server/buildDirectory.ts +0 -10
  138. package/src/server/coerceArgs.ts +0 -109
  139. package/src/server/derivedArgs.ts +0 -26
  140. package/src/server/runBuild.ts +0 -24
  141. package/src/server/serveBuild.ts +0 -144
  142. package/src/server/testBuild.ts +0 -220
  143. package/src/shared/LOAD_OFFLINE.ts +0 -15
  144. package/src/shared/LOAD_SIGNAL.ts +0 -10
  145. package/src/shared/issuesOf.ts +0 -18
  146. package/src/shared/reactive/ENTRY_LIVES.ts +0 -7
  147. package/src/shared/reactive/FOLLOWED.ts +0 -8
  148. package/src/shared/reactive/PATCHES.ts +0 -11
  149. package/src/shared/reactive/PATCH_SINKS.ts +0 -26
  150. package/src/shared/reactive/canonicalKey.ts +0 -95
@@ -1,26 +0,0 @@
1
- /**
2
- * One JSON Patch operation (RFC 6902), its `path` and `from` JSON Pointers (RFC 6901).
3
- *
4
- * A patch abide records is `add`, `remove` and `replace` alone; `move`, `copy` and `test` are
5
- * applied where a client sends them.
6
- */
7
- export type PatchOp =
8
- | { op: 'add'; path: string; value: unknown }
9
- | { op: 'remove'; path: string }
10
- | { op: 'replace'; path: string; value: unknown }
11
- | { op: 'move'; from: string; path: string }
12
- | { op: 'copy'; from: string; path: string }
13
- | { op: 'test'; path: string; value: unknown }
14
-
15
- /**
16
- * Where a patch's writes are kept as data, by the cell they were made to.
17
- *
18
- * 18.11. Only a value the server follows over the mux has one, so every other patch records
19
- * nothing but its marks (32.33). `lost` where a write could not be kept as data, and then the
20
- * change is sent as the value (18.13). `fed` is how many followers the server is feeding it, and
21
- * the sink goes with the last. A leaf, because the reactive core writes it and the server reads it.
22
- */
23
- export const PATCH_SINKS = new WeakMap<
24
- object,
25
- { ops: PatchOp[]; lost: boolean; fed: number }
26
- >()
@@ -1,95 +0,0 @@
1
- import { putOwn } from '../putOwn.ts'
2
-
3
- /**
4
- * The entry key for an `Args` value: its canonical wire form, as a string.
5
- *
6
- * RULEBOOK 11.24: members sorted by name, `undefined` members dropped, `Date` written ISO.
7
- *
8
- * 11.26: the key is taken BEFORE any gate runs, because a browser holds no copy of the gate — a
9
- * key taken after normalizing is computed one way on a server and another in a browser, and every
10
- * handler with a normalizing schema would miss its seed buffer and re-issue the call on hydration.
11
- *
12
- * 11.64: WHAT THE WIRE FORM CANNOT WRITE IS REFUSED AT THE REACH. `JSON.stringify` does not fail
13
- * on any of it — a `Set`, a `Map` and a class instance each have no own enumerable keys and
14
- * canonicalize to `{}`, and a non-finite number is written `null` — so two different reaches
15
- * produced one key and 1.8 joined the second to the first's standing work. The value was right
16
- * for the first caller and wrong for every other one, with nothing to see.
17
- */
18
- export function canonicalKey(args: unknown): string {
19
- if (args === undefined) return ''
20
- return JSON.stringify(canonical(args, []))
21
- }
22
-
23
- // THE PATH IS A STACK OF STEPS, joined only when a refusal names it. Built as a string per member
24
- // it was a concatenation for every element and every nested key on every reach, for a message the
25
- // success path never reads.
26
- type Steps = (string | number)[]
27
-
28
- function canonical(value: unknown, path: Steps): unknown {
29
- if (value === null) return value
30
- const kind = typeof value
31
- if (kind === 'number') {
32
- if (!Number.isFinite(value)) throw outside(String(value), path)
33
- return value
34
- }
35
- if (kind !== 'object') {
36
- if (kind === 'boolean' || kind === 'string') return value
37
- // `undefined` reaches here from an ARRAY element alone — a member is dropped above.
38
- throw outside(kind === 'undefined' ? 'undefined' : `a ${kind}`, path)
39
- }
40
- if (value instanceof Date) return value.toISOString()
41
- if (Array.isArray(value)) {
42
- const out: unknown[] = []
43
- for (let index = 0; index < value.length; index += 1) {
44
- path.push(index)
45
- out.push(canonical(value[index], path))
46
- path.pop()
47
- }
48
- return out
49
- }
50
- const prototype = Object.getPrototypeOf(value)
51
- if (prototype !== Object.prototype && prototype !== null)
52
- throw outside(named(value as object), path)
53
- const source = value as Record<string, unknown>
54
- const keys = Object.keys(source).sort()
55
- // AN ORDINARY OBJECT, AND `putOwn` FOR THE ONE KEY THAT NEEDS IT: `__proto__` is a SETTER on
56
- // `Object.prototype`, so `out[key] = …` for that key creates no own property and
57
- // `JSON.stringify` never sees it — `{id: 1, __proto__: {role: 'admin'}}` and `{id: 1}` then
58
- // canonicalize to one string, and 1.8 joins the second reach to the first's standing work.
59
- // `Object.create(null)` closed that too, and V8 builds it in DICTIONARY mode: the shipped key
60
- // took 49-56% of the time without it there, and a standing keyed reach 53%, where JSC reads
61
- // level to 110% (`abide/bench/sharedCases.ts`, two runs per engine).
62
- const out: Record<string, unknown> = {}
63
- for (let index = 0; index < keys.length; index += 1) {
64
- const key = keys[index] as string
65
- const member = source[key]
66
- if (member === undefined) continue
67
- path.push(key)
68
- putOwn(out, key, canonical(member, path))
69
- path.pop()
70
- }
71
- return out
72
- }
73
-
74
- function named(value: object): string {
75
- const from = value.constructor as { name?: unknown } | undefined
76
- return typeof from?.name === 'string' && from.name !== ''
77
- ? `a ${from.name}`
78
- : 'a class instance'
79
- }
80
-
81
- function outside(what: string, steps: Steps): Error {
82
- let path = ''
83
- for (const step of steps)
84
- path +=
85
- typeof step === 'number'
86
- ? `[${step}]`
87
- : path === ''
88
- ? step
89
- : `.${step}`
90
- return new Error(
91
- `An Args key cannot carry ${what} at ${
92
- path === '' ? 'the arguments themselves' : `"${path}"`
93
- }: the canonical wire form writes it as another entry's key (RULEBOOK 11.64).`,
94
- )
95
- }