create-octane-xplat 0.18.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 -144
- package/compatibility.json +97 -19
- package/compatibility.ts +141 -72
- package/dist/compatibility.js +66 -26
- package/dist/index.js +127 -64
- package/dist/package-manager.js +62 -0
- package/dist/scaffold.js +377 -127
- package/index.ts +256 -154
- package/library-template/AGENTS.md +6 -4
- package/library-template/README.md +22 -18
- package/library-template/bunfig +4 -0
- package/library-template/package.json +115 -18
- package/library-template/patches/@nativescript-community__octane@0.2.5.patch +1018 -0
- package/library-template/patches/@nativescript-community__sqlite-bridge@4.1.1.patch +30 -0
- package/library-template/patches/@nativescript-community__vite-octane@0.2.1.patch +72 -0
- package/library-template/patches/@nativescript__core@9.1.3.patch +1280 -0
- package/library-template/patches/@nativescript__doctor@2.0.18.patch +13 -0
- package/library-template/patches/@nativescript__vite@8.0.20.patch +2019 -0
- package/library-template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
- package/library-template/patches/@octanejs__tiptap@0.0.62.patch +12 -0
- package/library-template/patches/@sveltejs__acorn-typescript@1.0.13.patch +16 -0
- package/library-template/patches/css@3.0.0.patch +52 -0
- package/library-template/patches/octane@0.16.3.patch +1479 -0
- package/library-template/src/Badge.tsx +7 -6
- package/library-template/src/Badge.web.tsx +7 -6
- 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 +70 -58
- package/scaffold.ts +1056 -526
- package/template/.agents/skills/xplat/SKILL.md +6 -6
- package/template/.agents/skills/xplat/references/components.md +1 -1
- package/template/.agents/skills/xplat/references/navigation.md +1 -1
- package/template/.agents/skills/xplat/references/styling.md +14 -14
- package/template/AGENTS.md +10 -10
- package/template/bunfig +4 -0
- package/template/gitignore +1 -0
- package/template/nativescript.config.ts +13 -16
- package/template/package.json +119 -10
- package/template/patches/@nativescript-community__octane@0.2.5.patch +1018 -0
- package/template/patches/@nativescript-community__sqlite-bridge@4.1.1.patch +30 -0
- package/template/patches/@nativescript-community__vite-octane@0.2.1.patch +72 -0
- package/template/patches/@nativescript__core@9.1.3.patch +1280 -0
- package/template/patches/@nativescript__doctor@2.0.18.patch +13 -0
- package/template/patches/@nativescript__vite@8.0.20.patch +2019 -0
- package/template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
- package/template/patches/@octanejs__tiptap@0.0.62.patch +12 -0
- package/template/patches/@sveltejs__acorn-typescript@1.0.13.patch +16 -0
- package/template/patches/css@3.0.0.patch +52 -0
- package/template/patches/octane@0.16.3.patch +1479 -0
- package/template/src/App.tsrx +77 -42
- package/template/src/Welcome.stories.tsx +22 -0
- package/template/src/app.spec.tsrx +169 -163
- 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/main.web.tsrx +5 -5
- 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 +18 -18
- package/template/vitest.web.config.mts +7 -7
- package/template/workshop.config.ts +3 -0
- package/library-template/pnpm-workspace.yaml +0 -171
- package/template/pnpm-workspace.yaml +0 -192
package/template/src/App.tsrx
CHANGED
|
@@ -1,50 +1,85 @@
|
|
|
1
|
-
import { useState } from 'octane'
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { useState } from 'octane'
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
HStack,
|
|
5
|
+
Text,
|
|
6
|
+
Pressable,
|
|
7
|
+
ScrollableArea,
|
|
8
|
+
SafeArea,
|
|
9
|
+
useColorScheme,
|
|
10
|
+
} from '@octane-xplat/ui'
|
|
11
|
+
|
|
12
|
+
import { storage } from '@octane-xplat/platform'
|
|
4
13
|
|
|
5
14
|
const FEATURES = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
]
|
|
15
|
+
'shared components',
|
|
16
|
+
'platform leaves (.web / .mobile)',
|
|
17
|
+
'design tokens + dark mode',
|
|
18
|
+
'native navigation',
|
|
19
|
+
]
|
|
11
20
|
|
|
12
21
|
/** Every element here compiles for web AND for NativeScript iOS/Android —
|
|
13
22
|
* the same file, no branches. Platform divergence lives in leaf files
|
|
14
23
|
* (.web.tsrx / .mobile.tsrx), never inside a component. */
|
|
15
24
|
export function App() @{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
25
|
+
const [count, setCount] = useState(0)
|
|
26
|
+
// null = follow the system until the user chooses a mode.
|
|
27
|
+
const [override, setOverride] = useState<boolean | null>(() => {
|
|
28
|
+
const saved = storage.getString('theme-preference')
|
|
29
|
+
|
|
30
|
+
return saved === 'light' ? false : saved === 'dark' ? true : null
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const scheme = useColorScheme()
|
|
34
|
+
const dark = override ?? scheme === 'dark'
|
|
35
|
+
|
|
36
|
+
<SafeArea>
|
|
37
|
+
<View className={['app', dark ? 'dark' : 'light']}>
|
|
38
|
+
<Text className="title">octane-xplat</Text>
|
|
39
|
+
<Text className="muted">one codebase — web · iOS · android</Text>
|
|
40
|
+
|
|
41
|
+
<HStack className="counter">
|
|
42
|
+
<Pressable
|
|
43
|
+
testID="counter.decrement"
|
|
44
|
+
accessibilityLabel="Decrease count"
|
|
45
|
+
className="btn"
|
|
46
|
+
onPress={() => setCount(count - 1)}
|
|
47
|
+
>
|
|
48
|
+
<Text>−</Text>
|
|
49
|
+
</Pressable>
|
|
50
|
+
<Text testID="counter.value" className="count">
|
|
51
|
+
{count}
|
|
52
|
+
</Text>
|
|
53
|
+
<Pressable
|
|
54
|
+
testID="counter.increment"
|
|
55
|
+
accessibilityLabel="Increase count"
|
|
56
|
+
className="btn"
|
|
57
|
+
onPress={() => setCount(count + 1)}
|
|
58
|
+
>
|
|
59
|
+
<Text>+</Text>
|
|
60
|
+
</Pressable>
|
|
61
|
+
</HStack>
|
|
62
|
+
|
|
63
|
+
<ScrollableArea>
|
|
64
|
+
{FEATURES.map((f) => (
|
|
65
|
+
<Text className="chip">{f}</Text>
|
|
66
|
+
))}
|
|
67
|
+
</ScrollableArea>
|
|
68
|
+
|
|
69
|
+
<Pressable
|
|
70
|
+
testID="settings.toggle-theme"
|
|
71
|
+
className="link"
|
|
72
|
+
onPress={() => {
|
|
73
|
+
const next = !dark
|
|
74
|
+
|
|
75
|
+
storage.setString('theme-preference', next ? 'dark' : 'light')
|
|
76
|
+
setOverride(next)
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<Text>
|
|
80
|
+
{dark ? 'light' : 'dark'} mode (system: {scheme})
|
|
81
|
+
</Text>
|
|
82
|
+
</Pressable>
|
|
83
|
+
</View>
|
|
84
|
+
</SafeArea>
|
|
50
85
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useState } from 'octane'
|
|
2
|
+
import { Pressable, Text } from '@octane-xplat/ui'
|
|
3
|
+
import { defineStory } from '@octane-xplat/workshop'
|
|
4
|
+
|
|
5
|
+
function Welcome() {
|
|
6
|
+
const [count, setCount] = useState(0)
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Pressable onPress={() => setCount(count + 1)}>
|
|
10
|
+
<Text>Hello from Workshop: {count}</Text>
|
|
11
|
+
</Pressable>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const Basic = defineStory({
|
|
16
|
+
id: 'welcome/basic',
|
|
17
|
+
title: 'Welcome / Basic',
|
|
18
|
+
componentId: 'app/Welcome',
|
|
19
|
+
targets: 'all',
|
|
20
|
+
component: Welcome,
|
|
21
|
+
args: {},
|
|
22
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Starter spec — `
|
|
1
|
+
// Starter spec — `bun run test:ios` / `bun run test:android` run in the real mobile runtime
|
|
2
2
|
// (same renderer, native views, and services your app uses).
|
|
3
3
|
//
|
|
4
4
|
// mountXplat() renders a component onto the test host page and unmounts it
|
|
@@ -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,111 +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
|
-
|
|
36
|
-
<Pressable testID="greeting.reset" onPress={() => setName('Bob')}>
|
|
37
|
-
<Text>set bob</Text>
|
|
38
|
-
</Pressable>
|
|
39
|
-
<Text>{'greeting: ' + (name || 'stranger')}</Text>
|
|
40
|
-
</View>
|
|
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>
|
|
41
36
|
}
|
|
42
37
|
|
|
43
38
|
// Conditional mount — a subtree exists only while its state says so.
|
|
44
39
|
function Details() @{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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>
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
// Async states — loading first, then a settled value or an error. The
|
|
58
53
|
// cleanup flag keeps a late timer from writing into an unmounted tree.
|
|
59
54
|
function FetchLabel(props: { fail?: boolean }) @{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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>
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
describe('starter app on device', () => {
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
+
})
|
|
132
135
|
})
|
|
133
136
|
|
|
134
137
|
// Observable cleanup contracts: every effect subscribe must pair with a
|
|
@@ -138,73 +141,76 @@ let activeEffects = 0
|
|
|
138
141
|
let ticks = 0
|
|
139
142
|
|
|
140
143
|
function IntervalCounter() @{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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>
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
const listeners = new Set<() => void>()
|
|
157
161
|
|
|
158
162
|
function StoreReader() @{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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>
|
|
170
174
|
}
|
|
171
175
|
|
|
172
176
|
describe('mount/unmount cleanup', () => {
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
+
})
|
|
210
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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsxImportSource @octane-xplat/jsx/dom */
|
|
2
|
-
import { createRoot } from 'octane'
|
|
3
|
-
import { App } from './App.tsrx'
|
|
4
|
-
import '@octane-xplat/ui/theme/tokens.css'
|
|
5
|
-
import './style.css'
|
|
2
|
+
import { createRoot } from 'octane'
|
|
3
|
+
import { App } from './App.tsrx'
|
|
4
|
+
import '@octane-xplat/ui/theme/tokens.css'
|
|
5
|
+
import './style.css'
|
|
6
6
|
|
|
7
|
-
createRoot(document.getElementById('root')!).render(<App />)
|
|
7
|
+
createRoot(document.getElementById('root')!).render(<App />)
|