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
@@ -55,7 +55,7 @@ import { signal$, derived$ } from 'octane/signals'
55
55
  export const travelers$ = signal$(1)
56
56
  export const seatsRemaining$ = derived$(() => 4 - travelers$.get())
57
57
  export function addTraveler() {
58
- travelers$.set((count) => count + 1)
58
+ travelers$.set((count) => count + 1)
59
59
  }
60
60
  ```
61
61
 
@@ -6,8 +6,8 @@ while the app runs. Put the CSS in `src/style.css` and the component in a
6
6
 
7
7
  ```css
8
8
  .trip-card {
9
- padding: 16px;
10
- border-radius: 12px;
9
+ padding: 16px;
10
+ border-radius: 12px;
11
11
  }
12
12
  ```
13
13
 
@@ -30,14 +30,14 @@ before depending on that style.
30
30
 
31
31
  ```css
32
32
  .trip-card {
33
- display: flex;
34
- flex-direction: column;
35
- padding: 16px;
33
+ display: flex;
34
+ flex-direction: column;
35
+ padding: 16px;
36
36
  }
37
37
  .trip-actions {
38
- display: flex;
39
- flex-direction: row;
40
- justify-content: center;
38
+ display: flex;
39
+ flex-direction: row;
40
+ justify-content: center;
41
41
  }
42
42
  ```
43
43
 
@@ -52,8 +52,8 @@ import '@octane-xplat/ui/theme/tokens.css'
52
52
 
53
53
  ```css
54
54
  .trip-card {
55
- background-color: var(--color-surface);
56
- color: var(--color-text);
55
+ background-color: var(--color-surface);
56
+ color: var(--color-text);
57
57
  }
58
58
  ```
59
59
 
@@ -30,7 +30,7 @@ select DOM types on their first line; keep runtime imports from `octane`:
30
30
  ```tsx
31
31
  /** @jsxImportSource @octane-xplat/jsx/dom */
32
32
  export function BrowserMessage() {
33
- return <p>Ready</p>
33
+ return <p>Ready</p>
34
34
  }
35
35
  ```
36
36
 
@@ -61,7 +61,7 @@ distinguish document checks from browser layout or OS input checks. See the
61
61
  import { Button } from '@octane-xplat/ui'
62
62
 
63
63
  export function AddItem() {
64
- return <Button testID="packing.add-item" label="Add item" accessibilityLabel="Add item" />
64
+ return <Button testID="packing.add-item" label="Add item" accessibilityLabel="Add item" />
65
65
  }
66
66
  ```
67
67
 
@@ -0,0 +1,4 @@
1
+ [install]
2
+ # NativeScript resolves plugins from the app’s flat dependency tree.
3
+ linker = "hoisted"
4
+ exact = true
@@ -1,17 +1,17 @@
1
1
  import { NativeScriptConfig } from '@nativescript/core'
2
2
 
3
3
  export default {
4
- id: 'org.nativescript.octanexplat',
5
- appPath: 'src',
6
- appResourcesPath: 'App_Resources',
7
- // Keep NativeScript's installs on the same package manager as the app.
8
- cli: {
9
- packageManager: 'bun',
10
- },
11
- android: {
12
- v8Flags: '--expose_gc',
13
- markingMode: 'none',
14
- },
15
- bundler: 'vite',
16
- bundlerConfigPath: 'vite.config.native.mts',
4
+ id: 'org.nativescript.octanexplat',
5
+ appPath: 'src',
6
+ appResourcesPath: 'App_Resources',
7
+ // Keep NativeScript's installs on the same package manager as the app.
8
+ cli: {
9
+ packageManager: 'bun',
10
+ },
11
+ android: {
12
+ v8Flags: '--expose_gc',
13
+ markingMode: 'none',
14
+ },
15
+ bundler: 'vite',
16
+ bundlerConfigPath: 'vite.config.native.mts',
17
17
  } as NativeScriptConfig
@@ -13,20 +13,20 @@
13
13
  "@nativescript/types": "9.1.4",
14
14
  "@nativescript/unit-test-runner": "5.0.0",
15
15
  "@nativescript/vite": "8.0.20",
