|
|
|
@ -1,6 +1,6 @@
|
|
|
|
import type { Value } from './types';
|
|
|
|
import type { Value, UIValue } from './types';
|
|
|
|
import { valueToUI } from './valueToUI';
|
|
|
|
import { valueToUI } from './valueToUI';
|
|
|
|
import { render, hitTest, hitTestTextInput } from './ui';
|
|
|
|
import { render, hitTest } from './ui';
|
|
|
|
import { evaluate } from './interpreter';
|
|
|
|
import { evaluate } from './interpreter';
|
|
|
|
import { CGError } from './error';
|
|
|
|
import { CGError } from './error';
|
|
|
|
|
|
|
|
|
|
|
|
@ -23,7 +23,6 @@ export function runApp(app: App, canvas: HTMLCanvasElement, source: string) {
|
|
|
|
|
|
|
|
|
|
|
|
// Focus tracking
|
|
|
|
// Focus tracking
|
|
|
|
let focusedComponentKey: string | null = null;
|
|
|
|
let focusedComponentKey: string | null = null;
|
|
|
|
let focusableComponents: Map<string, { x: number, y: number, w: number, h: number }> = new Map();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setFocus(componentKey: string | null) {
|
|
|
|
function setFocus(componentKey: string | null) {
|
|
|
|
if (focusedComponentKey === componentKey) return;
|
|
|
|
if (focusedComponentKey === componentKey) return;
|
|
|
|
@ -135,7 +134,7 @@ export function runApp(app: App, canvas: HTMLCanvasElement, source: string) {
|
|
|
|
case 'column': {
|
|
|
|
case 'column': {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
...ui,
|
|
|
|
...ui,
|
|
|
|
children: ui.children.map((child, i) =>
|
|
|
|
children: ui.children.map((child: UIValue, i: number) =>
|
|
|
|
expandStateful(child, [...path, i])
|
|
|
|
expandStateful(child, [...path, i])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -237,14 +236,6 @@ export function runApp(app: App, canvas: HTMLCanvasElement, source: string) {
|
|
|
|
const x = e.clientX - rect.left;
|
|
|
|
const x = e.clientX - rect.left;
|
|
|
|
const y = e.clientY - rect.top;
|
|
|
|
const y = e.clientY - rect.top;
|
|
|
|
|
|
|
|
|
|
|
|
// Text Inputs
|
|
|
|
|
|
|
|
const hitTextInput = hitTestTextInput(x, y);
|
|
|
|
|
|
|
|
if (hitTextInput) {
|
|
|
|
|
|
|
|
rerender();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hitResult = hitTest(x, y);
|
|
|
|
const hitResult = hitTest(x, y);
|
|
|
|
if (hitResult) {
|
|
|
|
if (hitResult) {
|
|
|
|
const { event, relativeX, relativeY } = hitResult;
|
|
|
|
const { event, relativeX, relativeY } = hitResult;
|
|
|
|
|