@thewhateverapp/tile-sdk 0.2.4 → 0.2.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.
|
@@ -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,KAAK,EAAE,MAAM,CAAC;IACd,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;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,gBAAgB,CAAmD;IAC3E,OAAO,CAAC,aAAa,CAAoD;IACzE,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,YAAY,CAAS;gBAEjB,cAAc,GAAE,MAAkC;IA4B9D,OAAO,CAAC,UAAU;
|
|
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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AoBlD;;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;;OAEG;IACU,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC;IAehD,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,SAAS;CAIlB;AAKD,wBAAgB,aAAa,IAAI,UAAU,CAK1C"}
|
|
@@ -35,11 +35,12 @@ export class TileBridge {
|
|
|
35
35
|
initialize() {
|
|
36
36
|
if (typeof window === 'undefined')
|
|
37
37
|
return;
|
|
38
|
-
// Debug logging
|
|
39
|
-
if (this.isDevelopment()) {
|
|
38
|
+
// Debug logging (always enabled for preview and development)
|
|
39
|
+
if (this.isDevelopment() || this.isPreview()) {
|
|
40
40
|
console.log('[TileBridge] Initializing with config:', {
|
|
41
41
|
parentOrigin: this.parentOrigin,
|
|
42
42
|
currentOrigin: window.location.origin,
|
|
43
|
+
hostname: window.location.hostname,
|
|
43
44
|
isInIframe: window.self !== window.top,
|
|
44
45
|
});
|
|
45
46
|
}
|
|
@@ -51,11 +52,18 @@ export class TileBridge {
|
|
|
51
52
|
this.sendToParent({ type: 'tile:request-config' });
|
|
52
53
|
}
|
|
53
54
|
handleMessage(event) {
|
|
54
|
-
// Validate origin
|
|
55
|
-
if (event.origin !== this.parentOrigin && !this.isDevelopment()) {
|
|
56
|
-
console.warn('Received message from untrusted origin:', event.origin);
|
|
55
|
+
// Validate origin (skip validation in dev and preview)
|
|
56
|
+
if (event.origin !== this.parentOrigin && !this.isDevelopment() && !this.isPreview()) {
|
|
57
|
+
console.warn('[TileBridge] Received message from untrusted origin:', event.origin, 'expected:', this.parentOrigin);
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
60
|
+
if (this.isDevelopment() || this.isPreview()) {
|
|
61
|
+
console.log('[TileBridge] Received message:', {
|
|
62
|
+
type: event.data?.type,
|
|
63
|
+
origin: event.origin,
|
|
64
|
+
expectedOrigin: this.parentOrigin,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
59
67
|
const message = event.data;
|
|
60
68
|
// Handle system messages
|
|
61
69
|
switch (message.type) {
|
|
@@ -107,12 +115,24 @@ export class TileBridge {
|
|
|
107
115
|
timestamp: Date.now(),
|
|
108
116
|
id: message.id || this.generateId(),
|
|
109
117
|
};
|
|
110
|
-
//
|
|
111
|
-
|
|
118
|
+
// In preview mode, skip the ready check and send messages immediately
|
|
119
|
+
// Preview doesn't need the full config handshake for basic navigation
|
|
120
|
+
const isPreviewOrDev = this.isPreview() || this.isDevelopment();
|
|
121
|
+
// Queue if not ready (except in preview/dev where we send immediately)
|
|
122
|
+
if (!this.ready && !isPreviewOrDev && message.type !== 'tile:ready' && message.type !== 'tile:request-config') {
|
|
123
|
+
if (this.isDevelopment() || this.isPreview()) {
|
|
124
|
+
console.log('[TileBridge] Queueing message (not ready yet):', message.type);
|
|
125
|
+
}
|
|
112
126
|
this.messageQueue.push(fullMessage);
|
|
113
127
|
return;
|
|
114
128
|
}
|
|
115
129
|
// Send to parent
|
|
130
|
+
if (this.isDevelopment() || this.isPreview()) {
|
|
131
|
+
console.log('[TileBridge] 📤 Sending message to parent:', {
|
|
132
|
+
type: message.type,
|
|
133
|
+
parentOrigin: this.parentOrigin,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
116
136
|
window.parent.postMessage(fullMessage, this.parentOrigin);
|
|
117
137
|
}
|
|
118
138
|
// Public API
|
|
@@ -120,10 +140,11 @@ export class TileBridge {
|
|
|
120
140
|
* Request to navigate to full page view
|
|
121
141
|
*/
|
|
122
142
|
navigateToPage() {
|
|
123
|
-
if (this.isDevelopment()) {
|
|
143
|
+
if (this.isDevelopment() || this.isPreview()) {
|
|
124
144
|
console.log('[TileBridge] Requesting navigation to page', {
|
|
125
145
|
ready: this.ready,
|
|
126
146
|
parentOrigin: this.parentOrigin,
|
|
147
|
+
currentOrigin: window.location.origin,
|
|
127
148
|
});
|
|
128
149
|
}
|
|
129
150
|
this.sendToParent({
|
|
@@ -390,6 +411,10 @@ export class TileBridge {
|
|
|
390
411
|
(window.location.hostname === 'localhost' ||
|
|
391
412
|
window.location.hostname === '127.0.0.1');
|
|
392
413
|
}
|
|
414
|
+
isPreview() {
|
|
415
|
+
return typeof window !== 'undefined' &&
|
|
416
|
+
window.location.hostname === 'api.thewhatever.app';
|
|
417
|
+
}
|
|
393
418
|
}
|
|
394
419
|
// Singleton instance
|
|
395
420
|
let bridgeInstance = null;
|