@phpsandbox/sdk 0.0.2
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/README.md +718 -0
- package/dist/auth.d.ts +14 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +12 -0
- package/dist/auth.js.map +1 -0
- package/dist/beacon/index.d.ts +169 -0
- package/dist/beacon/index.d.ts.map +1 -0
- package/dist/beacon/index.js +537 -0
- package/dist/beacon/index.js.map +1 -0
- package/dist/beacon/navigator.d.ts +141 -0
- package/dist/beacon/navigator.d.ts.map +1 -0
- package/dist/beacon/navigator.js +246 -0
- package/dist/beacon/navigator.js.map +1 -0
- package/dist/beacon/types.d.ts +230 -0
- package/dist/beacon/types.d.ts.map +1 -0
- package/dist/beacon/types.js +2 -0
- package/dist/beacon/types.js.map +1 -0
- package/dist/browser/phpsandbox-sdk.esm.js +4755 -0
- package/dist/browser/phpsandbox-sdk.esm.js.map +7 -0
- package/dist/browser/phpsandbox-sdk.esm.min.js +27 -0
- package/dist/browser/phpsandbox-sdk.esm.min.js.map +7 -0
- package/dist/browser/phpsandbox-sdk.iife.js +4766 -0
- package/dist/browser/phpsandbox-sdk.iife.js.map +7 -0
- package/dist/browser/phpsandbox-sdk.iife.min.js +27 -0
- package/dist/browser/phpsandbox-sdk.iife.min.js.map +7 -0
- package/dist/composer.d.ts +45 -0
- package/dist/composer.d.ts.map +1 -0
- package/dist/composer.js +30 -0
- package/dist/composer.js.map +1 -0
- package/dist/container.d.ts +66 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/container.js +56 -0
- package/dist/container.js.map +1 -0
- package/dist/events/index.d.ts +23 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +46 -0
- package/dist/events/index.js.map +1 -0
- package/dist/filesystem.d.ts +483 -0
- package/dist/filesystem.d.ts.map +1 -0
- package/dist/filesystem.js +244 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/git.d.ts +42 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +18 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +167 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +265 -0
- package/dist/index.js.map +1 -0
- package/dist/laravel.d.ts +23 -0
- package/dist/laravel.d.ts.map +1 -0
- package/dist/laravel.js +12 -0
- package/dist/laravel.js.map +1 -0
- package/dist/log.d.ts +13 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +12 -0
- package/dist/log.js.map +1 -0
- package/dist/lsp.d.ts +57 -0
- package/dist/lsp.d.ts.map +1 -0
- package/dist/lsp.js +69 -0
- package/dist/lsp.js.map +1 -0
- package/dist/repl.d.ts +41 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +27 -0
- package/dist/repl.js.map +1 -0
- package/dist/shell.d.ts +29 -0
- package/dist/shell.d.ts.map +1 -0
- package/dist/shell.js +29 -0
- package/dist/shell.js.map +1 -0
- package/dist/socket/index.d.ts +229 -0
- package/dist/socket/index.d.ts.map +1 -0
- package/dist/socket/index.js +825 -0
- package/dist/socket/index.js.map +1 -0
- package/dist/terminal.d.ts +97 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/terminal.js +87 -0
- package/dist/terminal.js.map +1 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/disposable.d.ts +7 -0
- package/dist/utils/disposable.d.ts.map +1 -0
- package/dist/utils/disposable.js +20 -0
- package/dist/utils/disposable.js.map +1 -0
- package/dist/utils/promise.d.ts +13 -0
- package/dist/utils/promise.d.ts.map +1 -0
- package/dist/utils/promise.js +21 -0
- package/dist/utils/promise.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { Disposable } from '../types.js';
|
|
2
|
+
import { Beacon } from './index.js';
|
|
3
|
+
export interface NavigationResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
url?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface NavigatorActions {
|
|
9
|
+
visit(url: string): void;
|
|
10
|
+
goBack(): Promise<NavigationResult>;
|
|
11
|
+
goForward(): Promise<NavigationResult>;
|
|
12
|
+
canGoBack: boolean;
|
|
13
|
+
canGoForward: boolean;
|
|
14
|
+
refresh(): Promise<void>;
|
|
15
|
+
getCurrentUrl(): URL;
|
|
16
|
+
on<K extends keyof NavigatorEvents>(event: K, handler: (payload: NavigatorEvents[K]) => void): Disposable;
|
|
17
|
+
}
|
|
18
|
+
export interface NavigatorEvents {
|
|
19
|
+
historyChange: {
|
|
20
|
+
url: string;
|
|
21
|
+
state: unknown;
|
|
22
|
+
direction: 'back' | 'forward' | 'push' | 'replace' | 'reload';
|
|
23
|
+
timestamp: number;
|
|
24
|
+
};
|
|
25
|
+
navigationStateChange: {
|
|
26
|
+
canGoBack: boolean;
|
|
27
|
+
canGoForward: boolean;
|
|
28
|
+
currentIndex: number;
|
|
29
|
+
historyLength: number;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface HistoryNavigationRequest {
|
|
34
|
+
action: 'back' | 'forward' | 'reload';
|
|
35
|
+
}
|
|
36
|
+
export interface HistoryStateRequest {
|
|
37
|
+
state: unknown;
|
|
38
|
+
title: string;
|
|
39
|
+
url: string;
|
|
40
|
+
action: 'push' | 'replace';
|
|
41
|
+
}
|
|
42
|
+
export interface HistoryInfoResponse {
|
|
43
|
+
length: number;
|
|
44
|
+
state: unknown;
|
|
45
|
+
url: string;
|
|
46
|
+
canGoBack: boolean;
|
|
47
|
+
canGoForward: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface Navigator extends NavigatorActions {
|
|
50
|
+
on<K extends keyof NavigatorEvents>(event: K, handler: (payload: NavigatorEvents[K]) => void): Disposable;
|
|
51
|
+
once<K extends keyof NavigatorEvents>(event: K, handler: (payload: NavigatorEvents[K]) => void): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* SDK Navigator implementation with internal history management
|
|
55
|
+
*/
|
|
56
|
+
export declare class Navigator implements NavigatorActions {
|
|
57
|
+
private onEvent;
|
|
58
|
+
private onceEvent;
|
|
59
|
+
private readonly beacon;
|
|
60
|
+
private urlHistory;
|
|
61
|
+
private currentIndex;
|
|
62
|
+
private _canGoBack;
|
|
63
|
+
private _canGoForward;
|
|
64
|
+
constructor(onEvent: <K extends keyof NavigatorEvents>(event: K, handler: (payload: NavigatorEvents[K]) => void) => Disposable, onceEvent: <K extends keyof NavigatorEvents>(event: K, handler: (payload: NavigatorEvents[K]) => void) => void, beacon: Beacon);
|
|
65
|
+
/**
|
|
66
|
+
* Navigate to a URL using internal history management
|
|
67
|
+
*/
|
|
68
|
+
visit(url: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Set up listener for URL change events from the beacon
|
|
71
|
+
*/
|
|
72
|
+
private setupUrlChangeListener;
|
|
73
|
+
/**
|
|
74
|
+
* Add URL to internal history
|
|
75
|
+
*/
|
|
76
|
+
private addToHistory;
|
|
77
|
+
/**
|
|
78
|
+
* Update internal navigation state and emit changes
|
|
79
|
+
*/
|
|
80
|
+
private updateNavigationState;
|
|
81
|
+
/**
|
|
82
|
+
* Emit navigation state change event
|
|
83
|
+
*/
|
|
84
|
+
private emitNavigationStateChange;
|
|
85
|
+
get canGoBack(): boolean;
|
|
86
|
+
get canGoForward(): boolean;
|
|
87
|
+
goBack(): Promise<NavigationResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Navigate forward in internal history
|
|
90
|
+
*/
|
|
91
|
+
goForward(): Promise<NavigationResult>;
|
|
92
|
+
/**
|
|
93
|
+
* Reload the current page
|
|
94
|
+
*/
|
|
95
|
+
reload(): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Get current URL from internal history
|
|
98
|
+
*/
|
|
99
|
+
getCurrentUrl(): URL;
|
|
100
|
+
/**
|
|
101
|
+
* Get the complete history array
|
|
102
|
+
*/
|
|
103
|
+
getHistory(): readonly string[];
|
|
104
|
+
/**
|
|
105
|
+
* Get current history index
|
|
106
|
+
*/
|
|
107
|
+
getCurrentIndex(): number;
|
|
108
|
+
/**
|
|
109
|
+
* Check if can go back synchronously
|
|
110
|
+
*/
|
|
111
|
+
canGoBackSync(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Check if can go forward synchronously
|
|
114
|
+
*/
|
|
115
|
+
canGoForwardSync(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Emit history change event
|
|
118
|
+
*/
|
|
119
|
+
private emitHistoryChange;
|
|
120
|
+
/**
|
|
121
|
+
* Push a new state to internal history (legacy method for compatibility)
|
|
122
|
+
*/
|
|
123
|
+
pushState(url: string): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Replace current state in internal history (legacy method for compatibility)
|
|
126
|
+
*/
|
|
127
|
+
replaceState(url: string): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Get the current history length
|
|
130
|
+
*/
|
|
131
|
+
getHistoryLength(): Promise<number>;
|
|
132
|
+
/**
|
|
133
|
+
* Get the current history state (always null since we don't store state)
|
|
134
|
+
*/
|
|
135
|
+
getHistoryState(): Promise<any>;
|
|
136
|
+
/**
|
|
137
|
+
* Get comprehensive history information
|
|
138
|
+
*/
|
|
139
|
+
getHistoryInfo(): Promise<HistoryInfoResponse>;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=navigator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator.d.ts","sourceRoot":"","sources":["../../src/beacon/navigator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,C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,CAAC,qBAAqB;IAa7B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAYjC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAEK,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAkBzC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAkB5C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAa7B;;OAEG;IACH,aAAa,IAAI,GAAG;IAQpB;;OAEG;IACH,UAAU,IAAI,SAAS,MAAM,EAAE;IAI/B;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACI,aAAa,IAAI,OAAO;IAI/B;;OAEG;IACI,gBAAgB,IAAI,OAAO;IAIlC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAazB;;OAEG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3C;;OAEG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB9C;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIzC;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;IAIrC;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAuBrD"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Navigator implementation with internal history management
|
|
3
|
+
*/
|
|
4
|
+
export class Navigator {
|
|
5
|
+
constructor(onEvent, onceEvent, beacon) {
|
|
6
|
+
this.onEvent = onEvent;
|
|
7
|
+
this.onceEvent = onceEvent;
|
|
8
|
+
this.beacon = beacon;
|
|
9
|
+
this.urlHistory = [];
|
|
10
|
+
this.currentIndex = 0;
|
|
11
|
+
this._canGoBack = false;
|
|
12
|
+
this._canGoForward = false;
|
|
13
|
+
this.beacon = beacon;
|
|
14
|
+
this.setupUrlChangeListener();
|
|
15
|
+
this.urlHistory.push(beacon.iframe.src);
|
|
16
|
+
this.updateNavigationState();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Navigate to a URL using internal history management
|
|
20
|
+
*/
|
|
21
|
+
visit(url) {
|
|
22
|
+
if (!this.beacon) {
|
|
23
|
+
throw new Error('Beacon reference not set');
|
|
24
|
+
}
|
|
25
|
+
// Navigate the iframe
|
|
26
|
+
this.beacon.navigate(url);
|
|
27
|
+
// Add to history (remove any forward history if we're not at the end)
|
|
28
|
+
if (this.currentIndex < this.urlHistory.length - 1) {
|
|
29
|
+
this.urlHistory = this.urlHistory.slice(0, this.currentIndex + 1);
|
|
30
|
+
}
|
|
31
|
+
this.urlHistory.push(url);
|
|
32
|
+
this.currentIndex = this.urlHistory.length - 1;
|
|
33
|
+
this.updateNavigationState();
|
|
34
|
+
// Emit history change event
|
|
35
|
+
this.emitHistoryChange(url, 'push');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Set up listener for URL change events from the beacon
|
|
39
|
+
*/
|
|
40
|
+
setupUrlChangeListener() {
|
|
41
|
+
this.beacon.on('urlChange', (payload) => {
|
|
42
|
+
this.addToHistory(payload.newUrl);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Add URL to internal history
|
|
47
|
+
*/
|
|
48
|
+
addToHistory(url) {
|
|
49
|
+
// Remove any forward history if we're not at the end
|
|
50
|
+
if (this.currentIndex < this.urlHistory.length - 1) {
|
|
51
|
+
this.urlHistory = this.urlHistory.slice(0, this.currentIndex + 1);
|
|
52
|
+
}
|
|
53
|
+
// Add new URL
|
|
54
|
+
this.urlHistory.push(url);
|
|
55
|
+
this.currentIndex = this.urlHistory.length - 1;
|
|
56
|
+
// Update navigation state
|
|
57
|
+
this.updateNavigationState();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Update internal navigation state and emit changes
|
|
61
|
+
*/
|
|
62
|
+
updateNavigationState() {
|
|
63
|
+
const previousCanGoBack = this._canGoBack;
|
|
64
|
+
const previousCanGoForward = this._canGoForward;
|
|
65
|
+
this._canGoBack = this.currentIndex > 0;
|
|
66
|
+
this._canGoForward = this.currentIndex < this.urlHistory.length - 1;
|
|
67
|
+
// Emit navigation state change if it actually changed
|
|
68
|
+
if (previousCanGoBack !== this._canGoBack || previousCanGoForward !== this._canGoForward) {
|
|
69
|
+
this.emitNavigationStateChange();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Emit navigation state change event
|
|
74
|
+
*/
|
|
75
|
+
emitNavigationStateChange() {
|
|
76
|
+
if (this.beacon && this.beacon.emit) {
|
|
77
|
+
this.beacon.emit('navigationStateChange', {
|
|
78
|
+
canGoBack: this._canGoBack,
|
|
79
|
+
canGoForward: this._canGoForward,
|
|
80
|
+
currentIndex: this.currentIndex,
|
|
81
|
+
historyLength: this.urlHistory.length,
|
|
82
|
+
timestamp: Date.now(),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
get canGoBack() {
|
|
87
|
+
return this._canGoBack;
|
|
88
|
+
}
|
|
89
|
+
get canGoForward() {
|
|
90
|
+
return this._canGoForward;
|
|
91
|
+
}
|
|
92
|
+
async goBack() {
|
|
93
|
+
if (!this.canGoBack) {
|
|
94
|
+
return { success: false, error: 'Cannot go back - no previous history' };
|
|
95
|
+
}
|
|
96
|
+
this.currentIndex--;
|
|
97
|
+
this.updateNavigationState();
|
|
98
|
+
const url = this.urlHistory[this.currentIndex];
|
|
99
|
+
if (!this.beacon) {
|
|
100
|
+
return { success: false, error: 'Beacon reference not set' };
|
|
101
|
+
}
|
|
102
|
+
this.beacon.navigate(url);
|
|
103
|
+
this.emitHistoryChange(url, 'back');
|
|
104
|
+
return { success: true, url };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Navigate forward in internal history
|
|
108
|
+
*/
|
|
109
|
+
async goForward() {
|
|
110
|
+
if (!this.canGoForward) {
|
|
111
|
+
return { success: false, error: 'Cannot go forward - no forward history' };
|
|
112
|
+
}
|
|
113
|
+
this.currentIndex++;
|
|
114
|
+
this.updateNavigationState();
|
|
115
|
+
const url = this.urlHistory[this.currentIndex];
|
|
116
|
+
if (!this.beacon) {
|
|
117
|
+
return { success: false, error: 'Beacon reference not set' };
|
|
118
|
+
}
|
|
119
|
+
this.beacon.navigate(url);
|
|
120
|
+
this.emitHistoryChange(url, 'forward');
|
|
121
|
+
return { success: true, url };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Reload the current page
|
|
125
|
+
*/
|
|
126
|
+
async reload() {
|
|
127
|
+
if (this.currentIndex >= 0 && this.currentIndex < this.urlHistory.length) {
|
|
128
|
+
const currentUrl = this.urlHistory[this.currentIndex];
|
|
129
|
+
if (!this.beacon) {
|
|
130
|
+
throw new Error('Beacon reference not set');
|
|
131
|
+
}
|
|
132
|
+
this.beacon.navigate(currentUrl);
|
|
133
|
+
this.emitHistoryChange(currentUrl, 'reload');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get current URL from internal history
|
|
138
|
+
*/
|
|
139
|
+
getCurrentUrl() {
|
|
140
|
+
if (this.currentIndex >= 0 && this.currentIndex < this.urlHistory.length) {
|
|
141
|
+
return new URL(this.urlHistory[this.currentIndex]);
|
|
142
|
+
}
|
|
143
|
+
return new URL('about:blank');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get the complete history array
|
|
147
|
+
*/
|
|
148
|
+
getHistory() {
|
|
149
|
+
return [...this.urlHistory];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get current history index
|
|
153
|
+
*/
|
|
154
|
+
getCurrentIndex() {
|
|
155
|
+
return this.currentIndex;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Check if can go back synchronously
|
|
159
|
+
*/
|
|
160
|
+
canGoBackSync() {
|
|
161
|
+
return this.currentIndex > 0;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Check if can go forward synchronously
|
|
165
|
+
*/
|
|
166
|
+
canGoForwardSync() {
|
|
167
|
+
return this.currentIndex < this.urlHistory.length - 1;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Emit history change event
|
|
171
|
+
*/
|
|
172
|
+
emitHistoryChange(url, direction) {
|
|
173
|
+
// Note: We'll need to emit this through the beacon's event system
|
|
174
|
+
// This would require access to the beacon's emit method
|
|
175
|
+
if (this.beacon && this.beacon.emit) {
|
|
176
|
+
this.beacon.emit('historyChange', {
|
|
177
|
+
url,
|
|
178
|
+
state: null,
|
|
179
|
+
direction,
|
|
180
|
+
timestamp: Date.now(),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Push a new state to internal history (legacy method for compatibility)
|
|
186
|
+
*/
|
|
187
|
+
async pushState(url) {
|
|
188
|
+
// For compatibility, treat this as a navigation
|
|
189
|
+
this.visit(url);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Replace current state in internal history (legacy method for compatibility)
|
|
193
|
+
*/
|
|
194
|
+
async replaceState(url) {
|
|
195
|
+
if (this.currentIndex >= 0 && this.currentIndex < this.urlHistory.length) {
|
|
196
|
+
// Replace the current URL in history
|
|
197
|
+
this.urlHistory[this.currentIndex] = url;
|
|
198
|
+
if (!this.beacon) {
|
|
199
|
+
throw new Error('Beacon reference not set');
|
|
200
|
+
}
|
|
201
|
+
this.beacon.navigate(url);
|
|
202
|
+
this.emitHistoryChange(url, 'replace');
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
// If no current history, treat as push
|
|
206
|
+
this.visit(url);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get the current history length
|
|
211
|
+
*/
|
|
212
|
+
async getHistoryLength() {
|
|
213
|
+
return this.urlHistory.length;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Get the current history state (always null since we don't store state)
|
|
217
|
+
*/
|
|
218
|
+
async getHistoryState() {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Get comprehensive history information
|
|
223
|
+
*/
|
|
224
|
+
async getHistoryInfo() {
|
|
225
|
+
return {
|
|
226
|
+
length: this.urlHistory.length,
|
|
227
|
+
state: null,
|
|
228
|
+
url: this.urlHistory[this.currentIndex] || '',
|
|
229
|
+
canGoBack: this.canGoBack,
|
|
230
|
+
canGoForward: this.canGoForward,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Listen for navigator events
|
|
235
|
+
*/
|
|
236
|
+
on(event, handler) {
|
|
237
|
+
return this.onEvent(event, handler);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Listen for navigator events (once)
|
|
241
|
+
*/
|
|
242
|
+
once(event, handler) {
|
|
243
|
+
this.onceEvent(event, handler);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=navigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator.js","sourceRoot":"","sources":["../../src/beacon/navigator.ts"],"names":[],"mappings":"AA4DA;;GAEG;AACH,MAAM,OAAO,SAAS;IAMpB,YACU,OAAkH,EAClH,SAA8G,EACrG,MAAc;QAFvB,YAAO,GAAP,OAAO,CAA2G;QAClH,cAAS,GAAT,SAAS,CAAqG;QACrG,WAAM,GAAN,MAAM,CAAQ;QARzB,eAAU,GAAa,EAAE,CAAC;QAC1B,iBAAY,GAAG,CAAC,CAAC;QACjB,eAAU,GAAG,KAAK,CAAC;QACnB,kBAAa,GAAG,KAAK,CAAC;QAO5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CA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eAAe;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc;QAClB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;YAC9B,KAAK,EAAE,IAAI;YACX,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;YAC7C,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,EAAE,CAAkC,KAAQ,EAAE,OAA8C;QAC1F,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,IAAI,CAAkC,KAAQ,EAAE,OAA8C;QAC5F,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
export interface BeaconMessage<T = any> {
|
|
2
|
+
type: string;
|
|
3
|
+
payload: T;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
source: 'beacon' | 'parent';
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
export interface BeaconConfig {
|
|
9
|
+
enableUrlTracking?: boolean;
|
|
10
|
+
enableConsoleCapture?: boolean;
|
|
11
|
+
enableErrorCapture?: boolean;
|
|
12
|
+
enableDebugMode?: boolean;
|
|
13
|
+
targetOrigin?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface UrlChangeEvent {
|
|
16
|
+
oldUrl: string;
|
|
17
|
+
newUrl: string;
|
|
18
|
+
timestamp: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ConsoleEvent {
|
|
21
|
+
level: 'log' | 'warn' | 'error' | 'info' | 'debug';
|
|
22
|
+
args: any[];
|
|
23
|
+
timestamp: number;
|
|
24
|
+
stack?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface BeaconErrorEvent {
|
|
27
|
+
message: string;
|
|
28
|
+
filename: string;
|
|
29
|
+
lineno: number;
|
|
30
|
+
colno: number;
|
|
31
|
+
error?: Error;
|
|
32
|
+
stack?: string;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
}
|
|
35
|
+
export interface DebugInfo {
|
|
36
|
+
url: string;
|
|
37
|
+
userAgent: string;
|
|
38
|
+
viewport: {
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
42
|
+
timestamp: number;
|
|
43
|
+
performance?: {
|
|
44
|
+
navigation: any;
|
|
45
|
+
timing: any;
|
|
46
|
+
};
|
|
47
|
+
console?: ConsoleEvent[];
|
|
48
|
+
errors?: BeaconErrorEvent[];
|
|
49
|
+
}
|
|
50
|
+
export interface DebugRequest {
|
|
51
|
+
path: string;
|
|
52
|
+
options?: {
|
|
53
|
+
waitForLoad?: boolean;
|
|
54
|
+
captureScreenshot?: boolean;
|
|
55
|
+
captureConsole?: boolean;
|
|
56
|
+
captureNetworkInfo?: boolean;
|
|
57
|
+
timeout?: number;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export interface DebugResult {
|
|
61
|
+
success: boolean;
|
|
62
|
+
url: string;
|
|
63
|
+
timestamp: number;
|
|
64
|
+
loadTime?: number;
|
|
65
|
+
screenshot?: ArrayBuffer;
|
|
66
|
+
console: ConsoleEvent[];
|
|
67
|
+
errors: BeaconErrorEvent[];
|
|
68
|
+
networkInfo?: NetworkInfo;
|
|
69
|
+
domInfo?: DOMInfo;
|
|
70
|
+
performanceInfo?: PerformanceInfo;
|
|
71
|
+
error?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface NetworkInfo {
|
|
74
|
+
resources: Array<{
|
|
75
|
+
name: string;
|
|
76
|
+
type: string;
|
|
77
|
+
size: number;
|
|
78
|
+
duration: number;
|
|
79
|
+
status?: number;
|
|
80
|
+
}>;
|
|
81
|
+
totalRequests: number;
|
|
82
|
+
totalSize: number;
|
|
83
|
+
loadTime: number;
|
|
84
|
+
}
|
|
85
|
+
export interface DOMInfo {
|
|
86
|
+
title: string;
|
|
87
|
+
elementCount: number;
|
|
88
|
+
headElements: Array<{
|
|
89
|
+
tagName: string;
|
|
90
|
+
attributes: Record<string, string>;
|
|
91
|
+
}>;
|
|
92
|
+
bodySize: {
|
|
93
|
+
scrollWidth: number;
|
|
94
|
+
scrollHeight: number;
|
|
95
|
+
clientWidth: number;
|
|
96
|
+
clientHeight: number;
|
|
97
|
+
};
|
|
98
|
+
metaTags: Array<{
|
|
99
|
+
name?: string;
|
|
100
|
+
property?: string;
|
|
101
|
+
content?: string;
|
|
102
|
+
}>;
|
|
103
|
+
}
|
|
104
|
+
export interface PerformanceInfo {
|
|
105
|
+
navigationTiming: any;
|
|
106
|
+
loadEventEnd: number;
|
|
107
|
+
domContentLoaded: number;
|
|
108
|
+
firstPaint?: number;
|
|
109
|
+
firstContentfulPaint?: number;
|
|
110
|
+
largestContentfulPaint?: number;
|
|
111
|
+
memoryUsage?: {
|
|
112
|
+
used: number;
|
|
113
|
+
total: number;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export interface FetchRequest {
|
|
117
|
+
url: string;
|
|
118
|
+
options?: RequestInit;
|
|
119
|
+
}
|
|
120
|
+
export interface FetchResult<T = unknown> {
|
|
121
|
+
success: boolean;
|
|
122
|
+
response?: {
|
|
123
|
+
status: number;
|
|
124
|
+
statusText: string;
|
|
125
|
+
headers: Record<string, string>;
|
|
126
|
+
body: T;
|
|
127
|
+
url: string;
|
|
128
|
+
redirected: boolean;
|
|
129
|
+
type: ResponseType;
|
|
130
|
+
};
|
|
131
|
+
error?: string;
|
|
132
|
+
timestamp: number;
|
|
133
|
+
}
|
|
134
|
+
export interface BeaconActions {
|
|
135
|
+
ping: () => Promise<boolean>;
|
|
136
|
+
getDebugInfo: () => Promise<DebugInfo>;
|
|
137
|
+
getConsoleEvents: () => Promise<ConsoleEvent[]>;
|
|
138
|
+
getErrorEvents: () => Promise<BeaconErrorEvent[]>;
|
|
139
|
+
clearConsole: () => Promise<void>;
|
|
140
|
+
clearErrors: () => Promise<void>;
|
|
141
|
+
executeCode: (code: string) => Promise<{
|
|
142
|
+
success: boolean;
|
|
143
|
+
result?: any;
|
|
144
|
+
error?: string;
|
|
145
|
+
}>;
|
|
146
|
+
inspectElement: (selector: string) => Promise<{
|
|
147
|
+
success: boolean;
|
|
148
|
+
element?: any;
|
|
149
|
+
error?: string;
|
|
150
|
+
}>;
|
|
151
|
+
debug: (request: DebugRequest) => Promise<DebugResult>;
|
|
152
|
+
fetch: (request: FetchRequest) => Promise<FetchResult>;
|
|
153
|
+
}
|
|
154
|
+
export interface BeaconEvents {
|
|
155
|
+
ready: BeaconConfig & {
|
|
156
|
+
url: string;
|
|
157
|
+
timestamp: number;
|
|
158
|
+
};
|
|
159
|
+
urlChange: UrlChangeEvent;
|
|
160
|
+
console: ConsoleEvent;
|
|
161
|
+
error: BeaconErrorEvent;
|
|
162
|
+
pong: {
|
|
163
|
+
timestamp: number;
|
|
164
|
+
};
|
|
165
|
+
debugInfo: DebugInfo;
|
|
166
|
+
consoleEvents: ConsoleEvent[];
|
|
167
|
+
errorEvents: BeaconErrorEvent[];
|
|
168
|
+
codeExecutionResult: {
|
|
169
|
+
success: boolean;
|
|
170
|
+
result?: any;
|
|
171
|
+
error?: string;
|
|
172
|
+
};
|
|
173
|
+
elementInspectionResult: {
|
|
174
|
+
success: boolean;
|
|
175
|
+
element?: any;
|
|
176
|
+
error?: string;
|
|
177
|
+
};
|
|
178
|
+
debugResult: DebugResult;
|
|
179
|
+
fetchResult: FetchResult;
|
|
180
|
+
navigationResult: {
|
|
181
|
+
success: boolean;
|
|
182
|
+
error?: string;
|
|
183
|
+
};
|
|
184
|
+
historyNavigated: {
|
|
185
|
+
success: boolean;
|
|
186
|
+
error?: string;
|
|
187
|
+
action?: string;
|
|
188
|
+
};
|
|
189
|
+
historyStateChanged: {
|
|
190
|
+
success: boolean;
|
|
191
|
+
error?: string;
|
|
192
|
+
action?: string;
|
|
193
|
+
state?: any;
|
|
194
|
+
title?: string;
|
|
195
|
+
url?: string;
|
|
196
|
+
};
|
|
197
|
+
historyChange: {
|
|
198
|
+
url: string;
|
|
199
|
+
state: any;
|
|
200
|
+
direction: 'back' | 'forward' | 'push' | 'replace' | 'reload';
|
|
201
|
+
timestamp: number;
|
|
202
|
+
};
|
|
203
|
+
navigationStateChange: {
|
|
204
|
+
canGoBack: boolean;
|
|
205
|
+
canGoForward: boolean;
|
|
206
|
+
currentIndex: number;
|
|
207
|
+
historyLength: number;
|
|
208
|
+
timestamp: number;
|
|
209
|
+
};
|
|
210
|
+
historyInfo: {
|
|
211
|
+
length: number;
|
|
212
|
+
state: any;
|
|
213
|
+
url: string;
|
|
214
|
+
canGoBack: boolean;
|
|
215
|
+
canGoForward: boolean;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
export interface BeaconOptions {
|
|
219
|
+
timeout?: number;
|
|
220
|
+
targetOrigin?: string;
|
|
221
|
+
debug?: boolean;
|
|
222
|
+
retry?: {
|
|
223
|
+
retries?: number;
|
|
224
|
+
minTimeout?: number;
|
|
225
|
+
maxTimeout?: number;
|
|
226
|
+
factor?: number;
|
|
227
|
+
randomize?: boolean;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/beacon/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,YAAY;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CA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