nmtjs 0.16.1 → 0.17.0-beta.2

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 (224) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +41 -1
  3. package/dist/index.d.ts +22 -161
  4. package/dist/index.js +24 -53
  5. package/dist/index.js.map +1 -1
  6. package/package.json +11 -63
  7. package/src/index.ts +71 -91
  8. package/bin/cli.js +0 -2
  9. package/dist/cli.d.ts +0 -1
  10. package/dist/cli.js +0 -137
  11. package/dist/cli.js.map +0 -1
  12. package/dist/codegen.d.ts +0 -5
  13. package/dist/codegen.js +0 -18
  14. package/dist/codegen.js.map +0 -1
  15. package/dist/config.d.ts +0 -47
  16. package/dist/config.js +0 -16
  17. package/dist/config.js.map +0 -1
  18. package/dist/entrypoints/cli.d.ts +0 -1
  19. package/dist/entrypoints/cli.js +0 -12
  20. package/dist/entrypoints/cli.js.map +0 -1
  21. package/dist/entrypoints/main.d.ts +0 -5
  22. package/dist/entrypoints/main.js +0 -248
  23. package/dist/entrypoints/main.js.map +0 -1
  24. package/dist/entrypoints/thread.d.ts +0 -16
  25. package/dist/entrypoints/thread.js +0 -182
  26. package/dist/entrypoints/thread.js.map +0 -1
  27. package/dist/entrypoints/worker.d.ts +0 -9
  28. package/dist/entrypoints/worker.js +0 -143
  29. package/dist/entrypoints/worker.js.map +0 -1
  30. package/dist/resolver.d.ts +0 -2
  31. package/dist/resolver.js +0 -7
  32. package/dist/resolver.js.map +0 -1
  33. package/dist/runtime/application/index.d.ts +0 -1
  34. package/dist/runtime/application/index.js +0 -2
  35. package/dist/runtime/application/index.js.map +0 -1
  36. package/dist/runtime/constants.d.ts +0 -8
  37. package/dist/runtime/constants.js +0 -5
  38. package/dist/runtime/constants.js.map +0 -1
  39. package/dist/runtime/enums.d.ts +0 -10
  40. package/dist/runtime/enums.js +0 -13
  41. package/dist/runtime/enums.js.map +0 -1
  42. package/dist/runtime/hooks.d.ts +0 -1
  43. package/dist/runtime/hooks.js +0 -2
  44. package/dist/runtime/hooks.js.map +0 -1
  45. package/dist/runtime/index.d.ts +0 -28
  46. package/dist/runtime/index.js +0 -29
  47. package/dist/runtime/index.js.map +0 -1
  48. package/dist/runtime/injectables.d.ts +0 -69
  49. package/dist/runtime/injectables.js +0 -40
  50. package/dist/runtime/injectables.js.map +0 -1
  51. package/dist/runtime/jobs/job.d.ts +0 -146
  52. package/dist/runtime/jobs/job.js +0 -89
  53. package/dist/runtime/jobs/job.js.map +0 -1
  54. package/dist/runtime/jobs/manager.d.ts +0 -131
  55. package/dist/runtime/jobs/manager.js +0 -309
  56. package/dist/runtime/jobs/manager.js.map +0 -1
  57. package/dist/runtime/jobs/router.d.ts +0 -296
  58. package/dist/runtime/jobs/router.js +0 -458
  59. package/dist/runtime/jobs/router.js.map +0 -1
  60. package/dist/runtime/jobs/runner.d.ts +0 -103
  61. package/dist/runtime/jobs/runner.js +0 -425
  62. package/dist/runtime/jobs/runner.js.map +0 -1
  63. package/dist/runtime/jobs/step.d.ts +0 -26
  64. package/dist/runtime/jobs/step.js +0 -18
  65. package/dist/runtime/jobs/step.js.map +0 -1
  66. package/dist/runtime/jobs/types.d.ts +0 -86
  67. package/dist/runtime/jobs/types.js +0 -5
  68. package/dist/runtime/jobs/types.js.map +0 -1
  69. package/dist/runtime/metrics/metric.d.ts +0 -8
  70. package/dist/runtime/metrics/metric.js +0 -11
  71. package/dist/runtime/metrics/metric.js.map +0 -1
  72. package/dist/runtime/metrics/registry.d.ts +0 -3
  73. package/dist/runtime/metrics/registry.js +0 -5
  74. package/dist/runtime/metrics/registry.js.map +0 -1
  75. package/dist/runtime/metrics/server.d.ts +0 -7
  76. package/dist/runtime/metrics/server.js +0 -53
  77. package/dist/runtime/metrics/server.js.map +0 -1
  78. package/dist/runtime/plugin.d.ts +0 -2
  79. package/dist/runtime/plugin.js +0 -2
  80. package/dist/runtime/plugin.js.map +0 -1
  81. package/dist/runtime/runtime.d.ts +0 -27
  82. package/dist/runtime/runtime.js +0 -77
  83. package/dist/runtime/runtime.js.map +0 -1
  84. package/dist/runtime/scheduler/index.d.ts +0 -22
  85. package/dist/runtime/scheduler/index.js +0 -20
  86. package/dist/runtime/scheduler/index.js.map +0 -1
  87. package/dist/runtime/server/applications.d.ts +0 -91
  88. package/dist/runtime/server/applications.js +0 -171
  89. package/dist/runtime/server/applications.js.map +0 -1
  90. package/dist/runtime/server/config.d.ts +0 -148
  91. package/dist/runtime/server/config.js +0 -33
  92. package/dist/runtime/server/config.js.map +0 -1
  93. package/dist/runtime/server/environment.d.ts +0 -43
  94. package/dist/runtime/server/environment.js +0 -33
  95. package/dist/runtime/server/environment.js.map +0 -1
  96. package/dist/runtime/server/error-policy.d.ts +0 -62
  97. package/dist/runtime/server/error-policy.js +0 -73
  98. package/dist/runtime/server/error-policy.js.map +0 -1
  99. package/dist/runtime/server/hmr-coordinator.d.ts +0 -37
  100. package/dist/runtime/server/hmr-coordinator.js +0 -94
  101. package/dist/runtime/server/hmr-coordinator.js.map +0 -1
  102. package/dist/runtime/server/jobs.d.ts +0 -54
  103. package/dist/runtime/server/jobs.js +0 -176
  104. package/dist/runtime/server/jobs.js.map +0 -1
  105. package/dist/runtime/server/lifecycle.d.ts +0 -85
  106. package/dist/runtime/server/lifecycle.js +0 -177
  107. package/dist/runtime/server/lifecycle.js.map +0 -1
  108. package/dist/runtime/server/managed-worker.d.ts +0 -158
  109. package/dist/runtime/server/managed-worker.js +0 -420
  110. package/dist/runtime/server/managed-worker.js.map +0 -1
  111. package/dist/runtime/server/pool-manager.d.ts +0 -85
  112. package/dist/runtime/server/pool-manager.js +0 -129
  113. package/dist/runtime/server/pool-manager.js.map +0 -1
  114. package/dist/runtime/server/proxy.d.ts +0 -21
  115. package/dist/runtime/server/proxy.js +0 -76
  116. package/dist/runtime/server/proxy.js.map +0 -1
  117. package/dist/runtime/server/server.d.ts +0 -60
  118. package/dist/runtime/server/server.js +0 -163
  119. package/dist/runtime/server/server.js.map +0 -1
  120. package/dist/runtime/server/types.d.ts +0 -31
  121. package/dist/runtime/server/types.js +0 -2
  122. package/dist/runtime/server/types.js.map +0 -1
  123. package/dist/runtime/server/worker-pool.d.ts +0 -121
  124. package/dist/runtime/server/worker-pool.js +0 -171
  125. package/dist/runtime/server/worker-pool.js.map +0 -1
  126. package/dist/runtime/store/index.d.ts +0 -3
  127. package/dist/runtime/store/index.js +0 -23
  128. package/dist/runtime/store/index.js.map +0 -1
  129. package/dist/runtime/subscription/manager.d.ts +0 -49
  130. package/dist/runtime/subscription/manager.js +0 -170
  131. package/dist/runtime/subscription/manager.js.map +0 -1
  132. package/dist/runtime/subscription/redis.d.ts +0 -18
  133. package/dist/runtime/subscription/redis.js +0 -119
  134. package/dist/runtime/subscription/redis.js.map +0 -1
  135. package/dist/runtime/types.d.ts +0 -95
  136. package/dist/runtime/types.js +0 -2
  137. package/dist/runtime/types.js.map +0 -1
  138. package/dist/runtime/workers/application.d.ts +0 -29
  139. package/dist/runtime/workers/application.js +0 -77
  140. package/dist/runtime/workers/application.js.map +0 -1
  141. package/dist/runtime/workers/base.d.ts +0 -14
  142. package/dist/runtime/workers/base.js +0 -41
  143. package/dist/runtime/workers/base.js.map +0 -1
  144. package/dist/runtime/workers/cli.d.ts +0 -1
  145. package/dist/runtime/workers/cli.js +0 -2
  146. package/dist/runtime/workers/cli.js.map +0 -1
  147. package/dist/runtime/workers/job.d.ts +0 -20
  148. package/dist/runtime/workers/job.js +0 -170
  149. package/dist/runtime/workers/job.js.map +0 -1
  150. package/dist/vite/builder.d.ts +0 -5
  151. package/dist/vite/builder.js +0 -79
  152. package/dist/vite/builder.js.map +0 -1
  153. package/dist/vite/config.d.ts +0 -28
  154. package/dist/vite/config.js +0 -22
  155. package/dist/vite/config.js.map +0 -1
  156. package/dist/vite/plugins.d.ts +0 -2
  157. package/dist/vite/plugins.js +0 -43
  158. package/dist/vite/plugins.js.map +0 -1
  159. package/dist/vite/runners/worker.d.ts +0 -3
  160. package/dist/vite/runners/worker.js +0 -34
  161. package/dist/vite/runners/worker.js.map +0 -1
  162. package/dist/vite/server.d.ts +0 -3
  163. package/dist/vite/server.js +0 -36
  164. package/dist/vite/server.js.map +0 -1
  165. package/dist/vite/servers/main.d.ts +0 -8
  166. package/dist/vite/servers/main.js +0 -24
  167. package/dist/vite/servers/main.js.map +0 -1
  168. package/dist/vite/servers/worker.d.ts +0 -13
  169. package/dist/vite/servers/worker.js +0 -124
  170. package/dist/vite/servers/worker.js.map +0 -1
  171. package/src/cli.ts +0 -162
  172. package/src/codegen.ts +0 -30
  173. package/src/config.ts +0 -69
  174. package/src/entrypoints/cli.ts +0 -13
  175. package/src/entrypoints/main.ts +0 -317
  176. package/src/entrypoints/thread.ts +0 -223
  177. package/src/entrypoints/worker.ts +0 -174
  178. package/src/resolver.ts +0 -7
  179. package/src/runtime/application/index.ts +0 -1
  180. package/src/runtime/constants.ts +0 -13
  181. package/src/runtime/enums.ts +0 -12
  182. package/src/runtime/hooks.ts +0 -1
  183. package/src/runtime/index.ts +0 -29
  184. package/src/runtime/injectables.ts +0 -101
  185. package/src/runtime/jobs/job.ts +0 -467
  186. package/src/runtime/jobs/manager.ts +0 -454
  187. package/src/runtime/jobs/router.ts +0 -967
  188. package/src/runtime/jobs/runner.ts +0 -583
  189. package/src/runtime/jobs/step.ts +0 -66
  190. package/src/runtime/jobs/types.ts +0 -116
  191. package/src/runtime/metrics/metric.ts +0 -18
  192. package/src/runtime/metrics/registry.ts +0 -11
  193. package/src/runtime/metrics/server.ts +0 -69
  194. package/src/runtime/plugin.ts +0 -2
  195. package/src/runtime/runtime.ts +0 -103
  196. package/src/runtime/scheduler/index.ts +0 -39
  197. package/src/runtime/server/applications.ts +0 -264
  198. package/src/runtime/server/config.ts +0 -199
  199. package/src/runtime/server/environment.ts +0 -71
  200. package/src/runtime/server/error-policy.ts +0 -132
  201. package/src/runtime/server/hmr-coordinator.ts +0 -116
  202. package/src/runtime/server/jobs.ts +0 -266
  203. package/src/runtime/server/lifecycle.ts +0 -234
  204. package/src/runtime/server/managed-worker.ts +0 -546
  205. package/src/runtime/server/pool-manager.ts +0 -187
  206. package/src/runtime/server/proxy.ts +0 -119
  207. package/src/runtime/server/server.ts +0 -218
  208. package/src/runtime/server/types.ts +0 -32
  209. package/src/runtime/server/worker-pool.ts +0 -275
  210. package/src/runtime/store/index.ts +0 -30
  211. package/src/runtime/subscription/manager.ts +0 -307
  212. package/src/runtime/subscription/redis.ts +0 -159
  213. package/src/runtime/types.ts +0 -84
  214. package/src/runtime/workers/application.ts +0 -133
  215. package/src/runtime/workers/base.ts +0 -65
  216. package/src/runtime/workers/cli.ts +0 -0
  217. package/src/runtime/workers/job.ts +0 -142
  218. package/src/vite/builder.ts +0 -94
  219. package/src/vite/config.ts +0 -45
  220. package/src/vite/plugins.ts +0 -53
  221. package/src/vite/runners/worker.ts +0 -55
  222. package/src/vite/server.ts +0 -55
  223. package/src/vite/servers/main.ts +0 -41
  224. package/src/vite/servers/worker.ts +0 -177
