@rivetkit/supabase 2.3.10 → 2.3.11-rc.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 (3) hide show
  1. package/dist/mod.js +151 -21
  2. package/dist/mod.mjs +151 -21
  3. package/package.json +3 -3
package/dist/mod.js CHANGED
@@ -508,7 +508,7 @@ function unsupportedFeature(feature) {
508
508
  );
509
509
  }
510
510
 
511
- // ../rivetkit/dist/tsup/chunk-X7XY6NCU.js
511
+ // ../rivetkit/dist/tsup/chunk-XWIXH7JF.js
512
512
  var import_pino = require("pino");
513
513
 
514
514
  // ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
@@ -13181,7 +13181,7 @@ var classic_default = external_exports;
13181
13181
  // ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
13182
13182
  var v4_default = classic_default;
13183
13183
 
13184
- // ../rivetkit/dist/tsup/chunk-X7XY6NCU.js
13184
+ // ../rivetkit/dist/tsup/chunk-XWIXH7JF.js
13185
13185
  var cbor = __toESM(require("cbor-x"), 1);
13186
13186
  var import_invariant = __toESM(require_invariant(), 1);
13187
13187
  var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
@@ -13346,7 +13346,7 @@ function noopNext() {
13346
13346
  }
13347
13347
  var package_default = {
13348
13348
  name: "rivetkit",
13349
- version: "2.3.10",
13349
+ version: "2.3.11-rc.2",
13350
13350
  description: "Lightweight libraries for building stateful actors on edge platforms",
13351
13351
  license: "Apache-2.0",
13352
13352
  keywords: [
@@ -14097,7 +14097,10 @@ function jsonStringifyCompat(input, space) {
14097
14097
  return [JSON_COMPAT_BIGINT, value.toString()];
14098
14098
  }
14099
14099
  if (value instanceof ArrayBuffer) {
14100
- return [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(value)];
14100
+ return [
14101
+ JSON_COMPAT_ARRAY_BUFFER,
14102
+ base64EncodeArrayBuffer(value)
14103
+ ];
14101
14104
  }
14102
14105
  if (value instanceof Uint8Array) {
14103
14106
  return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
@@ -14636,7 +14639,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
14636
14639
  };
14637
14640
  }
14638
14641
 
14639
- // ../rivetkit/dist/tsup/chunk-XSPAARQ5.js
14642
+ // ../rivetkit/dist/tsup/chunk-NLAW2MIM.js
14640
14643
  var config2 = /* @__PURE__ */ Config({});
14641
14644
  function readWorkflowCbor(bc) {
14642
14645
  return readData(bc);
@@ -15509,7 +15512,7 @@ var AsyncMutex = class {
15509
15512
  }
15510
15513
  };
15511
15514
 
15512
- // ../rivetkit/dist/tsup/chunk-Q5H37KNQ.js
15515
+ // ../rivetkit/dist/tsup/chunk-RVJQMOAA.js
15513
15516
  function logger() {
15514
15517
  return getLogger("actor-client");
15515
15518
  }
@@ -15547,7 +15550,7 @@ async function importWebSocket() {
15547
15550
  return webSocketPromise;
15548
15551
  }
15549
15552
 
15550
- // ../rivetkit/dist/tsup/chunk-DPM73GAL.js
15553
+ // ../rivetkit/dist/tsup/chunk-XR2KF2ZA.js
15551
15554
  var import_invariant2 = __toESM(require_invariant(), 1);
15552
15555
 
15553
15556
  // ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
@@ -15725,7 +15728,7 @@ function createVersionedDataHandler(config3) {
15725
15728
  return new VersionedDataHandler(config3);
15726
15729
  }
15727
15730
 
15728
- // ../rivetkit/dist/tsup/chunk-DPM73GAL.js
15731
+ // ../rivetkit/dist/tsup/chunk-XR2KF2ZA.js
15729
15732
  var import_invariant3 = __toESM(require_invariant(), 1);
15730
15733
  var import_invariant4 = __toESM(require_invariant(), 1);
15731
15734
  var PATH_CONNECT = "/connect";
@@ -18209,14 +18212,26 @@ function createQueueSender(senderOptions) {
18209
18212
  send
18210
18213
  };
18211
18214
  }
