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,6 @@
import React, { type PropsWithChildren } from 'react';
export declare function Head(props: PropsWithChildren): null;
export declare namespace Head {
var Provider: React.ExoticComponent<React.FragmentProps>;
}
//# sourceMappingURL=ExpoHead.android.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExpoHead.android.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHead.android.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,wBAAgB,IAAI,CAAC,KAAK,EAAE,iBAAiB,QAE5C;yBAFe,IAAI"}

View File

@@ -0,0 +1,12 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Head = Head;
const react_1 = __importDefault(require("react"));
function Head(props) {
return null;
}
Head.Provider = react_1.default.Fragment;
//# sourceMappingURL=ExpoHead.android.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExpoHead.android.js","sourceRoot":"","sources":["../../src/head/ExpoHead.android.tsx"],"names":[],"mappings":";;;;;AAEA,oBAEC;AAJD,kDAAsD;AAEtD,SAAgB,IAAI,CAAC,KAAwB;IAC3C,OAAO,IAAI,CAAC;AACd,CAAC;AAED,IAAI,CAAC,QAAQ,GAAG,eAAK,CAAC,QAAQ,CAAC","sourcesContent":["import React, { type PropsWithChildren } from 'react';\n\nexport function Head(props: PropsWithChildren) {\n return null;\n}\n\nHead.Provider = React.Fragment;\n"]}

8
node_modules/expo-router/build/head/ExpoHead.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import React from 'react';
import { HelmetProvider } from '../../vendor/react-helmet-async/lib';
export declare const Head: React.FC<{
children?: React.ReactNode;
}> & {
Provider: typeof HelmetProvider;
};
//# sourceMappingURL=ExpoHead.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExpoHead.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAU,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAO7E,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,GAAG;IAC5D,QAAQ,EAAE,OAAO,cAAc,CAAC;CAOjC,CAAC"}

View File

@@ -0,0 +1,5 @@
import React from 'react';
export declare const Head: ((props: React.PropsWithChildren) => React.ReactNode) & {
Provider: React.ComponentType;
};
//# sourceMappingURL=ExpoHead.ios.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExpoHead.ios.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHead.ios.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAc,MAAM,OAAO,CAAC;AA4TnC,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,iBAAiB,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG;IACzE,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC;CACI,CAAC"}

261
node_modules/expo-router/build/head/ExpoHead.ios.js generated vendored Normal file
View File

