@proto-labs-inc/wire 0.2.1 → 0.2.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/dist/index.d.ts +26 -14
- package/dist/index.js +13 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -125,6 +125,16 @@ export declare const ELEMENT_STYLE_PROPERTIES: readonly ["color", "background-co
|
|
|
125
125
|
export type ElementStyleProperty = typeof ELEMENT_STYLE_PROPERTIES[number];
|
|
126
126
|
export type ElementStyles = Partial<Record<ElementStyleProperty, string>>;
|
|
127
127
|
export type FrameToRig = {
|
|
128
|
+
type: "set-edit-markers";
|
|
129
|
+
markers: {
|
|
130
|
+
selector: string;
|
|
131
|
+
number: number;
|
|
132
|
+
point?: {
|
|
133
|
+
x: number;
|
|
134
|
+
y: number;
|
|
135
|
+
};
|
|
136
|
+
}[];
|
|
137
|
+
} | {
|
|
128
138
|
type: "set-state";
|
|
129
139
|
id: string;
|
|
130
140
|
} | {
|
|
@@ -144,9 +154,6 @@ export type FrameToRig = {
|
|
|
144
154
|
} | {
|
|
145
155
|
type: "set-comment-mode";
|
|
146
156
|
on: boolean;
|
|
147
|
-
} | {
|
|
148
|
-
type: "capture-comment";
|
|
149
|
-
requestId: string;
|
|
150
157
|
} | {
|
|
151
158
|
type: "set-variant-set-picker";
|
|
152
159
|
on: boolean;
|
|
@@ -160,6 +167,17 @@ export type FrameToRig = {
|
|
|
160
167
|
} | {
|
|
161
168
|
type: "release-element";
|
|
162
169
|
selectionId: string;
|
|
170
|
+
} | {
|
|
171
|
+
type: "restore-selection";
|
|
172
|
+
selector: string;
|
|
173
|
+
anchor: CommentAnchor;
|
|
174
|
+
kind: "element";
|
|
175
|
+
selectionId: string;
|
|
176
|
+
} | {
|
|
177
|
+
type: "restore-selection";
|
|
178
|
+
selector: string;
|
|
179
|
+
anchor: CommentAnchor;
|
|
180
|
+
kind: "comment" | "variantSet";
|
|
163
181
|
};
|
|
164
182
|
export interface CommentAnchor {
|
|
165
183
|
/** Bounds of the selected component in the prototype viewport. */
|
|
@@ -187,17 +205,6 @@ export type RigToFrame = {
|
|
|
187
205
|
selector: string;
|
|
188
206
|
/** Used by the Frame to place the composer beside the selection. */
|
|
189
207
|
anchor: CommentAnchor;
|
|
190
|
-
} | {
|
|
191
|
-
type: "comment-capture";
|
|
192
|
-
/** CSS selector for the exact selected element. */
|
|
193
|
-
selector: string;
|
|
194
|
-
/** PNG data URL with the highlight composited in; null if capture failed
|
|
195
|
-
(e.g. modern-screenshot not installed) — the comment still works */
|
|
196
|
-
image: string | null;
|
|
197
|
-
/** The requestId of the capture-comment this answers. */
|
|
198
|
-
requestId: string;
|
|
199
|
-
/** Used by the Frame to place the composer beside the selection. */
|
|
200
|
-
anchor: CommentAnchor;
|
|
201
208
|
} | {
|
|
202
209
|
type: "thumbnail-capture";
|
|
203
210
|
/** Image data URL of the current viewport, or null when capture failed. */
|
|
@@ -224,6 +231,11 @@ export type RigToFrame = {
|
|
|
224
231
|
type: "variant-set-picker-exited";
|
|
225
232
|
} | {
|
|
226
233
|
type: "element-target-picked";
|
|
234
|
+
/** Click position as fractions of the selected element bounds. */
|
|
235
|
+
point?: {
|
|
236
|
+
x: number;
|
|
237
|
+
y: number;
|
|
238
|
+
};
|
|
227
239
|
inspection?: {
|
|
228
240
|
selectionId: string;
|
|
229
241
|
styles: ElementStyles;
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,18 @@ export function isFrameToRig(d) {
|
|
|
55
55
|
if (typeof d !== "object" || d === null)
|
|
56
56
|
return false;
|
|
57
57
|
const message = d;
|
|
58
|
+
if (message.type === "set-edit-markers") {
|
|
59
|
+
const markers = d.markers;
|
|
60
|
+
return Array.isArray(markers) && markers.every(marker => marker && typeof marker.selector === "string" && Number.isSafeInteger(marker.number) && marker.number > 0 &&
|
|
61
|
+
(marker.point === undefined || (marker.point && [marker.point.x, marker.point.y].every(value => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1))));
|
|
62
|
+
}
|
|
63
|
+
if (message.type === "restore-selection") {
|
|
64
|
+
const anchor = message.anchor;
|
|
65
|
+
return typeof message.selector === "string" && typeof anchor === "object" && anchor !== null &&
|
|
66
|
+
[anchor.x, anchor.y, anchor.width, anchor.height].every(value => typeof value === "number" && Number.isFinite(value)) &&
|
|
67
|
+
(message.kind === "comment" || message.kind === "variantSet" ||
|
|
68
|
+
(message.kind === "element" && typeof message.selectionId === "string"));
|
|
69
|
+
}
|
|
58
70
|
if (message.type === "release-element")
|
|
59
71
|
return typeof message.selectionId === "string";
|
|
60
72
|
if (message.type === "preview-element-styles") {
|
|
@@ -71,7 +83,6 @@ export function isFrameToRig(d) {
|
|
|
71
83
|
(message.visibility === undefined || message.visibility === "always" || message.visibility === "if-outside-viewport")) ||
|
|
72
84
|
(t === "measure-target" && typeof message.selector === "string") ||
|
|
73
85
|
t === "set-comment-mode" ||
|
|
74
|
-
t === "capture-comment" ||
|
|
75
86
|
t === "set-variant-set-picker" ||
|
|
76
87
|
t === "set-element-picker");
|
|
77
88
|
}
|
|
@@ -80,7 +91,7 @@ export function isRigToFrame(d) {
|
|
|
80
91
|
return false;
|
|
81
92
|
const message = d;
|
|
82
93
|
const t = message.type;
|
|
83
|
-
if (["comment-target-picked", "
|
|
94
|
+
if (["comment-target-picked", "variant-set-target-picked", "target-measured"].includes(t)) {
|
|
84
95
|
return typeof message.selector === "string";
|
|
85
96
|
}
|
|
86
97
|
return ((t === "frame-tools-status" && ["loading", "ready", "unavailable"].includes(message.status)) ||
|
package/package.json
CHANGED