expo-server 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/build/cjs/ImmutableRequest.d.ts +61 -0
- package/build/cjs/ImmutableRequest.js +160 -0
- package/build/cjs/ImmutableRequest.js.map +1 -0
- package/build/cjs/global.types.d.ts +13 -0
- package/build/cjs/global.types.js +3 -0
- package/build/cjs/global.types.js.map +1 -0
- package/build/cjs/index.d.ts +2 -0
- package/build/cjs/index.js +18 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/manifest.d.ts +27 -0
- package/build/cjs/manifest.js +3 -0
- package/build/cjs/manifest.js.map +1 -0
- package/build/cjs/middleware/rsc.d.ts +36 -0
- package/build/cjs/middleware/rsc.js +124 -0
- package/build/cjs/middleware/rsc.js.map +1 -0
- package/build/cjs/private.d.ts +2 -0
- package/build/cjs/private.js +6 -0
- package/build/cjs/private.js.map +1 -0
- package/build/cjs/runtime/api.d.ts +39 -0
- package/build/cjs/runtime/api.js +73 -0
- package/build/cjs/runtime/api.js.map +1 -0
- package/build/cjs/runtime/error.d.ts +36 -0
- package/build/cjs/runtime/error.js +86 -0
- package/build/cjs/runtime/error.js.map +1 -0
- package/build/cjs/runtime/index.d.ts +10 -0
- package/build/cjs/runtime/index.js +77 -0
- package/build/cjs/runtime/index.js.map +1 -0
- package/build/cjs/runtime/scope.d.ts +15 -0
- package/build/cjs/runtime/scope.js +12 -0
- package/build/cjs/runtime/scope.js.map +1 -0
- package/build/cjs/types.d.ts +57 -0
- package/build/cjs/types.js +3 -0
- package/build/cjs/types.js.map +1 -0
- package/build/cjs/utils/createReadableStreamFromReadable.d.ts +15 -0
- package/build/cjs/utils/createReadableStreamFromReadable.js +97 -0
- package/build/cjs/utils/createReadableStreamFromReadable.js.map +1 -0
- package/build/cjs/utils/importMetaRegistry.d.ts +3 -0
- package/build/cjs/utils/importMetaRegistry.js +30 -0
- package/build/cjs/utils/importMetaRegistry.js.map +1 -0
- package/build/cjs/utils/matchers.d.ts +12 -0
- package/build/cjs/utils/matchers.js +76 -0
- package/build/cjs/utils/matchers.js.map +1 -0
- package/build/cjs/utils/middleware.d.ts +9 -0
- package/build/cjs/utils/middleware.js +82 -0
- package/build/cjs/utils/middleware.js.map +1 -0
- package/build/cjs/vendor/abstract.d.ts +40 -0
- package/build/cjs/vendor/abstract.js +245 -0
- package/build/cjs/vendor/abstract.js.map +1 -0
- package/build/cjs/vendor/bun.d.ts +10 -0
- package/build/cjs/vendor/bun.js +22 -0
- package/build/cjs/vendor/bun.js.map +1 -0
- package/build/cjs/vendor/eas.d.ts +10 -0
- package/build/cjs/vendor/eas.js +28 -0
- package/build/cjs/vendor/eas.js.map +1 -0
- package/build/cjs/vendor/environment/common.d.ts +14 -0
- package/build/cjs/vendor/environment/common.js +66 -0
- package/build/cjs/vendor/environment/common.js.map +1 -0
- package/build/cjs/vendor/environment/node.d.ts +14 -0
- package/build/cjs/vendor/environment/node.js +55 -0
- package/build/cjs/vendor/environment/node.js.map +1 -0
- package/build/cjs/vendor/environment/workerd.d.ts +18 -0
- package/build/cjs/vendor/environment/workerd.js +72 -0
- package/build/cjs/vendor/environment/workerd.js.map +1 -0
- package/build/cjs/vendor/express.d.ts +14 -0
- package/build/cjs/vendor/express.js +100 -0
- package/build/cjs/vendor/express.js.map +1 -0
- package/build/cjs/vendor/http.d.ts +15 -0
- package/build/cjs/vendor/http.js +103 -0
- package/build/cjs/vendor/http.js.map +1 -0
- package/build/cjs/vendor/netlify.d.ts +15 -0
- package/build/cjs/vendor/netlify.js +46 -0
- package/build/cjs/vendor/netlify.js.map +1 -0
- package/build/cjs/vendor/vercel.d.ts +13 -0
- package/build/cjs/vendor/vercel.js +109 -0
- package/build/cjs/vendor/vercel.js.map +1 -0
- package/build/cjs/vendor/workerd.d.ts +11 -0
- package/build/cjs/vendor/workerd.js +22 -0
- package/build/cjs/vendor/workerd.js.map +1 -0
- package/build/mjs/ImmutableRequest.d.ts +61 -0
- package/build/mjs/ImmutableRequest.js +155 -0
- package/build/mjs/ImmutableRequest.js.map +1 -0
- package/build/mjs/global.types.d.ts +13 -0
- package/build/mjs/global.types.js +2 -0
- package/build/mjs/global.types.js.map +1 -0
- package/build/mjs/index.d.ts +2 -0
- package/build/mjs/index.js +2 -0
- package/build/mjs/index.js.map +1 -0
- package/build/mjs/manifest.d.ts +27 -0
- package/build/mjs/manifest.js +2 -0
- package/build/mjs/manifest.js.map +1 -0
- package/build/mjs/middleware/rsc.d.ts +36 -0
- package/build/mjs/middleware/rsc.js +119 -0
- package/build/mjs/middleware/rsc.js.map +1 -0
- package/build/mjs/private.d.ts +2 -0
- package/build/mjs/private.js +2 -0
- package/build/mjs/private.js.map +1 -0
- package/build/mjs/runtime/api.d.ts +39 -0
- package/build/mjs/runtime/api.js +65 -0
- package/build/mjs/runtime/api.js.map +1 -0
- package/build/mjs/runtime/error.d.ts +36 -0
- package/build/mjs/runtime/error.js +81 -0
- package/build/mjs/runtime/error.js.map +1 -0
- package/build/mjs/runtime/index.d.ts +10 -0
- package/build/mjs/runtime/index.js +74 -0
- package/build/mjs/runtime/index.js.map +1 -0
- package/build/mjs/runtime/scope.d.ts +15 -0
- package/build/mjs/runtime/scope.js +9 -0
- package/build/mjs/runtime/scope.js.map +1 -0
- package/build/mjs/types.d.ts +57 -0
- package/build/mjs/types.js +2 -0
- package/build/mjs/types.js.map +1 -0
- package/build/mjs/utils/createReadableStreamFromReadable.d.ts +15 -0
- package/build/mjs/utils/createReadableStreamFromReadable.js +93 -0
- package/build/mjs/utils/createReadableStreamFromReadable.js.map +1 -0
- package/build/mjs/utils/importMetaRegistry.d.ts +3 -0
- package/build/mjs/utils/importMetaRegistry.js +27 -0
- package/build/mjs/utils/importMetaRegistry.js.map +1 -0
- package/build/mjs/utils/matchers.d.ts +12 -0
- package/build/mjs/utils/matchers.js +69 -0
- package/build/mjs/utils/matchers.js.map +1 -0
- package/build/mjs/utils/middleware.d.ts +9 -0
- package/build/mjs/utils/middleware.js +79 -0
- package/build/mjs/utils/middleware.js.map +1 -0
- package/build/mjs/vendor/abstract.d.ts +40 -0
- package/build/mjs/vendor/abstract.js +240 -0
- package/build/mjs/vendor/abstract.js.map +1 -0
- package/build/mjs/vendor/bun.d.ts +10 -0
- package/build/mjs/vendor/bun.js +17 -0
- package/build/mjs/vendor/bun.js.map +1 -0
- package/build/mjs/vendor/eas.d.ts +10 -0
- package/build/mjs/vendor/eas.js +23 -0
- package/build/mjs/vendor/eas.js.map +1 -0
- package/build/mjs/vendor/environment/common.d.ts +14 -0
- package/build/mjs/vendor/environment/common.js +63 -0
- package/build/mjs/vendor/environment/common.js.map +1 -0
- package/build/mjs/vendor/environment/node.d.ts +14 -0
- package/build/mjs/vendor/environment/node.js +48 -0
- package/build/mjs/vendor/environment/node.js.map +1 -0
- package/build/mjs/vendor/environment/workerd.d.ts +18 -0
- package/build/mjs/vendor/environment/workerd.js +68 -0
- package/build/mjs/vendor/environment/workerd.js.map +1 -0
- package/build/mjs/vendor/express.d.ts +14 -0
- package/build/mjs/vendor/express.js +92 -0
- package/build/mjs/vendor/express.js.map +1 -0
- package/build/mjs/vendor/http.d.ts +15 -0
- package/build/mjs/vendor/http.js +95 -0
- package/build/mjs/vendor/http.js.map +1 -0
- package/build/mjs/vendor/netlify.d.ts +15 -0
- package/build/mjs/vendor/netlify.js +41 -0
- package/build/mjs/vendor/netlify.js.map +1 -0
- package/build/mjs/vendor/vercel.d.ts +13 -0
- package/build/mjs/vendor/vercel.js +101 -0
- package/build/mjs/vendor/vercel.js.map +1 -0
- package/build/mjs/vendor/workerd.d.ts +11 -0
- package/build/mjs/vendor/workerd.js +17 -0
- package/build/mjs/vendor/workerd.js.map +1 -0
- package/package.json +68 -7
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Server API for Expo Router projects
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
/** @hidden */
|
|
21
|
+
export type _ImmutableRequest = Omit<Request, 'body' | 'bodyUsed' | 'arrayBuffer' | 'blob' | 'formData' | 'json' | 'text' | 'bytes' | 'headers'> & {
|
|
22
|
+
headers: ImmutableHeaders;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* 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.
|
|
26
|
+
*/
|
|
27
|
+
export declare class ImmutableRequest implements _ImmutableRequest {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(request: Request);
|
|
30
|
+
get cache(): RequestCache;
|
|
31
|
+
get credentials(): RequestCredentials;
|
|
32
|
+
get destination(): RequestDestination;
|
|
33
|
+
get integrity(): string;
|
|
34
|
+
get keepalive(): boolean;
|
|
35
|
+
get method(): string;
|
|
36
|
+
get mode(): RequestMode;
|
|
37
|
+
get redirect(): RequestRedirect;
|
|
38
|
+
get referrer(): string;
|
|
39
|
+
get referrerPolicy(): ReferrerPolicy;
|
|
40
|
+
get signal(): AbortSignal;
|
|
41
|
+
get url(): string;
|
|
42
|
+
get bodyUsed(): boolean;
|
|
43
|
+
get duplex(): "half" | undefined;
|
|
44
|
+
get headers(): ImmutableHeaders;
|
|
45
|
+
/**
|
|
46
|
+
* The request body is not accessible in immutable requests.
|
|
47
|
+
*/
|
|
48
|
+
get body(): void;
|
|
49
|
+
arrayBuffer(): Promise<void>;
|
|
50
|
+
blob(): Promise<void>;
|
|
51
|
+
bytes(): Promise<void>;
|
|
52
|
+
formData(): Promise<void>;
|
|
53
|
+
json(): Promise<void>;
|
|
54
|
+
text(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a mutable clone of the original request. This is provided as an escape hatch.
|
|
57
|
+
*/
|
|
58
|
+
clone(): Request;
|
|
59
|
+
}
|
|
60
|
+
export declare function assertRuntimeFetchAPISupport({ Request, Response, Headers, process, }?: any): void;
|
|
61
|
+
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;;;AAoKH,oEAqCC;AAvMD,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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{"version":3,"file":"global.types.js","sourceRoot":"","sources":["../../src/global.types.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
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,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc.js","sourceRo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,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,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,39 @@
|
|
|
1
|
+
export { StatusError } from './error';
|
|
2
|
+
/** Returns the current request's origin URL.
|
|
3
|
+
*
|
|
4
|
+
* This typically returns the request's Origin header, which contains the
|
|
5
|
+
* request origin URL or defaults to `null`.
|
|
6
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Origin
|
|
7
|
+
* @returns A request origin
|
|
8
|
+
*/
|
|
9
|
+
export declare function origin(): string | null;
|
|
10
|
+
/** Returns the request's environment, if the server runtime supports this.
|
|
11
|
+
*
|
|
12
|
+
* In EAS Hosting, the returned environment name is the alias or deployment identifier,
|
|
13
|
+
* but the value may differ for other providers.
|
|
14
|
+
*
|
|
15
|
+
* @see https://docs.expo.dev/eas/hosting/deployments-and-aliases/
|
|
16
|
+
* @returns A request environment name, or `null` for production.
|
|
17
|
+
*/
|
|
18
|
+
export declare function environment(): string | null;
|
|
19
|
+
/** Runs a task immediately and instructs the runtime to complete the task.
|
|
20
|
+
*
|
|
21
|
+
* A request handler may be terminated as soon as the client has finished the full `Response`
|
|
22
|
+
* and unhandled promise rejections may not be logged properly. To run tasks concurrently to
|
|
23
|
+
* a request handler and keep the request alive until the task is completed, pass a task
|
|
24
|
+
* function to `runTask` instead. The request handler will be kept alive until the task
|
|
25
|
+
* completes.
|
|
26
|
+
*
|
|
27
|
+
* @param fn - A task function to execute. The request handler will be kept alive until this task finishes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runTask(fn: () => Promise<unknown>): void;
|
|
30
|
+
/** Defers a task until after a response has been sent.
|
|
31
|
+
*
|
|
32
|
+
* This only calls the task function once the request handler has finished resolving a `Response`
|
|
33
|
+
* and keeps the request handler alive until the task is completed. This is useful to run non-critical
|
|
34
|
+
* tasks after the request handler, for example to log analytics datapoints. If the request handler
|
|
35
|
+
* rejects with an error, deferred tasks won't be executed.
|
|
36
|
+
*
|
|
37
|
+
* @param fn - A task function to execute after the request handler has finished.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deferTask(fn: () => Promise<unknown>): void;
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
*
|
|
29
|
+
* This typically 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
|
+
* @returns A request origin
|
|
33
|
+
*/
|
|
34
|
+
function origin() {
|
|
35
|
+
return assertSupport('origin()', enforcedRequestScope().origin);
|
|
36
|
+
}
|
|
37
|
+
/** Returns the request's environment, if the server runtime supports this.
|
|
38
|
+
*
|
|
39
|
+
* In EAS Hosting, the returned environment name is the alias or deployment identifier,
|
|
40
|
+
* but the value may differ for other providers.
|
|
41
|
+
*
|
|
42
|
+
* @see https://docs.expo.dev/eas/hosting/deployments-and-aliases/
|
|
43
|
+
* @returns A request environment name, or `null` for production.
|
|
44
|
+
*/
|
|
45
|
+
function environment() {
|
|
46
|
+
return assertSupport('environment()', enforcedRequestScope().environment);
|
|
47
|
+
}
|
|
48
|
+
/** Runs a task immediately and instructs the runtime to complete the task.
|
|
49
|
+
*
|
|
50
|
+
* A request handler may be terminated as soon as the client has finished the full `Response`
|
|
51
|
+
* and unhandled promise rejections may not be logged properly. To run tasks concurrently to
|
|
52
|
+
* a request handler and keep the request alive until the task is completed, pass a task
|
|
53
|
+
* function to `runTask` instead. The request handler will be kept alive until the task
|
|
54
|
+
* completes.
|
|
55
|
+
*
|
|
56
|
+
* @param fn - A task function to execute. The request handler will be kept alive until this task finishes.
|
|
57
|
+
*/
|
|
58
|
+
function runTask(fn) {
|
|
59
|
+
assertSupport('runTask()', enforcedRequestScope().waitUntil)(fn());
|
|
60
|
+
}
|
|
61
|
+
/** Defers a task until after a response has been sent.
|
|
62
|
+
*
|
|
63
|
+
* This only calls the task function once the request handler has finished resolving a `Response`
|
|
64
|
+
* and keeps the request handler alive until the task is completed. This is useful to run non-critical
|
|
65
|
+
* tasks after the request handler, for example to log analytics datapoints. If the request handler
|
|
66
|
+
* rejects with an error, deferred tasks won't be executed.
|
|
67
|
+
*
|
|
68
|
+
* @param fn - A task function to execute after the request handler has finished.
|
|
69
|
+
*/
|
|
70
|
+
function deferTask(fn) {
|
|
71
|
+
assertSupport('deferTask()', enforcedRequestScope().deferTask)(fn);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/runtime/api.ts"],"names":[],"mappings":";;;AAiCA,wBAEC;AAUD,kCAEC;AAYD,0BAEC;AAWD,8BAEC;AA1ED,mCAAoD;AAEpD,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;AAEpB;;;;;;GAMG;AACH,SAAgB,MAAM;IACpB,OAAO,aAAa,CAAC,UAAU,EAAE,oBAAoB,EAAE,CAAC,MAAM,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,WAAW;IACzB,OAAO,aAAa,CAAC,eAAe,EAAE,oBAAoB,EAAE,CAAC,WAAW,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,OAAO,CAAC,EAA0B;IAChD,aAAa,CAAC,WAAW,EAAE,oBAAoB,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACrE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,SAAS,CAAC,EAA0B;IAClD,aAAa,CAAC,aAAa,EAAE,oBAAoB,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** An error response representation which can be thrown anywhere in server-side code.
|
|
2
|
+
*
|
|
3
|
+
* A `StatusError` can be thrown by a request handler and will be caught by the `expo-server`
|
|
4
|
+
* runtime and replaced by a `Response` with the `status` and `body` that's been passed to
|
|
5
|
+
* the `StatusError`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { StatusError } from 'expo-server';
|
|
10
|
+
*
|
|
11
|
+
* export function GET(request, { postId }) {
|
|
12
|
+
* if (!postId) {
|
|
13
|
+
* throw new StatusError(400, 'postId parameter is required');
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class StatusError extends Error {
|
|
19
|
+
status: number;
|
|
20
|
+
body: string;
|
|
21
|
+
constructor(status?: number, body?: {
|
|
22
|
+
error?: string;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
} | Error | string);
|
|
25
|
+
constructor(status?: number, errorOptions?: {
|
|
26
|
+
cause: unknown;
|
|
27
|
+
error?: string;
|
|
28
|
+
});
|
|
29
|
+
constructor(status?: number, body?: {
|
|
30
|
+
error?: string;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
} | Error | string, errorOptions?: {
|
|
33
|
+
cause?: unknown;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export declare function errorToResponse(error: Error): Response;
|