@ankhorage/expo-runtime 2.1.0 → 2.2.0
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/CHANGELOG.md +6 -0
- package/README.md +2 -1
- package/dist/bundledMediaRegistrySource.d.ts +6 -0
- package/dist/bundledMediaRegistrySource.d.ts.map +1 -0
- package/dist/bundledMediaRegistrySource.js +28 -0
- package/dist/bundledMediaRegistrySource.js.map +1 -0
- package/dist/bundledMediaResolver.d.ts +10 -0
- package/dist/bundledMediaResolver.d.ts.map +1 -0
- package/dist/bundledMediaResolver.js +9 -0
- package/dist/bundledMediaResolver.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/bundledMediaRegistrySource.test.ts +25 -0
- package/src/bundledMediaRegistrySource.ts +39 -0
- package/src/bundledMediaResolver.test.ts +31 -0
- package/src/bundledMediaResolver.ts +27 -0
- package/src/index.ts +12 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# EXPO-RUNTIME
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Declarative runtime integration for Expo apps: maps app capabilities to permissions, packages, config plugins, providers, and adapters
|
|
9
9
|
|
|
@@ -18,6 +18,7 @@ Declarative runtime integration for Expo apps: maps app capabilities to permissi
|
|
|
18
18
|
- [createExpoRuntimeRegistry sequence](././paradox/diagrams/sequences/create-expo-runtime-registry.mmd)
|
|
19
19
|
- [executeExpoRuntimeAction sequence](././paradox/diagrams/sequences/execute-expo-runtime-action.mmd)
|
|
20
20
|
- [ExpoBarcodeScannerAdapter sequence](././paradox/diagrams/sequences/expo-barcode-scanner-adapter.mmd)
|
|
21
|
+
- [getExpoBundledMediaRegistrySource sequence](././paradox/diagrams/sequences/get-expo-bundled-media-registry-source.mmd)
|
|
21
22
|
- [resolveExpoRuntimeGeneratedAppOutput sequence](././paradox/diagrams/sequences/resolve-expo-runtime-generated-app-output.mmd)
|
|
22
23
|
- [resolveExpoRuntimeNativeOutput sequence](././paradox/diagrams/sequences/resolve-expo-runtime-native-output.mmd)
|
|
23
24
|
- [resolveExpoRuntimePlan sequence](././paradox/diagrams/sequences/resolve-expo-runtime-plan.mmd)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface ExpoBundledMediaRegistrySourceEntry {
|
|
2
|
+
readonly path: string;
|
|
3
|
+
readonly requirePath: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function getExpoBundledMediaRegistrySource(entries: readonly ExpoBundledMediaRegistrySourceEntry[]): string;
|
|
6
|
+
//# sourceMappingURL=bundledMediaRegistrySource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundledMediaRegistrySource.d.ts","sourceRoot":"","sources":["../src/bundledMediaRegistrySource.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,SAAS,mCAAmC,EAAE,GACtD,MAAM,CAeR"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function getExpoBundledMediaRegistrySource(entries) {
|
|
2
|
+
const normalized = normalizeEntries(entries);
|
|
3
|
+
const rows = normalized.map((entry) => ` ${JSON.stringify(entry.path)}: require(${JSON.stringify(entry.requirePath)}),`);
|
|
4
|
+
return [
|
|
5
|
+
"import type { ExpoBundledMediaRegistry } from '@ankhorage/expo-runtime';",
|
|
6
|
+
'',
|
|
7
|
+
'declare const require: (path: string) => ExpoBundledMediaRegistry[string];',
|
|
8
|
+
'',
|
|
9
|
+
'export const bundledMediaRegistry: ExpoBundledMediaRegistry = {',
|
|
10
|
+
...rows,
|
|
11
|
+
'};',
|
|
12
|
+
'',
|
|
13
|
+
].join('\n');
|
|
14
|
+
}
|
|
15
|
+
function normalizeEntries(entries) {
|
|
16
|
+
const byPath = new Map();
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
const existing = byPath.get(entry.path);
|
|
19
|
+
if (existing !== undefined && existing !== entry.requirePath) {
|
|
20
|
+
throw new Error(`Bundled media path has conflicting require targets: ${entry.path}`);
|
|
21
|
+
}
|
|
22
|
+
byPath.set(entry.path, entry.requirePath);
|
|
23
|
+
}
|
|
24
|
+
return [...byPath.entries()]
|
|
25
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
26
|
+
.map(([path, requirePath]) => ({ path, requirePath }));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=bundledMediaRegistrySource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundledMediaRegistrySource.js","sourceRoot":"","sources":["../src/bundledMediaRegistrySource.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,iCAAiC,CAC/C,OAAuD;IAEvD,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CACzB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAC7F,CAAC;IACF,OAAO;QACL,0EAA0E;QAC1E,EAAE;QACF,4EAA4E;QAC5E,EAAE;QACF,iEAAiE;QACjE,GAAG,IAAI;QACP,IAAI;QACJ,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAS,gBAAgB,CACvB,OAAuD;IAEvD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CAAC,uDAAuD,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACvF,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;SACzB,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;SACpD,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["export interface ExpoBundledMediaRegistrySourceEntry {\n readonly path: string;\n readonly requirePath: string;\n}\n\nexport function getExpoBundledMediaRegistrySource(\n entries: readonly ExpoBundledMediaRegistrySourceEntry[],\n): string {\n const normalized = normalizeEntries(entries);\n const rows = normalized.map(\n (entry) => ` ${JSON.stringify(entry.path)}: require(${JSON.stringify(entry.requirePath)}),`,\n );\n return [\n \"import type { ExpoBundledMediaRegistry } from '@ankhorage/expo-runtime';\",\n '',\n 'declare const require: (path: string) => ExpoBundledMediaRegistry[string];',\n '',\n 'export const bundledMediaRegistry: ExpoBundledMediaRegistry = {',\n ...rows,\n '};',\n '',\n ].join('\\n');\n}\n\nfunction normalizeEntries(\n entries: readonly ExpoBundledMediaRegistrySourceEntry[],\n): readonly ExpoBundledMediaRegistrySourceEntry[] {\n const byPath = new Map<string, string>();\n for (const entry of entries) {\n const existing = byPath.get(entry.path);\n if (existing !== undefined && existing !== entry.requirePath) {\n throw new Error(`Bundled media path has conflicting require targets: ${entry.path}`);\n }\n byPath.set(entry.path, entry.requirePath);\n }\n return [...byPath.entries()]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([path, requirePath]) => ({ path, requirePath }));\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MediaAsset } from '@ankhorage/contracts';
|
|
2
|
+
export type ExpoBundledMediaValue = string | number | Readonly<Record<string, unknown>>;
|
|
3
|
+
export type ExpoBundledMediaRegistry = Readonly<Record<string, ExpoBundledMediaValue>>;
|
|
4
|
+
export interface ExpoBundledMediaResolverArgs {
|
|
5
|
+
readonly asset: MediaAsset;
|
|
6
|
+
}
|
|
7
|
+
export type ExpoBundledMediaResolver = (args: ExpoBundledMediaResolverArgs) => ExpoBundledMediaValue | null;
|
|
8
|
+
export declare function createExpoBundledMediaResolver(registry: ExpoBundledMediaRegistry): ExpoBundledMediaResolver;
|
|
9
|
+
export declare function resolveExpoBundledMediaAsset(registry: ExpoBundledMediaRegistry, asset: MediaAsset): ExpoBundledMediaValue | null;
|
|
10
|
+
//# sourceMappingURL=bundledMediaResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundledMediaResolver.d.ts","sourceRoot":"","sources":["../src/bundledMediaResolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAExF,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAEvF,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,MAAM,wBAAwB,GAAG,CACrC,IAAI,EAAE,4BAA4B,KAC/B,qBAAqB,GAAG,IAAI,CAAC;AAElC,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,wBAAwB,GACjC,wBAAwB,CAE1B;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,wBAAwB,EAClC,KAAK,EAAE,UAAU,GAChB,qBAAqB,GAAG,IAAI,CAG9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function createExpoBundledMediaResolver(registry) {
|
|
2
|
+
return ({ asset }) => resolveExpoBundledMediaAsset(registry, asset);
|
|
3
|
+
}
|
|
4
|
+
export function resolveExpoBundledMediaAsset(registry, asset) {
|
|
5
|
+
if (asset.source.kind !== 'bundled')
|
|
6
|
+
return null;
|
|
7
|
+
return registry[asset.source.path] ?? null;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=bundledMediaResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundledMediaResolver.js","sourceRoot":"","sources":["../src/bundledMediaResolver.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,8BAA8B,CAC5C,QAAkC;IAElC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,4BAA4B,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,QAAkC,EAClC,KAAiB;IAEjB,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACjD,OAAO,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAC7C,CAAC","sourcesContent":["import type { MediaAsset } from '@ankhorage/contracts';\n\nexport type ExpoBundledMediaValue = string | number | Readonly<Record<string, unknown>>;\n\nexport type ExpoBundledMediaRegistry = Readonly<Record<string, ExpoBundledMediaValue>>;\n\nexport interface ExpoBundledMediaResolverArgs {\n readonly asset: MediaAsset;\n}\n\nexport type ExpoBundledMediaResolver = (\n args: ExpoBundledMediaResolverArgs,\n) => ExpoBundledMediaValue | null;\n\nexport function createExpoBundledMediaResolver(\n registry: ExpoBundledMediaRegistry,\n): ExpoBundledMediaResolver {\n return ({ asset }) => resolveExpoBundledMediaAsset(registry, asset);\n}\n\nexport function resolveExpoBundledMediaAsset(\n registry: ExpoBundledMediaRegistry,\n asset: MediaAsset,\n): ExpoBundledMediaValue | null {\n if (asset.source.kind !== 'bundled') return null;\n return registry[asset.source.path] ?? null;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { BARCODE_SCAN_DEDUPE_WINDOW_MS, BARCODE_SCANNER_TYPES, type BarcodeScanRecord, type ExpoBarcodeScanResultLike, mapPermissionStatusToCameraPermissionStatus, normalizeExpoBarcodeScanResult, shouldIgnoreBarcodeScan, } from './barcodeScanRuntime';
|
|
2
|
+
export { type ExpoBundledMediaRegistrySourceEntry, getExpoBundledMediaRegistrySource, } from './bundledMediaRegistrySource';
|
|
3
|
+
export { createExpoBundledMediaResolver, type ExpoBundledMediaRegistry, type ExpoBundledMediaResolver, type ExpoBundledMediaResolverArgs, type ExpoBundledMediaValue, resolveExpoBundledMediaAsset, } from './bundledMediaResolver';
|
|
2
4
|
export type { ComponentRegistry } from './componentRegistry';
|
|
3
5
|
export { createComponentRegistry } from './componentRegistry';
|
|
4
6
|
export { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,2CAA2C,EAC3C,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,KAAK,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACtC,KAAK,2BAA2B,EAChC,oCAAoC,EACpC,+BAA+B,EAC/B,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EACL,KAAK,gCAAgC,EACrC,mCAAmC,GACpC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,2CAA2C,EAC3C,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,mCAAmC,EACxC,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,8BAA8B,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,KAAK,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACtC,KAAK,2BAA2B,EAChC,oCAAoC,EACpC,+BAA+B,EAC/B,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EACL,KAAK,gCAAgC,EACrC,mCAAmC,GACpC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { BARCODE_SCAN_DEDUPE_WINDOW_MS, BARCODE_SCANNER_TYPES, mapPermissionStatusToCameraPermissionStatus, normalizeExpoBarcodeScanResult, shouldIgnoreBarcodeScan, } from './barcodeScanRuntime';
|
|
2
|
+
export { getExpoBundledMediaRegistrySource, } from './bundledMediaRegistrySource';
|
|
3
|
+
export { createExpoBundledMediaResolver, resolveExpoBundledMediaAsset, } from './bundledMediaResolver';
|
|
2
4
|
export { createComponentRegistry } from './componentRegistry';
|
|
3
5
|
export { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';
|
|
4
6
|
export { executeExpoRuntimeAction, resolveExpoRuntimeRoutePath, } from './expoActionBridge';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EAGrB,2CAA2C,EAC3C,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EAGrB,2CAA2C,EAC3C,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,8BAA8B,EAK9B,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,wBAAwB,EAOxB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAkC,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAKL,oCAAoC,EACpC,+BAA+B,EAC/B,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAEL,mCAAmC,GACpC,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export {\n BARCODE_SCAN_DEDUPE_WINDOW_MS,\n BARCODE_SCANNER_TYPES,\n type BarcodeScanRecord,\n type ExpoBarcodeScanResultLike,\n mapPermissionStatusToCameraPermissionStatus,\n normalizeExpoBarcodeScanResult,\n shouldIgnoreBarcodeScan,\n} from './barcodeScanRuntime';\nexport {\n type ExpoBundledMediaRegistrySourceEntry,\n getExpoBundledMediaRegistrySource,\n} from './bundledMediaRegistrySource';\nexport {\n createExpoBundledMediaResolver,\n type ExpoBundledMediaRegistry,\n type ExpoBundledMediaResolver,\n type ExpoBundledMediaResolverArgs,\n type ExpoBundledMediaValue,\n resolveExpoBundledMediaAsset,\n} from './bundledMediaResolver';\nexport type { ComponentRegistry } from './componentRegistry';\nexport { createComponentRegistry } from './componentRegistry';\nexport { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';\nexport {\n executeExpoRuntimeAction,\n type ExecuteExpoRuntimeActionArgs,\n type ExpoRuntimeActionHandlerArgs,\n type ExpoRuntimeActionHandlers,\n type ExpoRuntimeRouteResolution,\n type ExpoRuntimeRouterLike,\n type ExpoRuntimeThemeMode,\n resolveExpoRuntimeRoutePath,\n} from './expoActionBridge';\nexport { ExpoBarcodeScannerAdapter } from './ExpoBarcodeScannerAdapter';\nexport { ExpoRuntimeProviders, type ExpoRuntimeProvidersProps } from './ExpoRuntimeProviders';\nexport {\n type ExpoRuntimeConfigPluginOutput,\n type ExpoRuntimeDependencyMap,\n type ExpoRuntimeGeneratedAppOutputPlan,\n type ExpoRuntimeNativeOutputPlan,\n resolveExpoRuntimeConfigPluginOutput,\n resolveExpoRuntimeDependencyMap,\n resolveExpoRuntimeGeneratedAppOutput,\n resolveExpoRuntimeNativeOutput,\n} from './generatedAppOutput';\nexport { getExpoBarcodeScannerViewSource } from './generatedSources';\nexport {\n type ExpoRuntimeLayoutIntegrationPlan,\n resolveExpoRuntimeLayoutIntegration,\n} from './layoutIntegrationPlanning';\nexport type {\n ExpoRuntimeAdapterId,\n ExpoRuntimePlan,\n ExpoRuntimeProviderId,\n} from './resolveExpoRuntimePlan';\nexport { resolveExpoRuntimePlan } from './resolveExpoRuntimePlan';\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/expo-runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"description": "Declarative runtime integration for Expo apps: maps app capabilities to permissions, packages, config plugins, providers, and adapters",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/expo-runtime#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { getExpoBundledMediaRegistrySource } from './bundledMediaRegistrySource';
|
|
4
|
+
|
|
5
|
+
describe('Expo bundled media registry source', () => {
|
|
6
|
+
test('renders sorted static require literals and deduplicates identical entries', () => {
|
|
7
|
+
const source = getExpoBundledMediaRegistrySource([
|
|
8
|
+
{ path: 'assets/z.png', requirePath: '../../assets/z.png' },
|
|
9
|
+
{ path: 'assets/a.png', requirePath: '../../assets/a.png' },
|
|
10
|
+
{ path: 'assets/a.png', requirePath: '../../assets/a.png' },
|
|
11
|
+
]);
|
|
12
|
+
expect(source.indexOf('assets/a.png')).toBeLessThan(source.indexOf('assets/z.png'));
|
|
13
|
+
expect(source.match(/require\("\.\.\/\.\.\/assets\/a\.png"\)/g)?.length).toBe(1);
|
|
14
|
+
expect(source).toContain('require("../../assets/z.png")');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('rejects one canonical path mapped to different files', () => {
|
|
18
|
+
expect(() =>
|
|
19
|
+
getExpoBundledMediaRegistrySource([
|
|
20
|
+
{ path: 'assets/a.png', requirePath: '../../assets/a.png' },
|
|
21
|
+
{ path: 'assets/a.png', requirePath: '../../assets/other.png' },
|
|
22
|
+
]),
|
|
23
|
+
).toThrow('conflicting require targets');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface ExpoBundledMediaRegistrySourceEntry {
|
|
2
|
+
readonly path: string;
|
|
3
|
+
readonly requirePath: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function getExpoBundledMediaRegistrySource(
|
|
7
|
+
entries: readonly ExpoBundledMediaRegistrySourceEntry[],
|
|
8
|
+
): string {
|
|
9
|
+
const normalized = normalizeEntries(entries);
|
|
10
|
+
const rows = normalized.map(
|
|
11
|
+
(entry) => ` ${JSON.stringify(entry.path)}: require(${JSON.stringify(entry.requirePath)}),`,
|
|
12
|
+
);
|
|
13
|
+
return [
|
|
14
|
+
"import type { ExpoBundledMediaRegistry } from '@ankhorage/expo-runtime';",
|
|
15
|
+
'',
|
|
16
|
+
'declare const require: (path: string) => ExpoBundledMediaRegistry[string];',
|
|
17
|
+
'',
|
|
18
|
+
'export const bundledMediaRegistry: ExpoBundledMediaRegistry = {',
|
|
19
|
+
...rows,
|
|
20
|
+
'};',
|
|
21
|
+
'',
|
|
22
|
+
].join('\n');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function normalizeEntries(
|
|
26
|
+
entries: readonly ExpoBundledMediaRegistrySourceEntry[],
|
|
27
|
+
): readonly ExpoBundledMediaRegistrySourceEntry[] {
|
|
28
|
+
const byPath = new Map<string, string>();
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
const existing = byPath.get(entry.path);
|
|
31
|
+
if (existing !== undefined && existing !== entry.requirePath) {
|
|
32
|
+
throw new Error(`Bundled media path has conflicting require targets: ${entry.path}`);
|
|
33
|
+
}
|
|
34
|
+
byPath.set(entry.path, entry.requirePath);
|
|
35
|
+
}
|
|
36
|
+
return [...byPath.entries()]
|
|
37
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
38
|
+
.map(([path, requirePath]) => ({ path, requirePath }));
|
|
39
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { MediaAsset } from '@ankhorage/contracts';
|
|
2
|
+
import { describe, expect, test } from 'bun:test';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
createExpoBundledMediaResolver,
|
|
6
|
+
resolveExpoBundledMediaAsset,
|
|
7
|
+
} from './bundledMediaResolver';
|
|
8
|
+
|
|
9
|
+
const bundledAsset: MediaAsset = {
|
|
10
|
+
id: 'hero',
|
|
11
|
+
name: 'Hero',
|
|
12
|
+
kind: 'image',
|
|
13
|
+
source: { kind: 'bundled', path: 'assets/authoring/hero/hero.png' },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe('Expo bundled media resolution', () => {
|
|
17
|
+
test('resolves canonical bundled paths from the static registry', () => {
|
|
18
|
+
const registry = { 'assets/authoring/hero/hero.png': 42 } as const;
|
|
19
|
+
expect(resolveExpoBundledMediaAsset(registry, bundledAsset)).toBe(42);
|
|
20
|
+
expect(createExpoBundledMediaResolver(registry)({ asset: bundledAsset })).toBe(42);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('returns null for unknown bundled paths and non-bundled assets', () => {
|
|
24
|
+
expect(resolveExpoBundledMediaAsset({}, bundledAsset)).toBeNull();
|
|
25
|
+
const remoteAsset: MediaAsset = {
|
|
26
|
+
...bundledAsset,
|
|
27
|
+
source: { kind: 'url', url: 'https://example.com/hero.png' },
|
|
28
|
+
};
|
|
29
|
+
expect(resolveExpoBundledMediaAsset({}, remoteAsset)).toBeNull();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { MediaAsset } from '@ankhorage/contracts';
|
|
2
|
+
|
|
3
|
+
export type ExpoBundledMediaValue = string | number | Readonly<Record<string, unknown>>;
|
|
4
|
+
|
|
5
|
+
export type ExpoBundledMediaRegistry = Readonly<Record<string, ExpoBundledMediaValue>>;
|
|
6
|
+
|
|
7
|
+
export interface ExpoBundledMediaResolverArgs {
|
|
8
|
+
readonly asset: MediaAsset;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type ExpoBundledMediaResolver = (
|
|
12
|
+
args: ExpoBundledMediaResolverArgs,
|
|
13
|
+
) => ExpoBundledMediaValue | null;
|
|
14
|
+
|
|
15
|
+
export function createExpoBundledMediaResolver(
|
|
16
|
+
registry: ExpoBundledMediaRegistry,
|
|
17
|
+
): ExpoBundledMediaResolver {
|
|
18
|
+
return ({ asset }) => resolveExpoBundledMediaAsset(registry, asset);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function resolveExpoBundledMediaAsset(
|
|
22
|
+
registry: ExpoBundledMediaRegistry,
|
|
23
|
+
asset: MediaAsset,
|
|
24
|
+
): ExpoBundledMediaValue | null {
|
|
25
|
+
if (asset.source.kind !== 'bundled') return null;
|
|
26
|
+
return registry[asset.source.path] ?? null;
|
|
27
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,18 @@ export {
|
|
|
7
7
|
normalizeExpoBarcodeScanResult,
|
|
8
8
|
shouldIgnoreBarcodeScan,
|
|
9
9
|
} from './barcodeScanRuntime';
|
|
10
|
+
export {
|
|
11
|
+
type ExpoBundledMediaRegistrySourceEntry,
|
|
12
|
+
getExpoBundledMediaRegistrySource,
|
|
13
|
+
} from './bundledMediaRegistrySource';
|
|
14
|
+
export {
|
|
15
|
+
createExpoBundledMediaResolver,
|
|
16
|
+
type ExpoBundledMediaRegistry,
|
|
17
|
+
type ExpoBundledMediaResolver,
|
|
18
|
+
type ExpoBundledMediaResolverArgs,
|
|
19
|
+
type ExpoBundledMediaValue,
|
|
20
|
+
resolveExpoBundledMediaAsset,
|
|
21
|
+
} from './bundledMediaResolver';
|
|
10
22
|
export type { ComponentRegistry } from './componentRegistry';
|
|
11
23
|
export { createComponentRegistry } from './componentRegistry';
|
|
12
24
|
export { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';
|