@formspec/analysis 0.1.0-alpha.20
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 +14 -0
- package/dist/__tests__/comment-syntax.test.d.ts +2 -0
- package/dist/__tests__/comment-syntax.test.d.ts.map +1 -0
- package/dist/__tests__/compiler-signatures.test.d.ts +2 -0
- package/dist/__tests__/compiler-signatures.test.d.ts.map +1 -0
- package/dist/__tests__/cursor-context.test.d.ts +2 -0
- package/dist/__tests__/cursor-context.test.d.ts.map +1 -0
- package/dist/__tests__/file-snapshots.test.d.ts +2 -0
- package/dist/__tests__/file-snapshots.test.d.ts.map +1 -0
- package/dist/__tests__/helpers.d.ts +7 -0
- package/dist/__tests__/helpers.d.ts.map +1 -0
- package/dist/__tests__/semantic-protocol.test.d.ts +2 -0
- package/dist/__tests__/semantic-protocol.test.d.ts.map +1 -0
- package/dist/__tests__/semantic-targets.test.d.ts +2 -0
- package/dist/__tests__/semantic-targets.test.d.ts.map +1 -0
- package/dist/__tests__/tag-registry.test.d.ts +2 -0
- package/dist/__tests__/tag-registry.test.d.ts.map +1 -0
- package/dist/__tests__/tag-value-parser.test.d.ts +2 -0
- package/dist/__tests__/tag-value-parser.test.d.ts.map +1 -0
- package/dist/__tests__/ts-binding.test.d.ts +2 -0
- package/dist/__tests__/ts-binding.test.d.ts.map +1 -0
- package/dist/analysis.d.ts +812 -0
- package/dist/comment-syntax.d.ts +43 -0
- package/dist/comment-syntax.d.ts.map +1 -0
- package/dist/compiler-signatures.d.ts +100 -0
- package/dist/compiler-signatures.d.ts.map +1 -0
- package/dist/cursor-context.d.ts +89 -0
- package/dist/cursor-context.d.ts.map +1 -0
- package/dist/file-snapshots.d.ts +18 -0
- package/dist/file-snapshots.d.ts.map +1 -0
- package/dist/index.cjs +3582 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3497 -0
- package/dist/index.js.map +1 -0
- package/dist/path-target.d.ts +11 -0
- package/dist/path-target.d.ts.map +1 -0
- package/dist/semantic-protocol.d.ts +234 -0
- package/dist/semantic-protocol.d.ts.map +1 -0
- package/dist/semantic-targets.d.ts +86 -0
- package/dist/semantic-targets.d.ts.map +1 -0
- package/dist/source-bindings.d.ts +21 -0
- package/dist/source-bindings.d.ts.map +1 -0
- package/dist/tag-registry.d.ts +46 -0
- package/dist/tag-registry.d.ts.map +1 -0
- package/dist/tag-value-parser.d.ts +20 -0
- package/dist/tag-value-parser.d.ts.map +1 -0
- package/dist/ts-binding.d.ts +28 -0
- package/dist/ts-binding.d.ts.map +1 -0
- package/dist/workspace-runtime.d.ts +15 -0
- package/dist/workspace-runtime.d.ts.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-target.d.ts","sourceRoot":"","sources":["../src/path-target.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAWvE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAK7E"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import type { CommentSpan, ParsedCommentTag, ParsedCommentTargetSpecifier } from "./comment-syntax.js";
|
|
2
|
+
import type { CommentHoverInfo, CommentTagSemanticContext, SemanticCommentCompletionContext } from "./cursor-context.js";
|
|
3
|
+
import type { FormSpecPlacement, FormSpecTargetKind } from "./tag-registry.js";
|
|
4
|
+
export declare const FORMSPEC_ANALYSIS_PROTOCOL_VERSION = 1;
|
|
5
|
+
export declare const FORMSPEC_ANALYSIS_SCHEMA_VERSION = 1;
|
|
6
|
+
/**
|
|
7
|
+
* Cross-process endpoint used by the language server to reach the semantic
|
|
8
|
+
* tsserver plugin on the current workspace host.
|
|
9
|
+
*/
|
|
10
|
+
export interface FormSpecIpcEndpoint {
|
|
11
|
+
readonly kind: "unix-socket" | "windows-pipe";
|
|
12
|
+
readonly address: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Discovery record written by the tsserver plugin so other FormSpec tooling
|
|
16
|
+
* can locate and validate the matching semantic service for a workspace.
|
|
17
|
+
*/
|
|
18
|
+
export interface FormSpecAnalysisManifest {
|
|
19
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
20
|
+
readonly analysisSchemaVersion: typeof FORMSPEC_ANALYSIS_SCHEMA_VERSION;
|
|
21
|
+
readonly workspaceRoot: string;
|
|
22
|
+
readonly workspaceId: string;
|
|
23
|
+
readonly endpoint: FormSpecIpcEndpoint;
|
|
24
|
+
readonly typescriptVersion: string;
|
|
25
|
+
readonly extensionFingerprint: string;
|
|
26
|
+
readonly generation: number;
|
|
27
|
+
readonly updatedAt: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Serializable subset of tag metadata needed by hover and completion UIs.
|
|
31
|
+
*/
|
|
32
|
+
export interface FormSpecSerializedTagDefinition {
|
|
33
|
+
readonly canonicalName: string;
|
|
34
|
+
readonly completionDetail: string;
|
|
35
|
+
readonly hoverMarkdown: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Serializable overload/signature summary for one comment tag form.
|
|
39
|
+
*/
|
|
40
|
+
export interface FormSpecSerializedTagSignature {
|
|
41
|
+
readonly label: string;
|
|
42
|
+
readonly placements: readonly FormSpecPlacement[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Serialized representation of a parsed target specifier with exact spans.
|
|
46
|
+
*/
|
|
47
|
+
export interface FormSpecSerializedCommentTargetSpecifier {
|
|
48
|
+
readonly rawText: string;
|
|
49
|
+
readonly valid: boolean;
|
|
50
|
+
readonly kind: ParsedCommentTargetSpecifier["kind"];
|
|
51
|
+
readonly fullSpan: CommentSpan;
|
|
52
|
+
readonly colonSpan: CommentSpan;
|
|
53
|
+
readonly span: CommentSpan;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Semantic facts about one parsed tag, reduced to JSON-safe data for IPC.
|
|
57
|
+
*/
|
|
58
|
+
export interface FormSpecSerializedTagSemanticContext {
|
|
59
|
+
readonly tagName: string;
|
|
60
|
+
readonly tagDefinition: FormSpecSerializedTagDefinition | null;
|
|
61
|
+
readonly placement: FormSpecPlacement | null;
|
|
62
|
+
readonly supportedTargets: readonly FormSpecTargetKind[];
|
|
63
|
+
readonly targetCompletions: readonly string[];
|
|
64
|
+
readonly compatiblePathTargets: readonly string[];
|
|
65
|
+
readonly valueLabels: readonly string[];
|
|
66
|
+
readonly signatures: readonly FormSpecSerializedTagSignature[];
|
|
67
|
+
readonly tagHoverMarkdown: string | null;
|
|
68
|
+
readonly targetHoverMarkdown: string | null;
|
|
69
|
+
readonly argumentHoverMarkdown: string | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Cursor-scoped completion context serialized for transport between the
|
|
73
|
+
* semantic tsserver plugin and the lightweight LSP.
|
|
74
|
+
*/
|
|
75
|
+
export type FormSpecSerializedCompletionContext = {
|
|
76
|
+
readonly kind: "tag-name";
|
|
77
|
+
readonly prefix: string;
|
|
78
|
+
readonly availableTags: readonly FormSpecSerializedTagDefinition[];
|
|
79
|
+
} | {
|
|
80
|
+
readonly kind: "target";
|
|
81
|
+
readonly semantic: FormSpecSerializedTagSemanticContext;
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: "argument";
|
|
84
|
+
readonly semantic: FormSpecSerializedTagSemanticContext;
|
|
85
|
+
readonly valueLabels: readonly string[];
|
|
86
|
+
} | {
|
|
87
|
+
readonly kind: "none";
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Hover payload for a single comment token under the cursor.
|
|
91
|
+
*/
|
|
92
|
+
export interface FormSpecSerializedHoverInfo {
|
|
93
|
+
readonly kind: CommentHoverInfo["kind"];
|
|
94
|
+
readonly markdown: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* File-local diagnostic derived from comment parsing or semantic analysis.
|
|
98
|
+
*/
|
|
99
|
+
export interface FormSpecAnalysisDiagnostic {
|
|
100
|
+
readonly code: string;
|
|
101
|
+
readonly message: string;
|
|
102
|
+
readonly range: CommentSpan;
|
|
103
|
+
readonly severity: "error" | "warning" | "info";
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Serializable view of a single parsed FormSpec tag within a doc comment.
|
|
107
|
+
*/
|
|
108
|
+
export interface FormSpecAnalysisTagSnapshot {
|
|
109
|
+
readonly rawTagName: string;
|
|
110
|
+
readonly normalizedTagName: string;
|
|
111
|
+
readonly recognized: boolean;
|
|
112
|
+
readonly fullSpan: CommentSpan;
|
|
113
|
+
readonly tagNameSpan: CommentSpan;
|
|
114
|
+
readonly payloadSpan: CommentSpan | null;
|
|
115
|
+
readonly target: FormSpecSerializedCommentTargetSpecifier | null;
|
|
116
|
+
readonly argumentSpan: CommentSpan | null;
|
|
117
|
+
readonly argumentText: string;
|
|
118
|
+
readonly semantic: FormSpecSerializedTagSemanticContext;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Serializable view of one declaration-attached doc comment in a source file.
|
|
122
|
+
*/
|
|
123
|
+
export interface FormSpecAnalysisCommentSnapshot {
|
|
124
|
+
readonly commentSpan: CommentSpan;
|
|
125
|
+
readonly declarationSpan: CommentSpan;
|
|
126
|
+
readonly placement: FormSpecPlacement | null;
|
|
127
|
+
readonly subjectType: string | null;
|
|
128
|
+
readonly hostType: string | null;
|
|
129
|
+
readonly tags: readonly FormSpecAnalysisTagSnapshot[];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Serializable analysis artifact for a single source file.
|
|
133
|
+
*/
|
|
134
|
+
export interface FormSpecAnalysisFileSnapshot {
|
|
135
|
+
readonly filePath: string;
|
|
136
|
+
readonly sourceHash: string;
|
|
137
|
+
readonly generatedAt: string;
|
|
138
|
+
readonly comments: readonly FormSpecAnalysisCommentSnapshot[];
|
|
139
|
+
readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Query variants supported by the semantic tsserver plugin.
|
|
143
|
+
*/
|
|
144
|
+
export type FormSpecSemanticQuery = {
|
|
145
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
146
|
+
readonly kind: "health";
|
|
147
|
+
} | {
|
|
148
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
149
|
+
readonly kind: "completion";
|
|
150
|
+
readonly filePath: string;
|
|
151
|
+
readonly offset: number;
|
|
152
|
+
} | {
|
|
153
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
154
|
+
readonly kind: "hover";
|
|
155
|
+
readonly filePath: string;
|
|
156
|
+
readonly offset: number;
|
|
157
|
+
} | {
|
|
158
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
159
|
+
readonly kind: "diagnostics";
|
|
160
|
+
readonly filePath: string;
|
|
161
|
+
} | {
|
|
162
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
163
|
+
readonly kind: "file-snapshot";
|
|
164
|
+
readonly filePath: string;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Response variants returned by the semantic tsserver plugin.
|
|
168
|
+
*/
|
|
169
|
+
export type FormSpecSemanticResponse = {
|
|
170
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
171
|
+
readonly kind: "health";
|
|
172
|
+
readonly manifest: FormSpecAnalysisManifest;
|
|
173
|
+
} | {
|
|
174
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
175
|
+
readonly kind: "completion";
|
|
176
|
+
readonly sourceHash: string;
|
|
177
|
+
readonly context: FormSpecSerializedCompletionContext;
|
|
178
|
+
} | {
|
|
179
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
180
|
+
readonly kind: "hover";
|
|
181
|
+
readonly sourceHash: string;
|
|
182
|
+
readonly hover: FormSpecSerializedHoverInfo | null;
|
|
183
|
+
} | {
|
|
184
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
185
|
+
readonly kind: "diagnostics";
|
|
186
|
+
readonly sourceHash: string;
|
|
187
|
+
readonly diagnostics: readonly FormSpecAnalysisDiagnostic[];
|
|
188
|
+
} | {
|
|
189
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
190
|
+
readonly kind: "file-snapshot";
|
|
191
|
+
readonly snapshot: FormSpecAnalysisFileSnapshot | null;
|
|
192
|
+
} | {
|
|
193
|
+
readonly protocolVersion: typeof FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
194
|
+
readonly kind: "error";
|
|
195
|
+
readonly error: string;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Validates an unknown manifest payload from disk before consumers trust it.
|
|
199
|
+
*/
|
|
200
|
+
export declare function isFormSpecAnalysisManifest(value: unknown): value is FormSpecAnalysisManifest;
|
|
201
|
+
/**
|
|
202
|
+
* Validates an unknown inbound IPC request before dispatching it.
|
|
203
|
+
*/
|
|
204
|
+
export declare function isFormSpecSemanticQuery(value: unknown): value is FormSpecSemanticQuery;
|
|
205
|
+
/**
|
|
206
|
+
* Validates an unknown IPC response before the language server consumes it.
|
|
207
|
+
*/
|
|
208
|
+
export declare function isFormSpecSemanticResponse(value: unknown): value is FormSpecSemanticResponse;
|
|
209
|
+
/**
|
|
210
|
+
* Computes a stable, non-cryptographic hash for document staleness checks
|
|
211
|
+
* across the plugin/LSP boundary.
|
|
212
|
+
*/
|
|
213
|
+
export declare function computeFormSpecTextHash(text: string): string;
|
|
214
|
+
/**
|
|
215
|
+
* Converts a parsed target specifier into its transport-safe JSON form.
|
|
216
|
+
*/
|
|
217
|
+
export declare function serializeCommentTargetSpecifier(target: ParsedCommentTargetSpecifier | null): FormSpecSerializedCommentTargetSpecifier | null;
|
|
218
|
+
/**
|
|
219
|
+
* Serializes tag-level semantic context for cross-process consumption.
|
|
220
|
+
*/
|
|
221
|
+
export declare function serializeCommentTagSemanticContext(semantic: CommentTagSemanticContext): FormSpecSerializedTagSemanticContext;
|
|
222
|
+
/**
|
|
223
|
+
* Serializes a cursor-scoped completion context for IPC.
|
|
224
|
+
*/
|
|
225
|
+
export declare function serializeCompletionContext(context: SemanticCommentCompletionContext): FormSpecSerializedCompletionContext;
|
|
226
|
+
/**
|
|
227
|
+
* Serializes hover information for cross-process transport.
|
|
228
|
+
*/
|
|
229
|
+
export declare function serializeHoverInfo(hover: CommentHoverInfo | null): FormSpecSerializedHoverInfo | null;
|
|
230
|
+
/**
|
|
231
|
+
* Serializes a parsed tag plus its semantic context into a file snapshot entry.
|
|
232
|
+
*/
|
|
233
|
+
export declare function serializeParsedCommentTag(tag: ParsedCommentTag, semantic: CommentTagSemanticContext): FormSpecAnalysisTagSnapshot;
|
|
234
|
+
//# sourceMappingURL=semantic-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-protocol.d.ts","sourceRoot":"","sources":["../src/semantic-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,4BAA4B,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAC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AK,EAAE,MAAM,CAAC;CACxB,CAAC;AAgON;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,wBAAwB,CAiB5F;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAsBtF;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,wBAAwB,CAmC5F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5D;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,4BAA4B,GAAG,IAAI,GAC1C,wCAAwC,GAAG,IAAI,CAajD;AAED;;GAEG;AACH,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,yBAAyB,GAClC,oCAAoC,CAwBtC;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,gCAAgC,GACxC,mCAAmC,CA8BrC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAC7B,2BAA2B,GAAG,IAAI,CAOpC;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,yBAAyB,GAClC,2BAA2B,CAa7B"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { AnnotationNode, ConstraintNode, JsonValue, PathTarget, Provenance, TypeNode } from "@formspec/core";
|
|
2
|
+
export interface AnalysisTypeDefinition {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly type: TypeNode;
|
|
5
|
+
readonly constraints?: readonly ConstraintNode[];
|
|
6
|
+
readonly annotations?: readonly AnnotationNode[];
|
|
7
|
+
readonly provenance: Provenance;
|
|
8
|
+
}
|
|
9
|
+
export type AnalysisTypeRegistry = Record<string, AnalysisTypeDefinition>;
|
|
10
|
+
export interface EffectiveTargetState {
|
|
11
|
+
readonly fieldName: string;
|
|
12
|
+
readonly path: PathTarget | null;
|
|
13
|
+
readonly targetName: string;
|
|
14
|
+
readonly type: TypeNode;
|
|
15
|
+
readonly inheritedConstraints: readonly ConstraintNode[];
|
|
16
|
+
readonly inheritedAnnotations: readonly AnnotationNode[];
|
|
17
|
+
readonly localConstraints: readonly ConstraintNode[];
|
|
18
|
+
readonly effectiveConstraints: readonly ConstraintNode[];
|
|
19
|
+
}
|
|
20
|
+
export type ResolvedTargetState = ({
|
|
21
|
+
readonly kind: "resolved";
|
|
22
|
+
} & EffectiveTargetState) | {
|
|
23
|
+
readonly kind: "missing-property";
|
|
24
|
+
readonly fieldName: string;
|
|
25
|
+
readonly path: PathTarget;
|
|
26
|
+
readonly targetName: string;
|
|
27
|
+
readonly segment: string;
|
|
28
|
+
readonly localConstraints: readonly ConstraintNode[];
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: "unresolvable";
|
|
31
|
+
readonly fieldName: string;
|
|
32
|
+
readonly path: PathTarget;
|
|
33
|
+
readonly targetName: string;
|
|
34
|
+
readonly type: TypeNode;
|
|
35
|
+
readonly localConstraints: readonly ConstraintNode[];
|
|
36
|
+
};
|
|
37
|
+
export interface ConstraintSemanticDiagnostic {
|
|
38
|
+
readonly code: string;
|
|
39
|
+
readonly message: string;
|
|
40
|
+
readonly severity: "error" | "warning";
|
|
41
|
+
readonly primaryLocation: Provenance;
|
|
42
|
+
readonly relatedLocations: readonly Provenance[];
|
|
43
|
+
}
|
|
44
|
+
export interface ConstraintTargetAnalysisResult {
|
|
45
|
+
readonly diagnostics: readonly ConstraintSemanticDiagnostic[];
|
|
46
|
+
readonly targetStates: readonly ResolvedTargetState[];
|
|
47
|
+
}
|
|
48
|
+
export interface ConstraintSemanticRoleLike {
|
|
49
|
+
readonly family: string;
|
|
50
|
+
readonly bound: "lower" | "upper" | "exact";
|
|
51
|
+
readonly inclusive: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface ConstraintRegistrationLike {
|
|
54
|
+
readonly constraintName: string;
|
|
55
|
+
readonly applicableTypes: readonly TypeNode["kind"][] | null;
|
|
56
|
+
readonly isApplicableToType?: (type: TypeNode) => boolean;
|
|
57
|
+
readonly comparePayloads?: (left: JsonValue, right: JsonValue) => number;
|
|
58
|
+
readonly semanticRole?: ConstraintSemanticRoleLike;
|
|
59
|
+
}
|
|
60
|
+
export interface ConstraintTagRegistrationLike {
|
|
61
|
+
readonly tagName: string;
|
|
62
|
+
readonly constraintName: string;
|
|
63
|
+
readonly isApplicableToType?: (type: TypeNode) => boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface ConstraintRegistryLike {
|
|
66
|
+
findConstraint(constraintId: string): ConstraintRegistrationLike | undefined;
|
|
67
|
+
findConstraintTag(tagName: string): {
|
|
68
|
+
readonly extensionId: string;
|
|
69
|
+
readonly registration: ConstraintTagRegistrationLike;
|
|
70
|
+
} | undefined;
|
|
71
|
+
}
|
|
72
|
+
export declare function formatConstraintTargetName(fieldName: string, path: PathTarget | null): string;
|
|
73
|
+
export declare function dereferenceAnalysisType(type: TypeNode, typeRegistry: AnalysisTypeRegistry): TypeNode;
|
|
74
|
+
export declare function collectReferencedTypeConstraints(type: TypeNode, typeRegistry: AnalysisTypeRegistry): readonly ConstraintNode[];
|
|
75
|
+
export declare function collectReferencedTypeAnnotations(type: TypeNode, typeRegistry: AnalysisTypeRegistry): readonly AnnotationNode[];
|
|
76
|
+
export declare function resolveConstraintTargetState(fieldName: string, fieldType: TypeNode, path: PathTarget | null, localConstraints: readonly ConstraintNode[], typeRegistry: AnalysisTypeRegistry): ResolvedTargetState;
|
|
77
|
+
export declare function buildConstraintTargetStates(fieldName: string, fieldType: TypeNode, constraints: readonly ConstraintNode[], typeRegistry: AnalysisTypeRegistry): readonly ResolvedTargetState[];
|
|
78
|
+
/**
|
|
79
|
+
* Resolves targeted constraints against a field type, producing effective
|
|
80
|
+
* target states plus semantic diagnostics such as contradictions, unknown
|
|
81
|
+
* paths, and type mismatches.
|
|
82
|
+
*/
|
|
83
|
+
export declare function analyzeConstraintTargets(fieldName: string, fieldType: TypeNode, constraints: readonly ConstraintNode[], typeRegistry: AnalysisTypeRegistry, options?: {
|
|
84
|
+
readonly extensionRegistry?: ConstraintRegistryLike;
|
|
85
|
+
}): ConstraintTargetAnalysisResult;
|
|
86
|
+
//# sourceMappingURL=semantic-targets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-targets.d.ts","sourceRoot":"","sources":["../src/semantic-targets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAEd,SAAS,EAET,UAAU,EACV,UAAU,EACV,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IACjD,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IACjD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACjC;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAE1E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,oBAAoB,EAAE,SAAS,cAAc,EAAE,CAAC;IACzD,QAAQ,CAAC,oBAAoB,EAAE,SAAS,cAAc,EAAE,CAAC;IACzD,QAAQ,CAAC,gBAAgB,EAAE,SAAS,cAA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gC,CAC9C,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,oBAAoB,GACjC,SAAS,cAAc,EAAE,CAwB3B;AAED,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,oBAAoB,GACjC,SAAS,cAAc,EAAE,CAwB3B;AAmDD,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,QAAQ,EACnB,IAAI,EAAE,UAAU,GAAG,IAAI,EACvB,gBAAgB,EAAE,SAAS,cAAc,EAAE,EAC3C,YAAY,EAAE,oBAAoB,GACjC,mBAAmB,CA8DrB;AASD,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,QAAQ,EACnB,WAAW,EAAE,SAAS,cAAc,EAAE,EACtC,YAAY,EAAE,oBAAoB,GACjC,SAAS,mBAAmB,EAAE,CAmBhC;AAg8BD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,QAAQ,EACnB,WAAW,EAAE,SAAS,cAAc,EAAE,EACtC,YAAY,EAAE,oBAAoB,EAClC,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;CACrD,GACA,8BAA8B,CA2ChC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the last leading TSDoc/JSDoc block attached to a declaration node.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getLastLeadingDocCommentRange(node: ts.Node, sourceFile: ts.SourceFile): ts.CommentRange | null;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the direct subject type for declarations that can carry FormSpec
|
|
8
|
+
* comment tags.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSubjectType(node: ts.Node, checker: ts.TypeChecker): ts.Type | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the enclosing host type for declarations nested under a containing
|
|
13
|
+
* class, interface, or type literal.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getHostType(node: ts.Node, checker: ts.TypeChecker): ts.Type | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Finds the smallest declaration whose leading doc comment contains the given
|
|
18
|
+
* source offset.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findDeclarationForCommentOffset(sourceFile: ts.SourceFile, offset: number): ts.Node | null;
|
|
21
|
+
//# sourceMappingURL=source-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-bindings.d.ts","sourceRoot":"","sources":["../src/source-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,EAAE,EAAE,CAAC,UAAU,GACxB,EAAE,CAAC,YAAY,GAAG,IAAI,CAMxB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,IAAI,GAAG,SAAS,CAgB1F;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,IAAI,GAAG,SAAS,CAYvF;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,MAAM,EAAE,MAAM,GACb,EAAE,CAAC,IAAI,GAAG,IAAI,CAkBhB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type FormSpecValueKind = "number" | "integer" | "signedInteger" | "string" | "json" | "boolean" | "condition";
|
|
2
|
+
export type FormSpecTargetKind = "none" | "path" | "member" | "variant";
|
|
3
|
+
export type FormSpecTagCategory = "constraint" | "annotation" | "structure" | "ecosystem";
|
|
4
|
+
export type FormSpecPlacement = "class" | "class-field" | "class-method" | "interface" | "interface-field" | "type-alias" | "type-alias-field" | "variable" | "function" | "function-parameter" | "method-parameter";
|
|
5
|
+
export type SemanticCapability = "numeric-comparable" | "string-like" | "array-like" | "enum-member-addressable" | "json-like" | "condition-like" | "object-like";
|
|
6
|
+
export interface TagSignatureParameter {
|
|
7
|
+
readonly kind: "value" | "target-path" | "target-member" | "target-variant";
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly optional?: boolean;
|
|
10
|
+
readonly capability?: SemanticCapability;
|
|
11
|
+
readonly valueKind?: FormSpecValueKind;
|
|
12
|
+
}
|
|
13
|
+
export interface TagSignature {
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly placements: readonly FormSpecPlacement[];
|
|
16
|
+
readonly parameters: readonly TagSignatureParameter[];
|
|
17
|
+
}
|
|
18
|
+
export interface TagDefinition {
|
|
19
|
+
readonly canonicalName: string;
|
|
20
|
+
readonly valueKind: FormSpecValueKind | null;
|
|
21
|
+
readonly requiresArgument: boolean;
|
|
22
|
+
readonly supportedTargets: readonly FormSpecTargetKind[];
|
|
23
|
+
readonly allowDuplicates: boolean;
|
|
24
|
+
readonly category: FormSpecTagCategory;
|
|
25
|
+
readonly placements: readonly FormSpecPlacement[];
|
|
26
|
+
readonly capabilities: readonly SemanticCapability[];
|
|
27
|
+
readonly completionDetail: string;
|
|
28
|
+
readonly hoverMarkdown: string;
|
|
29
|
+
readonly signatures: readonly TagSignature[];
|
|
30
|
+
}
|
|
31
|
+
export type FormSpecTagDefinition = TagDefinition;
|
|
32
|
+
export type FormSpecTagOverload = TagSignature;
|
|
33
|
+
export type FormSpecTagParameter = TagSignatureParameter;
|
|
34
|
+
export interface ExtensionConstraintTagSource {
|
|
35
|
+
readonly tagName: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ExtensionTagSource {
|
|
38
|
+
readonly extensionId: string;
|
|
39
|
+
readonly constraintTags?: readonly ExtensionConstraintTagSource[];
|
|
40
|
+
}
|
|
41
|
+
export declare function normalizeFormSpecTagName(rawName: string): string;
|
|
42
|
+
export declare function getTagDefinition(rawName: string, extensions?: readonly ExtensionTagSource[]): TagDefinition | null;
|
|
43
|
+
export declare function getConstraintTagDefinitions(extensions?: readonly ExtensionTagSource[]): readonly TagDefinition[];
|
|
44
|
+
export declare function getAllTagDefinitions(extensions?: readonly ExtensionTagSource[]): readonly TagDefinition[];
|
|
45
|
+
export declare function getTagHoverMarkdown(rawName: string, extensions?: readonly ExtensionTagSource[]): string | null;
|
|
46
|
+
//# sourceMappingURL=tag-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag-registry.d.ts","sourceRoot":"","sources":["../src/tag-registry.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,SAAS,GACT,eAAe,GACf,QAAQ,GACR,MAAM,GACN,SAAS,GACT,WAAW,CAAC;AAEhB,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC;AAE1F,MAAM,MAAM,iBAAiB,GACzB,OAAO,GACP,aAAa,GACb,cAAc,GACd,WAAW,GACX,iBAAiB,GACjB,YAAY,GACZ,kBAAkB,GAClB,UAAU,GACV,UAAU,GACV,oBAAoB,GACpB,kBAAkB,CAAC;AAEvB,MAAM,MAAM,kBAAkB,GAC1B,oBAAoB,GACpB,aAAa,GACb,YAAY,GACZ,yBAAyB,GACzB,WAAW,GACX,gBAAgB,GAChB,aAAa,CAAC;AAElB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,eAAe,GAAG,gBAAgB,CAAC;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB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Q,CAAC,cAAc,CAAC,EAAE,SAAS,4BAA4B,EAAE,CAAC;CACnE;AAspBD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,SAAS,kBAAkB,EAAE,GACzC,aAAa,GAAG,IAAI,CA6CtB;AAED,wBAAgB,2BAA2B,CACzC,UAAU,CAAC,EAAE,SAAS,kBAAkB,EAAE,GACzC,SAAS,aAAa,EAAE,CAM1B;AAED,wBAAgB,oBAAoB,CAClC,UAAU,CAAC,EAAE,SAAS,kBAAkB,EAAE,GACzC,SAAS,aAAa,EAAE,CAO1B;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,SAAS,kBAAkB,EAAE,GACzC,MAAM,GAAG,IAAI,CAEf"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AnnotationNode, type BuiltinConstraintBroadeningRegistration, type ConstraintNode, type ConstraintTagRegistration, type CustomConstraintRegistration, type ExtensionDefinition, type Provenance, type TypeNode } from "@formspec/core";
|
|
2
|
+
export interface ConstraintTagParseRegistryLike {
|
|
3
|
+
readonly extensions: readonly ExtensionDefinition[];
|
|
4
|
+
findConstraint(constraintId: string): CustomConstraintRegistration | undefined;
|
|
5
|
+
findConstraintTag(tagName: string): {
|
|
6
|
+
readonly extensionId: string;
|
|
7
|
+
readonly registration: ConstraintTagRegistration;
|
|
8
|
+
} | undefined;
|
|
9
|
+
findBuiltinConstraintBroadening(typeId: string, tagName: string): {
|
|
10
|
+
readonly extensionId: string;
|
|
11
|
+
readonly registration: BuiltinConstraintBroadeningRegistration;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface ParseConstraintTagValueOptions {
|
|
15
|
+
readonly registry?: ConstraintTagParseRegistryLike;
|
|
16
|
+
readonly fieldType?: TypeNode;
|
|
17
|
+
}
|
|
18
|
+
export declare function parseConstraintTagValue(tagName: string, text: string, provenance: Provenance, options?: ParseConstraintTagValueOptions): ConstraintNode | null;
|
|
19
|
+
export declare function parseDefaultValueTagValue(text: string, provenance: Provenance): AnnotationNode;
|
|
20
|
+
//# sourceMappingURL=tag-value-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag-value-parser.d.ts","sourceRoot":"","sources":["../src/tag-value-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,uCAAuC,EAC5C,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EAKxB,KAAK,UAAU,EACf,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AA0BxB,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACpD,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAAC;IAC/E,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAC7B;QACE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,YAAY,EAAE,yBAAyB,CAAC;KAClD,GACD,SAAS,CAAC;IACd,+BAA+B,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAEb;QACE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,YAAY,EAAE,uCAAuC,CAAC;KAChE,GACD,SAAS,CAAC;CACf;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,8BAA8B,CAAC;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC;CAC/B;AAQD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,8BAA8B,GACvC,cAAc,GAAG,IAAI,CAwIvB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,cAAc,CAqB9F"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import type { FormSpecPlacement, SemanticCapability } from "./tag-registry.js";
|
|
3
|
+
export type FormSpecSemanticCapability = SemanticCapability;
|
|
4
|
+
/**
|
|
5
|
+
* Result of resolving a dotted FormSpec path target through a TypeScript type.
|
|
6
|
+
*/
|
|
7
|
+
export type ResolvedPathTargetType = {
|
|
8
|
+
readonly kind: "resolved";
|
|
9
|
+
readonly type: ts.Type;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: "missing-property";
|
|
12
|
+
readonly segment: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "unresolvable";
|
|
15
|
+
readonly type: ts.Type;
|
|
16
|
+
};
|
|
17
|
+
export declare function resolveDeclarationPlacement(node: ts.Node): FormSpecPlacement | null;
|
|
18
|
+
export declare function getTypeSemanticCapabilities(type: ts.Type, checker: ts.TypeChecker): readonly SemanticCapability[];
|
|
19
|
+
export declare function hasTypeSemanticCapability(type: ts.Type, checker: ts.TypeChecker, capability: SemanticCapability): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves a dotted FormSpec path target against a TypeScript type.
|
|
22
|
+
*
|
|
23
|
+
* Arrays are traversed through their item type so path-targets behave the same
|
|
24
|
+
* way they do in the IR validator and cursor-context completion logic.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolvePathTargetType(type: ts.Type, checker: ts.TypeChecker, segments: readonly string[]): ResolvedPathTargetType;
|
|
27
|
+
export declare function collectCompatiblePathTargets(type: ts.Type, checker: ts.TypeChecker, capability: SemanticCapability): readonly string[];
|
|
28
|
+
//# sourceMappingURL=ts-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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,EAAE,kBAAkB,GAC7B,SAAS,MAAM,EAAE,CAEnB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable workspace-scoped identifier derived from the absolute workspace root.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getFormSpecWorkspaceId(workspaceRoot: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Directory used for machine-generated FormSpec tooling state inside a
|
|
7
|
+
* workspace.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getFormSpecWorkspaceRuntimeDirectory(workspaceRoot: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Path to the manifest that advertises the local FormSpec semantic service for
|
|
12
|
+
* a workspace.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getFormSpecManifestPath(workspaceRoot: string): string;
|
|
15
|
+
//# sourceMappingURL=workspace-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-runtime.d.ts","sourceRoot":"","sources":["../src/workspace-runtime.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAElF;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAErE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@formspec/analysis",
|
|
3
|
+
"version": "0.1.0-alpha.20",
|
|
4
|
+
"description": "Shared comment-tag analysis utilities for FormSpec tooling",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/analysis.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/analysis.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@formspec/core": "0.1.0-alpha.19"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"typescript": "^5.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"vitest": "^3.0.0"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"license": "UNLICENSED",
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup && tsc --emitDeclarationOnly && api-extractor run --local",
|
|
35
|
+
"clean": "rm -rf dist temp",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"api-extractor": "api-extractor run",
|
|
39
|
+
"api-extractor:local": "api-extractor run --local",
|
|
40
|
+
"api-documenter": "api-documenter markdown -i temp -o docs"
|
|
41
|
+
}
|
|
42
|
+
}
|