create-octane-xplat 0.19.0 → 0.20.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.
- package/README.md +2 -147
- package/compatibility.json +74 -61
- package/compatibility.ts +134 -79
- package/dist/compatibility.js +45 -13
- package/dist/index.js +127 -64
- package/dist/package-manager.js +62 -0
- package/dist/scaffold.js +362 -57
- package/index.ts +256 -156
- package/library-template/AGENTS.md +1 -1
- package/library-template/README.md +4 -3
- package/library-template/bunfig +4 -0
- package/library-template/package.json +73 -70
- package/library-template/patches/@nativescript-community__octane@0.2.5.patch +161 -24
- package/library-template/patches/@nativescript__core@9.1.3.patch +98 -0
- package/library-template/patches/@nativescript__vite@8.0.20.patch +532 -17
- package/library-template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
- package/library-template/patches/octane@0.16.3.patch +56 -2
- package/library-template/src/Badge.tsx +5 -5
- package/library-template/src/Badge.web.tsx +5 -5
- package/library-template/src/Welcome.stories.tsx +12 -0
- package/library-template/src/normalizeBadgeLabel.ts +1 -1
- package/library-template/src/props.ts +11 -11
- package/library-template/tests/normalizeBadgeLabel.test.ts +1 -1
- package/library-template/tests/packed-consumer.mjs +140 -123
- package/library-template/tsconfig.envs.json +1 -0
- package/library-template/tsconfig.json +1 -0
- package/library-template/tsconfig.types.json +15 -1
- package/library-template/tsrx-typegen.json +1 -1
- package/library-template/workshop.config.ts +3 -0
- package/package-manager.ts +93 -0
- package/package.json +10 -5
- package/scaffold.ts +1061 -449
- package/template/.agents/skills/xplat/SKILL.md +1 -1
- package/template/.agents/skills/xplat/references/styling.md +10 -10
- package/template/AGENTS.md +2 -2
- package/template/bunfig +4 -0
- package/template/nativescript.config.ts +13 -13
- package/template/package.json +69 -64
- package/template/patches/@nativescript-community__octane@0.2.5.patch +161 -24
- package/template/patches/@nativescript__core@9.1.3.patch +98 -0
- package/template/patches/@nativescript__vite@8.0.20.patch +532 -17
- package/template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
- package/template/patches/octane@0.16.3.patch +56 -2
- package/template/src/App.tsrx +66 -64
- package/template/src/Welcome.stories.tsx +22 -0
- package/template/src/app.spec.tsrx +168 -158
- package/template/src/app.web.test.tsx +18 -13
- package/template/src/failure-reporting.spec.ts +3 -3
- package/template/src/main.ts +14 -13
- package/template/src/main.tsrx +2 -0
- package/template/src/native-runtime.spec.ts +13 -11
- package/template/src/test-setup.web.ts +9 -8
- package/template/src/test.ts +6 -6
- package/template/tsconfig.json +17 -1
- package/template/vite.config.native.mts +1 -2
- package/template/vite.config.ts +29 -23
- package/template/vitest.config.mts +17 -17
- package/template/vitest.web.config.mts +7 -7
- package/template/workshop.config.ts +3 -0
- package/library-template/patches/@tsrx__typescript-plugin@0.4.11.patch +0 -11
- package/template/patches/@tsrx__typescript-plugin@0.4.11.patch +0 -11
- /package/library-template/patches/{@octanejs__tiptap@0.0.61.patch → @octanejs__tiptap@0.0.62.patch} +0 -0
- /package/template/patches/{@octanejs__tiptap@0.0.61.patch → @octanejs__tiptap@0.0.62.patch} +0 -0
|
@@ -9,14 +9,14 @@ import { describe, expect, it } from 'vitest'
|
|
|
9
9
|
import { useEffect, useState, useSyncExternalStore } from 'octane'
|
|
10
10
|
import { Pressable, Text, TextInput, View } from '@octane-xplat/ui'
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
type TextInputView,
|
|
13
|
+
enterText,
|
|
14
|
+
findByTestId,
|
|
15
|
+
mountXplat,
|
|
16
|
+
nextRenderPass,
|
|
17
|
+
tap,
|
|
18
|
+
viewText,
|
|
19
|
+
waitUntil,
|
|
20
20
|
} from '@octane-xplat/platform/testing'
|
|
21
21
|
|
|
22
22
|
import { App } from './App.tsrx'
|
|
@@ -24,108 +24,114 @@ import { App } from './App.tsrx'
|
|
|
24
24
|
// Controlled input — typing flows up through onChange and back down as the
|
|
25
25
|
// rendered value, and parent writes reach the native field.
|
|
26
26
|
function NameForm() @{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
const [name, setName] = useState('')
|
|
28
|
+
|
|
29
|
+
<View>
|
|
30
|
+
<TextInput testID="greeting.name" value={name} onChange={setName} placeholder="Your name" />
|
|
31
|
+
<Pressable testID="greeting.reset" onPress={() => setName('Bob')}>
|
|
32
|
+
<Text>set bob</Text>
|
|
33
|
+
</Pressable>
|
|
34
|
+
<Text>{'greeting: ' + (name || 'stranger')}</Text>
|
|
35
|
+
</View>
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// Conditional mount — a subtree exists only while its state says so.
|
|
39
39
|
function Details() @{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
const [open, setOpen] = useState(false)
|
|
41
|
+
|
|
42
|
+
<View>
|
|
43
|
+
<Pressable testID="details.toggle" onPress={() => setOpen(!open)}>
|
|
44
|
+
<Text>toggle</Text>
|
|
45
|
+
</Pressable>
|
|
46
|
+
@if (open) {
|
|
47
|
+
<Text>detail: open</Text>
|
|
48
|
+
}
|
|
49
|
+
</View>
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// Async states — loading first, then a settled value or an error. The
|
|
53
53
|
// cleanup flag keeps a late timer from writing into an unmounted tree.
|
|
54
54
|
function FetchLabel(props: { fail?: boolean }) @{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
const [state, setState] = useState('loading')
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
let live = true
|
|
59
|
+
const timer = setTimeout(() => {
|
|
60
|
+
if (live) {
|
|
61
|
+
setState(props.fail ? 'error' : 'ready')
|
|
62
|
+
}
|
|
63
|
+
}, 30)
|
|
64
|
+
|
|
65
|
+
return () => {
|
|
66
|
+
live = false
|
|
67
|
+
clearTimeout(timer)
|
|
68
|
+
}
|
|
69
|
+
}, [])
|
|
70
|
+
|
|
71
|
+
<Text>{'fetch: ' + state}</Text>
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
describe('starter app on device', () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
75
|
+
it('mounts, reacts to a tap, and unmounts cleanly', async () => {
|
|
76
|
+
const { view, host, unmount } = await mountXplat(App)
|
|
77
|
+
|
|
78
|
+
const increment = findByTestId(view, 'counter.increment')
|
|
79
|
+
const count = findByTestId<TextInputView>(view, 'counter.value')
|
|
80
|
+
|
|
81
|
+
expect(increment?.isLoaded, 'counter.increment resolves to a loaded native view').toBe(true)
|
|
82
|
+
|
|
83
|
+
await tap(increment!)
|
|
84
|
+
await waitUntil(() => count?.text === '1', {
|
|
85
|
+
message: 'tap did not reach the increment Pressable',
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
await unmount()
|
|
89
|
+
await nextRenderPass()
|
|
90
|
+
expect(host.content).toBe(null)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('round-trips a controlled TextInput', async () => {
|
|
94
|
+
const { view } = await mountXplat(NameForm)
|
|
95
|
+
const field = findByTestId<TextInputView>(view, 'greeting.name')
|
|
96
|
+
|
|
97
|
+
expect(field?.isLoaded).toBe(true)
|
|
98
|
+
|
|
99
|
+
await enterText(field!, 'Ada')
|
|
100
|
+
await waitUntil(() => viewText(view).includes('greeting: Ada'), {
|
|
101
|
+
message: 'onChange did not deliver the typed text',
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
await tap(findByTestId(view, 'greeting.reset')!)
|
|
105
|
+
await waitUntil(() => field?.text === 'Bob', {
|
|
106
|
+
message: 'parent write did not reach the native field',
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('mounts and unmounts a conditional subtree', async () => {
|
|
111
|
+
const { view } = await mountXplat(Details)
|
|
112
|
+
|
|
113
|
+
expect(viewText(view).includes('detail: open')).toBe(false)
|
|
114
|
+
|
|
115
|
+
await tap(findByTestId(view, 'details.toggle')!)
|
|
116
|
+
await waitUntil(() => viewText(view).includes('detail: open'))
|
|
117
|
+
|
|
118
|
+
await tap(findByTestId(view, 'details.toggle')!)
|
|
119
|
+
await waitUntil(() => !viewText(view).includes('detail: open'))
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('settles async loading and error states', async () => {
|
|
123
|
+
const ready = await mountXplat(FetchLabel)
|
|
124
|
+
|
|
125
|
+
await waitUntil(() => viewText(ready.view).includes('fetch: ready'), {
|
|
126
|
+
message: 'loading state never settled',
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
const failed = await mountXplat(FetchLabel, { fail: true })
|
|
130
|
+
|
|
131
|
+
await waitUntil(() => viewText(failed.view).includes('fetch: error'), {
|
|
132
|
+
message: 'error state never surfaced',
|
|
133
|
+
})
|
|
134
|
+
})
|
|
129
135
|
})
|
|
130
136
|
|
|
131
137
|
// Observable cleanup contracts: every effect subscribe must pair with a
|
|
@@ -135,72 +141,76 @@ let activeEffects = 0
|
|
|
135
141
|
let ticks = 0
|
|
136
142
|
|
|
137
143
|
function IntervalCounter() @{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
activeEffects += 1
|
|
146
|
+
|
|
147
|
+
const timer = setInterval(() => {
|
|
148
|
+
ticks += 1
|
|
149
|
+
}, 15)
|
|
150
|
+
|
|
151
|
+
return () => {
|
|
152
|
+
activeEffects -= 1
|
|
153
|
+
clearInterval(timer)
|
|
154
|
+
}
|
|
155
|
+
}, [])
|
|
156
|
+
|
|
157
|
+
<Text>interval</Text>
|
|
151
158
|
}
|
|
152
159
|
|
|
153
160
|
const listeners = new Set<() => void>()
|
|
154
161
|
|
|
155
162
|
function StoreReader() @{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
const count = useSyncExternalStore(
|
|
164
|
+
(callback) => {
|
|
165
|
+
listeners.add(callback)
|
|
166
|
+
return () => {
|
|
167
|
+
listeners.delete(callback)
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
() => listeners.size,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
<Text>{'subs: ' + count}</Text>
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
describe('mount/unmount cleanup', () => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
177
|
+
it('runs effect cleanups and stops delayed work at unmount', async () => {
|
|
178
|
+
ticks = 0
|
|
179
|
+
for (let i = 0; i < 3; i++) {
|
|
180
|
+
const { unmount } = await mountXplat(IntervalCounter)
|
|
181
|
+
|
|
182
|
+
expect(activeEffects, 'each mount subscribes exactly once').toBe(1)
|
|
183
|
+
await unmount()
|
|
184
|
+
expect(activeEffects, 'unmount runs the effect cleanup').toBe(0)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// The cleared interval must not fire after the last unmount.
|
|
188
|
+
const settled = ticks
|
|
189
|
+
|
|
190
|
+
await new Promise((resolve) => setTimeout(resolve, 60))
|
|
191
|
+
expect(ticks, 'interval work continued after unmount').toBe(settled)
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
it('releases external-store subscriptions at unmount', async () => {
|
|
195
|
+
for (let i = 0; i < 3; i++) {
|
|
196
|
+
const { unmount } = await mountXplat(StoreReader)
|
|
197
|
+
|
|
198
|
+
expect(listeners.size, 'each mount subscribes exactly once').toBe(1)
|
|
199
|
+
await unmount()
|
|
200
|
+
expect(listeners.size, 'unmount releases the subscription').toBe(0)
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('re-mounting replaces the previous root instead of leaking it', async () => {
|
|
205
|
+
await mountXplat(IntervalCounter)
|
|
206
|
+
expect(activeEffects).toBe(1)
|
|
207
|
+
// mountXplat drops the previous root — its cleanup must already have run.
|
|
208
|
+
await mountXplat(IntervalCounter)
|
|
209
|
+
expect(activeEffects, 'previous root stayed subscribed after re-mount').toBe(1)
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('finishes automatic cleanup before the next case', () => {
|
|
213
|
+
expect(activeEffects).toBe(0)
|
|
214
|
+
expect(listeners.size).toBe(0)
|
|
215
|
+
})
|
|
206
216
|
})
|
|
@@ -4,17 +4,22 @@ import { createRoot } from 'octane'
|
|
|
4
4
|
import { App } from './App.tsrx'
|
|
5
5
|
|
|
6
6
|
it('updates the counter when its button is pressed', async () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const container = document.createElement('div')
|
|
8
|
+
|
|
9
|
+
document.body.append(container)
|
|
10
|
+
|
|
11
|
+
const root = createRoot(container)
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
root.render(<App />)
|
|
15
|
+
|
|
16
|
+
const value = () => container.querySelector('[data-testid="counter.value"]')?.textContent
|
|
17
|
+
|
|
18
|
+
await vi.waitFor(() => expect(value()).toBe('0'))
|
|
19
|
+
container.querySelector<HTMLElement>('[data-testid="counter.increment"]')!.click()
|
|
20
|
+
await vi.waitFor(() => expect(value()).toBe('1'))
|
|
21
|
+
} finally {
|
|
22
|
+
root.unmount()
|
|
23
|
+
container.remove()
|
|
24
|
+
}
|
|
20
25
|
})
|
|
@@ -5,7 +5,7 @@ import { describe, expect, it } from 'vitest'
|
|
|
5
5
|
// real Vitest failures (it.fails inverts the outcome, keeping the committed
|
|
6
6
|
// suite green while pinning the failure-reporting path).
|
|
7
7
|
describe('failure reporting', () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
it.fails('a failed assertion on device is reported as a failure', () => {
|
|
9
|
+
expect('octane-xplat').toBe('a different string entirely')
|
|
10
|
+
})
|
|
11
11
|
})
|
package/template/src/main.ts
CHANGED
|
@@ -8,17 +8,18 @@ import '@octane-xplat/ui/theme/tokens.css'
|
|
|
8
8
|
import './style.css'
|
|
9
9
|
|
|
10
10
|
const entry = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
create: () => {
|
|
12
|
+
// A Frame hosts the root Page. RouteOutlet binds canonical routing
|
|
13
|
+
// to this Frame when the app adds generated routes.
|
|
14
|
+
const frame = new Frame()
|
|
15
|
+
// Full-screen page: SafeArea owns safe-area padding.
|
|
16
|
+
const page = prepareFullScreenPage(new Page())
|
|
17
|
+
|
|
18
|
+
page.actionBarHidden = true
|
|
19
|
+
renderNativeScriptApp(page, App)
|
|
20
|
+
frame.navigate({ create: () => page })
|
|
21
|
+
return frame
|
|
22
|
+
},
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
// Under the vite dev session the placeholder bootstrap has already run
|
|
@@ -27,7 +28,7 @@ const entry = {
|
|
|
27
28
|
// (iOS core handles the placeholder handoff internally); resetRootView is
|
|
28
29
|
// the documented way to swap the root of a running app.
|
|
29
30
|
if (Application.started) {
|
|
30
|
-
|
|
31
|
+
Application.resetRootView(entry)
|
|
31
32
|
} else {
|
|
32
|
-
|
|
33
|
+
Application.run(entry)
|
|
33
34
|
}
|
|
@@ -4,15 +4,17 @@ import { Device, isAndroid, isIOS, knownFolders } from '@nativescript/core'
|
|
|
4
4
|
// This executes NativeScript's filesystem bridge in the actual mobile host.
|
|
5
5
|
// Only this test's uniquely named temporary file is written and removed.
|
|
6
6
|
describe('native runtime', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
it('round-trips a file through the native bridge', () => {
|
|
8
|
+
expect(isAndroid || isIOS).toBe(true)
|
|
9
|
+
expect(Device.os).toBe(isAndroid ? 'Android' : 'iOS')
|
|
10
|
+
|
|
11
|
+
const file = knownFolders.temp().getFile(`xplat-native-test-${Date.now()}.txt`)
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
file.writeTextSync('octane-xplat')
|
|
15
|
+
expect(file.readTextSync()).toBe('octane-xplat')
|
|
16
|
+
} finally {
|
|
17
|
+
file.removeSync()
|
|
18
|
+
}
|
|
19
|
+
})
|
|
18
20
|
})
|
|
@@ -2,16 +2,17 @@ import { vi } from 'vitest'
|
|
|
2
2
|
|
|
3
3
|
// jsdom has no system color-scheme producer. Keep component tests in light mode.
|
|
4
4
|
globalThis.matchMedia ??= (query: string) => ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
media: query,
|
|
6
|
+
matches: false,
|
|
7
|
+
onchange: null,
|
|
8
|
+
addListener() {},
|
|
9
|
+
removeListener() {},
|
|
10
|
+
addEventListener() {},
|
|
11
|
+
removeEventListener() {},
|
|
12
|
+
dispatchEvent: () => true,
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
// Node 26 also exposes a host localStorage getter. Use jsdom's window storage.
|
|
16
16
|
declare const jsdom: { window: Window }
|
|
17
|
+
|
|
17
18
|
vi.stubGlobal('localStorage', jsdom.window.localStorage)
|
package/template/src/test.ts
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
import '@valor/nativescript-websockets'
|
|
5
5
|
import { Application } from '@nativescript/core'
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
NativeScriptVitestCoordinator,
|
|
8
|
+
createNativeScriptTestRegistry,
|
|
9
9
|
} from '@nativescript/unit-test-runner/runtime'
|
|
10
10
|
|
|
11
11
|
import { createVitestHostPage } from '@nativescript/unit-test-runner/testing'
|
|
12
12
|
|
|
13
13
|
const coordinator = new NativeScriptVitestCoordinator({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
// Every spec matched by vitest.config.mts `include` must also match this
|
|
15
|
+
// glob — vite statically bundles each as a lazily imported chunk that the
|
|
16
|
+
// registry loads on demand.
|
|
17
|
+
registry: createNativeScriptTestRegistry(import.meta.glob('./**/*.spec.{ts,tsx,tsrx}')),
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
void coordinator.start()
|
package/template/tsconfig.json
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
+
"contentMappers": [
|
|
3
|
+
{
|
|
4
|
+
"package": "octane-xplat",
|
|
5
|
+
"extensions": [
|
|
6
|
+
".tsrx"
|
|
7
|
+
]
|
|
8
|
+
}
|
|
9
|
+
],
|
|
2
10
|
"compilerOptions": {
|
|
3
11
|
"strict": true,
|
|
4
12
|
"target": "ESNext",
|
|
@@ -28,7 +36,15 @@
|
|
|
28
36
|
],
|
|
29
37
|
"noEmit": true,
|
|
30
38
|
"skipLibCheck": true,
|
|
31
|
-
"allowImportingTsExtensions": true
|
|
39
|
+
"allowImportingTsExtensions": true,
|
|
40
|
+
"paths": {
|
|
41
|
+
"@nativescript/core": [
|
|
42
|
+
"./node_modules/@nativescript/core"
|
|
43
|
+
],
|
|
44
|
+
"@nativescript/core/*": [
|
|
45
|
+
"./node_modules/@nativescript/core/*"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
32
48
|
},
|
|
33
49
|
"include": [
|
|
34
50
|
"src/**/*"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { defineConfig } from 'vite'
|
|
2
|
-
import { xplatNative } from '@octane-xplat/cli/vite'
|
|
1
|
+
import { defineConfig, xplatNative } from 'octane-xplat/vite'
|
|
3
2
|
|
|
4
3
|
// The shared preset owns the renderer rules, octane→universal/native alias,
|
|
5
4
|
// suffix extension chain, deps-bundle plugin exclusions, the HMR watchdog,
|
package/template/vite.config.ts
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
defineConfig,
|
|
3
|
+
octane,
|
|
4
|
+
xplatCss,
|
|
5
|
+
xplatBoundary,
|
|
6
|
+
xplatDevBridge,
|
|
7
|
+
xplatNodeEnvDefine,
|
|
8
|
+
} from 'octane-xplat/vite'
|
|
4
9
|
|
|
5
10
|
// The web build. For native (iOS/Android), the same source runs through
|
|
6
11
|
// @nativescript-community/vite-octane with `conditions: ['native']`, the
|
|
7
12
|
// .ios/.android/.mobile suffix chain, and the unsuffixed native default — see
|
|
8
13
|
// the octane-xplat repo's apps/mobile/vite.config.mts.
|
|
9
14
|
export default defineConfig(({ mode }) => ({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
plugins: [xplatCss('web'), ...octane(), xplatBoundary('web'), xplatDevBridge()],
|
|
16
|
+
define: xplatNodeEnvDefine(mode),
|
|
17
|
+
server: { port: 5200 },
|
|
18
|
+
resolve: {
|
|
19
|
+
conditions: ['web'],
|
|
20
|
+
// Suffix chain (first match wins): .web → shared → fallback.
|
|
21
|
+
// xplatBoundary also uses this order for dependency optimization in dev.
|
|
22
|
+
extensions: [
|
|
23
|
+
'.web.tsrx',
|
|
24
|
+
'.tsrx',
|
|
25
|
+
'.web.tsx',
|
|
26
|
+
'.tsx',
|
|
27
|
+
'.web.ts',
|
|
28
|
+
'.mjs',
|
|
29
|
+
'.mts',
|
|
30
|
+
'.ts',
|
|
31
|
+
'.jsx',
|
|
32
|
+
'.js',
|
|
33
|
+
'.json',
|
|
34
|
+
],
|
|
35
|
+
},
|
|
30
36
|
}))
|