dsh-typst-plugin 0.1.0-alpha.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.en.md +86 -52
  2. package/README.md +93 -59
  3. package/cordis.patch.yml +1 -1
  4. package/docs/images/icon.png +0 -0
  5. package/lib/client.js +2088 -1136
  6. package/lib/client.js.map +4 -4
  7. package/lib/config.d.ts +66 -9
  8. package/lib/config.d.ts.map +1 -1
  9. package/lib/config.js +161 -25
  10. package/lib/config.js.map +1 -7
  11. package/lib/constants.d.ts +21 -2
  12. package/lib/constants.d.ts.map +1 -1
  13. package/lib/constants.js +83 -60
  14. package/lib/constants.js.map +1 -7
  15. package/lib/contract.d.ts +90 -6
  16. package/lib/contract.d.ts.map +1 -1
  17. package/lib/contract.js +9 -1
  18. package/lib/contract.js.map +1 -7
  19. package/lib/diagnostic-text.d.ts +13 -0
  20. package/lib/diagnostic-text.d.ts.map +1 -0
  21. package/lib/diagnostic-text.js +28 -0
  22. package/lib/diagnostic-text.js.map +1 -0
  23. package/lib/errors.d.ts +57 -15
  24. package/lib/errors.d.ts.map +1 -1
  25. package/lib/errors.js +154 -79
  26. package/lib/errors.js.map +1 -7
  27. package/lib/host/facts.d.ts.map +1 -1
  28. package/lib/host/facts.js +133 -139
  29. package/lib/host/facts.js.map +1 -7
  30. package/lib/host/which.d.ts +20 -0
  31. package/lib/host/which.d.ts.map +1 -0
  32. package/lib/host/which.js +50 -0
  33. package/lib/host/which.js.map +1 -0
  34. package/lib/index.js +2 -5
  35. package/lib/index.js.map +1 -7
  36. package/lib/remote.d.ts +5 -4
  37. package/lib/remote.d.ts.map +1 -1
  38. package/lib/remote.js +153 -143
  39. package/lib/remote.js.map +1 -7
  40. package/lib/service.d.ts +28 -4
  41. package/lib/service.d.ts.map +1 -1
  42. package/lib/service.js +202 -99
  43. package/lib/service.js.map +1 -7
  44. package/lib/skills/typst.js +74 -68
  45. package/lib/skills/typst.js.map +1 -7
  46. package/lib/status-codec.js +10 -5
  47. package/lib/status-codec.js.map +1 -7
  48. package/lib/tools/registration.d.ts +4 -3
  49. package/lib/tools/registration.d.ts.map +1 -1
  50. package/lib/tools/registration.js +726 -493
  51. package/lib/tools/registration.js.map +1 -7
  52. package/lib/tools/shared.d.ts +4 -5
  53. package/lib/tools/shared.d.ts.map +1 -1
  54. package/lib/tools/shared.js +73 -64
  55. package/lib/tools/shared.js.map +1 -7
  56. package/lib/typert.d.ts +5 -3
  57. package/lib/typert.d.ts.map +1 -1
  58. package/lib/typert.js +113 -64
  59. package/lib/typert.js.map +1 -7
  60. package/lib/typst/diagnostics.d.ts.map +1 -1
  61. package/lib/typst/diagnostics.js +218 -152
  62. package/lib/typst/diagnostics.js.map +1 -7
  63. package/lib/typst/flags.d.ts +8 -0
  64. package/lib/typst/flags.d.ts.map +1 -0
  65. package/lib/typst/flags.js +8 -0
  66. package/lib/typst/flags.js.map +1 -0
  67. package/lib/typst/locate.d.ts +6 -13
  68. package/lib/typst/locate.d.ts.map +1 -1
  69. package/lib/typst/locate.js +138 -180
  70. package/lib/typst/locate.js.map +1 -7
  71. package/lib/typst/mainfile.d.ts +23 -4
  72. package/lib/typst/mainfile.d.ts.map +1 -1
  73. package/lib/typst/mainfile.js +131 -59
  74. package/lib/typst/mainfile.js.map +1 -7
  75. package/lib/typst/match.d.ts +9 -1
  76. package/lib/typst/match.d.ts.map +1 -1
  77. package/lib/typst/match.js +213 -157
  78. package/lib/typst/match.js.map +1 -7
  79. package/lib/typst/oneshot.d.ts +8 -5
  80. package/lib/typst/oneshot.d.ts.map +1 -1
  81. package/lib/typst/oneshot.js +76 -66
  82. package/lib/typst/oneshot.js.map +1 -7
  83. package/lib/typst/owners.d.ts +28 -0
  84. package/lib/typst/owners.d.ts.map +1 -0
  85. package/lib/typst/owners.js +98 -0
  86. package/lib/typst/owners.js.map +1 -0
  87. package/lib/typst/pdf-extract.d.ts +1 -2
  88. package/lib/typst/pdf-extract.d.ts.map +1 -1
  89. package/lib/typst/pdf-extract.js +98 -74
  90. package/lib/typst/pdf-extract.js.map +1 -7
  91. package/lib/typst/process.d.ts +73 -0
  92. package/lib/typst/process.d.ts.map +1 -0
  93. package/lib/typst/process.js +147 -0
  94. package/lib/typst/process.js.map +1 -0
  95. package/lib/typst/text.d.ts +4 -7
  96. package/lib/typst/text.d.ts.map +1 -1
  97. package/lib/typst/text.js +258 -290
  98. package/lib/typst/text.js.map +1 -7
  99. package/lib/typst/watcher.d.ts +16 -17
  100. package/lib/typst/watcher.d.ts.map +1 -1
  101. package/lib/typst/watcher.js +199 -208
  102. package/lib/typst/watcher.js.map +1 -7
  103. package/lib/wire-schemas.d.ts +8 -153
  104. package/lib/wire-schemas.d.ts.map +1 -1
  105. package/lib/wire-schemas.js +405 -361
  106. package/lib/wire-schemas.js.map +1 -7
  107. package/lib/workspace/containment.d.ts +25 -0
  108. package/lib/workspace/containment.d.ts.map +1 -0
  109. package/lib/workspace/containment.js +54 -0
  110. package/lib/workspace/containment.js.map +1 -0
  111. package/lib/workspace/session.d.ts +73 -14
  112. package/lib/workspace/session.d.ts.map +1 -1
  113. package/lib/workspace/session.js +1516 -1172
  114. package/lib/workspace/session.js.map +1 -7
  115. package/locale/en.json +8 -2
  116. package/locale/zh.json +8 -2
  117. package/package.json +36 -179
  118. package/release-provenance.json +137 -0
  119. package/lib/typst/pdfjs-worker.d.js +0 -1
  120. package/lib/typst/pdfjs-worker.d.js.map +0 -7
