@tacoreai/web-sdk 1.24.1-beta.3 → 1.24.1-beta.4
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.
|
@@ -121,18 +121,50 @@ const clearPreviewSessionToken = (appId) => {
|
|
|
121
121
|
previewSessionPromiseCache.delete(appId);
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
-
const
|
|
124
|
+
const getBrowserWindowCandidates = () => {
|
|
125
125
|
if (typeof window === "undefined") {
|
|
126
|
-
return
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const candidates = [window];
|
|
130
|
+
for (const candidate of [window.parent, window.top, window.opener]) {
|
|
131
|
+
if (candidate && !candidates.includes(candidate)) {
|
|
132
|
+
candidates.push(candidate);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return candidates;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const readBrowserPreviewBridgeValue = (key) => {
|
|
139
|
+
for (const candidate of getBrowserWindowCandidates()) {
|
|
140
|
+
try {
|
|
141
|
+
const value = String(candidate?.[key] || "").trim();
|
|
142
|
+
if (value) {
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
145
|
+
} catch (error) {
|
|
146
|
+
// Ignore cross-origin window access.
|
|
147
|
+
}
|
|
127
148
|
}
|
|
128
|
-
return
|
|
149
|
+
return "";
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const getBrowserPreviewBridgeBaseUrl = () => {
|
|
153
|
+
return readBrowserPreviewBridgeValue("__TACORE_APPSERVER_PREVIEW_BRIDGE_BASE_URL__").replace(/\/$/, "");
|
|
129
154
|
};
|
|
130
155
|
|
|
131
156
|
const getBrowserPreviewBridgeInvokeUrl = () => {
|
|
132
|
-
|
|
157
|
+
const rawUrl = readBrowserPreviewBridgeValue("__TACORE_APPSERVER_PREVIEW_BRIDGE_URL__");
|
|
158
|
+
if (!rawUrl) {
|
|
159
|
+
return "";
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
const url = new URL(rawUrl, typeof window !== "undefined" ? window.location.origin : "http://localhost");
|
|
164
|
+
return url.pathname.endsWith("/appserver-preview/invokeAppServerAPI") ? url.toString() : "";
|
|
165
|
+
} catch (error) {
|
|
133
166
|
return "";
|
|
134
167
|
}
|
|
135
|
-
return String(window.__TACORE_APPSERVER_PREVIEW_BRIDGE_URL__ || "").trim();
|
|
136
168
|
};
|
|
137
169
|
|
|
138
170
|
const appendPreviewInvokeParams = (rawUrl, appId, apiName) => {
|
package/package.json
CHANGED