@thewhateverapp/tile-sdk 0.14.3 → 0.14.4
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.
|
@@ -8,6 +8,13 @@ export interface SceneFromJsonProps extends Omit<SceneRendererProps, 'spec'> {
|
|
|
8
8
|
json: unknown;
|
|
9
9
|
/** Show validation errors in UI instead of throwing */
|
|
10
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';
|
|
11
18
|
}
|
|
12
19
|
/**
|
|
13
20
|
* SceneFromJson - Renders a scene from a JSON object with validation
|
|
@@ -23,5 +30,5 @@ export interface SceneFromJsonProps extends Omit<SceneRendererProps, 'spec'> {
|
|
|
23
30
|
* }
|
|
24
31
|
* ```
|
|
25
32
|
*/
|
|
26
|
-
export declare function SceneFromJson({ json, showErrors, onEvent, ...props }: SceneFromJsonProps): React.JSX.Element;
|
|
33
|
+
export declare function SceneFromJson({ json, showErrors, onEvent, container, ...props }: SceneFromJsonProps): React.JSX.Element;
|
|
27
34
|
//# sourceMappingURL=SceneFromJson.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneFromJson.d.ts","sourceRoot":"","sources":["../../src/scene/SceneFromJson.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,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;
|
|
1
|
+
{"version":3,"file":"SceneFromJson.d.ts","sourceRoot":"","sources":["../../src/scene/SceneFromJson.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,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,qBAiFpB"}
|
|
@@ -16,7 +16,14 @@ import { SceneRenderer } from './SceneRenderer.js';
|
|
|
16
16
|
* }
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export function SceneFromJson({ json, showErrors = true, onEvent, ...props }) {
|
|
19
|
+
export function SceneFromJson({ json, showErrors = true, onEvent, container = 'tile', ...props }) {
|
|
20
|
+
// Container styles based on mode
|
|
21
|
+
const containerStyle = container === 'none'
|
|
22
|
+
? undefined
|
|
23
|
+
: {
|
|
24
|
+
width: '100%',
|
|
25
|
+
height: container === 'page' ? '100vh' : '100%',
|
|
26
|
+
};
|
|
20
27
|
// Validate the JSON
|
|
21
28
|
const validationResult = React.useMemo(() => {
|
|
22
29
|
try {
|
|
@@ -45,7 +52,7 @@ export function SceneFromJson({ json, showErrors = true, onEvent, ...props }) {
|
|
|
45
52
|
// Show errors if validation failed
|
|
46
53
|
if (!validationResult.valid) {
|
|
47
54
|
if (showErrors) {
|
|
48
|
-
|
|
55
|
+
const errorContent = (React.createElement("div", { style: {
|
|
49
56
|
width: '100%',
|
|
50
57
|
height: '100%',
|
|
51
58
|
backgroundColor: '#1a0a0a',
|
|
@@ -62,6 +69,7 @@ export function SceneFromJson({ json, showErrors = true, onEvent, ...props }) {
|
|
|
62
69
|
":"),
|
|
63
70
|
" ",
|
|
64
71
|
error.message)))));
|
|
72
|
+
return containerStyle ? React.createElement("div", { style: containerStyle }, errorContent) : errorContent;
|
|
65
73
|
}
|
|
66
74
|
// Throw if not showing errors
|
|
67
75
|
throw new Error(`Scene validation failed: ${validationResult.errors.map((e) => e.message).join(', ')}`);
|
|
@@ -70,5 +78,6 @@ export function SceneFromJson({ json, showErrors = true, onEvent, ...props }) {
|
|
|
70
78
|
if (validationResult.warnings.length > 0) {
|
|
71
79
|
console.warn('Scene validation warnings:', validationResult.warnings);
|
|
72
80
|
}
|
|
73
|
-
|
|
81
|
+
const sceneContent = (React.createElement(SceneRenderer, { spec: json, onEvent: onEvent, ...props }));
|
|
82
|
+
return containerStyle ? React.createElement("div", { style: containerStyle }, sceneContent) : sceneContent;
|
|
74
83
|
}
|