create-isotope-app 1.0.1
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/LICENSE +21 -0
- package/README.md +108 -0
- package/index.js +209 -0
- package/package.json +38 -0
- package/src/templates/configs/configs.js +105 -0
- package/src/templates/configs/readme.js +63 -0
- package/src/templates/configs/splitter.js +42 -0
- package/src/templates/core/kernel.js +129 -0
- package/src/templates/core/nucleus.js +49 -0
- package/src/templates/core/utils.js +68 -0
- package/src/templates/layouts/layout.js +78 -0
- package/src/templates/pages/components.js +14 -0
- package/src/templates/pages/pages.js +409 -0
- package/src/templates/styles/styles.js +356 -0
- package/templates/isotope-splitter.ts +38 -0
- package/templates/logo.png +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ATOMS GAMING / K4GFX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="docs/assets/logo.png" alt="Isotope Logo" width="200">
|
|
4
|
+
|
|
5
|
+
# Isotope Framework
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/create-isotope-app)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://github.com/atoms-gaming/isotope)
|
|
10
|
+
[](https://www.php.net/)
|
|
11
|
+
|
|
12
|
+
**Isotope** is a unified PHP & React hybrid framework designed by **ATOMS GAMING**.
|
|
13
|
+
It transforms the constraints of shared hosting into a modern development field.
|
|
14
|
+
|
|
15
|
+
**Isotope** は、ATOMS GAMING が提供する PHP と React のハイブリッドフレームワークです。
|
|
16
|
+
レンタルサーバーという制限を、モダンな開発フィールドへと変貌させます。
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## ⚛️ Concept: Atomic Fusion
|
|
23
|
+
|
|
24
|
+
Isotope fuses server-side logic and client-side UI into a single atomic structure: **The ISX File (.isx)**.
|
|
25
|
+
|
|
26
|
+
- **Nucleus (PHP)**: The server-side core. Handles DB operations and initial data fetching.
|
|
27
|
+
- **Electron (React)**: The client-side shell. Handles interactive UI and state management.
|
|
28
|
+
|
|
29
|
+
### ⚛️ Quantum Fusion (SSR/CSR)
|
|
30
|
+
|
|
31
|
+
Next.js-like developer experience on standard PHP servers.
|
|
32
|
+
|
|
33
|
+
- **Server Components (Default)**: Rendered by PHP's Quantum Engine. Zero JS sent to browser.
|
|
34
|
+
- **Client Components**: Add `"use client";` to the top to enable React hydration and HMR.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
- **Atomic Fusion (.isx)**: Write PHP and React in a single file.
|
|
39
|
+
- **Quantum SSR Engine**: PHP-only JSX rendering. No Node.js required!
|
|
40
|
+
- **Zero-API Fetching**: Data from PHP is directly available in React props.
|
|
41
|
+
- **Shared Hosting Optimized**: Runs perfectly on standard rental servers.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 🚀 Quick Start / クイックスタート
|
|
46
|
+
|
|
47
|
+
### 1. Initialize / プロジェクト生成
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx create-isotope-app my-app
|
|
51
|
+
cd my-app
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Start Development / 開発エンジンの起動
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm run dev
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> [!TIP]
|
|
61
|
+
> `npm run dev` starts both `vite` and the PHP built-in server concurrently.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 🛠 Usage / 使い方
|
|
66
|
+
|
|
67
|
+
### Unified Component (Atomic Fusion)
|
|
68
|
+
|
|
69
|
+
`app/dashboard/page.isx`
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { proton } from "../../src/isotope";
|
|
73
|
+
|
|
74
|
+
export const nucleus = proton`
|
|
75
|
+
// SERVER SIDE LOGIC (Executed on Server)
|
|
76
|
+
return [
|
|
77
|
+
'user' => 'Atoms_User',
|
|
78
|
+
'status' => 'Stable'
|
|
79
|
+
];
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
// "use client"; // Uncomment to make it a Client Component
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Renders on Server by default (Quantum Engine)
|
|
86
|
+
*/
|
|
87
|
+
export default function Page({ user, status }) {
|
|
88
|
+
return (
|
|
89
|
+
<main>
|
|
90
|
+
<h1>User: {user}</h1>
|
|
91
|
+
<p>Status: {status}</p>
|
|
92
|
+
</main>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 🚢 Deployment / デプロイ
|
|
100
|
+
|
|
101
|
+
1. Run `npm run build`.
|
|
102
|
+
2. Upload `app/`, `core/`, `public/dist/`, `index.php`, `.htaccess` to your server.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
<div align="center">
|
|
107
|
+
Produced by <strong>ATOMS GAMING</strong>
|
|
108
|
+
</div>
|
package/index.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fse from "fs-extra";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { execSync } from "child_process";
|
|
8
|
+
import readline from "readline";
|
|
9
|
+
|
|
10
|
+
// ESM 互換
|
|
11
|
+
const fs = fse.default || fse;
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
|
|
15
|
+
// テンプレートのインポート
|
|
16
|
+
import { kernelPhp } from "./src/templates/core/kernel.js";
|
|
17
|
+
import { nucleusPhp } from "./src/templates/core/nucleus.js";
|
|
18
|
+
import { bridgePhp, optimizerPhp } from "./src/templates/core/utils.js";
|
|
19
|
+
import { homePageIsx, aboutPageIsx } from "./src/templates/pages/pages.js";
|
|
20
|
+
import { linkTsx } from "./src/templates/pages/components.js";
|
|
21
|
+
import { layoutIsx } from "./src/templates/layouts/layout.js";
|
|
22
|
+
import { tailwindStyles, scssStyles } from "./src/templates/styles/styles.js";
|
|
23
|
+
import {
|
|
24
|
+
tailwindConfig,
|
|
25
|
+
postcssConfig,
|
|
26
|
+
tsConfig,
|
|
27
|
+
tsConfigNode,
|
|
28
|
+
viteConfig,
|
|
29
|
+
mainTsx,
|
|
30
|
+
} from "./src/templates/configs/configs.js";
|
|
31
|
+
import { splitterTs } from "./src/templates/configs/splitter.js";
|
|
32
|
+
import { readmeMd } from "./src/templates/configs/readme.js";
|
|
33
|
+
|
|
34
|
+
const rl = readline.createInterface({
|
|
35
|
+
input: process.stdin,
|
|
36
|
+
output: process.stdout,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const question = (query) =>
|
|
40
|
+
new Promise((resolve) => rl.question(query, resolve));
|
|
41
|
+
|
|
42
|
+
async function init() {
|
|
43
|
+
const projectName = process.argv[2] || "my-isotope-app";
|
|
44
|
+
const root = path.resolve(projectName);
|
|
45
|
+
|
|
46
|
+
// 1. ポートの競合を解消
|
|
47
|
+
console.log(chalk.cyan("🧹 Cleaning up ports 8000 and 5173..."));
|
|
48
|
+
try {
|
|
49
|
+
execSync('pkill -9 -f "vite" || true');
|
|
50
|
+
execSync('pkill -9 -f "php -S localhost:8000" || true');
|
|
51
|
+
} catch (e) {}
|
|
52
|
+
|
|
53
|
+
const args = process.argv.slice(2);
|
|
54
|
+
let styleChoice = args
|
|
55
|
+
.find((arg) => arg.startsWith("--style="))
|
|
56
|
+
?.split("=")[1];
|
|
57
|
+
|
|
58
|
+
console.log(
|
|
59
|
+
chalk.blueBright(
|
|
60
|
+
`\n⚛️ Isotope: Stabilizing new atomic structure at ${root}...\n`,
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
if (!styleChoice) {
|
|
65
|
+
styleChoice = await question(
|
|
66
|
+
"Which CSS framework? (tailwind / scss / none): ",
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
rl.close();
|
|
70
|
+
|
|
71
|
+
console.log(chalk.yellow(`\n📂 Creating project directories...`));
|
|
72
|
+
|
|
73
|
+
// 2. ディレクトリ構造の作成
|
|
74
|
+
const dirs = [
|
|
75
|
+
"app/home",
|
|
76
|
+
"app/about",
|
|
77
|
+
"app/layouts",
|
|
78
|
+
"core",
|
|
79
|
+
"public/dist",
|
|
80
|
+
"src",
|
|
81
|
+
"src/styles",
|
|
82
|
+
"src/components",
|
|
83
|
+
"docs/framework",
|
|
84
|
+
".vscode",
|
|
85
|
+
];
|
|
86
|
+
dirs.forEach((dir) => {
|
|
87
|
+
fs.ensureDirSync(path.join(root, dir));
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
console.log(chalk.yellow(`\n📝 Generating templates...`));
|
|
91
|
+
|
|
92
|
+
// 3. テンプレートの生成
|
|
93
|
+
const pkgDeps = {
|
|
94
|
+
react: "^18.2.0",
|
|
95
|
+
"react-dom": "^18.2.0",
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const pkgDevDeps = {
|
|
99
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
100
|
+
vite: "^4.3.0",
|
|
101
|
+
typescript: "^5.0.0",
|
|
102
|
+
"@types/react": "^18.2.0",
|
|
103
|
+
"@types/react-dom": "^18.2.0",
|
|
104
|
+
"@types/node": "^20.0.0",
|
|
105
|
+
concurrently: "^8.2.0",
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if (styleChoice === "tailwind") {
|
|
109
|
+
Object.assign(pkgDevDeps, {
|
|
110
|
+
tailwindcss: "^3.3.0",
|
|
111
|
+
autoprefixer: "^10.4.0",
|
|
112
|
+
postcss: "^8.4.0",
|
|
113
|
+
});
|
|
114
|
+
fs.writeFileSync(path.join(root, "tailwind.config.js"), tailwindConfig());
|
|
115
|
+
fs.writeFileSync(path.join(root, "postcss.config.js"), postcssConfig());
|
|
116
|
+
fs.writeFileSync(
|
|
117
|
+
path.join(root, "src/styles/globals.css"),
|
|
118
|
+
tailwindStyles(),
|
|
119
|
+
);
|
|
120
|
+
} else if (styleChoice === "scss") {
|
|
121
|
+
pkgDevDeps["sass"] = "^1.62.0";
|
|
122
|
+
fs.writeFileSync(path.join(root, "src/styles/globals.scss"), scssStyles());
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// コアファイル
|
|
126
|
+
fs.writeFileSync(path.join(root, "core/Kernel.php"), kernelPhp(styleChoice));
|
|
127
|
+
fs.writeFileSync(path.join(root, "core/nucleus.php"), nucleusPhp());
|
|
128
|
+
fs.writeFileSync(path.join(root, "core/Bridge.php"), bridgePhp());
|
|
129
|
+
fs.writeFileSync(path.join(root, "core/optimizer.php"), optimizerPhp());
|
|
130
|
+
fs.writeFileSync(
|
|
131
|
+
path.join(root, "index.php"),
|
|
132
|
+
`<?php require_once 'core/Kernel.php'; Isotope\\Kernel::boot();`,
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
// 設定・ビルドツール
|
|
136
|
+
fs.writeFileSync(
|
|
137
|
+
path.join(root, "src/isotope.ts"),
|
|
138
|
+
`export function proton(strings: TemplateStringsArray, ...values: any[]): any { return null; }`,
|
|
139
|
+
);
|
|
140
|
+
fs.writeFileSync(path.join(root, "src/isotope-splitter.ts"), splitterTs());
|
|
141
|
+
fs.writeFileSync(path.join(root, "src/main.tsx"), mainTsx(styleChoice));
|
|
142
|
+
fs.writeFileSync(path.join(root, "vite.config.ts"), viteConfig(styleChoice));
|
|
143
|
+
fs.writeFileSync(
|
|
144
|
+
path.join(root, "tsconfig.json"),
|
|
145
|
+
JSON.stringify(tsConfig(projectName), null, 2),
|
|
146
|
+
);
|
|
147
|
+
fs.writeFileSync(
|
|
148
|
+
path.join(root, "tsconfig.node.json"),
|
|
149
|
+
JSON.stringify(tsConfigNode(), null, 2),
|
|
150
|
+
);
|
|
151
|
+
fs.writeFileSync(path.join(root, "README.md"), readmeMd());
|
|
152
|
+
fs.writeFileSync(
|
|
153
|
+
path.join(root, ".vscode/settings.json"),
|
|
154
|
+
JSON.stringify(
|
|
155
|
+
{ "files.associations": { "*.isx": "typescriptreact" } },
|
|
156
|
+
null,
|
|
157
|
+
2,
|
|
158
|
+
),
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
// コンポーネント・ページ
|
|
162
|
+
fs.writeFileSync(path.join(root, "src/components/Link.tsx"), linkTsx());
|
|
163
|
+
fs.writeFileSync(
|
|
164
|
+
path.join(root, "app/layouts/layout.isx"),
|
|
165
|
+
layoutIsx(styleChoice),
|
|
166
|
+
);
|
|
167
|
+
fs.writeFileSync(
|
|
168
|
+
path.join(root, "app/home/page.isx"),
|
|
169
|
+
homePageIsx(styleChoice),
|
|
170
|
+
);
|
|
171
|
+
fs.writeFileSync(
|
|
172
|
+
path.join(root, "app/about/page.isx"),
|
|
173
|
+
aboutPageIsx(styleChoice),
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
// ロゴコピー
|
|
177
|
+
const logoSrc = path.join(__dirname, "templates", "logo.png");
|
|
178
|
+
if (fs.existsSync(logoSrc)) {
|
|
179
|
+
fs.copySync(logoSrc, path.join(root, "public/logo.png"));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// 4. package.json & インストール
|
|
183
|
+
const pkg = {
|
|
184
|
+
name: projectName,
|
|
185
|
+
version: "1.0.0",
|
|
186
|
+
type: "module",
|
|
187
|
+
scripts: {
|
|
188
|
+
dev: 'concurrently "vite" "php -S localhost:8000 index.php"',
|
|
189
|
+
build: "vite build",
|
|
190
|
+
preview: "vite preview",
|
|
191
|
+
},
|
|
192
|
+
dependencies: pkgDeps,
|
|
193
|
+
devDependencies: pkgDevDeps,
|
|
194
|
+
};
|
|
195
|
+
fs.writeFileSync(
|
|
196
|
+
path.join(root, "package.json"),
|
|
197
|
+
JSON.stringify(pkg, null, 2),
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
console.log(chalk.yellow(`\n📦 Installing dependencies...`));
|
|
201
|
+
try {
|
|
202
|
+
execSync(`npm install`, { cwd: root, stdio: "inherit" });
|
|
203
|
+
console.log(chalk.green(`\n🚀 Ready! cd ${projectName} && npm run dev`));
|
|
204
|
+
} catch (err) {
|
|
205
|
+
console.log(chalk.red(`\n❌ Install failed.`));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
init();
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-isotope-app",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Atomic-based PHP & React hybrid framework for ATOMS GAMING",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-isotope-app": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"index.js",
|
|
12
|
+
"src",
|
|
13
|
+
"templates",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/K4GFX/create-isotope-app.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"php",
|
|
23
|
+
"react",
|
|
24
|
+
"framework",
|
|
25
|
+
"isotope",
|
|
26
|
+
"atoms-gaming"
|
|
27
|
+
],
|
|
28
|
+
"author": "ATOMS GAMING / K4GFX",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"chalk": "^5.6.2",
|
|
32
|
+
"fs-extra": "^11.3.3"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^25.2.3",
|
|
36
|
+
"vite": "^7.3.1"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export const tailwindConfig = () =>
|
|
2
|
+
`export default { content: ["./index.php", "./src/**/*.{js,ts,jsx,tsx,isx}", "./app/**/*.{js,ts,jsx,tsx,isx}"], theme: { extend: {} }, plugins: [], }`;
|
|
3
|
+
|
|
4
|
+
export const postcssConfig = () =>
|
|
5
|
+
`export default { plugins: { tailwindcss: {}, autoprefixer: {}, }, }`;
|
|
6
|
+
|
|
7
|
+
export const tsConfig = (projectName) => ({
|
|
8
|
+
compilerOptions: {
|
|
9
|
+
target: "ESNext",
|
|
10
|
+
lib: ["DOM", "DOM.Iterable", "ESNext"],
|
|
11
|
+
module: "ESNext",
|
|
12
|
+
skipLibCheck: true,
|
|
13
|
+
moduleResolution: "node",
|
|
14
|
+
allowImportingTsExtensions: true,
|
|
15
|
+
resolveJsonModule: true,
|
|
16
|
+
isolatedModules: true,
|
|
17
|
+
noEmit: true,
|
|
18
|
+
jsx: "react-jsx",
|
|
19
|
+
strict: true,
|
|
20
|
+
noUnusedLocals: true,
|
|
21
|
+
noUnusedParameters: true,
|
|
22
|
+
noFallthroughCasesInSwitch: true,
|
|
23
|
+
baseUrl: ".",
|
|
24
|
+
paths: {
|
|
25
|
+
"@/*": ["./src/*"],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
include: ["src", "app"],
|
|
29
|
+
references: [{ path: "./tsconfig.node.json" }],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const tsConfigNode = () => ({
|
|
33
|
+
compilerOptions: {
|
|
34
|
+
composite: true,
|
|
35
|
+
skipLibCheck: true,
|
|
36
|
+
module: "ESNext",
|
|
37
|
+
moduleResolution: "node",
|
|
38
|
+
allowSyntheticDefaultImports: true,
|
|
39
|
+
},
|
|
40
|
+
include: ["vite.config.ts"],
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const viteConfig = (styleChoice) => `import { defineConfig } from 'vite';
|
|
44
|
+
import react from '@vitejs/plugin-react';
|
|
45
|
+
import isotopeSplitter from './src/isotope-splitter';
|
|
46
|
+
|
|
47
|
+
export default defineConfig({
|
|
48
|
+
plugins: [isotopeSplitter(), react({ include: /\\.(isx|tsx?|jsx?)$/ })],
|
|
49
|
+
server: { cors: true, port: 5173, strictPort: true },
|
|
50
|
+
optimizeDeps: {
|
|
51
|
+
extensions: ['.isx'],
|
|
52
|
+
esbuildOptions: {
|
|
53
|
+
loader: {
|
|
54
|
+
'.isx': 'tsx',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
build: {
|
|
59
|
+
outDir: 'public/dist',
|
|
60
|
+
manifest: true,
|
|
61
|
+
rollupOptions: {
|
|
62
|
+
input: 'src/main.tsx',
|
|
63
|
+
output: {
|
|
64
|
+
entryFileNames: 'assets/[name].js',
|
|
65
|
+
chunkFileNames: 'assets/[name].js',
|
|
66
|
+
assetFileNames: 'assets/[name].[ext]'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
export const mainTsx = (styleChoice) => `import React from 'react';
|
|
74
|
+
import ReactDOM from 'react-dom/client';
|
|
75
|
+
import Layout from '../app/layouts/layout.isx';
|
|
76
|
+
|
|
77
|
+
const rootElement = document.getElementById('isotope-nucleus');
|
|
78
|
+
if (rootElement) {
|
|
79
|
+
const protonData = JSON.parse(rootElement.getAttribute('data-proton') || '{}');
|
|
80
|
+
const electronPath = rootElement.getAttribute('data-electron') || '';
|
|
81
|
+
|
|
82
|
+
// Client-side hydration logic
|
|
83
|
+
const pages = import.meta.glob('../app/**/page.isx');
|
|
84
|
+
|
|
85
|
+
const render = async () => {
|
|
86
|
+
const pageKey = electronPath.startsWith('/') ? electronPath : '/' + electronPath;
|
|
87
|
+
const matchedKey = Object.keys(pages).find(key => key.includes(electronPath));
|
|
88
|
+
|
|
89
|
+
if (matchedKey) {
|
|
90
|
+
const mod = await pages[matchedKey]() as any;
|
|
91
|
+
const Page = mod.default;
|
|
92
|
+
|
|
93
|
+
ReactDOM.createRoot(rootElement).render(
|
|
94
|
+
<React.StrictMode>
|
|
95
|
+
<Layout>
|
|
96
|
+
<Page {...protonData} />
|
|
97
|
+
</Layout>
|
|
98
|
+
</React.StrictMode>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
render();
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export const readmeMd = () => `<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="public/logo.png" alt="Isotope Logo" width="200">
|
|
4
|
+
|
|
5
|
+
# Isotope: Atomic Fusion
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/create-isotope-app)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://github.com/atoms-gaming/isotope)
|
|
10
|
+
[](https://www.php.net/)
|
|
11
|
+
|
|
12
|
+
**Isotope** is a unified PHP & React hybrid framework designed by **ATOMS GAMING**.
|
|
13
|
+
It transforms the constraints of shared hosting into a modern development field.
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## ⚛️ Getting Started
|
|
20
|
+
|
|
21
|
+
### 1. Start Development
|
|
22
|
+
|
|
23
|
+
\`\`\`bash
|
|
24
|
+
npm run dev
|
|
25
|
+
\`\`\`
|
|
26
|
+
|
|
27
|
+
This starts the **Proton (PHP Nucleus)** on port 8000 and the **Electron (Vite)** on port 5173.
|
|
28
|
+
|
|
29
|
+
### 2. File Structure
|
|
30
|
+
|
|
31
|
+
- \`app/\`: Contains your Atomic Components (\`.isx\`).
|
|
32
|
+
- \`core/\`: Framework kernel.
|
|
33
|
+
- \`src/\`: Frontend entry points.
|
|
34
|
+
|
|
35
|
+
## 🛠 Atomic Fusion (.isx)
|
|
36
|
+
|
|
37
|
+
Write PHP and React in a single file!
|
|
38
|
+
|
|
39
|
+
\`\`\`tsx
|
|
40
|
+
import { proton } from '../../src/isotope';
|
|
41
|
+
|
|
42
|
+
export const nucleus = proton\\\`
|
|
43
|
+
// SERVER SIDE LOGIC
|
|
44
|
+
return ['message' => 'Hello from Quantum SSR'];
|
|
45
|
+
\\\`;
|
|
46
|
+
|
|
47
|
+
// "use client"; // Add this for Client Components (CSR)
|
|
48
|
+
|
|
49
|
+
export default function Page({ message }) {
|
|
50
|
+
return <h1>{message}</h1>;
|
|
51
|
+
}
|
|
52
|
+
\`\`\`
|
|
53
|
+
|
|
54
|
+
### ⚛️ Quantum Fusion (SSR/CSR)
|
|
55
|
+
- **Server Components (Default)**: Rendered by PHP. Zero JS overhead.
|
|
56
|
+
- **Client Components**: Interactive UI using React hydration.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
<div align="center">
|
|
61
|
+
Produced by <strong>ATOMS GAMING</strong>
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const splitterTs =
|
|
2
|
+
() => `import { Plugin, transformWithEsbuild } from 'vite';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
|
|
5
|
+
export default function isotopeSplitter(): Plugin {
|
|
6
|
+
return {
|
|
7
|
+
name: 'isotope-splitter',
|
|
8
|
+
enforce: 'pre',
|
|
9
|
+
async transform(code, id) {
|
|
10
|
+
const [path] = id.split('?');
|
|
11
|
+
if (path.endsWith('.isx')) {
|
|
12
|
+
const isClient = /['"]use client['"]/.test(code.replace(/\\/\\*\\s*[\\s\\S]*?\\s*\\*\\/|\\/\\/.*/g, ''));
|
|
13
|
+
if (!isClient) {
|
|
14
|
+
const stubCode = 'import React from "react"; export default function SC(props) { return <div dangerouslySetInnerHTML={{ __html: props._pageHtml }} style={{ display: "contents" }} />; }';
|
|
15
|
+
return transformWithEsbuild(stubCode, id, {
|
|
16
|
+
loader: 'tsx',
|
|
17
|
+
jsx: 'automatic',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const cleanedCode = code
|
|
21
|
+
.replace(/<\\?php[\\s\\S]*?\\?>/g, '')
|
|
22
|
+
.replace(/proton\\\`[\\s\\S]*?\\\`/g, 'null');
|
|
23
|
+
|
|
24
|
+
return transformWithEsbuild(cleanedCode, id, {
|
|
25
|
+
loader: 'tsx',
|
|
26
|
+
jsx: 'automatic',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
},
|
|
31
|
+
handleHotUpdate({ file, server }) {
|
|
32
|
+
if (file.split('?')[0].endsWith('.isx')) {
|
|
33
|
+
const mod = server.moduleGraph.getModuleById(file);
|
|
34
|
+
if (mod) {
|
|
35
|
+
server.moduleGraph.invalidateModule(mod);
|
|
36
|
+
return [mod];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
`;
|