@nesso-how/plugin 1.0.0-beta.24 → 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.
- package/README.md +35 -35
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/runtime.d.ts +28 -28
- package/dist/node/runtime.js +23 -23
- package/dist/node/storage.d.ts +4 -4
- package/dist/node/storage.js +1 -1
- package/dist/package.d.ts +1 -1
- package/dist/package.js +1 -1
- package/dist/{runtime-ZHRz4_y1.js → runtime-BGO97h75.js} +55 -54
- package/dist/{runtime-BrbkQ4Oi.d.ts → runtime-C_IkTCNf.d.ts} +59 -59
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/example/README.md +3 -3
- package/example/package.json +4 -4
- package/example/src/Quiz.tsx +4 -4
- package/example/src/index.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ export const create = (): readonly ActionContribution[] => {
|
|
|
52
52
|
run: async ({ document }) => {
|
|
53
53
|
const state = document.getState()
|
|
54
54
|
|
|
55
|
-
const operations: readonly NessoOperation[] = state.
|
|
55
|
+
const operations: readonly NessoOperation[] = state.mapGraph.concepts.map(
|
|
56
56
|
({ id, label }) => ({
|
|
57
57
|
kind: 'concept.label',
|
|
58
58
|
id,
|
|
@@ -68,7 +68,7 @@ export const create = (): readonly ActionContribution[] => {
|
|
|
68
68
|
}
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
`create()` defines the action; Nesso calls `run` when the user invokes it. This action uppercases every concept label in that
|
|
71
|
+
`create()` defines the action; Nesso calls `run` when the user invokes it. This action uppercases every concept label in that map with one undoable batch. Shared concepts change in every map containing them.
|
|
72
72
|
|
|
73
73
|
### Package metadata and permissions
|
|
74
74
|
|
|
@@ -80,7 +80,7 @@ Keep the example's build configuration and set these fields in `package.json`:
|
|
|
80
80
|
"version": "1.0.0",
|
|
81
81
|
"keywords": ["nesso-plugin"],
|
|
82
82
|
"nesso": {
|
|
83
|
-
"apiVersion":
|
|
83
|
+
"apiVersion": 7,
|
|
84
84
|
"kind": "actions",
|
|
85
85
|
"entry": "dist/index.js",
|
|
86
86
|
"writes": ["concept.label"],
|
|
@@ -89,7 +89,7 @@ Keep the example's build configuration and set these fields in `package.json`:
|
|
|
89
89
|
"i18n": {
|
|
90
90
|
"metadata": {
|
|
91
91
|
"name": { "en": "Label tools" },
|
|
92
|
-
"description": { "en": "Uppercase concept labels in a
|
|
92
|
+
"description": { "en": "Uppercase concept labels in a map." },
|
|
93
93
|
"documentation": { "en": "Updates labels in one undoable batch." }
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -150,11 +150,11 @@ Local plugins stay installed across restarts and appear in Settings → Plugins
|
|
|
150
150
|
|
|
151
151
|
To update a local plugin the user has asked to replace, call `plugins`, find its entry with `local: true`, and pass its current `contentId` as `replacing` alongside `directory`. MCP cannot replace or shadow npm-installed or bundled plugins; use a different package name for your local copy.
|
|
152
152
|
|
|
153
|
-
Try the installed action from a
|
|
153
|
+
Try the installed action from a map's actions menu, or choose the theme/vocabulary in Settings. Check that the plugin handles cancellation and stale-state errors, closes cleanly, and restores saved data after restarting Nesso.
|
|
154
154
|
|
|
155
155
|
## Action API
|
|
156
156
|
|
|
157
|
-
Nesso passes `{ document, storage, files, images, notifications, signal,
|
|
157
|
+
Nesso passes `{ document, storage, files, images, notifications, signal, mapId }` to `run` as `ActionContext`. `document` exposes the shared graph, map membership, and transient selection; `storage` holds the plugin's private data for that document.
|
|
158
158
|
|
|
159
159
|
`create()` receives no arguments and returns an array of actions with unique lowercase kebab-case IDs, localized labels, optional icons, and either a `run(context)` handler or a React component in `ui`. The two forms are mutually exclusive. Use `ActionIconName` for supported icons.
|
|
160
160
|
|
|
@@ -172,7 +172,7 @@ function Browse({ document }: ActionContext) {
|
|
|
172
172
|
const state = useSyncExternalStore(document.subscribe, document.getState)
|
|
173
173
|
return (
|
|
174
174
|
<ul>
|
|
175
|
-
{state.
|
|
175
|
+
{state.mapGraph.concepts.map(({ id, label }) => (
|
|
176
176
|
<li key={id}>{label}</li>
|
|
177
177
|
))}
|
|
178
178
|
</ul>
|
|
@@ -186,7 +186,7 @@ export const create = (): readonly ActionContribution[] => [
|
|
|
186
186
|
|
|
187
187
|
#### Context
|
|
188
188
|
|
|
189
|
-
Components receive `ActionContext` directly as props, with the same APIs and permissions as `run`. `
|
|
189
|
+
Components receive `ActionContext` directly as props, with the same APIs and permissions as `run`. `mapId` and the supplied `mapGraph` refer to the invoked map. Subscribe with `useSyncExternalStore` when rendering snapshot data. Discovery runs `create()` in a Worker, so keep DOM access and effects inside components or `run`, not at module scope or in `create()`. The panel can access its own DOM, but not the host DOM, native bridge, network, or direct persistent storage; use the injected APIs for files and storage.
|
|
190
190
|
|
|
191
191
|
#### Styling
|
|
192
192
|
|
|
@@ -194,7 +194,7 @@ Nesso supplies React, the `@nesso-how/ui` component stylesheet, and theme CSS va
|
|
|
194
194
|
|
|
195
195
|
#### Lifecycle
|
|
196
196
|
|
|
197
|
-
Nesso provides the panel title, close control, and loading/error screens. Opening a panel or changing the active
|
|
197
|
+
Nesso provides the panel title, close control, and loading/error screens. Opening a panel or changing the active map starts a new React instance and invalidates the previous context. Closing it, changing documents, replacing/removing the plugin, or a runtime failure ends the session.
|
|
198
198
|
|
|
199
199
|
Keep mutable state inside the component and clean up subscriptions in React effects. Module-scope state is not guaranteed between sessions: Nesso may reuse or discard the runtime, so keep state in the instance or `storage`. Save progress through `storage` as it changes; cleanup may not finish. Panels have no action execution timeout, but initialization and API requests have deadlines. Handle expected errors in the UI; uncaught errors or rejected promises fail the session.
|
|
200
200
|
|
|
@@ -203,18 +203,18 @@ Keep mutable state inside the component and clean up subscriptions in React effe
|
|
|
203
203
|
Add optional `badge(input)` to a `run` or `ui` action. It may return synchronously or asynchronously:
|
|
204
204
|
|
|
205
205
|
```ts
|
|
206
|
-
badge: ({
|
|
207
|
-
value:
|
|
206
|
+
badge: ({ mapGraph }) => ({
|
|
207
|
+
value: mapGraph.concepts.length,
|
|
208
208
|
})
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
-
- `input`: readonly `
|
|
211
|
+
- `input`: readonly `mapId` (`null` for the graph), target `mapGraph`, private document storage `records` (requires `storage`; otherwise empty), and `now` in Unix milliseconds.
|
|
212
212
|
- Return `{ value: number | null, refreshAt?: number }`. `value` is an integer from 0 to 999,999; zero and `null` hide the badge.
|
|
213
213
|
- For time-dependent counts, calculate from `now` and return `refreshAt` as an absolute Unix-millisecond timestamp. Omit it otherwise. Timed refreshes run no more often than every 15 seconds.
|
|
214
214
|
|
|
215
|
-
Runs in an isolated Worker with no action APIs and a 2-second calculation limit. Nesso calculates only visible badges and refreshes them after graph,
|
|
215
|
+
Runs in an isolated Worker with no action APIs and a 2-second calculation limit. Nesso calculates only visible badges and refreshes them after graph, map, or plugin storage changes. Results are not persisted; failures hide the badge.
|
|
216
216
|
|
|
217
|
-
### Read the invoked
|
|
217
|
+
### Read the invoked map
|
|
218
218
|
|
|
219
219
|
- `document.getState()` returns the latest readonly local snapshot synchronously and makes it the basis for subsequent writes.
|
|
220
220
|
- `await document.refresh()` fetches and reads a fresh snapshot. Use it after deferred work, such as a file dialog, before computing edits.
|
|
@@ -222,12 +222,12 @@ Runs in an isolated Worker with no action APIs and a 2-second calculation limit.
|
|
|
222
222
|
|
|
223
223
|
The graph snapshot provides:
|
|
224
224
|
|
|
225
|
-
- `
|
|
226
|
-
- `selected`: the invoked
|
|
227
|
-
- `
|
|
225
|
+
- `mapGraph`: `{ concepts, relations, relationTypes }` for the invoked map. Outside the graph, concepts carry the map's `position`, `color`, `bold`, `italic`, and `strikethrough`; relations may carry a map-local `bend`. `color` is a preset id such as `sand`, shown with `var(--preset-sand)`, or a fixed `#rrggbb` value.
|
|
226
|
+
- `selected`: the invoked map's selection.
|
|
227
|
+
- `targetMapId`: the invoked map's ID, or `null` for the graph; fixed for each invocation. Headless actions keep their target during navigation; panels restart with a new invocation when the active map changes.
|
|
228
228
|
- `activeVocab`: the current vocabulary, or `null`.
|
|
229
229
|
|
|
230
|
-
`
|
|
230
|
+
`mapGraph` contains stored relation-type labels. `resolveRelationTypeLabel(type, vocabs, locale)`, exported by `@nesso-how/plugin`, returns a translated display label from the supplied vocabularies, preserving custom labels.
|
|
231
231
|
|
|
232
232
|
Concept and relation-type IDs are absolute IRIs. Relations are `{ source, predicate, target }` triples; use `JSON.stringify([source, predicate, target])` as their selection/write ID.
|
|
233
233
|
|
|
@@ -254,17 +254,17 @@ Call helpers on `document` and declare their operation kinds in `nesso.writes`:
|
|
|
254
254
|
| `removeRelation(id)` | `relation.remove` |
|
|
255
255
|
| `setRelationBend(id, value)` | `relation.bend` |
|
|
256
256
|
| `setSelection([{ kind, id }])` | `selection.set` |
|
|
257
|
-
| `
|
|
257
|
+
| `setMapMembership(mapId, conceptId, included)` | `map.membership` |
|
|
258
258
|
|
|
259
|
-
Position, color, and style helpers edit the invoked
|
|
259
|
+
Position, color, and style helpers edit the invoked map; they reject the batch in the graph, after navigation, or for concepts outside the map. `addConcept` returns the new IRI. New concepts join the active map, at the given position or near the single selected concept, and link to that concept, if any. These links and `connect` use the vocabulary's default relation type. `createRelationType` creates and assigns a type to the given relation. The selection keeps only concepts and relations visible in the active map.
|
|
260
260
|
|
|
261
|
-
`setRelationBend` follows the same active-
|
|
261
|
+
`setRelationBend` follows the same active-map guard. Its finite value is the signed midpoint displacement as a fraction of the endpoint segment's length; `0` restores the automatic curve. Both endpoints must belong to the active map, and self-relations cannot be bent. Removing or reconnecting a relation clears its bends; changing only its predicate preserves them.
|
|
262
262
|
|
|
263
263
|
For related edits, use `document.applyOperations(operations)` as in the quickstart. The entire batch succeeds or changes nothing. Editing, reconnecting, retyping, or removing an unknown concept or relation rejects the batch, as does reconnecting or retyping onto an existing relation; removing an item already removed earlier in the same batch, such as a relation of a removed concept, is allowed. Separate calls are separate transactions. Raw `concept.add` operations require an explicit new absolute IRI.
|
|
264
264
|
|
|
265
265
|
Every write checks against the last snapshot you read, or the initial snapshot if you haven't read one. Successful writes advance that baseline, so awaited sequential writes work normally. Incoming updates alone do not advance it. A conflict rejects with `stale-state`; let the failure propagate so Nesso can ask the user to run the action again. Never retry mutations automatically or read a new snapshot just to submit edits calculated from old data.
|
|
266
266
|
|
|
267
|
-
The invoked
|
|
267
|
+
The invoked map is **not a write sandbox**: permitted writes can affect the whole document. Only the operations listed above are available to plugins.
|
|
268
268
|
|
|
269
269
|
### Files, images, notifications, and failures
|
|
270
270
|
|
|
@@ -273,12 +273,12 @@ The invoked view is **not a write sandbox**: permitted writes can affect the who
|
|
|
273
273
|
| `files.open({ extensions: ['json'], mimeTypes: ['application/json'] })` | `files` | `{ name, mediaType, text }`, or `null` on cancellation. Extensions omit the dot. |
|
|
274
274
|
| `files.save({ name: 'graph.json', mediaType: 'application/json', text })` | `files` | `{ saved: boolean }`; cancellation returns `false`. |
|
|
275
275
|
| `files.save({ name: 'graph.png', mediaType: 'image/png', base64 })` | `files` | `{ saved: boolean }`; the host decodes canonical base64 before saving. |
|
|
276
|
-
| `images.
|
|
276
|
+
| `images.renderCanvas({ format: 'png', scale: 2 })` | `images` | `{ mediaType: 'image/png', base64 }` for the invoked canvas. |
|
|
277
277
|
| `notifications.notify({ tone: 'info', title: { en: 'Done' }, description: { en: 'Labels updated' } })` | `notifications` | A notification ID. Tone is `info` or `warning`; description is optional. |
|
|
278
278
|
|
|
279
279
|
File saves accept exactly one of UTF-8 `text` or canonical `base64` (without a data URL prefix), with a 16 MiB decoded byte limit. File opening remains UTF-8 text only. Host-managed dialogs or browser downloads grant no unrestricted filesystem access. Plugins have no Node, host DOM, direct filesystem, clipboard, or network access.
|
|
280
280
|
|
|
281
|
-
`images.
|
|
281
|
+
`images.renderCanvas` captures the canvas the action was invoked from with the current theme and fonts, without selection or canvas controls: the map, or in the graph (`mapId` `null`) every concept as shown on the graph canvas. Scale defaults to `2`, or accepts `4`, and is a maximum: canvases too large for it render at the highest of `4`, `2`, or `1` within 8192 pixels per side and 16,777,216 pixels total. Empty canvases, canvases over that budget at scale `1`, and PNGs over 16 MiB fail. Save the result separately with `files.save({ name: 'map.png', ...image })`; this also requires `files`.
|
|
282
282
|
|
|
283
283
|
Failures throw `PluginError` with `code` and `{ path, message }[]` issues. Let them propagate instead of reporting success. Files and notifications cannot be rolled back with graph edits.
|
|
284
284
|
|
|
@@ -295,24 +295,24 @@ await storage.set(
|
|
|
295
295
|
{ kind: 'concept', id: concept.id },
|
|
296
296
|
)
|
|
297
297
|
await storage.set('settings', { enabled: true })
|
|
298
|
-
if (
|
|
299
|
-
await storage.set('notes', { text: 'Project ideas' }, { kind: '
|
|
298
|
+
if (mapId !== null)
|
|
299
|
+
await storage.set('notes', { text: 'Project ideas' }, { kind: 'map', id: mapId })
|
|
300
300
|
await storage.delete('progress', { kind: 'concept', id: concept.id })
|
|
301
301
|
```
|
|
302
302
|
|
|
303
|
-
`storage.list()` returns all records as an array, including records associated with deleted concepts or
|
|
303
|
+
`storage.list()` returns all records as an array, including records associated with deleted concepts or maps. Each record has a `key`, a JSON `value`, and an optional `scope`:
|
|
304
304
|
|
|
305
|
-
- Without `scope`, the record belongs to the document, for example plugin configuration or notes for
|
|
306
|
-
- With `{ kind: 'concept', id }`, it belongs to that concept. Its data is shared across all
|
|
307
|
-
- With `{ kind: '
|
|
308
|
-
- Scopes identify records within the same plugin/document namespace; they do not create separate namespaces or revision baselines. The same key can be used at document scope and for different concepts and
|
|
305
|
+
- Without `scope`, the record belongs to the document, for example plugin configuration or notes for the graph (`mapId === null`).
|
|
306
|
+
- With `{ kind: 'concept', id }`, it belongs to that concept. Its data is shared across all maps containing the concept.
|
|
307
|
+
- With `{ kind: 'map', id }`, it belongs to that map, independently of its name or membership. Use a non-null `mapId`.
|
|
308
|
+
- Scopes identify records within the same plugin/document namespace; they do not create separate namespaces or revision baselines. The same key can be used at document scope and for different concepts and maps, including a concept and map with the same ID.
|
|
309
309
|
- Your plugin owns the payload format and any migrations. Version it independently of the SDK and package version; Nesso does not interpret its fields.
|
|
310
310
|
|
|
311
311
|
The [downgrade and backup policy](../../docs/compatibility.md#downgrades-and-backups) also applies to private plugin data.
|
|
312
312
|
|
|
313
313
|
`storage.set(key, value, scope?)` saves one record and `storage.delete(key, scope?)` removes one. Each call is a single transaction returning `true` if data changed, or `false` if nothing changed, such as saving an identical value or deleting a missing record. Failed writes throw.
|
|
314
314
|
|
|
315
|
-
Setting a scoped record requires the concept or
|
|
315
|
+
Setting a scoped record requires the concept or map to exist. Concept IDs must be absolute IRIs; map IDs are opaque identifiers. Deleting a record also accepts references to deleted entities.
|
|
316
316
|
|
|
317
317
|
Each write checks the storage revision from your last `storage.list()` or successful write. If you have not listed storage, the SDK reads the initial revision for you. Concurrent changes reject the write with `stale-state`; the SDK does not retry or refresh the revision. List storage again and recompute your changes rather than resubmitting old data.
|
|
318
318
|
|
|
@@ -323,9 +323,9 @@ Await all storage calls before the action returns. Success means the change is i
|
|
|
323
323
|
#### Data lifecycle
|
|
324
324
|
|
|
325
325
|
- A document has a persistent identity outside graph JSON-LD. Resetting it creates a new identity and empty plugin storage; a mismatched saved identity is reported and protected, never silently attached to another document.
|
|
326
|
-
- Renaming a
|
|
327
|
-
- Deleting a concept or
|
|
328
|
-
- Use scopes for concept or
|
|
326
|
+
- Renaming a map or changing membership does not affect scoped records. Removing a map does not delete concept data.
|
|
327
|
+
- Deleting a concept or map retains its records, including across restart and backup restoration. Document Undo/Redo can recover the entity during the current app session, reconnecting its records by the same ID; private storage changes themselves do not enter graph history. Creating a different entity with the same name does not reconnect old records.
|
|
328
|
+
- Use scopes for concept or map data, including logs. Nesso does not interpret IDs embedded in keys or payloads and does not automatically delete orphaned records; your plugin must clean them up explicitly.
|
|
329
329
|
- Disabling, uninstalling, replacing, or crashing a plugin does not delete its stored data.
|
|
330
330
|
|
|
331
331
|
#### Limits
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { type ActionBadgeInput, type ActionBadgeResult, type ActionContext, type ActionContribution, type ActionDescriptor, type ActionIconName, type ActionState, type ColorScheme, type GraphSnapshot, type ImageRenderOptions, type LocalizedText, type NessoOperation, PluginError, type PluginI18n, type PluginManifest, type PluginStorage, type PluginStorageKey, type PluginStorageRecord, type PluginStorageScope, type RenderedImage, type
|
|
1
|
+
import { $ as WorkspaceMap, B as LocalizedText, C as PluginStorage, E as PluginStorageScope, H as ColorScheme, I as ImageRenderOptions, J as GraphSnapshot, L as RenderedImage, Q as VocabDefinition, R as PluginError, T as PluginStorageRecord, W as ThemeDefinition, X as NessoOperation, Y as MapGraphSnapshot, Z as Selection, a as ActionDescriptor, c as PluginI18n, i as ActionContribution, l as PluginManifest, n as ActionBadgeResult, o as ActionIconName, q as resolveRelationTypeLabel, r as ActionContext, s as ActionState, t as ActionBadgeInput, u as actionIconNames, w as PluginStorageKey } from "./runtime-C_IkTCNf.js";
|
|
2
|
+
export { type ActionBadgeInput, type ActionBadgeResult, type ActionContext, type ActionContribution, type ActionDescriptor, type ActionIconName, type ActionState, type ColorScheme, type GraphSnapshot, type ImageRenderOptions, type LocalizedText, type MapGraphSnapshot, type NessoOperation, PluginError, type PluginI18n, type PluginManifest, type PluginStorage, type PluginStorageKey, type PluginStorageRecord, type PluginStorageScope, type RenderedImage, type Selection, type ThemeDefinition, type VocabDefinition, type WorkspaceMap, actionIconNames, resolveRelationTypeLabel };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as PluginError, t as actionIconNames } from "./runtime-
|
|
1
|
+
import { C as PluginError, t as actionIconNames } from "./runtime-BGO97h75.js";
|
|
2
2
|
//#region ../core/dist/vocab.js
|
|
3
3
|
function resolveRelationTypeLabel(type, vocabs, locale) {
|
|
4
4
|
for (const vocab of vocabs) {
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { GraphSnapshot, NessoOperation,
|
|
1
|
+
export type { GraphSnapshot, NessoOperation, WorkspaceMap, Selection, MapGraphSnapshot, VocabDefinition, } from '@nesso-how/core';
|
|
2
2
|
export { resolveRelationTypeLabel } from '@nesso-how/core';
|
|
3
3
|
export type { ColorScheme, ThemeDefinition } from './definitions.ts';
|
|
4
4
|
export { PluginError } from './errors.ts';
|
package/dist/node/runtime.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { type ImageRenderOptions, type RenderedImage } from './images.ts';
|
|
3
3
|
export type { ImageRenderOptions, RenderedImage } from './images.ts';
|
|
4
4
|
import type { ComponentType } from 'react';
|
|
5
|
-
import type { DeepReadonly, NessoOperation, Selection,
|
|
5
|
+
import type { DeepReadonly, NessoOperation, Selection, WorkspaceMap, MapGraphSnapshot, VocabDefinition } from '@nesso-how/core';
|
|
6
6
|
import type { Locale } from '@nesso-how/i18n';
|
|
7
7
|
import { type ColorScheme, type Definition } from './definitions.ts';
|
|
8
8
|
import { type FileOpenOptions, type FileOpenResult, type FileSaveOptions } from './files.ts';
|
|
@@ -36,8 +36,8 @@ declare const actionBadgeResult: z.ZodObject<{
|
|
|
36
36
|
refreshAt: z.ZodOptional<z.ZodNumber>;
|
|
37
37
|
}, z.core.$strict>;
|
|
38
38
|
export type ActionBadgeInput = {
|
|
39
|
-
readonly
|
|
40
|
-
readonly
|
|
39
|
+
readonly mapId: string | null;
|
|
40
|
+
readonly mapGraph: MapGraphSnapshot;
|
|
41
41
|
readonly records: readonly PluginStorageRecord[];
|
|
42
42
|
readonly now: number;
|
|
43
43
|
};
|
|
@@ -66,9 +66,9 @@ export type PluginI18n = DeepReadonly<{
|
|
|
66
66
|
[key: string]: LocalizedText | z.infer<typeof metadata>;
|
|
67
67
|
}>;
|
|
68
68
|
export declare function parsePluginI18n(value: unknown): PluginI18n;
|
|
69
|
-
export declare const pluginApiVersion =
|
|
69
|
+
export declare const pluginApiVersion = 7;
|
|
70
70
|
declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
71
|
-
apiVersion: z.ZodLiteral<
|
|
71
|
+
apiVersion: z.ZodLiteral<7>;
|
|
72
72
|
kind: z.ZodLiteral<"actions">;
|
|
73
73
|
entry: z.ZodString;
|
|
74
74
|
writes: z.ZodArray<z.ZodEnum<{
|
|
@@ -82,6 +82,8 @@ declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
82
82
|
"concept.positions": "concept.positions";
|
|
83
83
|
"concept.remove": "concept.remove";
|
|
84
84
|
"concept.strikethrough": "concept.strikethrough";
|
|
85
|
+
"map.create": "map.create";
|
|
86
|
+
"map.membership": "map.membership";
|
|
85
87
|
"relation.bend": "relation.bend";
|
|
86
88
|
"relation.connect": "relation.connect";
|
|
87
89
|
"relation.reconnect": "relation.reconnect";
|
|
@@ -89,8 +91,6 @@ declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
89
91
|
"relation.type": "relation.type";
|
|
90
92
|
"relation.type.create": "relation.type.create";
|
|
91
93
|
"selection.set": "selection.set";
|
|
92
|
-
"view.create": "view.create";
|
|
93
|
-
"view.membership": "view.membership";
|
|
94
94
|
}>>;
|
|
95
95
|
capabilities: z.ZodArray<z.ZodEnum<{
|
|
96
96
|
files: "files";
|
|
@@ -100,7 +100,7 @@ declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
100
100
|
ui: "ui";
|
|
101
101
|
}>>;
|
|
102
102
|
}, z.core.$strict>, ...z.ZodObject<{
|
|
103
|
-
apiVersion: z.ZodLiteral<
|
|
103
|
+
apiVersion: z.ZodLiteral<7>;
|
|
104
104
|
kind: z.ZodLiteral<"theme" | "vocab">;
|
|
105
105
|
entry: z.ZodString;
|
|
106
106
|
writes: z.ZodTuple<[], null>;
|
|
@@ -210,28 +210,28 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
210
210
|
id: z.ZodString;
|
|
211
211
|
}, z.core.$strict>>;
|
|
212
212
|
}, z.core.$strict>, z.ZodObject<{
|
|
213
|
-
kind: z.ZodLiteral<"
|
|
213
|
+
kind: z.ZodLiteral<"map.activate">;
|
|
214
214
|
id: z.ZodNullable<z.ZodString>;
|
|
215
215
|
}, z.core.$strict>, z.ZodObject<{
|
|
216
|
-
kind: z.ZodLiteral<"
|
|
216
|
+
kind: z.ZodLiteral<"map.create">;
|
|
217
217
|
id: z.ZodString;
|
|
218
218
|
name: z.ZodString;
|
|
219
219
|
conceptIds: z.ZodArray<z.ZodString>;
|
|
220
220
|
}, z.core.$strict>, z.ZodObject<{
|
|
221
|
-
kind: z.ZodLiteral<"
|
|
221
|
+
kind: z.ZodLiteral<"map.rename">;
|
|
222
222
|
id: z.ZodString;
|
|
223
223
|
name: z.ZodString;
|
|
224
224
|
}, z.core.$strict>, z.ZodObject<{
|
|
225
|
-
kind: z.ZodLiteral<"
|
|
225
|
+
kind: z.ZodLiteral<"map.pin">;
|
|
226
226
|
id: z.ZodString;
|
|
227
227
|
pinned: z.ZodBoolean;
|
|
228
228
|
}, z.core.$strict>, z.ZodObject<{
|
|
229
|
-
kind: z.ZodLiteral<"
|
|
230
|
-
|
|
229
|
+
kind: z.ZodLiteral<"map.membership">;
|
|
230
|
+
mapId: z.ZodString;
|
|
231
231
|
conceptId: z.ZodString;
|
|
232
232
|
included: z.ZodBoolean;
|
|
233
233
|
}, z.core.$strict>, z.ZodObject<{
|
|
234
|
-
kind: z.ZodLiteral<"
|
|
234
|
+
kind: z.ZodLiteral<"map.remove">;
|
|
235
235
|
id: z.ZodString;
|
|
236
236
|
}, z.core.$strict>, ...z.ZodObject<{
|
|
237
237
|
kind: z.ZodLiteral<"preferences.theme" | "preferences.vocab">;
|
|
@@ -254,11 +254,11 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
254
254
|
id: z.ZodEnum<{
|
|
255
255
|
inspector: "inspector";
|
|
256
256
|
"inspector.connections": "inspector.connections";
|
|
257
|
+
"inspector.maps": "inspector.maps";
|
|
257
258
|
"inspector.nodes": "inspector.nodes";
|
|
258
|
-
"inspector.views": "inspector.views";
|
|
259
259
|
sidebar: "sidebar";
|
|
260
|
-
"sidebar.
|
|
261
|
-
"sidebar.
|
|
260
|
+
"sidebar.maps": "sidebar.maps";
|
|
261
|
+
"sidebar.pinned-maps": "sidebar.pinned-maps";
|
|
262
262
|
}>;
|
|
263
263
|
open: z.ZodBoolean;
|
|
264
264
|
}, z.core.$strict>], "kind">>;
|
|
@@ -290,7 +290,7 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
290
290
|
kind: z.ZodLiteral<"concept">;
|
|
291
291
|
id: z.ZodString;
|
|
292
292
|
}, z.core.$strict>, z.ZodObject<{
|
|
293
|
-
kind: z.ZodLiteral<"
|
|
293
|
+
kind: z.ZodLiteral<"map">;
|
|
294
294
|
id: z.ZodString;
|
|
295
295
|
}, z.core.$strict>], "kind">>;
|
|
296
296
|
value: z.ZodPipe<z.ZodCustom<string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | /*elided*/ any | {
|
|
@@ -403,7 +403,7 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
403
403
|
kind: z.ZodLiteral<"concept">;
|
|
404
404
|
id: z.ZodString;
|
|
405
405
|
}, z.core.$strict>, z.ZodObject<{
|
|
406
|
-
kind: z.ZodLiteral<"
|
|
406
|
+
kind: z.ZodLiteral<"map">;
|
|
407
407
|
id: z.ZodString;
|
|
408
408
|
}, z.core.$strict>], "kind">>;
|
|
409
409
|
revision: z.ZodNumber;
|
|
@@ -456,7 +456,7 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
456
456
|
type: z.ZodLiteral<"request">;
|
|
457
457
|
id: z.ZodNumber;
|
|
458
458
|
contextId: z.ZodString;
|
|
459
|
-
method: z.ZodLiteral<"images.
|
|
459
|
+
method: z.ZodLiteral<"images.renderCanvas">;
|
|
460
460
|
params: z.ZodObject<{
|
|
461
461
|
format: z.ZodLiteral<"png">;
|
|
462
462
|
scale: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<4>]>>;
|
|
@@ -542,13 +542,13 @@ export type ActionState = {
|
|
|
542
542
|
x: number;
|
|
543
543
|
y: number;
|
|
544
544
|
}>;
|
|
545
|
-
readonly
|
|
545
|
+
readonly mapGraph: MapGraphSnapshot;
|
|
546
546
|
readonly selected: Selection;
|
|
547
547
|
readonly workspace: {
|
|
548
|
-
readonly
|
|
549
|
-
readonly
|
|
548
|
+
readonly activeMapId: string | null;
|
|
549
|
+
readonly maps: readonly Pick<WorkspaceMap, 'id' | 'name' | 'pinned'>[];
|
|
550
550
|
};
|
|
551
|
-
readonly
|
|
551
|
+
readonly targetMapId: string | null;
|
|
552
552
|
readonly activeVocab: VocabDefinition | null;
|
|
553
553
|
readonly history: {
|
|
554
554
|
readonly canUndo: boolean;
|
|
@@ -558,9 +558,9 @@ export type ActionState = {
|
|
|
558
558
|
type WriteOptions = {
|
|
559
559
|
readonly historyGroup?: string;
|
|
560
560
|
};
|
|
561
|
-
type PluginWrites = Omit<ReturnType<typeof createWriteCommands<Promise<void>, Promise<string>>>, 'undo' | 'redo' | '
|
|
561
|
+
type PluginWrites = Omit<ReturnType<typeof createWriteCommands<Promise<void>, Promise<string>>>, 'undo' | 'redo' | 'setMap' | 'setActiveVocab' | 'setActiveTheme' | 'setLocale' | 'setPanelSizes' | 'setSectionOpen' | 'createMap' | 'renameMap' | 'setMapPinned' | 'deleteMap'>;
|
|
562
562
|
export type ActionContext = {
|
|
563
|
-
readonly
|
|
563
|
+
readonly mapId: string | null;
|
|
564
564
|
readonly document: PluginWrites & {
|
|
565
565
|
readonly getState: () => ActionState;
|
|
566
566
|
readonly subscribe: (listener: () => void) => () => void;
|
|
@@ -585,7 +585,7 @@ export type ActionContext = {
|
|
|
585
585
|
};
|
|
586
586
|
readonly storage: PluginStorage;
|
|
587
587
|
readonly images: {
|
|
588
|
-
readonly
|
|
588
|
+
readonly renderCanvas: (options: ImageRenderOptions) => Promise<RenderedImage>;
|
|
589
589
|
};
|
|
590
590
|
readonly signal: AbortSignal;
|
|
591
591
|
};
|
package/dist/node/runtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { imageRenderOptions, renderedImage, } from './images.js';
|
|
3
|
-
import { positionSchema,
|
|
3
|
+
import { positionSchema, mapGraphSchema } from '@nesso-how/schema';
|
|
4
4
|
import { parseOrThrow, PluginError, pluginErrorCodes } from './errors.js';
|
|
5
5
|
import { colorSchemes, parseDefinition, themeColors, vocabRelationType, } from './definitions.js';
|
|
6
6
|
import { fileOpenOptions, fileOpenResult, fileSaveOptions, } from './files.js';
|
|
@@ -77,17 +77,17 @@ const operation = z.discriminatedUnion('kind', [
|
|
|
77
77
|
z.strictObject({ kind: z.literal('history.undo') }),
|
|
78
78
|
z.strictObject({ kind: z.literal('history.redo') }),
|
|
79
79
|
z.strictObject({ kind: z.literal('selection.set'), value: selection }),
|
|
80
|
-
z.strictObject({ kind: z.literal('
|
|
81
|
-
z.strictObject({ kind: z.literal('
|
|
82
|
-
z.strictObject({ kind: z.literal('
|
|
83
|
-
z.strictObject({ kind: z.literal('
|
|
80
|
+
z.strictObject({ kind: z.literal('map.activate'), id: id.nullable() }),
|
|
81
|
+
z.strictObject({ kind: z.literal('map.create'), id, name: z.string(), conceptIds: z.array(id) }),
|
|
82
|
+
z.strictObject({ kind: z.literal('map.rename'), id, name: z.string() }),
|
|
83
|
+
z.strictObject({ kind: z.literal('map.pin'), id, pinned: z.boolean() }),
|
|
84
84
|
z.strictObject({
|
|
85
|
-
kind: z.literal('
|
|
86
|
-
|
|
85
|
+
kind: z.literal('map.membership'),
|
|
86
|
+
mapId: id,
|
|
87
87
|
conceptId: id,
|
|
88
88
|
included: z.boolean(),
|
|
89
89
|
}),
|
|
90
|
-
z.strictObject({ kind: z.literal('
|
|
90
|
+
z.strictObject({ kind: z.literal('map.remove'), id }),
|
|
91
91
|
...['vocab', 'theme'].map((kind) => z.strictObject({ kind: z.literal(`preferences.${kind}`), id })),
|
|
92
92
|
z.strictObject({ kind: z.literal('preferences.locale'), value: locale }),
|
|
93
93
|
z.strictObject({
|
|
@@ -98,11 +98,11 @@ const operation = z.discriminatedUnion('kind', [
|
|
|
98
98
|
kind: z.literal('preferences.section'),
|
|
99
99
|
id: z.enum([
|
|
100
100
|
'sidebar',
|
|
101
|
-
'sidebar.pinned-
|
|
102
|
-
'sidebar.
|
|
101
|
+
'sidebar.pinned-maps',
|
|
102
|
+
'sidebar.maps',
|
|
103
103
|
'inspector',
|
|
104
104
|
'inspector.connections',
|
|
105
|
-
'inspector.
|
|
105
|
+
'inspector.maps',
|
|
106
106
|
'inspector.nodes',
|
|
107
107
|
]),
|
|
108
108
|
open: z.boolean(),
|
|
@@ -119,7 +119,7 @@ export function parsePluginI18n(value) {
|
|
|
119
119
|
checkMessageSize(value, 64 * 1024);
|
|
120
120
|
return parseOrThrow(pluginI18n, value, 'i18n.');
|
|
121
121
|
}
|
|
122
|
-
export const pluginApiVersion =
|
|
122
|
+
export const pluginApiVersion = 7;
|
|
123
123
|
const manifestFields = {
|
|
124
124
|
apiVersion: z.literal(pluginApiVersion),
|
|
125
125
|
};
|
|
@@ -149,8 +149,8 @@ const pluginWriteKinds = [
|
|
|
149
149
|
'relation.remove',
|
|
150
150
|
'relation.bend',
|
|
151
151
|
'selection.set',
|
|
152
|
-
'
|
|
153
|
-
'
|
|
152
|
+
'map.create',
|
|
153
|
+
'map.membership',
|
|
154
154
|
];
|
|
155
155
|
const operationDeclarations = z.array(z.enum(pluginWriteKinds));
|
|
156
156
|
const manifest = z
|
|
@@ -216,7 +216,7 @@ const request = z.discriminatedUnion('method', [
|
|
|
216
216
|
z.strictObject({ ...envelope, method: z.literal('files.save'), params: fileSaveOptions }),
|
|
217
217
|
z.strictObject({
|
|
218
218
|
...envelope,
|
|
219
|
-
method: z.literal('images.
|
|
219
|
+
method: z.literal('images.renderCanvas'),
|
|
220
220
|
params: imageRenderOptions,
|
|
221
221
|
}),
|
|
222
222
|
]);
|
|
@@ -301,16 +301,16 @@ const actionStateSchema = z.strictObject({
|
|
|
301
301
|
]))),
|
|
302
302
|
colorScheme: z.enum(colorSchemes),
|
|
303
303
|
conceptPlacementOffset: position,
|
|
304
|
-
|
|
304
|
+
mapGraph: mapGraphSchema,
|
|
305
305
|
selected: selection,
|
|
306
|
-
|
|
306
|
+
targetMapId: id.nullable(),
|
|
307
307
|
activeVocab: z
|
|
308
308
|
.strictObject({ id, relationTypes: z.array(vocabRelationType), defaultTypeId: id })
|
|
309
309
|
.nullable(),
|
|
310
310
|
history: z.strictObject({ canUndo: z.boolean(), canRedo: z.boolean() }),
|
|
311
311
|
workspace: z.strictObject({
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
activeMapId: id.nullable(),
|
|
313
|
+
maps: z.array(z.strictObject({ id, name: z.string(), pinned: z.boolean() })),
|
|
314
314
|
}),
|
|
315
315
|
});
|
|
316
316
|
const reply = z.union([
|
|
@@ -342,7 +342,7 @@ const results = {
|
|
|
342
342
|
'notifications.notify': id,
|
|
343
343
|
'files.open': fileOpenResult,
|
|
344
344
|
'files.save': z.strictObject({ saved: z.boolean() }),
|
|
345
|
-
'images.
|
|
345
|
+
'images.renderCanvas': renderedImage,
|
|
346
346
|
};
|
|
347
347
|
export function parsePluginMessage(value) {
|
|
348
348
|
checkMessageSize(value, runtimeLimits.request);
|
|
@@ -457,7 +457,7 @@ export function createPluginClient(port, initial) {
|
|
|
457
457
|
readRevision = Math.max(readRevision, result.revision);
|
|
458
458
|
return result;
|
|
459
459
|
};
|
|
460
|
-
const { undo: _undo, redo: _redo,
|
|
460
|
+
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) => {
|
|
461
461
|
await applyOperations(operations, options);
|
|
462
462
|
}, async (id, committed) => {
|
|
463
463
|
await committed;
|
|
@@ -479,7 +479,7 @@ export function createPluginClient(port, initial) {
|
|
|
479
479
|
return result.changed;
|
|
480
480
|
};
|
|
481
481
|
const context = {
|
|
482
|
-
|
|
482
|
+
mapId: state.targetMapId,
|
|
483
483
|
document: {
|
|
484
484
|
...writes,
|
|
485
485
|
getState,
|
|
@@ -494,7 +494,7 @@ export function createPluginClient(port, initial) {
|
|
|
494
494
|
applyOperations,
|
|
495
495
|
},
|
|
496
496
|
notifications: { notify: (value) => call('notifications.notify', value) },
|
|
497
|
-
images: {
|
|
497
|
+
images: { renderCanvas: (options) => call('images.renderCanvas', options) },
|
|
498
498
|
files: {
|
|
499
499
|
open: (options) => call('files.open', options),
|
|
500
500
|
save: (options) => call('files.save', options),
|
package/dist/node/storage.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ declare const pluginStorageScope: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
15
15
|
kind: z.ZodLiteral<"concept">;
|
|
16
16
|
id: z.ZodString;
|
|
17
17
|
}, z.core.$strict>, z.ZodObject<{
|
|
18
|
-
kind: z.ZodLiteral<"
|
|
18
|
+
kind: z.ZodLiteral<"map">;
|
|
19
19
|
id: z.ZodString;
|
|
20
20
|
}, z.core.$strict>], "kind">;
|
|
21
21
|
export declare const pluginStorageKey: z.ZodObject<{
|
|
@@ -24,7 +24,7 @@ export declare const pluginStorageKey: z.ZodObject<{
|
|
|
24
24
|
kind: z.ZodLiteral<"concept">;
|
|
25
25
|
id: z.ZodString;
|
|
26
26
|
}, z.core.$strict>, z.ZodObject<{
|
|
27
|
-
kind: z.ZodLiteral<"
|
|
27
|
+
kind: z.ZodLiteral<"map">;
|
|
28
28
|
id: z.ZodString;
|
|
29
29
|
}, z.core.$strict>], "kind">>;
|
|
30
30
|
}, z.core.$strict>;
|
|
@@ -34,7 +34,7 @@ export declare const pluginStorageRecord: z.ZodObject<{
|
|
|
34
34
|
kind: z.ZodLiteral<"concept">;
|
|
35
35
|
id: z.ZodString;
|
|
36
36
|
}, z.core.$strict>, z.ZodObject<{
|
|
37
|
-
kind: z.ZodLiteral<"
|
|
37
|
+
kind: z.ZodLiteral<"map">;
|
|
38
38
|
id: z.ZodString;
|
|
39
39
|
}, z.core.$strict>], "kind">>;
|
|
40
40
|
value: z.ZodPipe<z.ZodCustom<JsonValue, JsonValue>, z.ZodTransform<string | number | boolean | readonly JsonValue[] | {
|
|
@@ -50,7 +50,7 @@ export declare const pluginStorageSnapshot: z.ZodObject<{
|
|
|
50
50
|
kind: z.ZodLiteral<"concept">;
|
|
51
51
|
id: z.ZodString;
|
|
52
52
|
}, z.core.$strict>, z.ZodObject<{
|
|
53
|
-
kind: z.ZodLiteral<"
|
|
53
|
+
kind: z.ZodLiteral<"map">;
|
|
54
54
|
id: z.ZodString;
|
|
55
55
|
}, z.core.$strict>], "kind">>;
|
|
56
56
|
value: z.ZodPipe<z.ZodCustom<JsonValue, JsonValue>, z.ZodTransform<string | number | boolean | readonly JsonValue[] | {
|
package/dist/node/storage.js
CHANGED
|
@@ -27,7 +27,7 @@ const isJsonValue = (value, depth = 0) => {
|
|
|
27
27
|
};
|
|
28
28
|
const pluginStorageScope = z.discriminatedUnion('kind', [
|
|
29
29
|
z.strictObject({ kind: z.literal('concept'), id: z.string().max(2048) }),
|
|
30
|
-
z.strictObject({ kind: z.literal('
|
|
30
|
+
z.strictObject({ kind: z.literal('map'), id: z.string().max(2048) }),
|
|
31
31
|
]);
|
|
32
32
|
const fields = {
|
|
33
33
|
key: z.string().min(1).max(128),
|
package/dist/package.d.ts
CHANGED
package/dist/package.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as PluginError, _ as checkMessageSize, d as sha256Hex, o as parsePluginI18n, s as parsePluginManifest, w as parseOrThrow, y as parseDefinition } from "./runtime-
|
|
1
|
+
import { C as PluginError, _ as checkMessageSize, d as sha256Hex, o as parsePluginI18n, s as parsePluginManifest, w as parseOrThrow, y as parseDefinition } from "./runtime-BGO97h75.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import parseVersion from "semver/functions/parse.js";
|
|
4
4
|
import validateName from "validate-npm-package-name";
|