@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,6 +1,6 @@
|
|
|
1
1
|
import { ZodType, z } from "zod";
|
|
2
2
|
import { ComponentType } from "react";
|
|
3
|
-
//#region ../errors/
|
|
3
|
+
//#region ../errors/dist/index.d.ts
|
|
4
4
|
type ErrorIssue = {
|
|
5
5
|
path: string;
|
|
6
6
|
message: string;
|
|
@@ -11,99 +11,47 @@ declare class NessoError extends Error {
|
|
|
11
11
|
constructor(issues: ErrorIssue[]);
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
|
-
//#region ../schema/
|
|
15
|
-
|
|
16
|
-
x:
|
|
17
|
-
y:
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
id: string
|
|
21
|
-
label:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
predicate: string;
|
|
35
|
-
target: string;
|
|
36
|
-
};
|
|
37
|
-
type Graph = {
|
|
38
|
-
concepts: Concept[];
|
|
39
|
-
relationTypes: RelationType[];
|
|
40
|
-
relations: Relation[];
|
|
41
|
-
};
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region ../i18n/src/locale.d.ts
|
|
44
|
-
declare const locales: readonly ['en', 'it', 'zh-CN'];
|
|
45
|
-
type Locale = typeof locales[number];
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/definitions.d.ts
|
|
48
|
-
declare const themeColors: readonly ['background', 'foreground', 'canvas', 'sidebar', 'primary', 'primary-hover', 'primary-foreground', 'muted', 'muted-foreground', 'hover', 'pressed', 'border', 'ring', 'selection-halo', 'node-border', 'edge', 'handle'];
|
|
49
|
-
declare const themeDefinition: z.ZodObject<{
|
|
50
|
-
id: z.ZodString;
|
|
51
|
-
colors: z.ZodObject<{
|
|
52
|
-
background: z.ZodString;
|
|
53
|
-
border: z.ZodString;
|
|
54
|
-
canvas: z.ZodString;
|
|
55
|
-
edge: z.ZodString;
|
|
56
|
-
foreground: z.ZodString;
|
|
57
|
-
handle: z.ZodString;
|
|
58
|
-
hover: z.ZodString;
|
|
59
|
-
muted: z.ZodString;
|
|
60
|
-
"muted-foreground": z.ZodString;
|
|
61
|
-
"node-border": z.ZodString;
|
|
62
|
-
pressed: z.ZodString;
|
|
63
|
-
primary: z.ZodString;
|
|
64
|
-
"primary-foreground": z.ZodString;
|
|
65
|
-
"primary-hover": z.ZodString;
|
|
66
|
-
ring: z.ZodString;
|
|
67
|
-
"selection-halo": z.ZodString;
|
|
68
|
-
sidebar: z.ZodString;
|
|
69
|
-
}, z.core.$strict>;
|
|
70
|
-
metrics: z.ZodObject<{
|
|
71
|
-
'radius-control': z.ZodNumber;
|
|
72
|
-
'radius-object': z.ZodNumber;
|
|
73
|
-
'duration-state': z.ZodNumber;
|
|
74
|
-
}, z.core.$strict>;
|
|
75
|
-
fonts: z.ZodObject<{
|
|
76
|
-
sans: z.ZodObject<{
|
|
77
|
-
faces: z.ZodArray<z.ZodObject<{
|
|
78
|
-
path: z.ZodString;
|
|
79
|
-
weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
80
|
-
style: z.ZodEnum<{
|
|
81
|
-
italic: "italic";
|
|
82
|
-
normal: "normal";
|
|
83
|
-
}>;
|
|
84
|
-
unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
85
|
-
}, z.core.$strict>>;
|
|
86
|
-
}, z.core.$strict>;
|
|
87
|
-
mono: z.ZodObject<{
|
|
88
|
-
faces: z.ZodArray<z.ZodObject<{
|
|
89
|
-
path: z.ZodString;
|
|
90
|
-
weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
91
|
-
style: z.ZodEnum<{
|
|
92
|
-
italic: "italic";
|
|
93
|
-
normal: "normal";
|
|
94
|
-
}>;
|
|
95
|
-
unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
96
|
-
}, z.core.$strict>>;
|
|
14
|
+
//#region ../schema/dist/types.d.ts
|
|
15
|
+
declare const positionSchema: z.ZodObject<{
|
|
16
|
+
x: z.ZodNumber;
|
|
17
|
+
y: z.ZodNumber;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
declare const relationTypeSchema: z.ZodObject<{
|
|
20
|
+
id: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
21
|
+
label: z.ZodString;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
declare const graphSchema: z.ZodObject<{
|
|
24
|
+
concepts: z.ZodArray<z.ZodObject<{
|
|
25
|
+
id: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
26
|
+
label: z.ZodString;
|
|
27
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
28
|
+
color: z.ZodOptional<z.ZodString>;
|
|
29
|
+
bold: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
italic: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
position: z.ZodObject<{
|
|
32
|
+
x: z.ZodNumber;
|
|
33
|
+
y: z.ZodNumber;
|
|
97
34
|
}, z.core.$strict>;
|
|
98
|
-
}, z.core.$strict
|
|
35
|
+
}, z.core.$strict>>;
|
|
36
|
+
relationTypes: z.ZodArray<z.ZodObject<{
|
|
37
|
+
id: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
38
|
+
label: z.ZodString;
|
|
39
|
+
}, z.core.$strict>>;
|
|
40
|
+
relations: z.ZodArray<z.ZodObject<{
|
|
41
|
+
source: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
42
|
+
predicate: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
43
|
+
target: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
44
|
+
}, z.core.$strict>>;
|
|
99
45
|
}, z.core.$strict>;
|
|
100
|
-
type
|
|
101
|
-
type
|
|
102
|
-
|
|
103
|
-
declare function parseDefinition(kind: 'vocab', value: unknown): VocabDefinition;
|
|
104
|
-
declare function parseDefinition(kind: 'theme' | 'vocab', value: unknown): Definition;
|
|
46
|
+
type Position = z.infer<typeof positionSchema>;
|
|
47
|
+
type RelationType = z.infer<typeof relationTypeSchema>;
|
|
48
|
+
type Graph = z.infer<typeof graphSchema>;
|
|
105
49
|
//#endregion
|
|
106
|
-
//#region
|
|
50
|
+
//#region ../i18n/dist/locale.d.ts
|
|
51
|
+
declare const locales: readonly ['en', 'it', 'zh-CN'];
|
|
52
|
+
type Locale = (typeof locales)[number];
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region ../core/dist/types.d.ts
|
|
107
55
|
type DeepReadonly<T> = T extends readonly (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T;
|
|
108
56
|
type Selection = readonly {
|
|
109
57
|
readonly kind: 'concept' | 'relation';
|
|
@@ -115,7 +63,7 @@ type NessoOperation = {
|
|
|
115
63
|
readonly id: string;
|
|
116
64
|
readonly value: string;
|
|
117
65
|
} | {
|
|
118
|
-
readonly kind: 'concept.
|
|
66
|
+
readonly kind: 'concept.notes';
|
|
119
67
|
readonly id: string;
|
|
120
68
|
readonly value: string;
|
|
121
69
|
} | {
|
|
@@ -229,7 +177,9 @@ type NessoOperation = {
|
|
|
229
177
|
};
|
|
230
178
|
type VocabDefinition = {
|
|
231
179
|
readonly id: string;
|
|
232
|
-
readonly relationTypes: readonly Readonly<RelationType>
|
|
180
|
+
readonly relationTypes: readonly (Readonly<RelationType> & {
|
|
181
|
+
readonly translations?: Readonly<Partial<Record<Locale, string>>>;
|
|
182
|
+
})[];
|
|
233
183
|
readonly defaultTypeId: string;
|
|
234
184
|
};
|
|
235
185
|
type SavedView = {
|
|
@@ -256,6 +206,7 @@ type SectionId = 'sidebar' | 'sidebar.pinned-views' | 'sidebar.views' | 'inspect
|
|
|
256
206
|
type Preferences = {
|
|
257
207
|
readonly locale?: Locale;
|
|
258
208
|
readonly introSeen?: boolean;
|
|
209
|
+
readonly mcpEnabled?: boolean;
|
|
259
210
|
readonly activeVocabId: string;
|
|
260
211
|
readonly activeRendererId: string;
|
|
261
212
|
readonly activeThemeId: string;
|
|
@@ -288,7 +239,7 @@ type NessoStore = {
|
|
|
288
239
|
readonly position: Readonly<Position>;
|
|
289
240
|
}[], historyGroup?: string) => void;
|
|
290
241
|
readonly setConceptLabel: (id: string, label: string, historyGroup?: string) => void;
|
|
291
|
-
readonly
|
|
242
|
+
readonly setConceptNotes: (id: string, notes: string, historyGroup?: string) => void;
|
|
292
243
|
readonly setConceptColor: (id: string, color: string, historyGroup?: string) => void;
|
|
293
244
|
readonly setConceptBold: (id: string, value: boolean, historyGroup?: string) => void;
|
|
294
245
|
readonly setConceptItalic: (id: string, value: boolean, historyGroup?: string) => void;
|
|
@@ -318,24 +269,69 @@ type NessoStore = {
|
|
|
318
269
|
readonly deleteView: (id: string) => void;
|
|
319
270
|
readonly getViewGraph: (id: string) => GraphSnapshot;
|
|
320
271
|
};
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region ../core/dist/commands.d.ts
|
|
274
|
+
type WriteMethods = Omit<NessoStore, 'getState' | 'subscribe' | 'getViewGraph' | 'conceptPlacementOffset' | 'applyOperations' | 'setViewport' | 'setActiveRenderer' | 'resetGraph'>;
|
|
275
|
+
declare function createWriteCommands<Commit, Created>(applyOperations: (...args: Parameters<NessoStore['applyOperations']>) => Commit, created: (id: string, commit: Commit) => Created): { readonly [K in keyof WriteMethods]: (...args: Parameters<WriteMethods[K]>) => K extends 'addConcept' | 'createView' ? Created : Commit; };
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/definitions.d.ts
|
|
278
|
+
declare const themeColors: readonly ['background', 'foreground', 'canvas', 'sidebar', 'primary', 'primary-hover', 'primary-foreground', 'muted', 'muted-foreground', 'hover', 'pressed', 'border', 'ring', 'selection-halo', 'node-border', 'edge', 'handle'];
|
|
279
|
+
declare const themeDefinition: z.ZodObject<{
|
|
280
|
+
id: z.ZodString;
|
|
281
|
+
colors: z.ZodObject<{
|
|
282
|
+
background: z.ZodString;
|
|
283
|
+
border: z.ZodString;
|
|
284
|
+
canvas: z.ZodString;
|
|
285
|
+
edge: z.ZodString;
|
|
286
|
+
foreground: z.ZodString;
|
|
287
|
+
handle: z.ZodString;
|
|
288
|
+
hover: z.ZodString;
|
|
289
|
+
muted: z.ZodString;
|
|
290
|
+
"muted-foreground": z.ZodString;
|
|
291
|
+
"node-border": z.ZodString;
|
|
292
|
+
pressed: z.ZodString;
|
|
293
|
+
primary: z.ZodString;
|
|
294
|
+
"primary-foreground": z.ZodString;
|
|
295
|
+
"primary-hover": z.ZodString;
|
|
296
|
+
ring: z.ZodString;
|
|
297
|
+
"selection-halo": z.ZodString;
|
|
298
|
+
sidebar: z.ZodString;
|
|
299
|
+
}, z.core.$strict>;
|
|
300
|
+
metrics: z.ZodObject<{
|
|
301
|
+
'radius-control': z.ZodNumber;
|
|
302
|
+
'radius-object': z.ZodNumber;
|
|
303
|
+
'duration-state': z.ZodNumber;
|
|
304
|
+
}, z.core.$strict>;
|
|
305
|
+
fonts: z.ZodObject<{
|
|
306
|
+
sans: z.ZodObject<{
|
|
307
|
+
faces: z.ZodArray<z.ZodObject<{
|
|
308
|
+
path: z.ZodString;
|
|
309
|
+
weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
310
|
+
style: z.ZodEnum<{
|
|
311
|
+
italic: "italic";
|
|
312
|
+
normal: "normal";
|
|
313
|
+
}>;
|
|
314
|
+
unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
315
|
+
}, z.core.$strict>>;
|
|
316
|
+
}, z.core.$strict>;
|
|
317
|
+
mono: z.ZodObject<{
|
|
318
|
+
faces: z.ZodArray<z.ZodObject<{
|
|
319
|
+
path: z.ZodString;
|
|
320
|
+
weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
321
|
+
style: z.ZodEnum<{
|
|
322
|
+
italic: "italic";
|
|
323
|
+
normal: "normal";
|
|
324
|
+
}>;
|
|
325
|
+
unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
|
|
326
|
+
}, z.core.$strict>>;
|
|
327
|
+
}, z.core.$strict>;
|
|
328
|
+
}, z.core.$strict>;
|
|
329
|
+
}, z.core.$strict>;
|
|
330
|
+
type ThemeDefinition = DeepReadonly<z.infer<typeof themeDefinition>>;
|
|
331
|
+
type Definition = ThemeDefinition | VocabDefinition;
|
|
332
|
+
declare function parseDefinition(kind: 'theme', value: unknown): ThemeDefinition;
|
|
333
|
+
declare function parseDefinition(kind: 'vocab', value: unknown): VocabDefinition;
|
|
334
|
+
declare function parseDefinition(kind: 'theme' | 'vocab', value: unknown): Definition;
|
|
339
335
|
//#endregion
|
|
340
336
|
//#region src/i18n.d.ts
|
|
341
337
|
type LocalizedText = Readonly<{
|
|
@@ -352,10 +348,6 @@ declare class PluginError extends NessoError {
|
|
|
352
348
|
}
|
|
353
349
|
declare function parseOrThrow(schema: ZodType, value: unknown, prefix?: string): any;
|
|
354
350
|
//#endregion
|
|
355
|
-
//#region src/commands.d.ts
|
|
356
|
-
type WriteMethods = Omit<NessoStore, 'getState' | 'subscribe' | 'getViewGraph' | 'conceptPlacementOffset' | 'applyOperations' | 'setViewport' | 'setActiveRenderer' | 'resetGraph'>;
|
|
357
|
-
declare function createWriteCommands<Commit, Created>(applyOperations: (...args: Parameters<NessoStore['applyOperations']>) => Commit, created: (id: string, commit: Commit) => Created): { readonly [K in keyof WriteMethods]: (...args: Parameters<WriteMethods[K]>) => K extends 'addConcept' | 'createView' ? Created : Commit; };
|
|
358
|
-
//#endregion
|
|
359
351
|
//#region src/files.d.ts
|
|
360
352
|
declare const fileTextLimit: number;
|
|
361
353
|
declare const fileOpenOptions: z.ZodObject<{
|
|
@@ -424,6 +416,9 @@ declare function parsePluginStorageKey(value: unknown): PluginStorageKey;
|
|
|
424
416
|
//#region src/data.d.ts
|
|
425
417
|
declare function checkMessageSize(value: unknown, limit: number, maximumDepth?: number): void;
|
|
426
418
|
//#endregion
|
|
419
|
+
//#region src/theme-fonts.d.ts
|
|
420
|
+
declare const fontFaces: (ranges: Record<string, string>, stem: string, weight: [number, number]) => ThemeDefinition['fonts']['sans'];
|
|
421
|
+
//#endregion
|
|
427
422
|
//#region src/runtime.d.ts
|
|
428
423
|
declare const runtimeLimits: {
|
|
429
424
|
readonly request: number;
|
|
@@ -435,6 +430,24 @@ declare const runtimeLimits: {
|
|
|
435
430
|
readonly action: 120000;
|
|
436
431
|
readonly heartbeat: 15000;
|
|
437
432
|
};
|
|
433
|
+
declare const badgeLimits: {
|
|
434
|
+
readonly value: 999999;
|
|
435
|
+
readonly execution: 2000;
|
|
436
|
+
readonly refresh: 15000;
|
|
437
|
+
readonly rate: 1000;
|
|
438
|
+
};
|
|
439
|
+
declare const actionBadgeResult: z.ZodObject<{
|
|
440
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
441
|
+
refreshAt: z.ZodOptional<z.ZodNumber>;
|
|
442
|
+
}, z.core.$strict>;
|
|
443
|
+
type ActionBadgeInput = {
|
|
444
|
+
readonly viewId: string | null;
|
|
445
|
+
readonly viewGraph: GraphSnapshot;
|
|
446
|
+
readonly records: readonly PluginStorageRecord[];
|
|
447
|
+
readonly now: number;
|
|
448
|
+
};
|
|
449
|
+
type ActionBadgeResult = DeepReadonly<z.infer<typeof actionBadgeResult>>;
|
|
450
|
+
declare const parseActionBadgeResult: (value: unknown) => ActionBadgeResult;
|
|
438
451
|
declare const themeTokens: readonly ["background", "foreground", "canvas", "sidebar", "primary", "primary-hover", "primary-foreground", "muted", "muted-foreground", "hover", "pressed", "border", "ring", "selection-halo", "node-border", "edge", "handle", "font-sans", "font-mono", "radius-control", "radius-object", "duration-state"];
|
|
439
452
|
declare const metadata: z.ZodObject<{
|
|
440
453
|
name: z.ZodObject<{
|
|
@@ -466,9 +479,9 @@ declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
466
479
|
"concept.add": "concept.add";
|
|
467
480
|
"concept.bold": "concept.bold";
|
|
468
481
|
"concept.color": "concept.color";
|
|
469
|
-
"concept.description": "concept.description";
|
|
470
482
|
"concept.italic": "concept.italic";
|
|
471
483
|
"concept.label": "concept.label";
|
|
484
|
+
"concept.notes": "concept.notes";
|
|
472
485
|
"concept.position": "concept.position";
|
|
473
486
|
"concept.positions": "concept.positions";
|
|
474
487
|
"concept.remove": "concept.remove";
|
|
@@ -506,7 +519,7 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
506
519
|
id: z.ZodString;
|
|
507
520
|
value: z.ZodString;
|
|
508
521
|
}, z.core.$strict>, z.ZodObject<{
|
|
509
|
-
kind: z.ZodLiteral<"concept.
|
|
522
|
+
kind: z.ZodLiteral<"concept.notes">;
|
|
510
523
|
id: z.ZodString;
|
|
511
524
|
value: z.ZodString;
|
|
512
525
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -823,6 +836,12 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
823
836
|
}, z.core.$strict>, z.ZodObject<{
|
|
824
837
|
type: z.ZodLiteral<"contribution">;
|
|
825
838
|
value: z.ZodUnknown;
|
|
839
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
840
|
+
type: z.ZodLiteral<"badge-result">;
|
|
841
|
+
value: z.ZodObject<{
|
|
842
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
843
|
+
refreshAt: z.ZodOptional<z.ZodNumber>;
|
|
844
|
+
}, z.core.$strict>;
|
|
826
845
|
}, z.core.$strict>, z.ZodObject<{
|
|
827
846
|
type: z.ZodLiteral<"close">;
|
|
828
847
|
reason: z.ZodString;
|
|
@@ -864,11 +883,14 @@ declare const actionDescriptor: z.ZodObject<{
|
|
|
864
883
|
}, z.core.$strict>;
|
|
865
884
|
icon: z.ZodOptional<z.ZodString>;
|
|
866
885
|
ui: z.ZodOptional<z.ZodLiteral<true>>;
|
|
886
|
+
badge: z.ZodOptional<z.ZodLiteral<true>>;
|
|
867
887
|
}, z.core.$strict>;
|
|
868
|
-
declare const actionIconNames: readonly ['arrow-right', 'book-open', 'clipboard-paste', 'copy', 'download', 'file-down', 'file-up', 'folder', 'globe', 'layers', 'pencil', 'play', 'plus', 'refresh', 'scissors', 'search', 'share', 'sparkles', 'upload', 'zap'];
|
|
869
|
-
type ActionIconName = typeof actionIconNames[number];
|
|
888
|
+
declare const actionIconNames: readonly ['arrow-right', 'book-open', 'clipboard-paste', 'copy', 'download', 'file-down', 'file-up', 'folder', 'glasses', 'globe', 'layers', 'pencil', 'play', 'plus', 'refresh', 'repeat', 'scissors', 'search', 'share', 'sparkles', 'upload', 'zap'];
|
|
889
|
+
type ActionIconName = (typeof actionIconNames)[number];
|
|
870
890
|
type ActionDescriptor = DeepReadonly<z.infer<typeof actionDescriptor>>;
|
|
871
|
-
type ActionContribution = Omit<ActionDescriptor, 'ui'> &
|
|
891
|
+
type ActionContribution = Omit<ActionDescriptor, 'ui' | 'badge'> & {
|
|
892
|
+
readonly badge?: (input: ActionBadgeInput) => ActionBadgeResult | Promise<ActionBadgeResult>;
|
|
893
|
+
} & ({
|
|
872
894
|
readonly ui: ComponentType<ActionContext>;
|
|
873
895
|
readonly run?: never;
|
|
874
896
|
} | {
|
|
@@ -938,4 +960,4 @@ declare function createPluginClient(port: MessagePort, initial: unknown): {
|
|
|
938
960
|
getPresentation: () => Pick<ActionState, 'theme' | 'locale'>;
|
|
939
961
|
};
|
|
940
962
|
//#endregion
|
|
941
|
-
export {
|
|
963
|
+
export { FileOpenOptions as A, ThemeDefinition as B, PluginStorage as C, parsePluginStorageRecord as D, parsePluginStorageKey as E, PluginError as F, SavedView as G, themeColors as H, parseOrThrow as I, Selection as K, LocalizedText as L, FileSaveOptions as M, fileTextLimit as N, parsePluginStorageSnapshot as O, parseFileOptions as P, resolvePluginText as R, checkMessageSize as S, PluginStorageRecord as T, GraphSnapshot as U, parseDefinition as V, NessoOperation as W, parsePluginMessage as _, ActionDescriptor as a, themeTokens as b, PluginI18n as c, badgeLimits as d, createPluginClient as f, parsePluginManifest as g, parsePluginI18n as h, ActionContribution as i, FileOpenResult as j, pluginStorageLimits as k, PluginManifest as l, parseContribution as m, ActionBadgeResult as n, ActionIconName as o, parseActionBadgeResult as p, VocabDefinition as q, ActionContext as r, ActionState as s, ActionBadgeInput as t, actionIconNames as u, runtimeLimits as v, PluginStorageKey as w, fontFaces as x, sha256Hex as y, Definition as z };
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ActionContext, ActionContribution, ActionDescriptor, ActionIconName, ActionState, type Definition, type FileOpenOptions, type FileOpenResult, type FileSaveOptions, type LocalizedText, PluginError, PluginI18n, PluginManifest, actionIconNames, checkMessageSize, createPluginClient, fileTextLimit, parseContribution, parseDefinition, parseFileOptions, parseOrThrow, parsePluginI18n, parsePluginManifest, parsePluginMessage, parsePluginStorageKey, parsePluginStorageRecord, parsePluginStorageSnapshot, pluginStorageLimits, resolvePluginText, runtimeLimits, sha256Hex, themeColors, themeTokens };
|
|
1
|
+
import { A as FileOpenOptions, D as parsePluginStorageRecord, E as parsePluginStorageKey, F as PluginError, H as themeColors, I as parseOrThrow, L as LocalizedText, M as FileSaveOptions, N as fileTextLimit, O as parsePluginStorageSnapshot, P as parseFileOptions, R as resolvePluginText, S as checkMessageSize, V as parseDefinition, _ as parsePluginMessage, a as ActionDescriptor, b as themeTokens, c as PluginI18n, d as badgeLimits, f as createPluginClient, g as parsePluginManifest, h as parsePluginI18n, i as ActionContribution, j as FileOpenResult, k as pluginStorageLimits, l as PluginManifest, m as parseContribution, n as ActionBadgeResult, o as ActionIconName, p as parseActionBadgeResult, r as ActionContext, s as ActionState, t as ActionBadgeInput, u as actionIconNames, v as runtimeLimits, x as fontFaces, y as sha256Hex, z as Definition } from "./runtime-BxtTAcko.js";
|
|
2
|
+
export { ActionBadgeInput, ActionBadgeResult, ActionContext, ActionContribution, ActionDescriptor, ActionIconName, ActionState, type Definition, type FileOpenOptions, type FileOpenResult, type FileSaveOptions, type LocalizedText, PluginError, PluginI18n, PluginManifest, actionIconNames, badgeLimits, checkMessageSize, createPluginClient, fileTextLimit, fontFaces, parseActionBadgeResult, parseContribution, parseDefinition, parseFileOptions, parseOrThrow, parsePluginI18n, parsePluginManifest, parsePluginMessage, parsePluginStorageKey, parsePluginStorageRecord, parsePluginStorageSnapshot, pluginStorageLimits, resolvePluginText, runtimeLimits, sha256Hex, themeColors, themeTokens };
|
package/dist/runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { C as PluginError, t as actionIconNames, n as badgeLimits, _ as checkMessageSize, r as createPluginClient, y as fileTextLimit, f as fontFaces, i as parseActionBadgeResult, a as parseContribution, x as parseDefinition, b as parseFileOptions, w as parseOrThrow, o as parsePluginI18n, s as parsePluginManifest, c as parsePluginMessage, p as parsePluginStorageKey, m as parsePluginStorageRecord, h as parsePluginStorageSnapshot, g as pluginStorageLimits, v as resolvePluginText, l as runtimeLimits, u as sha256Hex, S as themeColors, d as themeTokens } from "./runtime-BM45o1qi.js";
|
package/example/README.md
CHANGED
|
@@ -28,8 +28,11 @@ Open `package.json` and `dist/index.js` in a text editor. In desktop DevTools, s
|
|
|
28
28
|
```ts
|
|
29
29
|
const result = await window.nessoPlugins.propose(
|
|
30
30
|
crypto.randomUUID(),
|
|
31
|
-
{
|
|
32
|
-
|
|
31
|
+
{
|
|
32
|
+
manifest,
|
|
33
|
+
files: [{ path: manifest.nesso.entry, bytes: new TextEncoder().encode(compiledCode) }],
|
|
34
|
+
},
|
|
35
|
+
'en',
|
|
33
36
|
)
|
|
34
37
|
```
|
|
35
38
|
|
package/example/package.json
CHANGED
|
@@ -1,50 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nesso-how/plugin-example",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Official example showing how to build Nesso plugins with the SDK and plugin APIs",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nesso-plugin"
|
|
7
|
+
],
|
|
5
8
|
"license": "MIT",
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "git+https://github.com/nesso-how/nesso.git",
|
|
9
12
|
"directory": "packages/plugin/example"
|
|
10
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src",
|
|
17
|
+
"tsconfig.json",
|
|
18
|
+
"vite.config.ts"
|
|
19
|
+
],
|
|
11
20
|
"type": "module",
|
|
12
|
-
"
|
|
13
|
-
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org/"
|
|
24
|
+
},
|
|
14
25
|
"scripts": {
|
|
15
26
|
"check": "tsc",
|
|
16
27
|
"build": "npm run check && vite build",
|
|
17
28
|
"prepack": "npm run build"
|
|
18
29
|
},
|
|
19
|
-
"publishConfig": {
|
|
20
|
-
"access": "public",
|
|
21
|
-
"registry": "https://registry.npmjs.org/"
|
|
22
|
-
},
|
|
23
30
|
"dependencies": {
|
|
24
|
-
"@nesso-how/ui": "1.0.0-
|
|
31
|
+
"@nesso-how/ui": "1.0.0-beta.1",
|
|
25
32
|
"react": "^19.2.8",
|
|
26
33
|
"react-dom": "^19.2.8"
|
|
27
34
|
},
|
|
28
35
|
"devDependencies": {
|
|
29
|
-
"@nesso-how/plugin": "0.
|
|
36
|
+
"@nesso-how/plugin": "0.6.0",
|
|
30
37
|
"@types/react": "^19.2.18",
|
|
31
38
|
"@types/react-dom": "^19.2.7",
|
|
32
39
|
"typescript": "~7.0.2",
|
|
33
40
|
"vite": "^8.3.0",
|
|
34
41
|
"vite-plugin-css-injected-by-js": "^5.0.3"
|
|
35
42
|
},
|
|
43
|
+
"i18n": {
|
|
44
|
+
"metadata": {
|
|
45
|
+
"name": {
|
|
46
|
+
"en": "Plugin Example"
|
|
47
|
+
},
|
|
48
|
+
"description": {
|
|
49
|
+
"en": "Learn how to build Nesso plugins with the SDK and plugin APIs."
|
|
50
|
+
},
|
|
51
|
+
"documentation": {
|
|
52
|
+
"en": "A reference plugin for developers, with practical examples of using Nesso's SDK and plugin APIs to define actions, interact with graph data, and build custom interfaces."
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
36
56
|
"nesso": {
|
|
37
57
|
"apiVersion": 1,
|
|
38
58
|
"kind": "actions",
|
|
39
59
|
"entry": "dist/index.js",
|
|
40
|
-
"writes": [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
"documentation": { "en": "A reference plugin for developers, with practical examples of using Nesso's SDK and plugin APIs to define actions, interact with graph data, and build custom interfaces." }
|
|
48
|
-
}
|
|
60
|
+
"writes": [
|
|
61
|
+
"concept.label"
|
|
62
|
+
],
|
|
63
|
+
"capabilities": [
|
|
64
|
+
"ui",
|
|
65
|
+
"storage"
|
|
66
|
+
]
|
|
49
67
|
}
|
|
50
68
|
}
|
package/example/src/Quiz.css
CHANGED
|
@@ -1,8 +1,50 @@
|
|
|
1
|
-
.quiz {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.
|
|
1
|
+
.quiz {
|
|
2
|
+
display: grid;
|
|
3
|
+
min-height: 100dvh;
|
|
4
|
+
place-items: center;
|
|
5
|
+
padding: 24px;
|
|
6
|
+
color: var(--foreground);
|
|
7
|
+
font:
|
|
8
|
+
13px/1.5 var(--font-sans),
|
|
9
|
+
system-ui,
|
|
10
|
+
sans-serif;
|
|
11
|
+
}
|
|
12
|
+
.quiz-card {
|
|
13
|
+
width: 100%;
|
|
14
|
+
max-width: 560px;
|
|
15
|
+
overflow-wrap: anywhere;
|
|
16
|
+
text-align: center;
|
|
17
|
+
}
|
|
18
|
+
.quiz h1 {
|
|
19
|
+
margin: 0 0 4px;
|
|
20
|
+
font-size: 20px;
|
|
21
|
+
font-weight: 500;
|
|
22
|
+
}
|
|
23
|
+
.quiz [data-step] {
|
|
24
|
+
margin: 0 0 16px;
|
|
25
|
+
color: var(--muted-foreground);
|
|
26
|
+
}
|
|
27
|
+
.quiz [data-question] {
|
|
28
|
+
margin: 0;
|
|
29
|
+
color: var(--muted-foreground);
|
|
30
|
+
}
|
|
31
|
+
.quiz [data-answer] {
|
|
32
|
+
min-height: 1.5em;
|
|
33
|
+
margin: 16px 0;
|
|
34
|
+
font-size: 18px;
|
|
35
|
+
}
|
|
36
|
+
.quiz [data-result] {
|
|
37
|
+
width: fit-content;
|
|
38
|
+
margin: 8px auto 24px;
|
|
39
|
+
padding: 16px 24px;
|
|
40
|
+
border: 1px solid var(--border);
|
|
41
|
+
border-radius: 12px;
|
|
42
|
+
background: var(--muted);
|
|
43
|
+
font-size: 18px;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
}
|
|
46
|
+
.quiz footer {
|
|
47
|
+
display: flex;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
gap: 8px;
|
|
50
|
+
}
|
package/example/src/Quiz.tsx
CHANGED
|
@@ -10,7 +10,9 @@ export function Quiz({ document, storage, viewId }: ActionContext) {
|
|
|
10
10
|
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
void storage.list().then((records) => {
|
|
13
|
-
const value = records.find(
|
|
13
|
+
const value = records.find(
|
|
14
|
+
(record) => record.key === key && record.conceptId === undefined,
|
|
15
|
+
)?.value
|
|
14
16
|
setStep(typeof value === 'number' ? value : 0)
|
|
15
17
|
})
|
|
16
18
|
}, [storage, key])
|
|
@@ -34,14 +36,33 @@ export function Quiz({ document, storage, viewId }: ActionContext) {
|
|
|
34
36
|
<section className="quiz">
|
|
35
37
|
<div className="quiz-card">
|
|
36
38
|
<h1>Concept Quiz</h1>
|
|
37
|
-
<p data-step>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
<p data-step>
|
|
40
|
+
Step {Math.min(step + 1, relations.length)} / {relations.length}
|
|
41
|
+
</p>
|
|
42
|
+
{relation ? (
|
|
43
|
+
<>
|
|
44
|
+
<p data-question>
|
|
45
|
+
{conceptLabel(relation.source)} — {relationType?.label || relation.predicate} → ?
|
|
46
|
+
</p>
|
|
47
|
+
<p data-answer role="status">
|
|
48
|
+
{revealed ? conceptLabel(relation.target) : ''}
|
|
49
|
+
</p>
|
|
50
|
+
</>
|
|
51
|
+
) : (
|
|
52
|
+
<p data-result role="status">
|
|
53
|
+
{relations.length ? 'Quiz complete!' : 'This view has no relations.'}
|
|
54
|
+
</p>
|
|
55
|
+
)}
|
|
42
56
|
<footer>
|
|
43
|
-
<Button variant="outline" onClick={() => void saveStep(0)}>
|
|
44
|
-
|
|
57
|
+
<Button variant="outline" onClick={() => void saveStep(0)}>
|
|
58
|
+
Reset
|
|
59
|
+
</Button>
|
|
60
|
+
<Button
|
|
61
|
+
disabled={!relation}
|
|
62
|
+
onClick={() => (revealed ? void saveStep(step + 1) : setRevealed(true))}
|
|
63
|
+
>
|
|
64
|
+
{buttonLabel}
|
|
65
|
+
</Button>
|
|
45
66
|
</footer>
|
|
46
67
|
</div>
|
|
47
68
|
</section>
|
package/example/src/index.ts
CHANGED
|
@@ -8,11 +8,13 @@ export const create = (): readonly ActionContribution[] => {
|
|
|
8
8
|
run: async ({ document }) => {
|
|
9
9
|
const state = document.getState()
|
|
10
10
|
|
|
11
|
-
const operations: readonly NessoOperation[] = state.viewGraph.concepts.map(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const operations: readonly NessoOperation[] = state.viewGraph.concepts.map(
|
|
12
|
+
({ id, label }) => ({
|
|
13
|
+
kind: 'concept.label',
|
|
14
|
+
id,
|
|
15
|
+
value: label.toUpperCase(),
|
|
16
|
+
}),
|
|
17
|
+
)
|
|
16
18
|
|
|
17
19
|
await document.applyOperations(operations)
|
|
18
20
|
},
|