@astrale-os/sdk 0.1.6 → 0.1.8

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 (103) hide show
  1. package/dist/cli/bin.d.ts +7 -0
  2. package/dist/cli/bin.d.ts.map +1 -0
  3. package/dist/cli/bin.js +15 -0
  4. package/dist/cli/bin.js.map +1 -0
  5. package/dist/cli/dotenv.d.ts +13 -0
  6. package/dist/cli/dotenv.d.ts.map +1 -0
  7. package/dist/cli/dotenv.js +46 -0
  8. package/dist/cli/dotenv.js.map +1 -0
  9. package/dist/cli/index.d.ts +15 -0
  10. package/dist/cli/index.d.ts.map +1 -0
  11. package/dist/cli/index.js +15 -0
  12. package/dist/cli/index.js.map +1 -0
  13. package/dist/cli/run.d.ts +84 -0
  14. package/dist/cli/run.d.ts.map +1 -0
  15. package/dist/cli/run.js +603 -0
  16. package/dist/cli/run.js.map +1 -0
  17. package/dist/cli/spec.d.ts +19 -0
  18. package/dist/cli/spec.d.ts.map +1 -0
  19. package/dist/cli/spec.js +31 -0
  20. package/dist/cli/spec.js.map +1 -0
  21. package/dist/config/adapter.d.ts +140 -0
  22. package/dist/config/adapter.d.ts.map +1 -0
  23. package/dist/config/adapter.js +40 -0
  24. package/dist/config/adapter.js.map +1 -0
  25. package/dist/config/define-domain.d.ts +112 -0
  26. package/dist/config/define-domain.d.ts.map +1 -0
  27. package/dist/config/define-domain.js +98 -0
  28. package/dist/config/define-domain.js.map +1 -0
  29. package/dist/config/deploy.d.ts +28 -0
  30. package/dist/config/deploy.d.ts.map +1 -0
  31. package/dist/config/deploy.js +24 -0
  32. package/dist/config/deploy.js.map +1 -0
  33. package/dist/config/index.d.ts +21 -0
  34. package/dist/config/index.d.ts.map +1 -0
  35. package/dist/config/index.js +18 -0
  36. package/dist/config/index.js.map +1 -0
  37. package/dist/define/remote-function.d.ts +19 -11
  38. package/dist/define/remote-function.d.ts.map +1 -1
  39. package/dist/define/remote-function.js.map +1 -1
  40. package/dist/dispatch/call-remote.d.ts +7 -3
  41. package/dist/dispatch/call-remote.d.ts.map +1 -1
  42. package/dist/dispatch/call-remote.js.map +1 -1
  43. package/dist/dispatch/dispatcher.d.ts.map +1 -1
  44. package/dist/dispatch/dispatcher.js +8 -4
  45. package/dist/dispatch/dispatcher.js.map +1 -1
  46. package/dist/dispatch/index.d.ts +1 -1
  47. package/dist/dispatch/index.d.ts.map +1 -1
  48. package/dist/dispatch/index.js.map +1 -1
  49. package/dist/dispatch/self.d.ts +46 -10
  50. package/dist/dispatch/self.d.ts.map +1 -1
  51. package/dist/dispatch/self.js +65 -8
  52. package/dist/dispatch/self.js.map +1 -1
  53. package/dist/domain/define.d.ts +3 -3
  54. package/dist/domain/define.js +3 -3
  55. package/dist/index.d.ts +5 -4
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +8 -2
  58. package/dist/index.js.map +1 -1
  59. package/dist/method/class.d.ts.map +1 -1
  60. package/dist/method/class.js.map +1 -1
  61. package/dist/method/context.d.ts +32 -7
  62. package/dist/method/context.d.ts.map +1 -1
  63. package/dist/method/index.d.ts +1 -1
  64. package/dist/method/index.d.ts.map +1 -1
  65. package/dist/method/single.d.ts +16 -11
  66. package/dist/method/single.d.ts.map +1 -1
  67. package/dist/method/single.js.map +1 -1
  68. package/dist/server/domain-entry.d.ts +67 -0
  69. package/dist/server/domain-entry.d.ts.map +1 -0
  70. package/dist/server/domain-entry.js +58 -0
  71. package/dist/server/domain-entry.js.map +1 -0
  72. package/dist/server/index.d.ts +3 -1
  73. package/dist/server/index.d.ts.map +1 -1
  74. package/dist/server/index.js +2 -1
  75. package/dist/server/index.js.map +1 -1
  76. package/dist/server/worker-entry.d.ts +80 -5
  77. package/dist/server/worker-entry.d.ts.map +1 -1
  78. package/dist/server/worker-entry.js +105 -24
  79. package/dist/server/worker-entry.js.map +1 -1
  80. package/package.json +12 -3
  81. package/src/cli/bin.ts +15 -0
  82. package/src/cli/dotenv.ts +45 -0
  83. package/src/cli/index.ts +15 -0
  84. package/src/cli/run.ts +710 -0
  85. package/src/cli/spec.ts +42 -0
  86. package/src/config/adapter.ts +172 -0
  87. package/src/config/define-domain.ts +218 -0
  88. package/src/config/deploy.ts +35 -0
  89. package/src/config/index.ts +31 -0
  90. package/src/define/remote-function.ts +42 -13
  91. package/src/dispatch/call-remote.ts +7 -2
  92. package/src/dispatch/dispatcher.ts +8 -4
  93. package/src/dispatch/index.ts +1 -1
  94. package/src/dispatch/self.ts +96 -10
  95. package/src/domain/define.ts +3 -3
  96. package/src/index.ts +25 -4
  97. package/src/method/class.ts +4 -3
  98. package/src/method/context.ts +38 -7
  99. package/src/method/index.ts +1 -1
  100. package/src/method/single.ts +30 -11
  101. package/src/server/domain-entry.ts +113 -0
  102. package/src/server/index.ts +3 -1
  103. package/src/server/worker-entry.ts +128 -24
