@tokamakdev/tok 0.1.1-beta.112 → 0.1.1-beta.114

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.
@@ -16,6 +16,7 @@ export declare class DevWorker {
16
16
  dispatch(name: string, event: Uint8Array): Promise<Uint8Array>;
17
17
  fetch(request: IncomingMessage, signal: AbortSignal): Promise<WorkerResponse>;
18
18
  couple(socket: WebSocket, pair: WorkerSocket): Promise<void>;
19
+ /** Disposes the runtime; later deliveries reject rather than start another. */
19
20
  dispose(): Promise<void>;
20
21
  }
21
22
  export {};
@@ -17,6 +17,7 @@ const CALLER = `export default {
17
17
  export class DevWorker {
18
18
  name;
19
19
  #session;
20
+ #disposed = false;
20
21
  constructor(name) {
21
22
  this.name = name;
22
23
  }
@@ -52,10 +53,14 @@ export class DevWorker {
52
53
  const { module } = await this.#connect();
53
54
  await module.coupleWebSocket(socket, pair);
54
55
  }
56
+ /** Disposes the runtime; later deliveries reject rather than start another. */
55
57
  async dispose() {
58
+ this.#disposed = true;
56
59
  await (await this.#session?.catch(() => undefined))?.runtime.dispose();
57
60
  }
58
61
  #connect() {
62
+ if (this.#disposed)
63
+ return Promise.reject(new Error("the development server has closed"));
59
64
  return this.#session ??= this.#start().catch((error) => {
60
65
  this.#session = undefined;
61
66
  throw error;
@@ -125,16 +125,17 @@ export const TokamakEvents = eventEntrypoint(Worker, nativeContext);\n`);
125
125
  configEnvironment: {
126
126
  order: "post",
127
127
  handler(name, config) {
128
- const scanned = [config.optimizeDeps?.entries ?? []].flat();
129
- const served = [
130
- scanned.includes(serviceModule("main")) && contracts.mainEntry,
131
- scanned.includes(serviceModule("native")) && entry,
132
- ].filter(module => typeof module === "string").map(normalizePath);
128
+ const served = new Map([[serviceModule("main"), contracts.mainEntry], [serviceModule("native"), entry]]);
129
+ const entries = [config.optimizeDeps?.entries ?? []].flat()
130
+ .map(scanned => served.get(scanned))
131
+ .filter(module => module !== undefined)
132
+ .map(normalizePath);
133
133
  // The main Worker's entry is the app, not a dependency, and the
134
134
  // plugin SDK keeps state that a dependency bundle would copy.
135
- const exclude = [contracts.mainEntry, name === "tokamak" && "@tokamakdev/plugin"]
136
- .filter(module => typeof module === "string");
137
- return { optimizeDeps: { entries: served, exclude } };
135
+ const exclude = contracts.mainEntry ? [contracts.mainEntry] : [];
136
+ if (name === "tokamak")
137
+ exclude.push("@tokamakdev/plugin");
138
+ return { optimizeDeps: { entries, exclude } };
138
139
  },
139
140
  },
140
141
  async buildStart() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokamakdev/tok",
3
- "version": "0.1.1-beta.112",
3
+ "version": "0.1.1-beta.114",
4
4
  "description": "The tokamak CLI, Vite plugin and app API: build native apps from a Cloudflare Workers codebase",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,13 +37,13 @@
37
37
  "scripts": {
38
38
  "build": "tsc",
39
39
  "prepack": "npm run build",
40
- "test": "node --test --test-concurrency=1"
40
+ "test": "node --import ./test-leaks.mjs --test --test-concurrency=1"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=18"
44
44
  },
45
45
  "dependencies": {
46
- "@tokamakdev/plugin": "0.1.0-beta.112",
46
+ "@tokamakdev/plugin": "0.1.0-beta.114",
47
47
  "typescript": "5.9.3",
48
48
  "ws": "^8.22.0"
49
49
  },
@@ -75,17 +75,17 @@
75
75
  "wrangler": "4.147.0"
76
76
  },
77
77
  "optionalDependencies": {
78
- "@tokamakdev/platform-android-arm64": "0.1.1-beta.112",
79
- "@tokamakdev/platform-ios-arm64": "0.1.1-beta.112",
80
- "@tokamakdev/platform-ios-simulator-arm64": "0.1.1-beta.112",
81
- "@tokamakdev/platform-ios-simulator-x64": "0.1.1-beta.112",
82
- "@tokamakdev/platform-macos-arm64": "0.1.1-beta.112",
83
- "@tokamakdev/platform-macos-x64": "0.1.1-beta.112",
84
- "@tokamakdev/platform-windows-x64": "0.1.1-beta.112",
85
- "@tokamakdev/tok-darwin-arm64": "0.1.1-beta.112",
86
- "@tokamakdev/tok-darwin-x64": "0.1.1-beta.112",
87
- "@tokamakdev/tok-linux-x64": "0.1.1-beta.112",
88
- "@tokamakdev/tok-win32-x64": "0.1.1-beta.112"
78
+ "@tokamakdev/platform-android-arm64": "0.1.1-beta.114",
79
+ "@tokamakdev/platform-ios-arm64": "0.1.1-beta.114",
80
+ "@tokamakdev/platform-ios-simulator-arm64": "0.1.1-beta.114",
81
+ "@tokamakdev/platform-ios-simulator-x64": "0.1.1-beta.114",
82
+ "@tokamakdev/platform-macos-arm64": "0.1.1-beta.114",
83
+ "@tokamakdev/platform-macos-x64": "0.1.1-beta.114",
84
+ "@tokamakdev/platform-windows-x64": "0.1.1-beta.114",
85
+ "@tokamakdev/tok-darwin-arm64": "0.1.1-beta.114",
86
+ "@tokamakdev/tok-darwin-x64": "0.1.1-beta.114",
87
+ "@tokamakdev/tok-linux-x64": "0.1.1-beta.114",
88
+ "@tokamakdev/tok-win32-x64": "0.1.1-beta.114"
89
89
  },
90
90
  "publishConfig": {
91
91
  "access": "public"