@nesso-how/plugin 1.0.0-beta.23 → 1.0.0-beta.25

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.
@@ -57,7 +57,7 @@ const presentationSchema = z.strictObject({
57
57
  italic: z.boolean().optional(),
58
58
  strikethrough: z.boolean().optional()
59
59
  });
60
- const viewMemberSchema = presentationSchema.extend({ id: iriSchema });
60
+ const conceptMapMemberSchema = presentationSchema.extend({ id: iriSchema });
61
61
  const relationTypeSchema = z.strictObject({
62
62
  id: iriSchema.refine((id) => !conceptKeys.includes(id), "Reserved concept property IRI"),
63
63
  label: z.string()
@@ -67,10 +67,12 @@ const relationSchema = z.strictObject({
67
67
  predicate: iriSchema,
68
68
  target: iriSchema
69
69
  });
70
- const viewSchema = z.strictObject({
70
+ const relationBendSchema = relationSchema.extend({ bend: z.number().refine((value) => value !== 0, "Manual bend must be nonzero") }).refine((relation) => relation.source !== relation.target, "Self-relations cannot be bent");
71
+ const mapSchema = z.strictObject({
71
72
  id: iriSchema,
72
73
  name: z.string(),
73
- members: z.array(viewMemberSchema)
74
+ members: z.array(conceptMapMemberSchema),
75
+ relationBends: z.array(relationBendSchema).optional()
74
76
  });
75
77
  const graphShape = {
76
78
  concepts: z.array(conceptSchema),
@@ -130,22 +132,24 @@ const checkReferences = (graph, context) => {
130
132
  }
131
133
  };
132
134
  const graphSchema = z.strictObject(graphShape).superRefine(checkReferences);
133
- const viewGraphSchema = z.strictObject({
135
+ const mapGraphSchema = z.strictObject({
134
136
  ...graphShape,
135
- concepts: z.array(conceptSchema.extend(presentationSchema.partial().shape))
137
+ concepts: z.array(conceptSchema.extend(presentationSchema.partial().shape)),
138
+ relations: z.array(relationSchema.extend({ bend: z.number().optional() }))
136
139
  }).superRefine(checkReferences);
137
- const viewsSchema = (graph) => z.array(viewSchema).superRefine((views, context) => {
140
+ const mapsSchema = (graph) => z.array(mapSchema).superRefine((maps, context) => {
138
141
  const concepts = new Set(graph.concepts.map(({ id }) => id));
142
+ const relations = new Set(graph.relations.map(relationKey));
139
143
  const taken = /* @__PURE__ */ new Set([...concepts, ...graph.relationTypes.map(({ id }) => id)]);
140
- for (const [index, view] of views.entries()) {
141
- if (taken.has(view.id)) context.addIssue({
144
+ for (const [index, map] of maps.entries()) {
145
+ if (taken.has(map.id)) context.addIssue({
142
146
  code: "custom",
143
147
  path: [index, "id"],
144
- message: `Duplicate view IRI: ${view.id}`
148
+ message: `Duplicate map IRI: ${map.id}`
145
149
  });
146
- taken.add(view.id);
150
+ taken.add(map.id);
147
151
  const members = /* @__PURE__ */ new Set();
148
- for (const [position, member] of view.members.entries()) {
152
+ for (const [position, member] of map.members.entries()) {
149
153
  if (!concepts.has(member.id) || members.has(member.id)) context.addIssue({
150
154
  code: "custom",
151
155
  path: [
@@ -154,10 +158,24 @@ const viewsSchema = (graph) => z.array(viewSchema).superRefine((views, context)
154
158
  position,
155
159
  "id"
156
160
  ],
157
- message: `${members.has(member.id) ? "Duplicate" : "Unknown"} view member: ${member.id}`
161
+ message: `${members.has(member.id) ? "Duplicate" : "Unknown"} map member: ${member.id}`
158
162
  });
159
163
  members.add(member.id);
160
164
  }
165
+ const bends = /* @__PURE__ */ new Set();
166
+ for (const [position, relation] of (map.relationBends ?? []).entries()) {
167
+ const key = relationKey(relation);
168
+ if (bends.has(key) || !relations.has(key) || !members.has(relation.source) || !members.has(relation.target)) context.addIssue({
169
+ code: "custom",
170
+ path: [
171
+ index,
172
+ "relationBends",
173
+ position
174
+ ],
175
+ message: "Duplicate or invalid relation bend"
176
+ });
177
+ bends.add(key);
178
+ }
161
179
  }
162
180
  });
163
181
  //#endregion
@@ -170,19 +188,20 @@ const legacyDocument = z.strictObject({
170
188
  presentationSchema.partial();
171
189
  z.object({ schemaVersion: z.number().int().positive().optional() });
172
190
  legacyDocument.extend({ schemaVersion: z.literal(1) });
191
+ legacyDocument.extend({ schemaVersion: z.literal(3) });
173
192
  //#endregion
174
193
  //#region ../schema/dist/validate.js
175
- function validateGraph(graph, views = []) {
194
+ function validateGraph(graph, maps = []) {
176
195
  const result = graphSchema.safeParse(graph);
177
196
  if (!result.success) return validationIssues(result.error.issues);
178
- const viewResult = viewsSchema(result.data).safeParse(views);
179
- return viewResult.success ? [] : validationIssues(viewResult.error.issues, "views");
197
+ const mapResult = mapsSchema(result.data).safeParse(maps);
198
+ return mapResult.success ? [] : validationIssues(mapResult.error.issues, "maps");
180
199
  }
181
200
  //#endregion
182
201
  //#region ../schema/dist/jsonld.js
183
202
  const jsonObject = z.record(z.string(), z.unknown());
184
203
  z.strictObject({
185
- schemaVersion: z.literal(2),
204
+ schemaVersion: z.literal(4),
186
205
  "@context": jsonObject,
187
206
  "@graph": z.array(jsonObject)
188
207
  });
@@ -198,9 +217,10 @@ z.object({
198
217
  }).catchall(z.unknown());
199
218
  z.strictObject({
200
219
  "@id": iriSchema,
201
- "@type": z.literal("View"),
220
+ "@type": z.literal("Map"),
202
221
  "rdfs:label": z.string(),
203
- members: z.array(presentationSchema.extend({ concept: z.strictObject({ "@id": iriSchema }) }))
222
+ members: z.array(presentationSchema.extend({ concept: z.strictObject({ "@id": iriSchema }) })),
223
+ relationBends: z.array(relationBendSchema).optional()
204
224
  });
205
225
  //#endregion
206
226
  //#region ../core/dist/commands.js
@@ -212,8 +232,8 @@ function createWriteCommands(applyOperations, created) {
212
232
  kind: "selection.set",
213
233
  value
214
234
  }]),
215
- setView: (id) => applyOperations([{
216
- kind: "view.activate",
235
+ setMap: (id) => applyOperations([{
236
+ kind: "map.activate",
217
237
  id
218
238
  }]),
219
239
  setConceptPosition: (id, value, historyGroup) => applyOperations([{
@@ -293,6 +313,11 @@ function createWriteCommands(applyOperations, created) {
293
313
  kind: "relation.remove",
294
314
  id
295
315
  }]),
316
+ setRelationBend: (id, value, historyGroup) => applyOperations([{
317
+ kind: "relation.bend",
318
+ id,
319
+ value
320
+ }], historyGroup ? { historyGroup } : void 0),
296
321
  setActiveVocab: (id) => applyOperations([{
297
322
  kind: "preferences.vocab",
298
323
  id
@@ -314,33 +339,33 @@ function createWriteCommands(applyOperations, created) {
314
339
  id,
315
340
  open
316
341
  }]),
317
- createView: (name, conceptIds) => {
342
+ createMap: (name, conceptIds) => {
318
343
  const id = newIri();
319
344
  return created(id, applyOperations([{
320
- kind: "view.create",
345
+ kind: "map.create",
321
346
  id,
322
347
  name,
323
348
  conceptIds
324
349
  }]));
325
350
  },
326
- renameView: (id, name) => applyOperations([{
327
- kind: "view.rename",
351
+ renameMap: (id, name) => applyOperations([{
352
+ kind: "map.rename",
328
353
  id,
329
354
  name
330
355
  }]),
331
- setViewPinned: (id, pinned) => applyOperations([{
332
- kind: "view.pin",
356
+ setMapPinned: (id, pinned) => applyOperations([{
357
+ kind: "map.pin",
333
358
  id,
334
359
  pinned
335
360
  }]),
336
- setViewMembership: (viewId, conceptId, included) => applyOperations([{
337
- kind: "view.membership",
338
- viewId,
361
+ setMapMembership: (mapId, conceptId, included) => applyOperations([{
362
+ kind: "map.membership",
363
+ mapId,
339
364
  conceptId,
340
365
  included
341
366
  }]),
342
- deleteView: (id) => applyOperations([{
343
- kind: "view.remove",
367
+ deleteMap: (id) => applyOperations([{
368
+ kind: "map.remove",
344
369
  id
345
370
  }])
346
371
  };
@@ -637,7 +662,7 @@ const pluginStorageScope = z.discriminatedUnion("kind", [z.strictObject({
637
662
  kind: z.literal("concept"),
638
663
  id: z.string().max(2048)
639
664
  }), z.strictObject({
640
- kind: z.literal("view"),
665
+ kind: z.literal("map"),
641
666
  id: z.string().max(2048)
642
667
  })]);
643
668
  const fields = {
@@ -800,6 +825,11 @@ const operation = z.discriminatedUnion("kind", [
800
825
  kind: z.literal("relation.remove"),
801
826
  id
802
827
  }),
828
+ z.strictObject({
829
+ kind: z.literal("relation.bend"),
830
+ id,
831
+ value: z.number()
832
+ }),
803
833
  z.strictObject({
804
834
  kind: z.literal("document.reset"),
805
835
  id
@@ -811,33 +841,33 @@ const operation = z.discriminatedUnion("kind", [
811
841
  value: selection
812
842
  }),
813
843
  z.strictObject({
814
- kind: z.literal("view.activate"),
844
+ kind: z.literal("map.activate"),
815
845
  id: id.nullable()
816
846
  }),
817
847
  z.strictObject({
818
- kind: z.literal("view.create"),
848
+ kind: z.literal("map.create"),
819
849
  id,
820
850
  name: z.string(),
821
851
  conceptIds: z.array(id)
822
852
  }),
823
853
  z.strictObject({
824
- kind: z.literal("view.rename"),
854
+ kind: z.literal("map.rename"),
825
855
  id,
826
856
  name: z.string()
827
857
  }),
828
858
  z.strictObject({
829
- kind: z.literal("view.pin"),
859
+ kind: z.literal("map.pin"),
830
860
  id,
831
861
  pinned: z.boolean()
832
862
  }),
833
863
  z.strictObject({
834
- kind: z.literal("view.membership"),
835
- viewId: id,
864
+ kind: z.literal("map.membership"),
865
+ mapId: id,
836
866
  conceptId: id,
837
867
  included: z.boolean()
838
868
  }),
839
869
  z.strictObject({
840
- kind: z.literal("view.remove"),
870
+ kind: z.literal("map.remove"),
841
871
  id
842
872
  }),
843
873
  ...["vocab", "theme"].map((kind) => z.strictObject({
@@ -859,11 +889,11 @@ const operation = z.discriminatedUnion("kind", [
859
889
  kind: z.literal("preferences.section"),
860
890
  id: z.enum([
861
891
  "sidebar",
862
- "sidebar.pinned-views",
863
- "sidebar.views",
892
+ "sidebar.pinned-maps",
893
+ "sidebar.maps",
864
894
  "inspector",
865
895
  "inspector.connections",
866
- "inspector.views",
896
+ "inspector.maps",
867
897
  "inspector.nodes"
868
898
  ]),
869
899
  open: z.boolean()
@@ -880,8 +910,8 @@ function parsePluginI18n(value) {
880
910
  checkMessageSize(value, 65536);
881
911
  return parseOrThrow(pluginI18n, value, "i18n.");
882
912
  }
883
- const pluginApiVersion = 5;
884
- const manifestFields = { apiVersion: z.literal(5) };
913
+ const pluginApiVersion = 7;
914
+ const manifestFields = { apiVersion: z.literal(7) };
885
915
  const jsEntry = z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.js$/);
886
916
  const jsonEntry = z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.json$/);
887
917
  const operationDeclarations = z.array(z.enum([
@@ -900,9 +930,10 @@ const operationDeclarations = z.array(z.enum([
900
930
  "relation.type",
901
931
  "relation.type.create",
902
932
  "relation.remove",
933
+ "relation.bend",
903
934
  "selection.set",
904
- "view.create",
905
- "view.membership"
935
+ "map.create",
936
+ "map.membership"
906
937
  ]));
907
938
  const manifest = z.discriminatedUnion("kind", [z.strictObject({
908
939
  ...manifestFields,
@@ -983,7 +1014,7 @@ const request = z.discriminatedUnion("method", [
983
1014
  }),
984
1015
  z.strictObject({
985
1016
  ...envelope,
986
- method: z.literal("images.renderView"),
1017
+ method: z.literal("images.renderCanvas"),
987
1018
  params: imageRenderOptions
988
1019
  })
989
1020
  ]);
@@ -1068,9 +1099,9 @@ const actionStateSchema = z.strictObject({
1068
1099
  theme: z.strictObject(Object.fromEntries(themeTokens.map((token) => [token, z.string().max(512).regex(/^[#\w\s.,()%/"'-]*$/)]))),
1069
1100
  colorScheme: z.enum(colorSchemes),
1070
1101
  conceptPlacementOffset: position,
1071
- viewGraph: viewGraphSchema,
1102
+ mapGraph: mapGraphSchema,
1072
1103
  selected: selection,
1073
- targetViewId: id.nullable(),
1104
+ targetMapId: id.nullable(),
1074
1105
  activeVocab: z.strictObject({
1075
1106
  id,
1076
1107
  relationTypes: z.array(vocabRelationType),
@@ -1081,8 +1112,8 @@ const actionStateSchema = z.strictObject({
1081
1112
  canRedo: z.boolean()
1082
1113
  }),
1083
1114
  workspace: z.strictObject({
1084
- activeViewId: id.nullable(),
1085
- savedViews: z.array(z.strictObject({
1115
+ activeMapId: id.nullable(),
1116
+ maps: z.array(z.strictObject({
1086
1117
  id,
1087
1118
  name: z.string(),
1088
1119
  pinned: z.boolean()
@@ -1133,7 +1164,7 @@ const results = {
1133
1164
  "notifications.notify": id,
1134
1165
  "files.open": fileOpenResult,
1135
1166
  "files.save": z.strictObject({ saved: z.boolean() }),
1136
- "images.renderView": renderedImage
1167
+ "images.renderCanvas": renderedImage
1137
1168
  };
1138
1169
  function parsePluginMessage(value) {
1139
1170
  checkMessageSize(value, runtimeLimits.request);
@@ -1263,7 +1294,7 @@ function createPluginClient(port, initial) {
1263
1294
  readRevision = Math.max(readRevision, result.revision);
1264
1295
  return result;
1265
1296
  };
1266
- const { undo: _undo, redo: _redo, setView: _view, setActiveVocab: _vocab, setActiveTheme: _theme, setLocale: _locale, setPanelSizes: _panels, setSectionOpen: _section, createView: _createView, renameView: _renameView, setViewPinned: _pin, deleteView: _deleteView, ...writes } = createWriteCommands(async (operations, options) => {
1297
+ const { undo: _undo, redo: _redo, setMap: _map, setActiveVocab: _vocab, setActiveTheme: _theme, setLocale: _locale, setPanelSizes: _panels, setSectionOpen: _section, createMap: _createMap, renameMap: _renameMap, setMapPinned: _pin, deleteMap: _deleteMap, ...writes } = createWriteCommands(async (operations, options) => {
1267
1298
  await applyOperations(operations, options);
1268
1299
  }, async (id, committed) => {
1269
1300
  await committed;
@@ -1285,7 +1316,7 @@ function createPluginClient(port, initial) {
1285
1316
  };
1286
1317
  return {
1287
1318
  context: {
1288
- viewId: state.targetViewId,
1319
+ mapId: state.targetMapId,
1289
1320
  document: {
1290
1321
  ...writes,
1291
1322
  getState,
@@ -1300,7 +1331,7 @@ function createPluginClient(port, initial) {
1300
1331
  applyOperations
1301
1332
  },
1302
1333
  notifications: { notify: (value) => call("notifications.notify", value) },
1303
- images: { renderView: (options) => call("images.renderView", options) },
1334
+ images: { renderCanvas: (options) => call("images.renderCanvas", options) },
1304
1335
  files: {
1305
1336
  open: (options) => call("files.open", options),
1306
1337
  save: (options) => call("files.save", options)