hudini 0.17.2 → 0.18.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/dist/components/card/card.d.ts +34 -9
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/card.js +117 -49
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/card/card.spec.js +28 -1
- package/dist/components/card/card.spec.js.map +1 -1
- package/dist/components/circular-progress/circular-progress.d.ts +4 -4
- package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
- package/dist/components/circular-progress/circular-progress.js +9 -8
- package/dist/components/circular-progress/circular-progress.js.map +1 -1
- package/dist/components/circular-progress/circular-progress.spec.js +4 -4
- package/dist/components/circular-progress/circular-progress.spec.js.map +1 -1
- package/dist/components/container-interactive/container-interactive.d.ts +65 -0
- package/dist/components/container-interactive/container-interactive.d.ts.map +1 -0
- package/dist/components/container-interactive/container-interactive.js +99 -0
- package/dist/components/container-interactive/container-interactive.js.map +1 -0
- package/dist/components/container-interactive/index.d.ts +2 -0
- package/dist/components/container-interactive/index.d.ts.map +1 -0
- package/dist/components/container-interactive/index.js +2 -0
- package/dist/components/container-interactive/index.js.map +1 -0
- package/dist/components/flat-icon-button/flat-icon-button.d.ts +3 -0
- package/dist/components/flat-icon-button/flat-icon-button.d.ts.map +1 -1
- package/dist/components/flat-icon-button/flat-icon-button.js +110 -19
- package/dist/components/flat-icon-button/flat-icon-button.js.map +1 -1
- package/dist/components/flat-section-header/flat-section-header.d.ts +143 -0
- package/dist/components/flat-section-header/flat-section-header.d.ts.map +1 -0
- package/dist/components/flat-section-header/flat-section-header.js +275 -0
- package/dist/components/flat-section-header/flat-section-header.js.map +1 -0
- package/dist/components/flat-section-header/flat-section-header.spec.d.ts +2 -0
- package/dist/components/flat-section-header/flat-section-header.spec.d.ts.map +1 -0
- package/dist/components/flat-section-header/flat-section-header.spec.js +255 -0
- package/dist/components/flat-section-header/flat-section-header.spec.js.map +1 -0
- package/dist/components/flat-section-header/index.d.ts +2 -0
- package/dist/components/flat-section-header/index.d.ts.map +1 -0
- package/dist/components/flat-section-header/index.js +2 -0
- package/dist/components/flat-section-header/index.js.map +1 -0
- package/dist/components/flat-text-button/flat-text-button.d.ts +165 -0
- package/dist/components/flat-text-button/flat-text-button.d.ts.map +1 -0
- package/dist/components/flat-text-button/flat-text-button.js +325 -0
- package/dist/components/flat-text-button/flat-text-button.js.map +1 -0
- package/dist/components/flat-text-button/flat-text-button.spec.d.ts +2 -0
- package/dist/components/flat-text-button/flat-text-button.spec.d.ts.map +1 -0
- package/dist/components/flat-text-button/flat-text-button.spec.js +243 -0
- package/dist/components/flat-text-button/flat-text-button.spec.js.map +1 -0
- package/dist/components/flat-text-button/index.d.ts +2 -0
- package/dist/components/flat-text-button/index.d.ts.map +1 -0
- package/dist/components/flat-text-button/index.js +2 -0
- package/dist/components/flat-text-button/index.js.map +1 -0
- package/dist/components/icon-button/icon-button.d.ts +11 -3
- package/dist/components/icon-button/icon-button.d.ts.map +1 -1
- package/dist/components/icon-button/icon-button.js +124 -70
- package/dist/components/icon-button/icon-button.js.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/panel/panel.d.ts +0 -1
- package/dist/components/panel/panel.d.ts.map +1 -1
- package/dist/components/panel/panel.js +7 -10
- package/dist/components/panel/panel.js.map +1 -1
- package/dist/components/section-header/section-header.d.ts +33 -39
- package/dist/components/section-header/section-header.d.ts.map +1 -1
- package/dist/components/section-header/section-header.js +124 -155
- package/dist/components/section-header/section-header.js.map +1 -1
- package/dist/components/section-header/section-header.spec.js +57 -17
- package/dist/components/section-header/section-header.spec.js.map +1 -1
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/index.d.ts.map +1 -0
- package/dist/components/text/index.js +2 -0
- package/dist/components/text/index.js.map +1 -0
- package/dist/components/text/text.d.ts +45 -0
- package/dist/components/text/text.d.ts.map +1 -0
- package/dist/components/text/text.js +35 -0
- package/dist/components/text/text.js.map +1 -0
- package/dist/components/text-button/text-button.d.ts +26 -23
- package/dist/components/text-button/text-button.d.ts.map +1 -1
- package/dist/components/text-button/text-button.js +114 -88
- package/dist/components/text-button/text-button.js.map +1 -1
- package/dist/components/text-button/text-button.spec.js +98 -8
- package/dist/components/text-button/text-button.spec.js.map +1 -1
- package/dist/hudini.js +4166 -460
- package/dist/hudini.min.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/loaders/index.d.ts +2 -0
- package/dist/loaders/index.d.ts.map +1 -0
- package/dist/loaders/index.js +2 -0
- package/dist/loaders/index.js.map +1 -0
- package/dist/loaders/load-fonts.d.ts +8 -0
- package/dist/loaders/load-fonts.d.ts.map +1 -0
- package/dist/loaders/load-fonts.js +41 -0
- package/dist/loaders/load-fonts.js.map +1 -0
- package/dist/test-setup.js +8 -2
- package/dist/test-setup.js.map +1 -1
- package/dist/utils/color-variants.d.ts +38 -0
- package/dist/utils/color-variants.d.ts.map +1 -0
- package/dist/utils/color-variants.js +59 -0
- package/dist/utils/color-variants.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-fonts.d.ts","sourceRoot":"","sources":["../../src/loaders/load-fonts.ts"],"names":[],"mappings":"AAEA,KAAK,gBAAgB,GAAG;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAiCF,eAAO,MAAM,SAAS,GAAU,UAAU,gBAAgB,KAAG,OAAO,CAAC,IAAI,CAexE,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { loadFont as loadFontAwesomeForPhaser } from 'font-awesome-for-phaser';
|
|
2
|
+
const loadStylesheet = (url) => {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
const existingLink = document.querySelector(`link[href="${url}"]`);
|
|
5
|
+
if (existingLink) {
|
|
6
|
+
resolve();
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const link = document.createElement('link');
|
|
10
|
+
link.rel = 'stylesheet';
|
|
11
|
+
link.href = url;
|
|
12
|
+
link.onload = () => {
|
|
13
|
+
resolve();
|
|
14
|
+
};
|
|
15
|
+
link.onerror = () => {
|
|
16
|
+
reject(new Error(`Failed to load stylesheet: ${url}`));
|
|
17
|
+
};
|
|
18
|
+
document.head.appendChild(link);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const ensureBaseFontReady = async (fontFamily) => {
|
|
22
|
+
const loads = [
|
|
23
|
+
document.fonts.load(`400 16px "${fontFamily}"`, 'A'),
|
|
24
|
+
document.fonts.load(`700 16px "${fontFamily}"`, 'B'),
|
|
25
|
+
];
|
|
26
|
+
await Promise.all(loads);
|
|
27
|
+
await document['fonts'].ready;
|
|
28
|
+
};
|
|
29
|
+
export const loadFonts = async (options) => {
|
|
30
|
+
const { fontAwesomeUrl, baseFont = 'https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap', baseFontFamily = 'Bebas Neue', } = options ?? {};
|
|
31
|
+
try {
|
|
32
|
+
await loadFontAwesomeForPhaser(fontAwesomeUrl);
|
|
33
|
+
await loadStylesheet(baseFont);
|
|
34
|
+
await ensureBaseFontReady(baseFontFamily);
|
|
35
|
+
await document.fonts.ready;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new Error(`Failed to load fonts: ${error instanceof Error ? error.message : String(error)}`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=load-fonts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AAK,CAAC;AACpF,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,OAA0B,EAAiB,EAAE;IAC3E,MAAM,EACJ,cAAc,EACd,QAAQ,GAAG,kEAAkE,EAC7E,cAAc,GAAG,YAAY,GAC9B,GAAG,OAAO,IAAI,EAAE,CAAC;IAElB,IAAI,CAAC;QACH,MAAM,wBAAwB,CAAC,cAAc,CAAC,CAAC;QAC/C,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC/B,MAAM,mBAAmB,CAAC,cAAc,CAAC,CAAC;QAC1C,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrG,CAAC;AACH,CAAC,CAAC"}
|
package/dist/test-setup.js
CHANGED
|
@@ -29,8 +29,14 @@ vi.mock('phaser', () => {
|
|
|
29
29
|
return this;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
class Text {
|
|
33
|
+
// Mock Text class for Phaser.GameObjects.Text
|
|
34
|
+
// eslint-disable-next-line no-unused-vars
|
|
35
|
+
constructor(..._args) { }
|
|
36
|
+
}
|
|
37
|
+
const GameObjects = { Container, Text };
|
|
38
|
+
const Phaser = { GameObjects, Scene };
|
|
39
|
+
return { GameObjects, Scene, Phaser, default: Phaser };
|
|
34
40
|
});
|
|
35
41
|
// Mock phaser-wind globally (after Phaser mock)
|
|
36
42
|
vi.mock('phaser-wind', () => {
|
package/dist/test-setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-setup.js","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":"AAAA,kCAAkC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K,EAAE,CAAC;SAC9C;QACD,iBAAiB,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,KAAqF,EAAE,EAAE;YACjH,IAAI,OAAO,KAAK,CAAC,YAAY,KAAK,QAAQ;gBAAE,OAAO,KAAK,CAAC,YAAY,CAAC;YACtE,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;gBAAE,OAAO,KAAK,CAAC,KAAK,CAAC;YACxD,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;YACnC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC;QACF,kBAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,KAAwF,EAAE,EAAE;YACrH,IAAI,OAAO,KAAK,CAAC,aAAa,KAAK,QAAQ;gBAAE,OAAO,KAAK,CAAC,aAAa,CAAC;YACxE,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;gBAAE,OAAO,KAAK,CAAC,MAAM,CAAC;YAC1D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;YACnC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC;QACF,gBAAgB,EAAE,MAAM,gBAAgB;SAAI;QAC5C,mBAAmB,EAAE,MAAM,mBAAmB;SAAI;KACnD,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ColorKey } from 'phaser-wind';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates a color variant by adjusting brightness.
|
|
4
|
+
*
|
|
5
|
+
* @param color - The base color (can be a Phaser Wind token like "blue-500" or a CSS color like "#3B82F6")
|
|
6
|
+
* @param tokenDiff - Amount to adjust the shade for color tokens. Positive values make it darker, negative lighter.
|
|
7
|
+
* For example: -400 for lighter (blue-500 → blue-100), +400 for darker (blue-500 → blue-900)
|
|
8
|
+
* @param colorDiff - Amount to lighten/darken CSS colors. Positive values lighten, negative values darken.
|
|
9
|
+
* Range: 0-100. For example: 90 to lighten, -90 to darken
|
|
10
|
+
* @returns The adjusted color as a number
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* - If a color token is provided (e.g., "blue-500"), it uses the token system to calculate variants
|
|
14
|
+
* by adjusting the shade value with tokenDiff (clamped between 100-900)
|
|
15
|
+
* - If a CSS color is provided (hex or rgb), it uses Phaser's lighten/darken methods
|
|
16
|
+
* with colorDiff (positive = lighten, negative = darken)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Using color token - lighter variant
|
|
21
|
+
* const lightBlue = getColorVariant('blue-500', -400, 0);
|
|
22
|
+
* // Returns blue-100 color value
|
|
23
|
+
*
|
|
24
|
+
* // Using color token - darker variant
|
|
25
|
+
* const darkBlue = getColorVariant('blue-500', 400, 0);
|
|
26
|
+
* // Returns blue-900 color value
|
|
27
|
+
*
|
|
28
|
+
* // Using CSS color - lighter
|
|
29
|
+
* const lightCss = getColorVariant('#3B82F6', 0, 90);
|
|
30
|
+
* // Returns lightened color
|
|
31
|
+
*
|
|
32
|
+
* // Using CSS color - darker
|
|
33
|
+
* const darkCss = getColorVariant('#3B82F6', 0, -90);
|
|
34
|
+
* // Returns darkened color
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const getColorVariant: (color: ColorKey | string, tokenDiff: number, colorDiff: number) => number;
|
|
38
|
+
//# sourceMappingURL=color-variants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-variants.d.ts","sourceRoot":"","sources":["../../src/utils/color-variants.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,QAAQ,EAAiB,MAAM,aAAa,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,QAAQ,GAAG,MAAM,EACxB,WAAW,MAAM,EACjB,WAAW,MAAM,KAChB,MA6BF,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Phaser from 'phaser';
|
|
2
|
+
import { Color } from 'phaser-wind';
|
|
3
|
+
/**
|
|
4
|
+
* Calculates a color variant by adjusting brightness.
|
|
5
|
+
*
|
|
6
|
+
* @param color - The base color (can be a Phaser Wind token like "blue-500" or a CSS color like "#3B82F6")
|
|
7
|
+
* @param tokenDiff - Amount to adjust the shade for color tokens. Positive values make it darker, negative lighter.
|
|
8
|
+
* For example: -400 for lighter (blue-500 → blue-100), +400 for darker (blue-500 → blue-900)
|
|
9
|
+
* @param colorDiff - Amount to lighten/darken CSS colors. Positive values lighten, negative values darken.
|
|
10
|
+
* Range: 0-100. For example: 90 to lighten, -90 to darken
|
|
11
|
+
* @returns The adjusted color as a number
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* - If a color token is provided (e.g., "blue-500"), it uses the token system to calculate variants
|
|
15
|
+
* by adjusting the shade value with tokenDiff (clamped between 100-900)
|
|
16
|
+
* - If a CSS color is provided (hex or rgb), it uses Phaser's lighten/darken methods
|
|
17
|
+
* with colorDiff (positive = lighten, negative = darken)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Using color token - lighter variant
|
|
22
|
+
* const lightBlue = getColorVariant('blue-500', -400, 0);
|
|
23
|
+
* // Returns blue-100 color value
|
|
24
|
+
*
|
|
25
|
+
* // Using color token - darker variant
|
|
26
|
+
* const darkBlue = getColorVariant('blue-500', 400, 0);
|
|
27
|
+
* // Returns blue-900 color value
|
|
28
|
+
*
|
|
29
|
+
* // Using CSS color - lighter
|
|
30
|
+
* const lightCss = getColorVariant('#3B82F6', 0, 90);
|
|
31
|
+
* // Returns lightened color
|
|
32
|
+
*
|
|
33
|
+
* // Using CSS color - darker
|
|
34
|
+
* const darkCss = getColorVariant('#3B82F6', 0, -90);
|
|
35
|
+
* // Returns darkened color
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export const getColorVariant = (color, tokenDiff, colorDiff) => {
|
|
39
|
+
const colorRgb = Color.rgb(color);
|
|
40
|
+
if (Color.isValidColorToken(color)) {
|
|
41
|
+
// Token-based calculation
|
|
42
|
+
const parts = color.split('-');
|
|
43
|
+
const colorShade = parseInt(parts[1].toString(), 10);
|
|
44
|
+
const shadeMin = 100;
|
|
45
|
+
const shadeMax = 900;
|
|
46
|
+
const newShade = Math.max(Math.min(colorShade + tokenDiff, shadeMax), shadeMin).toString();
|
|
47
|
+
return Color.hex(`${parts[0]}-${newShade}`);
|
|
48
|
+
}
|
|
49
|
+
// CSS color calculation
|
|
50
|
+
const baseColor = Phaser.Display.Color.ValueToColor(colorRgb);
|
|
51
|
+
if (colorDiff === 0) {
|
|
52
|
+
return baseColor.color;
|
|
53
|
+
}
|
|
54
|
+
if (colorDiff > 0) {
|
|
55
|
+
return baseColor.clone().lighten(colorDiff).color;
|
|
56
|
+
}
|
|
57
|
+
return baseColor.clone().darken(Math.abs(colorDiff)).color;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=color-variants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-variants.js","sourceRoot":"","sources":["../../src/utils/color-variants.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAgC,MAAM,aAAa,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAwB,EACxB,SAAiB,EACjB,SAAiB,EACT,EAAE;IACV,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,KAAiB,CAAC,CAAC;IAE9C,IAAI,KAAK,CAAC,iBAAiB,CAAC,KAAe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ceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
|
package/dist/utils/index.js
CHANGED
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hudini",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "🎩 Magical Phaser UI components - Reusable HUD elements for game development. Is magic, like a wizard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"vitest": "^3.2.4"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"phaser-wind": "0.
|
|
66
|
-
"font-awesome-for-phaser": "0.
|
|
65
|
+
"phaser-wind": "0.9.0",
|
|
66
|
+
"font-awesome-for-phaser": "0.10.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"phaser": "*"
|