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.
Files changed (63) hide show
  1. package/README.md +2 -147
  2. package/compatibility.json +74 -61
  3. package/compatibility.ts +134 -79
  4. package/dist/compatibility.js +45 -13
  5. package/dist/index.js +127 -64
  6. package/dist/package-manager.js +62 -0
  7. package/dist/scaffold.js +362 -57
  8. package/index.ts +256 -156
  9. package/library-template/AGENTS.md +1 -1
  10. package/library-template/README.md +4 -3
  11. package/library-template/bunfig +4 -0
  12. package/library-template/package.json +73 -70
  13. package/library-template/patches/@nativescript-community__octane@0.2.5.patch +161 -24
  14. package/library-template/patches/@nativescript__core@9.1.3.patch +98 -0
  15. package/library-template/patches/@nativescript__vite@8.0.20.patch +532 -17
  16. package/library-template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
  17. package/library-template/patches/octane@0.16.3.patch +56 -2
  18. package/library-template/src/Badge.tsx +5 -5
  19. package/library-template/src/Badge.web.tsx +5 -5
  20. package/library-template/src/Welcome.stories.tsx +12 -0
  21. package/library-template/src/normalizeBadgeLabel.ts +1 -1
  22. package/library-template/src/props.ts +11 -11
  23. package/library-template/tests/normalizeBadgeLabel.test.ts +1 -1
  24. package/library-template/tests/packed-consumer.mjs +140 -123
  25. package/library-template/tsconfig.envs.json +1 -0
  26. package/library-template/tsconfig.json +1 -0
  27. package/library-template/tsconfig.types.json +15 -1
  28. package/library-template/tsrx-typegen.json +1 -1
  29. package/library-template/workshop.config.ts +3 -0
  30. package/package-manager.ts +93 -0
  31. package/package.json +10 -5
  32. package/scaffold.ts +1061 -449
  33. package/template/.agents/skills/xplat/SKILL.md +1 -1
  34. package/template/.agents/skills/xplat/references/styling.md +10 -10
  35. package/template/AGENTS.md +2 -2
  36. package/template/bunfig +4 -0
  37. package/template/nativescript.config.ts +13 -13
  38. package/template/package.json +69 -64
  39. package/template/patches/@nativescript-community__octane@0.2.5.patch +161 -24
  40. package/template/patches/@nativescript__core@9.1.3.patch +98 -0
  41. package/template/patches/@nativescript__vite@8.0.20.patch +532 -17
  42. package/template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
  43. package/template/patches/octane@0.16.3.patch +56 -2
  44. package/template/src/App.tsrx +66 -64
  45. package/template/src/Welcome.stories.tsx +22 -0
  46. package/template/src/app.spec.tsrx +168 -158
  47. package/template/src/app.web.test.tsx +18 -13
  48. package/template/src/failure-reporting.spec.ts +3 -3
  49. package/template/src/main.ts +14 -13
  50. package/template/src/main.tsrx +2 -0
  51. package/template/src/native-runtime.spec.ts +13 -11
  52. package/template/src/test-setup.web.ts +9 -8
  53. package/template/src/test.ts +6 -6
  54. package/template/tsconfig.json +17 -1
  55. package/template/vite.config.native.mts +1 -2
  56. package/template/vite.config.ts +29 -23
  57. package/template/vitest.config.mts +17 -17
  58. package/template/vitest.web.config.mts +7 -7
  59. package/template/workshop.config.ts +3 -0
  60. package/library-template/patches/@tsrx__typescript-plugin@0.4.11.patch +0 -11
  61. package/template/patches/@tsrx__typescript-plugin@0.4.11.patch +0 -11
  62. /package/library-template/patches/{@octanejs__tiptap@0.0.61.patch → @octanejs__tiptap@0.0.62.patch} +0 -0
  63. /package/template/patches/{@octanejs__tiptap@0.0.61.patch → @octanejs__tiptap@0.0.62.patch} +0 -0
