openalgo-script 0.2.0 → 0.4.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 (276) hide show
  1. package/CHANGELOG.md +269 -0
  2. package/README.md +65 -31
  3. package/dist/adapters/charts/surfaces.d.ts +17 -0
  4. package/dist/adapters/charts/surfaces.d.ts.map +1 -1
  5. package/dist/adapters/charts/tables.js +82 -0
  6. package/dist/adapters/charts/tables.js.map +1 -1
  7. package/dist/adapters/codemirror/commands.d.ts +14 -0
  8. package/dist/adapters/codemirror/commands.d.ts.map +1 -0
  9. package/dist/adapters/codemirror/commands.js +52 -0
  10. package/dist/adapters/codemirror/commands.js.map +1 -0
  11. package/dist/adapters/codemirror/completion.d.ts +15 -0
  12. package/dist/adapters/codemirror/completion.d.ts.map +1 -0
  13. package/dist/adapters/codemirror/completion.js +64 -0
  14. package/dist/adapters/codemirror/completion.js.map +1 -0
  15. package/dist/adapters/codemirror/contract.d.ts +156 -0
  16. package/dist/adapters/codemirror/contract.d.ts.map +1 -0
  17. package/dist/adapters/codemirror/contract.js +42 -0
  18. package/dist/adapters/codemirror/contract.js.map +1 -0
  19. package/dist/adapters/codemirror/index.d.ts +43 -0
  20. package/dist/adapters/codemirror/index.d.ts.map +1 -0
  21. package/dist/adapters/codemirror/index.js +8 -0
  22. package/dist/adapters/codemirror/index.js.map +1 -0
  23. package/dist/adapters/codemirror/lint.d.ts +17 -0
  24. package/dist/adapters/codemirror/lint.d.ts.map +1 -0
  25. package/dist/adapters/codemirror/lint.js +62 -0
  26. package/dist/adapters/codemirror/lint.js.map +1 -0
  27. package/dist/adapters/codemirror/positions.d.ts +16 -0
  28. package/dist/adapters/codemirror/positions.d.ts.map +1 -0
  29. package/dist/adapters/codemirror/positions.js +65 -0
  30. package/dist/adapters/codemirror/positions.js.map +1 -0
  31. package/dist/adapters/codemirror/stream.d.ts +23 -0
  32. package/dist/adapters/codemirror/stream.d.ts.map +1 -0
  33. package/dist/adapters/codemirror/stream.js +70 -0
  34. package/dist/adapters/codemirror/stream.js.map +1 -0
  35. package/dist/adapters/codemirror/tokens.d.ts +44 -0
  36. package/dist/adapters/codemirror/tokens.d.ts.map +1 -0
  37. package/dist/adapters/codemirror/tokens.js +34 -0
  38. package/dist/adapters/codemirror/tokens.js.map +1 -0
  39. package/dist/adapters/codemirror/tooltips.d.ts +35 -0
  40. package/dist/adapters/codemirror/tooltips.d.ts.map +1 -0
  41. package/dist/adapters/codemirror/tooltips.js +108 -0
  42. package/dist/adapters/codemirror/tooltips.js.map +1 -0
  43. package/dist/core/accounting/charges.d.ts +136 -0
  44. package/dist/core/accounting/charges.d.ts.map +1 -0
  45. package/dist/core/accounting/charges.js +362 -0
  46. package/dist/core/accounting/charges.js.map +1 -0
  47. package/dist/core/accounting/equity.d.ts +158 -0
  48. package/dist/core/accounting/equity.d.ts.map +1 -0
  49. package/dist/core/accounting/equity.js +155 -0
  50. package/dist/core/accounting/equity.js.map +1 -0
  51. package/dist/core/accounting/index.d.ts +44 -0
  52. package/dist/core/accounting/index.d.ts.map +1 -0
  53. package/dist/core/accounting/index.js +36 -0
  54. package/dist/core/accounting/index.js.map +1 -0
  55. package/dist/core/accounting/markers.d.ts +43 -0
  56. package/dist/core/accounting/markers.d.ts.map +1 -0
  57. package/dist/core/accounting/markers.js +64 -0
  58. package/dist/core/accounting/markers.js.map +1 -0
  59. package/dist/core/accounting/monthly.d.ts +52 -0
  60. package/dist/core/accounting/monthly.d.ts.map +1 -0
  61. package/dist/core/accounting/monthly.js +99 -0
  62. package/dist/core/accounting/monthly.js.map +1 -0
  63. package/dist/core/accounting/report.d.ts +38 -0
  64. package/dist/core/accounting/report.d.ts.map +1 -0
  65. package/dist/core/accounting/report.js +63 -0
  66. package/dist/core/accounting/report.js.map +1 -0
  67. package/dist/core/accounting/shapes.d.ts +70 -0
  68. package/dist/core/accounting/shapes.d.ts.map +1 -0
  69. package/dist/core/accounting/shapes.js +21 -0
  70. package/dist/core/accounting/shapes.js.map +1 -0
  71. package/dist/core/accounting/statistics.d.ts +75 -0
  72. package/dist/core/accounting/statistics.d.ts.map +1 -0
  73. package/dist/core/accounting/statistics.js +246 -0
  74. package/dist/core/accounting/statistics.js.map +1 -0
  75. package/dist/core/accounting/trades.d.ts +118 -0
  76. package/dist/core/accounting/trades.d.ts.map +1 -0
  77. package/dist/core/accounting/trades.js +186 -0
  78. package/dist/core/accounting/trades.js.map +1 -0
  79. package/dist/core/backtest/compare.d.ts +38 -0
  80. package/dist/core/backtest/compare.d.ts.map +1 -0
  81. package/dist/core/backtest/compare.js +189 -0
  82. package/dist/core/backtest/compare.js.map +1 -0
  83. package/dist/core/backtest/declaration.d.ts +52 -0
  84. package/dist/core/backtest/declaration.d.ts.map +1 -0
  85. package/dist/core/backtest/declaration.js +48 -0
  86. package/dist/core/backtest/declaration.js.map +1 -0
  87. package/dist/core/backtest/drive.d.ts +29 -0
  88. package/dist/core/backtest/drive.d.ts.map +1 -0
  89. package/dist/core/backtest/drive.js +262 -0
  90. package/dist/core/backtest/drive.js.map +1 -0
  91. package/dist/core/backtest/index.d.ts +46 -0
  92. package/dist/core/backtest/index.d.ts.map +1 -0
  93. package/dist/core/backtest/index.js +36 -0
  94. package/dist/core/backtest/index.js.map +1 -0
  95. package/dist/core/backtest/range.d.ts +84 -0
  96. package/dist/core/backtest/range.d.ts.map +1 -0
  97. package/dist/core/backtest/range.js +90 -0
  98. package/dist/core/backtest/range.js.map +1 -0
  99. package/dist/core/backtest/record.d.ts +238 -0
  100. package/dist/core/backtest/record.d.ts.map +1 -0
  101. package/dist/core/backtest/record.js +176 -0
  102. package/dist/core/backtest/record.js.map +1 -0
  103. package/dist/core/backtest/replay.d.ts +48 -0
  104. package/dist/core/backtest/replay.d.ts.map +1 -0
  105. package/dist/core/backtest/replay.js +127 -0
  106. package/dist/core/backtest/replay.js.map +1 -0
  107. package/dist/core/backtest/resting.d.ts +62 -0
  108. package/dist/core/backtest/resting.d.ts.map +1 -0
  109. package/dist/core/backtest/resting.js +59 -0
  110. package/dist/core/backtest/resting.js.map +1 -0
  111. package/dist/core/backtest/settings.d.ts +117 -0
  112. package/dist/core/backtest/settings.d.ts.map +1 -0
  113. package/dist/core/backtest/settings.js +207 -0
  114. package/dist/core/backtest/settings.js.map +1 -0
  115. package/dist/core/backtest/simulate.d.ts +146 -0
  116. package/dist/core/backtest/simulate.d.ts.map +1 -0
  117. package/dist/core/backtest/simulate.js +217 -0
  118. package/dist/core/backtest/simulate.js.map +1 -0
  119. package/dist/core/catalogue/catalogue.generated.d.ts +66 -0
  120. package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -1
  121. package/dist/core/catalogue/catalogue.generated.js +6 -0
  122. package/dist/core/catalogue/catalogue.generated.js.map +1 -1
  123. package/dist/core/catalogue/values.generated.d.ts +24 -0
  124. package/dist/core/catalogue/values.generated.d.ts.map +1 -1
  125. package/dist/core/check/index.d.ts +2 -1
  126. package/dist/core/check/index.d.ts.map +1 -1
  127. package/dist/core/check/index.js +1 -1
  128. package/dist/core/check/index.js.map +1 -1
  129. package/dist/core/check/library-prose.generated.d.ts +16 -0
  130. package/dist/core/check/library-prose.generated.d.ts.map +1 -0
  131. package/dist/core/check/library-prose.generated.js +353 -0
  132. package/dist/core/check/library-prose.generated.js.map +1 -0
  133. package/dist/core/check/surface.d.ts +24 -0
  134. package/dist/core/check/surface.d.ts.map +1 -1
  135. package/dist/core/check/surface.js +29 -0
  136. package/dist/core/check/surface.js.map +1 -1
  137. package/dist/core/emit/defaults.d.ts +35 -16
  138. package/dist/core/emit/defaults.d.ts.map +1 -1
  139. package/dist/core/emit/defaults.js +66 -0
  140. package/dist/core/emit/defaults.js.map +1 -1
  141. package/dist/core/emit/index.d.ts +2 -0
  142. package/dist/core/emit/index.d.ts.map +1 -1
  143. package/dist/core/emit/index.js +2 -0
  144. package/dist/core/emit/index.js.map +1 -1
  145. package/dist/core/engine/index.d.ts +1 -1
  146. package/dist/core/engine/index.d.ts.map +1 -1
  147. package/dist/core/engine/index.js +1 -1
  148. package/dist/core/engine/index.js.map +1 -1
  149. package/dist/core/engine/load.d.ts +15 -1
  150. package/dist/core/engine/load.d.ts.map +1 -1
  151. package/dist/core/engine/load.js +1 -0
  152. package/dist/core/engine/load.js.map +1 -1
  153. package/dist/core/index.d.ts +37 -3
  154. package/dist/core/index.d.ts.map +1 -1
  155. package/dist/core/index.js +17 -1
  156. package/dist/core/index.js.map +1 -1
  157. package/dist/core/version/version.generated.d.ts +1 -1
  158. package/dist/core/version/version.generated.js +1 -1
  159. package/dist/editor/complete.d.ts +40 -0
  160. package/dist/editor/complete.d.ts.map +1 -0
  161. package/dist/editor/complete.js +206 -0
  162. package/dist/editor/complete.js.map +1 -0
  163. package/dist/editor/diagnose.d.ts +18 -0
  164. package/dist/editor/diagnose.d.ts.map +1 -0
  165. package/dist/editor/diagnose.js +70 -0
  166. package/dist/editor/diagnose.js.map +1 -0
  167. package/dist/editor/format.d.ts +11 -0
  168. package/dist/editor/format.d.ts.map +1 -0
  169. package/dist/editor/format.js +50 -0
  170. package/dist/editor/format.js.map +1 -0
  171. package/dist/editor/highlight.d.ts +28 -0
  172. package/dist/editor/highlight.d.ts.map +1 -0
  173. package/dist/editor/highlight.js +65 -0
  174. package/dist/editor/highlight.js.map +1 -0
  175. package/dist/editor/hover.d.ts +40 -0
  176. package/dist/editor/hover.d.ts.map +1 -0
  177. package/dist/editor/hover.js +147 -0
  178. package/dist/editor/hover.js.map +1 -0
  179. package/dist/editor/index.d.ts +60 -0
  180. package/dist/editor/index.d.ts.map +1 -0
  181. package/dist/editor/index.js +7 -0
  182. package/dist/editor/index.js.map +1 -0
  183. package/dist/editor/kinds.d.ts +27 -0
  184. package/dist/editor/kinds.d.ts.map +1 -0
  185. package/dist/editor/kinds.js +118 -0
  186. package/dist/editor/kinds.js.map +1 -0
  187. package/dist/editor/layout.d.ts +47 -0
  188. package/dist/editor/layout.d.ts.map +1 -0
  189. package/dist/editor/layout.js +135 -0
  190. package/dist/editor/layout.js.map +1 -0
  191. package/dist/editor/manifest.d.ts +47 -0
  192. package/dist/editor/manifest.d.ts.map +1 -0
  193. package/dist/editor/manifest.js +93 -0
  194. package/dist/editor/manifest.js.map +1 -0
  195. package/dist/editor/reading.d.ts +41 -0
  196. package/dist/editor/reading.d.ts.map +1 -0
  197. package/dist/editor/reading.js +51 -0
  198. package/dist/editor/reading.js.map +1 -0
  199. package/dist/editor/scan.d.ts +26 -0
  200. package/dist/editor/scan.d.ts.map +1 -0
  201. package/dist/editor/scan.js +139 -0
  202. package/dist/editor/scan.js.map +1 -0
  203. package/dist/editor/scope.d.ts +19 -0
  204. package/dist/editor/scope.d.ts.map +1 -0
  205. package/dist/editor/scope.js +99 -0
  206. package/dist/editor/scope.js.map +1 -0
  207. package/dist/editor/signature.d.ts +38 -0
  208. package/dist/editor/signature.d.ts.map +1 -0
  209. package/dist/editor/signature.js +112 -0
  210. package/dist/editor/signature.js.map +1 -0
  211. package/dist/editor/site.d.ts +46 -0
  212. package/dist/editor/site.d.ts.map +1 -0
  213. package/dist/editor/site.js +184 -0
  214. package/dist/editor/site.js.map +1 -0
  215. package/dist/editor/spacing.d.ts +29 -0
  216. package/dist/editor/spacing.d.ts.map +1 -0
  217. package/dist/editor/spacing.js +116 -0
  218. package/dist/editor/spacing.js.map +1 -0
  219. package/package.json +30 -3
  220. package/spec/errors.json +140 -0
  221. package/src/adapters/charts/surfaces.ts +17 -0
  222. package/src/adapters/charts/tables.ts +88 -0
  223. package/src/adapters/codemirror/commands.ts +53 -0
  224. package/src/adapters/codemirror/completion.ts +74 -0
  225. package/src/adapters/codemirror/contract.ts +156 -0
  226. package/src/adapters/codemirror/index.ts +66 -0
  227. package/src/adapters/codemirror/lint.ts +66 -0
  228. package/src/adapters/codemirror/positions.ts +79 -0
  229. package/src/adapters/codemirror/stream.ts +87 -0
  230. package/src/adapters/codemirror/tokens.ts +64 -0
  231. package/src/adapters/codemirror/tooltips.ts +113 -0
  232. package/src/core/accounting/charges.ts +452 -0
  233. package/src/core/accounting/equity.ts +276 -0
  234. package/src/core/accounting/index.ts +49 -0
  235. package/src/core/accounting/markers.ts +95 -0
  236. package/src/core/accounting/monthly.ts +137 -0
  237. package/src/core/accounting/report.ts +89 -0
  238. package/src/core/accounting/shapes.ts +73 -0
  239. package/src/core/accounting/statistics.ts +350 -0
  240. package/src/core/accounting/trades.ts +313 -0
  241. package/src/core/backtest/compare.ts +244 -0
  242. package/src/core/backtest/declaration.ts +97 -0
  243. package/src/core/backtest/drive.ts +364 -0
  244. package/src/core/backtest/index.ts +52 -0
  245. package/src/core/backtest/range.ts +137 -0
  246. package/src/core/backtest/record.ts +341 -0
  247. package/src/core/backtest/replay.ts +158 -0
  248. package/src/core/backtest/resting.ts +125 -0
  249. package/src/core/backtest/settings.ts +280 -0
  250. package/src/core/backtest/simulate.ts +304 -0
  251. package/src/core/catalogue/catalogue.generated.ts +6 -0
  252. package/src/core/catalogue/values.generated.ts +6 -0
  253. package/src/core/check/index.ts +3 -0
  254. package/src/core/check/library-prose.generated.ts +367 -0
  255. package/src/core/check/surface.ts +34 -0
  256. package/src/core/emit/defaults.ts +70 -0
  257. package/src/core/emit/index.ts +2 -0
  258. package/src/core/engine/index.ts +1 -1
  259. package/src/core/engine/load.ts +16 -2
  260. package/src/core/index.ts +85 -1
  261. package/src/core/version/version.generated.ts +1 -1
  262. package/src/editor/complete.ts +266 -0
  263. package/src/editor/diagnose.ts +71 -0
  264. package/src/editor/format.ts +85 -0
  265. package/src/editor/highlight.ts +110 -0
  266. package/src/editor/hover.ts +199 -0
  267. package/src/editor/index.ts +65 -0
  268. package/src/editor/kinds.ts +157 -0
  269. package/src/editor/layout.ts +189 -0
  270. package/src/editor/manifest.ts +119 -0
  271. package/src/editor/reading.ts +69 -0
  272. package/src/editor/scan.ts +162 -0
  273. package/src/editor/scope.ts +122 -0
  274. package/src/editor/signature.ts +150 -0
  275. package/src/editor/site.ts +233 -0
  276. package/src/editor/spacing.ts +132 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,275 @@ nothing, fails the build before it can become permanent.
