@stanko/kaplay-inspector 0.1.5 → 0.1.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
@@ -132,6 +132,5 @@ Same as with colors, be sure to have a higher specificity selector if inspector'
132
132
  ## TODO
133
133
 
134
134
  * [ ] Controllable theme - system/light/dark. At the moment it is always matching the system.
135
- * [ ] Filter/search
136
135
  * [ ] Persist search in URL or local storage
137
136
  * [ ] Collapse/Expand all button
@@ -0,0 +1,6 @@
1
+ import type { GameObj } from "kaplay";
2
+ export interface AnchorControlsProps {
3
+ className?: string;
4
+ obj: GameObj;
5
+ }
6
+ export declare const AnchorControls: ({ className, obj, }: AnchorControlsProps) => import("preact").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
+ import { cx } from "../lib/cx";
3
+ import { VectorControls } from "./vector-controls";
4
+ import { k } from "../k";
5
+ const strings = [
6
+ ["topleft", "top", "topright"],
7
+ ["left", "center", "right"],
8
+ ["botleft", "bot", "botright"],
9
+ ];
10
+ export const AnchorControls = ({ className = "", obj, }) => {
11
+ const object = obj;
12
+ const isString = typeof obj.anchor === "string";
13
+ return (_jsx("div", { class: cx(className, "anchor-controls"), children: isString ? (_jsxs(_Fragment, { children: [_jsxs("div", { class: "anchor-radios", children: [strings.map((row, i) => {
14
+ return (_jsx("div", { class: "anchor-row", children: row.map((anchor) => {
15
+ return (_jsx("label", { children: _jsx("input", { type: "radio", name: "anchor", value: anchor, checked: anchor === object.anchor, onChange: () => (object.anchor = anchor) }) }, anchor));
16
+ }) }, i));
17
+ }), _jsx("div", { children: isString && object.anchor })] }), _jsx("button", { class: "ki-btn", onClick: () => (object.anchor = k.vec2(0, 0)), children: "Switch to vector" })] })) : (_jsxs(_Fragment, { children: [_jsx(VectorControls, { value: object.anchor, onChange: (anchor) => (object.anchor = anchor), step: 0.05 }), _jsx("button", { class: "ki-btn", onClick: () => (object.anchor = "center"), children: "Switch to string" })] })) }));
18
+ };
@@ -1,5 +1,4 @@
1
1
  import type { GameObj } from "kaplay";
