keystonemc 4.2.0 → 4.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.
@@ -0,0 +1,50 @@
1
+ export declare class TextFormat {
2
+ static readonly ESCAPE = "\u00A7";
3
+ static readonly EOL = "\n";
4
+ static readonly BLACK: string;
5
+ static readonly DARK_BLUE: string;
6
+ static readonly DARK_GREEN: string;
7
+ static readonly DARK_AQUA: string;
8
+ static readonly DARK_RED: string;
9
+ static readonly DARK_PURPLE: string;
10
+ static readonly GOLD: string;
11
+ static readonly GRAY: string;
12
+ static readonly DARK_GRAY: string;
13
+ static readonly BLUE: string;
14
+ static readonly GREEN: string;
15
+ static readonly AQUA: string;
16
+ static readonly RED: string;
17
+ static readonly LIGHT_PURPLE: string;
18
+ static readonly YELLOW: string;
19
+ static readonly WHITE: string;
20
+ static readonly MINECOIN_GOLD: string;
21
+ static readonly MATERIAL_QUARTZ: string;
22
+ static readonly MATERIAL_IRON: string;
23
+ static readonly MATERIAL_NETHERITE: string;
24
+ static readonly MATERIAL_REDSTONE: string;
25
+ static readonly MATERIAL_COPPER: string;
26
+ static readonly MATERIAL_GOLD: string;
27
+ static readonly MATERIAL_EMERALD: string;
28
+ static readonly MATERIAL_DIAMOND: string;
29
+ static readonly MATERIAL_LAPIS: string;
30
+ static readonly MATERIAL_AMETHYST: string;
31
+ static readonly MATERIAL_RESIN: string;
32
+ static readonly COLORS: Readonly<Record<string, string>>;
33
+ static readonly OBFUSCATED: string;
34
+ static readonly BOLD: string;
35
+ static readonly ITALIC: string;
36
+ static readonly FORMATS: Readonly<Record<string, string>>;
37
+ static readonly RESET: string;
38
+ static tokenize(input: string): string[];
39
+ static clean(input: string): string;
40
+ static colorize(input: string, placeholder?: string): string;
41
+ static addBase(baseFormat: string, input: string): string;
42
+ /**
43
+ * Converts Java formatting to Bedrock-compatible formatting
44
+ */
45
+ static javaToBedrock(input: string): string;
46
+ /**
47
+ * Converts Minecraft formatting to HTML
48
+ */
49
+ static toHTML(input: string): string;
50
+ }
@@ -1,4 +1,34 @@
1
1
  import { Plugin } from 'vite';
2
+ type ManifestStub = {
3
+ format_version?: number;
4
+ header?: {
5
+ name?: string;
6
+ description?: string;
7
+ uuid?: string;
8
+ version?: number[];
9
+ min_engine_version?: number[];
10
+ [key: string]: unknown;
11
+ };
12
+ modules?: Array<{
13
+ description?: string;
14
+ type?: string;
15
+ language?: string;
16
+ uuid?: string;
17
+ version?: number[];
18
+ entry?: string;
19
+ [key: string]: unknown;
20
+ }>;
21
+ dependencies?: Array<{
22
+ module_name?: string;
23
+ version?: string;
24
+ [key: string]: unknown;
25
+ }>;
26
+ metadata?: {
27
+ authors?: string[];
28
+ [key: string]: unknown;
29
+ };
30
+ [key: string]: unknown;
31
+ };
2
32
  type PluginConfig = {
3
33
  name: string;
4
34
  uuid?: string;
@@ -6,6 +36,7 @@ type PluginConfig = {
6
36
  authors?: string[];
7
37
  version?: number[];
8
38
  embedSourceMap?: boolean;
39
+ manifest?: ManifestStub;
9
40
  };
10
- declare const behaviorPacker: ({ name, uuid, description, authors, version, embedSourceMap, }?: PluginConfig) => Plugin;
41
+ declare const behaviorPacker: ({ name, uuid, description, authors, version, embedSourceMap, manifest: manifestOverride, }?: PluginConfig) => Plugin;
11
42
  export default behaviorPacker;
@@ -1,13 +1,50 @@
1
1
  import { resolve, relative } from "path";
2
2
  import * as crypto from "node:crypto";
3
3
  import * as fs from "node:fs";
4
+ const mergeArrayByKey = (target, source, key) => {
5
+ const result = [...target];
6
+ for (const sourceItem of source) {
7
+ const keyValue = sourceItem[key];
8
+ const existingIndex = result.findIndex((item) => item[key] === keyValue);
9
+ if (existingIndex >= 0) {
10
+ result[existingIndex] = { ...result[existingIndex], ...sourceItem };
11
+ } else {
12
+ result.push(sourceItem);
13
+ }
14
+ }
15
+ return result;
16
+ };
17
+ const ARRAY_MERGE_KEYS = {
18
+ dependencies: "module_name",
19
+ modules: "type"
20
+ };
21
+ const deepMerge = (target, source) => {
22
+ const result = { ...target };
23
+ for (const key in source) {
24
+ const sourceValue = source[key];
25
+ const targetValue = target[key];
26
+ if (Array.isArray(sourceValue) && Array.isArray(targetValue) && ARRAY_MERGE_KEYS[key]) {
27
+ result[key] = mergeArrayByKey(
28
+ targetValue,
29
+ sourceValue,
30
+ ARRAY_MERGE_KEYS[key]
31
+ );
32
+ } else if (sourceValue && typeof sourceValue === "object" && !Array.isArray(sourceValue) && targetValue && typeof targetValue === "object" && !Array.isArray(targetValue)) {
33
+ result[key] = deepMerge(targetValue, sourceValue);
34
+ } else if (sourceValue !== void 0) {
35
+ result[key] = sourceValue;
36
+ }
37
+ }
38
+ return result;
39
+ };
4
40
  const behaviorPacker = ({
5
41
  name = "my first plugin",
6
42
  uuid,
7
43
  description = "",
8
44
  authors = [],
9
45
  version = [1, 0, 0],
10
- embedSourceMap = true
46
+ embedSourceMap = true,
47
+ manifest: manifestOverride
11
48
  } = {
12
49
  name: "my first plugin",
13
50
  description: "",
@@ -28,7 +65,8 @@ const behaviorPacker = ({
28
65
  external: [
29
66
  "@minecraft/server",
30
67
  "@minecraft/server-net",
31
- "@minecraft/server-ui"
68
+ "@minecraft/server-ui",
69
+ "@minecraft/server-admin"
32
70
  ],
33
71
  input: {
34
72
  index: resolve(process.cwd(), "./src/index.ts")
@@ -114,7 +152,8 @@ globalThis.__SOURCE_MAP__ = ${JSON.stringify(embeddedSourceMap)};
114
152
  "authors": authors
115
153
  }
116
154
  };
117
- fs.writeFileSync("./dist/behavior_pack/manifest.json", JSON.stringify(manifestStub, null, 2));
155
+ const finalManifest = manifestOverride ? deepMerge(manifestStub, manifestOverride) : manifestStub;
156
+ fs.writeFileSync("./dist/behavior_pack/manifest.json", JSON.stringify(finalManifest, null, 2));
118
157
  }
119
158
  });
120
159
  const supportJsx = () => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keystonemc",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "ScriptAPI Wrapper",
5
5
  "type": "module",
6
6
  "scripts": {