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
package/lib/remote.js CHANGED
@@ -1,146 +1,156 @@
1
- import {
2
- TypertRemoteService
3
- } from "@deepseek-ai/dsh-typert-protocol";
4
- import {
5
- TYPST_STATUS_SERVICE_KEY,
6
- TYPST_SETTINGS_NAMESPACE
7
- } from "./constants.js";
8
- import {
9
- domainCall,
10
- TYPST_NOT_COMPOSED_MESSAGE,
11
- TypstError,
12
- TYPST_NOT_COMPOSED
13
- } from "./errors.js";
14
- class TypstRuntime extends TypertRemoteService {
15
- /**
16
- * Register the service under the shared cordis key bound to the `typst`
17
- * wire namespace.
18
- * @param ctx - owning cordis context.
19
- */
20
- constructor(ctx) {
21
- super(ctx, TYPST_STATUS_SERVICE_KEY, {
22
- namespace: TYPST_SETTINGS_NAMESPACE
23
- });
24
- }
25
- /** The composed workbench service, or a stable not-composed failure. */
26
- workbench() {
27
- const service = this.ctx.get("typstWorkbench");
28
- if (service === void 0) {
29
- throw new TypstError(TYPST_NOT_COMPOSED_MESSAGE, TYPST_NOT_COMPOSED);
1
+ /**
2
+ * The host Typert Remote runtime for the `typst` namespace: state frames,
3
+ * the live watch stream, preview bytes, file discovery, and source
4
+ * matching, all scoped to the calling Session's workspace through the
5
+ * `typstScope` lookup, adapted from the `workspaceFileScope` lookup shape in
6
+ * `@deepseek-ai/dsh-api-workspace-files` (that package is a reference, not a
7
+ * dependency of this plugin). Host half only.
8
+ * @module dsh-typst/remote
9
+ */
10
+ import { TypertRemoteService, } from "@deepseek-ai/dsh-typert-protocol";
11
+ import { TYPST_STATUS_SERVICE_KEY, TYPST_SETTINGS_NAMESPACE, } from "./constants.js";
12
+ import { domainCall, rethrowRemote, TYPST_NOT_COMPOSED_MESSAGE, TypstError, TYPST_NOT_COMPOSED, } from "./errors.js";
13
+ /**
14
+ * The `typst` namespace's host service. Every method resolves the calling
15
+ * session's workspace through the service's session registry, so two
16
+ * sessions on two workspaces preview independently.
17
+ */
18
+ export class TypstRuntime extends TypertRemoteService {
19
+ /**
20
+ * Register the service under the shared cordis key bound to the `typst`
21
+ * wire namespace.
22
+ * @param ctx - owning cordis context.
23
+ */
24
+ constructor(ctx) {
25
+ super(ctx, TYPST_STATUS_SERVICE_KEY, {
26
+ namespace: TYPST_SETTINGS_NAMESPACE,
27
+ });
30
28
  }
31
- return service;
32
- }
33
- /** Live state frame for the calling session's workspace; activates the session. */
34
- async status(typstScope, signal) {
35
- signal.throwIfAborted();
36
- return domainCall(async () => {
37
- const session = await this.workbench().sessionFor(
38
- typstScope.workspaceRoot
39
- );
40
- await session.activate();
41
- return session.state();
42
- });
43
- }
44
- /** Choose the main `.typ` file; state updates follow on the watch stream. */
45
- async setMain(typstScope, path, signal) {
46
- signal.throwIfAborted();
47
- return domainCall(async () => {
48
- const session = await this.workbench().sessionFor(
49
- typstScope.workspaceRoot
50
- );
51
- const main = await session.setMain(path);
52
- return { main };
53
- });
54
- }
55
- /**
56
- * The live state stream: the current frame first, then one frame per
57
- * relevant change. Opening the stream counts as a panel subscription, so
58
- * the setup re-lookup runs while Typst is unusable and stops when the
59
- * stream closes.
60
- */
61
- async *watch(typstScope, signal) {
62
- signal.throwIfAborted();
63
- const session = await domainCall(async () => {
64
- const workbench = this.workbench();
65
- const workspaceSession = await workbench.sessionFor(
66
- typstScope.workspaceRoot
67
- );
68
- await workspaceSession.activate();
69
- return workspaceSession;
70
- });
71
- session.watchSetup(true);
72
- try {
73
- const queue = session.state();
74
- yield queue;
75
- for await (const _ of session.onChangeWaiter(signal)) {
76
- yield session.state();
77
- }
78
- } finally {
79
- session.watchSetup(false);
29
+ /** The composed workbench service, or a stable not-composed failure. */
30
+ workbench() {
31
+ const service = this.ctx.get("typstWorkbench");
32
+ if (service === undefined) {
33
+ throw new TypstError(TYPST_NOT_COMPOSED_MESSAGE, TYPST_NOT_COMPOSED);
34
+ }
35
+ return service;
36
+ }
37
+ /** Live state frame for the calling session's workspace; activates the session. */
38
+ async status(typstScope, signal) {
39
+ signal.throwIfAborted();
40
+ return domainCall(async () => {
41
+ const session = await this.workbench().sessionFor(typstScope.workspaceRoot);
42
+ await session.activate();
43
+ return session.state();
44
+ });
45
+ }
46
+ /** Choose the main `.typ` file; state updates follow on the watch stream. */
47
+ async setMain(typstScope, path, signal) {
48
+ signal.throwIfAborted();
49
+ return domainCall(async () => {
50
+ const session = await this.workbench().sessionFor(typstScope.workspaceRoot);
51
+ signal.throwIfAborted();
52
+ const main = await session.setMain(path);
53
+ return { main };
54
+ });
55
+ }
56
+ /**
57
+ * The live state stream: the current frame first, then one frame per
58
+ * relevant change. Opening the stream counts as a panel subscription, so
59
+ * the setup re-lookup runs while Typst is unusable and stops when the
60
+ * stream closes.
61
+ */
62
+ async *watch(typstScope, signal) {
63
+ signal.throwIfAborted();
64
+ const session = await domainCall(async () => {
65
+ const workbench = this.workbench();
66
+ const workspaceSession = await workbench.sessionFor(typstScope.workspaceRoot);
67
+ await workspaceSession.activate();
68
+ return workspaceSession;
69
+ });
70
+ session.watchSetup(true);
71
+ signal.throwIfAborted();
72
+ // Subscribe before the first snapshot: the generator registers its
73
+ // listener on the first next(), and a change that lands while the first
74
+ // frame is being written must not be lost.
75
+ const changes = session.onChangeWaiter(signal);
76
+ const wake = changes.next();
77
+ try {
78
+ yield session.state();
79
+ let next = await wake;
80
+ while (!next.done) {
81
+ yield session.state();
82
+ next = await changes.next();
83
+ }
84
+ }
85
+ catch (error) {
86
+ // Preserve the stream failure's own `typst/<reason>` code on the wire.
87
+ rethrowRemote(error);
88
+ }
89
+ finally {
90
+ await changes.return(undefined);
91
+ session.watchSetup(false);
92
+ }
93
+ }
94
+ /** The current preview PDF's bytes, or the telling no-preview failure. */
95
+ async readPreview(typstScope, identity, signal) {
96
+ signal.throwIfAborted();
97
+ return domainCall(async () => {
98
+ const session = await this.workbench().sessionFor(typstScope.workspaceRoot);
99
+ const { info, bytes } = session.previewBytes(identity);
100
+ return {
101
+ generation: info.generation,
102
+ seq: info.seq,
103
+ sha256: info.sha256,
104
+ // The gateway's writeBytes records this view for the RPC attachment;
105
+ // it never transfers or detaches it, so the retained snapshot stays
106
+ // readable for later page extraction and highlight relocation.
107
+ data: bytes,
108
+ };
109
+ });
110
+ }
111
+ /** Match rendered text against the workspace's sources (the panel's selection toolbar). */
112
+ async locateSource(typstScope, text, focus, signal) {
113
+ signal.throwIfAborted();
114
+ return domainCall(async () => {
115
+ const session = await this.workbench().sessionFor(typstScope.workspaceRoot);
116
+ const matches = await session.locateSource(text, focus ?? undefined, signal);
117
+ return { matches };
118
+ });
119
+ }
120
+ /** Look Typst up again (the setup page's refresh); answers with the new frame. */
121
+ async recheck(typstScope, signal) {
122
+ signal.throwIfAborted();
123
+ return domainCall(async () => {
124
+ const session = await this.workbench().sessionFor(typstScope.workspaceRoot);
125
+ signal.throwIfAborted();
126
+ await session.recheck(true);
127
+ return session.state();
128
+ });
129
+ }
130
+ /** Stop the watch, relocate typst, rescan, restart; answers with the new frame. */
131
+ async restart(typstScope, signal) {
132
+ signal.throwIfAborted();
133
+ return domainCall(async () => {
134
+ const session = await this.workbench().sessionFor(typstScope.workspaceRoot);
135
+ signal.throwIfAborted();
136
+ await session.restart();
137
+ return session.state();
138
+ });
139
+ }
140
+ /** Refresh the cancellable workspace index, optionally including excluded directories. */
141
+ async discover(typstScope, includeExcluded, signal) {
142
+ signal.throwIfAborted();
143
+ return domainCall(async () => {
144
+ const session = await this.workbench().sessionFor(typstScope.workspaceRoot);
145
+ signal.throwIfAborted();
146
+ await session.discover(includeExcluded, signal);
147
+ const frame = session.state();
148
+ return {
149
+ candidates: frame.candidates.length,
150
+ includeExcluded,
151
+ errors: frame.discovery.errors,
152
+ };
153
+ });
80
154
  }
81
- }
82
- /** The current preview PDF's bytes, or the telling no-preview failure. */
83
- async readPreview(typstScope, identity, signal) {
84
- signal.throwIfAborted();
85
- return domainCall(async () => {
86
- const session = await this.workbench().sessionFor(
87
- typstScope.workspaceRoot
88
- );
89
- const { info, bytes } = session.previewBytes(identity);
90
- return {
91
- generation: info.generation,
92
- seq: info.seq,
93
- sha256: info.sha256,
94
- data: Uint8Array.from(bytes)
95
- };
96
- });
97
- }
98
- /** Match rendered text against the workspace's sources (the panel's selection toolbar). */
99
- async locateSource(typstScope, text, focus, signal) {
100
- signal.throwIfAborted();
101
- return domainCall(async () => {
102
- const session = await this.workbench().sessionFor(
103
- typstScope.workspaceRoot
104
- );
105
- const matches = await session.locateSource(text, focus ?? void 0);
106
- return { matches };
107
- });
108
- }
109
- /** Look Typst up again (the setup page's refresh); answers with the new frame. */
110
- async recheck(typstScope, signal) {
111
- signal.throwIfAborted();
112
- return domainCall(async () => {
113
- const session = await this.workbench().sessionFor(
114
- typstScope.workspaceRoot
115
- );
116
- await session.recheck(true);
117
- return session.state();
118
- });
119
- }
120
- /** Stop the watch, relocate typst, rescan, restart; answers with the new frame. */
121
- async restart(typstScope, signal) {
122
- signal.throwIfAborted();
123
- return domainCall(async () => {
124
- const session = await this.workbench().sessionFor(
125
- typstScope.workspaceRoot
126
- );
127
- await session.restart();
128
- return session.state();
129
- });
130
- }
131
- /** Refresh the cancellable workspace index, optionally including excluded directories. */
132
- async discover(typstScope, includeExcluded, signal) {
133
- signal.throwIfAborted();
134
- return domainCall(async () => {
135
- const session = await this.workbench().sessionFor(
136
- typstScope.workspaceRoot
137
- );
138
- await session.discover(includeExcluded, signal);
139
- return {};
140
- });
141
- }
142
155
  }
143
- export {
144
- TypstRuntime
145
- };
146
- //# sourceMappingURL=remote.js.map
156
+ //# sourceMappingURL=remote.js.map
package/lib/remote.js.map CHANGED
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/remote.ts"],
4
- "sourcesContent": ["/**\n * The host Typert Remote runtime for the `typst` namespace: state frames,\n * the live watch stream, preview bytes, file discovery, and source\n * matching, all scoped to the calling Session's workspace through the\n * `typstScope` lookup (the `workspaceFileScope` pattern from\n * `@deepseek-ai/dsh-api-workspace-files`). Host half only.\n * @module dsh-typst/remote\n */\n\nimport type { Context } from \"@deepseek-ai/cordis\";\nimport type { SessionId } from \"@deepseek-ai/dsh-session/types\";\nimport {\n TypertRemoteService,\n type TypertLookup,\n} from \"@deepseek-ai/dsh-typert-protocol\";\nimport {\n TYPST_STATUS_SERVICE_KEY,\n TYPST_SETTINGS_NAMESPACE,\n} from \"./constants.js\";\nimport type {\n PreviewIdentity,\n PreviewBytes,\n TypstStateFrame,\n} from \"./contract.js\";\nimport {\n domainCall,\n TYPST_NOT_COMPOSED_MESSAGE,\n TypstError,\n TYPST_NOT_COMPOSED,\n} from \"./errors.js\";\nimport type { TypstWorkbenchService } from \"./service.js\";\nimport type { SourceMatch } from \"./typst/match.js\";\n\n/**\n * The session identity every endpoint is scoped by: received on the wire as\n * the calling Session's id, resolved to its workspace root before the method\n * body runs.\n */\nexport interface TypstScope {\n readonly sessionId: SessionId;\n readonly workspaceRoot: string;\n}\n\ndeclare module \"@deepseek-ai/dsh-typert-protocol\" {\n interface TypertLookupMap {\n /** Resolve a Session id to its workspace root without loading its event body or activating an Agent. */\n typstScope: TypertLookup<TypstScope, SessionId>;\n }\n}\n\n/**\n * The `typst` namespace's host service. Every method resolves the calling\n * session's workspace through the service's session registry, so two\n * sessions on two workspaces preview independently.\n */\nexport class TypstRuntime extends TypertRemoteService {\n /**\n * Register the service under the shared cordis key bound to the `typst`\n * wire namespace.\n * @param ctx - owning cordis context.\n */\n constructor(ctx: Context) {\n super(ctx, TYPST_STATUS_SERVICE_KEY, {\n namespace: TYPST_SETTINGS_NAMESPACE,\n });\n }\n\n /** The composed workbench service, or a stable not-composed failure. */\n private workbench(): TypstWorkbenchService {\n const service = this.ctx.get(\"typstWorkbench\");\n if (service === undefined) {\n throw new TypstError(TYPST_NOT_COMPOSED_MESSAGE, TYPST_NOT_COMPOSED);\n }\n return service;\n }\n\n /** Live state frame for the calling session's workspace; activates the session. */\n async status(\n typstScope: TypstScope,\n signal: AbortSignal,\n ): Promise<TypstStateFrame> {\n signal.throwIfAborted();\n return domainCall(async () => {\n const session = await this.workbench().sessionFor(\n typstScope.workspaceRoot,\n );\n await session.activate();\n return session.state();\n });\n }\n\n /** Choose the main `.typ` file; state updates follow on the watch stream. */\n async setMain(\n typstScope: TypstScope,\n path: string,\n signal: AbortSignal,\n ): Promise<{ main: string }> {\n signal.throwIfAborted();\n return domainCall(async () => {\n const session = await this.workbench().sessionFor(\n typstScope.workspaceRoot,\n );\n const main = await session.setMain(path);\n return { main };\n });\n }\n\n /**\n * The live state stream: the current frame first, then one frame per\n * relevant change. Opening the stream counts as a panel subscription, so\n * the setup re-lookup runs while Typst is unusable and stops when the\n * stream closes.\n */\n async *watch(\n typstScope: TypstScope,\n signal: AbortSignal,\n ): AsyncIterable<TypstStateFrame> {\n signal.throwIfAborted();\n const session = await domainCall(async () => {\n const workbench = this.workbench();\n const workspaceSession = await workbench.sessionFor(\n typstScope.workspaceRoot,\n );\n await workspaceSession.activate();\n return workspaceSession;\n });\n session.watchSetup(true);\n try {\n const queue = session.state();\n yield queue;\n for await (const _ of session.onChangeWaiter(signal)) {\n yield session.state();\n }\n } finally {\n session.watchSetup(false);\n }\n }\n\n /** The current preview PDF's bytes, or the telling no-preview failure. */\n async readPreview(\n typstScope: TypstScope,\n identity: PreviewIdentity,\n signal: AbortSignal,\n ): Promise<PreviewBytes> {\n signal.throwIfAborted();\n return domainCall(async () => {\n const session = await this.workbench().sessionFor(\n typstScope.workspaceRoot,\n );\n const { info, bytes } = session.previewBytes(identity);\n return {\n generation: info.generation,\n seq: info.seq,\n sha256: info.sha256,\n data: Uint8Array.from(bytes),\n };\n });\n }\n\n /** Match rendered text against the workspace's sources (the panel's selection toolbar). */\n async locateSource(\n typstScope: TypstScope,\n text: string,\n focus: string | null,\n signal: AbortSignal,\n ): Promise<{ matches: SourceMatch[] }> {\n signal.throwIfAborted();\n return domainCall(async () => {\n const session = await this.workbench().sessionFor(\n typstScope.workspaceRoot,\n );\n const matches = await session.locateSource(text, focus ?? undefined);\n return { matches };\n });\n }\n\n /** Look Typst up again (the setup page's refresh); answers with the new frame. */\n async recheck(\n typstScope: TypstScope,\n signal: AbortSignal,\n ): Promise<TypstStateFrame> {\n signal.throwIfAborted();\n return domainCall(async () => {\n const session = await this.workbench().sessionFor(\n typstScope.workspaceRoot,\n );\n await session.recheck(true);\n return session.state();\n });\n }\n\n /** Stop the watch, relocate typst, rescan, restart; answers with the new frame. */\n async restart(\n typstScope: TypstScope,\n signal: AbortSignal,\n ): Promise<TypstStateFrame> {\n signal.throwIfAborted();\n return domainCall(async () => {\n const session = await this.workbench().sessionFor(\n typstScope.workspaceRoot,\n );\n await session.restart();\n return session.state();\n });\n }\n\n /** Refresh the cancellable workspace index, optionally including excluded directories. */\n async discover(\n typstScope: TypstScope,\n includeExcluded: boolean,\n signal: AbortSignal,\n ): Promise<object> {\n signal.throwIfAborted();\n return domainCall(async () => {\n const session = await this.workbench().sessionFor(\n typstScope.workspaceRoot,\n );\n await session.discover(includeExcluded, signal);\n return {};\n });\n }\n}\n"],
5
- "mappings": "AAWA;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0BA,MAAM,qBAAqB,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpD,YAAY,KAAc;AACxB,UAAM,KAAK,0BAA0B;AAAA,MACnC,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AAAA;AAAA,EAGQ,YAAmC;AACzC,UAAM,UAAU,KAAK,IAAI,IAAI,gBAAgB;AAC7C,QAAI,YAAY,QAAW;AACzB,YAAM,IAAI,WAAW,4BAA4B,kBAAkB;AAAA,IACrE;AACA,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,MAAM,OACJ,YACA,QAC0B;AAC1B,WAAO,eAAe;AACtB,WAAO,WAAW,YAAY;AAC5B,YAAM,UAAU,MAAM,KAAK,UAAU,EAAE;AAAA,QACrC,WAAW;AAAA,MACb;AACA,YAAM,QAAQ,SAAS;AACvB,aAAO,QAAQ,MAAM;AAAA,IACvB,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,QACJ,YACA,MACA,QAC2B;AAC3B,WAAO,eAAe;AACtB,WAAO,WAAW,YAAY;AAC5B,YAAM,UAAU,MAAM,KAAK,UAAU,EAAE;AAAA,QACrC,WAAW;AAAA,MACb;AACA,YAAM,OAAO,MAAM,QAAQ,QAAQ,IAAI;AACvC,aAAO,EAAE,KAAK;AAAA,IAChB,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA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AC,KAAK,IAAI,EAAE;YAC3B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAC/C,UAAU,CAAC,aAAa,CACzB,CAAC;YACF,MAAM,CAAC,cAAc,EAAE,CAAC;YACxB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YACxB,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,0FAA0F;IAC1F,KAAK,CAAC,QAAQ,CACZ,UAAsB,EACtB,eAAwB,EACxB,MAAmB;QAEnB,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,OAAO,UAAU,CAAC,KAAK,IAAI,EAAE;YAC3B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAC/C,UAAU,CAAC,aAAa,CACzB,CAAC;YACF,MAAM,CAAC,cAAc,EAAE,CAAC;YACxB,MAAM,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;YAC9B,OAAO;gBACL,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM;gBACnC,eAAe;gBACf,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM;aAC/B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
package/lib/service.d.ts CHANGED
@@ -21,19 +21,29 @@ export declare class TypstWorkbenchService extends Service {
21
21
  static inject: string[];
22
22
  static Config: import("@deepseek-ai/schemastery").default<Schemastery.ObjectS<NoInfer<{
23
23
  typstPath: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
24
+ fontPaths: import("@deepseek-ai/schemastery").default<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
25
+ packagePath: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
26
+ excludeDirs: import("@deepseek-ai/schemastery").default<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
24
27
  }>>, Schemastery.ObjectT<NoInfer<{
25
28
  typstPath: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
29
+ fontPaths: import("@deepseek-ai/schemastery").default<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
30
+ packagePath: import("@deepseek-ai/schemastery").default<string, string, "volatile-defined">;
31
+ excludeDirs: import("@deepseek-ai/schemastery").default<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
26
32
  }>>, "plain">;
27
33
  /** Live entry config: volatile references re-read per request. */
28
34
  private readonly entry;
35
+ /** The last settings snapshot applied to live sessions, for change detection. */
36
+ private appliedSettings;
37
+ /** Settings commits are serialized: two overlapping commits never race a watch. */
38
+ private settingsQueue;
29
39
  /** Workspace sessions keyed by resolved workspace root. */
30
40
  private readonly sessions;
41
+ /** Workspace roots whose lazy session is being closed; new callers wait. */
42
+ private readonly closing;
31
43
  constructor(ctx: Context, config: Config);
32
44
  /** The live entry's current values, read per request. */
33
45
  private get resolved();
34
46
  protected [Service.init](): Promise<void>;
35
- /** The configured Typst path setting ('' = look it up). */
36
- get typstPath(): string;
37
47
  /**
38
48
  * The workspace's session, creating it on first use. Keyed by the
39
49
  * realpath of the workspace root so symlinked paths of the same workspace
@@ -41,7 +51,21 @@ export declare class TypstWorkbenchService extends Service {
41
51
  * @param workspaceRoot - the session workspace's absolute root.
42
52
  */
43
53
  sessionFor(workspaceRoot: string): Promise<WorkspaceSession>;
44
- /** A changed Typst path makes every live session look the binary up again. */
45
- private recheckAll;
54
+ /** Realpath when it exists; the original spelling otherwise. */
55
+ private canonical;
56
+ /**
57
+ * Close a workspace's session once its last live session is gone. The
58
+ * disposed session is excluded from the live set because the store removes
59
+ * it before announcing disposal.
60
+ */
61
+ private releaseIfUnused;
62
+ /**
63
+ * Diff the committed settings against the ones already applied. A toolchain
64
+ * change (binary, fonts, packages) restarts the watch; an exclusion change
65
+ * only re-runs discovery, because discovery is exactly what it feeds.
66
+ */
67
+ private scheduleSettingsApply;
68
+ /** Apply one settings change to every active session, in order; inactive ones read it when they start. */
69
+ private applySettings;
46
70
  }
47
71
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAK5D,OAAO,EACL,MAAM,EAIP,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,cAAc,EAAE,qBAAqB,CAAC;KACvC;CACF;AAED,qBAAa,qBAAsB,SAAQ,OAAO;IAChD,MAAM,CAAC,MAAM,WAAa;IAE1B,MAAM,CAAC,MAAM;;;;kBAAU;IAEvB,kEAAkE;IAClE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAElC,2DAA2D;IAC3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuC;gBAEpD,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;IAKxC,yDAAyD;IACzD,OAAO,KAAK,QAAQ,GAEnB;cAEe,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IA8D/C,2DAA2D;IAC3D,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;;;OAKG;IACG,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAclE,8EAA8E;YAChE,UAAU;CAKzB"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAO5D,OAAO,EACL,MAAM,EAMP,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