18215
+ function isUrlLike(value) {
18216
+ return typeof value === "object" && value !== null && typeof value.href === "string" && typeof value.pathname === "string" && typeof value.search === "string";
18217
+ }
18218
+ function isRequestLike(value) {
18219
+ return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.method === "string" && isHeadersLike(value.headers);
18220
+ }
18221
+ function isResponseLike(value) {
18222
+ return typeof value === "object" && value !== null && typeof value.status === "number" && isHeadersLike(value.headers) && typeof value.arrayBuffer === "function";
18223
+ }
18224
+ function isHeadersLike(value) {
18225
+ return typeof value === "object" && value !== null && typeof value.entries === "function";
18226
+ }
18212
18227
  async function rawHttpFetch(driver, target, params, input, init, options = {}) {
18213
18228
  let path2;
18214
18229
  let mergedInit = init || {};
18215
18230
  if (typeof input === "string") {
18216
18231
  path2 = input;
18217
- } else if (input instanceof URL) {
18232
+ } else if (isUrlLike(input)) {
18218
18233
  path2 = input.pathname + input.search;
18219
- } else if (input instanceof Request) {
18234
+ } else if (isRequestLike(input)) {
18220
18235
  const url2 = new URL(input.url);
18221
18236
  path2 = url2.pathname + url2.search;
18222
18237
  const requestHeaders = new Headers(input.headers);
@@ -19312,7 +19327,8 @@ var ActorConnRaw = class {
19312
19327
  );
19313
19328
  }
19314
19329
  });
19315
- this.#keepNodeAliveInterval = setInterval(() => 6e4);
19330
+ this.#keepNodeAliveInterval = setInterval(() => {
19331
+ }, 6e4);
19316
19332
  }
19317
19333
  #clearResolvedActorIdentity() {
19318
19334
  this.#actorId = void 0;
