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,19 @@
import { PageWillRender, PageFocusedEvent, PageBlurredEvent, PageRemoved } from './types';
export { PageWillRender, PageFocusedEvent, PageBlurredEvent, PageRemoved };
export type AnalyticsEvent = PageWillRender | PageFocusedEvent | PageBlurredEvent | PageRemoved;
type EventTypeName = AnalyticsEvent['type'];
type Payload<T extends EventTypeName> = Omit<Extract<AnalyticsEvent, {
type: T;
}>, 'type'>;
declare function addListener<EventType extends EventTypeName>(eventType: EventType, callback: (event: Payload<EventType>) => void): () => void;
export declare function emit<EventType extends EventTypeName>(type: EventType, event: Payload<EventType>): void;
export declare const unstable_navigationEvents: {
addListener: typeof addListener;
emit: typeof emit;
enable: () => void;
isEnabled: () => boolean;
saveCurrentPathname: () => void;
readonly currentPathname: string | undefined;
readonly currentParams: Record<string, string> | undefined;
};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigationEvents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1F,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC;AAE3E,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,WAAW,CAAC;AAShG,KAAK,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAC5C,KAAK,OAAO,CAAC,CAAC,SAAS,aAAa,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAM3F,iBAAS,WAAW,CAAC,SAAS,SAAS,aAAa,EAClD,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,KAAK,IAAI,cAe9C;AAED,wBAAgB,IAAI,CAAC,SAAS,SAAS,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,QAO/F;AAQD,eAAO,MAAM,yBAAyB;;;;;;;;CAsBrC,CAAC"}

View File

@@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unstable_navigationEvents = void 0;
exports.emit = emit;
const availableEvents = [
'pageWillRender',
'pageFocused',
'pageBlurred',
'pageRemoved',
];
const subscribers = {};
function addListener(eventType, callback) {
if (!availableEvents.includes(eventType)) {
throw new Error(`Unsupported event type: ${eventType}`);
}
if (!subscribers[eventType]) {
subscribers[eventType] = new Set();
}
subscribers[eventType].add(callback);
return () => {
subscribers[eventType].delete(callback);
if (subscribers[eventType].size === 0) {
delete subscribers[eventType];
}
};
}
function emit(type, event) {
const subscribersForEvent = subscribers[type];
if (subscribersForEvent) {
for (const callback of subscribersForEvent) {
callback(event);
}
}
}
let enabled = false;
let currentPathname = undefined;
let currentParams = undefined;
let currentPathnameListener = undefined;
exports.unstable_navigationEvents = {
addListener,
emit,
enable: () => {
enabled = true;
},
isEnabled: () => {
return enabled;
},
saveCurrentPathname: () => {
if (!enabled || currentPathnameListener)
return;
currentPathnameListener = addListener('pageFocused', (event) => {
currentPathname = event.pathname;
currentParams = event.params;
});
},
get currentPathname() {
return currentPathname;
},
get currentParams() {
return currentParams;
},
};
if (globalThis.expo) {
globalThis.expo.router = globalThis.expo.router || {};
if (!('navigationEvents' in globalThis.expo.router)) {
Object.defineProperties(globalThis.expo.router, {
navigationEvents: {
get() {
return exports.unstable_navigationEvents;
},
enumerable: true,
},
currentPathname: {
get() {
return currentPathname;
},
enumerable: true,
},
currentParams: {
get() {
return currentParams;
},
enumerable: true,
},
});
}
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,23 @@
export interface BasePageEvent {
pathname: string;
params: Record<string, string>;
screenId: string;
}
/**
* The rendering of the page started
*
* This can happen if screen is to be focused for the first time or when the screen is preloaded
*/
export interface PageWillRender extends BasePageEvent {
type: 'pageWillRender';
}
export interface PageFocusedEvent extends BasePageEvent {
type: 'pageFocused';
}
export interface PageBlurredEvent extends BasePageEvent {
type: 'pageBlurred';
}
export interface PageRemoved extends BasePageEvent {
type: 'pageRemoved';
}
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/navigationEvents/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,IAAI,EAAE,aAAa,CAAC;CACrB"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/navigationEvents/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface BasePageEvent {\n pathname: string;\n params: Record<string, string>;\n screenId: string;\n}\n\n/**\n * The rendering of the page started\n *\n * This can happen if screen is to be focused for the first time or when the screen is preloaded\n */\nexport interface PageWillRender extends BasePageEvent {\n type: 'pageWillRender';\n}\n\nexport interface PageFocusedEvent extends BasePageEvent {\n type: 'pageFocused';\n}\n\nexport interface PageBlurredEvent extends BasePageEvent {\n type: 'pageBlurred';\n}\n\nexport interface PageRemoved extends BasePageEvent {\n type: 'pageRemoved';\n}\n"]}

