openalgo-script 0.2.0 → 0.5.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.
- package/CHANGELOG.md +1198 -0
- package/README.md +127 -40
- package/dist/adapters/charts/driving.d.ts +50 -0
- package/dist/adapters/charts/driving.d.ts.map +1 -0
- package/dist/adapters/charts/driving.js +57 -0
- package/dist/adapters/charts/driving.js.map +1 -0
- package/dist/adapters/charts/run.d.ts +20 -0
- package/dist/adapters/charts/run.d.ts.map +1 -1
- package/dist/adapters/charts/run.js +83 -16
- package/dist/adapters/charts/run.js.map +1 -1
- package/dist/adapters/charts/surfaces.d.ts +17 -0
- package/dist/adapters/charts/surfaces.d.ts.map +1 -1
- package/dist/adapters/charts/tables.js +82 -0
- package/dist/adapters/charts/tables.js.map +1 -1
- package/dist/adapters/charts/venue.d.ts +73 -0
- package/dist/adapters/charts/venue.d.ts.map +1 -0
- package/dist/adapters/charts/venue.js +104 -0
- package/dist/adapters/charts/venue.js.map +1 -0
- package/dist/adapters/codemirror/commands.d.ts +14 -0
- package/dist/adapters/codemirror/commands.d.ts.map +1 -0
- package/dist/adapters/codemirror/commands.js +52 -0
- package/dist/adapters/codemirror/commands.js.map +1 -0
- package/dist/adapters/codemirror/completion.d.ts +15 -0
- package/dist/adapters/codemirror/completion.d.ts.map +1 -0
- package/dist/adapters/codemirror/completion.js +64 -0
- package/dist/adapters/codemirror/completion.js.map +1 -0
- package/dist/adapters/codemirror/contract.d.ts +156 -0
- package/dist/adapters/codemirror/contract.d.ts.map +1 -0
- package/dist/adapters/codemirror/contract.js +42 -0
- package/dist/adapters/codemirror/contract.js.map +1 -0
- package/dist/adapters/codemirror/index.d.ts +43 -0
- package/dist/adapters/codemirror/index.d.ts.map +1 -0
- package/dist/adapters/codemirror/index.js +8 -0
- package/dist/adapters/codemirror/index.js.map +1 -0
- package/dist/adapters/codemirror/lint.d.ts +17 -0
- package/dist/adapters/codemirror/lint.d.ts.map +1 -0
- package/dist/adapters/codemirror/lint.js +62 -0
- package/dist/adapters/codemirror/lint.js.map +1 -0
- package/dist/adapters/codemirror/positions.d.ts +16 -0
- package/dist/adapters/codemirror/positions.d.ts.map +1 -0
- package/dist/adapters/codemirror/positions.js +65 -0
- package/dist/adapters/codemirror/positions.js.map +1 -0
- package/dist/adapters/codemirror/stream.d.ts +23 -0
- package/dist/adapters/codemirror/stream.d.ts.map +1 -0
- package/dist/adapters/codemirror/stream.js +70 -0
- package/dist/adapters/codemirror/stream.js.map +1 -0
- package/dist/adapters/codemirror/tokens.d.ts +44 -0
- package/dist/adapters/codemirror/tokens.d.ts.map +1 -0
- package/dist/adapters/codemirror/tokens.js +34 -0
- package/dist/adapters/codemirror/tokens.js.map +1 -0
- package/dist/adapters/codemirror/tooltips.d.ts +35 -0
- package/dist/adapters/codemirror/tooltips.d.ts.map +1 -0
- package/dist/adapters/codemirror/tooltips.js +108 -0
- package/dist/adapters/codemirror/tooltips.js.map +1 -0
- package/dist/core/accounting/analysis.d.ts +111 -0
- package/dist/core/accounting/analysis.d.ts.map +1 -0
- package/dist/core/accounting/analysis.js +123 -0
- package/dist/core/accounting/analysis.js.map +1 -0
- package/dist/core/accounting/charges.d.ts +136 -0
- package/dist/core/accounting/charges.d.ts.map +1 -0
- package/dist/core/accounting/charges.js +362 -0
- package/dist/core/accounting/charges.js.map +1 -0
- package/dist/core/accounting/equity.d.ts +191 -0
- package/dist/core/accounting/equity.d.ts.map +1 -0
- package/dist/core/accounting/equity.js +167 -0
- package/dist/core/accounting/equity.js.map +1 -0
- package/dist/core/accounting/index.d.ts +46 -0
- package/dist/core/accounting/index.d.ts.map +1 -0
- package/dist/core/accounting/index.js +37 -0
- package/dist/core/accounting/index.js.map +1 -0
- package/dist/core/accounting/markers.d.ts +43 -0
- package/dist/core/accounting/markers.d.ts.map +1 -0
- package/dist/core/accounting/markers.js +64 -0
- package/dist/core/accounting/markers.js.map +1 -0
- package/dist/core/accounting/monthly.d.ts +52 -0
- package/dist/core/accounting/monthly.d.ts.map +1 -0
- package/dist/core/accounting/monthly.js +99 -0
- package/dist/core/accounting/monthly.js.map +1 -0
- package/dist/core/accounting/report.d.ts +41 -0
- package/dist/core/accounting/report.d.ts.map +1 -0
- package/dist/core/accounting/report.js +65 -0
- package/dist/core/accounting/report.js.map +1 -0
- package/dist/core/accounting/shapes.d.ts +70 -0
- package/dist/core/accounting/shapes.d.ts.map +1 -0
- package/dist/core/accounting/shapes.js +21 -0
- package/dist/core/accounting/shapes.js.map +1 -0
- package/dist/core/accounting/statistics.d.ts +87 -0
- package/dist/core/accounting/statistics.d.ts.map +1 -0
- package/dist/core/accounting/statistics.js +268 -0
- package/dist/core/accounting/statistics.js.map +1 -0
- package/dist/core/accounting/trades.d.ts +118 -0
- package/dist/core/accounting/trades.d.ts.map +1 -0
- package/dist/core/accounting/trades.js +186 -0
- package/dist/core/accounting/trades.js.map +1 -0
- package/dist/core/backtest/case.d.ts +60 -0
- package/dist/core/backtest/case.d.ts.map +1 -0
- package/dist/core/backtest/case.js +319 -0
- package/dist/core/backtest/case.js.map +1 -0
- package/dist/core/backtest/compare.d.ts +38 -0
- package/dist/core/backtest/compare.d.ts.map +1 -0
- package/dist/core/backtest/compare.js +191 -0
- package/dist/core/backtest/compare.js.map +1 -0
- package/dist/core/backtest/declaration.d.ts +52 -0
- package/dist/core/backtest/declaration.d.ts.map +1 -0
- package/dist/core/backtest/declaration.js +48 -0
- package/dist/core/backtest/declaration.js.map +1 -0
- package/dist/core/backtest/deliver.d.ts +93 -0
- package/dist/core/backtest/deliver.d.ts.map +1 -0
- package/dist/core/backtest/deliver.js +94 -0
- package/dist/core/backtest/deliver.js.map +1 -0
- package/dist/core/backtest/drive.d.ts +87 -0
- package/dist/core/backtest/drive.d.ts.map +1 -0
- package/dist/core/backtest/drive.js +312 -0
- package/dist/core/backtest/drive.js.map +1 -0
- package/dist/core/backtest/index.d.ts +58 -0
- package/dist/core/backtest/index.d.ts.map +1 -0
- package/dist/core/backtest/index.js +47 -0
- package/dist/core/backtest/index.js.map +1 -0
- package/dist/core/backtest/range.d.ts +84 -0
- package/dist/core/backtest/range.d.ts.map +1 -0
- package/dist/core/backtest/range.js +90 -0
- package/dist/core/backtest/range.js.map +1 -0
- package/dist/core/backtest/record.d.ts +299 -0
- package/dist/core/backtest/record.d.ts.map +1 -0
- package/dist/core/backtest/record.js +243 -0
- package/dist/core/backtest/record.js.map +1 -0
- package/dist/core/backtest/replay.d.ts +48 -0
- package/dist/core/backtest/replay.d.ts.map +1 -0
- package/dist/core/backtest/replay.js +137 -0
- package/dist/core/backtest/replay.js.map +1 -0
- package/dist/core/backtest/resting.d.ts +62 -0
- package/dist/core/backtest/resting.d.ts.map +1 -0
- package/dist/core/backtest/resting.js +59 -0
- package/dist/core/backtest/resting.js.map +1 -0
- package/dist/core/backtest/settings.d.ts +117 -0
- package/dist/core/backtest/settings.d.ts.map +1 -0
- package/dist/core/backtest/settings.js +207 -0
- package/dist/core/backtest/settings.js.map +1 -0
- package/dist/core/backtest/simulate.d.ts +258 -0
- package/dist/core/backtest/simulate.d.ts.map +1 -0
- package/dist/core/backtest/simulate.js +335 -0
- package/dist/core/backtest/simulate.js.map +1 -0
- package/dist/core/catalogue/catalogue.generated.d.ts +66 -0
- package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -1
- package/dist/core/catalogue/catalogue.generated.js +6 -0
- package/dist/core/catalogue/catalogue.generated.js.map +1 -1
- package/dist/core/catalogue/values.generated.d.ts +24 -0
- package/dist/core/catalogue/values.generated.d.ts.map +1 -1
- package/dist/core/check/index.d.ts +2 -1
- package/dist/core/check/index.d.ts.map +1 -1
- package/dist/core/check/index.js +1 -1
- package/dist/core/check/index.js.map +1 -1
- package/dist/core/check/library-orders.js +2 -2
- package/dist/core/check/library-orders.js.map +1 -1
- package/dist/core/check/library-prose.generated.d.ts +16 -0
- package/dist/core/check/library-prose.generated.d.ts.map +1 -0
- package/dist/core/check/library-prose.generated.js +353 -0
- package/dist/core/check/library-prose.generated.js.map +1 -0
- package/dist/core/check/surface.d.ts +24 -0
- package/dist/core/check/surface.d.ts.map +1 -1
- package/dist/core/check/surface.js +29 -0
- package/dist/core/check/surface.js.map +1 -1
- package/dist/core/emit/canonical.d.ts +22 -8
- package/dist/core/emit/canonical.d.ts.map +1 -1
- package/dist/core/emit/canonical.js +67 -6
- package/dist/core/emit/canonical.js.map +1 -1
- package/dist/core/emit/defaults.d.ts +35 -16
- package/dist/core/emit/defaults.d.ts.map +1 -1
- package/dist/core/emit/defaults.js +66 -0
- package/dist/core/emit/defaults.js.map +1 -1
- package/dist/core/emit/index.d.ts +2 -0
- package/dist/core/emit/index.d.ts.map +1 -1
- package/dist/core/emit/index.js +2 -0
- package/dist/core/emit/index.js.map +1 -1
- package/dist/core/engine/arithmetic.d.ts +6 -25
- package/dist/core/engine/arithmetic.d.ts.map +1 -1
- package/dist/core/engine/arithmetic.js +48 -3
- package/dist/core/engine/arithmetic.js.map +1 -1
- package/dist/core/engine/index.d.ts +2 -2
- package/dist/core/engine/index.d.ts.map +1 -1
- package/dist/core/engine/index.js +2 -2
- package/dist/core/engine/index.js.map +1 -1
- package/dist/core/engine/library/arrays.d.ts.map +1 -1
- package/dist/core/engine/library/arrays.js +8 -2
- package/dist/core/engine/library/arrays.js.map +1 -1
- package/dist/core/engine/library/code-points.d.ts +40 -0
- package/dist/core/engine/library/code-points.d.ts.map +1 -0
- package/dist/core/engine/library/code-points.js +74 -0
- package/dist/core/engine/library/code-points.js.map +1 -0
- package/dist/core/engine/library/index.d.ts +5 -0
- package/dist/core/engine/library/index.d.ts.map +1 -1
- package/dist/core/engine/library/index.js +5 -0
- package/dist/core/engine/library/index.js.map +1 -1
- package/dist/core/engine/library/text.d.ts.map +1 -1
- package/dist/core/engine/library/text.js +51 -34
- package/dist/core/engine/library/text.js.map +1 -1
- package/dist/core/engine/load.d.ts +35 -1
- package/dist/core/engine/load.d.ts.map +1 -1
- package/dist/core/engine/load.js +63 -0
- package/dist/core/engine/load.js.map +1 -1
- package/dist/core/engine/verify-tables.d.ts.map +1 -1
- package/dist/core/engine/verify-tables.js +41 -0
- package/dist/core/engine/verify-tables.js.map +1 -1
- package/dist/core/index.d.ts +43 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +23 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/stdlib/index.d.ts +1 -1
- package/dist/core/stdlib/index.d.ts.map +1 -1
- package/dist/core/stdlib/index.js +1 -1
- package/dist/core/stdlib/index.js.map +1 -1
- package/dist/core/stdlib/maths/index.d.ts +1 -1
- package/dist/core/stdlib/maths/index.d.ts.map +1 -1
- package/dist/core/stdlib/maths/index.js +1 -1
- package/dist/core/stdlib/maths/index.js.map +1 -1
- package/dist/core/stdlib/maths/rounding.d.ts +5 -0
- package/dist/core/stdlib/maths/rounding.d.ts.map +1 -1
- package/dist/core/stdlib/maths/rounding.js +19 -1
- package/dist/core/stdlib/maths/rounding.js.map +1 -1
- package/dist/core/version/version.generated.d.ts +1 -1
- package/dist/core/version/version.generated.js +1 -1
- package/dist/editor/complete.d.ts +40 -0
- package/dist/editor/complete.d.ts.map +1 -0
- package/dist/editor/complete.js +206 -0
- package/dist/editor/complete.js.map +1 -0
- package/dist/editor/diagnose.d.ts +18 -0
- package/dist/editor/diagnose.d.ts.map +1 -0
- package/dist/editor/diagnose.js +70 -0
- package/dist/editor/diagnose.js.map +1 -0
- package/dist/editor/format.d.ts +11 -0
- package/dist/editor/format.d.ts.map +1 -0
- package/dist/editor/format.js +50 -0
- package/dist/editor/format.js.map +1 -0
- package/dist/editor/highlight.d.ts +28 -0
- package/dist/editor/highlight.d.ts.map +1 -0
- package/dist/editor/highlight.js +65 -0
- package/dist/editor/highlight.js.map +1 -0
- package/dist/editor/hover.d.ts +40 -0
- package/dist/editor/hover.d.ts.map +1 -0
- package/dist/editor/hover.js +147 -0
- package/dist/editor/hover.js.map +1 -0
- package/dist/editor/index.d.ts +60 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +7 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/kinds.d.ts +27 -0
- package/dist/editor/kinds.d.ts.map +1 -0
- package/dist/editor/kinds.js +118 -0
- package/dist/editor/kinds.js.map +1 -0
- package/dist/editor/layout.d.ts +47 -0
- package/dist/editor/layout.d.ts.map +1 -0
- package/dist/editor/layout.js +135 -0
- package/dist/editor/layout.js.map +1 -0
- package/dist/editor/manifest.d.ts +47 -0
- package/dist/editor/manifest.d.ts.map +1 -0
- package/dist/editor/manifest.js +93 -0
- package/dist/editor/manifest.js.map +1 -0
- package/dist/editor/reading.d.ts +41 -0
- package/dist/editor/reading.d.ts.map +1 -0
- package/dist/editor/reading.js +51 -0
- package/dist/editor/reading.js.map +1 -0
- package/dist/editor/scan.d.ts +26 -0
- package/dist/editor/scan.d.ts.map +1 -0
- package/dist/editor/scan.js +139 -0
- package/dist/editor/scan.js.map +1 -0
- package/dist/editor/scope.d.ts +19 -0
- package/dist/editor/scope.d.ts.map +1 -0
- package/dist/editor/scope.js +99 -0
- package/dist/editor/scope.js.map +1 -0
- package/dist/editor/signature.d.ts +38 -0
- package/dist/editor/signature.d.ts.map +1 -0
- package/dist/editor/signature.js +112 -0
- package/dist/editor/signature.js.map +1 -0
- package/dist/editor/site.d.ts +46 -0
- package/dist/editor/site.d.ts.map +1 -0
- package/dist/editor/site.js +184 -0
- package/dist/editor/site.js.map +1 -0
- package/dist/editor/spacing.d.ts +29 -0
- package/dist/editor/spacing.d.ts.map +1 -0
- package/dist/editor/spacing.js +116 -0
- package/dist/editor/spacing.js.map +1 -0
- package/package.json +42 -3
- package/spec/README.md +2 -1
- package/spec/errors.json +141 -1
- package/src/adapters/charts/driving.ts +109 -0
- package/src/adapters/charts/run.ts +120 -28
- package/src/adapters/charts/surfaces.ts +17 -0
- package/src/adapters/charts/tables.ts +88 -0
- package/src/adapters/charts/venue.ts +132 -0
- package/src/adapters/codemirror/commands.ts +53 -0
- package/src/adapters/codemirror/completion.ts +74 -0
- package/src/adapters/codemirror/contract.ts +156 -0
- package/src/adapters/codemirror/index.ts +66 -0
- package/src/adapters/codemirror/lint.ts +66 -0
- package/src/adapters/codemirror/positions.ts +79 -0
- package/src/adapters/codemirror/stream.ts +87 -0
- package/src/adapters/codemirror/tokens.ts +64 -0
- package/src/adapters/codemirror/tooltips.ts +113 -0
- package/src/core/accounting/analysis.ts +188 -0
- package/src/core/accounting/charges.ts +452 -0
- package/src/core/accounting/equity.ts +314 -0
- package/src/core/accounting/index.ts +51 -0
- package/src/core/accounting/markers.ts +95 -0
- package/src/core/accounting/monthly.ts +137 -0
- package/src/core/accounting/report.ts +94 -0
- package/src/core/accounting/shapes.ts +73 -0
- package/src/core/accounting/statistics.ts +387 -0
- package/src/core/accounting/trades.ts +313 -0
- package/src/core/backtest/case.ts +395 -0
- package/src/core/backtest/compare.ts +246 -0
- package/src/core/backtest/declaration.ts +97 -0
- package/src/core/backtest/deliver.ts +161 -0
- package/src/core/backtest/drive.ts +468 -0
- package/src/core/backtest/index.ts +64 -0
- package/src/core/backtest/range.ts +137 -0
- package/src/core/backtest/record.ts +470 -0
- package/src/core/backtest/replay.ts +168 -0
- package/src/core/backtest/resting.ts +125 -0
- package/src/core/backtest/settings.ts +280 -0
- package/src/core/backtest/simulate.ts +499 -0
- package/src/core/catalogue/catalogue.generated.ts +6 -0
- package/src/core/catalogue/values.generated.ts +6 -0
- package/src/core/check/index.ts +3 -0
- package/src/core/check/library-orders.ts +2 -2
- package/src/core/check/library-prose.generated.ts +367 -0
- package/src/core/check/surface.ts +34 -0
- package/src/core/emit/canonical.ts +67 -9
- package/src/core/emit/defaults.ts +70 -0
- package/src/core/emit/index.ts +2 -0
- package/src/core/engine/arithmetic.ts +23 -3
- package/src/core/engine/index.ts +2 -2
- package/src/core/engine/library/arrays.ts +8 -2
- package/src/core/engine/library/code-points.ts +73 -0
- package/src/core/engine/library/index.ts +6 -0
- package/src/core/engine/library/text.ts +53 -35
- package/src/core/engine/load.ts +84 -2
- package/src/core/engine/verify-tables.ts +43 -0
- package/src/core/index.ts +100 -2
- package/src/core/stdlib/index.ts +1 -0
- package/src/core/stdlib/maths/index.ts +1 -0
- package/src/core/stdlib/maths/rounding.ts +23 -1
- package/src/core/version/version.generated.ts +1 -1
- package/src/editor/complete.ts +266 -0
- package/src/editor/diagnose.ts +71 -0
- package/src/editor/format.ts +85 -0
- package/src/editor/highlight.ts +110 -0
- package/src/editor/hover.ts +199 -0
- package/src/editor/index.ts +65 -0
- package/src/editor/kinds.ts +157 -0
- package/src/editor/layout.ts +189 -0
- package/src/editor/manifest.ts +119 -0
- package/src/editor/reading.ts +69 -0
- package/src/editor/scan.ts +162 -0
- package/src/editor/scope.ts +122 -0
- package/src/editor/signature.ts +150 -0
- package/src/editor/site.ts +233 -0
- package/src/editor/spacing.ts +132 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/contract.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The editor component's own shapes, as this adapter targets them.
|
|
3
|
+
*
|
|
4
|
+
* **Why they are declared here rather than imported.** The editor component is a
|
|
5
|
+
* peer dependency: a host that wants a text area installs it, and a host that
|
|
6
|
+
* wants only the language must not be made to. This repository therefore does
|
|
7
|
+
* not install it, cannot type check against it, and would fail its own layering
|
|
8
|
+
* check the moment a file here imported it. It is the same decision the chart
|
|
9
|
+
* adapter took, for the same reason, and `src/adapters/charts/contract.ts` says
|
|
10
|
+
* it at length.
|
|
11
|
+
*
|
|
12
|
+
* So the shapes this produces values for are declared below and the host's own
|
|
13
|
+
* build is where the two meet. Each one is a one line check that costs a host
|
|
14
|
+
* nothing and fails to compile if this file has drifted:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import type { StreamParser } from "<the editor's language package>";
|
|
18
|
+
* import type { CompletionSource } from "<the editor's completion package>";
|
|
19
|
+
* import type { Diagnostic } from "<the editor's lint package>";
|
|
20
|
+
*
|
|
21
|
+
* const parser: StreamParser<unknown> = openscriptStream;
|
|
22
|
+
* const source: CompletionSource = openscriptCompletion;
|
|
23
|
+
* const linter: (view: EditorView) => Diagnostic[] = openscriptLint;
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* **That line catches a value of the wrong shape and not an argument of the
|
|
27
|
+
* wrong shape.** A method's parameters are compared in both directions, so a
|
|
28
|
+
* hook declared here as taking something the editor never passes still assigns.
|
|
29
|
+
* That is the failure the chart adapter has actually made, so every member below
|
|
30
|
+
* takes the editor's own argument, spelled as the editor spells it, and every
|
|
31
|
+
* test drives each one with the argument the editor passes rather than with one
|
|
32
|
+
* of its own.
|
|
33
|
+
*
|
|
34
|
+
* **A style name is not checked by any of those lines.** The names this adapter
|
|
35
|
+
* returns from `token` are looked up by the editor in its own table of
|
|
36
|
+
* highlighting tags at run time, and an unknown one is a warning on a console
|
|
37
|
+
* rather than a compile error. That is why the whole mapping is one exported
|
|
38
|
+
* record a host can replace in a line, and why it is recorded in
|
|
39
|
+
* `spec/editor-narrowings.json` as the one thing here a type cannot hold.
|
|
40
|
+
*/
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/adapters/codemirror/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The editor adapter: the language intelligence, wired into a text component.
|
|
3
|
+
*
|
|
4
|
+
* This and the chart adapter are the only modules in the repository allowed to
|
|
5
|
+
* know two worlds at once, and it is the piece a platform with its own editor
|
|
6
|
+
* replaces rather than the piece it patches. Everything under `src/editor` stays
|
|
7
|
+
* ignorant of any component, and the layering check is what keeps it that way.
|
|
8
|
+
*
|
|
9
|
+
* **The editor component is a peer dependency, and nothing here imports it.** A
|
|
10
|
+
* package that pulled a text component into everyone's install would defeat the
|
|
11
|
+
* point of a language a platform can take on its own, so the shapes this
|
|
12
|
+
* produces are declared in `contract.ts` and the host's own build is where the
|
|
13
|
+
* two are compared, in one line per piece. See that file for the lines. The
|
|
14
|
+
* entry point resolves and every function here runs in an install that holds no
|
|
15
|
+
* editor at all, which `scripts/check-entry-points.mjs` proves on every build.
|
|
16
|
+
*
|
|
17
|
+
* Six functions in, five pieces out:
|
|
18
|
+
*
|
|
19
|
+
* openscriptStream highlighting, a line at a time
|
|
20
|
+
* openscriptCompletion the completion list
|
|
21
|
+
* openscriptLint errors as you type, with their fixes
|
|
22
|
+
* openscriptHoverTooltip what the thing under the pointer is
|
|
23
|
+
* openscriptSignatureTooltip the call being written
|
|
24
|
+
* formatDocument lay the script out again
|
|
25
|
+
*
|
|
26
|
+
* The two tooltips take the markup as a parameter and have no default for it, so
|
|
27
|
+
* nothing in this package names a browser global at any tier. A host that wants
|
|
28
|
+
* none of this calls the six functions itself and draws its own. That is not the fallback, it is the supported path: what a host gives up
|
|
29
|
+
* by taking these instead is recorded in `spec/editor-narrowings.json`, which is
|
|
30
|
+
* three lines long and worth reading before choosing.
|
|
31
|
+
*/
|
|
32
|
+
export type { EditorCompletion, EditorCompletionContext, EditorCompletionResult, EditorDiagnostic, EditorState, EditorStreamParser, EditorStringStream, EditorText, EditorTooltip, EditorTooltipView, EditorView, } from './contract.js';
|
|
33
|
+
export { COMPLETION_TYPES, HIGHLIGHT_TOKENS } from './tokens.js';
|
|
34
|
+
export type { StreamState } from './stream.js';
|
|
35
|
+
export { openscriptStream } from './stream.js';
|
|
36
|
+
export { openscriptCompletion } from './completion.js';
|
|
37
|
+
export { diagnosticsFor, openscriptLint } from './lint.js';
|
|
38
|
+
export type { Renderer } from './tooltips.js';
|
|
39
|
+
export { hoverLines, openscriptHoverTooltip, openscriptSignatureTooltip, signatureLines, } from './tooltips.js';
|
|
40
|
+
export { formatDocument } from './commands.js';
|
|
41
|
+
export type { Document } from './positions.js';
|
|
42
|
+
export { documentOf, normalisedOffset } from './positions.js';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEjE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3D,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { COMPLETION_TYPES, HIGHLIGHT_TOKENS } from './tokens.js';
|
|
2
|
+
export { openscriptStream } from './stream.js';
|
|
3
|
+
export { openscriptCompletion } from './completion.js';
|
|
4
|
+
export { diagnosticsFor, openscriptLint } from './lint.js';
|
|
5
|
+
export { hoverLines, openscriptHoverTooltip, openscriptSignatureTooltip, signatureLines, } from './tooltips.js';
|
|
6
|
+
export { formatDocument } from './commands.js';
|
|
7
|
+
export { documentOf, normalisedOffset } from './positions.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/codemirror/index.ts"],"names":[],"mappings":"AA6CA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3D,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EditorDiagnostic, EditorView } from './contract.js';
|
|
2
|
+
/** Every diagnostic of a document, in the editor's own shape. */
|
|
3
|
+
export declare function diagnosticsFor(raw: string): readonly EditorDiagnostic[];
|
|
4
|
+
/**
|
|
5
|
+
* The linter a host wires in one line.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* linter(openscriptLint)
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* It is synchronous because it is fast enough to be: a finished ninety line
|
|
12
|
+
* study compiles in a third of a millisecond and the same file with a bracket
|
|
13
|
+
* left open in about a millisecond, both with a budget in the benchmark suite.
|
|
14
|
+
* The editor's own linter already debounces, so nothing here does it twice.
|
|
15
|
+
*/
|
|
16
|
+
export declare function openscriptLint(view: EditorView): readonly EditorDiagnostic[];
|
|
17
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/lint.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAQlE,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,gBAAgB,EAAE,CAavE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,gBAAgB,EAAE,CAE5E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Errors as you type, as the editor's linter.
|
|
3
|
+
*
|
|
4
|
+
* The diagnostics are the compiler's own, whole: `diagnose` runs the lexer, the
|
|
5
|
+
* parser, the checker and the emitter, so what a writer sees beside their line
|
|
6
|
+
* is exactly what a compile produces and nothing new can appear when they press
|
|
7
|
+
* apply. Every message and every fix came from the error catalogue that the
|
|
8
|
+
* documentation site is generated from.
|
|
9
|
+
*
|
|
10
|
+
* Three decisions worth stating, because each one is visible to a trader.
|
|
11
|
+
*
|
|
12
|
+
* **The fix is shown.** A `Diagnostic` carries a message saying what is wrong and
|
|
13
|
+
* a fix saying what to do, and the fix is the half that is worth reading. The
|
|
14
|
+
* editor's panel shows one string, so the two are joined with a line break
|
|
15
|
+
* rather than the fix being dropped.
|
|
16
|
+
*
|
|
17
|
+
* **The code is the source.** The editor shows a diagnostic's source beside its
|
|
18
|
+
* message, and a code is the one part of a diagnostic this project promises never
|
|
19
|
+
* to change, so it is what a trader quotes and what a support page is indexed by.
|
|
20
|
+
*
|
|
21
|
+
* **A zero width span is widened by one character.** The compiler points at a
|
|
22
|
+
* position for a mistake that is an absence, a missing bracket among them, and a
|
|
23
|
+
* squiggle of no width is a squiggle nobody sees.
|
|
24
|
+
*/
|
|
25
|
+
import { endOffset } from '../../core/index.js';
|
|
26
|
+
import { diagnose } from '../../editor/index.js';
|
|
27
|
+
import { documentOf } from './positions.js';
|
|
28
|
+
/** What the editor prints beside a message, which is the code and nothing else. */
|
|
29
|
+
function sourceOf(one) {
|
|
30
|
+
return one.code;
|
|
31
|
+
}
|
|
32
|
+
/** Every diagnostic of a document, in the editor's own shape. */
|
|
33
|
+
export function diagnosticsFor(raw) {
|
|
34
|
+
const held = documentOf(raw);
|
|
35
|
+
return diagnose(held.text).map((one) => {
|
|
36
|
+
const from = held.at(one.span.offset);
|
|
37
|
+
const to = held.at(endOffset(one.span));
|
|
38
|
+
return {
|
|
39
|
+
from,
|
|
40
|
+
to: to > from ? to : from + 1,
|
|
41
|
+
severity: one.severity,
|
|
42
|
+
message: `${one.message}\n${one.fix}`,
|
|
43
|
+
source: sourceOf(one),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The linter a host wires in one line.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* linter(openscriptLint)
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* It is synchronous because it is fast enough to be: a finished ninety line
|
|
55
|
+
* study compiles in a third of a millisecond and the same file with a bracket
|
|
56
|
+
* left open in about a millisecond, both with a budget in the benchmark suite.
|
|
57
|
+
* The editor's own linter already debounces, so nothing here does it twice.
|
|
58
|
+
*/
|
|
59
|
+
export function openscriptLint(view) {
|
|
60
|
+
return diagnosticsFor(view.state.doc.toString());
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=lint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../src/adapters/codemirror/lint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,mFAAmF;AACnF,SAAS,QAAQ,CAAC,GAAe;IAC/B,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,OAAO;YACL,IAAI;YACJ,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;YAC7B,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,GAAG,EAAE;YACrC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC;SACtB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,IAAgB;IAC7C,OAAO,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** The document as the compiler reads it, and where each of its offsets sits. */
|
|
2
|
+
export interface Document {
|
|
3
|
+
/** The normalised text: what `diagnose`, `complete` and the rest are given. */
|
|
4
|
+
readonly text: string;
|
|
5
|
+
/**
|
|
6
|
+
* The offset in the editor's own document that a normalised offset names.
|
|
7
|
+
*
|
|
8
|
+
* The identity where the document is already normalised, which is what a
|
|
9
|
+
* document written on a machine that ends its lines with one character is.
|
|
10
|
+
*/
|
|
11
|
+
at(offset: number): number;
|
|
12
|
+
}
|
|
13
|
+
export declare function documentOf(raw: string): Document;
|
|
14
|
+
/** The normalised offset an editor offset names, which is the other direction. */
|
|
15
|
+
export declare function normalisedOffset(held: Document, raw: number): number;
|
|
16
|
+
//# sourceMappingURL=positions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"positions.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/positions.ts"],"names":[],"mappings":"AA0BA,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAwBhD;AAED,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAYpE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offsets, translated between the document the editor holds and the text the
|
|
3
|
+
* compiler read.
|
|
4
|
+
*
|
|
5
|
+
* `language.md` 3.1 normalises a file before anything reads it: a byte order
|
|
6
|
+
* mark is dropped and every CRLF becomes LF. Every span the compiler produces
|
|
7
|
+
* therefore indexes the normalised text, which `docs/integrating/the-editor-half.md`
|
|
8
|
+
* tells a host plainly and expects it to handle.
|
|
9
|
+
*
|
|
10
|
+
* A drop-in cannot expect it. A document written on a machine that ends its
|
|
11
|
+
* lines with two characters is an ordinary document, the editor holds it exactly
|
|
12
|
+
* as it is, and an adapter that handed the editor a span from the normalised
|
|
13
|
+
* text would put every squiggle on a file's fiftieth line fifty characters to
|
|
14
|
+
* the left. That is the kind of defect that is reported as "the underline is in
|
|
15
|
+
* the wrong place" and survives for months.
|
|
16
|
+
*
|
|
17
|
+
* So the two are mapped. The map is built only when the document is not already
|
|
18
|
+
* normalised, which is the common case and costs a comparison; when it is built
|
|
19
|
+
* it is one walk of the text.
|
|
20
|
+
*/
|
|
21
|
+
import { normaliseSource } from '../../core/index.js';
|
|
22
|
+
const BYTE_ORDER_MARK = 0xfeff;
|
|
23
|
+
const CARRIAGE_RETURN = 13;
|
|
24
|
+
const LINE_FEED = 10;
|
|
25
|
+
export function documentOf(raw) {
|
|
26
|
+
const text = normaliseSource(raw);
|
|
27
|
+
if (text === raw)
|
|
28
|
+
return { text, at: (offset) => offset };
|
|
29
|
+
// One entry per normalised offset, plus the one past its end, so that the end
|
|
30
|
+
// of a span at the end of the file maps as readily as its start.
|
|
31
|
+
const map = new Array(text.length + 1);
|
|
32
|
+
let normalised = 0;
|
|
33
|
+
let held = raw.charCodeAt(0) === BYTE_ORDER_MARK ? 1 : 0;
|
|
34
|
+
while (normalised <= text.length) {
|
|
35
|
+
map[normalised] = held;
|
|
36
|
+
if (normalised === text.length)
|
|
37
|
+
break;
|
|
38
|
+
if (raw.charCodeAt(held) === CARRIAGE_RETURN && raw.charCodeAt(held + 1) === LINE_FEED) {
|
|
39
|
+
held += 1;
|
|
40
|
+
}
|
|
41
|
+
held += 1;
|
|
42
|
+
normalised += 1;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
text,
|
|
46
|
+
at: (offset) => map[Math.min(Math.max(offset, 0), text.length)] ?? offset,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** The normalised offset an editor offset names, which is the other direction. */
|
|
50
|
+
export function normalisedOffset(held, raw) {
|
|
51
|
+
// Walked rather than inverted, because the inverse of the map above is only
|
|
52
|
+
// needed at one position per call and building a second array to answer one
|
|
53
|
+
// question would cost a file's length for a comparison's worth of work.
|
|
54
|
+
let low = 0;
|
|
55
|
+
let high = held.text.length;
|
|
56
|
+
while (low < high) {
|
|
57
|
+
const middle = (low + high + 1) >> 1;
|
|
58
|
+
if (held.at(middle) <= raw)
|
|
59
|
+
low = middle;
|
|
60
|
+
else
|
|
61
|
+
high = middle - 1;
|
|
62
|
+
}
|
|
63
|
+
return low;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=positions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"positions.js","sourceRoot":"","sources":["../../../src/adapters/codemirror/positions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,SAAS,GAAG,EAAE,CAAC;AAerB,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC;IAE1D,8EAA8E;IAC9E,iEAAiE;IACjE,MAAM,GAAG,GAAG,IAAI,KAAK,CAAS,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzD,OAAO,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACjC,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;QACvB,IAAI,UAAU,KAAK,IAAI,CAAC,MAAM;YAAE,MAAM;QACtC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,eAAe,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACvF,IAAI,IAAI,CAAC,CAAC;QACZ,CAAC;QACD,IAAI,IAAI,CAAC,CAAC;QACV,UAAU,IAAI,CAAC,CAAC;IAClB,CAAC;IAED,OAAO;QACL,IAAI;QACJ,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,MAAM;KAC1E,CAAC;AACJ,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,gBAAgB,CAAC,IAAc,EAAE,GAAW;IAC1D,4EAA4E;IAC5E,4EAA4E;IAC5E,wEAAwE;IACxE,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC5B,OAAO,GAAG,GAAG,IAAI,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG;YAAE,GAAG,GAAG,MAAM,CAAC;;YACpC,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Highlight } from '../../editor/index.js';
|
|
2
|
+
import type { EditorStreamParser } from './contract.js';
|
|
3
|
+
/** What is carried from one call to the next: the line, and its pieces. */
|
|
4
|
+
export interface StreamState {
|
|
5
|
+
/** The line the pieces were computed from, so a changed line is redone. */
|
|
6
|
+
line: string;
|
|
7
|
+
pieces: readonly Highlight[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The tokenizer, which a host turns into a language with one call.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const openscript = StreamLanguage.define(openscriptStream);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* `token` moves the stream to the end of the piece that starts where it is and
|
|
17
|
+
* returns that piece's style. A stream that has somehow been left inside a piece,
|
|
18
|
+
* which the editor does when it re-tokenizes from a column rather than from the
|
|
19
|
+
* start of a line, is moved to the end of the piece containing it, so the
|
|
20
|
+
* tokenizer always advances and the editor cannot be made to loop.
|
|
21
|
+
*/
|
|
22
|
+
export declare const openscriptStream: EditorStreamParser<StreamState>;
|
|
23
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/stream.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAsB,MAAM,eAAe,CAAC;AAG5E,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;CAC9B;AAWD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAAkB,CAAC,WAAW,CA4B5D,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Highlighting, as the editor's line at a time tokenizer.
|
|
3
|
+
*
|
|
4
|
+
* The editor asks for one line's tokens at a time and remembers nothing between
|
|
5
|
+
* lines except the state this file hands back. The tier's `highlight` takes a
|
|
6
|
+
* whole file. So the line is what is lexed here, by the real lexer, through the
|
|
7
|
+
* same `highlight` a host would call itself.
|
|
8
|
+
*
|
|
9
|
+
* **That is an equivalence rather than an approximation, and it is measured.**
|
|
10
|
+
* `tests/adapters/codemirror/stream.test.ts` puts every script in the repository
|
|
11
|
+
* and the malformed corpus through both routes and compares them piece for
|
|
12
|
+
* piece: 4279 lines of real scripts, and not one of them differs. It holds
|
|
13
|
+
* because nothing in this language crosses a line ending: a string literal is
|
|
14
|
+
* refused at the end of its line, there is no block comment, and the layout
|
|
15
|
+
* tokens that do depend on the lines above are painted as whitespace either way.
|
|
16
|
+
* If the language ever grows something that does cross one, that test fails on
|
|
17
|
+
* the day it is added rather than on the day somebody notices a half painted
|
|
18
|
+
* line, and this becomes a line the narrowings file has to carry.
|
|
19
|
+
*
|
|
20
|
+
* A line is lexed once, not once per token: the pieces are computed when the
|
|
21
|
+
* editor arrives at the start of a line and walked from there. Without that, a
|
|
22
|
+
* line of twenty tokens would be lexed twenty times, which is the shape that
|
|
23
|
+
* makes a tokenizer show up in a frame budget.
|
|
24
|
+
*/
|
|
25
|
+
import { highlight } from '../../editor/index.js';
|
|
26
|
+
import { HIGHLIGHT_TOKENS } from './tokens.js';
|
|
27
|
+
/** The pieces of one line, computed once and kept until the line changes. */
|
|
28
|
+
function piecesFor(state, line) {
|
|
29
|
+
if (state.line !== line || state.pieces.length === 0) {
|
|
30
|
+
state.line = line;
|
|
31
|
+
state.pieces = highlight(line);
|
|
32
|
+
}
|
|
33
|
+
return state.pieces;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The tokenizer, which a host turns into a language with one call.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const openscript = StreamLanguage.define(openscriptStream);
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* `token` moves the stream to the end of the piece that starts where it is and
|
|
43
|
+
* returns that piece's style. A stream that has somehow been left inside a piece,
|
|
44
|
+
* which the editor does when it re-tokenizes from a column rather than from the
|
|
45
|
+
* start of a line, is moved to the end of the piece containing it, so the
|
|
46
|
+
* tokenizer always advances and the editor cannot be made to loop.
|
|
47
|
+
*/
|
|
48
|
+
export const openscriptStream = {
|
|
49
|
+
name: 'openscript',
|
|
50
|
+
startState: () => ({ line: '', pieces: [] }),
|
|
51
|
+
copyState: (state) => ({ line: state.line, pieces: state.pieces }),
|
|
52
|
+
token(stream, state) {
|
|
53
|
+
if (stream.eol())
|
|
54
|
+
return null;
|
|
55
|
+
const pieces = piecesFor(state, stream.string);
|
|
56
|
+
const at = stream.pos;
|
|
57
|
+
const piece = pieces.find((one) => at >= one.span.offset && at < one.span.offset + one.span.length);
|
|
58
|
+
if (piece === undefined) {
|
|
59
|
+
// No piece covers the position, which cannot happen for a line the tier
|
|
60
|
+
// has covered and is still answered rather than trusted: the pieces tile
|
|
61
|
+
// the line, so this is a position outside it. Moving to the end leaves the
|
|
62
|
+
// editor with an unstyled remainder instead of an infinite loop.
|
|
63
|
+
stream.pos = stream.string.length;
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
stream.pos = piece.span.offset + piece.span.length;
|
|
67
|
+
return HIGHLIGHT_TOKENS[piece.kind];
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/adapters/codemirror/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAS/C,6EAA6E;AAC7E,SAAS,SAAS,CAAC,KAAkB,EAAE,IAAY;IACjD,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrD,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAoC;IAC/D,IAAI,EAAE,YAAY;IAElB,UAAU,EAAE,GAAgB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAEzD,SAAS,EAAE,CAAC,KAAkB,EAAe,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IAE5F,KAAK,CAAC,MAA0B,EAAE,KAAkB;QAClD,IAAI,MAAM,CAAC,GAAG,EAAE;YAAE,OAAO,IAAI,CAAC;QAE9B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/C,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CACvB,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CACzE,CAAC;QAEF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,wEAAwE;YACxE,yEAAyE;YACzE,2EAA2E;YAC3E,iEAAiE;YACjE,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;YAClC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QACnD,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The eleven kinds, as the editor's own highlighting tags.
|
|
3
|
+
*
|
|
4
|
+
* This is the translation an adapter exists to do: the language has eleven
|
|
5
|
+
* kinds, closed, and the editor has a vocabulary of tags its themes are written
|
|
6
|
+
* against. Neither knows about the other, and this file is the only place that
|
|
7
|
+
* knows both.
|
|
8
|
+
*
|
|
9
|
+
* **It is one record rather than a switch on purpose.** A style name is the one
|
|
10
|
+
* thing in this adapter that no type can hold: the editor looks a name up in its
|
|
11
|
+
* own tag table at run time and warns on a console about one it does not know,
|
|
12
|
+
* so a name that is wrong here is invisible to every check in this repository
|
|
13
|
+
* and shows up as an unpainted keyword in somebody's product. A host that
|
|
14
|
+
* disagrees with any of these, or whose theme is written against different
|
|
15
|
+
* names, replaces the row in one line:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const tokens = { ...HIGHLIGHT_TOKENS, unknown: "invalid" };
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Two of the eleven are deliberately unstyled. `whitespace` has nothing to
|
|
22
|
+
* paint. `unknown` is the honest name for source the lexer took no token from,
|
|
23
|
+
* which is a character the language does not have, a region somebody wrote as a
|
|
24
|
+
* block comment, or a line continuation backslash: the first is a mistake and
|
|
25
|
+
* the last is not, so painting all three as invalid would paint a correct line
|
|
26
|
+
* red. `diagnose` is what says which of them is wrong, and the linter below is
|
|
27
|
+
* how a host shows that.
|
|
28
|
+
*/
|
|
29
|
+
import type { HighlightKind } from '../../editor/index.js';
|
|
30
|
+
/**
|
|
31
|
+
* A style name per kind, or null for one the editor should leave alone.
|
|
32
|
+
*
|
|
33
|
+
* `builtin` uses the editor's modifier syntax for a name the environment
|
|
34
|
+
* supplies rather than the file, which is what a library name is.
|
|
35
|
+
*/
|
|
36
|
+
export declare const HIGHLIGHT_TOKENS: Readonly<Record<HighlightKind, string | null>>;
|
|
37
|
+
/**
|
|
38
|
+
* The editor's name for the icon beside a completion row, per kind.
|
|
39
|
+
*
|
|
40
|
+
* The editor ships icons for a fixed set of names and shows none for a name it
|
|
41
|
+
* does not know, which is a missing icon rather than a missing row.
|
|
42
|
+
*/
|
|
43
|
+
export declare const COMPLETION_TYPES: Readonly<Record<string, string>>;
|
|
44
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC,CAY3E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO7D,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A style name per kind, or null for one the editor should leave alone.
|
|
3
|
+
*
|
|
4
|
+
* `builtin` uses the editor's modifier syntax for a name the environment
|
|
5
|
+
* supplies rather than the file, which is what a library name is.
|
|
6
|
+
*/
|
|
7
|
+
export const HIGHLIGHT_TOKENS = {
|
|
8
|
+
keyword: 'keyword',
|
|
9
|
+
builtin: 'variableName.standard',
|
|
10
|
+
name: 'variableName',
|
|
11
|
+
number: 'number',
|
|
12
|
+
string: 'string',
|
|
13
|
+
color: 'color',
|
|
14
|
+
comment: 'comment',
|
|
15
|
+
operator: 'operator',
|
|
16
|
+
punctuation: 'punctuation',
|
|
17
|
+
whitespace: null,
|
|
18
|
+
unknown: null,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The editor's name for the icon beside a completion row, per kind.
|
|
22
|
+
*
|
|
23
|
+
* The editor ships icons for a fixed set of names and shows none for a name it
|
|
24
|
+
* does not know, which is a missing icon rather than a missing row.
|
|
25
|
+
*/
|
|
26
|
+
export const COMPLETION_TYPES = {
|
|
27
|
+
function: 'function',
|
|
28
|
+
value: 'constant',
|
|
29
|
+
namespace: 'namespace',
|
|
30
|
+
member: 'property',
|
|
31
|
+
variable: 'variable',
|
|
32
|
+
argument: 'property',
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/adapters/codemirror/tokens.ts"],"names":[],"mappings":"AA8BA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAmD;IAC9E,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,uBAAuB;IAChC,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;CACd,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqC;IAChE,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,UAAU;IACjB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,UAAU;IAClB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;CACrB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Hover, SignatureHelp } from '../../editor/index.js';
|
|
2
|
+
import type { EditorState, EditorTooltip, EditorTooltipView, EditorView } from './contract.js';
|
|
3
|
+
/** What a host supplies to draw a tooltip, which is the whole of the markup. */
|
|
4
|
+
export interface Renderer<Held> {
|
|
5
|
+
(held: Held): EditorTooltipView;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The lines a hover shows, in the order it shows them.
|
|
9
|
+
*
|
|
10
|
+
* Every one of them came from the compiler: the signatures from the library
|
|
11
|
+
* manifest, the sentence and the warmup from the specification's own tables, the
|
|
12
|
+
* type from the checker, and the refusal from the error catalogue. Nothing is
|
|
13
|
+
* written here, which is why this function is a join rather than a template.
|
|
14
|
+
*/
|
|
15
|
+
export declare function hoverLines(held: Hover): readonly string[];
|
|
16
|
+
/** The lines a signature tooltip shows, with the active parameter named. */
|
|
17
|
+
export declare function signatureLines(held: SignatureHelp): readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* A hover tooltip source, which a host wires in one line.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* hoverTooltip(openscriptHoverTooltip(render))
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function openscriptHoverTooltip(render: Renderer<Hover>): (view: EditorView, pos: number) => EditorTooltip | null;
|
|
26
|
+
/**
|
|
27
|
+
* A signature tooltip for wherever the cursor is, or nothing where it is in no
|
|
28
|
+
* call.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* showTooltip.compute(["doc", "selection"], openscriptSignatureTooltip(render))
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function openscriptSignatureTooltip(render: Renderer<SignatureHelp>): (state: EditorState) => EditorTooltip | null;
|
|
35
|
+
//# sourceMappingURL=tooltips.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltips.d.ts","sourceRoot":"","sources":["../../../src/adapters/codemirror/tooltips.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG/F,gFAAgF;AAChF,MAAM,WAAW,QAAQ,CAAC,IAAI;IAC5B,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS,MAAM,EAAE,CAOzD;AAED,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,MAAM,EAAE,CAYrE;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,GACtB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,aAAa,GAAG,IAAI,CAWzD;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC9B,CAAC,KAAK,EAAE,WAAW,KAAK,aAAa,GAAG,IAAI,CAY9C"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hover and signature, as the editor's tooltips.
|
|
3
|
+
*
|
|
4
|
+
* This is the one part of the adapter that would put something on screen, and it
|
|
5
|
+
* is the one part that does not: the markup is a parameter, and there is no
|
|
6
|
+
* default for it. So nothing in this package, at any tier, names a browser
|
|
7
|
+
* global, and `scripts/check-layering.mjs` fails the build if anything under
|
|
8
|
+
* `src` does. The same files load in a worker, on a server and inside somebody
|
|
9
|
+
* else's application.
|
|
10
|
+
*
|
|
11
|
+
* It costs a host four lines and it is the whole point of the split. Every
|
|
12
|
+
* platform has a design system and none of them wants to fight a styled panel
|
|
13
|
+
* that arrived with a language package; a default renderer here would be that
|
|
14
|
+
* panel, and it would be the one thing in this adapter a host could not replace
|
|
15
|
+
* without replacing the adapter.
|
|
16
|
+
*
|
|
17
|
+
* What is not a parameter is the content. `hoverLines` and `signatureLines`
|
|
18
|
+
* below are what a tooltip says, in order, and every line of it came from the
|
|
19
|
+
* compiler: the signatures from the library manifest, the sentence and the
|
|
20
|
+
* warmup from the specification's own tables, the type from the checker, and the
|
|
21
|
+
* refusal from the error catalogue.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* hoverTooltip(openscriptHoverTooltip((held) => ({ dom: yourPanel(hoverLines(held)) })))
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import { hover, signature } from '../../editor/index.js';
|
|
28
|
+
import { documentOf, normalisedOffset } from './positions.js';
|
|
29
|
+
/**
|
|
30
|
+
* The lines a hover shows, in the order it shows them.
|
|
31
|
+
*
|
|
32
|
+
* Every one of them came from the compiler: the signatures from the library
|
|
33
|
+
* manifest, the sentence and the warmup from the specification's own tables, the
|
|
34
|
+
* type from the checker, and the refusal from the error catalogue. Nothing is
|
|
35
|
+
* written here, which is why this function is a join rather than a template.
|
|
36
|
+
*/
|
|
37
|
+
export function hoverLines(held) {
|
|
38
|
+
const lines = [...held.signatures];
|
|
39
|
+
if (held.summary !== undefined)
|
|
40
|
+
lines.push(held.summary);
|
|
41
|
+
if (held.warmup !== undefined)
|
|
42
|
+
lines.push(`First value: ${held.warmup}`);
|
|
43
|
+
if (held.refusal !== undefined)
|
|
44
|
+
lines.push(held.refusal);
|
|
45
|
+
if (held.kind === 'keyword')
|
|
46
|
+
lines.push('A reserved word of the language.');
|
|
47
|
+
return lines;
|
|
48
|
+
}
|
|
49
|
+
/** The lines a signature tooltip shows, with the active parameter named. */
|
|
50
|
+
export function signatureLines(held) {
|
|
51
|
+
const lines = [held.signature];
|
|
52
|
+
const active = held.parameters[held.active];
|
|
53
|
+
if (active !== undefined) {
|
|
54
|
+
const value = active.defaultText === undefined ? '' : ` = ${active.defaultText}`;
|
|
55
|
+
const need = active.required ? 'required' : 'optional';
|
|
56
|
+
lines.push(`${active.name}: ${active.type}${value} (${need})`);
|
|
57
|
+
if (active.values.length > 0)
|
|
58
|
+
lines.push(`One of: ${active.values.join(', ')}`);
|
|
59
|
+
}
|
|
60
|
+
if (held.summary !== undefined)
|
|
61
|
+
lines.push(held.summary);
|
|
62
|
+
if (held.refusal !== undefined)
|
|
63
|
+
lines.push(held.refusal);
|
|
64
|
+
return lines;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A hover tooltip source, which a host wires in one line.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* hoverTooltip(openscriptHoverTooltip(render))
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function openscriptHoverTooltip(render) {
|
|
74
|
+
return (view, pos) => {
|
|
75
|
+
const held = documentOf(view.state.doc.toString());
|
|
76
|
+
const found = hover(held.text, normalisedOffset(held, pos));
|
|
77
|
+
if (found === undefined)
|
|
78
|
+
return null;
|
|
79
|
+
return {
|
|
80
|
+
pos: held.at(found.span.offset),
|
|
81
|
+
end: held.at(found.span.offset + found.span.length),
|
|
82
|
+
create: () => render(found),
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A signature tooltip for wherever the cursor is, or nothing where it is in no
|
|
88
|
+
* call.
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* showTooltip.compute(["doc", "selection"], openscriptSignatureTooltip(render))
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function openscriptSignatureTooltip(render) {
|
|
95
|
+
return (state) => {
|
|
96
|
+
const held = documentOf(state.doc.toString());
|
|
97
|
+
const at = normalisedOffset(held, state.selection.main.head);
|
|
98
|
+
const found = signature(held.text, at);
|
|
99
|
+
if (found === undefined)
|
|
100
|
+
return null;
|
|
101
|
+
return {
|
|
102
|
+
pos: state.selection.main.head,
|
|
103
|
+
above: true,
|
|
104
|
+
create: () => render(found),
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=tooltips.js.map
|