@evitcastudio/kit 1.1.5 → 1.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.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /*!
4
- * @evitcastudio/kit@1.1.5 git+https://github.com/EvitcaStudio/Kit.git
5
- * Compiled Wed, 01 Jan 2025 08:34:38 UTC
4
+ * @evitcastudio/kit@1.3.0 git+https://github.com/EvitcaStudio/Kit.git
5
+ * Compiled Sat, 04 Jan 2025 15:43:23 UTC
6
6
  * Copyright (c) 2025 Jared Bates, Evitca Studio, "doubleactii"
7
7
  *
8
8
  * @evitcastudio/kit is licensed under the MIT License.
@@ -2491,14 +2491,14 @@ function isValidExtension(pExtension) {
2491
2491
  }
2492
2492
  async function processAllFiles() {
2493
2493
  try {
2494
- await clearResourceTypeDirectories(`${resourceOutDirectory}/resources`, RESOURCE_TYPES);
2494
+ await clearResourceTypeDirectories(`${resourceOutDirectory}/resources`);
2495
2495
  const copyOperations = resourcesToProcess.map(({ filePath, type }) => {
2496
2496
  const fileName = basename(filePath);
2497
2497
  const resource = resourceJSON[type].find((res) => res.fileName === fileName);
2498
2498
  if (!resource) {
2499
2499
  throw new Error(`Resource not found for file: ${fileName}`);
2500
2500
  }
2501
- const destination = join(resourceOutDirectory, "resources", type);
2501
+ const destination = join(resourceOutDirectory, "resources");
2502
2502
  return copyFile(filePath, destination, resource.resourceIdentifier);
2503
2503
  });
2504
2504
  await Promise.all(copyOperations);
@@ -2508,17 +2508,11 @@ async function processAllFiles() {
2508
2508
  logError(`[Error] Processing files in batch: ${pError.message}`);
2509
2509
  }
2510
2510
  }
2511
- async function clearResourceTypeDirectories(pBaseDirectory, pDirectoriesToRemove) {
2511
+ async function clearResourceTypeDirectories(pBaseDirectory) {
2512
2512
  try {
2513
- for (const directory of pDirectoriesToRemove) {
2514
- const directoryPath = join(pBaseDirectory, directory);
2515
- const directoryExists = await fs.stat(directoryPath).then((stat) => stat.isDirectory()).catch(() => false);
2516
- if (directoryExists) {
2517
- await fs.rm(directoryPath, { recursive: true });
2518
- }
2519
- }
2513
+ await fs.rm(pBaseDirectory, { recursive: true });
2520
2514
  } catch (pError) {
2521
- log(`${error(`[Error]`)} clearing directories: ${pError}`);
2515
+ log(`${error(`[Error]`)} clearing resource directory: ${pError}`);
2522
2516
  }
2523
2517
  }
2524
2518
  async function copyFile(pSource, pDestinationDir, pNewName) {
@@ -2530,7 +2524,7 @@ async function copyFile(pSource, pDestinationDir, pNewName) {
2530
2524
  }
2531
2525
  }
2532
2526
  async function saveResourceJSON() {
2533
- const filePath = join(resourceOutDirectory, "resource.json");
2527
+ const filePath = join(resourceOutDirectory, "resources", "resource.json");
2534
2528
  try {
2535
2529
  await fs.writeFile(filePath, JSON.stringify(resourceJSON, null, 2));
2536
2530
  } catch (pError) {
@@ -2575,7 +2569,7 @@ class KitCLI {
2575
2569
  // package.json
2576
2570
  var package_default = {
2577
2571
  name: "@evitcastudio/kit",
2578
- version: "1.1.5",
2572
+ version: "1.3.0",
2579
2573
  author: "doubleactii 56242467+doubleactii@users.noreply.github.com (https://evitcastudio.com)",
2580
2574
  main: "./lib/index.js",
2581
2575
  types: "./lib/index.d.ts",
@@ -2606,7 +2600,7 @@ var package_default = {
2606
2600
  pack: "bun pm pack --dry-run",
2607
2601
  "build-types": "bun tsc",
2608
2602
  build: "bun bun-build.ts",
2609
- "build-docs": "bun typedoc ./src/index.ts ./src/types/shared-types.ts",
2603
+ "build-docs": "bun typedoc ./src/index.ts",
2610
2604
  "build-all": "bun run build-types && bun run build && bun run build-docs"
2611
2605
  },
2612
2606
  bin: {
@@ -1,4 +1,4 @@
1
- import './types/shared-types';
1
+ import type { EmitterEvent, Listener } from './types/shared-types';
2
2
  import type { KitPlugin } from '@evitcastudio/kit-plugin';
3
3
  export declare class EventEmitter {
4
4
  private listener;
@@ -1 +1 @@
1
- {"version":3,"file":"event-system.d.ts","sourceRoot":"","sources":["../src/event-system.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,MAAM,CAAY;gBAEd,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS;IAKnD;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;CAcnC"}
1
+ {"version":3,"file":"event-system.d.ts","sourceRoot":"","sources":["../src/event-system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,MAAM,CAAY;gBAEd,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS;IAKnD;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;CAcnC"}
@@ -1,4 +1,3 @@
1
- import './types/shared-types';
2
1
  export class EventEmitter {
3
2
  listener;
4
3
  plugin;
package/lib/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { Kit } from './kit';
2
+ export { EventEmitter } from './event-system';
3
+ export type { EmitterEvent, ResourceData, Listener } from './types/shared-types';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
package/lib/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { Kit } from './kit';
2
+ export { EventEmitter } from './event-system';
package/lib/kit.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { KitPlugin } from '@evitcastudio/kit-plugin';
2
- import './types/shared-types';
2
+ import type { EmitterEvent, Listener, KitPluginConstructor } from './types/shared-types';
3
3
  export declare class Kit {
4
4
  /**
5
5
  * A record of all plugins registered with the Kit class.
@@ -54,7 +54,7 @@ export declare class Kit {
54
54
  static off(pPluginName: string, pEventName: string, pListener: (pData: EmitterEvent) => void): void;
55
55
  /**
56
56
  * Sets the resource locator for the engine to reference the files we have in the resources folder. interface | map | icon | macro | sound are checked for.
57
- * @param pData - An array of each file that was found in the resources folder
57
+ * @param pData - An array of each file that was found in the resources folder.
58
58
  */
