expo-server 0.0.0 → 0.0.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.
Files changed (158) hide show
  1. package/README.md +1 -0
  2. package/build/cjs/ImmutableRequest.d.ts +60 -0
  3. package/build/cjs/ImmutableRequest.js +160 -0
  4. package/build/cjs/ImmutableRequest.js.map +1 -0
  5. package/build/cjs/global.types.d.ts +13 -0
  6. package/build/cjs/global.types.js +3 -0
  7. package/build/cjs/global.types.js.map +1 -0
  8. package/build/cjs/index.d.ts +2 -0
  9. package/build/cjs/index.js +18 -0
  10. package/build/cjs/index.js.map +1 -0
  11. package/build/cjs/manifest.d.ts +27 -0
  12. package/build/cjs/manifest.js +3 -0
  13. package/build/cjs/manifest.js.map +1 -0
  14. package/build/cjs/middleware/rsc.d.ts +36 -0
  15. package/build/cjs/middleware/rsc.js +124 -0
  16. package/build/cjs/middleware/rsc.js.map +1 -0
  17. package/build/cjs/private.d.ts +2 -0
  18. package/build/cjs/private.js +6 -0
  19. package/build/cjs/private.js.map +1 -0
  20. package/build/cjs/runtime/api.d.ts +36 -0
  21. package/build/cjs/runtime/api.js +64 -0
  22. package/build/cjs/runtime/api.js.map +1 -0
  23. package/build/cjs/runtime/error.d.ts +19 -0
  24. package/build/cjs/runtime/error.js +69 -0
  25. package/build/cjs/runtime/error.js.map +1 -0
  26. package/build/cjs/runtime/index.d.ts +11 -0
  27. package/build/cjs/runtime/index.js +77 -0
  28. package/build/cjs/runtime/index.js.map +1 -0
  29. package/build/cjs/runtime/scope.d.ts +10 -0
  30. package/build/cjs/runtime/scope.js +12 -0
  31. package/build/cjs/runtime/scope.js.map +1 -0
  32. package/build/cjs/types.d.ts +43 -0
  33. package/build/cjs/types.js +3 -0
  34. package/build/cjs/types.js.map +1 -0
  35. package/build/cjs/utils/createReadableStreamFromReadable.d.ts +15 -0
  36. package/build/cjs/utils/createReadableStreamFromReadable.js +97 -0
  37. package/build/cjs/utils/createReadableStreamFromReadable.js.map +1 -0
  38. package/build/cjs/utils/importMetaRegistry.d.ts +3 -0
  39. package/build/cjs/utils/importMetaRegistry.js +30 -0
  40. package/build/cjs/utils/importMetaRegistry.js.map +1 -0
  41. package/build/cjs/utils/matchers.d.ts +12 -0
  42. package/build/cjs/utils/matchers.js +76 -0
  43. package/build/cjs/utils/matchers.js.map +1 -0
  44. package/build/cjs/utils/middleware.d.ts +9 -0
  45. package/build/cjs/utils/middleware.js +82 -0
  46. package/build/cjs/utils/middleware.js.map +1 -0
  47. package/build/cjs/vendor/abstract.d.ts +40 -0
  48. package/build/cjs/vendor/abstract.js +245 -0
  49. package/build/cjs/vendor/abstract.js.map +1 -0
  50. package/build/cjs/vendor/bun.d.ts +10 -0
  51. package/build/cjs/vendor/bun.js +22 -0
  52. package/build/cjs/vendor/bun.js.map +1 -0
  53. package/build/cjs/vendor/eas.d.ts +10 -0
  54. package/build/cjs/vendor/eas.js +28 -0
  55. package/build/cjs/vendor/eas.js.map +1 -0
  56. package/build/cjs/vendor/environment/common.d.ts +14 -0
  57. package/build/cjs/vendor/environment/common.js +66 -0
  58. package/build/cjs/vendor/environment/common.js.map +1 -0
  59. package/build/cjs/vendor/environment/node.d.ts +14 -0
  60. package/build/cjs/vendor/environment/node.js +55 -0
  61. package/build/cjs/vendor/environment/node.js.map +1 -0
  62. package/build/cjs/vendor/environment/workerd.d.ts +18 -0
  63. package/build/cjs/vendor/environment/workerd.js +72 -0
  64. package/build/cjs/vendor/environment/workerd.js.map +1 -0
  65. package/build/cjs/vendor/express.d.ts +14 -0
  66. package/build/cjs/vendor/express.js +100 -0
  67. package/build/cjs/vendor/express.js.map +1 -0
  68. package/build/cjs/vendor/http.d.ts +15 -0
  69. package/build/cjs/vendor/http.js +103 -0
  70. package/build/cjs/vendor/http.js.map +1 -0
  71. package/build/cjs/vendor/netlify.d.ts +15 -0
  72. package/build/cjs/vendor/netlify.js +46 -0
  73. package/build/cjs/vendor/netlify.js.map +1 -0
  74. package/build/cjs/vendor/vercel.d.ts +13 -0
  75. package/build/cjs/vendor/vercel.js +109 -0
  76. package/build/cjs/vendor/vercel.js.map +1 -0
  77. package/build/cjs/vendor/workerd.d.ts +11 -0
  78. package/build/cjs/vendor/workerd.js +22 -0
  79. package/build/cjs/vendor/workerd.js.map +1 -0
  80. package/build/mjs/ImmutableRequest.d.ts +60 -0
  81. package/build/mjs/ImmutableRequest.js +155 -0
  82. package/build/mjs/ImmutableRequest.js.map +1 -0
  83. package/build/mjs/global.types.d.ts +13 -0
  84. package/build/mjs/global.types.js +2 -0
  85. package/build/mjs/global.types.js.map +1 -0
  86. package/build/mjs/index.d.ts +2 -0
  87. package/build/mjs/index.js +2 -0
  88. package/build/mjs/index.js.map +1 -0
  89. package/build/mjs/manifest.d.ts +27 -0
  90. package/build/mjs/manifest.js +2 -0
  91. package/build/mjs/manifest.js.map +1 -0
  92. package/build/mjs/middleware/rsc.d.ts +36 -0
  93. package/build/mjs/middleware/rsc.js +119 -0
  94. package/build/mjs/middleware/rsc.js.map +1 -0
  95. package/build/mjs/private.d.ts +2 -0
  96. package/build/mjs/private.js +2 -0
  97. package/build/mjs/private.js.map +1 -0
  98. package/build/mjs/runtime/api.d.ts +36 -0
  99. package/build/mjs/runtime/api.js +56 -0
  100. package/build/mjs/runtime/api.js.map +1 -0
  101. package/build/mjs/runtime/error.d.ts +19 -0
  102. package/build/mjs/runtime/error.js +64 -0
  103. package/build/mjs/runtime/error.js.map +1 -0
  104. package/build/mjs/runtime/index.d.ts +11 -0
  105. package/build/mjs/runtime/index.js +74 -0
  106. package/build/mjs/runtime/index.js.map +1 -0
  107. package/build/mjs/runtime/scope.d.ts +10 -0
  108. package/build/mjs/runtime/scope.js +9 -0
  109. package/build/mjs/runtime/scope.js.map +1 -0
  110. package/build/mjs/types.d.ts +43 -0
  111. package/build/mjs/types.js +2 -0
  112. package/build/mjs/types.js.map +1 -0
  113. package/build/mjs/utils/createReadableStreamFromReadable.d.ts +15 -0
  114. package/build/mjs/utils/createReadableStreamFromReadable.js +93 -0
  115. package/build/mjs/utils/createReadableStreamFromReadable.js.map +1 -0
  116. package/build/mjs/utils/importMetaRegistry.d.ts +3 -0
  117. package/build/mjs/utils/importMetaRegistry.js +27 -0
  118. package/build/mjs/utils/importMetaRegistry.js.map +1 -0
  119. package/build/mjs/utils/matchers.d.ts +12 -0
  120. package/build/mjs/utils/matchers.js +69 -0
  121. package/build/mjs/utils/matchers.js.map +1 -0
  122. package/build/mjs/utils/middleware.d.ts +9 -0
  123. package/build/mjs/utils/middleware.js +79 -0
  124. package/build/mjs/utils/middleware.js.map +1 -0
  125. package/build/mjs/vendor/abstract.d.ts +40 -0
  126. package/build/mjs/vendor/abstract.js +240 -0
  127. package/build/mjs/vendor/abstract.js.map +1 -0
  128. package/build/mjs/vendor/bun.d.ts +10 -0
  129. package/build/mjs/vendor/bun.js +17 -0
  130. package/build/mjs/vendor/bun.js.map +1 -0
  131. package/build/mjs/vendor/eas.d.ts +10 -0
  132. package/build/mjs/vendor/eas.js +23 -0
  133. package/build/mjs/vendor/eas.js.map +1 -0
  134. package/build/mjs/vendor/environment/common.d.ts +14 -0
  135. package/build/mjs/vendor/environment/common.js +63 -0
  136. package/build/mjs/vendor/environment/common.js.map +1 -0
  137. package/build/mjs/vendor/environment/node.d.ts +14 -0
  138. package/build/mjs/vendor/environment/node.js +48 -0
  139. package/build/mjs/vendor/environment/node.js.map +1 -0
  140. package/build/mjs/vendor/environment/workerd.d.ts +18 -0
  141. package/build/mjs/vendor/environment/workerd.js +68 -0
  142. package/build/mjs/vendor/environment/workerd.js.map +1 -0
  143. package/build/mjs/vendor/express.d.ts +14 -0
  144. package/build/mjs/vendor/express.js +92 -0
  145. package/build/mjs/vendor/express.js.map +1 -0
  146. package/build/mjs/vendor/http.d.ts +15 -0
  147. package/build/mjs/vendor/http.js +95 -0
  148. package/build/mjs/vendor/http.js.map +1 -0
  149. package/build/mjs/vendor/netlify.d.ts +15 -0
  150. package/build/mjs/vendor/netlify.js +41 -0
  151. package/build/mjs/vendor/netlify.js.map +1 -0
  152. package/build/mjs/vendor/vercel.d.ts +13 -0
  153. package/build/mjs/vendor/vercel.js +101 -0
  154. package/build/mjs/vendor/vercel.js.map +1 -0
  155. package/build/mjs/vendor/workerd.d.ts +11 -0
  156. package/build/mjs/vendor/workerd.js +17 -0
  157. package/build/mjs/vendor/workerd.js.map +1 -0
  158. package/package.json +58 -7
