@evitcastudio/kit 2.1.2 → 2.3.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/LICENSE +21 -21
- package/README.md +123 -59
- package/lib/bundle/cli/cli.js +1398 -53
- package/lib/bundle/cli/kit-game-templates/multi/README.md +5 -0
- package/lib/bundle/cli/kit-game-templates/multi/bun-build.ts +109 -0
- package/lib/bundle/cli/kit-game-templates/multi/favicon.ico +0 -0
- package/lib/bundle/cli/kit-game-templates/multi/package.json +24 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/client/c-network.ts +22 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/client/index.html +9 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/client/index.ts +45 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/client/packets/s-packets.ts +5 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/client/vendor/vylocity-game-engine/vylo.client.js +19 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/map-types.ts +9 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/resources/default-atlas.vyi +0 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/resources/default-macro.vymac +27 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/resources/main-map.vym +1 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/server/index.ts +58 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/server/packets/c-packets.ts +5 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/server/s-network.ts +16 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/server/settings.json +4 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/server/vendor/vylocity-game-engine/vylo.server.js +1 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/types/shared-types.ts +13 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/vylo.d.ts +3850 -0
- package/lib/bundle/cli/kit-game-templates/multi/tsconfig.json +28 -0
- package/lib/bundle/cli/kit-game-templates/single/README.md +5 -0
- package/lib/bundle/cli/kit-game-templates/single/bun-build.ts +33 -0
- package/lib/bundle/cli/kit-game-templates/single/bun-serve.ts +28 -0
- package/lib/bundle/cli/kit-game-templates/single/favicon.ico +0 -0
- package/lib/bundle/cli/kit-game-templates/single/package.json +23 -0
- package/lib/bundle/cli/kit-game-templates/single/src/index.html +12 -0
- package/lib/bundle/cli/kit-game-templates/single/src/index.ts +37 -0
- package/lib/bundle/cli/kit-game-templates/single/src/map-types.ts +9 -0
- package/lib/bundle/cli/kit-game-templates/single/src/resources/default-atlas.vyi +0 -0
- package/lib/bundle/cli/kit-game-templates/single/src/resources/default-macro.vymac +27 -0
- package/lib/bundle/cli/kit-game-templates/single/src/resources/main-map.vym +1 -0
- package/lib/bundle/cli/kit-game-templates/single/src/style.css +0 -0
- package/lib/bundle/cli/kit-game-templates/single/src/types/vylo.d.ts +3850 -0
- package/lib/bundle/cli/kit-game-templates/single/src/vendor/vylocity-game-engine/vylo.client.js +19 -0
- package/lib/bundle/cli/kit-game-templates/single/tsconfig.json +28 -0
- package/lib/cli/init.d.ts +15 -0
- package/lib/cli/init.d.ts.map +1 -0
- package/lib/cli/init.js +190 -0
- package/lib/cli/main.d.ts +13 -0
- package/lib/cli/main.d.ts.map +1 -0
- package/lib/cli/main.js +16 -0
- package/lib/cli/resource-builder.d.ts +6 -0
- package/lib/cli/resource-builder.d.ts.map +1 -0
- package/lib/cli/resource-builder.js +191 -0
- package/lib/cli/types.d.ts +11 -0
- package/lib/cli/types.d.ts.map +1 -0
- package/lib/cli/types.js +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/plugins/network/index.d.ts +7 -0
- package/lib/plugins/network/index.d.ts.map +1 -1
- package/lib/plugins/network/index.js +18 -5
- package/lib/types/vylo.d.ts +3848 -3848
- package/package.json +13 -5
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{PROJECT_NAME}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "{{PROJECT_AUTHOR}}",
|
|
5
|
+
"description": "",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"module": "src/index.ts",
|
|
8
|
+
"engines": {
|
|
9
|
+
"bun": ">=1.1.0"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@evitcastudio/kit": "latest"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@evitcastudio/copy-bun-plugin": "^1.0.4",
|
|
16
|
+
"@types/bun": "latest",
|
|
17
|
+
"chalk": "^5.4.1",
|
|
18
|
+
"typescript": "^5.7.2"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "kit build -v -i ./src/resources -o ./dist && bun run bun-build.ts",
|
|
22
|
+
"host": "bun run build && cd dist && node server.js"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Kit, Network } from '@evitcastudio/kit';
|
|
2
|
+
import { serverPackets } from './packets/s-packets';
|
|
3
|
+
|
|
4
|
+
Kit.registerPlugin(Network);
|
|
5
|
+
|
|
6
|
+
const networkPlugin = Kit.getPlugin<Network>('Network');
|
|
7
|
+
|
|
8
|
+
if (!networkPlugin) {
|
|
9
|
+
throw new Error('Network plugin not found.');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
networkPlugin.registerPackets(serverPackets);
|
|
13
|
+
|
|
14
|
+
networkPlugin.on('SERVER_EXAMPLE3_PACKET', (pClient: Client, pData: number, pData2: number, pData3: number) => {
|
|
15
|
+
console.log('data', pData, pData2, pData3);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
VYLO.setType('Client', {
|
|
19
|
+
onPacket(this: Client, pPacketName: string, pData: unknown[]) {
|
|
20
|
+
networkPlugin?.onNetwork(this, pPacketName, pData, true);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<HTML lang="en-us">
|
|
2
|
+
<head>
|
|
3
|
+
<meta charset="UTF-8">
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5
|
+
<title>{{PROJECT_NAME}}</title>
|
|
6
|
+
<script src="./vendor/vylocity-game-engine/vylo.client.js"></script>
|
|
7
|
+
<script type="module" src="./index.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
</HTML>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Kit } from '@evitcastudio/kit';
|
|
2
|
+
import type { Network } from '@evitcastudio/kit';
|
|
3
|
+
import '../map-types';
|
|
4
|
+
import './c-network';
|
|
5
|
+
import resourceJSON from 'resource.json';
|
|
6
|
+
|
|
7
|
+
await Kit.setResources(resourceJSON);
|
|
8
|
+
|
|
9
|
+
const networkPlugin = Kit.getPlugin<Network>('Network');
|
|
10
|
+
|
|
11
|
+
// Set the resolution of the game
|
|
12
|
+
VYLO.setType('World', {
|
|
13
|
+
onNew() {
|
|
14
|
+
console.log('World created.');
|
|
15
|
+
},
|
|
16
|
+
onMapLoaded(this: World, pName: string) {
|
|
17
|
+
console.log(`'${pName}' map loaded.`);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
VYLO.setType('Client', {
|
|
22
|
+
mainOutput: '',
|
|
23
|
+
maxFPS: 0,
|
|
24
|
+
hideFPS: false,
|
|
25
|
+
screenView: {
|
|
26
|
+
scaleTo: 'normal',
|
|
27
|
+
scaleNearest: true,
|
|
28
|
+
disableImageSmoothing: true
|
|
29
|
+
},
|
|
30
|
+
onConnect(this: Client) {
|
|
31
|
+
console.log('onConnect');
|
|
32
|
+
this.sendPacket(networkPlugin?.getPacket('SERVER_EXAMPLE2_PACKET')!, [1, 2, 3]);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
VYLO.setType('Mob/Player', {
|
|
37
|
+
onLogin(this: Diob) {
|
|
38
|
+
console.log('onLogin');
|
|
39
|
+
},
|
|
40
|
+
onLogout(this: Diob) {
|
|
41
|
+
console.log('onLogout');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
await VYLO.load();
|