@nuvio/shared 0.1.0 → 0.5.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +1952 -75
  2. package/dist/index.js +142 -6
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,12 +3,109 @@ var NUVIO_WS_PATH = "/__nuvio/ws";
3
3
 
4
4
  // src/protocol.ts
5
5
  import { z } from "zod";
6
- var PROTOCOL_VERSION = 4;
6
+ var PROTOCOL_VERSION = 7;
7
+ var riskLevelSchema = z.enum(["safe", "caution", "unsupported"]);
8
+ var textTargetSchema = z.object({
9
+ /** Stable within host: `data-nuvio-id` or `loc:line:column`. */
10
+ key: z.string(),
11
+ label: z.string(),
12
+ file: z.string(),
13
+ line: z.number().int(),
14
+ column: z.number().int(),
15
+ tagName: z.string(),
16
+ textEditable: z.boolean(),
17
+ textPreview: z.string().optional(),
18
+ /** Present when the text node has its own `data-nuvio-id`. */
19
+ nuvioId: z.string().optional(),
20
+ /** Host id used for `mergeTailwindClassName` when patching styles for this target. */
21
+ patchHostId: z.string(),
22
+ insideMap: z.boolean().optional()
23
+ });
24
+ var styleTargetSchema = z.object({
25
+ /** Stable key within host: `data-nuvio-id` or `host` for selected container. */
26
+ key: z.string(),
27
+ label: z.string(),
28
+ file: z.string(),
29
+ line: z.number().int(),
30
+ column: z.number().int(),
31
+ tagName: z.string(),
32
+ nuvioId: z.string(),
33
+ patchHostId: z.string(),
34
+ classNamePatchable: z.boolean(),
35
+ riskLevel: riskLevelSchema.optional()
36
+ });
37
+ var hierarchyRoleSchema = z.enum([
38
+ "section",
39
+ "card",
40
+ "table",
41
+ "form",
42
+ "group",
43
+ "layout",
44
+ "text",
45
+ "button",
46
+ "input",
47
+ "media",
48
+ "unknown"
49
+ ]);
50
+ var rowTargetSchema = z.object({
51
+ rowKey: z.string(),
52
+ nuvioId: z.string(),
53
+ label: z.string(),
54
+ file: z.string(),
55
+ line: z.number().int()
56
+ });
57
+ var tableMetaSchema = z.object({
58
+ dataBinding: z.string(),
59
+ file: z.string(),
60
+ line: z.number().int(),
61
+ columns: z.array(z.string()).optional()
62
+ });
63
+ var tableDataFieldSchema = z.object({
64
+ arrayName: z.string(),
65
+ rowKey: z.string(),
66
+ field: z.string()
67
+ });
7
68
  var indexEntrySchema = z.object({
8
69
  id: z.string(),
9
70
  file: z.string(),
10
71
  line: z.number().int(),
11
- column: z.number().int()
72
+ column: z.number().int(),
73
+ /** Source index v2 metadata */
74
+ tagName: z.string().optional(),
75
+ componentName: z.string().optional(),
76
+ hasLiteralClassName: z.boolean().optional(),
77
+ classNameValue: z.string().optional(),
78
+ textEditable: z.boolean().optional(),
79
+ structuralEditable: z.boolean().optional(),
80
+ riskLevel: riskLevelSchema.optional(),
81
+ unsupportedReasons: z.array(z.string()).optional(),
82
+ insideMap: z.boolean().optional(),
83
+ /** Index v3: default id for className patches on this host. */
84
+ patchHostId: z.string().optional(),
85
+ /** Index v3: preferred text target key in `textTargets`. */
86
+ primaryTextTargetKey: z.string().optional(),
87
+ /** Index v3: descendant (and host) text edit targets. */
88
+ textTargets: z.array(textTargetSchema).optional(),
89
+ /** Index v3: explicit style patch targets for this selected host. */
90
+ styleTargets: z.array(styleTargetSchema).optional(),
91
+ /** Index v3: coarse host role, used for defaults/hints only. */
92
+ hierarchyRole: hierarchyRoleSchema.optional(),
93
+ /** Index v3: nearest ancestor host id in JSX ownership hierarchy. */
94
+ parentHostId: z.string().optional(),
95
+ /** Index v3: descendant host ids under this host (if any). */
96
+ childTargetIds: z.array(z.string()).optional(),
97
+ /** Index v4: row hosts when this entry is a table section. */
98
+ rowTargets: z.array(rowTargetSchema).optional(),
99
+ /** Index v4: static table data binding for Tier C. */
100
+ tableMeta: tableMetaSchema.optional(),
101
+ /** Index v4: when this host maps to a `tableData` field edit. */
102
+ tableDataField: tableDataFieldSchema.optional()
103
+ });
104
+ var runtimeDiagnosticsSchema = z.object({
105
+ viteVersion: z.string().optional(),
106
+ reactVersion: z.string().optional(),
107
+ tailwindVersion: z.string().optional(),
108
+ overlayCssMode: z.literal("self-contained").optional()
12
109
  });
