chore: add mobile app

This commit is contained in:
2026-02-07 22:33:02 +01:00
parent db34640acc
commit e89384ad4e
29327 changed files with 3886944 additions and 12 deletions
+23
View File
@@ -0,0 +1,23 @@
/**
* Converts a Blob to an ArrayBuffer.
*/
export function blobToArrayBufferAsync(blob: Blob): Promise<ArrayBuffer> {
if (typeof blob.arrayBuffer === 'function') {
return blob.arrayBuffer();
}
return legacyBlobToArrayBufferAsync(blob);
}
/**
* Converts a Blob to an ArrayBuffer using the FileReader API.
*/
export async function legacyBlobToArrayBufferAsync(blob: Blob): Promise<ArrayBuffer> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
resolve(reader.result as ArrayBuffer);
};
reader.onerror = reject;
reader.readAsArrayBuffer(blob);
});
}
+17
View File
@@ -0,0 +1,17 @@
// Copyright 2015-present 650 Industries. All rights reserved.
/// <reference path="../ts-declarations/react-native.d.ts" />
import SourceCode from 'react-native/Libraries/NativeModules/specs/NativeSourceCode';
export function getBundleUrl(): string | null {
let scriptURL = SourceCode.getConstants().scriptURL;
if (scriptURL == null) {
return null;
}
if (scriptURL.startsWith('/')) {
scriptURL = `file://${scriptURL}`;
}
const url = new URL(scriptURL);
return url.toString();
}
+5
View File
@@ -0,0 +1,5 @@
// Copyright 2015-present 650 Industries. All rights reserved.
export function getBundleUrl(): string | null {
return null;
}
+21
View File
@@ -0,0 +1,21 @@
// Copyright 2015-present 650 Industries. All rights reserved.
export function getBundleUrl(): string | null {
let scriptURL: string | null | undefined = null;
if (typeof window === 'undefined') {
// For server runtime, we use the filename of the current script
// @ts-ignore The react-native tsconfig doesn't support CJS
scriptURL = 'file://' + __filename;
} else {
// TODO: Try to support `import.meta.url` when the ecosystem supports ESM,
// and jest doesn't throw SyntaxError when accessing `import.meta`.
scriptURL = (document.currentScript as HTMLScriptElement)?.src;
}
if (scriptURL == null) {
return null;
}
const url = new URL(scriptURL);
return `${url.protocol}//${url.host}${url.pathname}`;
}