@thewhateverapp/tile-sdk 0.14.7 → 0.14.8

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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type SceneRendererProps } from './SceneRenderer.js';
2
+ import type { SceneRendererProps } from './SceneRenderer.js';
3
3
  /**
4
4
  * Props for SceneFromJson
5
5
  */
@@ -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;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"}
1
+ {"version":3,"file":"SceneFromJson.d.ts","sourceRoot":"","sources":["../../src/scene/SceneFromJson.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAK5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;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,qBAuHpB"}
@@ -1,7 +1,6 @@
1
1
  'use client';
2
- import React from 'react';
2
+ import React, { useState, useEffect, useMemo } from 'react';
3
3
  import { validateScene } from '@thewhateverapp/scene-sdk';
4
- import { SceneRenderer } from './SceneRenderer.js';
5
4
  /**
6
5
  * SceneFromJson - Renders a scene from a JSON object with validation
7
6
  *
@@ -17,6 +16,16 @@ import { SceneRenderer } from './SceneRenderer.js';
17
16
  * ```
18
17
  */
19
18
  export function SceneFromJson({ json, showErrors = true, onEvent, container = 'tile', ...props }) {
19
+ // SSR detection - only render SceneRenderer on client
20
+ const [isClient, setIsClient] = useState(false);
21
+ const [SceneRenderer, setSceneRenderer] = useState(null);
22
+ // Load SceneRenderer dynamically on client only (pixi.js requires browser APIs)
23
+ useEffect(() => {
24
+ setIsClient(true);
25
+ import('./SceneRenderer.js').then((mod) => {
26
+ setSceneRenderer(() => mod.SceneRenderer);
27
+ });
28
+ }, []);
20
29
  // Container styles based on mode
21
30
  const containerStyle = container === 'none'
22
31
  ? undefined
@@ -25,7 +34,7 @@ export function SceneFromJson({ json, showErrors = true, onEvent, container = 't
25
34
  height: container === 'page' ? '100vh' : '100%',
26
35
  };
27
36
  // Validate the JSON
28
- const validationResult = React.useMemo(() => {
37
+ const validationResult = useMemo(() => {
29
38
  try {
30
39
  return validateScene(json);
31
40
  }
@@ -38,7 +47,7 @@ export function SceneFromJson({ json, showErrors = true, onEvent, container = 't
38
47
  }
39
48
  }, [json]);
40
49
  // Report validation errors to agent for correction
41
- React.useEffect(() => {
50
+ useEffect(() => {
42
51
  if (!validationResult.valid) {
43
52
  const errorMessage = `Scene Validation Errors:\n${validationResult.errors
44
53
  .map((e) => `${e.path}: ${e.message}`)
@@ -49,6 +58,20 @@ export function SceneFromJson({ json, showErrors = true, onEvent, container = 't
49
58
  }
50
59
  }
51
60
  }, [validationResult]);
61
+ // Loading placeholder for SSR and dynamic import
62
+ const loadingPlaceholder = (React.createElement("div", { style: {
63
+ width: '100%',
64
+ height: '100%',
65
+ backgroundColor: '#0a0a1a',
66
+ display: 'flex',
67
+ alignItems: 'center',
68
+ justifyContent: 'center',
69
+ } },
70
+ React.createElement("div", { style: {
71
+ color: '#666',
72
+ fontSize: 14,
73
+ fontFamily: 'system-ui, sans-serif',
74
+ } }, "Loading...")));
52
75
  // Show errors if validation failed
53
76
  if (!validationResult.valid) {
54
77
  if (showErrors) {
@@ -75,9 +98,13 @@ export function SceneFromJson({ json, showErrors = true, onEvent, container = 't
75
98
  throw new Error(`Scene validation failed: ${validationResult.errors.map((e) => e.message).join(', ')}`);
76
99
  }
77
100
  // Show warnings in console
78
- if (validationResult.warnings.length > 0) {
101
+ if (validationResult.warnings.length > 0 && isClient) {
79
102
  console.warn('Scene validation warnings:', validationResult.warnings);
80
103
  }
104
+ // Wait for client-side rendering and dynamic import
105
+ if (!isClient || !SceneRenderer) {
106
+ return containerStyle ? React.createElement("div", { style: containerStyle }, loadingPlaceholder) : loadingPlaceholder;
107
+ }
81
108
  const sceneContent = (React.createElement(SceneRenderer, { spec: json, onEvent: onEvent, ...props }));
82
109
  return containerStyle ? React.createElement("div", { style: containerStyle }, sceneContent) : sceneContent;
83
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thewhateverapp/tile-sdk",
3
- "version": "0.14.7",
3
+ "version": "0.14.8",
4
4
  "description": "SDK for building interactive tiles on The Whatever App platform",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",