@evitcastudio/kit 1.3.1 → 1.4.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/README.md CHANGED
@@ -14,6 +14,31 @@ npm i @evitcastudio/kit -g
14
14
 
15
15
  *global flag is so the path is set properly for the CLI tool*
16
16
 
17
+ # Resources
18
+
19
+ This script will locate all Vylocity engine-related files within the specified directory and anonymize them before placing them in the designated resources folder.
20
+
21
+ ```bash
22
+ # From the CLI you will build all your resources to the out dir
23
+ kit build -i ./<in-dir> -o ./<out-dir>
24
+ ```
25
+
26
+ During the execution of this command, a `resource.json` file will be automatically generated within your source directory.
27
+ It is recommended to exclude this file from your version control system, as it is considered a build artifact.
28
+
29
+
30
+ > [!IMPORTANT]
31
+ > This API should be ran BEFORE VYLO.load() is called.
32
+
33
+ > [!WARNING]
34
+ > Depending on your environment the following [import syntax](https://github.com/EvitcaStudio/Kit/wiki/FAQ#importing-json-resources) for json may not work.
35
+
36
+
37
+ ```js
38
+ import resourceJSON from 'resource.json';
39
+ await Kit.setResources(resourceJSON);
40
+ ```
41
+
17
42
  # Using Kit with plugins
18
43
 
19
44
  ```ts
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /*!
4
- * @evitcastudio/kit@1.3.1 git+https://github.com/EvitcaStudio/Kit.git
5
- * Compiled Sat, 04 Jan 2025 15:50:23 UTC
4
+ * @evitcastudio/kit@1.4.0 git+https://github.com/EvitcaStudio/Kit.git
5
+ * Compiled Sat, 04 Jan 2025 17:47:08 UTC
6
6
  * Copyright (c) 2025 Jared Bates, Evitca Studio, "doubleactii"
7
7
  *
8
8
  * @evitcastudio/kit is licensed under the MIT License.
@@ -2437,8 +2437,8 @@ function initializeResourceJSON() {
2437
2437
  }
2438
2438
  function prepareFileForProcessing(filePath) {
2439
2439
  const extension = extname(filePath).slice(1);
2440
- const fileName = filePath.replace(/^.*[\\\/]/, "");
2441
- const resourceIdentifier = `${v4_default()}.${extension}`;
2440
+ const fileName = basename(filePath);
2441
+ const resourceIdentifier = `${v4_default()}.vyr`;
2442
2442
  const type = getResourceType(extension);
2443
2443
  if (!type)
2444
2444
  return;
@@ -2499,7 +2499,8 @@ async function processAllFiles() {
2499
2499
  throw new Error(`Resource not found for file: ${fileName}`);
2500
2500
  }
2501
2501
  const destination = join(resourceOutDirectory, "resources");
2502
- return copyFile(filePath, destination, resource.resourceIdentifier);
2502
+ const resourceName = resource.resourceIdentifier;
2503
+ return copyFile(filePath, destination, resourceName);
2503
2504
  });
2504
2505
  await Promise.all(copyOperations);
2505
2506
  logVerbose(`[Kit CLI] All resources have been processed.`);
@@ -2527,9 +2528,9 @@ async function copyFile(pSource, pDestinationDir, pNewName) {
2527
2528
  }
2528
2529
  }
2529
2530
  async function saveResourceJSON() {
2530
- const filePath = join(resourceOutDirectory, "resources", "resource.json");
2531
+ const filePath = "resource.json";
2531
2532
  try {
2532
- await fs.writeFile(filePath, JSON.stringify(resourceJSON, null, 2));
2533
+ await fs.writeFile(filePath, JSON.stringify(resourceJSON, null, 4));
2533
2534
  } catch (pError) {
2534
2535
  logError(`[Error] Saving resource JSON: ${pError}`);
2535
2536
  }
@@ -2572,7 +2573,7 @@ class KitCLI {
2572
2573
  // package.json
2573
2574
  var package_default = {
2574
2575
  name: "@evitcastudio/kit",
2575
- version: "1.3.1",
2576
+ version: "1.4.0",
2576
2577
  author: "doubleactii 56242467+doubleactii@users.noreply.github.com (https://evitcastudio.com)",
2577
2578
  main: "./lib/index.js",
2578
2579
  types: "./lib/index.d.ts",
package/lib/kit.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { KitPlugin } from '@evitcastudio/kit-plugin';
2
- import type { EmitterEvent, Listener, KitPluginConstructor } from './types/shared-types';
2
+ import type { EmitterEvent, ResourceData, 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.
@@ -60,6 +60,6 @@ export declare class Kit {
60
60
  /**
61
61
  * Sets the resources found in resources and preloads all interfaces found.
62
62
  */
63
- static setResources(): Promise<void>;
63
+ static setResources(pResourceJson: Record<string, ResourceData[]>): Promise<void>;
64
64
  }
65
65
  //# sourceMappingURL=kit.d.ts.map
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,KAAK,EAAE,YAAY,EAAgB,QAAQ,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAevG,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,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,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,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,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAa1F"}
package/lib/kit.js CHANGED
@@ -124,39 +124,12 @@ export class Kit {
124
124
  /**
125
125
  * Sets the resources found in resources and preloads all interfaces found.
126
126
  */
127
- static async setResources() {
127
+ static async setResources(pResourceJson) {
128
128
  if (!globalThis.VYLO) {
129
129
  throw new Error('[Kit] VYLO is not defined. Please ensure the VYLO variable is available in the global namespace.');
130
130
  }
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();
153
- }
154
- catch (pError) {
155
- console.error(`[Kit] error reading ${resourcePath}`, pError);
156
- }
157
- }
158
- if (resourceJson) {
159
- const resources = Object.values(resourceJson);
131
+ if (pResourceJson) {
132
+ const resources = Object.values(pResourceJson);
160
133
  // Group all data from separate arrays in object to one unified array of all resource data
161
134
  const consolidatedData = resources.flat();
162
135
  // Set all the resources
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evitcastudio/kit",
3
- "version": "1.3.1",
3
+ "version": "1.4.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",