canvasengine 2.0.0-beta.24 → 2.0.0-beta.25
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/DebugRenderer-LPVGoCBJ.js +172 -0
- package/dist/DebugRenderer-LPVGoCBJ.js.map +1 -0
- package/dist/components/Canvas.d.ts +18 -0
- package/dist/components/Canvas.d.ts.map +1 -0
- package/dist/components/Container.d.ts +79 -0
- package/dist/components/Container.d.ts.map +1 -0
- package/dist/components/DOMContainer.d.ts +76 -0
- package/dist/components/DOMContainer.d.ts.map +1 -0
- package/dist/components/DOMElement.d.ts +44 -0
- package/dist/components/DOMElement.d.ts.map +1 -0
- package/dist/components/DisplayObject.d.ts +81 -0
- package/dist/components/DisplayObject.d.ts.map +1 -0
- package/dist/components/Graphic.d.ts +65 -0
- package/dist/components/Graphic.d.ts.map +1 -0
- package/dist/components/Mesh.d.ts +201 -0
- package/dist/components/Mesh.d.ts.map +1 -0
- package/dist/components/NineSliceSprite.d.ts +17 -0
- package/dist/components/NineSliceSprite.d.ts.map +1 -0
- package/dist/components/ParticleEmitter.d.ts +5 -0
- package/dist/components/ParticleEmitter.d.ts.map +1 -0
- package/dist/components/Scene.d.ts +2 -0
- package/dist/components/Scene.d.ts.map +1 -0
- package/dist/components/Sprite.d.ts +173 -0
- package/dist/components/Sprite.d.ts.map +1 -0
- package/dist/components/Text.d.ts +21 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/TilingSprite.d.ts +18 -0
- package/dist/components/TilingSprite.d.ts.map +1 -0
- package/dist/components/Video.d.ts +15 -0
- package/dist/components/Video.d.ts.map +1 -0
- package/dist/components/Viewport.d.ts +105 -0
- package/dist/components/Viewport.d.ts.map +1 -0
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/types/DisplayObject.d.ts +106 -0
- package/dist/components/types/DisplayObject.d.ts.map +1 -0
- package/dist/components/types/MouseEvent.d.ts +4 -0
- package/dist/components/types/MouseEvent.d.ts.map +1 -0
- package/dist/components/types/Spritesheet.d.ts +366 -0
- package/dist/components/types/Spritesheet.d.ts.map +1 -0
- package/dist/components/types/index.d.ts +5 -0
- package/dist/components/types/index.d.ts.map +1 -0
- package/dist/directives/Drag.d.ts +70 -0
- package/dist/directives/Drag.d.ts.map +1 -0
- package/dist/directives/KeyboardControls.d.ts +530 -0
- package/dist/directives/KeyboardControls.d.ts.map +1 -0
- package/dist/directives/Scheduler.d.ts +36 -0
- package/dist/directives/Scheduler.d.ts.map +1 -0
- package/dist/directives/Sound.d.ts +26 -0
- package/dist/directives/Sound.d.ts.map +1 -0
- package/dist/directives/Transition.d.ts +11 -0
- package/dist/directives/Transition.d.ts.map +1 -0
- package/dist/directives/ViewportCull.d.ts +12 -0
- package/dist/directives/ViewportCull.d.ts.map +1 -0
- package/dist/directives/ViewportFollow.d.ts +19 -0
- package/dist/directives/ViewportFollow.d.ts.map +1 -0
- package/dist/directives/index.d.ts +2 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/engine/animation.d.ts +59 -0
- package/dist/engine/animation.d.ts.map +1 -0
- package/dist/engine/bootstrap.d.ts +16 -0
- package/dist/engine/bootstrap.d.ts.map +1 -0
- package/dist/engine/directive.d.ts +14 -0
- package/dist/engine/directive.d.ts.map +1 -0
- package/dist/engine/reactive.d.ts +68 -0
- package/dist/engine/reactive.d.ts.map +1 -0
- package/dist/engine/signal.d.ts +72 -0
- package/dist/engine/signal.d.ts.map +1 -0
- package/dist/engine/trigger.d.ts +51 -0
- package/dist/engine/trigger.d.ts.map +1 -0
- package/dist/engine/utils.d.ts +90 -0
- package/dist/engine/utils.d.ts.map +1 -0
- package/dist/hooks/addContext.d.ts +2 -0
- package/dist/hooks/addContext.d.ts.map +1 -0
- package/dist/hooks/useProps.d.ts +42 -0
- package/dist/hooks/useProps.d.ts.map +1 -0
- package/dist/hooks/useRef.d.ts +5 -0
- package/dist/hooks/useRef.d.ts.map +1 -0
- package/dist/index-5TTorHyA.js +10931 -0
- package/dist/index-5TTorHyA.js.map +1 -0
- package/dist/index.d.ts +15 -1287
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +28 -1442
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +62 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/Ease.d.ts +17 -0
- package/dist/utils/Ease.d.ts.map +1 -0
- package/dist/utils/RadialGradient.d.ts +58 -0
- package/dist/utils/RadialGradient.d.ts.map +1 -0
- package/dist/utils/functions.d.ts +2 -0
- package/dist/utils/functions.d.ts.map +1 -0
- package/package.json +6 -4
- package/tsconfig.json +17 -0
- package/vite.config.ts +39 -0
- package/tsup.config.ts +0 -18
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/directive.ts","../src/engine/utils.ts","../src/directives/KeyboardControls.ts","../src/directives/Scheduler.ts","../src/hooks/useProps.ts","../src/engine/reactive.ts","../src/directives/ViewportFollow.ts","../src/directives/Sound.ts","../src/directives/Drag.ts","../src/hooks/addContext.ts","../src/directives/Transition.ts","../src/index.ts","../src/components/Canvas.ts","../src/components/DisplayObject.ts","../src/utils/functions.ts","../src/components/Container.ts","../src/components/Graphic.ts","../src/components/Mesh.ts","../src/engine/signal.ts","../src/components/Scene.ts","../src/components/ParticleEmitter.ts","../src/components/Sprite.ts","../src/engine/animation.ts","../src/components/Video.ts","../src/components/Text.ts","../src/engine/trigger.ts","../src/components/TilingSprite.ts","../src/components/Viewport.ts","../src/components/NineSliceSprite.ts","../src/components/DOMContainer.ts","../src/components/DOMElement.ts","../src/engine/bootstrap.ts","../src/utils/Ease.ts","../src/utils/RadialGradient.ts"],"sourcesContent":["import { Element } from \"./reactive\"\n\nexport const directives: { [key: string]: any } = {}\n\nexport abstract class Directive {\n abstract onDestroy(element: Element<any>);\n abstract onInit(element: Element<any>);\n abstract onMount(element: Element<any>);\n abstract onUpdate(props: any, element: Element<any>);\n}\n\nexport function registerDirective(name: string, directive: any) {\n directives[name] = directive\n}\n\nexport function applyDirective(element: Element, directiveName: string) {\n if (!directives[directiveName]) {\n return null\n }\n const directive = new directives[directiveName]()\n directive.onInit?.(element)\n return directive\n}","import { ObservablePoint } from \"pixi.js\"\nimport { Observable } from \"rxjs\"\n\n/**\n * Checks if code is running in a browser environment\n * @returns {boolean} True if running in browser, false otherwise\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined'\n}\n\n/**\n * Returns current high-resolution timestamp\n * @returns {number} Current time in milliseconds\n */\nexport function preciseNow(): number {\n return typeof performance !== 'undefined' ? performance.now() : Date.now()\n}\n\n/**\n * Converts frames per second to milliseconds\n * @param {number} fps - Frames per second\n * @returns {number} Milliseconds per frame\n */\nexport function fps2ms(fps: number): number {\n return 1000 / fps\n}\n\n/**\n * Checks if a value is a Promise\n * @param {any} value - Value to check\n * @returns {boolean} True if value is a Promise, false otherwise\n */\nexport function isPromise(value: any): boolean {\n return value && value instanceof Promise\n}\n\nexport function arrayEquals(a: any[], b: any[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const v = a[i];\n const bv = b[i];\n if (typeof v === 'object' && v !== null) {\n if (typeof bv !== 'object' || bv === null) return false;\n if (Array.isArray(v)) {\n if (!Array.isArray(bv) || !arrayEquals(v, bv)) return false;\n } else if (!objectEquals(v, bv)) {\n return false;\n }\n } else if (v !== bv) {\n return false;\n }\n }\n return true;\n}\n\nfunction objectEquals(a: object, b: object): boolean {\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n for (let key of keysA) {\n if (!b.hasOwnProperty(key)) return false;\n if (!deepEquals(a[key], b[key])) return false;\n }\n return true;\n}\n\nfunction deepEquals(a: any, b: any): boolean {\n if (a === b) return true;\n if (typeof a !== typeof b) return false;\n if (typeof a === 'object' && a !== null) {\n if (Array.isArray(a)) {\n return Array.isArray(b) && arrayEquals(a, b);\n }\n return objectEquals(a, b);\n }\n return false;\n}\n\n/**\n * Checks if a value is a function\n * @param {unknown} val - Value to check\n * @returns {boolean} True if value is a function, false otherwise\n */\nexport function isFunction(val: unknown): boolean {\n return {}.toString.call(val) === '[object Function]'\n}\n\n/**\n * Checks if a value is a plain object (not an instance of a class)\n * @param {unknown} val - Value to check\n * @returns {boolean} True if value is a plain object (not null, not array, not instance), false otherwise\n * @example\n * ```ts\n * isObject({}) // true\n * isObject(new Date()) // false\n * isObject([]) // false\n * isObject(null) // false\n * ```\n */\nexport function isObject(val: unknown): boolean {\n return typeof val == 'object' && val != null && !Array.isArray(val) && val.constructor === Object\n}\n\nexport function isObservable(val: unknown): boolean {\n return val instanceof Observable\n}\n\n/**\n * Sets a value in an object using a dot notation path\n * @param {Record<string, any>} obj - Target object\n * @param {string | string[]} path - Path to set value at (e.g., 'a.b.c' or ['a', 'b', 'c'])\n * @param {any} value - Value to set\n * @param {boolean} onlyPlainObject - If true, only creates plain objects in path\n * @returns {Record<string, any>} Modified object\n */\nexport function set(\n obj: Record<string, any>, \n path: string | string[], \n value: any, \n onlyPlainObject = false\n): Record<string, any> {\n if (Object(obj) !== obj) return obj;\n\n if (typeof path === 'string') {\n path = path.split('.');\n }\n\n let len = path.length;\n if (!len) return obj;\n\n let current = obj;\n for (let i = 0; i < len - 1; i++) {\n let segment = path[i];\n let nextSegment: number | string = path[i + 1];\n let isNextNumeric = !isNaN(Number(nextSegment)) && isFinite(Number(nextSegment));\n\n if (!current[segment] || typeof current[segment] !== 'object') {\n current[segment] = (isNextNumeric && !onlyPlainObject) ? [] : {};\n }\n\n current = current[segment];\n }\n\n current[path[len - 1]] = value;\n\n return obj;\n}\n\n/**\n * Gets a value from an object using a dot notation path\n * @param {Record<string, any>} obj - Source object\n * @param {string} path - Path to get value from (e.g., 'a.b.c')\n * @returns {any} Value at path or undefined if not found\n */\nexport function get(obj: Record<string, any>, path: string): any {\n const keys = path.split('.');\n let current = obj;\n\n for (let key of keys) {\n if (current[key] === undefined) {\n return undefined;\n }\n current = current[key];\n }\n\n return current;\n}\n\n/**\n * Logs a message to console\n * @param {any} text - Message to log\n */\nexport function log(text: any): void {\n console.log(text)\n}\n\n/**\n * Logs an error message to console\n * @param {any} text - Error message to log\n */\nexport function error(text: any): void {\n console.error(text)\n}\n\n/**\n * Sets the position of an ObservablePoint using various input formats\n * @param {ObservablePoint} observablePoint - The point to modify\n * @param {Object | number | [number, number]} point - New position value\n */\nexport function setObservablePoint(\n observablePoint: ObservablePoint, \n point: { x: number, y: number } | number | [number, number]\n): void {\n if (typeof point === 'number') {\n observablePoint.set(point);\n }\n else if (Array.isArray(point)) {\n observablePoint.set(point[0], point[1]);\n }\n else {\n observablePoint.set(point.x, point.y);\n }\n}\n\n/**\n * Calculates the Euclidean distance between two points\n * @param {number} x1 - X coordinate of first point\n * @param {number} y1 - Y coordinate of first point\n * @param {number} x2 - X coordinate of second point\n * @param {number} y2 - Y coordinate of second point\n * @returns {number} Distance between the points\n */\nexport function calculateDistance(\n x1: number, \n y1: number, \n x2: number, \n y2: number\n): number {\n const dx = x1 - x2;\n const dy = y1 - y2;\n return Math.sqrt(dx * dx + dy * dy);\n}","import { Directive, registerDirective } from \"../engine/directive\";\nimport { Element } from \"../engine/reactive\";\nimport { fps2ms } from \"../engine/utils\";\n\nexport enum Input {\n Break = 'break',\n Backspace = 'backspace',\n Tab = 'tab',\n Clear = 'clear',\n Enter = 'enter',\n Shift = 'shift',\n Ctrl = 'ctrl',\n Alt = 'alt',\n Pause = 'pause/break',\n CapsLock = 'caps lock',\n Escape = 'escape',\n Conversion = 'conversion',\n NonConversion = 'non-conversion',\n Space = 'space',\n PageUp = 'page up',\n PageDown = 'page down',\n End = 'end',\n Home = 'home',\n Left = 4,\n Up = 1,\n Right = 2,\n Down = 3,\n Select = 'select',\n Print = 'print',\n Execute = 'execute',\n PrintScreen = 'Print Screen',\n Insert = 'insert',\n Delete = 'delete',\n Zero = '0',\n One = '1',\n Two = '2',\n Three = '3',\n Four = '4',\n Five = '5',\n Six = '6',\n Seven = '7',\n Height = '8',\n Nine = '9',\n Equal = '=',\n Semicolon = 'semicolon (firefox), equals',\n LessThan = '<',\n Equals = 'equals (firefox)',\n Beta = 'ß',\n At = '@',\n A = 'a',\n B = 'b',\n C = 'c',\n D = 'd',\n E = 'e',\n F = 'f',\n G = 'g',\n H = 'h',\n I = 'i',\n J = 'j',\n K = 'k',\n L = 'l',\n M = 'm',\n N = 'n',\n O = 'o',\n P = 'p',\n Q = 'q',\n R = 'r',\n S = 's',\n T = 't',\n U = 'u',\n V = 'v',\n W = 'w',\n X = 'x',\n Y = 'y',\n Z = 'z',\n SearchKey = 'Windows Key / Left ⌘ / Chromebook Search key',\n NumPad0 = 'numpad 0',\n NumPad1 = 'numpad 1',\n NumPad2 = 'numpad 2',\n NumPad3 = 'numpad 3',\n NumPad4 = 'numpad 4',\n NumPad5 = 'numpad 5',\n NumPad6 = 'numpad 6',\n NumPad7 = 'numpad 7',\n NumPad8 = 'numpad 8',\n NumPad9 = 'numpad 9',\n Multiply = 'multiply',\n Add = 'add',\n Subtract = 'subtract',\n DecimalPoint = 'decimal point',\n Divide = 'divide',\n F1 = 'f1',\n F2 = 'f2',\n F3 = 'f3',\n F4 = 'f4',\n F5 = 'f5',\n F6 = 'f6',\n F7 = 'f7',\n F8 = 'f8',\n F9 = 'f9',\n F10 = 'f10',\n F11 = 'f11',\n F12 = 'f12',\n F13 = 'f13',\n F14 = 'f14',\n F15 = 'f15',\n F16 = 'f16',\n F17 = 'f17',\n F18 = 'f18',\n F19 = 'f19',\n F20 = 'f20',\n F21 = 'f21',\n F22 = 'f22',\n F23 = 'f23',\n F24 = 'f24',\n NumLock = 'num lock',\n ScrollLock = 'scroll lock',\n CircumflexAccent = '^',\n ExclamationMark = '!',\n Hash = '#',\n Dollar = '$',\n AccentU = 'ù',\n PageBackward = 'page backward',\n PageForWard = 'page forward',\n Star = '*',\n DecreaseVolume = 'decrease volume level',\n IncreaseVolume = 'increase volume level',\n Next = 'next',\n Previous = 'previous',\n Stop = 'stop',\n PlayPause = 'play/pause',\n Email = 'e-mail',\n SemiColon = 'semi-colon / ñ',\n EqualSign = 'equal sign',\n Comma = 'comma',\n Dash = 'dash',\n FowardSlach = 'forward slash / ç',\n GraveAccent = 'grave accent / ñ / æ',\n OpenBracket = 'open bracket',\n BackSlach = 'back slash',\n CloseBracket = 'close bracket / å',\n SingleQuote = 'single quote / ø',\n BackQuote = '`',\n Altgr = 'altgr'\n}\n\nexport interface ControlOptions {\n repeat?: boolean;\n bind: string | string[];\n keyUp?: Function;\n keyDown?: Function;\n delay?: number | {\n duration: number;\n otherControls?: (string)[];\n };\n}\nexport interface Controls {\n [controlName: string]: ControlOptions;\n}\n\n// keyboard handling\nconst keyCodeTable = {\n 3: 'break',\n 8: 'backspace', // backspace / delete\n 9: 'tab',\n 12: 'clear',\n 13: 'enter',\n 16: 'shift',\n 17: 'ctrl',\n 18: 'alt',\n 19: 'pause/break',\n 20: 'caps lock',\n 27: 'escape',\n 28: 'conversion',\n 29: 'non-conversion',\n 32: 'space',\n 33: 'page up',\n 34: 'page down',\n 35: 'end',\n 36: 'home',\n 37: 'left',\n 38: 'up',\n 39: 'right',\n 40: 'down',\n 41: 'select',\n 42: 'print',\n 43: 'execute',\n 44: 'Print Screen',\n 45: 'insert',\n 46: 'delete',\n 48: 'n0',\n 49: 'n1',\n 50: 'n2',\n 51: 'n3',\n 52: 'n4',\n 53: 'n5',\n 54: 'n6',\n 55: 'n7',\n 56: 'n8',\n 57: 'n9',\n 58: ':',\n 59: 'semicolon (firefox), equals',\n 60: '<',\n 61: 'equals (firefox)',\n 63: 'ß',\n 64: '@',\n 65: 'a',\n 66: 'b',\n 67: 'c',\n 68: 'd',\n 69: 'e',\n 70: 'f',\n 71: 'g',\n 72: 'h',\n 73: 'i',\n 74: 'j',\n 75: 'k',\n 76: 'l',\n 77: 'm',\n 78: 'n',\n 79: 'o',\n 80: 'p',\n 81: 'q',\n 82: 'r',\n 83: 's',\n 84: 't',\n 85: 'u',\n 86: 'v',\n 87: 'w',\n 88: 'x',\n 89: 'y',\n 90: 'z',\n 91: 'Windows Key / Left ⌘ / Chromebook Search key',\n 92: 'right window key',\n 93: 'Windows Menu / Right ⌘',\n 96: 'numpad 0',\n 97: 'numpad 1',\n 98: 'numpad 2',\n 99: 'numpad 3',\n 100: 'numpad 4',\n 101: 'numpad 5',\n 102: 'numpad 6',\n 103: 'numpad 7',\n 104: 'numpad 8',\n 105: 'numpad 9',\n 106: 'multiply',\n 107: 'add',\n 108: 'numpad period (firefox)',\n 109: 'subtract',\n 110: 'decimal point',\n 111: 'divide',\n 112: 'f1',\n 113: 'f2',\n 114: 'f3',\n 115: 'f4',\n 116: 'f5',\n 117: 'f6',\n 118: 'f7',\n 119: 'f8',\n 120: 'f9',\n 121: 'f10',\n 122: 'f11',\n 123: 'f12',\n 124: 'f13',\n 125: 'f14',\n 126: 'f15',\n 127: 'f16',\n 128: 'f17',\n 129: 'f18',\n 130: 'f19',\n 131: 'f20',\n 132: 'f21',\n 133: 'f22',\n 134: 'f23',\n 135: 'f24',\n 144: 'num lock',\n 145: 'scroll lock',\n 160: '^',\n 161: '!',\n 163: '#',\n 164: '$',\n 165: 'ù',\n 166: 'page backward',\n 167: 'page forward',\n 169: 'closing paren (AZERTY)',\n 170: '*',\n 171: '~ + * key',\n 173: 'minus (firefox), mute/unmute',\n 174: 'decrease volume level',\n 175: 'increase volume level',\n 176: 'next',\n 177: 'previous',\n 178: 'stop',\n 179: 'play/pause',\n 180: 'e-mail',\n 181: 'mute/unmute (firefox)',\n 182: 'decrease volume level (firefox)',\n 183: 'increase volume level (firefox)',\n 186: 'semi-colon / ñ',\n 187: 'equal sign',\n 188: 'comma',\n 189: 'dash',\n 190: 'period',\n 191: 'forward slash / ç',\n 192: 'grave accent / ñ / æ',\n 193: '?, / or °',\n 194: 'numpad period (chrome)',\n 219: 'open bracket',\n 220: 'back slash',\n 221: 'close bracket / å',\n 222: 'single quote / ø',\n 223: '`',\n 224: 'left or right ⌘ key (firefox)',\n 225: 'altgr',\n 226: '< /git >',\n 230: 'GNOME Compose Key',\n 231: 'ç',\n 233: 'XF86Forward',\n 234: 'XF86Back',\n 240: 'alphanumeric',\n 242: 'hiragana/katakana',\n 243: 'half-width/full-width',\n 244: 'kanji',\n 255: 'toggle touchpad'\n};\n\nconst inverse = (obj) => {\n const newObj = {}\n for (let key in obj) {\n const val = obj[key]\n newObj[val] = key\n }\n return newObj\n}\n\nconst inverseKeyCodeTable = inverse(keyCodeTable)\n\ntype BoundKey = { actionName: string, options: ControlOptions, parameters?: any }\n\nexport class KeyboardControls extends Directive {\n private keyState: {\n [keyName: string]: {\n isDown: boolean,\n count: number\n } | null\n } = {}\n private boundKeys: {\n [keyName: string]: BoundKey\n } = {}\n private stop: boolean = false\n private lastKeyPressed: number | null = null\n private _controlsOptions: Controls = {}\n private interval: any\n // TODO: This should be dynamic\n private serverFps: number = 60\n private directionState: {\n up: boolean,\n down: boolean,\n left: boolean,\n right: boolean\n } = {\n up: false,\n down: false,\n left: false,\n right: false\n };\n\n onInit(element: Element) {\n const value = element.props.controls.value ?? element.props.controls\n if (!value) return\n this.setupListeners();\n this.setInputs(value)\n // The processing is outside the rendering loop because if the FPS are lower (or higher) then the sending to the server would be slower or faster. Here it is constant\n this.interval = setInterval(() => {\n this.preStep()\n }, fps2ms(this.serverFps ?? 60))\n }\n\n onMount(element: Element) {}\n\n onUpdate(props) {\n this.setInputs(props)\n }\n\n onDestroy() {\n clearInterval(this.interval)\n document.removeEventListener('keydown', (e) => { this.onKeyChange(e, true); });\n document.removeEventListener('keyup', (e) => { this.onKeyChange(e, false); });\n }\n\n /** @internal */\n preStep() {\n if (this.stop) return;\n\n const direction = this.getDirection();\n if (direction !== 'none') {\n // Trigger only the composite direction\n const directionControl = this.boundKeys[direction];\n if (directionControl) {\n const { keyDown } = directionControl.options;\n if (keyDown ) {\n this.applyInput(direction);\n }\n }\n } else {\n // Process other controls as before\n const boundKeys = Object.keys(this.boundKeys);\n for (let keyName of boundKeys) {\n this.applyInput(keyName);\n }\n }\n }\n\n private applyInput(keyName: string) {\n const keyState = this.keyState[keyName];\n if (!keyState) return;\n const { isDown, count } = keyState;\n if (isDown) {\n const { repeat, keyDown } = this.boundKeys[keyName].options;\n if ((repeat || count == 0)) {\n let parameters = this.boundKeys[keyName].parameters;\n if (typeof parameters === \"function\") {\n parameters = parameters();\n }\n if (keyDown) {\n keyDown(this.boundKeys[keyName]);\n }\n this.keyState[keyName]!.count++;\n }\n }\n }\n\n private setupListeners() {\n document.addEventListener('keydown', (e) => { this.onKeyChange(e, true); });\n document.addEventListener('keyup', (e) => { this.onKeyChange(e, false); });\n }\n\n private bindKey(keys: Input | Input[], actionName: string, options: ControlOptions, parameters?: object) {\n if (!Array.isArray(keys)) keys = [keys] as Input[]\n const keyOptions = Object.assign({\n repeat: false\n }, options);\n (keys as Input[]).forEach(keyName => {\n this.boundKeys[keyName] = { actionName, options: keyOptions, parameters }\n })\n }\n\n private applyKeyDown(name: string) {\n const code = inverseKeyCodeTable[name]\n const e: any = new Event('keydown')\n e.keyCode = code\n this.onKeyChange(e, true)\n }\n\n private applyKeyUp(name: string) {\n const code = inverseKeyCodeTable[name]\n const e: any = new Event('keyup')\n e.keyCode = code\n this.onKeyChange(e, false)\n }\n\n private applyKeyPress(name: string): Promise<void> {\n return new Promise((resolve: any) => {\n this.applyKeyDown(name)\n setTimeout(() => {\n this.applyKeyUp(name)\n resolve()\n }, 200)\n })\n }\n\n private onKeyChange(e: KeyboardEvent, isDown: boolean) {\n e = (e || window.event) as KeyboardEvent;\n\n const keyName: string = keyCodeTable[e.keyCode];\n\n if (keyName && this.boundKeys[keyName]) {\n if (this.keyState[keyName] == null) {\n this.keyState[keyName] = {\n count: 0,\n isDown: true\n };\n }\n this.keyState[keyName]!.isDown = isDown;\n\n // key up, reset press count\n if (!isDown) {\n this.keyState[keyName]!.count = 0\n const { keyUp } = this.boundKeys[keyName].options\n if (keyUp) {\n keyUp(this.boundKeys[keyName]);\n }\n }\n\n // keep reference to the last key pressed to avoid duplicates\n this.lastKeyPressed = isDown ? e.keyCode : null;\n }\n\n if (keyName) {\n this.updateDirectionState(keyName, isDown);\n }\n }\n\n private updateDirectionState(keyName: string, isDown: boolean) {\n switch (keyName) {\n case 'up':\n this.directionState.up = isDown;\n break;\n case 'down':\n this.directionState.down = isDown;\n break;\n case 'left':\n this.directionState.left = isDown;\n break;\n case 'right':\n this.directionState.right = isDown;\n break;\n }\n }\n\n private getDirection(): string {\n const { up, down, left, right } = this.directionState;\n\n if (up && left) return 'up_left';\n if (up && right) return 'up_right';\n if (down && left) return 'down_left';\n if (down && right) return 'down_right';\n if (up) return 'up';\n if (down) return 'down';\n if (left) return 'left';\n if (right) return 'right';\n\n return 'none';\n }\n\n /**\n * From the name of the entry, we retrieve the control information\n * \n * ```ts \n * import { Input, inject, KeyboardControls } from '@rpgjs/client'\n * \n * const controls = inject(KeyboardControls)\n * controls.getControl(Input.Enter)\n\n * if (control) {\n * console.log(control.actionName) // action\n * }\n * ```\n * @title Get Control\n * @method getControl(inputName)\n * @param {string} inputName\n * @returns { { actionName: string, options: any } | undefined }\n * @memberof KeyboardControls\n */\n getControl(inputName: string): BoundKey | undefined {\n return this.boundKeys[inputName]\n }\n\n /**\n * Returns all controls\n * \n * @method getControls()\n * @since 4.2.0\n * @returns { { [key: string]: BoundKey } }\n * @memberof KeyboardControls\n */\n getControls(): { [key: string]: BoundKey } {\n return this.boundKeys\n }\n\n /**\n * Triggers an input according to the name of the control\n * \n * ```ts \n * import { Control, inject, KeyboardControls } from '@rpgjs/client'\n * \n * const controls = inject(KeyboardControls)\n * controls.applyControl(Control.Action)\n * ```\n * \n * You can put a second parameter or indicate on whether the key is pressed or released\n * \n * ```ts \n * import { Control, inject, KeyboardControls } from '@rpgjs/client'\n * \n * const controls = inject(KeyboardControls)\n * controls.applyControl(Control.Up, true) // keydown\n * controls.applyControl(Control.Up, false) // keyup\n * ```\n * @title Apply Control\n * @method applyControl(controlName,isDown)\n * @param {string} controlName\n * @param {boolean} [isDown]\n * @returns {Promise<void>}\n * @memberof KeyboardControls\n */\n async applyControl(controlName: string | number, isDown?: boolean | undefined): Promise<void> {\n const control = this._controlsOptions[controlName]\n if (control) {\n const input = Array.isArray(control.bind) ? control.bind[0] : control.bind\n if (isDown === undefined) {\n await this.applyKeyPress(input as string)\n }\n else if (isDown) {\n this.applyKeyDown(input as string)\n }\n else {\n this.applyKeyUp(input as string)\n }\n }\n }\n\n /**\n * Stop listening to the inputs. Pressing a key won't do anything\n * \n * @title Stop Inputs\n * @method stopInputs()\n * @returns {void}\n * @memberof KeyboardControls\n */\n stopInputs() {\n this.stop = true\n }\n\n /**\n * Listen to the inputs again\n * \n * @title Listen Inputs\n * @method listenInputs()\n * @returns {void}\n * @memberof KeyboardControls\n */\n listenInputs() {\n this.stop = false\n this.keyState = {}\n }\n\n /**\n * Assign custom inputs to the scene\n * \n * The object is the following:\n * \n * * the key of the object is the name of the control. Either it is existing controls (Up, Dow, Left, Right, Action, Back) or customized controls\n * * The value is an object representing control information:\n * * repeat {boolean} The key can be held down to repeat the action. (false by default)\n * * bind {string | string[]} To which key is linked the control\n * * method {Function} Function to be triggered. If you do not set this property, the name of the control is sent directly to the server.\n * * delay {object|number} (since v3.2.0) Indicates how long (in milliseconds) the player can press the key again to perform the action\n * * delay.duration\n * * delay.otherControls {string | string[]} Indicates the other controls that will also have the delay at the same time\n * \n * ```ts \n * import { Control, Input, inject, KeyboardControls } from '@rpgjs/client'\n * \n * const controls = inject(KeyboardControls)\n * controls.setInputs({\n [Control.Up]: {\n repeat: true,\n bind: Input.Up\n },\n [Control.Down]: {\n repeat: true,\n bind: Input.Down\n },\n [Control.Right]: {\n repeat: true,\n bind: Input.Right\n },\n [Control.Left]: {\n repeat: true,\n bind: Input.Left\n },\n [Control.Action]: {\n bind: [Input.Space, Input.Enter]\n },\n [Control.Back]: {\n bind: Input.Escape\n },\n\n // The myscustom1 control is sent to the server when the A key is pressed.\n mycustom1: {\n bind: Input.A\n },\n\n // the myAction method is executed when the B key is pressed\n mycustom2: {\n bind: Input.B,\n method({ actionName }) {\n console.log('cool', actionName)\n }\n },\n\n // The player can redo the action after 400ms\n mycustom3: {\n bind: Input.C,\n delay: 400 // ms\n },\n\n // The player can redo the action (mycustom4) and the directions after 400ms\n mycustom4: {\n bind: Input.C,\n delay: {\n duration: 400,\n otherControls: [Control.Up, Control.Down, Control.Left, Control.Right]\n }\n }\n })\n * \n * ```\n * @enum {string} Control \n * \n * Control.Up | up\n * Control.Down | down\n * Control.Left | left\n * Control.Right | right\n * Control.Action | action\n * Control.Back | back\n * \n * @enum {string} Mouse Event \n * \n * click | Click\n * dblclick | Double Click\n * mousedown | Mouse Down\n * mouseup | Mouse Up\n * mouseover | Mouse Over\n * mousemove | Mouse Move\n * mouseout | Mouse Out\n * contextmenu | Context Menu\n * \n * \n * @enum {string} Input \n * \n * break | Pause\n * backspace | Backspace / Delete\n * tab | Tab\n * clear | Clear\n * enter | Enter\n * shift | Shift\n * ctrl | Control\n * alt | Alt\n * pause/break | Pause / Break\n * caps lock | Caps Lock\n * escape | Escape\n * conversion | Conversion\n * non-conversion | Non-conversion\n * space | Space\n * page up | Page Up\n * page down | Page Down\n * end | End\n * home | Home\n * left | Left Arrow\n * up | Up Arrow\n * right | Right Arrow\n * down | Down Arrow\n * select | Select\n * print | Print\n * execute | Execute\n * Print Screen | Print Screen\n * insert | Insert\n * delete | Delete\n * n0 | 0\n * n1 | 1\n * n2 | 2\n * n3 | 3\n * n4 | 4\n * n5 | 5\n * n6 | 6\n * n7 | 7\n * n8 | 8\n * n9 | 9\n * : | Colon\n * semicolon (firefox), equals | Semicolon (Firefox), Equals\n * < | Less Than\n * equals (firefox) | Equals (Firefox)\n * ß | Eszett\n * @ | At\n * a | A\n * b | B\n * c | C\n * d | D\n * e | E\n * f | F\n * g | G\n * h | H\n * i | I\n * j | J\n * k | K\n * l | L\n * m | M\n * n | N\n * o | O\n * p | P\n * q | Q\n * r | R\n * s | S\n * t | T\n * u | U\n * v | V\n * w | W\n * x | X\n * y | Y\n * z | Z\n * Windows Key / Left ⌘ / Chromebook Search key | Windows Key / Left Command ⌘ / Chromebook Search Key\n * right window key | Right Windows Key\n * Windows Menu / Right ⌘ | Windows Menu / Right Command ⌘\n * numpad 0 | Numpad 0\n * numpad 1 | Numpad 1\n * numpad 2 | Numpad 2\n * numpad 3 | Numpad 3\n * numpad 4 | Numpad 4\n * numpad 5 | Numpad 5\n * numpad 6 | Numpad 6\n * numpad 7 | Numpad 7\n * numpad 8 | Numpad 8\n * numpad 9 | Numpad 9\n * multiply | Multiply\n * add | Add\n * numpad period (firefox) | Numpad Period (Firefox)\n * subtract | Subtract\n * decimal point | Decimal Point\n * divide | Divide\n * f1 | F1\n * f2 | F2\n * f3 | F3\n * f4 | F4\n * f5 | F5\n * f6 | F6\n * f7 | F7\n * f8 | F8\n * f9 | F9\n * f10 | F10\n * f11 | F11\n * f12 | F12\n * f13 | F13\n * f14 | F14\n * f15 | F15\n * f16 | F16\n * f17 | F17\n * f18 | F18\n * f19 | F19\n * f20 | F20\n * f21 | F21\n * f22 | F22\n * f23 | F23\n * f24 | F24\n * num lock | Num Lock\n * scroll lock | Scroll Lock\n * ^ | Caret\n * ! | Exclamation Point\n * # | Hash\n * $ | Dollar Sign\n * ù | Grave Accent U\n * page backward | Page Backward\n * page forward | Page Forward\n * closing paren (AZERTY) | Closing Parenthesis (AZERTY)\n * * | Asterisk\n * ~ + * key | Tilde + Asterisk Key\n * minus (firefox), mute/unmute | Minus (Firefox), Mute/Unmute\n * decrease volume level | Decrease Volume Level\n * increase volume level | Increase Volume Level\n * next | Next\n * previous | Previous\n * stop | Stop\n * play/pause | Play/Pause\n * e-mail | Email\n * mute/unmute (firefox) | Mute/Unmute (Firefox)\n * decrease volume level (firefox) | Decrease Volume Level (Firefox)\n * increase volume level (firefox) | Increase Volume Level (Firefox)\n * semi-colon / ñ | Semicolon / ñ\n * equal sign | Equal Sign\n * comma | Comma\n * dash | Dash\n * period | Period\n * forward slash / ç | Forward Slash / ç\n * grave accent / ñ / æ | Grave Accent / ñ / æ\n * ?, / or ° | ?, / or °\n * numpad period (chrome) | Numpad Period (Chrome)\n * open bracket | Open Bracket\n * back slash | Backslash\n * close bracket / å | Close Bracket / å\n * single quote / ø | Single Quote / ø\n * \\` | Backtick\n * left or right ⌘ key (firefox) | Left or Right Command Key (Firefox)\n * altgr | AltGr\n * < /git > | < /git >\n * GNOME Compose Key | GNOME Compose Key\n * ç | ç\n * XF86Forward | XF86Forward\n * XF86Back | XF86Back\n * alphanumeric | Alphanumeric\n * hiragana/katakana | Hiragana/Katakana\n * half-width/full-width | Half-Width/Full-Width\n * kanji | Kanji\n * toggle touchpad | Toggle Touchpad\n * \n * @title Set Inputs\n * @method setInputs(inputs)\n * @param {object} inputs\n * @memberof KeyboardControls\n */\n setInputs(inputs: Controls) {\n if (!inputs) return\n this.boundKeys = {}\n let inputsTransformed: any = {}\n for (let control in inputs) {\n const option = inputs[control]\n const { bind } = option\n let inputsKey: any = bind\n if (!Array.isArray(inputsKey)) {\n inputsKey = [bind]\n }\n for (let input of inputsKey) {\n this.bindKey(input, control, option)\n }\n }\n this._controlsOptions = inputs\n }\n\n get options(): Controls {\n return this._controlsOptions\n }\n}\n\nregisterDirective('controls', KeyboardControls)","import { WritableSignal } from '@signe/reactive';\nimport { Directive, registerDirective } from '../engine/directive';\nimport { Element } from '../engine/reactive';\nimport * as Utils from '../engine/utils';\n\nexport interface Tick {\n timestamp: number\n deltaTime: number\n frame: number\n deltaRatio: number\n}\n\nexport class Scheduler extends Directive {\n private maxFps?: number\n private fps: number = 60\n private deltaTime: number = 0\n public frame: number = 0\n private timestamp: number = 0\n private requestedDelay: number = 0\n private lastTimestamp: number = 0\n private _stop: boolean = false\n private tick: WritableSignal<Tick | null>\n \n onInit(element: Element) { \n this.tick = element.propObservables?.tick as any\n }\n\n onDestroy() { }\n onMount(element: Element) { }\n onUpdate(props: any) { }\n\n nextTick(timestamp: number) {\n this.lastTimestamp = this.lastTimestamp || this.timestamp // first\n this.deltaTime = Utils.preciseNow() - this.timestamp\n this.timestamp = timestamp\n this.tick.set({\n timestamp: this.timestamp,\n deltaTime: this.deltaTime,\n frame: this.frame,\n deltaRatio: ~~this.deltaTime / ~~Utils.fps2ms(this.fps)\n })\n this.lastTimestamp = this.timestamp\n this.frame++\n }\n /**\n * start the schedule\n * @return {Scheduler} returns this scheduler instance\n */\n start(options: {\n maxFps?: number\n fps?: number,\n delay?: number\n } = {}) {\n if (options.maxFps) this.maxFps = options.maxFps\n if (options.fps) this.fps = options.fps\n if (options.delay) this.requestedDelay = options.delay\n const requestAnimationFrame = (fn: (timestamp: number) => void) => {\n if (Utils.isBrowser()) {\n window.requestAnimationFrame(fn.bind(this))\n }\n else {\n setTimeout(() => {\n this.requestedDelay = 0\n fn(Utils.preciseNow())\n }, Utils.fps2ms(this.fps) + this.requestedDelay)\n }\n }\n\n if (!this.maxFps) {\n const loop = (timestamp: number) => {\n requestAnimationFrame(loop)\n this.nextTick(timestamp)\n }\n requestAnimationFrame(loop)\n }\n else {\n const msInterval = Utils.fps2ms(this.maxFps)\n let now = Utils.preciseNow()\n let then = Utils.preciseNow()\n const loop = (timestamp: number) => {\n if (this._stop) return\n requestAnimationFrame(loop)\n now = Utils.preciseNow()\n const elapsed = now - then\n if (elapsed > msInterval) {\n then = now - (elapsed % msInterval)\n this.nextTick(timestamp)\n }\n }\n requestAnimationFrame(loop)\n }\n\n return this;\n }\n\n stop() {\n this._stop = true\n }\n}\n\nregisterDirective('tick', Scheduler)","import { isSignal, signal } from \"@signe/reactive\"\nimport { isPrimitive } from \"../engine/reactive\"\n\n/**\n * Converts props into reactive signals if they are primitive values.\n * \n * @param {object} props - The properties to convert.\n * @param {object} [defaults={}] - Default values for properties.\n * @returns {object} An object with reactive signals.\n * \n * @example\n * const props = useProps({ count: 0, name: \"John\" });\n * console.log(props.count()); // 0\n * props.count.set(1);\n * console.log(props.count()); // 1\n */\nexport const useProps = (props, defaults = {}): any => {\n if (isSignal(props)) {\n return props()\n }\n const obj = {}\n for (let key in props) {\n const value = props[key]\n obj[key] = isPrimitive(value) ? signal(value) : value\n }\n for (let key in defaults) {\n if (!(key in obj)) {\n obj[key] = isPrimitive(defaults[key]) ? signal(defaults[key]) : defaults[key]\n }\n }\n return obj\n}\n\ntype PropType = NumberConstructor | StringConstructor | BooleanConstructor | \n FunctionConstructor | ObjectConstructor | ArrayConstructor | \n null | (new (...args: any[]) => any);\n\ninterface PropConfig {\n type?: PropType | PropType[];\n required?: boolean;\n default?: any | ((props: any) => any);\n validator?: (value: any, props: any) => boolean;\n}\n\ntype PropSchema = {\n [key: string]: PropType | PropType[] | PropConfig;\n}\n\n/**\n * Validates and defines properties based on a schema.\n * \n * @param {object} props - The properties to validate.\n * @returns {function} A function that takes a schema and returns validated properties.\n * \n * @example\n * const schema = {\n * age: { type: Number, required: true },\n * name: { type: String, default: \"Anonymous\" }\n * };\n * const validatedProps = useDefineProps({ age: 25 })(schema);\n * console.log(validatedProps.age()); // 25\n * console.log(validatedProps.name()); // \"Anonymous\"\n */\nexport const useDefineProps = (props: any) => {\n return (schema?: PropSchema) => {\n const rawProps = isSignal(props) ? props() : props\n const validatedProps: { [key: string]: any } = {}\n\n for (const key in schema) {\n const propConfig = schema[key]\n const value = rawProps[key]\n let validatedValue: any\n\n // Handle simple type definition\n if (typeof propConfig === 'function') {\n validateType(key, value, [propConfig])\n validatedValue = value\n }\n // Handle array of types\n else if (Array.isArray(propConfig)) {\n validateType(key, value, propConfig)\n validatedValue = value\n }\n // Handle detailed configuration object\n else if (propConfig && typeof propConfig === 'object') {\n // Check required prop\n if (propConfig.required && value === undefined) {\n throw new Error(`Missing required prop: ${key}`)\n }\n \n // Validate type if specified\n if (propConfig.type) {\n const types = Array.isArray(propConfig.type) ? propConfig.type : [propConfig.type]\n validateType(key, value, types)\n }\n \n // Run custom validator if provided\n if (propConfig.validator && !propConfig.validator(value, rawProps)) {\n throw new Error(`Invalid prop: custom validation failed for prop \"${key}\"`)\n }\n \n // Set default value if value is undefined\n if (value === undefined && 'default' in propConfig) {\n validatedValue = typeof propConfig.default === 'function' \n ? propConfig.default(rawProps)\n : propConfig.default\n } else {\n validatedValue = value\n }\n }\n\n validatedProps[key] = isSignal(validatedValue) \n ? validatedValue \n : signal(validatedValue)\n }\n \n return {\n ...useProps(rawProps),\n ...validatedProps\n }\n }\n}\n\n/**\n * Validates the type of a property.\n * \n * @param {string} key - The property key.\n * @param {any} value - The property value.\n * @param {any[]} types - The expected types.\n * @throws Will throw an error if the type check fails.\n */\nfunction validateType(key: string, value: any, types: any[]) {\n if (value === undefined || value === null) return\n \n // Si c'est un signal, on vérifie la valeur du signal\n const valueToCheck = isSignal(value) ? value() : value\n \n const valid = types.some(type => {\n if (type === Number) return typeof valueToCheck === 'number'\n if (type === String) return typeof valueToCheck === 'string'\n if (type === Boolean) return typeof valueToCheck === 'boolean'\n if (type === Function) return typeof valueToCheck === 'function'\n if (type === Object) return typeof valueToCheck === 'object'\n if (type === Array) return Array.isArray(valueToCheck)\n if (type === null) return valueToCheck === null\n return valueToCheck instanceof type\n })\n \n if (!valid) {\n throw new Error(\n `Invalid prop: type check failed for prop \"${key}\". ` +\n `Expected ${types.map(t => t.name).join(' or ')}`\n )\n }\n}","import { ArrayChange, ObjectChange, Signal, WritableArraySignal, WritableObjectSignal, isComputed, isSignal, signal } from \"@signe/reactive\";\nimport {\n Observable,\n Subject,\n Subscription,\n defer,\n from,\n map,\n of,\n share,\n switchMap,\n} from \"rxjs\";\nimport { ComponentInstance } from \"../components/DisplayObject\";\nimport { Directive, applyDirective } from \"./directive\";\nimport { isObject, isPromise, set } from \"./utils\";\n\nexport interface Props {\n [key: string]: any;\n}\n\ntype NestedSignalObjects = {\n [Key in string]: NestedSignalObjects | Signal<any>;\n};\n\nexport interface Element<T = ComponentInstance> {\n tag: string;\n props: Props;\n componentInstance: T;\n propSubscriptions: Subscription[];\n effectSubscriptions: Subscription[];\n effectMounts: (() => void)[];\n effectUnmounts: ((element?: Element) => void)[];\n propObservables: NestedSignalObjects | undefined;\n parent: Element | null;\n context?: {\n [key: string]: any;\n };\n directives: {\n [key: string]: Directive;\n };\n destroy: () => void;\n allElements: Subject<void>;\n}\n\ntype FlowResult = {\n elements: Element[];\n prev?: Element;\n fullElements?: Element[];\n};\n\ntype FlowObservable = Observable<FlowResult>;\n\nconst components: { [key: string]: any } = {};\n\nexport const isElement = (value: any): value is Element => {\n return (\n value &&\n typeof value === \"object\" &&\n \"tag\" in value &&\n \"props\" in value &&\n \"componentInstance\" in value\n );\n};\n\nexport const isPrimitive = (value) => {\n return (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\" ||\n value === null ||\n value === undefined\n );\n};\n\nexport function registerComponent(name, component) {\n components[name] = component;\n}\n\nfunction destroyElement(element: Element | Element[]) {\n if (Array.isArray(element)) {\n element.forEach((e) => destroyElement(e));\n return;\n }\n if (!element) {\n return;\n }\n if (element.props?.children) {\n for (let child of element.props.children) {\n destroyElement(child)\n }\n }\n for (let name in element.directives) {\n element.directives[name].onDestroy?.(element);\n }\n if (element.componentInstance && element.componentInstance.onDestroy) {\n element.componentInstance.onDestroy(element.parent as any, () => {\n element.propSubscriptions?.forEach((sub) => sub.unsubscribe());\n element.effectSubscriptions?.forEach((sub) => sub.unsubscribe());\n element.effectUnmounts?.forEach((fn) => fn?.());\n });\n } else {\n // If componentInstance is undefined or doesn't have onDestroy, still clean up subscriptions\n element.propSubscriptions?.forEach((sub) => sub.unsubscribe());\n element.effectSubscriptions?.forEach((sub) => sub.unsubscribe());\n element.effectUnmounts?.forEach((fn) => fn?.());\n }\n}\n\n/**\n * Creates a virtual element or a representation thereof, with properties that can be dynamically updated based on BehaviorSubjects.\n *\n * @param {string} tag - The tag name of the element to create.\n * @param {Object} props - An object containing properties for the element. Each property can either be a direct value\n * or an array where the first element is a function that returns a value based on input parameters,\n * and the second element is an array of BehaviorSubjects. The property is updated dynamically\n * using the combineLatest RxJS operator to wait for all BehaviorSubjects to emit.\n * @returns {Object} An object representing the created element, including tag name and dynamic properties.\n */\nexport function createComponent(tag: string, props?: Props): Element {\n if (!components[tag]) {\n throw new Error(`Component ${tag} is not registered`);\n }\n const instance = new components[tag]();\n const element: Element = {\n tag,\n props: {},\n componentInstance: instance,\n propSubscriptions: [],\n propObservables: props,\n parent: null,\n directives: {},\n effectUnmounts: [],\n effectSubscriptions: [],\n effectMounts: [],\n destroy() {\n destroyElement(this);\n },\n allElements: new Subject(),\n };\n\n // Iterate over each property in the props object\n if (props) {\n const recursiveProps = (props, path = \"\") => {\n const _set = (path, key, value) => {\n if (path == \"\") {\n element.props[key] = value;\n return;\n }\n set(element.props, path + \".\" + key, value);\n };\n\n Object.entries(props).forEach(([key, value]: [string, unknown]) => {\n if (isSignal(value)) {\n const _value = value as Signal<any>;\n if (\"dependencies\" in _value && _value.dependencies.size == 0) {\n _set(path, key, _value());\n return;\n }\n element.propSubscriptions.push(\n _value.observable.subscribe((value) => {\n _set(path, key, value);\n if (element.directives[key]) {\n element.directives[key].onUpdate?.(value, element);\n }\n if (key == \"tick\") {\n return\n }\n instance.onUpdate?.(\n path == \"\"\n ? {\n [key]: value,\n }\n : set({}, path + \".\" + key, value)\n );\n })\n );\n } else {\n if (isObject(value) && key != \"context\" && !isElement(value)) {\n recursiveProps(value, (path ? path + \".\" : \"\") + key);\n } else {\n _set(path, key, value);\n }\n }\n });\n };\n recursiveProps(props);\n }\n\n instance.onInit?.(element.props);\n\n const elementsListen = new Subject<any>()\n\n if (props?.isRoot) {\n element.allElements = elementsListen\n element.props.context.rootElement = element;\n element.componentInstance.onMount?.(element);\n propagateContext(element);\n }\n\n if (props) {\n for (let key in props) {\n const directive = applyDirective(element, key);\n if (directive) element.directives[key] = directive;\n }\n }\n\n function onMount(parent: Element, element: Element, index?: number) {\n element.props.context = parent.props.context;\n element.parent = parent;\n element.componentInstance.onMount?.(element, index);\n for (let name in element.directives) {\n element.directives[name].onMount?.(element);\n }\n element.effectMounts.forEach((fn: any) => {\n element.effectUnmounts.push(fn(element));\n });\n };\n\n async function propagateContext(element) {\n if (element.props.attach) {\n const isReactiveAttach = isSignal(element.propObservables?.attach)\n if (!isReactiveAttach) {\n element.props.children.push(element.props.attach)\n }\n else {\n await new Promise((resolve) => {\n let lastElement = null\n element.propSubscriptions.push(element.propObservables.attach.observable.subscribe(async (args) => {\n const value = args?.value ?? args\n if (!value) {\n throw new Error(`attach in ${element.tag} is undefined or null, add a component`)\n }\n if (lastElement) {\n destroyElement(lastElement)\n }\n lastElement = value\n await createElement(element, value)\n resolve(undefined)\n }))\n })\n }\n }\n if (!element.props.children) {\n return;\n }\n for (let child of element.props.children) {\n if (!child) continue;\n await createElement(element, child)\n }\n };\n\n async function createElement(parent: Element, child: Element) {\n if (isPromise(child)) {\n child = await child;\n }\n if (child instanceof Observable) {\n child.subscribe(\n ({\n elements: comp,\n prev,\n }: {\n elements: Element[];\n prev?: Element;\n }) => {\n // if prev, insert element after this\n const components = comp.filter((c) => c !== null);\n if (prev) {\n components.forEach((c) => {\n const index = parent.props.children.indexOf(prev.props.key);\n onMount(parent, c, index + 1);\n propagateContext(c);\n });\n return;\n }\n components.forEach((component) => {\n if (!Array.isArray(component)) {\n onMount(parent, component);\n propagateContext(component);\n } else {\n component.forEach((comp) => {\n onMount(parent, comp);\n propagateContext(comp);\n });\n }\n });\n elementsListen.next(undefined)\n }\n );\n } else {\n onMount(parent, child);\n await propagateContext(child);\n }\n }\n\n // Return the created element representation\n return element;\n}\n\n/**\n * Observes a BehaviorSubject containing an array or object of items and dynamically creates child elements for each item.\n *\n * @param {WritableArraySignal<T> | WritableObjectSignal<T>} itemsSubject - A signal that emits an array or object of items.\n * @param {Function} createElementFn - A function that takes an item and returns an element representation.\n * @returns {Observable} An observable that emits the list of created child elements.\n */\nexport function loop<T>(\n itemsSubject: any,\n createElementFn: (item: T, index: number | string) => Element | null\n): FlowObservable {\n\n if (isComputed(itemsSubject) && itemsSubject.dependencies.size == 0) {\n itemsSubject = signal(itemsSubject());\n }\n else if (!isSignal(itemsSubject)) {\n itemsSubject = signal(itemsSubject);\n }\n\n return defer(() => {\n let elements: Element[] = [];\n let elementMap = new Map<string | number, Element>();\n let isFirstSubscription = true;\n\n const isArraySignal = (signal: any): signal is WritableArraySignal<T[]> => \n Array.isArray(signal());\n\n return new Observable<FlowResult>(subscriber => {\n const subscription = isArraySignal(itemsSubject)\n ? itemsSubject.observable.subscribe(change => {\n if (isFirstSubscription) {\n isFirstSubscription = false;\n elements.forEach(el => el.destroy());\n elements = [];\n elementMap.clear();\n\n const items = itemsSubject();\n if (items) {\n items.forEach((item, index) => {\n const element = createElementFn(item, index);\n if (element) {\n elements.push(element);\n elementMap.set(index, element);\n }\n });\n }\n subscriber.next({\n elements: [...elements]\n });\n return;\n }\n\n if (change.type === 'init' || change.type === 'reset') {\n elements.forEach(el => el.destroy());\n elements = [];\n elementMap.clear();\n\n const items = itemsSubject();\n if (items) {\n items.forEach((item, index) => {\n const element = createElementFn(item, index);\n if (element) {\n elements.push(element);\n elementMap.set(index, element);\n }\n });\n }\n } else if (change.type === 'add' && change.index !== undefined) {\n const newElements = change.items.map((item, i) => {\n const element = createElementFn(item as T, change.index! + i);\n if (element) {\n elementMap.set(change.index! + i, element);\n }\n return element;\n }).filter((el): el is Element => el !== null);\n \n elements.splice(change.index, 0, ...newElements);\n } else if (change.type === 'remove' && change.index !== undefined) {\n const removed = elements.splice(change.index, 1);\n removed.forEach(el => {\n el.destroy();\n elementMap.delete(change.index!);\n });\n } else if (change.type === 'update' && change.index !== undefined && change.items.length === 1) {\n const index = change.index;\n const newItem = change.items[0];\n\n // Check if the previous item at this index was effectively undefined or non-existent\n if (index >= elements.length || elements[index] === undefined || !elementMap.has(index)) {\n // Treat as add operation\n const newElement = createElementFn(newItem as T, index);\n if (newElement) {\n elements.splice(index, 0, newElement); // Insert at the correct index\n elementMap.set(index, newElement);\n // Adjust indices in elementMap for subsequent elements might be needed if map relied on exact indices\n // This simple implementation assumes keys are stable or createElementFn handles context correctly\n } else {\n console.warn(`Element creation returned null for index ${index} during add-like update.`);\n }\n } else {\n // Treat as a standard update operation\n const oldElement = elements[index];\n oldElement.destroy();\n const newElement = createElementFn(newItem as T, index);\n if (newElement) {\n elements[index] = newElement;\n elementMap.set(index, newElement);\n } else {\n // Handle case where new element creation returns null\n elements.splice(index, 1);\n elementMap.delete(index);\n }\n }\n }\n\n subscriber.next({\n elements: [...elements] // Create a new array to ensure change detection\n });\n })\n : (itemsSubject as WritableObjectSignal<T>).observable.subscribe(change => {\n const key = change.key as string | number\n if (isFirstSubscription) {\n isFirstSubscription = false;\n elements.forEach(el => el.destroy());\n elements = [];\n elementMap.clear();\n\n const items = (itemsSubject as WritableObjectSignal<T>)();\n if (items) {\n Object.entries(items).forEach(([key, value]) => {\n const element = createElementFn(value, key);\n if (element) {\n elements.push(element);\n elementMap.set(key, element);\n }\n });\n }\n subscriber.next({\n elements: [...elements]\n });\n return;\n }\n\n if (change.type === 'init' || change.type === 'reset') {\n elements.forEach(el => el.destroy());\n elements = [];\n elementMap.clear();\n\n const items = (itemsSubject as WritableObjectSignal<T>)();\n if (items) {\n Object.entries(items).forEach(([key, value]) => {\n const element = createElementFn(value, key);\n if (element) {\n elements.push(element);\n elementMap.set(key, element);\n }\n });\n }\n } else if (change.type === 'add' && change.key && change.value !== undefined) {\n const element = createElementFn(change.value as T, key);\n if (element) {\n elements.push(element);\n elementMap.set(key, element);\n }\n } else if (change.type === 'remove' && change.key) {\n const index = elements.findIndex(el => elementMap.get(key) === el);\n if (index !== -1) {\n const [removed] = elements.splice(index, 1);\n removed.destroy();\n elementMap.delete(key);\n }\n } else if (change.type === 'update' && change.key && change.value !== undefined) {\n const index = elements.findIndex(el => elementMap.get(key) === el);\n if (index !== -1) {\n const oldElement = elements[index];\n oldElement.destroy();\n const newElement = createElementFn(change.value as T, key);\n if (newElement) {\n elements[index] = newElement;\n elementMap.set(key, newElement);\n }\n }\n }\n\n subscriber.next({\n elements: [...elements] // Create a new array to ensure change detection\n });\n });\n\n return subscription;\n });\n });\n}\n\n/**\n * Conditionally creates and destroys elements based on a condition signal.\n *\n * @param {Signal<boolean> | boolean} condition - A signal or boolean that determines whether to create an element.\n * @param {Function} createElementFn - A function that returns an element or a promise that resolves to an element.\n * @returns {Observable} An observable that emits the created or destroyed element.\n */\nexport function cond(\n condition: Signal<boolean> | boolean,\n createElementFn: () => Element | Promise<Element>\n): FlowObservable {\n let element: Element | null = null;\n\n if (isSignal(condition)) {\n const signalCondition = condition as WritableObjectSignal<boolean>;\n return new Observable<{elements: Element[], type?: \"init\" | \"remove\"}>(subscriber => {\n return signalCondition.observable.subscribe(bool => {\n if (bool) {\n let _el = createElementFn();\n if (isPromise(_el)) {\n from(_el as Promise<Element>).subscribe(el => {\n element = el;\n subscriber.next({\n type: \"init\",\n elements: [el],\n });\n });\n } else {\n element = _el as Element;\n subscriber.next({\n type: \"init\",\n elements: [element],\n });\n }\n } else if (element) {\n destroyElement(element);\n subscriber.next({\n elements: [],\n });\n } else {\n subscriber.next({\n elements: [],\n });\n }\n });\n }).pipe(share())\n } else {\n // Handle boolean case\n if (condition) {\n let _el = createElementFn();\n if (isPromise(_el)) {\n return from(_el as Promise<Element>).pipe(\n map((el) => ({\n type: \"init\",\n elements: [el],\n }))\n );\n }\n return of({\n type: \"init\",\n elements: [_el as Element],\n });\n }\n return of({\n elements: [],\n });\n }\n}\n","import { ComponentInstance } from '../components/DisplayObject';\nimport { SignalOrPrimitive } from '../components/types';\nimport { Directive, registerDirective } from '../engine/directive';\nimport { Element } from '../engine/reactive';\nimport { error } from '../engine/utils';\nimport { useProps } from '../hooks/useProps';\n\nexport type ViewportFollowProps = {\n viewportFollow?: boolean | {\n speed?: SignalOrPrimitive<number>;\n acceleration?: SignalOrPrimitive<number>;\n radius?: SignalOrPrimitive<number>;\n };\n}\n\nexport class ViewportFollow extends Directive {\n onInit(element: Element<ComponentInstance>) {\n\n }\n onMount(element: Element) {\n this.onUpdate(element.props.viewportFollow, element)\n }\n onUpdate(viewportFollow: any, element: Element) {\n const { viewport } = element.props.context\n if (!viewport) {\n throw error('ViewportFollow directive requires a Viewport component to be mounted in the same context')\n }\n if (viewportFollow) {\n if (viewportFollow === true) {\n viewport.follow(element.componentInstance)\n } else {\n const options = useProps(viewportFollow, {\n speed: undefined,\n acceleration: undefined,\n radius: undefined\n })\n viewport.follow(element.componentInstance, {\n speed: options.speed(),\n acceleration: options.acceleration(),\n radius: options.radius()\n })\n }\n } else if (viewportFollow === null) {\n viewport.plugins.remove('follow')\n }\n }\n onDestroy(element: Element) {\n const { viewportFollow } = element.props\n const { viewport } = element.props.context\n if (viewportFollow) viewport.plugins.remove('follow')\n }\n}\n\nregisterDirective('viewportFollow', ViewportFollow)","import { effect } from '@signe/reactive';\nimport { Howl } from 'howler';\nimport { Container } from 'pixi.js';\nimport { Subscription } from 'rxjs';\nimport { Directive, registerDirective } from '../engine/directive';\nimport { Element } from '../engine/reactive';\nimport { calculateDistance, error } from '../engine/utils';\n\nconst EVENTS = ['load', 'loaderror', 'playerror', 'play', 'end', 'pause', 'stop', 'mute', 'volume', 'rate', 'seek', 'fade', 'unlock']\n\n/**\n * Sound directive for playing audio with support for spatial audio and multiple sound sources\n * \n * This directive manages audio playback using Howler.js library. It supports:\n * - Single or multiple sound sources\n * - Spatial audio with distance-based volume calculation\n * - All standard audio controls (play, pause, volume, etc.)\n * - Event handling for audio lifecycle\n * \n */\nexport class Sound extends Directive {\n private sounds: Howl[] = []\n private eventsFn: ((...args: any[]) => void)[] = []\n private maxVolume: number = 1\n private maxDistance: number = 100\n private tickSubscription?: Subscription \n\n onInit(element: Element<Container>) { }\n\n onMount(element: Element<Container>) {\n const { props } = element\n const tick = props.context.tick\n const propsSound = props.sound.value ?? props.sound\n\n // Check if src is null or undefined\n if (!propsSound.src) {\n return\n }\n\n const { src, autoplay, loop, volume, spatial } = propsSound\n \n // Handle multiple sources\n const sources = Array.isArray(src) ? src : [src]\n\n // Create Howl instances for each source\n for (const source of sources) {\n if (!source) continue // Skip null/undefined sources\n \n const sound = new Howl({\n src: source,\n autoplay,\n loop,\n volume\n })\n \n // Add event listeners for each sound\n for (let event of EVENTS) {\n if (!propsSound[event]) continue\n const fn = propsSound[event]\n this.eventsFn.push(fn)\n sound.on(event, fn);\n }\n \n this.sounds.push(sound)\n }\n\n // Setup spatial audio if enabled\n if (spatial && this.sounds.length > 0) {\n const { soundListenerPosition } = props.context\n if (!soundListenerPosition) {\n throw new error('SoundListenerPosition directive is required for spatial sound in component parent')\n }\n const { x: listenerX, y: listenerY } = soundListenerPosition\n this.tickSubscription = effect(() => {\n tick()\n const { x, y } = element.componentInstance\n const distance = calculateDistance(x, y, listenerX(), listenerY());\n const volume = Math.max(this.maxVolume - (distance / this.maxDistance), 0)\n \n // Apply volume to all sounds\n this.sounds.forEach(sound => sound.volume(volume))\n }).subscription\n }\n\n this.onUpdate(propsSound)\n }\n\n onUpdate(props: any) {\n const soundProps = props.value ?? props\n const { volume, loop, mute, seek, playing, rate, spatial } = soundProps\n // Apply updates to all sounds\n this.sounds.forEach(sound => {\n if (volume !== undefined) sound.volume(volume)\n if (loop !== undefined) sound.loop(loop)\n if (mute !== undefined) sound.mute(mute)\n if (seek !== undefined) sound.seek(seek)\n if (playing !== undefined) {\n if (playing) sound.play()\n else sound.pause()\n }\n if (rate !== undefined) sound.rate(rate)\n })\n \n // Update spatial audio settings\n if (spatial) {\n this.maxVolume = spatial.maxVolume ?? this.maxVolume\n this.maxDistance = spatial.maxDistance ?? this.maxDistance\n }\n }\n\n onDestroy() {\n // Stop and clean up all sounds\n this.sounds.forEach(sound => {\n sound.stop()\n \n // Remove event listeners\n for (let event of EVENTS) {\n const eventFn = this.eventsFn.find(fn => fn === this.eventsFn[event])\n if (eventFn) {\n sound.off(event, eventFn);\n }\n }\n })\n \n this.sounds = []\n this.eventsFn = []\n this.tickSubscription?.unsubscribe()\n }\n}\n\n/**\n * SoundListenerPosition directive for spatial audio\n * \n * This directive provides the listener position for spatial audio calculations.\n * It should be placed on a parent component that contains spatial sound sources.\n * \n * @example\n * ```tsx\n * <Player soundListenerPosition={{ x: playerX, y: playerY }}>\n * <Enemy sound={{ src: 'growl.mp3', spatial: { maxDistance: 100 } }} />\n * </Player>\n * ```\n */\nclass SoundListenerPosition extends Directive {\n onMount(element: Element<any>) {\n element.props.context.soundListenerPosition = element.propObservables?.soundListenerPosition\n }\n onInit(element: Element<any>) { }\n onUpdate(props: any) { }\n onDestroy() { }\n}\n\nregisterDirective('sound', Sound)\nregisterDirective('soundListenerPosition', SoundListenerPosition)","import { effect, isComputed, isSignal, signal } from '@signe/reactive';\nimport { Container, Rectangle, Point, FederatedPointerEvent } from 'pixi.js';\nimport { Directive, registerDirective } from '../engine/directive';\nimport { Element } from '../engine/reactive';\nimport { snap } from 'popmotion';\nimport { addContext } from '../hooks/addContext';\nimport { Subscription } from 'rxjs';\nimport { useProps } from '../hooks/useProps';\nimport { SignalOrPrimitive } from '../components/types';\n\nexport type DragProps = {\n move?: (event: FederatedPointerEvent) => void;\n start?: () => void;\n end?: () => void;\n snap?: SignalOrPrimitive<number>;\n direction?: SignalOrPrimitive<'x' | 'y' | 'all'>;\n keyToPress?: SignalOrPrimitive<string[]>;\n viewport?: {\n edgeThreshold?: SignalOrPrimitive<number>;\n maxSpeed?: SignalOrPrimitive<number>;\n };\n}\n\nexport class Drop extends Directive {\n private elementRef: Element<Container> | null = null;\n\n onInit(element: Element<Container>) {\n this.elementRef = element;\n }\n\n onMount(element: Element<Container>) {\n addContext(element, 'drop', element);\n }\n\n onUpdate() {}\n\n onDestroy() {\n this.elementRef = null;\n }\n}\n\nexport class Drag extends Directive {\n private elementRef: Element<Container> | null = null;\n private stageRef: Container | null = null;\n private offsetInParent = new Point();\n private isDragging = false;\n private viewport: any | null = null;\n private animationFrameId: number | null = null;\n private lastPointerPosition: Point = new Point();\n private pressedKeys: Set<string> = new Set();\n private pointerIsDown = false;\n\n private onDragMoveHandler: (event: FederatedPointerEvent) => void = () => {};\n private onDragEndHandler: () => void = () => {};\n private onDragStartHandler: (event: FederatedPointerEvent) => void = () => {};\n private onKeyDownHandler: (event: KeyboardEvent) => void = () => {};\n private onKeyUpHandler: (event: KeyboardEvent) => void = () => {};\n\n private subscriptions: Subscription[] = [];\n\n onInit(element: Element<Container>) {\n this.elementRef = element;\n this.onDragMoveHandler = this.onDragMove.bind(this);\n this.onDragEndHandler = this.onDragEnd.bind(this);\n this.onDragStartHandler = this.onPointerDown.bind(this);\n this.onKeyDownHandler = this.onKeyDown.bind(this);\n this.onKeyUpHandler = this.onKeyUp.bind(this);\n }\n\n onMount(element: Element<Container>) {\n const { rootElement, canvasSize, viewport, tick } = element.props.context;\n const instance = element.componentInstance;\n const dragProps = this.dragProps;\n const haveNotProps = Object.keys(dragProps).length === 0;\n\n if (haveNotProps) {\n this.onDestroy();\n return;\n }\n \n if (!instance) return;\n this.stageRef = rootElement.componentInstance;\n if (!this.stageRef) return;\n this.viewport = viewport;\n\n instance.eventMode = 'static';\n this.stageRef.eventMode = 'static';\n\n const _effect = effect(() => {\n if (this.stageRef) {\n this.stageRef.hitArea = new Rectangle(0, 0, canvasSize().width, canvasSize().height);\n }\n });\n\n instance.on('pointerdown', this.onDragStartHandler);\n this.stageRef.on('pointerup', this.onDragEndHandler);\n this.stageRef.on('pointerupoutside', this.onDragEndHandler);\n\n const keysToPress = dragProps.keyToPress ? dragProps.keyToPress : [];\n \n // Always add keyboard event listeners to track pressed keys\n window.addEventListener('keydown', this.onKeyDownHandler);\n window.addEventListener('keyup', this.onKeyUpHandler);\n\n this.subscriptions = [\n tick.observable.subscribe(() => {\n if (this.isDragging && this.viewport) {\n this.updateViewportPosition(this.lastPointerPosition);\n }\n }),\n _effect.subscription\n ]\n }\n\n get dragProps() {\n const drag = this.elementRef?.props.drag\n const options = useProps(drag?.value ?? drag, {\n snap: 0,\n viewport: {},\n direction: 'all',\n keyToPress: []\n });\n options.viewport = useProps(options.viewport, {\n edgeThreshold: 300,\n maxSpeed: 40\n });\n return options;\n }\n\n get axis() {\n const direction = this.dragProps.direction();\n const axis = {\n x: true,\n y: true,\n }\n if (direction === 'x') {\n axis.y = false;\n }\n if (direction === 'y') {\n axis.x = false;\n }\n return axis;\n }\n\n /**\n * Updates element position when dragging and starts continuous viewport movement\n * @param event The pointer event that triggered the drag move\n */\n private onDragMove(event: FederatedPointerEvent) {\n if (!this.isDragging || !this.elementRef?.componentInstance || !this.elementRef.componentInstance.parent) return;\n\n const instance = this.elementRef.componentInstance;\n const parent = instance.parent;\n const dragProps = this.dragProps;\n const propObservables = this.elementRef.propObservables;\n const snapTo = snap(dragProps?.snap() ?? 0);\n\n dragProps?.move?.(event);\n\n const currentParentLocalPointer = parent.toLocal(event.global);\n\n const newX = currentParentLocalPointer.x - this.offsetInParent.x;\n const newY = currentParentLocalPointer.y - this.offsetInParent.y;\n\n if (dragProps?.snap()) {\n instance.position.x = snapTo(newX);\n instance.position.y = snapTo(newY);\n } else {\n if (this.axis.x) instance.position.x = newX;\n if (this.axis.y) instance.position.y = newY;\n }\n\n // Store the last pointer position for continuous viewport movement\n this.lastPointerPosition.copyFrom(event.global);\n\n const { x: xProp, y: yProp } = propObservables as any;\n\n const updatePosition = (prop: any, value: number) => {\n if (isComputed(prop)) {\n prop.dependencies.forEach(dependency => {\n dependency.set(value)\n })\n } else if (isSignal(prop)) {\n prop.set(value)\n }\n }\n\n if (xProp !== undefined) updatePosition(xProp, instance.position.x)\n if (yProp !== undefined) updatePosition(yProp, instance.position.y)\n }\n\n /**\n * Moves the viewport if the dragged element is near screen edges\n * @param globalPosition The global pointer position\n */\n private updateViewportPosition(globalPosition: Point) {\n if (!this.viewport || !this.elementRef) return;\n\n const dragProps = this.dragProps;\n const edgeThreshold = dragProps?.viewport?.edgeThreshold(); // Distance from edge to trigger viewport movement\n const maxSpeed = dragProps?.viewport?.maxSpeed(); // Maximum speed when element is at the very edge\n \n // Calculate screen boundaries\n const screenLeft = 0;\n const screenRight = this.viewport.screenWidth;\n const screenTop = 0;\n const screenBottom = this.viewport.screenHeight;\n const instance = this.elementRef.componentInstance;\n \n // Calculate distances from element to screen edges\n const distanceFromLeft = globalPosition.x - screenLeft;\n const distanceFromRight = screenRight - globalPosition.x;\n const distanceFromTop = globalPosition.y - screenTop;\n const distanceFromBottom = screenBottom - globalPosition.y;\n \n let moveX = 0;\n let moveY = 0;\n \n // Calculate horizontal movement with dynamic velocity\n if (distanceFromLeft < edgeThreshold) {\n // Velocity increases as distance decreases\n // When distance = 0, velocity = maxSpeed\n // When distance = threshold, velocity = 0\n const velocity = maxSpeed * (1 - (distanceFromLeft / edgeThreshold));\n moveX = -velocity;\n } else if (distanceFromRight < edgeThreshold) {\n const velocity = maxSpeed * (1 - (distanceFromRight / edgeThreshold));\n moveX = velocity;\n }\n \n // Calculate vertical movement with dynamic velocity\n if (distanceFromTop < edgeThreshold) {\n const velocity = maxSpeed * (1 - (distanceFromTop / edgeThreshold));\n moveY = -velocity;\n } else if (distanceFromBottom < edgeThreshold) {\n const velocity = maxSpeed * (1 - (distanceFromBottom / edgeThreshold));\n moveY = velocity;\n }\n \n // Apply movement with velocity-based displacement\n if (moveX !== 0 || moveY !== 0) {\n const lastViewValue = this.viewport.center;\n this.viewport.moveCenter(\n this.viewport.center.x + moveX,\n this.viewport.center.y + moveY\n );\n if (this.axis.x && lastViewValue.x !== this.viewport.center.x) {\n instance.position.x += moveX;\n }\n if (this.axis.y && lastViewValue.y !== this.viewport.center.y) {\n instance.position.y += moveY;\n }\n }\n }\n\n /**\n * Handles drag end event and stops viewport movement\n */\n private onDragEnd() {\n this.pointerIsDown = false;\n\n if (!this.isDragging) return;\n\n const dragProps = this.dragProps;\n this.isDragging = false;\n \n dragProps?.end?.();\n \n if (this.stageRef) {\n this.stageRef.off('pointermove', this.onDragMoveHandler);\n }\n }\n\n onKeyDown(event: KeyboardEvent) {\n this.pressedKeys.add(event.code);\n this.pressedKeys.add(event.key.toLowerCase());\n\n if (this.pointerIsDown && !this.isDragging && this.areRequiredKeysPressed()) {\n this.startDrag();\n }\n }\n\n onKeyUp(event: KeyboardEvent) {\n this.pressedKeys.delete(event.code);\n this.pressedKeys.delete(event.key.toLowerCase());\n if (this.isDragging && !this.areRequiredKeysPressed()) {\n this.onDragEnd();\n }\n }\n\n private areRequiredKeysPressed(): boolean {\n const keyToPress = this.dragProps.keyToPress ? this.dragProps.keyToPress : [];\n if (!keyToPress || keyToPress.length === 0) {\n return true; // No keys required, always return true\n }\n \n return keyToPress.some(key => {\n // Check if the key is pressed directly\n if (this.pressedKeys.has(key)) {\n return true;\n }\n \n // Check common alternative formats\n // Space key can be \"Space\", \" \", or \"space\"\n if (key.toLowerCase() === 'space') {\n return this.pressedKeys.has('Space') || this.pressedKeys.has(' ');\n }\n \n // Shift key can be \"ShiftLeft\", \"ShiftRight\", or \"shift\"\n if (key.toLowerCase() === 'shift') {\n return this.pressedKeys.has('ShiftLeft') || this.pressedKeys.has('ShiftRight');\n }\n \n // Control key can be \"ControlLeft\", \"ControlRight\", or \"control\"\n if (key.toLowerCase() === 'control' || key.toLowerCase() === 'ctrl') {\n return this.pressedKeys.has('ControlLeft') || this.pressedKeys.has('ControlRight');\n }\n \n // Alt key can be \"AltLeft\", \"AltRight\", or \"alt\"\n if (key.toLowerCase() === 'alt') {\n return this.pressedKeys.has('AltLeft') || this.pressedKeys.has('AltRight');\n }\n \n return false;\n });\n }\n\n private onPointerDown(event: FederatedPointerEvent) {\n if (!this.elementRef?.componentInstance || !this.stageRef || !this.elementRef.componentInstance.parent) return;\n \n this.pointerIsDown = true;\n\n const instance = this.elementRef.componentInstance;\n const parent = instance.parent;\n\n const parentLocalPointer = parent.toLocal(event.global);\n\n this.offsetInParent.x = parentLocalPointer.x - instance.position.x;\n this.offsetInParent.y = parentLocalPointer.y - instance.position.y;\n \n // Store initial pointer position\n this.lastPointerPosition.copyFrom(event.global);\n \n if (this.areRequiredKeysPressed()) {\n this.startDrag();\n }\n }\n\n private startDrag() {\n if (this.isDragging || !this.stageRef) return;\n\n this.isDragging = true;\n const dragProps = this.dragProps;\n dragProps?.start?.();\n this.stageRef.on('pointermove', this.onDragMoveHandler);\n }\n\n onUpdate(props) {\n if (props.type && props.type === 'reset') {\n this.onDestroy();\n this.onMount(this.elementRef);\n }\n }\n\n onDestroy() {\n this.subscriptions.forEach(subscription => subscription.unsubscribe());\n const instance = this.elementRef?.componentInstance;\n if (instance) {\n instance.off('pointerdown', this.onDragStartHandler);\n }\n if (this.stageRef) {\n this.stageRef.off('pointermove', this.onDragMoveHandler);\n this.stageRef.off('pointerup', this.onDragEndHandler);\n this.stageRef.off('pointerupoutside', this.onDragEndHandler);\n }\n \n // Remove keyboard event listeners\n window.removeEventListener('keydown', this.onKeyDownHandler);\n window.removeEventListener('keyup', this.onKeyUpHandler);\n \n this.stageRef = null;\n this.viewport = null;\n this.pressedKeys.clear();\n this.pointerIsDown = false;\n }\n}\n\nregisterDirective('drag', Drag);\nregisterDirective('drop', Drop);","export const addContext = (element, key, value) => {\n element.props.context = {\n ...(element.props.context ?? {}),\n [key]: value\n }\n}","import { Container, DisplacementFilter, Sprite, Texture, WRAP_MODES } from 'pixi.js';\nimport { animate } from 'popmotion';\nimport { Directive, registerDirective } from '../engine/directive';\nimport { Element } from '../engine/reactive';\n\n\nexport class Transition extends Directive {\n \n\n onInit(element: Element<Container>) {\n }\n\n onMount(element: Element<Container>) {\n const { image } = element.props.transition\n const displacementSprite = new Sprite(Texture.from(image))\n displacementSprite.texture.baseTexture.wrapMode = WRAP_MODES.REPEAT\n const displacementFilter = new DisplacementFilter(displacementSprite)\n const instance = element.componentInstance\n instance.filters = [displacementFilter]\n\n instance.addChild(displacementSprite)\n\n setTimeout(() => {\n animate({\n from: 0,\n to: 1,\n duration: 500,\n onUpdate: (progress) => {\n displacementFilter.scale.x = progress\n displacementFilter.scale.y = progress\n }\n })\n }, 5000)\n }\n\n onUpdate(props: any) {\n\n }\n\n onDestroy() {\n\n }\n}\n\nregisterDirective('transition', Transition)","\nimport './directives'\nexport * from '@signe/reactive'\nexport { Howler } from 'howler'\nexport * from './components'\nexport * from './engine/reactive'\nexport * from './engine/signal'\nexport * from './engine/trigger'\nexport * from './engine/bootstrap'\nexport * from './engine/animation'\nexport { useProps, useDefineProps } from './hooks/useProps'\nexport * from './utils/Ease'\nexport * from './utils/RadialGradient'\nexport * from './components/DisplayObject'\nexport { isObservable } from 'rxjs'\nexport * as Utils from './engine/utils'\nexport * as Howl from 'howler'","import { effect, Signal, signal } from \"@signe/reactive\";\nimport { Application, Container } from \"pixi.js\";\nimport {\n Props,\n createComponent,\n registerComponent,\n Element,\n} from \"../engine/reactive\";\nimport { useProps } from \"../hooks/useProps\";\nimport { ComponentInstance, DisplayObject } from \"./DisplayObject\";\nimport { ComponentFunction } from \"../engine/signal\";\nimport { SignalOrPrimitive } from \"./types\";\nimport { Size } from \"./types/DisplayObject\";\nimport { Scheduler, Tick } from \"../directives/Scheduler\";\n\ninterface CanvasElement extends Element<ComponentInstance> {\n render: (rootElement: HTMLElement, app?: Application) => void;\n directives: {\n tick: Scheduler;\n };\n propObservables: {\n tick: Signal<Tick>;\n };\n}\n\nregisterComponent(\"Canvas\", class Canvas extends DisplayObject(Container) {});\n\nexport interface CanvasProps extends Props {\n cursorStyles?: () => any;\n width?: SignalOrPrimitive<Size>;\n height?: SignalOrPrimitive<Size>;\n canvasEl?: HTMLElement;\n selector?: string;\n isRoot?: boolean;\n tick?: any;\n class?: SignalOrPrimitive<string>;\n background?: string;\n}\n\nexport const Canvas: ComponentFunction<CanvasProps> = async (props = {}) => {\n let { cursorStyles, width, height, class: className } = useProps(props);\n\n if (!props.width) width = signal<Size>(800);\n if (!props.height) height = signal<Size>(600);\n\n const canvasSize = signal({\n width: 0,\n height: 0,\n });\n\n props.isRoot = true;\n const options: CanvasProps = {\n ...props,\n context: {\n canvasSize,\n app: signal(null),\n },\n width: width?.(),\n height: height?.(),\n };\n\n if (!props.tick) {\n options.context!.tick = options.tick = signal({\n timestamp: 0,\n deltaTime: 0,\n frame: 0,\n deltaRatio: 1,\n });\n }\n\n const canvasElement = createComponent(\"Canvas\", options) as CanvasElement;\n\n canvasElement.render = (rootElement: HTMLElement, app?: Application) => {\n if (!app) {\n return;\n }\n\n const renderer = app.renderer;\n const canvasEl = renderer.view.canvas as HTMLCanvasElement;\n\n (globalThis as any).__PIXI_STAGE__ = canvasElement.componentInstance;\n (globalThis as any).__PIXI_RENDERER__ = renderer;\n\n if (props.tickStart !== false) canvasElement.directives.tick.start()\n\n effect(() => {\n canvasElement.propObservables!.tick();\n renderer.render(canvasElement.componentInstance as any);\n });\n\n app.stage = canvasElement.componentInstance as any;\n\n app.stage.layout = {\n width: app.screen.width,\n height: app.screen.height,\n justifyContent: props.justifyContent,\n alignItems: props.alignItems,\n };\n\n canvasSize.set({ width: app.screen.width, height: app.screen.height })\n\n app.renderer.on('resize', (width: number, height: number) => {\n canvasSize.set({ width, height });\n\n if (app.stage.layout) {\n app.stage.layout = {\n width,\n height\n }\n }\n });\n\n if (props.tickStart !== false) canvasElement.directives.tick.start();\n\n app.ticker.add(() => {\n canvasElement.propObservables!.tick();\n });\n\n if (cursorStyles) {\n effect(() => {\n renderer.events.cursorStyles = cursorStyles();\n });\n }\n\n if (className) {\n effect(() => {\n canvasEl.classList.add(className());\n });\n }\n\n const existingCanvas = rootElement.querySelector(\"canvas\");\n if (existingCanvas) {\n rootElement.replaceChild(canvasEl, existingCanvas);\n } else {\n rootElement.appendChild(canvasEl);\n }\n\n options.context!.app.set(app)\n };\n\n return canvasElement;\n};\n","import { Element, isElement, Props } from \"../engine/reactive\";\nimport { setObservablePoint } from \"../engine/utils\";\nimport type {\n AlignContent,\n EdgeSize,\n FlexDirection,\n ObjectFit,\n ObjectPosition,\n TransformOrigin,\n} from \"./types/DisplayObject\";\nimport { signal } from \"@signe/reactive\";\nimport { BlurFilter, ObservablePoint } from \"pixi.js\";\nimport * as FILTERS from \"pixi-filters\";\nimport { isPercent } from \"../utils/functions\";\nimport { BehaviorSubject, filter, Subject } from \"rxjs\";\n\nexport interface ComponentInstance extends PixiMixins.ContainerOptions {\n id?: string;\n children?: ComponentInstance[];\n onInit?(props: Props): void;\n onUpdate?(props: Props): void;\n onDestroy?(parent: Element, afterDestroy: () => void): void;\n onMount?(context: Element, index?: number): void;\n setWidth(width: number): void;\n setHeight(height: number): void;\n}\n\nexport const EVENTS = [\n \"added\",\n \"childAdded\",\n \"childRemoved\",\n \"click\",\n \"clickcapture\",\n \"destroyed\",\n \"globalmousemove\",\n \"globalpointermove\",\n \"globaltouchmove\",\n \"mousedown\",\n \"mousedowncapture\",\n \"mouseenter\",\n \"mouseentercapture\",\n \"mouseleave\",\n \"mouseleavecapture\",\n \"mousemove\",\n \"mousemovecapture\",\n \"mouseout\",\n \"mouseoutcapture\",\n \"mouseover\",\n \"mouseovercapture\",\n \"mouseup\",\n \"mouseupcapture\",\n \"mouseupoutside\",\n \"mouseupoutsidecapture\",\n \"pointercancel\",\n \"pointercancelcapture\",\n \"pointerdown\",\n \"pointerdowncapture\",\n \"pointerenter\",\n \"pointerentercapture\",\n \"pointerleave\",\n \"pointerleavecapture\",\n \"pointermove\",\n \"pointermovecapture\",\n \"pointerout\",\n \"pointeroutcapture\",\n \"pointerover\",\n \"pointerovercapture\",\n \"pointertap\",\n \"pointertapcapture\",\n \"pointerup\",\n \"pointerupcapture\",\n \"pointerupoutside\",\n \"pointerupoutsidecapture\",\n \"removed\",\n \"rightclick\",\n \"rightclickcapture\",\n \"rightdown\",\n \"rightdowncapture\",\n \"rightup\",\n \"rightupcapture\",\n \"rightupoutside\",\n \"rightupoutsidecapture\",\n \"tap\",\n \"tapcapture\",\n \"touchcancel\",\n \"touchcancelcapture\",\n \"touchend\",\n \"touchendcapture\",\n \"touchendoutside\",\n \"touchendoutsidecapture\",\n \"touchmove\",\n \"touchmovecapture\",\n \"touchstart\",\n \"touchstartcapture\",\n \"wheel\",\n \"wheelcapture\",\n];\n\nexport type OnHook = (() => void) | (() => Promise<void> | void);\n\nexport function DisplayObject(extendClass) {\n return class DisplayObject extends extendClass {\n #canvasContext: {\n [key: string]: any;\n } | null = null;\n isFlex: boolean = false;\n fullProps: Props = {};\n isMounted: boolean = false;\n _anchorPoints = new ObservablePoint({ _onUpdate: () => {} }, 0, 0);\n isCustomAnchor: boolean = false;\n displayWidth = signal(0);\n displayHeight = signal(0);\n overrideProps: string[] = [];\n layout = null;\n onBeforeDestroy: OnHook | null = null;\n onAfterMount: OnHook | null = null;\n subjectInit = new BehaviorSubject(null);\n disableLayout: boolean = false;\n\n get deltaRatio() {\n return this.#canvasContext?.scheduler?.tick.value.deltaRatio;\n }\n\n get parentIsFlex() {\n if (this.disableLayout) return false;\n return this.parent?.isFlex;\n }\n\n onInit(props: Props) {\n this._id = props.id;\n for (let event of EVENTS) {\n if (props[event] && !this.overrideProps.includes(event)) {\n this.eventMode = \"static\";\n this.on(event, props[event]);\n }\n }\n if (props.onBeforeDestroy || props['on-before-destroy']) {\n this.onBeforeDestroy = props.onBeforeDestroy || props['on-before-destroy'];\n }\n if (props.onAfterMount || props['on-after-mount']) {\n this.onAfterMount = props.onAfterMount || props['on-after-mount'];\n }\n if (\n props.justifyContent ||\n props.alignItems ||\n props.flexDirection ||\n props.flexWrap ||\n props.alignContent ||\n props.display == \"flex\" ||\n isPercent(props.width) ||\n isPercent(props.height) ||\n props.isRoot\n ) {\n this.layout = {};\n this.isFlex = true;\n }\n\n this.subjectInit.next(this);\n }\n\n async onMount({ parent, props }: Element<DisplayObject>, index?: number) {\n this.#canvasContext = props.context;\n if (parent) {\n const instance = parent.componentInstance as DisplayObject;\n if (instance.isFlex && !this.layout && !this.disableLayout) {\n try {\n this.layout = {};\n } catch (error) {\n console.warn('Failed to set layout:', error);\n }\n }\n if (index === undefined) {\n instance.addChild(this);\n } else {\n instance.addChildAt(this, index);\n }\n this.isMounted = true;\n this.onUpdate(props);\n if (this.onAfterMount) {\n await this.onAfterMount();\n }\n }\n }\n\n onUpdate(props: Props) {\n this.fullProps = {\n ...this.fullProps,\n ...props,\n };\n\n if (!this.#canvasContext || !this.parent) return;\n\n if (props.x !== undefined) this.setX(props.x);\n if (props.y !== undefined) this.setY(props.y);\n if (props.scale !== undefined)\n setObservablePoint(this.scale, props.scale);\n if (props.anchor !== undefined && !this.isCustomAnchor) {\n setObservablePoint(this.anchor, props.anchor);\n }\n if (props.width !== undefined) this.setWidth(props.width);\n if (props.height !== undefined) this.setHeight(props.height);\n if (props.minWidth !== undefined) this.setMinWidth(props.minWidth);\n if (props.minHeight !== undefined) this.setMinHeight(props.minHeight);\n if (props.maxWidth !== undefined) this.setMaxWidth(props.maxWidth);\n if (props.maxHeight !== undefined) this.setMaxHeight(props.maxHeight);\n if (props.aspectRatio !== undefined)\n this.setAspectRatio(props.aspectRatio);\n if (props.flexGrow !== undefined) this.setFlexGrow(props.flexGrow);\n if (props.flexShrink !== undefined) this.setFlexShrink(props.flexShrink);\n if (props.flexBasis !== undefined) this.setFlexBasis(props.flexBasis);\n if (props.rowGap !== undefined) this.setRowGap(props.rowGap);\n if (props.columnGap !== undefined) this.setColumnGap(props.columnGap);\n if (props.top !== undefined) this.setTop(props.top);\n if (props.left !== undefined) this.setLeft(props.left);\n if (props.right !== undefined) this.setRight(props.right);\n if (props.bottom !== undefined) this.setBottom(props.bottom);\n if (props.objectFit !== undefined) this.setObjectFit(props.objectFit);\n if (props.objectPosition !== undefined)\n this.setObjectPosition(props.objectPosition);\n if (props.transformOrigin !== undefined)\n this.setTransformOrigin(props.transformOrigin);\n if (props.skew !== undefined) setObservablePoint(this.skew, props.skew);\n if (props.tint) this.tint = props.tint;\n if (props.rotation !== undefined) this.rotation = props.rotation;\n if (props.angle !== undefined) this.angle = props.angle;\n if (props.zIndex !== undefined) this.zIndex = props.zIndex;\n if (props.roundPixels !== undefined) this.roundPixels = props.roundPixels;\n if (props.cursor) this.cursor = props.cursor;\n if (props.visible !== undefined) this.visible = props.visible;\n if (props.alpha !== undefined) this.alpha = props.alpha;\n if (props.pivot) setObservablePoint(this.pivot, props.pivot);\n if (props.flexDirection) this.setFlexDirection(props.flexDirection);\n if (props.flexWrap) this.setFlexWrap(props.flexWrap);\n if (props.justifyContent) this.setJustifyContent(props.justifyContent);\n if (props.alignItems) this.setAlignItems(props.alignItems);\n if (props.alignContent) this.setAlignContent(props.alignContent);\n if (props.alignSelf) this.setAlignSelf(props.alignSelf);\n if (props.margin) this.setMargin(props.margin);\n if (props.padding) this.setPadding(props.padding);\n if (props.gap) this.setGap(props.gap);\n if (props.border) this.setBorder(props.border);\n if (props.positionType) this.setPositionType(props.positionType);\n if (props.filters) this.filters = props.filters;\n if (props.maskOf) {\n if (isElement(props.maskOf)) {\n props.maskOf.componentInstance.mask = this as any;\n }\n }\n if (props.blendMode) this.blendMode = props.blendMode;\n if (props.filterArea) this.filterArea = props.filterArea;\n const currentFilters = this.filters || [];\n\n // TODO: Fix DropShadowFilter import issue\n // if (props.shadow) {\n // let dropShadowFilter = currentFilters.find(\n // (filter) => filter instanceof FILTERS.DropShadowFilter\n // );\n // if (!dropShadowFilter) {\n // dropShadowFilter = new FILTERS.DropShadowFilter();\n // currentFilters.push(dropShadowFilter);\n // }\n // Object.assign(dropShadowFilter, props.shadow);\n // }\n\n if (props.blur) {\n let blurFilter = currentFilters.find(\n (filter) => filter instanceof BlurFilter\n );\n if (!blurFilter) {\n const options =\n typeof props.blur === \"number\"\n ? {\n strength: props.blur,\n }\n : props.blur;\n blurFilter = new BlurFilter(options);\n currentFilters.push(blurFilter);\n }\n Object.assign(blurFilter, props.blur);\n }\n\n this.filters = currentFilters;\n }\n\n async onDestroy(parent: Element, afterDestroy?: () => void) {\n if (this.onBeforeDestroy) {\n await this.onBeforeDestroy();\n }\n super.destroy();\n if (afterDestroy) afterDestroy();\n }\n\n setFlexDirection(direction: FlexDirection) {\n this.layout = { flexDirection: direction };\n }\n\n setFlexWrap(wrap: \"wrap\" | \"nowrap\" | \"wrap-reverse\") {\n this.layout = { flexWrap: wrap };\n }\n\n setAlignContent(align: AlignContent) {\n this.layout = { alignContent: align };\n }\n\n setAlignSelf(align: AlignContent) {\n this.layout = { alignSelf: align };\n }\n\n setAlignItems(align: AlignContent) {\n this.layout = { alignItems: align };\n }\n\n setJustifyContent(\n justifyContent:\n | \"flex-start\"\n | \"flex-end\"\n | \"center\"\n | \"space-between\"\n | \"space-around\"\n ) {\n this.layout = { justifyContent };\n }\n\n setPosition(position: EdgeSize) {\n if (position instanceof Array) {\n if (position.length === 2) {\n this.layout = {\n positionY: position[0],\n positionX: position[1],\n };\n } else if (position.length === 4) {\n this.layout = {\n positionTop: position[0],\n positionRight: position[1],\n positionBottom: position[2],\n positionLeft: position[3],\n };\n }\n } else {\n this.layout = { position };\n }\n }\n\n setX(x: number) {\n x = x + this.getWidth() * this._anchorPoints.x;\n if (!this.parentIsFlex) {\n this.x = x;\n } else {\n this.x = x;\n this.layout = { x };\n }\n }\n\n setY(y: number) {\n y = y + this.getHeight() * this._anchorPoints.y;\n if (!this.parentIsFlex) {\n this.y = y;\n } else {\n this.y = y;\n this.layout = { y };\n }\n }\n\n setPadding(padding: EdgeSize) {\n if (padding instanceof Array) {\n if (padding.length === 2) {\n this.layout = {\n paddingVertical: padding[0],\n paddingHorizontal: padding[1],\n };\n } else if (padding.length === 4) {\n this.layout = {\n paddingTop: padding[0],\n paddingRight: padding[1],\n paddingBottom: padding[2],\n paddingLeft: padding[3],\n };\n }\n } else {\n this.layout = { padding };\n }\n }\n\n setMargin(margin: EdgeSize) {\n if (margin instanceof Array) {\n if (margin.length === 2) {\n this.layout = {\n marginVertical: margin[0],\n marginHorizontal: margin[1],\n };\n } else if (margin.length === 4) {\n this.layout = {\n marginTop: margin[0],\n marginRight: margin[1],\n marginBottom: margin[2],\n marginLeft: margin[3],\n };\n }\n } else {\n this.layout = { margin };\n }\n }\n\n setGap(gap: EdgeSize) {\n this.layout = { gap };\n }\n\n setBorder(border: EdgeSize) {\n if (border instanceof Array) {\n if (border.length === 2) {\n this.layout = {\n borderVertical: border[0],\n borderHorizontal: border[1],\n };\n } else if (border.length === 4) {\n this.layout = {\n borderTop: border[0],\n borderRight: border[1],\n borderBottom: border[2],\n borderLeft: border[3],\n };\n }\n } else {\n this.layout = { border };\n }\n }\n\n setPositionType(positionType: \"relative\" | \"absolute\") {\n this.layout = { position: positionType };\n }\n\n setWidth(width: number) {\n this.displayWidth.set(width);\n if (!this.parentIsFlex) {\n this.width = width;\n } else {\n this.layout = { width };\n }\n }\n\n setHeight(height: number) {\n this.displayHeight.set(height);\n if (!this.parentIsFlex) {\n this.height = height;\n } else {\n this.layout = { height };\n }\n }\n\n getWidth() {\n return this.displayWidth();\n }\n\n getHeight() {\n return this.displayHeight();\n }\n\n // Min/Max constraints\n setMinWidth(minWidth: number | string) {\n this.layout = { minWidth };\n }\n\n setMinHeight(minHeight: number | string) {\n this.layout = { minHeight };\n }\n\n setMaxWidth(maxWidth: number | string) {\n this.layout = { maxWidth };\n }\n\n setMaxHeight(maxHeight: number | string) {\n this.layout = { maxHeight };\n }\n\n // Aspect ratio\n setAspectRatio(aspectRatio: number) {\n this.layout = { aspectRatio };\n }\n\n // Flex properties\n setFlexGrow(flexGrow: number) {\n this.layout = { flexGrow };\n }\n\n setFlexShrink(flexShrink: number) {\n this.layout = { flexShrink };\n }\n\n setFlexBasis(flexBasis: number | string) {\n this.layout = { flexBasis };\n }\n\n // Gap properties\n setRowGap(rowGap: number) {\n this.layout = { rowGap };\n }\n\n setColumnGap(columnGap: number) {\n this.layout = { columnGap };\n }\n\n // Position insets\n setTop(top: number | string) {\n this.layout = { top };\n }\n\n setLeft(left: number | string) {\n this.layout = { left };\n }\n\n setRight(right: number | string) {\n this.layout = { right };\n }\n\n setBottom(bottom: number | string) {\n this.layout = { bottom };\n }\n\n // Object properties\n setObjectFit(objectFit: ObjectFit) {\n this.layout = { objectFit };\n }\n\n setObjectPosition(objectPosition: ObjectPosition) {\n this.layout = { objectPosition };\n }\n\n setTransformOrigin(transformOrigin: TransformOrigin) {\n this.layout = { transformOrigin };\n }\n };\n}\n","export function isPercent(value?: string | number) {\n if (!value) return false\n if (typeof value === \"string\") {\n return value.endsWith(\"%\")\n }\n return false\n}","import { Container as PixiContainer } from \"pixi.js\";\nimport { createComponent, registerComponent } from \"../engine/reactive\";\nimport { DisplayObject } from \"./DisplayObject\";\nimport { ComponentFunction } from \"../engine/signal\";\nimport { DisplayObjectProps } from \"./types/DisplayObject\";\nimport { setObservablePoint } from \"../engine/utils\";\n\ninterface ContainerProps extends DisplayObjectProps {\n sortableChildren?: boolean;\n}\n\nexport class CanvasContainer extends DisplayObject(PixiContainer) {\n isCustomAnchor = true;\n \n onUpdate(props) {\n if (props.anchor) {\n setObservablePoint(this._anchorPoints, props.anchor);\n props.pivot = [\n this.getWidth() * this._anchorPoints.x,\n this.getHeight() * this._anchorPoints.y\n ]\n }\n super.onUpdate(props);\n if (props.sortableChildren != undefined) {\n this.sortableChildren = props.sortableChildren;\n }\n }\n async onMount(args) {\n await super.onMount(args);\n const { componentInstance, props } = args;\n const { pixiChildren } = props;\n if (pixiChildren) {\n pixiChildren.forEach((child) => {\n componentInstance.addChild(child);\n });\n }\n }\n}\n\nexport interface CanvasContainer extends DisplayObjectProps {}\n\nregisterComponent(\"Container\", CanvasContainer);\n\nexport const Container: ComponentFunction<ContainerProps> = (props) => {\n return createComponent(\"Container\", props);\n};\n","import { Effect, effect, isSignal, signal, Signal, WritableSignal } from \"@signe/reactive\";\nimport { Assets, Graphics as PixiGraphics } from \"pixi.js\";\nimport { createComponent, Element, registerComponent } from \"../engine/reactive\";\nimport { ComponentInstance, DisplayObject } from \"./DisplayObject\";\nimport { DisplayObjectProps } from \"./types/DisplayObject\";\nimport { useProps } from \"../hooks/useProps\";\nimport { SignalOrPrimitive } from \"./types\";\nimport { isPercent } from \"../utils/functions\";\n\ninterface GraphicsProps extends DisplayObjectProps {\n draw?: (graphics: PixiGraphics, width: number, height: number) => void;\n}\n\ninterface RectProps extends DisplayObjectProps {\n color: SignalOrPrimitive<string>;\n}\n\ninterface CircleProps extends DisplayObjectProps {\n radius: SignalOrPrimitive<number>;\n color: SignalOrPrimitive<string>;\n}\n\ninterface EllipseProps extends DisplayObjectProps {\n color: SignalOrPrimitive<string>;\n}\n\ninterface TriangleProps extends DisplayObjectProps {\n base: SignalOrPrimitive<number>;\n color: SignalOrPrimitive<string>;\n}\n\ninterface SvgProps extends DisplayObjectProps {\n /** SVG content as string (legacy prop) */\n svg?: string;\n /** URL source of the SVG file to load */\n src?: string;\n /** Direct SVG content as string */\n content?: string;\n}\n\nclass CanvasGraphics extends DisplayObject(PixiGraphics) {\n clearEffect: Effect;\n width: WritableSignal<number>;\n height: WritableSignal<number>;\n \n /**\n * Initializes the graphics component with reactive width and height handling.\n * \n * This method handles different types of width and height props:\n * - **Numbers**: Direct pixel values\n * - **Strings with %**: Percentage values that trigger flex layout and use layout box dimensions\n * - **Signals**: Reactive values that update automatically\n * \n * When percentage values are detected, the component:\n * 1. Sets `display: 'flex'` to enable layout calculations\n * 2. Listens to layout events to get computed dimensions\n * 3. Updates internal width/height signals with layout box values\n * \n * The draw function receives the reactive width and height signals as parameters.\n * \n * @param props - Component properties including width, height, and draw function\n * @example\n * ```typescript\n * // With pixel values\n * Graphics({ width: 100, height: 50, draw: (g, w, h) => g.rect(0, 0, w(), h()) });\n * \n * // With percentage values (uses layout box)\n * Graphics({ width: \"50%\", height: \"100%\", draw: (g, w, h) => g.rect(0, 0, w(), h()) });\n * \n * // With signals\n * const width = signal(100);\n * Graphics({ width, height: 50, draw: (g, w, h) => g.rect(0, 0, w(), h()) });\n * ```\n */\n async onInit(props) {\n await super.onInit(props);\n }\n\n /**\n * Called when the component is mounted to the scene graph.\n * Creates the reactive effect for drawing using the original signals from propObservables.\n * @param {Element<DisplayObject>} element - The element being mounted with props and propObservables.\n * @param {number} [index] - The index of the component among its siblings.\n */\n async onMount(element: Element<any>, index?: number): Promise<void> {\n await super.onMount(element, index);\n const { props, propObservables } = element;\n \n // Use original signals from propObservables if available, otherwise create new ones\n const width = (isSignal(propObservables?.width) ? propObservables.width : signal(props.width || 0)) as WritableSignal<number>;\n const height = (isSignal(propObservables?.height) ? propObservables.height : signal(props.height || 0)) as WritableSignal<number>;\n \n // Store as class properties for access in other methods\n this.width = width;\n this.height = height;\n \n // Check if width or height are percentages to set display flex\n const isWidthPercentage = isPercent(width());\n const isHeightPercentage = isPercent(height());\n \n if (props.draw) {\n this.clearEffect = effect(() => {\n const w = width();\n const h = height();\n if (typeof w == 'string' || typeof h == 'string') {\n return\n }\n if (w == 0 || h == 0) {\n return\n }\n this.clear();\n props.draw?.(this, w, h);\n this.subjectInit.next(this)\n });\n }\n\n this.on('layout', (event) => {\n const layoutBox = event.computedLayout;\n // Update width if it's a percentage\n if (isWidthPercentage && isSignal(width)) {\n width.set(layoutBox.width);\n }\n \n // Update height if it's a percentage\n if (isHeightPercentage && isSignal(height)) {\n height.set(layoutBox.height);\n }\n });\n }\n\n /**\n * Called when component props are updated.\n * Updates the internal width and height signals when props change.\n * @param props - Updated properties\n */\n onUpdate(props: any) {\n super.onUpdate(props);\n \n // Update width signal if width prop changed\n if (props.width !== undefined && this.width) {\n if (isSignal(props.width)) {\n // If the new prop is a signal, we need to replace our local signal\n // This shouldn't happen in normal usage, but handle it just in case\n this.width = props.width;\n } else {\n // Update our local signal with the new value\n this.width.set(props.width);\n }\n }\n \n // Update height signal if height prop changed\n if (props.height !== undefined && this.height) {\n if (isSignal(props.height)) {\n // If the new prop is a signal, we need to replace our local signal\n // This shouldn't happen in normal usage, but handle it just in case\n this.height = props.height;\n } else {\n // Update our local signal with the new value\n this.height.set(props.height);\n }\n }\n }\n\n /**\n * Called when the component is about to be destroyed.\n * This method should be overridden by subclasses to perform any cleanup.\n * It ensures that the clearEffect subscription is unsubscribed before calling the original afterDestroy callback.\n * @param parent The parent element.\n * @param afterDestroy A callback function to be executed after the component's own destruction logic.\n * @example\n * // This method is typically called by the engine internally.\n * // await component.onDestroy(parentElement, () => console.log('Component destroyed'));\n */\n async onDestroy(parent: Element<ComponentInstance>, afterDestroy: () => void): Promise<void> {\n const _afterDestroyCallback = async () => {\n this.clearEffect.subscription.unsubscribe();\n afterDestroy();\n }\n await super.onDestroy(parent, _afterDestroyCallback);\n }\n}\n\nregisterComponent(\"Graphics\", CanvasGraphics);\n\nexport function Graphics(props: GraphicsProps) {\n return createComponent(\"Graphics\", props);\n}\n\nexport function Rect(props: RectProps) {\n const { color, borderRadius, border } = useProps(props, {\n borderRadius: null,\n border: null\n })\n\n return Graphics({\n draw: (g, width, height) => {\n if (borderRadius()) {\n g.roundRect(0, 0, width, height, borderRadius());\n } else {\n g.rect(0, 0, width, height);\n }\n if (border) {\n g.stroke(border);\n }\n g.fill(color());\n },\n ...props\n })\n}\n\nfunction drawShape(g: PixiGraphics, shape: 'circle' | 'ellipse', props: {\n radius: Signal<number>;\n color: Signal<string>;\n border: Signal<number>;\n} | {\n width: WritableSignal<number>;\n height: WritableSignal<number>;\n color: Signal<string>;\n border: Signal<number>;\n}) {\n const { color, border } = props;\n if ('radius' in props) {\n g.circle(0, 0, props.radius());\n } else {\n g.ellipse(0, 0, props.width() / 2, props.height() / 2);\n }\n if (border()) {\n g.stroke(border());\n }\n g.fill(color());\n}\n\nexport function Circle(props: CircleProps) { \n const { radius, color, border } = useProps(props, {\n border: null\n })\n return Graphics({\n draw: (g) => drawShape(g, 'circle', { radius, color, border }),\n ...props\n })\n}\n\nexport function Ellipse(props: EllipseProps) {\n const { width, height, color, border } = useProps(props, {\n border: null\n })\n return Graphics({\n draw: (g, gWidth, gHeight) => drawShape(g, 'ellipse', { width: signal(gWidth), height: signal(gHeight), color, border }),\n ...props\n })\n}\n\nexport function Triangle(props: TriangleProps) {\n const { width, height, color, border } = useProps(props, {\n border: null,\n color: '#000'\n })\n return Graphics({\n draw: (g, gWidth, gHeight) => {\n g.moveTo(0, gHeight);\n g.lineTo(gWidth / 2, 0);\n g.lineTo(gWidth, gHeight);\n g.lineTo(0, gHeight);\n g.fill(color());\n if (border) {\n g.stroke(border);\n }\n },\n ...props\n })\n}\n\n/**\n * Creates an SVG component that can render SVG graphics from URL, content, or legacy svg prop.\n * \n * This component provides three ways to display SVG graphics:\n * - **src**: Load SVG from a URL using Assets.load with parseAsGraphicsContext option\n * - **content**: Render SVG directly from string content using Graphics.svg() method\n * - **svg**: Legacy prop for SVG content (for backward compatibility)\n * \n * @param props - Component properties including src, content, or svg\n * @returns A reactive SVG component\n * @example\n * ```typescript\n * // Load from URL\n * const svgFromUrl = Svg({ src: \"/assets/logo.svg\" });\n * \n * // Direct content\n * const svgFromContent = Svg({ \n * content: `<svg viewBox=\"0 0 100 100\">\n * <circle cx=\"50\" cy=\"50\" r=\"40\" fill=\"blue\"/>\n * </svg>` \n * });\n * \n * // Legacy usage\n * const svgLegacy = Svg({ svg: \"<svg>...</svg>\" });\n * ```\n */\nexport function Svg(props: SvgProps) {\n return Graphics({\n draw: async (g) => {\n if (props.src) {\n // Load SVG from source URL with graphics context parsing\n const svgData = await Assets.load({\n src: props.src,\n data: {\n parseAsGraphicsContext: true,\n },\n });\n \n // Apply the loaded graphics context\n const graphics = new PixiGraphics(svgData);\n g.context = graphics.context;\n } else if (props.content) {\n // Render SVG directly from content string\n g.svg(props.content);\n } else if (props.svg) {\n // Legacy prop support\n g.svg(props.svg);\n }\n },\n ...props\n })\n}","import { Effect, effect } from \"@signe/reactive\";\nimport { Mesh as PixiMesh, Geometry, Shader, Texture, Assets, BLEND_MODES } from \"pixi.js\";\nimport { createComponent, Element, registerComponent } from \"../engine/reactive\";\nimport { ComponentInstance, DisplayObject } from \"./DisplayObject\";\nimport { DisplayObjectProps } from \"./types/DisplayObject\";\nimport { useProps } from \"../hooks/useProps\";\nimport { SignalOrPrimitive } from \"./types\";\nimport { ComponentFunction } from \"../engine/signal\";\n\n/**\n * Interface defining the properties for a Mesh component.\n * Extends DisplayObjectProps to inherit common display object properties.\n */\ninterface MeshProps extends DisplayObjectProps {\n /** The geometry defining the mesh structure (vertices, indices, UVs, etc.) */\n geometry?: Geometry;\n /** The shader to render the mesh with */\n shader?: Shader;\n /** The texture to apply to the mesh */\n texture?: Texture | string;\n /** The image URL to load as texture */\n image?: string;\n /** The tint color to apply to the mesh */\n tint?: SignalOrPrimitive<number>;\n /** Whether to round pixels for sharper rendering */\n roundPixels?: SignalOrPrimitive<boolean>;\n}\n\n/**\n * Canvas Mesh component class that extends DisplayObject with PixiMesh functionality.\n * This component allows rendering of custom 3D meshes with shaders and textures.\n * \n * @example\n * ```typescript\n * // Basic mesh with geometry and texture\n * const mesh = Mesh({\n * geometry: myGeometry,\n * texture: \"path/to/texture.png\",\n * tint: 0xff0000\n * });\n * \n * // Mesh with custom shader\n * const customMesh = Mesh({\n * geometry: myGeometry,\n * shader: myCustomShader,\n * draw: (mesh) => {\n * // Custom mesh manipulation\n * mesh.rotation += 0.01;\n * }\n * });\n * ```\n */\nclass CanvasMesh extends DisplayObject(PixiMesh) {\n /**\n * Constructor for the CanvasMesh component.\n * Initializes the PixiMesh with default geometry and shader to prevent errors.\n * \n * @example\n * ```typescript\n * // This constructor is called internally by the engine\n * const mesh = new CanvasMesh();\n * ```\n */\n constructor() {\n // Call parent constructor with minimal options to prevent destructuring error\n // @ts-ignore - PixiMesh constructor expects options object but TypeScript doesn't recognize it\n super({\n geometry: new Geometry()\n });\n }\n\n /**\n * Initializes the mesh component with the provided properties.\n * This method is called before onUpdate to set up initial state.\n * \n * @param props - The initial properties\n * @example\n * ```typescript\n * // This method is called internally when the component is created\n * mesh.onInit({\n * geometry: myGeometry,\n * texture: \"texture.png\"\n * });\n * ```\n */\n onInit(props: MeshProps) {\n super.onInit(props);\n\n // Set initial geometry if provided\n if (props.geometry) {\n try {\n this.geometry = props.geometry;\n } catch (error) {\n console.warn('Failed to set geometry:', error);\n }\n }\n \n // Set initial shader if provided\n if (props.shader) {\n this.shader = props.shader;\n }\n }\n\n /**\n * Updates the mesh component when properties change.\n * Handles texture loading, shader updates, and other property changes.\n * \n * @param props - The updated properties\n * @example\n * ```typescript\n * // This method is called internally when props change\n * mesh.onUpdate({\n * tint: 0x00ff00,\n * texture: \"new-texture.png\"\n * });\n * ```\n */\n async onUpdate(props: MeshProps) {\n super.onUpdate(props);\n\n // Handle geometry updates\n if (props.geometry) {\n try {\n this.geometry = props.geometry;\n } catch (error) {\n console.warn('Failed to update geometry:', error);\n }\n }\n\n // Handle shader/material updates\n if (props.shader) {\n this.shader = props.shader;\n }\n\n // Handle texture updates\n if (props.texture) {\n if (typeof props.texture === 'string') {\n this.texture = await Assets.load(props.texture);\n } else {\n this.texture = props.texture;\n }\n } else if (props.image) {\n this.texture = await Assets.load(props.image);\n }\n\n // Handle tint updates\n if (props.tint !== undefined) {\n this.tint = props.tint;\n }\n\n // Handle blend mode updates\n if (props.blendMode !== undefined) {\n this.blendMode = props.blendMode;\n }\n\n // Handle round pixels updates\n if (props.roundPixels !== undefined) {\n this.roundPixels = props.roundPixels;\n }\n }\n\n /**\n * Called when the component is about to be destroyed.\n * Cleans up the draw effect subscription and calls the parent destroy method.\n * \n * @param parent - The parent element\n * @param afterDestroy - Callback function to execute after destruction\n * @example\n * ```typescript\n * // This method is typically called by the engine internally\n * await mesh.onDestroy(parentElement, () => console.log('Mesh destroyed'));\n * ```\n */\n async onDestroy(parent: Element<ComponentInstance>, afterDestroy: () => void): Promise<void> {\n const _afterDestroyCallback = async () => {\n afterDestroy();\n };\n await super.onDestroy(parent, _afterDestroyCallback);\n }\n}\n\n// Register the component with the engine\nregisterComponent(\"Mesh\", CanvasMesh);\n\n/**\n * Creates a Mesh component with the specified properties.\n * This is the main function used to create mesh instances in your application.\n * \n * @param props - The properties for the mesh component\n * @returns A mesh component element\n * @example\n * ```typescript\n * import { Mesh } from 'canvasengine';\n * \n * // Create a basic textured mesh\n * const myMesh = Mesh({\n * geometry: triangleGeometry,\n * texture: \"assets/texture.png\",\n * x: 100,\n * y: 100,\n * tint: 0xff0000\n * });\n * \n * // Create a mesh with custom shader\n * const shaderMesh = Mesh({\n * geometry: planeGeometry,\n * shader: customShader,\n * draw: (mesh) => {\n * mesh.rotation += 0.01;\n * }\n * });\n * ```\n */\nexport const Mesh: ComponentFunction<MeshProps> = (props) => {\n return createComponent(\"Mesh\", props);\n};\n\n// Export the component class for advanced usage\nexport { CanvasMesh };\n\n// Export the props interface for TypeScript users\nexport type { MeshProps };","import {\n Subscription\n} from \"rxjs\";\nimport type { Element } from \"./reactive\";\nimport { Tick } from \"../directives/Scheduler\";\n\ntype MountFunction = (fn: (element: Element) => void) => void;\n\n// Define ComponentFunction type\nexport type ComponentFunction<P = {}> = (props: P) => Element | Promise<Element>;\n\nexport let currentSubscriptionsTracker: ((subscription: Subscription) => void) | null = null;\nexport let mountTracker: MountFunction | null = null;\n\n/**\n * Registers a mount function to be called when the component is mounted.\n * To unmount the component, the function must return a function that will be called by the engine.\n * \n * @param {(element: Element) => void} fn - The function to be called on mount.\n * @example\n * ```ts\n * mount((el) => {\n * console.log('mounted', el);\n * });\n * ```\n * Unmount the component by returning a function:\n * ```ts\n * mount((el) => {\n * console.log('mounted', el);\n * return () => {\n * console.log('unmounted', el);\n * }\n * });\n * ```\n */\nexport function mount(fn: (element: Element) => void) {\n mountTracker?.(fn);\n}\n\n/**\n * Registers a tick function to be called on each tick of the component's context.\n * @param {(tickValue: Tick, element: Element) => void} fn - The function to be called on each tick.\n * @example\n * ```ts\n * tick((tickValue, el) => {\n * console.log('tick', tickValue, el);\n * });\n * ```\n */\nexport function tick(fn: (tickValue: Tick, element: Element) => void) {\n mount((el: Element) => {\n const { context } = el.props\n let subscription: Subscription | undefined\n if (context.tick) {\n subscription = context.tick.observable.subscribe(({ value }) => {\n fn(value, el)\n })\n }\n return () => {\n subscription?.unsubscribe()\n }\n })\n}\n\n/**\n * Add tracking for subscriptions and mounts, then create an element from a component function.\n * @template C\n * @param {C} componentFunction - The component function to create an element from.\n * @param {Parameters<C>[0]} [props={}] - The props to pass to the component function.\n * @param {...any[]} children - The children elements of the component.\n * @returns {ReturnType<C>}\n * @example\n * ```ts\n * const el = h(MyComponent, {\n * x: 100,\n * y: 100,\n * });\n * ```\n * \n * with children:\n * ```ts\n * const el = h(MyComponent, {\n * x: 100,\n * y: 100,\n * }, \n * h(MyChildComponent, {\n * x: 50,\n * y: 50,\n * }),\n * );\n * ```\n */\nexport function h<C extends ComponentFunction<any>>(\n componentFunction: C,\n props: Parameters<C>[0] = {} as Parameters<C>[0],\n ...children: any[]\n): ReturnType<C> {\n const allSubscriptions = new Set<Subscription>();\n const allMounts = new Set<MountFunction>();\n\n currentSubscriptionsTracker = (subscription) => {\n allSubscriptions.add(subscription);\n };\n\n mountTracker = (fn: any) => {\n allMounts.add(fn);\n };\n\n if (children[0] instanceof Array) {\n children = children[0]\n }\n\n let component = componentFunction({ ...props, children }) as Element;\n\n if (!component) {\n component = {} as any\n }\n\n component.effectSubscriptions = Array.from(allSubscriptions);\n component.effectMounts = [\n ...Array.from(allMounts),\n ...((component as any).effectMounts ?? [])\n ];\n\n // call mount hook for root component\n if (component instanceof Promise) {\n component.then((component) => {\n if (component.props.isRoot) {\n allMounts.forEach((fn) => fn(component));\n }\n })\n }\n\n currentSubscriptionsTracker = null;\n mountTracker = null;\n\n return component as ReturnType<C>;\n}\n","import { h } from \"../engine/signal\";\nimport { Container } from \"./Container\";\n\nexport function Scene(props) {\n return h(Container)\n}","import * as particles from \"@barvynkoa/particle-emitter\";\nimport { createComponent, Element, registerComponent } from \"../engine/reactive\";\nimport { CanvasContainer } from \"./Container\";\nimport { Signal } from \"@signe/reactive\";\nimport { ComponentInstance } from \"./DisplayObject\";\n\nclass CanvasParticlesEmitter extends CanvasContainer {\n private emitter: particles.Emitter | null;\n private elapsed: number = Date.now();\n\n async onMount(params) {\n await super.onMount(params);\n const { props } = params;\n const tick: Signal = props.context.tick;\n this.emitter = new particles.Emitter(this as any, props.config);\n //this.emitter.emit = true\n\n this.subscriptionTick = tick.observable.subscribe((value) => {\n if (!this.emitter) return;\n const now = Date.now();\n this.emitter.update((now - this.elapsed) * 0.001);\n this.elapsed = now;\n });\n }\n\n onUpdate(props) {}\n\n async onDestroy(parent: Element<ComponentInstance>, afterDestroy: () => void) {\n const _afterDestroy = async () => {\n this.emitter?.destroy();\n this.emitter = null;\n this.subscriptionTick.unsubscribe();\n afterDestroy();\n }\n await super.onDestroy(parent, _afterDestroy);\n }\n}\n\nregisterComponent(\"ParticlesEmitter\", CanvasParticlesEmitter);\n\nexport function ParticlesEmitter(props) {\n return createComponent(\"ParticlesEmitter\", props);\n}\n","import { Howl } from 'howler';\nimport { computed, effect, isSignal, Signal } from \"@signe/reactive\";\nimport {\n Application,\n Assets,\n Container,\n Sprite as PixiSprite,\n Rectangle,\n Texture,\n} from \"pixi.js\";\nimport { Subscription } from \"rxjs\";\nimport {\n Element,\n createComponent,\n isElement,\n registerComponent,\n} from \"../engine/reactive\";\nimport { arrayEquals, isFunction } from \"../engine/utils\";\nimport { DisplayObject } from \"./DisplayObject\";\nimport {\n AnimationFrames,\n FrameOptions,\n SpritesheetOptions,\n TextureOptions,\n TransformOptions,\n} from \"./types/Spritesheet\";\nimport { ComponentFunction } from \"../engine/signal\";\nimport { DisplayObjectProps } from \"./types/DisplayObject\";\nimport { AnimatedSignal, isAnimatedSignal } from \"../engine/animation\";\nimport { Layout } from '@pixi/layout';\n\nconst log = console.log;\n\ntype Image = { image: string };\n\ntype TextureOptionsMerging = TextureOptions & {\n spriteWidth: number;\n spriteHeight: number;\n sound?: string;\n} & Image &\n TransformOptions;\n\ntype FrameOptionsMerging = TextureOptionsMerging & FrameOptions;\ntype SpritesheetOptionsMerging = TextureOptionsMerging & SpritesheetOptions;\ntype TransformOptionsAsArray = Pick<\n TransformOptions,\n \"anchor\" | \"scale\" | \"skew\" | \"pivot\"\n>;\n\ntype AnimationDataFrames = {\n sprites: FrameOptionsMerging[];\n frames: Texture[][];\n name: string;\n animations: AnimationFrames;\n params: any[];\n data: TextureOptionsMerging;\n};\n\nexport enum StandardAnimation {\n Stand = \"stand\",\n Walk = \"walk\",\n}\n\nexport class CanvasSprite extends DisplayObject(PixiSprite) {\n public hitbox: { w: number; h: number };\n public applyTransform: (\n frame: FrameOptionsMerging,\n data: TextureOptionsMerging,\n spritesheet: SpritesheetOptionsMerging\n ) => Partial<FrameOptionsMerging>;\n private spritesheet: SpritesheetOptionsMerging;\n private currentAnimation: AnimationDataFrames | null = null;\n private time: number = 0;\n private frameIndex: number = 0;\n private animations: Map<string, AnimationDataFrames> = new Map();\n private subscriptionTick: Subscription;\n private subscriptionSheet: Subscription[] = [];\n private sheetParams: any = {};\n private sheetCurrentAnimation: string = StandardAnimation.Stand;\n private app: Application | null = null;\n onFinish: () => void;\n\n get renderer() {\n return this.app?.renderer;\n }\n\n private currentAnimationContainer: Container | null = null;\n\n private async createTextures(\n options: Required<TextureOptionsMerging>\n ): Promise<Texture[][]> {\n const { width, height, framesHeight, framesWidth, image, offset } = options;\n \n if (!image || typeof image !== 'string' || image.trim() === '') {\n console.warn('Invalid image path provided to createTextures:', image);\n return [];\n }\n \n const texture = await Assets.load(image);\n const spriteWidth = options.spriteWidth;\n const spriteHeight = options.spriteHeight;\n const frames: Texture[][] = [];\n const offsetX = (offset && offset.x) || 0;\n const offsetY = (offset && offset.y) || 0;\n for (let i = 0; i < framesHeight; i++) {\n frames[i] = [];\n for (let j = 0; j < framesWidth; j++) {\n const rectX = j * spriteWidth + offsetX;\n const rectY = i * spriteHeight + offsetY;\n if (rectY > height) {\n throw log(\n `Warning, there is a problem with the height of the \"${this.id}\" spritesheet. When cutting into frames, the frame exceeds the height of the image.`\n );\n }\n if (rectX > width) {\n throw log(\n `Warning, there is a problem with the width of the \"${this.id}\" spritesheet. When cutting into frames, the frame exceeds the width of the image.`\n );\n }\n frames[i].push(\n new Texture({\n source: texture.source,\n frame: new Rectangle(rectX, rectY, spriteWidth, spriteHeight),\n })\n );\n }\n }\n return frames;\n }\n\n private async createAnimations() {\n const { textures } = this.spritesheet;\n if (!textures) {\n return;\n }\n for (let animationName in textures) {\n const props: (keyof TextureOptionsMerging)[] = [\n \"width\",\n \"height\",\n \"framesHeight\",\n \"framesWidth\",\n \"rectWidth\",\n \"rectHeight\",\n \"offset\",\n \"image\",\n \"sound\",\n ];\n const parentObj = props.reduce(\n (prev, val) => ({ ...prev, [val]: this.spritesheet[val] }),\n {}\n );\n const optionsTextures: TextureOptionsMerging = {\n ...parentObj,\n ...textures[animationName],\n } as any;\n const {\n rectWidth,\n width = 0,\n framesWidth = 1,\n rectHeight,\n height = 0,\n framesHeight = 1,\n } = optionsTextures;\n optionsTextures.spriteWidth = rectWidth ? rectWidth : width / framesWidth;\n optionsTextures.spriteHeight = rectHeight\n ? rectHeight\n : height / framesHeight;\n this.animations.set(animationName, {\n frames: await this.createTextures(\n optionsTextures as Required<TextureOptionsMerging>\n ),\n name: animationName,\n animations: textures[animationName].animations,\n params: [],\n data: optionsTextures,\n sprites: [],\n });\n }\n }\n\n async onMount(params: Element<CanvasSprite>) {\n const { props, propObservables } = params;\n const tick: Signal = props.context.tick;\n const sheet = props.sheet ?? {};\n this.app = props.context.app();\n if (sheet?.onFinish) {\n this.onFinish = sheet.onFinish;\n }\n this.subscriptionTick = tick.observable.subscribe((value) => {\n this.update(value);\n });\n if (props.sheet?.definition) {\n this.spritesheet = props.sheet.definition;\n await this.createAnimations();\n }\n if (sheet.params) {\n for (let key in propObservables?.sheet[\"params\"]) {\n const value = propObservables?.sheet[\"params\"][key] as Signal;\n if (isSignal(value)) {\n this.subscriptionSheet.push(\n value.observable.subscribe((value) => {\n if (this.animations.size == 0) return;\n this.play(this.sheetCurrentAnimation, [{ [key]: value }]);\n })\n );\n } else {\n this.play(this.sheetCurrentAnimation, [{ [key]: value }]);\n }\n }\n }\n\n const isMoving = computed(() => {\n const { x, y } = propObservables ?? {};\n if (!x || !y) return false;\n const xSignal = x as AnimatedSignal<any>;\n const ySignal = y as AnimatedSignal<any>;\n const isMovingX =\n isAnimatedSignal(xSignal) &&\n xSignal.animatedState().current !== xSignal.animatedState().end;\n const isMovingY =\n isAnimatedSignal(ySignal) &&\n ySignal.animatedState().current !== ySignal.animatedState().end;\n return isMovingX || isMovingY;\n });\n\n effect(() => {\n const _isMoving = isMoving();\n\n if (!this.isMounted) return;\n\n if (_isMoving) {\n this.sheetCurrentAnimation = StandardAnimation.Walk;\n } else {\n this.sheetCurrentAnimation = StandardAnimation.Stand;\n }\n\n if (this.spritesheet) this.play(this.sheetCurrentAnimation, [this.sheetParams]);\n });\n\n super.onMount(params);\n }\n\n async onUpdate(props) {\n super.onUpdate(props);\n\n const setTexture = async (image: string) => {\n if (!image || typeof image !== 'string' || image.trim() === '') {\n console.warn('Invalid image path provided to setTexture:', image);\n return null;\n }\n \n const onProgress = this.fullProps.loader?.onProgress;\n const texture = await Assets.load(image, (progress) => {\n if (onProgress) onProgress(progress);\n if (progress == 1) {\n const onComplete = this.fullProps.loader?.onComplete;\n if (onComplete) {\n // hack to memoize the texture\n setTimeout(() => {\n onComplete(texture);\n });\n }\n }\n });\n\n return texture\n }\n\n const sheet = props.sheet;\n if (sheet?.params) this.sheetParams = sheet?.params;\n\n if (sheet?.playing && this.isMounted) {\n this.sheetCurrentAnimation = sheet?.playing;\n this.play(this.sheetCurrentAnimation, [this.sheetParams]);\n }\n\n if (props.hitbox) this.hitbox = props.hitbox;\n\n if (props.scaleMode) this.baseTexture.scaleMode = props.scaleMode;\n else if (props.image && this.fullProps.rectangle === undefined) {\n const texture = await setTexture(this.fullProps.image);\n if (texture) {\n this.texture = texture;\n }\n } else if (props.texture) {\n if (isElement(props.texture)) {\n const textureInstance = props.texture.componentInstance;\n textureInstance.subjectInit\n .subscribe((value) => {\n console.log('a', value?.width)\n })\n this.texture = this.renderer?.generateTexture(props.texture.componentInstance);\n } else {\n this.texture = props.texture;\n }\n }\n if (props.rectangle !== undefined) {\n const { x, y, width, height } = props.rectangle?.value ?? props.rectangle;\n const texture = await setTexture(this.fullProps.image);\n if (texture) {\n this.texture = new Texture({\n source: texture.source,\n frame: new Rectangle(x, y, width, height),\n });\n }\n }\n }\n\n async onDestroy(parent: Element, afterDestroy: () => void): Promise<void> {\n await super.onDestroy(parent);\n this.subscriptionSheet.forEach((sub) => sub.unsubscribe());\n this.subscriptionTick.unsubscribe();\n if (this.currentAnimationContainer && this.parent instanceof Container) {\n this.parent.removeChild(this.currentAnimationContainer);\n }\n }\n\n has(name: string): boolean {\n return this.animations.has(name);\n }\n\n get(name: string): AnimationDataFrames {\n return this.animations.get(name) as AnimationDataFrames;\n }\n\n isPlaying(name?: string): boolean {\n if (!name) return !!this.currentAnimation;\n if (this.currentAnimation == null) return false;\n return this.currentAnimation.name == name;\n }\n\n stop() {\n this.currentAnimation = null;\n this.destroy();\n }\n\n play(name: string, params: any[] = []) {\n const animParams = this.currentAnimation?.params;\n\n if (this.isPlaying(name) && arrayEquals(params, animParams || [])) return;\n\n const animation = this.get(name);\n\n if (!animation) {\n throw new Error(\n `Impossible to play the ${name} animation because it doesn't exist on the \"${this.id}\" spritesheet`\n );\n }\n\n const cloneParams = structuredClone(params);\n\n this.removeChildren();\n animation.sprites = [];\n this.currentAnimation = animation;\n this.currentAnimation.params = cloneParams;\n this.time = 0;\n this.frameIndex = 0;\n let animations: any = animation.animations;\n animations = isFunction(animations)\n ? (animations as Function)(...cloneParams)\n : animations;\n\n this.currentAnimationContainer = new Container();\n\n for (let container of animations as FrameOptionsMerging[][]) {\n const sprite = new PixiSprite();\n for (let frame of container) {\n this.currentAnimation.sprites.push(frame);\n }\n this.currentAnimationContainer.addChild(sprite);\n }\n\n const sound = this.currentAnimation.data.sound;\n\n if (sound) {\n new Howl({\n src: sound,\n autoplay: true,\n loop: false,\n volume: 1,\n })\n }\n\n // Updates immediately to avoid flickering\n this.update({\n deltaRatio: 1,\n });\n }\n\n update({ deltaRatio }) {\n if (\n !this.isPlaying() ||\n !this.currentAnimation ||\n !this.currentAnimationContainer\n )\n return;\n\n const self = this;\n const { frames, sprites, data } = this.currentAnimation;\n let frame = sprites[this.frameIndex];\n const nextFrame = sprites[this.frameIndex + 1];\n\n for (let _sprite of this.currentAnimationContainer.children) {\n const sprite = _sprite as PixiSprite;\n\n if (!frame || frame.frameY == undefined || frame.frameX == undefined) {\n continue;\n }\n\n this.texture = frames[frame.frameY][frame.frameX];\n\n const getVal = <T extends keyof TransformOptions>(\n prop: T\n ): TransformOptions[T] | undefined => {\n return frame[prop] ?? data[prop] ?? this.spritesheet[prop];\n };\n\n const applyTransform = <T extends keyof TransformOptionsAsArray>(\n prop: T\n ): void => {\n const val = getVal<T>(prop);\n if (val) {\n this[prop as string].set(...val!);\n }\n };\n\n function applyTransformValue<T extends keyof TransformOptions>(prop: T);\n function applyTransformValue<T extends keyof TransformOptions>(\n prop: string,\n alias: T\n );\n function applyTransformValue<T extends keyof TransformOptions>(\n prop: T,\n alias?: T\n ): void {\n const optionProp = alias || prop;\n const val = getVal<T>(optionProp);\n if (val !== undefined) {\n self[prop as string] = val;\n }\n }\n\n if (this.applyTransform) {\n frame = {\n ...frame,\n ...this.applyTransform(frame, data, this.spritesheet),\n };\n }\n\n const realSize = getVal<\"spriteRealSize\">(\"spriteRealSize\");\n const heightOfSprite =\n typeof realSize == \"number\" ? realSize : realSize?.height;\n const widthOfSprite =\n typeof realSize == \"number\" ? realSize : realSize?.width;\n\n const applyAnchorBySize = () => {\n if (heightOfSprite && this.hitbox) {\n const { spriteWidth, spriteHeight } = data;\n const w = (spriteWidth - this.hitbox.w) / 2 / spriteWidth;\n const gap = (spriteHeight - heightOfSprite) / 2;\n const h = (spriteHeight - this.hitbox.h - gap) / spriteHeight;\n this.anchor.set(w, h);\n }\n };\n\n if (frame.sound) {\n //RpgSound.get(frame.sound).play()\n }\n\n applyAnchorBySize();\n\n applyTransform(\"anchor\");\n applyTransform(\"scale\");\n applyTransform(\"skew\");\n applyTransform(\"pivot\");\n\n applyTransformValue(\"alpha\", \"opacity\");\n applyTransformValue(\"x\");\n applyTransformValue(\"y\");\n applyTransformValue(\"angle\");\n applyTransformValue(\"rotation\");\n applyTransformValue(\"visible\");\n }\n\n if (!nextFrame) {\n this.time = 0;\n this.frameIndex = 0;\n if (this.onFinish && sprites.length > 1) this.onFinish();\n return;\n }\n\n this.time += deltaRatio ?? 1;\n\n if (this.time >= nextFrame.time) {\n this.frameIndex++;\n }\n }\n}\n\nexport interface CanvasSprite extends PixiSprite {\n layout: Layout | null;\n}\n\nregisterComponent(\"Sprite\", CanvasSprite);\n\n// Define the props interface for Sprite\nexport interface SpriteProps extends DisplayObjectProps {\n sheet?: {\n definition?: SpritesheetOptionsMerging;\n playing?: string;\n params?: any;\n onFinish?: () => void;\n };\n scaleMode?: number;\n image?: string;\n rectangle?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n context?: {\n tick: Signal;\n };\n}\n\nexport interface SpritePropsWithImage extends Omit<SpriteProps, \"sheet\"> {\n image: string;\n rectangle?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n}\n\nexport interface SpritePropsWithSheet\n extends Omit<SpriteProps, \"image\" | \"rectangle\"> {\n sheet: {\n definition: SpritesheetOptionsMerging;\n playing?: string;\n params?: any;\n onFinish?: () => void;\n };\n loader?: {\n onProgress?: (progress: number) => void;\n onComplete?: (texture: Texture) => void;\n };\n}\n\nexport type SpritePropTypes = SpritePropsWithImage | SpritePropsWithSheet;\n\n// Update the Sprite function to use the props interface\nexport const Sprite: ComponentFunction<SpritePropTypes> = (props) => {\n return createComponent(\"Sprite\", props);\n};\n","import { effect, signal, type WritableSignal } from \"@signe/reactive\";\nimport { animate as animatePopmotion } from \"popmotion\";\n\nexport interface AnimateOptions<T> {\n duration?: number;\n ease?: (t: number) => number;\n onUpdate?: (value: T) => void;\n onComplete?: () => void;\n}\n\nexport interface AnimatedState<T> {\n current: T;\n start: T;\n end: T;\n}\n\nexport interface AnimatedSignal<T> extends Omit<WritableSignal<T>, 'set'> {\n (): T;\n set: (newValue: T, options?: AnimateOptions<T>) => Promise<void>;\n animatedState: WritableSignal<AnimatedState<T>>;\n update: (updater: (value: T) => T) => void;\n}\n\nexport function isAnimatedSignal(signal: WritableSignal<any>): boolean {\n return (signal as unknown as AnimatedSignal<any>).animatedState !== undefined;\n}\n\n/**\n * Creates an animated signal with the given initial value and animation options.\n * It's a writable signal that can be animated using popmotion. Properties of the animated signal are:\n * - current: the current value of the signal.\n * - start: the start value of the animation.\n * - end: the end value of the animation.\n * \n * @param initialValue The initial value of the signal.\n * @param options The animation options.\n * @returns The animated signal.\n * @example\n * const animatedValue = animatedSignal(0, { duration: 1000 });\n * animatedValue.set(10);\n * animatedValue.update((value) => value + 1);\n * console.log(animatedValue()); // 11\n * \n * animatedValue.animatedState() // { current: 10, start: 10, end: 11 }\n */\nexport function animatedSignal<T>(initialValue: T, options: AnimateOptions<T> = {}): AnimatedSignal<T> {\n const state: AnimatedState<T> = {\n current: initialValue,\n start: initialValue,\n end: initialValue,\n };\n let animation\n\n const publicSignal = signal(initialValue);\n const privateSignal = signal(state);\n\n effect(() => {\n const currentState = privateSignal();\n publicSignal.set(currentState.current);\n });\n\n function animatedSignal(): AnimatedState<T>;\n function animatedSignal(newValue: T): void;\n function animatedSignal(newValue: T, animationConfig: AnimateOptions<T>): void;\n function animatedSignal(newValue?: T, animationConfig: AnimateOptions<T> = {}): AnimatedState<T> | void {\n if (newValue === undefined) {\n return privateSignal();\n }\n \n const prevState = privateSignal();\n const newState: AnimatedState<T> = {\n current: prevState.current,\n start: prevState.current,\n end: newValue,\n };\n\n privateSignal.set(newState);\n\n if (animation) {\n animation.stop();\n }\n\n animation = animatePopmotion({\n // TODO\n duration: 20,\n ...options,\n ...animationConfig,\n from: prevState.current,\n to: newValue,\n onUpdate: (value) => {\n privateSignal.update(s => ({ ...s, current: value as T }));\n if (options.onUpdate) {\n options.onUpdate(value as T);\n }\n },\n });\n }\n\n const fn = function() {\n return privateSignal().current\n }\n\n for (const key in publicSignal) {\n fn[key] = publicSignal[key]\n }\n\n fn.animatedState = privateSignal\n fn.update = (updater: (value: T) => any) => {\n animatedSignal(updater(privateSignal().current));\n }\n fn.set = async (newValue: T, animationConfig: AnimateOptions<T> = {}) => {\n return new Promise<void>((resolve) => {\n animatedSignal(newValue, {\n ...animationConfig,\n onComplete: resolve\n });\n })\n }\n\n return fn as any\n}\n\n/**\n * Executes a sequence of animations. If an array is provided as an element in the sequence,\n * those animations will be executed in parallel.\n * \n * @param sequence Array of animation functions or arrays of animation functions for parallel execution\n * @returns Promise that resolves when all animations are complete\n * @example\n * ```ts\n * await animatedSequence([\n * () => value1.set(10),\n * [\n * () => value2.set(20),\n * () => value3.set(30)\n * ],\n * () => value1.set(0)\n * ])\n * ```\n */\nexport async function animatedSequence(sequence: ((() => Promise<void>) | (() => Promise<void>)[])[]) {\n for (const item of sequence) {\n if (Array.isArray(item)) {\n await Promise.all(item.map(fn => fn()));\n } else {\n await item();\n }\n }\n}","import { Texture } from \"pixi.js\";\nimport { h, mount } from \"../engine/signal\";\nimport { useDefineProps } from \"../hooks/useProps\";\nimport { Sprite } from \"./Sprite\";\nimport { effect, Signal, signal } from \"@signe/reactive\";\n\ninterface VideoProps {\n src: string;\n paused?: boolean;\n loop?: boolean;\n muted?: boolean;\n loader?: {\n onComplete?: (texture: Texture) => void;\n onProgress?: (progress: number) => void;\n };\n}\n\nexport function Video(props: VideoProps) {\n const eventsMap = {\n audioprocess: null,\n canplay: null,\n canplaythrough: null,\n complete: null,\n durationchange: null,\n emptied: null,\n ended: null,\n loadeddata: null,\n loadedmetadata: null,\n pause: null,\n play: null,\n playing: null,\n progress: null,\n ratechange: null,\n seeked: null,\n seeking: null,\n stalled: null,\n suspend: null,\n timeupdate: null,\n volumechange: null,\n waiting: null\n }\n\n const video: Signal<HTMLVideoElement | null> = signal(null)\n const defineProps = useDefineProps(props)\n const { play, loop, muted } = defineProps({\n play: {\n type: Boolean,\n default: true\n },\n loop: {\n type: Boolean,\n default: false\n },\n muted: {\n type: Boolean,\n default: false\n }\n })\n\n effect(() => {\n const _video = video()\n const state = play()\n if (_video && state !== undefined) {\n if (state) {\n _video.play()\n } else {\n _video.pause()\n }\n }\n if (_video && loop()) {\n _video.loop = loop()\n }\n if (_video && muted()) {\n _video.muted = muted()\n }\n })\n\n mount(() => {\n return () => {\n for (let event in eventsMap) {\n if (eventsMap[event]) {\n video().removeEventListener(event, eventsMap[event])\n }\n }\n }\n })\n\n return h(Sprite, {\n ...props,\n image: props.src,\n loader: {\n onComplete: (texture) => {\n const source = texture.source.resource\n video.set(source)\n if (props?.loader?.onComplete) {\n props.loader.onComplete(texture)\n }\n for (let event in eventsMap) {\n if (props[event]) {\n const cb = (ev) => {\n props[event](ev)\n }\n eventsMap[event] = cb\n source.addEventListener(event, cb)\n }\n }\n }\n }\n })\n}","import { Text as PixiText, TextStyle } from \"pixi.js\";\nimport { createComponent, registerComponent, Element, Props } from \"../engine/reactive\";\nimport { DisplayObject, ComponentInstance } from \"./DisplayObject\";\nimport { DisplayObjectProps } from \"./types/DisplayObject\";\nimport { Signal } from \"@signe/reactive\";\nimport { on, isTrigger } from \"../engine/trigger\";\n\nenum TextEffect {\n Typewriter = \"typewriter\",\n}\n\nexport interface TextProps extends DisplayObjectProps {\n text?: string;\n style?: Partial<TextStyle>;\n color?: string;\n size?: string;\n fontFamily?: string;\n typewriter?: {\n speed?: number;\n start?: () => void;\n onComplete?: () => void;\n skip?: () => void;\n };\n context?: any; // Ensure context is available, ideally typed from a base prop or injected\n}\n\nclass CanvasText extends DisplayObject(PixiText) {\n private subscriptionTick: any;\n private fullText: string = \"\";\n private currentIndex: number = 0;\n private typewriterSpeed: number = 1; // Default speed\n private _wordWrapWidth: number = 0;\n private typewriterOptions: any = {};\n private skipSignal?: () => void;\n\n /**\n * Called when the component is mounted to the scene graph.\n * Initializes the typewriter effect if configured.\n * @param {Element<CanvasText>} element - The element being mounted with parent and props.\n * @param {number} [index] - The index of the component among its siblings.\n */\n async onMount(element: Element<CanvasText>, index?: number): Promise<void> {\n const { props } = element;\n await super.onMount(element, index);\n const tick: Signal = props.context.tick;\n\n if (props.text && props.typewriter) {\n this.fullText = props.text;\n this.text = \"\";\n this.currentIndex = 0;\n // Set typewriter options\n if (props.typewriter) {\n this.typewriterOptions = props.typewriter;\n if (this.typewriterOptions.skip && isTrigger(this.typewriterOptions.skip)) {\n on(this.typewriterOptions.skip, () => {\n this.skipTypewriter();\n });\n }\n }\n }\n this.subscriptionTick = tick.observable.subscribe(() => {\n if (props.typewriter) {\n this.typewriterEffect();\n }\n });\n }\n\n onUpdate(props: TextProps) {\n super.onUpdate(props);\n if (props.typewriter) {\n if (props.typewriter) {\n this.typewriterOptions = props.typewriter;\n }\n }\n if (props.text !== undefined) {\n this.text = ''+props.text;\n }\n if (props.text !== undefined && props.text !== this.fullText && this.fullProps.typewriter) {\n this.text = \"\";\n this.currentIndex = 0;\n this.fullText = props.text;\n }\n if (props.style) {\n for (const key in props.style) {\n this.style[key] = props.style[key];\n }\n if (props.style.wordWrapWidth) {\n this._wordWrapWidth = props.style.wordWrapWidth;\n }\n }\n if (props.color) {\n this.style.fill = props.color;\n }\n if (props.size) {\n this.style.fontSize = props.size;\n }\n if (props.fontFamily) {\n this.style.fontFamily = props.fontFamily;\n }\n if (this._wordWrapWidth) {\n this.setWidth(this._wordWrapWidth);\n } else {\n this.setWidth(this.width);\n }\n this.setHeight(this.height);\n }\n\n get onCompleteCallback() {\n return this.typewriterOptions.onComplete;\n }\n\n private typewriterEffect() {\n if (this.currentIndex < this.fullText.length) {\n const nextIndex = Math.min(\n this.currentIndex + (this.typewriterOptions.speed ?? 1),\n this.fullText.length\n );\n this.text = this.fullText.slice(0, nextIndex);\n this.currentIndex = nextIndex;\n\n // Check if typewriter effect is complete\n if (\n this.currentIndex === this.fullText.length &&\n this.onCompleteCallback\n ) {\n this.onCompleteCallback();\n }\n }\n }\n\n // Add a method to skip the typewriter effect\n private skipTypewriter() {\n if (this.skipSignal) {\n this.skipSignal();\n }\n this.text = this.fullText;\n this.currentIndex = this.fullText.length;\n }\n\n /**\n * Called when the component is about to be destroyed.\n * Unsubscribes from the tick observable.\n * @param {Element<any>} parent - The parent element.\n * @param {() => void} [afterDestroy] - An optional callback function to be executed after the component's own destruction logic.\n */\n async onDestroy(parent: Element<any>, afterDestroy?: () => void): Promise<void> {\n const _afterDestroy = async () => {\n if (this.subscriptionTick) {\n this.subscriptionTick.unsubscribe();\n }\n if (afterDestroy) {\n afterDestroy();\n }\n }\n await super.onDestroy(parent, _afterDestroy);\n }\n}\n\n// interface CanvasText extends PixiText {} // Removed as it's redundant and causes type conflicts\n\nregisterComponent(\"Text\", CanvasText);\n\nexport function Text(props: TextProps) {\n return createComponent(\"Text\", props);\n}\n","import { effect, signal } from \"@signe/reactive\";\n\ninterface Listen<T = any> {\n config: T | undefined;\n seed: {\n config: T | undefined;\n value: number;\n resolve: (value: any) => void;\n };\n}\n\ninterface Trigger<T = any> {\n start: () => Promise<void>;\n listen: () => Listen<T> | undefined;\n}\n\n/**\n * Checks if the given argument is a Trigger object\n * @param arg - The value to check\n * @returns True if the argument is a Trigger object\n */\nexport function isTrigger(arg: any): arg is Trigger<any> {\n return arg?.start && arg?.listen;\n}\n\n/**\n * Creates a new trigger that can be used to pass data between components\n * @param globalConfig - Optional configuration data to be passed when the trigger is activated\n * @returns A Trigger object with start and listen methods\n * @example\n * ```ts\n * const myTrigger = trigger()\n * \n * on(myTrigger, (data) => {\n * console.log('Triggered with data:', data)\n * })\n * \n * myTrigger.start({ message: 'Hello' })\n * ```\n */\nexport function trigger<T = any>(globalConfig?: T): Trigger<T> {\n const _signal = signal({\n config: globalConfig,\n value: 0,\n resolve: (value: any) => void 0,\n });\n return {\n start: (config?: T) => {\n return new Promise((resolve: (value: any) => void) => {\n _signal.set({\n config: {\n ...globalConfig,\n ...config,\n },\n resolve,\n value: Math.random(),\n });\n });\n },\n listen: (): Listen<T> | undefined => {\n return {\n config: globalConfig,\n seed: _signal(),\n };\n },\n };\n}\n\n/**\n * Subscribes to a trigger and executes a callback when the trigger is activated\n * @param triggerSignal - The trigger to subscribe to\n * @param callback - Function to execute when the trigger is activated\n * @throws Error if triggerSignal is not a valid trigger\n * @example\n * ```ts\n * const click = trigger()\n * \n * on(click, () => {\n * console.log('Click triggered')\n * })\n * ```\n */\nexport function on(triggerSignal: any, callback: (config: any) => void | Promise<void>) {\n if (!isTrigger(triggerSignal)) {\n throw new Error(\"In 'on(arg)' must have a trigger signal type\");\n }\n effect(() => {\n const result = triggerSignal.listen();\n if (result?.seed.value) {\n const ret = callback(result?.seed.config);\n if (ret && typeof ret.then === 'function') {\n ret.then(result?.seed.resolve);\n }\n }\n });\n}\n","import { TilingSprite as PixiTilingSprite, Texture } from 'pixi.js';\nimport { createComponent, registerComponent } from '../engine/reactive';\nimport { DisplayObject } from './DisplayObject';\nimport { DisplayObjectProps } from './types/DisplayObject';\n\ninterface TilingSpriteProps extends DisplayObjectProps {\n image?: string;\n tileScale?: { x: number; y: number };\n tilePosition?: { x: number; y: number };\n width?: number;\n height?: number;\n}\n\nclass CanvasTilingSprite extends DisplayObject(PixiTilingSprite) {\n onUpdate(props: TilingSpriteProps): void {\n super.onUpdate(props);\n if (props.image) {\n this.texture = Texture.from(props.image);\n }\n if (props.tileScale) {\n this.tileScale.set(props.tileScale.x, props.tileScale.y);\n }\n if (props.tilePosition) {\n this.tilePosition.set(props.tilePosition.x, props.tilePosition.y);\n }\n if (props.width !== undefined) {\n this.width = props.width;\n }\n if (props.height !== undefined) {\n this.height = props.height;\n }\n }\n}\n\nregisterComponent('TilingSprite', CanvasTilingSprite)\n\nexport function TilingSprite(props: TilingSpriteProps) {\n return createComponent('TilingSprite', props)\n}","import { Viewport as PixiViewport } from 'pixi-viewport';\nimport { Subscription } from 'rxjs';\nimport { createComponent, registerComponent, Element, Props } from '../engine/reactive';\nimport { DisplayObject, ComponentInstance } from './DisplayObject';\nimport { effect, Signal } from '@signe/reactive';\n\nconst EVENTS = [\n 'bounce-x-end',\n 'bounce-x-start',\n 'bounce-y-end',\n 'bounce-y-start',\n 'clicked',\n 'drag-end',\n 'drag-start',\n 'frame-end',\n 'mouse-edge-end',\n 'mouse-edge-start',\n 'moved',\n 'moved-end',\n 'pinch-end',\n 'pinch-start',\n 'snap-end',\n 'snap-start',\n 'snap-zoom-end',\n 'snap-zoom-start',\n 'wheel-scroll',\n 'zoomed',\n 'zoomed-end'\n]\n\nexport interface ViewportProps extends Props {\n screenWidth?: number;\n screenHeight?: number;\n worldWidth?: number;\n worldHeight?: number;\n clamp?: boolean | {\n left?: number;\n right?: number;\n top?: number;\n bottom?: number;\n };\n context?: any;\n [key: string]: any;\n}\n\nexport class CanvasViewport extends DisplayObject(PixiViewport) {\n private tickSubscription: Subscription\n overrideProps = ['wheel']\n\n constructor() {\n const defaultOptions = {\n noTicker: true,\n events: {\n domElement: {\n addEventListener: () => {}\n }\n },\n }\n // @ts-ignore\n super(defaultOptions) \n }\n\n onInit(props) {\n super.onInit(props)\n for (let event of EVENTS) {\n if (props[event]) this.on(event, props[event])\n }\n }\n\n /**\n * Called when the component is mounted to the scene graph.\n * Initializes viewport settings and subscriptions.\n * @param {Element<CanvasViewport>} element - The element being mounted. Its `props` property (of type ViewportProps) contains component properties and context.\n * @param {number} [index] - The index of the component among its siblings.\n */\n async onMount(element: Element<CanvasViewport>, index?: number): Promise<void> {\n await super.onMount(element, index);\n const { props } = element;\n const { tick, app, canvasSize } = props.context;\n let isDragging = false\n \n effect(() => {\n this.screenWidth = canvasSize().width\n this.screenHeight = canvasSize().height\n })\n\n effect(() => {\n const _app = app()\n if (!_app) return\n\n const renderer = _app.renderer\n \n renderer.events.domElement.addEventListener(\n 'wheel',\n this.input.wheelFunction\n );\n\n this.options.events = renderer.events\n })\n \n this.tickSubscription = tick.observable.subscribe(({ value }) => {\n this.update(value.timestamp)\n })\n\n element.props.context.viewport = this\n this.updateViewportSettings(props)\n }\n\n onUpdate(props) {\n super.onUpdate(props)\n this.updateViewportSettings(props)\n }\n\n private updateViewportSettings(props) {\n if (props.screenWidth !== undefined) {\n this.screenWidth = props.screenWidth\n }\n if (props.screenHeight !== undefined) {\n this.screenHeight = props.screenHeight\n }\n if (props.worldWidth !== undefined) {\n this.worldWidth = props.worldWidth\n }\n if (props.worldHeight !== undefined) {\n this.worldHeight = props.worldHeight\n }\n if (props.drag) {\n this.drag(props.drag)\n }\n if (props.clamp) {\n this.clamp(props.clamp.value ?? props.clamp)\n }\n if (props.wheel) {\n if (props.wheel === true) {\n this.wheel()\n } else {\n this.wheel(props.wheel)\n }\n }\n if (props.decelerate) {\n if (props.decelerate === true) {\n this.decelerate()\n } else {\n this.decelerate(props.decelerate)\n }\n }\n if (props.pinch) {\n if (props.pinch === true) {\n this.pinch()\n } else {\n this.pinch(props.pinch)\n }\n }\n }\n\n /**\n * Called when the component is about to be destroyed.\n * Unsubscribes from the tick observable.\n * @param {Element<any>} parent - The parent element.\n * @param {() => void} [afterDestroy] - An optional callback function to be executed after the component's own destruction logic.\n */\n async onDestroy(parent: Element<any>, afterDestroy?: () => void): Promise<void> {\n const _afterDestroy = async () => {\n this.tickSubscription.unsubscribe()\n afterDestroy()\n }\n await super.onDestroy(parent, _afterDestroy);\n }\n}\n\nregisterComponent('Viewport', CanvasViewport)\n\nexport function Viewport(props: ViewportProps) {\n return createComponent('Viewport', props);\n}","import { Assets, NineSliceSprite as PixiNineSliceSprite, Texture } from \"pixi.js\";\nimport { createComponent, registerComponent } from \"../engine/reactive\";\nimport { DisplayObject } from \"./DisplayObject\";\nimport { DisplayObjectProps } from \"./types/DisplayObject\";\nimport { Layout } from \"@pixi/layout\";\n\ninterface NineSliceSpriteProps extends DisplayObjectProps {\n image?: string;\n texture?: Texture;\n width?: number;\n height?: number;\n leftWidth?: number;\n rightWidth?: number;\n topHeight?: number;\n bottomHeight?: number;\n roundPixels?: boolean;\n}\n\nclass CanvasNineSliceSprite extends DisplayObject(PixiNineSliceSprite) {\n constructor() {\n // @ts-ignore\n super({\n width: 0,\n height: 0\n });\n }\n\n async onUpdate(props: NineSliceSpriteProps) {\n for (const [key, value] of Object.entries(props)) {\n if (value !== undefined) {\n if (key === 'image') {\n this.texture = await Assets.load(value);\n } else if (key in this) {\n (this as any)[key] = value;\n }\n }\n }\n }\n}\n\ninterface CanvasNineSliceSprite extends PixiNineSliceSprite {\n layout: Layout | null;\n}\n\nregisterComponent(\"NineSliceSprite\", CanvasNineSliceSprite);\n\nexport function NineSliceSprite(props: NineSliceSpriteProps) {\n return createComponent(\"NineSliceSprite\", props);\n}\n","import { DOMContainer as PixiDOMContainer } from \"pixi.js\";\nimport {\n createComponent,\n Element,\n registerComponent,\n} from \"../engine/reactive\";\nimport { ComponentInstance, DisplayObject } from \"./DisplayObject\";\nimport { ComponentFunction, h } from \"../engine/signal\";\nimport { DisplayObjectProps } from \"./types/DisplayObject\";\nimport { CanvasDOMElement, DOMElement } from \"./DOMElement\";\n\n\n/**\n * DOMContainer class for managing DOM elements within the canvas engine\n *\n * This class extends the DisplayObject functionality to handle DOM elements using\n * PixiJS's native DOMContainer. It provides a bridge between the canvas rendering\n * system and traditional DOM manipulation with proper transform hierarchy and visibility.\n *\n * The DOMContainer is especially useful for rendering standard DOM elements that handle\n * user input, such as `<input>` or `<textarea>`. This is often simpler and more flexible\n * than trying to implement text input directly in PixiJS.\n *\n * @example\n * ```typescript\n * // Basic usage with input element\n * const element = document.createElement('input');\n * element.type = 'text';\n * element.placeholder = 'Enter text...';\n *\n * const domContainer = new DOMContainer({\n * element,\n * x: 100,\n * y: 50,\n * anchor: { x: 0.5, y: 0.5 }\n * });\n *\n * // Using different class and style formats\n * const containerWithClasses = new DOMContainer({\n * element: 'div',\n * attrs: {\n * // String format: space-separated classes\n * class: 'container primary-theme',\n *\n * // Array format: array of class names\n * // class: ['container', 'primary-theme'],\n *\n * // Object format: conditional classes\n * // class: {\n * // 'container': true,\n * // 'primary-theme': true,\n * // 'disabled': false\n * // }\n *\n * // String format: CSS style string\n * style: 'background-color: red; padding: 10px;',\n *\n * // Object format: style properties\n * // style: {\n * // backgroundColor: 'red',\n * // padding: '10px',\n * // fontSize: 16\n * // }\n * }\n * });\n * ```\n */\nconst EVENTS = [\n \"click\",\n \"mouseover\",\n \"mouseout\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"mouseup\",\n \"mousedown\",\n \"touchstart\",\n \"touchend\",\n \"touchmove\",\n \"touchcancel\",\n \"wheel\",\n \"scroll\",\n \"resize\",\n \"focus\",\n \"blur\",\n \"change\",\n \"input\",\n \"submit\",\n \"reset\",\n \"keydown\",\n \"keyup\",\n \"keypress\",\n \"contextmenu\",\n \"drag\",\n \"dragend\",\n \"dragenter\",\n \"dragleave\",\n \"dragover\",\n \"drop\",\n \"dragstart\",\n \"select\",\n \"selectstart\",\n \"selectend\",\n \"selectall\",\n \"selectnone\",\n];\n\nexport class CanvasDOMContainer extends DisplayObject(PixiDOMContainer) {\n disableLayout = true;\n\n onInit(props: any) {\n const div = h(DOMElement, { element: \"div\" }, props.children) as unknown as Element<CanvasDOMElement>;\n this.element = div.componentInstance.element;\n }\n}\n\nexport interface CanvasDOMContainer extends DisplayObjectProps {}\n\nregisterComponent(\"DOMContainer\", CanvasDOMContainer);\n\nexport const DOMContainer: ComponentFunction<any> = (props) => {\n return createComponent(\"DOMContainer\", props);\n};\n","import { DOMContainer as PixiDOMContainer } from \"pixi.js\";\nimport {\n createComponent,\n Element,\n registerComponent,\n} from \"../engine/reactive\";\nimport { ComponentInstance, DisplayObject, OnHook } from \"./DisplayObject\";\nimport { ComponentFunction } from \"../engine/signal\";\nimport { DisplayObjectProps } from \"./types/DisplayObject\";\nimport { isObservable } from \"../engine/utils\";\nimport { isSignal } from \"@signe/reactive\";\n\ninterface DOMContainerProps extends DisplayObjectProps {\n element:\n | string\n | {\n value: HTMLElement;\n };\n textContent?: string;\n attrs?: Record<string, any> & {\n class?:\n | string\n | string[]\n | Record<string, boolean>\n | { items?: string[] }\n | { value?: string | string[] | Record<string, boolean> };\n style?:\n | string\n | Record<string, string | number>\n | { value?: string | Record<string, string | number> };\n };\n onBeforeDestroy?: OnHook;\n}\n\n/**\n * DOMContainer class for managing DOM elements within the canvas engine\n *\n * This class extends the DisplayObject functionality to handle DOM elements using\n * PixiJS's native DOMContainer. It provides a bridge between the canvas rendering\n * system and traditional DOM manipulation with proper transform hierarchy and visibility.\n *\n * The DOMContainer is especially useful for rendering standard DOM elements that handle\n * user input, such as `<input>` or `<textarea>`. This is often simpler and more flexible\n * than trying to implement text input directly in PixiJS.\n *\n * ## Form Elements with Reactive Signals\n *\n * For form elements (`input`, `textarea`, `select`), the component supports reactive\n * two-way data binding using signals. When the `value` attribute is a signal, the\n * component automatically:\n * - Sets the initial value from the signal\n * - Listens for `input` events and updates the signal with the new value\n * - Updates the DOM element when the signal value changes programmatically\n *\n * ## Form Submission Handling\n *\n * When a `form` element has a `submit` event handler, the component automatically:\n * - Prevents the default form submission behavior (stops propagation)\n * - Collects all form data from input elements within the form\n * - Passes both the event and the collected form data as parameters to the submit handler\n * - Handles multiple values for the same field name (e.g., checkboxes with same name)\n *\n * @example\n * ```typescript\n * import { signal } from '@signe/reactive';\n *\n * // Basic usage with input element\n * const element = document.createElement('input');\n * element.type = 'text';\n * element.placeholder = 'Enter text...';\n *\n * const domContainer = new DOMContainer({\n * element,\n * x: 100,\n * y: 50,\n * anchor: { x: 0.5, y: 0.5 }\n * });\n *\n * // Reactive form input with signal\n * const inputValue = signal('');\n *\n * const reactiveInput = new DOMContainer({\n * element: 'input',\n * attrs: {\n * type: 'text',\n * placeholder: 'Type something...',\n * value: inputValue // Signal for two-way binding\n * }\n * });\n *\n * // The signal will automatically update when user types\n * inputValue.subscribe(value => {\n * console.log('Input value changed:', value);\n * });\n *\n * // You can also update the input programmatically\n * inputValue.set('New value');\n *\n * // Form submission with automatic data collection\n * const loginForm = new DOMContainer({\n * element: 'form',\n * attrs: {\n * submit: (event, formData) => {\n * // event: the submit event (already prevented)\n * // formData: object containing all form field values\n * console.log('Form submitted with data:', formData);\n * // Example formData: { username: 'john', password: 'secret', remember: 'on' }\n * }\n * },\n * children: [\n * new DOMContainer({\n * element: 'input',\n * attrs: { name: 'username', type: 'text', placeholder: 'Username' }\n * }),\n * new DOMContainer({\n * element: 'input',\n * attrs: { name: 'password', type: 'password', placeholder: 'Password' }\n * }),\n * new DOMContainer({\n * element: 'input',\n * attrs: { name: 'remember', type: 'checkbox', value: 'on' }\n * }),\n * new DOMContainer({\n * element: 'button',\n * attrs: { type: 'submit' },\n * textContent: 'Login'\n * })\n * ]\n * });\n *\n * // Using different class and style formats\n * const containerWithClasses = new DOMContainer({\n * element: 'div',\n * attrs: {\n * // String format: space-separated classes\n * class: 'container primary-theme',\n *\n * // Array format: array of class names\n * // class: ['container', 'primary-theme'],\n *\n * // Object format: conditional classes\n * // class: {\n * // 'container': true,\n * // 'primary-theme': true,\n * // 'disabled': false\n * // }\n *\n * // String format: CSS style string\n * style: 'background-color: red; padding: 10px;',\n *\n * // Object format: style properties\n * // style: {\n * // backgroundColor: 'red',\n * // padding: '10px',\n * // fontSize: 16\n * // }\n * }\n * });\n * ```\n */\nconst EVENTS = [\n \"click\",\n \"mouseover\",\n \"mouseout\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"mouseup\",\n \"mousedown\",\n \"touchstart\",\n \"touchend\",\n \"touchmove\",\n \"touchcancel\",\n \"wheel\",\n \"scroll\",\n \"resize\",\n \"focus\",\n \"blur\",\n \"change\",\n \"input\",\n \"submit\",\n \"reset\",\n \"keydown\",\n \"keyup\",\n \"keypress\",\n \"contextmenu\",\n \"drag\",\n \"dragend\",\n \"dragenter\",\n \"dragleave\",\n \"dragover\",\n \"drop\",\n \"dragstart\",\n \"select\",\n \"selectstart\",\n \"selectend\",\n \"selectall\",\n \"selectnone\",\n];\n\nexport class CanvasDOMElement {\n public element: HTMLElement;\n private eventListeners: Map<string, (e: Event) => void> = new Map();\n private onBeforeDestroy: OnHook | null = null;\n private valueSignal: any = null;\n private isFormElementType: boolean = false;\n\n /**\n * Checks if the element is a form element that supports the value attribute\n * @param elementType - The element type string from props\n * @returns true if the element is a form element with value support\n */\n private isFormElement(elementType: string): boolean {\n const formElements = [\"input\", \"textarea\", \"select\"];\n return formElements.includes(elementType.toLowerCase());\n }\n\n onInit(props: DOMContainerProps) {\n if (typeof props.element === \"string\") {\n this.element = document.createElement(props.element);\n this.isFormElementType = this.isFormElement(props.element);\n } else {\n this.element = props.element.value;\n this.isFormElementType = this.isFormElement(this.element.tagName);\n }\n if (props.onBeforeDestroy || props[\"on-before-destroy\"]) {\n this.onBeforeDestroy =\n props.onBeforeDestroy || props[\"on-before-destroy\"];\n }\n\n for (const event of EVENTS) {\n if (props.attrs?.[event]) {\n const eventHandler = (e: Event) => {\n // Special handling for form submit events\n if (event === \"submit\" && this.element.tagName.toLowerCase() === \"form\") {\n e.preventDefault(); // Stop form submission propagation\n \n // Collect all form data\n const formData = new FormData(this.element as HTMLFormElement);\n const formObject: Record<string, any> = {};\n \n // Convert FormData to plain object\n formData.forEach((value, key) => {\n if (formObject[key]) {\n // Handle multiple values for same key (like checkboxes)\n if (Array.isArray(formObject[key])) {\n formObject[key].push(value);\n } else {\n formObject[key] = [formObject[key], value];\n }\n } else {\n formObject[key] = value;\n }\n });\n \n // Call the event handler with event and form data\n props.attrs[event]?.(e, formObject);\n } else {\n props.attrs[event]?.(e);\n }\n };\n this.eventListeners.set(event, eventHandler);\n this.element.addEventListener(event, eventHandler, false);\n }\n }\n if (props.children) {\n for (const child of props.children) {\n if (isObservable(child)) {\n child.subscribe(({ elements }) => {\n for (const element of elements) {\n this.element.appendChild(element.componentInstance.element);\n }\n });\n } else {\n this.element.appendChild(child.componentInstance.element);\n }\n }\n }\n this.onUpdate(props);\n }\n\n onMount(context: Element<CanvasDOMElement>) {\n const props = context.propObservables;\n const attrs = props.attrs as any;\n // Handle form elements with signal value\n if (\n this.isFormElementType &&\n attrs?.value &&\n isSignal(attrs.value)\n ) {\n this.valueSignal = attrs.value;\n // Set initial value from signal\n (\n this.element as\n | HTMLInputElement\n | HTMLTextAreaElement\n | HTMLSelectElement\n ).value = this.valueSignal();\n\n // Listen for input events and update the signal\n const inputHandler = (e: Event) => {\n const target = e.target as\n | HTMLInputElement\n | HTMLTextAreaElement\n | HTMLSelectElement;\n this.valueSignal.set(target.value);\n };\n\n this.eventListeners.set(\"input\", inputHandler);\n this.element.addEventListener(\"input\", inputHandler, false);\n }\n }\n\n onUpdate(props: DOMContainerProps) {\n if (!this.element) return;\n for (const [key, value] of Object.entries(props.attrs || {})) {\n if (key === \"class\") {\n const classList = value.items || value.value || value;\n\n // Clear existing classes first\n this.element.className = \"\";\n\n if (typeof classList === \"string\") {\n // String: space-separated class names\n this.element.className = classList;\n } else if (Array.isArray(classList)) {\n // Array: array of class names\n this.element.classList.add(...classList);\n } else if (typeof classList === \"object\" && classList !== null) {\n // Object: { className: boolean }\n for (const [className, shouldAdd] of Object.entries(classList)) {\n if (shouldAdd) {\n this.element.classList.add(className);\n }\n }\n }\n } else if (key === \"style\") {\n const styleValue = value.items || value.value || value;\n\n if (typeof styleValue === \"string\") {\n // String: CSS style string\n this.element.setAttribute(\"style\", styleValue);\n } else if (typeof styleValue === \"object\" && styleValue !== null) {\n // Object: { property: value }\n for (const [styleProp, styleVal] of Object.entries(styleValue)) {\n if (styleVal !== null && styleVal !== undefined) {\n (this.element.style as any)[styleProp] = styleVal;\n }\n }\n }\n } else if (key === \"value\" && this.isFormElementType) {\n // Handle value attribute for form elements\n if (isSignal(value)) {\n // If it's a signal, the value is already handled in onInit\n // Update the DOM element value if the signal value changed\n const currentValue = (\n this.element as\n | HTMLInputElement\n | HTMLTextAreaElement\n | HTMLSelectElement\n ).value;\n const signalValue = value();\n if (currentValue !== signalValue) {\n (\n this.element as\n | HTMLInputElement\n | HTMLTextAreaElement\n | HTMLSelectElement\n ).value = signalValue;\n }\n } else {\n // If it's not a signal, set the value directly\n (\n this.element as\n | HTMLInputElement\n | HTMLTextAreaElement\n | HTMLSelectElement\n ).value = value;\n }\n } else if (!EVENTS.includes(key)) {\n this.element.setAttribute(key, value);\n }\n }\n if (props.textContent) {\n this.element.textContent = props.textContent;\n }\n }\n\n async onDestroy(\n parent: Element<CanvasDOMElement>,\n afterDestroy: () => void\n ): Promise<void> {\n // Remove all event listeners from the DOM element\n\n if (this.element) {\n if (this.onBeforeDestroy) {\n await this.onBeforeDestroy();\n }\n\n for (const [event, handler] of this.eventListeners) {\n this.element.removeEventListener(event, handler, false);\n }\n\n this.eventListeners.clear();\n\n this.element.remove();\n\n if (afterDestroy) {\n afterDestroy();\n }\n }\n }\n}\n\nexport interface CanvasDOMElement extends DisplayObjectProps {}\n\nregisterComponent(\"DOMElement\", CanvasDOMElement);\n\nexport const DOMElement: ComponentFunction<DOMContainerProps> = (props) => {\n return createComponent(\"DOMElement\", props);\n};\n","import '@pixi/layout';\nimport { Application, ApplicationOptions } from \"pixi.js\";\nimport { ComponentFunction, h } from \"./signal\";\nimport { useProps } from '../hooks/useProps';\n\n/**\n * Bootstraps a canvas element and renders it to the DOM.\n * \n * @param rootElement - The HTML element where the canvas will be rendered. Can be null.\n * @param canvas - A Promise that resolves to an Element representing the canvas component.\n * @returns A Promise that resolves to the rendered canvas element.\n * @throws {Error} If the provided element is not a Canvas component.\n */\nexport const bootstrapCanvas = async (rootElement: HTMLElement | null, canvas: ComponentFunction<any>, options?: ApplicationOptions) => {\n \n const app = new Application();\n await app.init({\n resizeTo: rootElement,\n autoStart: false,\n ...(options ?? {})\n });\n const canvasElement = await h(canvas);\n if (canvasElement.tag != 'Canvas') {\n throw new Error('Canvas is required');\n }\n (canvasElement as any).render(rootElement, app);\n\n const { backgroundColor } = useProps(canvasElement.props, {\n backgroundColor: 'black'\n });\n\n app.renderer.background.color = backgroundColor()\n\n return {\n canvasElement,\n app\n };\n};\n","import { \n linear,\n easeIn,\n easeInOut,\n easeOut,\n circIn,\n circInOut,\n circOut,\n backIn,\n backInOut,\n backOut,\n anticipate,\n bounceIn,\n bounceInOut,\n bounceOut\n} from \"popmotion\"\n\nexport const Easing = {\n linear,\n easeIn,\n easeInOut,\n easeOut,\n circIn,\n circInOut,\n circOut,\n backIn,\n backInOut,\n backOut,\n anticipate,\n bounceIn,\n bounceInOut,\n bounceOut\n}","import { Texture, ImageSource, DOMAdapter, Matrix } from \"pixi.js\";\n\n/**\n * Creates a radial gradient texture that can be used in PixiJS.\n * @example\n * const gradient = new RadialGradient(size, size, 0, size, size, 0);\n * gradient.addColorStop(0, \"rgba(255, 255, 0, 1)\");\n * gradient.addColorStop(0.5, \"rgba(255, 255, 0, 0.3)\");\n * gradient.addColorStop(0.8, \"rgba(255, 255, 0, 0)\");\n */\nexport class RadialGradient {\n private canvas: HTMLCanvasElement;\n private ctx: CanvasRenderingContext2D | null;\n private gradient: CanvasGradient | null = null;\n private texture: Texture | null = null;\n public transform: Matrix;\n\n public size = 600;\n\n /**\n * Creates a new RadialGradient instance\n * @param x0 - The x-coordinate of the starting circle\n * @param y0 - The y-coordinate of the starting circle\n * @param x1 - The x-coordinate of the ending circle\n * @param y1 - The y-coordinate of the ending circle\n * @param x2 - The x-coordinate for gradient transformation\n * @param y2 - The y-coordinate for gradient transformation\n * @param focalPoint - The focal point of the gradient (0-1), defaults to 0\n */\n constructor(\n private x0: number,\n private y0: number,\n private x1: number,\n private y1: number,\n private x2: number,\n private y2: number,\n private focalPoint: number = 0\n ) {\n this.size = x0;\n const halfSize = this.size * 0.5;\n\n this.canvas = DOMAdapter.get().createCanvas() as any;\n this.canvas.width = this.size;\n this.canvas.height = this.size;\n this.ctx = this.canvas.getContext(\"2d\");\n\n if (this.ctx) {\n this.gradient = this.ctx.createRadialGradient(\n halfSize * (1 - focalPoint),\n halfSize,\n 0,\n halfSize,\n halfSize,\n halfSize - 0.5\n );\n }\n }\n\n /**\n * Adds a color stop to the gradient\n * @param offset - The position of the color stop (0-1)\n * @param color - The color value (any valid CSS color string)\n */\n addColorStop(offset: number, color: string) {\n if (this.gradient) {\n this.gradient.addColorStop(offset, color);\n }\n }\n\n /**\n * Renders the gradient and returns the texture with its transformation matrix\n * @param options - Render options\n * @param options.translate - Optional translation coordinates\n * @returns Object containing the texture and transformation matrix\n */\n render({ translate }: { translate?: { x: number; y: number } } = {}) {\n const { x0, y0, x1, y1, x2, y2, focalPoint } = this;\n const defaultSize = this.size;\n if (this.ctx && this.gradient) {\n this.ctx.fillStyle = this.gradient;\n this.ctx.fillRect(0, 0, defaultSize, defaultSize);\n\n this.texture = new Texture({\n source: new ImageSource({\n resource: this.canvas,\n addressModeU: \"clamp-to-edge\",\n addressModeV: \"clamp-to-edge\",\n }),\n });\n\n const m = new Matrix();\n const dx = Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));\n const dy = Math.sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0));\n const angle = Math.atan2(y1 - y0, x1 - x0);\n\n // Calculate the scale factors correctly\n const scaleX = dx / defaultSize;\n const scaleY = dy / defaultSize;\n\n // Apply transformations in the correct order\n m.rotate(-angle);\n m.scale(scaleX, scaleY);\n if (translate) {\n m.translate(translate.x, translate.y);\n }\n\n this.transform = m;\n }\n\n return {\n texture: this.texture,\n matrix: this.transform,\n };\n }\n}\n"],"mappings":"gbAEO,IAAMA,EAAqC,CAAC,EAE7BC,EAAf,KAAyB,CAKhC,EAEO,SAASC,EAAkBC,EAAcC,EAAgB,CAC5DJ,EAAWG,CAAI,EAAIC,CACvB,CAEO,SAASC,GAAeC,EAAkBC,EAAuB,CACpE,GAAI,CAACP,EAAWO,CAAa,EACzB,OAAO,KAEX,IAAMH,EAAY,IAAIJ,EAAWO,CAAa,EAC9C,OAAAH,EAAU,SAASE,CAAO,EACnBF,CACX,CCtBA,IAAAI,EAAA,GAAAC,GAAAD,EAAA,iBAAAE,EAAA,sBAAAC,EAAA,UAAAC,EAAA,WAAAC,EAAA,QAAAC,GAAA,cAAAC,EAAA,eAAAC,EAAA,aAAAC,EAAA,iBAAAC,EAAA,cAAAC,EAAA,QAAAC,GAAA,eAAAC,EAAA,QAAAC,EAAA,uBAAAC,IACA,OAAS,cAAAC,OAAkB,OAMpB,SAAST,GAAqB,CACjC,OAAO,O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F,EtBpGA,OAAS,gBAAAM,OAAoB,OAE7B,UAAYC,OAAU","names":["directives","Directive","registerDirective","name","directive","applyDirective","element","directiveName","utils_exports","__export","arrayEquals","calculateDistance","error","fps2ms","get","isBrowser","isFunction","isObject","isObservable","isPromise","log","preciseNow","set","setObservablePoint","Observable","fps","value","a","b","i","v","bv","objectEquals","keysA","keysB","key","deepEquals","val","obj","path","onlyPlainObject","len","current","segment","nextSegment","isNextNumeric","keys","text","observablePoint","point","x1","y1","x2","y2","dx","dy","keyCodeTable","inverse","obj","newObj","key","val","inverseKeyCodeTable","KeyboardControls","Directive","element","value","fps2ms","props","direction","directionControl","keyDown","boundKeys","keyName","keyState","isDown","count","repeat","parameters","keys","actionName","options","keyOptions","name","code","e","resolve","keyUp","up","down","left","right","inputName","controlName","control","input","inputs","inputsTransformed","option","bind","inputsKey","registerDirective","Scheduler","Directive","element","props","timestamp","preciseNow","fps2ms","options","requestAnimationFrame","fn","isBrowser","msInterval","now","then","loop","elapsed","registerDirective","isSignal","signal","isComputed","isSignal","signal","Observable","Subject","defer","from","map","of","share","components","isElement","value","isPrimitive","registerComponent","name","component","destroyElement","element","e","child","sub","fn","createComponent","tag","props","instance","Subject","recursiveProps","path","_set","key","set","isSignal","_value","isObject","elementsListen","propagateContext","directive","applyDirective","onMount","parent","index","resolve","lastElement","args","createElement","isPromise","Observable","comp","prev","c","loop","itemsSubject","createElementFn","isComputed","signal","defer","elements","elementMap","isFirstSubscription","isArraySignal","subscriber","change","el","items","item","newElements","i","newItem","newElement","removed","cond","condition","signalCondition","bool","_el","from","share","map","of","useProps","props","defaults","isSignal","obj","key","value","isPrimitive","signal","useDefineProps","schema","rawProps","validatedProps","propConfig","validatedValue","validateType","types","valueToCheck","type","ViewportFollow","Directive","element","viewportFollow","viewport","error","options","useProps","registerDirective","effect","Howl","EVENTS","Sound","Directive","element","props","tick","propsSound","src","autoplay","loop","volume","spatial","sources","source","sound","Howl","event","fn","soundListenerPosition","error","listenerX","listenerY","effect","x","y","distance","calculateDistance","soundProps","mute","seek","playing","rate","eventFn","SoundListenerPosition","registerDirective","effect","isComputed","isSignal","Rectangle","Point","snap","addContext","element","key","value","Drop","Directive","element","addContext","Drag","Point","rootElement","canvasSize","viewport","tick","instance","dragProps","_effect","effect","Rectangle","keysToPress","drag","options","useProps","direction","axis","event","parent","propObservables","snapTo","snap","currentParentLocalPointer","newX","newY","xProp","yProp","updatePosition","prop","value","isComputed","dependency","isSignal","globalPosition","edgeThreshold","maxSpeed","screenLeft","screenRight","screenTop","screenBottom","distanceFromLeft","distanceFromRight","distanceFromTop","distanceFromBottom","moveX","moveY","lastViewValue","keyToPress","key","parentLocalPointer","props","subscription","registerDirective","DisplacementFilter","Sprite","Texture","WRAP_MODES","animate","Transition","Directive","element","image","displacementSprite","Sprite","Texture","WRAP_MODES","displacementFilter","DisplacementFilter","instance","animate","progress","props","registerDirective","Howler","effect","signal","Container","signal","BlurFilter","ObservablePoint","isPercent","value","BehaviorSubject","EVENTS","DisplayObject","extendClass","_canvasContext","_a","__privateAdd","ObservablePoint","signal","BehaviorSubject","__privateGet","props","event","isPercent","parent","index","__privateSet","instance","error","setObservablePoint","isElement","currentFilters","blurFilter","filter","BlurFilter","options","afterDestroy","direction","wrap","align","justifyContent","position","x","y","padding","margin","gap","border","positionType","width","height","minWidth","minHeight","maxWidth","maxHeight","aspectRatio","flexGrow","flexShrink","flexBasis","rowGap","columnGap","top","left","right","bottom","objectFit","objectPosition","transformOrigin","registerComponent","DisplayObject","Container","Canvas","props","cursorStyles","width","height","className","useProps","signal","canvasSize","options","canvasElement","createComponent","rootElement","app","renderer","canvasEl","effect","existingCanvas","PixiContainer","CanvasContainer","DisplayObject","PixiContainer","props","setObservablePoint","args","componentInstance","pixiChildren","child","registerComponent","Container","createComponent","effect","isSignal","signal","Assets","PixiGraphics","CanvasGraphics","DisplayObject","PixiGraphics","props","element","index","propObservables","width","isSignal","signal","height","isWidthPercentage","isPercent","isHeightPercentage","effect","w","h","event","layoutBox","parent","afterDestroy","_afterDestroyCallback","registerComponent","Graphics","createComponent","Rect","color","borderRadius","border","useProps","g","drawShape","shape","Circle","radius","Ellipse","gWidth","gHeight","Triangle","Svg","svgData","Assets","graphics","PixiMesh","Geometry","Assets","CanvasMesh","DisplayObject","PixiMesh","Geometry","props","error","Assets","parent","afterDestroy","_afterDestroyCallback","registerComponent","Mesh","createComponent","currentSubscriptionsTracker","mountTracker","mount","fn","tick","el","context","subscription","value","h","componentFunction","props","children","allSubscriptions","allMounts","component","Scene","props","h","Container","particles","CanvasParticlesEmitter","CanvasContainer","params","props","tick","value","now","parent","afterDestroy","_afterDestroy","registerComponent","ParticlesEmitter","createComponent","Howl","computed","effect","isSignal","Assets","Container","PixiSprite","Rectangle","Texture","effect","signal","animatePopmotion","isAnimatedSignal","animatedSignal","initialValue","options","state","animation","publicSignal","privateSignal","currentState","newValue","animationConfig","prevState","newState","value","s","fn","key","updater","resolve","animatedSequence","sequence","item","log","CanvasSprite","DisplayObject","PixiSprite","options","width","height","framesHeight","framesWidth","image","offset","texture","Assets","spriteWidth","spriteHeight","frames","offsetX","offsetY","i","j","rectX","rectY","log","Texture","Rectangle","textures","animationName","optionsTextures","prev","val","rectWidth","rectHeight","params","props","propObservables","tick","sheet","value","key","isSignal","isMoving","computed","x","y","xSignal","ySignal","isMovingX","isAnimatedSignal","isMovingY","effect","_isMoving","setTexture","onProgress","progress","onComplete","isElement","parent","afterDestroy","sub","Container","name","animParams","arrayEquals","animation","cloneParams","animations","isFunction","container","sprite","frame","sound","Howl","deltaRatio","self","sprites","data","nextFrame","_sprite","applyTransformValue","prop","alias","getVal","applyTransform","realSize","heightOfSprite","widthOfSprite","applyAnchorBySize","w","gap","h","registerComponent","Sprite","createComponent","effect","signal","Video","props","eventsMap","video","defineProps","useDefineProps","play","loop","muted","_video","state","mount","event","h","Sprite","texture","source","cb","ev","PixiText","effect","signal","isTrigger","arg","trigger","globalConfig","_signal","value","config","resolve","on","triggerSignal","callback","result","ret","CanvasText","DisplayObject","PixiText","element","index","props","tick","isTrigger","on","key","nextIndex","parent","afterDestroy","_afterDestroy","registerComponent","Text","createComponent","PixiTilingSprite","Texture","CanvasTilingSprite","DisplayObject","PixiTilingSprite","props","Texture","registerComponent","TilingSprite","createComponent","PixiViewport","effect","EVENTS","CanvasViewport","DisplayObject","PixiViewport","props","event","element","index","tick","app","canvasSize","isDragging","_app","renderer","value","parent","afterDestroy","_afterDestroy","registerComponent","Viewport","createComponent","Assets","PixiNineSliceSprite","CanvasNineSliceSprite","DisplayObject","PixiNineSliceSprite","props","key","value","Assets","registerComponent","NineSliceSprite","createComponent","PixiDOMContainer","isSignal","EVENTS","CanvasDOMElement","elementType","props","event","eventHandler","e","formData","formObject","value","key","child","isObservable","elements","element","context","attrs","inputHandler","target","classList","className","shouldAdd","styleValue","styleProp","styleVal","currentValue","signalValue","parent","afterDestroy","handler","registerComponent","DOMElement","createComponent","CanvasDOMContainer","DisplayObject","PixiDOMContainer","props","div","h","DOMElement","registerComponent","DOMContainer","createComponent","Application","bootstrapCanvas","rootElement","canvas","options","app","Application","canvasElement","h","backgroundColor","useProps","linear","easeIn","easeInOut","easeOut","circIn","circInOut","circOut","backIn","backInOut","backOut","anticipate","bounceIn","bounceInOut","bounceOut","Easing","Texture","ImageSource","DOMAdapter","Matrix","RadialGradient","x0","y0","x1","y1","x2","y2","focalPoint","halfSize","offset","color","translate","defaultSize","m","dx","dy","angle","scaleX","scaleY","isObservable","Howl"]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|