@@ -13,7 +13,7 @@ import type { AuthPolicy, RouteBinding } from '@astrale-os/kernel-api/routed';
13
13
  import type { MethodClassKeys, ClassMethodConfig, NonSealedMethodKeys, OwnMethodKeys } from '@astrale-os/kernel-core/domain';
14
14
  import type { Schema } from '@astrale-os/kernel-dsl';
15
15
  import type { SelfResult } from '../dispatch/self';
16
- import type { RemoteContext } from './context';
16
+ import type { KernelForAuth, RemoteContext } from './context';
17
17
  /**
18
18
  * Remote function handler — execute with full typed context.
19
19
  *
@@ -27,9 +27,9 @@ import type { RemoteContext } from './context';
27
27
  * dispatcher throws — that's a programmer error indicating a stub leaked into
28
28
  * a code path that was supposed to execute it.
29
29
  */
30
- export type RemoteHandler<TParams, TResult, TSelf, TDeps> = {
30
+ export type RemoteHandler<TParams, TResult, TSelf, TDeps, TAuth extends AuthPolicy = 'required'> = {
31
31
  /** The handler body. May be async or an async generator (for `output: 'stream'`). */
32
- execute?: (ctx: RemoteContext<TParams, TSelf, TDeps>) => TResult | Promise<TResult> | AsyncGenerator<TResult>;
32
+ execute?: (ctx: RemoteContext<TParams, TSelf, TDeps, KernelForAuth<TAuth>>) => TResult | Promise<TResult> | AsyncGenerator<TResult>;
33
33
  /**
34
34
  * Optional REST binding — attaches a native HTTP route to this method.
35
35
  * Uses the kernel's canonical `RouteBinding` type directly.
@@ -43,8 +43,13 @@ export type RemoteHandler<TParams, TResult, TSelf, TDeps> = {
43
43
  remoteUrl?: string;
44
44
  /** Optional human-readable description. Appears in generated docs. */
45
45
  description?: string;
46
- /** Authentication policy. Defaults to `'required'` when absent. */
47
- auth?: AuthPolicy;
46
+ /**
47
+ * Authentication policy. Defaults to `'required'` when absent. Captured as a
48
+ * literal type so it drives {@link KernelForAuth} on the `execute`/`authorize`
49
+ * context: omit it (or set `'required'`) and `ctx.kernel` is non-null;
50
+ * `'optional'` widens it to `… | null`; `'public'` makes it `null`.
51
+ */
52
+ auth?: TAuth;
48
53
  /**
49
54
  * Optional pre-execute authorization check. Runs after auth resolution and
50
55
  * `_self` resolution, before `execute`. Throw any error to deny the call —
@@ -59,19 +64,19 @@ export type RemoteHandler<TParams, TResult, TSelf, TDeps> = {
59
64
  * The kernel still enforces `has_perm` independently — `authorize` is
60
65
  * additive ergonomic gating on top, not a replacement.
61
66
  */
62
- authorize?: (ctx: RemoteContext<TParams, TSelf, TDeps>) => void | Promise<void>;
67
+ authorize?: (ctx: RemoteContext<TParams, TSelf, TDeps, KernelForAuth<TAuth>>) => void | Promise<void>;
63
68
  };
64
- export type AnyRemoteHandler = RemoteHandler<any, any, any, any>;
69
+ export type AnyRemoteHandler = RemoteHandler<any, any, any, any, AuthPolicy>;
65
70
  /**
66
71
  * Fully typed method implementation — resolves params/result/self from the
67
72
  * schema, wraps in `RemoteHandler` with deps.
68
73
  */
69
- export type MethodImpl<S extends Schema, K extends MethodClassKeys<S> & string, M extends string, TDeps = unknown> = ClassMethodConfig<S, K, M> extends {
74
+ export type MethodImpl<S extends Schema, K extends MethodClassKeys<S> & string, M extends string, TDeps = unknown, TAuth extends AuthPolicy = 'required'> = ClassMethodConfig<S, K, M> extends {
70
75
  params: infer P;
71
76
  result: infer R;
72
77
  self: unknown;
73
78
  isStatic: infer St;
74
- } ? RemoteHandler<P, R, St extends true ? undefined : SelfResult, TDeps> : never;
79
+ } ? RemoteHandler<P, R, St extends true ? undefined : SelfResult, TDeps, TAuth> : never;
75
80
  type ImplementableMethodName<S extends Schema, K extends MethodClassKeys<S> & string> = (OwnMethodKeys<S, K> | NonSealedMethodKeys<S, K>) & string;
76
81
  /**
77
82
  * Identity helper for authoring one remote method with full schema-driven typing.
@@ -82,7 +87,7 @@ type ImplementableMethodName<S extends Schema, K extends MethodClassKeys<S> & st
82
87
  * - `remoteMethod(schema, className, methodName, impl)` — direct form with
83
88
  * `unknown` deps.
84
89
  */
85
- export declare function remoteMethod<TDeps>(): <S extends Schema, K extends MethodClassKeys<S> & string, M extends ImplementableMethodName<S, K>>(schema: S, className: K, methodName: M, impl: MethodImpl<S, K, M, TDeps>) => MethodImpl<S, K, M, TDeps>;
86
- export declare function remoteMethod<S extends Schema, K extends MethodClassKeys<S> & string, M extends ImplementableMethodName<S, K>>(schema: S, className: K, methodName: M, impl: MethodImpl<S, K, M>): MethodImpl<S, K, M>;
90
+ export declare function remoteMethod<TDeps>(): <S extends Schema, K extends MethodClassKeys<S> & string, M extends ImplementableMethodName<S, K>, TAuth extends AuthPolicy = 'required'>(schema: S, className: K, methodName: M, impl: MethodImpl<S, K, M, TDeps, TAuth>) => MethodImpl<S, K, M, TDeps, TAuth>;
91
+ export declare function remoteMethod<S extends Schema, K extends MethodClassKeys<S> & string, M extends ImplementableMethodName<S, K>, TAuth extends AuthPolicy = 'required'>(schema: S, className: K, methodName: M, impl: MethodImpl<S, K, M, unknown, TAuth>): MethodImpl<S, K, M, unknown, TAuth>;
87
92
  export {};
88
93
  //# sourceMappingURL=single.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../src/method/single.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM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CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KACpC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;AACtC,wBAAgB,YAAY,CAC1B,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,EACrC,CAAC,SAAS,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,EACvC,KAAK,SAAS,UAAU,GAAG,UAAU,EAErC,MAAM,EAAE,CAAC,EACT,SAAS,EAAE,CAAC,EACZ,UAAU,EAAE,CAAC,EACb,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GACxC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"single.js","sourceRoot":"","sources":["../../src/method/single.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAoHH,MAAM,UAAU,YAAY,CAAC,GAAG,IAAe;IAC7C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,SAAoB,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC"}
1
+ {"version":3,"file":"single.js","sourceRoot":"","sources":["../../src/method/single.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAuIH,MAAM,UAAU,YAAY,CAAC,GAAG,IAAe;IAC7C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,SAAoB,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * `domainWorkerEntry` — the one-call worker entry for a standalone domain.
3
+ *
4
+ * It folds the three steps every hand-rolled worker used to wire by hand —
5
+ * compile the runtime domain (`defineRemoteDomain`), build the server
6
+ * (`createRemoteServer`), and wrap it in the shared fetch plumbing
7
+ * (`createWorkerEntry`) — into a single declaration. The author passes the raw
8
+ * modules (`schema` / `methods` / `views` / `functions`) plus the identity and
9
+ * deploy bits; the helper does the rest. This is what the cloudflare adapter's
10
+ * codegen emits, and the recommended surface for a hand-rolled worker.
11
+ *
12
+ * Drop down to `createWorkerEntry` + `defineRemoteDomain` (from
13
+ * `@astrale-os/sdk/domain`) only when the worker needs something this config
14
+ * can't express — e.g. a serving-URL-dependent domain build (views stamped with
15
+ * the live url) or a globally-injected signing key resolved per request.
16
+ */
17
+ import type { Core, Schema } from '@astrale-os/kernel-dsl';
18
+ import type { Hono } from 'hono';
19
+ import type { AnyRemoteFunctionDef, ViewDef } from '../define';
20
+ import type { SchemaMethodsImpl } from '../method';
21
+ import type { RemoteServerConfig } from './config';
22
+ import type { WorkerEntry, WorkerEntryConfig } from './worker-entry';
23
+ export interface DomainWorkerEntryConfig<S extends Schema, TEnv, TDeps> {
24
+ /** The domain schema. */
25
+ schema: S;
26
+ /** Method implementations, typed against `schema` under `TDeps`. */
27
+ methods: SchemaMethodsImpl<S, TDeps>;
28
+ /** Optional Core override (extra genesis nodes / wiring). */
29
+ core?: Core<S>;
30
+ /** Views (iframe-mountable UIs) keyed by slug. */
31
+ views?: Record<string, ViewDef<TDeps>>;
32
+ /** Standalone Functions (callables not bound to a class) keyed by slug. */
33
+ functions?: Record<string, AnyRemoteFunctionDef>;
34
+ /**
35
+ * The worker's signing key (its `iss` identity material). A static JWK, or a
36
+ * resolver from `env` for keys injected as a secret / shared globally.
37
+ */
38
+ privateKey: JsonWebKey | ((env: TEnv) => JsonWebKey);
39
+ /** Cross-domain deps by origin — verified present at install. */
40
+ requires?: readonly string[];
41
+ /** Typed colon-path the kernel calls once as __SYSTEM__ after install. */
42
+ postInstall?: string;
43
+ /** Provenance stamped on `/meta`. */
44
+ meta?: RemoteServerConfig<TDeps>['meta'];
45
+ /**
46
+ * Map the worker `env` to the handler dependency container. Defaults to
47
+ * passing `env` straight through (the common case where handlers read
48
+ * bindings directly).
49
+ */
50
+ deps?: (env: TEnv, url: string) => TDeps;
51
+ /** Optional pre-built host Hono app (CORS / logging / extra routes). */
52
+ app?: (env: TEnv) => Hono;
53
+ resolveUrl?: WorkerEntryConfig<TEnv>['resolveUrl'];
54
+ selfBinding?: WorkerEntryConfig<TEnv>['selfBinding'];
55
+ routeSubrequest?: WorkerEntryConfig<TEnv>['routeSubrequest'];
56
+ before?: WorkerEntryConfig<TEnv>['before'];
57
+ rewriteRequest?: WorkerEntryConfig<TEnv>['rewriteRequest'];
58
+ }
59
+ /**
60
+ * Curried so `TDeps` can be fixed explicitly (it types `methods`/`views`) while
61
+ * `S` is inferred from `schema` — mirroring `defineRemoteDomain`. The common
62
+ * case `domainWorkerEntry<Env>()({ … })` leaves `TDeps = TEnv` (handlers read
63
+ * the env directly); pass both — `domainWorkerEntry<Env, Deps>()` — when the
64
+ * handler deps differ from the worker bindings and a `deps` mapper is supplied.
65
+ */
66
+ export declare function domainWorkerEntry<TEnv, TDeps = TEnv>(): <S extends Schema>(config: DomainWorkerEntryConfig<S, TEnv, TDeps>) => WorkerEntry<TEnv>;
67
+ //# sourceMappingURL=domain-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain-entry.d.ts","sourceRoot":"","sources":["../../src/server/domain-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEhC,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,WAAW,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AiB,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,CAAA;IACpD,eAAe,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,CAAA;IAC5D,MAAM,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC1C,cAAc,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,CAAA;CAC3D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,MACjC,CAAC,SAAS,MAAM,UACvB,uBAAuB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,KAC9C,WAAW,CAAC,IAAI,CAAC,CAiCrB"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * `domainWorkerEntry` — the one-call worker entry for a standalone domain.
3
+ *
4
+ * It folds the three steps every hand-rolled worker used to wire by hand —
5
+ * compile the runtime domain (`defineRemoteDomain`), build the server
6
+ * (`createRemoteServer`), and wrap it in the shared fetch plumbing
7
+ * (`createWorkerEntry`) — into a single declaration. The author passes the raw
8
+ * modules (`schema` / `methods` / `views` / `functions`) plus the identity and
9
+ * deploy bits; the helper does the rest. This is what the cloudflare adapter's
10
+ * codegen emits, and the recommended surface for a hand-rolled worker.
11
+ *
12
+ * Drop down to `createWorkerEntry` + `defineRemoteDomain` (from
13
+ * `@astrale-os/sdk/domain`) only when the worker needs something this config
14
+ * can't express — e.g. a serving-URL-dependent domain build (views stamped with
15
+ * the live url) or a globally-injected signing key resolved per request.
16
+ */
17
+ import { defineRemoteDomain } from '../domain';
18
+ import { createWorkerEntry } from './worker-entry';
19
+ /**
20
+ * Curried so `TDeps` can be fixed explicitly (it types `methods`/`views`) while
21
+ * `S` is inferred from `schema` — mirroring `defineRemoteDomain`. The common
22
+ * case `domainWorkerEntry<Env>()({ … })` leaves `TDeps = TEnv` (handlers read
23
+ * the env directly); pass both — `domainWorkerEntry<Env, Deps>()` — when the
24
+ * handler deps differ from the worker bindings and a `deps` mapper is supplied.
25
+ */
26
+ export function domainWorkerEntry() {
27
+ return function (config) {
28
+ const domain = defineRemoteDomain()({
29
+ schema: config.schema,
30
+ methods: config.methods,
31
+ ...(config.core ? { core: config.core } : {}),
32
+ ...(config.views ? { views: config.views } : {}),
33
+ ...(config.functions ? { remoteFunctions: config.functions } : {}),
34
+ });
35
+ return createWorkerEntry({
36
+ ...(config.resolveUrl ? { resolveUrl: config.resolveUrl } : {}),
37
+ ...(config.selfBinding ? { selfBinding: config.selfBinding } : {}),
38
+ ...(config.routeSubrequest ? { routeSubrequest: config.routeSubrequest } : {}),
39
+ ...(config.before ? { before: config.before } : {}),
40
+ ...(config.rewriteRequest ? { rewriteRequest: config.rewriteRequest } : {}),
41
+ // `createWorkerEntry` conflates the worker env and the handler deps into a
42
+ // single type param; we keep them distinct in the public config and bridge
43
+ // here. The runtime deps (and the methods typed against them) are correct;
44
+ // only this assembly is cast.
45
+ build: (url, env) => ({
46
+ domain,
47
+ deps: config.deps ? config.deps(env, url) : env,
48
+ url,
49
+ privateKey: typeof config.privateKey === 'function' ? config.privateKey(env) : config.privateKey,
50
+ ...(config.requires && config.requires.length > 0 ? { requires: config.requires } : {}),
51
+ ...(config.postInstall ? { postInstall: config.postInstall } : {}),
52
+ ...(config.meta ? { meta: config.meta } : {}),
53
+ ...(config.app ? { app: config.app(env) } : {}),
54
+ }),
55
+ });
56
+ };
57
+ }
58
+ //# sourceMappingURL=domain-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain-entry.js","sourceRoot":"","sources":["../../src/server/domain-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAUH,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AA2ClD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAC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E;YAC3E,8BAA8B;YAC9B,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAClB,CAAC;gBACC,MAAM;gBACN,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAwB;gBACrE,GAAG;gBACH,UAAU,EACR,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU;gBACtF,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvF,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAChD,CAAwC;SAC5C,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
@@ -4,8 +4,10 @@ export type { RemoteServer, RemoteServerHandle } from './handle';
4
4
  export { derivePublicJwk } from './jwks';
5
5
  export { requireEnv } from './require-env';
6
6
  export { canonicalizeServingUrl } from './serving-url';
7
- export { createWorkerEntry } from './worker-entry';
7
+ export { assets, createWorkerEntry } from './worker-entry';
8
8
  export type { WorkerEntry, WorkerEntryConfig } from './worker-entry';
9
+ export { domainWorkerEntry } from './domain-entry';
10
+ export type { DomainWorkerEntryConfig } from './domain-entry';
9
11
  export { workerMeta } from './worker-meta';
10
12
  export { startNodeServer } from './start';
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAC1D,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,YAAY,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA"}
@@ -2,7 +2,8 @@ export { createRemoteServer } from './create';
2
2
  export { derivePublicJwk } from './jwks';
3
3
  export { requireEnv } from './require-env';
4
4
  export { canonicalizeServingUrl } from './serving-url';
5
- export { createWorkerEntry } from './worker-entry';
5
+ export { assets, createWorkerEntry } from './worker-entry';
6
+ export { domainWorkerEntry } from './domain-entry';
6
7
  export { workerMeta } from './worker-meta';
7
8
  export { startNodeServer } from './start';
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA"}
@@ -6,11 +6,13 @@
6
6
  * • resolve the serving URL (== `iss`), canonicalize it (so the value matches
7
7
  * what `createRemoteServer` signs with and the kernel pins), and cache the
8
8
  * built app per distinct URL;
9
- * • optional self-binding routing: when a `SELF` service binding is provided,
10
- * route same-host subrequests (e.g. `ctx.callRemote` back into this domain)
11
- * through it Cloudflare forbids a Worker fetching its own hostname. This is
12
- * the ONLY reason a `globalThis.fetch` override is installed, and only when a
13
- * `selfBinding` is configured;
9
+ * • optional subrequest routing: a `globalThis.fetch` override (installed ONLY
10
+ * when `selfBinding` and/or `routeSubrequest` is configured) redirects
11
+ * certain outbound fetches through a caller-supplied binding `selfBinding`
12
+ * for same-host fetches (a Worker can't fetch its own hostname), and the
13
+ * vendor-neutral `routeSubrequest` for any caller policy (e.g. instance
14
+ * hostnames a same-zone Worker→Worker fetch would 522 on). The SDK names no
15
+ * backend or topology; the caller owns the predicate + the fetcher;
14
16
  * • optional SPA hook (e.g. `/ui/*` served from an `ASSETS` binding).
15
17
  *
16
18
  * The worker's OWN JWKS (`<url>/.well-known/jwks.json`) is served as a normal
@@ -23,6 +25,46 @@ import type { RemoteServerConfig } from './config';
23
25
  type Fetcher = {
24
26
  fetch(request: Request): Response | Promise<Response>;
25
27
  };
28
+ type App = {
29
+ fetch(request: Request): Response | Promise<Response>;
30
+ };
31
+ /** A built app cached by its serving URL: `origin` for same-origin matching,
32
+ * `app` for in-process self-dispatch. */
33
+ type CachedApp = {
34
+ origin: string;
35
+ app: App;
36
+ };
37
+ /**
38
+ * Choose where an OUTBOUND subrequest to `u` is routed — or `null` to let the
39
+ * real `fetch` handle it. Order matters and same-origin wins FIRST: a call to
40
+ * this worker's OWN serving origin is a self-dispatch, not an edge fetch — and
41
+ * the caller's `routeSubrequest` policy may itself match our own host (e.g. an
42
+ * `isInstanceHost` predicate matches every `*.svc.astrale.ai`, ours included),
43
+ * so it must never get first look at a same-origin call.
44
+ *
45
+ * • same-origin + SELF binding present → the SELF fetcher: a fresh same-script
46
+ * invocation. The normal Cloudflare path — a Worker can't fetch its own
47
+ * hostname over the edge, so it re-enters itself through the binding.
48
+ * • same-origin + NO SELF binding → the cached app, dispatched IN-PROCESS. A
49
+ * Workers-for-Platforms dispatch-namespace tenant can't service-bind to
50
+ * itself (its script name is platform-renamed), so it has no SELF binding; an
51
+ * in-process dispatch reaches the same script with no edge hop and no binding.
52
+ * `App` and the SELF `Fetcher` share the `{ fetch(request) }` shape, so the
53
+ * caller drives both identically.
54
+ * • else, the caller's `routeSubrequest` policy matched → its fetcher.
55
+ * • else → `null`: passthrough to the real network fetch.
56
+ *
57
+ * Pure (no closure over instance state) so the routing decision is unit-testable
58
+ * without standing up a real app.
59
+ */
60
+ export declare function selectSubrequestTarget<TDeps>(u: URL, ctx: {
61
+ self: Fetcher | null;
62
+ apps: Iterable<CachedApp>;
63
+ routeEnv: TDeps | null;
64
+ routeSubrequest?: (url: URL, env: TDeps) => Fetcher | null | undefined;
65
+ }): {
66
+ fetch(request: Request): Response | Promise<Response>;
67
+ } | null;
26
68
  export interface WorkerEntryConfig<TDeps> {
27
69
  /**
28
70
  * Build the `createRemoteServer` config for the resolved serving `url`. Called
@@ -43,6 +85,17 @@ export interface WorkerEntryConfig<TDeps> {
43
85
  resolveUrl?: (env: TDeps, requestOrigin: string) => string;
44
86
  /** Optional: the `SELF` service binding used to route same-host subrequests. */
45
87
  selfBinding?: (env: TDeps) => Fetcher | null | undefined;
88
+ /**
89
+ * Optional, vendor-neutral: route an OUTBOUND subrequest through a
90
+ * caller-supplied fetcher instead of the network — for hosts a Worker can't
91
+ * reach directly over the edge (e.g. a platform router on the SAME zone:
92
+ * Cloudflare 522s a same-zone Worker→Worker public `fetch`). Return a `Fetcher`
93
+ * to route the request through, or null/undefined to fall through to the normal
94
+ * fetch. The SDK names no backend or topology — the CALLER owns BOTH the
95
+ * predicate (which hosts) and the fetcher (the binding). This generalizes
96
+ * `selfBinding` (same-origin → SELF) to any caller policy; both are honored.
97
+ */
98
+ routeSubrequest?: (url: URL, env: TDeps) => Fetcher | null | undefined;
46
99
  /**
47
100
  * Optional: handle a request before it reaches the kernel app — e.g. serve a
48
101
  * SPA under `/ui/*` or a same-origin `/api/*` endpoint the view calls. Return
@@ -72,6 +125,28 @@ export interface WorkerEntry<TDeps> {
72
125
  * fails — it can never make this worker speak for another origin.
73
126
  */
74
127
  export declare function clientOrigin(url: URL, request: Request): string;
128
+ /**
129
+ * Build a `before` hook that serves a static-asset `binding` (e.g. a Workers
130
+ * Assets binding) mounted under `base` (default `/ui`) — the runtime half of a
131
+ * domain's `client` binding. Returns `undefined` for non-matching paths (and
132
+ * when no binding is present) so the request falls through to domain dispatch.
133
+ *
134
+ * Asset URLs are rooted at `base` (a client bundler sets `base: '<base>/'`);
135
+ * this hook strips that prefix before delegating to the binding, so
136
+ * `<base>/x.js` resolves from the binding's root. When `devProxy` yields a URL
137
+ * (local dev), requests are proxied there instead — the seam for a bundler's
138
+ * HMR dev server. Whether unknown sub-paths fall back to `index.html` is the
139
+ * binding's own concern (e.g. wrangler's `not_found_handling`), not baked in
140
+ * here.
141
+ *
142
+ * Lives here, type-checked and testable, instead of being emitted as a string
143
+ * by every adapter's worker codegen.
144
+ */
145
+ export declare function assets<TDeps>(opts: {
146
+ base?: string;
147
+ binding: (env: TDeps) => Fetcher | null | undefined;
148
+ devProxy?: (env: TDeps) => string | null | undefined;
149
+ }): (env: TDeps, url: URL, request: Request) => Response | Promise<Response> | undefined;
75
150
  export declare function createWorkerEntry<TDeps>(config: WorkerEntryConfig<TDeps>): WorkerEntry<TDeps>;
76
151
  export {};
77
152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AG,EAAE,KAAK,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CACrD,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,CAiBvF;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAsE7F"}
@@ -6,11 +6,13 @@
6
6
  * • resolve the serving URL (== `iss`), canonicalize it (so the value matches
7
7
  * what `createRemoteServer` signs with and the kernel pins), and cache the
8
8
  * built app per distinct URL;
9
- * • optional self-binding routing: when a `SELF` service binding is provided,
10
- * route same-host subrequests (e.g. `ctx.callRemote` back into this domain)
11
- * through it Cloudflare forbids a Worker fetching its own hostname. This is
12
- * the ONLY reason a `globalThis.fetch` override is installed, and only when a
13
- * `selfBinding` is configured;
9
+ * • optional subrequest routing: a `globalThis.fetch` override (installed ONLY
10
+ * when `selfBinding` and/or `routeSubrequest` is configured) redirects
11
+ * certain outbound fetches through a caller-supplied binding `selfBinding`
12
+ * for same-host fetches (a Worker can't fetch its own hostname), and the
13
+ * vendor-neutral `routeSubrequest` for any caller policy (e.g. instance
14
+ * hostnames a same-zone Worker→Worker fetch would 522 on). The SDK names no
15
+ * backend or topology; the caller owns the predicate + the fetcher;
14
16
  * • optional SPA hook (e.g. `/ui/*` served from an `ASSETS` binding).
15
17
  *
16
18
  * The worker's OWN JWKS (`<url>/.well-known/jwks.json`) is served as a normal
@@ -22,6 +24,43 @@
22
24
  import { createRemoteServer } from './create';
23
25
  import { requireEnv } from './require-env';
24
26
  import { canonicalizeServingUrl } from './serving-url';
27
+ /**
28
+ * Choose where an OUTBOUND subrequest to `u` is routed — or `null` to let the
29
+ * real `fetch` handle it. Order matters and same-origin wins FIRST: a call to
30
+ * this worker's OWN serving origin is a self-dispatch, not an edge fetch — and
31
+ * the caller's `routeSubrequest` policy may itself match our own host (e.g. an
32
+ * `isInstanceHost` predicate matches every `*.svc.astrale.ai`, ours included),
33
+ * so it must never get first look at a same-origin call.
34
+ *
35
+ * • same-origin + SELF binding present → the SELF fetcher: a fresh same-script
36
+ * invocation. The normal Cloudflare path — a Worker can't fetch its own
37
+ * hostname over the edge, so it re-enters itself through the binding.
38
+ * • same-origin + NO SELF binding → the cached app, dispatched IN-PROCESS. A
39
+ * Workers-for-Platforms dispatch-namespace tenant can't service-bind to
40
+ * itself (its script name is platform-renamed), so it has no SELF binding; an
41
+ * in-process dispatch reaches the same script with no edge hop and no binding.
42
+ * `App` and the SELF `Fetcher` share the `{ fetch(request) }` shape, so the
43
+ * caller drives both identically.
44
+ * • else, the caller's `routeSubrequest` policy matched → its fetcher.
45
+ * • else → `null`: passthrough to the real network fetch.
46
+ *
47
+ * Pure (no closure over instance state) so the routing decision is unit-testable
48
+ * without standing up a real app.
49
+ */
50
+ export function selectSubrequestTarget(u, ctx) {
51
+ // Same-origin self-subrequest → the same script (SELF binding, else in-process).
52
+ for (const cached of ctx.apps) {
53
+ if (cached.origin === u.origin)
54
+ return ctx.self ?? cached.app;
55
+ }
56
+ // Caller policy (e.g. a platform router on the same zone) → its fetcher.
57
+ if (ctx.routeSubrequest && ctx.routeEnv) {
58
+ const via = ctx.routeSubrequest(u, ctx.routeEnv);
59
+ if (via)
60
+ return via;
61
+ }
62
+ return null;
63
+ }
25
64
  /**
26
65
  * The request origin as the CLIENT reached it — i.e. the origin a fallback
27
66
  * serving URL (and therefore the `iss`) may be derived from. Behind a
@@ -41,6 +80,43 @@ export function clientOrigin(url, request) {
41
80
  const scheme = forwarded?.split(',')[0]?.trim().toLowerCase();
42
81
  return scheme === 'https' ? `https://${url.host}` : url.origin;
43
82
  }
83
+ /**
84
+ * Build a `before` hook that serves a static-asset `binding` (e.g. a Workers
85
+ * Assets binding) mounted under `base` (default `/ui`) — the runtime half of a
86
+ * domain's `client` binding. Returns `undefined` for non-matching paths (and
87
+ * when no binding is present) so the request falls through to domain dispatch.
88
+ *
89
+ * Asset URLs are rooted at `base` (a client bundler sets `base: '<base>/'`);
90
+ * this hook strips that prefix before delegating to the binding, so
91
+ * `<base>/x.js` resolves from the binding's root. When `devProxy` yields a URL
92
+ * (local dev), requests are proxied there instead — the seam for a bundler's
93
+ * HMR dev server. Whether unknown sub-paths fall back to `index.html` is the
94
+ * binding's own concern (e.g. wrangler's `not_found_handling`), not baked in
95
+ * here.
96
+ *
97
+ * Lives here, type-checked and testable, instead of being emitted as a string
98
+ * by every adapter's worker codegen.
99
+ */
100
+ export function assets(opts) {
101
+ const base = (opts.base ?? '/ui').replace(/\/+$/, '');
102
+ const prefix = `${base}/`;
103
+ return (env, url, request) => {
104
+ const binding = opts.binding(env);
105
+ if (!binding)
106
+ return undefined;
107
+ if (url.pathname !== base && !url.pathname.startsWith(prefix))
108
+ return undefined;
109
+ const devUrl = opts.devProxy?.(env);
110
+ if (devUrl) {
111
+ const devBase = devUrl.replace(/\/+$/, '');
112
+ return fetch(new Request(`${devBase}${url.pathname}${url.search}`, request));
113
+ }
114
+ // `<base>` → `/`, `<base>/x` → `/x`: serve from the binding's root.
115
+ const stripped = url.pathname.slice(base.length) || '/';
116
+ const rewritten = new URL(stripped + url.search, url.origin);
117
+ return binding.fetch(new Request(rewritten, request));
118
+ };
119
+ }
44
120
  export function createWorkerEntry(config) {
45
121
  // Cache the built app per distinct resolved URL — plural and bounded. On the
46
122
  // request-origin fallback the URL legitimately alternates for one worker
@@ -51,6 +127,7 @@ export function createWorkerEntry(config) {
51
127
  const MAX_CACHED_APPS = 4;
52
128
  const apps = new Map();
53
129
  let self = null;
130
+ let routeEnv = null;
54
131
  function getApp(url, env) {
55
132
  const cached = apps.get(url);
56
133
  if (cached)
@@ -64,27 +141,29 @@ export function createWorkerEntry(config) {
64
141
  apps.set(url, { origin: new URL(url).origin, app });
65
142
  return app;
66
143
  }
67
- // A Worker can't fetch its own hostname. When a SELF service binding is
68
- // configured, route same-host subrequests (e.g. `ctx.callRemote` back into
69
- // this domain) through it. This is the only reason to override
70
- // `globalThis.fetch` workers without a `selfBinding` get no global mutation.
71
- // (A self-issued credential's JWKS is resolved in-memory by the verifier, not
72
- // fetched see `auth/verify.ts` so no self-JWKS interception is needed.)
73
- if (config.selfBinding) {
144
+ // A Worker can't fetch its own hostname over the edge, nor on Cloudflare — a
145
+ // same-zone hostname routed to another Worker (the `routeSubrequest` case).
146
+ // When either is configured, override `globalThis.fetch` to redirect those
147
+ // subrequests through the right target (see `selectSubrequestTarget`). Workers
148
+ // with neither selfBinding nor routeSubrequest get no global mutation. (A
149
+ // self-issued credential's JWKS is resolved in-memory by the verifier, not
150
+ // fetched — see `auth/verify.ts` — so no self-JWKS shim is needed.)
151
+ if (config.selfBinding || config.routeSubrequest) {
74
152
  const originalFetch = globalThis.fetch;
75
153
  globalThis.fetch = (async (input, init) => {
76
- if (apps.size > 0 && self) {
77
- const href = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
78
- try {
79
- const origin = new URL(href).origin;
80
- for (const cached of apps.values()) {
81
- if (cached.origin === origin)
82
- return self.fetch(new Request(input, init));
83
- }
84
- }
85
- catch {
86
- // non-absolute URL — fall through to the original fetch
87
- }
154
+ const href = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
155
+ try {
156
+ const target = selectSubrequestTarget(new URL(href), {
157
+ self,
158
+ apps: apps.values(),
159
+ routeEnv,
160
+ routeSubrequest: config.routeSubrequest,
161
+ });
162
+ if (target)
163
+ return target.fetch(new Request(input, init));
164
+ }
165
+ catch {
166
+ // non-absolute URL — fall through to the original fetch
88
167
  }
89
168
  return originalFetch(input, init);
90
169
  });
@@ -93,6 +172,8 @@ export function createWorkerEntry(config) {
93
172
  async fetch(request, env) {
94
173
  if (config.selfBinding)
95
174
  self ??= config.selfBinding(env) ?? null;
175
+ if (config.routeSubrequest)
176
+ routeEnv = env;
96
177
  // Only parse the request URL when a hook actually needs it.
97
178
  const requestUrl = config.before || config.resolveUrl ? new URL(request.url) : null;
98
179
  if (config.before && requestUrl) {
@@ -1 +1 @@
1
- {"version":3,"file":"worker-entry.js","sourceRoot":"","sources":["../../src/server/worker-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAgDtD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,GAAQ,EAAE,OAAgB;IACrD,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,GAAG,CAAC,MAAM,CAAA;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;IAC1D,mFAAmF;IACnF,MAAM,MAAM,GAAG,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAC7D,OAAO,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAA;AAChE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAQ,MAAgC;IACvE,6EAA6E;IAC7E,yEAAyE;IACzE,wEAAwE;IACxE,0EAA0E;IAC1E,qEAAqE;IACrE,uDAAuD;IACvD,MAAM,eAAe,GAAG,CAAC,CAAA;IACzB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAwC,CAAA;IAC5D,IAAI,IAAI,GAAmB,IAAI,CAAA;IAE/B,SAAS,MAAM,CAAC,GAAW,EAAE,GAAU;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,MAAM;YAAE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