@ankhorage/expo-runtime 3.2.17 → 4.0.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 +1 -1
- package/dist/collectExpoRuntimeManifestRequirements.d.ts +15 -0
- package/dist/collectExpoRuntimeManifestRequirements.d.ts.map +1 -0
- package/dist/collectExpoRuntimeManifestRequirements.js +24 -0
- package/dist/collectExpoRuntimeManifestRequirements.js.map +1 -0
- package/dist/expoRuntimePlanningMetadata.d.ts +6 -6
- package/dist/expoRuntimePlanningMetadata.d.ts.map +1 -1
- package/dist/expoRuntimePlanningMetadata.js +3 -3
- package/dist/expoRuntimePlanningMetadata.js.map +1 -1
- package/dist/resolveExpoRuntimePlan.d.ts +6 -13
- package/dist/resolveExpoRuntimePlan.d.ts.map +1 -1
- package/dist/resolveExpoRuntimePlan.js +20 -29
- package/dist/resolveExpoRuntimePlan.js.map +1 -1
- package/dist/types/expoRuntimePlanning.d.ts +34 -0
- package/dist/types/expoRuntimePlanning.d.ts.map +1 -0
- package/dist/types/expoRuntimePlanning.js +2 -0
- package/dist/types/expoRuntimePlanning.js.map +1 -0
- package/package.json +2 -2
- package/src/collectExpoRuntimeManifestRequirements.ts +55 -0
- package/src/expoRuntimePlanningMetadata.ts +6 -6
- package/src/planning.test.ts +1 -1
- package/src/resolveExpoRuntimePlan.test.ts +19 -19
- package/src/resolveExpoRuntimePlan.ts +54 -86
- package/src/types/expoRuntimePlanning.ts +46 -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
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AnkhorageCapabilityName, type AnkhoragePermissionName, type ScreenRequirements } from '@ankhorage/contracts';
|
|
2
|
+
interface ExpoRuntimeManifestRequirementSelection {
|
|
3
|
+
readonly permissions: Map<AnkhoragePermissionName, {
|
|
4
|
+
readonly permission: AnkhoragePermissionName;
|
|
5
|
+
}>;
|
|
6
|
+
readonly capabilities: Map<AnkhorageCapabilityName, {
|
|
7
|
+
readonly capability: AnkhorageCapabilityName;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
/*** Collect canonical screen requirement-set membership into the deterministic planning maps. */
|
|
11
|
+
export declare function collectExpoRuntimeManifestRequirements(screens: Readonly<Record<string, {
|
|
12
|
+
readonly requires?: ScreenRequirements;
|
|
13
|
+
}>>): ExpoRuntimeManifestRequirementSelection;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=collectExpoRuntimeManifestRequirements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectExpoRuntimeManifestRequirements.d.ts","sourceRoot":"","sources":["../src/collectExpoRuntimeManifestRequirements.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,UAAU,uCAAuC;IAC/C,QAAQ,CAAC,WAAW,EAAE,GAAG,CACvB,uBAAuB,EACvB;QAAE,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAA;KAAE,CACjD,CAAC;IACF,QAAQ,CAAC,YAAY,EAAE,GAAG,CACxB,uBAAuB,EACvB;QAAE,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAA;KAAE,CACjD,CAAC;CACH;AAED,iGAAiG;AACjG,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAAC,GAC5E,uCAAuC,CAwBzC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ANKHORAGE_CAPABILITY_NAMES, ANKHORAGE_PERMISSION_NAMES, } from '@ankhorage/contracts';
|
|
2
|
+
/*** Collect canonical screen requirement-set membership into the deterministic planning maps. */
|
|
3
|
+
export function collectExpoRuntimeManifestRequirements(screens) {
|
|
4
|
+
const permissions = new Map();
|
|
5
|
+
const capabilities = new Map();
|
|
6
|
+
for (const screen of Object.values(screens)) {
|
|
7
|
+
for (const permission of ANKHORAGE_PERMISSION_NAMES) {
|
|
8
|
+
if (hasRequirement(screen.requires?.permissions, permission)) {
|
|
9
|
+
permissions.set(permission, { permission });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
for (const capability of ANKHORAGE_CAPABILITY_NAMES) {
|
|
13
|
+
if (hasRequirement(screen.requires?.capabilities, capability)) {
|
|
14
|
+
capabilities.set(capability, { capability });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return { permissions, capabilities };
|
|
19
|
+
}
|
|
20
|
+
/*** Return whether a canonical serializable requirement set contains one enabled name. */
|
|
21
|
+
function hasRequirement(requirements, name) {
|
|
22
|
+
return Object.hasOwn(requirements ?? {}, name);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=collectExpoRuntimeManifestRequirements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectExpoRuntimeManifestRequirements.js","sourceRoot":"","sources":["../src/collectExpoRuntimeManifestRequirements.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAI3B,MAAM,sBAAsB,CAAC;AAa9B,iGAAiG;AACjG,MAAM,UAAU,sCAAsC,CACpD,OAA6E;IAE7E,MAAM,WAAW,GAAG,IAAI,GAAG,EAGxB,CAAC;IACJ,MAAM,YAAY,GAAG,IAAI,GAAG,EAGzB,CAAC;IAEJ,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,KAAK,MAAM,UAAU,IAAI,0BAA0B,EAAE,CAAC;YACpD,IAAI,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,CAAC;gBAC7D,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QACD,KAAK,MAAM,UAAU,IAAI,0BAA0B,EAAE,CAAC;YACpD,IAAI,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,CAAC;gBAC9D,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;AACvC,CAAC;AAED,0FAA0F;AAC1F,SAAS,cAAc,CACrB,YAAiE,EACjE,IAAY;IAEZ,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import {\n ANKHORAGE_CAPABILITY_NAMES,\n ANKHORAGE_PERMISSION_NAMES,\n type AnkhorageCapabilityName,\n type AnkhoragePermissionName,\n type ScreenRequirements,\n} from '@ankhorage/contracts';\n\ninterface ExpoRuntimeManifestRequirementSelection {\n readonly permissions: Map<\n AnkhoragePermissionName,\n { readonly permission: AnkhoragePermissionName }\n >;\n readonly capabilities: Map<\n AnkhorageCapabilityName,\n { readonly capability: AnkhorageCapabilityName }\n >;\n}\n\n/*** Collect canonical screen requirement-set membership into the deterministic planning maps. */\nexport function collectExpoRuntimeManifestRequirements(\n screens: Readonly<Record<string, { readonly requires?: ScreenRequirements }>>,\n): ExpoRuntimeManifestRequirementSelection {\n const permissions = new Map<\n AnkhoragePermissionName,\n { readonly permission: AnkhoragePermissionName }\n >();\n const capabilities = new Map<\n AnkhorageCapabilityName,\n { readonly capability: AnkhorageCapabilityName }\n >();\n\n for (const screen of Object.values(screens)) {\n for (const permission of ANKHORAGE_PERMISSION_NAMES) {\n if (hasRequirement(screen.requires?.permissions, permission)) {\n permissions.set(permission, { permission });\n }\n }\n for (const capability of ANKHORAGE_CAPABILITY_NAMES) {\n if (hasRequirement(screen.requires?.capabilities, capability)) {\n capabilities.set(capability, { capability });\n }\n }\n }\n\n return { permissions, capabilities };\n}\n\n/*** Return whether a canonical serializable requirement set contains one enabled name. */\nfunction hasRequirement(\n requirements: Readonly<Partial<Record<string, true>>> | undefined,\n name: string,\n): boolean {\n return Object.hasOwn(requirements ?? {}, name);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnkhorageCapabilityName,
|
|
1
|
+
import type { AnkhorageCapabilityName, AnkhoragePermissionName, SerializableSet } from '@ankhorage/contracts';
|
|
2
2
|
import type { PermissionSupport } from '@ankhorage/permissions/expo/manifest';
|
|
3
3
|
import { EXPO_PLATFORM } from './platform';
|
|
4
4
|
export interface ExpoRuntimeConfigPlugin {
|
|
@@ -15,7 +15,7 @@ export interface ExpoRuntimeDiagnostic {
|
|
|
15
15
|
readonly support?: PermissionSupport;
|
|
16
16
|
}
|
|
17
17
|
export interface ExpoRuntimeCapabilityMetadata {
|
|
18
|
-
readonly impliedPermissions?:
|
|
18
|
+
readonly impliedPermissions?: SerializableSet<AnkhoragePermissionName>;
|
|
19
19
|
readonly requiredPackages?: readonly string[];
|
|
20
20
|
readonly providers?: readonly ExpoRuntimeProviderId[];
|
|
21
21
|
readonly runtimeAdapters?: readonly ExpoRuntimeAdapterId[];
|
|
@@ -43,9 +43,9 @@ export declare const EXPO_RUNTIME_PACKAGE_PEERS: {
|
|
|
43
43
|
};
|
|
44
44
|
export declare const EXPO_CAPABILITY_RUNTIME_REGISTRY: {
|
|
45
45
|
readonly barcodeScanner: {
|
|
46
|
-
readonly impliedPermissions:
|
|
47
|
-
readonly
|
|
48
|
-
}
|
|
46
|
+
readonly impliedPermissions: {
|
|
47
|
+
readonly camera: true;
|
|
48
|
+
};
|
|
49
49
|
readonly requiredPackages: readonly [string];
|
|
50
50
|
readonly providers: readonly ["permissions"];
|
|
51
51
|
readonly runtimeAdapters: readonly ["ExpoBarcodeScannerAdapter"];
|
|
@@ -64,7 +64,7 @@ export declare const EXPO_CAPABILITY_RUNTIME_REGISTRY: {
|
|
|
64
64
|
readonly runtimeAdapters: readonly ["ExpoReaderSurfaceAdapter"];
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
-
export declare function findCapabilityMetadata(registry: Readonly<Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>>,
|
|
67
|
+
export declare function findCapabilityMetadata(registry: Readonly<Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>>, capability: AnkhorageCapabilityName): ExpoRuntimeCapabilityMetadata | undefined;
|
|
68
68
|
export declare function findConfigHintMetadata(configHint: string): ExpoRuntimeHintMetadata | undefined;
|
|
69
69
|
export declare function unknownPermissionDiagnostic(permission: string): ExpoRuntimeDiagnostic;
|
|
70
70
|
export declare function unsupportedPermissionDiagnostic(permission: string, support: PermissionSupport): ExpoRuntimeDiagnostic;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expoRuntimePlanningMetadata.d.ts","sourceRoot":"","sources":["../src/expoRuntimePlanningMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"expoRuntimePlanningMetadata.d.ts","sourceRoot":"","sources":["../src/expoRuntimePlanningMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAE9E,OAAO,EAAE,aAAa,EAA4B,MAAM,YAAY,CAAC;AAErE,MAAM,W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A8B;;CAEe,CAAC;AAE3D,yFAAyF;AACzF,eAAO,MAAM,0BAA0B;IACrC,SAAA,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,oBAAqC;CACV,CAAC;AAqEjE,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;CAwB5C,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,6BAA6B,CAAC,CAAC,CAAC,EAC3F,UAAU,EAAE,uBAAuB,GAClC,6BAA6B,GAAG,SAAS,CAE3C;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS,CAE9F;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,qBAAqB,CAOrF;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,iBAAiB,GACzB,qBAAqB,CAQvB;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,qBAAqB,CAOrF"}
|
|
@@ -90,7 +90,7 @@ const EXPO_RUNTIME_CONFIG_HINTS = {
|
|
|
90
90
|
};
|
|
91
91
|
export const EXPO_CAPABILITY_RUNTIME_REGISTRY = {
|
|
92
92
|
barcodeScanner: {
|
|
93
|
-
impliedPermissions:
|
|
93
|
+
impliedPermissions: { camera: true },
|
|
94
94
|
requiredPackages: [EXPO_PLATFORM.packages.camera.name],
|
|
95
95
|
providers: ['permissions'],
|
|
96
96
|
runtimeAdapters: ['ExpoBarcodeScannerAdapter'],
|
|
@@ -111,8 +111,8 @@ export const EXPO_CAPABILITY_RUNTIME_REGISTRY = {
|
|
|
111
111
|
runtimeAdapters: ['ExpoReaderSurfaceAdapter'],
|
|
112
112
|
},
|
|
113
113
|
};
|
|
114
|
-
export function findCapabilityMetadata(registry,
|
|
115
|
-
return Object.entries(registry).find(([name]) => name ===
|
|
114
|
+
export function findCapabilityMetadata(registry, capability) {
|
|
115
|
+
return Object.entries(registry).find(([name]) => name === capability)?.[1];
|
|
116
116
|
}
|
|
117
117
|
export function findConfigHintMetadata(configHint) {
|
|
118
118
|
return Object.entries(EXPO_RUNTIME_CONFIG_HINTS).find(([name]) => name === configHint)?.[1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expoRuntimePlanningMetadata.js","sourceRoot":"","sources":["../src/expoRuntimePlanningMetadata.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAA4B,MAAM,YAAY,CAAC;AAgCrE,MAAM,uCAAuC,GAAG;IAC9C,wBAAwB,EAAE,QAAQ;IAClC,yBAAyB,EAAE,QAAQ;IACnC,oBAAoB,EAAE,OAAO;IAC7B,iBAAiB,EAAE,OAAO;IAC1B,gBAAgB,EAAE,OAAO;IACzB,YAAY,EAAE,SAAS;CACkB,CAAC;AAE5C,MAAM,kCAAkC,GAAG,MAAM,CAAC,WAAW,CAC3D,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,UAA+B,EAAE,EAAE,CAAC;IAC7E,UAAU,CAAC,IAAI;IACf,UAAU,CAAC,OAAO;CACnB,CAAC,CACiC,CAAC;AAEtC,MAAM,CAAC,MAAM,qCAAqC,GAAG;IACnD,GAAG,uCAAuC;IAC1C,GAAG,kCAAkC;CACc,CAAC;AAEtD,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,WAAW,EAAE,wBAAwB;CACmB,CAAC;AAE3D,yFAAyF;AACzF,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;CACV,CAAC;AAEjE,MAAM,yBAAyB,GAAG;IAChC,gBAAgB,EAAE;QAChB,MAAM,EAAE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C,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,UAAkB;IAC5D,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,eAAe,EAAE,YAAY;QAC7B,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,uBAAuB,UAAU,mDAAmD;KAC9F,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,UAAkB,EAClB,OAA0B;IAE1B,OAAO;QACL,QAAQ,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;QACrD,eAAe,EAAE,YAAY;QAC7B,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,6BAA6B,UAAU,SAAS,OAAO,IAAI;QACpE,OAAO;KACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,UAAkB;IAC5D,OAAO;QACL,QAAQ,EAAE,SAAS;QACnB,eAAe,EAAE,YAAY;QAC7B,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,0DAA0D,UAAU,IAAI;KAClF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n AnkhorageCapabilityName,\n ScreenCapabilityRequirement,\n ScreenPermissionRequirement,\n} from '@ankhorage/contracts';\nimport type { PermissionSupport } from '@ankhorage/permissions/expo/manifest';\n\nimport { EXPO_PLATFORM, type ExpoPlatformPackage } from './platform';\n\nexport interface ExpoRuntimeConfigPlugin {\n readonly name: string;\n readonly options?: Readonly<Record<string, boolean | string>>;\n}\n\nexport type ExpoRuntimeProviderId = 'permissions';\nexport type ExpoRuntimeAdapterId = 'ExpoBarcodeScannerAdapter' | 'ExpoReaderSurfaceAdapter';\n\nexport interface ExpoRuntimeDiagnostic {\n readonly severity: 'error' | 'warning';\n readonly requirementType: 'capability' | 'configHint' | 'package' | 'permission';\n readonly requirement: string;\n readonly message: string;\n readonly support?: PermissionSupport;\n}\n\nexport interface ExpoRuntimeCapabilityMetadata {\n readonly impliedPermissions?: readonly ScreenPermissionRequirement[];\n readonly requiredPackages?: readonly string[];\n readonly providers?: readonly ExpoRuntimeProviderId[];\n readonly runtimeAdapters?: readonly ExpoRuntimeAdapterId[];\n readonly androidPermissions?: readonly string[];\n readonly plugins?: readonly ExpoRuntimeConfigPlugin[];\n}\n\nexport interface ExpoRuntimeHintMetadata {\n readonly androidPermissions?: readonly string[];\n readonly plugin?: ExpoRuntimeConfigPlugin;\n}\n\nconst GENERATED_ANKHORAGE_DEPENDENCY_VERSIONS = {\n '@ankhorage/permissions': '^0.2.5',\n '@ankhorage/expo-runtime': '^3.0.0',\n '@readium/navigator': '2.8.2',\n '@readium/shared': '2.4.0',\n '@zip.js/zip.js': '2.9.0',\n 'pdfjs-dist': '6.3.289',\n} as const satisfies Record<string, string>;\n\nconst GENERATED_EXPO_DEPENDENCY_VERSIONS = Object.fromEntries(\n Object.values(EXPO_PLATFORM.packages).map((dependency: ExpoPlatformPackage) => [\n dependency.name,\n dependency.version,\n ]),\n) as Readonly<Record<string, string>>;\n\nexport const GENERATED_RUNTIME_DEPENDENCY_VERSIONS = {\n ...GENERATED_ANKHORAGE_DEPENDENCY_VERSIONS,\n ...GENERATED_EXPO_DEPENDENCY_VERSIONS,\n} as const satisfies Readonly<Record<string, string>>;\n\nexport const EXPO_RUNTIME_PROVIDER_PACKAGES = {\n permissions: '@ankhorage/permissions',\n} as const satisfies Record<ExpoRuntimeProviderId, string>;\n\n/** Native Expo packages whose peer modules must be direct generated-app dependencies. */\nexport const EXPO_RUNTIME_PACKAGE_PEERS = {\n [EXPO_PLATFORM.packages.audio.name]: [EXPO_PLATFORM.packages.asset.name],\n} as const satisfies Readonly<Record<string, readonly string[]>>;\n\nconst EXPO_RUNTIME_CONFIG_HINTS = {\n cameraPermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.camera.name,\n options: {\n barcodeScannerEnabled: false,\n cameraPermission: 'Allow camera access.',\n microphonePermission: false,\n recordAudioAndroid: false,\n },\n },\n },\n microphonePermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.audio.name,\n options: {\n enableBackgroundPlayback: false,\n enableBackgroundRecording: false,\n microphonePermission: 'Allow microphone access.',\n },\n },\n },\n recordAudioAndroid: {\n plugin: {\n name: EXPO_PLATFORM.packages.audio.name,\n options: {\n enableBackgroundPlayback: false,\n enableBackgroundRecording: false,\n recordAudioAndroid: true,\n },\n },\n },\n mediaLibraryPermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.mediaLibrary.name,\n options: {\n photosPermission: 'Allow photo library access.',\n savePhotosPermission: 'Allow saving to the photo library.',\n },\n },\n },\n locationWhenInUsePermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.location.name,\n options: {\n locationWhenInUsePermission: 'Allow location access while using the app.',\n },\n },\n },\n locationAlwaysAndWhenInUsePermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.location.name,\n options: {\n locationAlwaysAndWhenInUsePermission: 'Allow location access.',\n isAndroidBackgroundLocationEnabled: true,\n isAndroidForegroundServiceEnabled: true,\n isIosBackgroundLocationEnabled: true,\n },\n },\n },\n notificationsPermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.notifications.name,\n },\n },\n} as const satisfies Readonly<Record<string, ExpoRuntimeHintMetadata>>;\n\nexport const EXPO_CAPABILITY_RUNTIME_REGISTRY = {\n barcodeScanner: {\n impliedPermissions: [{ permission: 'camera' }],\n requiredPackages: [EXPO_PLATFORM.packages.camera.name],\n providers: ['permissions'],\n runtimeAdapters: ['ExpoBarcodeScannerAdapter'],\n plugins: [\n {\n name: EXPO_PLATFORM.packages.camera.name,\n options: {\n cameraPermission: 'Allow camera access to scan barcodes.',\n barcodeScannerEnabled: true,\n microphonePermission: false,\n recordAudioAndroid: false,\n },\n },\n ],\n },\n ebookReader: {\n requiredPackages: ['@readium/navigator', '@readium/shared', '@zip.js/zip.js', 'pdfjs-dist'],\n runtimeAdapters: ['ExpoReaderSurfaceAdapter'],\n },\n} as const satisfies Readonly<\n Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>\n>;\n\nexport function findCapabilityMetadata(\n registry: Readonly<Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>>,\n requirement: ScreenCapabilityRequirement,\n): ExpoRuntimeCapabilityMetadata | undefined {\n return Object.entries(registry).find(([name]) => name === requirement.capability)?.[1];\n}\n\nexport function findConfigHintMetadata(configHint: string): ExpoRuntimeHintMetadata | undefined {\n return Object.entries(EXPO_RUNTIME_CONFIG_HINTS).find(([name]) => name === configHint)?.[1];\n}\n\nexport function unknownPermissionDiagnostic(permission: string): ExpoRuntimeDiagnostic {\n return {\n severity: 'error',\n requirementType: 'permission',\n requirement: permission,\n message: `Unknown permission '${permission}' cannot be resolved for Expo runtime generation.`,\n };\n}\n\nexport function unsupportedPermissionDiagnostic(\n permission: string,\n support: PermissionSupport,\n): ExpoRuntimeDiagnostic {\n return {\n severity: support === 'limited' ? 'warning' : 'error',\n requirementType: 'permission',\n requirement: permission,\n message: `Expo runtime support for '${permission}' is '${support}'.`,\n support,\n };\n}\n\nexport function unknownCapabilityDiagnostic(capability: string): ExpoRuntimeDiagnostic {\n return {\n severity: 'warning',\n requirementType: 'capability',\n requirement: capability,\n message: `No Expo runtime metadata is registered for capability '${capability}'.`,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"expoRuntimePlanningMetadata.js","sourceRoot":"","sources":["../src/expoRuntimePlanningMetadata.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAA4B,MAAM,YAAY,CAAC;AAgCrE,MAAM,uCAAuC,GAAG;IAC9C,wBAAwB,EAAE,QAAQ;IAClC,yBAAyB,EAAE,QAAQ;IACnC,oBAAoB,EAAE,OAAO;IAC7B,iBAAiB,EAAE,OAAO;IAC1B,gBAAgB,EAAE,OAAO;IACzB,YAAY,EAAE,SAAS;CACkB,CAAC;AAE5C,MAAM,kCAAkC,GAAG,MAAM,CAAC,WAAW,CAC3D,MAAM,CAAC,MAAM,CAAC,a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AACJ,CAAC","sourcesContent":["import type {\n AnkhorageCapabilityName,\n AnkhoragePermissionName,\n SerializableSet,\n} from '@ankhorage/contracts';\nimport type { PermissionSupport } from '@ankhorage/permissions/expo/manifest';\n\nimport { EXPO_PLATFORM, type ExpoPlatformPackage } from './platform';\n\nexport interface ExpoRuntimeConfigPlugin {\n readonly name: string;\n readonly options?: Readonly<Record<string, boolean | string>>;\n}\n\nexport type ExpoRuntimeProviderId = 'permissions';\nexport type ExpoRuntimeAdapterId = 'ExpoBarcodeScannerAdapter' | 'ExpoReaderSurfaceAdapter';\n\nexport interface ExpoRuntimeDiagnostic {\n readonly severity: 'error' | 'warning';\n readonly requirementType: 'capability' | 'configHint' | 'package' | 'permission';\n readonly requirement: string;\n readonly message: string;\n readonly support?: PermissionSupport;\n}\n\nexport interface ExpoRuntimeCapabilityMetadata {\n readonly impliedPermissions?: SerializableSet<AnkhoragePermissionName>;\n readonly requiredPackages?: readonly string[];\n readonly providers?: readonly ExpoRuntimeProviderId[];\n readonly runtimeAdapters?: readonly ExpoRuntimeAdapterId[];\n readonly androidPermissions?: readonly string[];\n readonly plugins?: readonly ExpoRuntimeConfigPlugin[];\n}\n\nexport interface ExpoRuntimeHintMetadata {\n readonly androidPermissions?: readonly string[];\n readonly plugin?: ExpoRuntimeConfigPlugin;\n}\n\nconst GENERATED_ANKHORAGE_DEPENDENCY_VERSIONS = {\n '@ankhorage/permissions': '^0.2.5',\n '@ankhorage/expo-runtime': '^3.0.0',\n '@readium/navigator': '2.8.2',\n '@readium/shared': '2.4.0',\n '@zip.js/zip.js': '2.9.0',\n 'pdfjs-dist': '6.3.289',\n} as const satisfies Record<string, string>;\n\nconst GENERATED_EXPO_DEPENDENCY_VERSIONS = Object.fromEntries(\n Object.values(EXPO_PLATFORM.packages).map((dependency: ExpoPlatformPackage) => [\n dependency.name,\n dependency.version,\n ]),\n) as Readonly<Record<string, string>>;\n\nexport const GENERATED_RUNTIME_DEPENDENCY_VERSIONS = {\n ...GENERATED_ANKHORAGE_DEPENDENCY_VERSIONS,\n ...GENERATED_EXPO_DEPENDENCY_VERSIONS,\n} as const satisfies Readonly<Record<string, string>>;\n\nexport const EXPO_RUNTIME_PROVIDER_PACKAGES = {\n permissions: '@ankhorage/permissions',\n} as const satisfies Record<ExpoRuntimeProviderId, string>;\n\n/** Native Expo packages whose peer modules must be direct generated-app dependencies. */\nexport const EXPO_RUNTIME_PACKAGE_PEERS = {\n [EXPO_PLATFORM.packages.audio.name]: [EXPO_PLATFORM.packages.asset.name],\n} as const satisfies Readonly<Record<string, readonly string[]>>;\n\nconst EXPO_RUNTIME_CONFIG_HINTS = {\n cameraPermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.camera.name,\n options: {\n barcodeScannerEnabled: false,\n cameraPermission: 'Allow camera access.',\n microphonePermission: false,\n recordAudioAndroid: false,\n },\n },\n },\n microphonePermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.audio.name,\n options: {\n enableBackgroundPlayback: false,\n enableBackgroundRecording: false,\n microphonePermission: 'Allow microphone access.',\n },\n },\n },\n recordAudioAndroid: {\n plugin: {\n name: EXPO_PLATFORM.packages.audio.name,\n options: {\n enableBackgroundPlayback: false,\n enableBackgroundRecording: false,\n recordAudioAndroid: true,\n },\n },\n },\n mediaLibraryPermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.mediaLibrary.name,\n options: {\n photosPermission: 'Allow photo library access.',\n savePhotosPermission: 'Allow saving to the photo library.',\n },\n },\n },\n locationWhenInUsePermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.location.name,\n options: {\n locationWhenInUsePermission: 'Allow location access while using the app.',\n },\n },\n },\n locationAlwaysAndWhenInUsePermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.location.name,\n options: {\n locationAlwaysAndWhenInUsePermission: 'Allow location access.',\n isAndroidBackgroundLocationEnabled: true,\n isAndroidForegroundServiceEnabled: true,\n isIosBackgroundLocationEnabled: true,\n },\n },\n },\n notificationsPermission: {\n plugin: {\n name: EXPO_PLATFORM.packages.notifications.name,\n },\n },\n} as const satisfies Readonly<Record<string, ExpoRuntimeHintMetadata>>;\n\nexport const EXPO_CAPABILITY_RUNTIME_REGISTRY = {\n barcodeScanner: {\n impliedPermissions: { camera: true },\n requiredPackages: [EXPO_PLATFORM.packages.camera.name],\n providers: ['permissions'],\n runtimeAdapters: ['ExpoBarcodeScannerAdapter'],\n plugins: [\n {\n name: EXPO_PLATFORM.packages.camera.name,\n options: {\n cameraPermission: 'Allow camera access to scan barcodes.',\n barcodeScannerEnabled: true,\n microphonePermission: false,\n recordAudioAndroid: false,\n },\n },\n ],\n },\n ebookReader: {\n requiredPackages: ['@readium/navigator', '@readium/shared', '@zip.js/zip.js', 'pdfjs-dist'],\n runtimeAdapters: ['ExpoReaderSurfaceAdapter'],\n },\n} as const satisfies Readonly<\n Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>\n>;\n\nexport function findCapabilityMetadata(\n registry: Readonly<Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>>,\n capability: AnkhorageCapabilityName,\n): ExpoRuntimeCapabilityMetadata | undefined {\n return Object.entries(registry).find(([name]) => name === capability)?.[1];\n}\n\nexport function findConfigHintMetadata(configHint: string): ExpoRuntimeHintMetadata | undefined {\n return Object.entries(EXPO_RUNTIME_CONFIG_HINTS).find(([name]) => name === configHint)?.[1];\n}\n\nexport function unknownPermissionDiagnostic(permission: string): ExpoRuntimeDiagnostic {\n return {\n severity: 'error',\n requirementType: 'permission',\n requirement: permission,\n message: `Unknown permission '${permission}' cannot be resolved for Expo runtime generation.`,\n };\n}\n\nexport function unsupportedPermissionDiagnostic(\n permission: string,\n support: PermissionSupport,\n): ExpoRuntimeDiagnostic {\n return {\n severity: support === 'limited' ? 'warning' : 'error',\n requirementType: 'permission',\n requirement: permission,\n message: `Expo runtime support for '${permission}' is '${support}'.`,\n support,\n };\n}\n\nexport function unknownCapabilityDiagnostic(capability: string): ExpoRuntimeDiagnostic {\n return {\n severity: 'warning',\n requirementType: 'capability',\n requirement: capability,\n message: `No Expo runtime metadata is registered for capability '${capability}'.`,\n };\n}\n"]}
|
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnkhorageCapabilityName, type ScreenRequirements } from '@ankhorage/contracts';
|
|
2
2
|
import { type ExpoPermissionMetadata } from '@ankhorage/permissions/expo/manifest';
|
|
3
3
|
import { type Permission } from '@ankhorage/permissions/registry';
|
|
4
4
|
import { type ExpoRuntimeAdapterId, type ExpoRuntimeCapabilityMetadata, type ExpoRuntimeConfigPlugin, type ExpoRuntimeDiagnostic, type ExpoRuntimeProviderId } from './expoRuntimePlanningMetadata';
|
|
5
|
+
import type { ExpoRuntimeCapabilityRequirement, ExpoRuntimeDependency, ExpoRuntimePermissionRequirement } from './types/expoRuntimePlanning';
|
|
5
6
|
export type { ExpoRuntimeAdapterId, ExpoRuntimeProviderId };
|
|
6
7
|
export interface ExpoRuntimePlanningScreen {
|
|
7
|
-
readonly requires?:
|
|
8
|
-
readonly capabilities?: readonly ScreenCapabilityRequirement[];
|
|
9
|
-
readonly permissions?: readonly ScreenPermissionRequirement[];
|
|
10
|
-
};
|
|
8
|
+
readonly requires?: ScreenRequirements;
|
|
11
9
|
}
|
|
12
10
|
export interface ExpoRuntimePlanningManifest {
|
|
13
11
|
readonly screens: Readonly<Record<string, ExpoRuntimePlanningScreen>>;
|
|
14
12
|
}
|
|
15
|
-
interface ExpoRuntimeDependency {
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly version: string;
|
|
18
|
-
readonly reasons: readonly string[];
|
|
19
|
-
}
|
|
20
13
|
export interface ExpoRuntimePlan {
|
|
21
|
-
readonly permissions: readonly
|
|
22
|
-
readonly capabilities: readonly
|
|
23
|
-
readonly impliedPermissions: readonly
|
|
14
|
+
readonly permissions: readonly ExpoRuntimePermissionRequirement[];
|
|
15
|
+
readonly capabilities: readonly ExpoRuntimeCapabilityRequirement[];
|
|
16
|
+
readonly impliedPermissions: readonly ExpoRuntimePermissionRequirement[];
|
|
24
17
|
readonly dependencies: readonly ExpoRuntimeDependency[];
|
|
25
18
|
readonly nativeConfig: {
|
|
26
19
|
readonly androidPermissions: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveExpoRuntimePlan.d.ts","sourceRoot":"","sources":["../src/resolveExpoRuntimePlan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"resolveExpoRuntimePlan.d.ts","sourceRoot":"","sources":["../src/resolveExpoRuntimePlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGhF,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAO3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,gCAAgC,EAChC,qBAAqB,EACrB,gCAAgC,EAGjC,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC;AAE5D,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CACxC;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC,CAAC;CACvE;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,SAAS,gCAAgC,EAAE,CAAC;IAClE,QAAQ,CAAC,YAAY,EAAE,SAAS,gCAAgC,EAAE,CAAC;IACnE,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issions/registry';
|
|
4
|
+
import { collectExpoRuntimeManifestRequirements } from './collectExpoRuntimeManifestRequirements';
|
|
3
5
|
import { EXPO_CAPABILITY_RUNTIME_REGISTRY, EXPO_RUNTIME_PACKAGE_PEERS, EXPO_RUNTIME_PROVIDER_PACKAGES, findCapabilityMetadata, findConfigHintMetadata, GENERATED_RUNTIME_DEPENDENCY_VERSIONS, unknownCapabilityDiagnostic, unknownPermissionDiagnostic, unsupportedPermissionDiagnostic, } from './expoRuntimePlanningMetadata';
|
|
4
6
|
const EXPO_RUNTIME_PACKAGE_NAME = '@ankhorage/expo-runtime';
|
|
5
7
|
export function resolveExpoRuntimePlan(manifest, options = {}) {
|
|
6
|
-
const state =
|
|
8
|
+
const state = createExpoRuntimePlanningState(manifest);
|
|
7
9
|
const context = {
|
|
8
10
|
state,
|
|
9
11
|
capabilityRegistry: options.capabilityRegistry ?? EXPO_CAPABILITY_RUNTIME_REGISTRY,
|
|
@@ -18,20 +20,11 @@ export function resolveExpoRuntimePlan(manifest, options = {}) {
|
|
|
18
20
|
}
|
|
19
21
|
return buildPlan(state);
|
|
20
22
|
}
|
|
21
|
-
function
|
|
22
|
-
const
|
|
23
|
-
const capabilities = new Map();
|
|
24
|
-
for (const screen of Object.values(manifest.screens)) {
|
|
25
|
-
for (const requirement of screen.requires?.permissions ?? []) {
|
|
26
|
-
permissions.set(requirement.permission, requirement);
|
|
27
|
-
}
|
|
28
|
-
for (const requirement of screen.requires?.capabilities ?? []) {
|
|
29
|
-
capabilities.set(requirement.capability, requirement);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
23
|
+
function createExpoRuntimePlanningState(manifest) {
|
|
24
|
+
const requirements = collectExpoRuntimeManifestRequirements(manifest.screens);
|
|
32
25
|
return {
|
|
33
|
-
permissions,
|
|
34
|
-
capabilities,
|
|
26
|
+
permissions: requirements.permissions,
|
|
27
|
+
capabilities: requirements.capabilities,
|
|
35
28
|
impliedPermissions: new Map(),
|
|
36
29
|
diagnostics: [],
|
|
37
30
|
dependencies: new Map(),
|
|
@@ -45,11 +38,15 @@ function createPlanningState(manifest) {
|
|
|
45
38
|
function addImpliedPermissions(context) {
|
|
46
39
|
const { state } = context;
|
|
47
40
|
for (const capability of state.capabilities.values()) {
|
|
48
|
-
const metadata = findCapabilityMetadata(context.capabilityRegistry, capability);
|
|
49
|
-
for (const permission of
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
const metadata = findCapabilityMetadata(context.capabilityRegistry, capability.capability);
|
|
42
|
+
for (const permission of ANKHORAGE_PERMISSION_NAMES) {
|
|
43
|
+
const implied = Object.hasOwn(metadata?.impliedPermissions ?? {}, permission);
|
|
44
|
+
if (!implied)
|
|
45
|
+
continue;
|
|
46
|
+
const requirement = { permission };
|
|
47
|
+
if (!state.permissions.has(permission)) {
|
|
48
|
+
state.permissions.set(permission, requirement);
|
|
49
|
+
state.impliedPermissions.set(permission, requirement);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
}
|
|
@@ -79,7 +76,7 @@ function planPermission(context, requirement) {
|
|
|
79
76
|
}
|
|
80
77
|
function planCapabilities(context) {
|
|
81
78
|
for (const requirement of context.state.capabilities.values()) {
|
|
82
|
-
const metadata = findCapabilityMetadata(context.capabilityRegistry, requirement);
|
|
79
|
+
const metadata = findCapabilityMetadata(context.capabilityRegistry, requirement.capability);
|
|
83
80
|
if (metadata === undefined) {
|
|
84
81
|
context.state.diagnostics.push(unknownCapabilityDiagnostic(requirement.capability));
|
|
85
82
|
continue;
|
|
@@ -149,9 +146,9 @@ function buildPlan(state) {
|
|
|
149
146
|
options: Object.keys(options).length > 0 ? options : undefined,
|
|
150
147
|
})).sort((left, right) => left.name.localeCompare(right.name));
|
|
151
148
|
return {
|
|
152
|
-
permissions: Array.from(state.permissions.values()).sort(
|
|
153
|
-
capabilities: Array.from(state.capabilities.values()).sort(
|
|
154
|
-
impliedPermissions: Array.from(state.impliedPermissions.values()).sort(
|
|
149
|
+
permissions: Array.from(state.permissions.values()).sort((left, right) => left.permission.localeCompare(right.permission)),
|
|
150
|
+
capabilities: Array.from(state.capabilities.values()).sort((left, right) => left.capability.localeCompare(right.capability)),
|
|
151
|
+
impliedPermissions: Array.from(state.impliedPermissions.values()).sort((left, right) => left.permission.localeCompare(right.permission)),
|
|
155
152
|
dependencies: Array.from(state.dependencies.values()).sort((left, right) => left.name.localeCompare(right.name)),
|
|
156
153
|
nativeConfig: {
|
|
157
154
|
androidPermissions: Array.from(state.androidPermissions).sort(),
|
|
@@ -178,10 +175,4 @@ function findDependencyVersion(versions, name) {
|
|
|
178
175
|
function isUnsupported(support) {
|
|
179
176
|
return support === 'unsupported' || support === 'notImplemented' || support === 'limited';
|
|
180
177
|
}
|
|
181
|
-
function compareCapabilities(left, right) {
|
|
182
|
-
return left.capability.localeCompare(right.capability);
|
|
183
|
-
}
|
|
184
|
-
function comparePermissions(left, right) {
|
|
185
|
-
return left.permission.localeCompare(right.permission);
|
|
186
|
-
}
|
|
187
178
|
//# sourceMappingURL=resolveExpoRuntimePlan.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveExpoRuntimePlan.js","sourceRoot":"","sources":["../src/resolveExpoRuntimePlan.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,uBAAuB,GAGxB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAmB,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EACL,gCAAgC,EAChC,0BAA0B,EAC1B,8BAA8B,EAM9B,sBAAsB,EACtB,sBAAsB,EACtB,qCAAqC,EACrC,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AAoEvC,MAAM,yBAAyB,GAAG,yBAAyB,CAAC;AAE5D,MAAM,UAAU,sBAAsB,CACpC,QAAqC,EACrC,UAAyC,EAAE;IAE3C,MAAM,KAAK,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAA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ION_SUPPORT,\n type ExpoPermissionMetadata,\n type PermissionSupport,\n} from '@ankhorage/permissions/expo/manifest';\nimport { isPermission, type Permission } from '@ankhorage/permissions/registry';\n\nimport {\n EXPO_CAPABILITY_RUNTIME_REGISTRY,\n EXPO_RUNTIME_PACKAGE_PEERS,\n EXPO_RUNTIME_PROVIDER_PACKAGES,\n type ExpoRuntimeAdapterId,\n type ExpoRuntimeCapabilityMetadata,\n type ExpoRuntimeConfigPlugin,\n type ExpoRuntimeDiagnostic,\n type ExpoRuntimeProviderId,\n findCapabilityMetadata,\n findConfigHintMetadata,\n GENERATED_RUNTIME_DEPENDENCY_VERSIONS,\n unknownCapabilityDiagnostic,\n unknownPermissionDiagnostic,\n unsupportedPermissionDiagnostic,\n} from './expoRuntimePlanningMetadata';\n\nexport type { ExpoRuntimeAdapterId, ExpoRuntimeProviderId };\n\nexport interface ExpoRuntimePlanningScreen {\n readonly requires?: {\n readonly capabilities?: readonly ScreenCapabilityRequirement[];\n readonly permissions?: readonly ScreenPermissionRequirement[];\n };\n}\n\nexport interface ExpoRuntimePlanningManifest {\n readonly screens: Readonly<Record<string, ExpoRuntimePlanningScreen>>;\n}\n\ninterface ExpoRuntimeDependency {\n readonly name: string;\n readonly version: string;\n readonly reasons: readonly string[];\n}\n\nexport interface ExpoRuntimePlan {\n readonly permissions: readonly ScreenPermissionRequirement[];\n readonly capabilities: readonly ScreenCapabilityRequirement[];\n readonly impliedPermissions: readonly ScreenPermissionRequirement[];\n readonly dependencies: readonly ExpoRuntimeDependency[];\n readonly nativeConfig: {\n readonly androidPermissions: readonly string[];\n readonly configHints: readonly string[];\n readonly plugins: readonly ExpoRuntimeConfigPlugin[];\n };\n readonly providers: readonly ExpoRuntimeProviderId[];\n readonly runtimeAdapters: readonly ExpoRuntimeAdapterId[];\n readonly usesExpoRuntimeRegistry: boolean;\n readonly needsPermissionsProvider: boolean;\n readonly diagnostics: readonly ExpoRuntimeDiagnostic[];\n}\n\ninterface ResolveExpoRuntimePlanOptions {\n readonly capabilityRegistry?: Readonly<\n Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>\n >;\n readonly dependencyVersions?: Readonly<Record<string, string>>;\n readonly permissionSupport?: Readonly<Record<Permission, ExpoPermissionMetadata>>;\n}\n\ninterface PlanningState {\n readonly permissions: Map<string, ScreenPermissionRequirement>;\n readonly impliedPermissions: Map<string, ScreenPermissionRequirement>;\n readonly capabilities: Map<string, ScreenCapabilityRequirement>;\n readonly diagnostics: ExpoRuntimeDiagnostic[];\n readonly dependencies: Map<string, ExpoRuntimeDependency>;\n readonly pluginOptions: Map<string, Record<string, boolean | string>>;\n readonly configHints: Set<string>;\n readonly androidPermissions: Set<string>;\n readonly providers: Set<ExpoRuntimeProviderId>;\n readonly runtimeAdapters: Set<ExpoRuntimeAdapterId>;\n}\n\ninterface PlanningContext {\n readonly state: PlanningState;\n readonly capabilityRegistry: Readonly<\n Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>\n >;\n readonly dependencyVersions: Readonly<Record<string, string>>;\n readonly permissionSupport: Readonly<Record<Permission, ExpoPermissionMetadata>>;\n}\n\nconst EXPO_RUNTIME_PACKAGE_NAME = '@ankhorage/expo-runtime';\n\nexport function resolveExpoRuntimePlan(\n manifest: ExpoRuntimePlanningManifest,\n options: ResolveExpoRuntimePlanOptions = {},\n): ExpoRuntimePlan {\n const state = createPlanningState(manifest);\n const context: PlanningContext = {\n state,\n capabilityRegistry: options.capabilityRegistry ?? EXPO_CAPABILITY_RUNTIME_REGISTRY,\n dependencyVersions: options.dependencyVersions ?? GENERATED_RUNTIME_DEPENDENCY_VERSIONS,\n permissionSupport: options.permissionSupport ?? EXPO_PERMISSION_SUPPORT,\n };\n addImpliedPermissions(context);\n planPermissions(context);\n planCapabilities(context);\n if (state.providers.size > 0 || state.runtimeAdapters.size > 0) {\n addDependency(context, EXPO_RUNTIME_PACKAGE_NAME, 'runtime:expo');\n }\n return buildPlan(state);\n}\n\nfunction createPlanningState(manifest: ExpoRuntimePlanningManifest): PlanningState {\n const permissions = new Map<string, ScreenPermissionRequirement>();\n const capabilities = new Map<string, ScreenCapabilityRequirement>();\n for (const screen of Object.values(manifest.screens)) {\n for (const requirement of screen.requires?.permissions ?? []) {\n permissions.set(requirement.permission, requirement);\n }\n for (const requirement of screen.requires?.capabilities ?? []) {\n capabilities.set(requirement.capability, requirement);\n }\n }\n return {\n permissions,\n capabilities,\n impliedPermissions: new Map(),\n diagnostics: [],\n dependencies: new Map(),\n pluginOptions: new Map(),\n configHints: new Set(),\n androidPermissions: new Set(),\n providers: new Set(),\n runtimeAdapters: new Set(),\n };\n}\n\nfunction addImpliedPermissions(context: PlanningContext): void {\n const { state } = context;\n for (const capability of state.capabilities.values()) {\n const metadata = findCapabilityMetadata(context.capabilityRegistry, capability);\n for (const permission of metadata?.impliedPermissions ?? []) {\n if (!state.permissions.has(permission.permission)) {\n state.permissions.set(permission.permission, permission);\n state.impliedPermissions.set(permission.permission, permission);\n }\n }\n }\n}\n\nfunction planPermissions(context: PlanningContext): void {\n for (const requirement of context.state.permissions.values()) {\n planPermission(context, requirement);\n }\n}\n\nfunction planPermission(context: PlanningContext, requirement: ScreenPermissionRequirement): void {\n if (!isPermission(requirement.permission)) {\n context.state.diagnostics.push(unknownPermissionDiagnostic(requirement.permission));\n return;\n }\n const metadata = findPermissionSupport(context.permissionSupport, requirement.permission);\n if (isUnsupported(metadata.support)) {\n context.state.diagnostics.push(\n unsupportedPermissionDiagnostic(requirement.permission, metadata.support),\n );\n return;\n }\n if (metadata.support === 'notRequired') {\n return;\n }\n const reason = `permission:${requirement.permission}`;\n addProvider(context, 'permissions', reason);\n metadata.requiredPackages.forEach((name) => addDependency(context, name, reason));\n metadata.configHints.forEach((hint) => applyConfigHint(context.state, hint));\n}\n\nfunction planCapabilities(context: PlanningContext): void {\n for (const requirement of context.state.capabilities.values()) {\n const metadata = findCapabilityMetadata(context.capabilityRegistry, requirement);\n if (metadata === undefined) {\n context.state.diagnostics.push(unknownCapabilityDiagnostic(requirement.capability));\n continue;\n }\n const reason = `capability:${requirement.capability}`;\n metadata.requiredPackages?.forEach((name) => addDependency(context, name, reason));\n metadata.providers?.forEach((provider) => addProvider(context, provider, reason));\n metadata.runtimeAdapters?.forEach((adapter) => context.state.runtimeAdapters.add(adapter));\n metadata.androidPermissions?.forEach((permission) =>\n context.state.androidPermissions.add(permission),\n );\n metadata.plugins?.forEach((plugin) => addPlugin(context.state, plugin));\n }\n}\n\nfunction applyConfigHint(state: PlanningState, configHint: string): void {\n state.configHints.add(configHint);\n const metadata = findConfigHintMetadata(configHint);\n if (metadata === undefined) {\n state.diagnostics.push({\n severity: 'warning',\n requirementType: 'configHint',\n requirement: configHint,\n message: `Config hint '${configHint}' is not translated into generated Expo config yet.`,\n });\n return;\n }\n metadata.androidPermissions?.forEach((permission) => state.androidPermissions.add(permission));\n if (metadata.plugin !== undefined) {\n addPlugin(state, metadata.plugin);\n }\n}\n\nfunction addDependency(context: PlanningContext, name: string, reason: string): void {\n const version = findDependencyVersion(context.dependencyVersions, name);\n if (version === undefined) {\n context.state.diagnostics.push({\n severity: 'warning',\n requirementType: 'package',\n requirement: name,\n message: `No generated-app dependency version is registered for '${name}'.`,\n });\n return;\n }\n const existing = context.state.dependencies.get(name);\n context.state.dependencies.set(name, {\n name,\n version,\n reasons: existing === undefined ? [reason] : Array.from(new Set([...existing.reasons, reason])),\n });\n const requiredPeers = Object.entries(EXPO_RUNTIME_PACKAGE_PEERS).find(\n ([packageName]) => packageName === name,\n )?.[1];\n for (const peerName of requiredPeers ?? []) {\n addDependency(context, peerName, `peer:${name}`);\n }\n}\n\nfunction addProvider(\n context: PlanningContext,\n provider: ExpoRuntimeProviderId,\n reason: string,\n): void {\n context.state.providers.add(provider);\n const packageName = Object.entries(EXPO_RUNTIME_PROVIDER_PACKAGES).find(\n ([name]) => name === String(provider),\n )?.[1];\n if (packageName === undefined) {\n throw new Error(`Runtime package metadata is missing for provider '${provider}'.`);\n }\n addDependency(context, packageName, reason);\n}\n\nfunction addPlugin(state: PlanningState, plugin: ExpoRuntimeConfigPlugin): void {\n const existingOptions = state.pluginOptions.get(plugin.name) ?? {};\n state.pluginOptions.set(plugin.name, { ...existingOptions, ...(plugin.options ?? {}) });\n}\n\nfunction buildPlan(state: PlanningState): ExpoRuntimePlan {\n const plugins = Array.from(state.pluginOptions, ([name, options]) => ({\n name,\n options: Object.keys(options).length > 0 ? options : undefined,\n })).sort((left, right) => left.name.localeCompare(right.name));\n return {\n permissions: Array.from(state.permissions.values()).sort(comparePermissions),\n capabilities: Array.from(state.capabilities.values()).sort(compareCapabilities),\n impliedPermissions: Array.from(state.impliedPermissions.values()).sort(comparePermissions),\n dependencies: Array.from(state.dependencies.values()).sort((left, right) =>\n left.name.localeCompare(right.name),\n ),\n nativeConfig: {\n androidPermissions: Array.from(state.androidPermissions).sort(),\n configHints: Array.from(state.configHints).sort(),\n plugins,\n },\n providers: Array.from(state.providers).sort(),\n runtimeAdapters: Array.from(state.runtimeAdapters).sort(),\n usesExpoRuntimeRegistry: state.runtimeAdapters.size > 0,\n needsPermissionsProvider: state.providers.has('permissions'),\n diagnostics: state.diagnostics,\n };\n}\n\nfunction findPermissionSupport(\n registry: Readonly<Record<Permission, ExpoPermissionMetadata>>,\n permission: Permission,\n): ExpoPermissionMetadata {\n const metadata = Object.entries(registry).find(([name]) => name === String(permission))?.[1];\n if (metadata === undefined) {\n throw new Error(`Permission metadata is missing for '${permission}'.`);\n }\n return metadata;\n}\n\nfunction findDependencyVersion(\n versions: Readonly<Record<string, string>>,\n name: string,\n): string | undefined {\n return Object.entries(versions).find(([candidate]) => candidate === name)?.[1];\n}\n\nfunction isUnsupported(support: PermissionSupport): boolean {\n return support === 'unsupported' || support === 'notImplemented' || support === 'limited';\n}\n\nfunction compareCapabilities(\n left: ScreenCapabilityRequirement,\n right: ScreenCapabilityRequirement,\n): number {\n return left.capability.localeCompare(right.capability);\n}\n\nfunction comparePermissions(\n left: ScreenPermissionRequirement,\n right: ScreenPermissionRequirement,\n): number {\n return left.permission.localeCompare(right.permission);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resolveExpoRuntimePlan.js","sourceRoot":"","sources":["../src/resolveExpoRuntimePlan.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,GAG3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,GAGxB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAmB,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EACL,gCAAgC,EAChC,0BAA0B,EAC1B,8BAA8B,EAM9B,sBAAsB,EACtB,sBAAsB,EACtB,qCAAqC,EACrC,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AA4CvC,MAAM,yBAAyB,GAAG,yBAAyB,CAAC;AAE5D,MAAM,UAAU,sBAAsB,CACpC,QAAqC,EACrC,UAAyC,EAAE;IAE3C,MAAM,KAAK,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IACvD,MAAM,OAAO,GAA+B;QAC1C,KAAK;QACL,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,gCAAgC;QAClF,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,qCAAqC;QACvF,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,uBAAuB;KACxE,CAAC;IACF,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/B,eAAe,CAAC,OAAO,CAAC,CAAC;IACzB,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC1B,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QAC/D,aAAa,CAAC,OAAO,EAAE,yBAAyB,EAAE,cAAc,CAAC,CAAC;IACpE,CAAC;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AClB,CAAC;AAED,SAAS,qBAAqB,CAC5B,QAA0C,EAC1C,IAAY;IAEZ,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,aAAa,CAAC,OAA0B;IAC/C,OAAO,OAAO,KAAK,aAAa,IAAI,OAAO,KAAK,gBAAgB,IAAI,OAAO,KAAK,SAAS,CAAC;AAC5F,CAAC","sourcesContent":["import {\n ANKHORAGE_PERMISSION_NAMES,\n type AnkhorageCapabilityName,\n type ScreenRequirements,\n} from '@ankhorage/contracts';\nimport {\n EXPO_PERMISSION_SUPPORT,\n type ExpoPermissionMetadata,\n type PermissionSupport,\n} from '@ankhorage/permissions/expo/manifest';\nimport { isPermission, type Permission } from '@ankhorage/permissions/registry';\n\nimport { collectExpoRuntimeManifestRequirements } from './collectExpoRuntimeManifestRequirements';\nimport {\n EXPO_CAPABILITY_RUNTIME_REGISTRY,\n EXPO_RUNTIME_PACKAGE_PEERS,\n EXPO_RUNTIME_PROVIDER_PACKAGES,\n type ExpoRuntimeAdapterId,\n type ExpoRuntimeCapabilityMetadata,\n type ExpoRuntimeConfigPlugin,\n type ExpoRuntimeDiagnostic,\n type ExpoRuntimeProviderId,\n findCapabilityMetadata,\n findConfigHintMetadata,\n GENERATED_RUNTIME_DEPENDENCY_VERSIONS,\n unknownCapabilityDiagnostic,\n unknownPermissionDiagnostic,\n unsupportedPermissionDiagnostic,\n} from './expoRuntimePlanningMetadata';\nimport type {\n ExpoRuntimeCapabilityRequirement,\n ExpoRuntimeDependency,\n ExpoRuntimePermissionRequirement,\n ExpoRuntimePlanningContext,\n ExpoRuntimePlanningState,\n} from './types/expoRuntimePlanning';\n\nexport type { ExpoRuntimeAdapterId, ExpoRuntimeProviderId };\n\nexport interface ExpoRuntimePlanningScreen {\n readonly requires?: ScreenRequirements;\n}\n\nexport interface ExpoRuntimePlanningManifest {\n readonly screens: Readonly<Record<string, ExpoRuntimePlanningScreen>>;\n}\n\nexport interface ExpoRuntimePlan {\n readonly permissions: readonly ExpoRuntimePermissionRequirement[];\n readonly capabilities: readonly ExpoRuntimeCapabilityRequirement[];\n readonly impliedPermissions: readonly ExpoRuntimePermissionRequirement[];\n readonly dependencies: readonly ExpoRuntimeDependency[];\n readonly nativeConfig: {\n readonly androidPermissions: readonly string[];\n readonly configHints: readonly string[];\n readonly plugins: readonly ExpoRuntimeConfigPlugin[];\n };\n readonly providers: readonly ExpoRuntimeProviderId[];\n readonly runtimeAdapters: readonly ExpoRuntimeAdapterId[];\n readonly usesExpoRuntimeRegistry: boolean;\n readonly needsPermissionsProvider: boolean;\n readonly diagnostics: readonly ExpoRuntimeDiagnostic[];\n}\n\ninterface ResolveExpoRuntimePlanOptions {\n readonly capabilityRegistry?: Readonly<\n Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>\n >;\n readonly dependencyVersions?: Readonly<Record<string, string>>;\n readonly permissionSupport?: Readonly<Record<Permission, ExpoPermissionMetadata>>;\n}\n\nconst EXPO_RUNTIME_PACKAGE_NAME = '@ankhorage/expo-runtime';\n\nexport function resolveExpoRuntimePlan(\n manifest: ExpoRuntimePlanningManifest,\n options: ResolveExpoRuntimePlanOptions = {},\n): ExpoRuntimePlan {\n const state = createExpoRuntimePlanningState(manifest);\n const context: ExpoRuntimePlanningContext = {\n state,\n capabilityRegistry: options.capabilityRegistry ?? EXPO_CAPABILITY_RUNTIME_REGISTRY,\n dependencyVersions: options.dependencyVersions ?? GENERATED_RUNTIME_DEPENDENCY_VERSIONS,\n permissionSupport: options.permissionSupport ?? EXPO_PERMISSION_SUPPORT,\n };\n addImpliedPermissions(context);\n planPermissions(context);\n planCapabilities(context);\n if (state.providers.size > 0 || state.runtimeAdapters.size > 0) {\n addDependency(context, EXPO_RUNTIME_PACKAGE_NAME, 'runtime:expo');\n }\n return buildPlan(state);\n}\n\nfunction createExpoRuntimePlanningState(\n manifest: ExpoRuntimePlanningManifest,\n): ExpoRuntimePlanningState {\n const requirements = collectExpoRuntimeManifestRequirements(manifest.screens);\n return {\n permissions: requirements.permissions,\n capabilities: requirements.capabilities,\n impliedPermissions: new Map(),\n diagnostics: [],\n dependencies: new Map(),\n pluginOptions: new Map(),\n configHints: new Set(),\n androidPermissions: new Set(),\n providers: new Set(),\n runtimeAdapters: new Set(),\n };\n}\n\nfunction addImpliedPermissions(context: ExpoRuntimePlanningContext): void {\n const { state } = context;\n for (const capability of state.capabilities.values()) {\n const metadata = findCapabilityMetadata(context.capabilityRegistry, capability.capability);\n for (const permission of ANKHORAGE_PERMISSION_NAMES) {\n const implied = Object.hasOwn(metadata?.impliedPermissions ?? {}, permission);\n if (!implied) continue;\n const requirement = { permission };\n if (!state.permissions.has(permission)) {\n state.permissions.set(permission, requirement);\n state.impliedPermissions.set(permission, requirement);\n }\n }\n }\n}\n\nfunction planPermissions(context: ExpoRuntimePlanningContext): void {\n for (const requirement of context.state.permissions.values()) {\n planPermission(context, requirement);\n }\n}\n\nfunction planPermission(\n context: ExpoRuntimePlanningContext,\n requirement: ExpoRuntimePermissionRequirement,\n): void {\n if (!isPermission(requirement.permission)) {\n context.state.diagnostics.push(unknownPermissionDiagnostic(requirement.permission));\n return;\n }\n const metadata = findPermissionSupport(context.permissionSupport, requirement.permission);\n if (isUnsupported(metadata.support)) {\n context.state.diagnostics.push(\n unsupportedPermissionDiagnostic(requirement.permission, metadata.support),\n );\n return;\n }\n if (metadata.support === 'notRequired') {\n return;\n }\n const reason = `permission:${requirement.permission}`;\n addProvider(context, 'permissions', reason);\n metadata.requiredPackages.forEach((name) => addDependency(context, name, reason));\n metadata.configHints.forEach((hint) => applyConfigHint(context.state, hint));\n}\n\nfunction planCapabilities(context: ExpoRuntimePlanningContext): void {\n for (const requirement of context.state.capabilities.values()) {\n const metadata = findCapabilityMetadata(context.capabilityRegistry, requirement.capability);\n if (metadata === undefined) {\n context.state.diagnostics.push(unknownCapabilityDiagnostic(requirement.capability));\n continue;\n }\n const reason = `capability:${requirement.capability}`;\n metadata.requiredPackages?.forEach((name) => addDependency(context, name, reason));\n metadata.providers?.forEach((provider) => addProvider(context, provider, reason));\n metadata.runtimeAdapters?.forEach((adapter) => context.state.runtimeAdapters.add(adapter));\n metadata.androidPermissions?.forEach((permission) =>\n context.state.androidPermissions.add(permission),\n );\n metadata.plugins?.forEach((plugin) => addPlugin(context.state, plugin));\n }\n}\n\nfunction applyConfigHint(state: ExpoRuntimePlanningState, configHint: string): void {\n state.configHints.add(configHint);\n const metadata = findConfigHintMetadata(configHint);\n if (metadata === undefined) {\n state.diagnostics.push({\n severity: 'warning',\n requirementType: 'configHint',\n requirement: configHint,\n message: `Config hint '${configHint}' is not translated into generated Expo config yet.`,\n });\n return;\n }\n metadata.androidPermissions?.forEach((permission) => state.androidPermissions.add(permission));\n if (metadata.plugin !== undefined) {\n addPlugin(state, metadata.plugin);\n }\n}\n\nfunction addDependency(context: ExpoRuntimePlanningContext, name: string, reason: string): void {\n const version = findDependencyVersion(context.dependencyVersions, name);\n if (version === undefined) {\n context.state.diagnostics.push({\n severity: 'warning',\n requirementType: 'package',\n requirement: name,\n message: `No generated-app dependency version is registered for '${name}'.`,\n });\n return;\n }\n const existing = context.state.dependencies.get(name);\n context.state.dependencies.set(name, {\n name,\n version,\n reasons: existing === undefined ? [reason] : Array.from(new Set([...existing.reasons, reason])),\n });\n const requiredPeers = Object.entries(EXPO_RUNTIME_PACKAGE_PEERS).find(\n ([packageName]) => packageName === name,\n )?.[1];\n for (const peerName of requiredPeers ?? []) {\n addDependency(context, peerName, `peer:${name}`);\n }\n}\n\nfunction addProvider(\n context: ExpoRuntimePlanningContext,\n provider: ExpoRuntimeProviderId,\n reason: string,\n): void {\n context.state.providers.add(provider);\n const packageName = Object.entries(EXPO_RUNTIME_PROVIDER_PACKAGES).find(\n ([name]) => name === String(provider),\n )?.[1];\n if (packageName === undefined) {\n throw new Error(`Runtime package metadata is missing for provider '${provider}'.`);\n }\n addDependency(context, packageName, reason);\n}\n\nfunction addPlugin(state: ExpoRuntimePlanningState, plugin: ExpoRuntimeConfigPlugin): void {\n const existingOptions = state.pluginOptions.get(plugin.name) ?? {};\n state.pluginOptions.set(plugin.name, { ...existingOptions, ...(plugin.options ?? {}) });\n}\n\nfunction buildPlan(state: ExpoRuntimePlanningState): ExpoRuntimePlan {\n const plugins = Array.from(state.pluginOptions, ([name, options]) => ({\n name,\n options: Object.keys(options).length > 0 ? options : undefined,\n })).sort((left, right) => left.name.localeCompare(right.name));\n return {\n permissions: Array.from(state.permissions.values()).sort((left, right) =>\n left.permission.localeCompare(right.permission),\n ),\n capabilities: Array.from(state.capabilities.values()).sort((left, right) =>\n left.capability.localeCompare(right.capability),\n ),\n impliedPermissions: Array.from(state.impliedPermissions.values()).sort((left, right) =>\n left.permission.localeCompare(right.permission),\n ),\n dependencies: Array.from(state.dependencies.values()).sort((left, right) =>\n left.name.localeCompare(right.name),\n ),\n nativeConfig: {\n androidPermissions: Array.from(state.androidPermissions).sort(),\n configHints: Array.from(state.configHints).sort(),\n plugins,\n },\n providers: Array.from(state.providers).sort(),\n runtimeAdapters: Array.from(state.runtimeAdapters).sort(),\n usesExpoRuntimeRegistry: state.runtimeAdapters.size > 0,\n needsPermissionsProvider: state.providers.has('permissions'),\n diagnostics: state.diagnostics,\n };\n}\n\nfunction findPermissionSupport(\n registry: Readonly<Record<Permission, ExpoPermissionMetadata>>,\n permission: Permission,\n): ExpoPermissionMetadata {\n const metadata = Object.entries(registry).find(([name]) => name === String(permission))?.[1];\n if (metadata === undefined) {\n throw new Error(`Permission metadata is missing for '${permission}'.`);\n }\n return metadata;\n}\n\nfunction findDependencyVersion(\n versions: Readonly<Record<string, string>>,\n name: string,\n): string | undefined {\n return Object.entries(versions).find(([candidate]) => candidate === name)?.[1];\n}\n\nfunction isUnsupported(support: PermissionSupport): boolean {\n return support === 'unsupported' || support === 'notImplemented' || support === 'limited';\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AnkhorageCapabilityName, AnkhoragePermissionName } from '@ankhorage/contracts';
|
|
2
|
+
import type { ExpoPermissionMetadata } from '@ankhorage/permissions/expo/manifest';
|
|
3
|
+
import type { Permission } from '@ankhorage/permissions/registry';
|
|
4
|
+
import type { ExpoRuntimeAdapterId, ExpoRuntimeCapabilityMetadata, ExpoRuntimeDiagnostic, ExpoRuntimeProviderId } from '../expoRuntimePlanningMetadata';
|
|
5
|
+
export interface ExpoRuntimePermissionRequirement {
|
|
6
|
+
readonly permission: AnkhoragePermissionName;
|
|
7
|
+
}
|
|
8
|
+
export interface ExpoRuntimeCapabilityRequirement {
|
|
9
|
+
readonly capability: AnkhorageCapabilityName;
|
|
10
|
+
}
|
|
11
|
+
export interface ExpoRuntimeDependency {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly version: string;
|
|
14
|
+
readonly reasons: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
export interface ExpoRuntimePlanningState {
|
|
17
|
+
readonly permissions: Map<AnkhoragePermissionName, ExpoRuntimePermissionRequirement>;
|
|
18
|
+
readonly impliedPermissions: Map<AnkhoragePermissionName, ExpoRuntimePermissionRequirement>;
|
|
19
|
+
readonly capabilities: Map<AnkhorageCapabilityName, ExpoRuntimeCapabilityRequirement>;
|
|
20
|
+
readonly diagnostics: ExpoRuntimeDiagnostic[];
|
|
21
|
+
readonly dependencies: Map<string, ExpoRuntimeDependency>;
|
|
22
|
+
readonly pluginOptions: Map<string, Record<string, boolean | string>>;
|
|
23
|
+
readonly configHints: Set<string>;
|
|
24
|
+
readonly androidPermissions: Set<string>;
|
|
25
|
+
readonly providers: Set<ExpoRuntimeProviderId>;
|
|
26
|
+
readonly runtimeAdapters: Set<ExpoRuntimeAdapterId>;
|
|
27
|
+
}
|
|
28
|
+
export interface ExpoRuntimePlanningContext {
|
|
29
|
+
readonly state: ExpoRuntimePlanningState;
|
|
30
|
+
readonly capabilityRegistry: Readonly<Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>>;
|
|
31
|
+
readonly dependencyVersions: Readonly<Record<string, string>>;
|
|
32
|
+
readonly permissionSupport: Readonly<Record<Permission, ExpoPermissionMetadata>>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=expoRuntimePlanning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expoRuntimePlanning.d.ts","sourceRoot":"","sources":["../../src/types/expoRuntimePlanning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,KAAK,EACV,oBAAoB,EACpB,6BAA6B,EAC7B,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;CAC9C;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;CAC9C;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,uBAAuB,EAAE,gCAAgC,CAAC,CAAC;IACrF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,CAAC,uBAAuB,EAAE,gCAAgC,CAAC,CAAC;IAC5F,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,uBAAuB,EAAE,gCAAgC,CAAC,CAAC;IACtF,QAAQ,CAAC,WAAW,EAAE,qBAAqB,EAAE,CAAC;IAC9C,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC1D,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAC/C,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC,oBAAoB,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC;IACzC,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,CACnC,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,6BAA6B,CAAC,CAAC,CACxE,CAAC;IACF,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9D,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC;CAClF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expoRuntimePlanning.js","sourceRoot":"","sources":["../../src/types/expoRuntimePlanning.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnkhorageCapabilityName, AnkhoragePermissionName } from '@ankhorage/contracts';\nimport type { ExpoPermissionMetadata } from '@ankhorage/permissions/expo/manifest';\nimport type { Permission } from '@ankhorage/permissions/registry';\n\nimport type {\n ExpoRuntimeAdapterId,\n ExpoRuntimeCapabilityMetadata,\n ExpoRuntimeDiagnostic,\n ExpoRuntimeProviderId,\n} from '../expoRuntimePlanningMetadata';\n\nexport interface ExpoRuntimePermissionRequirement {\n readonly permission: AnkhoragePermissionName;\n}\n\nexport interface ExpoRuntimeCapabilityRequirement {\n readonly capability: AnkhorageCapabilityName;\n}\n\nexport interface ExpoRuntimeDependency {\n readonly name: string;\n readonly version: string;\n readonly reasons: readonly string[];\n}\n\nexport interface ExpoRuntimePlanningState {\n readonly permissions: Map<AnkhoragePermissionName, ExpoRuntimePermissionRequirement>;\n readonly impliedPermissions: Map<AnkhoragePermissionName, ExpoRuntimePermissionRequirement>;\n readonly capabilities: Map<AnkhorageCapabilityName, ExpoRuntimeCapabilityRequirement>;\n readonly diagnostics: ExpoRuntimeDiagnostic[];\n readonly dependencies: Map<string, ExpoRuntimeDependency>;\n readonly pluginOptions: Map<string, Record<string, boolean | string>>;\n readonly configHints: Set<string>;\n readonly androidPermissions: Set<string>;\n readonly providers: Set<ExpoRuntimeProviderId>;\n readonly runtimeAdapters: Set<ExpoRuntimeAdapterId>;\n}\n\nexport interface ExpoRuntimePlanningContext {\n readonly state: ExpoRuntimePlanningState;\n readonly capabilityRegistry: Readonly<\n Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>\n >;\n readonly dependencyVersions: Readonly<Record<string, string>>;\n readonly permissionSupport: Readonly<Record<Permission, ExpoPermissionMetadata>>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/expo-runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.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": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"runtime"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ankhorage/contracts": "^
|
|
29
|
+
"@ankhorage/contracts": "^22.0.2"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ANKHORAGE_CAPABILITY_NAMES,
|
|
3
|
+
ANKHORAGE_PERMISSION_NAMES,
|
|
4
|
+
type AnkhorageCapabilityName,
|
|
5
|
+
type AnkhoragePermissionName,
|
|
6
|
+
type ScreenRequirements,
|
|
7
|
+
} from '@ankhorage/contracts';
|
|
8
|
+
|
|
9
|
+
interface ExpoRuntimeManifestRequirementSelection {
|
|
10
|
+
readonly permissions: Map<
|
|
11
|
+
AnkhoragePermissionName,
|
|
12
|
+
{ readonly permission: AnkhoragePermissionName }
|
|
13
|
+
>;
|
|
14
|
+
readonly capabilities: Map<
|
|
15
|
+
AnkhorageCapabilityName,
|
|
16
|
+
{ readonly capability: AnkhorageCapabilityName }
|
|
17
|
+
>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/*** Collect canonical screen requirement-set membership into the deterministic planning maps. */
|
|
21
|
+
export function collectExpoRuntimeManifestRequirements(
|
|
22
|
+
screens: Readonly<Record<string, { readonly requires?: ScreenRequirements }>>,
|
|
23
|
+
): ExpoRuntimeManifestRequirementSelection {
|
|
24
|
+
const permissions = new Map<
|
|
25
|
+
AnkhoragePermissionName,
|
|
26
|
+
{ readonly permission: AnkhoragePermissionName }
|
|
27
|
+
>();
|
|
28
|
+
const capabilities = new Map<
|
|
29
|
+
AnkhorageCapabilityName,
|
|
30
|
+
{ readonly capability: AnkhorageCapabilityName }
|
|
31
|
+
>();
|
|
32
|
+
|
|
33
|
+
for (const screen of Object.values(screens)) {
|
|
34
|
+
for (const permission of ANKHORAGE_PERMISSION_NAMES) {
|
|
35
|
+
if (hasRequirement(screen.requires?.permissions, permission)) {
|
|
36
|
+
permissions.set(permission, { permission });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const capability of ANKHORAGE_CAPABILITY_NAMES) {
|
|
40
|
+
if (hasRequirement(screen.requires?.capabilities, capability)) {
|
|
41
|
+
capabilities.set(capability, { capability });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { permissions, capabilities };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*** Return whether a canonical serializable requirement set contains one enabled name. */
|
|
50
|
+
function hasRequirement(
|
|
51
|
+
requirements: Readonly<Partial<Record<string, true>>> | undefined,
|
|
52
|
+
name: string,
|
|
53
|
+
): boolean {
|
|
54
|
+
return Object.hasOwn(requirements ?? {}, name);
|
|
55
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AnkhorageCapabilityName,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
AnkhoragePermissionName,
|
|
4
|
+
SerializableSet,
|
|
5
5
|
} from '@ankhorage/contracts';
|
|
6
6
|
import type { PermissionSupport } from '@ankhorage/permissions/expo/manifest';
|
|
7
7
|
|
|
@@ -24,7 +24,7 @@ export interface ExpoRuntimeDiagnostic {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface ExpoRuntimeCapabilityMetadata {
|
|
27
|
-
readonly impliedPermissions?:
|
|
27
|
+
readonly impliedPermissions?: SerializableSet<AnkhoragePermissionName>;
|
|
28
28
|
readonly requiredPackages?: readonly string[];
|
|
29
29
|
readonly providers?: readonly ExpoRuntimeProviderId[];
|
|
30
30
|
readonly runtimeAdapters?: readonly ExpoRuntimeAdapterId[];
|
|
@@ -136,7 +136,7 @@ const EXPO_RUNTIME_CONFIG_HINTS = {
|
|
|
136
136
|
|
|
137
137
|
export const EXPO_CAPABILITY_RUNTIME_REGISTRY = {
|
|
138
138
|
barcodeScanner: {
|
|
139
|
-
impliedPermissions:
|
|
139
|
+
impliedPermissions: { camera: true },
|
|
140
140
|
requiredPackages: [EXPO_PLATFORM.packages.camera.name],
|
|
141
141
|
providers: ['permissions'],
|
|
142
142
|
runtimeAdapters: ['ExpoBarcodeScannerAdapter'],
|
|
@@ -162,9 +162,9 @@ export const EXPO_CAPABILITY_RUNTIME_REGISTRY = {
|
|
|
162
162
|
|
|
163
163
|
export function findCapabilityMetadata(
|
|
164
164
|
registry: Readonly<Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>>,
|
|
165
|
-
|
|
165
|
+
capability: AnkhorageCapabilityName,
|
|
166
166
|
): ExpoRuntimeCapabilityMetadata | undefined {
|
|
167
|
-
return Object.entries(registry).find(([name]) => name ===
|
|
167
|
+
return Object.entries(registry).find(([name]) => name === capability)?.[1];
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
export function findConfigHintMetadata(configHint: string): ExpoRuntimeHintMetadata | undefined {
|
package/src/planning.test.ts
CHANGED
|
@@ -11,7 +11,7 @@ describe('resolveExpoRuntimePlan permissions', () => {
|
|
|
11
11
|
const manifest: ExpoRuntimePlanningManifest = {
|
|
12
12
|
screens: {
|
|
13
13
|
home: {
|
|
14
|
-
requires: { permissions:
|
|
14
|
+
requires: { permissions: { camera: true } },
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
};
|
|
@@ -21,7 +21,7 @@ describe('resolveExpoRuntimePlan permissions', () => {
|
|
|
21
21
|
|
|
22
22
|
test('resolves camera permission through Expo permission metadata', () => {
|
|
23
23
|
const plan = resolveExpoRuntimePlan(
|
|
24
|
-
withFirstScreenRequirements({ permissions:
|
|
24
|
+
withFirstScreenRequirements({ permissions: { camera: true } }),
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
expect(plan.dependencies.map((dependency) => dependency.name)).toEqual([
|
|
@@ -53,7 +53,7 @@ describe('resolveExpoRuntimePlan permissions', () => {
|
|
|
53
53
|
describe('resolveExpoRuntimePlan barcode capability', () => {
|
|
54
54
|
test('resolves barcodeScanner capability with implied camera permission and adapter wiring', () => {
|
|
55
55
|
const plan = resolveExpoRuntimePlan(
|
|
56
|
-
withFirstScreenRequirements({ capabilities:
|
|
56
|
+
withFirstScreenRequirements({ capabilities: { barcodeScanner: true } }),
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
expect(plan.impliedPermissions).toEqual([{ permission: 'camera' }]);
|
|
@@ -80,8 +80,8 @@ describe('resolveExpoRuntimePlan barcode capability', () => {
|
|
|
80
80
|
test('lets barcodeScanner capability override camera-only scanner disabling', () => {
|
|
81
81
|
const plan = resolveExpoRuntimePlan(
|
|
82
82
|
withFirstScreenRequirements({
|
|
83
|
-
capabilities:
|
|
84
|
-
permissions:
|
|
83
|
+
capabilities: { barcodeScanner: true },
|
|
84
|
+
permissions: { camera: true },
|
|
85
85
|
}),
|
|
86
86
|
);
|
|
87
87
|
|
|
@@ -100,7 +100,7 @@ describe('resolveExpoRuntimePlan barcode capability', () => {
|
|
|
100
100
|
describe('resolveExpoRuntimePlan ebook reader capability', () => {
|
|
101
101
|
test('selects the reader adapter and exact renderer packages without permissions', () => {
|
|
102
102
|
const plan = resolveExpoRuntimePlan(
|
|
103
|
-
withFirstScreenRequirements({ capabilities:
|
|
103
|
+
withFirstScreenRequirements({ capabilities: { ebookReader: true } }),
|
|
104
104
|
);
|
|
105
105
|
|
|
106
106
|
expect(plan.permissions).toEqual([]);
|
|
@@ -136,7 +136,7 @@ describe('resolveExpoRuntimePlan ebook reader capability', () => {
|
|
|
136
136
|
describe('resolveExpoRuntimePlan Expo 57 plugin coverage', () => {
|
|
137
137
|
test('keeps microphone-only native configuration free of background audio behavior', () => {
|
|
138
138
|
const plan = resolveExpoRuntimePlan(
|
|
139
|
-
withFirstScreenRequirements({ permissions:
|
|
139
|
+
withFirstScreenRequirements({ permissions: { microphone: true } }),
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
expect(plan.nativeConfig.plugins).toEqual([
|
|
@@ -160,14 +160,14 @@ describe('resolveExpoRuntimePlan Expo 57 plugin coverage', () => {
|
|
|
160
160
|
test('translates every supported permission into current Expo 57 packages and plugins', () => {
|
|
161
161
|
const plan = resolveExpoRuntimePlan(
|
|
162
162
|
withFirstScreenRequirements({
|
|
163
|
-
permissions:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
permissions: {
|
|
164
|
+
microphone: true,
|
|
165
|
+
mediaLibrary: true,
|
|
166
|
+
mediaLibraryWrite: true,
|
|
167
|
+
locationForeground: true,
|
|
168
|
+
locationBackground: true,
|
|
169
|
+
notifications: true,
|
|
170
|
+
},
|
|
171
171
|
}),
|
|
172
172
|
);
|
|
173
173
|
|
|
@@ -184,8 +184,8 @@ describe('resolveExpoRuntimePlan diagnostics and deduplication', () => {
|
|
|
184
184
|
test('dedupes repeated permission and capability requirements', () => {
|
|
185
185
|
const plan = resolveExpoRuntimePlan(
|
|
186
186
|
withAllScreenRequirements({
|
|
187
|
-
capabilities:
|
|
188
|
-
permissions:
|
|
187
|
+
capabilities: { barcodeScanner: true },
|
|
188
|
+
permissions: { camera: true },
|
|
189
189
|
}),
|
|
190
190
|
);
|
|
191
191
|
|
|
@@ -200,7 +200,7 @@ describe('resolveExpoRuntimePlan diagnostics and deduplication', () => {
|
|
|
200
200
|
|
|
201
201
|
test('surfaces unsupported permission support explicitly', () => {
|
|
202
202
|
const plan = resolveExpoRuntimePlan(
|
|
203
|
-
withFirstScreenRequirements({ permissions:
|
|
203
|
+
withFirstScreenRequirements({ permissions: { camera: true } }),
|
|
204
204
|
{
|
|
205
205
|
permissionSupport: {
|
|
206
206
|
...EXPO_PERMISSION_SUPPORT,
|
|
@@ -227,7 +227,7 @@ describe('resolveExpoRuntimePlan diagnostics and deduplication', () => {
|
|
|
227
227
|
describe('resolveExpoRuntimePlan platform-neutral permissions', () => {
|
|
228
228
|
test('does not add runtime packages or providers for clipboard permissions', () => {
|
|
229
229
|
const plan = resolveExpoRuntimePlan(
|
|
230
|
-
withFirstScreenRequirements({ permissions:
|
|
230
|
+
withFirstScreenRequirements({ permissions: { clipboard: true } }),
|
|
231
231
|
);
|
|
232
232
|
|
|
233
233
|
expect(plan.dependencies).toEqual([]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
ANKHORAGE_PERMISSION_NAMES,
|
|
3
|
+
type AnkhorageCapabilityName,
|
|
4
|
+
type ScreenRequirements,
|
|
5
5
|
} from '@ankhorage/contracts';
|
|
6
6
|
import {
|
|
7
7
|
EXPO_PERMISSION_SUPPORT,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@ankhorage/permissions/expo/manifest';
|
|
11
11
|
import { isPermission, type Permission } from '@ankhorage/permissions/registry';
|
|
12
12
|
|
|
13
|
+
import { collectExpoRuntimeManifestRequirements } from './collectExpoRuntimeManifestRequirements';
|
|
13
14
|
import {
|
|
14
15
|
EXPO_CAPABILITY_RUNTIME_REGISTRY,
|
|
15
16
|
EXPO_RUNTIME_PACKAGE_PEERS,
|
|
@@ -26,30 +27,28 @@ import {
|
|
|
26
27
|
unknownPermissionDiagnostic,
|
|
27
28
|
unsupportedPermissionDiagnostic,
|
|
28
29
|
} from './expoRuntimePlanningMetadata';
|
|
30
|
+
import type {
|
|
31
|
+
ExpoRuntimeCapabilityRequirement,
|
|
32
|
+
ExpoRuntimeDependency,
|
|
33
|
+
ExpoRuntimePermissionRequirement,
|
|
34
|
+
ExpoRuntimePlanningContext,
|
|
35
|
+
ExpoRuntimePlanningState,
|
|
36
|
+
} from './types/expoRuntimePlanning';
|
|
29
37
|
|
|
30
38
|
export type { ExpoRuntimeAdapterId, ExpoRuntimeProviderId };
|
|
31
39
|
|
|
32
40
|
export interface ExpoRuntimePlanningScreen {
|
|
33
|
-
readonly requires?:
|
|
34
|
-
readonly capabilities?: readonly ScreenCapabilityRequirement[];
|
|
35
|
-
readonly permissions?: readonly ScreenPermissionRequirement[];
|
|
36
|
-
};
|
|
41
|
+
readonly requires?: ScreenRequirements;
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
export interface ExpoRuntimePlanningManifest {
|
|
40
45
|
readonly screens: Readonly<Record<string, ExpoRuntimePlanningScreen>>;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
interface ExpoRuntimeDependency {
|
|
44
|
-
readonly name: string;
|
|
45
|
-
readonly version: string;
|
|
46
|
-
readonly reasons: readonly string[];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
48
|
export interface ExpoRuntimePlan {
|
|
50
|
-
readonly permissions: readonly
|
|
51
|
-
readonly capabilities: readonly
|
|
52
|
-
readonly impliedPermissions: readonly
|
|
49
|
+
readonly permissions: readonly ExpoRuntimePermissionRequirement[];
|
|
50
|
+
readonly capabilities: readonly ExpoRuntimeCapabilityRequirement[];
|
|
51
|
+
readonly impliedPermissions: readonly ExpoRuntimePermissionRequirement[];
|
|
53
52
|
readonly dependencies: readonly ExpoRuntimeDependency[];
|
|
54
53
|
readonly nativeConfig: {
|
|
55
54
|
readonly androidPermissions: readonly string[];
|
|
@@ -71,36 +70,14 @@ interface ResolveExpoRuntimePlanOptions {
|
|
|
71
70
|
readonly permissionSupport?: Readonly<Record<Permission, ExpoPermissionMetadata>>;
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
interface PlanningState {
|
|
75
|
-
readonly permissions: Map<string, ScreenPermissionRequirement>;
|
|
76
|
-
readonly impliedPermissions: Map<string, ScreenPermissionRequirement>;
|
|
77
|
-
readonly capabilities: Map<string, ScreenCapabilityRequirement>;
|
|
78
|
-
readonly diagnostics: ExpoRuntimeDiagnostic[];
|
|
79
|
-
readonly dependencies: Map<string, ExpoRuntimeDependency>;
|
|
80
|
-
readonly pluginOptions: Map<string, Record<string, boolean | string>>;
|
|
81
|
-
readonly configHints: Set<string>;
|
|
82
|
-
readonly androidPermissions: Set<string>;
|
|
83
|
-
readonly providers: Set<ExpoRuntimeProviderId>;
|
|
84
|
-
readonly runtimeAdapters: Set<ExpoRuntimeAdapterId>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
interface PlanningContext {
|
|
88
|
-
readonly state: PlanningState;
|
|
89
|
-
readonly capabilityRegistry: Readonly<
|
|
90
|
-
Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>
|
|
91
|
-
>;
|
|
92
|
-
readonly dependencyVersions: Readonly<Record<string, string>>;
|
|
93
|
-
readonly permissionSupport: Readonly<Record<Permission, ExpoPermissionMetadata>>;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
73
|
const EXPO_RUNTIME_PACKAGE_NAME = '@ankhorage/expo-runtime';
|
|
97
74
|
|
|
98
75
|
export function resolveExpoRuntimePlan(
|
|
99
76
|
manifest: ExpoRuntimePlanningManifest,
|
|
100
77
|
options: ResolveExpoRuntimePlanOptions = {},
|
|
101
78
|
): ExpoRuntimePlan {
|
|
102
|
-
const state =
|
|
103
|
-
const context:
|
|
79
|
+
const state = createExpoRuntimePlanningState(manifest);
|
|
80
|
+
const context: ExpoRuntimePlanningContext = {
|
|
104
81
|
state,
|
|
105
82
|
capabilityRegistry: options.capabilityRegistry ?? EXPO_CAPABILITY_RUNTIME_REGISTRY,
|
|
106
83
|
dependencyVersions: options.dependencyVersions ?? GENERATED_RUNTIME_DEPENDENCY_VERSIONS,
|
|
@@ -115,20 +92,13 @@ export function resolveExpoRuntimePlan(
|
|
|
115
92
|
return buildPlan(state);
|
|
116
93
|
}
|
|
117
94
|
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
for (const requirement of screen.requires?.permissions ?? []) {
|
|
123
|
-
permissions.set(requirement.permission, requirement);
|
|
124
|
-
}
|
|
125
|
-
for (const requirement of screen.requires?.capabilities ?? []) {
|
|
126
|
-
capabilities.set(requirement.capability, requirement);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
95
|
+
function createExpoRuntimePlanningState(
|
|
96
|
+
manifest: ExpoRuntimePlanningManifest,
|
|
97
|
+
): ExpoRuntimePlanningState {
|
|
98
|
+
const requirements = collectExpoRuntimeManifestRequirements(manifest.screens);
|
|
129
99
|
return {
|
|
130
|
-
permissions,
|
|
131
|
-
capabilities,
|
|
100
|
+
permissions: requirements.permissions,
|
|
101
|
+
capabilities: requirements.capabilities,
|
|
132
102
|
impliedPermissions: new Map(),
|
|
133
103
|
diagnostics: [],
|
|
134
104
|
dependencies: new Map(),
|
|
@@ -140,26 +110,32 @@ function createPlanningState(manifest: ExpoRuntimePlanningManifest): PlanningSta
|
|
|
140
110
|
};
|
|
141
111
|
}
|
|
142
112
|
|
|
143
|
-
function addImpliedPermissions(context:
|
|
113
|
+
function addImpliedPermissions(context: ExpoRuntimePlanningContext): void {
|
|
144
114
|
const { state } = context;
|
|
145
115
|
for (const capability of state.capabilities.values()) {
|
|
146
|
-
const metadata = findCapabilityMetadata(context.capabilityRegistry, capability);
|
|
147
|
-
for (const permission of
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
116
|
+
const metadata = findCapabilityMetadata(context.capabilityRegistry, capability.capability);
|
|
117
|
+
for (const permission of ANKHORAGE_PERMISSION_NAMES) {
|
|
118
|
+
const implied = Object.hasOwn(metadata?.impliedPermissions ?? {}, permission);
|
|
119
|
+
if (!implied) continue;
|
|
120
|
+
const requirement = { permission };
|
|
121
|
+
if (!state.permissions.has(permission)) {
|
|
122
|
+
state.permissions.set(permission, requirement);
|
|
123
|
+
state.impliedPermissions.set(permission, requirement);
|
|
151
124
|
}
|
|
152
125
|
}
|
|
153
126
|
}
|
|
154
127
|
}
|
|
155
128
|
|
|
156
|
-
function planPermissions(context:
|
|
129
|
+
function planPermissions(context: ExpoRuntimePlanningContext): void {
|
|
157
130
|
for (const requirement of context.state.permissions.values()) {
|
|
158
131
|
planPermission(context, requirement);
|
|
159
132
|
}
|
|
160
133
|
}
|
|
161
134
|
|
|
162
|
-
function planPermission(
|
|
135
|
+
function planPermission(
|
|
136
|
+
context: ExpoRuntimePlanningContext,
|
|
137
|
+
requirement: ExpoRuntimePermissionRequirement,
|
|
138
|
+
): void {
|
|
163
139
|
if (!isPermission(requirement.permission)) {
|
|
164
140
|
context.state.diagnostics.push(unknownPermissionDiagnostic(requirement.permission));
|
|
165
141
|
return;
|
|
@@ -180,9 +156,9 @@ function planPermission(context: PlanningContext, requirement: ScreenPermissionR
|
|
|
180
156
|
metadata.configHints.forEach((hint) => applyConfigHint(context.state, hint));
|
|
181
157
|
}
|
|
182
158
|
|
|
183
|
-
function planCapabilities(context:
|
|
159
|
+
function planCapabilities(context: ExpoRuntimePlanningContext): void {
|
|
184
160
|
for (const requirement of context.state.capabilities.values()) {
|
|
185
|
-
const metadata = findCapabilityMetadata(context.capabilityRegistry, requirement);
|
|
161
|
+
const metadata = findCapabilityMetadata(context.capabilityRegistry, requirement.capability);
|
|
186
162
|
if (metadata === undefined) {
|
|
187
163
|
context.state.diagnostics.push(unknownCapabilityDiagnostic(requirement.capability));
|
|
188
164
|
continue;
|
|
@@ -198,7 +174,7 @@ function planCapabilities(context: PlanningContext): void {
|
|
|
198
174
|
}
|
|
199
175
|
}
|
|
200
176
|
|
|
201
|
-
function applyConfigHint(state:
|
|
177
|
+
function applyConfigHint(state: ExpoRuntimePlanningState, configHint: string): void {
|
|
202
178
|
state.configHints.add(configHint);
|
|
203
179
|
const metadata = findConfigHintMetadata(configHint);
|
|
204
180
|
if (metadata === undefined) {
|
|
@@ -216,7 +192,7 @@ function applyConfigHint(state: PlanningState, configHint: string): void {
|
|
|
216
192
|
}
|
|
217
193
|
}
|
|
218
194
|
|
|
219
|
-
function addDependency(context:
|
|
195
|
+
function addDependency(context: ExpoRuntimePlanningContext, name: string, reason: string): void {
|
|
220
196
|
const version = findDependencyVersion(context.dependencyVersions, name);
|
|
221
197
|
if (version === undefined) {
|
|
222
198
|
context.state.diagnostics.push({
|
|
@@ -242,7 +218,7 @@ function addDependency(context: PlanningContext, name: string, reason: string):
|
|
|
242
218
|
}
|
|
243
219
|
|
|
244
220
|
function addProvider(
|
|
245
|
-
context:
|
|
221
|
+
context: ExpoRuntimePlanningContext,
|
|
246
222
|
provider: ExpoRuntimeProviderId,
|
|
247
223
|
reason: string,
|
|
248
224
|
): void {
|
|
@@ -256,20 +232,26 @@ function addProvider(
|
|
|
256
232
|
addDependency(context, packageName, reason);
|
|
257
233
|
}
|
|
258
234
|
|
|
259
|
-
function addPlugin(state:
|
|
235
|
+
function addPlugin(state: ExpoRuntimePlanningState, plugin: ExpoRuntimeConfigPlugin): void {
|
|
260
236
|
const existingOptions = state.pluginOptions.get(plugin.name) ?? {};
|
|
261
237
|
state.pluginOptions.set(plugin.name, { ...existingOptions, ...(plugin.options ?? {}) });
|
|
262
238
|
}
|
|
263
239
|
|
|
264
|
-
function buildPlan(state:
|
|
240
|
+
function buildPlan(state: ExpoRuntimePlanningState): ExpoRuntimePlan {
|
|
265
241
|
const plugins = Array.from(state.pluginOptions, ([name, options]) => ({
|
|
266
242
|
name,
|
|
267
243
|
options: Object.keys(options).length > 0 ? options : undefined,
|
|
268
244
|
})).sort((left, right) => left.name.localeCompare(right.name));
|
|
269
245
|
return {
|
|
270
|
-
permissions: Array.from(state.permissions.values()).sort(
|
|
271
|
-
|
|
272
|
-
|
|
246
|
+
permissions: Array.from(state.permissions.values()).sort((left, right) =>
|
|
247
|
+
left.permission.localeCompare(right.permission),
|
|
248
|
+
),
|
|
249
|
+
capabilities: Array.from(state.capabilities.values()).sort((left, right) =>
|
|
250
|
+
left.capability.localeCompare(right.capability),
|
|
251
|
+
),
|
|
252
|
+
impliedPermissions: Array.from(state.impliedPermissions.values()).sort((left, right) =>
|
|
253
|
+
left.permission.localeCompare(right.permission),
|
|
254
|
+
),
|
|
273
255
|
dependencies: Array.from(state.dependencies.values()).sort((left, right) =>
|
|
274
256
|
left.name.localeCompare(right.name),
|
|
275
257
|
),
|
|
@@ -307,17 +289,3 @@ function findDependencyVersion(
|
|
|
307
289
|
function isUnsupported(support: PermissionSupport): boolean {
|
|
308
290
|
return support === 'unsupported' || support === 'notImplemented' || support === 'limited';
|
|
309
291
|
}
|
|
310
|
-
|
|
311
|
-
function compareCapabilities(
|
|
312
|
-
left: ScreenCapabilityRequirement,
|
|
313
|
-
right: ScreenCapabilityRequirement,
|
|
314
|
-
): number {
|
|
315
|
-
return left.capability.localeCompare(right.capability);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function comparePermissions(
|
|
319
|
-
left: ScreenPermissionRequirement,
|
|
320
|
-
right: ScreenPermissionRequirement,
|
|
321
|
-
): number {
|
|
322
|
-
return left.permission.localeCompare(right.permission);
|
|
323
|
-
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AnkhorageCapabilityName, AnkhoragePermissionName } from '@ankhorage/contracts';
|
|
2
|
+
import type { ExpoPermissionMetadata } from '@ankhorage/permissions/expo/manifest';
|
|
3
|
+
import type { Permission } from '@ankhorage/permissions/registry';
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
ExpoRuntimeAdapterId,
|
|
7
|
+
ExpoRuntimeCapabilityMetadata,
|
|
8
|
+
ExpoRuntimeDiagnostic,
|
|
9
|
+
ExpoRuntimeProviderId,
|
|
10
|
+
} from '../expoRuntimePlanningMetadata';
|
|
11
|
+
|
|
12
|
+
export interface ExpoRuntimePermissionRequirement {
|
|
13
|
+
readonly permission: AnkhoragePermissionName;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ExpoRuntimeCapabilityRequirement {
|
|
17
|
+
readonly capability: AnkhorageCapabilityName;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ExpoRuntimeDependency {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly version: string;
|
|
23
|
+
readonly reasons: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ExpoRuntimePlanningState {
|
|
27
|
+
readonly permissions: Map<AnkhoragePermissionName, ExpoRuntimePermissionRequirement>;
|
|
28
|
+
readonly impliedPermissions: Map<AnkhoragePermissionName, ExpoRuntimePermissionRequirement>;
|
|
29
|
+
readonly capabilities: Map<AnkhorageCapabilityName, ExpoRuntimeCapabilityRequirement>;
|
|
30
|
+
readonly diagnostics: ExpoRuntimeDiagnostic[];
|
|
31
|
+
readonly dependencies: Map<string, ExpoRuntimeDependency>;
|
|
32
|
+
readonly pluginOptions: Map<string, Record<string, boolean | string>>;
|
|
33
|
+
readonly configHints: Set<string>;
|
|
34
|
+
readonly androidPermissions: Set<string>;
|
|
35
|
+
readonly providers: Set<ExpoRuntimeProviderId>;
|
|
36
|
+
readonly runtimeAdapters: Set<ExpoRuntimeAdapterId>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ExpoRuntimePlanningContext {
|
|
40
|
+
readonly state: ExpoRuntimePlanningState;
|
|
41
|
+
readonly capabilityRegistry: Readonly<
|
|
42
|
+
Partial<Record<AnkhorageCapabilityName, ExpoRuntimeCapabilityMetadata>>
|
|
43
|
+
>;
|
|
44
|
+
readonly dependencyVersions: Readonly<Record<string, string>>;
|
|
45
|
+
readonly permissionSupport: Readonly<Record<Permission, ExpoPermissionMetadata>>;
|
|
46
|
+
}
|