@thewhateverapp/tile-sdk 0.8.5 → 0.8.6
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.
|
@@ -44,12 +44,14 @@ export declare class TileBridge {
|
|
|
44
44
|
* Request to navigate to full page view
|
|
45
45
|
* SIMPLE & EXPLICIT: Directly navigates using Next.js router + notifies parent
|
|
46
46
|
* In preview mode, only sends event to parent (no route change)
|
|
47
|
+
* Includes fallback for when router.push fails (e.g., due to hydration errors)
|
|
47
48
|
*/
|
|
48
49
|
navigateToPage(): void;
|
|
49
50
|
/**
|
|
50
51
|
* Request to navigate back to tile view (from page)
|
|
51
52
|
* SIMPLE & EXPLICIT: Directly navigates using Next.js router + notifies parent
|
|
52
53
|
* In preview mode, only sends event to parent (no route change)
|
|
54
|
+
* Includes fallback for when router.push fails (e.g., due to hydration errors)
|
|
53
55
|
*/
|
|
54
56
|
navigateToTile(): void;
|
|
55
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileBridge.d.ts","sourceRoot":"","sources":["../../src/bridge/TileBridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAGD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE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AC,IAAI,CAAC;IA2B/D;;OAEG;IACU,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAoBlD;;OAEG;IACI,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAWzD;;OAEG;IACU,OAAO,CAAC,OAAO,CAAC,EAAE;QAC7B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,GAAG,CAAC;IAiChB;;OAEG;IACU,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IA8B9D;;OAEG;IACU,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;IAuB3C;;OAEG;IACI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,MAAM,IAAI;IAgBlE;;OAEG;IACI,SAAS,IAAI,UAAU,GAAG,IAAI;IAIrC;;OAEG;IACI,OAAO,IAAI,OAAO;IAIzB;;;;;OAKG;IACU,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC;IAuBhD,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,aAAa;CAgCtB;AAKD,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,CAQ7D"}
|
|
@@ -165,14 +165,16 @@ export class TileBridge {
|
|
|
165
165
|
* Request to navigate to full page view
|
|
166
166
|
* SIMPLE & EXPLICIT: Directly navigates using Next.js router + notifies parent
|
|
167
167
|
* In preview mode, only sends event to parent (no route change)
|
|
168
|
+
* Includes fallback for when router.push fails (e.g., due to hydration errors)
|
|
168
169
|
*/
|
|
169
170
|
navigateToPage() {
|
|
170
171
|
const inPreview = this.isPreview();
|
|
172
|
+
const currentPath = typeof window !== 'undefined' ? window.location.pathname : 'unknown';
|
|
171
173
|
console.log('[TileBridge] 🚀 navigateToPage() called', {
|
|
172
174
|
hasRouter: !!this.router,
|
|
173
175
|
isInIframe: this.isInIframe(),
|
|
174
176
|
inPreview,
|
|
175
|
-
currentPath
|
|
177
|
+
currentPath,
|
|
176
178
|
});
|
|
177
179
|
// In preview mode, only notify parent - don't change routes in iframe
|
|
178
180
|
if (inPreview) {
|
|
@@ -186,11 +188,29 @@ export class TileBridge {
|
|
|
186
188
|
// 1. Navigate directly using Next.js router (deployed apps only)
|
|
187
189
|
if (this.router) {
|
|
188
190
|
console.log('[TileBridge] ✅ Using router.push("/page")');
|
|
189
|
-
|
|
191
|
+
try {
|
|
192
|
+
this.router.push('/page');
|
|
193
|
+
// Fallback: Check if navigation actually happened after a short delay
|
|
194
|
+
// This handles cases where router is broken due to hydration errors
|
|
195
|
+
if (typeof window !== 'undefined') {
|
|
196
|
+
setTimeout(() => {
|
|
197
|
+
if (window.location.pathname !== '/page') {
|
|
198
|
+
console.log('[TileBridge] ⚠️ router.push failed, falling back to window.location');
|
|
199
|
+
window.location.href = '/page';
|
|
200
|
+
}
|
|
201
|
+
}, 100);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
console.error('[TileBridge] router.push error, falling back:', err);
|
|
206
|
+
if (typeof window !== 'undefined') {
|
|
207
|
+
window.location.href = '/page';
|
|
208
|
+
}
|
|
209
|
+
}
|
|
190
210
|
}
|
|
191
211
|
else if (typeof window !== 'undefined') {
|
|
192
212
|
console.log('[TileBridge] ⚠️ No router, using window.location fallback');
|
|
193
|
-
window.location.
|
|
213
|
+
window.location.href = '/page';
|
|
194
214
|
}
|
|
195
215
|
// 2. Notify parent to enter fullscreen mode
|
|
196
216
|
console.log('[TileBridge] 📤 Sending tile:navigate message to parent');
|
|
@@ -203,6 +223,7 @@ export class TileBridge {
|
|
|
203
223
|
* Request to navigate back to tile view (from page)
|
|
204
224
|
* SIMPLE & EXPLICIT: Directly navigates using Next.js router + notifies parent
|
|
205
225
|
* In preview mode, only sends event to parent (no route change)
|
|
226
|
+
* Includes fallback for when router.push fails (e.g., due to hydration errors)
|
|
206
227
|
*/
|
|
207
228
|
navigateToTile() {
|
|
208
229
|
const inPreview = this.isPreview();
|
|
@@ -224,10 +245,27 @@ export class TileBridge {
|
|
|
224
245
|
}
|
|
225
246
|
// 1. Navigate directly using Next.js router (deployed apps only)
|
|
226
247
|
if (this.router) {
|
|
227
|
-
|
|
248
|
+
try {
|
|
249
|
+
this.router.push('/tile');
|
|
250
|
+
// Fallback: Check if navigation actually happened after a short delay
|
|
251
|
+
if (typeof window !== 'undefined') {
|
|
252
|
+
setTimeout(() => {
|
|
253
|
+
if (window.location.pathname !== '/tile') {
|
|
254
|
+
console.log('[TileBridge] ⚠️ router.push failed, falling back to window.location');
|
|
255
|
+
window.location.href = '/tile';
|
|
256
|
+
}
|
|
257
|
+
}, 100);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
console.error('[TileBridge] router.push error, falling back:', err);
|
|
262
|
+
if (typeof window !== 'undefined') {
|
|
263
|
+
window.location.href = '/tile';
|
|
264
|
+
}
|
|
265
|
+
}
|
|
228
266
|
}
|
|
229
267
|
else if (typeof window !== 'undefined') {
|
|
230
|
-
window.location.
|
|
268
|
+
window.location.href = '/tile';
|
|
231
269
|
}
|
|
232
270
|
// 2. Notify parent to exit fullscreen mode
|
|
233
271
|
this.sendToParent({
|