7
7
 
8
8
  ---
9
9
 
10
+ ## 0.4.0
11
+
12
+ **A backtest is driven, and what it produces is a document rather than a
13
+ number.** `backtest(program, bars, settings)` walks a compiled program over a
14
+ range of bars against a destination that prices fills, and hands back a
15
+ `RunRecord`: the compiled program and the hash of the source it came from, the
16
+ bars or a hash naming them, the settings the host chose, every frame the
17
+ destination answered in delivery order, every fill the engine folded in fold
18
+ order, the ledger the run ended with, the diagnostics and the report. Nothing in
19
+ it is an object reference, a function or a shape only this engine can read,
20
+ because the same document is what a second engine will be handed as a
21
+ conformance case.
22
+
23
+ **A stored run can be reported again and run again, and both are checked rather
24
+ than asserted.** `replay(record)` folds the money again from the record's own
25
+ fills with no bar executed, and has to produce the report the record carries:
26
+ that is what says the report is a function of the fills and not of anything the
27
+ engine happened to be holding. `rerun(record)` executes the record again and the
28
+ two runs are compared as bytes. Bars are revised, so a replay over bars that do
29
+ not hash to the record's is refused, OS6022, rather than reporting the original
30
+ figures over different data.
31
+
32
+ **The comparison that tells an improvement from noise.** `compareRuns` puts two
33
+ records beside each other. Two runs over different bars or different contracts
34
+ are two studies, so the pair is reported incomparable and given no separation at
35
+ all; a different program over the same bars is exactly what is comparable, and
36
+ every other difference is named, because the reason a run improved is as often a
37
+ setting somebody forgot they changed as it is the change they meant to test.
38
+ Separation is the gap between the two expectancies over the combined standard
39
+ error, analytic and with no resampling, so the same pair gives the same figure
40
+ for ever. It is null rather than infinite where neither run has the two closed
41
+ trades a spread needs.
42
+
43
+ **The phase's gate is executed rather than promised.**
44
+ `scripts/check-reproducible.mjs` runs on every `npm test`, over the shipped
45
+ strategy examples rather than over a probe written the same afternoon. Each run
46
+ is written to JSON, every other reference to it is dropped, and the record is
47
+ parsed back from that text alone; then it is reported again from its own fills to
48
+ the same report, executed again to the same bytes, refused a replay over revised
49
+ bars, compared with itself to no movement, and refused a separation against a run
50
+ over other bars. A strategy needing a capability the driver cannot supply is
51
+ named and counted, never skipped.
52
+
53
+ **The report: a trade list, an equity curve, a drawdown and a month by month
54
+ table.** A trade is one position reference from the fill that takes it off zero
55
+ to the fill that returns it, so a pyramided entry is more entry fills on one
56
+ trade, a partial close is an exit fill that does not close it, and a reversal is
57
+ two trades. Win rate is over closed trades on the net after charges, with an
58
+ exactly zero net counted as a scratch in neither half; expectancy carries its own
59
+ standard error. None of it is readable by a script: the money entries of the
60
+ `pos` namespace stay planned and go on refusing at the call, because the moment a
61
+ script can branch on its own equity every formula joins the conformance surface.
62
+
63
+ **Every bar supplied executes and only the ones inside the window are reported.**
64
+ A bar before the window is warmup: it runs, its orders are real, and a position
65
+ opened on one is carried in with its charges paid. A window holding none of the
66
+ bars supplied is refused, OS6020, rather than reported as a flat curve, which is
67
+ what a strategy that did nothing also produces.
68
+
69
+ **The costs are the destination's, where the specification puts them.** Slippage
70
+ is measured in ticks and is adverse always, worse on a buy and worse on a sell,
71
+ and it applies to a market fill and to a stop and never to a limit. A platform
72
+ that has its own rates supplies a charge schedule; a script that states a
73
+ commission gets a schedule of one line derived from it; both at once is refused,
74
+ OS6023, because two cost models charge the same money twice or charge whichever
75
+ an engine preferred.
76
+
77
+ **A quantity is converted into units by the destination, or the run is refused.**
78
+ A quantity travels in the declaration's own unit and the destination is the party
79
+ that converts it. Lots are converted through the instrument's lot size, and a lot
80
+ on an instrument stating none is refused. Cash and a percentage of equity are
81
+ refused by name: a backtest fills in units and works out no running equity to
82
+ size against, so it can convert neither, and filling the number as written is
83
+ what it used to do.
84
+
85
+ **What it does not model, said here rather than left to be discovered.** A
86
+ bracket reaches the destination as a protective instruction attached to a tag and
87
+ the engine appends no order row for one, so a stop cannot fill in a backtest yet
88
+ and a page that says otherwise is ahead of the engine. A limit fills only where
89
+ the bar traded through it and a stop that gapped fills at the open, both of which
90
+ a host can change in the fill policy; a bar is four prices and no path, and
91
+ nothing here pretends to know which extreme came first.
92
+
93
+ The equity curve marks a trade at the size it ended up entering from the bar it
94
+ first opened, so a scale-in is marked, before its second entry, on units it did
95
+ not hold at an average it had not reached: the curve reports a drawdown the
96
+ account never had, and the maximum drawdown figures are folded from it, so a
97
+ pyramiding strategy is reported as having risked more than it did. The realised
98
+ total is unaffected. Folding the curve from the fills rather than from the trades
99
+ is what fixes it, and that is a different fold rather than a correction to this
100
+ one.
101
+
102
+ The conformance case files a second engine would be handed are not written, and
103
+ cannot be from a record alone: a case has to carry the source text and a record
104
+ carries the source hash, its line count and its file name. Nothing can recompile
105
+ a stored revision for the same reason. Both belong to the next phase, and both
106
+ are now written down instead of implied.
107
+
108
+ **Four defects found by review before any of this shipped**, each a wrong number
109
+ rather than a crash:
110
+
111
+ - A quantity stated in lots, cash or a percentage of equity was filled at the
112
+ number the script wrote, so a strategy sizing in lots of sixty five traded one
113
+ sixty fifth of what it asked for and every money figure went with it.
114
+ - `checkSettings` asked about the cost model only when the host supplied one, so
115
+ on the path almost every run takes it asked nothing: a declared commission of
116
+ minus five was charged as a credit and turned a loss into a gain. A declared
117
+ slippage below zero improved both sides of every fill through the same hole.
118
+ - A month's return was divided by the equity it had already earned, so a month
119
+ that doubled an account reported fifty percent, with the money column beside it
120
+ right.
121
+ - A gross loss driven under zero by charges gave a negative profit factor, which
122
+ is a ratio nobody can act on. It is null there now, and the field says it can
123
+ go under zero instead of calling itself a positive magnitude.
124
+
125
+ A bar time outside the range a calendar can hold, which is what nanoseconds
126
+ instead of milliseconds produce, made the monthly table NaN and then threw a bare
127
+ error with no catalogue code out of core. Such a time names no month.
128
+
129
+ **`load` hands back the inputs it resolved**, beside the engine, so that a caller
130
+ outside the engine can read the declaration's capital, commission and fill rule
131
+ without resolving an input a second time under its own rules.
132
+
133
+ **`settingsFor`'s second argument no longer names a contract it ignored.** It
134
+ took a partial settings object whose contract field it discarded in favour of the
135
+ positional one, so a caller passing a contract there silently got the other. It
136
+ is now a compiler error at the call.
137
+
138
+ ## 0.3.0
139
+
140
+ **The editor half is here: six functions, text in and data out, and a drop-in
141
+ adapter for a text component.** `src/editor` is a new tier whose index is its
142
+ only door. It imports the compiler and nothing else: no package, no browser
143
+ global, no DOM type, which the layering check has enforced for it since before
144
+ the directory existed. Nothing in it is on screen, and nothing in it is hand
145
+ written: a hand written highlighter, completion list or tooltip drifts from the
146
+ language and nobody notices for a release.
147
+
148
+ **Two new entry points resolve: `openalgo-script/editor` and
149
+ `openalgo-script/adapters/codemirror`.** They are declared now that the tier they
150
+ name exists, because an entry point that resolves to half a tier fails at your
151
+ run time rather than honestly at install. A fifteenth check,
152
+ `scripts/check-entry-points.mjs`, builds a temporary install holding exactly what
153
+ the `files` list ships, with no package of any kind beside it, and imports every
154
+ door the export map declares. That is also what says both adapters' peer
155
+ dependencies are optional in fact: neither could have loaded if it imported one.
156
+
157
+ **`highlight(source)` gives every piece of a file, in order, covering every
158
+ character exactly once.** The kind of each piece comes from the language's own
159
+ tables, so a word added to the reserved list, a mark added to an operator table
160
+ and a function added to the standard library manifest are each painted the day
161
+ they are added. The covering property is the one a host cannot do without: a
162
+ highlighter that drops one character leaves everything after it on that line
163
+ drawn one column to the left, and that arrives as a bug report about the caret.
164
+ `highlightLines(source)` is the same pieces per line, which is where a host
165
+ otherwise makes the off-by-one itself.
166
+
167
+ Comments come out of `highlight` and are recovered in one place rather than by
168
+ each host. The lexer emits none, because the parser has no use for one; the two
169
+ ways a consumer ends up doing it, reading the gaps between token spans and
170
+ scanning the text for `//`, are folklore and a second lexer respectively, and the
171
+ second is wrong inside a string literal.
172
+
173
+ **`diagnose(source)` is the whole front end**, lexer through emitter, and returns
174
+ the compiler's own diagnostics with the message and the fix the error catalogue
175
+ gives them. Not a subset: there are codes the emitter raises and nothing before
176
+ it does, so an editor that stopped after the checker would show a clean file and
177
+ then have the apply refused. A source that does not parse answers usefully rather
178
+ than throwing, which is the state a file being typed into is in most of the time.
179
+
180
+ **What that costs is now a number rather than an impression.** Two measurements
181
+ join the benchmark suite, `diagnose-heavy` and `diagnose-typing`, the second on a
182
+ file with a call bracket left open half way down it, which is what a file looks
183
+ like the moment somebody types one. A third of a millisecond and about a
184
+ millisecond, against budgets of 1.5 and 4. That is the answer to whether an
185
+ editor needs a compiler of its own: at this price it does not, and the number to
186
+ beat is in the table rather than in somebody's judgement.
187
+
188
+ **`format(source)` lays a file out in the canonical layout, now stated in
189
+ `language.md` 3.13**, and formatting never changes what a script means. That is
190
+ proved twice rather than asserted: every example and every gate script in the
191
+ repository, a hundred and nineteen of them today, is laid out again, both texts are
192
+ compiled, and the compiled programs are compared field for field; and every call
193
+ lexes its own output and compares it with the tokens that went in, so a rule that
194
+ is wrong returns your source untouched rather than a changed program. A source
195
+ that does not parse comes back byte for byte, because a character the lexer
196
+ refused produces no token and a reprint from the tokens would delete it.
197
+
198
+ The three questions a reprinter usually guesses at are put to the parser instead:
199
+ which `-` is a sign, which bracket groups an expression rather than opening an
200
+ argument list, and which `:` belongs to a ternary rather than to a type. All
201
+ three are in the tree already, and the guess is where every formatter that has
202
+ turned `a - -b` into something else began.
203
+
204
+ **`complete(source, offset)` offers what may be written there**: the library's
205
+ names, the names the file has declared and still has in scope, the named
206
+ arguments of the call being written, and the members of a namespace after a dot.
207
+ The names are the standard library manifest, the same index the checker resolves
208
+ against and the same one the example check reads its globals from, so a function
209
+ added to the library is offered the day it is added. A name is offered from the
210
+ end of the statement that declares it and inside the block that declared it,
211
+ which are the compiler's own two rules rather than a second reading of them.
212
+
213
+ A call the library names and has not implemented is offered, sorted after
214
+ everything a script may write today, and carries the error catalogue's own OS2020
215
+ sentence with its name filled in. Leaving those out would send a writer to the
216
+ documentation to find out why a name is missing; offering them unmarked walks
217
+ them into a script that will not compile.
218
+
219
+ **`hover(source, offset)` says what the word under the pointer is**, and the
220
+ sentence it shows is the cell `spec/stdlib.md` prints for that call. It is read
221
+ out of the specification at build time by a new generator rather than retyped
222
+ into the source, so a description improved in the specification is improved in
223
+ the tooltip, and a test fails if the manifest and the specification ever describe
224
+ different sets of names. A name the file declared carries the type the checker
225
+ worked out and the span it was declared at; a named colour carries its channels.
226
+
227
+ Three things a hover wants and has no machine readable source for are stated
228
+ rather than invented: a reserved word has no per-word explanation anywhere, a
229
+ name with several signatures is described by the first row the specification
230
+ states for it, and a parameter has no description of its own. Those, and what the
231
+ adapter narrows, are recorded in `spec/editor-narrowings.json`.
232
+
233
+ **`signature(source, offset)` gives the call being written, which parameter the
234
+ cursor is in, and each parameter's name, type, default and whether it is
235
+ required.** The default is the one the compiler applies, which is the trap in
236
+ this function: most defaults live in the library manifest, and the eight
237
+ declaration calls keep theirs in the emitter, so a tooltip reading the manifest
238
+ alone shows nothing beside `width?` while every plot is drawn 1.5 wide. Both are
239
+ read through one answer that `scripts/check-defaults.mjs` holds to the
240
+ specification, so a number in a tooltip and a number in a compiled program cannot
241
+ differ without the build failing.
242
+
243
+ **The adapter, `src/adapters/codemirror`, is a drop-in that draws nothing.** The
244
+ text component is a peer dependency and nothing in the adapter imports it, the
245
+ same way the chart adapter treats a chart. Both tooltips take their markup as a
246
+ required parameter with no default, so no tier of this package names a browser
247
+ global at all and every file in it loads in a worker and on a server. Offsets are
248
+ translated between the document a component holds and the normalised text every
249
+ span in this package indexes, so a file with two character line endings is
250
+ underlined in the right place. Highlighting is computed a line at a time, which
251
+ is how the component asks for it, and a test compares that against the whole-file
252
+ `highlight` over every script in the repository: 4279 lines, not one piece
253
+ different.
254
+
255
+ **Two facts the core now exposes**, because a tier above it needs them and
256
+ reading them out of a module's internals would be a second copy: what a
257
+ declaration call's omitted argument resolves to, and the channels a colour name
258
+ denotes.
259
+
260
+ Eighty-eight further tests, each naming in a comment the wrong implementation it
261
+ catches, on top of the fifty-eight the first three functions came with.
262
+ Forty-five of those implementations were then written into the source one at a
263
+ time, with every file copied first and restored from the copy by hash afterwards:
264
+ forty-three were caught by a test and two by the compiler. One more was tried and
265
+ changed nothing a caller can observe, a guard in a private function, and is left
266
+ in place and untested for rather than counted as a catch.
267
+
268
+ **The first run of that harness proved nothing and said it had.** It named the
269
+ test directory, and `node --test <directory>` fails on this runtime whatever the
270
+ directory holds, so every mutation came back caught. The harness now names the
271
+ test files and runs each of its verify commands on the clean tree before it
272
+ starts, and refuses to run at all if one of them does not pass. Five mutations
273
+ then survived, every one of them a test that could not fail: a completion list
274
+ filtered by a word the assertion was about, a signature rendering compared with
275
+ the mapping it came from, a stale cache handed an empty cache to be stale with.
276
+ All five are caught now, and a control change that nothing should catch is
277
+ checked to be caught by nothing.
278
+
10
279
  ## 0.2.0
