@react-native-harness/plugins 1.1.0-rc.2

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.
@@ -0,0 +1,321 @@
1
+ import type { DeviceDescriptor, SerializedError, TestResultStatus, TestSuiteResult } from '@react-native-harness/bridge';
2
+ import type { AppCrashDetails, AppLaunchOptions, HarnessPlatform } from '@react-native-harness/platforms';
3
+ export type Awaitable<T> = T | Promise<T>;
4
+ export type HookLogger = {
5
+ debug: (...messages: unknown[]) => void;
6
+ info: (...messages: unknown[]) => void;
7
+ warn: (...messages: unknown[]) => void;
8
+ error: (...messages: unknown[]) => void;
9
+ };
10
+ export type HarnessRunSummary = {
11
+ passed: number;
12
+ failed: number;
13
+ skipped: number;
14
+ todo: number;
15
+ };
16
+ export type HarnessRunStatus = 'passed' | 'failed';
17
+ export type HarnessPlatformMetadata = {
18
+ name: string;
19
+ platformId: string;
20
+ };
21
+ export type HarnessHookMeta<TName extends string = string> = {
22
+ hook: TName;
23
+ invocationId: string;
24
+ runId?: string;
25
+ };
26
+ export type HarnessBaseHookContext<TState extends object, TConfig, TRunner extends HarnessPlatform, TName extends string> = {
27
+ plugin: {
28
+ name: string;
29
+ };
30
+ logger: HookLogger;
31
+ projectRoot: string;
32
+ config: TConfig;
33
+ runner: TRunner;
34
+ platform: HarnessPlatformMetadata;
35
+ state: TState;
36
+ timestamp: number;
37
+ abortSignal: AbortSignal;
38
+ meta: HarnessHookMeta<TName>;
39
+ };
40
+ export type HarnessBeforeCreationContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'harness:before-creation'> & {
41
+ appLaunchOptions?: AppLaunchOptions;
42
+ };
43
+ export type HarnessBeforeDisposeContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'harness:before-dispose'> & {
44
+ runId?: string;
45
+ reason?: 'normal' | 'abort' | 'error';
46
+ summary?: HarnessRunSummary;
47
+ status?: HarnessRunStatus;
48
+ error?: unknown;
49
+ };
50
+ export type RunStartedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'run:started'> & {
51
+ runId: string;
52
+ startTime: number;
53
+ testFiles: string[];
54
+ watchMode: boolean;
55
+ coverageEnabled: boolean;
56
+ };
57
+ export type RunFinishedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'run:finished'> & {
58
+ runId: string;
59
+ startTime: number;
60
+ duration: number;
61
+ testFiles: string[];
62
+ summary: HarnessRunSummary;
63
+ status: HarnessRunStatus;
64
+ error?: unknown;
65
+ };
66
+ export type RuntimeReadyContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'runtime:ready'> & {
67
+ runId: string;
68
+ device: DeviceDescriptor;
69
+ };
70
+ export type RuntimeDisconnectedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'runtime:disconnected'> & {
71
+ runId: string;
72
+ reason?: string;
73
+ };
74
+ export type MetroInitializedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'metro:initialized'> & {
75
+ runId: string;
76
+ port: number;
77
+ host?: string;
78
+ };
79
+ export type MetroBundleTarget = 'module' | 'setupFile';
80
+ export type MetroBundleStartedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'metro:bundle-started'> & {
81
+ runId: string;
82
+ target: MetroBundleTarget;
83
+ file: string;
84
+ setupType?: 'setupFiles' | 'setupFilesAfterEnv';
85
+ };
86
+ export type MetroBundleFinishedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'metro:bundle-finished'> & {
87
+ runId: string;
88
+ target: MetroBundleTarget;
89
+ file: string;
90
+ setupType?: 'setupFiles' | 'setupFilesAfterEnv';
91
+ duration: number;
92
+ };
93
+ export type MetroBundleFailedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'metro:bundle-failed'> & {
94
+ runId: string;
95
+ target: MetroBundleTarget;
96
+ file: string;
97
+ setupType?: 'setupFiles' | 'setupFilesAfterEnv';
98
+ duration: number;
99
+ error: string;
100
+ };
101
+ export type MetroClientLogLevel = 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug' | 'error';
102
+ export type MetroClientLogContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'metro:client-log'> & {
103
+ runId: string;
104
+ level: MetroClientLogLevel;
105
+ data: unknown[];
106
+ };
107
+ export type AppStartedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'app:started'> & {
108
+ runId: string;
109
+ testFile?: string;
110
+ pid?: number;
111
+ source?: 'polling' | 'logs';
112
+ line?: string;
113
+ };
114
+ export type AppExitedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'app:exited'> & {
115
+ runId: string;
116
+ testFile?: string;
117
+ pid?: number;
118
+ source?: 'polling' | 'logs';
119
+ line?: string;
120
+ isConfirmed?: boolean;
121
+ crashDetails?: AppCrashDetails;
122
+ };
123
+ export type AppPossibleCrashContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'app:possible-crash'> & {
124
+ runId: string;
125
+ testFile?: string;
126
+ pid?: number;
127
+ source?: 'polling' | 'logs';
128
+ line?: string;
129
+ isConfirmed?: boolean;
130
+ crashDetails?: AppCrashDetails;
131
+ };
132
+ export type CollectionStartedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'collection:started'> & {
133
+ runId: string;
134
+ file: string;
135
+ };
136
+ export type CollectionFinishedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'collection:finished'> & {
137
+ runId: string;
138
+ file: string;
139
+ duration: number;
140
+ totalTests: number;
141
+ };
142
+ export type TestFileStartedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'test-file:started'> & {
143
+ runId: string;
144
+ file: string;
145
+ };
146
+ export type TestFileFinishedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'test-file:finished'> & {
147
+ runId: string;
148
+ file: string;
149
+ duration: number;
150
+ status: TestResultStatus;
151
+ result: TestSuiteResult | null;
152
+ };
153
+ export type SuiteStartedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'suite:started'> & {
154
+ runId: string;
155
+ file: string;
156
+ name: string;
157
+ };
158
+ export type SuiteFinishedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'suite:finished'> & {
159
+ runId: string;
160
+ file: string;
161
+ name: string;
162
+ duration: number;
163
+ status: TestResultStatus;
164
+ error?: SerializedError;
165
+ };
166
+ export type TestStartedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'test:started'> & {
167
+ runId: string;
168
+ file: string;
169
+ suite: string;
170
+ name: string;
171
+ };
172
+ export type TestFinishedContext<TState extends object, TConfig, TRunner extends HarnessPlatform> = HarnessBaseHookContext<TState, TConfig, TRunner, 'test:finished'> & {
173
+ runId: string;
174
+ file: string;
175
+ suite: string;
176
+ name: string;
177
+ duration: number;
178
+ status: TestResultStatus;
179
+ error?: SerializedError;
180
+ };
181
+ export type FlatHarnessHookContexts<TState extends object, TConfig, TRunner extends HarnessPlatform> = {
182
+ 'harness:before-creation': HarnessBeforeCreationContext<TState, TConfig, TRunner>;
183
+ 'harness:before-dispose': HarnessBeforeDisposeContext<TState, TConfig, TRunner>;
184
+ 'run:started': RunStartedContext<TState, TConfig, TRunner>;
185
+ 'run:finished': RunFinishedContext<TState, TConfig, TRunner>;
186
+ 'runtime:ready': RuntimeReadyContext<TState, TConfig, TRunner>;
187
+ 'runtime:disconnected': RuntimeDisconnectedContext<TState, TConfig, TRunner>;
188
+ 'metro:initialized': MetroInitializedContext<TState, TConfig, TRunner>;
189
+ 'metro:bundle-started': MetroBundleStartedContext<TState, TConfig, TRunner>;
190
+ 'metro:bundle-finished': MetroBundleFinishedContext<TState, TConfig, TRunner>;
191
+ 'metro:bundle-failed': MetroBundleFailedContext<TState, TConfig, TRunner>;
192
+ 'metro:client-log': MetroClientLogContext<TState, TConfig, TRunner>;
193
+ 'app:started': AppStartedContext<TState, TConfig, TRunner>;
194
+ 'app:exited': AppExitedContext<TState, TConfig, TRunner>;
195
+ 'app:possible-crash': AppPossibleCrashContext<TState, TConfig, TRunner>;
196
+ 'collection:started': CollectionStartedContext<TState, TConfig, TRunner>;
197
+ 'collection:finished': CollectionFinishedContext<TState, TConfig, TRunner>;
198
+ 'test-file:started': TestFileStartedContext<TState, TConfig, TRunner>;
199
+ 'test-file:finished': TestFileFinishedContext<TState, TConfig, TRunner>;
200
+ 'suite:started': SuiteStartedContext<TState, TConfig, TRunner>;
201
+ 'suite:finished': SuiteFinishedContext<TState, TConfig, TRunner>;
202
+ 'test:started': TestStartedContext<TState, TConfig, TRunner>;
203
+ 'test:finished': TestFinishedContext<TState, TConfig, TRunner>;
204
+ };
205
+ export type FlatHarnessHookName = keyof FlatHarnessHookContexts<Record<string, never>, unknown, HarnessPlatform>;
206
+ export type HarnessHookHandler<TContext> = (ctx: TContext) => Awaitable<void>;
207
+ export type HarnessPluginHooks<TState extends object = Record<string, never>, TConfig = unknown, TRunner extends HarnessPlatform = HarnessPlatform> = {
208
+ harness?: {
209
+ beforeCreation?: HarnessHookHandler<HarnessBeforeCreationContext<TState, TConfig, TRunner>>;
210
+ beforeDispose?: HarnessHookHandler<HarnessBeforeDisposeContext<TState, TConfig, TRunner>>;
211
+ };
212
+ run?: {
213
+ started?: HarnessHookHandler<RunStartedContext<TState, TConfig, TRunner>>;
214
+ finished?: HarnessHookHandler<RunFinishedContext<TState, TConfig, TRunner>>;
215
+ };
216
+ runtime?: {
217
+ ready?: HarnessHookHandler<RuntimeReadyContext<TState, TConfig, TRunner>>;
218
+ disconnected?: HarnessHookHandler<RuntimeDisconnectedContext<TState, TConfig, TRunner>>;
219
+ };
220
+ metro?: {
221
+ initialized?: HarnessHookHandler<MetroInitializedContext<TState, TConfig, TRunner>>;
222
+ bundleStarted?: HarnessHookHandler<MetroBundleStartedContext<TState, TConfig, TRunner>>;
223
+ bundleFinished?: HarnessHookHandler<MetroBundleFinishedContext<TState, TConfig, TRunner>>;
224
+ bundleFailed?: HarnessHookHandler<MetroBundleFailedContext<TState, TConfig, TRunner>>;
225
+ clientLog?: HarnessHookHandler<MetroClientLogContext<TState, TConfig, TRunner>>;
226
+ };
227
+ app?: {
228
+ started?: HarnessHookHandler<AppStartedContext<TState, TConfig, TRunner>>;
229
+ exited?: HarnessHookHandler<AppExitedContext<TState, TConfig, TRunner>>;
230
+ possibleCrash?: HarnessHookHandler<AppPossibleCrashContext<TState, TConfig, TRunner>>;
231
+ };
232
+ collection?: {
233
+ started?: HarnessHookHandler<CollectionStartedContext<TState, TConfig, TRunner>>;
234
+ finished?: HarnessHookHandler<CollectionFinishedContext<TState, TConfig, TRunner>>;
235
+ };
236
+ testFile?: {
237
+ started?: HarnessHookHandler<TestFileStartedContext<TState, TConfig, TRunner>>;
238
+ finished?: HarnessHookHandler<TestFileFinishedContext<TState, TConfig, TRunner>>;
239
+ };
240
+ suite?: {
241
+ started?: HarnessHookHandler<SuiteStartedContext<TState, TConfig, TRunner>>;
242
+ finished?: HarnessHookHandler<SuiteFinishedContext<TState, TConfig, TRunner>>;
243
+ };
244
+ test?: {
245
+ started?: HarnessHookHandler<TestStartedContext<TState, TConfig, TRunner>>;
246
+ finished?: HarnessHookHandler<TestFinishedContext<TState, TConfig, TRunner>>;
247
+ };
248
+ };
249
+ export type HarnessPlugin<TState extends object = Record<string, never>, TConfig = unknown, TRunner extends HarnessPlatform = HarnessPlatform> = {
250
+ name: string;
251
+ hooks?: HarnessPluginHooks<TState, TConfig, TRunner>;
252
+ createState?: () => TState;
253
+ };
254
+ export declare const HARNESS_HOOKS: readonly [{
255
+ readonly flatName: "harness:before-creation";
256
+ readonly path: readonly ["harness", "beforeCreation"];
257
+ }, {
258
+ readonly flatName: "harness:before-dispose";
259
+ readonly path: readonly ["harness", "beforeDispose"];
260
+ }, {
261
+ readonly flatName: "run:started";
262
+ readonly path: readonly ["run", "started"];
263
+ }, {
264
+ readonly flatName: "run:finished";
265
+ readonly path: readonly ["run", "finished"];
266
+ }, {
267
+ readonly flatName: "runtime:ready";
268
+ readonly path: readonly ["runtime", "ready"];
269
+ }, {
270
+ readonly flatName: "runtime:disconnected";
271
+ readonly path: readonly ["runtime", "disconnected"];
272
+ }, {
273
+ readonly flatName: "metro:initialized";
274
+ readonly path: readonly ["metro", "initialized"];
275
+ }, {
276
+ readonly flatName: "metro:bundle-started";
277
+ readonly path: readonly ["metro", "bundleStarted"];
278
+ }, {
279
+ readonly flatName: "metro:bundle-finished";
280
+ readonly path: readonly ["metro", "bundleFinished"];
281
+ }, {
282
+ readonly flatName: "metro:bundle-failed";
283
+ readonly path: readonly ["metro", "bundleFailed"];
284
+ }, {
285
+ readonly flatName: "metro:client-log";
286
+ readonly path: readonly ["metro", "clientLog"];
287
+ }, {
288
+ readonly flatName: "app:started";
289
+ readonly path: readonly ["app", "started"];
290
+ }, {
291
+ readonly flatName: "app:exited";
292
+ readonly path: readonly ["app", "exited"];
293
+ }, {
294
+ readonly flatName: "app:possible-crash";
295
+ readonly path: readonly ["app", "possibleCrash"];
296
+ }, {
297
+ readonly flatName: "collection:started";
298
+ readonly path: readonly ["collection", "started"];
299
+ }, {
300
+ readonly flatName: "collection:finished";
301
+ readonly path: readonly ["collection", "finished"];
302
+ }, {
303
+ readonly flatName: "test-file:started";
304
+ readonly path: readonly ["testFile", "started"];
305
+ }, {
306
+ readonly flatName: "test-file:finished";
307
+ readonly path: readonly ["testFile", "finished"];
308
+ }, {
309
+ readonly flatName: "suite:started";
310
+ readonly path: readonly ["suite", "started"];
311
+ }, {
312
+ readonly flatName: "suite:finished";
313
+ readonly path: readonly ["suite", "finished"];
314
+ }, {
315
+ readonly flatName: "test:started";
316
+ readonly path: readonly ["test", "started"];
317
+ }, {
318
+ readonly flatName: "test:finished";
319
+ readonly path: readonly ["test", "finished"];
320
+ }];
321
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE1C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACxC,IAAI,EAAE,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACvC,IAAI,EAAE,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACvC,KAAK,EAAE,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MA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AAE,kBAAkB,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC5E,QAAQ,CAAC,EAAE,kBAAkB,CAC3B,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAC/C,CAAC;KACH,CAAC;IACF,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC3E,QAAQ,CAAC,EAAE,kBAAkB,CAC3B,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAC9C,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,aAAa,CACvB,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC7C,OAAO,GAAG,OAAO,EACjB,OAAO,SAAS,eAAe,GAAG,eAAe,IAC/C;IACF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACrD,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBhB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,24 @@
1
+ export const HARNESS_HOOKS = [
2
+ { flatName: 'harness:before-creation', path: ['harness', 'beforeCreation'] },
3
+ { flatName: 'harness:before-dispose', path: ['harness', 'beforeDispose'] },
4
+ { flatName: 'run:started', path: ['run', 'started'] },
5
+ { flatName: 'run:finished', path: ['run', 'finished'] },
6
+ { flatName: 'runtime:ready', path: ['runtime', 'ready'] },
7
+ { flatName: 'runtime:disconnected', path: ['runtime', 'disconnected'] },
8
+ { flatName: 'metro:initialized', path: ['metro', 'initialized'] },
9
+ { flatName: 'metro:bundle-started', path: ['metro', 'bundleStarted'] },
10
+ { flatName: 'metro:bundle-finished', path: ['metro', 'bundleFinished'] },
11
+ { flatName: 'metro:bundle-failed', path: ['metro', 'bundleFailed'] },
12
+ { flatName: 'metro:client-log', path: ['metro', 'clientLog'] },
13
+ { flatName: 'app:started', path: ['app', 'started'] },
14
+ { flatName: 'app:exited', path: ['app', 'exited'] },
15
+ { flatName: 'app:possible-crash', path: ['app', 'possibleCrash'] },
16
+ { flatName: 'collection:started', path: ['collection', 'started'] },
17
+ { flatName: 'collection:finished', path: ['collection', 'finished'] },
18
+ { flatName: 'test-file:started', path: ['testFile', 'started'] },
19
+ { flatName: 'test-file:finished', path: ['testFile', 'finished'] },
20
+ { flatName: 'suite:started', path: ['suite', 'started'] },
21
+ { flatName: 'suite:finished', path: ['suite', 'finished'] },
22
+ { flatName: 'test:started', path: ['test', 'started'] },
23
+ { flatName: 'test:finished', path: ['test', 'finished'] },
24
+ ];
@@ -0,0 +1,5 @@
1
+ import type { HookLogger } from './types.js';
2
+ export declare const isHookTree: (value: unknown) => boolean;
3
+ export declare const createPluginLogger: (pluginName: string) => HookLogger;
4
+ export declare const getNestedValue: (value: unknown, path: readonly string[]) => unknown;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,OAyB3C,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,YAAY,MAAM,KAAG,UASvD,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,OAAO,OAAO,EACd,MAAM,SAAS,MAAM,EAAE,KACtB,OAYF,CAAC"}
package/dist/utils.js ADDED
@@ -0,0 +1,40 @@
1
+ import { createLogger } from '@react-native-harness/tools';
2
+ export const isHookTree = (value) => {
3
+ if (value == null || typeof value !== 'object' || Array.isArray(value)) {
4
+ return false;
5
+ }
6
+ for (const child of Object.values(value)) {
7
+ if (child === undefined) {
8
+ continue;
9
+ }
10
+ if (typeof child === 'function') {
11
+ continue;
12
+ }
13
+ if (child == null ||
14
+ typeof child !== 'object' ||
15
+ Array.isArray(child) ||
16
+ !isHookTree(child)) {
17
+ return false;
18
+ }
19
+ }
20
+ return true;
21
+ };
22
+ export const createPluginLogger = (pluginName) => {
23
+ const pluginLogger = createLogger(`plugin:${pluginName}`);
24
+ return {
25
+ debug: (...messages) => pluginLogger.debug(...messages),
26
+ info: (...messages) => pluginLogger.info(...messages),
27
+ warn: (...messages) => pluginLogger.warn(...messages),
28
+ error: (...messages) => pluginLogger.error(...messages),
29
+ };
30
+ };
31
+ export const getNestedValue = (value, path) => {
32
+ let current = value;
33
+ for (const segment of path) {
34
+ if (current == null || typeof current !== 'object') {
35
+ return undefined;
36
+ }
37
+ current = current[segment];
38
+ }
39
+ return current;
40
+ };
@@ -0,0 +1,19 @@
1
+ import baseConfig from '../../eslint.config.mjs';
2
+
3
+ export default [
4
+ ...baseConfig,
5
+ {
6
+ files: ['**/*.json'],
7
+ rules: {
8
+ '@nx/dependency-checks': [
9
+ 'error',
10
+ {
11
+ ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}'],
12
+ },
13
+ ],
14
+ },
15
+ languageOptions: {
16
+ parser: await import('jsonc-eslint-parser'),
17
+ },
18
+ },
19
+ ];
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@react-native-harness/plugins",
3
+ "version": "1.1.0-rc.2",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "./package.json": "./package.json",
10
+ ".": {
11
+ "development": "./src/index.ts",
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "dependencies": {
18
+ "hookable": "^6.1.0",
19
+ "tslib": "^2.3.0",
20
+ "@react-native-harness/platforms": "1.1.0-rc.2",
21
+ "@react-native-harness/tools": "1.1.0-rc.2",
22
+ "@react-native-harness/bridge": "1.1.0-rc.2"
23
+ },
24
+ "license": "MIT"
25
+ }
package/src/index.ts ADDED
@@ -0,0 +1,40 @@
1
+ export { definePlugin, isHarnessPlugin } from './plugin.js';
2
+ export { createHarnessPluginManager } from './manager.js';
3
+ export type { HarnessPluginManager } from './manager.js';
4
+ export type {
5
+ AppExitedContext,
6
+ AppPossibleCrashContext,
7
+ AppStartedContext,
8
+ CollectionFinishedContext,
9
+ CollectionStartedContext,
10
+ FlatHarnessHookContexts,
11
+ FlatHarnessHookName,
12
+ HarnessBaseHookContext,
13
+ HarnessBeforeCreationContext,
14
+ HarnessBeforeDisposeContext,
15
+ HarnessHookHandler,
16
+ HarnessHookMeta,
17
+ HarnessPlatformMetadata,
18
+ HarnessPlugin,
19
+ HarnessPluginHooks,
20
+ HarnessRunStatus,
21
+ HarnessRunSummary,
22
+ HookLogger,
23
+ MetroBundleFailedContext,
24
+ MetroBundleFinishedContext,
25
+ MetroBundleStartedContext,
26
+ MetroBundleTarget,
27
+ MetroClientLogContext,
28
+ MetroClientLogLevel,
29
+ MetroInitializedContext,
30
+ RunFinishedContext,
31
+ RunStartedContext,
32
+ RuntimeDisconnectedContext,
33
+ RuntimeReadyContext,
34
+ SuiteFinishedContext,
35
+ SuiteStartedContext,
36
+ TestFileFinishedContext,
37
+ TestFileStartedContext,
38
+ TestFinishedContext,
39
+ TestStartedContext,
40
+ } from './types.js';
package/src/manager.ts ADDED
@@ -0,0 +1,166 @@
1
+ import { createHooks } from 'hookable';
2
+ import { logger } from '@react-native-harness/tools';
3
+ import type { HarnessPlatform } from '@react-native-harness/platforms';
4
+ import {
5
+ type FlatHarnessHookContexts,
6
+ HARNESS_HOOKS,
7
+ type HarnessPlugin,
8
+ } from './types.js';
9
+ import { createPluginLogger, getNestedValue } from './utils.js';
10
+
11
+ const pluginsLogger = logger.child('plugins');
12
+
13
+ type ManagerOptions<TConfig, TRunner extends HarnessPlatform> = {
14
+ plugins: Array<HarnessPlugin<object, TConfig, TRunner>>;
15
+ projectRoot: string;
16
+ config: TConfig;
17
+ runner: TRunner;
18
+ abortSignal: AbortSignal;
19
+ };
20
+
21
+ type HookName<TConfig, TRunner extends HarnessPlatform> = keyof FlatHarnessHookContexts<
22
+ object,
23
+ TConfig,
24
+ TRunner
25
+ >;
26
+
27
+ type HookPayload<
28
+ TConfig,
29
+ TRunner extends HarnessPlatform,
30
+ TName extends HookName<TConfig, TRunner>,
31
+ > = Omit<
32
+ FlatHarnessHookContexts<object, TConfig, TRunner>[TName],
33
+ | 'plugin'
34
+ | 'logger'
35
+ | 'projectRoot'
36
+ | 'config'
37
+ | 'runner'
38
+ | 'platform'
39
+ | 'state'
40
+ | 'timestamp'
41
+ | 'abortSignal'
42
+ | 'meta'
43
+ >;
44
+
45
+ type FlatHookRegistry<TConfig, TRunner extends HarnessPlatform> = Record<
46
+ HookName<TConfig, TRunner>,
47
+ (payload: unknown) => Promise<void>
48
+ >;
49
+
50
+ export type HarnessPluginManager<
51
+ TConfig = unknown,
52
+ TRunner extends HarnessPlatform = HarnessPlatform,
53
+ > = {
54
+ hasPlugins: () => boolean;
55
+ callHook: <TName extends HookName<TConfig, TRunner>>(
56
+ name: TName,
57
+ payload: HookPayload<TConfig, TRunner, TName>
58
+ ) => Promise<void>;
59
+ };
60
+
61
+ export const createHarnessPluginManager = <
62
+ TConfig,
63
+ TRunner extends HarnessPlatform,
64
+ >({
65
+ plugins,
66
+ projectRoot,
67
+ config,
68
+ runner,
69
+ abortSignal,
70
+ }: ManagerOptions<TConfig, TRunner>): HarnessPluginManager<TConfig, TRunner> => {
71
+ const hooks = createHooks<FlatHookRegistry<TConfig, TRunner>>();
72
+ let invocationCount = 0;
73
+
74
+ for (const plugin of plugins) {
75
+ const state = plugin.createState?.() ?? {};
76
+ const pluginLogger = createPluginLogger(plugin.name);
77
+
78
+ for (const hookDefinition of HARNESS_HOOKS) {
79
+ const handler = getNestedValue(plugin.hooks, hookDefinition.path);
80
+
81
+ if (typeof handler !== 'function') {
82
+ continue;
83
+ }
84
+
85
+ const hookName = hookDefinition.flatName as HookName<TConfig, TRunner>;
86
+ const typedHandler = handler as (payload: unknown) => Promise<void> | void;
87
+
88
+ hooks.hook(hookName, async (payload: unknown) => {
89
+ const typedPayload = payload as HookPayload<
90
+ TConfig,
91
+ TRunner,
92
+ typeof hookName
93
+ >;
94
+ const timestamp = Date.now();
95
+ const invocationId = `${hookName}-${++invocationCount}`;
96
+
97
+ try {
98
+ await typedHandler({
99
+ ...typedPayload,
100
+ plugin: {
101
+ name: plugin.name,
102
+ },
103
+ logger: pluginLogger,
104
+ projectRoot,
105
+ config,
106
+ runner,
107
+ platform: {
108
+ name: runner.name,
109
+ platformId: runner.platformId,
110
+ },
111
+ state,
112
+ timestamp,
113
+ abortSignal,
114
+ meta: {
115
+ hook: hookName,
116
+ invocationId,
117
+ runId:
118
+ 'runId' in typedPayload && typeof typedPayload.runId === 'string'
119
+ ? typedPayload.runId
120
+ : undefined,
121
+ },
122
+ });
123
+
124
+ if (logger.isVerbose()) {
125
+ pluginsLogger.debug(
126
+ 'hook completed: plugin=%s hook=%s invocationId=%s duration=%dms outcome=success',
127
+ plugin.name,
128
+ hookName,
129
+ invocationId,
130
+ Date.now() - timestamp
131
+ );
132
+ }
133
+ } catch (error) {
134
+ if (logger.isVerbose()) {
135
+ pluginsLogger.debug(
136
+ 'hook completed: plugin=%s hook=%s invocationId=%s duration=%dms outcome=error',
137
+ plugin.name,
138
+ hookName,
139
+ invocationId,
140
+ Date.now() - timestamp
141
+ );
142
+ pluginsLogger.debug(error);
143
+ }
144
+
145
+ throw error;
146
+ }
147
+ });
148
+ }
149
+ }
150
+
151
+ return {
152
+ hasPlugins: () => plugins.length > 0,
153
+ callHook: async (name, payload) => {
154
+ if (plugins.length === 0) {
155
+ return;
156
+ }
157
+
158
+ await hooks.callHook(
159
+ name,
160
+ ...([
161
+ payload,
162
+ ] as Parameters<FlatHookRegistry<TConfig, TRunner>[typeof name]>)
163
+ );
164
+ },
165
+ };
166
+ };