@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.
- package/lib/bundle/cli/cli.js +10 -16
- package/lib/event-system.d.ts +1 -1
- package/lib/event-system.d.ts.map +1 -1
- package/lib/event-system.js +0 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/kit.d.ts +2 -2
- package/lib/kit.d.ts.map +1 -1
- package/lib/kit.js +32 -18
- package/lib/types/shared-types.d.ts +19 -19
- package/lib/types/shared-types.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/bundle/cli/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
|
-
* @evitcastudio/kit@1.
|
|
5
|
-
* Compiled
|
|
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
|
|
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"
|
|
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
|
|
2511
|
+
async function clearResourceTypeDirectories(pBaseDirectory) {
|
|
2512
2512
|
try {
|
|
2513
|
-
|
|
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
|
|
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.
|
|
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
|
|
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: {
|
package/lib/event-system.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-system.d.ts","sourceRoot":"","sources":["../src/event-system.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
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"}
|
package/lib/event-system.js
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -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
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;
|
|
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,EA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
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,
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
140
|
-
|
|
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
|
-
|
|
149
|
-
|
|
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
|
-
|
|
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
|
|
11
|
+
* The data associated with the event.
|
|
5
12
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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.
|
|
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
|
|
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": {
|