@thewhateverapp/tile-sdk 0.17.15 → 0.17.16
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/react/useTile.d.ts.map +1 -1
- package/dist/react/useTile.js +38 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTile.d.ts","sourceRoot":"","sources":["../../src/react/useTile.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"useTile.d.ts","sourceRoot":"","sources":["../../src/react/useTile.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAkClE,wBAAgB,OAAO,IAAI,gBAAgB,CAe1C"}
|
package/dist/react/useTile.js
CHANGED
|
@@ -1,8 +1,46 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { TileContext } from './TileProvider.js';
|
|
3
|
+
// SSR-safe stub that returns no-op functions
|
|
4
|
+
// Used when useTile is called during server-side rendering before hydration
|
|
5
|
+
const ssrStub = {
|
|
6
|
+
tileId: null,
|
|
7
|
+
bridge: null, // Bridge doesn't exist on server
|
|
8
|
+
isReady: false,
|
|
9
|
+
stateClient: null,
|
|
10
|
+
navigateToPage: () => { },
|
|
11
|
+
navigateToTile: () => { },
|
|
12
|
+
openUrl: () => { },
|
|
13
|
+
trackEvent: () => { },
|
|
14
|
+
setAttributionVisible: () => { },
|
|
15
|
+
getToken: () => null,
|
|
16
|
+
storage: {
|
|
17
|
+
get: () => Promise.resolve(null),
|
|
18
|
+
set: () => Promise.resolve(),
|
|
19
|
+
},
|
|
20
|
+
clipboard: {
|
|
21
|
+
write: () => Promise.resolve(),
|
|
22
|
+
},
|
|
23
|
+
auth: {
|
|
24
|
+
getUser: () => Promise.resolve(null),
|
|
25
|
+
requestScopes: () => Promise.resolve(false),
|
|
26
|
+
getCurrentUser: () => Promise.resolve(null),
|
|
27
|
+
},
|
|
28
|
+
media: {
|
|
29
|
+
capturePhoto: () => Promise.reject(new Error('Media not available during SSR')),
|
|
30
|
+
selectFile: () => Promise.reject(new Error('Media not available during SSR')),
|
|
31
|
+
selectFiles: () => Promise.reject(new Error('Media not available during SSR')),
|
|
32
|
+
},
|
|
33
|
+
};
|
|
3
34
|
export function useTile() {
|
|
4
35
|
const context = useContext(TileContext);
|
|
36
|
+
// During SSR or before hydration, context may be null
|
|
37
|
+
// Return a stub that works during SSR - real context kicks in after hydration
|
|
5
38
|
if (!context) {
|
|
39
|
+
// Check if we're on the server or during initial hydration
|
|
40
|
+
if (typeof window === 'undefined') {
|
|
41
|
+
return ssrStub;
|
|
42
|
+
}
|
|
43
|
+
// On client but no context - this is a real error (missing TileProvider)
|
|
6
44
|
throw new Error('useTile must be used within a TileProvider');
|
|
7
45
|
}
|
|
8
46
|
return context;
|