@sproutboat/runtime 0.9.0 → 0.9.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @sproutboat/runtime
2
2
 
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e0944a4: Provide the native direct-transfer ABI in broker builds so the shared
8
+ uWebSockets patch does not introduce unresolved symbols outside standalone
9
+ mode.
10
+
3
11
  ## 0.9.0
4
12
 
5
13
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutboat/runtime",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
package/src/wrap.ts CHANGED
@@ -175,6 +175,8 @@ export function wrapNativeFetchHandler(
175
175
  appName: string = "app",
176
176
  /** #15 — assets baked into the module for a binary that has no files beside it. */
177
177
  assets?: { manifest: unknown; files: Record<string, string> },
178
+ /** The selected transport determines whether the direct-transfer C ABI is real or stubbed. */
179
+ transport: Transport = "broker",
178
180
  ): string {
179
181
  const neutralised = neutraliseExports(source);
180
182
  if (neutralised === null || !/\bfetch\s*\(/.test(source)) {
@@ -191,9 +193,14 @@ export function wrapNativeFetchHandler(
191
193
  // #15 — and enforces the outbound allowlist itself, with no broker to do it.
192
194
  `globalThis.__sbOutbound = ${JSON.stringify(bindings.outbound)};\n` +
193
195
  (assets ? `globalThis.__sbAssets = ${JSON.stringify(assets)};\n` : "");
194
- // The native transfer hook runs before JavaScript receives its Request, so
195
- // it needs the same default data-directory name as the embedded transport.
196
- const nativeAppName = `Porffor.c\`const char* sb_standalone_app_name(void) { return ${JSON.stringify(appName)}; }\`;\n`;
196
+ // The native transfer hook runs before JavaScript receives its Request. It
197
+ // has a real file-backed implementation only in embedded builds. The broker
198
+ // transport supplies ABI-compatible stubs because its separate transfer
199
+ // listener owns these URLs, while the shared uWebSockets patch is global.
200
+ const nativeTransferAbi =
201
+ transport === "embedded"
202
+ ? `Porffor.c\`const char* sb_standalone_app_name(void) { return ${JSON.stringify(appName)}; }\`;\n`
203
+ : "Porffor.c`typedef struct sb_r2_transfer_ctx { int unused; } sb_r2_transfer_ctx; int sb_r2_transfer_open(const char* a, const char* b, size_t c, sb_r2_transfer_ctx** d) { if (d) *d = 0; return 404; } int sb_r2_transfer_write(sb_r2_transfer_ctx* a, const char* b, size_t c) { return 404; } int sb_r2_transfer_finish(sb_r2_transfer_ctx* a) { return 404; } void sb_r2_transfer_abort(sb_r2_transfer_ctx* a) {}`;\n";
197
204
  const wire = hasBindings(bindings)
198
205
  ? `__sbInstallBindings(env, ${JSON.stringify(bindings)});\n`
199
206
  : "";
@@ -208,7 +215,7 @@ export function wrapNativeFetchHandler(
208
215
  : "";
209
216
 
210
217
  return (
211
- `${prelude}\n${nativeAppName}${compat}${env}${wire}` +
218
+ `${prelude}\n${nativeTransferAbi}${compat}${env}${wire}` +
212
219
  `${neutralised}\n` +
213
220
  `${registerDO}${triggers}` +
214
221
  `export default {\n port: ${port},\n fetch(request) { return __sbEntry(__sbHandlers, request); }\n};\n`