first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
/**
* Copyright © 2025 650 Industries.
* Copyright (c) Remix Software Inc. 2020-2021
* Copyright (c) Shopify Inc. 2022-2024
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* Original license https://github.com/remix-run/remix/blob/6d6caaed5dfc436242962dcb2ff9617757a11e17/LICENSE.md
* Code from https://github.com/remix-run/remix/blob/6d6caaed5dfc436242962dcb2ff9617757a11e17/packages/remix-node/stream.ts#L66
*/
import type { Readable } from 'node:stream';
export declare const createReadableStreamFromReadable: (source: Readable & {
readableHighWaterMark?: number;
}) => ReadableStream<Uint8Array<ArrayBufferLike>>;

View File

@@ -0,0 +1,97 @@
"use strict";
/**
* Copyright © 2025 650 Industries.
* Copyright (c) Remix Software Inc. 2020-2021
* Copyright (c) Shopify Inc. 2022-2024
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* Original license https://github.com/remix-run/remix/blob/6d6caaed5dfc436242962dcb2ff9617757a11e17/LICENSE.md
* Code from https://github.com/remix-run/remix/blob/6d6caaed5dfc436242962dcb2ff9617757a11e17/packages/remix-node/stream.ts#L66
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createReadableStreamFromReadable = void 0;
const node_stream_1 = require("node:stream");
const createReadableStreamFromReadable = (source) => {
const pump = new StreamPump(source);
const stream = new ReadableStream(pump, pump);
return stream;
};
exports.createReadableStreamFromReadable = createReadableStreamFromReadable;
class StreamPump {
highWaterMark;
accumalatedSize;
stream;
controller;
constructor(stream) {
this.highWaterMark =
stream.readableHighWaterMark || new node_stream_1.Stream.Readable().readableHighWaterMark;
this.accumalatedSize = 0;
this.stream = stream;
this.enqueue = this.enqueue.bind(this);
this.error = this.error.bind(this);
this.close = this.close.bind(this);
}
size(chunk) {
return chunk?.byteLength || 0;
}
start(controller) {
this.controller = controller;
this.stream.on('data', this.enqueue);
this.stream.once('error', this.error);
this.stream.once('end', this.close);
this.stream.once('close', this.close);
}
pull() {
this.resume();
}
cancel(reason) {
if (this.stream.destroy) {
this.stream.destroy(reason);
}
this.stream.off('data', this.enqueue);
this.stream.off('error', this.error);
this.stream.off('end', this.close);
this.stream.off('close', this.close);
}
enqueue(chunk) {
if (this.controller) {
try {
const bytes = chunk instanceof Uint8Array ? chunk : Buffer.from(chunk);
const available = (this.controller.desiredSize || 0) - bytes.byteLength;
this.controller.enqueue(bytes);
if (available <= 0) {
this.pause();
}
}
catch {
this.controller.error(new Error('Could not create Buffer, chunk must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object'));
this.cancel();
}
}
}
pause() {
if (this.stream.pause) {
this.stream.pause();
}
}
resume() {
if (this.stream.readable && this.stream.resume) {
this.stream.resume();
}
}
close() {
if (this.controller) {
this.controller.close();
delete this.controller;
}
}
error(error) {
if (this.controller) {
this.controller.error(error);
delete this.controller;
}
}
}
//# sourceMappingURL=createReadableStreamFromReadable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createReadableStreamFromReadable.js","sourceRoot":"","sources":["../../../src/utils/createReadableStreamFromReadable.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAGH,6CAAqC;AAE9B,MAAM,gCAAgC,GAAG,CAC9C,MAAqD,EACrD,EAAE;IACF,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AANW,QAAA,gCAAgC,oCAM3C;AAEF,MAAM,UAAU;IACP,aAAa,CAAS;IACtB,eAAe,CAAS;IACvB,MAAM,CAMZ;IACM,UAAU,CAAwC;IAE1D,YACE,MAMC;QAED,IAAI,CAAC,aAAa;YAChB,MAAM,CAAC,qBAAqB,IAAI,IAAI,oBAAM,CAAC,QA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,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAY;QAChB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC7B,OAAO,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;IACH,CAAC;CACF"}

View File

@@ -0,0 +1 @@
export declare const appendHeadersRecord: (headers: Headers, updateHeaders: Record<string, string | string[]>, shouldOverwrite: boolean) => void;

20
node_modules/expo-server/build/cjs/utils/headers.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.appendHeadersRecord = void 0;
const appendHeadersRecord = (headers, updateHeaders, shouldOverwrite) => {
for (const headerName in updateHeaders) {
if (Array.isArray(updateHeaders[headerName])) {
for (const headerValue of updateHeaders[headerName]) {
headers.append(headerName, headerValue);
}
}
else if (!shouldOverwrite && headers.has(headerName)) {
continue;
}
else if (updateHeaders[headerName] != null) {
headers.set(headerName, updateHeaders[headerName]);
}
}
};
exports.appendHeadersRecord = appendHeadersRecord;
//# sourceMappingURL=headers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../src/utils/headers.ts"],"names":[],"mappings":";;;AAAO,MAAM,mBAAmB,GAAG,CACjC,OAAgB,EAChB,aAAgD,EAChD,eAAwB,EAClB,EAAE;IACR,KAAK,MAAM,UAAU,IAAI,aAAa,EAAE,CAAC;QACvC,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;YAC7C,KAAK,MAAM,WAAW,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;gBACpD,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACvD,SAAS;QACX,CAAC;aAAM,IAAI,aAAa,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAhBW,QAAA,mBAAmB,uBAgB9B"}

View File

@@ -0,0 +1,3 @@
export declare const importMetaRegistry: {
readonly url: string;
};

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.importMetaRegistry = void 0;
const DEFAULT_SCRIPT_NAME = 'file:///__main.js';
const REGEXP_REPLACE_SLASHES = /\\/g;
const WIN32_PATH_REGEXP = /^[a-zA-Z]:[/\\]/;
// - ./runtime/importMetaRegistry.ts (this file) -> importMetaRegistry.url
// - ./runtime/index.ts -> globalThis.__ExpoImportMetaRegistry
// - <source>
const CALL_DEPTH = 3;
function getFileName(offset = 0) {
const originalStackFormatter = Error.prepareStackTrace;
const originalStackTraceLimit = Error.stackTraceLimit;
try {
Error.stackTraceLimit = offset;
Error.prepareStackTrace = (_err, stack) => stack[offset - 1]?.getFileName();
return new Error().stack;
}
finally {
Error.prepareStackTrace = originalStackFormatter;
Error.stackTraceLimit = originalStackTraceLimit;
}
}
/**
* Convert any platform-specific path to a POSIX path.
*/
function toPosixPath(filePath) {
return filePath.replace(REGEXP_REPLACE_SLASHES, '/');
}
exports.importMetaRegistry = {
get url() {
let scriptName = getFileName(CALL_DEPTH);
if (scriptName) {
if (scriptName[0] === '/') {
scriptName = `file://${scriptName}`;
}
else if (WIN32_PATH_REGEXP.test(scriptName)) {
scriptName = `file:///${scriptName}`;
}
}
return toPosixPath(scriptName || DEFAULT_SCRIPT_NAME);
},
};
//# sourceMappingURL=importMetaRegistry.js.map

