create-octane-xplat 0.4.0 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-octane-xplat",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Scaffold a minimal @octane-xplat/ui app — one Octane codebase for web + iOS + Android",
5
5
  "bin": {
6
6
  "create-octane-xplat": "./index.mjs"
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: xplat
3
+ description: Build and review code in an Octane xplat app — one TypeScript codebase targeting web (DOM) and iOS/Android (NativeScript). Use when writing components, styles, routes, platform leaves, or device-service calls, and when a feature works on one target but not another.
4
+ ---
5
+
6
+ # Octane xplat app
7
+
8
+ Every `src/*.tsrx` file compiles twice: once to the DOM renderer, once to
9
+ NativeScript views. The common failure mode is **silent divergence** — code
10
+ that compiles and works on web but no-ops or crashes on native. The rules
11
+ below prevent that; `pnpm lint` enforces most of them.
12
+
13
+ ## Non-negotiables
14
+
15
+ 1. **One element vocabulary per file.** Shared code renders only
16
+ `@octane-xplat/ui` components. Platform divergence lives in whole files
17
+ — `Foo.web.tsrx`, `Foo.native.tsrx`, `Foo.ios.tsrx`, `Foo.android.tsrx` —
18
+ chosen by the bundler when something imports `./Foo`. Never branch on
19
+ platform inside JSX (`Platform.OS`, conditional imports, `typeof
20
+ document` checks).
21
+ 2. **No DOM globals in shared code.** `document`, `window`, `localStorage`,
22
+ DOM events — all web-only. Device capabilities (clipboard, storage,
23
+ permissions, connectivity, geolocation, …) come from
24
+ `@octane-xplat/platform`.
25
+ 3. **Styles:** `className` for anything static; `style` objects only for
26
+ values that change while the app runs. Shared CSS must use the portable
27
+ subset — the native build warns on declarations it drops
28
+ (`position: fixed`, `margin: auto`, `box-shadow`, …).
29
+ 4. **Hooks and JSX live in `.tsrx` (or `.tsx`).** Plain `.ts` is for
30
+ non-component code and may not import `.tsrx`. Import `.tsrx` files with
31
+ the explicit extension: `import { App } from './App.tsrx'`.
32
+ 5. **State = `octane/signals`.** `signal$()` for module-level shared state,
33
+ `useSignal$()` for component-local, `derived$()` for computed, `query$()`
34
+ for async data. Name signal variables with a `$` suffix (`count$`,
35
+ `user$`) — the compiler uses the suffix to preserve reactive reads on
36
+ native. Every module that reads or writes signals needs a runtime
37
+ `import 'octane/signals'` (or `octane/signals/client`).
38
+ 6. **One `octane` per app.** Don't add a second renderer or duplicate the
39
+ package — two copies break the reconciler without a helpful error.
40
+
41
+ ## Compiler rules that surprise
42
+
43
+ - `.tsrx` files can't declare `async` top-level functions — the compiler
44
+ treats them as async components and the native build fails.
45
+ - Literal `@{` in JSX text parses as a code block. Write `{'@'}{expr}` to
46
+ render a literal `@`.
47
+ - Effect dependencies are inferred from closure reads. An effect that only
48
+ writes (refs, DOM) and never reads its driving prop won't re-run —
49
+ declare deps explicitly: `useLayoutEffect(fn, [props.x])`.
50
+ - Input handlers must be idempotent — `onInput`/`onChange` can dispatch
51
+ more than once per user action on web.
52
+ - `.native.tsrx`/`.ios.tsrx`/`.android.tsrx` files containing JSX must
53
+ start with `/** @jsxImportSource @nativescript-community/octane */` on
54
+ line 1 — nothing may precede it.
55
+
56
+ ## Verify
57
+
58
+ | Command | Catches |
59
+ | --- | --- |
60
+ | `pnpm lint` | vocabulary / DOM-global / style violations — its output is authoritative |
61
+ | `pnpm typecheck` | both web and native TS configs |
62
+ | `pnpm dev` | web behavior |
63
+ | `pnpm dev:ios` / `pnpm dev:android` | the platform where behavior actually differs |
64
+
65
+ ## Read next (only when needed)
66
+
67
+ - `references/components.md` — the component vocabulary plus per-platform
68
+ divergences and name traps.
69
+ - `references/styling.md` — tokens, the portable CSS subset, dark mode.
70
+ - `references/navigation.md` — route table, links, params, stacks.
71
+ - `references/platform.md` — device services and writing your own leaf.
72
+ - Current limits and platform boundaries:
73
+ https://octane-xplat.goddardai.org/known-limits
74
+ - Full framework docs, one file:
75
+ https://octane-xplat.goddardai.org/llms-full.txt (index:
76
+ https://octane-xplat.goddardai.org/llms.txt). The `/notes/*` design
77
+ record explains *why* a constraint exists — rarely needed for app work.
@@ -0,0 +1,49 @@
1
+ # Components — the shared vocabulary
2
+
3
+ Import everything from `@octane-xplat/ui`. Each component has a web leaf
4
+ (DOM) and a native leaf (NativeScript view) — the JSX is identical on both.
5
+
6
+ | Need | Component(s) |
7
+ | --- | --- |
8
+ | Layout | `View` (aliased `Column`), `Row`, `Grid`, `Stack`, `Absolute`, `Spacer`, `SafeArea`, `KeyboardAvoiding` |
9
+ | Text | `Text`, `Heading`, `RichText` + `RichTextSpan` |
10
+ | Tap/hover | `Pressable`, `Link`, `NavLink`, `Hoverable` |
11
+ | Input | `TextInput`, `TextArea`, `Switch`, `Slider` |
12
+ | Collections | `List` |
13
+ | Scrolling | `ScrollView`, `ScrollBox` |
14
+ | Media | `Image`, `Icon` (`registerIcon`/`registerIcons` for glyphs) |
15
+ | Feedback | `ActivityIndicator`, `Meter`, `showToast` |
16
+ | Overlays | `Modal`/`openModal`, `Sheet`/`openSheet`/`closeSheet`, `Overlay`, `Popover`, `Drawer`, `openWindow` |
17
+ | Shells | `Screen`, `Tabs` (+ `TabSpec`) |
18
+ | Animation | `useAnimation` → `AnimatedValue` |
19
+ | Theme/measure | `useColorScheme`/`getColorScheme`, `useSafeAreaInsets`, `useMeasure`, `styled()`, `createStore` |
20
+
21
+ ## Divergences that matter
22
+
23
+ - `ScrollBox` is a **name trap**: on native it's a plain, non-scrolling
24
+ container (a `List` inside it owns scrolling). Use `ScrollView` when you
25
+ actually want a scroller.
26
+ - `List` is not virtualized on web. On native it must not sit inside a
27
+ `ScrollView` — two scrollers fight and the framework throws.
28
+ - `TextArea` `onSubmit`: web fires on Cmd/Ctrl+Enter; native fires only
29
+ when `returnKeyType` is `"done"` or `"send"` — otherwise every newline
30
+ reports as a submit.
31
+ - `Modal` on Android: a non-fullscreen modal shows as a centered dialog,
32
+ not a bottom sheet. Context and theme don't cross overlay roots — read
33
+ them inside the overlay or pass values down.
34
+ - `Sheet`/`openSheet` is a bottom-anchored sheet on both platforms; on web
35
+ it renders an in-window portal layer over the app.
36
+ - `Drawer` has an edge-swipe gesture on native only — give web users a
37
+ visible toggle.
38
+ - `RichTextSpan` children carry their own `className`/`style`/`onPress`;
39
+ native maps spans to `FormattedString` runs.
40
+ - Accessibility props (`accessible`, label, hint, role, state, live
41
+ region) share names across targets; native translates roles such as
42
+ `heading` → `header`.
43
+
44
+ ## Things that look right but aren't
45
+
46
+ - `PlatformBadge` is an internal probe, not app vocabulary — don't use it.
47
+ - `keyFor` on `List` is web-only.
48
+ - Route `params` must be scalar (see navigation reference) — objects work
49
+ on native but are silently dropped on web.
@@ -0,0 +1,30 @@
1
+ # Navigation
2
+
3
+ One route table serves both targets. Declare named screens and stacks;
4
+ navigate with `<Link>`/`<NavLink>` in JSX or `pushRoute`/`popRoute`/
5
+ `useRoute`/`useCanGoBack` imperatively. Web maps routes to URLs and
6
+ history; native maps them to Frame pages and the back stack — the same
7
+ call sites drive both.
8
+
9
+ ## Rules
10
+
11
+ - **Params are scalar.** They serialize as query strings on web — pass
12
+ strings and numbers. Objects survive on native and are silently dropped
13
+ on web.
14
+ - **Tabs and named stacks** (`Tabs` + `TabSpec`, `registerStack`) exist on
15
+ both targets. Use a named stack for overlay-style flows (sheets,
16
+ sidebars) that shouldn't replace the root page.
17
+ - **Deep links:** web is the URL itself; native parses incoming URLs into
18
+ the same route names — keep names stable and shareable.
19
+ - **Back** — browser back, hardware back (Android), and swipe-back (iOS)
20
+ all map to `popRoute` on the current stack.
21
+
22
+ ## Known gap
23
+
24
+ Pushing into a *named* stack is iOS-only until
25
+ [NativeScript#11444](https://github.com/NativeScript/NativeScript/issues/11444)
26
+ lands — `pushRoute` there warns loudly on Android instead of dropping
27
+ silently. Root-stack navigation works on both platforms.
28
+
29
+ For loaders, route config, and generated route types, see the navigation
30
+ guide: https://octane-xplat.goddardai.org/navigation
@@ -0,0 +1,45 @@
1
+ # Platform services + writing leaves
2
+
3
+ Two seams cover everything shared code can't reach:
4
+
5
+ ## `@octane-xplat/platform` — device services
6
+
7
+ One import per capability; each service resolves internally to a `.web` or
8
+ `.native` implementation. Surface: `device`, `appInfo`, `locale`,
9
+ `connectivity`, `useWindowSize`, `useAppState`, `useSafeAreaInsets`, deep
10
+ links, clipboard, `secureStorage`, haptics, notifications, `announce`,
11
+ `systemBars`, geolocation, permissions, media, files, share, `openUrl`,
12
+ `openSettings`, biometrics.
13
+
14
+ Services report honestly — `biometrics` returns `unsupported` on web
15
+ rather than faking a result. Handle the tier your app can fall back to
16
+ instead of assuming success.
17
+
18
+ ## Leaf files — your own divergence
19
+
20
+ When a service doesn't exist yet or a visual behavior truly differs,
21
+ split the file, not the JSX:
22
+
23
+ ```text
24
+ src/parts/Scanner.tsrx shared part — imports './Scanner.impl'
25
+ src/parts/Scanner.impl.web.ts DOM implementation (camera via getUserMedia)
26
+ src/parts/Scanner.impl.native.ts NativeScript implementation
27
+ ```
28
+
29
+ Import the bare specifier (`./Scanner.impl`); the bundler picks the leaf
30
+ via the suffix chain `.ios` → `.android` → `.native` → shared / `.web` →
31
+ shared.
32
+
33
+ Leaf rules:
34
+
35
+ - Inside a leaf, platform APIs are *expected*: DOM globals in `.web.*`,
36
+ `@nativescript/*` imports in `.native.*`. The lint rules key off the
37
+ suffix — don't fight them with suppressions.
38
+ - Never read app-level NativeScript globals (`Application.android.*`)
39
+ at module top — read them inside the call. Top-level reads crash cold
40
+ start before the app exists.
41
+ - `.native.tsrx` files with JSX start with
42
+ `/** @jsxImportSource @nativescript-community/octane */` on line 1.
43
+ - Deep imports under `@nativescript/core/ui/*` bundle as a second module
44
+ instance — import from `@nativescript/core` only.
45
+ - `console.debug` doesn't exist on device — use `console.log`.
@@ -0,0 +1,42 @@
1
+ # Styling
2
+
3
+ Two channels, chosen by *when the value is known*:
4
+
5
+ - `className` → CSS classes and design tokens. Use for anything static.
6
+ - `style={{ ... }}` → inline object for runtime values: animated offsets,
7
+ measured sizes, state-driven opacity. Don't put static styles here.
8
+
9
+ ## The portable subset
10
+
11
+ Shared CSS compiles for both targets. The native build rewrites `px` →
12
+ `dip` and warns on declarations it can't honor — `position: fixed`/`sticky`,
13
+ `margin-*: auto`, `float`, `box-shadow`, `white-space: pre-wrap`. A warning
14
+ means the property does nothing on native: restructure (flex alignment,
15
+ `Absolute`, transforms) instead of suppressing it.
16
+
17
+ NativeScript limits worth knowing before you design around them:
18
+
19
+ - A scroll container can't clip children to a parent's rounded corners —
20
+ inset separators/padding instead.
21
+ - CSS transforms reach native views only through the `transform:`
22
+ shorthand — `transform: translateX(16) scaleX(0.95)`. For motion, prefer
23
+ `useAnimation`, which composes this per platform.
24
+
25
+ ## Tokens and dark mode
26
+
27
+ `import '@octane-xplat/ui/theme/tokens.css'` (already in `main.web.tsrx`)
28
+ provides color/spacing tokens and `--font-sans`/`--font-mono` fallbacks.
29
+ The shipped utility classes (`flex-1`, `items-center`, `gap-*`, `rounded`,
30
+ `text-*`, …) mirror Tailwind v4 names and scales — write them as you would
31
+ Tailwind utilities.
32
+
33
+ Dark mode: `useColorScheme()` reads the system; the app's override pattern
34
+ is in `src/App.tsrx` — hold `boolean | null` state, apply a `dark`/`light`
35
+ class on the root, and let tokens switch underneath.
36
+
37
+ ## Fonts
38
+
39
+ Family names differ per target (web face name, iOS PostScript name,
40
+ Android filename). Ship the font file in the app, register per platform,
41
+ and set the `--font-*` tokens in `style.css`. See the styling guide at
42
+ https://octane-xplat.goddardai.org/styling for the per-target table.
@@ -0,0 +1,8 @@
1
+ # AGENTS.md
2
+
3
+ Octane xplat app — one TypeScript codebase for web + iOS + Android (Octane
4
+ + NativeScript).
5
+
6
+ Before writing code, read `.agents/skills/xplat/SKILL.md` (or invoke the
7
+ `xplat` skill). Its invariants are enforced by `pnpm lint` — violations
8
+ usually still compile but silently break on one platform.
@@ -4,6 +4,13 @@ export default {
4
4
  id: 'org.nativescript.octanexplat',
5
5
  appPath: 'src',
6
6
  appResourcesPath: 'App_Resources',
7
+ // The workspace is pnpm-managed — without this the CLI defaults to npm
8
+ // and spawns the bundler with --preserve-symlinks, which breaks isolated
9
+ // node_modules resolution (a package's transitive deps never realpath
10
+ // into the .pnpm store → ERR_MODULE_NOT_FOUND).
11
+ cli: {
12
+ packageManager: 'pnpm',
13
+ },
7
14
  android: {
8
15
  v8Flags: '--expose_gc',
9
16
  markingMode: 'none',
@@ -16,11 +16,13 @@
16
16
  "typecheck": "tsrx-tsc --noEmit && tsrx-tsc --noEmit -p tsconfig.native.json"
17
17
  },
18
18
  "dependencies": {
19
+ "@nativescript-community/gesturehandler": "2.0.45",
19
20
  "@nativescript-community/octane": "0.2.1",
20
21
  "@nativescript-community/ui-canvas": "4.6.52",
22
+ "@nativescript-community/ui-drawer": "0.1.32",
21
23
  "@nativescript-community/ui-svg": "0.2.24",
22
24
  "@nativescript/core": "9.1.2",
23
- "@octane-xplat/ui": "^0.4.0",
25
+ "@octane-xplat/ui": "^0.5.0",
24
26
  "@valor/nativescript-websockets": "2.0.3",
25
27
  "octane": "0.4.0"
26
28
  },
@@ -30,7 +32,7 @@
30
32
  "@nativescript/ios": "9.1.0",
31
33
  "@nativescript/types": "9.0.0",
32
34
  "@nativescript/vite": "8.0.11",
33
- "@octane-xplat/cli": "^0.4.0",
35
+ "@octane-xplat/cli": "^0.5.0",
34
36
  "@octane-xplat/lint": "^0.1.0",
35
37
  "@octanejs/vite-plugin": "0.1.58",
36
38
  "@tsrx/typescript-plugin": "0.4.7",
@@ -65,7 +65,7 @@ body {
65
65
 
66
66
  .btn {
67
67
  background-color: var(--color-primary);
68
- color: var(--color-on-primary);
68
+ color: var(--color-onprimary);
69
69
  padding: 10px 20px;
70
70
  border-radius: 10px;
71
71
  corner-shape: squircle;
@@ -74,7 +74,7 @@ body {
74
74
 
75
75
  .chip {
76
76
  background-color: var(--color-primary);
77
- color: var(--color-on-primary);
77
+ color: var(--color-onprimary);
78
78
  padding: 6px 14px;
79
79
  border-radius: 14px;
80
80
  corner-shape: squircle;