@tutti-os/workbench-snapshot 0.0.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/LICENSE +202 -0
- package/README.md +11 -0
- package/dist/index.d.ts +259 -0
- package/dist/index.js +489 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.json +79 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @tutti-os/workbench-snapshot
|
|
2
|
+
|
|
3
|
+
Framework-neutral workbench snapshot contract helpers for Nextop workbench
|
|
4
|
+
surfaces.
|
|
5
|
+
|
|
6
|
+
The package exports stable TypeScript types, normalization helpers, validation
|
|
7
|
+
helpers, and the published JSON schema at:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
@tutti-os/workbench-snapshot/schema.json
|
|
11
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
declare const workbenchSnapshotLimits: {
|
|
2
|
+
readonly maxSerializedBytes: number;
|
|
3
|
+
readonly maxNodes: 128;
|
|
4
|
+
readonly maxNodeIDLength: 160;
|
|
5
|
+
readonly maxKindLength: 120;
|
|
6
|
+
readonly maxTitleLength: 240;
|
|
7
|
+
readonly minFrameWidth: 160;
|
|
8
|
+
readonly minFrameHeight: 120;
|
|
9
|
+
readonly maxFrameCoordinate: 1000000;
|
|
10
|
+
readonly maxFrameSize: 1000000;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
declare const workbenchSnapshotSchemaVersion: 1;
|
|
14
|
+
type WorkbenchSnapshotSchemaVersion = typeof workbenchSnapshotSchemaVersion;
|
|
15
|
+
interface WorkbenchSnapshotV1 {
|
|
16
|
+
schemaVersion: WorkbenchSnapshotSchemaVersion;
|
|
17
|
+
nodes: WorkbenchSnapshotNodeV1[];
|
|
18
|
+
nodeStack?: string[];
|
|
19
|
+
activeNodeId?: string | null;
|
|
20
|
+
spaces?: WorkbenchSnapshotSpaceV1[];
|
|
21
|
+
activeSpaceId?: string | null;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
interface WorkbenchFrameV1 {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
}
|
|
30
|
+
interface WorkbenchSnapshotNodeV1 {
|
|
31
|
+
id: string;
|
|
32
|
+
kind: string;
|
|
33
|
+
title: string;
|
|
34
|
+
frame: WorkbenchFrameV1;
|
|
35
|
+
displayMode?: WorkbenchSnapshotDisplayModeV1;
|
|
36
|
+
restoreFrame?: WorkbenchFrameV1 | null;
|
|
37
|
+
isMinimized?: boolean;
|
|
38
|
+
minimizedAtUnixMs?: number | null;
|
|
39
|
+
data?: unknown;
|
|
40
|
+
adapterState?: WorkbenchSnapshotNodeAdapterStateV1;
|
|
41
|
+
}
|
|
42
|
+
type WorkbenchSnapshotDisplayModeV1 = "floating" | "fullscreen";
|
|
43
|
+
interface WorkbenchSnapshotNodeAdapterStateV1 {
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
interface WorkbenchSnapshotSpaceV1 {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
nodeIds: string[];
|
|
50
|
+
frame?: WorkbenchFrameV1 | null;
|
|
51
|
+
data?: unknown;
|
|
52
|
+
}
|
|
53
|
+
type WorkbenchSnapshot = WorkbenchSnapshotV1;
|
|
54
|
+
type WorkbenchSnapshotNode = WorkbenchSnapshotNodeV1;
|
|
55
|
+
type WorkbenchFrame = WorkbenchFrameV1;
|
|
56
|
+
|
|
57
|
+
declare function migrateWorkbenchSnapshot(value: unknown): WorkbenchSnapshotV1;
|
|
58
|
+
|
|
59
|
+
declare function normalizeWorkbenchSnapshot(value: WorkbenchSnapshotV1): WorkbenchSnapshotV1;
|
|
60
|
+
|
|
61
|
+
var $schema = "https://json-schema.org/draft/2020-12/schema";
|
|
62
|
+
var $id = "https://nextop.local/schemas/workbench-snapshot.v1.json";
|
|
63
|
+
var title = "WorkbenchSnapshotV1";
|
|
64
|
+
var type = "object";
|
|
65
|
+
var additionalProperties = false;
|
|
66
|
+
var required = [
|
|
67
|
+
"schemaVersion",
|
|
68
|
+
"nodes"
|
|
69
|
+
];
|
|
70
|
+
var properties = {
|
|
71
|
+
schemaVersion: {
|
|
72
|
+
"const": 1
|
|
73
|
+
},
|
|
74
|
+
nodes: {
|
|
75
|
+
type: "array",
|
|
76
|
+
maxItems: 128,
|
|
77
|
+
items: {
|
|
78
|
+
$ref: "#/$defs/node"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
nodeStack: {
|
|
82
|
+
type: "array",
|
|
83
|
+
items: {
|
|
84
|
+
type: "string",
|
|
85
|
+
minLength: 1
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
activeNodeId: {
|
|
89
|
+
type: [
|
|
90
|
+
"string",
|
|
91
|
+
"null"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
spaces: {
|
|
95
|
+
type: "array",
|
|
96
|
+
items: {
|
|
97
|
+
$ref: "#/$defs/space"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
activeSpaceId: {
|
|
101
|
+
type: [
|
|
102
|
+
"string",
|
|
103
|
+
"null"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
metadata: {
|
|
107
|
+
type: "object"
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var $defs = {
|
|
111
|
+
frame: {
|
|
112
|
+
type: "object",
|
|
113
|
+
additionalProperties: false,
|
|
114
|
+
required: [
|
|
115
|
+
"x",
|
|
116
|
+
"y",
|
|
117
|
+
"width",
|
|
118
|
+
"height"
|
|
119
|
+
],
|
|
120
|
+
properties: {
|
|
121
|
+
x: {
|
|
122
|
+
type: "number"
|
|
123
|
+
},
|
|
124
|
+
y: {
|
|
125
|
+
type: "number"
|
|
126
|
+
},
|
|
127
|
+
width: {
|
|
128
|
+
type: "number",
|
|
129
|
+
minimum: 160
|
|
130
|
+
},
|
|
131
|
+
height: {
|
|
132
|
+
type: "number",
|
|
133
|
+
minimum: 120
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
node: {
|
|
138
|
+
type: "object",
|
|
139
|
+
additionalProperties: false,
|
|
140
|
+
required: [
|
|
141
|
+
"id",
|
|
142
|
+
"kind",
|
|
143
|
+
"title",
|
|
144
|
+
"frame"
|
|
145
|
+
],
|
|
146
|
+
properties: {
|
|
147
|
+
id: {
|
|
148
|
+
type: "string",
|
|
149
|
+
minLength: 1,
|
|
150
|
+
maxLength: 160
|
|
151
|
+
},
|
|
152
|
+
kind: {
|
|
153
|
+
type: "string",
|
|
154
|
+
minLength: 1,
|
|
155
|
+
maxLength: 120
|
|
156
|
+
},
|
|
157
|
+
title: {
|
|
158
|
+
type: "string",
|
|
159
|
+
maxLength: 240
|
|
160
|
+
},
|
|
161
|
+
frame: {
|
|
162
|
+
$ref: "#/$defs/frame"
|
|
163
|
+
},
|
|
164
|
+
displayMode: {
|
|
165
|
+
"enum": [
|
|
166
|
+
"floating",
|
|
167
|
+
"fullscreen"
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
restoreFrame: {
|
|
171
|
+
anyOf: [
|
|
172
|
+
{
|
|
173
|
+
$ref: "#/$defs/frame"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: "null"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
isMinimized: {
|
|
181
|
+
type: "boolean"
|
|
182
|
+
},
|
|
183
|
+
minimizedAtUnixMs: {
|
|
184
|
+
type: [
|
|
185
|
+
"integer",
|
|
186
|
+
"null"
|
|
187
|
+
],
|
|
188
|
+
minimum: 0
|
|
189
|
+
},
|
|
190
|
+
data: true,
|
|
191
|
+
adapterState: {
|
|
192
|
+
type: "object"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
space: {
|
|
197
|
+
type: "object",
|
|
198
|
+
additionalProperties: false,
|
|
199
|
+
required: [
|
|
200
|
+
"id",
|
|
201
|
+
"name",
|
|
202
|
+
"nodeIds"
|
|
203
|
+
],
|
|
204
|
+
properties: {
|
|
205
|
+
id: {
|
|
206
|
+
type: "string",
|
|
207
|
+
minLength: 1
|
|
208
|
+
},
|
|
209
|
+
name: {
|
|
210
|
+
type: "string"
|
|
211
|
+
},
|
|
212
|
+
nodeIds: {
|
|
213
|
+
type: "array",
|
|
214
|
+
items: {
|
|
215
|
+
type: "string",
|
|
216
|
+
minLength: 1
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
frame: {
|
|
220
|
+
anyOf: [
|
|
221
|
+
{
|
|
222
|
+
$ref: "#/$defs/frame"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: "null"
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
},
|
|
229
|
+
data: true
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
var schema = {
|
|
234
|
+
$schema: $schema,
|
|
235
|
+
$id: $id,
|
|
236
|
+
title: title,
|
|
237
|
+
type: type,
|
|
238
|
+
additionalProperties: additionalProperties,
|
|
239
|
+
required: required,
|
|
240
|
+
properties: properties,
|
|
241
|
+
$defs: $defs
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
declare function serializeWorkbenchSnapshot(snapshot: WorkbenchSnapshotV1): string;
|
|
245
|
+
declare function parseWorkbenchSnapshot(serialized: string): WorkbenchSnapshotV1;
|
|
246
|
+
|
|
247
|
+
interface WorkbenchSnapshotValidationIssue {
|
|
248
|
+
path: string;
|
|
249
|
+
message: string;
|
|
250
|
+
}
|
|
251
|
+
interface WorkbenchSnapshotValidationResult {
|
|
252
|
+
ok: boolean;
|
|
253
|
+
issues: WorkbenchSnapshotValidationIssue[];
|
|
254
|
+
}
|
|
255
|
+
declare function validateWorkbenchSnapshot(value: unknown): WorkbenchSnapshotValidationResult;
|
|
256
|
+
declare function assertValidWorkbenchSnapshot(value: unknown): asserts value is WorkbenchSnapshotV1;
|
|
257
|
+
declare function formatWorkbenchSnapshotValidationIssues(issues: WorkbenchSnapshotValidationIssue[]): string;
|
|
258
|
+
|
|
259
|
+
export { type WorkbenchFrame, type WorkbenchFrameV1, type WorkbenchSnapshot, type WorkbenchSnapshotDisplayModeV1, type WorkbenchSnapshotNode, type WorkbenchSnapshotNodeAdapterStateV1, type WorkbenchSnapshotNodeV1, type WorkbenchSnapshotSchemaVersion, type WorkbenchSnapshotSpaceV1, type WorkbenchSnapshotV1, type WorkbenchSnapshotValidationIssue, type WorkbenchSnapshotValidationResult, assertValidWorkbenchSnapshot, formatWorkbenchSnapshotValidationIssues, migrateWorkbenchSnapshot, normalizeWorkbenchSnapshot, parseWorkbenchSnapshot, serializeWorkbenchSnapshot, validateWorkbenchSnapshot, schema as workbenchSnapshotJsonSchema, workbenchSnapshotLimits, workbenchSnapshotSchemaVersion };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
// src/limits.ts
|
|
2
|
+
var workbenchSnapshotLimits = {
|
|
3
|
+
maxSerializedBytes: 512 * 1024,
|
|
4
|
+
maxNodes: 128,
|
|
5
|
+
maxNodeIDLength: 160,
|
|
6
|
+
maxKindLength: 120,
|
|
7
|
+
maxTitleLength: 240,
|
|
8
|
+
minFrameWidth: 160,
|
|
9
|
+
minFrameHeight: 120,
|
|
10
|
+
maxFrameCoordinate: 1e6,
|
|
11
|
+
maxFrameSize: 1e6
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// src/types.ts
|
|
15
|
+
var workbenchSnapshotSchemaVersion = 1;
|
|
16
|
+
|
|
17
|
+
// src/validate.ts
|
|
18
|
+
var displayModes = /* @__PURE__ */ new Set([
|
|
19
|
+
"floating",
|
|
20
|
+
"fullscreen"
|
|
21
|
+
]);
|
|
22
|
+
function validateWorkbenchSnapshot(value) {
|
|
23
|
+
const issues = [];
|
|
24
|
+
if (!isRecord(value)) {
|
|
25
|
+
return issue("snapshot", "snapshot must be an object");
|
|
26
|
+
}
|
|
27
|
+
validateAllowedKeys(
|
|
28
|
+
value,
|
|
29
|
+
"snapshot",
|
|
30
|
+
[
|
|
31
|
+
"schemaVersion",
|
|
32
|
+
"nodes",
|
|
33
|
+
"nodeStack",
|
|
34
|
+
"activeNodeId",
|
|
35
|
+
"spaces",
|
|
36
|
+
"activeSpaceId",
|
|
37
|
+
"metadata"
|
|
38
|
+
],
|
|
39
|
+
issues
|
|
40
|
+
);
|
|
41
|
+
if (value.schemaVersion !== workbenchSnapshotSchemaVersion) {
|
|
42
|
+
issues.push({
|
|
43
|
+
path: "schemaVersion",
|
|
44
|
+
message: "unsupported workbench snapshot schema version"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (!Array.isArray(value.nodes)) {
|
|
48
|
+
issues.push({ path: "nodes", message: "nodes must be an array" });
|
|
49
|
+
} else {
|
|
50
|
+
if (value.nodes.length > workbenchSnapshotLimits.maxNodes) {
|
|
51
|
+
issues.push({
|
|
52
|
+
path: "nodes",
|
|
53
|
+
message: `nodes must contain at most ${workbenchSnapshotLimits.maxNodes} items`
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
validateNodes(value.nodes, issues);
|
|
57
|
+
}
|
|
58
|
+
validateStringArray(value.nodeStack, "nodeStack", issues, true);
|
|
59
|
+
validateOptionalStringOrNull(value.activeNodeId, "activeNodeId", issues);
|
|
60
|
+
if (value.spaces !== void 0) {
|
|
61
|
+
if (!Array.isArray(value.spaces)) {
|
|
62
|
+
issues.push({ path: "spaces", message: "spaces must be an array" });
|
|
63
|
+
} else {
|
|
64
|
+
validateSpaces(value.spaces, issues);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
validateOptionalStringOrNull(value.activeSpaceId, "activeSpaceId", issues);
|
|
68
|
+
const serializedBytes = serializedByteLength(value);
|
|
69
|
+
if (serializedBytes > workbenchSnapshotLimits.maxSerializedBytes) {
|
|
70
|
+
issues.push({
|
|
71
|
+
path: "snapshot",
|
|
72
|
+
message: `snapshot must serialize to at most ${workbenchSnapshotLimits.maxSerializedBytes} bytes`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return { ok: issues.length === 0, issues };
|
|
76
|
+
}
|
|
77
|
+
function assertValidWorkbenchSnapshot(value) {
|
|
78
|
+
const result = validateWorkbenchSnapshot(value);
|
|
79
|
+
if (!result.ok) {
|
|
80
|
+
throw new Error(formatWorkbenchSnapshotValidationIssues(result.issues));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function formatWorkbenchSnapshotValidationIssues(issues) {
|
|
84
|
+
if (issues.length === 0) {
|
|
85
|
+
return "workbench snapshot is valid";
|
|
86
|
+
}
|
|
87
|
+
return issues.map((item) => `${item.path}: ${item.message}`).join("; ");
|
|
88
|
+
}
|
|
89
|
+
function validateNodes(nodes, issues) {
|
|
90
|
+
const ids = /* @__PURE__ */ new Set();
|
|
91
|
+
nodes.forEach((node, index) => {
|
|
92
|
+
const path = `nodes[${index}]`;
|
|
93
|
+
if (!isRecord(node)) {
|
|
94
|
+
issues.push({ path, message: "node must be an object" });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
validateAllowedKeys(
|
|
98
|
+
node,
|
|
99
|
+
path,
|
|
100
|
+
[
|
|
101
|
+
"id",
|
|
102
|
+
"kind",
|
|
103
|
+
"title",
|
|
104
|
+
"frame",
|
|
105
|
+
"displayMode",
|
|
106
|
+
"restoreFrame",
|
|
107
|
+
"isMinimized",
|
|
108
|
+
"minimizedAtUnixMs",
|
|
109
|
+
"data",
|
|
110
|
+
"adapterState"
|
|
111
|
+
],
|
|
112
|
+
issues
|
|
113
|
+
);
|
|
114
|
+
const id = validateRequiredString(node.id, `${path}.id`, issues, {
|
|
115
|
+
maxLength: workbenchSnapshotLimits.maxNodeIDLength
|
|
116
|
+
});
|
|
117
|
+
if (id) {
|
|
118
|
+
if (ids.has(id)) {
|
|
119
|
+
issues.push({ path: `${path}.id`, message: "node id must be unique" });
|
|
120
|
+
}
|
|
121
|
+
ids.add(id);
|
|
122
|
+
}
|
|
123
|
+
validateRequiredString(node.kind, `${path}.kind`, issues, {
|
|
124
|
+
maxLength: workbenchSnapshotLimits.maxKindLength
|
|
125
|
+
});
|
|
126
|
+
validateRequiredString(node.title, `${path}.title`, issues, {
|
|
127
|
+
allowEmpty: true,
|
|
128
|
+
maxLength: workbenchSnapshotLimits.maxTitleLength
|
|
129
|
+
});
|
|
130
|
+
validateFrame(node.frame, `${path}.frame`, issues);
|
|
131
|
+
if (node.displayMode !== void 0 && !displayModes.has(node.displayMode)) {
|
|
132
|
+
issues.push({
|
|
133
|
+
path: `${path}.displayMode`,
|
|
134
|
+
message: "displayMode must be floating or fullscreen"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (node.restoreFrame !== void 0 && node.restoreFrame !== null) {
|
|
138
|
+
validateFrame(node.restoreFrame, `${path}.restoreFrame`, issues);
|
|
139
|
+
}
|
|
140
|
+
if (node.isMinimized !== void 0 && typeof node.isMinimized !== "boolean") {
|
|
141
|
+
issues.push({
|
|
142
|
+
path: `${path}.isMinimized`,
|
|
143
|
+
message: "isMinimized must be a boolean"
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
validateOptionalNonNegativeIntegerOrNull(
|
|
147
|
+
node.minimizedAtUnixMs,
|
|
148
|
+
`${path}.minimizedAtUnixMs`,
|
|
149
|
+
issues
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function validateSpaces(spaces, issues) {
|
|
154
|
+
spaces.forEach((space, index) => {
|
|
155
|
+
const path = `spaces[${index}]`;
|
|
156
|
+
if (!isRecord(space)) {
|
|
157
|
+
issues.push({ path, message: "space must be an object" });
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
validateAllowedKeys(
|
|
161
|
+
space,
|
|
162
|
+
path,
|
|
163
|
+
["id", "name", "nodeIds", "frame", "data"],
|
|
164
|
+
issues
|
|
165
|
+
);
|
|
166
|
+
validateRequiredString(space.id, `${path}.id`, issues);
|
|
167
|
+
validateRequiredString(space.name, `${path}.name`, issues, {
|
|
168
|
+
allowEmpty: true
|
|
169
|
+
});
|
|
170
|
+
validateStringArray(space.nodeIds, `${path}.nodeIds`, issues, false);
|
|
171
|
+
if (space.frame !== void 0 && space.frame !== null) {
|
|
172
|
+
validateFrame(space.frame, `${path}.frame`, issues);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function validateRequiredString(value, path, issues, options = {}) {
|
|
177
|
+
if (typeof value !== "string") {
|
|
178
|
+
issues.push({ path, message: "value must be a string" });
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const trimmed = value.trim();
|
|
182
|
+
if (!options.allowEmpty && trimmed === "") {
|
|
183
|
+
issues.push({ path, message: "value must not be empty" });
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
if (options.maxLength !== void 0 && value.length > options.maxLength) {
|
|
187
|
+
issues.push({
|
|
188
|
+
path,
|
|
189
|
+
message: `value must be at most ${options.maxLength} characters`
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return trimmed;
|
|
193
|
+
}
|
|
194
|
+
function validateStringArray(value, path, issues, optional) {
|
|
195
|
+
if (value === void 0 && optional) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (!Array.isArray(value)) {
|
|
199
|
+
issues.push({ path, message: "value must be an array" });
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
value.forEach((item, index) => {
|
|
203
|
+
if (typeof item !== "string" || item.trim() === "") {
|
|
204
|
+
issues.push({
|
|
205
|
+
path: `${path}[${index}]`,
|
|
206
|
+
message: "value must be a non-empty string"
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function validateOptionalStringOrNull(value, path, issues) {
|
|
212
|
+
if (value === void 0 || value === null || typeof value === "string") {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
issues.push({ path, message: "value must be a string or null" });
|
|
216
|
+
}
|
|
217
|
+
function validateOptionalNonNegativeIntegerOrNull(value, path, issues) {
|
|
218
|
+
if (value === void 0 || value === null) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
|
|
222
|
+
issues.push({
|
|
223
|
+
path,
|
|
224
|
+
message: "value must be a non-negative integer or null"
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function validateFrame(value, path, issues) {
|
|
229
|
+
if (!isRecord(value)) {
|
|
230
|
+
issues.push({ path, message: "frame must be an object" });
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
validateAllowedKeys(value, path, ["x", "y", "width", "height"], issues);
|
|
234
|
+
validateFiniteNumber(value.x, `${path}.x`, issues);
|
|
235
|
+
validateFiniteNumber(value.y, `${path}.y`, issues);
|
|
236
|
+
validateFiniteNumber(value.width, `${path}.width`, issues);
|
|
237
|
+
validateFiniteNumber(value.height, `${path}.height`, issues);
|
|
238
|
+
const frame = value;
|
|
239
|
+
if (typeof frame.width === "number" && frame.width < workbenchSnapshotLimits.minFrameWidth) {
|
|
240
|
+
issues.push({
|
|
241
|
+
path: `${path}.width`,
|
|
242
|
+
message: `width must be at least ${workbenchSnapshotLimits.minFrameWidth}`
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
if (typeof frame.height === "number" && frame.height < workbenchSnapshotLimits.minFrameHeight) {
|
|
246
|
+
issues.push({
|
|
247
|
+
path: `${path}.height`,
|
|
248
|
+
message: `height must be at least ${workbenchSnapshotLimits.minFrameHeight}`
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function validateFiniteNumber(value, path, issues) {
|
|
253
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
254
|
+
issues.push({ path, message: "value must be a finite number" });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function validateAllowedKeys(value, path, allowedKeys, issues) {
|
|
258
|
+
const allowed = new Set(allowedKeys);
|
|
259
|
+
for (const key of Object.keys(value)) {
|
|
260
|
+
if (!allowed.has(key)) {
|
|
261
|
+
issues.push({
|
|
262
|
+
path: `${path}.${key}`,
|
|
263
|
+
message: "field is not part of the workbench snapshot contract"
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function serializedByteLength(value) {
|
|
269
|
+
try {
|
|
270
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
271
|
+
} catch {
|
|
272
|
+
return Number.POSITIVE_INFINITY;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function isRecord(value) {
|
|
276
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
277
|
+
}
|
|
278
|
+
function issue(path, message) {
|
|
279
|
+
return { ok: false, issues: [{ path, message }] };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// src/normalize.ts
|
|
283
|
+
function normalizeWorkbenchSnapshot(value) {
|
|
284
|
+
assertValidWorkbenchSnapshot(value);
|
|
285
|
+
const nodes = value.nodes.map(normalizeNode).sort(compareByID);
|
|
286
|
+
const nodeIDs = new Set(nodes.map((node) => node.id));
|
|
287
|
+
const nodeStack = uniqueStrings(value.nodeStack ?? []).filter(
|
|
288
|
+
(id) => nodeIDs.has(id)
|
|
289
|
+
);
|
|
290
|
+
for (const node of nodes) {
|
|
291
|
+
if (!nodeStack.includes(node.id)) {
|
|
292
|
+
nodeStack.push(node.id);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
const activeNodeId = value.activeNodeId && nodeIDs.has(value.activeNodeId) ? value.activeNodeId : nodeStack.at(-1) ?? null;
|
|
296
|
+
const spaces = value.spaces?.map(normalizeSpace).sort(compareByID);
|
|
297
|
+
const spaceIDs = new Set(spaces?.map((space) => space.id) ?? []);
|
|
298
|
+
const activeSpaceId = value.activeSpaceId && spaceIDs.has(value.activeSpaceId) ? value.activeSpaceId : spaces?.[0]?.id ?? null;
|
|
299
|
+
return stripUndefined({
|
|
300
|
+
schemaVersion: workbenchSnapshotSchemaVersion,
|
|
301
|
+
nodes,
|
|
302
|
+
nodeStack,
|
|
303
|
+
activeNodeId,
|
|
304
|
+
spaces,
|
|
305
|
+
activeSpaceId,
|
|
306
|
+
metadata: value.metadata
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function normalizeNode(node) {
|
|
310
|
+
return stripUndefined({
|
|
311
|
+
id: node.id.trim(),
|
|
312
|
+
kind: node.kind.trim(),
|
|
313
|
+
title: node.title,
|
|
314
|
+
frame: normalizeFrame(node.frame),
|
|
315
|
+
displayMode: node.displayMode ?? "floating",
|
|
316
|
+
restoreFrame: node.restoreFrame ? normalizeFrame(node.restoreFrame) : null,
|
|
317
|
+
isMinimized: node.isMinimized ?? false,
|
|
318
|
+
minimizedAtUnixMs: normalizeMinimizedAtUnixMs(node),
|
|
319
|
+
data: node.data,
|
|
320
|
+
adapterState: node.adapterState
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function normalizeMinimizedAtUnixMs(node) {
|
|
324
|
+
if (node.isMinimized !== true) {
|
|
325
|
+
return void 0;
|
|
326
|
+
}
|
|
327
|
+
return node.minimizedAtUnixMs ?? void 0;
|
|
328
|
+
}
|
|
329
|
+
function normalizeSpace(space) {
|
|
330
|
+
return stripUndefined({
|
|
331
|
+
id: space.id.trim(),
|
|
332
|
+
name: space.name,
|
|
333
|
+
nodeIds: uniqueStrings(space.nodeIds),
|
|
334
|
+
frame: space.frame ? normalizeFrame(space.frame) : null,
|
|
335
|
+
data: space.data
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function normalizeFrame(frame) {
|
|
339
|
+
return {
|
|
340
|
+
x: normalizeNumber(frame.x),
|
|
341
|
+
y: normalizeNumber(frame.y),
|
|
342
|
+
width: Math.max(
|
|
343
|
+
workbenchSnapshotLimits.minFrameWidth,
|
|
344
|
+
normalizeNumber(frame.width)
|
|
345
|
+
),
|
|
346
|
+
height: Math.max(
|
|
347
|
+
workbenchSnapshotLimits.minFrameHeight,
|
|
348
|
+
normalizeNumber(frame.height)
|
|
349
|
+
)
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function normalizeNumber(value) {
|
|
353
|
+
return Object.is(value, -0) ? 0 : Number(value.toFixed(3));
|
|
354
|
+
}
|
|
355
|
+
function compareByID(left, right) {
|
|
356
|
+
return left.id.localeCompare(right.id);
|
|
357
|
+
}
|
|
358
|
+
function uniqueStrings(values) {
|
|
359
|
+
return Array.from(
|
|
360
|
+
new Set(values.map((value) => value.trim()).filter(Boolean))
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
function stripUndefined(value) {
|
|
364
|
+
return Object.fromEntries(
|
|
365
|
+
Object.entries(value).filter(([, entryValue]) => entryValue !== void 0)
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// src/migrate.ts
|
|
370
|
+
function migrateWorkbenchSnapshot(value) {
|
|
371
|
+
if (!isRecord2(value)) {
|
|
372
|
+
throw new Error("workbench snapshot must be an object");
|
|
373
|
+
}
|
|
374
|
+
if (value.schemaVersion === workbenchSnapshotSchemaVersion) {
|
|
375
|
+
assertValidWorkbenchSnapshot(value);
|
|
376
|
+
return normalizeWorkbenchSnapshot(value);
|
|
377
|
+
}
|
|
378
|
+
throw new Error(
|
|
379
|
+
`unsupported workbench snapshot schema version: ${String(value.schemaVersion)}`
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
function isRecord2(value) {
|
|
383
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// src/schema.json
|
|
387
|
+
var schema_default = {
|
|
388
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
389
|
+
$id: "https://nextop.local/schemas/workbench-snapshot.v1.json",
|
|
390
|
+
title: "WorkbenchSnapshotV1",
|
|
391
|
+
type: "object",
|
|
392
|
+
additionalProperties: false,
|
|
393
|
+
required: ["schemaVersion", "nodes"],
|
|
394
|
+
properties: {
|
|
395
|
+
schemaVersion: { const: 1 },
|
|
396
|
+
nodes: {
|
|
397
|
+
type: "array",
|
|
398
|
+
maxItems: 128,
|
|
399
|
+
items: { $ref: "#/$defs/node" }
|
|
400
|
+
},
|
|
401
|
+
nodeStack: {
|
|
402
|
+
type: "array",
|
|
403
|
+
items: { type: "string", minLength: 1 }
|
|
404
|
+
},
|
|
405
|
+
activeNodeId: { type: ["string", "null"] },
|
|
406
|
+
spaces: {
|
|
407
|
+
type: "array",
|
|
408
|
+
items: { $ref: "#/$defs/space" }
|
|
409
|
+
},
|
|
410
|
+
activeSpaceId: { type: ["string", "null"] },
|
|
411
|
+
metadata: { type: "object" }
|
|
412
|
+
},
|
|
413
|
+
$defs: {
|
|
414
|
+
frame: {
|
|
415
|
+
type: "object",
|
|
416
|
+
additionalProperties: false,
|
|
417
|
+
required: ["x", "y", "width", "height"],
|
|
418
|
+
properties: {
|
|
419
|
+
x: { type: "number" },
|
|
420
|
+
y: { type: "number" },
|
|
421
|
+
width: { type: "number", minimum: 160 },
|
|
422
|
+
height: { type: "number", minimum: 120 }
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
node: {
|
|
426
|
+
type: "object",
|
|
427
|
+
additionalProperties: false,
|
|
428
|
+
required: ["id", "kind", "title", "frame"],
|
|
429
|
+
properties: {
|
|
430
|
+
id: { type: "string", minLength: 1, maxLength: 160 },
|
|
431
|
+
kind: { type: "string", minLength: 1, maxLength: 120 },
|
|
432
|
+
title: { type: "string", maxLength: 240 },
|
|
433
|
+
frame: { $ref: "#/$defs/frame" },
|
|
434
|
+
displayMode: { enum: ["floating", "fullscreen"] },
|
|
435
|
+
restoreFrame: {
|
|
436
|
+
anyOf: [{ $ref: "#/$defs/frame" }, { type: "null" }]
|
|
437
|
+
},
|
|
438
|
+
isMinimized: { type: "boolean" },
|
|
439
|
+
minimizedAtUnixMs: {
|
|
440
|
+
type: ["integer", "null"],
|
|
441
|
+
minimum: 0
|
|
442
|
+
},
|
|
443
|
+
data: true,
|
|
444
|
+
adapterState: { type: "object" }
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
space: {
|
|
448
|
+
type: "object",
|
|
449
|
+
additionalProperties: false,
|
|
450
|
+
required: ["id", "name", "nodeIds"],
|
|
451
|
+
properties: {
|
|
452
|
+
id: { type: "string", minLength: 1 },
|
|
453
|
+
name: { type: "string" },
|
|
454
|
+
nodeIds: {
|
|
455
|
+
type: "array",
|
|
456
|
+
items: { type: "string", minLength: 1 }
|
|
457
|
+
},
|
|
458
|
+
frame: {
|
|
459
|
+
anyOf: [{ $ref: "#/$defs/frame" }, { type: "null" }]
|
|
460
|
+
},
|
|
461
|
+
data: true
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
// src/serialize.ts
|
|
468
|
+
function serializeWorkbenchSnapshot(snapshot) {
|
|
469
|
+
const normalized = normalizeWorkbenchSnapshot(snapshot);
|
|
470
|
+
assertValidWorkbenchSnapshot(normalized);
|
|
471
|
+
return JSON.stringify(normalized);
|
|
472
|
+
}
|
|
473
|
+
function parseWorkbenchSnapshot(serialized) {
|
|
474
|
+
const parsed = JSON.parse(serialized);
|
|
475
|
+
return migrateWorkbenchSnapshot(parsed);
|
|
476
|
+
}
|
|
477
|
+
export {
|
|
478
|
+
assertValidWorkbenchSnapshot,
|
|
479
|
+
formatWorkbenchSnapshotValidationIssues,
|
|
480
|
+
migrateWorkbenchSnapshot,
|
|
481
|
+
normalizeWorkbenchSnapshot,
|
|
482
|
+
parseWorkbenchSnapshot,
|
|
483
|
+
serializeWorkbenchSnapshot,
|
|
484
|
+
validateWorkbenchSnapshot,
|
|
485
|
+
schema_default as workbenchSnapshotJsonSchema,
|
|
486
|
+
workbenchSnapshotLimits,
|
|
487
|
+
workbenchSnapshotSchemaVersion
|
|
488
|
+
};
|
|
489
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/limits.ts","../src/types.ts","../src/validate.ts","../src/normalize.ts","../src/migrate.ts","../src/schema.json","../src/serialize.ts"],"sourcesContent":["export const workbenchSnapshotLimits = {\n maxSerializedBytes: 512 * 1024,\n maxNodes: 128,\n maxNodeIDLength: 160,\n maxKindLength: 120,\n maxTitleLength: 240,\n minFrameWidth: 160,\n minFrameHeight: 120,\n maxFrameCoordinate: 1_000_000,\n maxFrameSize: 1_000_000\n} as const;\n","export const workbenchSnapshotSchemaVersion = 1 as const;\n\nexport type WorkbenchSnapshotSchemaVersion =\n typeof workbenchSnapshotSchemaVersion;\n\nexport interface WorkbenchSnapshotV1 {\n schemaVersion: WorkbenchSnapshotSchemaVersion;\n nodes: WorkbenchSnapshotNodeV1[];\n nodeStack?: string[];\n activeNodeId?: string | null;\n spaces?: WorkbenchSnapshotSpaceV1[];\n activeSpaceId?: string | null;\n metadata?: Record<string, unknown>;\n}\n\nexport interface WorkbenchFrameV1 {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface WorkbenchSnapshotNodeV1 {\n id: string;\n kind: string;\n title: string;\n frame: WorkbenchFrameV1;\n displayMode?: WorkbenchSnapshotDisplayModeV1;\n restoreFrame?: WorkbenchFrameV1 | null;\n isMinimized?: boolean;\n minimizedAtUnixMs?: number | null;\n data?: unknown;\n adapterState?: WorkbenchSnapshotNodeAdapterStateV1;\n}\n\nexport type WorkbenchSnapshotDisplayModeV1 = \"floating\" | \"fullscreen\";\n\nexport interface WorkbenchSnapshotNodeAdapterStateV1 {\n [key: string]: unknown;\n}\n\nexport interface WorkbenchSnapshotSpaceV1 {\n id: string;\n name: string;\n nodeIds: string[];\n frame?: WorkbenchFrameV1 | null;\n data?: unknown;\n}\n\nexport type WorkbenchSnapshot = WorkbenchSnapshotV1;\nexport type WorkbenchSnapshotNode = WorkbenchSnapshotNodeV1;\nexport type WorkbenchFrame = WorkbenchFrameV1;\n","import { workbenchSnapshotLimits } from \"./limits.ts\";\nimport {\n workbenchSnapshotSchemaVersion,\n type WorkbenchFrameV1,\n type WorkbenchSnapshotDisplayModeV1,\n type WorkbenchSnapshotV1\n} from \"./types.ts\";\n\nexport interface WorkbenchSnapshotValidationIssue {\n path: string;\n message: string;\n}\n\nexport interface WorkbenchSnapshotValidationResult {\n ok: boolean;\n issues: WorkbenchSnapshotValidationIssue[];\n}\n\nconst displayModes = new Set<WorkbenchSnapshotDisplayModeV1>([\n \"floating\",\n \"fullscreen\"\n]);\n\nexport function validateWorkbenchSnapshot(\n value: unknown\n): WorkbenchSnapshotValidationResult {\n const issues: WorkbenchSnapshotValidationIssue[] = [];\n\n if (!isRecord(value)) {\n return issue(\"snapshot\", \"snapshot must be an object\");\n }\n validateAllowedKeys(\n value,\n \"snapshot\",\n [\n \"schemaVersion\",\n \"nodes\",\n \"nodeStack\",\n \"activeNodeId\",\n \"spaces\",\n \"activeSpaceId\",\n \"metadata\"\n ],\n issues\n );\n\n if (value.schemaVersion !== workbenchSnapshotSchemaVersion) {\n issues.push({\n path: \"schemaVersion\",\n message: \"unsupported workbench snapshot schema version\"\n });\n }\n\n if (!Array.isArray(value.nodes)) {\n issues.push({ path: \"nodes\", message: \"nodes must be an array\" });\n } else {\n if (value.nodes.length > workbenchSnapshotLimits.maxNodes) {\n issues.push({\n path: \"nodes\",\n message: `nodes must contain at most ${workbenchSnapshotLimits.maxNodes} items`\n });\n }\n validateNodes(value.nodes, issues);\n }\n\n validateStringArray(value.nodeStack, \"nodeStack\", issues, true);\n validateOptionalStringOrNull(value.activeNodeId, \"activeNodeId\", issues);\n\n if (value.spaces !== undefined) {\n if (!Array.isArray(value.spaces)) {\n issues.push({ path: \"spaces\", message: \"spaces must be an array\" });\n } else {\n validateSpaces(value.spaces, issues);\n }\n }\n\n validateOptionalStringOrNull(value.activeSpaceId, \"activeSpaceId\", issues);\n\n const serializedBytes = serializedByteLength(value);\n if (serializedBytes > workbenchSnapshotLimits.maxSerializedBytes) {\n issues.push({\n path: \"snapshot\",\n message: `snapshot must serialize to at most ${workbenchSnapshotLimits.maxSerializedBytes} bytes`\n });\n }\n\n return { ok: issues.length === 0, issues };\n}\n\nexport function assertValidWorkbenchSnapshot(\n value: unknown\n): asserts value is WorkbenchSnapshotV1 {\n const result = validateWorkbenchSnapshot(value);\n if (!result.ok) {\n throw new Error(formatWorkbenchSnapshotValidationIssues(result.issues));\n }\n}\n\nexport function formatWorkbenchSnapshotValidationIssues(\n issues: WorkbenchSnapshotValidationIssue[]\n): string {\n if (issues.length === 0) {\n return \"workbench snapshot is valid\";\n }\n\n return issues.map((item) => `${item.path}: ${item.message}`).join(\"; \");\n}\n\nfunction validateNodes(\n nodes: unknown[],\n issues: WorkbenchSnapshotValidationIssue[]\n): void {\n const ids = new Set<string>();\n\n nodes.forEach((node, index) => {\n const path = `nodes[${index}]`;\n if (!isRecord(node)) {\n issues.push({ path, message: \"node must be an object\" });\n return;\n }\n validateAllowedKeys(\n node,\n path,\n [\n \"id\",\n \"kind\",\n \"title\",\n \"frame\",\n \"displayMode\",\n \"restoreFrame\",\n \"isMinimized\",\n \"minimizedAtUnixMs\",\n \"data\",\n \"adapterState\"\n ],\n issues\n );\n\n const id = validateRequiredString(node.id, `${path}.id`, issues, {\n maxLength: workbenchSnapshotLimits.maxNodeIDLength\n });\n if (id) {\n if (ids.has(id)) {\n issues.push({ path: `${path}.id`, message: \"node id must be unique\" });\n }\n ids.add(id);\n }\n\n validateRequiredString(node.kind, `${path}.kind`, issues, {\n maxLength: workbenchSnapshotLimits.maxKindLength\n });\n validateRequiredString(node.title, `${path}.title`, issues, {\n allowEmpty: true,\n maxLength: workbenchSnapshotLimits.maxTitleLength\n });\n validateFrame(node.frame, `${path}.frame`, issues);\n\n if (\n node.displayMode !== undefined &&\n !displayModes.has(node.displayMode as WorkbenchSnapshotDisplayModeV1)\n ) {\n issues.push({\n path: `${path}.displayMode`,\n message: \"displayMode must be floating or fullscreen\"\n });\n }\n\n if (node.restoreFrame !== undefined && node.restoreFrame !== null) {\n validateFrame(node.restoreFrame, `${path}.restoreFrame`, issues);\n }\n\n if (\n node.isMinimized !== undefined &&\n typeof node.isMinimized !== \"boolean\"\n ) {\n issues.push({\n path: `${path}.isMinimized`,\n message: \"isMinimized must be a boolean\"\n });\n }\n\n validateOptionalNonNegativeIntegerOrNull(\n node.minimizedAtUnixMs,\n `${path}.minimizedAtUnixMs`,\n issues\n );\n });\n}\n\nfunction validateSpaces(\n spaces: unknown[],\n issues: WorkbenchSnapshotValidationIssue[]\n): void {\n spaces.forEach((space, index) => {\n const path = `spaces[${index}]`;\n if (!isRecord(space)) {\n issues.push({ path, message: \"space must be an object\" });\n return;\n }\n validateAllowedKeys(\n space,\n path,\n [\"id\", \"name\", \"nodeIds\", \"frame\", \"data\"],\n issues\n );\n\n validateRequiredString(space.id, `${path}.id`, issues);\n validateRequiredString(space.name, `${path}.name`, issues, {\n allowEmpty: true\n });\n validateStringArray(space.nodeIds, `${path}.nodeIds`, issues, false);\n\n if (space.frame !== undefined && space.frame !== null) {\n validateFrame(space.frame, `${path}.frame`, issues);\n }\n });\n}\n\nfunction validateRequiredString(\n value: unknown,\n path: string,\n issues: WorkbenchSnapshotValidationIssue[],\n options: { allowEmpty?: boolean; maxLength?: number } = {}\n): string | null {\n if (typeof value !== \"string\") {\n issues.push({ path, message: \"value must be a string\" });\n return null;\n }\n\n const trimmed = value.trim();\n if (!options.allowEmpty && trimmed === \"\") {\n issues.push({ path, message: \"value must not be empty\" });\n return null;\n }\n\n if (options.maxLength !== undefined && value.length > options.maxLength) {\n issues.push({\n path,\n message: `value must be at most ${options.maxLength} characters`\n });\n }\n\n return trimmed;\n}\n\nfunction validateStringArray(\n value: unknown,\n path: string,\n issues: WorkbenchSnapshotValidationIssue[],\n optional: boolean\n): void {\n if (value === undefined && optional) {\n return;\n }\n if (!Array.isArray(value)) {\n issues.push({ path, message: \"value must be an array\" });\n return;\n }\n\n value.forEach((item, index) => {\n if (typeof item !== \"string\" || item.trim() === \"\") {\n issues.push({\n path: `${path}[${index}]`,\n message: \"value must be a non-empty string\"\n });\n }\n });\n}\n\nfunction validateOptionalStringOrNull(\n value: unknown,\n path: string,\n issues: WorkbenchSnapshotValidationIssue[]\n): void {\n if (value === undefined || value === null || typeof value === \"string\") {\n return;\n }\n issues.push({ path, message: \"value must be a string or null\" });\n}\n\nfunction validateOptionalNonNegativeIntegerOrNull(\n value: unknown,\n path: string,\n issues: WorkbenchSnapshotValidationIssue[]\n): void {\n if (value === undefined || value === null) {\n return;\n }\n if (typeof value !== \"number\" || !Number.isInteger(value) || value < 0) {\n issues.push({\n path,\n message: \"value must be a non-negative integer or null\"\n });\n }\n}\n\nfunction validateFrame(\n value: unknown,\n path: string,\n issues: WorkbenchSnapshotValidationIssue[]\n): void {\n if (!isRecord(value)) {\n issues.push({ path, message: \"frame must be an object\" });\n return;\n }\n validateAllowedKeys(value, path, [\"x\", \"y\", \"width\", \"height\"], issues);\n\n validateFiniteNumber(value.x, `${path}.x`, issues);\n validateFiniteNumber(value.y, `${path}.y`, issues);\n validateFiniteNumber(value.width, `${path}.width`, issues);\n validateFiniteNumber(value.height, `${path}.height`, issues);\n\n const frame = value as Partial<WorkbenchFrameV1>;\n if (\n typeof frame.width === \"number\" &&\n frame.width < workbenchSnapshotLimits.minFrameWidth\n ) {\n issues.push({\n path: `${path}.width`,\n message: `width must be at least ${workbenchSnapshotLimits.minFrameWidth}`\n });\n }\n if (\n typeof frame.height === \"number\" &&\n frame.height < workbenchSnapshotLimits.minFrameHeight\n ) {\n issues.push({\n path: `${path}.height`,\n message: `height must be at least ${workbenchSnapshotLimits.minFrameHeight}`\n });\n }\n}\n\nfunction validateFiniteNumber(\n value: unknown,\n path: string,\n issues: WorkbenchSnapshotValidationIssue[]\n): void {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n issues.push({ path, message: \"value must be a finite number\" });\n }\n}\n\nfunction validateAllowedKeys(\n value: Record<string, unknown>,\n path: string,\n allowedKeys: string[],\n issues: WorkbenchSnapshotValidationIssue[]\n): void {\n const allowed = new Set(allowedKeys);\n for (const key of Object.keys(value)) {\n if (!allowed.has(key)) {\n issues.push({\n path: `${path}.${key}`,\n message: \"field is not part of the workbench snapshot contract\"\n });\n }\n }\n}\n\nfunction serializedByteLength(value: unknown): number {\n try {\n return new TextEncoder().encode(JSON.stringify(value)).byteLength;\n } catch {\n return Number.POSITIVE_INFINITY;\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction issue(\n path: string,\n message: string\n): WorkbenchSnapshotValidationResult {\n return { ok: false, issues: [{ path, message }] };\n}\n","import { workbenchSnapshotLimits } from \"./limits.ts\";\nimport {\n workbenchSnapshotSchemaVersion,\n type WorkbenchFrameV1,\n type WorkbenchSnapshotNodeV1,\n type WorkbenchSnapshotSpaceV1,\n type WorkbenchSnapshotV1\n} from \"./types.ts\";\nimport { assertValidWorkbenchSnapshot } from \"./validate.ts\";\n\nexport function normalizeWorkbenchSnapshot(\n value: WorkbenchSnapshotV1\n): WorkbenchSnapshotV1 {\n assertValidWorkbenchSnapshot(value);\n\n const nodes = value.nodes.map(normalizeNode).sort(compareByID);\n const nodeIDs = new Set(nodes.map((node) => node.id));\n const nodeStack = uniqueStrings(value.nodeStack ?? []).filter((id) =>\n nodeIDs.has(id)\n );\n\n for (const node of nodes) {\n if (!nodeStack.includes(node.id)) {\n nodeStack.push(node.id);\n }\n }\n\n const activeNodeId =\n value.activeNodeId && nodeIDs.has(value.activeNodeId)\n ? value.activeNodeId\n : (nodeStack.at(-1) ?? null);\n\n const spaces = value.spaces?.map(normalizeSpace).sort(compareByID);\n const spaceIDs = new Set(spaces?.map((space) => space.id) ?? []);\n const activeSpaceId =\n value.activeSpaceId && spaceIDs.has(value.activeSpaceId)\n ? value.activeSpaceId\n : (spaces?.[0]?.id ?? null);\n\n return stripUndefined({\n schemaVersion: workbenchSnapshotSchemaVersion,\n nodes,\n nodeStack,\n activeNodeId,\n spaces,\n activeSpaceId,\n metadata: value.metadata\n });\n}\n\nfunction normalizeNode(node: WorkbenchSnapshotNodeV1): WorkbenchSnapshotNodeV1 {\n return stripUndefined({\n id: node.id.trim(),\n kind: node.kind.trim(),\n title: node.title,\n frame: normalizeFrame(node.frame),\n displayMode: node.displayMode ?? \"floating\",\n restoreFrame: node.restoreFrame ? normalizeFrame(node.restoreFrame) : null,\n isMinimized: node.isMinimized ?? false,\n minimizedAtUnixMs: normalizeMinimizedAtUnixMs(node),\n data: node.data,\n adapterState: node.adapterState\n });\n}\n\nfunction normalizeMinimizedAtUnixMs(\n node: WorkbenchSnapshotNodeV1\n): number | null | undefined {\n if (node.isMinimized !== true) {\n return undefined;\n }\n return node.minimizedAtUnixMs ?? undefined;\n}\n\nfunction normalizeSpace(\n space: WorkbenchSnapshotSpaceV1\n): WorkbenchSnapshotSpaceV1 {\n return stripUndefined({\n id: space.id.trim(),\n name: space.name,\n nodeIds: uniqueStrings(space.nodeIds),\n frame: space.frame ? normalizeFrame(space.frame) : null,\n data: space.data\n });\n}\n\nfunction normalizeFrame(frame: WorkbenchFrameV1): WorkbenchFrameV1 {\n return {\n x: normalizeNumber(frame.x),\n y: normalizeNumber(frame.y),\n width: Math.max(\n workbenchSnapshotLimits.minFrameWidth,\n normalizeNumber(frame.width)\n ),\n height: Math.max(\n workbenchSnapshotLimits.minFrameHeight,\n normalizeNumber(frame.height)\n )\n };\n}\n\nfunction normalizeNumber(value: number): number {\n return Object.is(value, -0) ? 0 : Number(value.toFixed(3));\n}\n\nfunction compareByID<T extends { id: string }>(left: T, right: T): number {\n return left.id.localeCompare(right.id);\n}\n\nfunction uniqueStrings(values: string[]): string[] {\n return Array.from(\n new Set(values.map((value) => value.trim()).filter(Boolean))\n );\n}\n\nfunction stripUndefined<T extends Record<string, unknown>>(value: T): T {\n return Object.fromEntries(\n Object.entries(value).filter(([, entryValue]) => entryValue !== undefined)\n ) as T;\n}\n","import {\n workbenchSnapshotSchemaVersion,\n type WorkbenchSnapshotV1\n} from \"./types.ts\";\nimport { normalizeWorkbenchSnapshot } from \"./normalize.ts\";\nimport { assertValidWorkbenchSnapshot } from \"./validate.ts\";\n\nexport function migrateWorkbenchSnapshot(value: unknown): WorkbenchSnapshotV1 {\n if (!isRecord(value)) {\n throw new Error(\"workbench snapshot must be an object\");\n }\n\n if (value.schemaVersion === workbenchSnapshotSchemaVersion) {\n assertValidWorkbenchSnapshot(value);\n return normalizeWorkbenchSnapshot(value);\n }\n\n throw new Error(\n `unsupported workbench snapshot schema version: ${String(value.schemaVersion)}`\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n","{\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"$id\": \"https://nextop.local/schemas/workbench-snapshot.v1.json\",\n \"title\": \"WorkbenchSnapshotV1\",\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"required\": [\"schemaVersion\", \"nodes\"],\n \"properties\": {\n \"schemaVersion\": { \"const\": 1 },\n \"nodes\": {\n \"type\": \"array\",\n \"maxItems\": 128,\n \"items\": { \"$ref\": \"#/$defs/node\" }\n },\n \"nodeStack\": {\n \"type\": \"array\",\n \"items\": { \"type\": \"string\", \"minLength\": 1 }\n },\n \"activeNodeId\": { \"type\": [\"string\", \"null\"] },\n \"spaces\": {\n \"type\": \"array\",\n \"items\": { \"$ref\": \"#/$defs/space\" }\n },\n \"activeSpaceId\": { \"type\": [\"string\", \"null\"] },\n \"metadata\": { \"type\": \"object\" }\n },\n \"$defs\": {\n \"frame\": {\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"required\": [\"x\", \"y\", \"width\", \"height\"],\n \"properties\": {\n \"x\": { \"type\": \"number\" },\n \"y\": { \"type\": \"number\" },\n \"width\": { \"type\": \"number\", \"minimum\": 160 },\n \"height\": { \"type\": \"number\", \"minimum\": 120 }\n }\n },\n \"node\": {\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"required\": [\"id\", \"kind\", \"title\", \"frame\"],\n \"properties\": {\n \"id\": { \"type\": \"string\", \"minLength\": 1, \"maxLength\": 160 },\n \"kind\": { \"type\": \"string\", \"minLength\": 1, \"maxLength\": 120 },\n \"title\": { \"type\": \"string\", \"maxLength\": 240 },\n \"frame\": { \"$ref\": \"#/$defs/frame\" },\n \"displayMode\": { \"enum\": [\"floating\", \"fullscreen\"] },\n \"restoreFrame\": {\n \"anyOf\": [{ \"$ref\": \"#/$defs/frame\" }, { \"type\": \"null\" }]\n },\n \"isMinimized\": { \"type\": \"boolean\" },\n \"minimizedAtUnixMs\": {\n \"type\": [\"integer\", \"null\"],\n \"minimum\": 0\n },\n \"data\": true,\n \"adapterState\": { \"type\": \"object\" }\n }\n },\n \"space\": {\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"required\": [\"id\", \"name\", \"nodeIds\"],\n \"properties\": {\n \"id\": { \"type\": \"string\", \"minLength\": 1 },\n \"name\": { \"type\": \"string\" },\n \"nodeIds\": {\n \"type\": \"array\",\n \"items\": { \"type\": \"string\", \"minLength\": 1 }\n },\n \"frame\": {\n \"anyOf\": [{ \"$ref\": \"#/$defs/frame\" }, { \"type\": \"null\" }]\n },\n \"data\": true\n }\n }\n }\n}\n","import { migrateWorkbenchSnapshot } from \"./migrate.ts\";\nimport { normalizeWorkbenchSnapshot } from \"./normalize.ts\";\nimport type { WorkbenchSnapshotV1 } from \"./types.ts\";\nimport { assertValidWorkbenchSnapshot } from \"./validate.ts\";\n\nexport function serializeWorkbenchSnapshot(\n snapshot: WorkbenchSnapshotV1\n): string {\n const normalized = normalizeWorkbenchSnapshot(snapshot);\n assertValidWorkbenchSnapshot(normalized);\n return JSON.stringify(normalized);\n}\n\nexport function parseWorkbenchSnapshot(\n serialized: string\n): WorkbenchSnapshotV1 {\n const parsed = JSON.parse(serialized) as unknown;\n return migrateWorkbenchSnapshot(parsed);\n}\n"],"mappings":";AAAO,IAAM,0BAA0B;AAAA,EACrC,oBAAoB,MAAM;AAAA,EAC1B,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,cAAc;AAChB;;;ACVO,IAAM,iCAAiC;;;ACkB9C,IAAM,eAAe,oBAAI,IAAoC;AAAA,EAC3D;AAAA,EACA;AACF,CAAC;AAEM,SAAS,0BACd,OACmC;AACnC,QAAM,SAA6C,CAAC;AAEpD,MAAI,CAAC,SAAS,KAAK,GAAG;AACpB,WAAO,MAAM,YAAY,4BAA4B;AAAA,EACvD;AACA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,EACF;AAEA,MAAI,MAAM,kBAAkB,gCAAgC;AAC1D,WAAO,KAAK;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,MAAM,QAAQ,MAAM,KAAK,GAAG;AAC/B,WAAO,KAAK,EAAE,MAAM,SAAS,SAAS,yBAAy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ACQ;AACR,QAAM,aAAa,2BAA2B,QAAQ;AACtD,+BAA6B,UAAU;AACvC,SAAO,KAAK,UAAU,UAAU;AAClC;AAEO,SAAS,uBACd,YACqB;AACrB,QAAM,SAAS,KAAK,MAAM,UAAU;AACpC,SAAO,yBAAyB,MAAM;AACxC;","names":["isRecord"]}
|
package/dist/schema.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://nextop.local/schemas/workbench-snapshot.v1.json",
|
|
4
|
+
"title": "WorkbenchSnapshotV1",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["schemaVersion", "nodes"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"schemaVersion": { "const": 1 },
|
|
10
|
+
"nodes": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"maxItems": 128,
|
|
13
|
+
"items": { "$ref": "#/$defs/node" }
|
|
14
|
+
},
|
|
15
|
+
"nodeStack": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"items": { "type": "string", "minLength": 1 }
|
|
18
|
+
},
|
|
19
|
+
"activeNodeId": { "type": ["string", "null"] },
|
|
20
|
+
"spaces": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"items": { "$ref": "#/$defs/space" }
|
|
23
|
+
},
|
|
24
|
+
"activeSpaceId": { "type": ["string", "null"] },
|
|
25
|
+
"metadata": { "type": "object" }
|
|
26
|
+
},
|
|
27
|
+
"$defs": {
|
|
28
|
+
"frame": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"additionalProperties": false,
|
|
31
|
+
"required": ["x", "y", "width", "height"],
|
|
32
|
+
"properties": {
|
|
33
|
+
"x": { "type": "number" },
|
|
34
|
+
"y": { "type": "number" },
|
|
35
|
+
"width": { "type": "number", "minimum": 160 },
|
|
36
|
+
"height": { "type": "number", "minimum": 120 }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"node": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"additionalProperties": false,
|
|
42
|
+
"required": ["id", "kind", "title", "frame"],
|
|
43
|
+
"properties": {
|
|
44
|
+
"id": { "type": "string", "minLength": 1, "maxLength": 160 },
|
|
45
|
+
"kind": { "type": "string", "minLength": 1, "maxLength": 120 },
|
|
46
|
+
"title": { "type": "string", "maxLength": 240 },
|
|
47
|
+
"frame": { "$ref": "#/$defs/frame" },
|
|
48
|
+
"displayMode": { "enum": ["floating", "fullscreen"] },
|
|
49
|
+
"restoreFrame": {
|
|
50
|
+
"anyOf": [{ "$ref": "#/$defs/frame" }, { "type": "null" }]
|
|
51
|
+
},
|
|
52
|
+
"isMinimized": { "type": "boolean" },
|
|
53
|
+
"minimizedAtUnixMs": {
|
|
54
|
+
"type": ["integer", "null"],
|
|
55
|
+
"minimum": 0
|
|
56
|
+
},
|
|
57
|
+
"data": true,
|
|
58
|
+
"adapterState": { "type": "object" }
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"space": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"additionalProperties": false,
|
|
64
|
+
"required": ["id", "name", "nodeIds"],
|
|
65
|
+
"properties": {
|
|
66
|
+
"id": { "type": "string", "minLength": 1 },
|
|
67
|
+
"name": { "type": "string" },
|
|
68
|
+
"nodeIds": {
|
|
69
|
+
"type": "array",
|
|
70
|
+
"items": { "type": "string", "minLength": 1 }
|
|
71
|
+
},
|
|
72
|
+
"frame": {
|
|
73
|
+
"anyOf": [{ "$ref": "#/$defs/frame" }, { "type": "null" }]
|
|
74
|
+
},
|
|
75
|
+
"data": true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tutti-os/workbench-snapshot",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./schema.json": "./dist/schema.json"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/tutti-os/tutti.git",
|
|
21
|
+
"directory": "packages/workbench/snapshot"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^24.0.1",
|
|
25
|
+
"typescript": "^5.8.3",
|
|
26
|
+
"@tutti-os/config-tsconfig": "0.0.0"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup --config tsup.config.ts && node ../../../tools/scripts/copy-package-assets.mjs src/schema.json dist/schema.json",
|
|
33
|
+
"test": "node --test --experimental-strip-types ./src/*.test.ts",
|
|
34
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
35
|
+
},
|
|
36
|
+
"typesVersions": {
|
|
37
|
+
"*": {
|
|
38
|
+
"schema.json": [
|
|
39
|
+
"./dist/schema.json"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|