View File

@@ -0,0 +1 @@
{"version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CAAC;gBAC9C,UAAU,GAAG,WAAW,UAAU,EAAE,CAAC;YACvC,CAAC;QACH,CAAC;QACD,OAAO,WAAW,CAAC,UAAU,IAAI,mBAAmB,CAAC,CAAC;IACxD,CAAC;CACF,CAAC"}

24
node_modules/expo-server/build/cjs/utils/matchers.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import type { Route } from '../manifest';
export declare function isResponse(input: unknown): input is Response;
export declare function parseParams(request: Request, route: Route): Record<string, string>;
/**
* Resolves a route's context key into a concrete path by substituting dynamic segments
* with actual param values.
*
* @example
* ```tsx
* resolveLoaderContextKey('/users/[id]`, { id: '123' }) // /users/123
* ```
*
* @see import('expo-router/src/utils/matchers').getSingularId
*/
export declare function resolveLoaderContextKey(contextKey: string, params: Record<string, string | string[]>): string;
export declare function getRedirectRewriteLocation(url: URL, request: Request, route: Route): URL;
/** Match `[page]` -> `page`
* @privateRemarks Ported from `expo-router/src/matchers.tsx`
*/
export declare function matchDynamicName(name: string): string | undefined;
/** Match `[...page]` -> `page`
* @privateRemarks Ported from `expo-router/src/matchers.tsx`
*/
export declare function matchDeepDynamicRouteName(name: string): string | undefined;