2
- import type { KAPLAYCtxType } from "../init";
3
2
  export interface GameObjectProps {
4
3
  className?: string;
5
4
  obj: GameObj;
@@ -7,6 +6,5 @@ export interface GameObjectProps {
7
6
  isExpanded?: boolean;
8
7
  isRenderRoot?: boolean;
9
8
  shouldDrawInspect: boolean;
10
- k: KAPLAYCtxType;
11
9
  }
12
- export declare const GameObject: ({ obj, className, isExpanded: isExpandedExternal, isRenderRoot, setRenderRoot, shouldDrawInspect, k, }: GameObjectProps) => import("preact").JSX.Element | null;
10
+ export declare const GameObject: ({ obj, className, isExpanded: isExpandedExternal, isRenderRoot, setRenderRoot, shouldDrawInspect, }: GameObjectProps) => import("preact").JSX.Element | null;
@@ -6,7 +6,8 @@ import { drawBoundingBox } from "../lib/draw-bbox";
6
6
  import { getObjectInfo } from "../lib/get-object-info";
7
7
  import { Breadcrumbs } from "./breadcrumbs";
8
8
  import { BooleanComp } from "./boolean-comp";
9
- export const GameObject = ({ obj, className = "", isExpanded: isExpandedExternal = false, isRenderRoot, setRenderRoot, shouldDrawInspect, k, }) => {
9
+ import { k } from "../k";
10
+ export const GameObject = ({ obj, className = "", isExpanded: isExpandedExternal = false, isRenderRoot, setRenderRoot, shouldDrawInspect, }) => {
10
11
  const [isExpanded, setIsExpanded] = useState(isExpandedExternal);
11
12
  const updateControllers = useRef([]);
12
13
  const { compsData, tags, compsLabel } = getObjectInfo(obj);
@@ -24,7 +25,7 @@ export const GameObject = ({ obj, className = "", isExpanded: isExpandedExternal
24
25
  const drawInspect = useCallback((obj) => {
25
26
  if (!obj.hidden) {
26
27
  const updateController = k.onDraw(() => {
27
- drawBoundingBox(obj, k);
28
+ drawBoundingBox(obj);
28
29
  obj.drawInspect();
29
30
  });
30
31
  updateControllers.current.push(updateController);
@@ -54,5 +55,5 @@ export const GameObject = ({ obj, className = "", isExpanded: isExpandedExternal
54
55
  "game-object--no-children": !hasChildren,
55
56
  }), children: [isInspecting && _jsx(Breadcrumbs, { setRenderRoot: setRenderRoot, obj: obj }), _jsxs("div", { class: "game-object__content", onMouseEnter: handleMouseEnter, onMouseLeave: cancelUpdateControllers, children: [_jsxs("button", { class: cx("game-object__header", {
56
57
  "game-object__header--expandable": showExpandTree,
57
- }), onClick: handleToggleClick, children: [isExpanded ? (_jsx(MinusIcon, { className: "game-object__expand-icon" })) : (_jsx(PlusIcon, { className: "game-object__expand-icon" })), _jsxs("div", { class: "game-object__id", children: ["ID ", obj.id, ":"] }), tags ? (_jsx("div", { class: "game-object__tags", children: isRootObject ? "Root" : tags })) : (_jsx("div", { class: "game-object__comp-names", children: compsLabel })), obj.children.length > 0 && _jsxs("div", { children: ["(", obj.children.length, ")"] }), isObjectDestroyed && (_jsx("div", { class: "game-object__destroyed", children: "DESTROYED" }))] }), _jsxs("div", { class: "game-object__buttons", children: [!isRenderRoot && (_jsx("button", { class: "ki-btn", onClick: () => setRenderRoot(obj), children: "inspect" })), _jsx("button", { class: "ki-btn ", onClick: () => console.log(obj), children: "log" })] }), isExpanded && (_jsx("div", { class: "game-object__comps-wrapper", children: _jsxs("div", { class: "game-object__comps", children: [_jsx(BooleanComp, { obj: obj, propName: "paused" }), _jsx(BooleanComp, { obj: obj, propName: "hidden" }), hasSize && (_jsxs("div", { class: "game-object__comps-row", children: [_jsx("b", { children: "size" }), _jsxs("div", { children: [obj.width, " x ", obj.height] })] })), compsData.map((comp) => (_jsxs("div", { class: "game-object__comps-row", children: [_jsx("b", { children: comp.tag }), _jsx("div", { children: comp.value })] }, comp.tag)))] }) }))] }), isExpanded && hasChildren && (_jsx("div", { class: "game-object__children", style: { display: isExpanded ? "block" : "none" }, children: obj.children.map((child) => (_jsx(GameObject, { k: k, obj: child, setRenderRoot: setRenderRoot, shouldDrawInspect: shouldDrawInspect }, child.id))) }))] }, obj.id));
58
+ }), onClick: handleToggleClick, children: [isExpanded ? (_jsx(MinusIcon, { className: "game-object__expand-icon" })) : (_jsx(PlusIcon, { className: "game-object__expand-icon" })), _jsxs("div", { class: "game-object__id", children: ["ID ", obj.id, ":"] }), tags ? (_jsx("div", { class: "game-object__tags", children: isRootObject ? "Root" : tags })) : (_jsx("div", { class: "game-object__comp-names", children: compsLabel })), obj.children.length > 0 && _jsxs("div", { children: ["(", obj.children.length, ")"] }), isObjectDestroyed && (_jsx("div", { class: "game-object__destroyed", children: "DESTROYED" }))] }), _jsxs("div", { class: "game-object__buttons", children: [!isRenderRoot && (_jsx("button", { class: "ki-btn", onClick: () => setRenderRoot(obj), children: "inspect" })), _jsx("button", { class: "ki-btn ", onClick: () => console.log(obj), children: "log" })] }), isExpanded && (_jsx("div", { class: "game-object__comps-wrapper", children: _jsxs("div", { class: "game-object__comps", children: [_jsx(BooleanComp, { obj: obj, propName: "paused" }), _jsx(BooleanComp, { obj: obj, propName: "hidden" }), hasSize && (_jsxs("div", { class: "game-object__comps-row", children: [_jsx("b", { children: "size" }), _jsxs("div", { children: [obj.width, " x ", obj.height] })] })), compsData.map((comp) => (_jsxs("div", { class: "game-object__comps-row", children: [_jsx("b", { children: comp.tag }), _jsx("div", { children: comp.value })] }, comp.tag)))] }) }))] }), isExpanded && hasChildren && (_jsx("div", { class: "game-object__children", style: { display: isExpanded ? "block" : "none" }, children: obj.children.map((child) => (_jsx(GameObject, { obj: child, setRenderRoot: setRenderRoot, shouldDrawInspect: shouldDrawInspect }, child.id))) }))] }, obj.id));
58
59
  };
