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',
@@ -14,9 +14,9 @@ import type { BadgeProps } from './props'
14
14
  * ```
15
15
  */
16
16
  export function Badge(props: BadgeProps): JSX.Element {
17
- return (
18
- <View className={props.className}>
19
- <Text>{normalizeBadgeLabel(props.label)}</Text>
20
- </View>
21
- )
17
+ return (
18
+ <View className={props.className}>
19
+ <Text>{normalizeBadgeLabel(props.label)}</Text>
20
+ </View>
21
+ )
22
22
  }
@@ -14,9 +14,9 @@ import type { BadgeProps } from './props'
14
14
  * ```
15
15
  */
16
16
  export function Badge(props: BadgeProps): JSX.Element {
17
- return (
18
- <View className={props.className}>
19
- <Text>{normalizeBadgeLabel(props.label)}</Text>
20
- </View>
21
- )
17
+ return (
18
+ <View className={props.className}>
19
+ <Text>{normalizeBadgeLabel(props.label)}</Text>
20
+ </View>
21
+ )
22
22
  }
@@ -0,0 +1,12 @@
1
+ import { defineStory } from '@octane-xplat/workshop'
2
+ import { Badge } from './Badge'
3
+
4
+ export const Basic = defineStory({
5
+ id: 'badge/basic',
6
+ title: 'Badge / Basic',
7
+ componentId: 'library/Badge',
8
+ targets: ['web', 'ios', 'android'],
9
+ component: Badge,
10
+ args: { label: 'Ready' },
11
+ controls: { label: { type: 'string' } },
12
+ })
@@ -8,5 +8,5 @@
8
8
  * ```
9
9
  */
10
10
  export function normalizeBadgeLabel(label: string): string {
11
- return label.trim()
11
+ return label.trim()
12
12
  }
@@ -1,14 +1,14 @@
1
1
  /** Props for the starter badge component. */
2
2
  export interface BadgeProps {
3
- /** Text displayed inside the badge.
4
- * @example
5
- * ```tsx
6
- * import { Badge } from 'octane-xplat-library'
7
- *
8
- * <Badge label="Ready" />
9
- * ```
10
- */
11
- label: string
12
- /** Optional class name forwarded to the outer view. */
13
- className?: string
3
+ /** Text displayed inside the badge.
4
+ * @example
5
+ * ```tsx
6
+ * import { Badge } from 'octane-xplat-library'
7
+ *
8
+ * <Badge label="Ready" />
9
+ * ```
10
+ */
11
+ label: string
12
+ /** Optional class name forwarded to the outer view. */
13
+ className?: string
14
14
  }
@@ -2,5 +2,5 @@ import { expect, it } from 'vitest'
2
2
  import { normalizeBadgeLabel } from '../src/normalizeBadgeLabel'
3
3
 
4
4
  it('trims surrounding whitespace from a badge label', () => {
5
- expect(normalizeBadgeLabel(' Ready ')).toBe('Ready')
5
+ expect(normalizeBadgeLabel(' Ready ')).toBe('Ready')
6
6
  })
@@ -1,14 +1,14 @@
1
1
  import assert from 'node:assert/strict'
2
2
  import { spawnSync } from 'node:child_process'
3
3
  import {
4
- cpSync,
5
- mkdirSync,
6
- mkdtempSync,
7
- readdirSync,
8
- readFileSync,
9
- rmSync,
10
- symlinkSync,
11
- writeFileSync,
4
+ cpSync,
5
+ mkdirSync,
6
+ mkdtempSync,
7
+ readdirSync,
8
+ readFileSync,
9
+ rmSync,
10
+ symlinkSync,
11
+ writeFileSync,
12
12
  } from 'node:fs'
13
13
 
14
14
  import { tmpdir } from 'node:os'
@@ -20,69 +20,85 @@ const sourceManifest = JSON.parse(readFileSync(join(packageRoot, 'package.json')
20
20
  const temporary = mkdtempSync(join(tmpdir(), 'octane-library-consumer-'))
21
21
 
22
22
  function run(command, args, cwd) {
23
- const result = spawnSync(command, args, { cwd, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 })
24
- if (result.stdout) {
25
- process.stdout.write(result.stdout)
26
- }
23
+ const result = spawnSync(command, args, { cwd, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 })
27
24
 
28
- if (result.stderr) {
29
- process.stderr.write(result.stderr)
30
- }
25
+ if (result.stdout) {
26
+ process.stdout.write(result.stdout)
27
+ }
31
28
 
32
- if (result.error) {
33
- throw result.error
34
- }
29
+ if (result.stderr) {
30
+ process.stderr.write(result.stderr)
31
+ }
35
32
 
36
- assert.equal(result.status, 0, `${command} ${args.join(' ')} failed`)
33
+ if (result.error) {
34
+ throw result.error
35
+ }
36
+
37
+ assert.equal(result.status, 0, `${command} ${args.join(' ')} failed`)
37
38
  }
38
39
 
39
40
  function installDirectory(root, name, destination) {
40
- const segments = name.split('/')
41
- const path = join(destination, 'node_modules', ...segments)
42
- mkdirSync(dirname(path), { recursive: true })
43
- cpSync(root, path, { recursive: true })
41
+ const segments = name.split('/')
42
+ const path = join(destination, 'node_modules', ...segments)
43
+
44
+ mkdirSync(dirname(path), { recursive: true })
45
+ cpSync(root, path, { recursive: true })
44
46
  }
45
47
 
46
48
  try {
47
- const pack = join(temporary, 'pack')
48
- const extracted = join(temporary, 'extracted')
49
- mkdirSync(pack)
50
- mkdirSync(extracted)
51
- run('bun', ['pm', 'pack', '--destination', pack], packageRoot)
52
- const tarball = readdirSync(pack).find((name) => name.endsWith('.tgz'))
53
- assert.ok(tarball)
54
- run('tar', ['-xzf', join(pack, tarball), '-C', extracted], temporary)
55
- const packed = join(extracted, 'package')
56
- const manifest = JSON.parse(readFileSync(join(packed, 'package.json'), 'utf8'))
57
- assert.ok(manifest.exports['.'].web.default.startsWith('./src/'))
58
- assert.ok(manifest.exports['.'].native.default.startsWith('./src/'))
59
- assert.ok(manifest.exports['.'].web.types)
60
- assert.ok(manifest.exports['.'].native.types)
61
-
62
- for (const target of ['web', 'native']) {
63
- for (const mode of ['bundler', 'nodenext']) {
64
- const consumer = join(temporary, `${target}-${mode}`)
65
- mkdirSync(consumer)
66
- mkdirSync(join(consumer, 'node_modules'), { recursive: true })
67
- installDirectory(packed, sourceManifest.name, consumer)
68
- for (const dependency of [
69
- 'octane',
70
- '@octane-xplat/jsx',
71
- '@octane-xplat/ui',
72
- ...(target === 'native'
73
- ? ['@nativescript-community/octane', '@nativescript/core', '@nativescript/types']
74
- : []),
75
- ]) {
76
- const source = join(packageRoot, 'node_modules', ...dependency.split('/'))
77
- const destination = join(consumer, 'node_modules', ...dependency.split('/'))
78
- mkdirSync(dirname(destination), { recursive: true })
79
- symlinkSync(source, destination, 'dir')
80
- }
81
-
82
- writeFileSync(join(consumer, 'package.json'), '{"type":"module"}')
83
- writeFileSync(
84
- join(consumer, 'consumer.tsx'),
85
- `import { Badge, type BadgeProps } from '${sourceManifest.name}'
49
+ const pack = join(temporary, 'pack')
50
+ const extracted = join(temporary, 'extracted')
51
+
52
+ mkdirSync(pack)
53
+ mkdirSync(extracted)
54
+
55
+ // Pack with the manager the scaffolded package.json declares.
56
+ const packer = (sourceManifest.packageManager ?? 'bun').split('@')[0]
57
+
58
+ if (packer === 'pnpm') {
59
+ run('pnpm', ['pack', '--pack-destination', pack], packageRoot)
60
+ } else {
61
+ run('bun', ['pm', 'pack', '--destination', pack], packageRoot)
62
+ }
63
+
64
+ const tarball = readdirSync(pack).find((name) => name.endsWith('.tgz'))
65
+
66
+ assert.ok(tarball)
67
+ run('tar', ['-xzf', join(pack, tarball), '-C', extracted], temporary)
68
+
69
+ const packed = join(extracted, 'package')
70
+ const manifest = JSON.parse(readFileSync(join(packed, 'package.json'), 'utf8'))
71
+
72
+ assert.ok(manifest.exports['.'].web.startsWith('./src/'))
73
+ assert.ok(manifest.exports['.'].native.startsWith('./src/'))
74
+ assert.ok(manifest.exports['.'].types)
75
+
76
+ for (const target of ['web', 'native']) {
77
+ for (const mode of ['bundler', 'nodenext']) {
78
+ const consumer = join(temporary, `${target}-${mode}`)
79
+
80
+ mkdirSync(consumer)
81
+ mkdirSync(join(consumer, 'node_modules'), { recursive: true })
82
+ installDirectory(packed, sourceManifest.name, consumer)
83
+ for (const dependency of [
84
+ 'octane',
85
+ '@octane-xplat/jsx',
86
+ '@octane-xplat/ui',
87
+ ...(target === 'native'
88
+ ? ['@nativescript-community/octane', '@nativescript/core', '@nativescript/types']
89
+ : []),
90
+ ]) {
91
+ const source = join(packageRoot, 'node_modules', ...dependency.split('/'))
92
+ const destination = join(consumer, 'node_modules', ...dependency.split('/'))
93
+
94
+ mkdirSync(dirname(destination), { recursive: true })
95
+ symlinkSync(source, destination, 'dir')
96
+ }
97
+
98
+ writeFileSync(join(consumer, 'package.json'), '{"type":"module"}')
99
+ writeFileSync(
100
+ join(consumer, 'consumer.tsx'),
101
+ `import { Badge, type BadgeProps } from '${sourceManifest.name}'
86
102
  const props: BadgeProps = { label: 'Ready' }
87
103
  const element = <Badge {...props} />
88
104
  // @ts-expect-error label is required
@@ -91,66 +107,67 @@ const missing = <Badge />
91
107
  const invalid = <Badge label={1} />
92
108
  void element; void missing; void invalid
93
109
  `,
94
- )
95
-
96
- writeFileSync(
97
- join(consumer, 'tsconfig.json'),
98
- JSON.stringify(
99
- {
100
- compilerOptions: {
101
- strict: true,
102
- noEmit: true,
103
- skipLibCheck: true,
104
- target: 'esnext',
105
- types: [],
106
- module: mode === 'bundler' ? 'esnext' : 'nodenext',
107
- moduleResolution: mode,
108
- jsx: 'react-jsx',
109
- jsxImportSource: target === 'native' ? '@octane-xplat/jsx' : '@octane-xplat/jsx/dom',
110
- customConditions: [target],
111
- moduleSuffixes: target === 'web' ? ['.web', ''] : ['.mobile', ''],
112
- },
113
- files: ['consumer.tsx'],
114
- },
115
- null,
116
- '\t',
117
- ),
118
- )
119
-
120
- run(
121
- process.execPath,
122
- [join(packageRoot, 'node_modules/typescript/bin/tsc'), '-p', 'tsconfig.json'],
123
- consumer,
124
- )
125
-
126
- const listed = spawnSync(
127
- process.execPath,
128
- [
129
- join(packageRoot, 'node_modules/typescript/bin/tsc'),
130
- '-p',
131
- 'tsconfig.json',
132
- '--listFilesOnly',
133
- ],
134
- { cwd: consumer, encoding: 'utf8' },
135
- )
136
-
137
- assert.equal(listed.status, 0, listed.stderr)
138
- const implementation = listed.stdout
139
- .split('\n')
140
- .filter(
141
- (file) =>
142
- file.includes(`/node_modules/${sourceManifest.name}/src/`) && !file.endsWith('.d.ts'),
143
- )
144
-
145
- assert.deepEqual(
146
- implementation,
147
- [],
148
- 'consumer types use declarations without package implementation',
149
- )
150
- }
151
- }
152
-
153
- console.log('packed consumer: web/native declarations pass Bundler and NodeNext')
110
+ )
111
+
112
+ writeFileSync(
113
+ join(consumer, 'tsconfig.json'),
114
+ JSON.stringify(
115
+ {
116
+ compilerOptions: {
117
+ strict: true,
118
+ noEmit: true,
119
+ skipLibCheck: true,
120
+ target: 'esnext',
121
+ types: [],
122
+ module: mode === 'bundler' ? 'esnext' : 'nodenext',
123
+ moduleResolution: mode,
124
+ jsx: 'react-jsx',
125
+ jsxImportSource: target === 'native' ? '@octane-xplat/jsx' : '@octane-xplat/jsx/dom',
126
+ customConditions: [target],
127
+ moduleSuffixes: target === 'web' ? ['.web', ''] : ['.mobile', ''],
128
+ },
129
+ files: ['consumer.tsx'],
130
+ },
131
+ null,
132
+ '\t',
133
+ ),
134
+ )
135
+
136
+ run(
137
+ process.execPath,
138
+ [join(packageRoot, 'node_modules/typescript/bin/tsc'), '-p', 'tsconfig.json'],
139
+ consumer,
140
+ )
141
+
142
+ const listed = spawnSync(
143
+ process.execPath,
144
+ [
145
+ join(packageRoot, 'node_modules/typescript/bin/tsc'),
146
+ '-p',
147
+ 'tsconfig.json',
148
+ '--listFilesOnly',
149
+ ],
150
+ { cwd: consumer, encoding: 'utf8' },
151
+ )
152
+
153
+ assert.equal(listed.status, 0, listed.stderr)
154
+
155
+ const implementation = listed.stdout
156
+ .split('\n')
157
+ .filter(
158
+ (file) =>
159
+ file.includes(`/node_modules/${sourceManifest.name}/src/`) && !file.endsWith('.d.ts'),
160
+ )
161
+
162
+ assert.deepEqual(
163
+ implementation,
164
+ [],
165
+ 'consumer types use declarations without package implementation',
166
+ )
167
+ }
168
+ }
169
+
170
+ console.log('packed consumer: web/native declarations pass Bundler and NodeNext')
154
171
  } finally {
155
- rmSync(temporary, { recursive: true, force: true })
172
+ rmSync(temporary, { recursive: true, force: true })
156
173
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "contentMappers": [{ "package": "@octane-xplat/cli", "extensions": [".tsrx"] }],
2
3
  "extends": "./tsconfig.json",
3
4
  "compilerOptions": {
4
5
  "jsxImportSource": "@octane-xplat/jsx"
@@ -1,4 +1,5 @@
1
1
  {
2
+ "contentMappers": [{ "package": "@octane-xplat/cli", "extensions": [".tsrx"] }],
2
3
  "compilerOptions": {
3
4
  "strict": true,
4
5
  "target": "es2022",
@@ -1,4 +1,12 @@
1
1
  {
2
+ "contentMappers": [
3
+ {
4
+ "package": "@octane-xplat/cli",
5
+ "extensions": [
6
+ ".tsrx"
7
+ ]
8
+ }
9
+ ],
2
10
  "extends": "./tsconfig.json",
3
11
  "compilerOptions": {
4
12
  "declaration": true,
@@ -7,5 +15,11 @@
7
15
  "noEmitOnError": true,
8
16
  "rootDir": "src",
9
17
  "outDir": "types"
10
- }
18
+ },
19
+ "exclude": [
20
+ "src/**/*.stories.*",
21
+ "dist",
22
+ "types",
23
+ "node_modules"
24
+ ]
11
25
  }
@@ -8,7 +8,7 @@
8
8
  ".": {
9
9
  "source": "src/index.ts",
10
10
  "runtime": ["./src/index.ts", "./src/index.web.ts"],
11
- "types": ["./types/index.d.ts", "./types/index.web.d.ts"]
11
+ "types": ["./types/index.d.ts"]
12
12
  }
13
13
  }
14
14
  }
@@ -0,0 +1,3 @@
1
+ import { defineWorkshopConfig } from '@octane-xplat/workshop'
2
+
3
+ export default defineWorkshopConfig({ stories: { include: 'src/**/*.stories.{tsx,tsrx}' } })