112
node_modules/expo-server/build/cjs/utils/matchers.js generated vendored Normal file
View File

@@ -0,0 +1,112 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isResponse = isResponse;
exports.parseParams = parseParams;
exports.resolveLoaderContextKey = resolveLoaderContextKey;
exports.getRedirectRewriteLocation = getRedirectRewriteLocation;
exports.matchDynamicName = matchDynamicName;
exports.matchDeepDynamicRouteName = matchDeepDynamicRouteName;
function isResponse(input) {
return !!input && typeof input === 'object' && input instanceof Response;
}
function parseParams(request, route) {
const params = {};
const { pathname } = new URL(request.url);
const match = route.namedRegex.exec(pathname);
if (match?.groups) {
for (const [key, value] of Object.entries(match.groups)) {
const namedKey = route.routeKeys[key];
params[namedKey] = value;
}
}
return params;
}
/**
* Resolves a route's context key into a concrete path by substituting dynamic segments
* with actual param values.
*
* @example
* ```tsx
* resolveLoaderContextKey('/users/[id]`, { id: '123' }) // /users/123
* ```
*
* @see import('expo-router/src/utils/matchers').getSingularId
*/
function resolveLoaderContextKey(contextKey, params) {
const normalizedKey = contextKey.startsWith('/') ? contextKey.slice(1) : contextKey;
// TODO(@hassankhan): Extract this logic into its own function and share with getRedirectRewriteLocation() below
const resolved = normalizedKey
.split('/')
.map((segment) => {
let match;
if ((match = matchDeepDynamicRouteName(segment))) {
const value = params[match];
if (value == null)
return segment;
return Array.isArray(value) ? value.join('/') : value;
}
if ((match = matchDynamicName(segment))) {
const value = params[match];
if (value == null)
return segment;
return Array.isArray(value) ? value.join('/') : value;
}
return segment;
})
.join('/');
return `/${resolved}`;
}
function getRedirectRewriteLocation(url, request, route) {
const originalQueryParams = url.searchParams.entries();
const params = parseParams(request, route);
const target = route.page
.split('/')
.map((segment) => {
let match;
if ((match = matchDynamicName(segment))) {
const value = params[match];
delete params[match];
return typeof value === 'string'
? value.split('/')[0] /* If we are redirecting from a catch-all route, we need to remove the extra segments */
: (value ?? segment);
}
else if ((match = matchDeepDynamicRouteName(segment))) {
const value = params[match];
delete params[match];
return value ?? segment;
}
else {
return segment;
}
})
.join('/');
const targetUrl = new URL(target, url.origin);
// NOTE: React Navigation doesn't differentiate between a path parameter
// and a search parameter. We have to preserve leftover search parameters
// to ensure we don't lose any intentional parameters with special meaning
for (const key in params)
targetUrl.searchParams.append(key, params[key]);
// NOTE(@krystofwoldrich): Query matching is not supported at the moment.
// Copy original query parameters to the target URL
for (const [key, value] of originalQueryParams) {
// NOTE(@krystofwoldrich): Params created from route overwrite existing (might be unexpected to the user)
if (!targetUrl.searchParams.has(key)) {
targetUrl.searchParams.append(key, value);
}
}
return targetUrl;
}
/** Match `[page]` -> `page`
* @privateRemarks Ported from `expo-router/src/matchers.tsx`
*/
function matchDynamicName(name) {
// Don't match `...` or `[` or `]` inside the brackets
return name.match(/^\[([^[\](?:\.\.\.)]+?)\]$/)?.[1]; // eslint-disable-line no-useless-escape
}
/** Match `[...page]` -> `page`
* @privateRemarks Ported from `expo-router/src/matchers.tsx`
*/
function matchDeepDynamicRouteName(name) {
return name.match(/^\[\.\.\.([^/]+?)\]$/)?.[1];
}
//# sourceMappingURL=matchers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"matchers.js","sourceRoot":"","sources":["../../../src/utils/matchers.ts"],"names":[],"mappings":";;AAEA,gCAEC;AAED,kCAWC;AAaD,0DAyBC;AAED,gEAyCC;AAKD,4CAGC;AAKD,8DAEC;AA/GD,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,QAAQ,CAAC;AAC3E,CAAC;AAED,SAAgB,WAAW,CAAC,OAAgB,EAAE,KAAY;IACxD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACxD,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACtC,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,uBAAuB,CACrC,UAAkB,EAClB,MAAyC;IAEzC,MAAM,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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AE,KAAK,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,sDAAsD;IACtD,OAAO,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,wCAAwC;AAChG,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CAAC,IAAY;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC"}