@@ -23971,6 +23987,22 @@ function toNapiSqlBatchStatement(statement) {
23971
23987
  function toNapiBuffer(value) {
23972
23988
  return Buffer.from(value);
23973
23989
  }
23990
+ function toNapiApplication(application) {
23991
+ return async (error46, request) => {
23992
+ if (error46) throw error46;
23993
+ if (!request) {
23994
+ throw new Error("application fetch callback received no request");
23995
+ }
23996
+ const response = await application({
23997
+ ...request,
23998
+ body: new Uint8Array(request.body)
23999
+ });
24000
+ return {
24001
+ ...response,
24002
+ body: toNapiBuffer(response.body)
24003
+ };
24004
+ };
24005
+ }
23974
24006
  function toNapiHttpRequest(request) {
23975
24007
  if (!request) {
23976
24008
  return request;
@@ -24077,12 +24109,25 @@ var NapiCoreRuntime = class {
24077
24109
  );
24078
24110
  }
24079
24111
  async serveListener(registry2, listener, config3) {
24112
+ const application = listener.application ? toNapiApplication(listener.application) : void 0;
24080
24113
  await asNativeRegistry(registry2).serveListener(
24081
24114
  {
24082
24115
  port: listener.port,
24083
24116
  host: listener.host,
24084
24117
  publicDir: listener.publicDir
24085
24118
  },
24119
+ config3,
24120
+ application
24121
+ );
24122
+ }
24123
+ async serveApplicationListener(registry2, listener, config3) {
24124
+ await asNativeRegistry(registry2).serveApplicationListener(
24125
+ {
24126
+ port: listener.port,
24127
+ host: listener.host,
24128
+ publicDir: listener.publicDir
24129
+ },
24130
+ toNapiApplication(listener.application),
24086
24131
  config3
24087
24132
  );
24088
24133
  }
@@ -24738,6 +24783,11 @@ var WasmCoreRuntime = class {
24738
24783
  "registry.listen() is not supported on the wasm runtime; use registry.serve() and mount the handler in your platform's HTTP server instead"
24739
24784
  );
24740
24785
  }
24786
+ async serveApplicationListener(_registry, _listener, _config) {
24787
+ throw new Error(
24788
+ "registry.listen() is not supported on the wasm runtime; use an application-owned HTTP server instead"
24789
+ );
24790
+ }
24741
24791
  createActorFactory(callbacks, config3) {
24742
24792
  return callWasmSync(
24743
24793
  () => asActorFactoryHandle2(
@@ -28575,7 +28625,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
28575
28625
  requestCtx,
28576
28626
  jsRequest
28577
28627
  );
28578
- if (!(response instanceof Response)) {
28628
+ if (!isResponseLike(response)) {
28579
28629
  throw new Error(
28580
28630
  "onRequest handler must return a Response"
28581
28631
  );
@@ -28845,6 +28895,29 @@ function finishShutdownSignal(signal) {
28845
28895
  }
28846
28896
  process.kill(process.pid, signal);
28847
28897
  }
28898
+ function createApplicationFetch(application) {
28899
+ return async (request) => {
28900
+ const method2 = request.method.toUpperCase();
28901
+ const body = method2 === "GET" || method2 === "HEAD" || request.body.length === 0 ? void 0 : Uint8Array.from(request.body).buffer;
28902
+ const response = await application.fetch(
28903
+ new Request(request.url, {
28904
+ method: method2,
28905
+ headers: request.headers,
28906
+ body
28907
+ })
28908
+ );
28909
+ if (!isResponseLike(response)) {
28910
+ throw new TypeError(
28911
+ "registry.listen() application fetch must return a Response"
28912
+ );
28913
+ }
28914
+ return {
28915
+ status: response.status,
28916
+ headers: Object.fromEntries(response.headers.entries()),
28917
+ body: new Uint8Array(await response.arrayBuffer())
28918
+ };
28919
+ };
28920
+ }
28848
28921
  var Registry = class {
28849
28922
  #config;
28850
28923
  #buildConfiguredRegistry;
@@ -28860,6 +28933,7 @@ var Registry = class {
28860
28933
  #runtimeReadyPromise;
28861
28934
  #runtimeServeConfiguredPromise;
28862
28935
  #runtimeServerlessPromise;
28936
+ #applicationListenerPromise;
28863
28937
  #configureServerlessPoolPromise;
28864
28938
  #welcomePrinted = false;
28865
28939
  #shutdownInstalled = false;
@@ -29085,17 +29159,63 @@ var Registry = class {
29085
29159
  * @param opts.host Address to bind. Defaults to `0.0.0.0`.
29086
29160
  * @param opts.publicDir If set, serves static files from this directory
29087
29161
  * as a fallback below the framework routes.
29162
+ * @param opts.application If set, handles requests that do not match a
29163
+ * framework route.
29088
29164
  *
29089
29165
  * @example
29090
29166
  * ```ts
29091
29167
  * await registry.listen();
29092
- * await registry.listen({ port: 8080, publicDir: "./public" });
29168
+ * await registry.listen({ application: app });
29093
29169
  * ```
29094
29170
  */
29095
29171
  async listen(opts = {}) {
29096
29172
  const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3e3;
29097
29173
  const publicDir = opts.publicDir ?? getRivetkitPublicDir();
29098
29174
  const config3 = this.parseConfig();
29175
+ const application = opts.application ? createApplicationFetch(opts.application) : void 0;
29176
+ if (application && getRivetkitRuntimeMode() !== "serverless") {
29177
+ if (config3.runtime === "wasm") {
29178
+ throw new Error(
29179
+ "registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
29180
+ );
29181
+ }
29182
+ this.#installSignalHandlers(config3);
29183
+ this.#printWelcome(config3, "serverful", {
29184
+ port,
29185
+ host: opts.host,
29186
+ publicDir
29187
+ });
29188
+ this.#startEnvoy(config3, true);
29189
+ const readyPromise = this.startAndWait();
29190
+ const configuredRegistryPromise2 = this.#runtimeServeConfiguredPromise;
29191
+ if (!configuredRegistryPromise2) {
29192
+ throw new Error("registry envoy startup did not initialize");
29193
+ }
29194
+ const { runtime: runtime2, registry: registry22, serveConfig: serveConfig2 } = await configuredRegistryPromise2;
29195
+ const listenerPromise = runtime2.serveApplicationListener(
29196
+ registry22,
29197
+ {
29198
+ port,
29199
+ host: opts.host,
29200
+ publicDir,
29201
+ application
29202
+ },
29203
+ serveConfig2
29204
+ );
29205
+ this.#applicationListenerPromise = listenerPromise;
29206
+ const serveLifecyclePromise = this.#runtimeServeLifecyclePromise;
29207
+ if (!serveLifecyclePromise) {
29208
+ throw new Error(
29209
+ "registry envoy serve lifecycle did not initialize"
29210
+ );
29211
+ }
29212
+ await Promise.all([
29213
+ readyPromise,
29214
+ listenerPromise,
29215
+ serveLifecyclePromise
29216
+ ]);
29217
+ return;
29218
+ }
29099
29219
  const configuredRegistryPromise = buildConfiguredRegistry(config3);
29100
29220
  this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
29101
29221
  this.#runtimeServerlessPromise = configuredRegistryPromise;
@@ -29109,7 +29229,12 @@ var Registry = class {
29109
29229
  const { runtime, registry: registry2, serveConfig } = await configuredRegistryPromise;
29110
29230
  await runtime.serveListener(
29111
29231
  registry2,
29112
- { port, host: opts.host, publicDir },
29232
+ {
29233
+ port,
29234
+ host: opts.host,
29235
+ publicDir,
29236
+ application
29237
+ },
29113
29238
  serveConfig
29114
29239
  );
29115
29240
  }
@@ -29209,11 +29334,9 @@ var Registry = class {
29209
29334
  await runtime.serveRegistry(registry2, serveConfig);
29210
29335
  }
29211
29336
  );
29212
- this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch(
29213
- (error46) => {
29214
- logger22().warn({ error: error46 }, "runtime registry serve errored");
29215
- }
29216
- );
29337
+ this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch((error46) => {
29338
+ logger22().warn({ error: error46 }, "runtime registry serve errored");
29339
+ });
29217
29340
  this.#installSignalHandlers(config3);
29218
29341
  }
29219
29342
  if (printWelcome) {
@@ -29320,6 +29443,9 @@ var Registry = class {
29320
29443
  if (runtimeServePromise !== void 0) {
29321
29444
  await runtimeServePromise.catch(() => void 0);
29322
29445
  }
29446
+ if (this.#applicationListenerPromise !== void 0) {
29447
+ await this.#applicationListenerPromise.catch(() => void 0);
29448
+ }
29323
29449
  };
29324
29450
  await Promise.race([
29325
29451
  drain(),
@@ -29370,7 +29496,9 @@ var Registry = class {
29370
29496
  startAndWait() {
29371
29497
  if (this.#shutdownInFlight !== null) {
29372
29498
  return Promise.reject(
29373
- new Error("registry.startAndWait() cannot run after shutdown has begun")
29499
+ new Error(
29500
+ "registry.startAndWait() cannot run after shutdown has begun"
29501
+ )
29374
29502
  );
29375
29503
  }
29376
29504
  if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
@@ -29411,7 +29539,9 @@ var Registry = class {
29411
29539
  const readinessPromise = (async () => {
29412
29540
  const { runtime, registry: registry2 } = await configuredRegistryPromise;
29413
29541
  const stoppedBeforeReady = serveLifecyclePromise.then(() => {
29414
- throw new Error("RivetKit registry stopped before becoming ready");
29542
+ throw new Error(
29543
+ "RivetKit registry stopped before becoming ready"
29544
+ );
29415
29545
  });
29416
29546
  await Promise.race([
29417
29547
  runtime.waitRegistryReady(registry2),
package/dist/mod.mjs CHANGED
@@ -471,7 +471,7 @@ function unsupportedFeature(feature) {
471
471
  );
472
472
  }
473
473
 
474
- // ../rivetkit/dist/tsup/chunk-X7XY6NCU.js
474
+ // ../rivetkit/dist/tsup/chunk-XWIXH7JF.js
475
475
  import {
476
476
  pino,
477
477
  stdTimeFunctions
@@ -13147,7 +13147,7 @@ var classic_default = external_exports;
13147
13147
  // ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
13148
13148
  var v4_default = classic_default;
13149
13149
 
13150
- // ../rivetkit/dist/tsup/chunk-X7XY6NCU.js
13150
+ // ../rivetkit/dist/tsup/chunk-XWIXH7JF.js
13151
13151
  var import_invariant = __toESM(require_invariant(), 1);
13152
13152
  import * as cbor from "cbor-x";
13153
13153
  var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
@@ -13312,7 +13312,7 @@ function noopNext() {
13312
13312
  }
13313
13313
  var package_default = {
13314
13314
  name: "rivetkit",
13315
- version: "2.3.10",
13315
+ version: "2.3.11-rc.2",
13316
13316
  description: "Lightweight libraries for building stateful actors on edge platforms",
13317
13317
  license: "Apache-2.0",
13318
13318
  keywords: [
@@ -14063,7 +14063,10 @@ function jsonStringifyCompat(input, space) {
14063
14063
  return [JSON_COMPAT_BIGINT, value.toString()];
14064
14064
  }
14065
14065
  if (value instanceof ArrayBuffer) {
14066
- return [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(value)];
14066
+ return [
14067
+ JSON_COMPAT_ARRAY_BUFFER,
14068
+ base64EncodeArrayBuffer(value)
14069
+ ];
14067
14070
  }
14068
14071
  if (value instanceof Uint8Array) {
14069
14072
  return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
@@ -14602,7 +14605,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
14602
14605
  };
14603
14606
  }
14604
14607
 
14605
- // ../rivetkit/dist/tsup/chunk-XSPAARQ5.js
14608
+ // ../rivetkit/dist/tsup/chunk-NLAW2MIM.js
14606
14609
  var config2 = /* @__PURE__ */ Config({});
14607
14610
  function readWorkflowCbor(bc) {
14608
14611
  return readData(bc);
@@ -15475,7 +15478,7 @@ var AsyncMutex = class {
15475
15478
  }
15476
15479
  };
15477
15480
 
15478
- // ../rivetkit/dist/tsup/chunk-Q5H37KNQ.js
15481
+ // ../rivetkit/dist/tsup/chunk-RVJQMOAA.js
15479
15482
  function logger() {
15480
15483
  return getLogger("actor-client");
15481
15484
  }
@@ -15513,7 +15516,7 @@ async function importWebSocket() {
15513
15516
  return webSocketPromise;
15514
15517
  }
15515
15518
 
15516
- // ../rivetkit/dist/tsup/chunk-DPM73GAL.js
15519
+ // ../rivetkit/dist/tsup/chunk-XR2KF2ZA.js
15517
15520
  var import_invariant2 = __toESM(require_invariant(), 1);
15518
15521
 
15519
15522
  // ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
@@ -15691,7 +15694,7 @@ function createVersionedDataHandler(config3) {
15691
15694
  return new VersionedDataHandler(config3);
15692
15695
  }
15693
15696
 
15694
- // ../rivetkit/dist/tsup/chunk-DPM73GAL.js
15697
+ // ../rivetkit/dist/tsup/chunk-XR2KF2ZA.js
15695
15698
  var import_invariant3 = __toESM(require_invariant(), 1);
15696
15699
  var import_invariant4 = __toESM(require_invariant(), 1);
15697
15700
  var PATH_CONNECT = "/connect";
@@ -18175,14 +18178,26 @@ function createQueueSender(senderOptions) {
18175
18178
  send
18176
18179
  };
18177
18180
  }
18181
+ function isUrlLike(value) {
18182
+ return typeof value === "object" && value !== null && typeof value.href === "string" && typeof value.pathname === "string" && typeof value.search === "string";
18183
+ }
18184
+ function isRequestLike(value) {
18185
+ return typeof value === "object" && value !== null && typeof value.url === "string" && typeof value.method === "string" && isHeadersLike(value.headers);
18186
+ }
18187
+ function isResponseLike(value) {
18188
+ return typeof value === "object" && value !== null && typeof value.status === "number" && isHeadersLike(value.headers) && typeof value.arrayBuffer === "function";
18189
+ }
18190
+ function isHeadersLike(value) {
18191
+ return typeof value === "object" && value !== null && typeof value.entries === "function";
18192
+ }
18178
18193
  async function rawHttpFetch(driver, target, params, input, init, options = {}) {
18179
18194
  let path2;
18180
18195
  let mergedInit = init || {};
18181
18196
  if (typeof input === "string") {
18182
18197
  path2 = input;
18183
- } else if (input instanceof URL) {
18198
+ } else if (isUrlLike(input)) {
18184
18199
  path2 = input.pathname + input.search;
18185
- } else if (input instanceof Request) {
18200
+ } else if (isRequestLike(input)) {
18186
18201
  const url2 = new URL(input.url);
18187
18202
  path2 = url2.pathname + url2.search;
18188
18203
  const requestHeaders = new Headers(input.headers);
@@ -19278,7 +19293,8 @@ var ActorConnRaw = class {
19278
19293
  );
19279
19294
  }
19280
19295
  });
19281
- this.#keepNodeAliveInterval = setInterval(() => 6e4);
19296
+ this.#keepNodeAliveInterval = setInterval(() => {
19297
+ }, 6e4);
19282
19298
  }
19283
19299
  #clearResolvedActorIdentity() {
19284
19300
  this.#actorId = void 0;
@@ -23936,6 +23952,22 @@ function toNapiSqlBatchStatement(statement) {
23936
23952
  function toNapiBuffer(value) {
23937
23953
  return Buffer.from(value);
23938
23954
  }
23955
+ function toNapiApplication(application) {
23956
+ return async (error46, request) => {
23957
+ if (error46) throw error46;
23958
+ if (!request) {
23959
+ throw new Error("application fetch callback received no request");
23960
+ }
23961
+ const response = await application({
23962
+ ...request,
23963
+ body: new Uint8Array(request.body)
23964
+ });
23965
+ return {
23966
+ ...response,
23967
+ body: toNapiBuffer(response.body)
23968
+ };
23969
+ };
23970
+ }
23939
23971
  function toNapiHttpRequest(request) {
23940
23972
  if (!request) {
23941
23973
  return request;
@@ -24042,12 +24074,25 @@ var NapiCoreRuntime = class {
24042
24074
  );
24043
24075
  }
24044
24076
  async serveListener(registry2, listener, config3) {
24077
+ const application = listener.application ? toNapiApplication(listener.application) : void 0;
24045
24078
  await asNativeRegistry(registry2).serveListener(
24046
24079
  {
24047
24080
  port: listener.port,
24048
24081
  host: listener.host,
24049
24082
  publicDir: listener.publicDir
24050
24083
  },
24084
+ config3,
24085
+ application
24086
+ );
24087
+ }
24088
+ async serveApplicationListener(registry2, listener, config3) {
24089
+ await asNativeRegistry(registry2).serveApplicationListener(
24090
+ {
24091
+ port: listener.port,
24092
+ host: listener.host,
24093
+ publicDir: listener.publicDir
24094
+ },
24095
+ toNapiApplication(listener.application),
24051
24096
  config3
24052
24097
  );
24053
24098
  }
@@ -24703,6 +24748,11 @@ var WasmCoreRuntime = class {
24703
24748
  "registry.listen() is not supported on the wasm runtime; use registry.serve() and mount the handler in your platform's HTTP server instead"
24704
24749
  );
24705
24750
  }
24751
+ async serveApplicationListener(_registry, _listener, _config) {
24752
+ throw new Error(
24753
+ "registry.listen() is not supported on the wasm runtime; use an application-owned HTTP server instead"
24754
+ );
24755
+ }
24706
24756
  createActorFactory(callbacks, config3) {
24707
24757
  return callWasmSync(
24708
24758
  () => asActorFactoryHandle2(
@@ -28540,7 +28590,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
28540
28590
  requestCtx,
28541
28591
  jsRequest
28542
28592
  );
28543
- if (!(response instanceof Response)) {
28593
+ if (!isResponseLike(response)) {
28544
28594
  throw new Error(
28545
28595
  "onRequest handler must return a Response"
28546
28596
  );
@@ -28810,6 +28860,29 @@ function finishShutdownSignal(signal) {
28810
28860
  }
28811
28861
  process.kill(process.pid, signal);
28812
28862
  }
28863
+ function createApplicationFetch(application) {
28864
+ return async (request) => {
28865
+ const method2 = request.method.toUpperCase();
28866
+ const body = method2 === "GET" || method2 === "HEAD" || request.body.length === 0 ? void 0 : Uint8Array.from(request.body).buffer;
28867
+ const response = await application.fetch(
28868
+ new Request(request.url, {
28869
+ method: method2,
28870
+ headers: request.headers,
28871
+ body
28872
+ })
28873
+ );
28874
+ if (!isResponseLike(response)) {
28875
+ throw new TypeError(
28876
+ "registry.listen() application fetch must return a Response"
28877
+ );
28878
+ }
28879
+ return {
28880
+ status: response.status,
28881
+ headers: Object.fromEntries(response.headers.entries()),
28882
+ body: new Uint8Array(await response.arrayBuffer())
28883
+ };
28884
+ };
28885
+ }
28813
28886
  var Registry = class {
28814
28887
  #config;
28815
28888
  #buildConfiguredRegistry;
@@ -28825,6 +28898,7 @@ var Registry = class {
28825
28898
  #runtimeReadyPromise;
28826
28899
  #runtimeServeConfiguredPromise;
28827
28900
  #runtimeServerlessPromise;
28901
+ #applicationListenerPromise;
28828
28902
  #configureServerlessPoolPromise;
28829
28903
  #welcomePrinted = false;
28830
28904
  #shutdownInstalled = false;
@@ -29050,17 +29124,63 @@ var Registry = class {
29050
29124
  * @param opts.host Address to bind. Defaults to `0.0.0.0`.
29051
29125
  * @param opts.publicDir If set, serves static files from this directory
29052
29126
  * as a fallback below the framework routes.
29127
+ * @param opts.application If set, handles requests that do not match a
29128
+ * framework route.
29053
29129
  *
29054
29130
  * @example
29055
29131
  * ```ts
29056
29132
  * await registry.listen();
29057
- * await registry.listen({ port: 8080, publicDir: "./public" });
29133
+ * await registry.listen({ application: app });
29058
29134
  * ```
29059
29135
  */
29060
29136
  async listen(opts = {}) {
29061
29137
  const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3e3;
29062
29138
  const publicDir = opts.publicDir ?? getRivetkitPublicDir();
29063
29139
  const config3 = this.parseConfig();
29140
+ const application = opts.application ? createApplicationFetch(opts.application) : void 0;
29141
+ if (application && getRivetkitRuntimeMode() !== "serverless") {
29142
+ if (config3.runtime === "wasm") {
29143
+ throw new Error(
29144
+ "registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
29145
+ );
29146
+ }
29147
+ this.#installSignalHandlers(config3);
29148
+ this.#printWelcome(config3, "serverful", {
29149
+ port,
29150
+ host: opts.host,
29151
+ publicDir
29152
+ });
29153
+ this.#startEnvoy(config3, true);
29154
+ const readyPromise = this.startAndWait();
29155
+ const configuredRegistryPromise2 = this.#runtimeServeConfiguredPromise;
29156
+ if (!configuredRegistryPromise2) {
29157
+ throw new Error("registry envoy startup did not initialize");
29158
+ }
29159
+ const { runtime: runtime2, registry: registry22, serveConfig: serveConfig2 } = await configuredRegistryPromise2;
29160
+ const listenerPromise = runtime2.serveApplicationListener(
29161
+ registry22,
29162
+ {
29163
+ port,
29164
+ host: opts.host,
29165
+ publicDir,
29166
+ application
29167
+ },
29168
+ serveConfig2
29169
+ );
29170
+ this.#applicationListenerPromise = listenerPromise;
29171
+ const serveLifecyclePromise = this.#runtimeServeLifecyclePromise;
29172
+ if (!serveLifecyclePromise) {
29173
+ throw new Error(
29174
+ "registry envoy serve lifecycle did not initialize"
29175
+ );
29176
+ }
29177
+ await Promise.all([
29178
+ readyPromise,
29179
+ listenerPromise,
29180
+ serveLifecyclePromise
29181
+ ]);
29182
+ return;
29183
+ }
29064
29184
  const configuredRegistryPromise = buildConfiguredRegistry(config3);
29065
29185
  this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
29066
29186
  this.#runtimeServerlessPromise = configuredRegistryPromise;
@@ -29074,7 +29194,12 @@ var Registry = class {
29074
29194
  const { runtime, registry: registry2, serveConfig } = await configuredRegistryPromise;
29075
29195
  await runtime.serveListener(
29076
29196
  registry2,
29077
- { port, host: opts.host, publicDir },
29197
+ {
29198
+ port,
29199
+ host: opts.host,
29200
+ publicDir,
29201
+ application
29202
+ },
29078
29203
  serveConfig
29079
29204
  );
29080
29205
  }
@@ -29174,11 +29299,9 @@ var Registry = class {
29174
29299
  await runtime.serveRegistry(registry2, serveConfig);
29175
29300
  }
29176
29301
  );
29177
- this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch(
29178
- (error46) => {
29179
- logger22().warn({ error: error46 }, "runtime registry serve errored");
29180
- }
29181
- );
29302
+ this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch((error46) => {
29303
+ logger22().warn({ error: error46 }, "runtime registry serve errored");
29304
+ });
29182
29305
  this.#installSignalHandlers(config3);
29183
29306
  }
29184
29307
  if (printWelcome) {
@@ -29285,6 +29408,9 @@ var Registry = class {
29285
29408
  if (runtimeServePromise !== void 0) {
29286
29409
  await runtimeServePromise.catch(() => void 0);
29287
29410
  }
29411
+ if (this.#applicationListenerPromise !== void 0) {
29412
+ await this.#applicationListenerPromise.catch(() => void 0);
29413
+ }
29288
29414
  };
29289
29415
  await Promise.race([
29290
29416
  drain(),
@@ -29335,7 +29461,9 @@ var Registry = class {
29335
29461
  startAndWait() {
29336
29462
  if (this.#shutdownInFlight !== null) {
29337
29463
  return Promise.reject(
29338
- new Error("registry.startAndWait() cannot run after shutdown has begun")
29464
+ new Error(
29465
+ "registry.startAndWait() cannot run after shutdown has begun"
29466
+ )
29339
29467
  );
29340
29468
  }
29341
29469
  if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
@@ -29376,7 +29504,9 @@ var Registry = class {
29376
29504
  const readinessPromise = (async () => {
29377
29505
  const { runtime, registry: registry2 } = await configuredRegistryPromise;
29378
29506
  const stoppedBeforeReady = serveLifecyclePromise.then(() => {
29379
- throw new Error("RivetKit registry stopped before becoming ready");
29507
+ throw new Error(
29508
+ "RivetKit registry stopped before becoming ready"
29509
+ );
29380
29510
  });
29381
29511
  await Promise.race([
29382
29512
  runtime.waitRegistryReady(registry2),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivetkit/supabase",
3
- "version": "2.3.10",
3
+ "version": "2.3.11-rc.2",
4
4
  "description": "Supabase Edge Functions integration for RivetKit actors",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -39,14 +39,14 @@
39
39
  "check-edge-closure": "node ../../../scripts/ci/check-edge-native-closure.mjs"
40
40
  },
41
41
  "dependencies": {
42
- "@rivetkit/rivetkit-wasm": "2.3.10",
42
+ "@rivetkit/rivetkit-wasm": "2.3.11-rc.2",
43
43
  "cbor-x": "^1.6.0",
44
44
  "pino": "^9.5.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@size-limit/file": "^11.1.6",
48
48
  "@types/node": "^22.0.0",
49
- "rivetkit": "2.3.10",
49
+ "rivetkit": "2.3.11-rc.2",
50
50
  "size-limit": "^11.1.6",
51
51
  "tsup": "^8.4.0",
52
52
  "typescript": "^5.5.2"