59
59
  private static setResource;
60
60
  /**
package/lib/kit.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../src/kit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,sBAAsB,CAAC;AAe9B,qBAAa,GAAG;IACZ;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,OAAO,CAAiC;IACvD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAmC;IAC1D;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,MAAM,CAAuC;IAE5D,OAAO;IAIP;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAM3E;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAA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AE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAkBlF;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAInE;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM,EAAE;IAI7B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,IAAI;IAWlB;;;;;MAKE;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,GAAG,IAAI;IAQ7E;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI;IAOnG;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiB1B;;OAEG;WACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CA4C7C"}
package/lib/kit.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { EventEmitter } from './event-system';
2
- import './types/shared-types';
3
2
  const extensionToPath = {
4
3
  '.vyint': 'interface',
5
4
  '.vym': 'map',
@@ -106,7 +105,7 @@ export class Kit {
106
105
  }
107
106
  /**
108
107
  * Sets the resource locator for the engine to reference the files we have in the resources folder. interface | map | icon | macro | sound are checked for.
109
- * @param pData - An array of each file that was found in the resources folder
108
+ * @param pData - An array of each file that was found in the resources folder.
110
109
  */
111
110
  static setResource(pData) {
112
111
  pData.forEach((pResource) => {
@@ -117,7 +116,7 @@ export class Kit {
117
116
  const fileNameWithoutExtension = fileNameWithoutExtensionMatch[0];
118
117
  const resourceType = extensionToPath[extension];
119
118
  if (resourceType) {
120
- globalThis.VYLO.Resource.setResource(resourceType, fileNameWithoutExtension, `resources/${resourceType}/${pResource.resourceIdentifier}`, true);
119
+ globalThis.VYLO.Resource.setResource(resourceType, fileNameWithoutExtension, `${pResource.resourceIdentifier}`);
121
120
  }
122
121
  }
123
122
  });
@@ -129,24 +128,39 @@ export class Kit {
129
128
  if (!globalThis.VYLO) {
130
129
  throw new Error('[Kit] VYLO is not defined. Please ensure the VYLO variable is available in the global namespace.');
131
130
  }
132
- const resourcePath = './resource.json';
133
- // Load the resource json and set the resources found
134
- try {
135
- const response = await fetch(resourcePath);
136
- if (!response.ok) {
137
- throw new Error(`[Kit] HTTP error! Status: ${response.status}`);
131
+ let resourcePath = './resources/resource.json';
132
+ let resourceJson;
133
+ // Server environment (we do not use fetch as the file:// protocol is not supported atm)
134
+ if (!globalThis.window) {
135
+ const [fsPromises, path] = await Promise.all([
136
+ import('fs/promises'),
137
+ import('path')
138
+ ]);
139
+ const { readFile } = fsPromises;
140
+ resourcePath = path.resolve('resources', 'resource.json');
141
+ const data = await readFile(resourcePath, 'utf-8');
142
+ resourceJson = JSON.parse(data);
143
+ // Client environment
144
+ }
145
+ else {
146
+ // Load the resource json and set the resources found
147
+ try {
148
+ const response = await fetch(resourcePath);
149
+ if (!response.ok) {
150
+ throw new Error(`[Kit] HTTP error! Status: ${response.status}`);
151
+ }
152
+ resourceJson = await response.json();
138
153
  }
139
- const resourceJSON = await response.json();
140
- if (resourceJSON) {
141
- const resources = Object.values(resourceJSON);
142
- // Group all data from separate arrays in object to one unified array of all resource data
143
- const consolidatedData = resources.flat();
144
- // Set all the resources
145
- this.setResource(consolidatedData);
154
+ catch (pError) {
155
+ console.error(`[Kit] error reading ${resourcePath}`, pError);
146
156
  }
147
157
  }
148
- catch (pError) {
149
- console.error(`[Kit] error reading ${resourcePath}`, pError);
158
+ if (resourceJson) {
159
+ const resources = Object.values(resourceJson);
160
+ // Group all data from separate arrays in object to one unified array of all resource data
161
+ const consolidatedData = resources.flat();
162
+ // Set all the resources
163
+ this.setResource(consolidatedData);
150
164
  }
151
165
  }
152
166
  }
@@ -1,25 +1,25 @@
1
1
  import type { KitPlugin } from '@evitcastudio/kit-plugin';
2
- declare global {
2
+ /**
3
+ * The EmitterEvent type is used to define the shape of the data that is passed to the event listeners.
4
+ */
5
+ type EmitterEvent = {
6
+ /**
7
+ * The event name, e.g., "draw-frame".
8
+ */
9
+ event: string;
3
10
  /**
4
- * The EmitterEvent type is used to define the shape of the data that is passed to the event listeners.
11
+ * The data associated with the event.
5
12
  */
6
- type EmitterEvent = {
7
- /**
8
- * The event name, e.g., "draw-frame".
9
- */
10
- event: string;
11
- /**
12
- * The data associated with the event.
13
- */
14
- data?: Record<string, unknown>;
15
- } & Record<string, unknown>;
16
- type ResourceData = {
17
- resourceIdentifier: string;
18
- fileName: string;
19
- };
20
- type Listener = (pData: EmitterEvent) => void;
21
- type KitPluginConstructor<T extends KitPlugin> = new () => T;
13
+ data?: Record<string, unknown>;
14
+ } & Record<string, unknown>;
15
+ type ResourceData = {
16
+ resourceIdentifier: string;
17
+ fileName: string;
18
+ };
19
+ type Listener = (pData: EmitterEvent) => void;
20
+ type KitPluginConstructor<T extends KitPlugin> = new () => T;
21
+ declare global {
22
22
  var VYLO: VyloType;
23
23
  }
24
- export type {};
24
+ export type { EmitterEvent, ResourceData, Listener, KitPluginConstructor };
25
25
  //# sourceMappingURL=shared-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-types.d.ts","sourceRoot":"","sources":["../../src/types/shared-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,CAAC,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,YAAY,GAAG;QAChB;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QACd;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5B,KAAK,YAAY,GAAG;QAChB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,QAAQ,EAAE,MAAM,CAAA;KACnB,CAAC;IAEF,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAE9C,KAAK,oBAAoB,CAAC,CAAC,SAAS,SAAS,IAAI,UAAU,CAAC,CAAC;IAE7D,IAAI,IAAI,EAAE,QAAQ,CAAC;CACtB;AAED,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"shared-types.d.ts","sourceRoot":"","sources":["../../src/types/shared-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,KAAK,YAAY,GAAG;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,KAAK,YAAY,GAAG;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAC;AAEF,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAE9C,KAAK,oBAAoB,CAAC,CAAC,SAAS,SAAS,IAAI,UAAU,CAAC,CAAC;AAC7D,OAAO,CAAC,MAAM,CAAC;IAEX,IAAI,IAAI,EAAE,QAAQ,CAAC;CACtB;AAED,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evitcastudio/kit",
3
- "version": "1.1.5",
3
+ "version": "1.3.0",
4
4
  "author": "doubleactii 56242467+doubleactii@users.noreply.github.com (https://evitcastudio.com)",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "pack": "bun pm pack --dry-run",
32
32
  "build-types": "bun tsc",
33
33
  "build": "bun bun-build.ts",
34
- "build-docs": "bun typedoc ./src/index.ts ./src/types/shared-types.ts",
34
+ "build-docs": "bun typedoc ./src/index.ts",
35
35
  "build-all": "bun run build-types && bun run build && bun run build-docs"
36
36
  },
37
37
  "bin": {