@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.
- package/README.md +12 -0
- package/bin/expo-harmony-autolinking.ts +14 -0
- package/build/bin/expo-harmony-autolinking.d.ts +2 -0
- package/build/bin/expo-harmony-autolinking.js +11 -0
- package/build/index.d.ts +8 -0
- package/build/index.js +15 -0
- package/build/src/autolinking/link.d.ts +3 -0
- package/build/src/autolinking/link.js +150 -0
- package/build/src/autolinking/resolve.d.ts +4 -0
- package/build/src/autolinking/resolve.js +25 -0
- package/build/src/autolinking/search.d.ts +3 -0
- package/build/src/autolinking/search.js +357 -0
- package/build/src/autolinking/verify.d.ts +4 -0
- package/build/src/autolinking/verify.js +366 -0
- package/build/src/commands/autolinkingOptions.d.ts +12 -0
- package/build/src/commands/autolinkingOptions.js +35 -0
- package/build/src/commands/cli.d.ts +2 -0
- package/build/src/commands/cli.js +50 -0
- package/build/src/commands/link.d.ts +2 -0
- package/build/src/commands/link.js +27 -0
- package/build/src/commands/output.d.ts +3 -0
- package/build/src/commands/output.js +33 -0
- package/build/src/commands/resolve.d.ts +2 -0
- package/build/src/commands/resolve.js +13 -0
- package/build/src/commands/search.d.ts +2 -0
- package/build/src/commands/search.js +13 -0
- package/build/src/commands/verify.d.ts +2 -0
- package/build/src/commands/verify.js +17 -0
- package/build/src/config/constants.d.ts +17 -0
- package/build/src/config/constants.js +40 -0
- package/build/src/config/options.d.ts +13 -0
- package/build/src/config/options.js +202 -0
- package/build/src/errors.d.ts +18 -0
- package/build/src/errors.js +35 -0
- package/build/src/harmony/manifest/generate.d.ts +4 -0
- package/build/src/harmony/manifest/generate.js +55 -0
- package/build/src/harmony/manifest/index.d.ts +7 -0
- package/build/src/harmony/manifest/index.js +64 -0
- package/build/src/harmony/materialize.d.ts +12 -0
- package/build/src/harmony/materialize.js +278 -0
- package/build/src/harmony/ohpm/dependencies.d.ts +7 -0
- package/build/src/harmony/ohpm/dependencies.js +52 -0
- package/build/src/harmony/persistence/canonicalize.d.ts +15 -0
- package/build/src/harmony/persistence/canonicalize.js +108 -0
- package/build/src/harmony/providers/host.d.ts +3 -0
- package/build/src/harmony/providers/host.js +88 -0
- package/build/src/harmony/rnoh/cli.d.ts +2 -0
- package/build/src/harmony/rnoh/cli.js +55 -0
- package/build/src/harmony/rnoh/link.d.ts +2 -0
- package/build/src/harmony/rnoh/link.js +419 -0
- package/build/src/harmony/rnoh/packageMetadata.d.ts +12 -0
- package/build/src/harmony/rnoh/packageMetadata.js +125 -0
- package/build/src/harmony/transaction/previousState.d.ts +15 -0
- package/build/src/harmony/transaction/previousState.js +96 -0
- package/build/src/harmony/transaction/publish.d.ts +6 -0
- package/build/src/harmony/transaction/publish.js +272 -0
- package/build/src/harmony/transaction/stageProject.d.ts +18 -0
- package/build/src/harmony/transaction/stageProject.js +313 -0
- package/build/src/metadata/descriptor.d.ts +19 -0
- package/build/src/metadata/descriptor.js +306 -0
- package/build/src/metadata/host.d.ts +5 -0
- package/build/src/metadata/host.js +37 -0
- package/build/src/metadata/schema.d.ts +10 -0
- package/build/src/metadata/schema.js +171 -0
- package/build/src/types.d.ts +194 -0
- package/build/src/types.js +2 -0
- package/build/src/utilities/values.d.ts +17 -0
- package/build/src/utilities/values.js +205 -0
- package/harmony-module.schema.json +28 -0
- package/index.ts +41 -0
- package/package.json +66 -0
- package/src/autolinking/link.ts +170 -0
- package/src/autolinking/resolve.ts +33 -0
- package/src/autolinking/search.ts +369 -0
- package/src/autolinking/verify.ts +415 -0
- package/src/commands/autolinkingOptions.ts +38 -0
- package/src/commands/cli.ts +56 -0
- package/src/commands/link.ts +28 -0
- package/src/commands/output.ts +36 -0
- package/src/commands/resolve.ts +14 -0
- package/src/commands/search.ts +14 -0
- package/src/commands/verify.ts +17 -0
- package/src/config/constants.ts +45 -0
- package/src/config/options.ts +195 -0
- package/src/errors.ts +48 -0
- package/src/harmony/manifest/generate.ts +65 -0
- package/src/harmony/manifest/index.ts +81 -0
- package/src/harmony/materialize.ts +382 -0
- package/src/harmony/ohpm/dependencies.ts +59 -0
- package/src/harmony/persistence/canonicalize.ts +156 -0
- package/src/harmony/providers/host.ts +147 -0
- package/src/harmony/rnoh/cli.ts +59 -0
- package/src/harmony/rnoh/link.ts +481 -0
- package/src/harmony/rnoh/packageMetadata.ts +105 -0
- package/src/harmony/transaction/previousState.ts +71 -0
- package/src/harmony/transaction/publish.ts +287 -0
- package/src/harmony/transaction/stageProject.ts +345 -0
- package/src/metadata/descriptor.ts +324 -0
- package/src/metadata/host.ts +41 -0
- package/src/metadata/schema.ts +184 -0
- package/src/types.ts +220 -0
- package/src/utilities/values.ts +190 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
export type Platform = 'harmony';
|
|
2
|
+
export type BuildType = 'debug' | 'release';
|
|
3
|
+
export type ModuleSource = 'dependency' | 'searchPath' | 'nativeModulesDir' | 'reactNativeProjectConfig';
|
|
4
|
+
export interface ArkTsModulePackage {
|
|
5
|
+
/** Conventional package-relative HAR exporting the ArkTS module classes. */
|
|
6
|
+
readonly harPath: string;
|
|
7
|
+
/** OHPM package name read from the Harmony library manifest. */
|
|
8
|
+
readonly ohPackageName: string;
|
|
9
|
+
}
|
|
10
|
+
export interface HostMetadata {
|
|
11
|
+
readonly rootViewComponents: ReadonlyArray<string>;
|
|
12
|
+
}
|
|
13
|
+
export type ExpoMetadata = HostMetadata;
|
|
14
|
+
export interface RnohMetadata {
|
|
15
|
+
readonly ohPackageName?: string | ReadonlyArray<{
|
|
16
|
+
readonly harName: string;
|
|
17
|
+
readonly packageName: string;
|
|
18
|
+
readonly version?: string;
|
|
19
|
+
}>;
|
|
20
|
+
readonly mainHarPath?: string;
|
|
21
|
+
readonly harPaths: ReadonlyArray<string>;
|
|
22
|
+
readonly etsPackageClassName?: string;
|
|
23
|
+
readonly etsPackageImport?: 'default' | 'named';
|
|
24
|
+
readonly cppPackageClassName?: string;
|
|
25
|
+
readonly cmakeLibraryTargetName?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface HarmonyModuleMetadata extends HostMetadata {
|
|
28
|
+
/** ArkTS Module classes exported by the conventional Harmony library. */
|
|
29
|
+
readonly modules: ReadonlyArray<string>;
|
|
30
|
+
}
|
|
31
|
+
export interface FixedHvigorBuildDescriptor {
|
|
32
|
+
readonly executable: 'hvigorw';
|
|
33
|
+
readonly cwd: string;
|
|
34
|
+
readonly args: ReadonlyArray<string>;
|
|
35
|
+
}
|
|
36
|
+
export type ModuleArtifactDescriptor = {
|
|
37
|
+
readonly kind: 'bundled';
|
|
38
|
+
readonly harPaths: ReadonlyArray<string>;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: 'local-source';
|
|
41
|
+
readonly outputPath: string;
|
|
42
|
+
readonly materialized: false;
|
|
43
|
+
readonly build: FixedHvigorBuildDescriptor;
|
|
44
|
+
};
|
|
45
|
+
export interface ModuleDescriptor {
|
|
46
|
+
readonly packageName: string;
|
|
47
|
+
readonly packageVersion: string;
|
|
48
|
+
readonly packageRoot: string;
|
|
49
|
+
/** Reachable package path used to install the bundled HAR during a native build. */
|
|
50
|
+
readonly packageLinkPath: string;
|
|
51
|
+
readonly source: ModuleSource;
|
|
52
|
+
/** Host extension declarations consumed by the generated application provider. */
|
|
53
|
+
readonly expo: ExpoMetadata;
|
|
54
|
+
/** RNOH package metadata read from package.json#harmony.autolinking. */
|
|
55
|
+
readonly rnoh: RnohMetadata;
|
|
56
|
+
/** Expo module author metadata from expo-module.config.json#harmony. */
|
|
57
|
+
readonly harmony: HarmonyModuleMetadata;
|
|
58
|
+
/** Build/package data derived from the conventional Harmony project, never author config. */
|
|
59
|
+
readonly arkTs?: ArkTsModulePackage;
|
|
60
|
+
readonly artifact: ModuleArtifactDescriptor;
|
|
61
|
+
}
|
|
62
|
+
export interface SearchRecord {
|
|
63
|
+
readonly packageName: string;
|
|
64
|
+
readonly packageVersion: string;
|
|
65
|
+
readonly packageRoot: string;
|
|
66
|
+
readonly source: ModuleSource;
|
|
67
|
+
readonly supportsHarmony: boolean;
|
|
68
|
+
readonly expoModuleConfig: Readonly<Record<string, unknown>> | null;
|
|
69
|
+
readonly rnohMetadata: unknown;
|
|
70
|
+
readonly revision: {
|
|
71
|
+
readonly depth: number | null;
|
|
72
|
+
readonly originPath: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface SearchResult {
|
|
76
|
+
readonly platform: Platform;
|
|
77
|
+
readonly modules: ReadonlyArray<SearchRecord>;
|
|
78
|
+
readonly duplicates: ReadonlyArray<{
|
|
79
|
+
readonly packageName: string;
|
|
80
|
+
readonly revisions: ReadonlyArray<{
|
|
81
|
+
readonly version: string;
|
|
82
|
+
readonly path: string;
|
|
83
|
+
}>;
|
|
84
|
+
}>;
|
|
85
|
+
readonly missingIncludes: ReadonlyArray<string>;
|
|
86
|
+
readonly options: {
|
|
87
|
+
readonly projectRoot: string;
|
|
88
|
+
readonly searchPaths: ReadonlyArray<string>;
|
|
89
|
+
readonly nativeModulesDir: string | null;
|
|
90
|
+
readonly exclude: ReadonlyArray<string>;
|
|
91
|
+
readonly include: ReadonlyArray<string>;
|
|
92
|
+
readonly buildType: BuildType;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export interface DiagnosticSource {
|
|
96
|
+
readonly packageName: string;
|
|
97
|
+
readonly packageVersion: string;
|
|
98
|
+
readonly packageRoot: string;
|
|
99
|
+
readonly field?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface Diagnostic {
|
|
102
|
+
readonly severity: 'error' | 'warning';
|
|
103
|
+
readonly code: string;
|
|
104
|
+
readonly message: string;
|
|
105
|
+
readonly packageName?: string;
|
|
106
|
+
readonly stage: string;
|
|
107
|
+
readonly sources?: ReadonlyArray<DiagnosticSource>;
|
|
108
|
+
}
|
|
109
|
+
export interface VerificationResult {
|
|
110
|
+
readonly valid: boolean;
|
|
111
|
+
readonly diagnostics: ReadonlyArray<Diagnostic>;
|
|
112
|
+
readonly modules: ReadonlyArray<ModuleDescriptor>;
|
|
113
|
+
}
|
|
114
|
+
export interface Manifest {
|
|
115
|
+
readonly schemaVersion: 3;
|
|
116
|
+
readonly platform: 'harmony';
|
|
117
|
+
readonly buildType: BuildType;
|
|
118
|
+
readonly modules: ReadonlyArray<ModuleDescriptor>;
|
|
119
|
+
readonly managedArtifacts: ReadonlyArray<string>;
|
|
120
|
+
}
|
|
121
|
+
export interface CanonicalizeAutolinkingArtifactsOptions {
|
|
122
|
+
readonly manifestSource: string;
|
|
123
|
+
readonly ohPackageSource: string;
|
|
124
|
+
readonly generatedProjectRoot: string;
|
|
125
|
+
readonly canonicalProjectRoot: string;
|
|
126
|
+
readonly harmonyProjectPath?: string;
|
|
127
|
+
}
|
|
128
|
+
export interface CanonicalizedAutolinkingArtifacts {
|
|
129
|
+
readonly manifest: Manifest;
|
|
130
|
+
readonly manifestSource: string;
|
|
131
|
+
readonly ohPackageSource: string;
|
|
132
|
+
}
|
|
133
|
+
export interface Logger {
|
|
134
|
+
debug?(message: string, details?: unknown): void;
|
|
135
|
+
info?(message: string, details?: unknown): void;
|
|
136
|
+
warn?(message: string, details?: unknown): void;
|
|
137
|
+
error?(message: string, details?: unknown): void;
|
|
138
|
+
}
|
|
139
|
+
export interface SearchOptions {
|
|
140
|
+
projectRoot?: string;
|
|
141
|
+
platform?: Platform;
|
|
142
|
+
searchPaths?: ReadonlyArray<string>;
|
|
143
|
+
nativeModulesDir?: string | null;
|
|
144
|
+
exclude?: ReadonlyArray<string>;
|
|
145
|
+
include?: ReadonlyArray<string>;
|
|
146
|
+
buildType?: BuildType;
|
|
147
|
+
logger?: Logger;
|
|
148
|
+
}
|
|
149
|
+
export interface ResolveOptions extends SearchOptions {
|
|
150
|
+
searchResult?: SearchResult;
|
|
151
|
+
}
|
|
152
|
+
export interface VerifyOptions extends ResolveOptions {
|
|
153
|
+
modules?: ReadonlyArray<ModuleDescriptor>;
|
|
154
|
+
}
|
|
155
|
+
export interface LinkOptions extends VerifyOptions {
|
|
156
|
+
projectRoot: string;
|
|
157
|
+
harmonyProjectPath: string;
|
|
158
|
+
nodeModulesPath?: string;
|
|
159
|
+
reactNativeExecutable?: string;
|
|
160
|
+
rnohCliPackageJsonPath?: string;
|
|
161
|
+
timeoutMs?: number;
|
|
162
|
+
outputLimit?: number;
|
|
163
|
+
env?: NodeJS.ProcessEnv;
|
|
164
|
+
}
|
|
165
|
+
export interface MaterializeLocalSourceOptions {
|
|
166
|
+
readonly projectRoot: string;
|
|
167
|
+
readonly module: ModuleDescriptor;
|
|
168
|
+
readonly timeoutMs?: number;
|
|
169
|
+
readonly outputLimit?: number;
|
|
170
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
171
|
+
}
|
|
172
|
+
export interface MaterializedLocalSource {
|
|
173
|
+
readonly packageName: string;
|
|
174
|
+
readonly harPath: string;
|
|
175
|
+
}
|
|
176
|
+
export interface LinkResult {
|
|
177
|
+
readonly platform: Platform;
|
|
178
|
+
readonly modules: ReadonlyArray<ModuleDescriptor>;
|
|
179
|
+
readonly buildType: BuildType;
|
|
180
|
+
readonly managedArtifacts: ReadonlyArray<string>;
|
|
181
|
+
readonly changedArtifacts: ReadonlyArray<string>;
|
|
182
|
+
readonly unchangedArtifacts: ReadonlyArray<string>;
|
|
183
|
+
readonly diagnostics: ReadonlyArray<Diagnostic>;
|
|
184
|
+
readonly warnings: ReadonlyArray<Diagnostic>;
|
|
185
|
+
}
|
|
186
|
+
export interface AutolinkingErrorJson {
|
|
187
|
+
readonly name: 'HarmonyAutolinkingError';
|
|
188
|
+
readonly code: string;
|
|
189
|
+
readonly message: string;
|
|
190
|
+
readonly stage: string;
|
|
191
|
+
readonly packageName?: string;
|
|
192
|
+
readonly diagnostics?: ReadonlyArray<Diagnostic>;
|
|
193
|
+
readonly details?: unknown;
|
|
194
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare function isObject(value: any): boolean;
|
|
2
|
+
declare function compareText(left: any, right: any): 1 | -1 | 0;
|
|
3
|
+
declare function sortedUniqueStrings(items: ReadonlyArray<string>): string[];
|
|
4
|
+
declare function uniqueStrings(items: ReadonlyArray<string>): string[];
|
|
5
|
+
declare function stringifyJson(value: any): string;
|
|
6
|
+
declare function normalizeSlashes(value: any): any;
|
|
7
|
+
declare function readJsonAsync(file: any, code?: string, stage?: string): Promise<any>;
|
|
8
|
+
declare function pathExistsAsync(target: any): Promise<boolean>;
|
|
9
|
+
declare function resolvePackageFromProject(projectRoot: any, specifier: any): string;
|
|
10
|
+
declare function isPathInside(parent: any, child: any): boolean;
|
|
11
|
+
declare function realpathExistingAsync(target: any, options?: Record<string, any>): Promise<string>;
|
|
12
|
+
declare function resolveInsideAsync(root: any, relative: any, field: any, options?: Record<string, any>): Promise<any>;
|
|
13
|
+
declare function requireNonEmptyString(value: any, field: any, options?: Record<string, any>): string;
|
|
14
|
+
declare function normalizeStringArray(value: any, field: any, options?: Record<string, any>): any[];
|
|
15
|
+
declare function sanitizeOutput(value: any, roots?: any[], limit?: number): string;
|
|
16
|
+
declare function emitLog(logger: any, level: any, message: any, details: any): void;
|
|
17
|
+
export { compareText, emitLog, isObject, isPathInside, normalizeSlashes, pathExistsAsync, resolvePackageFromProject, readJsonAsync, realpathExistingAsync, requireNonEmptyString, resolveInsideAsync, sanitizeOutput, stringifyJson, sortedUniqueStrings, normalizeStringArray, uniqueStrings, };
|
|
@@ -0,0 +1,205 @@
|
|
|
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.compareText = compareText;
|
|
37
|
+
exports.emitLog = emitLog;
|
|
38
|
+
exports.isObject = isObject;
|
|
39
|
+
exports.isPathInside = isPathInside;
|
|
40
|
+
exports.normalizeSlashes = normalizeSlashes;
|
|
41
|
+
exports.pathExistsAsync = pathExistsAsync;
|
|
42
|
+
exports.resolvePackageFromProject = resolvePackageFromProject;
|
|
43
|
+
exports.readJsonAsync = readJsonAsync;
|
|
44
|
+
exports.realpathExistingAsync = realpathExistingAsync;
|
|
45
|
+
exports.requireNonEmptyString = requireNonEmptyString;
|
|
46
|
+
exports.resolveInsideAsync = resolveInsideAsync;
|
|
47
|
+
exports.sanitizeOutput = sanitizeOutput;
|
|
48
|
+
exports.stringifyJson = stringifyJson;
|
|
49
|
+
exports.sortedUniqueStrings = sortedUniqueStrings;
|
|
50
|
+
exports.normalizeStringArray = normalizeStringArray;
|
|
51
|
+
exports.uniqueStrings = uniqueStrings;
|
|
52
|
+
const node_module_1 = require("node:module");
|
|
53
|
+
const fs = __importStar(require("node:fs"));
|
|
54
|
+
const path = __importStar(require("node:path"));
|
|
55
|
+
const errors_1 = require("../errors");
|
|
56
|
+
function isObject(value) {
|
|
57
|
+
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
58
|
+
}
|
|
59
|
+
function compareText(left, right) {
|
|
60
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
61
|
+
}
|
|
62
|
+
function sortedUniqueStrings(items) {
|
|
63
|
+
return [...new Set(items)].sort(compareText);
|
|
64
|
+
}
|
|
65
|
+
function uniqueStrings(items) {
|
|
66
|
+
return [...new Set(items)];
|
|
67
|
+
}
|
|
68
|
+
function stringifyJson(value) {
|
|
69
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
70
|
+
}
|
|
71
|
+
function normalizeSlashes(value) {
|
|
72
|
+
return value.split(path.sep).join('/');
|
|
73
|
+
}
|
|
74
|
+
async function readJsonAsync(file, code = 'INVALID_METADATA', stage = 'metadata') {
|
|
75
|
+
try {
|
|
76
|
+
return JSON.parse(await fs.promises.readFile(file, 'utf8'));
|
|
77
|
+
}
|
|
78
|
+
catch (cause) {
|
|
79
|
+
throw new errors_1.HarmonyAutolinkingError(code, `Unable to read valid JSON from ${file}.`, { cause, stage });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function pathExistsAsync(target) {
|
|
83
|
+
try {
|
|
84
|
+
await fs.promises.access(target);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
catch (_cause) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function resolvePackageFromProject(projectRoot, specifier) {
|
|
92
|
+
return (0, node_module_1.createRequire)(path.join(projectRoot, 'package.json')).resolve(specifier);
|
|
93
|
+
}
|
|
94
|
+
function isPathInside(parent, child) {
|
|
95
|
+
const relative = path.relative(parent, child);
|
|
96
|
+
return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));
|
|
97
|
+
}
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
async function realpathExistingAsync(target, options = {}) {
|
|
100
|
+
const type = options.type || 'path';
|
|
101
|
+
const code = options.code || 'INVALID_OPTIONS';
|
|
102
|
+
const stage = options.stage || 'validation';
|
|
103
|
+
const field = options.field || 'path';
|
|
104
|
+
try {
|
|
105
|
+
const resolved = await fs.promises.realpath(path.resolve(target));
|
|
106
|
+
const stat = await fs.promises.stat(resolved);
|
|
107
|
+
if (type === 'directory' && !stat.isDirectory())
|
|
108
|
+
throw new TypeError('not a directory');
|
|
109
|
+
if (type === 'file' && !stat.isFile())
|
|
110
|
+
throw new TypeError('not a file');
|
|
111
|
+
return resolved;
|
|
112
|
+
}
|
|
113
|
+
catch (cause) {
|
|
114
|
+
throw new errors_1.HarmonyAutolinkingError(code, `${field} does not reference an existing ${type}: ${target}`, {
|
|
115
|
+
cause,
|
|
116
|
+
stage,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
|
+
async function resolveInsideAsync(root, relative, field, options = {}) {
|
|
122
|
+
const mustExist = options.mustExist !== false;
|
|
123
|
+
const type = options.type || 'path';
|
|
124
|
+
const packageName = options.packageName;
|
|
125
|
+
if (typeof relative !== 'string' || !relative.trim() || path.isAbsolute(relative)) {
|
|
126
|
+
throw new errors_1.HarmonyAutolinkingError('INVALID_METADATA', `${field} must be a non-empty package-relative path.`, {
|
|
127
|
+
packageName,
|
|
128
|
+
stage: 'metadata',
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const realRoot = await fs.promises.realpath(root);
|
|
132
|
+
const lexical = path.resolve(realRoot, relative);
|
|
133
|
+
if (!isPathInside(realRoot, lexical)) {
|
|
134
|
+
throw new errors_1.HarmonyAutolinkingError('PATH_OUTSIDE_PACKAGE', `${field} escapes package root.`, {
|
|
135
|
+
packageName,
|
|
136
|
+
stage: 'metadata',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (!mustExist)
|
|
140
|
+
return lexical;
|
|
141
|
+
let resolved;
|
|
142
|
+
try {
|
|
143
|
+
resolved = await fs.promises.realpath(lexical);
|
|
144
|
+
}
|
|
145
|
+
catch (cause) {
|
|
146
|
+
throw new errors_1.HarmonyAutolinkingError('INVALID_METADATA', `${field} does not exist: ${relative}`, {
|
|
147
|
+
cause,
|
|
148
|
+
packageName,
|
|
149
|
+
stage: 'metadata',
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (!isPathInside(realRoot, resolved)) {
|
|
153
|
+
throw new errors_1.HarmonyAutolinkingError('PATH_OUTSIDE_PACKAGE', `${field} resolves outside package root.`, {
|
|
154
|
+
packageName,
|
|
155
|
+
stage: 'metadata',
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const stat = await fs.promises.stat(resolved);
|
|
159
|
+
if (type === 'file' && !stat.isFile()) {
|
|
160
|
+
throw new errors_1.HarmonyAutolinkingError('INVALID_METADATA', `${field} must reference a file: ${relative}`, {
|
|
161
|
+
packageName,
|
|
162
|
+
stage: 'metadata',
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (type === 'directory' && !stat.isDirectory()) {
|
|
166
|
+
throw new errors_1.HarmonyAutolinkingError('INVALID_METADATA', `${field} must reference a directory: ${relative}`, {
|
|
167
|
+
packageName,
|
|
168
|
+
stage: 'metadata',
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return resolved;
|
|
172
|
+
}
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
|
+
function requireNonEmptyString(value, field, options = {}) {
|
|
175
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
176
|
+
throw new errors_1.HarmonyAutolinkingError(options.code || 'INVALID_METADATA', `${field} must be a non-empty string.`, {
|
|
177
|
+
packageName: options.packageName,
|
|
178
|
+
stage: options.stage || 'metadata',
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
184
|
+
function normalizeStringArray(value, field, options = {}) {
|
|
185
|
+
if (value == null && options.optional)
|
|
186
|
+
return [];
|
|
187
|
+
const values = Array.isArray(value) ? value : options.allowScalar ? [value] : null;
|
|
188
|
+
if (!values || values.some(item => typeof item !== 'string' || !item.trim())) {
|
|
189
|
+
throw new errors_1.HarmonyAutolinkingError(options.code || 'INVALID_OPTIONS', `${field} must be an array of non-empty strings.`, {
|
|
190
|
+
packageName: options.packageName,
|
|
191
|
+
stage: options.stage || 'options',
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return [...new Set(values)];
|
|
195
|
+
}
|
|
196
|
+
function sanitizeOutput(value, roots = [], limit = 8192) {
|
|
197
|
+
let result = String(value || '');
|
|
198
|
+
for (const root of roots.filter(Boolean))
|
|
199
|
+
result = result.split(root).join('<path>');
|
|
200
|
+
return result.slice(0, limit);
|
|
201
|
+
}
|
|
202
|
+
function emitLog(logger, level, message, details) {
|
|
203
|
+
if (logger && typeof logger[level] === 'function')
|
|
204
|
+
logger[level](message, details);
|
|
205
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/renbaoshuo/expo-harmony/schemas/expo-module-harmony.json",
|
|
4
|
+
"title": "Expo Module Harmony metadata",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"modules": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": { "$ref": "#/$defs/arkTsIdentifier" },
|
|
10
|
+
"uniqueItems": true,
|
|
11
|
+
"default": [],
|
|
12
|
+
"description": "ArkTS Expo Module classes exported by the conventional Harmony library."
|
|
13
|
+
},
|
|
14
|
+
"rootViewComponents": { "$ref": "#/$defs/arkTsIdentifiers" }
|
|
15
|
+
},
|
|
16
|
+
"$defs": {
|
|
17
|
+
"arkTsIdentifier": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
|
|
20
|
+
},
|
|
21
|
+
"arkTsIdentifiers": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"items": { "$ref": "#/$defs/arkTsIdentifier" },
|
|
24
|
+
"uniqueItems": true,
|
|
25
|
+
"default": []
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { linkModulesAsync } from './src/autolinking/link';
|
|
2
|
+
import { canonicalizeAutolinkingArtifacts } from './src/harmony/persistence/canonicalize';
|
|
3
|
+
import { resolveModulesAsync } from './src/autolinking/resolve';
|
|
4
|
+
import { searchModulesAsync } from './src/autolinking/search';
|
|
5
|
+
import { verifyModulesAsync } from './src/autolinking/verify';
|
|
6
|
+
import { normalizeHarmonyModuleMetadata } from './src/metadata/schema';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
canonicalizeAutolinkingArtifacts,
|
|
10
|
+
linkModulesAsync,
|
|
11
|
+
normalizeHarmonyModuleMetadata,
|
|
12
|
+
resolveModulesAsync,
|
|
13
|
+
searchModulesAsync,
|
|
14
|
+
verifyModulesAsync,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
BuildType,
|
|
19
|
+
CanonicalizeAutolinkingArtifactsOptions,
|
|
20
|
+
CanonicalizedAutolinkingArtifacts,
|
|
21
|
+
Diagnostic,
|
|
22
|
+
DiagnosticSource,
|
|
23
|
+
ExpoMetadata,
|
|
24
|
+
HostMetadata,
|
|
25
|
+
HarmonyModuleMetadata,
|
|
26
|
+
LinkOptions,
|
|
27
|
+
LinkResult,
|
|
28
|
+
Logger,
|
|
29
|
+
Manifest,
|
|
30
|
+
ModuleDescriptor,
|
|
31
|
+
ModuleArtifactDescriptor,
|
|
32
|
+
ModuleSource,
|
|
33
|
+
Platform,
|
|
34
|
+
ResolveOptions,
|
|
35
|
+
RnohMetadata,
|
|
36
|
+
SearchOptions,
|
|
37
|
+
SearchRecord,
|
|
38
|
+
SearchResult,
|
|
39
|
+
VerificationResult,
|
|
40
|
+
VerifyOptions,
|
|
41
|
+
} from './src/types';
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@expo-harmony/expo-modules-autolinking",
|
|
3
|
+
"version": "55.0.25-harmony.1",
|
|
4
|
+
"description": "HarmonyOS port of expo-modules-autolinking",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-native",
|
|
7
|
+
"expo",
|
|
8
|
+
"expo-harmony",
|
|
9
|
+
"harmonyos"
|
|
10
|
+
],
|
|
11
|
+
"author": "Baoshuo <i@baoshuo.ren>",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/renbaoshuo/expo-harmony.git",
|
|
16
|
+
"directory": "packages/expo-modules-autolinking"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/renbaoshuo/expo-harmony/tree/master/packages/expo-modules-autolinking#readme",
|
|
19
|
+
"bugs": "https://github.com/renbaoshuo/expo-harmony/issues",
|
|
20
|
+
"main": "build/index.js",
|
|
21
|
+
"types": "build/index.d.ts",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rm -rf build && tsc -p tsconfig.json && chmod +x build/bin/expo-harmony-autolinking.js",
|
|
24
|
+
"prepare": "yarn build",
|
|
25
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./build/index.d.ts",
|
|
30
|
+
"require": "./build/index.js",
|
|
31
|
+
"default": "./build/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./harmony-module.schema.json": {
|
|
34
|
+
"default": "./harmony-module.schema.json"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"bin": {
|
|
38
|
+
"expo-harmony-autolinking": "build/bin/expo-harmony-autolinking.js"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"case": "1.6.3",
|
|
42
|
+
"commander": "7.2.0",
|
|
43
|
+
"expo-modules-autolinking": "55.0.25",
|
|
44
|
+
"json5": "2.2.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@react-native-oh/react-native-harmony-cli": "^0.84.1",
|
|
48
|
+
"@types/node": "18.19.0",
|
|
49
|
+
"metro": "0.83.3",
|
|
50
|
+
"typescript": "6.0.3"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@react-native-oh/react-native-harmony-cli": "^0.84.1"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"@react-native-oh/react-native-harmony-cli": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=20"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
}
|
|
66
|
+
}
|