@expo-harmony/expo-modules-autolinking 55.0.25-harmony.1

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.
Files changed (103) hide show
  1. package/README.md +12 -0
  2. package/bin/expo-harmony-autolinking.ts +14 -0
  3. package/build/bin/expo-harmony-autolinking.d.ts +2 -0
  4. package/build/bin/expo-harmony-autolinking.js +11 -0
  5. package/build/index.d.ts +8 -0
  6. package/build/index.js +15 -0
  7. package/build/src/autolinking/link.d.ts +3 -0
  8. package/build/src/autolinking/link.js +150 -0
  9. package/build/src/autolinking/resolve.d.ts +4 -0
  10. package/build/src/autolinking/resolve.js +25 -0
  11. package/build/src/autolinking/search.d.ts +3 -0
  12. package/build/src/autolinking/search.js +357 -0
  13. package/build/src/autolinking/verify.d.ts +4 -0
  14. package/build/src/autolinking/verify.js +366 -0
  15. package/build/src/commands/autolinkingOptions.d.ts +12 -0
  16. package/build/src/commands/autolinkingOptions.js +35 -0
  17. package/build/src/commands/cli.d.ts +2 -0
  18. package/build/src/commands/cli.js +50 -0
  19. package/build/src/commands/link.d.ts +2 -0
  20. package/build/src/commands/link.js +27 -0
  21. package/build/src/commands/output.d.ts +3 -0
  22. package/build/src/commands/output.js +33 -0
  23. package/build/src/commands/resolve.d.ts +2 -0
  24. package/build/src/commands/resolve.js +13 -0
  25. package/build/src/commands/search.d.ts +2 -0
  26. package/build/src/commands/search.js +13 -0
  27. package/build/src/commands/verify.d.ts +2 -0
  28. package/build/src/commands/verify.js +17 -0
  29. package/build/src/config/constants.d.ts +17 -0
  30. package/build/src/config/constants.js +40 -0
  31. package/build/src/config/options.d.ts +13 -0
  32. package/build/src/config/options.js +202 -0
  33. package/build/src/errors.d.ts +18 -0
  34. package/build/src/errors.js +35 -0
  35. package/build/src/harmony/manifest/generate.d.ts +4 -0
  36. package/build/src/harmony/manifest/generate.js +55 -0
  37. package/build/src/harmony/manifest/index.d.ts +7 -0
  38. package/build/src/harmony/manifest/index.js +64 -0
  39. package/build/src/harmony/materialize.d.ts +12 -0
  40. package/build/src/harmony/materialize.js +278 -0
  41. package/build/src/harmony/ohpm/dependencies.d.ts +7 -0
  42. package/build/src/harmony/ohpm/dependencies.js +52 -0
  43. package/build/src/harmony/persistence/canonicalize.d.ts +15 -0
  44. package/build/src/harmony/persistence/canonicalize.js +108 -0
  45. package/build/src/harmony/providers/host.d.ts +3 -0
  46. package/build/src/harmony/providers/host.js +88 -0
  47. package/build/src/harmony/rnoh/cli.d.ts +2 -0
  48. package/build/src/harmony/rnoh/cli.js +55 -0
  49. package/build/src/harmony/rnoh/link.d.ts +2 -0
  50. package/build/src/harmony/rnoh/link.js +419 -0
  51. package/build/src/harmony/rnoh/packageMetadata.d.ts +12 -0
  52. package/build/src/harmony/rnoh/packageMetadata.js +125 -0
  53. package/build/src/harmony/transaction/previousState.d.ts +15 -0
  54. package/build/src/harmony/transaction/previousState.js +96 -0
  55. package/build/src/harmony/transaction/publish.d.ts +6 -0
  56. package/build/src/harmony/transaction/publish.js +272 -0
  57. package/build/src/harmony/transaction/stageProject.d.ts +18 -0
  58. package/build/src/harmony/transaction/stageProject.js +313 -0
  59. package/build/src/metadata/descriptor.d.ts +19 -0
  60. package/build/src/metadata/descriptor.js +306 -0
  61. package/build/src/metadata/host.d.ts +5 -0
  62. package/build/src/metadata/host.js +37 -0
  63. package/build/src/metadata/schema.d.ts +10 -0
  64. package/build/src/metadata/schema.js +171 -0
  65. package/build/src/types.d.ts +194 -0
  66. package/build/src/types.js +2 -0
  67. package/build/src/utilities/values.d.ts +17 -0
  68. package/build/src/utilities/values.js +205 -0
  69. package/harmony-module.schema.json +28 -0
  70. package/index.ts +41 -0
  71. package/package.json +66 -0
  72. package/src/autolinking/link.ts +170 -0
  73. package/src/autolinking/resolve.ts +33 -0
  74. package/src/autolinking/search.ts +369 -0
  75. package/src/autolinking/verify.ts +415 -0
  76. package/src/commands/autolinkingOptions.ts +38 -0
  77. package/src/commands/cli.ts +56 -0
  78. package/src/commands/link.ts +28 -0
  79. package/src/commands/output.ts +36 -0
  80. package/src/commands/resolve.ts +14 -0
  81. package/src/commands/search.ts +14 -0
  82. package/src/commands/verify.ts +17 -0
  83. package/src/config/constants.ts +45 -0
  84. package/src/config/options.ts +195 -0
  85. package/src/errors.ts +48 -0
  86. package/src/harmony/manifest/generate.ts +65 -0
  87. package/src/harmony/manifest/index.ts +81 -0
  88. package/src/harmony/materialize.ts +382 -0
  89. package/src/harmony/ohpm/dependencies.ts +59 -0
  90. package/src/harmony/persistence/canonicalize.ts +156 -0
  91. package/src/harmony/providers/host.ts +147 -0
  92. package/src/harmony/rnoh/cli.ts +59 -0
  93. package/src/harmony/rnoh/link.ts +481 -0
  94. package/src/harmony/rnoh/packageMetadata.ts +105 -0
  95. package/src/harmony/transaction/previousState.ts +71 -0
  96. package/src/harmony/transaction/publish.ts +287 -0
  97. package/src/harmony/transaction/stageProject.ts +345 -0
  98. package/src/metadata/descriptor.ts +324 -0
  99. package/src/metadata/host.ts +41 -0
  100. package/src/metadata/schema.ts +184 -0
  101. package/src/types.ts +220 -0
  102. package/src/utilities/values.ts +190 -0
  103. package/tsconfig.json +24 -0