@@ -0,0 +1,261 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Head = void 0;
const react_1 = __importDefault(require("react"));
const useIsFocused_1 = require("../useIsFocused");
const ExpoHeadModule_1 = require("./ExpoHeadModule");
const url_1 = require("./url");
const hooks_1 = require("../hooks");
function urlToId(url) {
return url.replace(/[^a-zA-Z0-9]/g, '-');
}
function getLastSegment(path) {
// Remove the extension
const lastSegment = path.split('/').pop() ?? '';
return lastSegment.replace(/\.[^/.]+$/, '').split('?')[0];
}
// TODO: Use Head Provider to collect all props so only one Head is rendered for a given route.
function useAddressableLink() {
const pathname = (0, hooks_1.useUnstableGlobalHref)();
const params = (0, hooks_1.useLocalSearchParams)();
const url = (0, url_1.getStaticUrlFromExpoRouter)(pathname);
return { url, pathname, params };
}
function useMetaChildren(children) {
return react_1.default.useMemo(() => {
const renderableChildren = [];
const metaChildren = [];
react_1.default.Children.forEach(children, (child) => {
if (!react_1.default.isValidElement(child)) {
return;
}
if (typeof child.type === 'string') {
metaChildren.push(child);
}
else {
renderableChildren.push(child);
}
});
return { children: renderableChildren, metaChildren };
}, [children]);
}
function serializedMetaChildren(meta) {
const validMeta = meta.filter((child) => child.type === 'meta' || child.type === 'title');
return validMeta.map((child) => {
if (child.type === 'title') {
return {
type: 'title',
props: {
children: child.props &&
typeof child.props === 'object' &&
'children' in child.props &&
typeof child.props.children === 'string'
? child.props.children
: undefined,
},
};
}
return {
type: 'meta',
props: {
property: child.props &&
typeof child.props === 'object' &&
'property' in child.props &&
typeof child.props.property === 'string'
? child.props.property
: undefined,
content: child.props &&
typeof child.props === 'object' &&
'content' in child.props &&
typeof child.props.content === 'string'
? child.props.content
: undefined,
},
};
});
}
function useActivityFromMetaChildren(meta) {
const { url: href, pathname } = useAddressableLink();
const previousMeta = react_1.default.useRef([]);
const cachedActivity = react_1.default.useRef({});
const sortedMeta = react_1.default.useMemo(() => serializedMetaChildren(meta), [meta]);
const url = react_1.default.useMemo(() => {
const urlMeta = sortedMeta.find((child) => child.type === 'meta' && child.props.property === 'og:url');
if (urlMeta) {
// Support =`/foo/bar` -> `https://example.com/foo/bar`
if (urlMeta.props.content?.startsWith('/')) {
return (0, url_1.getStaticUrlFromExpoRouter)(urlMeta.props.content);
}
return urlMeta.props.content;
}
return href;
}, [sortedMeta, href]);
const title = react_1.default.useMemo(() => {
const titleTag = sortedMeta.find((child) => child.type === 'title');
if (titleTag) {
return titleTag.props.children ?? '';
}
const titleMeta = sortedMeta.find((child) => child.type === 'meta' && child.props.property === 'og:title');
if (titleMeta) {
return titleMeta.props.content ?? '';
}
return getLastSegment(pathname);
}, [sortedMeta, pathname]);
const activity = react_1.default.useMemo(() => {
if (!!previousMeta.current &&
!!cachedActivity.current &&
deepObjectCompare(previousMeta.current, sortedMeta)) {
return cachedActivity.current;
}
previousMeta.current = sortedMeta;
const userActivity = {};
sortedMeta.forEach((child) => {
if (
// <meta />
child.type === 'meta') {
const { property, content } = child.props;
switch (property) {
case 'og:description':
userActivity.description = content;
break;
// Custom properties
case 'expo:handoff':
userActivity.isEligibleForHandoff = isTruthy(content);
break;
case 'expo:spotlight':
userActivity.isEligibleForSearch = isTruthy(content);
break;
}
// // <meta name="keywords" content="foo,bar,baz" />
// if (["keywords"].includes(name)) {
// userActivity.keywords = Array.isArray(content)
// ? content
// : content.split(",");
// }
}
});
cachedActivity.current = userActivity;
return userActivity;
}, [meta, pathname, href]);
const parsedActivity = {
keywords: [title],
...activity,
title,
webpageURL: url,
activityType: ExpoHeadModule_1.ExpoHead.activities.INDEXED_ROUTE,
userInfo: {
// TODO: This may need to be versioned in the future, e.g. `_v1` if we change the format.
href,
},
};
return parsedActivity;
}
function isTruthy(value) {
return [true, 'true'].includes(value);
}
function HeadNative(props) {
const isFocused = (0, useIsFocused_1.useIsFocused)();
if (!isFocused) {
return <UnfocusedHead />;
}
return <FocusedHead {...props}/>;
}
function UnfocusedHead(props) {
const { children } = useMetaChildren(props.children);
return <>{children}</>;
}
function FocusedHead(props) {
const { metaChildren, children } = useMetaChildren(props.children);
const activity = useActivityFromMetaChildren(metaChildren);
useRegisterCurrentActivity(activity);
return <>{children}</>;
}
// segments => activity
const activities = new Map();
function useRegisterCurrentActivity(activity) {
// ID is tied to Expo Router and agnostic of URLs to ensure dynamic parameters are not considered.
// Using all segments ensures that cascading routes are considered.
const activityId = urlToId((0, hooks_1.usePathname)() || '/');
const cascadingId = urlToId((0, hooks_1.useSegments)().join('-') || '-');
const activityIds = Array.from(activities.keys());
const cascadingActivity = react_1.default.useMemo(() => {
// Get all nested activities together, then update the id to match the current pathname.
// This enables cases like `/user/[name]/post/[id]` to match all nesting, while still having a URL-specific ID, i.e. `/user/evanbacon/post/123`
const cascadingActivity = activities.has(cascadingId)
? {
...activities.get(cascadingId),
...activity,
id: activityId,
}
: {
...activity,
id: activityId,
};
activities.set(cascadingId, cascadingActivity);
return cascadingActivity;
}, [cascadingId, activityId, activity, activityIds]);
const previousActivity = react_1.default.useRef(null);
react_1.default.useEffect(() => {
if (!cascadingActivity) {
return () => { };
}
if (!!previousActivity.current &&
deepObjectCompare(previousActivity.current, cascadingActivity)) {
return () => { };
}
previousActivity.current = cascadingActivity;
if (!cascadingActivity.id) {
throw new Error('Activity must have an ID');
}
// If no features are enabled, then skip registering the activity
if (cascadingActivity.isEligibleForHandoff || cascadingActivity.isEligibleForSearch) {
ExpoHeadModule_1.ExpoHead?.createActivity(cascadingActivity);
}
return () => { };
}, [cascadingActivity]);
react_1.default.useEffect(() => {
return () => {
if (activityId) {
ExpoHeadModule_1.ExpoHead?.suspendActivity(activityId);
}
};
}, [activityId]);
}
function deepObjectCompare(a, b) {
if (typeof a !== typeof b) {
return false;
}
if (typeof a === 'object') {
if (Array.isArray(a) !== Array.isArray(b)) {
return false;
}
if (Array.isArray(a)) {
if (a.length !== b.length) {
return false;
}
return a.every((item, index) => deepObjectCompare(item, b[index]));
}
// handle null
if (a === null || b === null) {
return a === b;
}
const aKeys = Object.keys(a);
const bKeys = Object.keys(b);
if (aKeys.length !== bKeys.length) {
return false;
}
return aKeys.every((key) => deepObjectCompare(a[key], b[key]));
}
return a === b;
}
HeadNative.Provider = react_1.default.Fragment;
function HeadShim(props) {
return null;
}
HeadShim.Provider = react_1.default.Fragment;
// Native Head is only enabled in bare iOS apps.
exports.Head = ExpoHeadModule_1.ExpoHead ? HeadNative : HeadShim;
//# sourceMappingURL=ExpoHead.ios.js.map