package/README.md ADDED
@@ -0,0 +1 @@
1
+ Server API for Expo Router projects
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Copyright © 2025 650 Industries.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ declare const ImmutableHeaders_base: {
8
+ new (init?: HeadersInit): Headers;
9
+ prototype: Headers;
10
+ };
11
+ /**
12
+ * An immutable version of the Fetch API's [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) object which prevents mutations.
13
+ */
14
+ declare class ImmutableHeaders extends ImmutableHeaders_base {
15
+ #private;
16
+ set(): void;
17
+ append(): void;
18
+ delete(): void;
19
+ }
20
+ export type _ImmutableRequest = Omit<Request, 'body' | 'bodyUsed' | 'arrayBuffer' | 'blob' | 'formData' | 'json' | 'text' | 'bytes' | 'headers'> & {
21
+ headers: ImmutableHeaders;
22
+ };
23
+ /**
24
+ * An immutable version of the Fetch API's [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) object which prevents mutations to the request body and headers.
25
+ */
26
+ export declare class ImmutableRequest implements _ImmutableRequest {
27
+ #private;
28
+ constructor(request: Request);
29
+ get cache(): RequestCache;
30
+ get credentials(): RequestCredentials;
31
+ get destination(): RequestDestination;
32
+ get integrity(): string;
33
+ get keepalive(): boolean;
34
+ get method(): string;
35
+ get mode(): RequestMode;
36
+ get redirect(): RequestRedirect;
37
+ get referrer(): string;
38
+ get referrerPolicy(): ReferrerPolicy;
39
+ get signal(): AbortSignal;
40
+ get url(): string;
41
+ get bodyUsed(): boolean;
42
+ get duplex(): "half" | undefined;
43
+ get headers(): ImmutableHeaders;
44
+ /**
45
+ * The request body is not accessible in immutable requests.
46
+ */
47
+ get body(): void;
48
+ arrayBuffer(): Promise<void>;
49
+ blob(): Promise<void>;
50
+ bytes(): Promise<void>;
51
+ formData(): Promise<void>;
52
+ json(): Promise<void>;
53
+ text(): Promise<void>;
54
+ /**
55
+ * Creates a mutable clone of the original request. This is provided as an escape hatch.
56
+ */
57
+ clone(): Request;
58
+ }
59
+ export declare function assertRuntimeFetchAPISupport({ Request, Response, Headers, process, }?: any): void;
60
+ export {};
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright © 2025 650 Industries.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ImmutableRequest = void 0;
10
+ exports.assertRuntimeFetchAPISupport = assertRuntimeFetchAPISupport;
11
+ const getHeadersConstructor = () => {
12
+ if (typeof Headers !== 'undefined') {
13
+ return Headers;
14
+ }
15
+ else {
16
+ // NOTE(@kitten): The `assertRuntimeFetchAPISupport` helper will catch this. Currently only an issue in Jest
17
+ return (globalThis.Headers ??
18
+ class _MockHeaders {
19
+ constructor() {
20
+ throw new Error('Runtime built-in Headers API is not available.');
21
+ }
22
+ });
23
+ }
24
+ };
25
+ /**
26
+ * An immutable version of the Fetch API's [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) object which prevents mutations.
27
+ */
28
+ class ImmutableHeaders extends getHeadersConstructor() {
29
+ // TODO(@hassankhan): Merge with `ReadonlyHeaders` from `expo-router`
30
+ #throwImmutableError() {
31
+ throw new Error('This operation is not allowed on immutable headers.');
32
+ }
33
+ set() {
34
+ this.#throwImmutableError();
35
+ }
36
+ append() {
37
+ this.#throwImmutableError();
38
+ }
39
+ delete() {
40
+ this.#throwImmutableError();
41
+ }
42
+ }
43
+ /**
44
+ * An immutable version of the Fetch API's [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) object which prevents mutations to the request body and headers.
45
+ */
46
+ class ImmutableRequest {
47
+ #headers;
48
+ #request;
49
+ constructor(request) {
50
+ this.#headers = new ImmutableHeaders(request.headers);
51
+ this.#request = request;
52
+ }
53
+ get cache() {
54
+ return this.#request.cache;
55
+ }
56
+ get credentials() {
57
+ return this.#request.credentials;
58
+ }
59
+ get destination() {
60
+ return this.#request.destination;
61
+ }
62
+ get integrity() {
63
+ return this.#request.integrity;
64
+ }
65
+ get keepalive() {
66
+ return this.#request.keepalive;
67
+ }
68
+ get method() {
69
+ return this.#request.method;
70
+ }
71
+ get mode() {
72
+ return this.#request.mode;
73
+ }
74
+ get redirect() {
75
+ return this.#request.redirect;
76
+ }
77
+ get referrer() {
78
+ return this.#request.referrer;
79
+ }
80
+ get referrerPolicy() {
81
+ return this.#request.referrerPolicy;
82
+ }
83
+ get signal() {
84
+ return this.#request.signal;
85
+ }
86
+ get url() {
87
+ return this.#request.url;
88
+ }
89
+ get bodyUsed() {
90
+ return this.#request.bodyUsed;
91
+ }
92
+ get duplex() {
93
+ return this.#request.duplex;
94
+ }
95
+ get headers() {
96
+ return this.#headers;
97
+ }
98
+ #throwImmutableBodyError() {
99
+ throw new Error('This operation is not allowed on immutable requests.');
100
+ }
101
+ /**
102
+ * The request body is not accessible in immutable requests.
103
+ */
104
+ // @ts-expect-error This ensures JavaScript users cannot mutate the request body
105
+ // eslint-disable-next-line getter-return
106
+ get body() {
107
+ this.#throwImmutableBodyError();
108
+ }
109
+ async arrayBuffer() {
110
+ this.#throwImmutableBodyError();
111
+ }
112
+ async blob() {
113
+ this.#throwImmutableBodyError();
114
+ }
115
+ async bytes() {
116
+ this.#throwImmutableBodyError();
117
+ }
118
+ async formData() {
119
+ this.#throwImmutableBodyError();
120
+ }
121
+ async json() {
122
+ this.#throwImmutableBodyError();
123
+ }
124
+ async text() {
125
+ this.#throwImmutableBodyError();
126
+ }
127
+ /**
128
+ * Creates a mutable clone of the original request. This is provided as an escape hatch.
129
+ */
130
+ clone() {
131
+ return this.#request.clone();
132
+ }
133
+ }
134
+ exports.ImmutableRequest = ImmutableRequest;
135
+ // Add assertions to improve usage in non-standard environments.
136
+ function assertRuntimeFetchAPISupport({ Request, Response, Headers, process, } = globalThis) {
137
+ // Check if Request and Response are available.
138
+ if (typeof Request === 'undefined' ||
139
+ typeof Response === 'undefined' ||
140
+ typeof Headers === 'undefined') {
141
+ // Detect if `--no-experimental-fetch` flag is enabled and warn that it must be disabled.
142
+ if (typeof process !== 'undefined' && process.env && process.env.NODE_OPTIONS) {
143
+ const nodeOptions = process.env.NODE_OPTIONS;
144
+ if (nodeOptions.includes('--no-experimental-fetch')) {
145
+ throw new Error('NODE_OPTIONS="--no-experimental-fetch" is not supported with Expo server. Node.js built-in Request/Response APIs are required to continue.');
146
+ }
147
+ }
148
+ // If Node.js is <18, throw an error.
149
+ if (typeof process !== 'undefined' && process.version) {
150
+ const version = process.version;
151
+ const majorVersion = parseInt(version.replace(/v/g, '').split('.')[0], 10);
152
+ if (majorVersion < 18) {
153
+ throw new Error(`Node.js version ${majorVersion} is not supported. Upgrade to Node.js 20 or newer.`);
154
+ }
155
+ }
156
+ // Default error event for missing APIs.
157
+ throw new Error('Runtime built-in Request/Response/Headers APIs are not available. If running Node ensure that Node Fetch API, first available in Node.js 18, is enabled.');
158
+ }
159
+ }
160
+ //# sourceMappingURL=ImmutableRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImmutableRequest.js","sourceRoot":"","sources":["../../src/ImmutableRequest.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAmKH,oEAqCC;AAtMD,MAAM,qBAAqB,GAAG,GAAmB,EAAE;IACjD,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC;IACjB,CAAC;SAAM,CAAC;QACN,4GAA4G;QAC5G,OAAO,CACL,UAAU,CAAC,OAAO;YAClB,MAAM,YAAY;gBAChB;oBACE,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face Request {
6
+ duplex?: 'half';
7
+ }
8
+ interface Response {
9
+ cf?: unknown;
10
+ webSocket?: unknown;
11
+ }
12
+ }
13
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=global.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.types.js","sourceRoot":"","sources":["../../src/global.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './runtime/api';
2
+ export type * from './types';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./runtime/api"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B"}
@@ -0,0 +1,27 @@
1
+ export interface MiddlewareInfo {
2
+ /**
3
+ * Path to the module that contains the middleware function as a default export.
4
+ *
5
+ * @example _expo/functions/+middleware.js
6
+ */
7
+ file: string;
8
+ }
9
+ export interface RouteInfo<TRegex = RegExp | string> {
10
+ file: string;
11
+ page: string;
12
+ namedRegex: TRegex;
13
+ routeKeys: Record<string, string>;
14
+ permanent?: boolean;
15
+ methods?: string[];
16
+ }
17
+ export interface RoutesManifest<TRegex = RegExp | string> {
18
+ middleware?: MiddlewareInfo;
19
+ apiRoutes: RouteInfo<TRegex>[];
20
+ htmlRoutes: RouteInfo<TRegex>[];
21
+ notFoundRoutes: RouteInfo<TRegex>[];
22
+ redirects: RouteInfo<TRegex>[];
23
+ rewrites: RouteInfo<TRegex>[];
24
+ }
25
+ export type RawManifest = RoutesManifest<string>;
26
+ export type Manifest = RoutesManifest<RegExp>;
27
+ export type Route = RouteInfo<RegExp>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/manifest.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright © 2024 650 Industries.
3
+ * Copyright © 2024 dai-shi.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * https://github.com/dai-shi/waku/blob/f9111ed7d96c95d7e128b37e8f7ae2d80122218e/packages/waku/src/lib/middleware/rsc.ts#L1
9
+ */
10
+ type ResolvedConfig = any;
11
+ export type RenderRscArgs = {
12
+ config: ResolvedConfig;
13
+ input: string;
14
+ searchParams: URLSearchParams;
15
+ platform: string;
16
+ engine?: 'hermes' | null;
17
+ method: 'GET' | 'POST';
18
+ body?: ReadableStream | null;
19
+ contentType?: string | undefined;
20
+ decodedBody?: unknown;
21
+ moduleIdCallback?: ((id: string) => void) | undefined;
22
+ onError?: (err: unknown) => void;
23
+ headers: Record<string, string>;
24
+ };
25
+ export declare const decodeInput: (encodedInput: string) => string;
26
+ export declare function getRscMiddleware(options: {
27
+ config: ResolvedConfig;
28
+ baseUrl: string;
29
+ rscPath: string;
30
+ renderRsc: (args: RenderRscArgs) => Promise<ReadableStream<any>>;
31
+ onError?: (err: unknown) => void;
32
+ }): {
33
+ GET: (req: Request) => Promise<Response>;
34
+ POST: (req: Request) => Promise<Response>;
35
+ };
36
+ export {};
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright © 2024 650 Industries.
4
+ * Copyright © 2024 dai-shi.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * https://github.com/dai-shi/waku/blob/f9111ed7d96c95d7e128b37e8f7ae2d80122218e/packages/waku/src/lib/middleware/rsc.ts#L1
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.decodeInput = void 0;
13
+ exports.getRscMiddleware = getRscMiddleware;
14
+ const decodeInput = (encodedInput) => {
15
+ if (encodedInput === 'index.txt') {
16
+ return '';
17
+ }
18
+ if (encodedInput?.endsWith('.txt')) {
19
+ return encodedInput.slice(0, -'.txt'.length);
20
+ }
21
+ const err = new Error('Invalid encoded input');
22
+ err.statusCode = 400;
23
+ throw err;
24
+ };
25
+ exports.decodeInput = decodeInput;
26
+ // Production / Development API Route for handling RSC. Must be applied to the RSC paths, e.g. `/_flight/[...slug]+api.tsx`
27
+ function getRscMiddleware(options) {
28
+ let rscPathPrefix = options.rscPath;
29
+ if (rscPathPrefix !== '/' && !rscPathPrefix.endsWith('/')) {
30
+ rscPathPrefix += '/';
31
+ }
32
+ async function getOrPostAsync(req) {
33
+ const url = new URL(req.url);
34
+ const { method } = req;
35
+ if (method !== 'GET' && method !== 'POST') {
36
+ throw new Error(`Unsupported method '${method}'`);
37
+ }
38
+ const platform = url.searchParams.get('platform') ?? req.headers.get('expo-platform');
39
+ if (typeof platform !== 'string' || !platform) {
40
+ return new Response('Missing expo-platform header or platform query parameter', {
41
+ status: 500,
42
+ headers: {
43
+ 'Content-Type': 'text/plain',
44
+ },
45
+ });
46
+ }
47
+ const engine = url.searchParams.get('transform.engine');
48
+ // TODO: Will the hermes flag apply in production later?
49
+ if (engine && !['hermes'].includes(engine)) {
50
+ return new Response(`Query parameter "transform.engine" is an unsupported value: ${engine}`, {
51
+ status: 500,
52
+ headers: {
53
+ 'Content-Type': 'text/plain',
54
+ },
55
+ });
56
+ }
57
+ let encodedInput = url.pathname.replace(
58
+ // TODO: baseUrl support
59
+ rscPathPrefix, '');
60
+ // First segment should be the target platform.
61
+ // This is used for aligning with production exports which are statically exported to a single location at build-time.
62
+ encodedInput = encodedInput.replace(new RegExp(`^${platform}/`), '');
63
+ try {
64
+ encodedInput = (0, exports.decodeInput)(encodedInput);
65
+ }
66
+ catch {
67
+ return new Response(`Invalid encoded input: "${encodedInput}"`, {
68
+ status: 400,
69
+ headers: {
70
+ 'Content-Type': 'text/plain',
71
+ },
72
+ });
73
+ }
74
+ try {
75
+ const args = {
76
+ config: options.config,
77
+ platform,
78
+ engine: engine,
79
+ input: encodedInput,
80
+ searchParams: url.searchParams,
81
+ method,
82
+ body: req.body,
83
+ contentType: req.headers.get('Content-Type') ?? '',
84
+ decodedBody: req.headers.get('X-Expo-Params'),
85
+ onError: options.onError,
86
+ headers: headersToRecord(req.headers),
87
+ };
88
+ const readable = await options.renderRsc(args);
89
+ return new Response(readable, {
90
+ headers: {
91
+ // The response is a streamed text file
92
+ 'Content-Type': 'text/plain',
93
+ },
94
+ });
95
+ }
96
+ catch (err) {
97
+ if (err instanceof Response) {
98
+ return err;
99
+ }
100
+ if (process.env.NODE_ENV !== 'development') {
101
+ throw err;
102
+ }
103
+ console.error(err);
104
+ return new Response(`Unexpected server error rendering RSC: ` + err.message, {
105
+ status: 'statusCode' in err ? err.statusCode : 500,
106
+ headers: {
107
+ 'Content-Type': 'text/plain',
108
+ },
109
+ });
110
+ }
111
+ }
112
+ return {
113
+ GET: getOrPostAsync,
114
+ POST: getOrPostAsync,
115
+ };
116
+ }
117
+ function headersToRecord(headers) {
118
+ const record = {};
119
+ for (const [key, value] of headers.entries()) {
120
+ record[key] = value;
121
+ }
122
+ return record;
123
+ }
124
+ //# sourceMappingURL=rsc.js.map
@@ -0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AC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC7C,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { type RenderRscArgs, getRscMiddleware } from './middleware/rsc';
2
+ export type * from './manifest';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRscMiddleware = void 0;
4
+ var rsc_1 = require("./middleware/rsc");
5
+ Object.defineProperty(exports, "getRscMiddleware", { enumerable: true, get: function () { return rsc_1.getRscMiddleware; } });
6
+ //# sourceMappingURL=private.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private.js","sourceRoot":"","sources":["../../src/private.ts"],"names":[],"mappings":";;;AAAA,wCAAwE;AAA3C,uGAAA,gBAAgB,OAAA"}
@@ -0,0 +1,36 @@
1
+ export { StatusError } from './error';
2
+ export interface RequestAPI {
3
+ origin?: string;
4
+ environment?: string | null;
5
+ waitUntil?(promise: Promise<unknown>): void;
6
+ deferTask?(fn: () => Promise<unknown>): void;
7
+ }
8
+ /** Returns the current request's origin URL
9
+ * @remarks
10
+ * This returns the request's Origin header, which contains the
11
+ * request origin URL or defaults to `null`.
12
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Origin
13
+ */
14
+ export declare function origin(): string | null;
15
+ /** Returns the currently specified "environment", if any is set up.
16
+ * @remarks
17
+ * The request's environment. When this is `null`, this by convention typically
18
+ * signifies the production environment. This is typically customized via the
19
+ * Expo server adapters, and will default to the current `alias` name in
20
+ * EAS Hosting.
21
+ */
22
+ export declare function environment(): string | null;
23
+ /** Runs a task immediately and instructs the runtime to complete the task.
24
+ * @remarks
25
+ * Running a promise concurrently to the request doesn't usually guarantee that your
26
+ * serverless function will continue executing the task. Passing the task to `runTask`
27
+ * will attempt to keep the current invocation running until the task is completed.
28
+ */
29
+ export declare function runTask(fn: () => Promise<unknown>): void;
30
+ /** Defers a task until after a response has been sent.
31
+ * @remarks
32
+ * After a response has been sent, if no error occurred, the tasks passed to `deferTask`
33
+ * will be executed and the serverless function will be instructed to continue executing
34
+ * the task until it has completed.
35
+ */
36
+ export declare function deferTask(fn: () => Promise<unknown>): void;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StatusError = void 0;
4
+ exports.origin = origin;
5
+ exports.environment = environment;
6
+ exports.runTask = runTask;
7
+ exports.deferTask = deferTask;
8
+ const scope_1 = require("./scope");
9
+ function enforcedRequestScope() {
10
+ const scope = scope_1.scopeRef.current?.getStore();
11
+ if (scope === undefined) {
12
+ throw new Error('Invalid server runtime API call. Runtime APIs can only be called during ongoing requests.\n' +
13
+ '- You may be calling this API in the global scope.\n' +
14
+ '- You might be calling this API outside of a promise scoped to a request.\n' +
15
+ '- You might have more than one copy of this API installed.');
16
+ }
17
+ return scope;
18
+ }
19
+ function assertSupport(name, v) {
20
+ if (v === undefined) {
21
+ throw new Error(`Unsupported server runtime API call: ${name}. This API is not supported in your current environment.`);
22
+ }
23
+ return v;
24
+ }
25
+ var error_1 = require("./error");
26
+ Object.defineProperty(exports, "StatusError", { enumerable: true, get: function () { return error_1.StatusError; } });
27
+ /** Returns the current request's origin URL
28
+ * @remarks
29
+ * This returns the request's Origin header, which contains the
30
+ * request origin URL or defaults to `null`.
31
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Origin
32
+ */
33
+ function origin() {
34
+ return assertSupport('origin()', enforcedRequestScope().origin);
35
+ }
36
+ /** Returns the currently specified "environment", if any is set up.
37
+ * @remarks
38
+ * The request's environment. When this is `null`, this by convention typically
39
+ * signifies the production environment. This is typically customized via the
40
+ * Expo server adapters, and will default to the current `alias` name in
41
+ * EAS Hosting.
42
+ */
43
+ function environment() {
44
+ return assertSupport('environment()', enforcedRequestScope().environment);
45
+ }
46
+ /** Runs a task immediately and instructs the runtime to complete the task.
47
+ * @remarks
48
+ * Running a promise concurrently to the request doesn't usually guarantee that your
49
+ * serverless function will continue executing the task. Passing the task to `runTask`
50
+ * will attempt to keep the current invocation running until the task is completed.
51
+ */
52
+ function runTask(fn) {
53
+ assertSupport('runTask()', enforcedRequestScope().waitUntil)(fn());
54
+ }
55
+ /** Defers a task until after a response has been sent.
56
+ * @remarks
57
+ * After a response has been sent, if no error occurred, the tasks passed to `deferTask`
58
+ * will be executed and the serverless function will be instructed to continue executing
59
+ * the task until it has completed.
60
+ */
61
+ function deferTask(fn) {
62
+ assertSupport('deferTask()', enforcedRequestScope().deferTask)(fn);
63
+ }
64
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/runtime/api.ts"],"names":[],"mappings":";;;AAuCA,wBAEC;AASD,kCAEC;AAQD,0BAEC;AAQD,8BAEC;AAxED,mCAAmC;AAEnC,SAAS,oBAAoB;IAC3B,MAAM,KAAK,GAAG,gBAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC3C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,6FAA6F;YAC3F,sDAAsD;YACtD,6EAA6E;YAC7E,4DAA4D,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,aAAa,CAAI,IAAY,EAAE,CAAgB;IACtD,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,wCAAwC,IAAI,0DAA0D,CACvG,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AASpB;;;;;GAKG;AACH,SAAgB,MAAM;IACpB,OAAO,aAAa,CAAC,UAAU,EAAE,oBAAoB,EAAE,CAAC,MAAM,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW;IACzB,OAAO,aAAa,CAAC,eAAe,EAAE,oBAAoB,EAAE,CAAC,WAAW,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,EAA0B;IAChD,aAAa,CAAC,WAAW,EAAE,oBAAoB,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACrE,CAAC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,EAA0B;IAClD,aAAa,CAAC,aAAa,EAAE,oBAAoB,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,19 @@
1
+ export declare class StatusError extends Error {
2
+ status: number;
3
+ body: string;
4
+ constructor(status?: number, body?: {
5
+ error?: string;
6
+ [key: string]: any;
7
+ } | Error | string);
8
+ constructor(status?: number, errorOptions?: {
9
+ cause: unknown;
10
+ error?: string;
11
+ });
12
+ constructor(status?: number, body?: {
13
+ error?: string;
14
+ [key: string]: any;
15
+ } | Error | string, errorOptions?: {
16
+ cause?: unknown;
17
+ });
18
+ }
19
+ export declare function errorToResponse(error: Error): Response;