@@ -0,0 +1,65 @@
1
+ diff --git a/common.js b/common.js
2
+ --- a/common.js
3
+ +++ b/common.js
4
+ @@ -1020,6 +1020,39 @@
5
+ get _masonPlacedNatively() {
6
+ return __APPLE__ && !!this[isMasonView_] && !!this.parent?.[isMasonView_];
7
+ }
8
+ + // Refresh nested roots before the outer Rust compute takes the shared lock.
9
+ + // Otherwise core can reuse the foreign host's previous exact frame as its
10
+ + // intrinsic minimum, preventing a grid/flex ancestor from shrinking.
11
+ + _masonWarmForeignRoots() {
12
+ + if (!__APPLE__) return;
13
+ + for (let ancestor = this.parent; ancestor; ancestor = ancestor.parent) {
14
+ + if (ancestor[isMasonView_]) return;
15
+ + }
16
+ + const native = this.nativeViewProtected;
17
+ + const mason = native?.mason ?? native?.node?.mason;
18
+ + if (typeof mason?.invalidateForeignView !== 'function') return;
19
+ + const containsMason = (view) => {
20
+ + let found = false;
21
+ + view.eachChildView?.((child) => {
22
+ + found = !!child[isMasonView_] || containsMason(child);
23
+ + return !found;
24
+ + });
25
+ + return found;
26
+ + };
27
+ + const visit = (parent) => parent.eachChildView?.((child) => {
28
+ + if (child[isMasonView_]) {
29
+ + visit(child);
30
+ + } else if (child.nativeViewProtected && containsMason(child)) {
31
+ + // Settle the deepest independent roots first. Both axes must
32
+ + // be unconstrained: a previous width can also preserve height.
33
+ + visit(child);
34
+ + child.measure(0, 0);
35
+ + mason.invalidateForeignView(child.nativeViewProtected);
36
+ + }
37
+ + return true;
38
+ + });
39
+ + visit(this);
40
+ + }
41
+ /** Size a non-Mason child with core's measure: its native view rarely implements sizeThatFits. */
42
+ _masonMeasureForeign(child) {
43
+ if (!__APPLE__ || child[isMasonView_] || !child.nativeViewProtected)
44
+ diff --git a/scroll/index.ios.js b/scroll/index.ios.js
45
+ --- a/scroll/index.ios.js
46
+ +++ b/scroll/index.ios.js
47
+ @@ -50,6 +50,7 @@
48
+ onMeasure(widthMeasureSpec, heightMeasureSpec) {
49
+ const nativeView = this._view;
50
+ if (nativeView) {
51
+ + if (this.parent && !this.parent[isMasonView_]) this._masonWarmForeignRoots();
52
+ // As a root, the box is the viewport: clamped to the specs so the content overflows it and scrolls.
53
+ // @ts-ignore
54
+ setMeasuredFromNative(this, nativeView.mason_measure(widthMeasureSpec, heightMeasureSpec, !!this.parent && !this.parent[isMasonView_], true));
55
+ diff --git a/view/index.ios.js b/view/index.ios.js
56
+ --- a/view/index.ios.js
57
+ +++ b/view/index.ios.js
58
+ @@ -56,6 +56,7 @@
59
+ const root = !this.parent?.[isMasonView_];
60
+ if (root && pendingAddHosts > 0)
61
+ flushNativeAddsDeep(this);
62
+ + if (root) this._masonWarmForeignRoots();
63
+ // One native call computes a root for the host's specs, or reads a child's placed box.
64
+ // @ts-ignore
65
+ setMeasuredFromNative(this, nativeView.mason_measure(widthMeasureSpec, heightMeasureSpec, root, false));
@@ -529,10 +529,11 @@ index 617ed9a63..1c6e01f17 100644
529
529
  visibility: parent?.visibility ?? record.visibility,
530
530
  contextStable: null
531
531
  };
532
- @@ -1121,6 +1130,7 @@ function executeOwner(owner, build, initialRenderCount = 0) {
532
+ @@ -1121,6 +1130,8 @@ function executeOwner(owner, build, initialRenderCount = 0) {
533
533
  owner.contextStable = null;
534
534
  owner.needsRender = false;
535
535
  owner.implicitSlot = 0;
536
+ + owner.hookChain = void 0;
536
537
  + owner.signalReads = NO_SIGNAL_READS;
537
538
  const previousOwner = CURRENT_OWNER;
538
539
  const previousAttemptOwner = attempt.owner;
@@ -576,6 +577,26 @@ index 617ed9a63..1c6e01f17 100644
576
577
  for (const [slot, applied] of draftOwner2.appliedUpdates) {
577
578
  const queue = owner.updates.get(slot);
578
579
  if (queue !== applied.queue || applied.lane) continue;
580
+ @@ -3457,5 +3457,6 @@ function resolveHookSlot(slot) {
581
+ const own = slot ?? `implicit:${owner.implicitSlot++}`;
582
+ - const depth = UNIVERSAL_SLOT_STACK.length;
583
+ - if (depth === 0) return own;
584
+ - return resolveHookPath(UNIVERSAL_SLOT_STACK, own, true);
585
+ + const chain = owner.hookChain;
586
+ + const resolved = chain === void 0 && UNIVERSAL_SLOT_STACK.length === 0 ? own : resolveHookPath(chain === void 0 ? UNIVERSAL_SLOT_STACK : [...UNIVERSAL_SLOT_STACK, chain], own, true);
587
+ + owner.hookChain = resolved;
588
+ + return resolved;
589
+ }
590
+ @@ -3507,7 +3507,9 @@ function withSlot(sym, fn, ...args) {
591
+ Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
592
+ return provider;
593
+ }
594
+ function withSlot(sym, fn, ...args) {
595
+ + const hmr = fn?.[UNIVERSAL_HMR];
596
+ + if (hmr !== void 0) fn = hmr.component;
597
+ const driver = MANUAL_HOOK_DRIVER;
598
+ const pending = driver?.pending;
599
+ const active = driver?.active ?? false;
579
600
  @@ -3683,6 +3701,86 @@ function scheduleOwner(owner, slot) {
580
601
  }
581
602
  owner.root.scheduleOwned(owner);
@@ -1063,10 +1084,11 @@ index 617ed9a63..1c6e01f17 100644
1063
1084
  visibility: parent?.visibility ?? record.visibility,
1064
1085
  contextStable: null
1065
1086
  };
1066
- @@ -1121,6 +1130,7 @@ function executeOwner(owner, build, initialRenderCount = 0) {
1087
+ @@ -1121,6 +1130,8 @@ function executeOwner(owner, build, initialRenderCount = 0) {
1067
1088
  owner.contextStable = null;
1068
1089
  owner.needsRender = false;
1069
1090
  owner.implicitSlot = 0;
1091
+ + owner.hookChain = void 0;
1070
1092
  + owner.signalReads = NO_SIGNAL_READS;
1071
1093
  const previousOwner = CURRENT_OWNER;
1072
1094
  const previousAttemptOwner = attempt.owner;
@@ -1110,6 +1132,26 @@ index 617ed9a63..1c6e01f17 100644
1110
1132
  for (const [slot, applied] of draftOwner2.appliedUpdates) {
1111
1133
  const queue = owner.updates.get(slot);
1112
1134
  if (queue !== applied.queue || applied.lane) continue;
1135
+ @@ -3457,5 +3457,6 @@ function resolveHookSlot(slot) {
1136
+ const own = slot ?? `implicit:${owner.implicitSlot++}`;
1137
+ - const depth = UNIVERSAL_SLOT_STACK.length;
1138
+ - if (depth === 0) return own;
1139
+ - return resolveHookPath(UNIVERSAL_SLOT_STACK, own, true);
1140
+ + const chain = owner.hookChain;
1141
+ + const resolved = chain === void 0 && UNIVERSAL_SLOT_STACK.length === 0 ? own : resolveHookPath(chain === void 0 ? UNIVERSAL_SLOT_STACK : [...UNIVERSAL_SLOT_STACK, chain], own, true);
1142
+ + owner.hookChain = resolved;
1143
+ + return resolved;
1144
+ }
1145
+ @@ -3507,7 +3507,9 @@ function withSlot(sym, fn, ...args) {
1146
+ Object.defineProperty(provider, "length", { value: fn.length, configurable: true });
1147
+ return provider;
1148
+ }
1149
+ function withSlot(sym, fn, ...args) {
1150
+ + const hmr = fn?.[UNIVERSAL_HMR];
1151
+ + if (hmr !== void 0) fn = hmr.component;
1152
+ const driver = MANUAL_HOOK_DRIVER;
1153
+ const pending = driver?.pending;
1154
+ const active = driver?.active ?? false;
1113
1155
  @@ -3683,6 +3701,86 @@ function scheduleOwner(owner, slot) {
1114
1156
  }
1115
1157
  owner.root.scheduleOwned(owner);
@@ -1423,3 +1465,15 @@ index 1e7a3b90..5c9d02f1 100644
1423
1465
  if (owner !== void 0) NATIVE_READ_DRIVER.stampQueuedPublication(owner, entry);
1424
1466
  }
1425
1467
  }
1468
+ diff --git a/dist/compiler/compile-universal.js b/dist/compiler/compile-universal.js
1469
+ index 229c024159..f453bb4e4d 100644
1470
+ --- a/dist/compiler/compile-universal.js
1471
+ +++ b/dist/compiler/compile-universal.js
1472
+ @@ -415,6 +415,7 @@
1473
+ 'useId',
1474
+ 'useImperativeHandle',
1475
+ 'useInsertionEffect',
1476
+ + '__methodDep',
1477
+ 'useLayoutEffect',
1478
+ 'useLinkedState',
1479
+ 'useMemo',
@@ -1,83 +1,85 @@
1
1
  import { useState } from 'octane'
2
2
  import {
3
- View,
4
- HStack,
5
- Text,
6
- Pressable,
7
- ScrollableArea,
8
- SafeArea,
9
- useColorScheme,
3
+ View,
4
+ HStack,
5
+ Text,
6
+ Pressable,
7
+ ScrollableArea,
8
+ SafeArea,
9
+ useColorScheme,
10
10
  } from '@octane-xplat/ui'
11
11
 
12
12
  import { storage } from '@octane-xplat/platform'
13
13
 
14
14
  const FEATURES = [
15
- 'shared components',
16
- 'platform leaves (.web / .mobile)',
17
- 'design tokens + dark mode',
18
- 'native navigation',
15
+ 'shared components',
16
+ 'platform leaves (.web / .mobile)',
17
+ 'design tokens + dark mode',
18
+ 'native navigation',
19
19
  ]
20
20
 
21
21
  /** Every element here compiles for web AND for NativeScript iOS/Android —
22
22
  * the same file, no branches. Platform divergence lives in leaf files
23
23
  * (.web.tsrx / .mobile.tsrx), never inside a component. */
24
24
  export function App() @{
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
- return saved === 'light' ? false : saved === 'dark' ? true : null
30
- })
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')
31
29
 
32
- const scheme = useColorScheme()
33
- const dark = override ?? scheme === 'dark'
30
+ return saved === 'light' ? false : saved === 'dark' ? true : null
31
+ })
34
32
 
35
- <SafeArea>
36
- <View className={['app', dark ? 'dark' : 'light']}>
37
- <Text className="title">octane-xplat</Text>
38
- <Text className="muted">one codebase — web · iOS · android</Text>
33
+ const scheme = useColorScheme()
34
+ const dark = override ?? scheme === 'dark'
39
35
 
40
- <HStack className="counter">
41
- <Pressable
42
- testID="counter.decrement"
43
- accessibilityLabel="Decrease count"
44
- className="btn"
45
- onPress={() => setCount(count - 1)}
46
- >
47
- <Text>−</Text>
48
- </Pressable>
49
- <Text testID="counter.value" className="count">
50
- {count}
51
- </Text>
52
- <Pressable
53
- testID="counter.increment"
54
- accessibilityLabel="Increase count"
55
- className="btn"
56
- onPress={() => setCount(count + 1)}
57
- >
58
- <Text>+</Text>
59
- </Pressable>
60
- </HStack>
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>
61
40
 
62
- <ScrollableArea>
63
- {FEATURES.map((f) => (
64
- <Text className="chip">{f}</Text>
65
- ))}
66
- </ScrollableArea>
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>
67
62
 
68
- <Pressable
69
- testID="settings.toggle-theme"
70
- className="link"
71
- onPress={() => {
72
- const next = !dark
73
- storage.setString('theme-preference', next ? 'dark' : 'light')
74
- setOverride(next)
75
- }}
76
- >
77
- <Text>
78
- {dark ? 'light' : 'dark'} mode (system: {scheme})
79
- </Text>
80
- </Pressable>
81
- </View>
82
- </SafeArea>
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>
83
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
+ })