File diff suppressed because one or more lines are too long

22
node_modules/expo-router/build/head/ExpoHead.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Head = void 0;
const react_1 = __importDefault(require("react"));
const lib_1 = require("../../vendor/react-helmet-async/lib");
const useIsFocused_1 = require("../useIsFocused");
function FocusedHelmet({ children }) {
return <lib_1.Helmet>{children}</lib_1.Helmet>;
}
const Head = ({ children }) => {
const isFocused = (0, useIsFocused_1.useIsFocused)();
if (!isFocused) {
return null;
}
return <FocusedHelmet>{children}</FocusedHelmet>;
};
exports.Head = Head;
exports.Head.Provider = lib_1.HelmetProvider;
//# sourceMappingURL=ExpoHead.js.map

1
node_modules/expo-router/build/head/ExpoHead.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ExpoHead.js","sourceRoot":"","sources":["../../src/head/ExpoHead.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,6DAA6E;AAC7E,kDAA+C;AAE/C,SAAS,aAAa,CAAC,EAAE,QAAQ,EAAkC;IACjE,OAAO,CAAC,YAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,YAAM,CAAC,CAAC;AACrC,CAAC;AAEM,MAAM,IAAI,GAEb,CAAC,EAAE,QAAQ,EAAkC,EAAE,EAAE;IACnD,MAAM,SAAS,GAAG,IAAA,2BAAY,GAAE,CAAC;IACjC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,CAAC;AACnD,CAAC,CAAC;AARW,QAAA,IAAI,QAQf;AAEF,YAAI,CAAC,QAAQ,GAAG,oBAAc,CAAC","sourcesContent":["import React from 'react';\n\nimport { Helmet, HelmetProvider } from '../../vendor/react-helmet-async/lib';\nimport { useIsFocused } from '../useIsFocused';\n\nfunction FocusedHelmet({ children }: { children?: React.ReactNode }) {\n return <Helmet>{children}</Helmet>;\n}\n\nexport const Head: React.FC<{ children?: React.ReactNode }> & {\n Provider: typeof HelmetProvider;\n} = ({ children }: { children?: React.ReactNode }) => {\n const isFocused = useIsFocused();\n if (!isFocused) {\n return null;\n }\n return <FocusedHelmet>{children}</FocusedHelmet>;\n};\n\nHead.Provider = HelmetProvider;\n"]}

