@mexty/cli 1.8.2 → 1.9.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/dist/block-68f6a9dd608928af6fbea9ba/.eslintrc +14 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/.prettierrc +10 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/README.md +63 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/index.html +13 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/package-lock.json +6657 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/package.json +34 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/src/App.tsx +45 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/src/block.tsx +111 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/src/index.tsx +6 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/src/styles.css +8 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/tsconfig.json +27 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/vite.config.ts +20 -0
- package/dist/block-68f6a9dd608928af6fbea9ba/webpack.config.js +59 -0
- package/dist/block-68f6aa43608928af6fbea9c9/.eslintrc +14 -0
- package/dist/block-68f6aa43608928af6fbea9c9/.prettierrc +10 -0
- package/dist/block-68f6aa43608928af6fbea9c9/README.md +63 -0
- package/dist/block-68f6aa43608928af6fbea9c9/coco +0 -0
- package/dist/block-68f6aa43608928af6fbea9c9/index.html +13 -0
- package/dist/block-68f6aa43608928af6fbea9c9/package-lock.json +6657 -0
- package/dist/block-68f6aa43608928af6fbea9c9/package.json +34 -0
- package/dist/block-68f6aa43608928af6fbea9c9/src/App.tsx +45 -0
- package/dist/block-68f6aa43608928af6fbea9c9/src/block.tsx +111 -0
- package/dist/block-68f6aa43608928af6fbea9c9/src/index.tsx +6 -0
- package/dist/block-68f6aa43608928af6fbea9c9/src/styles.css +8 -0
- package/dist/block-68f6aa43608928af6fbea9c9/tsconfig.json +27 -0
- package/dist/block-68f6aa43608928af6fbea9c9/vite.config.ts +20 -0
- package/dist/block-68f6aa43608928af6fbea9c9/webpack.config.js +59 -0
- package/dist/coco +0 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +61 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/utils/api.d.ts +7 -0
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +4 -0
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +55 -9
- package/dist/utils/git.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/create.ts +69 -1
- package/src/commands/github-login.ts +107 -107
- package/src/utils/api.ts +5 -0
- package/src/utils/git.ts +269 -254
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"scripts": {
|
|
3
|
+
"dev": "vite",
|
|
4
|
+
"build": "webpack --config webpack.config.js --mode production",
|
|
5
|
+
"preview": "vite preview",
|
|
6
|
+
"build:dev": "vite build"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@mexty/block": "1.3.1",
|
|
10
|
+
"@mexty/realtime": "2.1.0",
|
|
11
|
+
"@react-three/drei": "^10.0.5",
|
|
12
|
+
"@react-three/fiber": "^9.1.0",
|
|
13
|
+
"@react-three/postprocessing": "^3.0.4",
|
|
14
|
+
"peerjs": "^1.5.5",
|
|
15
|
+
"react": "^19.0.0",
|
|
16
|
+
"react-dom": "^19.0.0",
|
|
17
|
+
"three": "^0.174.0",
|
|
18
|
+
"zustand": "^5.0.8"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/react": "^19.0.8",
|
|
22
|
+
"@types/react-dom": "^19.0.3",
|
|
23
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
24
|
+
"css-loader": "^6.8.0",
|
|
25
|
+
"html-webpack-plugin": "^5.5.0",
|
|
26
|
+
"style-loader": "^3.3.0",
|
|
27
|
+
"ts-loader": "^9.4.0",
|
|
28
|
+
"typescript": "^5.0.0",
|
|
29
|
+
"vite": "^6.0.7",
|
|
30
|
+
"webpack": "^5.88.0",
|
|
31
|
+
"webpack-cli": "^5.1.0",
|
|
32
|
+
"webpack-dev-server": "^4.15.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// In your App.tsx
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom/client';
|
|
4
|
+
import {Block} from "./block";
|
|
5
|
+
import './styles.css';
|
|
6
|
+
|
|
7
|
+
interface MountAPI {
|
|
8
|
+
updateProps: (props: any) => void;
|
|
9
|
+
unmount: () => void;
|
|
10
|
+
getProps: () => any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function mount(container: HTMLElement, initialProps?: any): MountAPI {
|
|
14
|
+
const root = ReactDOM.createRoot(container);
|
|
15
|
+
let currentProps = initialProps || {};
|
|
16
|
+
|
|
17
|
+
const App = () => {
|
|
18
|
+
const [props, setProps] = React.useState(currentProps);
|
|
19
|
+
|
|
20
|
+
// Expose setProps to the API
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
(window as any).__updateProps = setProps;
|
|
23
|
+
}, []);
|
|
24
|
+
|
|
25
|
+
return <Block {...props} />;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
root.render(<App />);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
updateProps: (newProps: any) => {
|
|
32
|
+
currentProps = { ...currentProps, ...newProps };
|
|
33
|
+
if ((window as any).__updateProps) {
|
|
34
|
+
(window as any).__updateProps(currentProps);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
unmount: () => {
|
|
38
|
+
delete (window as any).__updateProps;
|
|
39
|
+
root.unmount();
|
|
40
|
+
},
|
|
41
|
+
getProps: () => currentProps
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default mount;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { Suspense, useEffect, useRef } from "react";
|
|
2
|
+
import { Canvas } from "@react-three/fiber";
|
|
3
|
+
import { OrbitControls, useGLTF, useAnimations, Environment, Text, Html } from "@react-three/drei";
|
|
4
|
+
import { EffectComposer, Bloom, LUT } from "@react-three/postprocessing";
|
|
5
|
+
import * as THREE from "three";
|
|
6
|
+
|
|
7
|
+
interface BlockProps {
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
modelPath?: string;
|
|
11
|
+
autoRotate?: boolean;
|
|
12
|
+
playAnimations?: boolean;
|
|
13
|
+
cameraPosition?: [number, number, number];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function CubeCascadeModel({ modelPath = "https://content.mext.app/block/quantum_cube.glb", playAnimations = true, ...props }) {
|
|
17
|
+
const group = useRef<THREE.Group>(null);
|
|
18
|
+
const { scene, animations } = useGLTF(modelPath);
|
|
19
|
+
const { actions, names } = useAnimations(animations, group);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (actions && names.length > 0 && playAnimations) {
|
|
23
|
+
names.forEach((name) => {
|
|
24
|
+
const action = actions[name];
|
|
25
|
+
if (action) {
|
|
26
|
+
action.reset();
|
|
27
|
+
action.play();
|
|
28
|
+
action.setLoop(THREE.LoopRepeat, Infinity);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return () => {
|
|
34
|
+
if (actions && names.length > 0) {
|
|
35
|
+
names.forEach((name) => {
|
|
36
|
+
const action = actions[name];
|
|
37
|
+
if (action) {
|
|
38
|
+
console.log(`Stopping animation: ${name}`);
|
|
39
|
+
action.stop();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, [actions, names, playAnimations]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<group ref={group} {...props}>
|
|
48
|
+
<primitive object={scene} />
|
|
49
|
+
</group>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function Scene({ autoRotate = true, playAnimations = true }: { autoRotate: boolean, playAnimations?: boolean }) {
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<EffectComposer>
|
|
57
|
+
<Bloom mipmapBlur levels={9} intensity={4} luminanceThreshold={0.2} luminanceSmoothing={1} />
|
|
58
|
+
</EffectComposer>
|
|
59
|
+
<Suspense fallback={null}>
|
|
60
|
+
<CubeCascadeModel position={[0, 0, 0]} playAnimations={playAnimations} />
|
|
61
|
+
</Suspense>
|
|
62
|
+
<OrbitControls
|
|
63
|
+
|
|
64
|
+
enablePan={true}
|
|
65
|
+
enableZoom={true}
|
|
66
|
+
enableRotate={true}
|
|
67
|
+
autoRotate={autoRotate}
|
|
68
|
+
autoRotateSpeed={2}
|
|
69
|
+
maxPolarAngle={Math.PI / 2}
|
|
70
|
+
minDistance={3}
|
|
71
|
+
maxDistance={20}
|
|
72
|
+
/>
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function LoadingSpinner() {
|
|
78
|
+
return (
|
|
79
|
+
<div className="flex items-center justify-center h-full">
|
|
80
|
+
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500"></div>
|
|
81
|
+
<span className="ml-3 text-gray-600">Loading 3D Scene...</span>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const Block: React.FC<BlockProps> = ({
|
|
87
|
+
autoRotate = true,
|
|
88
|
+
playAnimations = true,
|
|
89
|
+
cameraPosition = [10, 10, 10]
|
|
90
|
+
}) => {
|
|
91
|
+
return (
|
|
92
|
+
<div className="relative w-screen h-screen">
|
|
93
|
+
<Canvas
|
|
94
|
+
camera={{ position: cameraPosition, fov: 90 }}
|
|
95
|
+
gl={{ antialias: true, alpha: true }}
|
|
96
|
+
className="w-full h-full"
|
|
97
|
+
>
|
|
98
|
+
<Suspense fallback={
|
|
99
|
+
<Html center>
|
|
100
|
+
<LoadingSpinner />
|
|
101
|
+
</Html>
|
|
102
|
+
}>
|
|
103
|
+
<Scene
|
|
104
|
+
autoRotate={autoRotate}
|
|
105
|
+
playAnimations={playAnimations}
|
|
106
|
+
/>
|
|
107
|
+
</Suspense>
|
|
108
|
+
</Canvas>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "es6"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"module": "esnext",
|
|
12
|
+
"moduleResolution": "node",
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"noEmit": false,
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
"declaration": false,
|
|
18
|
+
"outDir": "./dist"
|
|
19
|
+
},
|
|
20
|
+
"include": [
|
|
21
|
+
"**/*"
|
|
22
|
+
],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"node_modules",
|
|
25
|
+
"dist"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [react()],
|
|
6
|
+
server: {
|
|
7
|
+
open: true,
|
|
8
|
+
host: true,
|
|
9
|
+
},
|
|
10
|
+
build: {
|
|
11
|
+
sourcemap: true,
|
|
12
|
+
},
|
|
13
|
+
optimizeDeps: {
|
|
14
|
+
include: ['react', 'react-dom', '@react-three/fiber', '@react-three/drei', 'three'],
|
|
15
|
+
},
|
|
16
|
+
resolve: {
|
|
17
|
+
extensions: ['.tsx', '.ts', '.js', '.jsx'],
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
3
|
+
const { ModuleFederationPlugin } = require('webpack').container;
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
mode: 'production',
|
|
7
|
+
entry: './src/index.tsx',
|
|
8
|
+
devtool: 'source-map',
|
|
9
|
+
devServer: {
|
|
10
|
+
port: 3001,
|
|
11
|
+
open: true,
|
|
12
|
+
hot: true,
|
|
13
|
+
},
|
|
14
|
+
resolve: {
|
|
15
|
+
extensions: ['.tsx', '.ts', '.js', '.jsx'],
|
|
16
|
+
},
|
|
17
|
+
module: {
|
|
18
|
+
rules: [
|
|
19
|
+
{
|
|
20
|
+
test: /\.(tsx?|jsx?)$/,
|
|
21
|
+
use: 'ts-loader',
|
|
22
|
+
exclude: /node_modules/,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
test: /\.css$/i,
|
|
26
|
+
use: ['style-loader', 'css-loader'],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
plugins: [
|
|
31
|
+
new HtmlWebpackPlugin({
|
|
32
|
+
template: './index.html',
|
|
33
|
+
}),
|
|
34
|
+
new ModuleFederationPlugin({
|
|
35
|
+
name: 'threescene',
|
|
36
|
+
filename: 'remoteEntry.js',
|
|
37
|
+
exposes: {
|
|
38
|
+
'./Block': './src/App',
|
|
39
|
+
},
|
|
40
|
+
// CRITICAL: Empty object = no shared dependencies, full isolation
|
|
41
|
+
shared: {},
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
externals: {},
|
|
45
|
+
optimization: {
|
|
46
|
+
splitChunks: false,
|
|
47
|
+
concatenateModules: true,
|
|
48
|
+
},
|
|
49
|
+
output: {
|
|
50
|
+
filename: 'bundle.js',
|
|
51
|
+
path: path.resolve(__dirname, 'dist'),
|
|
52
|
+
clean: true,
|
|
53
|
+
library: {
|
|
54
|
+
type: 'var',
|
|
55
|
+
name: 'threescene'
|
|
56
|
+
},
|
|
57
|
+
publicPath: 'auto',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Webpack Block Template
|
|
2
|
+
|
|
3
|
+
This is a standardized template for creating Module Federation blocks in the MEXT system.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔧 **Webpack 5** with Module Federation
|
|
8
|
+
- ⚛️ **React 19** with TypeScript
|
|
9
|
+
- 🎨 **CSS Loader** support
|
|
10
|
+
- 🔥 **Hot Module Replacement** for development
|
|
11
|
+
- 📦 **Independent Dependencies** - no sharing to avoid conflicts
|
|
12
|
+
|
|
13
|
+
## Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
src/
|
|
17
|
+
├── index.tsx # Entry point for development
|
|
18
|
+
├── App.tsx # Main component (exported as ./Block)
|
|
19
|
+
└── ... # Your custom components
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Development
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install
|
|
26
|
+
npm run dev # Start development server on port 3001
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Build for Production
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run build # Creates dist/ with remoteEntry.js
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Module Federation
|
|
36
|
+
|
|
37
|
+
This template exposes:
|
|
38
|
+
- `./Block` → `./src/App` component
|
|
39
|
+
|
|
40
|
+
The block can receive props from the host application:
|
|
41
|
+
- `title?: string` - Custom title for the block
|
|
42
|
+
- `data?: any` - Any data passed from the host
|
|
43
|
+
|
|
44
|
+
## Usage as Federation Module
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
// In host application
|
|
48
|
+
const RemoteBlock = React.lazy(() => import('blockName/Block'));
|
|
49
|
+
|
|
50
|
+
<RemoteBlock title="Custom Title" data={someData} />
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Customization
|
|
54
|
+
|
|
55
|
+
1. Replace `src/App.tsx` with your custom component
|
|
56
|
+
2. Add dependencies to `package.json`
|
|
57
|
+
3. The backend will automatically use this template and inject your files
|
|
58
|
+
|
|
59
|
+
## Important Notes
|
|
60
|
+
|
|
61
|
+
- The `name` in `webpack.config.js` will be replaced automatically by the backend
|
|
62
|
+
- All dependencies are bundled independently (no sharing)
|
|
63
|
+
- CORS headers are configured for federation module loading
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
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.0">
|
|
6
|
+
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
7
|
+
<title>Mexty Block</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/index.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|