@react-native-harness/config 1.4.1 → 1.6.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,YAAY,CAAC;AAsElD,eAAO,MAAM,SAAS,GACpB,KAAK,MAAM,KACV,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAOjD,CAAC"}
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgB,MAAM,YAAY,CAAC;AA2ElD,eAAO,MAAM,SAAS,GACpB,KAAK,MAAM,KACV,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAOjD,CAAC"}
package/dist/reader.js CHANGED
@@ -2,6 +2,7 @@ import { ConfigSchema } from './types.js';
2
2
  import { ConfigValidationError, ConfigNotFoundError, ConfigLoadError, } from './errors.js';
3
3
  import path from 'node:path';
4
4
  import fs from 'node:fs';
5
+ import { pathToFileURL } from 'node:url';
5
6
  import { createRequire } from 'node:module';
6
7
  import { ZodError } from 'zod';
7
8
  const extensions = ['.js', '.mjs', '.cjs', '.json'];
@@ -13,7 +14,11 @@ const importUp = async (dir, name) => {
13
14
  let rawConfig;
14
15
  try {
15
16
  if (ext === '.mjs') {
16
- rawConfig = await import(filePathWithExt).then((module) => module.default);
17
+ // A dynamic import() of an absolute path only accepts a file:// URL.
18
+ // On POSIX the bare path happens to work; on Windows it is read as a
19
+ // URL and `C:` is rejected as an unknown scheme
20
+ // (ERR_UNSUPPORTED_ESM_URL_SCHEME). pathToFileURL normalizes both.
21
+ rawConfig = await import(pathToFileURL(filePathWithExt).href).then((module) => module.default);
17
22
  }
18
23
  else {
19
24
  const require = createRequire(import.meta.url);
package/dist/types.d.ts CHANGED
@@ -10,19 +10,28 @@ export declare const ConfigSchema: z.ZodEffects<z.ZodObject<{
10
10
  config: z.ZodRecord<z.ZodString, z.ZodAny>;
11
11
  runner: z.ZodString;
12
12
  cli: z.ZodOptional<z.ZodString>;
13
+ metroConfigEnhancer: z.ZodOptional<z.ZodString>;
14
+ bundlePlatform: z.ZodOptional<z.ZodString>;
13
15
  platformId: z.ZodString;
16
+ getResourceLockKey: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodPromise<z.ZodString>]>>>;
14
17
  }, "strip", z.ZodTypeAny, {
15
- config: Record<string, any>;
16
18
  name: string;
19
+ config: Record<string, any>;
17
20
  runner: string;
18
21
  platformId: string;
19
22
  cli?: string | undefined;
23
+ metroConfigEnhancer?: string | undefined;
24
+ bundlePlatform?: string | undefined;
25
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
20
26
  }, {
21
- config: Record<string, any>;
22
27
  name: string;
28
+ config: Record<string, any>;
23
29
  runner: string;
24
30
  platformId: string;
25
31
  cli?: string | undefined;
32
+ metroConfigEnhancer?: string | undefined;
33
+ bundlePlatform?: string | undefined;
34
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
26
35
  }>, "many">;
27
36
  plugins: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<AnyHarnessPlugin, z.ZodTypeDef, AnyHarnessPlugin>, "many">>>;
28
37
  defaultRunner: z.ZodOptional<z.ZodString>;
@@ -94,11 +103,14 @@ export declare const ConfigSchema: z.ZodEffects<z.ZodObject<{
94
103
  entryPoint: string;
95
104
  appRegistryComponentName: string;
96
105
  runners: {
97
- config: Record<string, any>;
98
106
  name: string;
107
+ config: Record<string, any>;
99
108
  runner: string;
100
109
  platformId: string;
101
110
  cli?: string | undefined;
111
+ metroConfigEnhancer?: string | undefined;
112
+ bundlePlatform?: string | undefined;
113
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
102
114
  }[];
103
115
  plugins: AnyHarnessPlugin[];
104
116
  metroPort: number;
@@ -138,11 +150,14 @@ export declare const ConfigSchema: z.ZodEffects<z.ZodObject<{
138
150
  entryPoint: string;
139
151
  appRegistryComponentName: string;
140
152
  runners: {
141
- config: Record<string, any>;
142
153
  name: string;
154
+ config: Record<string, any>;
143
155
  runner: string;
144
156
  platformId: string;
145
157
  cli?: string | undefined;
158
+ metroConfigEnhancer?: string | undefined;
159
+ bundlePlatform?: string | undefined;
160
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
146
161
  }[];
147
162
  plugins?: AnyHarnessPlugin[] | undefined;
148
163
  defaultRunner?: string | undefined;
@@ -182,11 +197,14 @@ export declare const ConfigSchema: z.ZodEffects<z.ZodObject<{
182
197
  entryPoint: string;
183
198
  appRegistryComponentName: string;
184
199
  runners: {
185
- config: Record<string, any>;
186
200
  name: string;
201
+ config: Record<string, any>;
187
202
  runner: string;
188
203
  platformId: string;
189
204
  cli?: string | undefined;
205
+ metroConfigEnhancer?: string | undefined;
206
+ bundlePlatform?: string | undefined;
207
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
190
208
  }[];
191
209
  plugins: AnyHarnessPlugin[];
192
210
  metroPort: number;
@@ -226,11 +244,14 @@ export declare const ConfigSchema: z.ZodEffects<z.ZodObject<{
226
244
  entryPoint: string;
227
245
  appRegistryComponentName: string;
228
246
  runners: {
229
- config: Record<string, any>;
230
247
  name: string;
248
+ config: Record<string, any>;
231
249
  runner: string;
232
250
  platformId: string;
233
251
  cli?: string | undefined;
252
+ metroConfigEnhancer?: string | undefined;
253
+ bundlePlatform?: string | undefined;
254
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
234
255
  }[];
235
256
  plugins?: AnyHarnessPlugin[] | undefined;
236
257
  defaultRunner?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAInE,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAkBvC,KAAK,gBAAgB,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAOvD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8MtB,CAAC;AAEJ,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,EAC/C,MAAK,MAAM,CAAC,UAAwB,KACnC,OAOF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iCAAiC,GAC5C,QAAQ,IAAI,CACV,MAAM,EACN,4BAA4B,GAAG,sCAAsC,CACtE,KACA,OAiBF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,GACnC,QAAQ,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,4BAA4B,CAAC,KAC3D,OAiBF,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAInE,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAkCvC,KAAK,gBAAgB,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAOvD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8MtB,CAAC;AAEJ,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,EAC/C,MAAK,MAAM,CAAC,UAAwB,KACnC,OAOF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iCAAiC,GAC5C,QAAQ,IAAI,CACV,MAAM,EACN,4BAA4B,GAAG,sCAAsC,CACtE,KACA,OAiBF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,GACnC,QAAQ,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,4BAA4B,CAAC,KAC3D,OAiBF,CAAC"}
package/dist/types.js CHANGED
@@ -11,7 +11,23 @@ const RunnerSchema = z.object({
11
11
  config: z.record(z.any()),
12
12
  runner: z.string(),
13
13
  cli: z.string().optional(),
14
+ // Module specifier whose default export adjusts the Metro config for this
15
+ // runner. Set by a platform factory (`HarnessPlatform.metroConfigEnhancer`);
16
+ // imported and run by the bundler while it composes the config.
17
+ metroConfigEnhancer: z.string().optional(),
18
+ // The Metro platform the app requests when it differs from platformId
19
+ // (e.g. Vega apps request "kepler"). Set by the platform factory.
20
+ bundlePlatform: z.string().optional(),
14
21
  platformId: z.string(),
22
+ // Set by the platform factories (`HarnessPlatform.getResourceLockKey`) to
23
+ // scope the run's resource lock — e.g. per emulator/simulator/device rather
24
+ // than per platform. A bare `z.object()` strips unknown keys, so without
25
+ // this the harness always fell back to `${platformId}:${name}`.
26
+ getResourceLockKey: z
27
+ .function()
28
+ .args()
29
+ .returns(z.union([z.string(), z.promise(z.string())]))
30
+ .optional(),
15
31
  });
16
32
  const PluginSchema = z.custom((value) => isHarnessPlugin(value), 'Invalid Harness plugin');
17
33
  export const ConfigSchema = z
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-harness/config",
3
- "version": "1.4.1",
3
+ "version": "1.6.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -17,8 +17,8 @@
17
17
  "dependencies": {
18
18
  "tslib": "^2.3.0",
19
19
  "zod": "^3.25.67",
20
- "@react-native-harness/plugins": "1.4.1",
21
- "@react-native-harness/tools": "1.4.1"
20
+ "@react-native-harness/tools": "1.6.0",
21
+ "@react-native-harness/plugins": "1.6.0"
22
22
  },
23
23
  "license": "MIT"
24
24
  }
package/src/reader.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  } from './errors.js';
7
7
  import path from 'node:path';
8
8
  import fs from 'node:fs';
9
+ import { pathToFileURL } from 'node:url';
9
10
  import { createRequire } from 'node:module';
10
11
  import { ZodError } from 'zod';
11
12
 
@@ -28,7 +29,11 @@ const importUp = async (
28
29
 
29
30
  try {
30
31
  if (ext === '.mjs') {
31
- rawConfig = await import(filePathWithExt).then(
32
+ // A dynamic import() of an absolute path only accepts a file:// URL.
33
+ // On POSIX the bare path happens to work; on Windows it is read as a
34
+ // URL and `C:` is rejected as an unknown scheme
35
+ // (ERR_UNSUPPORTED_ESM_URL_SCHEME). pathToFileURL normalizes both.
36
+ rawConfig = await import(pathToFileURL(filePathWithExt).href).then(
32
37
  (module) => module.default
33
38
  );
34
39
  } else {
package/src/types.ts CHANGED
@@ -18,7 +18,23 @@ const RunnerSchema = z.object({
18
18
  config: z.record(z.any()),
19
19
  runner: z.string(),
20
20
  cli: z.string().optional(),
21
+ // Module specifier whose default export adjusts the Metro config for this
22
+ // runner. Set by a platform factory (`HarnessPlatform.metroConfigEnhancer`);
23
+ // imported and run by the bundler while it composes the config.
24
+ metroConfigEnhancer: z.string().optional(),
25
+ // The Metro platform the app requests when it differs from platformId
26
+ // (e.g. Vega apps request "kepler"). Set by the platform factory.
27
+ bundlePlatform: z.string().optional(),
21
28
  platformId: z.string(),
29
+ // Set by the platform factories (`HarnessPlatform.getResourceLockKey`) to
30
+ // scope the run's resource lock — e.g. per emulator/simulator/device rather
31
+ // than per platform. A bare `z.object()` strips unknown keys, so without
32
+ // this the harness always fell back to `${platformId}:${name}`.
33
+ getResourceLockKey: z
34
+ .function()
35
+ .args()
36
+ .returns(z.union([z.string(), z.promise(z.string())]))
37
+ .optional(),
22
38
  });
23
39
 
24
40
  type AnyHarnessPlugin = HarnessPlugin<object, unknown>;