@@ -1,5 +1,4 @@
1
- import type { InspectorOptions, KAPLAYCtxType } from "../init";
1
+ import type { InspectorOptions } from "../init";
2
2
  export interface InspectorProps extends InspectorOptions {
3
- k: KAPLAYCtxType;
4
3
  }
5
- export declare const Inspector: ({ initUpdateTimeout, isVisibleOnLoad, initDrawInspectOnHover, k, }: InspectorProps) => import("preact").JSX.Element;
4
+ export declare const Inspector: ({ initUpdateTimeout, isVisibleOnLoad, initDrawInspectOnHover, }: InspectorProps) => import("preact").JSX.Element;
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from "preact/hooks";
3
3
  import { GameObject } from "./game-object";
4
4
  import { useObjectBoolean } from "./boolean-comp";
5
5
  import { SearchResults } from "./search-results";
6
+ import { k } from "../k";
6
7
  const INTERVAL_OPTIONS = [
7
8
  { value: 100, label: "100ms" },
8
9
  { value: 250, label: "250ms" },
@@ -10,7 +11,7 @@ const INTERVAL_OPTIONS = [
10
11
  { value: 1000, label: "1s" },
11
12
  ];
12
13
  const TYPING_TIMEOUT = 250;
13
- export const Inspector = ({ initUpdateTimeout = 250, isVisibleOnLoad = true, initDrawInspectOnHover = true, k, }) => {
14
+ export const Inspector = ({ initUpdateTimeout = 250, isVisibleOnLoad = true, initDrawInspectOnHover = true, }) => {
14
15
  const [updateTimeout, setUpdateTimeout] = useState(initUpdateTimeout);
15
16
  const [shouldDrawInspect, setShouldDrawInspect] = useState(initDrawInspectOnHover);
16
17
  const [root, setRoot] = useState(k.getTreeRoot());
@@ -44,5 +45,5 @@ export const Inspector = ({ initUpdateTimeout = 250, isVisibleOnLoad = true, ini
44
45
  if (!isVisible) {
45
46
  return (_jsx("button", { class: "ki-btn k-inspector__show", onClick: toggleVisibility, children: "Show Inspector" }));
46
47
  }
47
- return (_jsxs(_Fragment, { children: [_jsxs("div", { class: "k-inspector__header", children: [_jsx("button", { class: "ki-btn", onClick: () => paused.onChange(!paused.checked), children: paused.checked ? "Resume Game" : "Pause Game" }), "\u2022", _jsx("input", { placeholder: "Search tags or comps", type: "text", class: "ki-input", onInput: handleSearchInput }), "\u2022", _jsxs("div", { children: [k.get("*", { recursive: true }).length, " objects"] }), "\u2022", _jsxs("div", { children: [Math.round(k.debug.fps()), " fps"] }), "\u2022", _jsxs("div", { class: "k-inspector__interval", children: ["Update:", INTERVAL_OPTIONS.map((option) => (_jsxs("label", { children: [_jsx("input", { type: "radio", name: "interval", value: option.value, checked: updateTimeout === option.value, onChange: () => setUpdateTimeout(option.value) }), option.label] }, option.value)))] }), "\u2022", _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: shouldDrawInspect, onChange: () => setShouldDrawInspect(!shouldDrawInspect) }), "Draw bbox on hover"] }), _jsx("button", { class: "ki-btn k-inspector__hide", onClick: toggleVisibility, children: "Hide" })] }), _jsx("div", { class: "k-inspector__objects", children: searchTerm.length > 0 ? (_jsx(SearchResults, { k: k, results: searchResults, setRenderRoot: setRoot, shouldDrawInspect: shouldDrawInspect })) : (_jsx(GameObject, { k: k, className: "game-object--root", obj: root, setRenderRoot: setRoot, shouldDrawInspect: shouldDrawInspect, isExpanded: true, isRenderRoot: true })) })] }));
48
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { class: "k-inspector__header", children: [_jsx("button", { class: "ki-btn", onClick: () => paused.onChange(!paused.checked), children: paused.checked ? "Resume Game" : "Pause Game" }), "\u2022", _jsx("input", { placeholder: "Search tags or comps", type: "text", class: "ki-input", onInput: handleSearchInput }), "\u2022", _jsxs("div", { children: [k.get("*", { recursive: true }).length, " objects"] }), "\u2022", _jsxs("div", { children: [Math.round(k.debug.fps()), " fps"] }), "\u2022", _jsxs("div", { class: "k-inspector__interval", children: ["Update:", INTERVAL_OPTIONS.map((option) => (_jsxs("label", { children: [_jsx("input", { type: "radio", name: "interval", value: option.value, checked: updateTimeout === option.value, onChange: () => setUpdateTimeout(option.value) }), option.label] }, option.value)))] }), "\u2022", _jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: shouldDrawInspect, onChange: () => setShouldDrawInspect(!shouldDrawInspect) }), "Draw bbox on hover"] }), _jsx("button", { class: "ki-btn k-inspector__hide", onClick: toggleVisibility, children: "Hide" })] }), _jsx("div", { class: "k-inspector__objects", children: searchTerm.length > 0 ? (_jsx(SearchResults, { results: searchResults, setRenderRoot: setRoot, shouldDrawInspect: shouldDrawInspect })) : (_jsx(GameObject, { className: "game-object--root", obj: root, setRenderRoot: setRoot, shouldDrawInspect: shouldDrawInspect, isExpanded: true, isRenderRoot: true })) })] }));
48
49
  };
