@geometra/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +28 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +40 -0
- package/dist/app.js.map +1 -0
- package/dist/canvas-polyfill.d.ts +2 -0
- package/dist/canvas-polyfill.d.ts.map +1 -0
- package/dist/canvas-polyfill.js +21 -0
- package/dist/canvas-polyfill.js.map +1 -0
- package/dist/elements.d.ts +18 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +26 -0
- package/dist/elements.js.map +1 -0
- package/dist/hit-test.d.ts +5 -0
- package/dist/hit-test.d.ts.map +1 -0
- package/dist/hit-test.js +40 -0
- package/dist/hit-test.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +5 -0
- package/dist/node.js.map +1 -0
- package/dist/signals.d.ts +18 -0
- package/dist/signals.d.ts.map +1 -0
- package/dist/signals.js +102 -0
- package/dist/signals.js.map +1 -0
- package/dist/tree.d.ts +5 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +13 -0
- package/dist/tree.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ComputedLayout } from 'textura';
|
|
2
|
+
import type { UIElement, Renderer } from './types.js';
|
|
3
|
+
export interface AppOptions {
|
|
4
|
+
/** Root width for layout computation. */
|
|
5
|
+
width?: number;
|
|
6
|
+
/** Root height for layout computation. */
|
|
7
|
+
height?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface App {
|
|
10
|
+
/** The current computed layout. */
|
|
11
|
+
layout: ComputedLayout | null;
|
|
12
|
+
/** The current element tree. */
|
|
13
|
+
tree: UIElement | null;
|
|
14
|
+
/** Manually trigger a re-render. */
|
|
15
|
+
update(): void;
|
|
16
|
+
/** Dispatch a pointer event at (x, y). */
|
|
17
|
+
dispatch(eventType: 'onClick' | 'onPointerDown' | 'onPointerUp' | 'onPointerMove', x: number, y: number): boolean;
|
|
18
|
+
/** Tear down the app. */
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Mount a reactive UI tree onto a renderer.
|
|
23
|
+
*
|
|
24
|
+
* The `view` function is called inside a reactive effect — any signals
|
|
25
|
+
* read during its execution will trigger automatic re-layout and re-render.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createApp(view: () => UIElement, renderer: Renderer, options?: AppOptions): Promise<App>;
|
|
28
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAKrD,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,GAAG;IAClB,mCAAmC;IACnC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAA;IAC7B,gCAAgC;IAChC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAA;IACtB,oCAAoC;IACpC,MAAM,IAAI,IAAI,CAAA;IACd,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,eAAe,GAAG,aAAa,GAAG,eAAe,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACjH,yBAAyB;IACzB,OAAO,IAAI,IAAI,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,SAAS,EACrB,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,GAAG,CAAC,CA8Bd"}
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { init, computeLayout } from 'textura';
|
|
2
|
+
import { toLayoutTree } from './tree.js';
|
|
3
|
+
import { dispatchHit } from './hit-test.js';
|
|
4
|
+
import { effect } from './signals.js';
|
|
5
|
+
/**
|
|
6
|
+
* Mount a reactive UI tree onto a renderer.
|
|
7
|
+
*
|
|
8
|
+
* The `view` function is called inside a reactive effect — any signals
|
|
9
|
+
* read during its execution will trigger automatic re-layout and re-render.
|
|
10
|
+
*/
|
|
11
|
+
export async function createApp(view, renderer, options = {}) {
|
|
12
|
+
await init();
|
|
13
|
+
const app = {
|
|
14
|
+
layout: null,
|
|
15
|
+
tree: null,
|
|
16
|
+
update() {
|
|
17
|
+
app.tree = view();
|
|
18
|
+
const layoutTree = toLayoutTree(app.tree);
|
|
19
|
+
app.layout = computeLayout(layoutTree, {
|
|
20
|
+
width: options.width,
|
|
21
|
+
height: options.height,
|
|
22
|
+
});
|
|
23
|
+
renderer.render(app.layout, app.tree);
|
|
24
|
+
},
|
|
25
|
+
dispatch(eventType, x, y) {
|
|
26
|
+
if (!app.tree || !app.layout)
|
|
27
|
+
return false;
|
|
28
|
+
return dispatchHit(app.tree, app.layout, eventType, x, y);
|
|
29
|
+
},
|
|
30
|
+
destroy() {
|
|
31
|
+
dispose();
|
|
32
|
+
renderer.destroy();
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const dispose = effect(() => {
|
|
36
|
+
app.update();
|
|
37
|
+
});
|
|
38
|
+
return app;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAsBrC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAqB,EACrB,QAAkB,EAClB,UAAsB,EAAE;IAExB,MAAM,IAAI,EAAE,CAAA;IAEZ,MAAM,GAAG,GAAQ;QACf,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,IAAI;QACV,MAAM;YACJ,GAAG,CAAC,IAAI,GAAG,IAAI,EAAE,CAAA;YACjB,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACzC,GAAG,CAAC,MAAM,GAAG,aAAa,CAAC,UAAU,EAAE;gBACrC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC,CAAA;YACF,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;QACvC,CAAC;QACD,QAAQ,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM;gBAAE,OAAO,KAAK,CAAA;YAC1C,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;QAC3D,CAAC;QACD,OAAO;YACL,OAAO,EAAE,CAAA;YACT,QAAQ,CAAC,OAAO,EAAE,CAAA;QACpB,CAAC;KACF,CAAA;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE;QAC1B,GAAG,CAAC,MAAM,EAAE,CAAA;IACd,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas-polyfill.d.ts","sourceRoot":"","sources":["../src/canvas-polyfill.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Must be imported BEFORE textura or @chenglou/pretext.
|
|
2
|
+
// Pretext requires OffscreenCanvas for text measurement.
|
|
3
|
+
// @napi-rs/canvas provides a compatible canvas for Node.js.
|
|
4
|
+
import { createCanvas } from '@napi-rs/canvas';
|
|
5
|
+
if (typeof globalThis.OffscreenCanvas === 'undefined') {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
;
|
|
8
|
+
globalThis.OffscreenCanvas = class OffscreenCanvas {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
_canvas;
|
|
11
|
+
constructor(width, height) {
|
|
12
|
+
this._canvas = createCanvas(width, height);
|
|
13
|
+
}
|
|
14
|
+
getContext(type) {
|
|
15
|
+
if (type === '2d')
|
|
16
|
+
return this._canvas.getContext('2d');
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=canvas-polyfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas-polyfill.js","sourceRoot":"","sources":["../src/canvas-polyfill.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yDAAyD;AACzD,4DAA4D;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,IAAI,OAAO,UAAU,CAAC,eAAe,KAAK,WAAW,EAAE,CAAC;IACtD,8DAA8D;IAC9D,CAAC;IAAC,UAAkB,CAAC,eAAe,GAAG,MAAM,eAAe;QAC1D,8DAA8D;QACtD,OAAO,CAAK;QACpB,YAAY,KAAa,EAAE,MAAc;YACvC,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC5C,CAAC;QACD,UAAU,CAAC,IAAY;YACrB,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YACvD,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FlexProps } from 'textura';
|
|
2
|
+
import type { StyleProps, BoxElement, TextElement, UIElement, EventHandlers } from './types.js';
|
|
3
|
+
type BoxProps = FlexProps & StyleProps & EventHandlers & {
|
|
4
|
+
key?: string;
|
|
5
|
+
};
|
|
6
|
+
type TextProps = FlexProps & StyleProps & {
|
|
7
|
+
text: string;
|
|
8
|
+
font: string;
|
|
9
|
+
lineHeight: number;
|
|
10
|
+
whiteSpace?: 'normal' | 'pre-wrap';
|
|
11
|
+
key?: string;
|
|
12
|
+
};
|
|
13
|
+
/** Create a box (container) element. */
|
|
14
|
+
export declare function box(props: BoxProps, children?: UIElement[]): BoxElement;
|
|
15
|
+
/** Create a text leaf element. */
|
|
16
|
+
export declare function text(props: TextProps): TextElement;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../src/elements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/F,KAAK,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACzE,KAAK,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAClC,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wCAAwC;AACxC,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAE,SAAS,EAAO,GAAG,UAAU,CAe3E;AAED,kCAAkC;AAClC,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,CAGlD"}
|
package/dist/elements.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Create a box (container) element. */
|
|
2
|
+
export function box(props, children = []) {
|
|
3
|
+
const { onClick, onPointerDown, onPointerUp, onPointerMove, key, ...rest } = props;
|
|
4
|
+
const handlers = {};
|
|
5
|
+
if (onClick)
|
|
6
|
+
handlers.onClick = onClick;
|
|
7
|
+
if (onPointerDown)
|
|
8
|
+
handlers.onPointerDown = onPointerDown;
|
|
9
|
+
if (onPointerUp)
|
|
10
|
+
handlers.onPointerUp = onPointerUp;
|
|
11
|
+
if (onPointerMove)
|
|
12
|
+
handlers.onPointerMove = onPointerMove;
|
|
13
|
+
return {
|
|
14
|
+
kind: 'box',
|
|
15
|
+
props: rest,
|
|
16
|
+
children,
|
|
17
|
+
key,
|
|
18
|
+
handlers: Object.keys(handlers).length > 0 ? handlers : undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Create a text leaf element. */
|
|
22
|
+
export function text(props) {
|
|
23
|
+
const { key, ...rest } = props;
|
|
24
|
+
return { kind: 'text', props: rest, key };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=elements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../src/elements.ts"],"names":[],"mappings":"AAYA,wCAAwC;AACxC,MAAM,UAAU,GAAG,CAAC,KAAe,EAAE,WAAwB,EAAE;IAC7D,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAA;IAClF,MAAM,QAAQ,GAAkB,EAAE,CAAA;IAClC,IAAI,OAAO;QAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAA;IACvC,IAAI,aAAa;QAAE,QAAQ,CAAC,aAAa,GAAG,aAAa,CAAA;IACzD,IAAI,WAAW;QAAE,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAA;IACnD,IAAI,aAAa;QAAE,QAAQ,CAAC,aAAa,GAAG,aAAa,CAAA;IAEzD,OAAO;QACL,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,IAAI;QACX,QAAQ;QACR,GAAG;QACH,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;KAClE,CAAA;AACH,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAA;IAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ComputedLayout } from 'textura';
|
|
2
|
+
import type { UIElement, EventHandlers } from './types.js';
|
|
3
|
+
/** Dispatch an event at (x, y) against the element tree. Returns true if any handler fired. */
|
|
4
|
+
export declare function dispatchHit(element: UIElement, layout: ComputedLayout, eventType: keyof EventHandlers, x: number, y: number): boolean;
|
|
5
|
+
//# sourceMappingURL=hit-test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hit-test.d.ts","sourceRoot":"","sources":["../src/hit-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAc,aAAa,EAAY,MAAM,YAAY,CAAA;AA0ChF,+FAA+F;AAC/F,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,aAAa,EAC9B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAeT"}
|
package/dist/hit-test.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Walk the element tree + computed layout in parallel to find hit targets at (x, y). */
|
|
2
|
+
function collectHits(element, layout, x, y, offsetX, offsetY, results) {
|
|
3
|
+
const absX = offsetX + layout.x;
|
|
4
|
+
const absY = offsetY + layout.y;
|
|
5
|
+
const inside = x >= absX &&
|
|
6
|
+
x <= absX + layout.width &&
|
|
7
|
+
y >= absY &&
|
|
8
|
+
y <= absY + layout.height;
|
|
9
|
+
if (!inside)
|
|
10
|
+
return;
|
|
11
|
+
if (element.kind === 'box') {
|
|
12
|
+
const boxEl = element;
|
|
13
|
+
if (boxEl.handlers) {
|
|
14
|
+
results.push({ layout, handlers: boxEl.handlers });
|
|
15
|
+
}
|
|
16
|
+
for (let i = 0; i < boxEl.children.length; i++) {
|
|
17
|
+
const childLayout = layout.children[i];
|
|
18
|
+
if (childLayout) {
|
|
19
|
+
collectHits(boxEl.children[i], childLayout, x, y, absX, absY, results);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Dispatch an event at (x, y) against the element tree. Returns true if any handler fired. */
|
|
25
|
+
export function dispatchHit(element, layout, eventType, x, y) {
|
|
26
|
+
const hits = [];
|
|
27
|
+
collectHits(element, layout, x, y, 0, 0, hits);
|
|
28
|
+
// Deepest hit first (last in list = most nested)
|
|
29
|
+
for (let i = hits.length - 1; i >= 0; i--) {
|
|
30
|
+
const hit = hits[i];
|
|
31
|
+
const handler = hit.handlers[eventType];
|
|
32
|
+
if (handler) {
|
|
33
|
+
const event = { x, y, target: hit.layout };
|
|
34
|
+
handler(event);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=hit-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hit-test.js","sourceRoot":"","sources":["../src/hit-test.ts"],"names":[],"mappings":"AAQA,yFAAyF;AACzF,SAAS,WAAW,CAClB,OAAkB,EAClB,MAAsB,EACtB,CAAS,EACT,CAAS,EACT,OAAe,EACf,OAAe,EACf,OAAoB;IAEpB,MAAM,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC,CAAA;IAC/B,MAAM,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC,CAAA;IAE/B,MAAM,MAAM,GACV,CAAC,IAAI,IAAI;QACT,CAAC,IAAI,IAAI,GAAG,MAAM,CAAC,KAAK;QACxB,CAAC,IAAI,IAAI;QACT,CAAC,IAAI,IAAI,GAAG,MAAM,CAAC,MAAM,CAAA;IAE3B,IAAI,CAAC,MAAM;QAAE,OAAM;IAEnB,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,OAAqB,CAAA;QACnC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;QACpD,CAAC;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/C,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;YACtC,IAAI,WAAW,EAAE,CAAC;gBAChB,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;YACzE,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,WAAW,CACzB,OAAkB,EAClB,MAAsB,EACtB,SAA8B,EAC9B,CAAS,EACT,CAAS;IAET,MAAM,IAAI,GAAgB,EAAE,CAAA;IAC5B,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;IAE9C,iDAAiD;IACjD,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAE,CAAA;QACpB,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;QACvC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,KAAK,GAAa,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAA;YACpD,OAAO,CAAC,KAAK,CAAC,CAAA;YACd,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { signal, computed, effect, batch } from './signals.js';
|
|
2
|
+
export type { Signal, Computed } from './signals.js';
|
|
3
|
+
export { box, text } from './elements.js';
|
|
4
|
+
export { createApp } from './app.js';
|
|
5
|
+
export type { App, AppOptions } from './app.js';
|
|
6
|
+
export { toLayoutTree } from './tree.js';
|
|
7
|
+
export { dispatchHit } from './hit-test.js';
|
|
8
|
+
export type { UIElement, BoxElement, TextElement, StyleProps, EventHandlers, HitEvent, Component, Renderer, } from './types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAC9D,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAGpD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAGzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAGxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3C,YAAY,EACV,SAAS,EACT,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,QAAQ,EACR,SAAS,EACT,QAAQ,GACT,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Reactivity
|
|
2
|
+
export { signal, computed, effect, batch } from './signals.js';
|
|
3
|
+
// Element constructors
|
|
4
|
+
export { box, text } from './elements.js';
|
|
5
|
+
// App mount
|
|
6
|
+
export { createApp } from './app.js';
|
|
7
|
+
// Tree conversion
|
|
8
|
+
export { toLayoutTree } from './tree.js';
|
|
9
|
+
// Hit testing
|
|
10
|
+
export { dispatchHit } from './hit-test.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAG9D,uBAAuB;AACvB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEzC,YAAY;AACZ,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGpC,kBAAkB;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,cAAc;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
package/dist/node.js
ADDED
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,0DAA0D;AAC1D,OAAO,sBAAsB,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Minimal signals-based reactivity system. */
|
|
2
|
+
/** Batch multiple signal updates into a single flush. */
|
|
3
|
+
export declare function batch(fn: () => void): void;
|
|
4
|
+
export interface Signal<T> {
|
|
5
|
+
readonly value: T;
|
|
6
|
+
set(value: T): void;
|
|
7
|
+
peek(): T;
|
|
8
|
+
}
|
|
9
|
+
/** Create a reactive signal. */
|
|
10
|
+
export declare function signal<T>(initial: T): Signal<T>;
|
|
11
|
+
export interface Computed<T> {
|
|
12
|
+
readonly value: T;
|
|
13
|
+
}
|
|
14
|
+
/** Create a derived computation that re-runs when dependencies change. */
|
|
15
|
+
export declare function computed<T>(fn: () => T): Computed<T>;
|
|
16
|
+
/** Run a side effect whenever its signal dependencies change. Returns a dispose function. */
|
|
17
|
+
export declare function effect(fn: () => void): () => void;
|
|
18
|
+
//# sourceMappingURL=signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAQ/C,yDAAyD;AACzD,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAY1C;AAED,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;IACjB,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;IACnB,IAAI,IAAI,CAAC,CAAA;CACV;AAED,gCAAgC;AAChC,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAwB/C;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAClB;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAgCpD;AAED,6FAA6F;AAC7F,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAgBjD"}
|
package/dist/signals.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/** Minimal signals-based reactivity system. */
|
|
2
|
+
let currentSubscriber = null;
|
|
3
|
+
const batchQueue = new Set();
|
|
4
|
+
let batchDepth = 0;
|
|
5
|
+
/** Batch multiple signal updates into a single flush. */
|
|
6
|
+
export function batch(fn) {
|
|
7
|
+
batchDepth++;
|
|
8
|
+
try {
|
|
9
|
+
fn();
|
|
10
|
+
}
|
|
11
|
+
finally {
|
|
12
|
+
batchDepth--;
|
|
13
|
+
if (batchDepth === 0) {
|
|
14
|
+
const queued = [...batchQueue];
|
|
15
|
+
batchQueue.clear();
|
|
16
|
+
for (const sub of queued)
|
|
17
|
+
sub();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Create a reactive signal. */
|
|
22
|
+
export function signal(initial) {
|
|
23
|
+
let value = initial;
|
|
24
|
+
const subscribers = new Set();
|
|
25
|
+
return {
|
|
26
|
+
get value() {
|
|
27
|
+
if (currentSubscriber)
|
|
28
|
+
subscribers.add(currentSubscriber);
|
|
29
|
+
return value;
|
|
30
|
+
},
|
|
31
|
+
set(next) {
|
|
32
|
+
if (Object.is(value, next))
|
|
33
|
+
return;
|
|
34
|
+
value = next;
|
|
35
|
+
for (const sub of subscribers) {
|
|
36
|
+
if (batchDepth > 0) {
|
|
37
|
+
batchQueue.add(sub);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
sub();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
peek() {
|
|
45
|
+
return value;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Create a derived computation that re-runs when dependencies change. */
|
|
50
|
+
export function computed(fn) {
|
|
51
|
+
let cached;
|
|
52
|
+
let dirty = true;
|
|
53
|
+
const subscribers = new Set();
|
|
54
|
+
const recompute = () => {
|
|
55
|
+
dirty = true;
|
|
56
|
+
for (const sub of subscribers) {
|
|
57
|
+
if (batchDepth > 0) {
|
|
58
|
+
batchQueue.add(sub);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
sub();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
get value() {
|
|
67
|
+
if (currentSubscriber)
|
|
68
|
+
subscribers.add(currentSubscriber);
|
|
69
|
+
if (dirty) {
|
|
70
|
+
const prev = currentSubscriber;
|
|
71
|
+
currentSubscriber = recompute;
|
|
72
|
+
try {
|
|
73
|
+
cached = fn();
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
currentSubscriber = prev;
|
|
77
|
+
}
|
|
78
|
+
dirty = false;
|
|
79
|
+
}
|
|
80
|
+
return cached;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Run a side effect whenever its signal dependencies change. Returns a dispose function. */
|
|
85
|
+
export function effect(fn) {
|
|
86
|
+
let disposed = false;
|
|
87
|
+
const run = () => {
|
|
88
|
+
if (disposed)
|
|
89
|
+
return;
|
|
90
|
+
const prev = currentSubscriber;
|
|
91
|
+
currentSubscriber = run;
|
|
92
|
+
try {
|
|
93
|
+
fn();
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
currentSubscriber = prev;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
run();
|
|
100
|
+
return () => { disposed = true; };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=signals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAI/C,IAAI,iBAAiB,GAAsB,IAAI,CAAA;AAC/C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAc,CAAA;AACxC,IAAI,UAAU,GAAG,CAAC,CAAA;AAElB,yDAAyD;AACzD,MAAM,UAAU,KAAK,CAAC,EAAc;IAClC,UAAU,EAAE,CAAA;IACZ,IAAI,CAAC;QACH,EAAE,EAAE,CAAA;IACN,CAAC;YAAS,CAAC;QACT,UAAU,EAAE,CAAA;QACZ,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,MAAM,GAAG,CAAC,GAAG,UAAU,CAAC,CAAA;YAC9B,UAAU,CAAC,KAAK,EAAE,CAAA;YAClB,KAAK,MAAM,GAAG,IAAI,MAAM;gBAAE,GAAG,EAAE,CAAA;QACjC,CAAC;IACH,CAAC;AACH,CAAC;AAQD,gCAAgC;AAChC,MAAM,UAAU,MAAM,CAAI,OAAU;IAClC,IAAI,KAAK,GAAG,OAAO,CAAA;IACnB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAc,CAAA;IAEzC,OAAO;QACL,IAAI,KAAK;YACP,IAAI,iBAAiB;gBAAE,WAAW,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;YACzD,OAAO,KAAK,CAAA;QACd,CAAC;QACD,GAAG,CAAC,IAAO;YACT,IAAI,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;gBAAE,OAAM;YAClC,KAAK,GAAG,IAAI,CAAA;YACZ,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;gBAC9B,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;oBACnB,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBACrB,CAAC;qBAAM,CAAC;oBACN,GAAG,EAAE,CAAA;gBACP,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI;YACF,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC;AAMD,0EAA0E;AAC1E,MAAM,UAAU,QAAQ,CAAI,EAAW;IACrC,IAAI,MAAS,CAAA;IACb,IAAI,KAAK,GAAG,IAAI,CAAA;IAChB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAc,CAAA;IAEzC,MAAM,SAAS,GAAe,GAAG,EAAE;QACjC,KAAK,GAAG,IAAI,CAAA;QACZ,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;gBACnB,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACrB,CAAC;iBAAM,CAAC;gBACN,GAAG,EAAE,CAAA;YACP,CAAC;QACH,CAAC;IACH,CAAC,CAAA;IAED,OAAO;QACL,IAAI,KAAK;YACP,IAAI,iBAAiB;gBAAE,WAAW,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;YACzD,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,IAAI,GAAG,iBAAiB,CAAA;gBAC9B,iBAAiB,GAAG,SAAS,CAAA;gBAC7B,IAAI,CAAC;oBACH,MAAM,GAAG,EAAE,EAAE,CAAA;gBACf,CAAC;wBAAS,CAAC;oBACT,iBAAiB,GAAG,IAAI,CAAA;gBAC1B,CAAC;gBACD,KAAK,GAAG,KAAK,CAAA;YACf,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,MAAM,CAAC,EAAc;IACnC,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,MAAM,GAAG,GAAe,GAAG,EAAE;QAC3B,IAAI,QAAQ;YAAE,OAAM;QACpB,MAAM,IAAI,GAAG,iBAAiB,CAAA;QAC9B,iBAAiB,GAAG,GAAG,CAAA;QACvB,IAAI,CAAC;YACH,EAAE,EAAE,CAAA;QACN,CAAC;gBAAS,CAAC;YACT,iBAAiB,GAAG,IAAI,CAAA;QAC1B,CAAC;IACH,CAAC,CAAA;IAED,GAAG,EAAE,CAAA;IACL,OAAO,GAAG,EAAE,GAAG,QAAQ,GAAG,IAAI,CAAA,CAAC,CAAC,CAAA;AAClC,CAAC"}
|
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LayoutNode } from 'textura';
|
|
2
|
+
import type { UIElement } from './types.js';
|
|
3
|
+
/** Convert a UIElement tree into a textura LayoutNode tree for layout computation. */
|
|
4
|
+
export declare function toLayoutTree(element: UIElement): LayoutNode;
|
|
5
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,GAAG,UAAU,CAW3D"}
|
package/dist/tree.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Convert a UIElement tree into a textura LayoutNode tree for layout computation. */
|
|
2
|
+
export function toLayoutTree(element) {
|
|
3
|
+
if (element.kind === 'text') {
|
|
4
|
+
const { backgroundColor: _bg, color: _c, borderColor: _bc, borderRadius: _br, opacity: _o, ...layoutProps } = element.props;
|
|
5
|
+
return layoutProps;
|
|
6
|
+
}
|
|
7
|
+
const { backgroundColor: _bg, color: _c, borderColor: _bc, borderRadius: _br, opacity: _o, ...layoutProps } = element.props;
|
|
8
|
+
return {
|
|
9
|
+
...layoutProps,
|
|
10
|
+
children: element.children.map(toLayoutTree),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=tree.js.map
|
package/dist/tree.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAGA,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,OAAkB;IAC7C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC3H,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC3H,OAAO;QACL,GAAG,WAAW;QACd,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;KAC7C,CAAA;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { FlexProps, ComputedLayout } from 'textura';
|
|
2
|
+
/** Style properties for visual rendering (not layout). */
|
|
3
|
+
export interface StyleProps {
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
borderColor?: string;
|
|
7
|
+
borderRadius?: number;
|
|
8
|
+
opacity?: number;
|
|
9
|
+
}
|
|
10
|
+
/** A text node in the component tree. */
|
|
11
|
+
export interface TextElement {
|
|
12
|
+
kind: 'text';
|
|
13
|
+
props: FlexProps & StyleProps & {
|
|
14
|
+
text: string;
|
|
15
|
+
font: string;
|
|
16
|
+
lineHeight: number;
|
|
17
|
+
whiteSpace?: 'normal' | 'pre-wrap';
|
|
18
|
+
};
|
|
19
|
+
key?: string;
|
|
20
|
+
}
|
|
21
|
+
/** A box (container) node in the component tree. */
|
|
22
|
+
export interface BoxElement {
|
|
23
|
+
kind: 'box';
|
|
24
|
+
props: FlexProps & StyleProps;
|
|
25
|
+
children: UIElement[];
|
|
26
|
+
key?: string;
|
|
27
|
+
/** Optional event handlers — resolved via hit-testing. */
|
|
28
|
+
handlers?: EventHandlers;
|
|
29
|
+
}
|
|
30
|
+
/** Union of all element types. */
|
|
31
|
+
export type UIElement = TextElement | BoxElement;
|
|
32
|
+
/** Supported event handlers on box elements. */
|
|
33
|
+
export interface EventHandlers {
|
|
34
|
+
onClick?: (e: HitEvent) => void;
|
|
35
|
+
onPointerDown?: (e: HitEvent) => void;
|
|
36
|
+
onPointerUp?: (e: HitEvent) => void;
|
|
37
|
+
onPointerMove?: (e: HitEvent) => void;
|
|
38
|
+
}
|
|
39
|
+
/** Event delivered to handlers after hit-testing. */
|
|
40
|
+
export interface HitEvent {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
target: ComputedLayout;
|
|
44
|
+
}
|
|
45
|
+
/** A component function receives props and returns a UIElement tree. */
|
|
46
|
+
export type Component<P = Record<string, never>> = (props: P) => UIElement;
|
|
47
|
+
/** Interface that all render backends implement. */
|
|
48
|
+
export interface Renderer {
|
|
49
|
+
/** Render a computed layout frame. */
|
|
50
|
+
render(layout: ComputedLayout, tree: UIElement): void;
|
|
51
|
+
/** Clean up renderer resources. */
|
|
52
|
+
destroy(): void;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExD,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG;QAC9B,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;KACnC,CAAA;IACD,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,SAAS,GAAG,UAAU,CAAA;IAC7B,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,aAAa,CAAA;CACzB;AAED,kCAAkC;AAClC,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,UAAU,CAAA;AAEhD,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC/B,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAA;IACrC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAA;IACnC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAA;CACtC;AAED,qDAAqD;AACrD,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,MAAM,EAAE,cAAc,CAAA;CACvB;AAED,wEAAwE;AACxE,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,SAAS,CAAA;AAE1E,oDAAoD;AACpD,MAAM,WAAW,QAAQ;IACvB,sCAAsC;IACtC,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAAA;IACrD,mCAAmC;IACnC,OAAO,IAAI,IAAI,CAAA;CAChB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geometra/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "DOM-free UI framework core: components, signals, reconciler",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/razroo/textrura-framework",
|
|
10
|
+
"directory": "packages/core"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://razroo.github.io/textrura-framework",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"ui",
|
|
15
|
+
"framework",
|
|
16
|
+
"dom-free",
|
|
17
|
+
"canvas",
|
|
18
|
+
"flexbox",
|
|
19
|
+
"signals",
|
|
20
|
+
"textura"
|
|
21
|
+
],
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./node": {
|
|
30
|
+
"types": "./dist/node.d.ts",
|
|
31
|
+
"import": "./dist/node.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
39
|
+
"check": "tsc --noEmit"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"textura": "^1.1.1"
|
|
43
|
+
},
|
|
44
|
+
"optionalDependencies": {
|
|
45
|
+
"@napi-rs/canvas": "^0.1.65"
|
|
46
|
+
}
|
|
47
|
+
}
|