@expo-harmony/config-plugins 55.0.10-harmony.1 → 55.0.10-harmony.3
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/README.md +203 -11
- package/build/compiler.d.ts +7 -0
- package/build/compiler.js +12 -0
- package/build/composition.d.ts +24 -0
- package/build/composition.js +11 -0
- package/build/config.d.ts +51 -0
- package/build/config.js +6 -0
- package/build/customFiles.d.ts +15 -0
- package/build/customFiles.js +108 -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/generatedFiles.d.ts +15 -0
- package/build/generatedFiles.js +70 -0
- package/build/index.d.ts +27 -0
- package/build/index.js +52 -6
- package/build/internal.d.ts +3 -0
- package/build/internal.js +13 -0
- package/build/manifest.d.ts +38 -0
- package/build/manifest.js +71 -0
- package/build/mods.d.ts +57 -0
- package/build/mods.js +428 -0
- package/build/nativeInputs.d.ts +14 -0
- package/build/nativeInputs.js +81 -0
- package/build/normalizeConfig.d.ts +35 -0
- package/build/normalizeConfig.js +270 -0
- package/build/ownership.d.ts +17 -0
- package/build/ownership.js +129 -0
- package/build/paths.d.ts +64 -0
- package/build/paths.js +129 -0
- package/build/permissions.d.ts +12 -0
- package/build/permissions.js +60 -0
- package/build/pluginTypes.d.ts +15 -0
- package/build/pluginTypes.js +2 -0
- package/build/resources.d.ts +13 -0
- package/build/resources.js +55 -0
- package/package.json +9 -9
- package/src/compiler.ts +21 -0
- package/src/composition.ts +45 -0
- package/src/config.ts +3 -19
- package/src/customFiles.ts +142 -0
- package/src/files.ts +3 -4
- package/src/generatedFiles.ts +85 -0
- package/src/index.ts +19 -11
- package/src/internal.ts +3 -0
- package/src/manifest.ts +151 -0
- package/src/mods.ts +170 -129
- package/src/nativeInputs.ts +0 -1
- package/src/normalizeConfig.ts +51 -59
- package/src/ownership.ts +25 -5
- package/src/paths.ts +38 -46
- package/src/permissions.ts +68 -0
- package/src/pluginTypes.ts +24 -0
- package/src/resources.ts +65 -0
|
@@ -0,0 +1,70 @@
|
|
|
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.withRawfile = exports.withHarmonyGeneratedFiles = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const errors_1 = require("./errors");
|
|
10
|
+
const files_1 = require("./files");
|
|
11
|
+
const mods_1 = require("./mods");
|
|
12
|
+
const ownership_1 = require("./ownership");
|
|
13
|
+
const paths_1 = require("./paths");
|
|
14
|
+
const withHarmonyGeneratedFiles = (config, options) => {
|
|
15
|
+
const { owner, files } = options;
|
|
16
|
+
if (!files || typeof files !== 'object' || Array.isArray(files)) {
|
|
17
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_CONFIG_INVALID', 'Generated files must be a path-to-descriptor map.');
|
|
18
|
+
}
|
|
19
|
+
const claims = (0, ownership_1.getHarmonyConfigPlugins)(config).find(plugin => plugin.owner === owner);
|
|
20
|
+
const paths = [...new Set([...(claims?.files ?? []), ...Object.keys(files)])];
|
|
21
|
+
config = (0, ownership_1.registerHarmonyConfigPlugin)(config, owner, { ...claims, files: paths });
|
|
22
|
+
return (0, mods_1.withHarmonyDangerousMod)(config, async (mod) => {
|
|
23
|
+
if (mod.modRequest.introspect)
|
|
24
|
+
return mod;
|
|
25
|
+
const writes = [];
|
|
26
|
+
for (const [relative, input] of Object.entries(files)) {
|
|
27
|
+
if (!input || typeof input !== 'object'
|
|
28
|
+
|| Object.hasOwn(input, 'source') === Object.hasOwn(input, 'content')) {
|
|
29
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_CONFIG_INVALID', `${relative} must define exactly one of source or content.`);
|
|
30
|
+
}
|
|
31
|
+
const file = await (0, paths_1.resolveHarmonyPath)(mod.modRequest.platformProjectRoot, relative);
|
|
32
|
+
let content;
|
|
33
|
+
if (Object.hasOwn(input, 'source')) {
|
|
34
|
+
if (typeof input.source !== 'string' || !input.source) {
|
|
35
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_CONFIG_INVALID', `${relative} source must be a non-empty path.`);
|
|
36
|
+
}
|
|
37
|
+
const source = node_path_1.default.resolve(mod.modRequest.projectRoot, input.source);
|
|
38
|
+
content = Uint8Array.from(await node_fs_1.default.promises.readFile(source));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (typeof input.content !== 'string' && !(input.content instanceof Uint8Array)) {
|
|
42
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_CONFIG_INVALID', `${relative} content must be a string or Uint8Array.`);
|
|
43
|
+
}
|
|
44
|
+
content = input.content;
|
|
45
|
+
}
|
|
46
|
+
writes.push({ file, content });
|
|
47
|
+
}
|
|
48
|
+
for (const { file, content } of writes) {
|
|
49
|
+
await (0, files_1.atomicWrite)(file, content);
|
|
50
|
+
(0, mods_1.recordManagedFile)(mod, file, owner);
|
|
51
|
+
}
|
|
52
|
+
return mod;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
exports.withHarmonyGeneratedFiles = withHarmonyGeneratedFiles;
|
|
56
|
+
const withRawfile = (config, { owner, files }) => {
|
|
57
|
+
if (!files || typeof files !== 'object' || Array.isArray(files)) {
|
|
58
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_CONFIG_INVALID', 'Rawfiles must be a path-to-descriptor map.');
|
|
59
|
+
}
|
|
60
|
+
const prefix = 'entry/src/main/resources/rawfile/';
|
|
61
|
+
const output = {};
|
|
62
|
+
for (const [relative, input] of Object.entries(files)) {
|
|
63
|
+
if (!relative || relative.includes('\\') || relative.split('/').some(part => !part || part === '.' || part === '..')) {
|
|
64
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_PATH_ESCAPE', `Invalid rawfile path: ${relative}`);
|
|
65
|
+
}
|
|
66
|
+
output[prefix + relative] = input;
|
|
67
|
+
}
|
|
68
|
+
return (0, exports.withHarmonyGeneratedFiles)(config, { owner, files: output });
|
|
69
|
+
};
|
|
70
|
+
exports.withRawfile = withRawfile;
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { defineExpoHarmonyConfig } from './config';
|
|
2
|
+
export { createRunOncePlugin, withPlugins, withRunOnce, withStaticPlugin } from './composition';
|
|
3
|
+
export type { HarmonyPluginReference, HarmonyStaticPlugin } from './composition';
|
|
4
|
+
export { compileHarmonyModsAsync } from './compiler';
|
|
5
|
+
export type { HarmonyCompileOptions } from './compiler';
|
|
6
|
+
export { createHarmonyFileMod, withHarmonyJsonFile } from './customFiles';
|
|
7
|
+
export type { HarmonyFileModOptions, HarmonyJsonFileOptions } from './customFiles';
|
|
8
|
+
export type { ExpoConfigWithHarmony, ExpoHarmonyPlatform, ExpoKnownPlatform, HarmonyConfig, HarmonyDeviceType, HarmonyOrientation, HarmonyPermission, HarmonyPlatform, HarmonySkill, HarmonySkillUri, } from './config';
|
|
9
|
+
export { HarmonyConfigPluginError } from './errors';
|
|
10
|
+
export type { HarmonyConfigPluginErrorOptions } from './errors';
|
|
11
|
+
export { atomicWrite, stableJson as stableHarmonyJson } from './files';
|
|
12
|
+
export { normalizeHarmonyConfig } from './normalizeConfig';
|
|
13
|
+
export type { HarmonyExpoConfig, NormalizedHarmonyConfig } from './normalizeConfig';
|
|
14
|
+
export { HarmonyModNames as HARMONY_MOD_NAMES, recordManagedFile, withAppJson, withArkTSPackageProvider, withCMakeLists, withColors, withCppPackageProvider, withEntryAbility, withEntryBuildProfile, withEntryHvigor, withEntryOhPackage, withHarmonyAutolinking, withHarmonyBaseMods, withHarmonyDangerousMod, withHarmonyMod, withHarmonyResources, withHvigorConfig, withIndexPage, withMedia, withModuleJson, withProfiles, withProjectBuildProfile, withReactNativeConfig, withRootHvigor, withRootOhPackage, withStrings, withWorker, } from './mods';
|
|
15
|
+
export type { HarmonyJson, HarmonyMediaDescriptor, HarmonyMediaMap, HarmonyModName, HarmonyResourceMap, } from './mods';
|
|
16
|
+
export { registerHarmonyConfigPlugin } from './ownership';
|
|
17
|
+
export type { HarmonyConfigPluginOwnership } from './ownership';
|
|
18
|
+
export { HarmonyPaths } from './paths';
|
|
19
|
+
export type { HarmonyManagedPaths, HarmonyPathsApi, HarmonyProjectPathCandidates, HarmonyProjectPaths, HarmonyResourcePaths, } from './paths';
|
|
20
|
+
export type { HarmonyConfigPlugin, HarmonyModAction, HarmonyModConfig } from './pluginTypes';
|
|
21
|
+
export * as HarmonyManifest from './manifest';
|
|
22
|
+
export * as HarmonyResources from './resources';
|
|
23
|
+
export type { HarmonyAbility, HarmonyExtensionAbility, HarmonyMetadata, HarmonyModule, HarmonyModuleJson } from './manifest';
|
|
24
|
+
export type { HarmonyResourceFile, HarmonyResourceItem } from './resources';
|
|
25
|
+
export { withHarmonyGeneratedFiles, withRawfile } from './generatedFiles';
|
|
26
|
+
export type { HarmonyFileDescriptor, HarmonyFileMap, HarmonyGeneratedFilesOptions } from './generatedFiles';
|
|
27
|
+
export { HarmonyPermissions, withHarmonyPermissions } from './permissions';
|
package/build/index.js
CHANGED
|
@@ -1,15 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
36
|
+
exports.withHarmonyPermissions = exports.HarmonyPermissions = exports.withRawfile = exports.withHarmonyGeneratedFiles = exports.HarmonyResources = exports.HarmonyManifest = exports.HarmonyPaths = exports.registerHarmonyConfigPlugin = exports.withWorker = exports.withStrings = exports.withRootOhPackage = exports.withRootHvigor = exports.withReactNativeConfig = exports.withProjectBuildProfile = exports.withProfiles = exports.withModuleJson = exports.withMedia = exports.withIndexPage = exports.withHvigorConfig = exports.withHarmonyResources = exports.withHarmonyMod = exports.withHarmonyDangerousMod = exports.withHarmonyBaseMods = exports.withHarmonyAutolinking = exports.withEntryOhPackage = exports.withEntryHvigor = exports.withEntryBuildProfile = exports.withEntryAbility = exports.withCppPackageProvider = exports.withColors = exports.withCMakeLists = exports.withArkTSPackageProvider = exports.withAppJson = exports.recordManagedFile = exports.HARMONY_MOD_NAMES = exports.normalizeHarmonyConfig = exports.stableHarmonyJson = exports.atomicWrite = exports.HarmonyConfigPluginError = exports.withHarmonyJsonFile = exports.createHarmonyFileMod = exports.compileHarmonyModsAsync = exports.withStaticPlugin = exports.withRunOnce = exports.withPlugins = exports.createRunOncePlugin = exports.defineExpoHarmonyConfig = void 0;
|
|
4
37
|
var config_1 = require("./config");
|
|
5
38
|
Object.defineProperty(exports, "defineExpoHarmonyConfig", { enumerable: true, get: function () { return config_1.defineExpoHarmonyConfig; } });
|
|
39
|
+
var composition_1 = require("./composition");
|
|
40
|
+
Object.defineProperty(exports, "createRunOncePlugin", { enumerable: true, get: function () { return composition_1.createRunOncePlugin; } });
|
|
41
|
+
Object.defineProperty(exports, "withPlugins", { enumerable: true, get: function () { return composition_1.withPlugins; } });
|
|
42
|
+
Object.defineProperty(exports, "withRunOnce", { enumerable: true, get: function () { return composition_1.withRunOnce; } });
|
|
43
|
+
Object.defineProperty(exports, "withStaticPlugin", { enumerable: true, get: function () { return composition_1.withStaticPlugin; } });
|
|
44
|
+
var compiler_1 = require("./compiler");
|
|
45
|
+
Object.defineProperty(exports, "compileHarmonyModsAsync", { enumerable: true, get: function () { return compiler_1.compileHarmonyModsAsync; } });
|
|
46
|
+
var customFiles_1 = require("./customFiles");
|
|
47
|
+
Object.defineProperty(exports, "createHarmonyFileMod", { enumerable: true, get: function () { return customFiles_1.createHarmonyFileMod; } });
|
|
48
|
+
Object.defineProperty(exports, "withHarmonyJsonFile", { enumerable: true, get: function () { return customFiles_1.withHarmonyJsonFile; } });
|
|
6
49
|
var errors_1 = require("./errors");
|
|
7
50
|
Object.defineProperty(exports, "HarmonyConfigPluginError", { enumerable: true, get: function () { return errors_1.HarmonyConfigPluginError; } });
|
|
8
51
|
var files_1 = require("./files");
|
|
9
52
|
Object.defineProperty(exports, "atomicWrite", { enumerable: true, get: function () { return files_1.atomicWrite; } });
|
|
10
53
|
Object.defineProperty(exports, "stableHarmonyJson", { enumerable: true, get: function () { return files_1.stableJson; } });
|
|
11
54
|
var normalizeConfig_1 = require("./normalizeConfig");
|
|
12
|
-
Object.defineProperty(exports, "HarmonySdkVersions", { enumerable: true, get: function () { return normalizeConfig_1.HarmonySdkVersions; } });
|
|
13
55
|
Object.defineProperty(exports, "normalizeHarmonyConfig", { enumerable: true, get: function () { return normalizeConfig_1.normalizeHarmonyConfig; } });
|
|
14
56
|
var mods_1 = require("./mods");
|
|
15
57
|
Object.defineProperty(exports, "HARMONY_MOD_NAMES", { enumerable: true, get: function () { return mods_1.HarmonyModNames; } });
|
|
@@ -17,7 +59,6 @@ Object.defineProperty(exports, "recordManagedFile", { enumerable: true, get: fun
|
|
|
17
59
|
Object.defineProperty(exports, "withAppJson", { enumerable: true, get: function () { return mods_1.withAppJson; } });
|
|
18
60
|
Object.defineProperty(exports, "withArkTSPackageProvider", { enumerable: true, get: function () { return mods_1.withArkTSPackageProvider; } });
|
|
19
61
|
Object.defineProperty(exports, "withCMakeLists", { enumerable: true, get: function () { return mods_1.withCMakeLists; } });
|
|
20
|
-
Object.defineProperty(exports, "withCngManifest", { enumerable: true, get: function () { return mods_1.withCngManifest; } });
|
|
21
62
|
Object.defineProperty(exports, "withColors", { enumerable: true, get: function () { return mods_1.withColors; } });
|
|
22
63
|
Object.defineProperty(exports, "withCppPackageProvider", { enumerable: true, get: function () { return mods_1.withCppPackageProvider; } });
|
|
23
64
|
Object.defineProperty(exports, "withEntryAbility", { enumerable: true, get: function () { return mods_1.withEntryAbility; } });
|
|
@@ -33,7 +74,6 @@ Object.defineProperty(exports, "withHvigorConfig", { enumerable: true, get: func
|
|
|
33
74
|
Object.defineProperty(exports, "withIndexPage", { enumerable: true, get: function () { return mods_1.withIndexPage; } });
|
|
34
75
|
Object.defineProperty(exports, "withMedia", { enumerable: true, get: function () { return mods_1.withMedia; } });
|
|
35
76
|
Object.defineProperty(exports, "withModuleJson", { enumerable: true, get: function () { return mods_1.withModuleJson; } });
|
|
36
|
-
Object.defineProperty(exports, "withNativeInputsStamp", { enumerable: true, get: function () { return mods_1.withNativeInputsStamp; } });
|
|
37
77
|
Object.defineProperty(exports, "withProfiles", { enumerable: true, get: function () { return mods_1.withProfiles; } });
|
|
38
78
|
Object.defineProperty(exports, "withProjectBuildProfile", { enumerable: true, get: function () { return mods_1.withProjectBuildProfile; } });
|
|
39
79
|
Object.defineProperty(exports, "withReactNativeConfig", { enumerable: true, get: function () { return mods_1.withReactNativeConfig; } });
|
|
@@ -42,8 +82,14 @@ Object.defineProperty(exports, "withRootOhPackage", { enumerable: true, get: fun
|
|
|
42
82
|
Object.defineProperty(exports, "withStrings", { enumerable: true, get: function () { return mods_1.withStrings; } });
|
|
43
83
|
Object.defineProperty(exports, "withWorker", { enumerable: true, get: function () { return mods_1.withWorker; } });
|
|
44
84
|
var ownership_1 = require("./ownership");
|
|
45
|
-
Object.defineProperty(exports, "getHarmonyConfigPlugins", { enumerable: true, get: function () { return ownership_1.getHarmonyConfigPlugins; } });
|
|
46
|
-
Object.defineProperty(exports, "normalizeHarmonyConfigPlugins", { enumerable: true, get: function () { return ownership_1.normalizeHarmonyConfigPlugins; } });
|
|
47
85
|
Object.defineProperty(exports, "registerHarmonyConfigPlugin", { enumerable: true, get: function () { return ownership_1.registerHarmonyConfigPlugin; } });
|
|
48
86
|
var paths_1 = require("./paths");
|
|
49
87
|
Object.defineProperty(exports, "HarmonyPaths", { enumerable: true, get: function () { return paths_1.HarmonyPaths; } });
|
|
88
|
+
exports.HarmonyManifest = __importStar(require("./manifest"));
|
|
89
|
+
exports.HarmonyResources = __importStar(require("./resources"));
|
|
90
|
+
var generatedFiles_1 = require("./generatedFiles");
|
|
91
|
+
Object.defineProperty(exports, "withHarmonyGeneratedFiles", { enumerable: true, get: function () { return generatedFiles_1.withHarmonyGeneratedFiles; } });
|
|
92
|
+
Object.defineProperty(exports, "withRawfile", { enumerable: true, get: function () { return generatedFiles_1.withRawfile; } });
|
|
93
|
+
var permissions_1 = require("./permissions");
|
|
94
|
+
Object.defineProperty(exports, "HarmonyPermissions", { enumerable: true, get: function () { return permissions_1.HarmonyPermissions; } });
|
|
95
|
+
Object.defineProperty(exports, "withHarmonyPermissions", { enumerable: true, get: function () { return permissions_1.withHarmonyPermissions; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NativeInputsStampPath = exports.withProjectPatch = exports.withPreparation = exports.withNativeInputsStamp = exports.withCngManifest = exports.normalizeHarmonyConfigPlugins = exports.getHarmonyConfigPlugins = void 0;
|
|
4
|
+
var ownership_1 = require("./ownership");
|
|
5
|
+
Object.defineProperty(exports, "getHarmonyConfigPlugins", { enumerable: true, get: function () { return ownership_1.getHarmonyConfigPlugins; } });
|
|
6
|
+
Object.defineProperty(exports, "normalizeHarmonyConfigPlugins", { enumerable: true, get: function () { return ownership_1.normalizeHarmonyConfigPlugins; } });
|
|
7
|
+
var mods_1 = require("./mods");
|
|
8
|
+
Object.defineProperty(exports, "withCngManifest", { enumerable: true, get: function () { return mods_1.withCngManifest; } });
|
|
9
|
+
Object.defineProperty(exports, "withNativeInputsStamp", { enumerable: true, get: function () { return mods_1.withNativeInputsStamp; } });
|
|
10
|
+
Object.defineProperty(exports, "withPreparation", { enumerable: true, get: function () { return mods_1.withPreparation; } });
|
|
11
|
+
Object.defineProperty(exports, "withProjectPatch", { enumerable: true, get: function () { return mods_1.withProjectPatch; } });
|
|
12
|
+
var paths_1 = require("./paths");
|
|
13
|
+
Object.defineProperty(exports, "NativeInputsStampPath", { enumerable: true, get: function () { return paths_1.NativeInputsStampPath; } });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { HarmonyPermission, HarmonySkill } from './config';
|
|
2
|
+
export interface HarmonyMetadata extends Record<string, unknown> {
|
|
3
|
+
name: string;
|
|
4
|
+
value?: string;
|
|
5
|
+
resource?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface HarmonyAbility extends Record<string, unknown> {
|
|
8
|
+
name: string;
|
|
9
|
+
srcEntry?: string;
|
|
10
|
+
exported?: boolean;
|
|
11
|
+
skills?: HarmonySkill[];
|
|
12
|
+
backgroundModes?: string[];
|
|
13
|
+
metadata?: HarmonyMetadata[];
|
|
14
|
+
}
|
|
15
|
+
export interface HarmonyExtensionAbility extends HarmonyAbility {
|
|
16
|
+
type: string;
|
|
17
|
+
}
|
|
18
|
+
export interface HarmonyModule extends Record<string, unknown> {
|
|
19
|
+
name?: string;
|
|
20
|
+
mainElement?: string;
|
|
21
|
+
abilities?: HarmonyAbility[];
|
|
22
|
+
extensionAbilities?: HarmonyExtensionAbility[];
|
|
23
|
+
metadata?: HarmonyMetadata[];
|
|
24
|
+
requestPermissions?: HarmonyPermission[];
|
|
25
|
+
querySchemes?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface HarmonyModuleJson extends Record<string, unknown> {
|
|
28
|
+
module?: HarmonyModule;
|
|
29
|
+
}
|
|
30
|
+
export declare function getModuleOrThrow(manifest: HarmonyModuleJson): HarmonyModule;
|
|
31
|
+
export declare function getMainAbilityOrThrow(manifest: HarmonyModuleJson, name?: string): HarmonyAbility;
|
|
32
|
+
export declare function setMetadata(target: {
|
|
33
|
+
metadata?: HarmonyMetadata[];
|
|
34
|
+
}, item: HarmonyMetadata): void;
|
|
35
|
+
export declare function removeMetadata(target: {
|
|
36
|
+
metadata?: HarmonyMetadata[];
|
|
37
|
+
}, name: string): void;
|
|
38
|
+
export declare function ensureExtensionAbility(manifest: HarmonyModuleJson, ability: HarmonyExtensionAbility): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModuleOrThrow = getModuleOrThrow;
|
|
4
|
+
exports.getMainAbilityOrThrow = getMainAbilityOrThrow;
|
|
5
|
+
exports.setMetadata = setMetadata;
|
|
6
|
+
exports.removeMetadata = removeMetadata;
|
|
7
|
+
exports.ensureExtensionAbility = ensureExtensionAbility;
|
|
8
|
+
const errors_1 = require("./errors");
|
|
9
|
+
const files_1 = require("./files");
|
|
10
|
+
function getModuleOrThrow(manifest) {
|
|
11
|
+
const module = manifest.module;
|
|
12
|
+
if (!module || typeof module !== 'object' || Array.isArray(module)) {
|
|
13
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', 'Harmony module.json5 must contain a module object.', { operation: 'edit-manifest' });
|
|
14
|
+
}
|
|
15
|
+
return module;
|
|
16
|
+
}
|
|
17
|
+
function getMainAbilityOrThrow(manifest, name) {
|
|
18
|
+
const module = getModuleOrThrow(manifest);
|
|
19
|
+
const abilities = module.abilities;
|
|
20
|
+
if (!Array.isArray(abilities)) {
|
|
21
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', 'Harmony module.json5 must declare an abilities array.', { operation: 'edit-manifest' });
|
|
22
|
+
}
|
|
23
|
+
const selected = name ?? module.mainElement ?? abilities[0]?.name;
|
|
24
|
+
const matches = abilities.filter(ability => ability && typeof ability.name === 'string' && ability.name === selected);
|
|
25
|
+
if (matches.length !== 1) {
|
|
26
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', `Expected exactly one Harmony Ability '${selected ?? ''}', found ${matches.length}.`, { operation: 'edit-manifest' });
|
|
27
|
+
}
|
|
28
|
+
return matches[0];
|
|
29
|
+
}
|
|
30
|
+
function setMetadata(target, item) {
|
|
31
|
+
if (!item || typeof item.name !== 'string' || !item.name.trim()) {
|
|
32
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', 'Metadata must have a non-empty name.', { operation: 'edit-manifest' });
|
|
33
|
+
}
|
|
34
|
+
if (target.metadata !== undefined && !Array.isArray(target.metadata)) {
|
|
35
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', 'metadata must be an array.', { operation: 'edit-manifest' });
|
|
36
|
+
}
|
|
37
|
+
const items = target.metadata ?? [];
|
|
38
|
+
const existing = items.find(value => value?.name === item.name);
|
|
39
|
+
target.metadata = [...items.filter(value => value?.name !== item.name), { ...existing, ...item }];
|
|
40
|
+
}
|
|
41
|
+
function removeMetadata(target, name) {
|
|
42
|
+
if (target.metadata !== undefined && !Array.isArray(target.metadata)) {
|
|
43
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', 'metadata must be an array.', { operation: 'edit-manifest' });
|
|
44
|
+
}
|
|
45
|
+
if (target.metadata)
|
|
46
|
+
target.metadata = target.metadata.filter(item => item?.name !== name);
|
|
47
|
+
}
|
|
48
|
+
function ensureExtensionAbility(manifest, ability) {
|
|
49
|
+
if (!ability || typeof ability.name !== 'string' || !ability.name.trim()
|
|
50
|
+
|| typeof ability.type !== 'string' || !ability.type.trim()) {
|
|
51
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', 'An extension Ability must have a non-empty name and type.', { operation: 'edit-manifest' });
|
|
52
|
+
}
|
|
53
|
+
const module = getModuleOrThrow(manifest);
|
|
54
|
+
if (module.extensionAbilities !== undefined && !Array.isArray(module.extensionAbilities)) {
|
|
55
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', 'module.extensionAbilities must be an array.', { operation: 'edit-manifest' });
|
|
56
|
+
}
|
|
57
|
+
const abilities = module.extensionAbilities ?? [];
|
|
58
|
+
const matches = abilities.filter(value => value?.name === ability.name);
|
|
59
|
+
if (matches.length > 1) {
|
|
60
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', `Harmony module declares ${ability.name} more than once.`, { operation: 'edit-manifest' });
|
|
61
|
+
}
|
|
62
|
+
if (matches.length === 1) {
|
|
63
|
+
for (const [key, value] of Object.entries(ability)) {
|
|
64
|
+
if ((0, files_1.stableJson)(matches[0][key]) !== (0, files_1.stableJson)(value)) {
|
|
65
|
+
throw new errors_1.HarmonyConfigPluginError('ERR_HARMONY_MANIFEST_INVALID', `Harmony extension Ability '${ability.name}' has an incompatible ${key}.`, { operation: 'edit-manifest' });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
module.extensionAbilities = [...abilities, structuredClone(ability)];
|
|
71
|
+
}
|
package/build/mods.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ExpoConfig } from '@expo/config-types';
|
|
2
|
+
import type { ExpoConfigWithHarmony } from './config';
|
|
3
|
+
import type { HarmonyModuleJson } from './manifest';
|
|
4
|
+
import type { HarmonyConfigPlugin, HarmonyModAction } from './pluginTypes';
|
|
5
|
+
import type { HarmonyResourceFile } from './resources';
|
|
6
|
+
export type HarmonyModName = 'dangerous' | 'reactNativeConfig' | 'appJson' | 'projectBuildProfile' | 'rootOhPackage' | 'rootHvigor' | 'hvigorConfig' | 'entryBuildProfile' | 'entryOhPackage' | 'entryHvigor' | 'moduleJson' | 'strings' | 'colors' | 'media' | 'profiles' | 'entryAbility' | 'indexPage' | 'worker' | 'arktsPackageProvider' | 'cppPackageProvider' | 'cmakeLists' | 'autolinking';
|
|
7
|
+
export type HarmonyJson = Record<string, unknown>;
|
|
8
|
+
export type HarmonyResourceMap = Record<string, HarmonyResourceFile>;
|
|
9
|
+
export type HarmonyMediaDescriptor = {
|
|
10
|
+
source: string;
|
|
11
|
+
content?: never;
|
|
12
|
+
replaceBase?: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
source?: never;
|
|
15
|
+
content: string | Uint8Array;
|
|
16
|
+
replaceBase?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type HarmonyMediaMap = Record<string, Record<string, HarmonyMediaDescriptor>>;
|
|
19
|
+
interface ManagedConfig {
|
|
20
|
+
_internal?: ExpoConfig['_internal'];
|
|
21
|
+
modRequest: {
|
|
22
|
+
projectRoot: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare const HarmonyModNames: readonly HarmonyModName[];
|
|
26
|
+
export declare function recordManagedFile(config: ManagedConfig, file: string, owner: string): void;
|
|
27
|
+
export declare function withHarmonyBaseMods<Config extends ExpoConfigWithHarmony>(config: Config): Config;
|
|
28
|
+
export declare function withHarmonyMod<T = unknown, Config extends ExpoConfigWithHarmony = ExpoConfigWithHarmony>(config: Config, tuple: [HarmonyModName, HarmonyModAction<T>]): Config;
|
|
29
|
+
export declare function registerMod<T, Config extends ExpoConfigWithHarmony>(config: Config, name: string, action: HarmonyModAction<T>): Config;
|
|
30
|
+
export declare const withReactNativeConfig: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
31
|
+
export declare const withAppJson: HarmonyConfigPlugin<HarmonyModAction<HarmonyJson>>;
|
|
32
|
+
export declare const withProjectBuildProfile: HarmonyConfigPlugin<HarmonyModAction<HarmonyJson>>;
|
|
33
|
+
export declare const withRootOhPackage: HarmonyConfigPlugin<HarmonyModAction<HarmonyJson>>;
|
|
34
|
+
export declare const withRootHvigor: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
35
|
+
export declare const withNativeInputsStamp: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
36
|
+
export declare const withHvigorConfig: HarmonyConfigPlugin<HarmonyModAction<HarmonyJson>>;
|
|
37
|
+
export declare const withEntryBuildProfile: HarmonyConfigPlugin<HarmonyModAction<HarmonyJson>>;
|
|
38
|
+
export declare const withEntryOhPackage: HarmonyConfigPlugin<HarmonyModAction<HarmonyJson>>;
|
|
39
|
+
export declare const withEntryHvigor: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
40
|
+
export declare const withModuleJson: HarmonyConfigPlugin<HarmonyModAction<HarmonyModuleJson>>;
|
|
41
|
+
export declare const withStrings: HarmonyConfigPlugin<HarmonyModAction<HarmonyResourceMap>>;
|
|
42
|
+
export declare const withColors: HarmonyConfigPlugin<HarmonyModAction<HarmonyResourceMap>>;
|
|
43
|
+
export declare const withMedia: HarmonyConfigPlugin<HarmonyModAction<HarmonyMediaMap>>;
|
|
44
|
+
export declare const withProfiles: HarmonyConfigPlugin<HarmonyModAction<HarmonyJson>>;
|
|
45
|
+
export declare const withEntryAbility: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
46
|
+
export declare const withIndexPage: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
47
|
+
export declare const withWorker: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
48
|
+
export declare const withArkTSPackageProvider: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
49
|
+
export declare const withCppPackageProvider: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
50
|
+
export declare const withCMakeLists: HarmonyConfigPlugin<HarmonyModAction<string>>;
|
|
51
|
+
export declare const withHarmonyAutolinking: HarmonyConfigPlugin<HarmonyModAction<null>>;
|
|
52
|
+
export declare const withCngManifest: HarmonyConfigPlugin<HarmonyModAction<null>>;
|
|
53
|
+
export declare const withPreparation: HarmonyConfigPlugin<HarmonyModAction<null>>;
|
|
54
|
+
export declare const withProjectPatch: HarmonyConfigPlugin<HarmonyModAction<null>>;
|
|
55
|
+
export declare const withHarmonyDangerousMod: HarmonyConfigPlugin<HarmonyModAction<null>>;
|
|
56
|
+
export declare const withHarmonyResources: HarmonyConfigPlugin<HarmonyModAction<unknown>>;
|
|
57
|
+
export {};
|