11
280
 
12
281
  **This release is the studies surface, finished.** A script compiles in a browser
package/README.md CHANGED
@@ -17,29 +17,54 @@ can write their own engine for it.
17
17
 
18
18
  ## Status
19
19
 
20
- **`0.2.0` runs studies. It does not yet backtest, and it ships no editor.**
21
-
22
- What an install gets you today: the compiler, the engine, and the chart adapter.
23
- A script compiles in milliseconds in a browser tab and computes, bar by bar, the
24
- same numbers everywhere. One hundred and one independently written studies
25
- compile, load and run, and five of them match arithmetic transcribed from the
26
- specification alone, bit for bit, warmups included.
20
+ **`0.4.0` runs studies, backtests strategies, and ships the language
21
+ intelligence an editor needs.**
22
+
23
+ What an install gets you today: the compiler, the engine, the chart adapter and
24
+ the backtest. A script compiles in milliseconds in a browser tab and computes,
25
+ bar by bar, the same numbers everywhere. One hundred and one independently
26
+ written studies compile, load and run, and five of them match arithmetic
27
+ transcribed from the specification alone, bit for bit, warmups included.
28
+
29
+ A strategy is walked over a range of bars and what comes back is a document
30
+ rather than a number: the program, the bars, the settings, every frame, every
31
+ fill, the ledger and the report. That document replays to the same report and
32
+ reruns to the same bytes, and `npm test` proves it over the shipped strategy
33
+ examples on every run rather than asserting it in a page. Two records can be put
34
+ beside each other, and a pair over different bars is reported incomparable
35
+ instead of being subtracted into a table that reads like a result.
27
36
 
