@argila/core 0.0.0-alpha-20250607064138

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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Argila.d.ts +24 -0
  3. package/dist/Argila.d.ts.map +1 -0
  4. package/dist/Argila.js +62 -0
  5. package/dist/Argila.test.d.ts +2 -0
  6. package/dist/Argila.test.d.ts.map +1 -0
  7. package/dist/Argila.test.js +150 -0
  8. package/dist/Canvas.d.ts +117 -0
  9. package/dist/Canvas.d.ts.map +1 -0
  10. package/dist/Canvas.js +311 -0
  11. package/dist/Canvas.test.d.ts +2 -0
  12. package/dist/Canvas.test.d.ts.map +1 -0
  13. package/dist/Canvas.test.js +311 -0
  14. package/dist/Common.d.ts +11 -0
  15. package/dist/Common.d.ts.map +1 -0
  16. package/dist/Common.js +64 -0
  17. package/dist/Common.test.js +118 -0
  18. package/dist/Event.d.ts +10 -0
  19. package/dist/Event.d.ts.map +1 -0
  20. package/dist/Event.js +23 -0
  21. package/dist/Event.test.js +72 -0
  22. package/dist/LinkedList.d.ts +44 -0
  23. package/dist/LinkedList.d.ts.map +1 -0
  24. package/dist/LinkedList.js +95 -0
  25. package/dist/LinkedList.test.d.ts +2 -0
  26. package/dist/LinkedList.test.d.ts.map +1 -0
  27. package/dist/LinkedList.test.js +197 -0
  28. package/dist/Vector3.d.ts +104 -0
  29. package/dist/Vector3.d.ts.map +1 -0
  30. package/dist/Vector3.js +185 -0
  31. package/dist/Vector3.test.d.ts +2 -0
  32. package/dist/Vector3.test.d.ts.map +1 -0
  33. package/dist/Vector3.test.js +127 -0
  34. package/dist/common.test.d.ts +2 -0
  35. package/dist/common.test.d.ts.map +1 -0
  36. package/dist/event.test.d.ts +2 -0
  37. package/dist/event.test.d.ts.map +1 -0
  38. package/dist/index.d.ts +29 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +41 -0
  41. package/dist/systems/Draw.d.ts +8 -0
  42. package/dist/systems/Draw.d.ts.map +1 -0
  43. package/dist/systems/Draw.js +15 -0
  44. package/dist/systems/Entity.d.ts +18 -0
  45. package/dist/systems/Entity.d.ts.map +1 -0
  46. package/dist/systems/Entity.js +44 -0
  47. package/dist/systems/Input.d.ts +127 -0
  48. package/dist/systems/Input.d.ts.map +1 -0
  49. package/dist/systems/Input.js +191 -0
  50. package/dist/systems/Loop.d.ts +29 -0
  51. package/dist/systems/Loop.d.ts.map +1 -0
  52. package/dist/systems/Loop.js +93 -0
  53. package/dist/systems/Render.d.ts +21 -0
  54. package/dist/systems/Render.d.ts.map +1 -0
  55. package/dist/systems/Render.js +112 -0
  56. package/dist/systems/Shape.d.ts +48 -0
  57. package/dist/systems/Shape.d.ts.map +1 -0
  58. package/dist/systems/Shape.js +146 -0
  59. package/dist/systems/System.d.ts +22 -0
  60. package/dist/systems/System.d.ts.map +1 -0
  61. package/dist/systems/System.js +20 -0
  62. package/dist/systems/World.d.ts +24 -0
  63. package/dist/systems/World.d.ts.map +1 -0
  64. package/dist/systems/World.js +84 -0
  65. package/dist/systems/debugs/Debug.d.ts +9 -0
  66. package/dist/systems/debugs/Debug.d.ts.map +1 -0
  67. package/dist/systems/debugs/Debug.js +12 -0
  68. package/dist/systems/debugs/InputDebug.d.ts +7 -0
  69. package/dist/systems/debugs/InputDebug.d.ts.map +1 -0
  70. package/dist/systems/debugs/InputDebug.js +11 -0
  71. package/dist/systems/debugs/LoopDebug.d.ts +7 -0
  72. package/dist/systems/debugs/LoopDebug.d.ts.map +1 -0
  73. package/dist/systems/debugs/LoopDebug.js +11 -0
  74. package/package.json +79 -0
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ import { v4 as uuidv4 } from "uuid";
3
+ export class System {
4
+ static id = uuidv4();
5
+ static debug;
6
+ static list = /* @__PURE__ */ new Map();
7
+ static loopType = "entity";
8
+ static has(entity) {
9
+ if (!this.list) {
10
+ return false;
11
+ }
12
+ return this.list.has(entity);
13
+ }
14
+ static tick(..._args) {
15
+ throw new Error(`${this.id} doesn't implement tick()`);
16
+ }
17
+ static clear() {
18
+ throw new Error(`${this.id} doesn't implement clear()`);
19
+ }
20
+ }
@@ -0,0 +1,24 @@
1
+ import { ISystem, System } from "./System";
2
+ export interface WorldConfig {
3
+ id: string;
4
+ name: string;
5
+ rate: number;
6
+ disabled: boolean;
7
+ entities: Set<string>;
8
+ systems: Set<ISystem>;
9
+ }
10
+ export default class World extends System {
11
+ static id: string;
12
+ static list: Map<string, WorldConfig>;
13
+ static create(name?: string, rate?: number, disabled?: boolean): string;
14
+ static get(world: string): WorldConfig | undefined;
15
+ static addSystem(world: string, system: ISystem): void;
16
+ static removeSystem(world: string, system: ISystem): void;
17
+ static addEntity(world: string, entity: string): void;
18
+ static removeEntity(world: string, entity: string): void;
19
+ static forEach(callback: (world: string) => void): void;
20
+ static tick(dt: number, world: string): void;
21
+ static destroy(world: string): void;
22
+ static clear(): void;
23
+ }
24
+ //# sourceMappingURL=World.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"World.d.ts","sourceRoot":"","sources":["../../src/systems/World.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,MAAM;IACxC,MAAM,CAAC,EAAE,SAAW;IAEpB,OAAc,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAa;WAE3C,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,SAAI,EAAE,QAAQ,UAAQ,GAAG,MAAM;WAezD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;WAI3C,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;WAO/C,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;WAOlD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;WAO9C,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;WAOjD,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;WAMhD,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;WAiCrC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAI5B,KAAK,IAAI,IAAI;CAG3B"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ import { v4 as uuidv4 } from "uuid";
3
+ import { System } from "./System";
4
+ export default class World extends System {
5
+ static id = "world";
6
+ static list = /* @__PURE__ */ new Map();
7
+ static create(name, rate = 1, disabled = false) {
8
+ const id = uuidv4();
9
+ World.list.set(id, {
10
+ id,
11
+ name: name ?? `world-${World.list.size}`,
12
+ rate,
13
+ disabled,
14
+ entities: /* @__PURE__ */ new Set(),
15
+ systems: /* @__PURE__ */ new Set()
16
+ });
17
+ return id;
18
+ }
19
+ static get(world) {
20
+ return World.list.get(world);
21
+ }
22
+ static addSystem(world, system) {
23
+ const w = World.list.get(world);
24
+ if (w) {
25
+ w.systems.add(system);
26
+ }
27
+ }
28
+ static removeSystem(world, system) {
29
+ const w = World.list.get(world);
30
+ if (w) {
31
+ w.systems.delete(system);
32
+ }
33
+ }
34
+ static addEntity(world, entity) {
35
+ const w = World.list.get(world);
36
+ if (w) {
37
+ w.entities.add(entity);
38
+ }
39
+ }
40
+ static removeEntity(world, entity) {
41
+ const w = World.list.get(world);
42
+ if (w) {
43
+ w.entities.delete(entity);
44
+ }
45
+ }
46
+ static forEach(callback) {
47
+ World.list.forEach((_world, key) => {
48
+ callback(key);
49
+ });
50
+ }
51
+ static tick(dt, world) {
52
+ const w = World.list.get(world);
53
+ if (!w) {
54
+ return;
55
+ }
56
+ if (w.systems.size === 0) {
57
+ return;
58
+ }
59
+ if (w.disabled) {
60
+ return;
61
+ }
62
+ w.systems.forEach((system) => {
63
+ if (system.loopType === "entity") {
64
+ w.entities.forEach((entity) => {
65
+ if (system.has(entity)) {
66
+ system.tick(dt / w.rate, entity);
67
+ }
68
+ });
69
+ }
70
+ if (system.loopType === "single") {
71
+ system.tick(dt / w.rate);
72
+ }
73
+ if (system.debug) {
74
+ system.debug.tick(dt / w.rate);
75
+ }
76
+ });
77
+ }
78
+ static destroy(world) {
79
+ World.list.delete(world);
80
+ }
81
+ static clear() {
82
+ World.list.clear();
83
+ }
84
+ }
@@ -0,0 +1,9 @@
1
+ export declare abstract class IDebugSystem {
2
+ id: string;
3
+ color: string;
4
+ visible: boolean;
5
+ abstract tick(dt: number): void;
6
+ hide(): void;
7
+ show(): void;
8
+ }
9
+ //# sourceMappingURL=Debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Debug.d.ts","sourceRoot":"","sources":["../../../src/systems/debugs/Debug.ts"],"names":[],"mappings":"AAAA,8BAAsB,YAAY;IACjC,EAAE,SAAW;IACb,KAAK,SAAa;IAClB,OAAO,UAAS;IAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAC/B,IAAI,IAAI,IAAI;IAGZ,IAAI,IAAI,IAAI;CAGZ"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ export class IDebugSystem {
3
+ id = "debug";
4
+ color = "#544948";
5
+ visible = false;
6
+ hide() {
7
+ this.visible = false;
8
+ }
9
+ show() {
10
+ this.visible = true;
11
+ }
12
+ }
@@ -0,0 +1,7 @@
1
+ import { IDebugSystem } from "./Debug";
2
+ export default class InputDebug extends IDebugSystem {
3
+ id: string;
4
+ color: string;
5
+ tick(): void;
6
+ }
7
+ //# sourceMappingURL=InputDebug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputDebug.d.ts","sourceRoot":"","sources":["../../../src/systems/debugs/InputDebug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,YAAY;IACnD,EAAE,SAAW;IACb,KAAK,SAAuB;IAE5B,IAAI,IAAI,IAAI;CAKZ"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ import { IDebugSystem } from "./Debug";
3
+ export default class InputDebug extends IDebugSystem {
4
+ id = "mouse";
5
+ color = "hsl(0, 100%, 71%)";
6
+ tick() {
7
+ if (!this.visible) {
8
+ return;
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,7 @@
1
+ import { IDebugSystem } from "./Debug";
2
+ export default class LoopDebug extends IDebugSystem {
3
+ id: string;
4
+ color: string;
5
+ tick(): void;
6
+ }
7
+ //# sourceMappingURL=LoopDebug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoopDebug.d.ts","sourceRoot":"","sources":["../../../src/systems/debugs/LoopDebug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,YAAY;IAClD,EAAE,SAAU;IACZ,KAAK,SAAyB;IAE9B,IAAI,IAAI,IAAI;CAKZ"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ import { IDebugSystem } from "./Debug";
3
+ export default class LoopDebug extends IDebugSystem {
4
+ id = "loop";
5
+ color = "hsl(197, 100%, 45%)";
6
+ tick() {
7
+ if (!this.visible) {
8
+ return;
9
+ }
10
+ }
11
+ }
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@argila/core",
3
+ "version": "0.0.0-alpha-20250607064138",
4
+ "description": "Javascript game engine",
5
+ "files": [
6
+ "dist",
7
+ "LICENSE",
8
+ "README.md",
9
+ "package.json"
10
+ ],
11
+ "typesVersions": {
12
+ "*": {
13
+ "*": [
14
+ "./dist/*",
15
+ "./dist/index.d.ts"
16
+ ],
17
+ "system/*": [
18
+ "./dist/system/*"
19
+ ],
20
+ "systems/debugs/*": [
21
+ "./dist/systems/debugs/*"
22
+ ]
23
+ }
24
+ },
25
+ "module": "./dist/index.js",
26
+ "exports": {
27
+ ".": "./dist/index.js",
28
+ "./systems/*": "./dist/systems/*.js",
29
+ "./systems/debugs/*": "./dist/systems/debugs/*.js"
30
+ },
31
+ "type": "module",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/EduardoLopes/argila.git"
35
+ },
36
+ "keywords": [
37
+ "game",
38
+ "engine"
39
+ ],
40
+ "author": "Eduardo <EduardoLopesDS@gmail.com> (http://eduardolopes.dev.br)",
41
+ "license": "MIT",
42
+ "bugs": {
43
+ "url": "https://github.com/EduardoLopes/argila/issues"
44
+ },
45
+ "homepage": "https://github.com/EduardoLopes/argila#readme",
46
+ "devDependencies": {
47
+ "@types/uuid": "^9.0.8",
48
+ "@vitest/ui": "^2.1.6",
49
+ "esbuild": "^0.20.2",
50
+ "glob": "^10.3.12",
51
+ "nodemon": "^3.1.0",
52
+ "type-fest": "^4.17.0",
53
+ "typedoc": "^0.25.13",
54
+ "typedoc-plugin-missing-exports": "^2.2.0",
55
+ "typescript": "^5.4.5",
56
+ "vitest": "^2.1.6",
57
+ "jsdom": "^25.0.1",
58
+ "vitest-canvas-mock": "^0.3.3",
59
+ "@vitest/coverage-v8": "^2.1.6"
60
+ },
61
+ "dependencies": {
62
+ "uuid": "^9.0.1"
63
+ },
64
+ "directories": {
65
+ "doc": "docs",
66
+ "test": "tests"
67
+ },
68
+ "scripts": {
69
+ "dev": "nodemon esbuild.config.js",
70
+ "build": "node esbuild.config.js && tsc",
71
+ "watch:types": "tsc -w",
72
+ "clean": "rm -rf dist",
73
+ "test": "vitest",
74
+ "test:coverage": "vitest run --coverage",
75
+ "test:watch": "vitest",
76
+ "docs:build": "typedoc src/index.ts --excludeInternal",
77
+ "docs:serve": "python3 -m http.server -d ./docs"
78
+ }
79
+ }