@@ -0,0 +1,13 @@
1
+ declare function assertSafeRnohPackageList(values: any, field: any, stage?: string): void;
2
+ declare function normalizeModuleOverrides(value: any, options?: Record<string, any>): Readonly<{}>;
3
+ declare function normalizeOptionsAsync(rawOptions?: Record<string, any>): Promise<{
4
+ projectRoot: string;
5
+ platform: string;
6
+ searchPaths: string[];
7
+ nativeModulesDir: string;
8
+ exclude: string[];
9
+ include: string[];
10
+ moduleOverrides: Readonly<{}>;
11
+ buildType: any;
12
+ }>;
13
+ export { assertSafeRnohPackageList, normalizeOptionsAsync, normalizeModuleOverrides, };
@@ -0,0 +1,202 @@
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
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.assertSafeRnohPackageList = assertSafeRnohPackageList;
37
+ exports.normalizeOptionsAsync = normalizeOptionsAsync;
38
+ exports.normalizeModuleOverrides = normalizeModuleOverrides;
39
+ const fs = __importStar(require("node:fs"));
40
+ const path = __importStar(require("node:path"));
41
+ const constants_1 = require("./constants");
42
+ const errors_1 = require("../errors");
43
+ const values_1 = require("../utilities/values");
44
+ const ListFields = ['searchPaths', 'exclude', 'include'];
45
+ const NpmPackageNamePattern = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u;
46
+ const RnohPackageListDelimiterPattern = /[;\0\r\n]/;
47
+ function selectConfiguredValue(rawOptions, platform, sharedConfig, field, fallback) {
48
+ if (rawOptions[field] !== undefined)
49
+ return rawOptions[field];
50
+ if (platform[field] !== undefined)
51
+ return platform[field];
52
+ if (sharedConfig[field] !== undefined)
53
+ return sharedConfig[field];
54
+ return fallback;
55
+ }
56
+ function configuredList(platform, sharedConfig, field) {
57
+ const normalize = (value) => {
58
+ if (value === undefined)
59
+ return [];
60
+ const values = field === 'searchPaths' && typeof value === 'string'
61
+ ? [value]
62
+ : Array.isArray(value) ? value : [];
63
+ return values.filter(item => typeof item === 'string' && item.trim());
64
+ };
65
+ if (field === 'include') {
66
+ return [
67
+ ...normalize(sharedConfig.include),
68
+ ...normalize(platform.include),
69
+ ];
70
+ }
71
+ return normalize(platform[field] !== undefined ? platform[field] : sharedConfig[field]);
72
+ }
73
+ function validateConfigObject(value, field) {
74
+ if (value === undefined)
75
+ return {};
76
+ if (!(0, values_1.isObject)(value)) {
77
+ throw new errors_1.HarmonyAutolinkingError('INVALID_OPTIONS', `${field} must be an object.`, { stage: 'options' });
78
+ }
79
+ return value;
80
+ }
81
+ function normalizeBuildType(value) {
82
+ const buildType = value === undefined ? 'debug' : value;
83
+ if (buildType !== 'debug' && buildType !== 'release') {
84
+ throw new errors_1.HarmonyAutolinkingError('INVALID_OPTIONS', 'buildType must be either "debug" or "release".', { stage: 'options' });
85
+ }
86
+ return buildType;
87
+ }
88
+ function assertSafeRnohPackageList(values, field, stage = 'options') {
89
+ if (!Array.isArray(values)
90
+ || values.some(value => typeof value !== 'string'
91
+ || !value.trim()
92
+ || RnohPackageListDelimiterPattern.test(value))) {
93
+ throw new errors_1.HarmonyAutolinkingError('INVALID_OPTIONS', `${field} entries must not contain semicolons or NUL/CR/LF control characters.`, { stage });
94
+ }
95
+ }
96
+ function normalizeNativeModulesDirectory(value, projectRoot) {
97
+ if (value === null)
98
+ return null;
99
+ if (typeof value !== 'string' || !value.trim()) {
100
+ throw new errors_1.HarmonyAutolinkingError('INVALID_OPTIONS', 'nativeModulesDir must be a non-empty string or null.', { stage: 'options' });
101
+ }
102
+ return path.resolve(projectRoot, value);
103
+ }
104
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
+ function normalizeModuleOverrides(value, options = {}) {
106
+ const code = options.code || 'INVALID_OPTIONS';
107
+ const field = options.field || 'package.json#expo.autolinking.harmony.modules';
108
+ const stage = options.stage || 'options';
109
+ if (value === undefined)
110
+ return Object.freeze({});
111
+ if (!(0, values_1.isObject)(value)) {
112
+ throw new errors_1.HarmonyAutolinkingError(code, `${field} must be an object.`, { stage });
113
+ }
114
+ const overrides = {};
115
+ for (const packageName of Object.keys(value).sort()) {
116
+ const metadata = value[packageName];
117
+ if (!NpmPackageNamePattern.test(packageName) || !(0, values_1.isObject)(metadata)) {
118
+ throw new errors_1.HarmonyAutolinkingError(code, `Invalid Harmony sidecar module registration for ${packageName} in ${field}.`, { stage });
119
+ }
120
+ if (metadata.version !== undefined
121
+ && (typeof metadata.version !== 'string'
122
+ || !metadata.version
123
+ || /^[*~^]|^(?:file|link|workspace):/u.test(metadata.version))) {
124
+ throw new errors_1.HarmonyAutolinkingError(code, `Harmony sidecar module ${packageName} in ${field} must use an exact version.`, { stage });
125
+ }
126
+ overrides[packageName] = Object.freeze({ ...metadata });
127
+ }
128
+ return Object.freeze(overrides);
129
+ }
130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
+ async function normalizeOptionsAsync(rawOptions = {}) {
132
+ if (!(0, values_1.isObject)(rawOptions)) {
133
+ throw new errors_1.HarmonyAutolinkingError('INVALID_OPTIONS', 'Options must be an object.', { stage: 'options' });
134
+ }
135
+ if (rawOptions.logger !== undefined) {
136
+ if (!(0, values_1.isObject)(rawOptions.logger)
137
+ || ['debug', 'info', 'warn', 'error'].some((level) => {
138
+ return rawOptions.logger[level] !== undefined && typeof rawOptions.logger[level] !== 'function';
139
+ })) {
140
+ throw new errors_1.HarmonyAutolinkingError('INVALID_OPTIONS', 'logger must expose only callable debug/info/warn/error methods.', { stage: 'options' });
141
+ }
142
+ }
143
+ if (rawOptions.platform != null && rawOptions.platform !== constants_1.Platform) {
144
+ throw new errors_1.HarmonyAutolinkingError('INVALID_OPTIONS', 'Only platform "harmony" is supported.', { stage: 'options' });
145
+ }
146
+ const rawRoot = rawOptions.projectRoot === undefined ? process.cwd() : rawOptions.projectRoot;
147
+ if (typeof rawRoot !== 'string' || !rawRoot) {
148
+ throw new errors_1.HarmonyAutolinkingError('INVALID_OPTIONS', 'projectRoot must be a non-empty string.', { stage: 'options' });
149
+ }
150
+ let projectRoot = await (0, values_1.realpathExistingAsync)(rawRoot, {
151
+ type: 'directory',
152
+ field: 'projectRoot',
153
+ stage: 'options',
154
+ });
155
+ let pkgPath = path.join(projectRoot, 'package.json');
156
+ while (!fs.existsSync(pkgPath) && path.dirname(projectRoot) !== projectRoot) {
157
+ projectRoot = path.dirname(projectRoot);
158
+ pkgPath = path.join(projectRoot, 'package.json');
159
+ }
160
+ if (!fs.existsSync(pkgPath)) {
161
+ throw new errors_1.HarmonyAutolinkingError('INVALID_OPTIONS', `No package.json exists at projectRoot: ${projectRoot}`, { stage: 'options' });
162
+ }
163
+ const packageJson = await (0, values_1.readJsonAsync)(pkgPath, 'INVALID_OPTIONS', 'options');
164
+ const expo = packageJson.expo === undefined ? {} : validateConfigObject(packageJson.expo, 'package.json#expo');
165
+ const shared = expo.autolinking === undefined ? {} : validateConfigObject(expo.autolinking, 'package.json#expo.autolinking');
166
+ const platform = shared.harmony === undefined ? {} : validateConfigObject(shared.harmony, 'package.json#expo.autolinking.harmony');
167
+ const configured = Object.fromEntries(ListFields.map(field => [field, configuredList(platform, shared, field)]));
168
+ const lists = {
169
+ searchPaths: rawOptions.searchPaths === undefined
170
+ ? configured.searchPaths
171
+ : [...(0, values_1.normalizeStringArray)(rawOptions.searchPaths, 'searchPaths'), ...configured.searchPaths],
172
+ exclude: rawOptions.exclude === undefined
173
+ ? configured.exclude
174
+ : [...configured.exclude, ...(0, values_1.normalizeStringArray)(rawOptions.exclude, 'exclude')],
175
+ include: rawOptions.include === undefined
176
+ ? configured.include
177
+ : [...configured.include, ...(0, values_1.normalizeStringArray)(rawOptions.include, 'include')],
178
+ };
179
+ assertSafeRnohPackageList(lists.include, 'include');
180
+ assertSafeRnohPackageList(lists.exclude, 'exclude');
181
+ const paths = [];
182
+ for (const value of lists.searchPaths) {
183
+ const target = path.resolve(projectRoot, value);
184
+ paths.push(fs.existsSync(target) ? await fs.promises.realpath(target) : target);
185
+ }
186
+ const searchPaths = (0, values_1.uniqueStrings)(paths);
187
+ const rawDir = selectConfiguredValue(rawOptions, platform, shared, 'nativeModulesDir', './modules');
188
+ let nativeDir = normalizeNativeModulesDirectory(rawDir, projectRoot);
189
+ if (nativeDir && fs.existsSync(nativeDir)) {
190
+ nativeDir = await fs.promises.realpath(nativeDir);
191
+ }
192
+ return {
193
+ projectRoot,
194
+ platform: constants_1.Platform,
195
+ searchPaths,
196
+ nativeModulesDir: nativeDir,
197
+ exclude: (0, values_1.uniqueStrings)(lists.exclude),
198
+ include: (0, values_1.uniqueStrings)(lists.include),
199
+ moduleOverrides: normalizeModuleOverrides(platform.modules),
200
+ buildType: normalizeBuildType(selectConfiguredValue(rawOptions, platform, shared, 'buildType', 'debug')),
201
+ };
202
+ }
@@ -0,0 +1,18 @@
1
+ import type { AutolinkingErrorJson, Diagnostic } from './types';
2
+ interface HarmonyAutolinkingErrorDetails {
3
+ cause?: unknown;
4
+ stage?: string;
5
+ packageName?: string;
6
+ diagnostics?: ReadonlyArray<Diagnostic>;
7
+ details?: unknown;
8
+ }
9
+ declare class HarmonyAutolinkingError extends Error {
10
+ readonly code: string;
11
+ readonly stage: string;
12
+ readonly packageName?: string;
13
+ readonly diagnostics?: ReadonlyArray<Diagnostic>;
14
+ readonly details?: unknown;
15
+ constructor(code: string, message: string, details?: HarmonyAutolinkingErrorDetails);
16
+ toJSON(): AutolinkingErrorJson;
17
+ }
18
+ export { HarmonyAutolinkingError };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HarmonyAutolinkingError = void 0;
4
+ const ErrorPrefix = 'ERR_EXPO_HARMONY_';
5
+ class HarmonyAutolinkingError extends Error {
6
+ code;
7
+ stage;
8
+ packageName;
9
+ diagnostics;
10
+ details;
11
+ constructor(code, message, details = {}) {
12
+ const value = code.startsWith(ErrorPrefix) ? code : `${ErrorPrefix}${code}`;
13
+ super(message, details.cause ? { cause: details.cause } : undefined);
14
+ this.name = 'HarmonyAutolinkingError';
15
+ this.code = value;
16
+ this.stage = details.stage || 'unknown';
17
+ this.packageName = details.packageName;
18
+ this.diagnostics = details.diagnostics;
19
+ this.details = details.details;
20
+ Error.captureStackTrace?.(this, HarmonyAutolinkingError);
21
+ }
22
+ toJSON() {
23
+ const value = {
24
+ name: 'HarmonyAutolinkingError',
25
+ code: this.code,
26
+ message: this.message,
27
+ stage: this.stage,
28
+ ...(this.packageName ? { packageName: this.packageName } : {}),
29
+ ...(this.diagnostics ? { diagnostics: this.diagnostics } : {}),
30
+ ...(this.details ? { details: this.details } : {}),
31
+ };
32
+ return value;
33
+ }
34
+ }
35
+ exports.HarmonyAutolinkingError = HarmonyAutolinkingError;
@@ -0,0 +1,4 @@
1
+ import type { Manifest } from '../../types';
2
+ declare function createManifest(modules: any, options?: Record<string, any>): Manifest;
3
+ declare function serializeManifest(modules: any, options?: Record<string, any>): string;
4
+ export { createManifest, serializeManifest, };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createManifest = createManifest;
4
+ exports.serializeManifest = serializeManifest;
5
+ const constants_1 = require("../../config/constants");
6
+ const values_1 = require("../../utilities/values");
7
+ function cloneOhPackageName(value) {
8
+ if (Array.isArray(value))
9
+ return value.map(mapping => ({ ...mapping }));
10
+ return value;
11
+ }
12
+ function createManifestEntry(descriptor) {
13
+ return {
14
+ packageName: descriptor.packageName,
15
+ packageVersion: descriptor.packageVersion,
16
+ packageRoot: descriptor.packageRoot,
17
+ packageLinkPath: descriptor.packageLinkPath,
18
+ source: descriptor.source,
19
+ harmony: {
20
+ modules: [...descriptor.harmony.modules],
21
+ },
22
+ ...(descriptor.arkTs ? { arkTs: { ...descriptor.arkTs } } : {}),
23
+ expo: {
24
+ rootViewComponents: [...descriptor.expo.rootViewComponents],
25
+ },
26
+ rnoh: {
27
+ ...(descriptor.rnoh.ohPackageName !== undefined
28
+ ? { ohPackageName: cloneOhPackageName(descriptor.rnoh.ohPackageName) }
29
+ : {}),
30
+ ...(descriptor.rnoh.mainHarPath ? { mainHarPath: descriptor.rnoh.mainHarPath } : {}),
31
+ harPaths: [...descriptor.rnoh.harPaths],
32
+ ...(descriptor.rnoh.etsPackageClassName ? { etsPackageClassName: descriptor.rnoh.etsPackageClassName } : {}),
33
+ ...(descriptor.rnoh.etsPackageImport ? { etsPackageImport: descriptor.rnoh.etsPackageImport } : {}),
34
+ ...(descriptor.rnoh.cppPackageClassName ? { cppPackageClassName: descriptor.rnoh.cppPackageClassName } : {}),
35
+ ...(descriptor.rnoh.cmakeLibraryTargetName
36
+ ? { cmakeLibraryTargetName: descriptor.rnoh.cmakeLibraryTargetName }
37
+ : {}),
38
+ },
39
+ };
40
+ }
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
+ function createManifest(modules, options = {}) {
43
+ const buildType = options.buildType || 'debug';
44
+ return {
45
+ schemaVersion: constants_1.ManifestSchemaVersion,
46
+ platform: constants_1.Platform,
47
+ buildType,
48
+ modules: modules.map(descriptor => createManifestEntry(descriptor)),
49
+ managedArtifacts: [...(options.managedArtifacts || constants_1.ManagedArtifacts)],
50
+ };
51
+ }
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ function serializeManifest(modules, options = {}) {
54
+ return (0, values_1.stringifyJson)(createManifest(modules, options));
55
+ }
@@ -0,0 +1,7 @@
1
+ import type { Manifest } from '../../types';
2
+ declare function validateManifest(manifest: unknown, options?: Record<string, any>): Manifest;
3
+ declare function ohpmDependenciesFromManifest(manifest: Manifest, options?: {
4
+ harmonyProjectPath?: string;
5
+ nodeModulesPath?: string;
6
+ }): Readonly<Record<string, string>>;
7
+ export { ohpmDependenciesFromManifest, validateManifest, };
@@ -0,0 +1,64 @@
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.ohpmDependenciesFromManifest = ohpmDependenciesFromManifest;
7
+ exports.validateManifest = validateManifest;
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const constants_1 = require("../../config/constants");
10
+ const errors_1 = require("../../errors");
11
+ const dependencies_1 = require("../ohpm/dependencies");
12
+ const schema_1 = require("../../metadata/schema");
13
+ const values_1 = require("../../utilities/values");
14
+ const ModuleSources = new Set(['dependency', 'searchPath', 'nativeModulesDir', 'reactNativeProjectConfig']);
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ function validateManifest(manifest, options = {}) {
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ const candidate = (0, values_1.isObject)(manifest) ? manifest : null;
19
+ if (!candidate
20
+ || candidate.schemaVersion !== constants_1.ManifestSchemaVersion
21
+ || candidate.platform !== constants_1.Platform
22
+ || !['debug', 'release'].includes(candidate.buildType)
23
+ || !Array.isArray(candidate.modules)
24
+ || !Array.isArray(candidate.managedArtifacts)) {
25
+ throw new errors_1.HarmonyAutolinkingError('INVALID_MANIFEST', `Harmony autolinking manifest must use schema ${constants_1.ManifestSchemaVersion}.`, {
26
+ details: options.file ? { file: options.file } : undefined,
27
+ stage: 'manifest',
28
+ });
29
+ }
30
+ for (const [index, entry] of candidate.modules.entries()) {
31
+ if (!(0, values_1.isObject)(entry)
32
+ || typeof entry.packageName !== 'string'
33
+ || !entry.packageName
34
+ || typeof entry.packageVersion !== 'string'
35
+ || !entry.packageVersion
36
+ || typeof entry.packageRoot !== 'string'
37
+ || !node_path_1.default.isAbsolute(entry.packageRoot)
38
+ || typeof entry.packageLinkPath !== 'string'
39
+ || !node_path_1.default.isAbsolute(entry.packageLinkPath)
40
+ || !ModuleSources.has(entry.source)
41
+ || (entry.harmony !== undefined && (!(0, values_1.isObject)(entry.harmony)
42
+ || !Array.isArray(entry.harmony.modules)
43
+ || entry.harmony.modules.some(moduleClass => typeof moduleClass !== 'string' || !moduleClass)))
44
+ || (entry.arkTs !== undefined && (!(0, values_1.isObject)(entry.arkTs)
45
+ || entry.arkTs.harPath !== 'harmony/library.har'
46
+ || !(0, schema_1.isValidOhpmPackageName)(entry.arkTs.ohPackageName)))
47
+ || (entry.harmony?.modules.length > 0 && !(0, values_1.isObject)(entry.arkTs))
48
+ || !(0, values_1.isObject)(entry.expo)
49
+ || !Array.isArray(entry.expo.rootViewComponents)
50
+ || !(0, values_1.isObject)(entry.rnoh)
51
+ || !Array.isArray(entry.rnoh.harPaths)) {
52
+ throw new errors_1.HarmonyAutolinkingError('INVALID_MANIFEST', `Harmony autolinking manifest module ${index} is invalid.`, { details: options.file ? { file: options.file } : undefined, stage: 'manifest' });
53
+ }
54
+ }
55
+ return structuredClone(candidate);
56
+ }
57
+ function ohpmDependenciesFromManifest(manifest, options = {}) {
58
+ const validated = validateManifest(manifest);
59
+ return Object.fromEntries((0, dependencies_1.collectOhpmDeps)(validated.modules)
60
+ .map(({ descriptor, mapping }) => [
61
+ mapping.ohPackageName,
62
+ (0, dependencies_1.resolveOhpmSpecifier)(descriptor, mapping, options),
63
+ ]));
64
+ }
@@ -0,0 +1,12 @@
1
+ import type { ArkTsModulePackage, BuildType, MaterializedLocalSource, MaterializeLocalSourceOptions, ModuleArtifactDescriptor, ModuleSource, RnohMetadata } from '../types';
2
+ interface MaterializeModuleArtifactOptions {
3
+ readonly packageName: string;
4
+ readonly packageRoot: string;
5
+ readonly source: ModuleSource;
6
+ readonly buildType: BuildType;
7
+ readonly arkTs?: ArkTsModulePackage;
8
+ readonly rnoh: RnohMetadata;
9
+ }
10
+ declare function materializeModuleArtifactAsync(options: MaterializeModuleArtifactOptions): Promise<ModuleArtifactDescriptor>;
11
+ declare function materializeLocalSourcesAsync(modules: ReadonlyArray<MaterializeLocalSourceOptions['module']>, options: Omit<MaterializeLocalSourceOptions, 'module'>): Promise<ReadonlyArray<MaterializedLocalSource>>;
12
+ export { materializeLocalSourcesAsync, materializeModuleArtifactAsync, };