@thewhateverapp/tile-sdk 0.15.3 → 0.15.5
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/bridge/TileBridge.d.ts +29 -0
- package/dist/bridge/TileBridge.d.ts.map +1 -1
- package/dist/bridge/TileBridge.js +78 -0
- package/dist/excalibur/index.d.ts +48 -0
- package/dist/excalibur/index.d.ts.map +1 -0
- package/dist/excalibur/index.js +51 -0
- package/dist/react/ExcaliburGame.d.ts +109 -0
- package/dist/react/ExcaliburGame.d.ts.map +1 -0
- package/dist/react/ExcaliburGame.js +215 -0
- package/dist/react/index.js +3 -3
- package/dist/scene/index.d.ts +3 -41
- package/dist/scene/index.d.ts.map +1 -1
- package/dist/scene/index.js +1 -49
- package/dist/spec/schema.d.ts +12 -12
- package/package.json +7 -7
- package/dist/pixi/index.d.ts +0 -43
- package/dist/pixi/index.d.ts.map +0 -1
- package/dist/pixi/index.js +0 -46
- package/dist/react/PixiGame.d.ts +0 -138
- package/dist/react/PixiGame.d.ts.map +0 -1
- package/dist/react/PixiGame.js +0 -237
- package/dist/scene/SceneContext.d.ts +0 -173
- package/dist/scene/SceneContext.d.ts.map +0 -1
- package/dist/scene/SceneContext.js +0 -89
- package/dist/scene/SceneFromJson.d.ts +0 -34
- package/dist/scene/SceneFromJson.d.ts.map +0 -1
- package/dist/scene/SceneFromJson.js +0 -97
- package/dist/scene/SceneRenderer.d.ts +0 -29
- package/dist/scene/SceneRenderer.d.ts.map +0 -1
- package/dist/scene/SceneRenderer.js +0 -312
- package/dist/scene/camera/CameraController.d.ts +0 -6
- package/dist/scene/camera/CameraController.d.ts.map +0 -1
- package/dist/scene/camera/CameraController.js +0 -90
- package/dist/scene/components/ComponentRunner.d.ts +0 -22
- package/dist/scene/components/ComponentRunner.d.ts.map +0 -1
- package/dist/scene/components/ComponentRunner.js +0 -210
- package/dist/scene/effects/GlowFilter.d.ts +0 -38
- package/dist/scene/effects/GlowFilter.d.ts.map +0 -1
- package/dist/scene/effects/GlowFilter.js +0 -40
- package/dist/scene/effects/ParticleSystem.d.ts +0 -52
- package/dist/scene/effects/ParticleSystem.d.ts.map +0 -1
- package/dist/scene/effects/ParticleSystem.js +0 -107
- package/dist/scene/entities/EntityGraphics.d.ts +0 -26
- package/dist/scene/entities/EntityGraphics.d.ts.map +0 -1
- package/dist/scene/entities/EntityGraphics.js +0 -226
- package/dist/scene/input/InputManager.d.ts +0 -18
- package/dist/scene/input/InputManager.d.ts.map +0 -1
- package/dist/scene/input/InputManager.js +0 -86
- package/dist/scene/physics/PhysicsEngine.d.ts +0 -15
- package/dist/scene/physics/PhysicsEngine.d.ts.map +0 -1
- package/dist/scene/physics/PhysicsEngine.js +0 -260
- package/dist/scene/timeline/TimelineExecutor.d.ts +0 -6
- package/dist/scene/timeline/TimelineExecutor.d.ts.map +0 -1
- package/dist/scene/timeline/TimelineExecutor.js +0 -241
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { type MutableRefObject } from 'react';
|
|
2
|
-
import type { SceneSpecV1, Entity, CameraConfig } from '@thewhateverapp/scene-sdk';
|
|
3
|
-
import type { Engine, Body } from 'matter-js';
|
|
4
|
-
/**
|
|
5
|
-
* Runtime entity state - mutable for performance
|
|
6
|
-
*/
|
|
7
|
-
export interface EntityState {
|
|
8
|
-
/** Entity definition from spec */
|
|
9
|
-
entity: Entity;
|
|
10
|
-
/** Current position (updated by physics/components) */
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
/** Current rotation in radians */
|
|
14
|
-
rotation: number;
|
|
15
|
-
/** Current scale */
|
|
16
|
-
scaleX: number;
|
|
17
|
-
scaleY: number;
|
|
18
|
-
/** Current velocity (for physics/movement) */
|
|
19
|
-
velocityX: number;
|
|
20
|
-
velocityY: number;
|
|
21
|
-
/** Whether entity is visible */
|
|
22
|
-
visible: boolean;
|
|
23
|
-
/** Current fill color (can be animated) */
|
|
24
|
-
fill?: string;
|
|
25
|
-
/** Current alpha (can be animated) */
|
|
26
|
-
alpha: number;
|
|
27
|
-
/** Matter.js body (if entity has physics) */
|
|
28
|
-
body?: Body;
|
|
29
|
-
/** Whether entity is destroyed */
|
|
30
|
-
destroyed: boolean;
|
|
31
|
-
/** Custom component state */
|
|
32
|
-
componentState: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Player-specific state for dash games
|
|
36
|
-
*/
|
|
37
|
-
export interface PlayerState {
|
|
38
|
-
/** Has the game started (waiting for first jump) */
|
|
39
|
-
started: boolean;
|
|
40
|
-
/** Is player on ground */
|
|
41
|
-
grounded: boolean;
|
|
42
|
-
/** Is player dead */
|
|
43
|
-
dead: boolean;
|
|
44
|
-
/** Current jump count (for double jump) */
|
|
45
|
-
jumpCount: number;
|
|
46
|
-
/** Last checkpoint position */
|
|
47
|
-
checkpointX: number;
|
|
48
|
-
checkpointY: number;
|
|
49
|
-
/** Is touching a jump orb */
|
|
50
|
-
touchingOrb: string | null;
|
|
51
|
-
/** Gravity direction (1 = down, -1 = up) */
|
|
52
|
-
gravityDir: number;
|
|
53
|
-
/** Current speed multiplier */
|
|
54
|
-
speedMultiplier: number;
|
|
55
|
-
/** Death count */
|
|
56
|
-
deaths: number;
|
|
57
|
-
/** Level complete */
|
|
58
|
-
complete: boolean;
|
|
59
|
-
/** Invincibility frames (prevents instant re-death after respawn) */
|
|
60
|
-
invincible: boolean;
|
|
61
|
-
/** Invincibility time remaining in ms */
|
|
62
|
-
invincibilityTimeRemaining: number;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Camera state
|
|
66
|
-
*/
|
|
67
|
-
export interface CameraState {
|
|
68
|
-
x: number;
|
|
69
|
-
y: number;
|
|
70
|
-
zoom: number;
|
|
71
|
-
shakeIntensity: number;
|
|
72
|
-
shakeTimeRemaining: number;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Input state
|
|
76
|
-
*/
|
|
77
|
-
export interface InputState {
|
|
78
|
-
/** Is jump/action pressed (space, tap, or up arrow) */
|
|
79
|
-
jumpPressed: boolean;
|
|
80
|
-
/** Is currently touching (for hold detection) */
|
|
81
|
-
touching: boolean;
|
|
82
|
-
/** Keys currently held */
|
|
83
|
-
keys: Record<string, boolean>;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Timeline state
|
|
87
|
-
*/
|
|
88
|
-
export interface TimelineState {
|
|
89
|
-
/** Elapsed time in ms */
|
|
90
|
-
elapsedMs: number;
|
|
91
|
-
/** Current beat (based on BPM) */
|
|
92
|
-
currentBeat: number;
|
|
93
|
-
/** Index of next event to process */
|
|
94
|
-
nextEventIndex: number;
|
|
95
|
-
/** Active tweens */
|
|
96
|
-
activeTweens: ActiveTween[];
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Active tween animation
|
|
100
|
-
*/
|
|
101
|
-
export interface ActiveTween {
|
|
102
|
-
targetId: string;
|
|
103
|
-
property: string;
|
|
104
|
-
startValue: number;
|
|
105
|
-
endValue: number;
|
|
106
|
-
startTime: number;
|
|
107
|
-
duration: number;
|
|
108
|
-
easing: string;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Scene context value - all scene runtime state
|
|
112
|
-
*/
|
|
113
|
-
export interface SceneContextValue {
|
|
114
|
-
/** Compiled scene spec */
|
|
115
|
-
spec: SceneSpecV1;
|
|
116
|
-
/** Entity states by ID */
|
|
117
|
-
entities: MutableRefObject<Map<string, EntityState>>;
|
|
118
|
-
/** Layer order (front to back) */
|
|
119
|
-
layers: string[];
|
|
120
|
-
/** Player state (for dash games) */
|
|
121
|
-
player: MutableRefObject<PlayerState>;
|
|
122
|
-
/** Camera state */
|
|
123
|
-
camera: MutableRefObject<CameraState>;
|
|
124
|
-
/** Input state */
|
|
125
|
-
input: MutableRefObject<InputState>;
|
|
126
|
-
/** Timeline state */
|
|
127
|
-
timeline: MutableRefObject<TimelineState>;
|
|
128
|
-
/** Matter.js engine */
|
|
129
|
-
engine: MutableRefObject<Engine | null>;
|
|
130
|
-
/** Emit an event to parent */
|
|
131
|
-
emitEvent: (event: string, data?: unknown) => void;
|
|
132
|
-
/** Get entity state by ID */
|
|
133
|
-
getEntity: (id: string) => EntityState | undefined;
|
|
134
|
-
/** Spawn an entity from prefab */
|
|
135
|
-
spawnEntity: (prefabId: string, x: number, y: number) => void;
|
|
136
|
-
/** Destroy an entity */
|
|
137
|
-
destroyEntity: (id: string) => void;
|
|
138
|
-
/** Respawn player at checkpoint */
|
|
139
|
-
respawnPlayer: () => void;
|
|
140
|
-
/** BPM for beat calculations */
|
|
141
|
-
bpm: number;
|
|
142
|
-
/** Start time for timeline */
|
|
143
|
-
startTime: number;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Scene context
|
|
147
|
-
*/
|
|
148
|
-
export declare const SceneContext: import("react").Context<SceneContextValue | null>;
|
|
149
|
-
/**
|
|
150
|
-
* Hook to access scene context
|
|
151
|
-
*/
|
|
152
|
-
export declare function useScene(): SceneContextValue;
|
|
153
|
-
/**
|
|
154
|
-
* Create initial entity state from entity definition
|
|
155
|
-
*/
|
|
156
|
-
export declare function createEntityState(entity: Entity): EntityState;
|
|
157
|
-
/**
|
|
158
|
-
* Create initial player state
|
|
159
|
-
*/
|
|
160
|
-
export declare function createPlayerState(): PlayerState;
|
|
161
|
-
/**
|
|
162
|
-
* Create initial camera state from config
|
|
163
|
-
*/
|
|
164
|
-
export declare function createCameraState(config?: CameraConfig): CameraState;
|
|
165
|
-
/**
|
|
166
|
-
* Create initial input state
|
|
167
|
-
*/
|
|
168
|
-
export declare function createInputState(): InputState;
|
|
169
|
-
/**
|
|
170
|
-
* Create initial timeline state
|
|
171
|
-
*/
|
|
172
|
-
export declare function createTimelineState(): TimelineState;
|
|
173
|
-
//# sourceMappingURL=SceneContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SceneContext.d.ts","sourceRoot":"","sources":["../../src/scene/SceneContext.ts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AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAgB/C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,CAQpE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAM7C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAOnD"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { createContext, useContext } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* Scene context
|
|
5
|
-
*/
|
|
6
|
-
export const SceneContext = createContext(null);
|
|
7
|
-
/**
|
|
8
|
-
* Hook to access scene context
|
|
9
|
-
*/
|
|
10
|
-
export function useScene() {
|
|
11
|
-
const context = useContext(SceneContext);
|
|
12
|
-
if (!context) {
|
|
13
|
-
throw new Error('useScene must be used within a SceneRenderer');
|
|
14
|
-
}
|
|
15
|
-
return context;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Create initial entity state from entity definition
|
|
19
|
-
*/
|
|
20
|
-
export function createEntityState(entity) {
|
|
21
|
-
return {
|
|
22
|
-
entity,
|
|
23
|
-
x: entity.transform.x,
|
|
24
|
-
y: entity.transform.y,
|
|
25
|
-
rotation: (entity.transform.rotation ?? 0) * (Math.PI / 180), // Convert to radians
|
|
26
|
-
scaleX: entity.transform.scaleX ?? 1,
|
|
27
|
-
scaleY: entity.transform.scaleY ?? 1,
|
|
28
|
-
velocityX: 0,
|
|
29
|
-
velocityY: 0,
|
|
30
|
-
visible: entity.render?.visible ?? true,
|
|
31
|
-
fill: entity.render?.fill,
|
|
32
|
-
alpha: entity.render?.alpha ?? 1,
|
|
33
|
-
destroyed: false,
|
|
34
|
-
componentState: {},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Create initial player state
|
|
39
|
-
*/
|
|
40
|
-
export function createPlayerState() {
|
|
41
|
-
return {
|
|
42
|
-
started: false,
|
|
43
|
-
grounded: false,
|
|
44
|
-
dead: false,
|
|
45
|
-
jumpCount: 0,
|
|
46
|
-
checkpointX: 0,
|
|
47
|
-
checkpointY: 0,
|
|
48
|
-
touchingOrb: null,
|
|
49
|
-
gravityDir: 1,
|
|
50
|
-
speedMultiplier: 1,
|
|
51
|
-
deaths: 0,
|
|
52
|
-
complete: false,
|
|
53
|
-
invincible: false,
|
|
54
|
-
invincibilityTimeRemaining: 0,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Create initial camera state from config
|
|
59
|
-
*/
|
|
60
|
-
export function createCameraState(config) {
|
|
61
|
-
return {
|
|
62
|
-
x: config?.initialX ?? 0,
|
|
63
|
-
y: config?.initialY ?? 0,
|
|
64
|
-
zoom: config?.zoom ?? 1,
|
|
65
|
-
shakeIntensity: 0,
|
|
66
|
-
shakeTimeRemaining: 0,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Create initial input state
|
|
71
|
-
*/
|
|
72
|
-
export function createInputState() {
|
|
73
|
-
return {
|
|
74
|
-
jumpPressed: false,
|
|
75
|
-
touching: false,
|
|
76
|
-
keys: {},
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Create initial timeline state
|
|
81
|
-
*/
|
|
82
|
-
export function createTimelineState() {
|
|
83
|
-
return {
|
|
84
|
-
elapsedMs: 0,
|
|
85
|
-
currentBeat: 0,
|
|
86
|
-
nextEventIndex: 0,
|
|
87
|
-
activeTweens: [],
|
|
88
|
-
};
|
|
89
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type SceneRendererProps } from './SceneRenderer.js';
|
|
3
|
-
/**
|
|
4
|
-
* Props for SceneFromJson
|
|
5
|
-
*/
|
|
6
|
-
export interface SceneFromJsonProps extends Omit<SceneRendererProps, 'spec'> {
|
|
7
|
-
/** The scene spec JSON object (imported from scene.json) */
|
|
8
|
-
json: unknown;
|
|
9
|
-
/** Show validation errors in UI instead of throwing */
|
|
10
|
-
showErrors?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Container sizing mode:
|
|
13
|
-
* - 'tile': Fills parent container (w-full h-full) - default
|
|
14
|
-
* - 'page': Fills viewport (w-full h-screen)
|
|
15
|
-
* - 'none': No container wrapper (you manage sizing)
|
|
16
|
-
*/
|
|
17
|
-
container?: 'tile' | 'page' | 'none';
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* SceneFromJson - Renders a scene from a JSON object with validation
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```tsx
|
|
24
|
-
* // In your tile page:
|
|
25
|
-
* import { SceneFromJson } from '@thewhateverapp/tile-sdk/scene';
|
|
26
|
-
* import sceneJson from './scene.json';
|
|
27
|
-
*
|
|
28
|
-
* export default function TilePage() {
|
|
29
|
-
* return <SceneFromJson json={sceneJson} />;
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export declare function SceneFromJson({ json, showErrors, onEvent, container, ...props }: SceneFromJsonProps): React.JSX.Element;
|
|
34
|
-
//# sourceMappingURL=SceneFromJson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SceneFromJson.d.ts","sourceRoot":"","sources":["../../src/scene/SceneFromJson.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAG/D,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC1E,4DAA4D;IAC5D,IAAI,EAAE,OAAO,CAAC;IACd,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CACtC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,UAAiB,EACjB,OAAO,EACP,SAAkB,EAClB,GAAG,KAAK,EACT,EAAE,kBAAkB,qBAoGpB"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React, { useEffect, useMemo, useCallback } from 'react';
|
|
3
|
-
import { validateScene } from '@thewhateverapp/scene-sdk';
|
|
4
|
-
import { SceneRenderer } from './SceneRenderer.js';
|
|
5
|
-
/**
|
|
6
|
-
* SceneFromJson - Renders a scene from a JSON object with validation
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```tsx
|
|
10
|
-
* // In your tile page:
|
|
11
|
-
* import { SceneFromJson } from '@thewhateverapp/tile-sdk/scene';
|
|
12
|
-
* import sceneJson from './scene.json';
|
|
13
|
-
*
|
|
14
|
-
* export default function TilePage() {
|
|
15
|
-
* return <SceneFromJson json={sceneJson} />;
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function SceneFromJson({ json, showErrors = true, onEvent, container = 'tile', ...props }) {
|
|
20
|
-
// Wrap onEvent to forward to parent window via postMessage
|
|
21
|
-
const wrappedOnEvent = useCallback((event, data) => {
|
|
22
|
-
// Call user's onEvent handler
|
|
23
|
-
onEvent?.(event, data);
|
|
24
|
-
// Forward to parent window for tile containers to handle
|
|
25
|
-
if (typeof window !== 'undefined' && window.parent !== window) {
|
|
26
|
-
window.parent.postMessage({
|
|
27
|
-
type: 'tile:event',
|
|
28
|
-
payload: { event, data },
|
|
29
|
-
timestamp: Date.now(),
|
|
30
|
-
}, '*' // Allow any parent origin (tile containers validate origin)
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}, [onEvent]);
|
|
34
|
-
// Container styles based on mode
|
|
35
|
-
const containerStyle = container === 'none'
|
|
36
|
-
? undefined
|
|
37
|
-
: {
|
|
38
|
-
width: '100%',
|
|
39
|
-
height: container === 'page' ? '100vh' : '100%',
|
|
40
|
-
};
|
|
41
|
-
// Validate the JSON
|
|
42
|
-
const validationResult = useMemo(() => {
|
|
43
|
-
try {
|
|
44
|
-
return validateScene(json);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
return {
|
|
48
|
-
valid: false,
|
|
49
|
-
errors: [{ path: 'root', message: String(error), code: 'PARSE_ERROR' }],
|
|
50
|
-
warnings: [],
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}, [json]);
|
|
54
|
-
// Report validation errors to agent for correction
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (!validationResult.valid) {
|
|
57
|
-
const errorMessage = `Scene Validation Errors:\n${validationResult.errors
|
|
58
|
-
.map((e) => `${e.path}: ${e.message}`)
|
|
59
|
-
.join('\n')}`;
|
|
60
|
-
// Report to agent via preview error reporting mechanism
|
|
61
|
-
if (typeof window !== 'undefined' && window.__PREVIEW_REPORT_ERROR__) {
|
|
62
|
-
window.__PREVIEW_REPORT_ERROR__(errorMessage, null, null);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, [validationResult]);
|
|
66
|
-
// Show errors if validation failed
|
|
67
|
-
if (!validationResult.valid) {
|
|
68
|
-
if (showErrors) {
|
|
69
|
-
const errorContent = (React.createElement("div", { style: {
|
|
70
|
-
width: '100%',
|
|
71
|
-
height: '100%',
|
|
72
|
-
backgroundColor: '#1a0a0a',
|
|
73
|
-
color: '#ff4444',
|
|
74
|
-
padding: 16,
|
|
75
|
-
fontFamily: 'monospace',
|
|
76
|
-
fontSize: 12,
|
|
77
|
-
overflow: 'auto',
|
|
78
|
-
} },
|
|
79
|
-
React.createElement("div", { style: { fontWeight: 'bold', marginBottom: 8 } }, "Scene Validation Errors:"),
|
|
80
|
-
validationResult.errors.map((error, i) => (React.createElement("div", { key: i, style: { marginBottom: 4 } },
|
|
81
|
-
React.createElement("span", { style: { color: '#ff8888' } },
|
|
82
|
-
error.path,
|
|
83
|
-
":"),
|
|
84
|
-
" ",
|
|
85
|
-
error.message)))));
|
|
86
|
-
return containerStyle ? React.createElement("div", { style: containerStyle }, errorContent) : errorContent;
|
|
87
|
-
}
|
|
88
|
-
// Throw if not showing errors
|
|
89
|
-
throw new Error(`Scene validation failed: ${validationResult.errors.map((e) => e.message).join(', ')}`);
|
|
90
|
-
}
|
|
91
|
-
// Show warnings in console
|
|
92
|
-
if (validationResult.warnings.length > 0) {
|
|
93
|
-
console.warn('Scene validation warnings:', validationResult.warnings);
|
|
94
|
-
}
|
|
95
|
-
const sceneContent = (React.createElement(SceneRenderer, { spec: json, onEvent: wrappedOnEvent, ...props }));
|
|
96
|
-
return containerStyle ? React.createElement("div", { style: containerStyle }, sceneContent) : sceneContent;
|
|
97
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { SceneSpecV1 } from '@thewhateverapp/scene-sdk';
|
|
3
|
-
/**
|
|
4
|
-
* Props for SceneRenderer
|
|
5
|
-
*/
|
|
6
|
-
export interface SceneRendererProps {
|
|
7
|
-
/** Scene specification to render */
|
|
8
|
-
spec: SceneSpecV1;
|
|
9
|
-
/** Callback for scene events (player.death, level.complete, etc.) */
|
|
10
|
-
onEvent?: (event: string, data?: unknown) => void;
|
|
11
|
-
/** Whether the scene is paused */
|
|
12
|
-
paused?: boolean;
|
|
13
|
-
/** Fixed width (if not set, fills container responsively) */
|
|
14
|
-
width?: number;
|
|
15
|
-
/** Fixed height (if not set, fills container responsively) */
|
|
16
|
-
height?: number;
|
|
17
|
-
/** Enable debug rendering */
|
|
18
|
-
debug?: boolean;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* SceneRenderer - Renders a SceneSpecV1 with physics, components, and timeline
|
|
22
|
-
*
|
|
23
|
-
* By default, fills its parent container responsively. Pass explicit width/height
|
|
24
|
-
* to override with fixed dimensions.
|
|
25
|
-
*/
|
|
26
|
-
export declare function SceneRenderer({ spec: inputSpec, onEvent, paused, width: fixedWidth, height: fixedHeight, debug, }: SceneRendererProps): React.JSX.Element;
|
|
27
|
-
import { useScene } from './SceneContext.js';
|
|
28
|
-
export { useScene };
|
|
29
|
-
//# sourceMappingURL=SceneRenderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SceneRenderer.d.ts","sourceRoot":"","sources":["../../src/scene/SceneRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAGjF,OAAO,KAAK,EAAE,WAAW,EAAU,MAAM,2BAA2B,CAAC;AAwDrE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,qEAAqE;IACrE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EAAE,SAAS,EACf,OAAO,EACP,MAAc,EACd,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,WAAW,EACnB,KAAa,GACd,EAAE,kBAAkB,qBA0CpB;AAgTD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|