@formspec/ts-plugin 0.1.0-alpha.21 → 0.1.0-alpha.22

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/README.md CHANGED
@@ -2,6 +2,62 @@
2
2
 
3
3
  TypeScript language service plugin for FormSpec semantic comment analysis.
4
4
 
5
+ This package serves two roles:
6
+
7
+ - a turnkey `tsserver` plugin via `init()`
8
+ - a composable in-process semantic API for downstream TypeScript hosts
9
+
10
+ The shipped plugin is the reference implementation. Downstream tools that
11
+ already own their own TypeScript plugin/runtime can use
12
+ `FormSpecSemanticService` and `createLanguageServiceProxy(...)` directly while
13
+ reusing the same host `Program`.
14
+
15
+ ## Public Composition APIs
16
+
17
+ ```ts
18
+ import { FormSpecSemanticService, createLanguageServiceProxy } from "@formspec/ts-plugin";
19
+ ```
20
+
21
+ `FormSpecSemanticService` provides:
22
+
23
+ - `getFileSnapshot(filePath)`
24
+ - `getCompletionContext(filePath, offset)`
25
+ - `getHover(filePath, offset)`
26
+ - `getDiagnostics(filePath)`
27
+ - `scheduleSnapshotRefresh(filePath)`
28
+ - `getStats()`
29
+
30
+ `FormSpecPluginService` wraps the same semantic service with the manifest + IPC
31
+ transport used by the packaged language server.
32
+
33
+ ## Reference Host Example
34
+
35
+ The shipped FormSpec `tsserver` plugin is only one reference implementation.
36
+ Downstream tools that already own a TypeScript `Program` can build their own
37
+ feedback layer directly on top of `FormSpecSemanticService`.
38
+
39
+ See:
40
+
41
+ - [reference-host-example.ts](https://github.com/mike-north/formspec/blob/main/packages/ts-plugin/src/reference-host-example.ts)
42
+ - [downstream-authoring-host.test.ts](https://github.com/mike-north/formspec/blob/main/packages/ts-plugin/src/__tests__/downstream-authoring-host.test.ts)
43
+
44
+ These source-repository references intentionally show a downstream host that
45
+ renders diagnostics from `code` + `data` instead of reusing FormSpec's default
46
+ message text.
47
+
48
+ ## White-Label Diagnostics
49
+
50
+ Diagnostics returned by the semantic service and plugin transport include:
51
+
52
+ - stable machine-readable `code`
53
+ - structured `category`
54
+ - raw diagnostic `data`
55
+ - optional `relatedLocations`
56
+ - default human-readable `message`
57
+
58
+ Downstream tools can ignore `message` and render from `code` + `data` if they
59
+ want full control over presentation.
60
+
5
61
  ## Profiling
6
62
 
7
63
  Set `FORMSPEC_PLUGIN_PROFILE=1` to enable semantic query hotspot logging.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=downstream-authoring-host.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"downstream-authoring-host.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/downstream-authoring-host.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=semantic-service.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-service.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/semantic-service.test.ts"],"names":[],"mappings":""}