@expo-harmony/config-plugins 55.0.10-harmony.1 → 55.0.10-harmony.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/build/config.d.ts +64 -0
- package/build/config.js +6 -0
- package/build/errors.d.ts +11 -0
- package/build/errors.js +14 -0
- package/build/files.d.ts +6 -0
- package/build/files.js +69 -0
- package/build/index.d.ts +12 -0
- package/build/mods.d.ts +52 -0
- package/build/mods.js +400 -0
- package/build/nativeInputs.d.ts +14 -0
- package/build/nativeInputs.js +81 -0
- package/build/normalizeConfig.d.ts +28 -0
- package/build/normalizeConfig.js +276 -0
- package/build/ownership.d.ts +16 -0
- package/build/ownership.js +112 -0
- package/build/paths.d.ts +62 -0
- package/build/paths.js +129 -0
- package/package.json +1 -1
package/build/paths.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ResourcePaths = exports.ProjectPaths = exports.ProjectPathCandidates = exports.ManagedPaths = exports.HarmonyPaths = void 0;
|
|
7
|
+
exports.isInside = isInside;
|
|
8
|
+
exports.assertNoExternalSymlink = assertNoExternalSymlink;
|
|
9
|
+
exports.resolveHarmonyPath = resolveHarmonyPath;
|
|
10
|
+
exports.resolveProjectPath = resolveProjectPath;
|
|
11
|
+
exports.toPosixRelative = toPosixRelative;
|
|
12
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
13
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
const errors_1 = require("./errors");
|
|
15
|
+
const ManagedPaths = Object.freeze({
|
|
16
|
+
appJson: 'AppScope/app.json5',
|
|
17
|
+
projectBuildProfile: 'build-profile.json5',
|
|
18
|
+
rootOhPackage: 'oh-package.json5',
|
|
19
|
+
rootHvigor: 'hvigorfile.ts',
|
|
20
|
+
nativeInputsStamp: 'native-inputs-stamp.ts',
|
|
21
|
+
hvigorConfig: 'hvigor/hvigor-config.json5',
|
|
22
|
+
entryBuildProfile: 'entry/build-profile.json5',
|
|
23
|
+
entryOhPackage: 'entry/oh-package.json5',
|
|
24
|
+
entryHvigor: 'entry/hvigorfile.ts',
|
|
25
|
+
moduleJson: 'entry/src/main/module.json5',
|
|
26
|
+
profiles: 'entry/src/main/resources/base/profile/main_pages.json',
|
|
27
|
+
entryAbility: 'entry/src/main/ets/entryability/EntryAbility.ets',
|
|
28
|
+
indexPage: 'entry/src/main/ets/pages/Index.ets',
|
|
29
|
+
worker: 'entry/src/main/ets/workers/RNOHWorker.ets',
|
|
30
|
+
arktsPackageProvider: 'entry/src/main/ets/PackageProvider.ets',
|
|
31
|
+
cppPackageProvider: 'entry/src/main/cpp/PackageProvider.cpp',
|
|
32
|
+
cmakeLists: 'entry/src/main/cpp/CMakeLists.txt',
|
|
33
|
+
});
|
|
34
|
+
exports.ManagedPaths = ManagedPaths;
|
|
35
|
+
const ProjectPaths = Object.freeze({
|
|
36
|
+
reactNativeConfig: 'react-native.config.js',
|
|
37
|
+
});
|
|
38
|
+
exports.ProjectPaths = ProjectPaths;
|
|
39
|
+
const ProjectPathCandidates = Object.freeze({
|
|
40
|
+
// Keep this order aligned with @react-native-community/cli-config's async
|
|
41
|
+
// search places. The first entry is also the file created for new projects.
|
|
42
|
+
reactNativeConfig: Object.freeze([
|
|
43
|
+
'react-native.config.js',
|
|
44
|
+
'react-native.config.cjs',
|
|
45
|
+
'react-native.config.ts',
|
|
46
|
+
'react-native.config.mjs',
|
|
47
|
+
]),
|
|
48
|
+
});
|
|
49
|
+
exports.ProjectPathCandidates = ProjectPathCandidates;
|
|
50
|
+
const ResourcePaths = Object.freeze({
|
|
51
|
+
strings: Object.freeze({
|
|
52
|
+
app: 'AppScope/resources/base/element/string.json',
|
|
53
|
+
entry: 'entry/src/main/resources/base/element/string.json',
|
|
54
|
+
}),
|
|
55
|
+
colors: Object.freeze({
|
|
56
|
+
entry: 'entry/src/main/resources/base/element/color.json',
|
|
57
|
+
entryDark: 'entry/src/main/resources/dark/element/color.json',
|
|
58
|
+
}),
|
|
59
|
+
media: Object.freeze({
|
|
60
|
+
app: 'AppScope/resources/base/media',
|
|
61
|
+
entry: 'entry/src/main/resources/base/media',
|
|
62
|
+
entryDark: 'entry/src/main/resources/dark/media',
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
exports.ResourcePaths = ResourcePaths;
|
|
66
|
+
function isInside(root, target) {
|
|
67
|
+
const relative = node_path_1.default.relative(root, target);
|
|
68
|
+
return relative === ''
|
|
69
|
+
|| (!relative.startsWith(`..${node_path_1.default.sep}`) && relative !== '..' && !node_path_1.default.isAbsolute(relative));
|
|
70
|
+
}
|
|
71
|
+
async function assertNoExternalSymlink(root, target) {
|
|
72
|
+
const absoluteRoot = node_path_1.default.resolve(root);
|
|
73
|
+
const realRoot = await node_fs_1.default.promises.realpath(absoluteRoot).catch(() => absoluteRoot);
|
|
74
|
+
const relative = node_path_1.default.relative(absoluteRoot, target);
|
|
75
|
+
let cursor = absoluteRoot;
|
|
76
|
+
for (const segment of relative.split(node_path_1.default.sep).filter(Boolean)) {
|
|
77
|
+
cursor = node_path_1.default.join(cursor, segment);
|
|
78
|
+
let stat;
|
|
79
|
+
try {
|
|
80
|
+
stat = await node_fs_1.default.promises.lstat(cursor);
|
|
81
|
+
}
|
|
82
|
+
catch (cause) {
|
|
83
|
+
if (cause.code === 'ENOENT')
|
|
84
|
+
break;
|
|
85
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_PATH_INVALID', `Cannot inspect managed Harmony path ${cursor}: ${cause.message}`, { cause, file: cursor, operation: 'resolve-path' });
|
|
86
|
+
}
|
|
87
|
+
if (stat.isSymbolicLink()) {
|
|
88
|
+
const real = await node_fs_1.default.promises.realpath(cursor);
|
|
89
|
+
if (!isInside(realRoot, real)) {
|
|
90
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_PATH_ESCAPE', `Refusing to follow a symlink outside the Harmony project: ${cursor}`, { file: cursor, operation: 'resolve-path' });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function resolveHarmonyPath(platformProjectRoot, relativePath) {
|
|
96
|
+
if (typeof relativePath !== 'string' || !relativePath || node_path_1.default.isAbsolute(relativePath)) {
|
|
97
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_PATH_ESCAPE', `Invalid managed path: ${relativePath}`, { operation: 'resolve-path' });
|
|
98
|
+
}
|
|
99
|
+
const root = node_path_1.default.resolve(platformProjectRoot);
|
|
100
|
+
const target = node_path_1.default.resolve(root, relativePath);
|
|
101
|
+
if (!isInside(root, target)) {
|
|
102
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_PATH_ESCAPE', `Managed path escapes the Harmony project: ${relativePath}`, { file: target, operation: 'resolve-path' });
|
|
103
|
+
}
|
|
104
|
+
await assertNoExternalSymlink(root, target);
|
|
105
|
+
return target;
|
|
106
|
+
}
|
|
107
|
+
async function resolveProjectPath(projectRoot, modName) {
|
|
108
|
+
const candidates = ProjectPathCandidates[modName] || [ProjectPaths[modName]];
|
|
109
|
+
const resolved = await Promise.all(candidates.map(candidate => resolveHarmonyPath(projectRoot, candidate)));
|
|
110
|
+
const existing = resolved.filter(file => node_fs_1.default.existsSync(file));
|
|
111
|
+
if (existing.length > 1) {
|
|
112
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_CONFIG_INVALID', `Multiple files provide harmony.${modName}: ${existing.map(file => node_path_1.default.basename(file)).join(', ')}`, { file: existing[0], operation: `harmony.${modName}.read` });
|
|
113
|
+
}
|
|
114
|
+
return existing[0] || resolved[0];
|
|
115
|
+
}
|
|
116
|
+
function toPosixRelative(projectRoot, target) {
|
|
117
|
+
return node_path_1.default.relative(projectRoot, target).split(node_path_1.default.sep).join('/');
|
|
118
|
+
}
|
|
119
|
+
exports.HarmonyPaths = {
|
|
120
|
+
HARMONY_PATHS: ManagedPaths,
|
|
121
|
+
PROJECT_PATH_CANDIDATES: ProjectPathCandidates,
|
|
122
|
+
PROJECT_PATHS: ProjectPaths,
|
|
123
|
+
RESOURCE_PATHS: ResourcePaths,
|
|
124
|
+
assertNoExternalSymlink,
|
|
125
|
+
isInside,
|
|
126
|
+
resolveHarmonyPath,
|
|
127
|
+
resolveProjectPath,
|
|
128
|
+
toPosixRelative,
|
|
129
|
+
};
|