@shaper.org/core 1.0.7 → 1.1.0-0
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/client/index.d.mts +85 -2
- package/dist/client/index.mjs +111 -2
- package/dist/runtime/error-tracker.ts +1 -2
- package/package.json +1 -1
- package/dist/runtime/vite-hook.ts +0 -133
package/dist/client/index.d.mts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { ErrorPayload, FullReloadPayload, PrunePayload, UpdatePayload } from "vite/types/hmrPayload.js";
|
|
2
|
+
import { ViteHotContext } from "vite/types/hot.js";
|
|
3
|
+
|
|
1
4
|
//#region src/client/iframe-post-message.d.ts
|
|
2
|
-
type PostMessageType = "server-ready" | "all-routes" | "route-change" | "route-refresh" | "error";
|
|
5
|
+
type PostMessageType = "server-ready" | "all-routes" | "route-change" | "route-refresh" | "error" | "inspector-tree-update" | "inspector-selected-node" | "inspector-reset-inline-style";
|
|
3
6
|
interface PostMessage {
|
|
4
7
|
message: any;
|
|
5
8
|
type: PostMessageType;
|
|
@@ -39,6 +42,17 @@ interface ErrorInfo {
|
|
|
39
42
|
has_blank_screen: boolean;
|
|
40
43
|
filename?: string;
|
|
41
44
|
}
|
|
45
|
+
interface SelectedNode {
|
|
46
|
+
file: string;
|
|
47
|
+
line: number;
|
|
48
|
+
column: number;
|
|
49
|
+
attributes: Record<string, string>;
|
|
50
|
+
}
|
|
51
|
+
interface InspectorNode {
|
|
52
|
+
id: string;
|
|
53
|
+
tag: string;
|
|
54
|
+
children: InspectorNode[];
|
|
55
|
+
}
|
|
42
56
|
declare class IframePostMessageClient {
|
|
43
57
|
authHost: string;
|
|
44
58
|
private receiveCallbacks;
|
|
@@ -56,6 +70,75 @@ declare class IframePostMessageClient {
|
|
|
56
70
|
sendRouteRefresh(route: RouteInfo): void;
|
|
57
71
|
sendError(errorInfo: ErrorInfo): void;
|
|
58
72
|
sendConsole(): void;
|
|
73
|
+
sendSelectedNode(node: SelectedNode): void;
|
|
74
|
+
sendTree(tree: InspectorNode): void;
|
|
75
|
+
}
|
|
76
|
+
interface ReceiveBaseMessage {
|
|
77
|
+
object: "shaper-post-action";
|
|
78
|
+
_source: "workspace";
|
|
79
|
+
type: string;
|
|
80
|
+
data: any;
|
|
81
|
+
}
|
|
82
|
+
interface WorkspaceModeMessage extends ReceiveBaseMessage {
|
|
83
|
+
type: "WORKSPACE_MODE";
|
|
84
|
+
data: {
|
|
85
|
+
mode: "edit" | "view";
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
declare const isWorkspaceModeEvent: (event: MessageEvent<any>) => event is MessageEvent<WorkspaceModeMessage>;
|
|
89
|
+
interface NodeAttributesPatchMessage extends ReceiveBaseMessage {
|
|
90
|
+
type: "NODE_ATTRIBUTES_PATCH";
|
|
91
|
+
data: {
|
|
92
|
+
id: string;
|
|
93
|
+
property: string;
|
|
94
|
+
value: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
declare const isNodeAttributesPatchEvent: (event: MessageEvent<any>) => event is MessageEvent<NodeAttributesPatchMessage>;
|
|
98
|
+
interface NodeAttributesPatchBatchMessage extends ReceiveBaseMessage {
|
|
99
|
+
type: "NODE_ATTRIBUTES_PATCH_BATCH";
|
|
100
|
+
data: {
|
|
101
|
+
selector: string;
|
|
102
|
+
property: string;
|
|
103
|
+
value: string;
|
|
104
|
+
}[];
|
|
105
|
+
}
|
|
106
|
+
declare const isNodeAttributesPatchBatchEvent: (event: MessageEvent<any>) => event is MessageEvent<NodeAttributesPatchBatchMessage>;
|
|
107
|
+
interface SetSelectNodeMessage extends ReceiveBaseMessage {
|
|
108
|
+
type: "SET_SELECT_NODE";
|
|
109
|
+
data: {
|
|
110
|
+
id: string;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
declare const isSetSelectNodeEvent: (event: MessageEvent<any>) => event is MessageEvent<SetSelectNodeMessage>;
|
|
114
|
+
interface SetHoverNodeMessage extends ReceiveBaseMessage {
|
|
115
|
+
type: "SET_HOVER_NODE";
|
|
116
|
+
data: {
|
|
117
|
+
id: string;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
declare const isSetHoverNodeEvent: (event: MessageEvent<any>) => event is MessageEvent<SetSelectNodeMessage>;
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/client/vite-hook.d.ts
|
|
123
|
+
type ViteUpdateCallback = ((data: UpdatePayload, timestamp: number) => void) | null;
|
|
124
|
+
type VitePruneCallback = ((data: PrunePayload, timestamp: number) => void) | null;
|
|
125
|
+
type VitFullReloadCallback = ((data: FullReloadPayload, timestamp: number) => void) | null;
|
|
126
|
+
type ViteErrorCallback = ((data: ErrorPayload, timestamp: number) => void) | null;
|
|
127
|
+
type ViteInvalidateCallback = ((data: any, timestamp: number) => void) | null;
|
|
128
|
+
type ViteWebSocketConnectCallback = ((data: any, timestamp: number) => void) | null;
|
|
129
|
+
type ViteWebSocketDisconnectCallback = ((data: any, timestamp: number) => void) | null;
|
|
130
|
+
declare class ViteHook {
|
|
131
|
+
private hmr;
|
|
132
|
+
constructor();
|
|
133
|
+
hotExists(hmr: ViteHotContext | undefined): hmr is ViteHotContext;
|
|
134
|
+
onBeforeUpdate(fn?: ViteUpdateCallback): void;
|
|
135
|
+
onAfterUpdate(fn?: ViteUpdateCallback): void;
|
|
136
|
+
onBeforePrune(fn?: VitePruneCallback): void;
|
|
137
|
+
onBeforeFullReload(fn?: VitFullReloadCallback): void;
|
|
138
|
+
onError(fn?: ViteErrorCallback): void;
|
|
139
|
+
onInvalidate(fn?: ViteInvalidateCallback): void;
|
|
140
|
+
onWsConnect(fn?: ViteWebSocketConnectCallback): void;
|
|
141
|
+
onWsDisconnect(fn?: ViteWebSocketDisconnectCallback): void;
|
|
59
142
|
}
|
|
60
143
|
//#endregion
|
|
61
|
-
export { AllRoutesMessage, IframePostMessageClient, PostMessage, PostMessageType, RouteChangeMessage, RouteInfo, RouteRefreshMessage, ServerReadyMessage };
|
|
144
|
+
export { AllRoutesMessage, IframePostMessageClient, InspectorNode, NodeAttributesPatchBatchMessage, NodeAttributesPatchMessage, PostMessage, PostMessageType, RouteChangeMessage, RouteInfo, RouteRefreshMessage, ServerReadyMessage, SetHoverNodeMessage, SetSelectNodeMessage, ViteHook, isNodeAttributesPatchBatchEvent, isNodeAttributesPatchEvent, isSetHoverNodeEvent, isSetSelectNodeEvent, isWorkspaceModeEvent };
|
package/dist/client/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ var IframePostMessageClient = class {
|
|
|
23
23
|
this.receiveCallbacks.push(callback);
|
|
24
24
|
}
|
|
25
25
|
onReceiveMessage(message) {
|
|
26
|
-
if (message.origin !== this.authHost) return;
|
|
26
|
+
if (message.origin !== this.authHost || message.data.object !== "shaper-post-action") return;
|
|
27
27
|
for (const cb of this.receiveCallbacks) try {
|
|
28
28
|
cb(message);
|
|
29
29
|
} catch (err) {
|
|
@@ -73,7 +73,116 @@ var IframePostMessageClient = class {
|
|
|
73
73
|
this._send(message);
|
|
74
74
|
}
|
|
75
75
|
sendConsole() {}
|
|
76
|
+
sendSelectedNode(node) {
|
|
77
|
+
const message = {
|
|
78
|
+
type: "inspector-selected-node",
|
|
79
|
+
message: { ...node },
|
|
80
|
+
object: "shaper-post-message"
|
|
81
|
+
};
|
|
82
|
+
this._send(message);
|
|
83
|
+
}
|
|
84
|
+
sendTree(tree) {
|
|
85
|
+
const message = {
|
|
86
|
+
type: "inspector-tree-update",
|
|
87
|
+
message: { tree },
|
|
88
|
+
object: "shaper-post-message"
|
|
89
|
+
};
|
|
90
|
+
this._send(message);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const isWorkspaceModeEvent = (event) => {
|
|
94
|
+
return event.data.type === "WORKSPACE_MODE";
|
|
95
|
+
};
|
|
96
|
+
const isNodeAttributesPatchEvent = (event) => {
|
|
97
|
+
return event.data.type === "NODE_ATTRIBUTES_PATCH";
|
|
98
|
+
};
|
|
99
|
+
const isNodeAttributesPatchBatchEvent = (event) => {
|
|
100
|
+
return event.data.type === "NODE_ATTRIBUTES_PATCH_BATCH";
|
|
101
|
+
};
|
|
102
|
+
const isSetSelectNodeEvent = (event) => {
|
|
103
|
+
return event.data.type === "SET_SELECT_NODE";
|
|
104
|
+
};
|
|
105
|
+
const isSetHoverNodeEvent = (event) => {
|
|
106
|
+
return event.data.type === "SET_HOVER_NODE";
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/client/vite-hook.ts
|
|
111
|
+
var ViteHook = class {
|
|
112
|
+
hmr;
|
|
113
|
+
constructor() {
|
|
114
|
+
this.hmr = import.meta.hot;
|
|
115
|
+
}
|
|
116
|
+
hotExists(hmr) {
|
|
117
|
+
if (hmr) return true;
|
|
118
|
+
console.error("HotContext does not exists");
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
onBeforeUpdate(fn = null) {
|
|
122
|
+
if (!this.hotExists(this.hmr)) return;
|
|
123
|
+
this.hmr.on("vite:beforeUpdate", (data) => {
|
|
124
|
+
const timestamp = Date.now();
|
|
125
|
+
console.debug("beforeUpdate");
|
|
126
|
+
fn && fn(data, timestamp);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
onAfterUpdate(fn = null) {
|
|
130
|
+
if (!this.hotExists(this.hmr)) return;
|
|
131
|
+
this.hmr.on("vite:afterUpdate", (data) => {
|
|
132
|
+
const timestamp = Date.now();
|
|
133
|
+
console.debug("afterUpdate");
|
|
134
|
+
fn && fn(data, timestamp);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
onBeforePrune(fn = null) {
|
|
138
|
+
if (!this.hotExists(this.hmr)) return;
|
|
139
|
+
this.hmr.on("vite:beforePrune", (data) => {
|
|
140
|
+
const timestamp = Date.now();
|
|
141
|
+
console.debug("beforePrune");
|
|
142
|
+
fn && fn(data, timestamp);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
onBeforeFullReload(fn = null) {
|
|
146
|
+
if (!this.hotExists(this.hmr)) return;
|
|
147
|
+
this.hmr.on("vite:beforeFullReload", (data) => {
|
|
148
|
+
const timestamp = Date.now();
|
|
149
|
+
console.debug("beforeFullReload");
|
|
150
|
+
fn && fn(data, timestamp);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
onError(fn = null) {
|
|
154
|
+
if (!this.hotExists(this.hmr)) return;
|
|
155
|
+
this.hmr.on("vite:error", (data) => {
|
|
156
|
+
const timestamp = Date.now();
|
|
157
|
+
console.debug("error");
|
|
158
|
+
fn && fn(data, timestamp);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
onInvalidate(fn = null) {
|
|
162
|
+
if (!this.hotExists(this.hmr)) return;
|
|
163
|
+
this.hmr.on("vite:invalidate", (data) => {
|
|
164
|
+
const timestamp = Date.now();
|
|
165
|
+
console.debug("invalidate");
|
|
166
|
+
fn && fn(data, timestamp);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
onWsConnect(fn = null) {
|
|
170
|
+
if (!this.hotExists(this.hmr)) return;
|
|
171
|
+
this.hmr.on("vite:ws:connect", (data) => {
|
|
172
|
+
const timestamp = Date.now();
|
|
173
|
+
console.debug("ws:connect");
|
|
174
|
+
fn && fn(data, timestamp);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
onWsDisconnect(fn = null) {
|
|
178
|
+
if (!this.hotExists(this.hmr)) return;
|
|
179
|
+
this.hmr.on("vite:ws:disconnect", (data) => {
|
|
180
|
+
const timestamp = Date.now();
|
|
181
|
+
console.debug(":ws:disconnect");
|
|
182
|
+
fn && fn(data, timestamp);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
76
185
|
};
|
|
77
186
|
|
|
78
187
|
//#endregion
|
|
79
|
-
export { IframePostMessageClient };
|
|
188
|
+
export { IframePostMessageClient, ViteHook, isNodeAttributesPatchBatchEvent, isNodeAttributesPatchEvent, isSetHoverNodeEvent, isSetSelectNodeEvent, isWorkspaceModeEvent };
|
package/package.json
CHANGED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ErrorPayload,
|
|
3
|
-
FullReloadPayload,
|
|
4
|
-
PrunePayload,
|
|
5
|
-
UpdatePayload,
|
|
6
|
-
} from "vite/types/hmrPayload.js";
|
|
7
|
-
import { ViteHotContext } from "vite/types/hot.js";
|
|
8
|
-
|
|
9
|
-
type ViteUpdateCallback =
|
|
10
|
-
| ((data: UpdatePayload, timestamp: number) => void)
|
|
11
|
-
| null;
|
|
12
|
-
|
|
13
|
-
type VitePruneCallback =
|
|
14
|
-
| ((data: PrunePayload, timestamp: number) => void)
|
|
15
|
-
| null;
|
|
16
|
-
|
|
17
|
-
type VitFullReloadCallback =
|
|
18
|
-
| ((data: FullReloadPayload, timestamp: number) => void)
|
|
19
|
-
| null;
|
|
20
|
-
|
|
21
|
-
type ViteErrorCallback =
|
|
22
|
-
| ((data: ErrorPayload, timestamp: number) => void)
|
|
23
|
-
| null;
|
|
24
|
-
|
|
25
|
-
type ViteInvalidateCallback = ((data: any, timestamp: number) => void) | null;
|
|
26
|
-
|
|
27
|
-
type ViteWebSocketConnectCallback =
|
|
28
|
-
| ((data: any, timestamp: number) => void)
|
|
29
|
-
| null;
|
|
30
|
-
|
|
31
|
-
type ViteWebSocketDisconnectCallback =
|
|
32
|
-
| ((data: any, timestamp: number) => void)
|
|
33
|
-
| null;
|
|
34
|
-
|
|
35
|
-
class ViteHook {
|
|
36
|
-
private hmr: ViteHotContext | undefined;
|
|
37
|
-
constructor() {
|
|
38
|
-
this.hmr = import.meta.hot;
|
|
39
|
-
}
|
|
40
|
-
hotExists(hmr: ViteHotContext | undefined): hmr is ViteHotContext {
|
|
41
|
-
if (hmr) return true;
|
|
42
|
-
console.error("HotContext does not exists");
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
onBeforeUpdate(fn: ViteUpdateCallback = null) {
|
|
47
|
-
if (!this.hotExists(this.hmr)) return;
|
|
48
|
-
|
|
49
|
-
this.hmr.on("vite:beforeUpdate", (data: UpdatePayload) => {
|
|
50
|
-
const timestamp = Date.now();
|
|
51
|
-
console.debug("beforeUpdate");
|
|
52
|
-
fn && fn(data, timestamp);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
onAfterUpdate(fn: ViteUpdateCallback = null) {
|
|
57
|
-
if (!this.hotExists(this.hmr)) return;
|
|
58
|
-
|
|
59
|
-
this.hmr.on("vite:afterUpdate", (data: UpdatePayload) => {
|
|
60
|
-
const timestamp = Date.now();
|
|
61
|
-
console.debug("afterUpdate");
|
|
62
|
-
fn && fn(data, timestamp);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
onBeforePrune(fn: VitePruneCallback = null) {
|
|
67
|
-
if (!this.hotExists(this.hmr)) return;
|
|
68
|
-
|
|
69
|
-
this.hmr.on("vite:beforePrune", (data: PrunePayload) => {
|
|
70
|
-
const timestamp = Date.now();
|
|
71
|
-
console.debug("beforePrune");
|
|
72
|
-
|
|
73
|
-
fn && fn(data, timestamp);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
onBeforeFullReload(fn: VitFullReloadCallback = null) {
|
|
78
|
-
if (!this.hotExists(this.hmr)) return;
|
|
79
|
-
|
|
80
|
-
this.hmr.on("vite:beforeFullReload", (data: FullReloadPayload) => {
|
|
81
|
-
const timestamp = Date.now();
|
|
82
|
-
console.debug("beforeFullReload");
|
|
83
|
-
|
|
84
|
-
fn && fn(data, timestamp);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
onError(fn: ViteErrorCallback = null) {
|
|
89
|
-
if (!this.hotExists(this.hmr)) return;
|
|
90
|
-
|
|
91
|
-
this.hmr.on("vite:error", (data: ErrorPayload) => {
|
|
92
|
-
const timestamp = Date.now();
|
|
93
|
-
console.debug("error");
|
|
94
|
-
|
|
95
|
-
fn && fn(data, timestamp);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
onInvalidate(fn: ViteInvalidateCallback = null) {
|
|
100
|
-
if (!this.hotExists(this.hmr)) return;
|
|
101
|
-
|
|
102
|
-
this.hmr.on("vite:invalidate", (data: any) => {
|
|
103
|
-
const timestamp = Date.now();
|
|
104
|
-
console.debug("invalidate");
|
|
105
|
-
|
|
106
|
-
fn && fn(data, timestamp);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
onWsConnect(fn: ViteWebSocketConnectCallback = null) {
|
|
111
|
-
if (!this.hotExists(this.hmr)) return;
|
|
112
|
-
|
|
113
|
-
this.hmr.on("vite:ws:connect", (data: any) => {
|
|
114
|
-
const timestamp = Date.now();
|
|
115
|
-
console.debug("ws:connect");
|
|
116
|
-
|
|
117
|
-
fn && fn(data, timestamp);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
onWsDisconnect(fn: ViteWebSocketDisconnectCallback = null) {
|
|
122
|
-
if (!this.hotExists(this.hmr)) return;
|
|
123
|
-
|
|
124
|
-
this.hmr.on("vite:ws:disconnect", (data: any) => {
|
|
125
|
-
const timestamp = Date.now();
|
|
126
|
-
console.debug(":ws:disconnect");
|
|
127
|
-
|
|
128
|
-
fn && fn(data, timestamp);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export { ViteHook };
|