@octostar/platform-api 0.5.31 → 0.5.32
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/apis.d.ts +12 -0
- package/dist/apis.d.ts.map +1 -1
- package/dist/apis.js +7 -1
- package/dist/apis.js.map +1 -1
- package/dist/factory.d.ts +127 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +445 -137
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/RemoteDevManager.d.ts +79 -0
- package/dist/lib/RemoteDevManager.d.ts.map +1 -0
- package/dist/lib/RemoteDevManager.js +218 -0
- package/dist/lib/RemoteDevManager.js.map +1 -0
- package/dist/octostar-platform-api.js +854 -190
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +4 -4
package/dist/factory.js
CHANGED
|
@@ -1,172 +1,480 @@
|
|
|
1
1
|
import * as postRobot from 'post-robot';
|
|
2
2
|
import { retry } from './utils';
|
|
3
3
|
import { getPostMessageNames } from './constants';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// assuming cross-origin iframe
|
|
13
|
-
return currentWindow;
|
|
14
|
-
}
|
|
15
|
-
for (let i = 0; i < iframes.length; i += 1) {
|
|
16
|
-
const iframe = iframes[i];
|
|
17
|
-
if (iframe.getAttribute('data-octostar-iframe') === 'true' &&
|
|
18
|
-
iframe.getAttribute('data-octostar-iframe-channel') === channelId) {
|
|
19
|
-
return currentWindow;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// Check if we've reached the top window
|
|
23
|
-
if (!hasParent(currentWindow)) {
|
|
24
|
-
console.error('Top window reached without finding the Octostar window. You are trying to view the app from outside Octostar?');
|
|
25
|
-
// could be an old version of Octostar?
|
|
26
|
-
return currentWindow;
|
|
4
|
+
/**
|
|
5
|
+
* Manages Octostar connection state, including remote dev mode, channel IDs, window references,
|
|
6
|
+
* and connection lifecycle. This is a singleton class accessed via getOctostarConnectionManager().
|
|
7
|
+
*/
|
|
8
|
+
export class OctostarConnectionManager {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.remoteDevWindow = null;
|
|
11
|
+
this.channelIdSubscribers = new Set();
|
|
27
12
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return getOctostarWindow(channelId, currentWindow.parent, depth + 1);
|
|
34
|
-
}
|
|
35
|
-
const handlePostResponse = (response) => {
|
|
36
|
-
if (response.data.error) {
|
|
37
|
-
throw new Error(response.data.error.message);
|
|
13
|
+
/* ------------------------------------------------------------------ */
|
|
14
|
+
/* Private Helpers */
|
|
15
|
+
/* ------------------------------------------------------------------ */
|
|
16
|
+
hasParent(window) {
|
|
17
|
+
return window.parent !== window;
|
|
38
18
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
const callResult = methodTarget(...args);
|
|
48
|
-
const isPromise = callResult instanceof Promise;
|
|
49
|
-
const isPromiseLike = typeof callResult?.then === 'function' && typeof callResult?.catch === 'function';
|
|
50
|
-
if (isPromise || isPromiseLike) {
|
|
51
|
-
return callResult.catch((e) => {
|
|
52
|
-
const methodFullPath = `${options.name}.${prop}()`;
|
|
53
|
-
const error = new Error(`Error calling ${methodFullPath}: ${e.message}`);
|
|
54
|
-
error.stack = `at ${methodFullPath}: ${e.stack}`;
|
|
55
|
-
error.originalError = e;
|
|
56
|
-
throw error;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return callResult;
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return target[prop];
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
function tryFetchingFomAttributes(currentWindow) {
|
|
67
|
-
try {
|
|
68
|
-
const iframes = currentWindow.parent.document.getElementsByTagName('iframe');
|
|
19
|
+
getParentOctostarWindow(channelId, currentWindow = window, depth = 0) {
|
|
20
|
+
let iframes;
|
|
21
|
+
try {
|
|
22
|
+
iframes = currentWindow.document.querySelectorAll('iframe');
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return currentWindow;
|
|
26
|
+
}
|
|
69
27
|
for (const iframe of iframes) {
|
|
70
|
-
if (iframe.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
28
|
+
if (iframe.getAttribute('data-octostar-iframe') === 'true' &&
|
|
29
|
+
iframe.getAttribute('data-octostar-iframe-channel') === channelId) {
|
|
30
|
+
return currentWindow;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (!this.hasParent(currentWindow)) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (depth > 25) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return this.getParentOctostarWindow(channelId, currentWindow.parent, depth + 1);
|
|
40
|
+
}
|
|
41
|
+
tryFetchingFromAttributes(currentWindow) {
|
|
42
|
+
try {
|
|
43
|
+
const iframes = currentWindow.parent.document.getElementsByTagName('iframe');
|
|
44
|
+
for (const iframe of iframes) {
|
|
45
|
+
if (iframe.contentWindow === currentWindow) {
|
|
46
|
+
return iframe.getAttribute('data-octostar-iframe-channel') ?? undefined;
|
|
76
47
|
}
|
|
77
48
|
}
|
|
78
49
|
}
|
|
50
|
+
catch {
|
|
51
|
+
/* ignore */
|
|
52
|
+
}
|
|
79
53
|
return undefined;
|
|
80
54
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
55
|
+
traverseForChannelId(currentWindow = window, depth = 0) {
|
|
56
|
+
if (depth > 25)
|
|
57
|
+
return undefined;
|
|
58
|
+
// Try to read octostarChannelId from window, but handle SecurityError for cross-origin windows
|
|
59
|
+
try {
|
|
60
|
+
if (currentWindow.octostarChannelId) {
|
|
61
|
+
return currentWindow.octostarChannelId;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// SecurityError on cross-origin windows - continue to fallback mechanisms
|
|
66
|
+
}
|
|
67
|
+
// Try to get channelId from URL query params
|
|
68
|
+
try {
|
|
69
|
+
if (currentWindow.location.search) {
|
|
70
|
+
const params = new URLSearchParams(currentWindow.location.search);
|
|
71
|
+
const fromQuery = params.get('octostarChannelId');
|
|
72
|
+
if (fromQuery) {
|
|
73
|
+
window.octostarChannelId = fromQuery;
|
|
74
|
+
return fromQuery;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Cross-origin iframe - can't access location
|
|
80
|
+
// Continue to try other methods
|
|
81
|
+
}
|
|
82
|
+
// Try fetching from iframe attributes (only works if we can access parent)
|
|
83
|
+
try {
|
|
84
|
+
const fromAttrs = this.tryFetchingFromAttributes(currentWindow);
|
|
85
|
+
if (fromAttrs) {
|
|
86
|
+
window.octostarChannelId = fromAttrs;
|
|
87
|
+
return fromAttrs;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Ignore errors
|
|
92
|
+
}
|
|
93
|
+
// Try parent window
|
|
94
|
+
try {
|
|
95
|
+
return this.traverseForChannelId(currentWindow.parent, depth + 1);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Cross-origin parent - can't traverse further
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
84
101
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (depth > 25) {
|
|
89
|
-
throw new Error('PostRobot: Max depth reached. octostarChannelId not found.');
|
|
102
|
+
clearConnectionHistory() {
|
|
103
|
+
sessionStorage.removeItem('octostarRemoteDevWasConnected');
|
|
104
|
+
sessionStorage.removeItem('octostarRemoteDevIntentionallyDisconnected');
|
|
90
105
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
106
|
+
notifyChannelIdChanged(channelId) {
|
|
107
|
+
this.channelIdSubscribers.forEach(callback => {
|
|
108
|
+
callback(channelId);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
handlePostResponse(response) {
|
|
112
|
+
if (response.data.error) {
|
|
113
|
+
throw new Error(response.data.error.message);
|
|
95
114
|
}
|
|
115
|
+
return response.data.data;
|
|
96
116
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
117
|
+
createObjectProxy(value, options) {
|
|
118
|
+
return new Proxy(value, {
|
|
119
|
+
get: (target, prop) => {
|
|
120
|
+
if (typeof target[prop] === 'function') {
|
|
121
|
+
return new Proxy(target[prop], {
|
|
122
|
+
apply: (methodTarget, _, args) => {
|
|
123
|
+
const result = methodTarget(...args);
|
|
124
|
+
if (result?.then) {
|
|
125
|
+
return result.catch((e) => {
|
|
126
|
+
const path = `${options.name}.${String(prop)}()`;
|
|
127
|
+
const err = new Error(`Error calling ${path}: ${e.message}`);
|
|
128
|
+
err.originalError = e;
|
|
129
|
+
throw err;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return target[prop];
|
|
137
|
+
},
|
|
138
|
+
});
|
|
100
139
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
140
|
+
/* ------------------------------------------------------------------ */
|
|
141
|
+
/* Public API - Window Management */
|
|
142
|
+
/* ------------------------------------------------------------------ */
|
|
143
|
+
/**
|
|
144
|
+
* Sets the remote dev window reference.
|
|
145
|
+
* This should be called when opening a remote dev window from a React component.
|
|
146
|
+
*/
|
|
147
|
+
setWindow(window) {
|
|
148
|
+
this.remoteDevWindow = window;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Gets the remote dev window reference.
|
|
152
|
+
*/
|
|
153
|
+
getWindow() {
|
|
154
|
+
return this.remoteDevWindow;
|
|
155
|
+
}
|
|
156
|
+
/* ------------------------------------------------------------------ */
|
|
157
|
+
/* Public API - Channel ID Management */
|
|
158
|
+
/* ------------------------------------------------------------------ */
|
|
159
|
+
/**
|
|
160
|
+
* Gets or creates a remote dev channel ID.
|
|
161
|
+
* If a channel ID already exists in sessionStorage, returns it.
|
|
162
|
+
* Otherwise, generates a new one and stores it.
|
|
163
|
+
*/
|
|
164
|
+
getOrCreateChannelId() {
|
|
165
|
+
const key = 'octostarRemoteDevChannelId';
|
|
166
|
+
const existing = sessionStorage.getItem(key);
|
|
167
|
+
if (existing)
|
|
168
|
+
return existing;
|
|
169
|
+
const generated = typeof crypto !== 'undefined' && 'randomUUID' in crypto
|
|
170
|
+
? crypto.randomUUID()
|
|
171
|
+
: `rd-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
172
|
+
sessionStorage.setItem(key, generated);
|
|
173
|
+
return generated;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Checks if a remote dev channel ID exists without creating one.
|
|
177
|
+
* Used to determine if a connection attempt has been made.
|
|
178
|
+
*/
|
|
179
|
+
hasChannelId() {
|
|
180
|
+
const key = 'octostarRemoteDevChannelId';
|
|
181
|
+
return sessionStorage.getItem(key) !== null;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Subscribe to remote dev channel ID changes.
|
|
185
|
+
* Returns an unsubscribe function.
|
|
186
|
+
*/
|
|
187
|
+
onChannelIdChanged(callback) {
|
|
188
|
+
this.channelIdSubscribers.add(callback);
|
|
189
|
+
return () => this.channelIdSubscribers.delete(callback);
|
|
190
|
+
}
|
|
191
|
+
/* ------------------------------------------------------------------ */
|
|
192
|
+
/* Public API - Connection State */
|
|
193
|
+
/* ------------------------------------------------------------------ */
|
|
194
|
+
/**
|
|
195
|
+
* Marks that a successful remote dev connection was established.
|
|
196
|
+
* This is called when a connection is successfully made (e.g., ping succeeds).
|
|
197
|
+
*/
|
|
198
|
+
markConnectionSuccess() {
|
|
199
|
+
sessionStorage.setItem('octostarRemoteDevWasConnected', 'true');
|
|
200
|
+
// Clear intentional disconnect flag since we're now connected
|
|
201
|
+
sessionStorage.removeItem('octostarRemoteDevIntentionallyDisconnected');
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Marks whether the remote dev connection was intentionally disconnected.
|
|
205
|
+
* @param intentionallyDisconnected - true if user clicked Disconnect/Reset, false if user is trying to connect
|
|
206
|
+
*/
|
|
207
|
+
markIntentionallyDisconnected(intentionallyDisconnected) {
|
|
208
|
+
if (intentionallyDisconnected) {
|
|
209
|
+
sessionStorage.setItem('octostarRemoteDevIntentionallyDisconnected', 'true');
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
sessionStorage.removeItem('octostarRemoteDevIntentionallyDisconnected');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Returns whether a successful remote dev connection was ever established in this session.
|
|
217
|
+
* This persists across component remounts and page refreshes (within the same session).
|
|
218
|
+
* Only returns true if a channel ID exists (fixes initial load bug).
|
|
219
|
+
*/
|
|
220
|
+
wasEverConnected() {
|
|
221
|
+
// Only return true if we have evidence of a connection attempt (channel ID exists)
|
|
222
|
+
// This prevents showing "CONNECTION LOST" on initial load when sessionStorage has stale data
|
|
223
|
+
return this.hasChannelId() && sessionStorage.getItem('octostarRemoteDevWasConnected') === 'true';
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Returns whether the remote dev connection was intentionally disconnected.
|
|
227
|
+
* This is used to determine whether to show "Connect" vs "Reconnect" button.
|
|
228
|
+
*/
|
|
229
|
+
wasIntentionallyDisconnected() {
|
|
230
|
+
return sessionStorage.getItem('octostarRemoteDevIntentionallyDisconnected') === 'true';
|
|
231
|
+
}
|
|
232
|
+
/* ------------------------------------------------------------------ */
|
|
233
|
+
/* Public API - URL Management */
|
|
234
|
+
/* ------------------------------------------------------------------ */
|
|
235
|
+
/**
|
|
236
|
+
* Gets the remote dev URL from sessionStorage.
|
|
237
|
+
* Returns empty string if not set.
|
|
238
|
+
*/
|
|
239
|
+
getUrl() {
|
|
240
|
+
return sessionStorage.getItem('octostarRemoteDevUrl') || '';
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Sets the remote dev URL in sessionStorage.
|
|
244
|
+
*/
|
|
245
|
+
setUrl(url) {
|
|
246
|
+
sessionStorage.setItem('octostarRemoteDevUrl', url);
|
|
247
|
+
}
|
|
248
|
+
/* ------------------------------------------------------------------ */
|
|
249
|
+
/* Public API - Mode Detection */
|
|
250
|
+
/* ------------------------------------------------------------------ */
|
|
251
|
+
/**
|
|
252
|
+
* Returns true when the app is not in connected iframe mode (no octostarChannelId found in URL or
|
|
253
|
+
* iframe chain), i.e. running in remote dev mode. Returns false when running inside an Octostar
|
|
254
|
+
* iframe (embedded).
|
|
255
|
+
*/
|
|
256
|
+
isRemoteDevMode() {
|
|
257
|
+
if (this.resolvedMode) {
|
|
258
|
+
return this.resolvedMode.mode === 'remote';
|
|
259
|
+
}
|
|
260
|
+
return this.traverseForChannelId() === undefined;
|
|
261
|
+
}
|
|
262
|
+
/* ------------------------------------------------------------------ */
|
|
263
|
+
/* Public API - Connection Lifecycle */
|
|
264
|
+
/* ------------------------------------------------------------------ */
|
|
265
|
+
/**
|
|
266
|
+
* Clears resolvedMode if the channel ID has changed.
|
|
267
|
+
* This is called when SET_CHANNEL_ID message is received to ensure
|
|
268
|
+
* createRemoteApiHandle re-resolves with the new channel ID.
|
|
269
|
+
* @param newChannelId - The new channel ID that was set
|
|
270
|
+
*/
|
|
271
|
+
clearResolvedModeIfChannelChanged(newChannelId) {
|
|
272
|
+
if (this.resolvedMode && this.resolvedMode.mode === 'iframe') {
|
|
273
|
+
if (this.resolvedMode.channelId !== newChannelId) {
|
|
274
|
+
console.log('PostRobot: channel ID changed, clearing cached resolvedMode', {
|
|
275
|
+
old: this.resolvedMode.channelId,
|
|
276
|
+
new: newChannelId,
|
|
277
|
+
});
|
|
278
|
+
this.resolvedMode = undefined;
|
|
110
279
|
}
|
|
111
280
|
}
|
|
112
281
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
282
|
+
/**
|
|
283
|
+
* Resets the remote dev connection state.
|
|
284
|
+
* This clears the resolved mode and window reference, allowing the connection to be re-established.
|
|
285
|
+
* Should be called when connection is lost and user wants to reconnect.
|
|
286
|
+
*/
|
|
287
|
+
resetConnection() {
|
|
288
|
+
// Clear resolved mode to force re-resolution on next API call
|
|
289
|
+
this.resolvedMode = undefined;
|
|
290
|
+
// Clear remote dev window if it's closed
|
|
291
|
+
if (this.remoteDevWindow && this.remoteDevWindow.closed) {
|
|
292
|
+
this.remoteDevWindow = null;
|
|
293
|
+
}
|
|
116
294
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Resets remote dev mode by closing the window and clearing all connection state.
|
|
297
|
+
* This puts the app back into a disconnected startup state.
|
|
298
|
+
* A new channel ID will be generated automatically when the user clicks Connect.
|
|
299
|
+
*/
|
|
300
|
+
resetMode() {
|
|
301
|
+
// Close the remote dev window if it's open
|
|
302
|
+
if (this.remoteDevWindow && !this.remoteDevWindow.closed) {
|
|
303
|
+
this.remoteDevWindow.close();
|
|
122
304
|
}
|
|
305
|
+
// Get the old channel ID before clearing it, so we can clear its cached app mapping
|
|
306
|
+
const oldChannelId = sessionStorage.getItem('octostarRemoteDevChannelId');
|
|
307
|
+
// Clear the old channel ID from sessionStorage
|
|
308
|
+
sessionStorage.removeItem('octostarRemoteDevChannelId');
|
|
309
|
+
// Clear the cached app entity mapping for the old channel ID
|
|
310
|
+
// Note: mappings are stored in localStorage (not sessionStorage) to persist across tab closes
|
|
311
|
+
// Only clear the mapping for this specific channel to avoid invalidating other active remote dev sessions
|
|
312
|
+
if (oldChannelId) {
|
|
313
|
+
const mappingKey = `octostarRemoteDevMapping-${oldChannelId}`;
|
|
314
|
+
localStorage.removeItem(mappingKey);
|
|
315
|
+
}
|
|
316
|
+
// Clear resolved mode to force re-resolution on next API call
|
|
317
|
+
this.resolvedMode = undefined;
|
|
318
|
+
// Clear remote dev window reference
|
|
319
|
+
this.remoteDevWindow = null;
|
|
320
|
+
// Clear connection history
|
|
321
|
+
this.clearConnectionHistory();
|
|
322
|
+
// Don't generate a new channel ID or notify subscribers here
|
|
323
|
+
// A new channel ID will be created when openWindow() is called
|
|
123
324
|
}
|
|
124
|
-
|
|
125
|
-
|
|
325
|
+
/**
|
|
326
|
+
* Opens a remote dev window with the given URL.
|
|
327
|
+
* This function:
|
|
328
|
+
* - Validates the URL
|
|
329
|
+
* - Saves it to sessionStorage
|
|
330
|
+
* - Gets or creates a channel ID
|
|
331
|
+
* - Adds remoteDevChannelId as a URL parameter
|
|
332
|
+
* - Opens the window and stores the reference
|
|
333
|
+
* - Returns the window or null if popup was blocked
|
|
334
|
+
*/
|
|
335
|
+
openWindow(url) {
|
|
336
|
+
if (!url) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
// Save URL to sessionStorage
|
|
340
|
+
this.setUrl(url);
|
|
341
|
+
// Mark that user is trying to connect (not intentionally disconnected)
|
|
342
|
+
this.markIntentionallyDisconnected(false);
|
|
343
|
+
// Check if channel ID already exists
|
|
344
|
+
const key = 'octostarRemoteDevChannelId';
|
|
345
|
+
const existingChannelId = sessionStorage.getItem(key);
|
|
346
|
+
// Get or create channel ID
|
|
347
|
+
const channelId = this.getOrCreateChannelId();
|
|
348
|
+
// Notify subscribers if this is a new channel ID (created after reset)
|
|
349
|
+
if (!existingChannelId) {
|
|
350
|
+
this.notifyChannelIdChanged(channelId);
|
|
351
|
+
}
|
|
352
|
+
// Add remoteDevChannelId as a URL parameter
|
|
353
|
+
let urlObj;
|
|
354
|
+
try {
|
|
355
|
+
urlObj = new URL(url);
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
// Invalid URL - return null to indicate failure (consistent with popup blocked behavior)
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
urlObj.searchParams.set('remoteDevChannelId', channelId);
|
|
362
|
+
// Open window
|
|
363
|
+
const win = window.open(urlObj.toString(), channelId);
|
|
364
|
+
if (!win) {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
// Store window reference
|
|
368
|
+
this.setWindow(win);
|
|
369
|
+
return win;
|
|
126
370
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
371
|
+
/* ------------------------------------------------------------------ */
|
|
372
|
+
/* Public API - API Creation */
|
|
373
|
+
/* ------------------------------------------------------------------ */
|
|
374
|
+
/**
|
|
375
|
+
* Creates a remote API handle for communicating with Octostar.
|
|
376
|
+
* This resolves the connection mode (iframe vs remote dev) and sets up post-robot communication.
|
|
377
|
+
*/
|
|
378
|
+
async createRemoteApiHandle(params) {
|
|
379
|
+
// Resolve once, reuse forever
|
|
380
|
+
if (!this.resolvedMode) {
|
|
381
|
+
const iframeChannelId = this.traverseForChannelId();
|
|
382
|
+
if (iframeChannelId) {
|
|
383
|
+
const targetWindow = this.getParentOctostarWindow(iframeChannelId);
|
|
384
|
+
if (!targetWindow) {
|
|
385
|
+
throw new Error('PostRobot: iframe channel found but no Octostar window');
|
|
386
|
+
}
|
|
387
|
+
this.resolvedMode = {
|
|
388
|
+
mode: 'iframe',
|
|
389
|
+
channelId: iframeChannelId,
|
|
390
|
+
targetWindow,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
const channelId = this.getOrCreateChannelId();
|
|
395
|
+
let targetWindow = this.remoteDevWindow;
|
|
396
|
+
// Check if existing window is closed, and clear it if so
|
|
397
|
+
if (targetWindow?.closed) {
|
|
398
|
+
this.remoteDevWindow = null;
|
|
399
|
+
targetWindow = null;
|
|
400
|
+
}
|
|
401
|
+
if (!targetWindow) {
|
|
402
|
+
// Don't automatically open window - user must click "Connect" or "Reconnect"
|
|
403
|
+
throw new Error('Remote dev window not open. Please click "Connect" or "Reconnect" to open the Octostar window.');
|
|
404
|
+
}
|
|
405
|
+
console.log('PostRobot: No iframe detected → remote dev mode', channelId);
|
|
406
|
+
this.resolvedMode = {
|
|
407
|
+
mode: 'remote',
|
|
408
|
+
channelId,
|
|
409
|
+
targetWindow,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const { channelId, targetWindow, mode } = this.resolvedMode;
|
|
414
|
+
const topic = getPostMessageNames(channelId).get_api;
|
|
415
|
+
console.debug('PostRobot: sending get_api', topic, params?.name);
|
|
416
|
+
// Use different retry parameters based on connection mode:
|
|
417
|
+
// - iframe mode: fail fast (3 attempts) since parent window should be immediately available
|
|
418
|
+
// - remote mode: retry many times (100 attempts) since Octostar window may take a while to open
|
|
419
|
+
const retryOptions = mode === 'iframe'
|
|
420
|
+
? {
|
|
421
|
+
maxAttempts: 3,
|
|
422
|
+
retryInterval: 1000,
|
|
423
|
+
}
|
|
424
|
+
: {
|
|
425
|
+
maxAttempts: 100,
|
|
426
|
+
retryInterval: 1000,
|
|
427
|
+
};
|
|
428
|
+
const response = await retry(() => {
|
|
429
|
+
const actualTargetWindow = this.remoteDevWindow ?? targetWindow;
|
|
430
|
+
return postRobot.send(actualTargetWindow, topic, params);
|
|
431
|
+
}, retryOptions);
|
|
432
|
+
const api = this.handlePostResponse(response);
|
|
433
|
+
return this.createObjectProxy(api, { name: params.name });
|
|
130
434
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
435
|
+
}
|
|
436
|
+
/* ------------------------------------------------------------------ */
|
|
437
|
+
/* Singleton Pattern */
|
|
438
|
+
/* ------------------------------------------------------------------ */
|
|
439
|
+
let instance = null;
|
|
440
|
+
/**
|
|
441
|
+
* Gets the singleton instance of OctostarConnectionManager.
|
|
442
|
+
* Creates a new instance if one doesn't exist.
|
|
443
|
+
*/
|
|
444
|
+
export function getOctostarConnectionManager() {
|
|
445
|
+
if (!instance) {
|
|
446
|
+
instance = new OctostarConnectionManager();
|
|
135
447
|
}
|
|
448
|
+
return instance;
|
|
136
449
|
}
|
|
450
|
+
/* ------------------------------------------------------------------ */
|
|
451
|
+
/* Standalone Functions (used internally) */
|
|
452
|
+
/* ------------------------------------------------------------------ */
|
|
453
|
+
// Listen for SET_CHANNEL_ID messages and update channel ID + clear cached resolvedMode
|
|
137
454
|
window.addEventListener('message', event => {
|
|
138
|
-
if (event.data?.type === 'SET_CHANNEL_ID') {
|
|
139
|
-
|
|
140
|
-
|
|
455
|
+
if (event.data?.type === 'SET_CHANNEL_ID' && typeof event.data.channelId === 'string') {
|
|
456
|
+
const newChannelId = event.data.channelId;
|
|
457
|
+
window.octostarChannelId = newChannelId;
|
|
458
|
+
console.log('PostRobot: received channelId', newChannelId);
|
|
459
|
+
// Clear cached resolvedMode if channel ID changed and we're in iframe mode
|
|
460
|
+
// This ensures createRemoteApiHandle re-resolves with the new channel ID
|
|
461
|
+
const manager = getOctostarConnectionManager();
|
|
462
|
+
manager.clearResolvedModeIfChannelChanged(newChannelId);
|
|
141
463
|
}
|
|
142
464
|
});
|
|
465
|
+
/**
|
|
466
|
+
* Creates a remote API handle. This is a convenience function that delegates to the manager.
|
|
467
|
+
* @deprecated Use getOctostarConnectionManager().createRemoteApiHandle() instead
|
|
468
|
+
*/
|
|
143
469
|
export const createRemoteApiHandle = async (params) => {
|
|
144
|
-
|
|
145
|
-
if (!channelId) {
|
|
146
|
-
throw new Error('PostRobot: No channelId found');
|
|
147
|
-
}
|
|
148
|
-
const octostarWindow = getOctostarWindow(channelId);
|
|
149
|
-
console.log(`PostRobot: Trying to get handle ${channelId}`);
|
|
150
|
-
const topic = getPostMessageNames(channelId).get_api;
|
|
151
|
-
try {
|
|
152
|
-
const response = await retry(() => postRobot.send(octostarWindow, topic, params), {
|
|
153
|
-
maxAttempts: 5,
|
|
154
|
-
retryInterval: 2000,
|
|
155
|
-
});
|
|
156
|
-
console.log(`PostRobot: Got remote api handle for ${params.name} on ${channelId}`);
|
|
157
|
-
const api = handlePostResponse(response);
|
|
158
|
-
return createObjectProxy(api, {
|
|
159
|
-
name: params.name,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
catch (e) {
|
|
163
|
-
console.log(`PostRobot: Error while trying to create remote API handle on ${topic}`, e);
|
|
164
|
-
throw e;
|
|
165
|
-
}
|
|
470
|
+
return getOctostarConnectionManager().createRemoteApiHandle(params);
|
|
166
471
|
};
|
|
472
|
+
/**
|
|
473
|
+
* Forwards calls to a future object. Used for creating proxies that forward to promises.
|
|
474
|
+
*/
|
|
167
475
|
export const forwardCallsToFutureObject = (chain) => new Proxy({}, {
|
|
168
|
-
get: (
|
|
169
|
-
apply: (
|
|
476
|
+
get: (_, prop) => new Proxy(() => { }, {
|
|
477
|
+
apply: (_, __, args) => chain.then((obj) => obj[prop](...args)),
|
|
170
478
|
}),
|
|
171
479
|
});
|
|
172
480
|
//# sourceMappingURL=factory.js.map
|
package/dist/factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,SAAS,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;AAExE,SAAS,iBAAiB,CAAC,SAAiB,EAAE,gBAAwB,MAAM,EAAE,KAAK,GAAG,CAAC;IACrF,0CAA0C;IAC1C,IAAI,OAAsC,CAAC;IAC3C,IAAI,CAAC;QACH,OAAO,GAA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