create-octane-xplat 0.1.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/index.mjs +28 -0
- package/package.json +16 -0
- package/template/gitignore +2 -0
- package/template/index.html +12 -0
- package/template/package.json +20 -0
- package/template/pnpm-workspace.yaml +7 -0
- package/template/src/App.tsrx +35 -0
- package/template/src/main.tsrx +6 -0
- package/template/src/style.css +74 -0
- package/template/tsconfig.json +16 -0
- package/template/vite.config.ts +21 -0
package/index.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, readdirSync, cpSync, renameSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
|
+
|
|
7
|
+
const dir = resolve(process.argv[2] ?? 'octane-xplat-app');
|
|
8
|
+
|
|
9
|
+
if (existsSync(dir) && readdirSync(dir).length > 0) {
|
|
10
|
+
console.error(`✗ ${dir} exists and is not empty`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const template = join(dirname(fileURLToPath(import.meta.url)), 'template');
|
|
15
|
+
cpSync(template, dir, { recursive: true });
|
|
16
|
+
// npm packs .gitignore as a renamed file or drops it — ship it undotted.
|
|
17
|
+
try { renameSync(join(dir, 'gitignore'), join(dir, '.gitignore')); } catch {}
|
|
18
|
+
console.log(`\n✓ scaffolded ${dir}`);
|
|
19
|
+
|
|
20
|
+
const install = spawnSync('pnpm', ['install'], { cwd: dir, stdio: 'inherit' });
|
|
21
|
+
if (install.status !== 0) {
|
|
22
|
+
console.log(`\nInstall didn't finish (pnpm missing?). To run manually:`);
|
|
23
|
+
console.log(` cd ${dir}\n pnpm install\n pnpm dev`);
|
|
24
|
+
process.exit(install.status ?? 1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
console.log('\n✓ installed — starting dev server (Ctrl+C to stop)\n');
|
|
28
|
+
spawnSync('pnpm', ['dev'], { cwd: dir, stdio: 'inherit' });
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-octane-xplat",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Scaffold a minimal @octane-xplat/ui app — one Octane codebase for web + iOS + Android",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-octane-xplat": "./index.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.mjs",
|
|
11
|
+
"template"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>octane-xplat app</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsrx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "octane-xplat-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"typecheck": "tsrx-tsc --noEmit"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@octane-xplat/ui": "^0.2.0",
|
|
12
|
+
"octane": "0.4.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@octanejs/vite-plugin": "0.1.58",
|
|
16
|
+
"@tsrx/typescript-plugin": "0.4.7",
|
|
17
|
+
"typescript": "5.9.3",
|
|
18
|
+
"vite": "8.3.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# pnpm 11 settings live here, not in package.json.
|
|
2
|
+
# esbuild needs its install script to place the platform binary.
|
|
3
|
+
# @nativescript/core lands via optional peers — its scripts are native
|
|
4
|
+
# toolchain prep the ns CLI does itself; skipping keeps installs clean.
|
|
5
|
+
allowBuilds:
|
|
6
|
+
esbuild: true
|
|
7
|
+
'@nativescript/core': false
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useState } from 'octane';
|
|
2
|
+
import { View, Row, Text, Pressable, List, useColorScheme } from '@octane-xplat/ui';
|
|
3
|
+
|
|
4
|
+
const FEATURES = [
|
|
5
|
+
'shared components',
|
|
6
|
+
'platform leaves (.web / .native)',
|
|
7
|
+
'design tokens + dark mode',
|
|
8
|
+
'native navigation',
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
/** Every element here compiles for web AND for NativeScript iOS/Android —
|
|
12
|
+
* the same file, no branches. Platform divergence lives in leaf files
|
|
13
|
+
* (.web.tsrx / .native.tsrx), never inside a component. */
|
|
14
|
+
export function App() @{
|
|
15
|
+
const [count, setCount] = useState(0);
|
|
16
|
+
const [dark, setDark] = useState(false);
|
|
17
|
+
const scheme = useColorScheme();
|
|
18
|
+
|
|
19
|
+
<View className={['app', dark ? 'dark' : '']}>
|
|
20
|
+
<Text className="title">octane-xplat</Text>
|
|
21
|
+
<Text className="muted">one codebase — web · iOS · android</Text>
|
|
22
|
+
|
|
23
|
+
<Row className="counter">
|
|
24
|
+
<Pressable className="btn" onPress={() => setCount(count - 1)}><Text>−</Text></Pressable>
|
|
25
|
+
<Text className="count">{count}</Text>
|
|
26
|
+
<Pressable className="btn" onPress={() => setCount(count + 1)}><Text>+</Text></Pressable>
|
|
27
|
+
</Row>
|
|
28
|
+
|
|
29
|
+
<List items={FEATURES} renderItem={(f) => <Text className="chip">{f}</Text>} />
|
|
30
|
+
|
|
31
|
+
<Pressable className="link" onPress={() => setDark(!dark)}>
|
|
32
|
+
<Text>{dark ? 'light' : 'dark'} mode (system: {scheme})</Text>
|
|
33
|
+
</Pressable>
|
|
34
|
+
</View>
|
|
35
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* App chrome — everything here is inside the web∩native CSS grammar
|
|
2
|
+
* (see docs/css-support-matrix.md in the framework repo). Design tokens
|
|
3
|
+
* (--color-*) come from @octane-xplat/ui/theme/tokens.css; .dark re-themes
|
|
4
|
+
* the same vars — no JS color values anywhere. */
|
|
5
|
+
|
|
6
|
+
body {
|
|
7
|
+
margin: 0;
|
|
8
|
+
font-family: system-ui, sans-serif;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.app {
|
|
12
|
+
min-height: 100vh;
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
gap: 20px;
|
|
18
|
+
background-color: var(--color-surface);
|
|
19
|
+
color: var(--color-text);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.app Text {
|
|
23
|
+
color: var(--color-text);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.title {
|
|
27
|
+
font-size: 28px;
|
|
28
|
+
font-weight: bold;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.muted {
|
|
32
|
+
opacity: 0.65;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.counter {
|
|
36
|
+
align-items: center;
|
|
37
|
+
gap: 24px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.count {
|
|
41
|
+
font-size: 32px;
|
|
42
|
+
font-weight: bold;
|
|
43
|
+
min-width: 48px;
|
|
44
|
+
text-align: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.btn {
|
|
48
|
+
background-color: var(--color-primary);
|
|
49
|
+
color: var(--color-on-primary);
|
|
50
|
+
padding: 10px 20px;
|
|
51
|
+
border-radius: 10px;
|
|
52
|
+
font-size: 20px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.chip {
|
|
56
|
+
background-color: var(--color-primary);
|
|
57
|
+
color: var(--color-on-primary);
|
|
58
|
+
padding: 6px 14px;
|
|
59
|
+
border-radius: 14px;
|
|
60
|
+
font-size: 14px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.vx-list {
|
|
64
|
+
flex-direction: row;
|
|
65
|
+
flex-wrap: wrap;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
gap: 8px;
|
|
68
|
+
max-width: 420px;
|
|
69
|
+
flex-grow: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.link {
|
|
73
|
+
opacity: 0.7;
|
|
74
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"jsxImportSource": "octane",
|
|
9
|
+
"moduleSuffixes": [".web", ""],
|
|
10
|
+
"customConditions": ["web"],
|
|
11
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
12
|
+
"types": ["vite/client"],
|
|
13
|
+
"noEmit": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { octane } from '@octanejs/vite-plugin';
|
|
3
|
+
|
|
4
|
+
// The web build. For native (iOS/Android), the same source runs through
|
|
5
|
+
// @nativescript-community/vite-octane with `conditions: ['native']` and the
|
|
6
|
+
// .ios/.android/.native suffix chain — see the octane-xplat repo's
|
|
7
|
+
// apps/native/vite.config.mts.
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [...octane()],
|
|
10
|
+
server: { port: 5200 },
|
|
11
|
+
resolve: {
|
|
12
|
+
conditions: ['web'],
|
|
13
|
+
// Suffix chain (first match wins): .web → shared → fallback.
|
|
14
|
+
extensions: [
|
|
15
|
+
'.web.tsrx', '.tsrx',
|
|
16
|
+
'.web.tsx', '.tsx',
|
|
17
|
+
'.web.ts', '.mjs', '.mts', '.ts',
|
|
18
|
+
'.jsx', '.js', '.json',
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
});
|