@number10/phaserjsx 4.1.0 → 4.2.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/clip/index.cjs +7 -695
- package/dist/clip/index.js +1 -687
- package/dist/clip/stencil-clip-depth.d.ts +10 -0
- package/dist/clip/stencil-clip-depth.d.ts.map +1 -0
- package/dist/clip/stencil-clip-fbo-bridge.d.ts +7 -0
- package/dist/clip/stencil-clip-fbo-bridge.d.ts.map +1 -0
- package/dist/clip/stencil-clip-renderer.d.ts +7 -0
- package/dist/clip/stencil-clip-renderer.d.ts.map +1 -0
- package/dist/clip/stencil-clip-state.d.ts +28 -0
- package/dist/clip/stencil-clip-state.d.ts.map +1 -0
- package/dist/clip/stencil-clip-types.d.ts +67 -0
- package/dist/clip/stencil-clip-types.d.ts.map +1 -0
- package/dist/clip/stencil-clip.d.ts +3 -84
- package/dist/clip/stencil-clip.d.ts.map +1 -1
- package/dist/clip-CHmjztBQ.cjs +705 -0
- package/dist/clip-CHmjztBQ.cjs.map +1 -0
- package/dist/clip-CPufWCSD.js +668 -0
- package/dist/clip-CPufWCSD.js.map +1 -0
- package/dist/components/custom/DebugPanel.d.ts +30 -0
- package/dist/components/custom/DebugPanel.d.ts.map +1 -0
- package/dist/components/custom/Toggle.d.ts.map +1 -1
- package/dist/components/custom/index.cjs +2 -1
- package/dist/components/custom/index.d.ts +1 -0
- package/dist/components/custom/index.d.ts.map +1 -1
- package/dist/components/custom/index.js +2 -2
- package/dist/components/primitives/graphics.d.ts +2 -2
- package/dist/{custom-C_w8D39m.js → custom-BXDJDGOl.js} +262 -5
- package/dist/custom-BXDJDGOl.js.map +1 -0
- package/dist/{custom-Dp3yAJdU.cjs → custom-DTd4LxDn.cjs} +273 -4
- package/dist/custom-DTd4LxDn.cjs.map +1 -0
- package/dist/gestures/gesture-manager.d.ts +1 -1
- package/dist/index.cjs +10 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -86
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/clip/index.cjs.map +0 -1
- package/dist/clip/index.js.map +0 -1
- package/dist/custom-C_w8D39m.js.map +0 -1
- package/dist/custom-Dp3yAJdU.cjs.map +0 -1
|
@@ -16938,7 +16938,7 @@ var GestureManager = class {
|
|
|
16938
16938
|
/**
|
|
16939
16939
|
* Handle global pointer down event
|
|
16940
16940
|
* Registers all containers that were hit for move event tracking
|
|
16941
|
-
* Only the topmost gets touch/
|
|
16941
|
+
* Only the topmost gets touch/long-press callbacks
|
|
16942
16942
|
*/
|
|
16943
16943
|
handlePointerDown(pointer) {
|
|
16944
16944
|
const hitContainers = /* @__PURE__ */ new Set();
|
|
@@ -24155,7 +24155,7 @@ function registerBuiltins() {
|
|
|
24155
24155
|
/**
|
|
24156
24156
|
* Preprocesses SVG string to ensure tinting works correctly
|
|
24157
24157
|
* Replaces fill/stroke="currentColor" and other colors with white (#FFFFFF)
|
|
24158
|
-
* This allows Phaser's tint to work
|
|
24158
|
+
* This allows Phaser's tint to work by multiplication (white × tint = tint color)
|
|
24159
24159
|
* @param svg - Raw SVG string
|
|
24160
24160
|
* @returns Preprocessed SVG string with white fills/strokes
|
|
24161
24161
|
*/
|
|
@@ -26747,6 +26747,264 @@ function CharTextInput(props) {
|
|
|
26747
26747
|
});
|
|
26748
26748
|
}
|
|
26749
26749
|
//#endregion
|
|
26750
|
+
//#region src/design-tokens/use-theme-tokens.ts
|
|
26751
|
+
/**
|
|
26752
|
+
* Hook to access complete design token system
|
|
26753
|
+
* Combines colors with text styles, spacing, sizes, and radius tokens
|
|
26754
|
+
*/
|
|
26755
|
+
/**
|
|
26756
|
+
* Hook to access complete design token system from theme context
|
|
26757
|
+
* Provides colors, text styles, spacing, sizes, and radius tokens
|
|
26758
|
+
* Automatically updates when color mode or preset changes
|
|
26759
|
+
* @returns Current DesignTokens or undefined
|
|
26760
|
+
* @example
|
|
26761
|
+
* ```typescript
|
|
26762
|
+
* function MyComponent() {
|
|
26763
|
+
* const tokens = useThemeTokens()
|
|
26764
|
+
*
|
|
26765
|
+
* if (!tokens) return null
|
|
26766
|
+
*
|
|
26767
|
+
* return (
|
|
26768
|
+
* <View
|
|
26769
|
+
* backgroundColor={tokens.colors.surface.DEFAULT}
|
|
26770
|
+
* padding={tokens.spacing.lg}
|
|
26771
|
+
* cornerRadius={tokens.radius.md}
|
|
26772
|
+
* >
|
|
26773
|
+
* <Text text="Title" style={tokens.textStyles.title} />
|
|
26774
|
+
* <Text text="Body text" style={tokens.textStyles.DEFAULT} />
|
|
26775
|
+
* </View>
|
|
26776
|
+
* )
|
|
26777
|
+
* }
|
|
26778
|
+
* ```
|
|
26779
|
+
*/
|
|
26780
|
+
function useThemeTokens() {
|
|
26781
|
+
const localTheme = useTheme();
|
|
26782
|
+
const getInitialTokens = () => {
|
|
26783
|
+
if (localTheme?.__colorPreset) {
|
|
26784
|
+
const preset = getPresetWithMode(localTheme.__colorPreset.name, localTheme.__colorPreset.mode ?? "light");
|
|
26785
|
+
return {
|
|
26786
|
+
colors: preset.colors,
|
|
26787
|
+
textStyles: createTextStyleTokens(preset.colors.text.DEFAULT.toString()),
|
|
26788
|
+
spacing: defaultSpacingTokens,
|
|
26789
|
+
sizes: defaultSizeTokens,
|
|
26790
|
+
radius: defaultRadiusTokens
|
|
26791
|
+
};
|
|
26792
|
+
}
|
|
26793
|
+
const colors = themeRegistry.getColorTokens();
|
|
26794
|
+
if (!colors) return void 0;
|
|
26795
|
+
return {
|
|
26796
|
+
colors,
|
|
26797
|
+
textStyles: createTextStyleTokens(colors.text.DEFAULT.toString()),
|
|
26798
|
+
spacing: defaultSpacingTokens,
|
|
26799
|
+
sizes: defaultSizeTokens,
|
|
26800
|
+
radius: defaultRadiusTokens
|
|
26801
|
+
};
|
|
26802
|
+
};
|
|
26803
|
+
const [tokens, setTokens] = useState(getInitialTokens());
|
|
26804
|
+
const [, forceUpdate] = useState(0);
|
|
26805
|
+
useEffect(() => {
|
|
26806
|
+
return themeRegistry.subscribe(() => {
|
|
26807
|
+
if (localTheme?.__colorPreset) {
|
|
26808
|
+
const currentMode = themeRegistry.getColorMode();
|
|
26809
|
+
const preset = getPresetWithMode(localTheme.__colorPreset.name, currentMode);
|
|
26810
|
+
setTokens({
|
|
26811
|
+
colors: preset.colors,
|
|
26812
|
+
textStyles: createTextStyleTokens(preset.colors.text.DEFAULT.toString()),
|
|
26813
|
+
spacing: defaultSpacingTokens,
|
|
26814
|
+
sizes: defaultSizeTokens,
|
|
26815
|
+
radius: defaultRadiusTokens
|
|
26816
|
+
});
|
|
26817
|
+
} else {
|
|
26818
|
+
const colors = themeRegistry.getColorTokens();
|
|
26819
|
+
if (colors) setTokens({
|
|
26820
|
+
colors,
|
|
26821
|
+
textStyles: createTextStyleTokens(colors.text.DEFAULT.toString()),
|
|
26822
|
+
spacing: defaultSpacingTokens,
|
|
26823
|
+
sizes: defaultSizeTokens,
|
|
26824
|
+
radius: defaultRadiusTokens
|
|
26825
|
+
});
|
|
26826
|
+
}
|
|
26827
|
+
forceUpdate((n) => n + 1);
|
|
26828
|
+
});
|
|
26829
|
+
}, [localTheme]);
|
|
26830
|
+
return tokens;
|
|
26831
|
+
}
|
|
26832
|
+
//#endregion
|
|
26833
|
+
//#region src/components/custom/DebugPanel.tsx
|
|
26834
|
+
/** @jsxImportSource ../.. */
|
|
26835
|
+
/**
|
|
26836
|
+
* DebugPanel component - lightweight runtime diagnostics for Phaser + PhaserJSX
|
|
26837
|
+
* Renders selected metrics as text rows or a compact single-line summary.
|
|
26838
|
+
*/
|
|
26839
|
+
var PRESET_METRICS = {
|
|
26840
|
+
fps: ["fps", "frameMs"],
|
|
26841
|
+
perf: [
|
|
26842
|
+
"fps",
|
|
26843
|
+
"frameMs",
|
|
26844
|
+
"renderer",
|
|
26845
|
+
"viewport"
|
|
26846
|
+
],
|
|
26847
|
+
vdom: [
|
|
26848
|
+
"mountsTotal",
|
|
26849
|
+
"mountsByType",
|
|
26850
|
+
"mountsByParent",
|
|
26851
|
+
"mountsByKey"
|
|
26852
|
+
],
|
|
26853
|
+
textures: ["textureCount"],
|
|
26854
|
+
full: [
|
|
26855
|
+
"fps",
|
|
26856
|
+
"frameMs",
|
|
26857
|
+
"phaserVersion",
|
|
26858
|
+
"renderer",
|
|
26859
|
+
"viewport",
|
|
26860
|
+
"textureCount",
|
|
26861
|
+
"mountsTotal",
|
|
26862
|
+
"mountsByType",
|
|
26863
|
+
"mountsByParent",
|
|
26864
|
+
"mountsByKey",
|
|
26865
|
+
"debugFlags"
|
|
26866
|
+
]
|
|
26867
|
+
};
|
|
26868
|
+
var DEFAULT_LABELS = {
|
|
26869
|
+
fps: "FPS",
|
|
26870
|
+
frameMs: "Frame ms",
|
|
26871
|
+
phaserVersion: "Phaser",
|
|
26872
|
+
renderer: "Renderer",
|
|
26873
|
+
viewport: "Viewport",
|
|
26874
|
+
textureCount: "Textures",
|
|
26875
|
+
mountsTotal: "Mounts",
|
|
26876
|
+
mountsByType: "Mounts/type",
|
|
26877
|
+
mountsByParent: "Mounts/parent",
|
|
26878
|
+
mountsByKey: "Mounts/key",
|
|
26879
|
+
debugFlags: "Debug flags"
|
|
26880
|
+
};
|
|
26881
|
+
function resolveRendererName(scene) {
|
|
26882
|
+
const renderer = scene.renderer;
|
|
26883
|
+
const canvasType = phaser.CANVAS;
|
|
26884
|
+
if (renderer.type === phaser.WEBGL) return "WebGL";
|
|
26885
|
+
if (canvasType !== void 0 && renderer.type === canvasType) return "Canvas";
|
|
26886
|
+
if (renderer.constructor?.name) return renderer.constructor.name;
|
|
26887
|
+
if (typeof renderer.type === "number") return `Type ${renderer.type}`;
|
|
26888
|
+
return "Unknown";
|
|
26889
|
+
}
|
|
26890
|
+
function resolveTextureCount(scene) {
|
|
26891
|
+
const manager = scene.textures;
|
|
26892
|
+
const keys = typeof manager.getTextureKeys === "function" ? manager.getTextureKeys() : Object.keys(manager.list ?? {});
|
|
26893
|
+
const internalKeys = new Set([
|
|
26894
|
+
"__DEFAULT",
|
|
26895
|
+
"__MISSING",
|
|
26896
|
+
"__NORMAL",
|
|
26897
|
+
"__WHITE"
|
|
26898
|
+
]);
|
|
26899
|
+
return keys.filter((key) => !internalKeys.has(key.toUpperCase())).length;
|
|
26900
|
+
}
|
|
26901
|
+
function resolveFrameStats(scene) {
|
|
26902
|
+
const loop = scene.game.loop;
|
|
26903
|
+
const rawFps = loop?.actualFps ?? loop?.fps ?? 0;
|
|
26904
|
+
const rawFrameMs = loop?.delta ?? loop?.frameDelta ?? 0;
|
|
26905
|
+
return {
|
|
26906
|
+
fps: Number.isFinite(rawFps) ? Number(rawFps.toFixed(1)) : 0,
|
|
26907
|
+
frameMs: Number.isFinite(rawFrameMs) ? Number(rawFrameMs.toFixed(2)) : 0
|
|
26908
|
+
};
|
|
26909
|
+
}
|
|
26910
|
+
function summarizeMap(map, maxEntries = 3) {
|
|
26911
|
+
return Array.from(map.entries()).sort((a, b) => b[1] - a[1]).slice(0, maxEntries).map(([key, value]) => `${String(key)}:${value}`).join(" | ") || "-";
|
|
26912
|
+
}
|
|
26913
|
+
function resolveDebugFlags() {
|
|
26914
|
+
const debugConfig = DevConfig.debug;
|
|
26915
|
+
if (!debugConfig.enabled) return "off";
|
|
26916
|
+
const enabledFlags = Object.entries(debugConfig).filter(([key, value]) => key !== "enabled" && value).map(([key]) => key);
|
|
26917
|
+
return enabledFlags.length ? enabledFlags.join(",") : "enabled";
|
|
26918
|
+
}
|
|
26919
|
+
function collectSnapshot(scene) {
|
|
26920
|
+
const { fps, frameMs } = resolveFrameStats(scene);
|
|
26921
|
+
const mountStats = getMountStats();
|
|
26922
|
+
return {
|
|
26923
|
+
fps,
|
|
26924
|
+
frameMs,
|
|
26925
|
+
phaserVersion: phaser.VERSION,
|
|
26926
|
+
renderer: resolveRendererName(scene),
|
|
26927
|
+
viewport: `${scene.scale.width}x${scene.scale.height}`,
|
|
26928
|
+
textureCount: resolveTextureCount(scene),
|
|
26929
|
+
mountsTotal: mountStats.totalMounts,
|
|
26930
|
+
mountsByType: summarizeMap(mountStats.byType),
|
|
26931
|
+
mountsByParent: summarizeMap(mountStats.byParent),
|
|
26932
|
+
mountsByKey: summarizeMap(mountStats.byKey),
|
|
26933
|
+
debugFlags: resolveDebugFlags()
|
|
26934
|
+
};
|
|
26935
|
+
}
|
|
26936
|
+
function formatDefault(value) {
|
|
26937
|
+
return typeof value === "number" ? String(value) : value;
|
|
26938
|
+
}
|
|
26939
|
+
/**
|
|
26940
|
+
* DebugPanel component
|
|
26941
|
+
* Shows selected diagnostics from Phaser + PhaserJSX as overlay-ready content.
|
|
26942
|
+
*/
|
|
26943
|
+
function DebugPanel(props) {
|
|
26944
|
+
const scene = useScene();
|
|
26945
|
+
const { preset = "fps", metrics, intervalMs = 250, compact = false, maxRows, labels, formatters, innerProps, ...viewProps } = props;
|
|
26946
|
+
const selectedMetrics = useMemo(() => {
|
|
26947
|
+
const source = metrics && metrics.length > 0 ? metrics : PRESET_METRICS[preset];
|
|
26948
|
+
return Array.from(new Set(source));
|
|
26949
|
+
}, [metrics, preset]);
|
|
26950
|
+
const [snapshot, setSnapshot] = useState(collectSnapshot(scene));
|
|
26951
|
+
useEffect(() => {
|
|
26952
|
+
const delay = Math.max(50, intervalMs);
|
|
26953
|
+
setSnapshot(collectSnapshot(scene));
|
|
26954
|
+
const timer = window.setInterval(() => {
|
|
26955
|
+
setSnapshot(collectSnapshot(scene));
|
|
26956
|
+
}, delay);
|
|
26957
|
+
return () => {
|
|
26958
|
+
window.clearInterval(timer);
|
|
26959
|
+
};
|
|
26960
|
+
}, [
|
|
26961
|
+
scene,
|
|
26962
|
+
intervalMs,
|
|
26963
|
+
selectedMetrics
|
|
26964
|
+
]);
|
|
26965
|
+
const tokens = useThemeTokens();
|
|
26966
|
+
const rowStyle = tokens?.textStyles.small;
|
|
26967
|
+
const valueStyle = tokens?.textStyles.small;
|
|
26968
|
+
const rows = selectedMetrics.map((metric) => {
|
|
26969
|
+
const rawValue = snapshot[metric];
|
|
26970
|
+
const label = labels?.[metric] ?? DEFAULT_LABELS[metric];
|
|
26971
|
+
const formatter = formatters?.[metric];
|
|
26972
|
+
return {
|
|
26973
|
+
metric,
|
|
26974
|
+
label,
|
|
26975
|
+
value: formatter ? formatter(rawValue) : formatDefault(rawValue)
|
|
26976
|
+
};
|
|
26977
|
+
});
|
|
26978
|
+
const limitedRows = typeof maxRows === "number" ? rows.slice(0, Math.max(1, maxRows)) : rows;
|
|
26979
|
+
if (compact) {
|
|
26980
|
+
const compactText = limitedRows.map((row) => `${row.label} ${row.value}`).join(" | ");
|
|
26981
|
+
return /* @__PURE__ */ require_jsx_runtime.jsx(View, {
|
|
26982
|
+
...viewProps,
|
|
26983
|
+
children: /* @__PURE__ */ require_jsx_runtime.jsx(Text, {
|
|
26984
|
+
text: compactText,
|
|
26985
|
+
style: valueStyle
|
|
26986
|
+
})
|
|
26987
|
+
});
|
|
26988
|
+
}
|
|
26989
|
+
return /* @__PURE__ */ require_jsx_runtime.jsx(View, {
|
|
26990
|
+
direction: "column",
|
|
26991
|
+
gap: 4,
|
|
26992
|
+
...viewProps,
|
|
26993
|
+
children: limitedRows.map((row) => /* @__PURE__ */ require_jsx_runtime.jsxs(View, {
|
|
26994
|
+
direction: "row",
|
|
26995
|
+
gap: 8,
|
|
26996
|
+
...innerProps,
|
|
26997
|
+
children: [/* @__PURE__ */ require_jsx_runtime.jsx(Text, {
|
|
26998
|
+
text: `${row.label}:`,
|
|
26999
|
+
style: rowStyle
|
|
27000
|
+
}), /* @__PURE__ */ require_jsx_runtime.jsx(Text, {
|
|
27001
|
+
text: row.value,
|
|
27002
|
+
style: valueStyle
|
|
27003
|
+
})]
|
|
27004
|
+
}, `debug-${row.metric}`))
|
|
27005
|
+
});
|
|
27006
|
+
}
|
|
27007
|
+
//#endregion
|
|
26750
27008
|
//#region src/components/custom/Divider.tsx
|
|
26751
27009
|
/**
|
|
26752
27010
|
* Divider component - renders a simple line separator
|
|
@@ -29199,7 +29457,6 @@ function Toggle(props) {
|
|
|
29199
29457
|
setIsAnimating(true);
|
|
29200
29458
|
const endX = newChecked ? thumbOffsetOn : thumbOffsetOff;
|
|
29201
29459
|
const startX = thumbX;
|
|
29202
|
-
console.log("Duration:", duration.current);
|
|
29203
29460
|
scene.tweens.addCounter({
|
|
29204
29461
|
from: 0,
|
|
29205
29462
|
to: 1,
|
|
@@ -29420,6 +29677,12 @@ Object.defineProperty(exports, "DebugLogger", {
|
|
|
29420
29677
|
return DebugLogger;
|
|
29421
29678
|
}
|
|
29422
29679
|
});
|
|
29680
|
+
Object.defineProperty(exports, "DebugPanel", {
|
|
29681
|
+
enumerable: true,
|
|
29682
|
+
get: function() {
|
|
29683
|
+
return DebugPanel;
|
|
29684
|
+
}
|
|
29685
|
+
});
|
|
29423
29686
|
Object.defineProperty(exports, "DevConfig", {
|
|
29424
29687
|
enumerable: true,
|
|
29425
29688
|
get: function() {
|
|
@@ -30458,6 +30721,12 @@ Object.defineProperty(exports, "useTheme", {
|
|
|
30458
30721
|
return useTheme;
|
|
30459
30722
|
}
|
|
30460
30723
|
});
|
|
30724
|
+
Object.defineProperty(exports, "useThemeTokens", {
|
|
30725
|
+
enumerable: true,
|
|
30726
|
+
get: function() {
|
|
30727
|
+
return useThemeTokens;
|
|
30728
|
+
}
|
|
30729
|
+
});
|
|
30461
30730
|
Object.defineProperty(exports, "useViewportSize", {
|
|
30462
30731
|
enumerable: true,
|
|
30463
30732
|
get: function() {
|
|
@@ -30495,4 +30764,4 @@ Object.defineProperty(exports, "withHooks", {
|
|
|
30495
30764
|
}
|
|
30496
30765
|
});
|
|
30497
30766
|
|
|
30498
|
-
//# sourceMappingURL=custom-
|
|
30767
|
+
//# sourceMappingURL=custom-DTd4LxDn.cjs.map
|