@abide/abide 0.118.0 → 0.119.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 (149) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/bin/abide.ts +74 -11
  3. package/docs/REGISTRY.md +2 -1
  4. package/docs/RULEBOOK.md +22 -0
  5. package/docs/abide.md +338 -118
  6. package/package.json +1 -1
  7. package/scaffold/src/getGreeting.test.ts +1 -0
  8. package/scaffold/src/index.abide +4 -1
  9. package/scaffold/src/index.test.ts +2 -0
  10. package/scaffold/src/layout.abide +6 -6
  11. package/src/compiler/Lowering.ts +20 -2
  12. package/src/compiler/PositionTable.ts +1 -0
  13. package/src/compiler/Refusals.ts +1 -0
  14. package/src/compiler/TypeSession.ts +11 -8
  15. package/src/compiler/aliasedSymbol.ts +1 -1
  16. package/src/compiler/ambientReadsIn.ts +1 -0
  17. package/src/compiler/appLayout.ts +4 -2
  18. package/src/compiler/argsDefaultsIn.ts +1 -0
  19. package/src/compiler/argsSchemaOf.ts +1 -0
  20. package/src/compiler/checkApp.ts +3 -1
  21. package/src/compiler/checkedShadow.ts +2 -1
  22. package/src/compiler/classifyRead.ts +1 -0
  23. package/src/compiler/classifyTemplate.ts +1 -0
  24. package/src/compiler/compileApp.ts +4 -2
  25. package/src/compiler/compiledEntry.ts +1 -0
  26. package/src/compiler/componentGraph.ts +1 -0
  27. package/src/compiler/declaredExports.ts +4 -2
  28. package/src/compiler/emitClient.ts +19 -14
  29. package/src/compiler/emitComponent.ts +1 -0
  30. package/src/compiler/emitSource.ts +2 -1
  31. package/src/compiler/formatAbide.ts +857 -0
  32. package/src/compiler/formatDiagnosis.ts +1 -0
  33. package/src/compiler/handlersUnder.ts +2 -1
  34. package/src/compiler/hookCalls.ts +1 -0
  35. package/src/compiler/lineOf.ts +17 -0
  36. package/src/compiler/matchersOf.ts +13 -3
  37. package/src/compiler/mountsOf.ts +2 -0
  38. package/src/compiler/paramFile.ts +1 -0
  39. package/src/compiler/parseAbide.ts +48 -28
  40. package/src/compiler/projectShadow.ts +10 -3
  41. package/src/compiler/reactiveOptions.ts +1 -0
  42. package/src/compiler/reactiveTypes.ts +2 -1
  43. package/src/compiler/readsIn.ts +3 -2
  44. package/src/compiler/renderMarkup.ts +3 -2
  45. package/src/compiler/resolverIn.ts +2 -0
  46. package/src/compiler/sameTemplate.ts +150 -0
  47. package/src/compiler/scaffold.ts +4 -11
  48. package/src/compiler/serveLanguage.ts +46 -19
  49. package/src/compiler/sharedModuleWrites.ts +2 -1
  50. package/src/compiler/sourceMapOf.ts +1 -0
  51. package/src/compiler/splitImports.ts +2 -0
  52. package/src/compiler/templateWarnings.ts +2 -2
  53. package/src/compiler/trackingWarnings.ts +1 -0
  54. package/src/compiler/writeDefaultProject.ts +5 -1
  55. package/src/server/BRIDGE_VERSION.ts +1 -1
  56. package/src/server/abideModules.ts +2 -0
  57. package/src/server/answerFailure.ts +1 -0
  58. package/src/server/answerRequest.ts +15 -14
  59. package/src/server/answerRpc.ts +3 -2
  60. package/src/server/answerSocket.ts +2 -1
  61. package/src/server/answerValue.ts +1 -0
  62. package/src/server/answerWorker.ts +1 -0
  63. package/src/server/appTree.ts +3 -1
  64. package/src/server/argsFor.ts +1 -0
  65. package/src/server/assistant.ts +2 -1
  66. package/src/server/banner.ts +2 -0
  67. package/src/server/bridgeRelay.ts +1 -0
  68. package/src/server/callerOf.ts +1 -0
  69. package/src/server/claudeApi.ts +1 -0
  70. package/src/server/claudeCode.ts +1 -0
  71. package/src/server/clientBundle.ts +1 -0
  72. package/src/server/coerceArgs.ts +1 -2
  73. package/src/server/commands.ts +9 -0
  74. package/src/server/compressAnswer.ts +2 -1
  75. package/src/server/config.ts +2 -0
  76. package/src/server/createApp.ts +4 -2
  77. package/src/server/crossingOrigin.ts +1 -0
  78. package/src/server/csp.ts +1 -0
  79. package/src/server/deferredBuilds.ts +1 -0
  80. package/src/server/derivedArgs.ts +1 -0
  81. package/src/server/devWorker.ts +2 -1
  82. package/src/server/faceOf.ts +2 -7
  83. package/src/server/generatedSurfaces.ts +5 -1
  84. package/src/server/hooks.ts +1 -0
  85. package/src/server/iconAccent.ts +1 -1
  86. package/src/server/installServer.ts +1 -0
  87. package/src/server/installSourceMaps.ts +1 -0
  88. package/src/server/launcherPage.ts +2 -2
  89. package/src/server/manifestOf.ts +1 -0
  90. package/src/server/muxUpgrade.ts +1 -0
  91. package/src/server/nativeMenu.ts +2 -0
  92. package/src/server/principal.ts +2 -1
  93. package/src/server/remote.ts +1 -0
  94. package/src/server/render.ts +3 -3
  95. package/src/server/renderComponent.ts +1 -0
  96. package/src/server/reportHealth.ts +1 -0
  97. package/src/server/requestScope.ts +3 -1
  98. package/src/server/runDesktop.ts +3 -2
  99. package/src/server/seedBuffer.ts +1 -0
  100. package/src/server/serveDev.ts +3 -2
  101. package/src/server/shell.ts +2 -0
  102. package/src/server/streamEvent.ts +1 -0
  103. package/src/server/surfaceOf.ts +1 -0
  104. package/src/server/testBuild.ts +1 -0
  105. package/src/server/testMount.ts +1 -0
  106. package/src/server/trace.ts +2 -0
  107. package/src/server/withAbideSources.ts +1 -0
  108. package/src/shared/Attributes.ts +12 -8
  109. package/src/shared/cookies.ts +1 -1
  110. package/src/shared/escapeText.ts +1 -1
  111. package/src/shared/index.ts +1 -5
  112. package/src/shared/jsonSchema.ts +1 -3
  113. package/src/shared/menuBridge.ts +1 -2
  114. package/src/shared/outbox.ts +1 -1
  115. package/src/shared/reactive/Keyed.ts +2 -2
  116. package/src/shared/reactive/Reactive.ts +12 -16
  117. package/src/shared/reactive/index.ts +3 -4
  118. package/src/shared/reactive/isReactive.ts +1 -1
  119. package/src/shared/reactive/scoped.ts +2 -2
  120. package/src/shared/reactive/share.ts +1 -1
  121. package/src/shared/reactive/watch.ts +4 -4
  122. package/src/shared/refuse.ts +1 -1
  123. package/src/shared/rpc.ts +8 -11
  124. package/src/shared/url.ts +1 -1
  125. package/src/shared/validateJson.ts +1 -1
  126. package/src/ui/ArmRegion.ts +1 -0
  127. package/src/ui/Level.ts +1 -0
  128. package/src/ui/List.ts +1 -0
  129. package/src/ui/RawRun.ts +1 -0
  130. package/src/ui/Router.ts +1 -0
  131. package/src/ui/TryRegion.ts +1 -0
  132. package/src/ui/adoptWalk.ts +2 -1
  133. package/src/ui/bindElement.ts +1 -0
  134. package/src/ui/bindFiles.ts +1 -0
  135. package/src/ui/bindGroup.ts +1 -0
  136. package/src/ui/bindProperty.ts +1 -0
  137. package/src/ui/bindSpread.ts +1 -0
  138. package/src/ui/index.ts +1 -6
  139. package/src/ui/outboxQueue.ts +1 -1
  140. package/src/ui/parseMarkup.ts +2 -1
  141. package/src/ui/reconcile.ts +2 -1
  142. package/src/ui/reconcileHead.ts +1 -0
  143. package/src/ui/regions.ts +2 -1
  144. package/src/ui/registerWorker.ts +1 -0
  145. package/src/ui/rows.ts +1 -0
  146. package/src/ui/setMarkup.ts +1 -0
  147. package/src/ui/setText.ts +1 -0
  148. package/src/ui/socketWire.ts +4 -3
  149. package/src/ui/wire.ts +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @abide/abide
