@evitcastudio/kit 3.1.1 → 3.2.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.
Files changed (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +224 -123
  3. package/lib/bundle/cli/cli.js +905 -154
  4. package/lib/bundle/cli/kit-game-templates/multi/_gitignore +180 -180
  5. package/lib/bundle/cli/kit-game-templates/multi/package.json +3 -3
  6. package/lib/bundle/cli/kit-game-templates/multi/resource.json +1 -0
  7. package/lib/bundle/cli/kit-game-templates/multi/src/client/packets/s-packets.ts +4 -4
  8. package/lib/bundle/cli/kit-game-templates/multi/src/server/packets/c-packets.ts +4 -4
  9. package/lib/bundle/cli/kit-game-templates/single/_gitignore +180 -180
  10. package/lib/bundle/cli/kit-game-templates/single/package.json +3 -3
  11. package/lib/bundle/cli/kit-game-templates/single/resource.json +1 -0
  12. package/lib/cli/app-bundler.d.ts +29 -0
  13. package/lib/cli/app-bundler.d.ts.map +1 -0
  14. package/lib/cli/app-bundler.js +230 -0
  15. package/lib/cli/create.d.ts +11 -0
  16. package/lib/cli/create.d.ts.map +1 -0
  17. package/lib/cli/create.js +88 -0
  18. package/lib/cli/doctor.d.ts +9 -0
  19. package/lib/cli/doctor.d.ts.map +1 -0
  20. package/lib/cli/doctor.js +179 -0
  21. package/lib/cli/host.d.ts +49 -0
  22. package/lib/cli/host.d.ts.map +1 -0
  23. package/lib/cli/host.js +127 -0
  24. package/lib/cli/init.d.ts +2 -0
  25. package/lib/cli/init.d.ts.map +1 -1
  26. package/lib/cli/init.js +42 -15
  27. package/lib/cli/main.d.ts +22 -1
  28. package/lib/cli/main.d.ts.map +1 -1
  29. package/lib/cli/main.js +28 -1
  30. package/lib/cli/resource-builder.d.ts +1 -1
  31. package/lib/cli/resource-builder.d.ts.map +1 -1
  32. package/lib/cli/resource-builder.js +139 -19
  33. package/lib/cli/types.d.ts +12 -6
  34. package/lib/cli/types.d.ts.map +1 -1
  35. package/lib/types/vylo.d.ts +3848 -3848
  36. package/lib/vendor/vyi/index.js +26 -26
  37. package/package.json +73 -73
  38. package/lib/bundle/cli/kit-game-templates/multi/bun-build.ts +0 -109
  39. package/lib/bundle/cli/kit-game-templates/single/bun-build.ts +0 -33
  40. package/lib/bundle/cli/kit-game-templates/single/bun-serve.ts +0 -28
@@ -1,109 +0,0 @@
1
- import Bun from 'bun';
2
- import type { BunPlugin } from 'bun';
3
- import CopyBunPlugin from '@evitcastudio/copy-bun-plugin';
4
- import chalk from 'chalk';
5
-
6
- import packageJson from './package.json';
7
-
8
- const banner = [
9
- `/*!`,
10
- ` * ${packageJson.name}@${packageJson.version}`,
11
- ` * Compiled ${new Date().toUTCString().replace(/GMT/g, 'UTC')}`,
12
- ` *`,
13
- ` * ${packageJson.name} is privately licensed. All rights reserved.`,
14
- ` * Author: ${packageJson.author ?? 'Unnamed'}`,
15
- ` */`,
16
- ].join('\n');
17
-
18
- type BuildOptions = {
19
- entries: string[],
20
- outDir: string,
21
- outName: string,
22
- banner?: boolean,
23
- minify?: boolean,
24
- sourceMap?: 'none' | 'linked' | 'inline' | 'external' | undefined,
25
- plugins?: BunPlugin[],
26
- target: 'browser' | 'bun' | 'node' | undefined
27
- }
28
-
29
- export const logMessage = (pLevel: string, pMessage: string): void => {
30
- const colors: Record<string, string> = { error: '#c42847', info: '#ffa552' };
31
- const levelFormatted = pLevel.charAt(0).toUpperCase() + pLevel.slice(1);
32
- const color = colors[pLevel] || '#ffa552';
33
- console.log(chalk.hex(color)(`[Builder][${levelFormatted}]`), `${pMessage}`);
34
- };
35
-
36
- const build = async(pBuildOptions: BuildOptions): Promise<number> => {
37
- const startStamp = Date.now();
38
- const result = await Bun.build({
39
- entrypoints: pBuildOptions.entries,
40
- outdir: pBuildOptions.outDir,
41
- minify: {
42
- identifiers: pBuildOptions.minify,
43
- syntax: pBuildOptions.minify,
44
- whitespace: pBuildOptions.minify
45
- },
46
- sourcemap: pBuildOptions.sourceMap,
47
- naming: pBuildOptions.outName,
48
- target: pBuildOptions.target,
49
- plugins: pBuildOptions.plugins,
50
- banner: banner
51
- });
52
-
53
- if (!result.success) {
54
- logMessage('error', `Build failed.`);
55
- console.error(result);
56
- throw new AggregateError(result.logs, 'Build failed');
57
- }
58
-
59
- const elapsed = Date.now() - startStamp;
60
- return elapsed;
61
- }
62
-
63
- export const buildEnvs = async () => {
64
- const [ clientBuildTime, serverBuildTime ] = await Promise.all([
65
- // Client build
66
- build({
67
- entries: ['./src/client/index.ts'],
68
- outDir: './dist',
69
- outName: 'index.js',
70
- minify: true,
71
- banner: true,
72
- // sourceMap: 'linked',
73
- target: 'browser',
74
- plugins: [
75
- CopyBunPlugin({
76
- verbose: true,
77
- resources: [
78
- { src: './src/client/**/*.{html,css}', dst: 'dist/' },
79
- { src: './favicon.ico', dst: 'dist/' },
80
- { src: './src/client/vendor/vylocity-game-engine/vylo.client.js', dst: 'dist/vendor/vylocity-game-engine/' },
81
- ]
82
- })
83
- ]
84
- }),
85
- // Server build
86
- build({
87
- entries: ['./src/server/index.ts'],
88
- outDir: './dist',
89
- outName: 'server.js',
90
- banner: true,
91
- target: 'node',
92
- plugins: [
93
- CopyBunPlugin({
94
- verbose: true,
95
- resources: [
96
- { src: './src/server/settings.json', dst: 'dist/' },
97
- ]
98
- })
99
- ]
100
- })
101
- ]);
102
-
103
- logMessage('info', `Client Build took: ${clientBuildTime}ms`);
104
- logMessage('info', `Server Build took: ${serverBuildTime}ms`);
105
- }
106
-
107
- if (import.meta.main) {
108
- await buildEnvs();
109
- }
@@ -1,33 +0,0 @@
1
- import CopyBunPlugin from '@evitcastudio/copy-bun-plugin';
2
- import Bun from 'bun';
3
- import chalk from 'chalk';
4
-
5
- export const logMessage = (pLevel: string, pMessage: string): void => {
6
- const colors: Record<string, string> = { error: '#c42847', info: '#ffa552' };
7
- const levelFormatted = pLevel.charAt(0).toUpperCase() + pLevel.slice(1);
8
- const color = colors[pLevel] || '#ffa552';
9
- console.log(chalk.hex(color)(`[Builder][${levelFormatted}]`), `${pMessage}`);
10
- };
11
-
12
- if (import.meta.main) {
13
- const startStamp = Date.now();
14
-
15
- await Bun.build({
16
- entrypoints: ['./src/index.ts'],
17
- naming: 'index.js',
18
- outdir: './dist',
19
- plugins: [
20
- CopyBunPlugin({
21
- verbose: true,
22
- resources: [
23
- { src: './src/**/*.{html,css}', dst: 'dist/' },
24
- { src: './favicon.ico', dst: 'dist/' },
25
- { src: './src/vendor/vylocity-game-engine/vylo.client.js', dst: 'dist/vendor/vylocity-game-engine/' },
26
- ]
27
- })
28
- ]
29
- });
30
-
31
- const clientBuildTime = Date.now() - startStamp;
32
- logMessage('info', `Client Build took: ${clientBuildTime}ms`);
33
- }
@@ -1,28 +0,0 @@
1
- import { logMessage } from './bun-build.ts';
2
-
3
- const server = Bun.serve({
4
- port: 8090,
5
- fetch(req) {
6
- const path = new URL(req.url).pathname;
7
- // Default to index.html if the user hits the root URL
8
- const target = path === "/" ? "/index.html" : path;
9
-
10
- return new Response(Bun.file(`./dist${target}`));
11
- },
12
- });
13
-
14
- // signal interrupt event
15
- process.on('SIGINT', () => {
16
- logMessage('info', 'Shutting down server...');
17
- server.stop();
18
- process.exit(0);
19
- });
20
-
21
- // signal termination event
22
- process.on('SIGTERM', () => {
23
- logMessage('info', 'Shutting down server...');
24
- server.stop();
25
- process.exit(0);
26
- });
27
-
28
- logMessage('info', `Ready to play at http://localhost:8090`);