@@ -1,384 +1,428 @@
1
+ /**
2
+ * The wire boundary's single source: every zod schema the `typst` namespace
3
+ * validates with, and the one shared invocation list both halves register.
4
+ * `TYPST_INVOCATIONS` materializes each schema once through `strictCodec()`;
5
+ * the host manifest aliases it in `src/status-codec.ts` and the browser face
6
+ * aliases it in `src/client/status-codec.ts`. Neither half imports the
7
+ * other's module or builds its own descriptor list, so the two sides cannot
8
+ * disagree about a boundary.
9
+ *
10
+ * Client-safe: its imports are `zod`, the contract's own types, and the
11
+ * runtime constants module, all of which
12
+ * `scripts/client-graph-authority.mjs` allowlists.
13
+ * @module dsh-typst/wire-schemas
14
+ */
1
15
  import { z } from "zod";
2
- import {
3
- TYPST_LOCATE_SOURCE_METHOD,
4
- TYPST_READ_PREVIEW_METHOD,
5
- TYPST_SET_MAIN_METHOD,
6
- TYPST_STATUS_METHOD,
7
- TYPST_STATUS_SERVICE_KEY,
8
- TYPST_SETTINGS_NAMESPACE,
9
- TYPST_WATCH_METHOD
10
- } from "./constants.js";
11
- function strictCodec(typeSymbol, schema) {
12
- return { mode: "strict", typeSymbol, create: () => schema };
16
+ import { TYPST_LOCATE_SOURCE_METHOD, TYPST_READ_PREVIEW_METHOD, TYPST_REMOTE_PACKAGE, TYPST_SCOPE_WIRE_SYMBOL, TYPST_SET_MAIN_METHOD, TYPST_STATUS_METHOD, TYPST_STATUS_SERVICE_KEY, TYPST_SETTINGS_NAMESPACE, TYPST_WATCH_METHOD, } from "./constants.js";
17
+ /**
18
+ * Wrap a wire schema in the strict codec arm Typert expects. The strict arm
19
+ * is exactly `{ mode, typeSymbol, create }` (plus optional `encode`/`decode`
20
+ * for byte-carrying results, which the preview result adds), so no live
21
+ * schema property is carried and `create()` materializes on first use.
22
+ * @param typeSymbol - the boundary type identity the manifest declares.
23
+ * @param schema - the shared wire schema both halves validate through.
24
+ * @returns the strict codec arm.
25
+ */
26
+ export function strictCodec(typeSymbol, schema) {
27
+ return { mode: "strict", typeSymbol, create: () => schema };
13
28
  }
14
- const typstSourceSchema = z.enum(["setting", "path", "common", "shell"]);
15
- const toolchainSchema = z.discriminatedUnion("state", [
16
- z.object({
17
- state: z.literal("ready"),
18
- version: z.string(),
19
- path: z.string(),
20
- source: typstSourceSchema
21
- }).strict(),
22
- z.object({ state: z.literal("missing") }).strict(),
23
- z.object({
24
- state: z.literal("too_old"),
25
- version: z.string(),
26
- path: z.string(),
27
- source: typstSourceSchema,
28
- error: z.string()
29
- }).strict(),
30
- z.object({
31
- state: z.literal("error"),
32
- path: z.string().optional(),
33
- source: typstSourceSchema.optional(),
34
- error: z.string()
35
- }).strict()
29
+ /** The boundary symbol of a type this package owns. */
30
+ function typstTypeSymbol(name) {
31
+ return `${TYPST_REMOTE_PACKAGE}#${name}`;
32
+ }
33
+ // ---------------------------------------------------------------------------
34
+ // Schemas
35
+ // ---------------------------------------------------------------------------
36
+ export const typstSourceSchema = z.enum(["setting", "path", "common", "shell"]);
37
+ export const toolchainSchema = z.discriminatedUnion("state", [
38
+ z
39
+ .object({
40
+ state: z.literal("ready"),
41
+ version: z.string(),
42
+ path: z.string(),
43
+ source: typstSourceSchema,
44
+ })
45
+ .strict(),
46
+ z.object({ state: z.literal("missing") }).strict(),
47
+ z
48
+ .object({
49
+ state: z.literal("too_old"),
50
+ version: z.string(),
51
+ path: z.string(),
52
+ source: typstSourceSchema,
53
+ error: z.string(),
54
+ })
55
+ .strict(),
56
+ z
57
+ .object({
58
+ state: z.literal("error"),
59
+ path: z.string().optional(),
60
+ source: typstSourceSchema.optional(),
61
+ error: z.string(),
62
+ })
63
+ .strict(),
36
64
  ]);
37
- const diagnosticLocationSchema = z.object({
38
- file: z.string(),
39
- line: z.number().int(),
40
- column: z.number().int()
41
- }).strict();
42
- const diagnosticPointSchema = z.object({
43
- message: z.string(),
44
- location: diagnosticLocationSchema.nullable()
45
- }).strict();
46
- const diagnosticSchema = z.object({
47
- severity: z.enum(["error", "warning"]),
48
- message: z.string(),
49
- location: diagnosticLocationSchema.nullable(),
50
- excerpt: z.string().optional(),
51
- hints: z.array(z.string()),
52
- trace: z.array(diagnosticPointSchema)
53
- }).strict();
54
- const compilePhaseSchema = z.enum([
55
- "idle",
56
- "starting",
57
- "compiling",
58
- "ok",
59
- "warnings",
60
- "error",
61
- "crashed"
65
+ export const diagnosticLocationSchema = z
66
+ .object({
67
+ file: z.string(),
68
+ line: z.number().int(),
69
+ column: z.number().int(),
70
+ })
71
+ .strict();
72
+ export const diagnosticPointSchema = z
73
+ .object({
74
+ message: z.string(),
75
+ location: diagnosticLocationSchema.nullable(),
76
+ })
77
+ .strict();
78
+ export const diagnosticSchema = z
79
+ .object({
80
+ severity: z.enum(["error", "warning"]),
81
+ message: z.string(),
82
+ location: diagnosticLocationSchema.nullable(),
83
+ excerpt: z.string().optional(),
84
+ hints: z.array(z.string()),
85
+ trace: z.array(diagnosticPointSchema),
86
+ })
87
+ .strict();
88
+ export const compilePhaseSchema = z.enum([
89
+ "idle",
90
+ "starting",
91
+ "compiling",
92
+ "ok",
93
+ "warnings",
94
+ "error",
95
+ "crashed",
62
96
  ]);
63
- const statusSchema = z.object({
64
- phase: compilePhaseSchema,
65
- run: z.number().int(),
66
- durationMs: z.number().optional(),
67
- error: z.string().optional(),
68
- finishedAt: z.number().optional()
69
- }).strict();
70
- const previewIdentitySchema = z.object({
71
- generation: z.number().int(),
72
- seq: z.number().int(),
73
- sha256: z.string()
74
- }).strict();
75
- const snapshotSchema = z.object({
76
- generation: z.number().int(),
77
- main: z.string(),
78
- run: z.number().int(),
79
- seq: z.number().int(),
80
- bytes: z.number().int(),
81
- pages: z.number().int(),
82
- sha256: z.string(),
83
- createdAt: z.number()
84
- }).strict();
85
- const sourceRefSchema = z.object({
86
- file: z.string(),
87
- line: z.number().int(),
88
- endLine: z.number().int()
89
- }).strict();
90
- const highlightSchema = z.object({
91
- id: z.string(),
92
- identity: previewIdentitySchema,
93
- quote: z.string(),
94
- comment: z.string(),
95
- source: sourceRefSchema.optional(),
96
- seq: z.number().int(),
97
- pageIndex: z.number().int(),
98
- rects: z.array(z.array(z.number())),
99
- stale: z.boolean(),
100
- createdAt: z.number()
101
- }).strict();
102
- const panelViewSchema = z.discriminatedUnion("kind", [
103
- z.object({
104
- kind: z.literal("page"),
105
- pageIndex: z.number().int(),
106
- identity: previewIdentitySchema
107
- }).strict(),
108
- z.object({
109
- kind: z.literal("highlight"),
97
+ export const statusSchema = z
98
+ .object({
99
+ phase: compilePhaseSchema,
100
+ run: z.number().int(),
101
+ durationMs: z.number().optional(),
102
+ error: z.string().optional(),
103
+ finishedAt: z.number().optional(),
104
+ })
105
+ .strict();
106
+ export const previewIdentitySchema = z
107
+ .object({
108
+ generation: z.number().int(),
109
+ seq: z.number().int(),
110
+ sha256: z.string(),
111
+ })
112
+ .strict();
113
+ export const snapshotSchema = z
114
+ .object({
115
+ generation: z.number().int(),
116
+ main: z.string(),
117
+ run: z.number().int(),
118
+ seq: z.number().int(),
119
+ bytes: z.number().int(),
120
+ pages: z.number().int(),
121
+ sha256: z.string(),
122
+ createdAt: z.number(),
123
+ })
124
+ .strict();
125
+ export const sourceRefSchema = z
126
+ .object({
127
+ file: z.string(),
128
+ line: z.number().int(),
129
+ endLine: z.number().int(),
130
+ })
131
+ .strict();
132
+ export const highlightSchema = z
133
+ .object({
110
134
  id: z.string(),
111
- identity: previewIdentitySchema
112
- }).strict()
135
+ identity: previewIdentitySchema,
136
+ quote: z.string(),
137
+ comment: z.string(),
138
+ source: sourceRefSchema.optional(),
139
+ seq: z.number().int(),
140
+ pageIndex: z.number().int(),
141
+ startOffset: z.number().int().optional(),
142
+ occurrence: z.number().int().optional(),
143
+ rects: z.array(z.array(z.number())),
144
+ stale: z.boolean(),
145
+ createdAt: z.number(),
146
+ })
147
+ .strict();
148
+ export const panelViewSchema = z.discriminatedUnion("kind", [
149
+ z
150
+ .object({
151
+ kind: z.literal("page"),
152
+ pageIndex: z.number().int(),
153
+ identity: previewIdentitySchema,
154
+ })
155
+ .strict(),
156
+ z
157
+ .object({
158
+ kind: z.literal("highlight"),
159
+ id: z.string(),
160
+ identity: previewIdentitySchema,
161
+ })
162
+ .strict(),
113
163
  ]);
114
- const packageManagerSchema = z.object({
115
- name: z.string(),
116
- version: z.string().optional(),
117
- path: z.string()
118
- }).strict();
119
- const hostFactsSchema = z.object({
120
- os: z.enum(["macos", "windows", "linux", "other"]),
121
- osName: z.string(),
122
- arch: z.string(),
123
- tools: z.array(packageManagerSchema)
124
- }).strict();
125
- const setupSchema = z.object({
126
- facts: hostFactsSchema.nullable(),
127
- searched: z.array(z.string())
128
- }).strict();
129
- const typstStateFrameSchema = z.object({
130
- version: z.number().int(),
131
- generation: z.number().int(),
132
- previewError: z.string().nullable(),
133
- discovery: z.object({
134
- scanning: z.boolean(),
135
- includeExcluded: z.boolean(),
136
- visited: z.number().int(),
137
- errors: z.array(z.string())
138
- }).strict(),
139
- toolchain: toolchainSchema,
140
- workspace: z.string(),
141
- main: z.string().nullable(),
142
- candidates: z.array(z.string()),
143
- fragments: z.array(z.string()),
144
- status: statusSchema,
145
- diagnostics: z.array(diagnosticSchema),
146
- snapshot: snapshotSchema.nullable(),
147
- highlights: z.array(highlightSchema),
148
- view: z.union([panelViewSchema, z.null()]),
149
- viewSeq: z.number().int(),
150
- setup: setupSchema
151
- }).strict();
152
- const setMainResultSchema = z.object({ main: z.string() }).strict();
153
- const sourceMatchSchema = z.object({
154
- file: z.string(),
155
- line: z.number().int(),
156
- column: z.number().int(),
157
- endLine: z.number().int(),
158
- excerpt: z.string(),
159
- score: z.number()
160
- }).strict();
161
- const locateSourceResultSchema = z.object({ matches: z.array(sourceMatchSchema) }).strict();
162
- const previewBytesSchema = z.object({
163
- generation: z.number().int(),
164
- seq: z.number().int(),
165
- sha256: z.string(),
166
- data: z.custom()
167
- }).strict();
168
- const recheckResultSchema = typstStateFrameSchema;
164
+ export const packageManagerSchema = z
165
+ .object({
166
+ name: z.string(),
167
+ version: z.string().optional(),
168
+ path: z.string(),
169
+ })
170
+ .strict();
171
+ export const hostFactsSchema = z
172
+ .object({
173
+ os: z.enum(["macos", "windows", "linux", "other"]),
174
+ osName: z.string(),
175
+ arch: z.string(),
176
+ tools: z.array(packageManagerSchema),
177
+ })
178
+ .strict();
179
+ export const setupSchema = z
180
+ .object({
181
+ facts: hostFactsSchema.nullable(),
182
+ searched: z.array(z.string()),
183
+ })
184
+ .strict();
185
+ export const typstStateFrameSchema = z
186
+ .object({
187
+ version: z.number().int(),
188
+ generation: z.number().int(),
189
+ previewError: z.string().nullable(),
190
+ discovery: z
191
+ .object({
192
+ scanning: z.boolean(),
193
+ includeExcluded: z.boolean(),
194
+ visited: z.number().int(),
195
+ errors: z.array(z.string()),
196
+ })
197
+ .strict(),
198
+ toolchain: toolchainSchema,
199
+ workspace: z.string(),
200
+ workspaceRoot: z.string(),
201
+ main: z.string().nullable(),
202
+ candidates: z.array(z.string()),
203
+ fragments: z.array(z.string()),
204
+ status: statusSchema,
205
+ diagnostics: z.array(diagnosticSchema),
206
+ diagnosticsTotal: z.number().int(),
207
+ diagnosticsTruncated: z.boolean(),
208
+ snapshot: snapshotSchema.nullable(),
209
+ highlights: z.array(highlightSchema),
210
+ view: z.union([panelViewSchema, z.null()]),
211
+ viewSeq: z.number().int(),
212
+ setup: setupSchema,
213
+ })
214
+ .strict();
215
+ export const setMainResultSchema = z.object({ main: z.string() }).strict();
216
+ export const sourceMatchSchema = z
217
+ .object({
218
+ file: z.string(),
219
+ line: z.number().int(),
220
+ column: z.number().int(),
221
+ endLine: z.number().int(),
222
+ excerpt: z.string(),
223
+ score: z.number(),
224
+ })
225
+ .strict();
226
+ export const locateSourceResultSchema = z
227
+ .object({ matches: z.array(sourceMatchSchema) })
228
+ .strict();
229
+ export const previewBytesSchema = z
230
+ .object({
231
+ generation: z.number().int(),
232
+ seq: z.number().int(),
233
+ sha256: z.string(),
234
+ data: z.instanceof(Uint8Array),
235
+ })
236
+ .strict();
237
+ // ---------------------------------------------------------------------------
238
+ // Invocation descriptors
239
+ // ---------------------------------------------------------------------------
169
240
  const SERVICE = TYPST_STATUS_SERVICE_KEY;
170
241
  const NAMESPACE = TYPST_SETTINGS_NAMESPACE;
242
+ /** One strict result codec keyed to the manifest's declared symbol. */
171
243
  function resultCodec(typeSymbol, schema) {
172
- return strictCodec(typeSymbol, schema);
244
+ return strictCodec(typeSymbol, schema);
173
245
  }
246
+ /**
247
+ * Strict result codec that projects one typed binary field into the RPC's
248
+ * byte attachments: the preview PDF never rides JSON as base64.
249
+ */
174
250
  function bytesCodec(typeSymbol, schema, byteField) {
175
- return {
176
- mode: "strict",
177
- typeSymbol,
178
- create: () => schema,
179
- encode: (value, writeBytes) => {
180
- const record = value;
181
- const { [byteField]: data, ...rest } = record;
182
- return {
183
- ...rest,
184
- [byteField]: writeBytes(data, [byteField])
185
- };
186
- }
187
- };
251
+ return {
252
+ mode: "strict",
253
+ typeSymbol,
254
+ create: () => schema,
255
+ encode: (value, writeBytes) => {
256
+ const record = value;
257
+ const { [byteField]: data, ...rest } = record;
258
+ return {
259
+ ...rest,
260
+ [byteField]: writeBytes(data, [byteField]),
261
+ };
262
+ },
263
+ decode: (value) => schema.parse(value),
264
+ };
188
265
  }
266
+ /** The scope lookup parameter every endpoint takes (registered by the service). */
189
267
  function scopeParameter() {
190
- return {
191
- name: "typstScope",
192
- wire: "typstScopeId",
193
- source: "lookup",
194
- lookup: "typstScope",
195
- codec: strictCodec("@deepseek-ai/dsh-typst#TypstScopeId", z.string())
196
- };
268
+ return {
269
+ name: "typstScope",
270
+ wire: "typstScopeId",
271
+ source: "lookup",
272
+ lookup: "typstScope",
273
+ codec: strictCodec(TYPST_SCOPE_WIRE_SYMBOL, z.string()),
274
+ };
197
275
  }
198
- const stateFrameCodec = resultCodec(
199
- "@deepseek-ai/dsh-typst/types#TypstStateFrame",
200
- typstStateFrameSchema
201
- );
202
- const typstStatusInvocation = {
203
- id: "dsh-typst/status",
204
- service: SERVICE,
205
- namespace: NAMESPACE,
206
- method: TYPST_STATUS_METHOD,
207
- invocation: { kind: "direct" },
208
- cancellation: { parameter: "signal" },
209
- parameters: [scopeParameter()],
210
- result: stateFrameCodec
276
+ /** The typst state frame result codec, shared by `status`, `watch`, and `recheck`. */
277
+ export const stateFrameCodec = resultCodec(typstTypeSymbol("TypstStateFrame"), typstStateFrameSchema);
278
+ /** `status`: the current state frame, first push of the panel's data. */
279
+ export const typstStatusInvocation = {
280
+ id: "dsh-typst/status",
281
+ service: SERVICE,
282
+ namespace: NAMESPACE,
283
+ method: TYPST_STATUS_METHOD,
284
+ invocation: { kind: "direct" },
285
+ cancellation: { parameter: "signal" },
286
+ parameters: [scopeParameter()],
287
+ result: stateFrameCodec,
211
288
  };
212
- const typstSetMainInvocation = {
213
- id: "dsh-typst/setMain",
214
- service: SERVICE,
215
- namespace: NAMESPACE,
216
- method: TYPST_SET_MAIN_METHOD,
217
- invocation: { kind: "direct" },
218
- cancellation: { parameter: "signal" },
219
- parameters: [
220
- scopeParameter(),
221
- {
222
- name: "path",
223
- wire: "path",
224
- source: "json",
225
- codec: strictCodec(
226
- "@deepseek-ai/dsh-typst#setMain.path",
227
- z.string().min(1).max(1024)
228
- )
229
- }
230
- ],
231
- result: resultCodec(
232
- "@deepseek-ai/dsh-typst/types#SetMainResult",
233
- setMainResultSchema
234
- )
289
+ /** `setMain`: choose the main `.typ` file; the frame updates follow on the stream. */
290
+ export const typstSetMainInvocation = {
291
+ id: "dsh-typst/setMain",
292
+ service: SERVICE,
293
+ namespace: NAMESPACE,
294
+ method: TYPST_SET_MAIN_METHOD,
295
+ invocation: { kind: "direct" },
296
+ cancellation: { parameter: "signal" },
297
+ parameters: [
298
+ scopeParameter(),
299
+ {
300
+ name: "path",
301
+ wire: "path",
302
+ source: "json",
303
+ codec: strictCodec(typstTypeSymbol("typst/setMain:path"), z.string().min(1).max(1024)),
304
+ },
305
+ ],
306
+ result: resultCodec(typstTypeSymbol("typst/setMain:result"), setMainResultSchema),
235
307
  };
236
- const typstWatchInvocation = {
237
- id: "dsh-typst/watch",
238
- service: SERVICE,
239
- namespace: NAMESPACE,
240
- method: TYPST_WATCH_METHOD,
241
- mode: "stream",
242
- invocation: { kind: "direct" },
243
- cancellation: { parameter: "signal" },
244
- parameters: [scopeParameter()],
245
- result: stateFrameCodec
308
+ /**
309
+ * `watch`: the live state stream. `mode: 'stream'`: the first yielded frame
310
+ * is the current state, one frame follows every relevant change.
311
+ */
312
+ export const typstWatchInvocation = {
313
+ id: "dsh-typst/watch",
314
+ service: SERVICE,
315
+ namespace: NAMESPACE,
316
+ method: TYPST_WATCH_METHOD,
317
+ mode: "stream",
318
+ invocation: { kind: "direct" },
319
+ cancellation: { parameter: "signal" },
320
+ parameters: [scopeParameter()],
321
+ result: stateFrameCodec,
246
322
  };
247
- const typstReadPreviewInvocation = {
248
- id: "dsh-typst/readPreview",
249
- service: SERVICE,
250
- namespace: NAMESPACE,
251
- method: TYPST_READ_PREVIEW_METHOD,
252
- invocation: { kind: "direct" },
253
- cancellation: { parameter: "signal" },
254
- parameters: [
255
- scopeParameter(),
256
- {
257
- name: "identity",
258
- wire: "identity",
259
- source: "json",
260
- codec: strictCodec("dsh-typst#PreviewIdentity", previewIdentitySchema)
261
- }
262
- ],
263
- result: bytesCodec(
264
- "@deepseek-ai/dsh-typst/types#PreviewBytes",
265
- previewBytesSchema,
266
- "data"
267
- )
323
+ /**
324
+ * `readPreview`: the current preview PDF's bytes. The strict codec projects
325
+ * the `data` field into the RPC's byte attachments on the wire.
326
+ */
327
+ export const typstReadPreviewInvocation = {
328
+ id: "dsh-typst/readPreview",
329
+ service: SERVICE,
330
+ namespace: NAMESPACE,
331
+ method: TYPST_READ_PREVIEW_METHOD,
332
+ invocation: { kind: "direct" },
333
+ cancellation: { parameter: "signal" },
334
+ parameters: [
335
+ scopeParameter(),
336
+ {
337
+ name: "identity",
338
+ wire: "identity",
339
+ source: "json",
340
+ codec: strictCodec(typstTypeSymbol("PreviewIdentity"), previewIdentitySchema),
341
+ },
342
+ ],
343
+ result: bytesCodec(typstTypeSymbol("PreviewBytes"), previewBytesSchema, "data"),
268
344
  };
269
- const typstLocateSourceInvocation = {
270
- id: "dsh-typst/locateSource",
271
- service: SERVICE,
272
- namespace: NAMESPACE,
273
- method: TYPST_LOCATE_SOURCE_METHOD,
274
- invocation: { kind: "direct" },
275
- cancellation: { parameter: "signal" },
276
- parameters: [
277
- scopeParameter(),
278
- {
279
- name: "text",
280
- wire: "text",
281
- source: "json",
282
- codec: strictCodec(
283
- "@deepseek-ai/dsh-typst#locateSource.text",
284
- z.string().min(1).max(2e4)
285
- )
286
- },
287
- {
288
- name: "focus",
289
- wire: "focus",
290
- source: "json",
291
- codec: strictCodec(
292
- "@deepseek-ai/dsh-typst#locateSource.focus",
293
- z.string().min(1).max(2e4).nullable()
294
- )
295
- }
296
- ],
297
- result: resultCodec(
298
- "@deepseek-ai/dsh-typst/types#LocateSourceResult",
299
- locateSourceResultSchema
300
- )
345
+ /** `locateSource`: match rendered text against the workspace's sources. */
346
+ export const typstLocateSourceInvocation = {
347
+ id: "dsh-typst/locateSource",
348
+ service: SERVICE,
349
+ namespace: NAMESPACE,
350
+ method: TYPST_LOCATE_SOURCE_METHOD,
351
+ invocation: { kind: "direct" },
352
+ cancellation: { parameter: "signal" },
353
+ parameters: [
354
+ scopeParameter(),
355
+ {
356
+ name: "text",
357
+ wire: "text",
358
+ source: "json",
359
+ codec: strictCodec(typstTypeSymbol("typst/locateSource:text"), z.string().min(1).max(20_000)),
360
+ },
361
+ {
362
+ name: "focus",
363
+ wire: "focus",
364
+ source: "json",
365
+ codec: strictCodec(typstTypeSymbol("typst/locateSource:focus"), z.string().min(1).max(20_000).nullable()),
366
+ },
367
+ ],
368
+ result: resultCodec(typstTypeSymbol("typst/locateSource:result"), locateSourceResultSchema),
301
369
  };
302
- const typstRecheckInvocation = {
303
- id: "dsh-typst/recheck",
304
- service: SERVICE,
305
- namespace: NAMESPACE,
306
- method: "recheck",
307
- invocation: { kind: "direct" },
308
- cancellation: { parameter: "signal" },
309
- parameters: [scopeParameter()],
310
- result: stateFrameCodec
370
+ /** `recheck`: look Typst up again (the setup page's refresh), returning the new frame. */
371
+ export const typstRecheckInvocation = {
372
+ id: "dsh-typst/recheck",
373
+ service: SERVICE,
374
+ namespace: NAMESPACE,
375
+ method: "recheck",
376
+ invocation: { kind: "direct" },
377
+ cancellation: { parameter: "signal" },
378
+ parameters: [scopeParameter()],
379
+ result: stateFrameCodec,
311
380
  };
312
- const typstRestartInvocation = {
313
- id: "dsh-typst/restart",
314
- service: SERVICE,
315
- namespace: NAMESPACE,
316
- method: "restart",
317
- invocation: { kind: "direct" },
318
- cancellation: { parameter: "signal" },
319
- parameters: [scopeParameter()],
320
- result: stateFrameCodec
381
+ /** `restart`: stop the watch, relocate typst, rescan, restart (the panel's restart button). */
382
+ export const typstRestartInvocation = {
383
+ id: "dsh-typst/restart",
384
+ service: SERVICE,
385
+ namespace: NAMESPACE,
386
+ method: "restart",
387
+ invocation: { kind: "direct" },
388
+ cancellation: { parameter: "signal" },
389
+ parameters: [scopeParameter()],
390
+ result: stateFrameCodec,
321
391
  };
322
- const typstDiscoverInvocation = {
323
- id: "dsh-typst/discover",
324
- service: SERVICE,
325
- namespace: NAMESPACE,
326
- method: "discover",
327
- invocation: { kind: "direct" },
328
- cancellation: { parameter: "signal" },
329
- parameters: [
330
- scopeParameter(),
331
- {
332
- name: "includeExcluded",
333
- wire: "includeExcluded",
334
- source: "json",
335
- codec: strictCodec("dsh-typst#discover.includeExcluded", z.boolean())
336
- }
337
- ],
338
- result: resultCodec("dsh-typst#DiscoverResult", z.object({}).strict())
392
+ /** Explicit index refresh; the stream reports incremental progress. */
393
+ export const typstDiscoverInvocation = {
394
+ id: "dsh-typst/discover",
395
+ service: SERVICE,
396
+ namespace: NAMESPACE,
397
+ method: "discover",
398
+ invocation: { kind: "direct" },
399
+ cancellation: { parameter: "signal" },
400
+ parameters: [
401
+ scopeParameter(),
402
+ {
403
+ name: "includeExcluded",
404
+ wire: "includeExcluded",
405
+ source: "json",
406
+ codec: strictCodec(typstTypeSymbol("typst/discover:includeExcluded"), z.boolean()),
407
+ },
408
+ ],
409
+ result: resultCodec(typstTypeSymbol("typst/discover:result"), z
410
+ .object({
411
+ candidates: z.number().int(),
412
+ includeExcluded: z.boolean(),
413
+ errors: z.array(z.string()),
414
+ })
415
+ .strict()),
339
416
  };
340
- const TYPST_INVOCATIONS = [
341
- typstStatusInvocation,
342
- typstSetMainInvocation,
343
- typstWatchInvocation,
344
- typstReadPreviewInvocation,
345
- typstLocateSourceInvocation,
346
- typstRecheckInvocation,
347
- typstRestartInvocation,
348
- typstDiscoverInvocation
417
+ /** Both halves register exactly this list. */
418
+ export const TYPST_INVOCATIONS = [
419
+ typstStatusInvocation,
420
+ typstSetMainInvocation,
421
+ typstWatchInvocation,
422
+ typstReadPreviewInvocation,
423
+ typstLocateSourceInvocation,
424
+ typstRecheckInvocation,
425
+ typstRestartInvocation,
426
+ typstDiscoverInvocation,
349
427
  ];
350
- export {
351
- TYPST_INVOCATIONS,
352
- compilePhaseSchema,
353
- diagnosticLocationSchema,
354
- diagnosticPointSchema,
355
- diagnosticSchema,
356
- highlightSchema,
357
- hostFactsSchema,
358
- locateSourceResultSchema,
359
- packageManagerSchema,
360
- panelViewSchema,
361
- previewBytesSchema,
362
- previewIdentitySchema,
363
- recheckResultSchema,
364
- setMainResultSchema,
365
- setupSchema,
366
- snapshotSchema,
367
- sourceMatchSchema,
368
- sourceRefSchema,
369
- stateFrameCodec,
370
- statusSchema,
371
- strictCodec,
372
- toolchainSchema,
373
- typstDiscoverInvocation,
374
- typstLocateSourceInvocation,
375
- typstReadPreviewInvocation,
376
- typstRecheckInvocation,
377
- typstRestartInvocation,
378
- typstSetMainInvocation,
379
- typstSourceSchema,
380
- typstStateFrameSchema,
381
- typstStatusInvocation,
382
- typstWatchInvocation
383
- };
384
- //# sourceMappingURL=wire-schemas.js.map
428
+ //# sourceMappingURL=wire-schemas.js.map