@@ -3,4 +3,4 @@ export interface PositionControlsProps {
3
3
  className?: string;
4
4
  obj: GameObj;
5
5
  }
6
- export declare const PositionControls: ({ obj }: PositionControlsProps) => import("preact").JSX.Element | null;
6
+ export declare const PositionControls: ({ className, obj, }: PositionControlsProps) => import("preact").JSX.Element | null;
@@ -1,10 +1,8 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
- import { roundToDecimal } from "../lib/round-to-decimal";
3
- import { HoldButton } from "./hold-button";
4
- import { ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon, } from "./icons";
5
- export const PositionControls = ({ obj }) => {
1
+ import { jsx as _jsx } from "preact/jsx-runtime";
2
+ import { VectorControls } from "./vector-controls";
3
+ export const PositionControls = ({ className = "", obj, }) => {
6
4
  if (!obj.pos) {
7
5
  return null;
8
6
  }
9
- return (_jsxs("div", { class: "pos-controls", children: [_jsx(HoldButton, { className: "ki-btn", onClickAndHold: () => obj.moveTo(obj.pos.x - 1, obj.pos.y), children: _jsx(ArrowLeftIcon, {}) }), _jsx(HoldButton, { className: "ki-btn", onClickAndHold: () => obj.moveTo(obj.pos.x + 1, obj.pos.y), children: _jsx(ArrowRightIcon, {}) }), _jsxs("div", { class: "pos-controls__value", children: ["x: ", roundToDecimal(obj.pos.x, 2)] }), _jsxs("div", { class: "pos-controls__value", children: ["y: ", roundToDecimal(obj.pos.y, 2)] }), _jsx(HoldButton, { className: "ki-btn", onClickAndHold: () => obj.moveTo(obj.pos.x, obj.pos.y - 1), children: _jsx(ArrowUpIcon, {}) }), _jsx(HoldButton, { className: "ki-btn", onClickAndHold: () => obj.moveTo(obj.pos.x, obj.pos.y + 1), children: _jsx(ArrowDownIcon, {}) })] }));
7
+ return (_jsx(VectorControls, { className: className, value: obj.pos, onChange: (pos) => (obj.pos = pos) }));
10
8
  };
@@ -1,10 +1,8 @@
1
1
  import type { GameObj } from "kaplay";
2
- import type { KAPLAYCtxType } from "../init";
3
2
  export interface SearchResultsProps {
4
- k: KAPLAYCtxType;
5
3
  className?: string;
6
4
  results: GameObj[];
7
5
  setRenderRoot: (obj: GameObj) => void;
8
6
  shouldDrawInspect: boolean;
9
7
  }
10
- export declare const SearchResults: ({ k, results, setRenderRoot, shouldDrawInspect, }: SearchResultsProps) => import("preact").JSX.Element;
8
+ export declare const SearchResults: ({ results, setRenderRoot, shouldDrawInspect, }: SearchResultsProps) => import("preact").JSX.Element;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { GameObject } from "./game-object";
3
- export const SearchResults = ({ k, results, setRenderRoot, shouldDrawInspect, }) => {
3
+ export const SearchResults = ({ results, setRenderRoot, shouldDrawInspect, }) => {
4
4
  if (results.length === 0) {
5
5
  return _jsx("div", { children: "No results found." });
6
6
  }
7
7
  return (_jsxs("div", { children: [results.map((result) => {
8
- return (_jsx(GameObject, { k: k, className: "game-object--root", obj: result, setRenderRoot: setRenderRoot, shouldDrawInspect: shouldDrawInspect }));
8
+ return (_jsx(GameObject, { className: "game-object--root", obj: result, setRenderRoot: setRenderRoot, shouldDrawInspect: shouldDrawInspect }));
9
9
  }), " "] }));
10
10
  };
@@ -1,16 +1,10 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
- import { useEffect, useState } from "preact/hooks";
3
2
  export const TextControls = ({ obj }) => {
4
- const [text, setText] = useState(obj.text);
5
- useEffect(() => {
6
- setText(obj.text);
7
- }, [obj.text]);
8
3
  if (typeof obj.text !== "string") {
9
4
  return null;
10
5
  }
11
6
  const handleInput = (e) => {
12
7
  obj.text = e.target.value;
13
- setText(text);
14
8
  };
15
- return (_jsx("div", { class: "text-controls", children: _jsx("input", { class: "text-controls__input", type: "text", placeholder: "Enter text", value: text, onInput: handleInput }) }));
9
+ return (_jsx("div", { class: "text-controls", children: _jsx("textarea", { class: "text-controls__input ki-input", placeholder: "Enter text", value: obj.text, onInput: handleInput }) }));
16
10
  };
@@ -0,0 +1,8 @@
1
+ import type { Vec2 } from "kaplay";
2
+ export interface VectorControlsProps {
3
+ className?: string;
4
+ value: Vec2;
5
+ onChange: (v: Vec2) => void;
6
+ step?: number;
7
+ }
8
+ export declare const VectorControls: ({ className, value, onChange, step, }: VectorControlsProps) => import("preact").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { roundToDecimal } from "../lib/round-to-decimal";
3
+ import { HoldButton } from "./hold-button";
4
+ import { ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon, } from "./icons";
5
+ import { k } from "../k";
6
+ import { cx } from "../lib/cx";
7
+ export const VectorControls = ({ className = "", value, onChange, step = 1, }) => {
8
+ return (_jsxs("div", { class: cx(className, "vector-controls"), children: [_jsx(HoldButton, { className: "ki-btn", onClickAndHold: () => onChange(k.vec2(value.x - step, value.y)), children: _jsx(ArrowLeftIcon, {}) }), _jsx(HoldButton, { className: "ki-btn", onClickAndHold: () => onChange(k.vec2(value.x + step, value.y)), children: _jsx(ArrowRightIcon, {}) }), _jsxs("div", { class: "vector-controls__value", children: ["x: ", roundToDecimal(value.x, 2)] }), _jsxs("div", { class: "vector-controls__value", children: ["y: ", roundToDecimal(value.y, 2)] }), _jsx(HoldButton, { className: "ki-btn", onClickAndHold: () => onChange(k.vec2(value.x, value.y - step)), children: _jsx(ArrowUpIcon, {}) }), _jsx(HoldButton, { className: "ki-btn", onClickAndHold: () => onChange(k.vec2(value.x, value.y + step)), children: _jsx(ArrowDownIcon, {}) })] }));
9
+ };
package/dist/init.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import kaplay from "kaplay";
2
- export type KAPLAYCtxType = ReturnType<typeof kaplay>;
1
+ import { type KAPLAYCtxType } from "./k";
3
2
  export interface InspectorOptions {
4
3
  initUpdateTimeout?: number;
5
4
  initDrawInspectOnHover?: boolean;
package/dist/init.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
2
  import { render } from "preact";
3
3
  import { Inspector } from "./components/inspector";
4
+ import { setK } from "./k";
4
5
  export default function init(k, props = {}) {
5
6
  const { className = "", initUpdateTimeout = 250, isVisibleOnLoad = true, initDrawInspectOnHover = true, } = props;
7
+ // Set kaplay context to be imported directly from components to reduce prop drilling
8
+ setK(k);
6
9
  const appElement = document.createElement("div");
7
10
  appElement.className = `k-inspector ${className}`;
8
11
  document.body.appendChild(appElement);
9
- render(_jsx(Inspector, { k: k, initUpdateTimeout: initUpdateTimeout, isVisibleOnLoad: isVisibleOnLoad, initDrawInspectOnHover: initDrawInspectOnHover }), appElement);
12
+ render(_jsx(Inspector, { initUpdateTimeout: initUpdateTimeout, isVisibleOnLoad: isVisibleOnLoad, initDrawInspectOnHover: initDrawInspectOnHover }), appElement);
10
13
  }
package/dist/k.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import kaplay from "kaplay";
2
+ export type KAPLAYCtxType = ReturnType<typeof kaplay>;
3
+ export declare let k: KAPLAYCtxType;
4
+ export declare const setK: (ctx: KAPLAYCtxType) => void;
package/dist/k.js ADDED
@@ -0,0 +1,4 @@
1
+ export let k;
2
+ export const setK = (ctx) => {
3
+ k = ctx;
4
+ };
@@ -1,3 +1,2 @@
1
1
  import type { GameObj } from "kaplay";
2
- import type { KAPLAYCtxType } from "../init";
3
- export declare const drawBoundingBox: (obj: GameObj, k: KAPLAYCtxType) => void;
2
+ export declare const drawBoundingBox: (obj: GameObj) => void;
@@ -1,3 +1,4 @@
1
+ import { k } from "../k";
1
2
  const anchorMap = {
2
3
  topleft: [-1, -1],
3
4
  top: [0, -1],
@@ -9,7 +10,7 @@ const anchorMap = {
9
10
  bot: [0, 1],
10
11
  botright: [1, 1],
11
12
  };
12
- export const drawBoundingBox = (obj, k) => {
13
+ export const drawBoundingBox = (obj) => {
13
14
  if (obj.renderArea) {
14
15
  const localArea = obj.renderArea();
15
16
  const transform = obj.transform.clone();
@@ -40,7 +41,7 @@ export const drawBoundingBox = (obj, k) => {
40
41
  }
41
42
  obj.children.forEach((child) => {
42
43
  if (!child.hidden) {
43
- drawBoundingBox(child, k);
44
+ drawBoundingBox(child);
44
45
  }
45
46
  });
46
47
  };
@@ -6,11 +6,13 @@ import { SpriteControls } from "../components/sprite-controls";
6
6
  import { Color } from "../components/color-controls";
7
7
  import { ChildObject } from "../components/child-object";
8
8
  import { isGameObj } from "./is-game-obj";
9
+ import { AnchorControls } from "../components/anchor-controls";
9
10
  const componentMap = {
10
11
  pos: PositionControls,
11
12
  text: TextControls,
12
13
  sprite: SpriteControls,
13
14
  color: Color,
15
+ anchor: AnchorControls,
14
16
  };
15
17
  export const inspectComps = (obj) => {
16
18
  const object = obj;
package/dist/styles.css CHANGED
@@ -309,9 +309,9 @@
309
309
  padding-bottom: 1rem;
310
310
  }
311
311
 
312
- /* Position controls */
312
+ /* Vector controls */
313
313
 
314
- .pos-controls {
314
+ .vector-controls {
315
315
  display: flex;
316
316
  align-items: center;
317
317
  gap: 0.25rem;
@@ -319,13 +319,13 @@
319
319
  min-width: 12rem;
320
320
  }
321
321
 
322
- .pos-controls .ki-btn,
323
- .pos-controls__value {
322
+ .vector-controls .ki-btn,
323
+ .vector-controls__value {
324
324
  flex-shrink: 0;
325
325
  text-align: center;
326
326
  }
327
327
 
328
- .pos-controls__value {
328
+ .vector-controls__value {
329
329
  width: 5rem;
330
330
  }
331
331
 
@@ -335,6 +335,26 @@
335
335
  width: 100%;
336
336
  }
337
337
 
338
+ /* Anchor controls */
339
+
340
+ .anchor-controls {
341
+ display: flex;
342
+ align-items: center;
343
+ gap: 1rem;
344
+ }
345
+
346
+ .anchor-radios {
347
+ text-align: center;
348
+ }
349
+
350
+ .anchor-row {
351
+ display: flex;
352
+ }
353
+
354
+ .anchor-radios label {
355
+ padding: 0.25rem;
356
+ }
357
+
338
358
  /* Color */
339
359
 
340
360
  .color-controls {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stanko/kaplay-inspector",
3
3
  "description": "A dev tool for Kaplay which allows you to explore and inspect the game object tree real time.",
4
4
  "private": false,
5
- "version": "0.1.5",
5
+ "version": "0.1.7",
6
6
  "type": "module",
7
7
  "main": "./dist/init.js",
8
8
  "types": "./dist/init.d.ts",
@@ -24,13 +24,13 @@
24
24
  "kaplay": "^4000.0.0-alpha.20"
25
25
  },
26
26
  "dependencies": {
27
- "preact": "^10.28.0"
27
+ "preact": "^10.28.2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@preact/preset-vite": "^2.10.2",
31
- "@types/node": "^25.0.3",
31
+ "@types/node": "^25.0.6",
32
32
  "typescript": "~5.9.3",
33
- "vite": "^7.3.0"
33
+ "vite": "^7.3.1"
34
34
  },
35
35
  "repository": {
36
36
  "type": "git",
Binary file