@proveanything/smartlinks 1.3.9 → 1.3.11
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/docs/API_SUMMARY.md +1 -1
- package/dist/iframeResponder.js +46 -3
- package/docs/API_SUMMARY.md +1 -1
- package/package.json +1 -1
package/dist/docs/API_SUMMARY.md
CHANGED
package/dist/iframeResponder.js
CHANGED
|
@@ -32,6 +32,7 @@ import { collection } from './api/collection';
|
|
|
32
32
|
*/
|
|
33
33
|
export class IframeResponder {
|
|
34
34
|
constructor(options) {
|
|
35
|
+
var _a;
|
|
35
36
|
this.iframe = null;
|
|
36
37
|
this.uploads = new Map();
|
|
37
38
|
this.isInitialLoad = true;
|
|
@@ -39,6 +40,17 @@ export class IframeResponder {
|
|
|
39
40
|
this.resizeHandler = null;
|
|
40
41
|
this.appUrl = null;
|
|
41
42
|
this.resolveReady = null;
|
|
43
|
+
console.log('[IframeResponder] Constructor called', {
|
|
44
|
+
collectionId: options.collectionId,
|
|
45
|
+
appId: options.appId,
|
|
46
|
+
productId: options.productId,
|
|
47
|
+
hasCache: !!options.cache,
|
|
48
|
+
hasCachedApps: !!((_a = options.cache) === null || _a === void 0 ? void 0 : _a.apps),
|
|
49
|
+
});
|
|
50
|
+
console.log('[IframeResponder] SDK version check:', {
|
|
51
|
+
hasCache: typeof cache !== 'undefined',
|
|
52
|
+
hasCacheGetOrFetch: typeof (cache === null || cache === void 0 ? void 0 : cache.getOrFetch) === 'function',
|
|
53
|
+
});
|
|
42
54
|
this.options = options;
|
|
43
55
|
this.cache = options.cache || {};
|
|
44
56
|
// Create ready promise
|
|
@@ -46,9 +58,18 @@ export class IframeResponder {
|
|
|
46
58
|
this.resolveReady = resolve;
|
|
47
59
|
});
|
|
48
60
|
// Start resolving app URL
|
|
49
|
-
this.resolveAppUrl()
|
|
61
|
+
this.resolveAppUrl()
|
|
62
|
+
.then(() => {
|
|
50
63
|
var _a;
|
|
64
|
+
console.log('[IframeResponder] App URL resolved successfully:', this.appUrl);
|
|
51
65
|
(_a = this.resolveReady) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
66
|
+
})
|
|
67
|
+
.catch((err) => {
|
|
68
|
+
var _a, _b, _c;
|
|
69
|
+
console.error('[IframeResponder] App URL resolution failed:', err);
|
|
70
|
+
(_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
71
|
+
// Still resolve to prevent hanging, but with null URL
|
|
72
|
+
(_c = this.resolveReady) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
52
73
|
});
|
|
53
74
|
}
|
|
54
75
|
/**
|
|
@@ -56,7 +77,9 @@ export class IframeResponder {
|
|
|
56
77
|
* Returns the src URL to set on the iframe.
|
|
57
78
|
*/
|
|
58
79
|
async attach(iframe) {
|
|
80
|
+
console.log('[IframeResponder] attach() called, waiting for ready...');
|
|
59
81
|
await this.ready;
|
|
82
|
+
console.log('[IframeResponder] Ready resolved, appUrl:', this.appUrl);
|
|
60
83
|
this.iframe = iframe;
|
|
61
84
|
// Set up message listener
|
|
62
85
|
this.messageHandler = this.handleMessage.bind(this);
|
|
@@ -65,7 +88,9 @@ export class IframeResponder {
|
|
|
65
88
|
this.resizeHandler = this.calculateViewportHeight.bind(this);
|
|
66
89
|
window.addEventListener('resize', this.resizeHandler);
|
|
67
90
|
window.addEventListener('orientationchange', this.resizeHandler);
|
|
68
|
-
|
|
91
|
+
const src = this.buildIframeSrc();
|
|
92
|
+
console.log('[IframeResponder] Built iframe src:', src);
|
|
93
|
+
return src;
|
|
69
94
|
}
|
|
70
95
|
/**
|
|
71
96
|
* Update cached data (e.g., after user logs in).
|
|
@@ -94,31 +119,45 @@ export class IframeResponder {
|
|
|
94
119
|
// ===========================================================================
|
|
95
120
|
async resolveAppUrl() {
|
|
96
121
|
var _a, _b;
|
|
122
|
+
console.log('[IframeResponder] resolveAppUrl started');
|
|
97
123
|
// Use explicit override if provided
|
|
98
124
|
if (this.options.appUrl) {
|
|
99
125
|
this.appUrl = this.options.appUrl;
|
|
126
|
+
console.log('[IframeResponder] Using override URL:', this.appUrl);
|
|
100
127
|
return;
|
|
101
128
|
}
|
|
102
129
|
// Check pre-populated cache
|
|
103
130
|
const cachedApps = this.cache.apps;
|
|
104
131
|
if (cachedApps) {
|
|
132
|
+
console.log('[IframeResponder] Found cached apps:', cachedApps.length);
|
|
105
133
|
const app = cachedApps.find(a => a.id === this.options.appId);
|
|
106
134
|
if (app) {
|
|
107
135
|
this.appUrl = this.getVersionUrl(app);
|
|
136
|
+
console.log('[IframeResponder] Using cached app URL:', this.appUrl);
|
|
108
137
|
return;
|
|
109
138
|
}
|
|
139
|
+
console.log('[IframeResponder] App not found in cache, fetching from API');
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
console.log('[IframeResponder] No cached apps, fetching from API');
|
|
110
143
|
}
|
|
111
144
|
// Fetch from API with caching
|
|
112
145
|
try {
|
|
146
|
+
console.log('[IframeResponder] Calling cache.getOrFetch for apps');
|
|
113
147
|
const appsConfig = await cache.getOrFetch(`apps:${this.options.collectionId}`, () => collection.getAppsConfig(this.options.collectionId), { ttl: 5 * 60 * 1000, storage: 'session' });
|
|
148
|
+
console.log('[IframeResponder] Got appsConfig from API:', appsConfig);
|
|
114
149
|
const apps = appsConfig.apps;
|
|
150
|
+
console.log('[IframeResponder] Extracted apps array:', apps === null || apps === void 0 ? void 0 : apps.length, apps);
|
|
115
151
|
const app = apps.find(a => a.id === this.options.appId);
|
|
116
152
|
if (!app) {
|
|
153
|
+
console.error('[IframeResponder] App not found:', this.options.appId, 'Available:', apps.map(a => a.id));
|
|
117
154
|
throw new Error(`App "${this.options.appId}" not found in collection "${this.options.collectionId}"`);
|
|
118
155
|
}
|
|
119
156
|
this.appUrl = this.getVersionUrl(app);
|
|
157
|
+
console.log('[IframeResponder] Resolved app URL:', this.appUrl);
|
|
120
158
|
}
|
|
121
159
|
catch (err) {
|
|
160
|
+
console.error('[IframeResponder] resolveAppUrl error:', err);
|
|
122
161
|
(_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
123
162
|
throw err;
|
|
124
163
|
}
|
|
@@ -135,7 +174,9 @@ export class IframeResponder {
|
|
|
135
174
|
// ===========================================================================
|
|
136
175
|
buildIframeSrc() {
|
|
137
176
|
var _a, _b;
|
|
177
|
+
console.log('[IframeResponder] buildIframeSrc called, appUrl:', this.appUrl);
|
|
138
178
|
if (!this.appUrl) {
|
|
179
|
+
console.error('[IframeResponder] Cannot build src - appUrl is null!');
|
|
139
180
|
throw new Error('App URL not resolved');
|
|
140
181
|
}
|
|
141
182
|
const params = new URLSearchParams();
|
|
@@ -188,7 +229,9 @@ export class IframeResponder {
|
|
|
188
229
|
if (hashPath === '/') {
|
|
189
230
|
hashPath = '';
|
|
190
231
|
}
|
|
191
|
-
|
|
232
|
+
const finalUrl = `${base}/#/${hashPath}?${params.toString()}`.replace('/#//', '/#/');
|
|
233
|
+
console.log('[IframeResponder] Final iframe URL:', finalUrl);
|
|
234
|
+
return finalUrl;
|
|
192
235
|
}
|
|
193
236
|
// ===========================================================================
|
|
194
237
|
// Viewport Resize Calculation
|
package/docs/API_SUMMARY.md
CHANGED