@justscale/typescript 0.1.1

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 (245) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -0
  3. package/dist/api.d.ts +144 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +380 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/compiler/analyzer.d.ts +247 -0
  8. package/dist/compiler/analyzer.d.ts.map +1 -0
  9. package/dist/compiler/analyzer.js +3201 -0
  10. package/dist/compiler/analyzer.js.map +1 -0
  11. package/dist/compiler/cli.d.ts +12 -0
  12. package/dist/compiler/cli.d.ts.map +1 -0
  13. package/dist/compiler/cli.js +209 -0
  14. package/dist/compiler/cli.js.map +1 -0
  15. package/dist/compiler/compile.d.ts +26 -0
  16. package/dist/compiler/compile.d.ts.map +1 -0
  17. package/dist/compiler/compile.js +121 -0
  18. package/dist/compiler/compile.js.map +1 -0
  19. package/dist/compiler/errors.d.ts +336 -0
  20. package/dist/compiler/errors.d.ts.map +1 -0
  21. package/dist/compiler/errors.js +466 -0
  22. package/dist/compiler/errors.js.map +1 -0
  23. package/dist/compiler/exports-prepass.d.ts +31 -0
  24. package/dist/compiler/exports-prepass.d.ts.map +1 -0
  25. package/dist/compiler/exports-prepass.js +249 -0
  26. package/dist/compiler/exports-prepass.js.map +1 -0
  27. package/dist/compiler/hmr-change-detector.d.ts +47 -0
  28. package/dist/compiler/hmr-change-detector.d.ts.map +1 -0
  29. package/dist/compiler/hmr-change-detector.js +395 -0
  30. package/dist/compiler/hmr-change-detector.js.map +1 -0
  31. package/dist/compiler/hmr-transformer.d.ts +54 -0
  32. package/dist/compiler/hmr-transformer.d.ts.map +1 -0
  33. package/dist/compiler/hmr-transformer.js +535 -0
  34. package/dist/compiler/hmr-transformer.js.map +1 -0
  35. package/dist/compiler/index.d.ts +19 -0
  36. package/dist/compiler/index.d.ts.map +1 -0
  37. package/dist/compiler/index.js +16 -0
  38. package/dist/compiler/index.js.map +1 -0
  39. package/dist/compiler/primitive-detector.d.ts +70 -0
  40. package/dist/compiler/primitive-detector.d.ts.map +1 -0
  41. package/dist/compiler/primitive-detector.js +338 -0
  42. package/dist/compiler/primitive-detector.js.map +1 -0
  43. package/dist/compiler/ptsc.d.ts +40 -0
  44. package/dist/compiler/ptsc.d.ts.map +1 -0
  45. package/dist/compiler/ptsc.js +462 -0
  46. package/dist/compiler/ptsc.js.map +1 -0
  47. package/dist/compiler/rewriter.d.ts +96 -0
  48. package/dist/compiler/rewriter.d.ts.map +1 -0
  49. package/dist/compiler/rewriter.js +418 -0
  50. package/dist/compiler/rewriter.js.map +1 -0
  51. package/dist/compiler/step-hash.d.ts +43 -0
  52. package/dist/compiler/step-hash.d.ts.map +1 -0
  53. package/dist/compiler/step-hash.js +83 -0
  54. package/dist/compiler/step-hash.js.map +1 -0
  55. package/dist/compiler/switch-codegen.d.ts +84 -0
  56. package/dist/compiler/switch-codegen.d.ts.map +1 -0
  57. package/dist/compiler/switch-codegen.js +1540 -0
  58. package/dist/compiler/switch-codegen.js.map +1 -0
  59. package/dist/compiler/transformer.d.ts +29 -0
  60. package/dist/compiler/transformer.d.ts.map +1 -0
  61. package/dist/compiler/transformer.js +216 -0
  62. package/dist/compiler/transformer.js.map +1 -0
  63. package/dist/config/index.d.ts +122 -0
  64. package/dist/config/index.d.ts.map +1 -0
  65. package/dist/config/index.js +215 -0
  66. package/dist/config/index.js.map +1 -0
  67. package/dist/di-errors/formatter.d.ts +126 -0
  68. package/dist/di-errors/formatter.d.ts.map +1 -0
  69. package/dist/di-errors/formatter.js +384 -0
  70. package/dist/di-errors/formatter.js.map +1 -0
  71. package/dist/di-errors/index.d.ts +5 -0
  72. package/dist/di-errors/index.d.ts.map +1 -0
  73. package/dist/di-errors/index.js +13 -0
  74. package/dist/di-errors/index.js.map +1 -0
  75. package/dist/editor.d.ts +11 -0
  76. package/dist/editor.d.ts.map +1 -0
  77. package/dist/editor.js +2 -0
  78. package/dist/editor.js.map +1 -0
  79. package/dist/index.d.ts +35 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +40 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/language-service/index.d.ts +52 -0
  84. package/dist/language-service/index.d.ts.map +1 -0
  85. package/dist/language-service/index.js +366 -0
  86. package/dist/language-service/index.js.map +1 -0
  87. package/dist/language-service/process-quick-fixes.d.ts +20 -0
  88. package/dist/language-service/process-quick-fixes.d.ts.map +1 -0
  89. package/dist/language-service/process-quick-fixes.js +114 -0
  90. package/dist/language-service/process-quick-fixes.js.map +1 -0
  91. package/dist/language-service/quick-fix-discovery.d.ts +39 -0
  92. package/dist/language-service/quick-fix-discovery.d.ts.map +1 -0
  93. package/dist/language-service/quick-fix-discovery.js +124 -0
  94. package/dist/language-service/quick-fix-discovery.js.map +1 -0
  95. package/dist/loader/incremental.d.ts +50 -0
  96. package/dist/loader/incremental.d.ts.map +1 -0
  97. package/dist/loader/incremental.js +151 -0
  98. package/dist/loader/incremental.js.map +1 -0
  99. package/dist/loader/index.d.ts +25 -0
  100. package/dist/loader/index.d.ts.map +1 -0
  101. package/dist/loader/index.js +24 -0
  102. package/dist/loader/index.js.map +1 -0
  103. package/dist/loader/loader.d.ts +52 -0
  104. package/dist/loader/loader.d.ts.map +1 -0
  105. package/dist/loader/loader.js +248 -0
  106. package/dist/loader/loader.js.map +1 -0
  107. package/dist/loader/register.d.ts +14 -0
  108. package/dist/loader/register.d.ts.map +1 -0
  109. package/dist/loader/register.js +20 -0
  110. package/dist/loader/register.js.map +1 -0
  111. package/dist/plugins/index.d.ts +13 -0
  112. package/dist/plugins/index.d.ts.map +1 -0
  113. package/dist/plugins/index.js +13 -0
  114. package/dist/plugins/index.js.map +1 -0
  115. package/dist/plugins/index.public.d.ts +13 -0
  116. package/dist/plugins/index.public.d.ts.map +1 -0
  117. package/dist/plugins/index.public.js +13 -0
  118. package/dist/plugins/index.public.js.map +1 -0
  119. package/dist/plugins/types.d.ts +83 -0
  120. package/dist/plugins/types.d.ts.map +1 -0
  121. package/dist/plugins/types.js +24 -0
  122. package/dist/plugins/types.js.map +1 -0
  123. package/dist/server/index.d.ts +33 -0
  124. package/dist/server/index.d.ts.map +1 -0
  125. package/dist/server/index.js +42 -0
  126. package/dist/server/index.js.map +1 -0
  127. package/dist/server/tsserver.d.ts +28 -0
  128. package/dist/server/tsserver.d.ts.map +1 -0
  129. package/dist/server/tsserver.js +126 -0
  130. package/dist/server/tsserver.js.map +1 -0
  131. package/lib/lib.d.ts +20 -0
  132. package/lib/lib.decorators.d.ts +382 -0
  133. package/lib/lib.decorators.legacy.d.ts +20 -0
  134. package/lib/lib.dom.asynciterable.d.ts +18 -0
  135. package/lib/lib.dom.d.ts +45125 -0
  136. package/lib/lib.dom.iterable.d.ts +18 -0
  137. package/lib/lib.es2015.collection.d.ts +150 -0
  138. package/lib/lib.es2015.core.d.ts +595 -0
  139. package/lib/lib.es2015.d.ts +26 -0
  140. package/lib/lib.es2015.generator.d.ts +75 -0
  141. package/lib/lib.es2015.iterable.d.ts +603 -0
  142. package/lib/lib.es2015.promise.d.ts +79 -0
  143. package/lib/lib.es2015.proxy.d.ts +126 -0
  144. package/lib/lib.es2015.reflect.d.ts +142 -0
  145. package/lib/lib.es2015.symbol.d.ts +44 -0
  146. package/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
  147. package/lib/lib.es2016.array.include.d.ts +114 -0
  148. package/lib/lib.es2016.d.ts +19 -0
  149. package/lib/lib.es2016.full.d.ts +21 -0
  150. package/lib/lib.es2016.intl.d.ts +29 -0
  151. package/lib/lib.es2017.arraybuffer.d.ts +19 -0
  152. package/lib/lib.es2017.d.ts +24 -0
  153. package/lib/lib.es2017.date.d.ts +29 -0
  154. package/lib/lib.es2017.full.d.ts +21 -0
  155. package/lib/lib.es2017.intl.d.ts +42 -0
  156. package/lib/lib.es2017.object.d.ts +47 -0
  157. package/lib/lib.es2017.sharedmemory.d.ts +133 -0
  158. package/lib/lib.es2017.string.d.ts +43 -0
  159. package/lib/lib.es2017.typedarrays.d.ts +51 -0
  160. package/lib/lib.es2018.asyncgenerator.d.ts +75 -0
  161. package/lib/lib.es2018.asynciterable.d.ts +51 -0
  162. package/lib/lib.es2018.d.ts +22 -0
  163. package/lib/lib.es2018.full.d.ts +22 -0
  164. package/lib/lib.es2018.intl.d.ts +81 -0
  165. package/lib/lib.es2018.promise.d.ts +28 -0
  166. package/lib/lib.es2018.regexp.d.ts +35 -0
  167. package/lib/lib.es2019.array.d.ts +77 -0
  168. package/lib/lib.es2019.d.ts +22 -0
  169. package/lib/lib.es2019.full.d.ts +22 -0
  170. package/lib/lib.es2019.intl.d.ts +21 -0
  171. package/lib/lib.es2019.object.d.ts +31 -0
  172. package/lib/lib.es2019.string.d.ts +35 -0
  173. package/lib/lib.es2019.symbol.d.ts +22 -0
  174. package/lib/lib.es2020.bigint.d.ts +763 -0
  175. package/lib/lib.es2020.d.ts +25 -0
  176. package/lib/lib.es2020.date.d.ts +40 -0
  177. package/lib/lib.es2020.full.d.ts +22 -0
  178. package/lib/lib.es2020.intl.d.ts +472 -0
  179. package/lib/lib.es2020.number.d.ts +26 -0
  180. package/lib/lib.es2020.promise.d.ts +45 -0
  181. package/lib/lib.es2020.sharedmemory.d.ts +97 -0
  182. package/lib/lib.es2020.string.d.ts +42 -0
  183. package/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
  184. package/lib/lib.es2021.d.ts +21 -0
  185. package/lib/lib.es2021.full.d.ts +22 -0
  186. package/lib/lib.es2021.intl.d.ts +164 -0
  187. package/lib/lib.es2021.promise.d.ts +46 -0
  188. package/lib/lib.es2021.string.d.ts +31 -0
  189. package/lib/lib.es2021.weakref.d.ts +76 -0
  190. package/lib/lib.es2022.array.d.ts +119 -0
  191. package/lib/lib.es2022.d.ts +23 -0
  192. package/lib/lib.es2022.error.d.ts +73 -0
  193. package/lib/lib.es2022.full.d.ts +22 -0
  194. package/lib/lib.es2022.intl.d.ts +143 -0
  195. package/lib/lib.es2022.object.d.ts +24 -0
  196. package/lib/lib.es2022.regexp.d.ts +37 -0
  197. package/lib/lib.es2022.string.d.ts +23 -0
  198. package/lib/lib.es2023.array.d.ts +922 -0
  199. package/lib/lib.es2023.collection.d.ts +19 -0
  200. package/lib/lib.es2023.d.ts +20 -0
  201. package/lib/lib.es2023.full.d.ts +22 -0
  202. package/lib/lib.es2023.intl.d.ts +62 -0
  203. package/lib/lib.es2024.arraybuffer.d.ts +63 -0
  204. package/lib/lib.es2024.collection.d.ts +27 -0
  205. package/lib/lib.es2024.d.ts +24 -0
  206. package/lib/lib.es2024.full.d.ts +22 -0
  207. package/lib/lib.es2024.object.d.ts +27 -0
  208. package/lib/lib.es2024.promise.d.ts +33 -0
  209. package/lib/lib.es2024.regexp.d.ts +23 -0
  210. package/lib/lib.es2024.sharedmemory.d.ts +66 -0
  211. package/lib/lib.es2024.string.d.ts +27 -0
  212. package/lib/lib.es2025.collection.d.ts +94 -0
  213. package/lib/lib.es2025.d.ts +23 -0
  214. package/lib/lib.es2025.float16.d.ts +443 -0
  215. package/lib/lib.es2025.full.d.ts +22 -0
  216. package/lib/lib.es2025.intl.d.ts +200 -0
  217. package/lib/lib.es2025.iterator.d.ts +146 -0
  218. package/lib/lib.es2025.promise.d.ts +32 -0
  219. package/lib/lib.es2025.regexp.d.ts +30 -0
  220. package/lib/lib.es5.d.ts +4599 -0
  221. package/lib/lib.es6.d.ts +21 -0
  222. package/lib/lib.esnext.array.d.ts +33 -0
  223. package/lib/lib.esnext.collection.d.ts +47 -0
  224. package/lib/lib.esnext.d.ts +27 -0
  225. package/lib/lib.esnext.date.d.ts +21 -0
  226. package/lib/lib.esnext.decorators.d.ts +26 -0
  227. package/lib/lib.esnext.disposable.d.ts +191 -0
  228. package/lib/lib.esnext.error.d.ts +22 -0
  229. package/lib/lib.esnext.full.d.ts +22 -0
  230. package/lib/lib.esnext.intl.d.ts +107 -0
  231. package/lib/lib.esnext.sharedmemory.d.ts +23 -0
  232. package/lib/lib.esnext.temporal.d.ts +485 -0
  233. package/lib/lib.esnext.typedarrays.d.ts +90 -0
  234. package/lib/lib.scripthost.d.ts +320 -0
  235. package/lib/lib.webworker.asynciterable.d.ts +18 -0
  236. package/lib/lib.webworker.d.ts +15606 -0
  237. package/lib/lib.webworker.importscripts.d.ts +21 -0
  238. package/lib/lib.webworker.iterable.d.ts +18 -0
  239. package/lib/logger.js +144 -0
  240. package/lib/package.json +7 -0
  241. package/lib/tsserver.js +57 -0
  242. package/lib/tsserverlibrary.js +171 -0
  243. package/lib/typesMap.json +497 -0
  244. package/lib/typescript.js +373 -0
  245. package/package.json +115 -0
