@kbve/laser 0.0.6 → 0.0.7

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
@@ -1,11 +1,22 @@
1
- # laser
1
+ # Laser
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Laser is an npm library that provides seamless integration between React and Phaser, allowing you to create rich, interactive web applications with ease.
4
4
 
5
- ## Building
5
+ ## Features
6
6
 
7
- Run `nx build laser` to build the library.
7
+ - **React and Phaser Integration**: Leverage the power of both React and Phaser in your projects.
8
+ - **Component-Based Architecture**: Utilize React's component-based architecture for structuring your game elements.
9
+ - **Easy Setup**: Quickly set up and start building your projects with minimal configuration.
10
+ - **Optimized Performance**: Efficiently manage and update your game state with React's rendering optimizations.
8
11
 
9
- ## Running unit tests
12
+ ## Installation
10
13
 
11
- Run `nx test laser` to execute the unit tests via [Vitest](https://vitest.dev/).
14
+ To install Laser, use npm or pnpm:
15
+
16
+ ```bash
17
+ pnpm install @kbve/laser
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ We recommend that you import all of it as `import * as Laser from '@kbve/laser';`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbve/laser",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "A comprehensive game development toolkit for Node.js. Laser is a powerful npm package designed to streamline game development processes, with a focus on efficient game client management. It provides essential tools and utilities to enhance your game creation workflow, including an event handler, quadtree, client management and performance utilities.",
5
5
  "keywords": [
6
6
  "phaser",
package/src/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  export * from './types';
2
+ export * from './lib/constants';
2
3
  export * from './lib/laser';
3
4
  export * from './lib/quadtree';
4
5
  export * from './lib/eventhandler';
5
6
  export * from './lib/localdb';
6
7
  export * from './lib/utils/ulid';
7
8
  export * from './lib/utils/debug';
9
+ export * from './lib/utils/loader';
8
10
  export { default as CollapseIcon } from './lib/icon/CollapseIcon';
9
11
  export { default as ExpandIcon } from './lib/icon/ExpandIcon';
10
12
  export { default as MinigameDice } from './lib/minigame/dice/MinigameDice';
package/src/index.js CHANGED
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.TypewriterComponent = exports.MinigameDice = exports.ExpandIcon = exports.CollapseIcon = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  tslib_1.__exportStar(require("./types"), exports);
7
+ // Constants
8
+ tslib_1.__exportStar(require("./lib/constants"), exports);
7
9
  tslib_1.__exportStar(require("./lib/laser"), exports);
8
10
  tslib_1.__exportStar(require("./lib/quadtree"), exports);
9
11
  tslib_1.__exportStar(require("./lib/eventhandler"), exports);
@@ -11,6 +13,7 @@ tslib_1.__exportStar(require("./lib/localdb"), exports);
11
13
  // Utils
12
14
  tslib_1.__exportStar(require("./lib/utils/ulid"), exports); // ULID
13
15
  tslib_1.__exportStar(require("./lib/utils/debug"), exports); // Debug
16
+ tslib_1.__exportStar(require("./lib/utils/loader"), exports); // Loader
14
17
  // Icons
15
18
  var CollapseIcon_1 = require("./lib/icon/CollapseIcon");
16
19
  Object.defineProperty(exports, "CollapseIcon", { enumerable: true, get: function () { return tslib_1.__importDefault(CollapseIcon_1).default; } });
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/laser/src/index.ts"],"names":[],"mappings":";AAAA,QAAQ;;;;AAER,kDAAwB;AAExB,sDAA4B;AAC5B,yDAA+B;AAC/B,6DAAmC;AACnC,wDAA8B;AAE9B,QAAQ;AACR,2DAAiC,CAAC,OAAO;AACzC,4DAAkC,CAAC,QAAQ;AAE3C,QAAQ;AACR,wDAAkE;AAAzD,qIAAA,OAAO,OAAgB;AAChC,oDAA8D;AAArD,iIAAA,OAAO,OAAc;AAE9B,YAAY;AACZ,iEAA2E;AAAlE,qIAAA,OAAO,OAAgB;AAEhC,aAAa;AACb,4EAAqF;AAA5E,mJAAA,OAAO,OAAuB;AAEvC,SAAS;AACT,+EAAqD;AAErD,MAAM;AACN,uEAA6C;AAC7C,sEAA4C;AAC5C,sEAA4C;AAC5C,uEAA6C;AAI7C,WAAW;AACX,oEAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/laser/src/index.ts"],"names":[],"mappings":";AAAA,QAAQ;;;;AAER,kDAAwB;AAExB,YAAY;AACZ,0DAAgC;AAEhC,sDAA4B;AAC5B,yDAA+B;AAC/B,6DAAmC;AACnC,wDAA8B;AAE9B,QAAQ;AACR,2DAAiC,CAAC,OAAO;AACzC,4DAAkC,CAAC,QAAQ;AAC3C,6DAAmC,CAAC,SAAS;AAE7C,QAAQ;AACR,wDAAkE;AAAzD,qIAAA,OAAO,OAAgB;AAChC,oDAA8D;AAArD,iIAAA,OAAO,OAAc;AAE9B,YAAY;AACZ,iEAA2E;AAAlE,qIAAA,OAAO,OAAgB;AAEhC,aAAa;AACb,4EAAqF;AAA5E,mJAAA,OAAO,OAAuB;AAEvC,SAAS;AACT,+EAAqD;AAErD,MAAM;AACN,uEAA6C;AAC7C,sEAA4C;AAC5C,sEAA4C;AAC5C,uEAA6C;AAI7C,WAAW;AACX,oEAA0C"}
@@ -0,0 +1,2 @@
1
+ export declare const kbve_hcaptcha_site_key = "5ba581fa-b6fc-4bb0-8222-02fcd6a59e35";
2
+ export declare const hcaptcha_api = "https://js.hcaptcha.com/1/api.js";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hcaptcha_api = exports.kbve_hcaptcha_site_key = void 0;
4
+ exports.kbve_hcaptcha_site_key = '5ba581fa-b6fc-4bb0-8222-02fcd6a59e35'; // 9-20-2023 Key
5
+ exports.hcaptcha_api = 'https://js.hcaptcha.com/1/api.js';
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/laser/src/lib/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,sCAAsC,CAAC,CAAC,gBAAgB;AACjF,QAAA,YAAY,GAAG,kCAAkC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { LoaderOptions } from '../../types';
2
+ export declare function removeLoader(options: LoaderOptions): void;
3
+ export declare function addLoader(options: LoaderOptions): void;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addLoader = exports.removeLoader = void 0;
4
+ const debug_1 = require("./debug");
5
+ function removeLoader(options) {
6
+ const { elementIdOrName, duration = 500, onComplete } = options;
7
+ let loader = null;
8
+ loader = document.getElementById(elementIdOrName);
9
+ if (!loader) {
10
+ const elementsByName = document.getElementsByName(elementIdOrName);
11
+ if (elementsByName.length > 0) {
12
+ loader = elementsByName[0];
13
+ }
14
+ }
15
+ if (!loader) {
16
+ debug_1.Debug.error(`Loader element with ID or name "${elementIdOrName}" not found.`);
17
+ return;
18
+ }
19
+ if (!(loader instanceof HTMLElement)) {
20
+ debug_1.Debug.error(`Element found by "${elementIdOrName}" is not an HTMLElement.`);
21
+ return;
22
+ }
23
+ debug_1.Debug.log(`Removing loader element with ID or name "${elementIdOrName}" with duration ${duration}ms.`);
24
+ loader.classList.add('opacity-0', 'transition-opacity', `duration-${duration}`);
25
+ setTimeout(() => {
26
+ loader.style.display = 'none';
27
+ debug_1.Debug.log(`Loader element with ID or name "${elementIdOrName}" has been hidden.`);
28
+ // Call the optional onComplete callback if provided
29
+ if (onComplete) {
30
+ onComplete();
31
+ }
32
+ }, duration);
33
+ }
34
+ exports.removeLoader = removeLoader;
35
+ function addLoader(options) {
36
+ const { elementIdOrName, duration = 500, onComplete } = options;
37
+ let loader = null;
38
+ // Try to get the element by ID first
39
+ loader = document.getElementById(elementIdOrName);
40
+ // If not found by ID, try to get the element by name
41
+ if (!loader) {
42
+ const elementsByName = document.getElementsByName(elementIdOrName);
43
+ if (elementsByName.length > 0) {
44
+ loader = elementsByName[0];
45
+ }
46
+ }
47
+ // If loader is still not found, create a new one
48
+ if (!loader) {
49
+ loader = document.createElement('div');
50
+ loader.id = elementIdOrName;
51
+ loader.classList.add('z-[1000]', 'fixed', 'top-0', 'left-0', 'w-full', 'h-full', 'flex', 'items-center', 'justify-center', 'bg-gray-100', 'opacity-100', 'transition-opacity', `duration-${duration}`);
52
+ loader.innerHTML = `
53
+ <div class="loader"></div>
54
+ <style>
55
+ .loader {
56
+ border: 16px solid #f3f3f3;
57
+ border-top: 16px solid #3498db;
58
+ border-radius: 50%;
59
+ width: 120px;
60
+ height: 120px;
61
+ animation: spin 2s linear infinite;
62
+ }
63
+ @keyframes spin {
64
+ 0% { transform: rotate(0deg); }
65
+ 100% { transform: rotate(360deg); }
66
+ }
67
+ </style>
68
+ `;
69
+ document.body.appendChild(loader);
70
+ }
71
+ if (!(loader instanceof HTMLElement)) {
72
+ debug_1.Debug.error(`Element found by "${elementIdOrName}" is not an HTMLElement.`);
73
+ return;
74
+ }
75
+ debug_1.Debug.log(`Adding loader element with ID or name "${elementIdOrName}" with duration ${duration}ms.`);
76
+ loader.style.display = 'block';
77
+ loader.classList.remove('opacity-0');
78
+ loader.classList.add('opacity-100');
79
+ // Call the optional onComplete callback if provided
80
+ if (onComplete) {
81
+ setTimeout(() => {
82
+ onComplete();
83
+ }, duration);
84
+ }
85
+ }
86
+ exports.addLoader = addLoader;
87
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../../../../packages/laser/src/lib/utils/loader.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAGhC,SAAgB,YAAY,CAAC,OAAsB;IACjD,MAAM,EAAE,eAAe,EAAE,QAAQ,GAAG,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAChE,IAAI,MAAM,GAAuB,IAAI,CAAC;IAEtC,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAElD,IAAI,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,CAAC;IACf,CAAC;AACH,CAAC;AAzED,8BAyEC"}
package/src/types.d.ts CHANGED
@@ -353,3 +353,29 @@ export interface NPCDialogueEventData {
353
353
  read: boolean;
354
354
  };
355
355
  }
356
+ export interface CaptchaConfig {
357
+ hl: string;
358
+ sitekey: string;
359
+ apihost: string;
360
+ reCaptchaCompat: boolean;
361
+ theme: CaptchaTheme;
362
+ size: 'normal' | 'compact' | 'invisible';
363
+ }
364
+ export declare enum CaptchaTheme {
365
+ DARK = "dark",// Represents the dark theme.
366
+ LIGHT = "light"
367
+ }
368
+ export interface UIRegiserState {
369
+ email: string;
370
+ password: string;
371
+ confirm: string;
372
+ username: string;
373
+ captchaToken: string;
374
+ svelte_internal_message: string;
375
+ successful_message: string;
376
+ }
377
+ export interface LoaderOptions {
378
+ elementIdOrName: string;
379
+ duration?: number;
380
+ onComplete?: () => void;
381
+ }
package/src/types.js CHANGED
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDiceAction = void 0;
3
+ exports.CaptchaTheme = exports.isDiceAction = void 0;
4
4
  // Type Guards
5
5
  function isDiceAction(action) {
6
6
  return action.type === 'ROLL_DICE';
7
7
  }
8
8
  exports.isDiceAction = isDiceAction;
9
+ var CaptchaTheme;
10
+ (function (CaptchaTheme) {
11
+ CaptchaTheme["DARK"] = "dark";
12
+ CaptchaTheme["LIGHT"] = "light";
13
+ })(CaptchaTheme || (exports.CaptchaTheme = CaptchaTheme = {}));
9
14
  //# sourceMappingURL=types.js.map
package/src/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../packages/laser/src/types.ts"],"names":[],"mappings":";;;AAmWA,cAAc;AAEd,SAAgB,YAAY,CAAC,MAAsB;IACjD,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC;AACrC,CAAC;AAFD,oCAEC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../packages/laser/src/types.ts"],"names":[],"mappings":";;;AAmWA,cAAc;AAEd,SAAgB,YAAY,CAAC,MAAsB;IACjD,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC;AACrC,CAAC;AAFD,oCAEC;AAgFD,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}