View File

@@ -0,0 +1,9 @@
import type { MiddlewareFunction, MiddlewareSettings } from '../types';
export interface MiddlewareModule {
default: MiddlewareFunction;
unstable_settings?: MiddlewareSettings;
}
/**
* Determines whether middleware should run for a given request based on matcher configuration.
*/
export declare function shouldRunMiddleware(request: Request, middleware: MiddlewareModule): boolean;

82
node_modules/expo-server/build/cjs/utils/middleware.js generated vendored Normal file
View File

@@ -0,0 +1,82 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.shouldRunMiddleware = shouldRunMiddleware;
const matchers_1 = require("./matchers");
/**
* Determines whether middleware should run for a given request based on matcher configuration.
*/
function shouldRunMiddleware(request, middleware) {
const matcher = middleware.unstable_settings?.matcher;
// No matcher means middleware runs on all requests
if (!matcher) {
return true;
}
const url = new URL(request.url);
const pathname = url.pathname;
// Check HTTP methods, if specified
if (matcher.methods) {
const methods = matcher.methods.map((method) => method.toUpperCase());
if (methods.length === 0 || !methods.includes(request.method)) {
return false;
}
}
// Check path patterns, if specified
if (matcher.patterns) {
const patterns = Array.isArray(matcher.patterns) ? matcher.patterns : [matcher.patterns];
if (patterns.length === 0) {
return false;
}
return patterns.some((pattern) => matchesPattern(pathname, pattern));
}
// If neither methods nor patterns are specified, run middleware on all requests
return true;
}
/**
* Tests if a pathname matches a given pattern. The matching order is as follows:
*
* - Exact string
* - Named parameters (supports `[param]` and `[...param]`)
* - Regular expression
*/
function matchesPattern(pathname, pattern) {
if (typeof pattern === 'string') {
if (pattern === pathname) {
return true;
}
if (hasNamedParameters(pattern)) {
return namedParamToRegex(pattern).test(pathname);
}
}
else if (pattern != null) {
return pattern.test(pathname);
}
return false;
}
/**
* Check if a pattern contains named parameters like `[postId]` or `[...slug]`
*/
function hasNamedParameters(pattern) {
return pattern.split('/').some((segment) => {
return (0, matchers_1.matchDynamicName)(segment) || (0, matchers_1.matchDeepDynamicRouteName)(segment);
});
}
/**
* Convert a pattern with named parameters to regex
*/
function namedParamToRegex(pattern) {
const normalizedPattern = pattern.replace(/\/$/, '') || '/';
const segments = normalizedPattern.split('/');
const regexSegments = segments.map((segment) => {
if (!segment)
return '';
if ((0, matchers_1.matchDeepDynamicRouteName)(segment)) {
return '.+';
}
if ((0, matchers_1.matchDynamicName)(segment)) {
return '[^/]+';
}
return segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
});
return new RegExp(`^${regexSegments.join('/')}(?:/)?$`);
}
//# sourceMappingURL=middleware.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/utils/middleware.ts"],"names":[],"mappings":";;AAWA,kDA8BC;AAxCD,yCAAyE;AAOzE;;GAEG;AACH,SAAgB,mBAAmB,CAAC,OAAgB,EAAE,UAA4B;IAChF,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAEtD,mDAAmD;IACnD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAE9B,mCAAmC;IACnC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,M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