create-spatius-app 0.1.3-beta.1 → 0.1.3
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/README.md +12 -10
- package/dist/cli.js +199 -207
- package/dist/templates.js +183 -199
- package/package.json +3 -3
- package/templates/cloudflare-livekit/AGENTS.md +2 -0
- package/templates/cloudflare-livekit/README.md +10 -0
- package/templates/cloudflare-livekit/agent/Dockerfile.pip +8 -0
- package/templates/cloudflare-livekit/agent/Dockerfile.uv +8 -0
- package/templates/cloudflare-livekit/agent/README.md +16 -1
- package/templates/cloudflare-livekit/agent/pyproject.toml +1 -1
- package/templates/cloudflare-livekit/agent/src/agent.py +2 -1
- package/templates/cloudflare-livekit/agent/tests/test_agent_startup.py +49 -0
- package/templates/cloudflare-livekit/agent/uv.lock +14 -14
- package/templates/cloudflare-livekit/gitignore +1 -0
- package/templates/cloudflare-livekit/package-lock.json +511 -411
- package/templates/cloudflare-livekit/package.json +17 -16
- package/templates/cloudflare-livekit/pnpm-lock.yaml +572 -480
- package/templates/cloudflare-livekit/tests/dev-fixtures.mjs +7 -2
- package/templates/cloudflare-livekit/tests/dev-supervision.test.mjs +82 -20
- package/templates/layers/agora/AGENTS.md +9 -4
- package/templates/layers/agora/README.md +14 -8
- package/templates/layers/agora/package-lock.json +6307 -4129
- package/templates/layers/agora/package.json +24 -18
- package/templates/layers/agora/pnpm-lock.yaml +1765 -563
- package/templates/layers/agora/pnpm-workspace.yaml +8 -0
- package/templates/layers/agora/scripts/check-worker.mjs +98 -0
- package/templates/layers/agora/tsconfig.worker.json +23 -0
- package/templates/layers/agora/worker/agora.test.ts +2 -0
- package/templates/layers/agora/worker/agora.ts +1 -10
- package/templates/layers/agora/worker/index.test.ts +66 -0
- package/templates/layers/agora/worker/index.ts +4 -0
- package/templates/layers/agora/wrangler.jsonc +24 -0
- package/templates/cloudflare-livekit/worker-configuration.d.ts +0 -17184
- package/templates/layers/agora/tsconfig.json +0 -16
- package/templates/layers/node/Dockerfile +0 -12
- package/templates/layers/node/dockerignore +0 -10
- package/templates/layers/node/package-lock.json +0 -5569
- package/templates/layers/node/pnpm-lock.yaml +0 -3470
- package/templates/layers/node/railway.json +0 -8
- package/templates/layers/node/scripts/dev-service.mjs +0 -14
- package/templates/layers/node/scripts/dev-web.mjs +0 -22
- package/templates/layers/node/server/index.ts +0 -92
- package/templates/layers/node/vite.config.ts +0 -17
- package/templates/layers/railway-agent/agent/railway.json +0 -5
- /package/templates/layers/agora/{env.example → dev.vars.example} +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { projectDirectory } from './agent-runtime.mjs';
|
|
3
|
-
import { runProcess } from './managed-process.mjs';
|
|
4
|
-
|
|
5
|
-
const api = process.argv[2] === 'api';
|
|
6
|
-
const result = await runProcess(
|
|
7
|
-
api ? 'tsx' : process.execPath,
|
|
8
|
-
api
|
|
9
|
-
? ['watch', '--env-file-if-exists=.env.local', 'server/index.ts']
|
|
10
|
-
: [join(projectDirectory, 'node_modules', 'vite', 'bin', 'vite.js')],
|
|
11
|
-
{ cwd: projectDirectory, env: process.env },
|
|
12
|
-
);
|
|
13
|
-
if (result.failed) console.error('Could not start the development service.');
|
|
14
|
-
process.exitCode = result.code;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { runProcess } from './managed-process.mjs';
|
|
2
|
-
import { waitForAgent } from './wait-for-agent.mjs';
|
|
3
|
-
try {
|
|
4
|
-
if (process.env.SPATIUS_DEV_READY_FILE) {
|
|
5
|
-
console.log('Waiting for the LiveKit agent to register…');
|
|
6
|
-
await waitForAgent(process.env.SPATIUS_DEV_READY_FILE);
|
|
7
|
-
console.log('LiveKit agent registered. Starting frontend and API…');
|
|
8
|
-
}
|
|
9
|
-
} catch (error) {
|
|
10
|
-
console.error(error.message);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
13
|
-
const result = await runProcess(
|
|
14
|
-
'concurrently',
|
|
15
|
-
[
|
|
16
|
-
'--kill-others',
|
|
17
|
-
'node scripts/dev-service.mjs web',
|
|
18
|
-
'node scripts/dev-service.mjs api',
|
|
19
|
-
],
|
|
20
|
-
{ cwd: process.cwd(), env: process.env },
|
|
21
|
-
);
|
|
22
|
-
process.exitCode = result.code;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createServer,
|
|
3
|
-
type IncomingMessage,
|
|
4
|
-
type ServerResponse,
|
|
5
|
-
} from 'node:http';
|
|
6
|
-
import { readFile, stat } from 'node:fs/promises';
|
|
7
|
-
import { resolve, sep, extname } from 'node:path';
|
|
8
|
-
import { handleRequest } from '../worker/index.js';
|
|
9
|
-
|
|
10
|
-
const root = resolve('dist');
|
|
11
|
-
const mime: Record<string, string> = {
|
|
12
|
-
'.html': 'text/html',
|
|
13
|
-
'.js': 'text/javascript',
|
|
14
|
-
'.css': 'text/css',
|
|
15
|
-
'.json': 'application/json',
|
|
16
|
-
'.wasm': 'application/wasm',
|
|
17
|
-
'.woff2': 'font/woff2',
|
|
18
|
-
'.svg': 'image/svg+xml',
|
|
19
|
-
'.png': 'image/png',
|
|
20
|
-
};
|
|
21
|
-
const server = createServer((incoming, outgoing) => {
|
|
22
|
-
void serve(incoming, outgoing);
|
|
23
|
-
});
|
|
24
|
-
async function serve(incoming: IncomingMessage, outgoing: ServerResponse) {
|
|
25
|
-
try {
|
|
26
|
-
const scheme = process.env.NODE_ENV === 'production' ? 'https' : 'http';
|
|
27
|
-
const origin = `${scheme}://${incoming.headers.host ?? 'localhost'}`;
|
|
28
|
-
const url = new URL(incoming.url ?? '/', origin);
|
|
29
|
-
outgoing.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
|
|
30
|
-
outgoing.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
|
|
31
|
-
if (url.pathname.startsWith('/api/')) {
|
|
32
|
-
const chunks: Buffer[] = [];
|
|
33
|
-
let size = 0;
|
|
34
|
-
for await (const raw of incoming) {
|
|
35
|
-
const chunk: unknown = raw;
|
|
36
|
-
if (!Buffer.isBuffer(chunk)) throw new Error('Invalid request body');
|
|
37
|
-
size += Buffer.byteLength(chunk);
|
|
38
|
-
if (size > 64 * 1024) {
|
|
39
|
-
outgoing.writeHead(413).end();
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
chunks.push(Buffer.from(chunk));
|
|
43
|
-
}
|
|
44
|
-
const headers = new Headers();
|
|
45
|
-
for (const [key, value] of Object.entries(incoming.headers))
|
|
46
|
-
if (value)
|
|
47
|
-
headers.set(key, Array.isArray(value) ? value.join(', ') : value);
|
|
48
|
-
const request = new Request(url, {
|
|
49
|
-
method: incoming.method,
|
|
50
|
-
headers,
|
|
51
|
-
...(['GET', 'HEAD'].includes(incoming.method ?? 'GET')
|
|
52
|
-
? {}
|
|
53
|
-
: { body: Buffer.concat(chunks) }),
|
|
54
|
-
});
|
|
55
|
-
const env = process.env;
|
|
56
|
-
const response = await handleRequest(request, env);
|
|
57
|
-
outgoing.writeHead(response.status, Object.fromEntries(response.headers));
|
|
58
|
-
outgoing.end(Buffer.from(await response.arrayBuffer()));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (!['GET', 'HEAD'].includes(incoming.method ?? '')) {
|
|
62
|
-
outgoing.writeHead(405).end();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
let path = resolve(root, '.' + decodeURIComponent(url.pathname));
|
|
66
|
-
if (!path.startsWith(root + sep) && path !== root) {
|
|
67
|
-
outgoing.writeHead(403).end();
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
if (!(await stat(path)).isFile()) path = resolve(root, 'index.html');
|
|
72
|
-
} catch {
|
|
73
|
-
if (extname(path)) {
|
|
74
|
-
outgoing.writeHead(404).end();
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
path = resolve(root, 'index.html');
|
|
78
|
-
}
|
|
79
|
-
const data = await readFile(path);
|
|
80
|
-
outgoing.setHeader(
|
|
81
|
-
'Content-Type',
|
|
82
|
-
mime[extname(path)] ?? 'application/octet-stream',
|
|
83
|
-
);
|
|
84
|
-
outgoing.end(incoming.method === 'HEAD' ? undefined : data);
|
|
85
|
-
} catch {
|
|
86
|
-
outgoing.writeHead(500).end('Request failed.');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
server.listen(Number(process.env.PORT ?? 8787), '0.0.0.0');
|
|
90
|
-
process.on('SIGTERM', () => {
|
|
91
|
-
server.close();
|
|
92
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { avatarkitVitePlugin } from '@spatius/avatarkit/vite';
|
|
2
|
-
import react from '@vitejs/plugin-react';
|
|
3
|
-
import tailwindcss from '@tailwindcss/vite';
|
|
4
|
-
import { resolve } from 'node:path';
|
|
5
|
-
import { defineConfig } from 'vite';
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
resolve: { alias: { '@': resolve(import.meta.dirname, 'web') } },
|
|
8
|
-
plugins: [react(), tailwindcss(), avatarkitVitePlugin()],
|
|
9
|
-
build: { outDir: 'dist', chunkSizeWarningLimit: 3200 },
|
|
10
|
-
server: {
|
|
11
|
-
headers: {
|
|
12
|
-
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
13
|
-
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
14
|
-
},
|
|
15
|
-
proxy: { '/api': 'http://127.0.0.1:8787' },
|
|
16
|
-
},
|
|
17
|
-
});
|
|
File without changes
|