28
37
  What it does **not** do yet, stated plainly because the registry page is the
29
38
  first thing a stranger reads:
30
39
 
31
- - **No backtest and no report.** A strategy can place orders through a host, and
32
- the order ledger refuses what the specification says to refuse, but the
33
- equity curve, the drawdown, the trade list and the run you can reproduce
34
- months later are Phase 5 and are not here.
35
- - **No editor.** The six headless language functions, highlight, complete,
36
- diagnose, hover, signature and format, are Phase 4 and are not built. You get
37
- a compiler, not an authoring experience.
38
- - **No second engine.** The Python engine and the conformance suite that would
39
- prove two engines agree are Phase 6. Until an engine somebody else wrote
40
- passes that suite, the portability claim is a design, not a result.
41
-
42
- The version is `0.2.0` rather than `1.0` because of that list. The studies
40
+ - **The backtest does not model everything, and says which.** A bracket's stop
41
+ cannot fill, because the engine appends no order row for a bracket. A quantity
42
+ stated in cash or in a percentage of equity is refused rather than filled,
43
+ because a backtest works out no running equity to size against. The equity
44
+ curve marks a trade at the size it ended up entering, so a strategy that
45
+ scales in is reported with a drawdown deeper than the account had. A script
46
+ still cannot read its own equity mid-run. The `0.4.0` entry in
47
+ [`CHANGELOG.md`](./CHANGELOG.md) is the full list, and every item on it is
48
+ there because somebody would otherwise find it inside a report they had
49
+ already believed.
50
+ - **No editor on screen, and that is the design.** The six headless functions are
51
+ here and resolve as `openalgo-script/editor`: highlight, complete, diagnose,
52
+ hover, signature and format, text in and data out, with no DOM at any tier. The
53
+ text component, the panel, the apply button, saving and the theme are yours,
54
+ and the drop-in adapter for one editor component wires the six into it without
55
+ drawing anything itself. What each function gives you, and what stays yours, is
56
+ in
57
+ [`docs/integrating/the-editor-half.md`](./docs/integrating/the-editor-half.md).
58
+ The language server that would put the same errors in a desktop editor is the
59
+ rest of Phase 4 and is not written.
60
+ - **No second engine, and no case files to hand one.** The Python engine and the
61
+ conformance suite that would prove two engines agree are Phase 6. A run record
62
+ is the case, but the files a suite is run from cannot be written from one yet:
63
+ a case has to carry the source text and a record carries the source's hash.
64
+ Until an engine somebody else wrote passes that suite, the portability claim is
65
+ a design, not a result.
66
+
67
+ The version is `0.4.0` rather than `1.0` because of that list. The studies
43
68
  surface is the part that is finished, and it is the part to build on.