View File

@@ -0,0 +1,9 @@
import { type State } from '../fork/getPathFromState';
export declare function generateStringUrlForState(state: State | undefined): string | undefined;
export declare function getPathAndParamsFromStringUrl(urlString: string): {
pathname: string;
params: {
[k: string]: string;
};
};
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/navigationEvents/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAG5E,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAYtF;AAED,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM;;;;;EAM9D"}

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateStringUrlForState = generateStringUrlForState;
exports.getPathAndParamsFromStringUrl = getPathAndParamsFromStringUrl;
const getPathFromState_1 = require("../fork/getPathFromState");
const url_1 = require("../utils/url");
function generateStringUrlForState(state) {
if (!state) {
return undefined;
}
const { path: rawPath, params: nonPathParams } = (0, getPathFromState_1.getPathDataFromState)(state);
const url = (0, url_1.parseUrlUsingCustomBase)(rawPath);
for (const [key, value] of Object.entries(nonPathParams)) {
url.searchParams.append(key, value);
}
return `${decodeURIComponent(url.pathname)}${url.search}`;
}
function getPathAndParamsFromStringUrl(urlString) {
const url = (0, url_1.parseUrlUsingCustomBase)(urlString);
return {
pathname: url.pathname,
params: Object.fromEntries(url.searchParams.entries()),
};
}
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/navigationEvents/utils.ts"],"names":[],"mappings":";;AAGA,8DAYC;AAED,sEAMC;AAvBD,+DAA4E;AAC5E,sCAAuD;AAEvD,SAAgB,yBAAyB,CAAC,KAAwB;IAChE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,uCAAoB,EAAC,KAAK,CAAC,CAAC;IAC7E,MAAM,GAAG,GAAG,IAAA,6BAAuB,EAAC,OAAO,CAAC,CAAC;IAE7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;AAC5D,CAAC;AAED,SAAgB,6BAA6B,CAAC,SAAiB;IAC7D,MAAM,GAAG,GAAG,IAAA,6BAAuB,EAAC,SAAS,CAAC,CAAC;IAC/C,OAAO;QACL,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;KACvD,CAAC;AACJ,CAAC","sourcesContent":["import { getPathDataFromState, type State } from '../fork/getPathFromState';\nimport { parseUrlUsingCustomBase } from '../utils/url';\n\nexport function generateStringUrlForState(state: State | undefined): string | undefined {\n if (!state) {\n return undefined;\n }\n const { path: rawPath, params: nonPathParams } = getPathDataFromState(state);\n const url = parseUrlUsingCustomBase(rawPath);\n\n for (const [key, value] of Object.entries(nonPathParams)) {\n url.searchParams.append(key, value);\n }\n\n return `${decodeURIComponent(url.pathname)}${url.search}`;\n}\n\nexport function getPathAndParamsFromStringUrl(urlString: string) {\n const url = parseUrlUsingCustomBase(urlString);\n return {\n pathname: url.pathname,\n params: Object.fromEntries(url.searchParams.entries()),\n };\n}\n"]}