@simpludify/web 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 oz-coden
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,22 @@
1
- # Temporary Holding Version
1
+ # @simpludify/web
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Experimental v0.1.0 browser SDK for Simpludify, a code-first TypeScript 2D engine. APIs may change between 0.x releases. Includes Game, PixiJS rendering, browser input and Canvas/DOM UI adapters; re-exports the host-independent Core API. Core and PixiJS are installed as runtime dependencies, not bundled into this package.
4
+
5
+ The v0.1.0 distribution is being prepared; registry availability is not yet confirmed. Once published:
6
+
7
+ ```sh
8
+ npm install @simpludify/web@0.1.0
9
+ npm install --save-dev vite typescript
10
+ ```
11
+
12
+ ```ts
13
+ import { Game, Character } from "@simpludify/web";
14
+ const game = new Game();
15
+ game.add(Character());
16
+ await game.run();
17
+ // Call game.dispose() when removing the game.
18
+ ```
19
+
20
+ Use a browser bundler such as Vite, with an HTML module entry and a parent with an explicit height. The entry automatically imports scoped CSS. It can also be imported explicitly with `import "@simpludify/web/style.css"`. Do not configure CSS as side-effect-free. No repository CLI, example assets or global stylesheet reset is included.
21
+
22
+ ESM only, ES2022. Tooling requires Node >=22.12; Chromium/WebGL is the automated rendering target. This browser package is not a Node/SSR entry; use `@simpludify/core` for headless execution. Source maps embed original sources. [Complete Vite setup](https://github.oz-coden.com/Simpludify/guides/npm.html) · [Repository/API](https://github.com/oz-coden/Simpludify). MIT.
@@ -0,0 +1 @@
1
+ export { containsUI, intersectUI, layoutCanvas, type MeasureText, type UISizeValue, } from "@simpludify/core";
@@ -0,0 +1,47 @@
1
+ import { type CanvasNode, type CanvasUI, type UIBounds } from "@simpludify/core";
2
+ export interface NativeControlHost {
3
+ traverse(reverse: boolean): boolean;
4
+ wheel(event: WheelEvent): void;
5
+ }
6
+ /** Engine-owned native surfaces share Core focus/generation/lifetime and never route text through keys. */
7
+ declare abstract class NativeControl {
8
+ protected readonly node: CanvasNode;
9
+ protected readonly ui: CanvasUI;
10
+ protected readonly host: NativeControlHost;
11
+ abstract readonly element: HTMLInputElement | HTMLSelectElement;
12
+ readonly revision: number;
13
+ protected readonly abort: AbortController;
14
+ private readonly unparent;
15
+ protected constructor(node: CanvasNode, ui: CanvasUI, parentSignal: AbortSignal, host: NativeControlHost);
16
+ get disposed(): boolean;
17
+ protected get live(): boolean;
18
+ protected run(task: () => void): void;
19
+ protected mount(): void;
20
+ protected tab(event: KeyboardEvent): boolean;
21
+ abstract update(clip?: UIBounds): void;
22
+ dispose(): void;
23
+ }
24
+ /** Native browser/OS popup supplies viewport placement, list scrolling and platform key conventions. */
25
+ export declare class CanvasNativeSelect extends NativeControl {
26
+ readonly element: HTMLSelectElement;
27
+ private session;
28
+ private signature;
29
+ constructor(node: CanvasNode, ui: CanvasUI, signal: AbortSignal, host: NativeControlHost);
30
+ update(clip?: UIBounds): void;
31
+ }
32
+ /** Native caret, selection, clipboard and IME paint replace Canvas text only while focused. */
33
+ export declare class CanvasNativeText extends NativeControl {
34
+ readonly element: HTMLInputElement;
35
+ private session;
36
+ private composing;
37
+ private source;
38
+ constructor(node: CanvasNode, ui: CanvasUI, signal: AbortSignal, host: NativeControlHost);
39
+ private begin;
40
+ private send;
41
+ update(clip?: UIBounds): void;
42
+ }
43
+ /** Keep full native geometry; clip without shifting text, selection or the IME anchor. */
44
+ export declare function nativeGeometry(el: HTMLInputElement | HTMLSelectElement, node: CanvasNode, ui: CanvasUI, clip: UIBounds): void;
45
+ /** Native editors must not cover later Canvas hit surfaces or overlay scrollbars. */
46
+ export declare function clipNativeRegions(element: HTMLInputElement | HTMLSelectElement, node: CanvasNode, ui: CanvasUI, clip: UIBounds, covers: readonly UIBounds[]): void;
47
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type CancellationSignal, type CanvasNode, type CanvasStyle } from "@simpludify/core";
2
+ export { CanvasColumn, CanvasHoldButton, CanvasLabel, CanvasNode, type CanvasNodeKind, type CanvasNodeOwner, CanvasPanel, CanvasRow, type CanvasStyle, defaultCanvasStyle, type ResolvedCanvasStyle, type UIAlign, type UIBounds, type UIJustify, type UISize, } from "@simpludify/core";
3
+ /** Bridge owner cancellation to browser APIs such as fetch. */
4
+ export declare function browserAbortSignal(signal: CancellationSignal): AbortSignal;
5
+ /** Preserve Web callbacks' native AbortSignal; portable definitions import Core's factory. */
6
+ export declare function CanvasButton(text: string, click: (signal: AbortSignal) => void | Promise<void>, style?: CanvasStyle): CanvasNode;
@@ -0,0 +1 @@
1
+ export { wrapCanvasText } from "@simpludify/core";
@@ -0,0 +1 @@
1
+ export { CanvasUI, type CanvasUIOptions } from "@simpludify/core";
@@ -0,0 +1,44 @@
1
+ import type { CanvasNode, CanvasUI, PointerRouting } from "@simpludify/core";
2
+ import { Container, Graphics, Text } from "pixi.js";
3
+ export interface CanvasPresentation {
4
+ update(width: number, height: number): void;
5
+ focus(node: CanvasNode): void;
6
+ dispose(): void;
7
+ }
8
+ /** Pixi rendering and a small native focus mirror share the same resolved boxes. */
9
+ export declare class CanvasVisual implements CanvasPresentation {
10
+ private readonly ui;
11
+ private readonly host;
12
+ private readonly routing;
13
+ private readonly resources;
14
+ readonly display: Container<import("pixi.js").ContainerChild>;
15
+ private readonly element;
16
+ private readonly entries;
17
+ private readonly metrics;
18
+ private dirty;
19
+ private dead;
20
+ private active;
21
+ private mirroredFocus;
22
+ private readonly subscriptions;
23
+ private syncs;
24
+ constructor(ui: CanvasUI, host: HTMLElement, routing: PointerRouting, resources: {
25
+ graphics(graphics: Graphics, context: number | undefined): void;
26
+ text(text: Text, key: string | undefined): void;
27
+ changedText(key: string): void;
28
+ });
29
+ get diagnostics(): {
30
+ nodes: number;
31
+ buttons: number;
32
+ syncs: number;
33
+ textMetrics: number;
34
+ };
35
+ private measure;
36
+ beforeResolutionChange(): void;
37
+ focus(node: CanvasNode): void;
38
+ private native;
39
+ private button;
40
+ private updateButton;
41
+ update(width: number, height: number): void;
42
+ private releaseEntry;
43
+ dispose(): void;
44
+ }
package/dist/game.d.ts ADDED
@@ -0,0 +1,136 @@
1
+ import type { CanvasNode } from "@simpludify/core";
2
+ import { type ActionBindings, ActionController, type ActionSet, type Actor, Aspect, Camera, CanvasUI, type CanvasUIOptions, Engine, type FixedStepOptions, type FrameDriver, type JsonValue, type LogicalResolution, type RendererPort, type ReplayControllers, ReplayPlayer, Scene, ScenePointer, type ScreenPoint, type TweenScheduler, type Viewport, type ViewTransform, type WorldPoint } from "@simpludify/core";
3
+ import { Theme, type ThemeTokens, type UINode } from "./ui.js";
4
+ export interface SceneContext {
5
+ readonly scene: Scene;
6
+ readonly signal: AbortSignal;
7
+ readonly tweens: TweenScheduler;
8
+ readonly presentationTweens: TweenScheduler;
9
+ add<T extends Actor>(actor: T): T;
10
+ ui(...nodes: UINode[]): void;
11
+ canvasUI(root: CanvasNode, options?: CanvasUIOptions): CanvasUI;
12
+ readonly pointer: ScenePointer;
13
+ actions<A extends ActionSet>(actions: A, bindings?: ActionBindings<A>): ActionController<A>;
14
+ onUpdate(callback: (seconds: number) => void): () => void;
15
+ onActivate(callback: () => void): () => void;
16
+ onDeactivate(callback: () => void): () => void;
17
+ onDispose(callback: () => void): () => void;
18
+ }
19
+ export type SceneSetup = (context: SceneContext) => void | Promise<void>;
20
+ export interface GameOptions {
21
+ parent?: HTMLElement;
22
+ resolution?: LogicalResolution;
23
+ aspect?: Aspect;
24
+ camera?: Camera;
25
+ viewport?: Viewport;
26
+ pixelRatio?: number;
27
+ theme?: Theme;
28
+ tokens?: Partial<ThemeTokens>;
29
+ seed?: number;
30
+ maxDelta?: number;
31
+ fixedStep?: FixedStepOptions;
32
+ renderer?: (host: HTMLElement) => RendererPort;
33
+ frames?: FrameDriver;
34
+ onError?: (error: unknown) => void;
35
+ }
36
+ export declare class Game<SceneId extends string = string> {
37
+ readonly engine: Engine;
38
+ readonly element: HTMLDivElement;
39
+ readonly camera: Camera;
40
+ private readonly renderer;
41
+ private readonly keyboard;
42
+ private readonly pointers;
43
+ private readonly pointerChannels;
44
+ private canvas;
45
+ private canvasPresentation;
46
+ private defaultCanvas;
47
+ get pointer(): ScenePointer;
48
+ get pointerDiagnostics(): {
49
+ captures: number;
50
+ suppressedPointers: number;
51
+ hoverPointers: number;
52
+ heldNodes: number;
53
+ keyboardNodes: number;
54
+ deliveries: number;
55
+ scrollDrags: number;
56
+ controlDrags: number;
57
+ };
58
+ private channelFor;
59
+ private readonly observer;
60
+ private readonly frames;
61
+ private readonly options;
62
+ private readonly resolution;
63
+ private readonly aspect;
64
+ private readonly maxDelta;
65
+ private readonly fixed;
66
+ private playback;
67
+ private playbackScene;
68
+ private removeReplayOwner;
69
+ private requestedViewport;
70
+ private projection;
71
+ private projectionDirty;
72
+ private cameraX;
73
+ private cameraY;
74
+ private cameraZoom;
75
+ private width;
76
+ private height;
77
+ private ratio;
78
+ private readonly scenes;
79
+ private readonly pendingScenes;
80
+ private readonly defaultUI;
81
+ private ui;
82
+ private prepared;
83
+ private startPromise;
84
+ private queue;
85
+ private frame;
86
+ private previousTime;
87
+ private dead;
88
+ private ready;
89
+ private rendererReady;
90
+ private rendererSized;
91
+ private staging;
92
+ private readonly shutdown;
93
+ private readonly errorBox;
94
+ constructor(options?: GameOptions);
95
+ private assertAlive;
96
+ get tweens(): TweenScheduler;
97
+ get presentationTweens(): TweenScheduler;
98
+ get paused(): boolean;
99
+ pause(): void;
100
+ resume(): void;
101
+ /** Configure inside the initial Scene factory after game setup, before the first Engine step. */
102
+ playReplay(data: unknown, options: {
103
+ scene: Scene;
104
+ controllers: ReplayControllers;
105
+ expectedMetadata?: Readonly<Record<string, JsonValue>>;
106
+ }): ReplayPlayer;
107
+ stopReplay(): void;
108
+ add<T extends Actor>(actor: T): T;
109
+ /** Scene-owned Actions for the current Scene. In a staged factory use context.actions. */
110
+ actions<A extends ActionSet>(actions: A, bindings?: ActionBindings<A>): ActionController<A>;
111
+ remove(actor: Actor | string): boolean;
112
+ canvasUI(root: CanvasNode, options?: CanvasUIOptions): CanvasUI;
113
+ uiOverlay(...nodes: UINode[]): void;
114
+ scene(id: SceneId, setup: SceneSetup): this;
115
+ private wait;
116
+ run(initialScene?: SceneId): Promise<void>;
117
+ goTo(id: SceneId): Promise<void>;
118
+ private navigate;
119
+ private present;
120
+ get viewport(): Viewport;
121
+ get view(): ViewTransform;
122
+ setViewport(viewport?: Viewport): void;
123
+ worldToScreen(point: WorldPoint): ScreenPoint;
124
+ screenToWorld(point: ScreenPoint): WorldPoint;
125
+ pointerToWorld(pointer: {
126
+ readonly clientX: number;
127
+ readonly clientY: number;
128
+ }): WorldPoint;
129
+ whenReady(): Promise<void>;
130
+ private updateProjection;
131
+ private resize;
132
+ private render;
133
+ private readonly tick;
134
+ private readonly report;
135
+ dispose(): void;
136
+ }
@@ -0,0 +1,30 @@
1
+ import { type GeometryTilemap, type ViewTransform } from "@simpludify/core";
2
+ import { Container, Graphics } from "pixi.js";
3
+ /** Visible-cell Graphics with no image/UV contract; no full Grid walk per frame. */
4
+ export declare class GeometryTilemapVisual {
5
+ readonly map: GeometryTilemap;
6
+ private readonly released;
7
+ readonly display: Container<import("pixi.js").ContainerChild>;
8
+ readonly graphics: Map<number, Graphics>;
9
+ readonly stats: {
10
+ visitedCells: number;
11
+ updatedTiles: number;
12
+ createdGraphics: number;
13
+ destroyedGraphics: number;
14
+ };
15
+ order: number;
16
+ depth: number;
17
+ disposed: boolean;
18
+ private readonly dirty;
19
+ private visibleCells;
20
+ private invalid;
21
+ private boundsKey;
22
+ private readonly off;
23
+ private readonly offDispose;
24
+ constructor(map: GeometryTilemap, released: () => void);
25
+ private remove;
26
+ private cell;
27
+ render(view: ViewTransform): void;
28
+ private bulk;
29
+ dispose(): void;
30
+ }
@@ -0,0 +1,8 @@
1
+ import "./style.css";
2
+ export * from "@simpludify/core";
3
+ export { browserAbortSignal, CanvasButton } from "./canvas-node.js";
4
+ export type { CanvasPresentation } from "./canvas-visual.js";
5
+ export * from "./game.js";
6
+ export { BrowserInput } from "./input.js";
7
+ export { PixiRenderer } from "./renderer.js";
8
+ export * from "./ui.js";