2
2
 
3
+ ## 0.119.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a9f8ad1: abide format formats every .abide — its scripts, styles and expressions by bun fmt, its markup by its nesting — and leaves one as written where the template would change (RULEBOOK 38.125-38.130) ([`fb0b837`](https://github.com/briancray/abide/commit/fb0b837b1264a4193371388a61fb64ec81f16638))
8
+
9
+ ### Patch Changes
10
+
11
+ - a9f8ad1: bun fmt replaces biome, and an unused local or parameter is a type error ([`259f9b1`](https://github.com/briancray/abide/commit/259f9b18b9c2bd12b6ab5c9d9784adb2b8d2edd1))
12
+ - a9f8ad1: format the repo with abide format and bun fmt ([`d7cd46d`](https://github.com/briancray/abide/commit/d7cd46da1e0cd523631d38d923f8bb08d1f0716f))
13
+
3
14
  ## 0.118.0
4
15
 
5
16
  ### Minor Changes
package/bin/abide.ts CHANGED
@@ -4,17 +4,19 @@
4
4
 
5
5
  import { existsSync, realpathSync } from 'node:fs' // bun exposes no sync existence check or realpath of its own
6
6
  import { mkdir, rename, rm } from 'node:fs/promises' // bun exposes no directory creation, rename or recursive directory removal of its own
7
- import { dirname, resolve } from 'node:path' // bun exposes no path helpers of its own
7
+ import { dirname, relative, resolve } from 'node:path' // bun exposes no path helpers of its own
8
8
  import { brotliCompress, constants } from 'node:zlib' // bun's brotli is `CompressionStream`, which compresses on the main thread — 1390 ms against this pool's 300 ms over the docs bundle
9
+
9
10
  import { paints } from '#compiler/appLayout.ts'
10
11
  import { appMap, mapText } from '#compiler/appMap.ts'
11
12
  import { checkApp } from '#compiler/checkApp.ts'
12
13
  import {
13
- type CompiledApp,
14
14
  compilationOf,
15
15
  compileApp,
16
+ type CompiledApp,
16
17
  } from '#compiler/compileApp.ts'
17
18
  import { compiledEntry } from '#compiler/compiledEntry.ts'
19
+ import { formatAbide } from '#compiler/formatAbide.ts'
18
20
  import { formatDiagnosis } from '#compiler/formatDiagnosis.ts'
19
21
  import { parseAbide } from '#compiler/parseAbide.ts'
20
22
  import { scaffold } from '#compiler/scaffold.ts'
@@ -40,18 +42,23 @@ import { appOnDisk, appRoot, noAppHere } from '#server/createApp.ts'
40
42
  import { executableName } from '#server/executableName.ts'
41
43
  import { iconAccent } from '#server/iconAccent.ts'
42
44
  import { namesUnder } from '#server/namesUnder.ts'
45
+ import { skipped } from '#server/placement.ts'
43
46
  import { DEFAULT_DOCUMENT, intoHead } from '#server/render.ts'
44
47
  import { runtimeRefusal } from '#server/runtimeRefusal.ts'
45
48
  import { pathsUnder, serveBuild } from '#server/serveBuild.ts'
46
49
  import { serveDev } from '#server/serveDev.ts'
47
50
  import { escapeText } from '#shared/escapeText.ts'
48
51
  import { ICON_ADDRESSES, LAUNCHER_PAGE } from '#shared/LAUNCHER_FILES.ts'
52
+
49
53
  import abidePackage from '../package.json' with { type: 'json' }
50
54
 
51
55
  // 38.123 — the bun this process runs on, held to abide's `engines.bun` before anything is built or
52
56
  // booted. A compiled app carries the bun `abide compile` ran on, which this held already.
53
57
  const RUNTIME_REFUSAL = runtimeRefusal(Bun.version, abidePackage.engines.bun)
54
58
 
59
+ /** How many files `abide format` formats at once, each spawning `bun fmt` for its pieces. */
60
+ const FILES_AT_ONCE = 8
61
+
55
62
  /** Where the app a command builds or serves is, and where its build goes — both absolute. */
56
63
  type AppDirectories = { root: string; out: string }
57
64
 
@@ -81,6 +88,10 @@ const DISK: Host = {
81
88
  dev: inApp(dev),
82
89
  build: inApp(build),
83
90
  check: inApp(check),
91
+ format: (given) =>
92
+ given.positionals.length > 1
93
+ ? format(namedDirectories(given.positionals), given)
94
+ : inApp(({ root }) => format([root], given))(given),
84
95
  routes: inApp(routes),
85
96
  compile: inApp(compile),
86
97
  bundle: inApp(bundle),
@@ -699,9 +710,9 @@ async function scaffoldCommand({
699
710
  return 1
700
711
  }
701
712
  const into = resolve(name)
702
- const { written, skipped } = await scaffold(name, into)
713
+ const { written, skipped: kept } = await scaffold(name, into)
703
714
  for (const path of written) console.log(` wrote ${path}`)
704
- for (const path of skipped) console.log(` kept ${path}`)
715
+ for (const path of kept) console.log(` kept ${path}`)
705
716
  console.log(
706
717
  // The starter's own script: `abide` alone is on no PATH until it is installed globally.
707
718
  `\nabide scaffold: ${into}\n\n cd ${name}\n bun install\n bun run dev`,
@@ -729,13 +740,7 @@ async function check(
729
740
  { root }: AppDirectories,
730
741
  { positionals }: Given,
731
742
  ): Promise<number> {
732
- const within: string[] = []
733
- for (const directory of positionals.slice(1))
734
- within.push(
735
- existsSync(directory)
736
- ? realpathSync(resolve(directory))
737
- : resolve(directory),
738
- )
743
+ const within = namedDirectories(positionals)
739
744
  const found = await checkApp(root)
740
745
  let errors = 0
741
746
  let warnings = 0
@@ -760,6 +765,64 @@ async function check(
760
765
  return errors > 0 ? 1 : 0
761
766
  }
762
767
 
768
+ /** The directories a command's `[dir…]` names, each as the real path a finding is filed under. */
769
+ function namedDirectories(positionals: string[]): string[] {
770
+ const named: string[] = []
771
+ for (const directory of positionals.slice(1))
772
+ named.push(
773
+ existsSync(directory)
774
+ ? realpathSync(resolve(directory))
775
+ : resolve(directory),
776
+ )
777
+ return named
778
+ }
779
+
780
+ /**
781
+ * `abide format`: formats every `.abide` under `within` — the directories named, or the app where
782
+ * none are — and fails where any file was left as written. 38.125, 38.128.
783
+ *
784
+ * `--check` writes nothing, and fails where a file would change. 38.129.
785
+ *
786
+ * NAMED DIRECTORIES NEED NO APP, unlike `check`'s: a formatter reads one file at a time, so a
787
+ * monorepo formats every app under it in one run.
788
+ */
789
+ async function format(within: string[], { values }: Given): Promise<number> {
790
+ const paths: string[] = []
791
+ for (const directory of within)
792
+ for (const name of namesUnder(directory, '**/*.abide'))
793
+ if (!name.split('/').some(skipped))
794
+ paths.push(`${directory}/${name}`)
795
+ let changed = 0
796
+ let errors = 0
797
+ // A file's pieces are formatted in parallel already, so files are taken a few at a time.
798
+ let next = 0
799
+ const take = async (): Promise<void> => {
800
+ while (next < paths.length) {
801
+ const path = paths[next] as string
802
+ next += 1
803
+ const text = await Bun.file(path).text()
804
+ const formatted = await formatAbide(path, text)
805
+ for (const finding of formatted.findings) {
806
+ errors += 1
807
+ console.log(formatDiagnosis(finding, process.cwd()))
808
+ }
809
+ if (formatted.text === text) continue
810
+ changed += 1
811
+ if (values.check)
812
+ console.log(
813
+ `${relative(process.cwd(), path)} - needs formatting`,
814
+ )
815
+ else await Bun.write(path, formatted.text)
816
+ }
817
+ }
818
+ await Promise.all(Array.from({ length: FILES_AT_ONCE }, take))
819
+ const files = `${changed} file${changed === 1 ? '' : 's'}`
820
+ console.log(
821
+ `abide format: ${values.check ? `${files} to format` : `${files} formatted`} of ${paths.length}, ${errors} error${errors === 1 ? '' : 's'}`,
822
+ )
823
+ return errors > 0 || (values.check && changed > 0) ? 1 : 0
824
+ }
825
+
763
826
  /**
764
827
  * `abide lsp`: the language server over stdio.
765
828
  *
package/docs/REGISTRY.md CHANGED
@@ -861,6 +861,7 @@ rows a runner prints, and an adapter for an abide app.
861
861
  | `abide scaffold <name>` | Writes a starter project. | 38.1, 38.42, 38.103, 38.104, 38.106, 38.112, 38.122, 38.124 |
862
862
  | `abide run <file> [args…]` | Runs a script under the abide runtime. | 38.2, 38.57 |
863
863
  | `abide check [dir…]` | The type-checker over a `.abide` tree. | 38.3, 38.31, 38.32, 38.33, 38.40, 38.105, 38.123 |
864
+ | `abide format [--check] [dir…]` | The formatter over a `.abide` tree. | 38.25, 38.125, 38.126, 38.127, 38.128, 38.129 |
864
865
  | `abide routes [--json]` | Every address the app answers, the file answering it, what each matcher takes, and where each hook is filed. | 38.108, 38.123 |
865
866
  | `abide dev [--port <n>]` | Watches the project and keeps the app up. | 16.23, 16.56, 37.8, 37.9, 38.4, 38.14, 38.15, 38.16, 38.17, 38.19, 38.24, 38.25, 38.26, 38.28, 38.30, 38.35, 38.36, 38.37, 38.38, 38.41, 38.43, 38.58, 38.63, 38.64, 38.65, 38.94, 38.96, 38.97, 38.123 |
866
867
  | `abide build` | Builds the client into content-hashed chunks and a manifest. | 38.43, 38.5, 38.18, 38.25, 38.26, 38.27, 38.30, 38.66, 38.94, 38.123 |
@@ -872,6 +873,6 @@ rows a runner prints, and an adapter for an abide app.
872
873
  | `abide watch <address> [args]` | A live subscription to one of the app's followed `GET`s. | 38.69 |
873
874
  | `abide compile [--target] [--out] [--platforms]` | One standalone executable. | 37.8, 37.10, 37.11, 37.12, 38.10, 38.25, 38.26, 38.44, 38.45, 38.46, 38.47, 38.48, 38.49, 38.50, 38.51, 38.52, 38.56, 38.93, 38.97, 38.123 |
874
875
  | `abide bundle [--out]` | A desktop app for the host platform, with a window on the app. | 38.10, 38.25, 38.26, 38.70, 38.71, 38.72, 38.73, 38.74, 38.75, 38.76, 38.77, 38.78, 38.79, 38.80, 38.81, 38.82, 38.83, 38.84, 38.85, 38.86, 38.87, 38.88, 38.89, 38.90, 38.91, 38.92, 38.101, 38.102, 38.123 |
875
- | `abide lsp` | The `.abide` language server, over stdio. | 38.11, 38.34, 38.39, 38.98, 38.116, 38.117, 38.118 |
876
+ | `abide lsp` | The `.abide` language server, over stdio. | 38.11, 38.34, 38.39, 38.98, 38.116, 38.117, 38.118, 38.130 |
876
877
  | `--help` · `-h` · `abide help` | Usage, generated from the command list. | 38.12, 38.113, 38.114 |
877
878
  | `--version` · `-v` | The version of abide, or of the app a compiled executable holds. | 38.115 |
package/docs/RULEBOOK.md CHANGED
@@ -2825,6 +2825,28 @@ the range.
2825
2825
 
2826
2826
  38.124 The project `abide scaffold` writes MUST carry a `bench` script that runs `harness-bench`.
2827
2827
 
2828
+ 38.125 `abide format` MUST hand each `<script>` block and each `<style>` of every `.abide` under the
2829
+ directories named, or under the app where none are, to `bun fmt` as TypeScript and as CSS, under the
2830
+ options `bun fmt` reads for that file, and MUST leave as written a file those options'
2831
+ `ignorePatterns` name.
2832
+
2833
+ 38.126 `abide format` MUST hand each expression a slot, an attribute, a spread, a `{#if}`, a
2834
+ `{:else if}` or a `{#for}` holds to `bun fmt` as an expression, and MUST keep one as written where
2835
+ the printed expression would end the attribute value it stands in.
2836
+
2837
+ 38.127 `abide format` MUST indent the markup by its element and block nesting, and MUST NOT change
2838
+ the template the file parses to: a run 33.17 drops between two nodes MUST NOT gain indentation, and
2839
+ the body of a `<pre>`, a `<textarea>` and a markup `<script>` MUST stay as written.
2840
+
2841
+ 38.128 `abide format` MUST leave as written a file the parser refuses, a file whose formatted text
2842
+ would parse to a different template (38.127), and a piece `bun fmt` refuses, MUST report each on its
2843
+ line, MUST go on formatting the rest, and MUST exit non-zero where it reports one.
2844
+
2845
+ 38.129 `abide format --check` MUST write nothing, and MUST exit non-zero where a file would change.
2846
+
2847
+ 38.130 `abide lsp` MUST answer a formatting request with what `abide format` makes of the text the
2848
+ editor holds.
2849
+
2828
2850
  # 39. Head and view transitions
2829
2851
 
2830
2852
  39.1 A `<head>` element in a `.abide` file MUST contribute its children to the document head.