16
- "@octane-xplat/cli": "0.19.0",
17
- "@octane-xplat/jsx": "0.19.0",
18
- "@octane-xplat/nativescript-mason-core": "1.0.0-beta.5",
19
- "@octane-xplat/platform": "0.19.0",
20
- "@octane-xplat/ui": "0.19.0",
16
+ "@octane-xplat/jsx": "0.20.0",
17
+ "@octane-xplat/nativescript-mason-core": "1.0.0-beta.7",
18
+ "@octane-xplat/platform": "0.20.0",
19
+ "@octane-xplat/ui": "0.20.0",
20
+ "@octane-xplat/workshop": "0.20.0",
21
21
  "@octanejs/vite-plugin": "0.5.0",
22
22
  "@tsrx/oxc": "0.20.0",
23
- "@tsrx/typescript-plugin": "0.4.11",
24
23
  "@valor/nativescript-websockets": "2.0.3",
25
24
  "jsdom": "30.1.1",
26
25
  "nativescript": "9.1.1",
27
26
  "octane": "0.16.3",
28
- "typescript": "5.9.3",
29
- "vite": "8.3.0",
27
+ "octane-xplat": "0.20.0",
28
+ "typescript-classic": "npm:typescript@5.9.3",
29
+ "vite": "8.3.6",
30
30
  "vitest": "4.1.11"
31
31
  }
32
32
  }
@@ -35,10 +35,10 @@
35
35
  "main": "src/main.ts",
36
36
  "scripts": {
37
37
  "xplat": "xplat",
38
- "dev": "vite",
38
+ "dev": "xplat dev web",
39
39
  "dev:ios": "ns run ios",
40
40
  "dev:android": "ns run android",
41
- "build": "vite build",
41
+ "build": "xplat build --targets web",
42
42
  "build:ios": "ns build ios",
43
43
  "build:android": "ns build android",
44
44
  "test": "vitest run --config vitest.web.config.mts",
@@ -48,7 +48,8 @@
48
48
  "lint": "xplat lint",
49
49
  "lint:fix": "xplat lint --fix",
50
50
  "typecheck": "xplat typecheck",
51
- "format": "xplat fmt"
51
+ "format": "xplat fmt",
52
+ "workshop": "xplat workshop dev --target web"
52
53
  },
53
54
  "dependencies": {
54
55
  "@nativescript-community/octane": "catalog:xplat",
@@ -67,67 +68,70 @@
67
68
  "@nativescript/types": "catalog:xplat",
68
69
  "@nativescript/unit-test-runner": "catalog:xplat",
69
70
  "@nativescript/vite": "catalog:xplat",
70
- "@octane-xplat/cli": "catalog:xplat",
71
+ "@octane-xplat/workshop": "catalog:xplat",
71
72
  "@octanejs/vite-plugin": "catalog:xplat",
72
73
  "@tsrx/oxc": "catalog:xplat",
73
- "@tsrx/typescript-plugin": "catalog:xplat",
74
74
  "jsdom": "catalog:xplat",
75
75
  "nativescript": "catalog:xplat",
76
- "typescript": "catalog:xplat",
76
+ "octane-xplat": "catalog:xplat",
77
+ "typescript-classic": "catalog:xplat",
77
78
  "vite": "catalog:xplat",
78
79
  "vitest": "catalog:xplat"
79
80
  },
