expo 58.0.1 → 58.0.2
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/android/build.gradle +2 -2
- package/bundledNativeModules.json +71 -71
- package/ios/Expo/ExpoReactNativeFactory.swift +2 -2
- package/ios/ExpoObjC/AppDelegates/EXReactRootViewFactory.mm +16 -2
- package/ios/ExpoObjC/include/Expo/EXReactRootViewFactory.h +2 -1
- package/package.json +11 -11
- package/scripts/spm/__tests__/app-target.test.js +105 -1
- package/scripts/spm/__tests__/autolink-gate.test.js +188 -0
- package/scripts/spm/__tests__/classify.test.js +17 -19
- package/scripts/spm/__tests__/diagnostics.test.js +705 -132
- package/scripts/spm/__tests__/manifests.test.js +1086 -75
- package/scripts/spm/__tests__/metadata.test.js +120 -0
- package/scripts/spm/__tests__/plugin.test.js +2549 -346
- package/scripts/spm/app-target.js +42 -1
- package/scripts/spm/autolink-gate.js +40 -0
- package/scripts/spm/classify.js +54 -77
- package/scripts/spm/diagnostics.js +540 -147
- package/scripts/spm/flavored-frameworks.js +80 -125
- package/scripts/spm/manifests.js +523 -205
- package/scripts/spm/metadata.js +152 -0
- package/scripts/spm/plugin.js +592 -277
- package/scripts/spm/podspec.js +56 -19
- package/template.tgz +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prebuilt-metadata document, read once. Every entry is checked and filled in
|
|
3
|
+
* here, so nothing downstream reads a raw entry or guesses at an absent field.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const { prebuiltMetadata } = require('./cli');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {{ exact: string } | { from: string } | { branch: string } | { revision: string }} PrebuiltSpmVersion
|
|
12
|
+
* @typedef {{ url: string, productName: string, version: PrebuiltSpmVersion }} PrebuiltSpmPackage
|
|
13
|
+
* @typedef {{ podName?: string, npmPackage?: string, podfileProperty?: string, disabledValue?: unknown }} PrebuiltAutolinkWhen
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One pod's entry, with every field the plugin reads present. Mirrors
|
|
18
|
+
* `PrebuiltMetadataEntry` in expo-modules-autolinking/src/prebuiltMetadata.ts,
|
|
19
|
+
* less `type`, `npmPackage` and `podspecDir`, which nothing here reads.
|
|
20
|
+
*
|
|
21
|
+
* @typedef {object} PrebuiltMetadataRecord
|
|
22
|
+
* @property {string} podName
|
|
23
|
+
* @property {string | null} packageRoot
|
|
24
|
+
* @property {string} productName the pod name where the entry names no product.
|
|
25
|
+
* @property {boolean} sourceOnly
|
|
26
|
+
* @property {string | null} iosDeploymentTarget
|
|
27
|
+
* @property {PrebuiltSpmPackage[]} spmPackages
|
|
28
|
+
* @property {PrebuiltAutolinkWhen | null} autolinkWhen
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const SPM_VERSION_KINDS = ['exact', 'from', 'branch', 'revision'];
|
|
32
|
+
const AUTOLINK_WHEN_SUBJECTS = ['podName', 'npmPackage', 'podfileProperty'];
|
|
33
|
+
|
|
34
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
35
|
+
const isNonEmptyString = (value) => typeof value === 'string' && value.trim() !== '';
|
|
36
|
+
const isBoolean = (value) => typeof value === 'boolean';
|
|
37
|
+
|
|
38
|
+
function describeValue(value) {
|
|
39
|
+
if (value === undefined) return 'nothing';
|
|
40
|
+
if (Array.isArray(value)) return 'an array';
|
|
41
|
+
return JSON.stringify(value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// The producer validates every field it writes, so an entry that fails here was
|
|
45
|
+
// written by an expo-modules-autolinking other than the one this plugin ships with.
|
|
46
|
+
const REMEDY =
|
|
47
|
+
'The plugin links each Expo module from this document, so it stops rather than guess. ' +
|
|
48
|
+
'The document is the output of `expo-modules-autolinking prebuilt-metadata --json`; an entry it cannot have written usually means expo and expo-modules-autolinking come from different installs. ' +
|
|
49
|
+
'Reinstall your JavaScript dependencies and sync again. If the entry is still unusable, report it at https://github.com/expo/expo/issues with the output of that command.';
|
|
50
|
+
|
|
51
|
+
function unusable(podName, field, expected, value) {
|
|
52
|
+
return new Error(
|
|
53
|
+
`[expo-spm-plugin] The prebuilt-metadata entry for pod ${podName} has an unusable ${field}: ` +
|
|
54
|
+
`expected ${expected}, got ${describeValue(value)}. ${REMEDY}`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** An entry field, or `fallback` where the entry omits it. */
|
|
59
|
+
function optionalField(podName, entry, field, isValid, expected, fallback) {
|
|
60
|
+
const value = entry[field];
|
|
61
|
+
if (value == null) return fallback;
|
|
62
|
+
if (!isValid(value)) throw unusable(podName, field, expected, value);
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The one requirement a version declares, or null when it declares none or several. */
|
|
67
|
+
function readSpmVersion(version) {
|
|
68
|
+
if (!isObject(version)) return null;
|
|
69
|
+
const declared = SPM_VERSION_KINDS.filter((kind) => kind in version);
|
|
70
|
+
if (declared.length !== 1 || typeof version[declared[0]] !== 'string') return null;
|
|
71
|
+
return { [declared[0]]: version[declared[0]] };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function readSpmPackages(podName, spmPackages) {
|
|
75
|
+
if (spmPackages == null) return [];
|
|
76
|
+
if (!Array.isArray(spmPackages)) {
|
|
77
|
+
throw unusable(podName, 'spmPackages', 'an array', spmPackages);
|
|
78
|
+
}
|
|
79
|
+
return spmPackages.map((pkg, index) => {
|
|
80
|
+
const field = `spmPackages[${index}]`;
|
|
81
|
+
if (!isObject(pkg)) {
|
|
82
|
+
throw unusable(podName, field, 'an object with url, productName and version', pkg);
|
|
83
|
+
}
|
|
84
|
+
if (!isNonEmptyString(pkg.url)) {
|
|
85
|
+
throw unusable(podName, `${field}.url`, 'a package URL', pkg.url);
|
|
86
|
+
}
|
|
87
|
+
if (!isNonEmptyString(pkg.productName)) {
|
|
88
|
+
throw unusable(podName, `${field}.productName`, 'a product name', pkg.productName);
|
|
89
|
+
}
|
|
90
|
+
const version = readSpmVersion(pkg.version);
|
|
91
|
+
if (version == null) {
|
|
92
|
+
throw unusable(
|
|
93
|
+
podName,
|
|
94
|
+
`${field}.version`,
|
|
95
|
+
'exactly one of exact, from, branch or revision, as a string',
|
|
96
|
+
pkg.version
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return { url: pkg.url, productName: pkg.productName, version };
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function readAutolinkWhen(podName, condition) {
|
|
104
|
+
if (condition == null) return null;
|
|
105
|
+
if (!isObject(condition)) throw unusable(podName, 'autolinkWhen', 'an object', condition);
|
|
106
|
+
for (const subject of AUTOLINK_WHEN_SUBJECTS) {
|
|
107
|
+
const value = condition[subject];
|
|
108
|
+
if (value !== undefined && typeof value !== 'string') {
|
|
109
|
+
throw unusable(podName, `autolinkWhen.${subject}`, 'a string', value);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return condition;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** @returns {PrebuiltMetadataRecord} */
|
|
116
|
+
function readEntry(podName, entry) {
|
|
117
|
+
if (!isObject(entry)) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
`[expo-spm-plugin] The prebuilt-metadata entry for pod ${podName} is not an object: got ${describeValue(entry)}. ${REMEDY}`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
const field = (name, isValid, expected, fallback) =>
|
|
123
|
+
optionalField(podName, entry, name, isValid, expected, fallback);
|
|
124
|
+
return {
|
|
125
|
+
podName,
|
|
126
|
+
packageRoot: field('packageRoot', isNonEmptyString, 'a directory path', null),
|
|
127
|
+
productName: field('productName', isNonEmptyString, 'a product name', podName),
|
|
128
|
+
sourceOnly: field('sourceOnly', isBoolean, 'true or false', false),
|
|
129
|
+
iosDeploymentTarget: field('iosDeploymentTarget', isNonEmptyString, 'a version string', null),
|
|
130
|
+
spmPackages: readSpmPackages(podName, entry.spmPackages),
|
|
131
|
+
autolinkWhen: readAutolinkWhen(podName, entry.autolinkWhen),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The prebuilt-metadata document for the app at `appRoot`, by pod name.
|
|
137
|
+
*
|
|
138
|
+
* @returns {Map<string, PrebuiltMetadataRecord>}
|
|
139
|
+
*/
|
|
140
|
+
function readPrebuiltMetadata(appRoot) {
|
|
141
|
+
const document = prebuiltMetadata(appRoot);
|
|
142
|
+
if (!isObject(document)) {
|
|
143
|
+
throw new Error(
|
|
144
|
+
`[expo-spm-plugin] The prebuilt-metadata document is not an object keyed by pod name: got ${describeValue(document)}. ${REMEDY}`
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
return new Map(
|
|
148
|
+
Object.entries(document).map(([podName, entry]) => [podName, readEntry(podName, entry)])
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
module.exports = { readPrebuiltMetadata };
|