@expofp/loader 1.0.78 → 1.0.91
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/dist/bundle/ImportHttpRuntime.node-B85BNHJG.js +92 -0
- package/dist/bundle/ImportHttpRuntime.node-B85BNHJG.js.map +1 -0
- package/dist/bundle/bundle.js +236 -768
- package/dist/bundle/bundle.js.map +1 -1
- package/dist/bundle/fetch-retry.umd-g1itNdNw.js +115 -0
- package/dist/bundle/fetch-retry.umd-g1itNdNw.js.map +1 -0
- package/dist/esm/ImportHttpRuntime.node.d.ts +28 -0
- package/dist/esm/ImportHttpRuntime.node.js +139 -0
- package/dist/esm/_OLD_resolveRuntimeUrl.d.ts +1 -0
- package/dist/esm/_OLD_resolveRuntimeUrl.js +10 -0
- package/dist/esm/fetch.d.ts +1 -0
- package/dist/esm/fetch.js +14 -0
- package/dist/esm/importHttpRuntime.d.ts +1 -0
- package/dist/esm/importHttpRuntime.js +12 -0
- package/dist/esm/index.d.ts +10 -7
- package/dist/esm/index.js +40 -19
- package/dist/esm/resolve.d.ts +10 -44
- package/dist/esm/resolve.js +91 -295
- package/dist/esm/types.d.ts +11 -26
- package/package.json +3 -1
- package/dist/bundle/cssTextAssetResolver.offlineFunc-CWvHnYni.js +0 -19
- package/dist/bundle/cssTextAssetResolver.offlineFunc-CWvHnYni.js.map +0 -1
- package/dist/bundle/downloadOfflineZip-CNz_lUGZ.js +0 -2344
- package/dist/bundle/downloadOfflineZip-CNz_lUGZ.js.map +0 -1
- package/dist/bundle/legacyDataUrlBaseResolver.offlineFunc-DPaSp_zV.js +0 -87
- package/dist/bundle/legacyDataUrlBaseResolver.offlineFunc-DPaSp_zV.js.map +0 -1
- package/dist/bundle/makeOffline-Dj-0o5_7.js +0 -76
- package/dist/bundle/makeOffline-Dj-0o5_7.js.map +0 -1
- package/dist/bundle/makeOfflineBundle-D8tePWGI.js +0 -70
- package/dist/bundle/makeOfflineBundle-D8tePWGI.js.map +0 -1
- package/dist/bundle/saveOfflineZip.browser-BTQeRUY_.js +0 -7
- package/dist/bundle/saveOfflineZip.browser-BTQeRUY_.js.map +0 -1
- package/dist/bundle/tools-D0u8lBvQ.js +0 -102
- package/dist/bundle/tools-D0u8lBvQ.js.map +0 -1
- package/dist/esm/_OLD_fetchWithRetry.d.ts +0 -1
- package/dist/esm/_OLD_fetchWithRetry.js +0 -101
- package/dist/esm/importJson.d.ts +0 -2
- package/dist/esm/importJson.js +0 -57
- package/dist/esm/loadScript.d.ts +0 -16
- package/dist/esm/loadScript.js +0 -167
- package/dist/esm/logger.d.ts +0 -1
- package/dist/esm/logger.js +0 -5
- package/dist/esm/mutateManifest.d.ts +0 -2
- package/dist/esm/mutateManifest.js +0 -10
- package/dist/esm/offline/downloadOfflineZip.d.ts +0 -4
- package/dist/esm/offline/downloadOfflineZip.js +0 -15
- package/dist/esm/offline/generateZip.d.ts +0 -4
- package/dist/esm/offline/generateZip.js +0 -41
- package/dist/esm/offline/hashString.d.ts +0 -1
- package/dist/esm/offline/hashString.js +0 -16
- package/dist/esm/offline/index.d.ts +0 -14
- package/dist/esm/offline/index.js +0 -41
- package/dist/esm/offline/makeOffline.d.ts +0 -2
- package/dist/esm/offline/makeOffline.js +0 -144
- package/dist/esm/offline/makeOfflineBundle.d.ts +0 -4
- package/dist/esm/offline/makeOfflineBundle.js +0 -92
- package/dist/esm/offline/saveOfflineZip.browser.d.ts +0 -1
- package/dist/esm/offline/saveOfflineZip.browser.js +0 -3
- package/dist/esm/offline/saveOfflineZip.d.ts +0 -1
- package/dist/esm/offline/saveOfflineZip.js +0 -16
- package/dist/esm/offline/slugify.d.ts +0 -1
- package/dist/esm/offline/slugify.js +0 -61
- package/dist/esm/offline/tools.d.ts +0 -3
- package/dist/esm/offline/tools.js +0 -85
- package/dist/esm/resolvers/_OLD_expoResolver.d.ts +0 -1
- package/dist/esm/resolvers/_OLD_expoResolver.js +0 -49
- package/dist/esm/resolvers/assetResolver.d.ts +0 -6
- package/dist/esm/resolvers/assetResolver.js +0 -26
- package/dist/esm/resolvers/bundleAssetsResolver.d.ts +0 -2
- package/dist/esm/resolvers/bundleAssetsResolver.js +0 -20
- package/dist/esm/resolvers/cssTextAssetResolver.d.ts +0 -8
- package/dist/esm/resolvers/cssTextAssetResolver.js +0 -15
- package/dist/esm/resolvers/cssTextAssetResolver.offlineFunc.d.ts +0 -2
- package/dist/esm/resolvers/cssTextAssetResolver.offlineFunc.js +0 -22
- package/dist/esm/resolvers/expoRuntimeBranchResolver.d.ts +0 -2
- package/dist/esm/resolvers/expoRuntimeBranchResolver.js +0 -20
- package/dist/esm/resolvers/expoRuntimeGetBranchResolver.d.ts +0 -2
- package/dist/esm/resolvers/expoRuntimeGetBranchResolver.js +0 -14
- package/dist/esm/resolvers/expoRuntimeResolver.d.ts +0 -2
- package/dist/esm/resolvers/expoRuntimeResolver.js +0 -39
- package/dist/esm/resolvers/httpResolver.d.ts +0 -5
- package/dist/esm/resolvers/httpResolver.js +0 -14
- package/dist/esm/resolvers/index.d.ts +0 -2
- package/dist/esm/resolvers/index.js +0 -22
- package/dist/esm/resolvers/legacyAssetUrlsResolver.d.ts +0 -9
- package/dist/esm/resolvers/legacyAssetUrlsResolver.js +0 -116
- package/dist/esm/resolvers/legacyDataResolver.d.ts +0 -8
- package/dist/esm/resolvers/legacyDataResolver.js +0 -20
- package/dist/esm/resolvers/legacyDataUrlBaseResolver.d.ts +0 -8
- package/dist/esm/resolvers/legacyDataUrlBaseResolver.js +0 -15
- package/dist/esm/resolvers/legacyDataUrlBaseResolver.offlineFunc.d.ts +0 -2
- package/dist/esm/resolvers/legacyDataUrlBaseResolver.offlineFunc.js +0 -129
- package/dist/esm/returnCachedRef.d.ts +0 -1
- package/dist/esm/returnCachedRef.js +0 -12
- package/dist/esm/shared.d.ts +0 -8
- package/dist/esm/shared.js +0 -273
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// Module-level caches
|
|
2
|
-
const inputToSlug = new Map();
|
|
3
|
-
const slugToInput = new Map();
|
|
4
|
-
const WINDOWS_RESERVED = new Set([
|
|
5
|
-
"con", "prn", "aux", "nul",
|
|
6
|
-
"com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9",
|
|
7
|
-
"lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9",
|
|
8
|
-
]);
|
|
9
|
-
function makeBaseSlug(input) {
|
|
10
|
-
let slug = input
|
|
11
|
-
.normalize("NFKD")
|
|
12
|
-
// All non letters/numbers → "-"
|
|
13
|
-
.replace(/[^\p{Letter}\p{Number}]+/gu, "-")
|
|
14
|
-
// Collapse multiple "-"
|
|
15
|
-
.replace(/-+/g, "-")
|
|
16
|
-
// Trim "-" from start/end
|
|
17
|
-
.replace(/^-|-$/g, "")
|
|
18
|
-
.toLowerCase();
|
|
19
|
-
// Strip forbidden Windows characters just in case
|
|
20
|
-
slug = slug.replace(/[<>:"/\\|?*]/g, "");
|
|
21
|
-
// Windows forbids trailing space/period
|
|
22
|
-
slug = slug.replace(/[. ]+$/g, "");
|
|
23
|
-
// Fallback if everything was stripped
|
|
24
|
-
if (!slug)
|
|
25
|
-
slug = "file";
|
|
26
|
-
// Avoid bare reserved device names
|
|
27
|
-
if (WINDOWS_RESERVED.has(slug)) {
|
|
28
|
-
slug += "-file";
|
|
29
|
-
}
|
|
30
|
-
return slug;
|
|
31
|
-
}
|
|
32
|
-
export function slugifyFsUnique(input) {
|
|
33
|
-
// If we've seen this exact input before, return the same slug
|
|
34
|
-
const existing = inputToSlug.get(input);
|
|
35
|
-
if (existing)
|
|
36
|
-
return existing;
|
|
37
|
-
const base = makeBaseSlug(input);
|
|
38
|
-
let candidate = base;
|
|
39
|
-
let counter = 2;
|
|
40
|
-
while (true) {
|
|
41
|
-
const existingInput = slugToInput.get(candidate);
|
|
42
|
-
if (!existingInput) {
|
|
43
|
-
// Free slug → claim it for this input
|
|
44
|
-
slugToInput.set(candidate, input);
|
|
45
|
-
inputToSlug.set(input, candidate);
|
|
46
|
-
return candidate;
|
|
47
|
-
}
|
|
48
|
-
if (existingInput === input) {
|
|
49
|
-
// Same input somehow (super defensive)
|
|
50
|
-
inputToSlug.set(input, candidate);
|
|
51
|
-
return candidate;
|
|
52
|
-
}
|
|
53
|
-
// Collision: same slug already used by different input → add suffix
|
|
54
|
-
candidate = `${base}-${counter++}`;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// // Optional: to reset between runs/tests
|
|
58
|
-
// export function resetSlugCache() {
|
|
59
|
-
// inputToSlug.clear();
|
|
60
|
-
// slugToInput.clear();
|
|
61
|
-
// }
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
import { hashString } from './hashString';
|
|
3
|
-
import { slugifyFsUnique } from './slugify';
|
|
4
|
-
const log = debug('efp:loader:offline');
|
|
5
|
-
export function makeUniqueJsonTargetPathFromString(str, namespace = '') {
|
|
6
|
-
// const hash = hashString(str);
|
|
7
|
-
let result = slugifyFsUnique(str); // + '-' + hash;
|
|
8
|
-
if (namespace) {
|
|
9
|
-
result = `${slugifyFsUnique(namespace)}$${result}`;
|
|
10
|
-
}
|
|
11
|
-
if (result.endsWith('/')) {
|
|
12
|
-
result += 'index.json';
|
|
13
|
-
}
|
|
14
|
-
else if (!result.endsWith('.json')) {
|
|
15
|
-
result += '.json';
|
|
16
|
-
}
|
|
17
|
-
return './' + result;
|
|
18
|
-
// handle directory case
|
|
19
|
-
}
|
|
20
|
-
export function relativeUrlToFilePath(relativeUrl) {
|
|
21
|
-
const urlObj = new URL(relativeUrl, 'http://example.com');
|
|
22
|
-
const pathname = relativeUrl.startsWith('/') ? urlObj.pathname : urlObj.pathname.slice(1);
|
|
23
|
-
const search = urlObj.search;
|
|
24
|
-
return pathnameSearchToPahthname(pathname, search);
|
|
25
|
-
}
|
|
26
|
-
const MAX_PATHNAME_LENGTH = 120;
|
|
27
|
-
function pathnameSearchToPahthname(pathname, search) {
|
|
28
|
-
// for directory
|
|
29
|
-
if (pathname.endsWith('/')) {
|
|
30
|
-
// just trust it for now
|
|
31
|
-
// TODO: need to combine with the logic below
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
// if path doesn't end with extension, throw
|
|
35
|
-
if (!pathname.match(/\.[^\/]+$/)) {
|
|
36
|
-
throw new Error(`Cannot make target path from URL without file extension: ${pathname}`);
|
|
37
|
-
}
|
|
38
|
-
const extension = pathname.substring(pathname.lastIndexOf('.'));
|
|
39
|
-
let pathnameWithoutExtension = pathname.substring(0, pathname.lastIndexOf('.'));
|
|
40
|
-
// check the pathname contains only valid fs characters
|
|
41
|
-
const invalidPathnameChars = pathnameWithoutExtension.match(/[^a-zA-Z0-9\-._\/]/g);
|
|
42
|
-
if (invalidPathnameChars) {
|
|
43
|
-
const fixedPathnameWithoutExtension = slugifyFsUnique(pathnameWithoutExtension);
|
|
44
|
-
log(`Pathname contains invalid filesystem characters (${[...new Set(invalidPathnameChars)].join(', ')}), slugifying it: ${pathnameWithoutExtension}${extension} => ${fixedPathnameWithoutExtension}${extension}`);
|
|
45
|
-
pathnameWithoutExtension = fixedPathnameWithoutExtension;
|
|
46
|
-
}
|
|
47
|
-
pathname = pathnameWithoutExtension + extension;
|
|
48
|
-
if (pathname.length > MAX_PATHNAME_LENGTH) {
|
|
49
|
-
log(`Pathname is too long (${pathname.length} characters), truncating to ${MAX_PATHNAME_LENGTH} characters: ${pathname}`);
|
|
50
|
-
pathname = pathname.substring(0, MAX_PATHNAME_LENGTH - extension.length) + extension;
|
|
51
|
-
}
|
|
52
|
-
if (search) {
|
|
53
|
-
// create a hash from search params
|
|
54
|
-
const hash = hashString(search);
|
|
55
|
-
const dotIndex = pathname.lastIndexOf('.');
|
|
56
|
-
if (dotIndex !== -1) {
|
|
57
|
-
pathname = `${pathname.slice(0, dotIndex)}.${hash}${pathname.slice(dotIndex)}`;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
pathname = `${pathname}${hash}`;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return pathname;
|
|
65
|
-
}
|
|
66
|
-
export function makeTargetPathFromUrl(url, prefix = '') {
|
|
67
|
-
// https://example.com/dir1/dir2/a.js => "{prefix}{origin-slug}/dir1/dir2/a.js";
|
|
68
|
-
// https://example.com/dir1/dir2/a.js?params => "{prefix}{origin-slug}/dir1/dir2/a{paramsmd5hash}.js";
|
|
69
|
-
// use slugify.ts
|
|
70
|
-
try {
|
|
71
|
-
new URL(url);
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
debugger;
|
|
75
|
-
}
|
|
76
|
-
const urlObj = new URL(url);
|
|
77
|
-
const origin = `${urlObj.protocol}//${urlObj.host}`;
|
|
78
|
-
const originSlug = slugifyFsUnique(origin);
|
|
79
|
-
const pathname = pathnameSearchToPahthname(urlObj.pathname, urlObj.search);
|
|
80
|
-
// // handle directory case
|
|
81
|
-
// if (pathname.endsWith('/')) {
|
|
82
|
-
// pathname += '__index.json';
|
|
83
|
-
// }
|
|
84
|
-
return `./${prefix}${originSlug}${pathname}`;
|
|
85
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// import { parseRefValue } from '../resolve';
|
|
2
|
-
// import { log } from '../logger';
|
|
3
|
-
// import type { Resolver } from '../types';
|
|
4
|
-
// import { httpResolver } from './httpResolver';
|
|
5
|
-
export {};
|
|
6
|
-
// // const SCHEMA = 'expo';
|
|
7
|
-
// export const expoResolver: Resolver = {
|
|
8
|
-
// // canResolve(ref: string) {
|
|
9
|
-
// // return canResolveRefSchema(ref, SCHEMA);
|
|
10
|
-
// // },
|
|
11
|
-
// schema: 'expo',
|
|
12
|
-
// async resolveRef(ref: string) {
|
|
13
|
-
// log('expoResolver resolveRef:', ref);
|
|
14
|
-
// // if (!this.canResolve(ref)) throw new Error(`Unexpected ref in httpResolver: ${ref}`);
|
|
15
|
-
// const expo = parseRefValue(ref);
|
|
16
|
-
// // try to resolve {$ref: `https://${expo}.expofp.com/manifest.json`}
|
|
17
|
-
// try {
|
|
18
|
-
// return await httpResolver.resolveRef(`https://${expo}.expofp.com/manifest.json`);
|
|
19
|
-
// } catch (error) {
|
|
20
|
-
// log(`Falling back to legacyDataUrlBase (no manifest for '${expo}')`);
|
|
21
|
-
// }
|
|
22
|
-
// // ET: fallback, remove in the future, when all expos support manifest.json
|
|
23
|
-
// // and throw instead
|
|
24
|
-
// const data = {
|
|
25
|
-
// expo,
|
|
26
|
-
// runtime: { $ref: `expo-runtime-get-branch:${expo}` },
|
|
27
|
-
// legacyData: { $ref: `legacy-data:https://${expo}.expofp.com/data/` },
|
|
28
|
-
// };
|
|
29
|
-
// return data;
|
|
30
|
-
// },
|
|
31
|
-
// // async *makeOfflineRef(ref: string) {
|
|
32
|
-
// // log('expoRuntimeBranchResolver makeOfflineRef:', ref);
|
|
33
|
-
// // if (!this.canResolve(ref)) throw new Error(`Unexpected ref: ${ref}`);
|
|
34
|
-
// // const value = parseRefValue(ref);
|
|
35
|
-
// // const refData = deepClone(await this.resolveRef(ref));
|
|
36
|
-
// // const targetFilePath = makeUniqueJsonTargetPathFromString(value, SCHEMA_PREFIX_BASE);
|
|
37
|
-
// // const data = yield* makeOfflineInternal(refData);
|
|
38
|
-
// // yield { data: data, targetFilePath };
|
|
39
|
-
// // return { $ref: targetFilePath, [STOP_RESOLVING]: true };
|
|
40
|
-
// // },
|
|
41
|
-
// // async *makeOfflineRef2(ref: string) {
|
|
42
|
-
// // const refData = deepClone(await this.resolveRef(ref));
|
|
43
|
-
// // const targetFilePath = makeUniqueJsonTargetPathFromString(ref);
|
|
44
|
-
// // const data = yield* makeOfflineInternal(refData);
|
|
45
|
-
// // yield { data, targetFilePath };
|
|
46
|
-
// // return targetFilePath;
|
|
47
|
-
// // },
|
|
48
|
-
// offlineMethod: 'resolveRef',
|
|
49
|
-
// };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { parseRefValue } from '../resolve';
|
|
2
|
-
import { log } from '../logger';
|
|
3
|
-
export function resolveAssetRefSync(ref) {
|
|
4
|
-
log('assetResolver resolveRef:', ref);
|
|
5
|
-
// if (!assetResolver.canResolve(ref)) throw new Error(`Unexpected ref: ${ref}`);
|
|
6
|
-
return parseRefValue(ref);
|
|
7
|
-
}
|
|
8
|
-
export const assetResolver = {
|
|
9
|
-
schema: 'asset',
|
|
10
|
-
resolveRef: async (ref) => resolveAssetRefSync(ref),
|
|
11
|
-
offlineFunc: 'localizeRef',
|
|
12
|
-
};
|
|
13
|
-
// async *makeOfflineRef(ref: string) {
|
|
14
|
-
// log('assetResolver makeOfflineRef:', ref);
|
|
15
|
-
// if (!this.canResolve(ref)) throw new Error(`Unexpected ref: ${ref}`);
|
|
16
|
-
// const url = parseRefValue(ref);
|
|
17
|
-
// const targetFilePath = makeTargetPathFromUrl(url);
|
|
18
|
-
// yield { url, targetFilePath };
|
|
19
|
-
// return { $ref: `asset:${targetFilePath}`, [STOP_RESOLVING]: true };
|
|
20
|
-
// },
|
|
21
|
-
// async *makeOfflineRef2(ref: string) {
|
|
22
|
-
// const url = parseRefValue(ref);
|
|
23
|
-
// const targetFilePath = makeTargetPathFromUrl(url);
|
|
24
|
-
// yield { url, targetFilePath };
|
|
25
|
-
// return `asset:${targetFilePath}`;
|
|
26
|
-
// },
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { importJson } from '../importJson';
|
|
2
|
-
import { parseRefValue } from '../resolve';
|
|
3
|
-
import { returnCachedRef } from '../returnCachedRef';
|
|
4
|
-
import { log } from '../logger';
|
|
5
|
-
export const bundleAssetsResolver = {
|
|
6
|
-
schema: 'bundle-assets',
|
|
7
|
-
async resolveRef(ref, context) {
|
|
8
|
-
log('bundleAssetsResolver resolveRef:', ref);
|
|
9
|
-
const url = parseRefValue(ref);
|
|
10
|
-
return returnCachedRef(ref, context.refCache, async () => {
|
|
11
|
-
const files = await importJson(url, context);
|
|
12
|
-
const baseUrl = url.substring(0, url.lastIndexOf('/') + 1);
|
|
13
|
-
const assets = files.map((file) => ({
|
|
14
|
-
$ref: `asset+${baseUrl}${file}`,
|
|
15
|
-
}));
|
|
16
|
-
return assets;
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
offlineFunc: 'localizeRef',
|
|
20
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
export declare const log: debug.Debugger;
|
|
3
|
-
export declare const SCHEMA = "css-text-asset";
|
|
4
|
-
export declare const cssTextAssetResolver: {
|
|
5
|
-
schema: string;
|
|
6
|
-
resolveRef(ref: string): Promise<string>;
|
|
7
|
-
offlineFunc: (ref: string, _context: import("../resolve").ResolveContextInternal) => AsyncGenerator<import("../types").LocalFile, string, void>;
|
|
8
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
import { parseRefValue } from '../resolve';
|
|
3
|
-
export const log = debug('efp:loader:resolver:cssTextAsset');
|
|
4
|
-
export const SCHEMA = 'css-text-asset';
|
|
5
|
-
export const cssTextAssetResolver = {
|
|
6
|
-
schema: SCHEMA,
|
|
7
|
-
resolveRef(ref) {
|
|
8
|
-
log('cssTextAssetResolver resolveRef:', ref);
|
|
9
|
-
return Promise.resolve(parseRefValue(ref));
|
|
10
|
-
},
|
|
11
|
-
offlineFunc: async function* (ref, _context) {
|
|
12
|
-
const { offlineFunc } = await import('./cssTextAssetResolver.offlineFunc');
|
|
13
|
-
return yield* offlineFunc(ref, _context);
|
|
14
|
-
},
|
|
15
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { makeTargetPathFromUrl } from '../offline/tools';
|
|
2
|
-
import { parseRefValue } from '../resolve';
|
|
3
|
-
import { log, SCHEMA } from './cssTextAssetResolver';
|
|
4
|
-
export const offlineFunc = async function* (ref, _context) {
|
|
5
|
-
const originalCss = parseRefValue(ref);
|
|
6
|
-
const { urls, css } = extractCssUrls(originalCss, makeTargetPathFromUrl);
|
|
7
|
-
for (const { originalUrl, replacedUrl } of urls) {
|
|
8
|
-
yield { url: originalUrl, targetFilePath: replacedUrl };
|
|
9
|
-
}
|
|
10
|
-
return `${SCHEMA}:${css}`;
|
|
11
|
-
};
|
|
12
|
-
function extractCssUrls(css, replace) {
|
|
13
|
-
const urlRegex = /url\(\s*(['"]?)(.*?)\1\s*\)/g;
|
|
14
|
-
const urls = [];
|
|
15
|
-
const replacedCss = css.replace(urlRegex, (_match, quote, url) => {
|
|
16
|
-
const replacedUrl = replace(url);
|
|
17
|
-
urls.push({ originalUrl: url, replacedUrl });
|
|
18
|
-
log('Extracted and replaced URL in CSS:', url, '->', replacedUrl);
|
|
19
|
-
return `url(${quote}${replacedUrl}${quote})`;
|
|
20
|
-
});
|
|
21
|
-
return { urls, css: replacedCss };
|
|
22
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { importJson } from '../importJson';
|
|
2
|
-
import { parseRefValue } from '../resolve';
|
|
3
|
-
import { returnCachedRef } from '../returnCachedRef';
|
|
4
|
-
import { log } from '../logger';
|
|
5
|
-
const BASE_URL = 'https://efp-runtime.expofp.com/';
|
|
6
|
-
export const expoRuntimeBranchResolver = {
|
|
7
|
-
schema: 'expo-runtime-branch',
|
|
8
|
-
async resolveRef(ref, context) {
|
|
9
|
-
log('expoRuntimeBranchResolver resolveRef:', ref);
|
|
10
|
-
const branch = parseRefValue(ref);
|
|
11
|
-
const branchUrl = `${BASE_URL}branches/${branch}.json`;
|
|
12
|
-
return returnCachedRef(ref, context.refCache, async () => {
|
|
13
|
-
const { release } = await importJson(branchUrl, context);
|
|
14
|
-
return {
|
|
15
|
-
$ref: `expo-runtime+https://efp-runtime.expofp.com/releases/${release}/`,
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
offlineFunc: 'resolveRef',
|
|
20
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { importJson } from '../importJson';
|
|
2
|
-
import { parseRefValue } from '../resolve';
|
|
3
|
-
import { log } from '../logger';
|
|
4
|
-
// const SCHEMA = 'expo-runtime-get-branch';
|
|
5
|
-
export const expoRuntimeGetBranchResolver = {
|
|
6
|
-
schema: 'expo-runtime-get-branch',
|
|
7
|
-
async resolveRef(ref, context) {
|
|
8
|
-
log('expoRuntimeGetBranchResolver resolveRef:', ref);
|
|
9
|
-
const expo = parseRefValue(ref);
|
|
10
|
-
const url = `https://${expo}.expofp.com/get-branch`;
|
|
11
|
-
return importJson(url, context);
|
|
12
|
-
},
|
|
13
|
-
offlineFunc: 'resolveRef',
|
|
14
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { log } from '../logger';
|
|
2
|
-
import { parseRefValue } from '../resolve';
|
|
3
|
-
import { deepFreeze } from '../shared';
|
|
4
|
-
// const SCHEMA = 'expo-runtime';
|
|
5
|
-
export const expoRuntimeResolver = {
|
|
6
|
-
schema: 'expo-runtime',
|
|
7
|
-
// canResolve(ref: string) {
|
|
8
|
-
// return canResolveRefSchema(ref, SCHEMA);
|
|
9
|
-
// },
|
|
10
|
-
async resolveRef(ref) {
|
|
11
|
-
log('expoRuntimeResolver resolveRef:', ref);
|
|
12
|
-
// if (!this.canResolve(ref)) throw new Error(`Unexpected ref: ${ref}`);
|
|
13
|
-
const url = parseRefValue(ref);
|
|
14
|
-
const data = {
|
|
15
|
-
entry: { $ref: `asset+${url}expofp.js` },
|
|
16
|
-
assets: { $ref: `bundle-assets+${url}bundle.json` },
|
|
17
|
-
};
|
|
18
|
-
deepFreeze(data);
|
|
19
|
-
return data;
|
|
20
|
-
},
|
|
21
|
-
// async *makeOfflineRef(ref: string) {
|
|
22
|
-
// log('expoRuntimeResolver makeOfflineRef:', ref);
|
|
23
|
-
// if (!this.canResolve(ref)) throw new Error(`Unexpected ref: ${ref}`);
|
|
24
|
-
// const url = parseRefValue(ref);
|
|
25
|
-
// const refData = deepClone(await this.resolveRef(ref));
|
|
26
|
-
// const targetFilePath = makeUniqueJsonTargetPathFromString(url, SCHEMA_PREFIX_BASE);
|
|
27
|
-
// const data = yield* makeOfflineInternal(refData);
|
|
28
|
-
// yield { data: data, targetFilePath };
|
|
29
|
-
// return { $ref: targetFilePath, [STOP_RESOLVING]: true };
|
|
30
|
-
// },
|
|
31
|
-
// async *makeOfflineRef2(ref: string) {
|
|
32
|
-
// const refData = deepClone(await this.resolveRef(ref));
|
|
33
|
-
// const targetFilePath = makeUniqueJsonTargetPathFromString(ref);
|
|
34
|
-
// const data = yield* makeOfflineInternal(refData);
|
|
35
|
-
// yield { data, targetFilePath };
|
|
36
|
-
// return targetFilePath;
|
|
37
|
-
// },
|
|
38
|
-
offlineFunc: 'resolveRef',
|
|
39
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { importJson } from '../importJson';
|
|
2
|
-
import { log } from '../logger';
|
|
3
|
-
export const httpResolver = {
|
|
4
|
-
canResolve(ref) {
|
|
5
|
-
return ref.startsWith('http://') || ref.startsWith('https://') || ref.startsWith('./');
|
|
6
|
-
},
|
|
7
|
-
resolveRef(ref, context) {
|
|
8
|
-
log('httpResolver resolveRef:', ref);
|
|
9
|
-
if (!this.canResolve(ref))
|
|
10
|
-
throw new Error(`Unexpected ref in httpResolver: ${ref}`);
|
|
11
|
-
return importJson(ref, context);
|
|
12
|
-
},
|
|
13
|
-
offlineFunc: 'resolveRef',
|
|
14
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { assetResolver } from './assetResolver';
|
|
2
|
-
import { bundleAssetsResolver } from './bundleAssetsResolver';
|
|
3
|
-
import { cssTextAssetResolver } from './cssTextAssetResolver';
|
|
4
|
-
import { expoRuntimeBranchResolver } from './expoRuntimeBranchResolver';
|
|
5
|
-
import { expoRuntimeGetBranchResolver } from './expoRuntimeGetBranchResolver';
|
|
6
|
-
import { expoRuntimeResolver } from './expoRuntimeResolver';
|
|
7
|
-
import { httpResolver } from './httpResolver';
|
|
8
|
-
import { legacyAssetUrlsResolver } from './legacyAssetUrlsResolver';
|
|
9
|
-
import { legacyDataResolver } from './legacyDataResolver';
|
|
10
|
-
import { legacyDataUrlBaseResolver } from './legacyDataUrlBaseResolver';
|
|
11
|
-
export const resolvers = [
|
|
12
|
-
httpResolver,
|
|
13
|
-
bundleAssetsResolver,
|
|
14
|
-
assetResolver,
|
|
15
|
-
expoRuntimeResolver,
|
|
16
|
-
expoRuntimeBranchResolver,
|
|
17
|
-
expoRuntimeGetBranchResolver,
|
|
18
|
-
cssTextAssetResolver,
|
|
19
|
-
legacyDataResolver,
|
|
20
|
-
legacyAssetUrlsResolver,
|
|
21
|
-
legacyDataUrlBaseResolver,
|
|
22
|
-
];
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ResolveContextInternal } from '../resolve';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated Use legacyDataUrlBaseResolver instead
|
|
4
|
-
*/
|
|
5
|
-
export declare const legacyAssetUrlsResolver: {
|
|
6
|
-
schema: string;
|
|
7
|
-
resolveRef(ref: string, context: ResolveContextInternal): Promise<any>;
|
|
8
|
-
offlineFunc: "resolveRef";
|
|
9
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { loadAndWaitGlobal } from '../loadScript';
|
|
2
|
-
import { parseRefValue } from '../resolve';
|
|
3
|
-
import { returnCachedRef } from '../returnCachedRef';
|
|
4
|
-
import { log } from '../logger';
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use legacyDataUrlBaseResolver instead
|
|
7
|
-
*/
|
|
8
|
-
export const legacyAssetUrlsResolver = {
|
|
9
|
-
schema: 'legacy-asset-urls',
|
|
10
|
-
resolveRef(ref, context) {
|
|
11
|
-
log('legacyAssetUrlsResolver resolveRef:', ref);
|
|
12
|
-
const signal = context.signal;
|
|
13
|
-
return returnCachedRef(ref, context.refCache, async () => {
|
|
14
|
-
const dataUrlBase = parseRefValue(ref);
|
|
15
|
-
// load version.js - it will contain "window.__fpDataVersion = "20251129003330106";"
|
|
16
|
-
const versionUrl = `${dataUrlBase}version.js`;
|
|
17
|
-
try {
|
|
18
|
-
await loadAndWaitGlobal(versionUrl, {
|
|
19
|
-
globalVar: '__fpDataVersion',
|
|
20
|
-
timeoutMs: 30_000,
|
|
21
|
-
signal,
|
|
22
|
-
});
|
|
23
|
-
context.importCallback?.(versionUrl, 'script');
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
console.warn(`Could not load version.js at ${versionUrl}, proceeding without it`);
|
|
27
|
-
}
|
|
28
|
-
const version = globalThis.__fpDataVersion || (+new Date()).toString();
|
|
29
|
-
// const filesUrl = `${dataUrlBase}files.json?v=${version}`;
|
|
30
|
-
const dataUrl = `${dataUrlBase}data.js?v=${version}`;
|
|
31
|
-
// const filesPromise = importJson<string[]>(filesUrl, context).catch(() => {
|
|
32
|
-
// console.warn(`Could not load files.json at ${filesUrl}, proceeding without it`);
|
|
33
|
-
// return [];
|
|
34
|
-
// });
|
|
35
|
-
// data.js
|
|
36
|
-
const dataLoadPromise = loadAndWaitGlobal(dataUrl, {
|
|
37
|
-
globalVar: '__data',
|
|
38
|
-
signal,
|
|
39
|
-
});
|
|
40
|
-
context.importCallback?.(dataUrl, 'script');
|
|
41
|
-
// wf.data.js
|
|
42
|
-
const wfDataUrl = `${dataUrlBase}wf.data.js?v=${version}`;
|
|
43
|
-
const wfDataLoadPromise = loadAndWaitGlobal(wfDataUrl, {
|
|
44
|
-
globalVar: '__wfData',
|
|
45
|
-
signal,
|
|
46
|
-
})
|
|
47
|
-
.then(() => {
|
|
48
|
-
context.importCallback?.(wfDataUrl, 'script');
|
|
49
|
-
})
|
|
50
|
-
.catch(() => {
|
|
51
|
-
console.warn(`Could not load wf.data.js at ${wfDataUrl}, proceeding without it`);
|
|
52
|
-
});
|
|
53
|
-
// fp.svg.js
|
|
54
|
-
delete globalThis.__fpLayers;
|
|
55
|
-
const fpSvgUrl = `${dataUrlBase}fp.svg.js?v=${version}`;
|
|
56
|
-
const fpSvgLoadPromise = loadAndWaitGlobal(fpSvgUrl, {
|
|
57
|
-
globalVar: '__fp',
|
|
58
|
-
signal,
|
|
59
|
-
});
|
|
60
|
-
context.importCallback?.(fpSvgUrl, 'script');
|
|
61
|
-
await Promise.all([dataLoadPromise, wfDataLoadPromise, fpSvgLoadPromise]);
|
|
62
|
-
const __fpLayers = (globalThis.__fpLayers ?? []);
|
|
63
|
-
const fpLayerFiles = __fpLayers.map((x) => `fp.svg.${x.name}.js`);
|
|
64
|
-
for (const layerFile of fpLayerFiles) {
|
|
65
|
-
const layerUrl = `${dataUrlBase}${layerFile}?v=${version}`;
|
|
66
|
-
context.importCallback?.(layerUrl, 'script');
|
|
67
|
-
}
|
|
68
|
-
// const files = await filesPromise;...files,
|
|
69
|
-
const data = globalThis.__data || {};
|
|
70
|
-
const dataFiles = ['data.js', 'wf.data.js', 'fp.svg.js', ...fpLayerFiles];
|
|
71
|
-
const dataFilesAssets = dataFiles.reduce((map, file) => {
|
|
72
|
-
map[file] = { $ref: `asset+${dataUrlBase}${file}?v=${version}` };
|
|
73
|
-
return map;
|
|
74
|
-
}, {});
|
|
75
|
-
// return {};
|
|
76
|
-
return { ...dataFilesAssets, ...populateDataJsAssetsMap(dataUrlBase, data) };
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
offlineFunc: 'resolveRef',
|
|
80
|
-
};
|
|
81
|
-
function populateDataJsAssetsMap(dataUrlBase, data) {
|
|
82
|
-
const links = new Set();
|
|
83
|
-
function addLink(link) {
|
|
84
|
-
if (typeof link === 'string' && link.length > 0) {
|
|
85
|
-
// if (!link.startsWith('http://') && !link.startsWith('https://')) {
|
|
86
|
-
// link = dataUrlBase + link;
|
|
87
|
-
// }
|
|
88
|
-
links.add(link);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
addLink(data.logo);
|
|
92
|
-
data.exhibitors?.forEach((e) => {
|
|
93
|
-
addLink(e.logo);
|
|
94
|
-
// add same files but with __small and __tiny suffixes
|
|
95
|
-
if (e.logo) {
|
|
96
|
-
const dotIndex = e.logo.lastIndexOf('.');
|
|
97
|
-
if (dotIndex !== -1) {
|
|
98
|
-
const name = e.logo.substring(0, dotIndex);
|
|
99
|
-
const ext = e.logo.substring(dotIndex);
|
|
100
|
-
addLink(`${name}__small${ext}`);
|
|
101
|
-
addLink(`${name}__tiny${ext}`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
e.gallery?.forEach((img) => addLink(img));
|
|
105
|
-
});
|
|
106
|
-
data.events?.forEach((e) => {
|
|
107
|
-
addLink(e.logoFile);
|
|
108
|
-
e.speakers?.forEach((s) => {
|
|
109
|
-
addLink(s.photoFile);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
return Array.from(links).reduce((map, link) => {
|
|
113
|
-
map[link] = { $ref: `asset+${dataUrlBase}${link}` };
|
|
114
|
-
return map;
|
|
115
|
-
}, {});
|
|
116
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { parseRefValue } from '../resolve';
|
|
2
|
-
import { returnCachedRef } from '../returnCachedRef';
|
|
3
|
-
import { log } from '../logger';
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use legacyDataUrlBaseResolver instead
|
|
6
|
-
*/
|
|
7
|
-
export const legacyDataResolver = {
|
|
8
|
-
schema: 'legacy-data',
|
|
9
|
-
resolveRef(ref, context) {
|
|
10
|
-
log('legacyDataResolver resolveRef:', ref);
|
|
11
|
-
return returnCachedRef(ref, context.refCache, async () => {
|
|
12
|
-
const dataUrlBase = parseRefValue(ref);
|
|
13
|
-
return {
|
|
14
|
-
_to_remove_for_offline_to_work_dataUrlBase: dataUrlBase,
|
|
15
|
-
legacyAssetUrls: { $ref: `legacy-asset-urls+${dataUrlBase}` },
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
offlineFunc: 'resolveRef',
|
|
20
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
export declare const log: debug.Debugger;
|
|
3
|
-
export declare const SCHEMA = "legacy-data-url-base";
|
|
4
|
-
export declare const legacyDataUrlBaseResolver: {
|
|
5
|
-
schema: string;
|
|
6
|
-
resolveRef(ref: string): Promise<string>;
|
|
7
|
-
offlineFunc: (ref: string, _context: import("../resolve").ResolveContextInternal) => AsyncGenerator<import("../types").LocalFile, string, void>;
|
|
8
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
import { parseRefValue } from '../resolve';
|
|
3
|
-
export const log = debug('efp:loader:resolver:legacyDataUrlBase');
|
|
4
|
-
export const SCHEMA = 'legacy-data-url-base';
|
|
5
|
-
export const legacyDataUrlBaseResolver = {
|
|
6
|
-
schema: SCHEMA,
|
|
7
|
-
resolveRef(ref) {
|
|
8
|
-
log('legacyDataResolver resolveRef:', ref);
|
|
9
|
-
return Promise.resolve(parseRefValue(ref));
|
|
10
|
-
},
|
|
11
|
-
offlineFunc: async function* (ref, _context) {
|
|
12
|
-
const { offlineFunc } = await import('./legacyDataUrlBaseResolver.offlineFunc');
|
|
13
|
-
return yield* offlineFunc(ref, _context);
|
|
14
|
-
},
|
|
15
|
-
};
|