@seanhogg/builderforce-webcontainers 2026.10.2 → 2026.10.4

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 (93) hide show
  1. package/README.md +6 -1
  2. package/dist/assets.d.ts +2 -0
  3. package/dist/assets.js +4 -2
  4. package/dist/check/cachedFetch.d.ts +3 -0
  5. package/dist/check/cachedFetch.d.ts.map +1 -0
  6. package/dist/check/cachedFetch.js +39 -0
  7. package/dist/check/cachedFetch.js.map +1 -0
  8. package/dist/check/index.d.ts +41 -0
  9. package/dist/check/index.d.ts.map +1 -0
  10. package/dist/check/index.js +74 -0
  11. package/dist/check/index.js.map +1 -0
  12. package/dist/check/protocol.d.ts +29 -0
  13. package/dist/check/protocol.d.ts.map +1 -0
  14. package/dist/check/protocol.js +13 -0
  15. package/dist/check/protocol.js.map +1 -0
  16. package/dist/check/worker.js +20 -0
  17. package/dist/componentCompilers.d.ts +21 -0
  18. package/dist/componentCompilers.d.ts.map +1 -0
  19. package/dist/componentCompilers.js +35 -0
  20. package/dist/componentCompilers.js.map +1 -0
  21. package/dist/esbuildWasm.d.ts +10 -4
  22. package/dist/esbuildWasm.d.ts.map +1 -1
  23. package/dist/esbuildWasm.js +14 -6
  24. package/dist/esbuildWasm.js.map +1 -1
  25. package/dist/host.d.ts +39 -3
  26. package/dist/host.d.ts.map +1 -1
  27. package/dist/host.js +22 -7
  28. package/dist/host.js.map +1 -1
  29. package/dist/index.d.ts +9 -4
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +5 -2
  32. package/dist/index.js.map +1 -1
  33. package/dist/node/index.d.ts +42 -0
  34. package/dist/node/index.d.ts.map +1 -0
  35. package/dist/node/index.js +45 -0
  36. package/dist/node/index.js.map +1 -0
  37. package/dist/node/processHost.d.ts +65 -0
  38. package/dist/node/processHost.d.ts.map +1 -0
  39. package/dist/node/processHost.js +269 -0
  40. package/dist/node/processHost.js.map +1 -0
  41. package/dist/node/protocol.d.ts +139 -0
  42. package/dist/node/protocol.d.ts.map +1 -0
  43. package/dist/node/protocol.js +5 -0
  44. package/dist/node/protocol.js.map +1 -0
  45. package/dist/node/worker.js +197 -0
  46. package/dist/node/workerProcess.d.ts +22 -0
  47. package/dist/node/workerProcess.d.ts.map +1 -0
  48. package/dist/node/workerProcess.js +210 -0
  49. package/dist/node/workerProcess.js.map +1 -0
  50. package/dist/packageCache.d.ts +12 -0
  51. package/dist/packageCache.d.ts.map +1 -0
  52. package/dist/packageCache.js +28 -0
  53. package/dist/packageCache.js.map +1 -0
  54. package/dist/process-worker.js +197 -0
  55. package/dist/protocol.d.ts +9 -0
  56. package/dist/protocol.d.ts.map +1 -1
  57. package/dist/protocol.js +7 -0
  58. package/dist/protocol.js.map +1 -1
  59. package/dist/relay.html +1 -1
  60. package/dist/relayWorker.d.ts +19 -0
  61. package/dist/relayWorker.d.ts.map +1 -0
  62. package/dist/relayWorker.js +39 -0
  63. package/dist/relayWorker.js.map +1 -0
  64. package/dist/sw.js +1 -1
  65. package/dist/swRouter.d.ts +9 -1
  66. package/dist/swRouter.d.ts.map +1 -1
  67. package/dist/swRouter.js +26 -4
  68. package/dist/swRouter.js.map +1 -1
  69. package/dist/transport.d.ts +7 -0
  70. package/dist/transport.d.ts.map +1 -1
  71. package/dist/transport.js +7 -1
  72. package/dist/transport.js.map +1 -1
  73. package/package.json +12 -3
  74. package/src/check/cachedFetch.ts +47 -0
  75. package/src/check/index.ts +98 -0
  76. package/src/check/protocol.ts +34 -0
  77. package/src/check/worker.ts +49 -0
  78. package/src/componentCompilers.ts +66 -0
  79. package/src/esbuildWasm.ts +19 -7
  80. package/src/host.ts +64 -9
  81. package/src/index.ts +17 -4
  82. package/src/node/index.ts +69 -0
  83. package/src/node/processHost.ts +307 -0
  84. package/src/node/protocol.ts +63 -0
  85. package/src/node/worker.ts +46 -0
  86. package/src/node/workerProcess.ts +219 -0
  87. package/src/packageCache.ts +28 -0
  88. package/src/protocol.ts +13 -0
  89. package/src/relay.ts +5 -1
  90. package/src/relayWorker.ts +53 -0
  91. package/src/sw.ts +25 -6
  92. package/src/swRouter.ts +33 -4
  93. package/src/transport.ts +14 -0
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Messages between the page (the process host, which owns the master file
3
+ * system and the port table) and one process Worker. Everything is plain
4
+ * structured-clone data; file contents travel as strings or bytes.
5
+ */
6
+ import type { FileContent, HttpRequestData, HttpResponseData } from '@seanhogg/builderforce-webcontainers-core';
7
+ export type FsOp = {
8
+ op: 'write';
9
+ path: string;
10
+ content: FileContent;
11
+ } | {
12
+ op: 'remove';
13
+ path: string;
14
+ } | {
15
+ op: 'mkdir';
16
+ path: string;
17
+ };
18
+ export interface StartMessage {
19
+ type: 'start';
20
+ pid: number;
21
+ command: string;
22
+ args: string[];
23
+ cwd: string;
24
+ env: Record<string, string>;
25
+ terminal?: {
26
+ cols: number;
27
+ rows: number;
28
+ };
29
+ files: Array<[string, FileContent]>;
30
+ dirs: string[];
31
+ /** Ports already listening anywhere in the runtime (so `listen` can fail fast with EADDRINUSE). */
32
+ ports: number[];
33
+ /** `/__bfwc/<id>/` on the preview origin, for `serverUrl`. */
34
+ previewOrigin: string;
35
+ previewBase: string;
36
+ previewUrl?: string;
37
+ registry?: string;
38
+ /** Use Cache Storage for npm tarballs. */
39
+ packageCache: boolean;
40
+ }
41
+ /** page → worker */
42
+ export type HostToWorker = StartMessage | {
43
+ type: 'stdin';
44
+ data: string | null;
45
+ } | {
46
+ type: 'kill';
47
+ signal: string;
48
+ } | {
49
+ type: 'resize';
50
+ cols: number;
51
+ rows: number;
52
+ } | {
53
+ type: 'fs';
54
+ ops: FsOp[];
55
+ } | {
56
+ type: 'ports';
57
+ open: number[];
58
+ closed: number[];
59
+ } | {
60
+ type: 'child-out';
61
+ childId: number;
62
+ stream: 'stdout' | 'stderr';
63
+ data: string;
64
+ } | {
65
+ type: 'child-exit';
66
+ childId: number;
67
+ code: number;
68
+ } | {
69
+ type: 'child-error';
70
+ childId: number;
71
+ code: string;
72
+ message: string;
73
+ } | {
74
+ type: 'http-request';
75
+ reqId: number;
76
+ port: number;
77
+ request: HttpRequestData;
78
+ } | {
79
+ type: 'loopback-response';
80
+ reqId: number;
81
+ response: HttpResponseData | null;
82
+ };
83
+ /** worker → page */
84
+ export type WorkerToHost = {
85
+ type: 'stdout' | 'stderr';
86
+ data: string;
87
+ } | {
88
+ type: 'exit';
89
+ code: number;
90
+ } | {
91
+ type: 'fs';
92
+ ops: FsOp[];
93
+ } | {
94
+ type: 'spawn';
95
+ childId: number;
96
+ command: string;
97
+ args: string[];
98
+ cwd?: string;
99
+ env?: Record<string, string>;
100
+ terminal?: {
101
+ cols: number;
102
+ rows: number;
103
+ };
104
+ } | {
105
+ type: 'child-stdin';
106
+ childId: number;
107
+ data: string | null;
108
+ } | {
109
+ type: 'child-kill';
110
+ childId: number;
111
+ signal: string;
112
+ } | {
113
+ type: 'child-resize';
114
+ childId: number;
115
+ cols: number;
116
+ rows: number;
117
+ } | {
118
+ type: 'listen';
119
+ port: number;
120
+ } | {
121
+ type: 'unlisten';
122
+ port: number;
123
+ } | {
124
+ type: 'http-response';
125
+ reqId: number;
126
+ response: HttpResponseData;
127
+ } | {
128
+ type: 'loopback';
129
+ reqId: number;
130
+ port: number;
131
+ request: HttpRequestData;
132
+ } | {
133
+ type: 'server-ready';
134
+ port: number;
135
+ url: string;
136
+ };
137
+ /** The preview-relative URL a virtual server on `port` is reachable at. */
138
+ export declare function portPath(previewBase: string, port: number): string;
139
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/node/protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAEhH,MAAM,MAAM,IAAI,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM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ewBase}__port/${port}/`;
4
+ }
5
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/node/protocol.ts"],"names":[],"mappings":"AA2DA,2EAA2E;AAC3E,MAAM,UAAU,QAAQ,CAAC,WAAmB,EAAE,IAAY;IACxD,OAAO,GAAG,WAAW,UAAU,IAAI,GAAG,CAAC;AACzC,CAAC"}