@proto-labs-inc/wire 0.1.1 → 0.2.1

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
@@ -1,4 +1,4 @@
1
- export declare const PROTOCOL_VERSION = 2;
1
+ export declare const PROTOCOL_VERSION = 3;
2
2
  export type ResolvedPreviewTheme = "light" | "dark";
3
3
  export interface StateDef {
4
4
  id: string;
@@ -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;
@@ -88,6 +90,8 @@ export interface VariantSetDef {
88
90
  }
89
91
  export interface Manifest {
90
92
  schemaVersion: 2;
93
+ /** Trusted Frame app origin, configured by the workspace owner. */
94
+ frameOrigin?: string;
91
95
  /** the slug */
92
96
  name: string;
93
97
  port: number;
@@ -132,10 +136,11 @@ export type FrameToRig = {
132
136
  variant: string;
133
137
  } | {
134
138
  type: "focus-target";
135
- id: string | null;
139
+ selector: string | null;
140
+ visibility?: "always" | "if-outside-viewport";
136
141
  } | {
137
142
  type: "measure-target";
138
- id: string;
143
+ selector: string;
139
144
  } | {
140
145
  type: "set-comment-mode";
141
146
  on: boolean;
@@ -164,6 +169,9 @@ export interface CommentAnchor {
164
169
  height: number;
165
170
  }
166
171
  export type RigToFrame = {
172
+ type: "frame-tools-status";
173
+ status: "loading" | "ready" | "unavailable";
174
+ } | {
167
175
  type: "hello";
168
176
  protocolVersion: number;
169
177
  rigVersion: string;
@@ -175,14 +183,14 @@ export type RigToFrame = {
175
183
  search: string;
176
184
  } | {
177
185
  type: "comment-target-picked";
178
- /** the clicked [data-proto-id], if the click landed on a marked component */
179
- targetId: string | null;
186
+ /** CSS selector for the exact selected element. */
187
+ selector: string;
180
188
  /** Used by the Frame to place the composer beside the selection. */
181
189
  anchor: CommentAnchor;
182
190
  } | {
183
191
  type: "comment-capture";
184
- /** the clicked [data-proto-id], if the click landed on a marked component */
185
- targetId: string | null;
192
+ /** CSS selector for the exact selected element. */
193
+ selector: string;
186
194
  /** PNG data URL with the highlight composited in; null if capture failed
187
195
  (e.g. modern-screenshot not installed) — the comment still works */
188
196
  image: string | null;
@@ -204,12 +212,12 @@ export type RigToFrame = {
204
212
  type: "target-focus-dismissed";
205
213
  } | {
206
214
  type: "target-measured";
207
- targetId: string;
208
- /** Null when no matching registered component exists in the current state. */
215
+ selector: string;
216
+ /** Null when no matching element exists in the current state. */
209
217
  anchor: CommentAnchor | null;
210
218
  } | {
211
219
  type: "variant-set-target-picked";
212
- targetId: string;
220
+ selector: string;
213
221
  /** Used by the Frame to place the variant-set brief beside the selection. */
214
222
  anchor: CommentAnchor;
215
223
  } | {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const PROTOCOL_VERSION = 2;
1
+ export const PROTOCOL_VERSION = 3;
2
2
  // ─── URL param conventions ─────────────────────────────────────────
3
3
  export const STATE_PARAM = "state";
4
4
  export const variantParam = (component) => `v.${component}`;
@@ -67,8 +67,9 @@ export function isFrameToRig(d) {
67
67
  (t === "set-theme" &&
68
68
  (message.theme === "light" || message.theme === "dark")) ||
69
69
  t === "set-variant" ||
70
- t === "focus-target" ||
71
- t === "measure-target" ||
70
+ (t === "focus-target" && (message.selector === null || typeof message.selector === "string") &&
71
+ (message.visibility === undefined || message.visibility === "always" || message.visibility === "if-outside-viewport")) ||
72
+ (t === "measure-target" && typeof message.selector === "string") ||
72
73
  t === "set-comment-mode" ||
73
74
  t === "capture-comment" ||
74
75
  t === "set-variant-set-picker" ||
@@ -77,16 +78,17 @@ export function isFrameToRig(d) {
77
78
  export function isRigToFrame(d) {
78
79
  if (typeof d !== "object" || d === null)
79
80
  return false;
80
- const t = d.type;
81
- return (t === "hello" ||
81
+ const message = d;
82
+ const t = message.type;
83
+ if (["comment-target-picked", "comment-capture", "variant-set-target-picked", "target-measured"].includes(t)) {
84
+ return typeof message.selector === "string";
85
+ }
86
+ return ((t === "frame-tools-status" && ["loading", "ready", "unavailable"].includes(message.status)) ||
87
+ t === "hello" ||
82
88
  t === "state-changed" ||
83
- t === "comment-target-picked" ||
84
- t === "comment-capture" ||
85
89
  t === "thumbnail-capture" ||
86
90
  t === "comment-mode-exited" ||
87
91
  t === "target-focus-dismissed" ||
88
- t === "target-measured" ||
89
- t === "variant-set-target-picked" ||
90
92
  t === "variant-set-picker-exited" ||
91
93
  t === "element-preview-bounds" ||
92
94
  t === "element-target-picked" ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proto-labs-inc/wire",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
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": {