@thewhateverapp/tile-sdk 0.8.0 → 0.8.3
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.
|
@@ -42,11 +42,13 @@ export declare class TileBridge {
|
|
|
42
42
|
/**
|
|
43
43
|
* Request to navigate to full page view
|
|
44
44
|
* SIMPLE & EXPLICIT: Directly navigates using Next.js router + notifies parent
|
|
45
|
+
* In preview mode, only sends event to parent (no route change)
|
|
45
46
|
*/
|
|
46
47
|
navigateToPage(): void;
|
|
47
48
|
/**
|
|
48
49
|
* Request to navigate back to tile view (from page)
|
|
49
50
|
* SIMPLE & EXPLICIT: Directly navigates using Next.js router + notifies parent
|
|
51
|
+
* In preview mode, only sends event to parent (no route change)
|
|
50
52
|
*/
|
|
51
53
|
navigateToTile(): void;
|
|
52
54
|
/**
|
|
@@ -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,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,OAAO,EAAE,CAAC,IAAI,E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,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"}
|
|
@@ -143,21 +143,32 @@ export class TileBridge {
|
|
|
143
143
|
/**
|
|
144
144
|
* Request to navigate to full page view
|
|
145
145
|
* SIMPLE & EXPLICIT: Directly navigates using Next.js router + notifies parent
|
|
146
|
+
* In preview mode, only sends event to parent (no route change)
|
|
146
147
|
*/
|
|
147
148
|
navigateToPage() {
|
|
149
|
+
const inPreview = this.isPreview();
|
|
148
150
|
console.log('[TileBridge] 🚀 navigateToPage() called', {
|
|
149
151
|
hasRouter: !!this.router,
|
|
150
152
|
isInIframe: this.isInIframe(),
|
|
153
|
+
inPreview,
|
|
151
154
|
currentPath: typeof window !== 'undefined' ? window.location.pathname : 'unknown',
|
|
152
155
|
});
|
|
153
|
-
//
|
|
156
|
+
// In preview mode, only notify parent - don't change routes in iframe
|
|
157
|
+
if (inPreview) {
|
|
158
|
+
console.log('[TileBridge] 📤 Preview mode - sending event to parent (no route change)');
|
|
159
|
+
this.sendToParent({
|
|
160
|
+
type: 'tile:navigate',
|
|
161
|
+
payload: { target: 'page' },
|
|
162
|
+
});
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
// 1. Navigate directly using Next.js router (deployed apps only)
|
|
154
166
|
if (this.router) {
|
|
155
167
|
console.log('[TileBridge] ✅ Using router.push("/page")');
|
|
156
168
|
this.router.push('/page');
|
|
157
169
|
}
|
|
158
170
|
else if (typeof window !== 'undefined') {
|
|
159
171
|
console.log('[TileBridge] ⚠️ No router, using window.location fallback');
|
|
160
|
-
// Fallback: use window.location for preview mode
|
|
161
172
|
window.location.pathname = '/page';
|
|
162
173
|
}
|
|
163
174
|
// 2. Notify parent to enter fullscreen mode
|
|
@@ -170,20 +181,31 @@ export class TileBridge {
|
|
|
170
181
|
/**
|
|
171
182
|
* Request to navigate back to tile view (from page)
|
|
172
183
|
* SIMPLE & EXPLICIT: Directly navigates using Next.js router + notifies parent
|
|
184
|
+
* In preview mode, only sends event to parent (no route change)
|
|
173
185
|
*/
|
|
174
186
|
navigateToTile() {
|
|
175
|
-
|
|
187
|
+
const inPreview = this.isPreview();
|
|
188
|
+
if (this.isDevelopment() || inPreview) {
|
|
176
189
|
console.log('[TileBridge] Navigating to /tile', {
|
|
177
190
|
hasRouter: !!this.router,
|
|
178
191
|
isInIframe: this.isInIframe(),
|
|
192
|
+
inPreview,
|
|
179
193
|
});
|
|
180
194
|
}
|
|
181
|
-
//
|
|
195
|
+
// In preview mode, only notify parent - don't change routes in iframe
|
|
196
|
+
if (inPreview) {
|
|
197
|
+
console.log('[TileBridge] 📤 Preview mode - sending event to parent (no route change)');
|
|
198
|
+
this.sendToParent({
|
|
199
|
+
type: 'tile:navigate',
|
|
200
|
+
payload: { target: 'tile' },
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
// 1. Navigate directly using Next.js router (deployed apps only)
|
|
182
205
|
if (this.router) {
|
|
183
206
|
this.router.push('/tile');
|
|
184
207
|
}
|
|
185
208
|
else if (typeof window !== 'undefined') {
|
|
186
|
-
// Fallback: use window.location for preview mode
|
|
187
209
|
window.location.pathname = '/tile';
|
|
188
210
|
}
|
|
189
211
|
// 2. Notify parent to exit fullscreen mode
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TileInitializer - Automatically initializes the TileBridge with Next.js router
|
|
3
|
-
*
|
|
4
|
-
* This component should be included in the app's root layout to enable
|
|
5
|
-
* tile navigation features. It's invisible and has no visual output.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* // In app/layout.tsx
|
|
10
|
-
* import { TileInitializer } from '@thewhateverapp/tile-sdk/react';
|
|
11
|
-
*
|
|
12
|
-
* export default function RootLayout({ children }) {
|
|
13
|
-
* return (
|
|
14
|
-
* <html>
|
|
15
|
-
* <body>
|
|
16
|
-
* <TileInitializer />
|
|
17
|
-
* {children}
|
|
18
|
-
* </body>
|
|
19
|
-
* </html>
|
|
20
|
-
* );
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function TileInitializer(): null;
|
|
25
|
-
//# sourceMappingURL=TileInitializer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TileInitializer.d.ts","sourceRoot":"","sources":["../../src/react/TileInitializer.tsx"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,SAe9B"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
|
-
import { useRouter } from 'next/navigation';
|
|
4
|
-
import { getTileBridge } from '../bridge/TileBridge';
|
|
5
|
-
/**
|
|
6
|
-
* TileInitializer - Automatically initializes the TileBridge with Next.js router
|
|
7
|
-
*
|
|
8
|
-
* This component should be included in the app's root layout to enable
|
|
9
|
-
* tile navigation features. It's invisible and has no visual output.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* // In app/layout.tsx
|
|
14
|
-
* import { TileInitializer } from '@thewhateverapp/tile-sdk/react';
|
|
15
|
-
*
|
|
16
|
-
* export default function RootLayout({ children }) {
|
|
17
|
-
* return (
|
|
18
|
-
* <html>
|
|
19
|
-
* <body>
|
|
20
|
-
* <TileInitializer />
|
|
21
|
-
* {children}
|
|
22
|
-
* </body>
|
|
23
|
-
* </html>
|
|
24
|
-
* );
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export function TileInitializer() {
|
|
29
|
-
const router = useRouter();
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
// Initialize TileBridge with router for navigation support
|
|
32
|
-
const bridge = getTileBridge(router);
|
|
33
|
-
console.log('[TileInitializer] ✅ TileBridge initialized with router', {
|
|
34
|
-
hasRouter: !!router,
|
|
35
|
-
routerMethods: router ? Object.keys(router) : [],
|
|
36
|
-
});
|
|
37
|
-
}, [router]);
|
|
38
|
-
// This component renders nothing - it only initializes the bridge
|
|
39
|
-
return null;
|
|
40
|
-
}
|