80
81
  "overrides": {
81
- "@lexical/a11y": "0.52.0",
82
- "@lexical/code": "0.52.0",
83
- "@lexical/devtools-core": "0.52.0",
84
- "@lexical/dragon": "0.52.0",
85
- "@lexical/extension": "0.52.0",
86
- "@lexical/hashtag": "0.52.0",
87
- "@lexical/history": "0.52.0",
88
- "@lexical/html": "0.52.0",
89
- "@lexical/internal": "0.52.0",
90
- "@lexical/link": "0.52.0",
91
- "@lexical/list": "0.52.0",
92
- "@lexical/mark": "0.52.0",
93
- "@lexical/markdown": "0.52.0",
94
- "@lexical/overflow": "0.52.0",
95
- "@lexical/plain-text": "0.52.0",
96
- "@lexical/rich-text": "0.52.0",
97
- "@lexical/selection": "0.52.0",
98
- "@lexical/table": "0.52.0",
99
- "@lexical/text": "0.52.0",
100
- "@lexical/utils": "0.52.0",
101
- "@lexical/yjs": "0.52.0",
82
+ "@lexical/a11y": "0.53.0",
83
+ "@lexical/code": "0.53.0",
84
+ "@lexical/devtools-core": "0.53.0",
85
+ "@lexical/dragon": "0.53.0",
86
+ "@lexical/extension": "0.53.0",
87
+ "@lexical/hashtag": "0.53.0",
88
+ "@lexical/history": "0.53.0",
89
+ "@lexical/html": "0.53.0",
90
+ "@lexical/internal": "0.53.0",
91
+ "@lexical/link": "0.53.0",
92
+ "@lexical/list": "0.53.0",
93
+ "@lexical/mark": "0.53.0",
94
+ "@lexical/markdown": "0.53.0",
95
+ "@lexical/overflow": "0.53.0",
96
+ "@lexical/plain-text": "0.53.0",
97
+ "@lexical/rich-text": "0.53.0",
98
+ "@lexical/selection": "0.53.0",
99
+ "@lexical/table": "0.53.0",
100
+ "@lexical/text": "0.53.0",
101
+ "@lexical/utils": "0.53.0",
102
+ "@lexical/yjs": "0.53.0",
102
103
  "@nativescript-community/vite-octane>esbuild": "0.27.7",
103
104
  "@nativescript/vite>esbuild": "0.27.7",
104
- "@tiptap/core": "3.32.0",
105
- "@tiptap/extension-blockquote": "3.32.0",
106
- "@tiptap/extension-bold": "3.32.0",
107
- "@tiptap/extension-bullet-list": "3.32.0",
108
- "@tiptap/extension-code": "3.32.0",
109
- "@tiptap/extension-code-block": "3.32.0",
110
- "@tiptap/extension-document": "3.32.0",
111
- "@tiptap/extension-dropcursor": "3.32.0",
112
- "@tiptap/extension-gapcursor": "3.32.0",
113
- "@tiptap/extension-hard-break": "3.32.0",
114
- "@tiptap/extension-heading": "3.32.0",
115
- "@tiptap/extension-horizontal-rule": "3.32.0",
116
- "@tiptap/extension-italic": "3.32.0",
117
- "@tiptap/extension-link": "3.32.0",
118
- "@tiptap/extension-list": "3.32.0",
119
- "@tiptap/extension-list-item": "3.32.0",
120
- "@tiptap/extension-list-keymap": "3.32.0",
121
- "@tiptap/extension-ordered-list": "3.32.0",
122
- "@tiptap/extension-paragraph": "3.32.0",
123
- "@tiptap/extension-strike": "3.32.0",
124
- "@tiptap/extension-text": "3.32.0",
125
- "@tiptap/extension-underline": "3.32.0",
126
- "@tiptap/extensions": "3.32.0",
127
- "@tiptap/pm": "3.32.0",
128
- "@tiptap/starter-kit": "3.32.0",
129
- "@tiptap/static-renderer": "3.32.0",
130
- "lexical": "0.52.0",
105
+ "@nativescript/vite>typescript": "5.9.3",
106
+ "@tiptap/core": "3.32.2",
107
+ "@tiptap/extension-blockquote": "3.32.2",
108
+ "@tiptap/extension-bold": "3.32.2",
109
+ "@tiptap/extension-bubble-menu": "3.32.2",
110
+ "@tiptap/extension-bullet-list": "3.32.2",
111
+ "@tiptap/extension-code": "3.32.2",
112
+ "@tiptap/extension-code-block": "3.32.2",
113
+ "@tiptap/extension-document": "3.32.2",
114
+ "@tiptap/extension-dropcursor": "3.32.2",
115
+ "@tiptap/extension-floating-menu": "3.32.2",
116
+ "@tiptap/extension-gapcursor": "3.32.2",
117
+ "@tiptap/extension-hard-break": "3.32.2",
118
+ "@tiptap/extension-heading": "3.32.2",
119
+ "@tiptap/extension-horizontal-rule": "3.32.2",
120
+ "@tiptap/extension-italic": "3.32.2",
121
+ "@tiptap/extension-link": "3.32.2",
122
+ "@tiptap/extension-list": "3.32.2",
123
+ "@tiptap/extension-list-item": "3.32.2",
124
+ "@tiptap/extension-list-keymap": "3.32.2",
125
+ "@tiptap/extension-ordered-list": "3.32.2",
126
+ "@tiptap/extension-paragraph": "3.32.2",
127
+ "@tiptap/extension-strike": "3.32.2",
128
+ "@tiptap/extension-text": "3.32.2",
129
+ "@tiptap/extension-underline": "3.32.2",
130
+ "@tiptap/extensions": "3.32.2",
131
+ "@tiptap/pm": "3.32.2",
132
+ "@tiptap/starter-kit": "3.32.2",
133
+ "@tiptap/static-renderer": "3.32.2",
134
+ "lexical": "0.53.0",
131
135
  "oxlint-tsgolint": "7.0.2005",
132
136
  "regenerate": "1.5.0",
133
137
  "vite>esbuild": "0.27.7"
@@ -140,17 +144,18 @@
140
144
  "patchedDependencies": {
141
145
  "octane@0.16.3": "patches/octane@0.16.3.patch",
142
146
  "@nativescript/core@9.1.3": "patches/@nativescript__core@9.1.3.patch",
147
+ "@octane-xplat/nativescript-mason-core@1.0.0-beta.7": "patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch",
143
148
  "css@3.0.0": "patches/css@3.0.0.patch",
144
149
  "@nativescript/vite@8.0.20": "patches/@nativescript__vite@8.0.20.patch",
145
150
  "@nativescript-community/octane@0.2.5": "patches/@nativescript-community__octane@0.2.5.patch",
146
151
  "@nativescript-community/vite-octane@0.2.1": "patches/@nativescript-community__vite-octane@0.2.1.patch",
147
- "@tsrx/typescript-plugin@0.4.11": "patches/@tsrx__typescript-plugin@0.4.11.patch",
148
- "@octanejs/tiptap@0.0.61": "patches/@octanejs__tiptap@0.0.61.patch",
152
+ "@octanejs/tiptap@0.0.62": "patches/@octanejs__tiptap@0.0.62.patch",
149
153
  "@nativescript/doctor@2.0.18": "patches/@nativescript__doctor@2.0.18.patch",
150
154
  "@sveltejs/acorn-typescript@1.0.13": "patches/@sveltejs__acorn-typescript@1.0.13.patch",
151
155
  "@nativescript-community/sqlite-bridge@4.1.1": "patches/@nativescript-community__sqlite-bridge@4.1.1.patch"
152
156
  },
153
157
  "trustedDependencies": [
158
+ "@octane-xplat/cli",
154
159
  "esbuild",
155
160
  "@parcel/watcher",
156
161
  "nativescript"
@@ -35,7 +35,7 @@ index 80e30299c44e889e3a066ce2c9a8feb6b7ceaa42..85c447ecf9952d28019f3093faab1600
35
35
  * Mount an Octane component into an existing NativeScript view.
36
36
  *
37
37
  diff --git a/dist/driver.js b/dist/driver.js
38
- index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad06226494 100644
38
+ index 8bc563add4cb675a12651184b63805b10224274d..0f0e395ce195862db32ef5539e086de84b8828d2 100644
39
39
  --- a/dist/driver.js
40
40
  +++ b/dist/driver.js
41
41
  @@ -1,8 +1,11 @@
@@ -166,7 +166,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
166
166
  if (typeof value === 'string')
167
167
  return value;
168
168
  if (Array.isArray(value))
169
- @@ -147,16 +190,309 @@ function normalizeClass(value) {
169
+ @@ -147,23 +190,397 @@ function normalizeClass(value) {
170
170
  .join(' ');
171
171
  return '';
172
172
  }
@@ -296,7 +296,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
296
296
  +function warnStyleOnlyProp(node, name) {
297
297
  + const key = node.type + ':' + name;
298
298
  + if (warnedStyleOnlyProps.has(key))
299
- + return;
299
+ return;
300
300
  + warnedStyleOnlyProps.add(key);
301
301
  + console.warn(`[xplat] <${node.type} ${name}=...> is a layout key — move it into style={{ ${name}: ... }} or a class.`);
302
302
  +}
@@ -376,8 +376,11 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
376
376
  + style.overflowX = enabled ? 'scroll' : 'hidden';
377
377
  + style.overflowY = enabled ? 'scroll' : 'hidden';
378
378
  + }
379
- + }
380
- +}
379
+ }
380
+ - if (typeof value === 'object')
381
+ - Object.assign(view.style, value);
382
+ }
383
+ -/** Recompute a text host's `text` from its `#text` children. */
381
384
  +