13
110
  var duplicateIdOccurrenceSchema = z.object({
14
111
  file: z.string(),
@@ -38,6 +135,10 @@ var patchOpMergeTailwindSchema = z.object({
38
135
  kind: z.literal("mergeTailwindClassName"),
39
136
  classNameFragment: z.string()
40
137
  });
138
+ var patchOpRemoveTailwindSchema = z.object({
139
+ kind: z.literal("removeTailwindClassName"),
140
+ classNameFragment: z.string()
141
+ });
41
142
  var patchOpMoveSiblingSchema = z.object({
42
143
  kind: z.literal("moveSibling"),
43
144
  direction: z.enum(["up", "down"])
@@ -49,19 +150,31 @@ var patchOpSetHiddenSchema = z.object({
49
150
  var patchOpDuplicateHostSchema = z.object({
50
151
  kind: z.literal("duplicateHost")
51
152
  });
153
+ var patchOpSetTableDataFieldSchema = z.object({
154
+ kind: z.literal("setTableDataField"),
155
+ arrayName: z.string(),
156
+ rowKey: z.string(),
157
+ field: z.string(),
158
+ value: z.string()
159
+ });
52
160
  var patchOpSchema = z.discriminatedUnion("kind", [
53
161
  patchOpSetTextSchema,
54
162
  patchOpMergeTailwindSchema,
163
+ patchOpRemoveTailwindSchema,
55
164
  patchOpMoveSiblingSchema,
56
165
  patchOpSetHiddenSchema,
57
- patchOpDuplicateHostSchema
166
+ patchOpDuplicateHostSchema,
167
+ patchOpSetTableDataFieldSchema
58
168
  ]);
169
+ var breakpointSchema = z.enum(["base", "sm", "md", "lg", "xl"]);
59
170
  var clientPatchApplySchema = z.object({
60
171
  type: z.literal("patchApply"),
61
172
  protocolVersion: z.number().int(),
62
173
  requestId: z.string().min(1),
63
174
  id: z.string().min(1),
64
175
  ops: z.array(patchOpSchema).min(1),
176
+ /** Optional responsive context for className merges. */
177
+ activeBreakpoint: breakpointSchema.optional(),
65
178
  /** When true, server validates and returns `patchAck` with `diffSummary` but does not write disk or push undo. */
66
179
  dryRun: z.boolean().optional()
67
180
  });
@@ -79,7 +192,8 @@ var clientMessageSchema = z.discriminatedUnion("type", [
79
192
  var serverPongSchema = z.object({
80
193
  type: z.literal("pong"),
81
194
  protocolVersion: z.number().int(),
82
- requestId: z.string()
195
+ requestId: z.string(),
196
+ diagnostics: runtimeDiagnosticsSchema.optional()
83
197
  });
84
198
  var serverErrorSchema = z.object({
85
199
  type: z.literal("error"),
@@ -92,7 +206,8 @@ var serverIndexReadySchema = z.object({
92
206
  protocolVersion: z.number().int(),
93
207
  indexVersion: z.number().int(),
94
208
  entries: z.array(indexEntrySchema),
95
- duplicateErrors: z.array(duplicateIdErrorSchema)
209
+ duplicateErrors: z.array(duplicateIdErrorSchema),
210
+ diagnostics: runtimeDiagnosticsSchema.optional()
96
211
  });
97
212
  var serverSelectAckSchema = z.object({
98
213
  type: z.literal("selectAck"),
@@ -103,6 +218,17 @@ var serverSelectAckSchema = z.object({
103
218
  file: z.string().optional(),
104
219
  line: z.number().int().optional(),
105
220
  column: z.number().int().optional(),
221
+ /** Index v3 snapshot for the selected host (also on `indexReady` entries). */
222
+ patchHostId: z.string().optional(),
223
+ primaryTextTargetKey: z.string().optional(),
224
+ textTargets: z.array(textTargetSchema).optional(),
225
+ styleTargets: z.array(styleTargetSchema).optional(),
226
+ hierarchyRole: hierarchyRoleSchema.optional(),
227
+ parentHostId: z.string().optional(),
228
+ childTargetIds: z.array(z.string()).optional(),
229
+ rowTargets: z.array(rowTargetSchema).optional(),
230
+ tableMeta: tableMetaSchema.optional(),
231
+ tableDataField: tableDataFieldSchema.optional(),
106
232
  errorCode: z.string().optional(),
107
233
  errorMessage: z.string().optional()
108
234
  });
@@ -167,6 +293,7 @@ function serializeServerMessage(msg) {
167
293
  export {
168
294
  NUVIO_WS_PATH,
169
295
  PROTOCOL_VERSION,
296
+ breakpointSchema,
170
297
  clientMessageSchema,
171
298
  clientPatchApplySchema,
172
299
  clientPatchUndoSchema,
@@ -174,6 +301,7 @@ export {
174
301
  clientSelectSchema,
175
302
  duplicateIdErrorSchema,
176
303
  duplicateIdOccurrenceSchema,
304
+ hierarchyRoleSchema,
177
305
  indexEntrySchema,
178
306
  parseClientMessage,
179
307
  parseServerMessage,
@@ -182,7 +310,11 @@ export {
182
310
  patchOpMoveSiblingSchema,
183
311
  patchOpSchema,
184
312
  patchOpSetHiddenSchema,
313
+ patchOpSetTableDataFieldSchema,
185
314
  patchOpSetTextSchema,
315
+ riskLevelSchema,
316
+ rowTargetSchema,
317
+ runtimeDiagnosticsSchema,
186
318
  serializeServerMessage,
187
319
  serverErrorSchema,
188
320
  serverIndexReadySchema,
@@ -190,5 +322,9 @@ export {
190
322
  serverPatchAckSchema,
191
323
  serverPatchUndoAckSchema,
192
324
  serverPongSchema,
193
- serverSelectAckSchema
325
+ serverSelectAckSchema,
326
+ styleTargetSchema,
327
+ tableDataFieldSchema,
328
+ tableMetaSchema,
329
+ textTargetSchema
194
330
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvio/shared",
3
- "version": "0.1.0",
3
+ "version": "0.5.1",
4
4
  "description": "Nuvio wire protocol (Zod), shared types, and path helpers for dev tooling.",
5
5
  "license": "MIT",
6
6
  "repository": {