@react-native-harness/runtime 1.0.0-alpha.1 → 1.0.0-alpha.10
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/dist/bundler/bundle.d.ts.map +1 -1
- package/dist/bundler/bundle.js +7 -1
- package/dist/bundler/errors.d.ts +5 -0
- package/dist/bundler/errors.d.ts.map +1 -1
- package/dist/bundler/errors.js +10 -0
- package/dist/client/factory.d.ts.map +1 -1
- package/dist/client/factory.js +8 -1
- package/dist/initialize.js +8 -6
- package/dist/mocker/registry.d.ts +2 -2
- package/dist/mocker/registry.d.ts.map +1 -1
- package/dist/runner/errors.d.ts +4 -2
- package/dist/runner/errors.d.ts.map +1 -1
- package/dist/runner/errors.js +21 -3
- package/dist/runner/runSuite.d.ts.map +1 -1
- package/dist/runner/runSuite.js +22 -7
- package/dist/symbolicate.d.ts +3 -0
- package/dist/symbolicate.d.ts.map +1 -0
- package/dist/symbolicate.js +18 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/progressLogger.d.ts +8 -0
- package/dist/utils/progressLogger.d.ts.map +1 -0
- package/dist/utils/progressLogger.js +73 -0
- package/package.json +7 -5
- package/src/bundler/bundle.ts +9 -1
- package/src/bundler/errors.ts +10 -0
- package/src/client/factory.ts +8 -1
- package/src/initialize.ts +11 -8
- package/src/mocker/registry.ts +3 -3
- package/src/react-native.d.ts +37 -0
- package/src/runner/errors.ts +35 -5
- package/src/runner/runSuite.ts +27 -9
- package/src/symbolicate.ts +22 -0
- package/src/utils/progressLogger.ts +91 -0
- package/dist/bundler/dev-server.d.ts +0 -2
- package/dist/bundler/dev-server.d.ts.map +0 -1
- package/dist/bundler/dev-server.js +0 -5
- package/dist/exports.d.ts +0 -7
- package/dist/exports.d.ts.map +0 -1
- package/dist/exports.js +0 -6
- package/dist/getEntryComponent.d.ts +0 -6
- package/dist/getEntryComponent.d.ts.map +0 -1
- package/dist/getEntryComponent.js +0 -6
- package/dist/logger.d.ts +0 -6
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -14
- package/dist/mock.d.ts +0 -15
- package/dist/mock.d.ts.map +0 -1
- package/dist/mock.js +0 -37
- package/dist/module.d.ts +0 -3
- package/dist/module.d.ts.map +0 -1
- package/dist/module.js +0 -19
- package/dist/module.web.d.ts +0 -2
- package/dist/module.web.d.ts.map +0 -1
- package/dist/module.web.js +0 -12
- package/dist/rntl/client.d.ts +0 -3
- package/dist/rntl/client.d.ts.map +0 -1
- package/dist/rntl/client.js +0 -8
- package/dist/rntl/describe.d.ts +0 -2
- package/dist/rntl/describe.d.ts.map +0 -1
- package/dist/rntl/describe.js +0 -1
- package/dist/rntl/expect.d.ts +0 -128
- package/dist/rntl/expect.d.ts.map +0 -1
- package/dist/rntl/expect.js +0 -670
- package/dist/rntl/fn.d.ts +0 -2
- package/dist/rntl/fn.d.ts.map +0 -1
- package/dist/rntl/fn.js +0 -1
- package/dist/rntl/mock.d.ts +0 -2
- package/dist/rntl/mock.d.ts.map +0 -1
- package/dist/rntl/mock.js +0 -1
- package/dist/rntl/render.d.ts +0 -4
- package/dist/rntl/render.d.ts.map +0 -1
- package/dist/rntl/render.js +0 -11
- package/dist/rntl/screen.d.ts +0 -45
- package/dist/rntl/screen.d.ts.map +0 -1
- package/dist/rntl/screen.js +0 -31
- package/dist/rntl/spies.d.ts +0 -45
- package/dist/rntl/spies.d.ts.map +0 -1
- package/dist/rntl/spies.js +0 -553
- package/dist/rntl/userEvent.d.ts +0 -22
- package/dist/rntl/userEvent.d.ts.map +0 -1
- package/dist/rntl/userEvent.js +0 -19
- package/dist/runner.d.ts +0 -7
- package/dist/runner.d.ts.map +0 -1
- package/dist/runner.js +0 -201
- package/dist/runtime.d.ts +0 -2
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -44
- package/dist/state.d.ts +0 -25
- package/dist/state.d.ts.map +0 -1
- package/dist/state.js +0 -37
- package/dist/ui/UI.d.ts +0 -13
- package/dist/ui/UI.d.ts.map +0 -1
- package/dist/ui/UI.js +0 -121
package/dist/runner.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
async function runHooks(hooks) {
|
|
2
|
-
for (const hook of hooks) {
|
|
3
|
-
await hook();
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
function collectInheritedHooks(suite, hookType) {
|
|
7
|
-
const hooks = [];
|
|
8
|
-
const suiteChain = [];
|
|
9
|
-
// Collect all suites from current to root
|
|
10
|
-
let currentSuite = suite;
|
|
11
|
-
while (currentSuite) {
|
|
12
|
-
suiteChain.push(currentSuite);
|
|
13
|
-
currentSuite = currentSuite.parent;
|
|
14
|
-
}
|
|
15
|
-
if (hookType === 'beforeEach') {
|
|
16
|
-
// For beforeEach: run parent hooks first (reverse the chain)
|
|
17
|
-
for (let i = suiteChain.length - 1; i >= 0; i--) {
|
|
18
|
-
hooks.push(...suiteChain[i].beforeEach);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
// For afterEach: run child hooks first (use chain as-is)
|
|
23
|
-
for (const suiteInChain of suiteChain) {
|
|
24
|
-
hooks.push(...suiteInChain.afterEach);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return hooks;
|
|
28
|
-
}
|
|
29
|
-
async function runTest(test, suite, eventHandler, context) {
|
|
30
|
-
const startTime = Date.now();
|
|
31
|
-
// Emit test-started event
|
|
32
|
-
eventHandler({
|
|
33
|
-
type: 'test-started',
|
|
34
|
-
path: context.testFilePath,
|
|
35
|
-
suite: suite.name,
|
|
36
|
-
name: test.name,
|
|
37
|
-
});
|
|
38
|
-
try {
|
|
39
|
-
if (test.status === 'skipped') {
|
|
40
|
-
console.log(`- ${test.name} (skipped)`);
|
|
41
|
-
const result = {
|
|
42
|
-
name: test.name,
|
|
43
|
-
status: 'skipped',
|
|
44
|
-
duration: 0,
|
|
45
|
-
};
|
|
46
|
-
// Emit test-finished event
|
|
47
|
-
eventHandler({
|
|
48
|
-
type: 'test-finished',
|
|
49
|
-
path: context.testFilePath,
|
|
50
|
-
suite: suite.name,
|
|
51
|
-
name: test.name,
|
|
52
|
-
duration: 0,
|
|
53
|
-
reason: 'skipped',
|
|
54
|
-
});
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
if (test.status === 'todo') {
|
|
58
|
-
console.log(`- ${test.name} (todo)`);
|
|
59
|
-
const result = {
|
|
60
|
-
name: test.name,
|
|
61
|
-
status: 'todo',
|
|
62
|
-
duration: 0,
|
|
63
|
-
};
|
|
64
|
-
// Emit test-finished event
|
|
65
|
-
eventHandler({
|
|
66
|
-
type: 'test-finished',
|
|
67
|
-
path: context.testFilePath,
|
|
68
|
-
suite: suite.name,
|
|
69
|
-
name: test.name,
|
|
70
|
-
duration: 0,
|
|
71
|
-
reason: 'todo',
|
|
72
|
-
});
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
// Run all beforeEach hooks from the current suite and its parents
|
|
76
|
-
const beforeEachHooks = collectInheritedHooks(suite, 'beforeEach');
|
|
77
|
-
await runHooks(beforeEachHooks);
|
|
78
|
-
// Run the actual test
|
|
79
|
-
await test.fn();
|
|
80
|
-
// Run all afterEach hooks from the current suite and its parents
|
|
81
|
-
const afterEachHooks = collectInheritedHooks(suite, 'afterEach');
|
|
82
|
-
await runHooks(afterEachHooks);
|
|
83
|
-
const duration = Date.now() - startTime;
|
|
84
|
-
console.log(`✓ ${test.name}`);
|
|
85
|
-
const result = {
|
|
86
|
-
name: test.name,
|
|
87
|
-
status: 'passed',
|
|
88
|
-
duration,
|
|
89
|
-
};
|
|
90
|
-
// Emit test-finished event
|
|
91
|
-
eventHandler({
|
|
92
|
-
type: 'test-finished',
|
|
93
|
-
path: context.testFilePath,
|
|
94
|
-
suite: suite.name,
|
|
95
|
-
name: test.name,
|
|
96
|
-
duration,
|
|
97
|
-
reason: 'passed',
|
|
98
|
-
});
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
const duration = Date.now() - startTime;
|
|
103
|
-
console.error(`✗ ${test.name}`);
|
|
104
|
-
console.error(error);
|
|
105
|
-
const result = {
|
|
106
|
-
name: test.name,
|
|
107
|
-
status: 'failed',
|
|
108
|
-
error: {
|
|
109
|
-
name: typeof error === 'object' && error !== null && 'name' in error
|
|
110
|
-
? error.name
|
|
111
|
-
: 'Unknown error',
|
|
112
|
-
message: typeof error === 'object' && error !== null && 'message' in error
|
|
113
|
-
? error.message
|
|
114
|
-
: JSON.stringify(error),
|
|
115
|
-
stack: typeof error === 'object' && error !== null && 'stack' in error
|
|
116
|
-
? error.stack
|
|
117
|
-
: undefined,
|
|
118
|
-
},
|
|
119
|
-
duration,
|
|
120
|
-
};
|
|
121
|
-
// Emit test-finished event
|
|
122
|
-
eventHandler({
|
|
123
|
-
type: 'test-finished',
|
|
124
|
-
path: context.testFilePath,
|
|
125
|
-
suite: suite.name,
|
|
126
|
-
name: test.name,
|
|
127
|
-
duration,
|
|
128
|
-
reason: 'failed',
|
|
129
|
-
});
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
export async function runSuite(suite, eventHandler, context) {
|
|
134
|
-
console.log(`\n${suite.name}`);
|
|
135
|
-
const startTime = Date.now();
|
|
136
|
-
// Emit suite-started event
|
|
137
|
-
eventHandler({
|
|
138
|
-
type: 'suite-started',
|
|
139
|
-
path: context.testFilePath,
|
|
140
|
-
name: suite.name,
|
|
141
|
-
});
|
|
142
|
-
const testResults = [];
|
|
143
|
-
const suiteResults = [];
|
|
144
|
-
let suiteError;
|
|
145
|
-
try {
|
|
146
|
-
// Run beforeAll hooks
|
|
147
|
-
await runHooks(suite.beforeAll);
|
|
148
|
-
// Run all tests in the current suite
|
|
149
|
-
for (const test of suite.tests) {
|
|
150
|
-
const result = await runTest(test, suite, eventHandler, context);
|
|
151
|
-
testResults.push(result);
|
|
152
|
-
}
|
|
153
|
-
// Run all child suites
|
|
154
|
-
for (const childSuite of suite.suites) {
|
|
155
|
-
const result = await runSuite(childSuite, eventHandler, context);
|
|
156
|
-
suiteResults.push(result);
|
|
157
|
-
}
|
|
158
|
-
// Run afterAll hooks
|
|
159
|
-
await runHooks(suite.afterAll);
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
console.error(`Suite "${suite.name}" failed`);
|
|
163
|
-
suiteError = error;
|
|
164
|
-
}
|
|
165
|
-
const duration = Date.now() - startTime;
|
|
166
|
-
// Determine overall suite status
|
|
167
|
-
let status = 'passed';
|
|
168
|
-
if (suiteError) {
|
|
169
|
-
status = 'failed';
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
// Check if any tests or child suites failed
|
|
173
|
-
const hasFailedTests = testResults.some((result) => result.status === 'failed');
|
|
174
|
-
const hasFailedSuites = suiteResults.some((result) => result.status === 'failed');
|
|
175
|
-
if (hasFailedTests || hasFailedSuites) {
|
|
176
|
-
status = 'failed';
|
|
177
|
-
}
|
|
178
|
-
else if ((testResults.every((result) => result.status === 'skipped') &&
|
|
179
|
-
suiteResults.every((result) => result.status === 'skipped') &&
|
|
180
|
-
testResults.length > 0) ||
|
|
181
|
-
suiteResults.length > 0) {
|
|
182
|
-
status = 'skipped';
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// Emit suite-finished event
|
|
186
|
-
eventHandler({
|
|
187
|
-
type: 'suite-finished',
|
|
188
|
-
path: context.testFilePath,
|
|
189
|
-
name: suite.name,
|
|
190
|
-
duration,
|
|
191
|
-
reason: status,
|
|
192
|
-
});
|
|
193
|
-
return {
|
|
194
|
-
name: suite.name,
|
|
195
|
-
tests: testResults,
|
|
196
|
-
suites: suiteResults,
|
|
197
|
-
status,
|
|
198
|
-
error: suiteError,
|
|
199
|
-
duration,
|
|
200
|
-
};
|
|
201
|
-
}
|
package/dist/runtime.d.ts
DELETED
package/dist/runtime.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,SAAS,2EA6CrB,CAAC"}
|
package/dist/runtime.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { getBridgeClient } from '@react-native-harness/bridge/client';
|
|
2
|
-
import { fetchModule, evaluateModule } from './bundler/index.js';
|
|
3
|
-
import { state } from './state.js';
|
|
4
|
-
import { getTestRunner } from './runner/index.js';
|
|
5
|
-
import { getTestCollector } from './collector/index.js';
|
|
6
|
-
import { combineEventEmitters } from './utils/emitter.js';
|
|
7
|
-
import { getWSServer } from './client/getWSServer.js';
|
|
8
|
-
import { Alert } from 'react-native';
|
|
9
|
-
import { getDeviceDescriptor } from './client/getDeviceDescriptor.js';
|
|
10
|
-
export const getClient = async () => {
|
|
11
|
-
const client = await getBridgeClient(getWSServer(), {
|
|
12
|
-
runTests: async () => {
|
|
13
|
-
throw new Error('Not implemented');
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
Alert.alert('Device', JSON.stringify(getDeviceDescriptor()));
|
|
17
|
-
client.rpc.$functions.runTests = async (path) => {
|
|
18
|
-
if (state.getState().status === 'running') {
|
|
19
|
-
throw new Error('Already running tests');
|
|
20
|
-
}
|
|
21
|
-
state.getState().setStatus('running');
|
|
22
|
-
let collector = null;
|
|
23
|
-
let runner = null;
|
|
24
|
-
let events = null;
|
|
25
|
-
try {
|
|
26
|
-
collector = getTestCollector();
|
|
27
|
-
runner = getTestRunner();
|
|
28
|
-
events = combineEventEmitters(collector.events, runner.events);
|
|
29
|
-
events.addListener((event) => {
|
|
30
|
-
client.rpc.emitEvent(event.type, event);
|
|
31
|
-
});
|
|
32
|
-
const moduleJs = await fetchModule(path);
|
|
33
|
-
const collectionResult = await collector.collect(() => evaluateModule(moduleJs, path), path);
|
|
34
|
-
return await runner.run(collectionResult.testSuite, path);
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
collector?.dispose();
|
|
38
|
-
runner?.dispose();
|
|
39
|
-
events?.clearAllListeners();
|
|
40
|
-
state.getState().setStatus('idle');
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
return client;
|
|
44
|
-
};
|
package/dist/state.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { BridgeClient } from '@react-native-harness/bridge/client';
|
|
3
|
-
type ComponentHarnessState = {
|
|
4
|
-
node: ReactNode;
|
|
5
|
-
options: unknown;
|
|
6
|
-
layout: {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
type RunnerState = {
|
|
14
|
-
status: 'loading' | 'idle' | 'running';
|
|
15
|
-
componentHarness: ComponentHarnessState | null;
|
|
16
|
-
client: BridgeClient | null;
|
|
17
|
-
setStatus: (status: 'idle' | 'running') => void;
|
|
18
|
-
render: (node: ReactNode, options: unknown) => void;
|
|
19
|
-
cleanup: () => void;
|
|
20
|
-
bootstrap: () => Promise<void>;
|
|
21
|
-
reportLayout: (x: number, y: number, width: number, height: number) => void;
|
|
22
|
-
};
|
|
23
|
-
export declare const state: import("zustand/react").UseBoundStore<import("zustand/vanilla").StoreApi<RunnerState>>;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=state.d.ts.map
|
package/dist/state.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGnE,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACjE,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,gBAAgB,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC/C,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAChD,MAAM,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACpD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7E,CAAC;AAUF,eAAO,MAAM,KAAK,wFA+Bf,CAAC"}
|
package/dist/state.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { create } from 'zustand/react';
|
|
2
|
-
import { getClient } from './runtime.js';
|
|
3
|
-
function assertComponentHarnessReady(state) {
|
|
4
|
-
if (!state.componentHarness) {
|
|
5
|
-
throw new Error('ComponentHarness is not ready');
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export const state = create((set) => ({
|
|
9
|
-
status: 'loading',
|
|
10
|
-
componentHarness: null,
|
|
11
|
-
client: null,
|
|
12
|
-
setStatus: (status) => set({ status }),
|
|
13
|
-
render: (node, options) => set({
|
|
14
|
-
componentHarness: {
|
|
15
|
-
node,
|
|
16
|
-
options,
|
|
17
|
-
layout: { x: 0, y: 0, width: 0, height: 0 },
|
|
18
|
-
},
|
|
19
|
-
}),
|
|
20
|
-
cleanup: () => set({ componentHarness: null }),
|
|
21
|
-
bootstrap: async () => {
|
|
22
|
-
const client = await getClient();
|
|
23
|
-
set({ client, status: 'idle' });
|
|
24
|
-
client.rpc.reportReady();
|
|
25
|
-
},
|
|
26
|
-
reportLayout: (x, y, width, height) => {
|
|
27
|
-
set((state) => {
|
|
28
|
-
assertComponentHarnessReady(state);
|
|
29
|
-
return {
|
|
30
|
-
componentHarness: {
|
|
31
|
-
...state.componentHarness,
|
|
32
|
-
layout: { x, y, width, height },
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
},
|
|
37
|
-
}));
|
package/dist/ui/UI.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ComponentType, ReactNode } from 'react';
|
|
2
|
-
export type ComponentHarnessOptions = {
|
|
3
|
-
wrapper: ComponentType<{
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
}>;
|
|
6
|
-
};
|
|
7
|
-
export type ComponentHarnessProps = {
|
|
8
|
-
element: ReactNode;
|
|
9
|
-
options: ComponentHarnessOptions;
|
|
10
|
-
};
|
|
11
|
-
export declare const UI: () => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export default UI;
|
|
13
|
-
//# sourceMappingURL=UI.d.ts.map
|
package/dist/ui/UI.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UI.d.ts","sourceRoot":"","sources":["../../src/ui/UI.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAQ,SAAS,EAAa,MAAM,OAAO,CAAC;AAKlE,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,aAAa,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,SAAS,CAAC;IACnB,OAAO,EAAE,uBAAuB,CAAC;CAClC,CAAC;AAeF,eAAO,MAAM,EAAE,+CA+Cd,CAAC;AAuGF,eAAe,EAAE,CAAC"}
|
package/dist/ui/UI.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { View, Text, Image, StyleSheet, ActivityIndicator, StatusBar, Platform, } from 'react-native';
|
|
3
|
-
import { memo, useEffect } from 'react';
|
|
4
|
-
import { useStore } from 'zustand/react';
|
|
5
|
-
import { state } from '../state.js';
|
|
6
|
-
import { LOGO_IMAGE } from '../constants.js';
|
|
7
|
-
const ComponentHarness = memo(function ComponentHarness({ element, options, }) {
|
|
8
|
-
const Wrapper = options.wrapper ?? View;
|
|
9
|
-
return (_jsx(View, { style: { flex: 1, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Wrapper, { children: element }) }));
|
|
10
|
-
});
|
|
11
|
-
export const UI = () => {
|
|
12
|
-
const { componentHarness, status, bootstrap } = useStore(state);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
void bootstrap();
|
|
15
|
-
}, [bootstrap]);
|
|
16
|
-
if (componentHarness) {
|
|
17
|
-
return (_jsx(ComponentHarness, { element: componentHarness.node, options: componentHarness.options }));
|
|
18
|
-
}
|
|
19
|
-
return (_jsx(View, { style: styles.container, children: _jsxs(View, { style: styles.contentContainer, children: [_jsx(View, { style: styles.logoContainer, children: _jsx(Image, { style: styles.logo, source: LOGO_IMAGE }) }), _jsx(Text, { style: styles.title, children: "React Native Harness" }), status === 'idle' ? (_jsxs(View, { style: styles.statusIndicator, children: [_jsx(View, { style: styles.statusDot }), _jsx(Text, { style: styles.statusText, children: "Idle" })] })) : status === 'loading' ? (_jsxs(View, { style: styles.loadingContainer, children: [_jsx(ActivityIndicator, { size: "small", color: "#3b82f6", style: styles.loadingSpinner }), _jsx(Text, { style: styles.loadingText, children: "Loading..." })] })) : (_jsxs(View, { style: styles.statusIndicator, children: [_jsx(View, { style: styles.statusDot }), _jsx(Text, { style: styles.statusText, children: "Running..." })] }))] }) }));
|
|
20
|
-
};
|
|
21
|
-
const styles = StyleSheet.create({
|
|
22
|
-
container: {
|
|
23
|
-
flex: 1,
|
|
24
|
-
justifyContent: 'center',
|
|
25
|
-
alignItems: 'center',
|
|
26
|
-
backgroundColor: '#0a1628',
|
|
27
|
-
position: 'relative',
|
|
28
|
-
},
|
|
29
|
-
safeArea: {
|
|
30
|
-
flex: 1,
|
|
31
|
-
backgroundColor: 'transparent',
|
|
32
|
-
paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,
|
|
33
|
-
},
|
|
34
|
-
contentContainer: {
|
|
35
|
-
alignItems: 'center',
|
|
36
|
-
padding: 24,
|
|
37
|
-
borderRadius: 24,
|
|
38
|
-
backgroundColor: 'rgba(59, 130, 246, 0.1)',
|
|
39
|
-
borderWidth: 1,
|
|
40
|
-
borderColor: 'rgba(59, 130, 246, 0.2)',
|
|
41
|
-
shadowColor: '#000',
|
|
42
|
-
shadowOffset: {
|
|
43
|
-
width: 0,
|
|
44
|
-
height: 20,
|
|
45
|
-
},
|
|
46
|
-
shadowOpacity: 0.3,
|
|
47
|
-
shadowRadius: 30,
|
|
48
|
-
},
|
|
49
|
-
logoContainer: {
|
|
50
|
-
marginBottom: 12,
|
|
51
|
-
},
|
|
52
|
-
logo: {
|
|
53
|
-
width: 128,
|
|
54
|
-
height: 128,
|
|
55
|
-
},
|
|
56
|
-
title: {
|
|
57
|
-
fontSize: 28,
|
|
58
|
-
fontWeight: '700',
|
|
59
|
-
color: '#38bdf8',
|
|
60
|
-
textAlign: 'center',
|
|
61
|
-
letterSpacing: 1,
|
|
62
|
-
marginBottom: 8,
|
|
63
|
-
},
|
|
64
|
-
subtitle: {
|
|
65
|
-
fontSize: 16,
|
|
66
|
-
fontWeight: '400',
|
|
67
|
-
color: 'rgba(255, 255, 255, 0.7)',
|
|
68
|
-
textAlign: 'center',
|
|
69
|
-
letterSpacing: 0.5,
|
|
70
|
-
marginBottom: 24,
|
|
71
|
-
},
|
|
72
|
-
statusIndicator: {
|
|
73
|
-
flexDirection: 'row',
|
|
74
|
-
alignItems: 'center',
|
|
75
|
-
backgroundColor: 'rgba(34, 211, 238, 0.15)',
|
|
76
|
-
paddingHorizontal: 16,
|
|
77
|
-
paddingVertical: 8,
|
|
78
|
-
height: 36,
|
|
79
|
-
borderRadius: 20,
|
|
80
|
-
borderWidth: 1,
|
|
81
|
-
borderColor: 'rgba(34, 211, 238, 0.4)',
|
|
82
|
-
},
|
|
83
|
-
statusDot: {
|
|
84
|
-
width: 8,
|
|
85
|
-
height: 8,
|
|
86
|
-
borderRadius: 4,
|
|
87
|
-
backgroundColor: '#22d3ee',
|
|
88
|
-
marginRight: 8,
|
|
89
|
-
shadowColor: '#22d3ee',
|
|
90
|
-
shadowOffset: { width: 0, height: 0 },
|
|
91
|
-
shadowOpacity: 0.8,
|
|
92
|
-
shadowRadius: 4,
|
|
93
|
-
},
|
|
94
|
-
statusText: {
|
|
95
|
-
fontSize: 14,
|
|
96
|
-
fontWeight: '500',
|
|
97
|
-
color: '#22d3ee',
|
|
98
|
-
letterSpacing: 0.5,
|
|
99
|
-
},
|
|
100
|
-
loadingContainer: {
|
|
101
|
-
flexDirection: 'row',
|
|
102
|
-
alignItems: 'center',
|
|
103
|
-
backgroundColor: 'rgba(59, 130, 246, 0.15)',
|
|
104
|
-
paddingHorizontal: 16,
|
|
105
|
-
paddingVertical: 8,
|
|
106
|
-
height: 36,
|
|
107
|
-
borderRadius: 20,
|
|
108
|
-
borderWidth: 1,
|
|
109
|
-
borderColor: 'rgba(59, 130, 246, 0.4)',
|
|
110
|
-
},
|
|
111
|
-
loadingSpinner: {
|
|
112
|
-
marginRight: 8,
|
|
113
|
-
},
|
|
114
|
-
loadingText: {
|
|
115
|
-
fontSize: 14,
|
|
116
|
-
fontWeight: '500',
|
|
117
|
-
color: '#3b82f6',
|
|
118
|
-
letterSpacing: 0.5,
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
export default UI;
|