44
69
 
45
70
  `ROADMAP.md` says what each phase owes before it is allowed to finish. The
@@ -143,10 +168,11 @@ and the dependencies only ever point one way.
143
168
  | \ /
144
169
  | .../adapters/charts <- knows both. The only place that does
145
170
  |
146
- .../editor <- designed, not built
171
+ .../editor <- the six headless functions. No DOM, no
172
+ | package, nothing on screen
147
173
  |
148
- .../adapters/codemirror <- designed, not built. Would know the
149
- editor component, and nothing else would
174
+ .../adapters/codemirror <- knows both. Takes its markup from the
175
+ host, so it draws nothing either
150
176
  ```
151
177
 
152
178
  The language ships as one package with an entry point per tier, so a consumer who
@@ -154,17 +180,20 @@ wants only the compiler never pays for an adapter. A tier is declared only once
154
180
  exists: an entry point that resolves to nothing fails at a consumer's run time
155
181
  rather than honestly at install.
156
182
 
157
- These two resolve today, from an install holding nothing but the manifest and the
158
- built output:
183
+ These four resolve today, from an install holding nothing but the manifest and the
184
+ built output. That is a check rather than a sentence: `scripts/check-entry-points.mjs`
185
+ builds exactly that install in a temporary directory, with no package of any kind
186
+ beside it, and imports every one of them.
159
187
 
160
188
  | Entry point | Is | Depends on |
161
189
  |---|---|---|
162
190
  | `openalgo-script` | Compiler and engine | Nothing |
191
+ | `openalgo-script/editor` | The six headless language functions an editor needs | The compiler |
163
192
  | `openalgo-script/adapters/charts` | Turns a compiled study into a chart's indicator descriptor | The compiler and a chart |
193
+ | `openalgo-script/adapters/codemirror` | Wires the six into a text component | The editor half and a text component |
164
194
 
165
- The editor half and its drop-in adapter are in the roadmap rather than in the
166
- export map, and so is the server-side engine, which is a separate package in
167
- another language. The roadmap says which phase owes each of them.
195
+ The server-side engine is not among them: it is a separate package in another
196
+ language, and the roadmap says which phase owes it.
168
197
 
169
198
  An adapter is the only thing allowed to know two worlds at once, which is what
170
199
  makes it the piece a platform replaces rather than the piece they patch. A
@@ -173,8 +202,10 @@ else. A platform with its own editor does the same on that side.
173
202
 
174
203
  This is enforced rather than promised. `scripts/check-layering.mjs` runs in
175
204
  continuous integration and fails the build if the compiler imports a chart, if
176
- anything outside an adapter imports a package, or if the compiler or the editor
177
- half so much as mentions a browser global.
205
+ anything outside an adapter imports a package, or if anything under `src` so much
206
+ as mentions a browser global. That last one holds of the adapters too: the editor
207
+ adapter takes a tooltip's markup from the host rather than building an element,
208
+ so every file in the package loads in a worker and on a server.
178
209
 
179
210
  ## Taking it, one step at a time
180
211
 
@@ -184,7 +215,7 @@ Each row is usable on its own. Nobody has to take the next one.
184
215
  |---|---|---|
185
216
  | Scripts that produce numbers | `openalgo-script`, and the six-item host interface | An afternoon |
186
217
  | Those studies on your chart | the charts adapter, plus a chart | Days. Free if the chart is the one this adapter already targets |
187
- | Traders authoring in your app | The editor half, once it is built, and your own text component or the drop-in one | Days |
218
+ | Traders authoring in your app | The editor half, and your own text component or the drop-in adapter | Days |
188
219
  | Traders trading from it | Wire the order half of the host interface to your order API | About a week |
189
220
  | To run it on your own stack | Implement the compiled program format in your language, then pass the conformance suite | Weeks |
190
221
 
@@ -215,8 +246,11 @@ fails the build.
215
246
  | Two engines agree to the last decimal | The conformance suite, run against both. A disagreement blocks a release | Phase 6 gate |
216
247
  | A runaway script stops | Instruction, memory and wall clock budgets, counters in the loop the engine owns. `tests/engine/budget.test.ts` | Enforced |
217
248
  | A failing script does not take anything else down | One script's failure is a diagnostic on that script and reaches nothing else | Enforced |
249
+ | Every entry point in the export map resolves from a real install | `scripts/check-entry-points.mjs`. Each one is imported from a temporary install built from the `files` list alone, with no package beside it, which is also what says both adapters' peer dependencies are optional in fact and not only in the manifest | Enforced |
250
+ | A completion, a tooltip and a default come from the compiler, not from a list | The names are the standard library manifest the checker resolves against; what a call is for is the cell `spec/stdlib.md` prints, read at build time by `scripts/generate-library-prose.mjs`; a default is the one `scripts/check-defaults.mjs` holds the compiler to. `tests/editor/hover.test.ts` fails if the manifest and the specification describe different sets of names | Enforced |
251
+ | Laying a script out again cannot change what it computes | `tests/editor/format.test.ts`. Every example and every gate script is formatted, both texts are compiled, and the compiled programs are compared. Each call also checks itself against the lexer, so a rule that is wrong returns your source untouched rather than a changed program | Enforced |
218
252
  | A saved script never stops working | The language version is declared per file and old front ends are retained | Phase 7, with a test per retained version |
219
- | Performance | Six benchmarks with recorded budgets, run by `npm test` and in continuous integration. A regression past a budget fails the build | Enforced |
253
+ | Performance | Eight benchmarks with recorded budgets, run by `npm test` and in continuous integration. A regression past a budget fails the build | Enforced |
220
254
 
221
255
  The rows marked as gates are not promises we intend to keep. They are conditions a
222
256
  phase does not finish without, and each one is written into the roadmap beside the
@@ -75,6 +75,23 @@ export interface ChartTableOptions {
75
75
  readonly borderWidth: number;
76
76
  /** The backdrop behind the whole grid, which is the grid's own `bgColor`. */
77
77
  readonly background?: string;
78
+ /**
79
+ * Column widths in media pixels, one per column.
80
+ *
81
+ * The chart's own default is one flat width for every column, which is a
82
+ * width chosen without seeing the text. A grid whose first column says
83
+ * "Moving averages" and whose second says "RSI: 27.22" has two columns that
84
+ * want different room, and one number cannot give it to both.
85
+ */
86
+ readonly cellWidth?: readonly number[];
87
+ /**
88
+ * `'auto'` to shrink a cell's type until its text fits the cell it is in.
89
+ *
90
+ * The chart measures the text it is about to draw, which nothing upstream of
91
+ * it can do, so this is what makes a column width that is slightly wrong
92
+ * merely slightly loose instead of two cells written over each other.
93
+ */
94
+ readonly fontSize?: number | 'auto';
78
95
  }
79
96
  /** A grid of cells pinned to a corner, and the options it is drawn with. */
80
97
  export interface ChartGrid {
@@ -1 +1 @@
1
- {"version":3,"file":"surfaces.d.ts","sourceRoot":"","sources":["../../../src/adapters/charts/surfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE1F,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,UA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CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;IAChD,oBAAoB,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAChF"}
@@ -47,9 +47,91 @@ function oneTable(declared, lookup, written) {
47
47
  position: CORNERS[position] ?? 'top-right',
48
48
  borderWidth: numberField(declared.options.borderWidth, lookup, 0),
49
49
  ...(bgColour === undefined ? {} : { background: cssColour(bgColour) }),
50
+ ...(cols > 0 ? { cellWidth: columnWidths(grid, cols) } : {}),
51
+ // The chart measures the text it is about to draw and shrinks it to fit,
52
+ // which is the half of this that cannot be done from here.
53
+ fontSize: 'auto',
50
54
  },
51
55
  };
52
56
  }
57
+ /**
58
+ * How wide each column has to be, in media pixels.
59
+ *
60
+ * The chart's default is one width for every column, chosen without seeing the
61
+ * text, and a grid whose header says "Moving averages" over cells saying
62
+ * "RSI: 27.22" has one column bleeding into the next. Nothing downstream can
63
+ * choose better, because by the time the chart has the grid it has lost which
64
+ * cells belong together; and nothing upstream can, because the script declares
65
+ * a size and writes text, not a layout.
66
+ *
67
+ * **This is an estimate, and it is allowed to be.** A real width needs the font
68
+ * the chart will draw with, and only the chart has it. So the width is counted
69
+ * off the characters and the chart's own `fontSize: 'auto'` corrects whatever
70
+ * this gets wrong: too narrow and the type shrinks a little, too wide and the
71
+ * column is a little loose. Either is a table that reads. The failure this
72
+ * replaces was neither.
73
+ *
74
+ * Delete it when the chart can size a column from its own measurements. It
75
+ * exists because that is not a thing it can be asked to do yet.
76
+ */
77
+ function columnWidths(grid, cols) {
78
+ const widths = [];
79
+ for (let col = 0; col < cols; col += 1) {
80
+ let widest = 0;
81
+ for (const row of grid) {
82
+ const text = row[col]?.text ?? '';
83
+ if (text.length > 0)
84
+ widest = Math.max(widest, textWidth(text));
85
+ }
86
+ widths.push(Math.min(MAX_COLUMN, Math.max(MIN_COLUMN, Math.ceil(widest) + CELL_PADDING * 2)));
87
+ }
88
+ return widths;
89
+ }
90
+ /**
91
+ * Roughly how wide a string is at the type size the chart starts from.
92
+ *
93
+ * Counted rather than measured, and counted in two weights rather than one: a
94
+ * column of "Histogram: -7.01" is half punctuation and narrow digits, and
95
+ * treating every character as an em-and-a-bit makes that column half again as
96
+ * wide as it needs to be while "Moving averages" stays too narrow. Two weights
97
+ * is not typography, but it is enough to tell those two apart.
98
+ */
99
+ function textWidth(text) {
100
+ let width = 0;
101
+ for (const character of text) {
102
+ width += NARROW.has(character) ? BASE_SIZE * NARROW_EM : BASE_SIZE * WIDE_EM;
103
+ }
104
+ return width;
105
+ }
106
+ /** The characters that take noticeably less than an average advance. */
107
+ const NARROW = new Set([...' .,:;!|ijlt1IJfr()[]{}-']);
108
+ /**
109
+ * The type size the widths are counted at.
110
+ *
111
+ * The chart's own default row is 18 media pixels and it draws at 62% of the
112
+ * row, so this is the size a cell gets before anything shrinks it. Counting at
113
+ * a larger size would reserve room the text never uses.
114
+ */
115
+ const BASE_SIZE = 11;
116
+ const NARROW_EM = 0.32;
117
+ const WIDE_EM = 0.56;
118
+ /** What the chart insets a cell's text by, on each side. */
119
+ const CELL_PADDING = 4;
120
+ /**
121
+ * The narrowest a column is drawn.
122
+ *
123
+ * A column of one-character cells sized to its content is a sliver, and a grid
124
+ * of slivers reads as a rendering fault rather than as a narrow column.
125
+ */
126
+ const MIN_COLUMN = 56;
127
+ /**
128
+ * The widest a column is drawn.
129
+ *
130
+ * A cell holding a sentence would otherwise push the grid past the pane it is
131
+ * pinned inside, taking the chart with it. Past this the type shrinks instead,
132
+ * which is the chart's job and it is better at it.
133
+ */
134
+ const MAX_COLUMN = 220;
53
135
  /**
54
136
  * One written cell, or none.
55
137
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../src/adapters/charts/tables.ts"],"names":[],"mappings":"AAoDA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CA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AAG,CAAC,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;;;;;;;;;;GAWG;AACH,SAAS,OAAO,CAAC,IAAc,EAAE,QAA4B;IAC3D,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACpD,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7E,CAAC,CAAE,IAAI,CAAC,KAAwB;QAChC,CAAC,CAAC,MAAM,CAAC;IACX,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC;IACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;QAC9D,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;QACxD,KAAK;KACN,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { EditorView } from './contract.js';
2
+ /**
3
+ * Lays the document out again, and says whether anything changed.
4
+ *
5
+ * ```ts
6
+ * keymap.of([{ key: "Shift-Alt-f", run: formatDocument }])
7
+ * ```
8
+ *
9
+ * False where the document is already laid out, which is what an editor command
10
+ * returns when it has nothing to do: the key press then falls through to
11
+ * whatever else is bound to it rather than being swallowed.
12
+ */
13
+ export declare function formatDocument(view: EditorView): boolean;
14
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/commands.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAaxD"}