keystonemc 1.0.0 → 1.1.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/dist/core/event/eventManager.d.ts +33 -0
- package/dist/core/event/flow.d.ts +18 -0
- package/dist/core/event/priority.d.ts +8 -0
- package/dist/core/event/types.d.ts +6 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/keystone.d.ts +5 -0
- package/dist/core/math/axisAlignedBB.d.ts +114 -0
- package/dist/core/math/vector3.d.ts +225 -0
- package/dist/core/timer/timer.d.ts +94 -0
- package/dist/core/utils/debugger.d.ts +1 -0
- package/dist/index.js +988 -0
- package/dist/vite-plugin/index.d.ts +11 -0
- package/dist/vite-plugin/index.js +120 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
type PluginConfig = {
|
|
3
|
+
name: string;
|
|
4
|
+
uuid?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
authors?: string[];
|
|
7
|
+
version?: number[];
|
|
8
|
+
embedSourceMap?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const behaviorPacker: ({ name, uuid, description, authors, version, embedSourceMap, }?: PluginConfig) => Plugin;
|
|
11
|
+
export default behaviorPacker;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { resolve } from "path";
|
|
2
|
+
import * as crypto from "node:crypto";
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
const behaviorPacker = ({
|
|
5
|
+
name = "my first plugin",
|
|
6
|
+
uuid,
|
|
7
|
+
description = "",
|
|
8
|
+
authors = [],
|
|
9
|
+
version = [1, 0, 0],
|
|
10
|
+
embedSourceMap = true
|
|
11
|
+
} = {
|
|
12
|
+
name: "my first plugin",
|
|
13
|
+
description: "",
|
|
14
|
+
authors: [],
|
|
15
|
+
version: [1, 0, 0],
|
|
16
|
+
embedSourceMap: true
|
|
17
|
+
}) => ({
|
|
18
|
+
name: "BehaviorPacker",
|
|
19
|
+
config: (config) => {
|
|
20
|
+
return {
|
|
21
|
+
...config,
|
|
22
|
+
build: {
|
|
23
|
+
sourcemap: true,
|
|
24
|
+
minify: false,
|
|
25
|
+
outDir: "./dist_behavior_pack/scripts",
|
|
26
|
+
emptyOutDir: true,
|
|
27
|
+
assetsDir: "",
|
|
28
|
+
rollupOptions: {
|
|
29
|
+
external: [
|
|
30
|
+
"@minecraft/server",
|
|
31
|
+
"@minecraft/server-net",
|
|
32
|
+
"@minecraft/server-ui"
|
|
33
|
+
],
|
|
34
|
+
input: {
|
|
35
|
+
index: resolve(process.cwd(), "./src/index.ts")
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
generateBundle(options, bundle) {
|
|
42
|
+
if (!embedSourceMap) return;
|
|
43
|
+
for (const [fileName, file] of Object.entries(bundle)) {
|
|
44
|
+
if (file.type === "chunk" && file.map) {
|
|
45
|
+
const sourceMapData = file.map;
|
|
46
|
+
const embeddedSourceMap = {
|
|
47
|
+
version: sourceMapData.version,
|
|
48
|
+
sources: sourceMapData.sources,
|
|
49
|
+
sourcesContent: sourceMapData.sourcesContent,
|
|
50
|
+
mappings: sourceMapData.mappings,
|
|
51
|
+
names: sourceMapData.names
|
|
52
|
+
};
|
|
53
|
+
const sourceMapEmbed = `// ========== Embedded Source Map ==========
|
|
54
|
+
globalThis.__SOURCE_MAP__ = ${JSON.stringify(embeddedSourceMap)};
|
|
55
|
+
// ========== End of Embedded Source Map ==========
|
|
56
|
+
|
|
57
|
+
`;
|
|
58
|
+
const originalCode = file.code;
|
|
59
|
+
const modifiedCode = sourceMapEmbed + originalCode;
|
|
60
|
+
file.code = modifiedCode.replace(/\/\/# sourceMappingURL=.+$/gm, "");
|
|
61
|
+
file.map = null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for (const fileName in bundle) {
|
|
65
|
+
if (fileName.endsWith(".map")) {
|
|
66
|
+
delete bundle[fileName];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
writeBundle: async (_options, bundle) => {
|
|
71
|
+
const entryFile = Object.values(bundle).find(
|
|
72
|
+
(file) => file.type === "chunk" && file.isEntry
|
|
73
|
+
);
|
|
74
|
+
if (!entryFile || entryFile.type !== "chunk") {
|
|
75
|
+
throw new Error("No entry file found");
|
|
76
|
+
}
|
|
77
|
+
const behaviorUUID = uuid ?? crypto.randomUUID();
|
|
78
|
+
const manifestStub = {
|
|
79
|
+
"format_version": 2,
|
|
80
|
+
"header": {
|
|
81
|
+
"name": name,
|
|
82
|
+
"description": description,
|
|
83
|
+
"uuid": behaviorUUID,
|
|
84
|
+
"version": version,
|
|
85
|
+
"min_engine_version": [1, 21, 120]
|
|
86
|
+
},
|
|
87
|
+
"modules": [
|
|
88
|
+
{
|
|
89
|
+
"description": "script",
|
|
90
|
+
"type": "script",
|
|
91
|
+
"language": "javascript",
|
|
92
|
+
"uuid": crypto.randomUUID(),
|
|
93
|
+
"version": [1, 0, 0],
|
|
94
|
+
"entry": `scripts/${entryFile.fileName}`
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"dependencies": [
|
|
98
|
+
{
|
|
99
|
+
"module_name": "@minecraft/server",
|
|
100
|
+
"version": "beta"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"module_name": "@minecraft/server-ui",
|
|
104
|
+
"version": "beta"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"module_name": "@minecraft/server-net",
|
|
108
|
+
"version": "beta"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"metadata": {
|
|
112
|
+
"authors": authors
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
fs.writeFileSync("./dist_behavior_pack/manifest.json", JSON.stringify(manifestStub, null, 2));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
export {
|
|
119
|
+
behaviorPacker as default
|
|
120
|
+
};
|