View File

@@ -0,0 +1,34 @@
export type UserActivity = {
id?: string;
/**
* The activity title should be clear and concise. This text describes the content of the link, like “Photo taken on July 27, 2020” or “Conversation with Maria”. Use nouns for activity titles.
*/
title?: string;
description?: string;
webpageURL?: string;
keywords?: string[];
activityType: string;
phrase?: string;
thumbnailURL?: string;
userInfo?: Record<string, string>;
isEligibleForHandoff?: boolean;
isEligibleForPrediction?: boolean;
isEligibleForSearch?: boolean;
/** Local file path for an image */
imageUrl?: string;
darkImageUrl?: string;
dateModified?: Date;
expirationDate?: Date;
};
declare let ExpoHead: {
activities: {
INDEXED_ROUTE: string;
};
getLaunchActivity(): UserActivity;
createActivity(userActivity: UserActivity): void;
clearActivitiesAsync(ids: string[]): Promise<void>;
suspendActivity(id: string): void;
revokeActivity(id: string): void;
} | null;
export { ExpoHead };
//# sourceMappingURL=ExpoHeadModule.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExpoHeadModule.d.ts","sourceRoot":"","sources":["../../src/head/ExpoHeadModule.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB,YAAY,EAAE,MAAM,CAAC;IAErB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,IAAI,CAAC;CACvB,CAAC;AAEF,QAAA,IAAI,QAAQ,EAAE;IACZ,UAAU,EAAE;QACV,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,iBAAiB,IAAI,YAAY,CAAC;IAClC,cAAc,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IACjD,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,GAAG,IAAW,CAAC;AAOhB,OAAO,EAAE,QAAQ,EAAE,CAAC"}

12
node_modules/expo-router/build/head/ExpoHeadModule.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
// isEligibleForPrediction
// https://developer.apple.com/documentation/foundation/nsuseractivity/2980674-iseligibleforprediction
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpoHead = void 0;
let ExpoHead = null;
exports.ExpoHead = ExpoHead;
// If running in Expo Go.
if (typeof expo !== 'undefined' && !globalThis.expo?.modules?.ExpoGo) {
exports.ExpoHead = ExpoHead = globalThis.expo?.modules?.ExpoHead;
}
//# sourceMappingURL=ExpoHeadModule.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExpoHeadModule.js","sourceRoot":"","sources":["../../src/head/ExpoHeadModule.ts"],"names":[],"mappings":";AAAA,0BAA0B;AAC1B,sGAAsG;;;AA+BtG,IAAI,QAAQ,GASD,IAAI,CAAC;AAOP,4BAAQ;AALjB,yBAAyB;AACzB,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrE,mBAAA,QAAQ,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC;AAChD,CAAC","sourcesContent":["// isEligibleForPrediction\n// https://developer.apple.com/documentation/foundation/nsuseractivity/2980674-iseligibleforprediction\n\nexport type UserActivity = {\n id?: string;\n /**\n * The activity title should be clear and concise. This text describes the content of the link, like “Photo taken on July 27, 2020” or “Conversation with Maria”. Use nouns for activity titles.\n */\n title?: string;\n description?: string;\n webpageURL?: string;\n keywords?: string[];\n // TODO: Get this automatically somehow\n activityType: string;\n // TODO: Maybe something like robots.txt?\n phrase?: string;\n\n thumbnailURL?: string;\n\n userInfo?: Record<string, string>;\n\n isEligibleForHandoff?: boolean;\n isEligibleForPrediction?: boolean;\n isEligibleForSearch?: boolean;\n\n /** Local file path for an image */\n imageUrl?: string;\n darkImageUrl?: string;\n dateModified?: Date;\n expirationDate?: Date;\n};\n\nlet ExpoHead: {\n activities: {\n INDEXED_ROUTE: string;\n };\n getLaunchActivity(): UserActivity;\n createActivity(userActivity: UserActivity): void;\n clearActivitiesAsync(ids: string[]): Promise<void>;\n suspendActivity(id: string): void;\n revokeActivity(id: string): void;\n} | null = null;\n\n// If running in Expo Go.\nif (typeof expo !== 'undefined' && !globalThis.expo?.modules?.ExpoGo) {\n ExpoHead = globalThis.expo?.modules?.ExpoHead;\n}\n\nexport { ExpoHead };\n"]}