@@ -0,0 +1,466 @@
1
+ /**
2
+ * Custom error codes for the process compiler (TSPxxxx range).
3
+ */
4
+ import ts from 'typescript';
5
+ /**
6
+ * Custom error codes for process compilation.
7
+ * Range: TSP1000-TSP9999
8
+ */
9
+ export const ProcessErrorCode = {
10
+ /**
11
+ * TSP1001: Non-serializable await result must use `using` declaration.
12
+ *
13
+ * Process state is serialized to storage when suspended. Awaited values
14
+ * from service calls (like `orders.get(Order.ref(id))`) return non-serializable
15
+ * objects that must be rehydrated on resume.
16
+ *
17
+ * Wrong: `const order = await orders.get(Order.ref(id))`
18
+ * Right: `using order = await orders.get(Order.ref(id))`
19
+ */
20
+ NonSerializableConst: 1001,
21
+ /**
22
+ * TSP1002: Signal must be awaited inside process handler.
23
+ *
24
+ * The `signal()` primitive creates a suspension point and must be awaited.
25
+ *
26
+ * Wrong: `signal(orders.complete)`
27
+ * Right: `await signal(orders.complete)`
28
+ */
29
+ SignalNotAwaited: 1002,
30
+ /**
31
+ * TSP1003: Invalid race pattern - switch must use `await race()`.
32
+ *
33
+ * The race pattern requires a specific structure with switch/case.
34
+ */
35
+ InvalidRacePattern: 1003,
36
+ /**
37
+ * TSP1004: Process handler must be an async function.
38
+ */
39
+ HandlerNotAsync: 1004,
40
+ /**
41
+ * TSP1005: Cannot use non-deterministic operations in process handler.
42
+ *
43
+ * Operations like `Date.now()`, `Math.random()`, or `crypto.randomUUID()`
44
+ * produce different results on replay and break determinism.
45
+ */
46
+ NonDeterministicOperation: 1005,
47
+ /**
48
+ * TSP1006: Signal/delay must be used directly, not stored in a variable.
49
+ *
50
+ * The compiler transforms signal() and delay() calls at compile time.
51
+ * Storing them in variables breaks this transformation.
52
+ *
53
+ * Wrong: `const s = signal(orders.paid); await s;`
54
+ * Right: `await signal(orders.paid)`
55
+ *
56
+ * Wrong: `const d = delay.minutes(5); await d;`
57
+ * Right: `await delay.minutes(5)`
58
+ */
59
+ SignalStoredInVariable: 1006,
60
+ /**
61
+ * TSP1007: Cannot use try-catch around suspension points.
62
+ *
63
+ * Process suspensions serialize state to storage. Exceptions cannot be
64
+ * caught across suspension boundaries because the try-catch context is
65
+ * lost when the process resumes from storage.
66
+ *
67
+ * Wrong: `try { await signal(orders.paid) } catch (e) { ... }`
68
+ * Right: Use race() with a timeout or handle errors in the signaling service.
69
+ */
70
+ TryCatchWithSuspension: 1007,
71
+ /**
72
+ * TSP1008: Cannot use nested async functions with suspension points.
73
+ *
74
+ * Suspension points must be directly in the process handler, not in
75
+ * nested async functions or callbacks. The compiler cannot track
76
+ * suspensions through nested function boundaries.
77
+ *
78
+ * Wrong: `const fn = async () => { await signal(...) }; await fn()`
79
+ * Right: Use await signal() directly in the handler.
80
+ */
81
+ NestedAsyncWithSuspension: 1008,
82
+ /**
83
+ * TSP1009: Cannot use Promise.all/Promise.race with signals.
84
+ *
85
+ * Process primitives like signal() and delay() must be awaited directly
86
+ * or used in a race() switch pattern. Promise combinators bypass the
87
+ * compiler's suspension tracking.
88
+ *
89
+ * Wrong: `await Promise.all([signal(a), signal(b)])`
90
+ * Right: Use sequential awaits or the race() switch pattern.
91
+ */
92
+ PromiseCombinatorWithSignal: 1009,
93
+ /**
94
+ * TSP1010: For-in loops with suspension points are not supported.
95
+ *
96
+ * For-in iteration over object keys cannot be made durable because
97
+ * property enumeration order is not guaranteed to be stable.
98
+ * Convert to Object.keys() with a for-of loop or while loop.
99
+ *
100
+ * Wrong: `for (const key in obj) { await signal(...) }`
101
+ * Right: `for (const key of Object.keys(obj)) { await signal(...) }`
102
+ */
103
+ ForInWithSuspension: 1010,
104
+ /**
105
+ * TSP1011: Inner function escapes handler scope.
106
+ *
107
+ * Inner functions with suspension points must be called directly within
108
+ * the handler. Returning them, storing them in arrays, or passing them
109
+ * to other functions prevents the compiler from inlining.
110
+ *
111
+ * Wrong: `const fn = async () => { await signal(...) }; return fn`
112
+ * Right: `const fn = async () => { await signal(...) }; await fn()`
113
+ */
114
+ FunctionEscapesScope: 1011,
115
+ /**
116
+ * TSP1012: Parallel functions cannot have parameters.
117
+ *
118
+ * Functions used in signal.all() cannot have parameters because they
119
+ * are executed in parallel without specific arguments.
120
+ *
121
+ * Wrong: `signal.all([async (x) => { await signal(...) }])`
122
+ * Right: `signal.all([async () => { await signal(...) }])`
123
+ */
124
+ ParallelFunctionWithParams: 1012,
125
+ /**
126
+ * TSP1013: While-loop condition contains a suspension point.
127
+ *
128
+ * The compiler cannot suspend inside a while-loop condition because
129
+ * the condition is re-evaluated on each iteration before the loop body.
130
+ * Move the suspension into the loop body with an explicit break.
131
+ *
132
+ * Wrong: `while (await signal(svc.hasMore)) { ... }`
133
+ * Right: `while (true) { if (!await signal(svc.hasMore)) break; ... }`
134
+ */
135
+ WhileConditionSuspension: 1013,
136
+ /**
137
+ * TSP1014: Do-while loops with suspension points are not supported.
138
+ *
139
+ * The compiler does not yet support do-while loops containing
140
+ * suspension points. Convert to a while(true) loop with a break.
141
+ *
142
+ * Wrong: `do { await signal(svc.event) } while (condition)`
143
+ * Right: `while (true) { await signal(svc.event); if (!condition) break }`
144
+ */
145
+ DoWhileWithSuspension: 1014,
146
+ /**
147
+ * TSP1015: Classic for loops with suspension points are not supported.
148
+ *
149
+ * The compiler cannot make classic for(;;) loops durable because the
150
+ * incrementor and condition expressions would need to be re-evaluated
151
+ * on resume. Convert to a while loop with explicit counter management.
152
+ *
153
+ * Wrong: `for (let i = 0; i < n; i++) { await signal(...) }`
154
+ * Right: `let i = 0; while (i < n) { await signal(...); i++ }`
155
+ */
156
+ ForWithSuspension: 1015,
157
+ /**
158
+ * TSP2001: Recursion depth cannot be determined statically.
159
+ *
160
+ * The compiler must inline inner functions into the parent state machine.
161
+ * Recursive calls require static bounds to prevent infinite expansion.
162
+ *
163
+ * Wrong: `function recurse(n) { if (n > 0) await recurse(n - 1) }`
164
+ * Right: Use a while loop or bounded recursion with a constant limit.
165
+ */
166
+ RecursionDepthUnknown: 2001,
167
+ /**
168
+ * TSP2002: Mutual recursion detected.
169
+ *
170
+ * Two or more functions that call each other cannot be inlined into
171
+ * a state machine. The compiler cannot determine the call order.
172
+ *
173
+ * Wrong: `function a() { b() } function b() { a() }`
174
+ * Right: Restructure to use a single function or loop.
175
+ */
176
+ MutualRecursion: 2002,
177
+ /**
178
+ * TSP2003: Maximum inlining depth exceeded.
179
+ *
180
+ * The nested function call depth exceeds the maximum allowed for
181
+ * inlining (default: 10 levels). This prevents state machine explosion.
182
+ */
183
+ MaxInliningDepthExceeded: 2003,
184
+ /**
185
+ * TSP3001: Invalid durable iterator (missing ORDER BY).
186
+ *
187
+ * Repository queries used in for-of loops must have an ORDER BY clause
188
+ * with at least one unique column for keyset pagination to work.
189
+ */
190
+ InvalidDurableIterator: 3001,
191
+ /**
192
+ * TSP3002: Non-serializable cursor type.
193
+ *
194
+ * Durable iterators must produce serializable cursors (strings, numbers,
195
+ * or objects of primitives). Complex objects cannot be persisted.
196
+ */
197
+ NonSerializableCursor: 3002,
198
+ /**
199
+ * TSP3003: Yield in non-generator handler.
200
+ *
201
+ * The `yield` expression can only be used in async generator handlers
202
+ * declared with `async *handler()`. Regular async handlers cannot yield.
203
+ *
204
+ * Wrong: `async handler() { yield event }`
205
+ * Right: `async *handler() { yield event }`
206
+ */
207
+ YieldInNonGenerator: 3003,
208
+ /**
209
+ * TSP3004: Throw statement not allowed in process handler.
210
+ *
211
+ * Process handlers should return error results instead of throwing.
212
+ * Thrown exceptions break the durable execution model.
213
+ *
214
+ * Wrong: `throw new Error('failed')`
215
+ * Right: `return { status: 'error', message: 'failed' }`
216
+ */
217
+ ThrowNotAllowed: 3004,
218
+ /**
219
+ * TSP3005: signal.all() with empty array literal.
220
+ *
221
+ * Parallel blocks must have at least one branch.
222
+ *
223
+ * Wrong: `await signal.all([])`
224
+ * Right: `await signal.all([svc.a, svc.b])`
225
+ */
226
+ EmptyParallelBlock: 3005,
227
+ /**
228
+ * TSP3006: scope() exceeded item limit.
229
+ *
230
+ * The scope() function limits the number of entities to prevent
231
+ * state explosion. Default limit is 1000 items.
232
+ */
233
+ ScopeItemLimitExceeded: 3006,
234
+ /**
235
+ * TSP3007: Scope handler cannot yield.
236
+ *
237
+ * Handlers inside scope() cannot use yield. To emit events from
238
+ * scoped processing, use a process reference with subprocess.
239
+ *
240
+ * Wrong: `scope(items, async (item) => { yield item })`
241
+ * Right: `scope(processRef, items)`
242
+ */
243
+ ScopeHandlerCannotYield: 3007,
244
+ /**
245
+ * TSP3008: Duplicate entity in scope.
246
+ *
247
+ * Each entity in a scope() call must have a unique identity.
248
+ * Duplicate IDs would create conflicting execution paths.
249
+ */
250
+ DuplicateEntityInScope: 3008,
251
+ /**
252
+ * TSP3009: Nested scope collision.
253
+ *
254
+ * Cannot nest scope() calls with the same model type. This would
255
+ * create ambiguous identity paths.
256
+ */
257
+ NestedScopeCollision: 3009,
258
+ /**
259
+ * TSP3010: Race switch has no valid branches.
260
+ *
261
+ * A race switch must have at least one signal or delay branch.
262
+ * An empty switch would suspend indefinitely.
263
+ *
264
+ * Wrong: `const r = race(); switch (true) { default: break }`
265
+ * Right: `const r = race(); switch (true) { case signal(r, svc.a): ... }`
266
+ */
267
+ EmptyRace: 3010,
268
+ /**
269
+ * TSP3011: Invalid scope() arguments.
270
+ *
271
+ * scope() requires at least 2 arguments in one of these forms:
272
+ * - scope(signal, entities)
273
+ * - scope(entities, handler)
274
+ * - scope(entities, idFn, handler)
275
+ */
276
+ InvalidScopeArguments: 3011,
277
+ /**
278
+ * TSP3012: signal.all / signal.settled / stream inside race switch.
279
+ *
280
+ * These combinators are not yet supported as case expressions in a race
281
+ * switch. Use them as standalone awaits outside of a race, or use plain
282
+ * signal(r, ...) / delay(r, ...) branches.
283
+ *
284
+ * Wrong: `case signal.all(r, [svc.a, svc.b]):`
285
+ * Right: `case signal(r, svc.a):` or `const result = await signal.all([svc.a, svc.b])`
286
+ */
287
+ RaceCombinatorNotSupported: 3012,
288
+ /**
289
+ * TSP3013: Variable shadowing in process handler.
290
+ *
291
+ * Process state is serialized to a flat `state.vars.{name}` namespace.
292
+ * Block-scoped redeclarations (`const x = 1; { const x = 99 }`) collapse
293
+ * onto the same storage slot — the inner binding silently overwrites the
294
+ * outer, breaking lexical scope semantics. Function-parameter shadowing
295
+ * is fine (parameters live in their own activation record); this error
296
+ * is only for declarations that share a flat scope with the outer binding.
297
+ *
298
+ * Wrong: `const x = 1; { const x = 99; ... }`
299
+ * Right: `const x = 1; { const innerX = 99; ... }`
300
+ */
301
+ ShadowedHandlerLocal: 3013,
302
+ };
303
+ const errorMessages = {
304
+ [ProcessErrorCode.NonSerializableConst]: "Process state is serialized to storage on suspension - 'const {0}' cannot be restored on resume. " +
305
+ "Declare it as 'using {0}' so the runtime can rehydrate it on resume.",
306
+ [ProcessErrorCode.SignalNotAwaited]: 'Signal must be awaited to create a suspension point. ' +
307
+ "Use 'await signal({0})' instead of 'signal({0})'.",
308
+ [ProcessErrorCode.InvalidRacePattern]: 'Invalid race pattern. Expected: switch (await race()) { case await signal(...): ... }',
309
+ [ProcessErrorCode.HandlerNotAsync]: 'Process handler must be an async function.',
310
+ [ProcessErrorCode.NonDeterministicOperation]: "Non-deterministic operation '{0}' cannot be used in a process handler - " +
311
+ 'replaying from persisted state would produce different results. ' +
312
+ 'For timestamps, pass the current time as a signal payload. For random values, generate them before the process starts and pass as a parameter.',
313
+ [ProcessErrorCode.SignalStoredInVariable]: "'{0}' must be used directly in an await expression so the compiler can track the suspension point - storing it in a variable loses tracking. " +
314
+ "Write 'await {0}(...)' or 'case {0}(r, ...):' directly.",
315
+ [ProcessErrorCode.TryCatchWithSuspension]: 'Cannot use try-catch around suspension points - processes resume from persisted state, so catch blocks cannot be serialized. ' +
316
+ 'Handle errors by adding a timeout branch to your race, or move error-prone logic into a service method.',
317
+ [ProcessErrorCode.NestedAsyncWithSuspension]: 'Cannot use suspension points (signal/delay) inside nested async functions. ' +
318
+ 'Move the await signal() directly into the process handler.',
319
+ [ProcessErrorCode.PromiseCombinatorWithSignal]: 'Cannot use {0} with process primitives. ' +
320
+ 'Use sequential awaits or the race() switch pattern instead.',
321
+ [ProcessErrorCode.ForInWithSuspension]: 'For-in loops with suspension points are not supported. ' +
322
+ 'Convert to for-of with Object.keys(): for (const key of Object.keys(obj)) { ... }',
323
+ [ProcessErrorCode.FunctionEscapesScope]: 'Inner function with suspension points escapes handler scope. ' +
324
+ 'Functions with signal/delay must be called directly, not returned or passed.',
325
+ [ProcessErrorCode.ParallelFunctionWithParams]: 'Parallel functions cannot have parameters. ' +
326
+ "Use 'async () => {{ ... }}' instead of 'async ({0}) => {{ ... }}'.",
327
+ [ProcessErrorCode.WhileConditionSuspension]: 'While-loop condition contains a suspension point (signal/delay). ' +
328
+ 'Move it into the body: while (true) {{ if (!await signal(...)) break; ... }}',
329
+ [ProcessErrorCode.DoWhileWithSuspension]: 'Do-while loops with suspension points are not supported. ' +
330
+ 'Convert to: while (true) {{ await signal(...); if (!condition) break }}',
331
+ [ProcessErrorCode.ForWithSuspension]: 'Classic for loops with suspension points are not supported. ' +
332
+ 'Convert to a while loop: let i = 0; while (i < n) { await signal(...); i++ }',
333
+ [ProcessErrorCode.RecursionDepthUnknown]: "Recursive function '{0}' cannot be inlined - recursion depth is not statically known. " +
334
+ 'Use a while loop or provide a constant recursion limit.',
335
+ [ProcessErrorCode.MutualRecursion]: "Mutual recursion detected between '{0}' and '{1}'. " +
336
+ 'Restructure to use a single function or loop.',
337
+ [ProcessErrorCode.MaxInliningDepthExceeded]: "Maximum inlining depth ({0}) exceeded for function '{1}'. " +
338
+ 'Reduce nesting or restructure to use loops.',
339
+ [ProcessErrorCode.InvalidDurableIterator]: 'Durable iteration requires ORDER BY with a unique final column. ' +
340
+ "Add .orderBy('createdAt', 'id') to your query for keyset pagination.",
341
+ [ProcessErrorCode.NonSerializableCursor]: 'Durable iterator cursor must be serializable (string, number, or plain object). ' +
342
+ 'The cursor type {0} cannot be persisted.',
343
+ [ProcessErrorCode.YieldInNonGenerator]: "Cannot use 'yield' in a regular async handler. " +
344
+ "Use 'async *handler()' instead of 'async handler()' to enable yields.",
345
+ [ProcessErrorCode.ThrowNotAllowed]: 'Throw statements are not allowed in process handlers - processes track state via program counter, not exception unwinding. ' +
346
+ "Return an error result object instead: return {{ status: 'error', message: '...' }}.",
347
+ [ProcessErrorCode.EmptyParallelBlock]: 'signal.all() requires at least one signal. ' +
348
+ 'Use await signal(svc.single) for a single signal.',
349
+ [ProcessErrorCode.ScopeItemLimitExceeded]: 'scope() exceeded maximum item limit ({0}). ' +
350
+ 'Process batches or increase the limit if necessary.',
351
+ [ProcessErrorCode.ScopeHandlerCannotYield]: 'Scope handlers cannot use yield. ' +
352
+ 'Use scope(processRef, items) with a generator process to emit events.',
353
+ [ProcessErrorCode.DuplicateEntityInScope]: "Duplicate entity ID '{0}' in scope(). " +
354
+ 'Each entity must have a unique identity.',
355
+ [ProcessErrorCode.NestedScopeCollision]: "Nested scope() with same model type '{0}' creates ambiguous paths. " +
356
+ 'Use different model types or restructure the nesting.',
357
+ [ProcessErrorCode.EmptyRace]: 'Race switch has no valid signal or delay branches. ' +
358
+ 'Add at least one case with signal(r, ...) or delay(r, ...).',
359
+ [ProcessErrorCode.InvalidScopeArguments]: 'Invalid scope() arguments. Use one of: scope(signal, entities), scope(entities, handler), or scope(entities, idFn, handler).',
360
+ [ProcessErrorCode.RaceCombinatorNotSupported]: 'signal.all / signal.settled / stream inside a race switch is not yet supported. ' +
361
+ 'Use signal(r, svc.x) / delay.seconds(r, n) branches, or await the combinator outside the race.',
362
+ [ProcessErrorCode.ShadowedHandlerLocal]: "Variable '{0}' shadows an outer process-handler local. Process state is serialized to a flat " +
363
+ 'state.vars namespace; block-scoped redeclarations would silently overwrite the outer binding. ' +
364
+ 'Rename the inner variable.',
365
+ };
366
+ /**
367
+ * Create a process-specific diagnostic.
368
+ */
369
+ export function createProcessDiagnostic(code, node, ...args) {
370
+ let message = errorMessages[code];
371
+ for (let i = 0; i < args.length; i++) {
372
+ message = message.split(`{${i}}`).join(args[i]);
373
+ }
374
+ const sourceFile = node.getSourceFile();
375
+ const start = node.getStart();
376
+ const length = node.getWidth();
377
+ return {
378
+ file: sourceFile,
379
+ start,
380
+ length,
381
+ messageText: message,
382
+ category: ts.DiagnosticCategory.Error,
383
+ code: 100000 + code, // Offset to avoid collision with TS codes
384
+ source: 'justscale-process',
385
+ };
386
+ }
387
+ /**
388
+ * Format error code for display.
389
+ */
390
+ export function formatErrorCode(code) {
391
+ return `TSP${code}`;
392
+ }
393
+ /**
394
+ * Check if a diagnostic is a process-specific error.
395
+ */
396
+ export function isProcessDiagnostic(diagnostic) {
397
+ return diagnostic.source === 'justscale-process';
398
+ }
399
+ /**
400
+ * Get the process error code from a diagnostic.
401
+ */
402
+ export function getProcessErrorCode(diagnostic) {
403
+ if (!isProcessDiagnostic(diagnostic))
404
+ return null;
405
+ return (diagnostic.code - 100000);
406
+ }
407
+ /**
408
+ * Collector for process diagnostics during compilation.
409
+ */
410
+ export class DiagnosticCollector {
411
+ diagnostics = [];
412
+ add(code, node, ...args) {
413
+ this.diagnostics.push(createProcessDiagnostic(code, node, ...args));
414
+ }
415
+ getAll() {
416
+ return [...this.diagnostics];
417
+ }
418
+ hasErrors() {
419
+ return this.diagnostics.length > 0;
420
+ }
421
+ clear() {
422
+ this.diagnostics = [];
423
+ }
424
+ }
425
+ /**
426
+ * Filter TS2850 diagnostics for `using exports` declarations in process files.
427
+ * TS2850 fires because the exports object doesn't have Symbol.dispose, but
428
+ * our compiler handles disposal separately - this diagnostic is noise.
429
+ */
430
+ export function filterUsingExportsDiagnostics(diagnostics) {
431
+ return diagnostics.filter(d => {
432
+ if (d.code !== 2850)
433
+ return true;
434
+ if (d.start === undefined || !d.file)
435
+ return true;
436
+ const node = findNodeAt(d.file, d.start);
437
+ if (!node)
438
+ return true;
439
+ let current = node;
440
+ while (current) {
441
+ if (ts.isVariableDeclaration(current)) {
442
+ if (ts.isIdentifier(current.name) && current.name.text === 'exports') {
443
+ const parent = current.parent;
444
+ if (parent && ts.isVariableDeclarationList(parent)) {
445
+ return (parent.flags & ts.NodeFlags.Using) === 0;
446
+ }
447
+ }
448
+ return true;
449
+ }
450
+ current = current.parent;
451
+ }
452
+ return true;
453
+ });
454
+ }
455
+ function findNodeAt(sourceFile, position) {
456
+ let found;
457
+ const visit = (node) => {
458
+ if (position >= node.getStart(sourceFile) && position < node.getEnd()) {
459
+ found = node;
460
+ ts.forEachChild(node, visit);
461
+ }
462
+ };
463
+ ts.forEachChild(sourceFile, visit);
464
+ return found;
465
+ }
466
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/compiler/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B;;;;;;;;;OASG;IACH,oBAAoB,EAAE,IAAI;IAE1B;;;;;;;OAOG;IACH,gBAAgB,EAAE,IAAI;IAEtB;;;;OAIG;IACH,kBAAkB,EAAE,IAAI;IAExB;;OAEG;IACH,eAAe,EAAE,IAAI;IAErB;;;;;OAKG;IACH,yBAAyB,EAAE,IAAI;IAE/B;;;;;;;;;;;OAWG;IACH,sBAAsB,EAAE,IAAI;IAE5B;;;;;;;;;OASG;IACH,sBAAsB,EAAE,IAAI;IAE5B;;;;;;;;;OASG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AAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACtE,KAAK,GAAG,IAAI,CAAC;YACb,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,CAAC;IACF,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Exports Pre-pass
3
+ *
4
+ * Two-pass compilation for process exports type inference.
5
+ *
6
+ * Pass 1: Create a TypeScript program, find `using exports = { ... }` declarations
7
+ * in process handlers, extract the type via typeChecker.getTypeAtLocation().
8
+ * Pass 2: Inject `__exportsType: void 0 as unknown as <ExportsType>` into the
9
+ * createProcess config, re-create the program. TypeScript now infers TExports
10
+ * correctly from the phantom property.
11
+ *
12
+ * Non-exported types referenced by the exports (e.g. local interfaces) are
13
+ * automatically exported so the declaration emitter can reference them.
14
+ *
15
+ * This gives us correct types everywhere: type checking, .d.ts output, IDE.
16
+ */
17
+ import ts from 'typescript';
18
+ /**
19
+ * Extract exports types from all process files in a program and return
20
+ * modified source texts with `__exportsType` phantom properties injected.
21
+ *
22
+ * Returns a map from file name to modified source text.
23
+ * Only files that contain createProcess calls with `using exports` are included.
24
+ */
25
+ export declare function extractAndInjectExportsTypes(program: ts.Program): Map<string, string>;
26
+ /**
27
+ * Create a compiler host that serves modified source for specific files,
28
+ * falling back to the base host for everything else.
29
+ */
30
+ export declare function createModifiedHost(baseHost: ts.CompilerHost, modifiedSources: Map<string, string>): ts.CompilerHost;
31
+ //# sourceMappingURL=exports-prepass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-prepass.d.ts","sourceRoot":"","sources":["../../src/compiler/exports-prepass.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAW5B;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,EAAE,CAAC,OAAO,GAClB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBrB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,EAAE,CAAC,YAAY,EACzB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,EAAE,CAAC,YAAY,CAmBjB"}