382
385
  +/** Keep foreign leaves in sync with the effective NativeScript cascade.
383
386
  + * MasonKit's property handlers only forward to its own _styleHelper views.
@@ -390,10 +393,8 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
390
393
  + return;
391
394
  + if (masonLeafBindings.has(view)) {
392
395
  + masonLeafBindings.get(view).sync();
393
- return;
394
- }
395
- - if (typeof value === 'object')
396
- - Object.assign(view.style, value);
396
+ + return;
397
+ + }
397
398
  + let native;
398
399
  + let leaf;
399
400
  + let defaultDisplay;
@@ -470,7 +471,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
470
471
  + },
471
472
  + });
472
473
  + sync();
473
- }
474
+ +}
474
475
  +function releaseMasonChildLayout(view) {
475
476
  + if (!view)
476
477
  + return;
@@ -478,10 +479,98 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
478
479
  + masonLeafBindings.delete(view);
479
480
  +}
480
481
  +
481
- /** Recompute a text host's `text` from its `#text` children. */
482
+ +/** Mint (or reuse) the driver-owned Span a `#text` child folds into when it
483
+ + * shares its text host with run elements, then apply its current text. */
484
+ +function foldedSpan(parent, child) {
485
+ + const spans = (parent.textSpans ??= new Map());
486
+ + for (const key of [...spans.keys()])
487
+ + if (!parent.children.includes(key))
488
+ + spans.delete(key);
489
+ + let span = spans.get(child);
490
+ + if (span === undefined) {
491
+ + span = new Span();
492
+ + spans.set(child, span);
493
+ + }
494
+ + span.text = child.text;
495
+ + return span;
496
+ +}
497
+ +/** Assign a FormattedString's run list in place. Removed spans leave the
498
+ + * collection before any re-add — a span re-enters only after its parent
499
+ + * clears, so reorder/growth never re-adds a still-parented span. */
500
+ +function replaceSpans(fs, runs) {
501
+ + const spans = fs.spans;
502
+ + let i = 0;
503
+ + while (i < spans.length && i < runs.length && spans[i] === runs[i])
504
+ + i++;
505
+ + if (i === spans.length && i === runs.length)
506
+ + return;
507
+ + if (i < spans.length)
508
+ + spans.splice(i, spans.length - i);
509
+ + if (i < runs.length)
510
+ + spans.splice(i, 0, ...runs.slice(i));
511
+ +}
512
+ +/** Recompute a text host's text from its `#text` children, folding mixed
513
+ + * text/run children into a single FormattedString in child order. `Span`
514
+ + * under a TextBase auto-wraps into `formattedText`; `#text` under
515
+ + * FormattedString/Span folds to text (octane-xplat decisions #25). */
482
516
  function syncText(parent) {
483
517
  if (parent === null || isPortalTarget(parent))
484
- @@ -190,6 +526,15 @@ function addViewChild(parentView, view, index) {
518
+ return;
519
+ const view = parent.view;
520
+ + if (view instanceof Span) {
521
+ + // A Span can't host views; its `#text` children fold into `text`.
522
+ + let text = '';
523
+ + for (const child of parent.children)
524
+ + if (child.view === null)
525
+ + text += child.text;
526
+ + view.text = text;
527
+ + return;
528
+ + }
529
+ + if (view instanceof FormattedString) {
530
+ + // Span children splice through add/removeViewChild; `#text` children
531
+ + // fold into minted spans interleaved in child order.
532
+ + if (!parent.children.some((child) => child.view === null))
533
+ + return;
534
+ + const runs = [];
535
+ + for (const child of parent.children) {
536
+ + if (child.view === null)
537
+ + runs.push(foldedSpan(parent, child));
538
+ + else if (child.view instanceof Span)
539
+ + runs.push(child.view);
540
+ + }
541
+ + replaceSpans(view, runs);
542
+ + return;
543
+ + }
544
+ if (!(view instanceof TextBase))
545
+ return;
546
+ + const elementChildren = parent.children.filter((child) => child.view !== null);
547
+ + if (elementChildren.length > 0 &&
548
+ + elementChildren.every((child) => child.view instanceof Span)) {
549
+ + // Mixed text/span children fold into one driver-owned FormattedString
550
+ + // in child order. An explicit formattedstring child or another view
551
+ + // type keeps its own attach path instead of joining the fold.
552
+ + const folded = (parent.foldedText ??= { fs: new FormattedString() });
553
+ + const runs = [];
554
+ + for (const child of parent.children)
555
+ + runs.push(child.view === null ? foldedSpan(parent, child) : child.view);
556
+ + replaceSpans(folded.fs, runs);
557
+ + if (view.formattedText !== folded.fs)
558
+ + view.formattedText = folded.fs;
559
+ + if (parent.textApplied || view.text !== '') {
560
+ + parent.textApplied = false;
561
+ + view.text = '';
562
+ + }
563
+ + return;
564
+ + }
565
+ + if (parent.foldedText != null) {
566
+ + if (view.formattedText === parent.foldedText.fs)
567
+ + view.formattedText = CLEARED;
568
+ + parent.foldedText = null;
569
+ + }
570
+ let text = '';
571
+ let found = false;
572
+ for (const child of parent.children) {
573
+ @@ -190,6 +607,15 @@ function addViewChild(parentView, view, index) {
485
574
  parentView.insertChild(view, Math.min(index, parentView.getChildrenCount()));
486
575
  return;
487
576
  }
@@ -497,7 +586,32 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
497
586
  if (parentView instanceof ContentView) {
498
587
  parentView.content = view;
499
588
  return;
500
- @@ -234,6 +579,13 @@ function removeViewChild(parentView, view) {
589
+ @@ -203,9 +629,24 @@ function addViewChild(parentView, view, index) {
590
+ return;
591
+ }
592
+ if (parentView instanceof FormattedString && view instanceof Span) {
593
+ + // When the formattedstring mixes `#text` and span children, syncText
594
+ + // owns the whole ordered run list.
595
+ + const owner = viewOwners.get(parentView)?.node;
596
+ + if (owner != null && owner.children.some((child) => child.view === null)) {
597
+ + syncText(owner);
598
+ + return;
599
+ + }
600
+ parentView.spans.splice(Math.min(index, parentView.spans.length), 0, view);
601
+ return;
602
+ }
603
+ + if (parentView instanceof TextBase && view instanceof Span) {
604
+ + // A span run under a text host joins its folded FormattedString;
605
+ + // syncText rebuilds the ordered run list.
606
+ + const owner = viewOwners.get(parentView)?.node;
607
+ + if (owner != null)
608
+ + syncText(owner);
609
+ + return;
610
+ + }
611
+ if (parentView instanceof TextBase && view instanceof FormattedString) {
612
+ parentView.formattedText = view;
613
+ return;
614
+ @@ -234,6 +675,13 @@ function removeViewChild(parentView, view) {
501
615
  parentView.removeChild(view);
502
616
  return;
503
617
  }
@@ -511,7 +625,30 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
511
625
  if (parentView instanceof ContentView) {
512
626
  if (parentView.content === view)
513
627
  parentView.content = CLEARED;
514
- @@ -315,6 +667,7 @@ function tabViewOwning(node) {
628
+ @@ -248,11 +696,22 @@ function removeViewChild(parentView, view) {
629
+ return;
630
+ }
631
+ if (parentView instanceof FormattedString && view instanceof Span) {
632
+ + const owner = viewOwners.get(parentView)?.node;
633
+ + if (owner != null && owner.children.some((child) => child.view === null)) {
634
+ + syncText(owner);
635
+ + return;
636
+ + }
637
+ const index = parentView.spans.indexOf(view);
638
+ if (index !== -1)
639
+ parentView.spans.splice(index, 1);
640
+ return;
641
+ }
642
+ + if (parentView instanceof TextBase && view instanceof Span) {
643
+ + const owner = viewOwners.get(parentView)?.node;
644
+ + if (owner != null)
645
+ + syncText(owner);
646
+ + return;
647
+ + }
648
+ if (parentView instanceof TextBase && parentView.formattedText === view) {
649
+ parentView.formattedText = CLEARED;
650
+ return;
651
+ @@ -315,6 +774,7 @@ function tabViewOwning(node) {
515
652
  return null;
516
653
  }
517
654
  function detach(container, node) {
@@ -519,7 +656,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
519
656
  const parent = node.parent;
520
657
  const siblings = childrenOf(container, parent);
521
658
  const index = siblings.indexOf(node);
522
- @@ -370,6 +723,12 @@ function attach(container, node) {
659
+ @@ -370,6 +830,12 @@ function attach(container, node) {
523
660
  }
524
661
  }
525
662
  addViewChild(parentView, node.view, index);
@@ -532,7 +669,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
532
669
  markTabView(tabViewOwning(node));
533
670
  }
534
671
  function insert(container, parent, node, before) {
535
- @@ -395,6 +754,23 @@ function insert(container, parent, node, before) {
672
+ @@ -395,6 +861,23 @@ function insert(container, parent, node, before) {
536
673
  * nests an apply, so this is a depth rather than a flag.
537
674
  */
538
675
  let applyingDepth = 0;
@@ -556,7 +693,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
556
693
  function setEvent(container, node, type, listener) {
557
694
  const view = node.view;
558
695
  if (view === null)
559
- @@ -429,6 +805,7 @@ function setEvent(container, node, type, listener) {
696
+ @@ -429,6 +912,7 @@ function setEvent(container, node, type, listener) {
560
697
  view.on(type, handler);
561
698
  }
562
699
  function disposeListeners(node) {
@@ -564,7 +701,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
564
701
  const view = node.view;
565
702
  if (view !== null) {
566
703
  for (const [type, handler] of node.listeners)
567
- @@ -460,6 +837,7 @@ function recreateView(container, node) {
704
+ @@ -460,6 +944,7 @@ function recreateView(container, node) {
568
705
  // no longer host them.
569
706
  throw new Error(`NativeScript driver: re-registered <${node.type}> is a <${view.typeName}>, which cannot host portal children; the registration stays on the previous view.`);
570
707
  }
@@ -572,7 +709,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
572
709
  const parentView = hostViewOf(container, node.parent);
573
710
  for (const child of node.children) {
574
711
  if (child.view !== null)
575
- @@ -480,6 +858,9 @@ function recreateView(container, node) {
712
+ @@ -480,6 +965,9 @@ function recreateView(container, node) {
576
713
  viewOwners.set(view, { container, node });
577
714
  node.view = view;
578
715
  node.textApplied = false;
@@ -582,7 +719,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
582
719
  applyProps(node, node.props);
583
720
  for (const [type, handler] of node.listeners)
584
721
  view.on(type, handler);
585
- @@ -500,6 +881,12 @@ function recreateView(container, node) {
722
+ @@ -500,6 +988,12 @@ function recreateView(container, node) {
586
723
  addViewChild(view, child.view, index++);
587
724
  }
588
725
  }
@@ -595,7 +732,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
595
732
  syncText(node);
596
733
  markTabView(node);
597
734
  attach(container, node);
598
- @@ -548,7 +935,7 @@ function preparePortalTarget(context) {
735
+ @@ -548,7 +1042,7 @@ function preparePortalTarget(context) {
599
736
  }
600
737
  const target = owner?.node.view ?? suppliedTarget;
601
738
  if (!(target instanceof LayoutBase)) {
@@ -604,7 +741,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
604
741
  }
605
742
  let id = portalTargetIds.get(target);
606
743
  if (id === undefined) {
607
- @@ -641,7 +1028,7 @@ function applyCommand(container, command) {
744
+ @@ -641,7 +1135,7 @@ function applyCommand(container, command) {
608
745
  }
609
746
  export const nativeScriptDriver = {
610
747
  id: NATIVESCRIPT_RENDERER_ID,
@@ -613,7 +750,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
613
750
  events: {
614
751
  classify(name) {
615
752
  if (!EVENT_PROP.test(name))
616
- @@ -656,6 +1043,7 @@ export const nativeScriptDriver = {
753
+ @@ -656,6 +1150,7 @@ export const nativeScriptDriver = {
617
754
  }
618
755
  return {
619
756
  apply() {
@@ -621,7 +758,7 @@ index 8bc563add4cb675a12651184b63805b10224274d..494acc783b1608485e640e157ee9d9ad
621
758
  applyingDepth++;
622
759
  pendingTabViews.push(new Set());
623
760
  try {
624
- @@ -670,6 +1058,7 @@ export const nativeScriptDriver = {
761
+ @@ -670,6 +1165,7 @@ export const nativeScriptDriver = {
625
762
  applyingDepth--;
626
763
  }
627
764
  }