@react-native-harness/config 1.4.1 → 1.5.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,25 @@ 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>;
13
14
  platformId: z.ZodString;
15
+ getResourceLockKey: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodPromise<z.ZodString>]>>>;
14
16
  }, "strip", z.ZodTypeAny, {
15
17
  config: Record<string, any>;
16
18
  name: string;
17
19
  runner: string;
18
20
  platformId: string;
19
21
  cli?: string | undefined;
22
+ metroConfigEnhancer?: string | undefined;
23
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
20
24
  }, {
21
25
  config: Record<string, any>;
22
26
  name: string;
23
27
  runner: string;
24
28
  platformId: string;
25
29
  cli?: string | undefined;
30
+ metroConfigEnhancer?: string | undefined;
31
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
26
32
  }>, "many">;
27
33
  plugins: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<AnyHarnessPlugin, z.ZodTypeDef, AnyHarnessPlugin>, "many">>>;
28
34
  defaultRunner: z.ZodOptional<z.ZodString>;
@@ -99,6 +105,8 @@ export declare const ConfigSchema: z.ZodEffects<z.ZodObject<{
99
105
  runner: string;
100
106
  platformId: string;
101
107
  cli?: string | undefined;
108
+ metroConfigEnhancer?: string | undefined;
109
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
102
110
  }[];
103
111
  plugins: AnyHarnessPlugin[];
104
112
  metroPort: number;
@@ -143,6 +151,8 @@ export declare const ConfigSchema: z.ZodEffects<z.ZodObject<{
143
151
  runner: string;
144
152
  platformId: string;
145
153
  cli?: string | undefined;
154
+ metroConfigEnhancer?: string | undefined;
155
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
146
156
  }[];
147
157
  plugins?: AnyHarnessPlugin[] | undefined;
148
158
  defaultRunner?: string | undefined;
@@ -187,6 +197,8 @@ export declare const ConfigSchema: z.ZodEffects<z.ZodObject<{
187
197
  runner: string;
188
198
  platformId: string;
189
199
  cli?: string | undefined;
200
+ metroConfigEnhancer?: string | undefined;
201
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
190
202
  }[];
191
203
  plugins: AnyHarnessPlugin[];
192
204
  metroPort: number;
@@ -231,6 +243,8 @@ export declare const ConfigSchema: z.ZodEffects<z.ZodObject<{
231
243
  runner: string;
232
244
  platformId: string;
233
245
  cli?: string | undefined;
246
+ metroConfigEnhancer?: string | undefined;
247
+ getResourceLockKey?: ((...args: unknown[]) => string | Promise<string>) | undefined;
234
248
  }[];
235
249
  plugins?: AnyHarnessPlugin[] | undefined;
236
250
  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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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,20 @@ 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(),
14
18
  platformId: z.string(),
19
+ // Set by the platform factories (`HarnessPlatform.getResourceLockKey`) to
20
+ // scope the run's resource lock — e.g. per emulator/simulator/device rather
21
+ // than per platform. A bare `z.object()` strips unknown keys, so without
22
+ // this the harness always fell back to `${platformId}:${name}`.
23
+ getResourceLockKey: z
24
+ .function()
25
+ .args()
26
+ .returns(z.union([z.string(), z.promise(z.string())]))
27
+ .optional(),
15
28
  });
16
29
  const PluginSchema = z.custom((value) => isHarnessPlugin(value), 'Invalid Harness plugin');
17
30
  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.5.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.5.0",
21
+ "@react-native-harness/plugins": "1.5.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,20 @@ 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(),
21
25
  platformId: z.string(),
26
+ // Set by the platform factories (`HarnessPlatform.getResourceLockKey`) to
27
+ // scope the run's resource lock — e.g. per emulator/simulator/device rather
28
+ // than per platform. A bare `z.object()` strips unknown keys, so without
29
+ // this the harness always fell back to `${platformId}:${name}`.
30
+ getResourceLockKey: z
31
+ .function()
32
+ .args()
33
+ .returns(z.union([z.string(), z.promise(z.string())]))
34
+ .optional(),
22
35
  });
23
36
 
24
37
  type AnyHarnessPlugin = HarnessPlugin<object, unknown>;