@formspec/ts-plugin 0.1.0-alpha.20 → 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
@@ -1,3 +1,67 @@
1
1
  # @formspec/ts-plugin
2
2
 
3
3
  TypeScript language service plugin for FormSpec semantic comment analysis.
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
+
61
+ ## Profiling
62
+
63
+ Set `FORMSPEC_PLUGIN_PROFILE=1` to enable semantic query hotspot logging.
64
+
65
+ Set `FORMSPEC_PLUGIN_PROFILE_THRESHOLD_MS=<number>` to raise or lower the
66
+ minimum total query duration required before a profiling summary is logged.
67
+ Empty or non-finite values are ignored.
@@ -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=handle-query.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-query.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/handle-query.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import * as ts from "typescript";
2
+ import type { FormSpecPluginService } from "../service.js";
3
+ export declare const FORM_SPEC_PLUGIN_TEST_SOCKET_TIMEOUT_MS = 1000;
4
+ export interface TestProgramContext {
5
+ readonly workspaceRoot: string;
6
+ readonly filePath: string;
7
+ readonly program: ts.Program;
8
+ }
9
+ export declare function createProgramContext(sourceText: string): Promise<TestProgramContext>;
10
+ export declare function expectErrorResponse(response: ReturnType<FormSpecPluginService["handleQuery"]>, fragment: string): void;
11
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/__tests__/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,eAAO,MAAM,uCAAuC,OAAQ,CAAC;AAE7D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;CAC9B;AAED,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgB1F;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,UAAU,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,EAC1D,QAAQ,EAAE,MAAM,GACf,IAAI,CAMN"}
@@ -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":""}
@@ -0,0 +1,8 @@
1
+ export declare const FORM_SPEC_PLUGIN_MAX_SOCKET_PAYLOAD_BYTES: number;
2
+ export declare const FORM_SPEC_PLUGIN_SOCKET_IDLE_TIMEOUT_MS = 30000;
3
+ export declare const FORM_SPEC_PLUGIN_DEFAULT_PERFORMANCE_LOG_THRESHOLD_MS = 50;
4
+ export declare const FORM_SPEC_PLUGIN_DEFAULT_SNAPSHOT_DEBOUNCE_MS = 250;
5
+ export declare const FORM_SPEC_PLUGIN_PERFORMANCE_EVENT: {
6
+ readonly handleQuery: "plugin.handleQuery";
7
+ };
8
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yCAAyC,QAAa,CAAC;AACpE,eAAO,MAAM,uCAAuC,QAAS,CAAC;AAC9D,eAAO,MAAM,qDAAqD,KAAK,CAAC;AACxE,eAAO,MAAM,6CAA6C,MAAM,CAAC;AAEjE,eAAO,MAAM,kCAAkC;;CAErC,CAAC"}