@proto-labs-inc/wire 0.2.0 → 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 CHANGED
@@ -48,6 +48,8 @@ export interface VariantDef {
48
48
  reference?: VariantLink;
49
49
  }
50
50
  export interface ReferenceDef {
51
+ /** Aggregator that supplied the reference, independent of its destination URL. */
52
+ source?: "mobbin" | "refero" | "nicelydone" | "landingfolio" | "recent";
51
53
  app: string;
52
54
  url: string;
53
55
  note?: string;
@@ -123,6 +125,16 @@ export declare const ELEMENT_STYLE_PROPERTIES: readonly ["color", "background-co
123
125
  export type ElementStyleProperty = typeof ELEMENT_STYLE_PROPERTIES[number];
124
126
  export type ElementStyles = Partial<Record<ElementStyleProperty, string>>;
125
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
+ } | {
126
138
  type: "set-state";
127
139
  id: string;
128
140
  } | {
@@ -135,15 +147,13 @@ export type FrameToRig = {
135
147
  } | {
136
148
  type: "focus-target";
137
149
  selector: string | null;
150
+ visibility?: "always" | "if-outside-viewport";
138
151
  } | {
139
152
  type: "measure-target";
140
153
  selector: string;
141
154
  } | {
142
155
  type: "set-comment-mode";
143
156
  on: boolean;
144
- } | {
145
- type: "capture-comment";
146
- requestId: string;
147
157
  } | {
148
158
  type: "set-variant-set-picker";
149
159
  on: boolean;
@@ -157,6 +167,17 @@ export type FrameToRig = {
157
167
  } | {
158
168
  type: "release-element";
159
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";
160
181
  };
161
182
  export interface CommentAnchor {
162
183
  /** Bounds of the selected component in the prototype viewport. */
@@ -184,17 +205,6 @@ export type RigToFrame = {
184
205
  selector: string;
185
206
  /** Used by the Frame to place the composer beside the selection. */
186
207
  anchor: CommentAnchor;
187
- } | {
188
- type: "comment-capture";
189
- /** CSS selector for the exact selected element. */
190
- selector: string;
191
- /** PNG data URL with the highlight composited in; null if capture failed
192
- (e.g. modern-screenshot not installed) — the comment still works */
193
- image: string | null;
194
- /** The requestId of the capture-comment this answers. */
195
- requestId: string;
196
- /** Used by the Frame to place the composer beside the selection. */
197
- anchor: CommentAnchor;
198
208
  } | {
199
209
  type: "thumbnail-capture";
200
210
  /** Image data URL of the current viewport, or null when capture failed. */
@@ -221,6 +231,11 @@ export type RigToFrame = {
221
231
  type: "variant-set-picker-exited";
222
232
  } | {
223
233
  type: "element-target-picked";
234
+ /** Click position as fractions of the selected element bounds. */
235
+ point?: {
236
+ x: number;
237
+ y: number;
238
+ };
224
239
  inspection?: {
225
240
  selectionId: string;
226
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") {
@@ -67,10 +79,10 @@ export function isFrameToRig(d) {
67
79
  (t === "set-theme" &&
68
80
  (message.theme === "light" || message.theme === "dark")) ||
69
81
  t === "set-variant" ||
70
- (t === "focus-target" && (message.selector === null || typeof message.selector === "string")) ||
82
+ (t === "focus-target" && (message.selector === null || typeof message.selector === "string") &&
83
+ (message.visibility === undefined || message.visibility === "always" || message.visibility === "if-outside-viewport")) ||
71
84
  (t === "measure-target" && typeof message.selector === "string") ||
72
85
  t === "set-comment-mode" ||
73
- t === "capture-comment" ||
74
86
  t === "set-variant-set-picker" ||
75
87
  t === "set-element-picker");
76
88
  }
@@ -79,7 +91,7 @@ export function isRigToFrame(d) {
79
91
  return false;
80
92
  const message = d;
81
93
  const t = message.type;
82
- if (["comment-target-picked", "comment-capture", "variant-set-target-picked", "target-measured"].includes(t)) {
94
+ if (["comment-target-picked", "variant-set-target-picked", "target-measured"].includes(t)) {
83
95
  return typeof message.selector === "string";
84
96
  }
85
97
  return ((t === "frame-tools-status" && ["loading", "ready", "unavailable"].includes(message.status)) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proto-labs-inc/wire",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "The typed contract between Proto's Frame and the rig inside a prototype: bridge messages and the prototype.json schema.",
5
5
  "license": "MIT",
6
6
  "repository": {