@nesso-how/plugin 0.5.0 → 0.6.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/README.md +77 -46
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/node/data.d.ts +1 -0
- package/dist/node/data.js +28 -0
- package/dist/node/definitions.d.ts +69 -0
- package/dist/node/definitions.js +124 -0
- package/dist/node/errors.d.ts +10 -0
- package/dist/node/errors.js +45 -0
- package/dist/node/files.d.ts +20 -0
- package/dist/node/files.js +36 -0
- package/dist/node/i18n.d.ts +12 -0
- package/dist/node/i18n.js +11 -0
- package/dist/node/index.d.ts +6 -0
- package/dist/node/index.js +2 -0
- package/dist/node/package.d.ts +34 -0
- package/dist/node/package.js +224 -0
- package/dist/node/runtime.d.ts +555 -0
- package/dist/node/runtime.js +513 -0
- package/dist/node/storage.d.ts +46 -0
- package/dist/node/storage.js +67 -0
- package/dist/node/theme-fonts.d.ts +2 -0
- package/dist/node/theme-fonts.js +11 -0
- package/dist/package.d.ts +1 -1
- package/dist/package.js +1 -1
- package/dist/{runtime-CJPU4o4h.js → runtime-BM45o1qi.js} +281 -216
- package/dist/{runtime-D4jO7tbm.d.ts → runtime-BxtTAcko.d.ts} +144 -122
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +1 -1
- package/example/README.md +5 -2
- package/example/package.json +36 -18
- package/example/src/Quiz.css +50 -8
- package/example/src/Quiz.tsx +29 -8
- package/example/src/index.ts +7 -5
- package/package.json +4 -3
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
//#region ../errors/
|
|
2
|
+
//#region ../errors/dist/index.js
|
|
3
|
+
function validationIssues(issues, prefix = "") {
|
|
4
|
+
return issues.map(({ path, message }) => ({
|
|
5
|
+
path: path.reduce((result, key) => typeof key === "number" ? `${result}[${key}]` : result ? `${result}.${String(key)}` : String(key), prefix),
|
|
6
|
+
message
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
3
9
|
var NessoError = class extends Error {
|
|
4
10
|
name = "NessoError";
|
|
5
11
|
issues;
|
|
@@ -52,7 +58,7 @@ function parseOrThrow(schema, value, prefix = "") {
|
|
|
52
58
|
return parsed.data;
|
|
53
59
|
}
|
|
54
60
|
//#endregion
|
|
55
|
-
//#region ../schema/
|
|
61
|
+
//#region ../schema/dist/core.js
|
|
56
62
|
const newIri = () => `urn:uuid:${crypto.randomUUID()}`;
|
|
57
63
|
const isAbsoluteIri = (value) => typeof value === "string" && /^[a-z][a-z0-9+.-]*:/i.test(value);
|
|
58
64
|
const relationKey = ({ source, predicate, target }) => JSON.stringify([
|
|
@@ -61,211 +67,114 @@ const relationKey = ({ source, predicate, target }) => JSON.stringify([
|
|
|
61
67
|
target
|
|
62
68
|
]);
|
|
63
69
|
//#endregion
|
|
64
|
-
//#region
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
id,
|
|
94
|
-
value
|
|
95
|
-
}], historyGroup ? { historyGroup } : void 0),
|
|
96
|
-
setConceptColor: (id, value, historyGroup) => applyOperations([{
|
|
97
|
-
kind: "concept.color",
|
|
98
|
-
id,
|
|
99
|
-
value
|
|
100
|
-
}], historyGroup ? { historyGroup } : void 0),
|
|
101
|
-
setConceptBold: (id, value, historyGroup) => applyOperations([{
|
|
102
|
-
kind: "concept.bold",
|
|
103
|
-
id,
|
|
104
|
-
value
|
|
105
|
-
}], historyGroup ? { historyGroup } : void 0),
|
|
106
|
-
setConceptItalic: (id, value, historyGroup) => applyOperations([{
|
|
107
|
-
kind: "concept.italic",
|
|
108
|
-
id,
|
|
109
|
-
value
|
|
110
|
-
}], historyGroup ? { historyGroup } : void 0),
|
|
111
|
-
addConcept: (position, historyGroup) => {
|
|
112
|
-
const id = newIri();
|
|
113
|
-
return created(id, applyOperations([{
|
|
114
|
-
kind: "concept.add",
|
|
115
|
-
id,
|
|
116
|
-
position
|
|
117
|
-
}], historyGroup ? { historyGroup } : void 0));
|
|
118
|
-
},
|
|
119
|
-
connect: (source, target) => applyOperations([{
|
|
120
|
-
kind: "relation.connect",
|
|
121
|
-
source,
|
|
122
|
-
target
|
|
123
|
-
}]),
|
|
124
|
-
reconnectRelation: (id, source, target) => applyOperations([{
|
|
125
|
-
kind: "relation.reconnect",
|
|
126
|
-
id,
|
|
127
|
-
source,
|
|
128
|
-
target
|
|
129
|
-
}]),
|
|
130
|
-
setRelationType: (id, typeId) => applyOperations([{
|
|
131
|
-
kind: "relation.type",
|
|
132
|
-
id,
|
|
133
|
-
typeId
|
|
134
|
-
}]),
|
|
135
|
-
createRelationType: (id, label) => applyOperations([{
|
|
136
|
-
kind: "relation.type.create",
|
|
137
|
-
id,
|
|
138
|
-
typeId: newIri(),
|
|
139
|
-
label
|
|
140
|
-
}]),
|
|
141
|
-
removeConcept: (id) => applyOperations([{
|
|
142
|
-
kind: "concept.remove",
|
|
143
|
-
id
|
|
144
|
-
}]),
|
|
145
|
-
removeRelation: (id) => applyOperations([{
|
|
146
|
-
kind: "relation.remove",
|
|
147
|
-
id
|
|
148
|
-
}]),
|
|
149
|
-
setActiveVocab: (id) => applyOperations([{
|
|
150
|
-
kind: "preferences.vocab",
|
|
151
|
-
id
|
|
152
|
-
}]),
|
|
153
|
-
setActiveTheme: (id) => applyOperations([{
|
|
154
|
-
kind: "preferences.theme",
|
|
155
|
-
id
|
|
156
|
-
}]),
|
|
157
|
-
setLocale: (value) => applyOperations([{
|
|
158
|
-
kind: "preferences.locale",
|
|
159
|
-
value
|
|
160
|
-
}]),
|
|
161
|
-
setPanelSizes: (value) => applyOperations([{
|
|
162
|
-
kind: "preferences.panels",
|
|
163
|
-
value
|
|
164
|
-
}]),
|
|
165
|
-
setSectionOpen: (id, open) => applyOperations([{
|
|
166
|
-
kind: "preferences.section",
|
|
167
|
-
id,
|
|
168
|
-
open
|
|
169
|
-
}]),
|
|
170
|
-
createView: (name, conceptIds) => {
|
|
171
|
-
const id = newIri();
|
|
172
|
-
return created(id, applyOperations([{
|
|
173
|
-
kind: "view.create",
|
|
174
|
-
id,
|
|
175
|
-
name,
|
|
176
|
-
conceptIds
|
|
177
|
-
}]));
|
|
178
|
-
},
|
|
179
|
-
renameView: (id, name) => applyOperations([{
|
|
180
|
-
kind: "view.rename",
|
|
181
|
-
id,
|
|
182
|
-
name
|
|
183
|
-
}]),
|
|
184
|
-
setViewPinned: (id, pinned) => applyOperations([{
|
|
185
|
-
kind: "view.pin",
|
|
186
|
-
id,
|
|
187
|
-
pinned
|
|
188
|
-
}]),
|
|
189
|
-
setViewMembership: (viewId, conceptId, included) => applyOperations([{
|
|
190
|
-
kind: "view.membership",
|
|
191
|
-
viewId,
|
|
192
|
-
conceptId,
|
|
193
|
-
included
|
|
194
|
-
}]),
|
|
195
|
-
deleteView: (id) => applyOperations([{
|
|
196
|
-
kind: "view.remove",
|
|
197
|
-
id
|
|
198
|
-
}])
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region ../schema/src/validate.ts
|
|
203
|
-
function validateGraph(graph) {
|
|
204
|
-
const issues = [];
|
|
70
|
+
//#region ../schema/dist/types.js
|
|
71
|
+
const iriSchema = z.string({ error: "Expected an absolute IRI" }).refine(isAbsoluteIri, "Expected an absolute IRI");
|
|
72
|
+
const positionSchema = z.strictObject({
|
|
73
|
+
x: z.number(),
|
|
74
|
+
y: z.number()
|
|
75
|
+
});
|
|
76
|
+
const conceptSchema = z.strictObject({
|
|
77
|
+
id: iriSchema,
|
|
78
|
+
label: z.string(),
|
|
79
|
+
notes: z.string().optional(),
|
|
80
|
+
color: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),
|
|
81
|
+
bold: z.boolean().optional(),
|
|
82
|
+
italic: z.boolean().optional(),
|
|
83
|
+
position: positionSchema
|
|
84
|
+
});
|
|
85
|
+
const relationTypeSchema = z.strictObject({
|
|
86
|
+
id: iriSchema,
|
|
87
|
+
label: z.string()
|
|
88
|
+
});
|
|
89
|
+
const relationSchema = z.strictObject({
|
|
90
|
+
source: iriSchema,
|
|
91
|
+
predicate: iriSchema,
|
|
92
|
+
target: iriSchema
|
|
93
|
+
});
|
|
94
|
+
const graphSchema = z.strictObject({
|
|
95
|
+
concepts: z.array(conceptSchema),
|
|
96
|
+
relationTypes: z.array(relationTypeSchema),
|
|
97
|
+
relations: z.array(relationSchema)
|
|
98
|
+
}).superRefine((graph, context) => {
|
|
205
99
|
const concepts = /* @__PURE__ */ new Set();
|
|
206
100
|
const types = /* @__PURE__ */ new Set();
|
|
207
101
|
const relations = /* @__PURE__ */ new Set();
|
|
208
102
|
for (const [index, concept] of graph.concepts.entries()) {
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
103
|
+
if (concepts.has(concept.id)) context.addIssue({
|
|
104
|
+
code: "custom",
|
|
105
|
+
path: [
|
|
106
|
+
"concepts",
|
|
107
|
+
index,
|
|
108
|
+
"id"
|
|
109
|
+
],
|
|
215
110
|
message: `Duplicate concept IRI: ${concept.id}`
|
|
216
111
|
});
|
|
217
112
|
concepts.add(concept.id);
|
|
218
|
-
if (concept.description !== void 0 && typeof concept.description !== "string") issues.push({
|
|
219
|
-
path: `concepts[${index}].description`,
|
|
220
|
-
message: "Expected a string"
|
|
221
|
-
});
|
|
222
|
-
if (!Number.isFinite(concept.position.x) || !Number.isFinite(concept.position.y)) issues.push({
|
|
223
|
-
path: `concepts[${index}].position`,
|
|
224
|
-
message: `Invalid position: ${concept.id}`
|
|
225
|
-
});
|
|
226
|
-
if (concept.color !== void 0 && !/^#[0-9a-fA-F]{6}$/.test(concept.color)) issues.push({
|
|
227
|
-
path: `concepts[${index}].color`,
|
|
228
|
-
message: `Invalid color: ${concept.id}`
|
|
229
|
-
});
|
|
230
|
-
if (concept.bold !== void 0 && typeof concept.bold !== "boolean") issues.push({
|
|
231
|
-
path: `concepts[${index}].bold`,
|
|
232
|
-
message: "Expected a boolean"
|
|
233
|
-
});
|
|
234
|
-
if (concept.italic !== void 0 && typeof concept.italic !== "boolean") issues.push({
|
|
235
|
-
path: `concepts[${index}].italic`,
|
|
236
|
-
message: "Expected a boolean"
|
|
237
|
-
});
|
|
238
113
|
}
|
|
239
114
|
for (const [index, type] of graph.relationTypes.entries()) {
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
115
|
+
if (types.has(type.id) || concepts.has(type.id)) context.addIssue({
|
|
116
|
+
code: "custom",
|
|
117
|
+
path: [
|
|
118
|
+
"relationTypes",
|
|
119
|
+
index,
|
|
120
|
+
"id"
|
|
121
|
+
],
|
|
246
122
|
message: `Duplicate relation IRI: ${type.id}`
|
|
247
123
|
});
|
|
248
124
|
types.add(type.id);
|
|
249
125
|
}
|
|
250
126
|
for (const [index, relation] of graph.relations.entries()) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
127
|
+
const key = relationKey(relation);
|
|
128
|
+
if (!concepts.has(relation.source) || !concepts.has(relation.target)) context.addIssue({
|
|
129
|
+
code: "custom",
|
|
130
|
+
path: ["relations", index],
|
|
131
|
+
message: `Unknown concept in relation: ${key}`
|
|
254
132
|
});
|
|
255
|
-
if (!types.has(relation.predicate))
|
|
256
|
-
|
|
133
|
+
if (!types.has(relation.predicate)) context.addIssue({
|
|
134
|
+
code: "custom",
|
|
135
|
+
path: [
|
|
136
|
+
"relations",
|
|
137
|
+
index,
|
|
138
|
+
"predicate"
|
|
139
|
+
],
|
|
257
140
|
message: `Unknown relation type: ${relation.predicate}`
|
|
258
141
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
path:
|
|
142
|
+
if (relations.has(key)) context.addIssue({
|
|
143
|
+
code: "custom",
|
|
144
|
+
path: ["relations", index],
|
|
262
145
|
message: `Duplicate relation: ${key}`
|
|
263
146
|
});
|
|
264
147
|
relations.add(key);
|
|
265
148
|
}
|
|
266
|
-
|
|
149
|
+
});
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region ../schema/dist/validate.js
|
|
152
|
+
function validateGraph(graph) {
|
|
153
|
+
const result = graphSchema.safeParse(graph);
|
|
154
|
+
return result.success ? [] : validationIssues(result.error.issues);
|
|
267
155
|
}
|
|
268
156
|
//#endregion
|
|
157
|
+
//#region ../schema/dist/jsonld.js
|
|
158
|
+
const jsonObject = z.record(z.string(), z.unknown());
|
|
159
|
+
z.strictObject({
|
|
160
|
+
"@context": jsonObject,
|
|
161
|
+
"@graph": z.array(jsonObject)
|
|
162
|
+
});
|
|
163
|
+
z.strictObject({
|
|
164
|
+
"@id": iriSchema,
|
|
165
|
+
"@type": z.literal("rdf:Property"),
|
|
166
|
+
"rdfs:label": z.string()
|
|
167
|
+
});
|
|
168
|
+
z.object({
|
|
169
|
+
"@id": iriSchema,
|
|
170
|
+
"rdfs:label": conceptSchema.shape.label,
|
|
171
|
+
"rdfs:comment": conceptSchema.shape.notes,
|
|
172
|
+
position: positionSchema.optional(),
|
|
173
|
+
color: conceptSchema.shape.color,
|
|
174
|
+
bold: conceptSchema.shape.bold,
|
|
175
|
+
italic: conceptSchema.shape.italic
|
|
176
|
+
}).catchall(z.unknown());
|
|
177
|
+
//#endregion
|
|
269
178
|
//#region src/definitions.ts
|
|
270
179
|
const themeColors = [
|
|
271
180
|
"background",
|
|
@@ -345,18 +254,27 @@ const themeDefinition = z.strictObject({
|
|
|
345
254
|
message: "Font face limit exceeded"
|
|
346
255
|
});
|
|
347
256
|
});
|
|
257
|
+
const vocabRelationType = z.strictObject({
|
|
258
|
+
id: z.string().min(1).max(2048),
|
|
259
|
+
label: z.string().max(30),
|
|
260
|
+
translations: z.strictObject({
|
|
261
|
+
en: z.string().trim().min(1).max(30).optional(),
|
|
262
|
+
it: z.string().trim().min(1).max(30).optional(),
|
|
263
|
+
"zh-CN": z.string().trim().min(1).max(30).optional()
|
|
264
|
+
}).optional()
|
|
265
|
+
});
|
|
348
266
|
const vocabDefinition = z.strictObject({
|
|
349
267
|
id: contributionId,
|
|
350
|
-
relationTypes: z.array(
|
|
351
|
-
id: z.string().min(1).max(2048),
|
|
352
|
-
label: z.string().max(30)
|
|
353
|
-
})).min(1),
|
|
268
|
+
relationTypes: z.array(vocabRelationType).min(1),
|
|
354
269
|
defaultTypeId: z.string().min(1).max(2048)
|
|
355
270
|
}).superRefine(({ relationTypes, defaultTypeId }, context) => {
|
|
356
271
|
for (const issue of validateGraph({
|
|
357
272
|
concepts: [],
|
|
358
273
|
relations: [],
|
|
359
|
-
relationTypes
|
|
274
|
+
relationTypes: relationTypes.map(({ id, label }) => ({
|
|
275
|
+
id,
|
|
276
|
+
label
|
|
277
|
+
}))
|
|
360
278
|
})) context.addIssue({
|
|
361
279
|
code: "custom",
|
|
362
280
|
path: ["relationTypes"],
|
|
@@ -393,6 +311,144 @@ function parseFileOptions(kind, value) {
|
|
|
393
311
|
return parseOrThrow(kind === "open" ? fileOpenOptions : fileSaveOptions, value);
|
|
394
312
|
}
|
|
395
313
|
//#endregion
|
|
314
|
+
//#region ../core/dist/commands.js
|
|
315
|
+
function createWriteCommands(applyOperations, created) {
|
|
316
|
+
return {
|
|
317
|
+
undo: () => applyOperations([{ kind: "history.undo" }]),
|
|
318
|
+
redo: () => applyOperations([{ kind: "history.redo" }]),
|
|
319
|
+
setSelection: (value) => applyOperations([{
|
|
320
|
+
kind: "selection.set",
|
|
321
|
+
value
|
|
322
|
+
}]),
|
|
323
|
+
setView: (id) => applyOperations([{
|
|
324
|
+
kind: "view.activate",
|
|
325
|
+
id
|
|
326
|
+
}]),
|
|
327
|
+
setConceptPosition: (id, value, historyGroup) => applyOperations([{
|
|
328
|
+
kind: "concept.position",
|
|
329
|
+
id,
|
|
330
|
+
value
|
|
331
|
+
}], historyGroup ? { historyGroup } : void 0),
|
|
332
|
+
setConceptPositions: (updates, historyGroup) => applyOperations([{
|
|
333
|
+
kind: "concept.positions",
|
|
334
|
+
updates
|
|
335
|
+
}], historyGroup ? { historyGroup } : void 0),
|
|
336
|
+
setConceptLabel: (id, value, historyGroup) => applyOperations([{
|
|
337
|
+
kind: "concept.label",
|
|
338
|
+
id,
|
|
339
|
+
value
|
|
340
|
+
}], historyGroup ? { historyGroup } : void 0),
|
|
341
|
+
setConceptNotes: (id, value, historyGroup) => applyOperations([{
|
|
342
|
+
kind: "concept.notes",
|
|
343
|
+
id,
|
|
344
|
+
value
|
|
345
|
+
}], historyGroup ? { historyGroup } : void 0),
|
|
346
|
+
setConceptColor: (id, value, historyGroup) => applyOperations([{
|
|
347
|
+
kind: "concept.color",
|
|
348
|
+
id,
|
|
349
|
+
value
|
|
350
|
+
}], historyGroup ? { historyGroup } : void 0),
|
|
351
|
+
setConceptBold: (id, value, historyGroup) => applyOperations([{
|
|
352
|
+
kind: "concept.bold",
|
|
353
|
+
id,
|
|
354
|
+
value
|
|
355
|
+
}], historyGroup ? { historyGroup } : void 0),
|
|
356
|
+
setConceptItalic: (id, value, historyGroup) => applyOperations([{
|
|
357
|
+
kind: "concept.italic",
|
|
358
|
+
id,
|
|
359
|
+
value
|
|
360
|
+
}], historyGroup ? { historyGroup } : void 0),
|
|
361
|
+
addConcept: (position, historyGroup) => {
|
|
362
|
+
const id = newIri();
|
|
363
|
+
return created(id, applyOperations([{
|
|
364
|
+
kind: "concept.add",
|
|
365
|
+
id,
|
|
366
|
+
position
|
|
367
|
+
}], historyGroup ? { historyGroup } : void 0));
|
|
368
|
+
},
|
|
369
|
+
connect: (source, target) => applyOperations([{
|
|
370
|
+
kind: "relation.connect",
|
|
371
|
+
source,
|
|
372
|
+
target
|
|
373
|
+
}]),
|
|
374
|
+
reconnectRelation: (id, source, target) => applyOperations([{
|
|
375
|
+
kind: "relation.reconnect",
|
|
376
|
+
id,
|
|
377
|
+
source,
|
|
378
|
+
target
|
|
379
|
+
}]),
|
|
380
|
+
setRelationType: (id, typeId) => applyOperations([{
|
|
381
|
+
kind: "relation.type",
|
|
382
|
+
id,
|
|
383
|
+
typeId
|
|
384
|
+
}]),
|
|
385
|
+
createRelationType: (id, label) => applyOperations([{
|
|
386
|
+
kind: "relation.type.create",
|
|
387
|
+
id,
|
|
388
|
+
typeId: newIri(),
|
|
389
|
+
label
|
|
390
|
+
}]),
|
|
391
|
+
removeConcept: (id) => applyOperations([{
|
|
392
|
+
kind: "concept.remove",
|
|
393
|
+
id
|
|
394
|
+
}]),
|
|
395
|
+
removeRelation: (id) => applyOperations([{
|
|
396
|
+
kind: "relation.remove",
|
|
397
|
+
id
|
|
398
|
+
}]),
|
|
399
|
+
setActiveVocab: (id) => applyOperations([{
|
|
400
|
+
kind: "preferences.vocab",
|
|
401
|
+
id
|
|
402
|
+
}]),
|
|
403
|
+
setActiveTheme: (id) => applyOperations([{
|
|
404
|
+
kind: "preferences.theme",
|
|
405
|
+
id
|
|
406
|
+
}]),
|
|
407
|
+
setLocale: (value) => applyOperations([{
|
|
408
|
+
kind: "preferences.locale",
|
|
409
|
+
value
|
|
410
|
+
}]),
|
|
411
|
+
setPanelSizes: (value) => applyOperations([{
|
|
412
|
+
kind: "preferences.panels",
|
|
413
|
+
value
|
|
414
|
+
}]),
|
|
415
|
+
setSectionOpen: (id, open) => applyOperations([{
|
|
416
|
+
kind: "preferences.section",
|
|
417
|
+
id,
|
|
418
|
+
open
|
|
419
|
+
}]),
|
|
420
|
+
createView: (name, conceptIds) => {
|
|
421
|
+
const id = newIri();
|
|
422
|
+
return created(id, applyOperations([{
|
|
423
|
+
kind: "view.create",
|
|
424
|
+
id,
|
|
425
|
+
name,
|
|
426
|
+
conceptIds
|
|
427
|
+
}]));
|
|
428
|
+
},
|
|
429
|
+
renameView: (id, name) => applyOperations([{
|
|
430
|
+
kind: "view.rename",
|
|
431
|
+
id,
|
|
432
|
+
name
|
|
433
|
+
}]),
|
|
434
|
+
setViewPinned: (id, pinned) => applyOperations([{
|
|
435
|
+
kind: "view.pin",
|
|
436
|
+
id,
|
|
437
|
+
pinned
|
|
438
|
+
}]),
|
|
439
|
+
setViewMembership: (viewId, conceptId, included) => applyOperations([{
|
|
440
|
+
kind: "view.membership",
|
|
441
|
+
viewId,
|
|
442
|
+
conceptId,
|
|
443
|
+
included
|
|
444
|
+
}]),
|
|
445
|
+
deleteView: (id) => applyOperations([{
|
|
446
|
+
kind: "view.remove",
|
|
447
|
+
id
|
|
448
|
+
}])
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
396
452
|
//#region src/i18n.ts
|
|
397
453
|
const text = (limit) => z.string().max(limit).refine((value) => new TextEncoder().encode(value).byteLength <= limit, "Text byte limit exceeded");
|
|
398
454
|
const localizedText = (limit) => z.strictObject({
|
|
@@ -486,6 +542,17 @@ function parsePluginStorageKey(value) {
|
|
|
486
542
|
return parseOrThrow(pluginStorageKey, value);
|
|
487
543
|
}
|
|
488
544
|
//#endregion
|
|
545
|
+
//#region src/theme-fonts.ts
|
|
546
|
+
const fontFaces = (ranges, stem, weight) => ({ faces: Object.entries(ranges).map(([subset, intervals]) => ({
|
|
547
|
+
path: `fonts/${stem.replace("{subset}", subset)}.woff2`,
|
|
548
|
+
weight,
|
|
549
|
+
style: "normal",
|
|
550
|
+
unicodeRange: intervals.split(",").map((interval) => {
|
|
551
|
+
const [from, to = from] = interval.slice(2).split("-");
|
|
552
|
+
return [parseInt(from, 16), parseInt(to, 16)];
|
|
553
|
+
})
|
|
554
|
+
})) });
|
|
555
|
+
//#endregion
|
|
489
556
|
//#region src/runtime.ts
|
|
490
557
|
const runtimeLimits = {
|
|
491
558
|
request: 33554432,
|
|
@@ -497,6 +564,17 @@ const runtimeLimits = {
|
|
|
497
564
|
action: 12e4,
|
|
498
565
|
heartbeat: 15e3
|
|
499
566
|
};
|
|
567
|
+
const badgeLimits = {
|
|
568
|
+
value: 999999,
|
|
569
|
+
execution: 2e3,
|
|
570
|
+
refresh: 15e3,
|
|
571
|
+
rate: 1e3
|
|
572
|
+
};
|
|
573
|
+
const actionBadgeResult = z.strictObject({
|
|
574
|
+
value: z.number().int().min(0).max(badgeLimits.value).nullable(),
|
|
575
|
+
refreshAt: z.number().int().min(0).max(864e13).optional()
|
|
576
|
+
});
|
|
577
|
+
const parseActionBadgeResult = (value) => parseOrThrow(actionBadgeResult, value);
|
|
500
578
|
const themeTokens = [
|
|
501
579
|
...themeColors,
|
|
502
580
|
"font-sans",
|
|
@@ -506,10 +584,7 @@ const themeTokens = [
|
|
|
506
584
|
"duration-state"
|
|
507
585
|
];
|
|
508
586
|
const id = z.string().min(1).max(2048);
|
|
509
|
-
const position =
|
|
510
|
-
x: z.number(),
|
|
511
|
-
y: z.number()
|
|
512
|
-
});
|
|
587
|
+
const position = positionSchema;
|
|
513
588
|
const selection = z.array(z.strictObject({
|
|
514
589
|
kind: z.enum(["concept", "relation"]),
|
|
515
590
|
id
|
|
@@ -530,7 +605,7 @@ const operation = z.discriminatedUnion("kind", [
|
|
|
530
605
|
value: z.string()
|
|
531
606
|
}),
|
|
532
607
|
z.strictObject({
|
|
533
|
-
kind: z.literal("concept.
|
|
608
|
+
kind: z.literal("concept.notes"),
|
|
534
609
|
id,
|
|
535
610
|
value: z.string()
|
|
536
611
|
}),
|
|
@@ -682,7 +757,7 @@ const jsEntry = z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.js$/);
|
|
|
682
757
|
const jsonEntry = z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.json$/);
|
|
683
758
|
const operationDeclarations = z.array(z.enum([
|
|
684
759
|
"concept.label",
|
|
685
|
-
"concept.
|
|
760
|
+
"concept.notes",
|
|
686
761
|
"concept.color",
|
|
687
762
|
"concept.bold",
|
|
688
763
|
"concept.italic",
|
|
@@ -804,6 +879,10 @@ const message = z.union([
|
|
|
804
879
|
type: z.literal("contribution"),
|
|
805
880
|
value: z.unknown()
|
|
806
881
|
}),
|
|
882
|
+
z.strictObject({
|
|
883
|
+
type: z.literal("badge-result"),
|
|
884
|
+
value: actionBadgeResult
|
|
885
|
+
}),
|
|
807
886
|
z.strictObject({
|
|
808
887
|
type: z.literal("close"),
|
|
809
888
|
reason: z.string().max(2048)
|
|
@@ -822,7 +901,8 @@ const actionDescriptor = z.strictObject({
|
|
|
822
901
|
id: z.string().max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
|
823
902
|
label: localizedText(128),
|
|
824
903
|
icon: z.string().min(1).max(32).regex(/^[a-z]+(?:-[a-z]+)*$/).optional(),
|
|
825
|
-
ui: z.literal(true).optional()
|
|
904
|
+
ui: z.literal(true).optional(),
|
|
905
|
+
badge: z.literal(true).optional()
|
|
826
906
|
});
|
|
827
907
|
const actionIconNames = [
|
|
828
908
|
"arrow-right",
|
|
@@ -833,12 +913,14 @@ const actionIconNames = [
|
|
|
833
913
|
"file-down",
|
|
834
914
|
"file-up",
|
|
835
915
|
"folder",
|
|
916
|
+
"glasses",
|
|
836
917
|
"globe",
|
|
837
918
|
"layers",
|
|
838
919
|
"pencil",
|
|
839
920
|
"play",
|
|
840
921
|
"plus",
|
|
841
922
|
"refresh",
|
|
923
|
+
"repeat",
|
|
842
924
|
"scissors",
|
|
843
925
|
"search",
|
|
844
926
|
"share",
|
|
@@ -852,35 +934,18 @@ function parseContribution(kind, value) {
|
|
|
852
934
|
if (kind === "theme" || kind === "vocab") return parseDefinition(kind, value);
|
|
853
935
|
return parseOrThrow(actionDescriptors, value);
|
|
854
936
|
}
|
|
855
|
-
const graph = z.strictObject({
|
|
856
|
-
concepts: z.array(z.strictObject({
|
|
857
|
-
id,
|
|
858
|
-
label: z.string(),
|
|
859
|
-
description: z.string().optional(),
|
|
860
|
-
color: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),
|
|
861
|
-
bold: z.boolean().optional(),
|
|
862
|
-
italic: z.boolean().optional(),
|
|
863
|
-
position
|
|
864
|
-
})),
|
|
865
|
-
relationTypes: z.array(relationType),
|
|
866
|
-
relations: z.array(z.strictObject({
|
|
867
|
-
source: id,
|
|
868
|
-
predicate: id,
|
|
869
|
-
target: id
|
|
870
|
-
}))
|
|
871
|
-
});
|
|
872
937
|
const actionStateSchema = z.strictObject({
|
|
873
938
|
revision: z.number().int().nonnegative(),
|
|
874
939
|
contextId: id,
|
|
875
940
|
locale,
|
|
876
941
|
theme: z.strictObject(Object.fromEntries(themeTokens.map((token) => [token, z.string().max(512).regex(/^[#\w\s.,()%/"'-]*$/)]))),
|
|
877
942
|
conceptPlacementOffset: position,
|
|
878
|
-
viewGraph:
|
|
943
|
+
viewGraph: graphSchema,
|
|
879
944
|
selected: selection,
|
|
880
945
|
targetViewId: id.nullable(),
|
|
881
946
|
activeVocab: z.strictObject({
|
|
882
947
|
id,
|
|
883
|
-
relationTypes: z.array(
|
|
948
|
+
relationTypes: z.array(vocabRelationType),
|
|
884
949
|
defaultTypeId: id
|
|
885
950
|
}).nullable(),
|
|
886
951
|
history: z.strictObject({
|
|
@@ -1135,4 +1200,4 @@ function createPluginClient(port, initial) {
|
|
|
1135
1200
|
};
|
|
1136
1201
|
}
|
|
1137
1202
|
//#endregion
|
|
1138
|
-
export {
|
|
1203
|
+
export { PluginError as C, themeColors as S, checkMessageSize as _, parseContribution as a, parseFileOptions as b, parsePluginMessage as c, themeTokens as d, fontFaces as f, pluginStorageLimits as g, parsePluginStorageSnapshot as h, parseActionBadgeResult as i, runtimeLimits as l, parsePluginStorageRecord as m, badgeLimits as n, parsePluginI18n as o, parsePluginStorageKey as p, createPluginClient as r, parsePluginManifest as s, actionIconNames as t, sha256Hex as u, resolvePluginText as v, parseOrThrow as w, parseDefinition as x, fileTextLimit as y };
|