2
node_modules/expo-router/build/head/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export * from './ExpoHead';
//# sourceMappingURL=index.d.ts.map

1
node_modules/expo-router/build/head/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/head/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}

18
node_modules/expo-router/build/head/index.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./ExpoHead"), exports);
//# sourceMappingURL=index.js.map

1
node_modules/expo-router/build/head/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/head/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B","sourcesContent":["export * from './ExpoHead';\n"]}

3
node_modules/expo-router/build/head/url.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare function getOriginFromConstants(): string | null;
export declare function getStaticUrlFromExpoRouter(pathname: string): string;
//# sourceMappingURL=url.d.ts.map

1
node_modules/expo-router/build/head/url.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/head/url.tsx"],"names":[],"mappings":"AAqEA,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAmBtD;AAeD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,UAI1D"}

86
node_modules/expo-router/build/head/url.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOriginFromConstants = getOriginFromConstants;
exports.getStaticUrlFromExpoRouter = getStaticUrlFromExpoRouter;
const expo_constants_1 = __importDefault(require("expo-constants"));
const protocolWarningString = `{ plugins: [["expo-router", { origin: "...<URL>..." }]] }`;
/** `lodash.memoize` */
function memoize(fn) {
const cache = {};
return ((...args) => {
const key = JSON.stringify(args);
if (cache[key]) {
return cache[key];
}
const result = fn(...args);
cache[key] = result;
return result;
});
}
function sanitizeUrl(url) {
const parsed = new URL(url);
// Allow empty protocol, http, and https
const validProtocol = !parsed.protocol || parsed.protocol === 'http:' || parsed.protocol === 'https:';
if (!validProtocol) {
throwOrAlert(`Expo Head: Native origin has invalid protocol "${parsed.protocol}" for URL in Expo Config: ${protocolWarningString}.`);
}
parsed.pathname = '';
parsed.search = '';
parsed.hash = '';
parsed.protocol ??= 'https:';
return parsed.toString().replace(/\/$/, '');
}
const memoSanitizeUrl = memoize(sanitizeUrl);
function getHeadOriginFromConstants() {
// This will require a rebuild in bare-workflow to update.
const manifest = expo_constants_1.default.expoConfig;
const origin = manifest?.extra?.router?.headOrigin ??
manifest?.extra?.router?.origin ??
manifest?.extra?.router?.generatedOrigin;
if (!origin) {
throwOrAlert(`Expo Head: Add the handoff origin to the Expo Config (requires rebuild). Add the Config Plugin ${protocolWarningString}, where \`origin\` is the hosted URL.`);
// Fallback value that shouldn't be used for real.
return 'https://expo.dev';
}
// Without this, the URL will go to an IP address which is not allowed.
if (!origin.match(/^http(s)?:\/\//)) {
console.warn(`Expo Head: origin "${origin}" is missing a \`https://\` protocol. ${protocolWarningString}.`);
}
// Return the development URL last so the user gets all production warnings first.
return memoSanitizeUrl(origin);
}
function getOriginFromConstants() {
// This will require a rebuild in bare-workflow to update.
const manifest = expo_constants_1.default.expoConfig;
const origin = manifest?.extra?.router?.headOrigin ??
manifest?.extra?.router?.origin ??
manifest?.extra?.router?.generatedOrigin;
if (!origin) {
throwOrAlert(`Expo RSC: Add the origin to the Expo Config (requires rebuild). Add the Config Plugin ${protocolWarningString}, where \`origin\` is the hosted URL.`);
// Fallback value that shouldn't be used for real.
return 'http://localhost:3000';
}
// Return the development URL last so the user gets all production warnings first.
return memoSanitizeUrl(origin);
}
function throwOrAlert(msg) {
// Production apps fatally crash which is often not helpful.
if (
// @ts-ignore: process is defined
process.env.NODE_ENV === 'production') {
console.error(msg);
alert(msg);
}
else {
throw new Error(msg);
}
}
function getStaticUrlFromExpoRouter(pathname) {
// const host = "https://expo.io";
// Append the URL we'd find in context
return getHeadOriginFromConstants() + pathname;
}
//# sourceMappingURL=url.js.map

1
node_modules/expo-router/build/head/url.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long