@proto-labs-inc/wire 0.1.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/LICENSE +21 -0
- package/README.md +6 -0
- package/dist/index.d.ts +191 -0
- package/dist/index.js +38 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Proto Labs Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# @proto-labs-inc/wire
|
|
2
|
+
|
|
3
|
+
The typed contract between Proto's Frame and the rig inside a prototype: the
|
|
4
|
+
bridge's message shapes, their guards, and the `prototype.json` schema.
|
|
5
|
+
Prototypes get it through `@proto-labs-inc/rig` or `@proto-labs-inc/rig-vue`;
|
|
6
|
+
import it directly only for its types (`Manifest`, `StateDef`).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
export declare const PROTOCOL_VERSION = 2;
|
|
2
|
+
export type ResolvedPreviewTheme = "light" | "dark";
|
|
3
|
+
export interface StateDef {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
/** optional parent state id, used by the state map's layout/edges */
|
|
8
|
+
parent?: string;
|
|
9
|
+
/** variants that make this state a complete reproducible view */
|
|
10
|
+
variants?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export interface PrPlanEntryDef {
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
/** implementation pull request, present once this slice has been created */
|
|
16
|
+
pullRequestUrl?: string;
|
|
17
|
+
/** source branch in the implementation repository */
|
|
18
|
+
branchUrl?: string;
|
|
19
|
+
/** current pull request state, present once the implementation PR exists */
|
|
20
|
+
status?: "draft" | "in-review" | "merged" | "closed";
|
|
21
|
+
/** deployed preview for this implementation, when available */
|
|
22
|
+
previewUrl?: string;
|
|
23
|
+
/** state that demonstrates this implementation slice */
|
|
24
|
+
state: string;
|
|
25
|
+
/** schematic asset, relative to the prototype origin */
|
|
26
|
+
wireframe: string;
|
|
27
|
+
/** registered prototype region to focus after selecting this slice */
|
|
28
|
+
targetId: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PrPlanDef {
|
|
31
|
+
entries: PrPlanEntryDef[];
|
|
32
|
+
}
|
|
33
|
+
export interface VariantLink {
|
|
34
|
+
title: string;
|
|
35
|
+
url: string;
|
|
36
|
+
}
|
|
37
|
+
export interface VariantDef {
|
|
38
|
+
id: string;
|
|
39
|
+
title: string;
|
|
40
|
+
note?: string;
|
|
41
|
+
/** workspace-relative implementation and style files for targeted edits */
|
|
42
|
+
sourceFiles?: string[];
|
|
43
|
+
/** optional static preview asset, relative to the prototype origin */
|
|
44
|
+
preview?: string;
|
|
45
|
+
/** canvas color shown around a contained static preview */
|
|
46
|
+
previewBackground?: string;
|
|
47
|
+
/** optional per-variant reference (e.g. a Loom or call recording) */
|
|
48
|
+
reference?: VariantLink;
|
|
49
|
+
}
|
|
50
|
+
export interface ReferenceDef {
|
|
51
|
+
app: string;
|
|
52
|
+
url: string;
|
|
53
|
+
note?: string;
|
|
54
|
+
/** screenshot path relative to the prototype origin (or absolute URL) */
|
|
55
|
+
image?: string;
|
|
56
|
+
/** variant id this reference inspired — linked from that variant's card */
|
|
57
|
+
variant?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface VariantSetDef {
|
|
60
|
+
/** component id the variants belong to (matches the rig's registration) */
|
|
61
|
+
component: string;
|
|
62
|
+
title?: string;
|
|
63
|
+
/** temporary lifecycle state while an agent is creating the variant set */
|
|
64
|
+
status?: "building";
|
|
65
|
+
variants: VariantDef[];
|
|
66
|
+
/** variant id the prototype's code defaults to */
|
|
67
|
+
default: string;
|
|
68
|
+
/** preview-state id that showcases this variant set (used by previews) */
|
|
69
|
+
state?: string;
|
|
70
|
+
/** variant id that is the pre-variant-set original — pinned last, badged ORIGINAL */
|
|
71
|
+
baseline?: string;
|
|
72
|
+
/** overview copy shown at the bottom of the variants panel */
|
|
73
|
+
overview?: {
|
|
74
|
+
title?: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
};
|
|
77
|
+
references?: ReferenceDef[];
|
|
78
|
+
}
|
|
79
|
+
export interface Manifest {
|
|
80
|
+
schemaVersion: 2;
|
|
81
|
+
/** the slug */
|
|
82
|
+
name: string;
|
|
83
|
+
port: number;
|
|
84
|
+
needsServer: boolean;
|
|
85
|
+
states: StateDef[];
|
|
86
|
+
variantSets: VariantSetDef[];
|
|
87
|
+
prPlan?: PrPlanDef;
|
|
88
|
+
}
|
|
89
|
+
export declare const STATE_PARAM = "state";
|
|
90
|
+
export declare const variantParam: (component: string) => string;
|
|
91
|
+
export type FrameToRig = {
|
|
92
|
+
type: "set-state";
|
|
93
|
+
id: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: "set-theme";
|
|
96
|
+
theme: ResolvedPreviewTheme;
|
|
97
|
+
} | {
|
|
98
|
+
type: "set-variant";
|
|
99
|
+
component: string;
|
|
100
|
+
variant: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: "focus-target";
|
|
103
|
+
id: string | null;
|
|
104
|
+
} | {
|
|
105
|
+
type: "measure-target";
|
|
106
|
+
id: string;
|
|
107
|
+
} | {
|
|
108
|
+
type: "set-comment-mode";
|
|
109
|
+
on: boolean;
|
|
110
|
+
} | {
|
|
111
|
+
type: "capture-comment";
|
|
112
|
+
requestId: string;
|
|
113
|
+
} | {
|
|
114
|
+
type: "set-variant-set-picker";
|
|
115
|
+
on: boolean;
|
|
116
|
+
} | {
|
|
117
|
+
type: "set-element-picker";
|
|
118
|
+
on: boolean;
|
|
119
|
+
};
|
|
120
|
+
export interface CommentAnchor {
|
|
121
|
+
/** Bounds of the selected component in the prototype viewport. */
|
|
122
|
+
x: number;
|
|
123
|
+
y: number;
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
}
|
|
127
|
+
export type RigToFrame = {
|
|
128
|
+
type: "hello";
|
|
129
|
+
protocolVersion: number;
|
|
130
|
+
rigVersion: string;
|
|
131
|
+
/** manifest.name, so the Frame can sanity-check what it framed */
|
|
132
|
+
name: string;
|
|
133
|
+
} | {
|
|
134
|
+
type: "state-changed";
|
|
135
|
+
/** the prototype's current location.search, the full addressable state */
|
|
136
|
+
search: string;
|
|
137
|
+
} | {
|
|
138
|
+
type: "comment-target-picked";
|
|
139
|
+
/** the clicked [data-proto-id], if the click landed on a marked component */
|
|
140
|
+
targetId: string | null;
|
|
141
|
+
/** Used by the Frame to place the composer beside the selection. */
|
|
142
|
+
anchor: CommentAnchor;
|
|
143
|
+
} | {
|
|
144
|
+
type: "comment-capture";
|
|
145
|
+
/** the clicked [data-proto-id], if the click landed on a marked component */
|
|
146
|
+
targetId: string | null;
|
|
147
|
+
/** PNG data URL with the highlight composited in; null if capture failed
|
|
148
|
+
(e.g. modern-screenshot not installed) — the comment still works */
|
|
149
|
+
image: string | null;
|
|
150
|
+
/** The requestId of the capture-comment this answers. */
|
|
151
|
+
requestId: string;
|
|
152
|
+
/** Used by the Frame to place the composer beside the selection. */
|
|
153
|
+
anchor: CommentAnchor;
|
|
154
|
+
} | {
|
|
155
|
+
type: "thumbnail-capture";
|
|
156
|
+
/** Image data URL of the current viewport, or null when capture failed. */
|
|
157
|
+
image: string | null;
|
|
158
|
+
/** The requestId of the capture-thumbnail request this answers. */
|
|
159
|
+
requestId: string;
|
|
160
|
+
}
|
|
161
|
+
/** the user pressed Escape inside the prototype */
|
|
162
|
+
| {
|
|
163
|
+
type: "comment-mode-exited";
|
|
164
|
+
} | {
|
|
165
|
+
type: "target-focus-dismissed";
|
|
166
|
+
} | {
|
|
167
|
+
type: "target-measured";
|
|
168
|
+
targetId: string;
|
|
169
|
+
/** Null when no matching registered component exists in the current state. */
|
|
170
|
+
anchor: CommentAnchor | null;
|
|
171
|
+
} | {
|
|
172
|
+
type: "variant-set-target-picked";
|
|
173
|
+
targetId: string;
|
|
174
|
+
/** Used by the Frame to place the variant-set brief beside the selection. */
|
|
175
|
+
anchor: CommentAnchor;
|
|
176
|
+
} | {
|
|
177
|
+
type: "variant-set-picker-exited";
|
|
178
|
+
} | {
|
|
179
|
+
type: "element-target-picked";
|
|
180
|
+
/** A CSS selector scoped as narrowly as possible to a registered ancestor. */
|
|
181
|
+
selector: string;
|
|
182
|
+
tagName: string;
|
|
183
|
+
/** Short, whitespace-normalized text content to help identify the element. */
|
|
184
|
+
text: string | null;
|
|
185
|
+
/** Used by the Frame to place the prompt composer beside the selection. */
|
|
186
|
+
anchor: CommentAnchor;
|
|
187
|
+
} | {
|
|
188
|
+
type: "element-picker-exited";
|
|
189
|
+
};
|
|
190
|
+
export declare function isFrameToRig(d: unknown): d is FrameToRig;
|
|
191
|
+
export declare function isRigToFrame(d: unknown): d is RigToFrame;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const PROTOCOL_VERSION = 2;
|
|
2
|
+
// ─── URL param conventions ─────────────────────────────────────────
|
|
3
|
+
export const STATE_PARAM = "state";
|
|
4
|
+
export const variantParam = (component) => `v.${component}`;
|
|
5
|
+
// ─── guards (tolerant: unknown message types are ignored, never errors) ──
|
|
6
|
+
export function isFrameToRig(d) {
|
|
7
|
+
if (typeof d !== "object" || d === null)
|
|
8
|
+
return false;
|
|
9
|
+
const message = d;
|
|
10
|
+
const t = message.type;
|
|
11
|
+
return (t === "set-state" ||
|
|
12
|
+
(t === "set-theme" &&
|
|
13
|
+
(message.theme === "light" || message.theme === "dark")) ||
|
|
14
|
+
t === "set-variant" ||
|
|
15
|
+
t === "focus-target" ||
|
|
16
|
+
t === "measure-target" ||
|
|
17
|
+
t === "set-comment-mode" ||
|
|
18
|
+
t === "capture-comment" ||
|
|
19
|
+
t === "set-variant-set-picker" ||
|
|
20
|
+
t === "set-element-picker");
|
|
21
|
+
}
|
|
22
|
+
export function isRigToFrame(d) {
|
|
23
|
+
if (typeof d !== "object" || d === null)
|
|
24
|
+
return false;
|
|
25
|
+
const t = d.type;
|
|
26
|
+
return (t === "hello" ||
|
|
27
|
+
t === "state-changed" ||
|
|
28
|
+
t === "comment-target-picked" ||
|
|
29
|
+
t === "comment-capture" ||
|
|
30
|
+
t === "thumbnail-capture" ||
|
|
31
|
+
t === "comment-mode-exited" ||
|
|
32
|
+
t === "target-focus-dismissed" ||
|
|
33
|
+
t === "target-measured" ||
|
|
34
|
+
t === "variant-set-target-picked" ||
|
|
35
|
+
t === "variant-set-picker-exited" ||
|
|
36
|
+
t === "element-target-picked" ||
|
|
37
|
+
t === "element-picker-exited");
|
|
38
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proto-labs-inc/wire",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The typed contract between Proto's Frame and the rig inside a prototype: bridge messages and the prototype.json schema.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/proto-labs-inc/proto.git",
|
|
9
|
+
"directory": "packages/wire"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "~6.0.2"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.build.json",
|
|
30
|
+
"typecheck": "tsc --noEmit"
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts"
|
|
34
|
+
}
|