@@ -1,41 +0,0 @@
1
- import { CoreInjectables, provision } from '@nmtjs/core';
2
- import * as injectables from '../injectables.js';
3
- import { JobManager } from '../jobs/manager.js';
4
- import { BaseRuntime } from '../runtime.js';
5
- export class BaseWorkerRuntime extends BaseRuntime {
6
- config;
7
- workerType;
8
- jobManager;
9
- constructor(config, options, workerType) {
10
- super(options);
11
- this.config = config;
12
- this.workerType = workerType;
13
- if (this.config.store) {
14
- this.jobManager = new JobManager(this.config.store, this.config.jobs ? Array.from(this.config.jobs.jobs.values()) : []);
15
- }
16
- }
17
- async initialize() {
18
- const injections = [
19
- provision(CoreInjectables.logger, this.logger),
20
- provision(injectables.workerType, this.workerType),
21
- ];
22
- if (this.config.store) {
23
- injections.push(provision(injectables.storeConfig, this.config.store));
24
- }
25
- if (this.config.subscription) {
26
- injections.push(provision(injectables.subscriptionAdapter, this.config.subscription.adapter));
27
- }
28
- if (this.jobManager) {
29
- injections.push(provision(injectables.jobManager, this.jobManager.publicInstance));
30
- }
31
- this.container.provide(injections);
32
- await super.initialize();
33
- }
34
- async _initialize() {
35
- await this.jobManager?.initialize();
36
- }
37
- async _dispose() {
38
- await this.jobManager?.terminate();
39
- }
40
- }
41
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/runtime/workers/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAKxD,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,OAAgB,iBAAkB,SAAQ,WAAW;IAI9C,MAAM;IAEN,UAAU;IALrB,UAAU,CAAa;IAEvB,YACW,MAAoB,EAC7B,OAA2B,EAClB,UAAsB;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAA;sBAJL,MAAM;0BAEN,UAAU;QAInB,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,EACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CACnE,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,UAAU,GAAgB;YAC9B,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;YAC9C,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;SACnD,CAAA;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QACxE,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC7B,UAAU,CAAC,IAAI,CACb,SAAS,CACP,WAAW,CAAC,mBAAmB,EAC/B,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CACjC,CACF,CAAA;QACH,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,UAAU,CAAC,IAAI,CACb,SAAS,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAClE,CAAA;QACH,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QAClC,MAAM,KAAK,CAAC,UAAU,EAAE,CAAA;IAC1B,CAAC;IAES,KAAK,CAAC,WAAW;QACzB,MAAM,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,CAAA;IACrC,CAAC;IAES,KAAK,CAAC,QAAQ;QACtB,MAAM,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,CAAA;IACpC,CAAC;CACF"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/runtime/workers/cli.ts"],"names":[],"mappings":""}
@@ -1,20 +0,0 @@
1
- import type { MessagePort } from 'node:worker_threads';
2
- import type { ServerConfig } from '../server/config.ts';
3
- import { ApplicationWorkerJobRunner } from '../jobs/runner.ts';
4
- import { BaseWorkerRuntime } from './base.ts';
5
- export interface JobWorkerRuntimeOptions {
6
- poolName: string;
7
- port: MessagePort;
8
- }
9
- export declare class JobWorkerRuntime extends BaseWorkerRuntime {
10
- readonly config: ServerConfig;
11
- readonly runtimeOptions: JobWorkerRuntimeOptions;
12
- jobRunner: ApplicationWorkerJobRunner;
13
- constructor(config: ServerConfig, runtimeOptions: JobWorkerRuntimeOptions);
14
- start(): Promise<void>;
15
- stop(): Promise<void>;
16
- initialize(): Promise<void>;
17
- protected _initialize(): Promise<void>;
18
- protected _dispose(): Promise<void>;
19
- protected _dependents(): Generator<import("../index.ts").AnyJob, void, unknown>;
20
- }
@@ -1,170 +0,0 @@
1
- var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
- if (value !== null && value !== void 0) {
3
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
- var dispose, inner;
5
- if (async) {
6
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
- dispose = value[Symbol.asyncDispose];
8
- }
9
- if (dispose === void 0) {
10
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
- dispose = value[Symbol.dispose];
12
- if (async) inner = dispose;
13
- }
14
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
- if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
- env.stack.push({ value: value, dispose: dispose, async: async });
17
- }
18
- else if (async) {
19
- env.stack.push({ async: true });
20
- }
21
- return value;
22
- };
23
- var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
- return function (env) {
25
- function fail(e) {
26
- env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
- env.hasError = true;
28
- }
29
- var r, s = 0;
30
- function next() {
31
- while (r = env.stack.pop()) {
32
- try {
33
- if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
- if (r.dispose) {
35
- var result = r.dispose.call(r.value);
36
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
- }
38
- else s |= 1;
39
- }
40
- catch (e) {
41
- fail(e);
42
- }
43
- }
44
- if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
- if (env.hasError) throw env.error;
46
- }
47
- return next();
48
- };
49
- })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
- var e = new Error(message);
51
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
- });
53
- import { LifecycleHook } from '@nmtjs/application';
54
- import { UnrecoverableError } from 'bullmq';
55
- import { WorkerType } from '../enums.js';
56
- import { jobWorkerPool } from '../injectables.js';
57
- import { ApplicationWorkerJobRunner } from '../jobs/runner.js';
58
- import { BaseWorkerRuntime } from './base.js';
59
- export class JobWorkerRuntime extends BaseWorkerRuntime {
60
- config;
61
- runtimeOptions;
62
- jobRunner;
63
- constructor(config, runtimeOptions) {
64
- super(config, { logger: config.logger, name: `Job Worker ${runtimeOptions.poolName}` }, WorkerType.Job);
65
- this.config = config;
66
- this.runtimeOptions = runtimeOptions;
67
- }
68
- async start() {
69
- await this.initialize();
70
- await this.lifecycleHooks.callHook(LifecycleHook.Start);
71
- }
72
- async stop() {
73
- await this.lifecycleHooks.callHook(LifecycleHook.Stop);
74
- await this.dispose();
75
- }
76
- async initialize() {
77
- // Validate all jobs are complete before accepting work
78
- if (this.config.jobs) {
79
- for (const job of this.config.jobs.jobs.values()) {
80
- if (!job.returnHandler) {
81
- throw new Error(`Job "${job.name}" is incomplete. Jobs must call .return() to be finalized before use.`);
82
- }
83
- }
84
- }
85
- this.container.provide(jobWorkerPool, this.runtimeOptions.poolName);
86
- await super.initialize();
87
- }
88
- async _initialize() {
89
- await super._initialize();
90
- this.jobRunner = new ApplicationWorkerJobRunner({
91
- logger: this.logger,
92
- container: this.container,
93
- lifecycleHooks: this.lifecycleHooks,
94
- });
95
- this.runtimeOptions.port.on('message', async (msg) => {
96
- if (msg.type === 'task') {
97
- const { id, task } = msg.data;
98
- try {
99
- const env_1 = { stack: [], error: void 0, hasError: false };
100
- try {
101
- const job = this.config.jobs?.jobs.get(task.jobName);
102
- if (!job) {
103
- this.runtimeOptions.port.postMessage({
104
- type: 'task',
105
- data: { id, task: { type: 'job_not_found' } },
106
- });
107
- return;
108
- }
109
- const cancellationSignal = __addDisposableResource(env_1, this.jobManager.cancellationSignal(job, task.jobId), false);
110
- const queue = this.jobManager.getQueue(job).queue;
111
- const bullJob = await queue.getJob(task.jobId);
112
- if (!bullJob) {
113
- throw new UnrecoverableError(`Job ${task.jobId} not found in queue (may have been removed)`);
114
- }
115
- // Load checkpoint from BullMQ progress for resume support
116
- const checkpoint = bullJob.progress;
117
- const result = await this.jobRunner.runJob(job, task.data, {
118
- signal: cancellationSignal,
119
- queueJob: bullJob,
120
- result: checkpoint?.result,
121
- stepResults: checkpoint?.stepResults,
122
- currentStepIndex: checkpoint?.stepIndex ?? 0,
123
- progress: checkpoint?.progress,
124
- });
125
- this.runtimeOptions.port.postMessage({
126
- type: 'task',
127
- data: { id, task: { type: 'success', result } },
128
- });
129
- }
130
- catch (e_1) {
131
- env_1.error = e_1;
132
- env_1.hasError = true;
133
- }
134
- finally {
135
- __disposeResources(env_1);
136
- }
137
- }
138
- catch (error) {
139
- if (error instanceof UnrecoverableError) {
140
- this.runtimeOptions.port.postMessage({
141
- type: 'task',
142
- data: { id, task: { type: 'unrecoverable_error', error } },
143
- });
144
- }
145
- else {
146
- this.runtimeOptions.port.postMessage({
147
- type: 'task',
148
- data: { id, task: { type: 'error', error } },
149
- });
150
- }
151
- }
152
- }
153
- });
154
- }
155
- async _dispose() {
156
- this.runtimeOptions.port.removeAllListeners('message');
157
- await super._dispose();
158
- }
159
- *_dependents() {
160
- if (this.config.jobs) {
161
- for (const job of this.config.jobs.jobs.values()) {
162
- yield job;
163
- // we explicitly DO NOT WANT to yield steps here, so per-job container
164
- // resolves them independently each time — creates more isolation
165
- // yield* job.jobSteps
166
- }
167
- }
168
- }
169
- }
170
- //# sourceMappingURL=job.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"job.js","sourceRoot":"","sources":["../../../src/runtime/workers/job.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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Ac,CAAC,IAAI,CAAC,WAAW,CAAC;4BACnC,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;yBACjB,CAAC,CAAA;oBAChC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAES,KAAK,CAAC,QAAQ;QACtB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAA;QACtD,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;IAES,CAAC,WAAW;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;gBACjD,MAAM,GAAG,CAAA;gBACT,sEAAsE;gBACtE,iEAAiE;gBACjE,sBAAsB;YACxB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -1,5 +0,0 @@
1
- import type { NeemataConfig } from '../config.ts';
2
- import type { ViteConfigOptions } from './config.ts';
3
- export declare function createBuilder(configOptions: ViteConfigOptions, neemataConfig: NeemataConfig): Promise<{
4
- build: () => Promise<any>;
5
- }>;
@@ -1,79 +0,0 @@
1
- var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
- if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
- return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
- });
6
- }
7
- return path;
8
- };
9
- import { isBuiltin } from 'node:module';
10
- import { resolve } from 'node:path';
11
- import { mergeConfig, build as viteBuild } from 'vite';
12
- import { createConfig } from './config.js';
13
- import { plugins } from './plugins.js';
14
- export async function createBuilder(configOptions, neemataConfig) {
15
- const config = createConfig(configOptions);
16
- async function build() {
17
- const packageJson = await import(__rewriteRelativeImportExtension(resolve('./package.json')), {
18
- with: { type: 'json' },
19
- }).then((mod) => mod.default);
20
- return await viteBuild(mergeConfig({
21
- appType: 'custom',
22
- clearScreen: false,
23
- resolve: { alias: config.alias, noExternal: true },
24
- plugins: [...plugins],
25
- build: {
26
- lib: { entry: config.entries, formats: ['es'] },
27
- ssr: true,
28
- ssrEmitAssets: true,
29
- target: 'node24',
30
- sourcemap: true,
31
- outDir: resolve('./dist'),
32
- minify: true,
33
- emptyOutDir: true,
34
- rolldownOptions: {
35
- platform: 'node',
36
- external: (id) => {
37
- if (neemataConfig.externalDependencies === 'all')
38
- return true;
39
- if (isBuiltin(id) ||
40
- id.includes('nmtjs/src/vite/servers') ||
41
- id.includes('nmtjs/src/vite/runners'))
42
- return true;
43
- if (neemataConfig.externalDependencies === 'prod') {
44
- const prodDeps = Object.keys(packageJson.dependencies ?? {});
45
- if (prodDeps.includes(id))
46
- return true;
47
- }
48
- if (Array.isArray(neemataConfig.externalDependencies)) {
49
- for (const dep of neemataConfig.externalDependencies) {
50
- if (typeof dep === 'string' && dep === id)
51
- return true;
52
- if (dep instanceof RegExp && dep.test(id))
53
- return true;
54
- }
55
- }
56
- return false;
57
- },
58
- transform: {
59
- define: {
60
- __VITE_CONFIG__: '""',
61
- __APPLICATIONS_CONFIG__: JSON.stringify(JSON.stringify(Object.fromEntries(Object.entries(configOptions.applicationImports).map(([appName, { type }]) => [
62
- appName,
63
- { type, specifier: `./application.${appName}.js` },
64
- ])))),
65
- },
66
- },
67
- output: {
68
- entryFileNames: '[name].js',
69
- chunkFileNames: '[name]-[hash].js',
70
- assetFileNames: '[name][extname]',
71
- },
72
- },
73
- chunkSizeWarningLimit: 10_000,
74
- },
75
- }, neemataConfig.vite));
76
- }
77
- return { build };
78
- }
79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,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;gCACvB,OAAO;gCACP,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,OAAO,KAAK,EAAE;6BACnD,CACF,CACF,CACF,CACF;yBACF;qBACF;oBACD,MAAM,EAAE;wBACN,cAAc,EAAE,WAAW;wBAC3B,cAAc,EAAE,kBAAkB;wBAClC,cAAc,EAAE,iBAAiB;qBAClC;iBACF;gBACD,qBAAqB,EAAE,MAAM;aAC9B;SACmB,EACtB,aAAa,CAAC,IAAI,CACnB,CACF,CAAA;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC"}
@@ -1,28 +0,0 @@
1
- export type ViteConfigOptions = {
2
- applicationImports: Record<string, {
3
- path: string;
4
- specifier: string;
5
- type: 'neemata' | 'custom';
6
- }>;
7
- serverEntryPath: string;
8
- entrypointMainPath: string;
9
- entrypointWorkerPath: string;
10
- entrypointThreadPath: string;
11
- configPath: string;
12
- };
13
- export declare const baseViteConfigOptions: {
14
- entrypointMainPath: string;
15
- entrypointWorkerPath: string;
16
- entrypointThreadPath: string;
17
- };
18
- export declare function createConfig(options: ViteConfigOptions): {
19
- alias: {
20
- '#server': string;
21
- };
22
- entries: {
23
- server: string;
24
- main: string;
25
- thread: string;
26
- worker: string;
27
- };
28
- };
@@ -1,22 +0,0 @@
1
- import { fileURLToPath } from 'node:url';
2
- const ext = new URL(import.meta.url).pathname.endsWith('.ts') ? '.ts' : '.js';
3
- export const baseViteConfigOptions = {
4
- entrypointMainPath: fileURLToPath(new URL(`../entrypoints/main${ext}`, import.meta.url)),
5
- entrypointWorkerPath: fileURLToPath(new URL(`../entrypoints/worker${ext}`, import.meta.url)),
6
- entrypointThreadPath: fileURLToPath(new URL(`../entrypoints/thread${ext}`, import.meta.url)),
7
- // entrypointCLIPath: fileURLToPath(import.meta.resolve('../entrypoints/cli')),
8
- };
9
- export function createConfig(options) {
10
- const alias = { '#server': options.serverEntryPath };
11
- const entries = {
12
- server: options.serverEntryPath,
13
- main: options.entrypointMainPath,
14
- thread: options.entrypointThreadPath,
15
- worker: options.entrypointWorkerPath,
16
- };
17
- for (const [name, { path }] of Object.entries(options.applicationImports)) {
18
- entries[`application.${name}`] = path;
19
- }
20
- return { alias, entries };
21
- }
22
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/vite/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAexC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;AAE7E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,kBAAkB,EAAE,aAAa,CAC/B,IAAI,GAAG,CAAC,sBAAsB,GAAG,EAAE,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CACtD;IACD,oBAAoB,EAAE,aAAa,CACjC,IAAI,GAAG,CAAC,wBAAwB,GAAG,EAAE,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CACxD;IACD,oBAAoB,EAAE,aAAa,CACjC,IAAI,GAAG,CAAC,wBAAwB,GAAG,EAAE,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CACxD;IACD,+EAA+E;CAC3C,CAAA;AAEtC,MAAM,UAAU,YAAY,CAAC,OAA0B;IACrD,MAAM,KAAK,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,eAAe,EAAE,CAAA;IACpD,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,OAAO,CAAC,eAAe;QAC/B,IAAI,EAAE,OAAO,CAAC,kBAAkB;QAChC,MAAM,EAAE,OAAO,CAAC,oBAAoB;QACpC,MAAM,EAAE,OAAO,CAAC,oBAAoB;KACrC,CAAA;IAED,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC1E,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IACvC,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC3B,CAAC"}
@@ -1,2 +0,0 @@
1
- import type { Plugin } from 'vite';
2
- export declare const plugins: Plugin[];
@@ -1,43 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { readFile } from 'node:fs/promises';
3
- import { basename, dirname, join } from 'node:path';
4
- export const plugins = [
5
- {
6
- name: 'neemata:native-addon',
7
- apply: 'build',
8
- enforce: 'pre',
9
- async load(id) {
10
- if (id.endsWith('.node') && existsSync(id)) {
11
- const refId = this.emitFile({
12
- type: 'asset',
13
- name: basename(id),
14
- source: await readFile(id),
15
- });
16
- const runtimePath = `./${this.getFileName(refId)}`;
17
- return (`const id = ${JSON.stringify(runtimePath)};` +
18
- `export default require(id);`);
19
- }
20
- return null;
21
- },
22
- },
23
- {
24
- name: 'neemata:uws-native-addon',
25
- apply: 'build',
26
- enforce: 'post',
27
- async load(id) {
28
- if (id.includes('uWebSockets.js/uws.js')) {
29
- const uwsNodeAddonPath = join(dirname(id), `uws_${process.platform}_${process.arch}_${process.versions.modules}.node`);
30
- const refId = this.emitFile({
31
- type: 'asset',
32
- name: basename(uwsNodeAddonPath),
33
- source: await readFile(uwsNodeAddonPath),
34
- });
35
- const runtimePath = `./${this.getFileName(refId)}`;
36
- return (`const id = ${JSON.stringify(runtimePath)};` +
37
- `export default require(id);`);
38
- }
39
- return null;
40
- },
41
- },
42
- ];
43
- //# sourceMappingURL=plugins.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/vite/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE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B,CAAC;oBAChC,MAAM,EAAE,MAAM,QAAQ,CAAC,gBAAgB,CAAC;iBACzC,CAAC,CAAA;gBACF,MAAM,WAAW,GAAG,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAA;gBAClD,OAAO,CACL,cAAc,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG;oBAC5C,6BAA6B,CAC9B,CAAA;YACH,CAAC;YACD,OAAO,IAAI,CAAA;QACb,CAAC;KACF;CACF,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { MessagePort } from 'node:worker_threads';
2
- import { ModuleRunner } from 'vite/module-runner';
3
- export declare function createModuleRunner(vitePort: MessagePort | undefined, mode?: 'development' | 'production', timeoutMs?: number): ModuleRunner;
@@ -1,34 +0,0 @@
1
- import wt, { isMainThread } from 'node:worker_threads';
2
- import { noopFn } from '@nmtjs/common';
3
- import { createNodeImportMeta, ESModulesEvaluator, ModuleRunner, } from 'vite/module-runner';
4
- export function createModuleRunner(vitePort, mode = 'development', timeoutMs = 5000) {
5
- // TODO: bun does not support isInternalThread yet
6
- if (isMainThread || wt.isInternalThread)
7
- throw new Error('Module runner can only be created inside worker threads.');
8
- if (!vitePort) {
9
- throw new Error('Module runner requires a dedicated Vite message port.');
10
- }
11
- const transportTimeout = Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : 5000;
12
- const transport = {
13
- connect({ onMessage, onDisconnection }) {
14
- vitePort.on('message', onMessage);
15
- vitePort.on('close', onDisconnection);
16
- },
17
- send(data) {
18
- vitePort.postMessage(data);
19
- },
20
- disconnect() {
21
- vitePort.close();
22
- },
23
- timeout: transportTimeout,
24
- };
25
- const runner = new ModuleRunner({
26
- transport,
27
- createImportMeta: createNodeImportMeta,
28
- hmr: mode === 'development'
29
- ? { logger: { debug: noopFn, error: console.error } }
30
- : false,
31
- }, new ESModulesEvaluator());
32
- return runner;
33
- }
34
- //# sourceMappingURL=worker.js.map
@@ -1 +0,0 @@
1
- {"version":3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AE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE;YACrD,CAAC,CAAC,KAAK;KACZ,EACD,IAAI,kBAAkB,EAAE,CACzB,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { DevEnvironmentOptions, UserConfig } from 'vite';
2
- import type { ViteConfigOptions } from './config.ts';
3
- export declare function createServer(options: ViteConfigOptions, config: UserConfig, dev?: DevEnvironmentOptions): Promise<import("vite").ViteDevServer>;
@@ -1,36 +0,0 @@
1
- import { createServer as createViteServer } from 'vite';
2
- // Packages that must NOT be externalized to prevent module duplication.
3
- // When externalized, Vite's ModuleRunner uses native Node import() which has
4
- // a separate module cache from Vite's cache, causing the same module to be
5
- // loaded twice with different object references.
6
- const noExternalPackages = ['nmtjs', /^@nmtjs\/(?!prom-client$)/];
7
- export function createServer(options, config, dev = {}) {
8
- const usePolling = !!process.env.CI;
9
- return createViteServer({
10
- ...config,
11
- server: {
12
- middlewareMode: true,
13
- ws: false,
14
- watch: usePolling ? { usePolling: true } : undefined,
15
- },
16
- resolve: { tsconfigPaths: true, ...config.resolve },
17
- environments: {
18
- neemata: {
19
- consumer: 'server',
20
- dev,
21
- resolve: {
22
- // Ensure nmtjs packages are not externalized in this environment
23
- noExternal: noExternalPackages,
24
- },
25
- define: {
26
- __VITE_CONFIG__: JSON.stringify(JSON.stringify({ options, mode: config.mode })),
27
- __APPLICATIONS_CONFIG__: JSON.stringify(JSON.stringify(Object.fromEntries(Object.entries(options.applicationImports).map(([appName, { path, type }]) => [
28
- appName,
29
- { specifier: path, type },
30
- ])))),
31
- },
32
- },
33
- },
34
- });
35
- }
36
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAA;AAIv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C"}
@@ -1,8 +0,0 @@
1
- import type { ViteDevServer } from 'vite';
2
- import type { ModuleRunner } from 'vite/module-runner';
3
- import type { NeemataConfig } from '../../config.ts';
4
- import type { ViteConfigOptions } from '../config.ts';
5
- export declare function createMainServer(options: ViteConfigOptions, mode: 'development' | 'production', { vite }: NeemataConfig): Promise<{
6
- server: ViteDevServer;
7
- runner: ModuleRunner;
8
- }>;
@@ -1,24 +0,0 @@
1
- import { noopFn } from '@nmtjs/common';
2
- import { createServerModuleRunner, mergeConfig } from 'vite';
3
- import { createConfig } from '../config.js';
4
- import { plugins } from '../plugins.js';
5
- import { createServer } from '../server.js';
6
- export async function createMainServer(options, mode, { vite }) {
7
- const config = createConfig(options);
8
- const server = await createServer(options, mergeConfig({
9
- appType: 'custom',
10
- clearScreen: false,
11
- resolve: { alias: config.alias, external: ['@nmtjs/proxy'] },
12
- mode,
13
- plugins: [...plugins],
14
- optimizeDeps: { noDiscovery: true },
15
- }, vite));
16
- const environment = server.environments.neemata;
17
- const runner = createServerModuleRunner(environment, {
18
- hmr: mode === 'development'
19
- ? { logger: { debug: noopFn, error: console.error } }
20
- : false,
21
- });
22
- return { server, runner };
23
- }
24
- //# sourceMappingURL=main.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/vite/servers/main.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAI5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAA0B,EAC1B,IAAkC,EAClC,EAAE,IAAI,EAAiB;IAEvB,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,MAAM,YAAY,CAC/B,OAAO,EACP,WAAW,CACT;QACE,OAAO,EAAE,QAAQ;QACjB,WAAW,EAAE,KAAK;QAClB,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,cAAc,CAAC,EAAE;QAC5D,IAAI;QACJ,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;QACrB,YAAY,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;KACf,EACtB,IAAI,CACL,CACF,CAAA;IACD,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAA;IAE/C,MAAM,MAAM,GAAG,wBAAwB,CAAC,WAAW,EAAE;QACnD,GAAG,EACD,IAAI,KAAK,aAAa;YACpB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE;YACrD,CAAC,CAAC,KAAK;KACZ,CAAC,CAAA;IACF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AAC3B,CAAC"}
@@ -1,13 +0,0 @@
1
- import type EventEmitter from 'node:events';
2
- import type { ViteDevServer } from 'vite';
3
- import type { NeemataConfig } from '../../config.ts';
4
- import type { WorkerRegistration } from '../../runtime/server/types.ts';
5
- import type { ViteConfigOptions } from '../config.ts';
6
- export type WorkerServerEventMap = {
7
- worker: [WorkerRegistration];
8
- /** Emitted when an HMR update occurs for an application file (useful for restarting dead workers) */
9
- 'hmr-update': [{
10
- file: string;
11
- }];
12
- };
13
- export declare function createViteServer(options: ViteConfigOptions, mode: 'development' | 'production', neemataConfig: NeemataConfig, events: EventEmitter<WorkerServerEventMap>): Promise<ViteDevServer>;