@nesso-how/plugin 0.7.0 → 0.8.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 CHANGED
@@ -4,21 +4,34 @@ Build Nesso plugins with TypeScript: **actions** read and edit graphs, **vocabul
4
4
 
5
5
  ## Install
6
6
 
7
- With Node.js and npm installed, add the SDK to your TypeScript project:
7
+ Use Node.js 24. To add the SDK to an existing TypeScript project:
8
8
 
9
9
  ```sh
10
10
  npm install --save-dev @nesso-how/plugin
11
11
  ```
12
12
 
13
- This installs the development SDK, not a plugin in Nesso. If you are starting a new plugin, use the example below for TypeScript and bundler configuration, including React UI support. To install and try your built plugin in the desktop app, follow the [local testing instructions](example/README.md#test-an-unpublished-build).
13
+ For a new project, start with the [standalone example](example/), which includes TypeScript, Vite, and React configuration. Plugins can be installed locally through MCP without publishing to npm.
14
14
 
15
15
  ## Create a plugin
16
16
 
17
- Copy the [standalone action example](example/) into a separate project. It includes the SDK, TypeScript configuration, and bundler setup:
17
+ ### With an agent
18
+
19
+ Use an agent such as Claude Code or Codex that can create files and run commands on your computer. Nesso's internal chat cannot build or install plugins.
20
+
21
+ 1. In the desktop app, open Settings → AI → MCP and start the server. If `plugins` and `propose_plugin` are not available, update Nesso.
22
+ 2. In your agent's MCP configuration, connect to the URL shown in Nesso using Streamable HTTP and an `Authorization: Bearer <token>` header. Copy the token from Settings into the client's configuration, not into a chat message, source file, or repository. Keep Nesso open.
23
+ 3. Describe the plugin you want, or use this prompt:
24
+
25
+ > Build a Nesso plugin that [describe the behavior]. Call `read_docs` for `plugin` and `plugin-example` through Nesso MCP and follow the documented workflow, then propose a local installation for my approval in Nesso.
26
+
27
+ The agent should work in a separate project, choose a unique package name, and request only the permissions the plugin needs. For a panel, also read `read_docs` with `{"topic":"ui"}`. Follow [Build and test](#build-and-test), then [Install or update through MCP](#install-or-update-through-mcp). Nesso reads the finished package; it never installs dependencies or runs build scripts.
28
+
29
+ ### By hand
30
+
31
+ Copy the [standalone example](example/) into a separate project and install its dependencies:
18
32
 
19
33
  ```sh
20
34
  npm install
21
- npm run build
22
35
  ```
23
36
 
24
37
  Choose your own package name and action ID, then edit `src/index.ts`:
@@ -49,13 +62,7 @@ export const create = (): readonly ActionContribution[] => {
49
62
  }
50
63
  ```
51
64
 
52
- This changes labels in the invoked view in one undoable batch. Shared concepts change in every view containing them.
53
-
54
- How the example works:
55
-
56
- - `create()` defines the actions. Nesso supplies the execution context to `run`, where graph data is always available.
57
- - `applyOperations` takes an array of edits. Here, `.map()` creates one `concept.label` edit per concept, with its ID and new label.
58
- - Writes automatically check that the snapshot you read is still current. If it changed, the entire batch is rejected rather than overwriting newer edits.
65
+ `create()` defines the action; Nesso calls `run` when the user invokes it. This action uppercases every concept label in that view with one undoable batch. Shared concepts change in every view containing them.
59
66
 
60
67
  ### Package metadata and permissions
61
68
 
@@ -67,7 +74,7 @@ Keep the example's build configuration and set these fields in `package.json`:
67
74
  "version": "1.0.0",
68
75
  "keywords": ["nesso-plugin"],
69
76
  "nesso": {
70
- "apiVersion": 2,
77
+ "apiVersion": 3,
71
78
  "kind": "actions",
72
79
  "entry": "dist/index.js",
73
80
  "writes": ["concept.label"],
@@ -83,21 +90,65 @@ Keep the example's build configuration and set these fields in `package.json`:
83
90
  }
84
91
  ```
85
92
 
86
- Declare the operations your action uses in `writes`. The optional permissions listed in `capabilities` are `files`, `notifications`, `storage`, and `ui`. The first three authorize their APIs; `ui` authorizes interactive UI contributions. All fields shown under `nesso` and `i18n.metadata` are required. Add the `nesso-plugin` keyword for discovery in Settings → Plugins.
93
+ Declare the operations your action uses in `writes`. Available capabilities are `files`, `images`, `notifications`, `storage`, and `ui`: the first four grant access to their APIs; `ui` allows interactive panels. Declare only what you use. All fields shown under `nesso` and `i18n.metadata` are required. The `nesso-plugin` keyword makes published packages discoverable in Settings → Plugins.
87
94
 
88
- API version, npm SDK version, host storage envelope version, and private payload versions remain independent: bump only what your change affects.
95
+ `nesso.apiVersion` identifies the plugin API, not the SDK version or your package's version.
89
96
 
90
97
  `i18n.metadata.name` names the plugin in Settings. Each action defines its own `label` for menus, independently of the plugin name. Labels and metadata use `{ en: string, it?: string, 'zh-CN'?: string }`, with English required as the fallback.
91
98
 
92
99
  ### Build and test
93
100
 
94
- Run `npm run build`, then follow the example's [local testing instructions](example/README.md#test-an-unpublished-build).
101
+ Run `npm run build` to typecheck and build the example. Use `npm run check` to typecheck without building.
102
+
103
+ Test calculations, graph edit generation, and storage transformations separately from React and host APIs. Node.js 24 can run pure TypeScript tests with `node --test "src/**/*.test.ts"`, using `node:test` and `node:assert/strict`. These tests need `.ts` imports and cannot load JSX or DOM-dependent modules. Add `@types/node` and `node` to your test TypeScript configuration's `types` if needed.
104
+
105
+ An action package ships one browser ES module. Bundle its dependencies except `react`, `react/*`, `react-dom`, and `react-dom/*`; Nesso supplies React 19 in the sandbox. The example's Vite configuration handles this.
106
+
107
+ Before installing, validate the built package with `preparePluginPackage`. Save this as `validate.ts` in the project root and run `node validate.ts` after building:
108
+
109
+ ```ts
110
+ import { readFile } from 'node:fs/promises'
111
+ import { preparePluginPackage } from '@nesso-how/plugin/package'
112
+ import { parsePluginManifest } from '@nesso-how/plugin/runtime'
113
+
114
+ const manifest = JSON.parse(await readFile('package.json', 'utf8'))
115
+ const nesso = parsePluginManifest(manifest.nesso)
116
+ const entry = new Uint8Array(await readFile(nesso.entry))
117
+ const files = [{ path: nesso.entry, bytes: entry }]
118
+
119
+ const prepared = await preparePluginPackage({ manifest, files })
120
+ console.log(prepared.name, prepared.version, prepared.contentId)
121
+ ```
122
+
123
+ This checks metadata, permission declarations, file sizes, UTF-8, and theme/vocabulary definitions without running action code. Validation failures throw `PluginError` with details in `issues`. It does not call `create()` or test behavior; those still need testing in Nesso.
124
+
125
+ ### Install or update through MCP
126
+
127
+ Connect to the [desktop MCP server](#with-an-agent) and call `plugins` to check installed names and local builds. Then call `propose_plugin` with the absolute package root, containing `package.json` and the built entry:
128
+
129
+ ```json
130
+ { "directory": "/absolute/path/to/nesso-plugin-my-action" }
131
+ ```
132
+
133
+ Pass the package root, not `dist`, an archive, or inline JavaScript. Nesso reads only `package.json` and the `nesso.entry` file. Relative paths, files outside the directory (including through symlinks), and oversized files are rejected.
134
+
135
+ Tell the user to switch to Nesso before proposing. Every install or replacement needs approval within the **120-second** request timeout, which includes processing time. The result is one of:
95
136
 
96
- Actions ship one browser ES module with dependencies bundled except React and React DOM, which Nesso supplies inside the sandbox. Keep `react`, `react/*`, `react-dom`, and `react-dom/*` external in your bundler; the example's build handles this. The runtime supports React 19. Test and install external plugins in the desktop app.
137
+ - `installed`: includes `name`, `version`, and `contentId`.
138
+ - `cancelled`: the proposal was not approved. Do not automatically propose again.
139
+ - `failed`: includes `{ path, message }[]` issues to fix before a new proposal.
140
+
141
+ If the client times out or disconnects, call `plugins` to check whether installation completed. Do not retry automatically or report success without confirmation.
142
+
143
+ Local plugins stay installed across restarts and appear in Settings → Plugins with a **Local** badge. They are not verified by npm or checked for npm updates. Rebuilding your project does not update the installed copy.
144
+
145
+ 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.
146
+
147
+ Try the installed action from a view'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.
97
148
 
98
149
  ## Action API
99
150
 
100
- Nesso passes `{ document, storage, files, notifications, signal, viewId }` to `run` as `ActionContext`. `document` exposes the shared graph, view membership, and transient selection; `storage` holds the plugin's private data for that document.
151
+ Nesso passes `{ document, storage, files, images, notifications, signal, viewId }` to `run` as `ActionContext`. `document` exposes the shared graph, view membership, and transient selection; `storage` holds the plugin's private data for that document.
101
152
 
102
153
  `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.
103
154
 
@@ -137,7 +188,9 @@ Nesso supplies React, the `@nesso-how/ui` component stylesheet, and theme CSS va
137
188
 
138
189
  #### Lifecycle
139
190
 
140
- Use React effects to clean up subscriptions and resources. Panels have no action execution timeout, but initialization and API requests have deadlines. Uncaught errors or rejected promises fail the session; handle expected errors in your UI. Nesso provides the title, close control, and loading/failure screens. Changing the active view revokes the current channel and context and mounts a fresh React instance for the selected view, including All, while reusing the sandbox and loaded modules. Closing or replacing a panel discards its React state: save progress through `storage` during use, not during cleanup, which is best effort.
191
+ Nesso provides the panel title, close control, and loading/error screens. Opening a panel or changing the active view 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.
192
+
193
+ Keep mutable state inside the component and clean up subscriptions in React effects. 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.
141
194
 
142
195
  ### Action badges
143
196
 
@@ -219,7 +272,7 @@ Failures throw `PluginError` with `code` and `{ path, message }[]` issues. Let t
219
272
 
220
273
  ### Private persistent storage
221
274
 
222
- Declare `storage` to read, write, or delete your plugin's private data. Nesso derives the namespace from the authorized npm package name and current document, never from plugin-provided identity fields. Different versions and action instances of the same package share data; different packages and documents do not.
275
+ Declare `storage` to read, write, or delete private data. Storage is separate for each package name, installation source (local or npm), and document. Versions and action instances of the same package share data; a local install and an npm install never do, even with the same name. Plugins cannot choose another package's namespace.
223
276
 
224
277
  ```ts
225
278
  const records = await storage.list()
@@ -241,20 +294,24 @@ await storage.delete('progress', { kind: 'concept', id: concept.id })
241
294
  - With `{ kind: 'concept', id }`, it belongs to that concept. Its data is shared across all views containing the concept.
242
295
  - With `{ kind: 'view', id }`, it belongs to that saved view, independently of its name or membership. Use a non-null `viewId`.
243
296
  - 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 views, including a concept and view with the same ID.
244
- - Payloads belong to the plugin: the host does not interpret their fields or implement domain logic.
297
+ - Your plugin owns the payload format and any migrations. Version it independently of the SDK and package version; Nesso does not interpret its fields.
298
+
299
+ `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.
245
300
 
246
- `storage.set(key, value, scope?)` saves one record and `storage.delete(key, scope?)` removes one. Set requires the referenced concept or saved view to exist. Concept IDs must be absolute IRIs; view IDs are opaque identifiers. Delete also accepts references to deleted entities so plugins can explicitly remove orphan records. Each call is a single transaction returning `true` when storage changed and `false` for valid net-no-op writes, such as saving an identical value or deleting a missing record. Failed writes throw instead of returning `false`.
301
+ Setting a scoped record requires the concept or saved view to exist. Concept IDs must be absolute IRIs; view IDs are opaque identifiers. Deleting a record also accepts references to deleted entities.
247
302
 
248
- The SDK tracks storage revisions internally. Every mutation checks against the last listed snapshot or the preceding successful mutation. If you haven't listed storage, the first mutation reads its baseline automatically. Concurrent changes reject stale writes with `stale-state`, without refreshing the baseline or retrying automatically. List storage again before recomputing edits; never refresh just to resubmit edits calculated from old data. Document reads do not refresh the storage baseline, and storage writes do not invalidate the document snapshot. Document edits and private storage calls are separate transactions.
303
+ 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.
249
304
 
250
- Await all storage calls before the action returns. Success means the validated change was committed in memory, not that a disk write has finished. Nesso autosaves through its shared persistence API, reports failures in its persistence banner, and waits for saving before desktop close, update installation, and data-folder transfers. Unreadable records are protected until explicit recovery; in-memory editing can continue but may remain unsaved.
305
+ Document and storage revisions are independent: reading one does not refresh the other. Graph edits and storage calls are separate transactions.
306
+
307
+ Await all storage calls before the action returns. Success means the change is in memory, not necessarily on disk. Nesso autosaves, reports save failures in its persistence banner, and waits for saving before closing the desktop app. Unreadable records require user recovery and are not overwritten automatically.
251
308
 
252
309
  #### Data lifecycle
253
310
 
254
311
  - 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.
255
312
  - Renaming a view or changing membership does not affect scoped records. Removing a view does not delete concept data.
256
313
  - Deleting a concept or saved view 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.
257
- - Use explicit scopes to identify concept or view data, including logs. Plugins own payload schemas and any explicit cleanup; the host does not automatically purge orphan records. IDs embedded in arbitrary keys or payloads remain opaque to the host.
314
+ - Use scopes for concept or view 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.
258
315
  - Disabling, uninstalling, replacing, or crashing a plugin does not delete its stored data.
259
316
 
260
317
  #### Limits
@@ -271,7 +328,7 @@ Storage accepts finite JSON primitives, dense arrays, and plain objects, includi
271
328
  | Record nesting | 24 levels |
272
329
  | Record key | 1–128 characters |
273
330
 
274
- Concept IDs must be absolute IRIs and refer to an existing document concept when writing. Deletes may remove retained orphan records. Keys are logical identifiers, not paths. Normal action channel request, deadline, rate, and cancellation limits also apply.
331
+ Keys are logical identifiers, not file paths. Action channel size, deadline, rate, and cancellation limits also apply.
275
332
 
276
333
  ## Vocabularies
277
334
 
@@ -302,10 +359,11 @@ Set `nesso.kind` to `"theme"`, point `entry` to your JSON definition, and use em
302
359
  - `id`: a lowercase kebab-case contribution ID.
303
360
  - `colors`: every required token, using `#RRGGBB` or `#RRGGBBAA`. Start with [Paper's palette](../../plugins/paper-theme/src/index.ts) or [Kernel's](../../plugins/kernel-theme/src/index.ts).
304
361
  - `metrics`: `radius-control` and `radius-object` in pixels, and `duration-state` in milliseconds.
305
- - `fonts`: `sans` and `mono`, each with a `faces` array. Use `[]` for system fallbacks, or include local WOFF2 files with package-relative `path`, `weight: [min, max]`, and `style: "normal"` or `"italic"`.
306
362
 
307
- Only light themes are supported. Use readable text contrast; arbitrary CSS and remote fonts are unsupported.
363
+ Only light themes are supported. Use readable text contrast; arbitrary CSS and plugin fonts are unsupported. Theme packages ship only their JSON entry. Nesso owns `--font-sans` (Geist) and `--font-mono` (IBM Plex Mono), with system fallbacks for other scripts. Switching themes does not change typography.
364
+
365
+ ## API reference
308
366
 
309
- The SDK exposes shared graph and operation types from the internal [`@nesso-how/core`](../core/) package. Trusted renderers use its synchronous store contract; plugins use only the permission-limited asynchronous `ActionContext` above. The published SDK bundles these shared contracts and helpers, so plugin projects need no separate core dependency.
367
+ Import graph and operation types from `@nesso-how/plugin`; no separate `@nesso-how/core` dependency is needed.
310
368
 
311
369
  For the full API and validation rules, see [action types](src/runtime.ts), [graph operations](../core/src/types.ts), and [theme/vocabulary schemas](src/definitions.ts).
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { B as LocalizedText, C as PluginStorage, E as PluginStorageScope, I as ImageRenderOptions, J as SavedView, K as GraphSnapshot, L as RenderedImage, R as PluginError, T as PluginStorageRecord, U as ThemeDefinition, X as VocabDefinition, Y as Selection, a as ActionDescriptor, c as PluginI18n, i as ActionContribution, l as PluginManifest, n as ActionBadgeResult, o as ActionIconName, q as NessoOperation, r as ActionContext, s as ActionState, t as ActionBadgeInput, u as actionIconNames, w as PluginStorageKey } from "./runtime-DGDBGkWs.js";
1
+ import { C as PluginStorageKey, F as ImageRenderOptions, G as GraphSnapshot, H as ThemeDefinition, I as RenderedImage, J as Selection, K as NessoOperation, L as PluginError, S as PluginStorage, T as PluginStorageScope, Y as VocabDefinition, a as ActionDescriptor, c as PluginI18n, i as ActionContribution, l as PluginManifest, n as ActionBadgeResult, o as ActionIconName, q as SavedView, r as ActionContext, s as ActionState, t as ActionBadgeInput, u as actionIconNames, w as PluginStorageRecord, z as LocalizedText } from "./runtime-DCyJA620.js";
2
2
  export { type ActionBadgeInput, type ActionBadgeResult, type ActionContext, type ActionContribution, type ActionDescriptor, type ActionIconName, type ActionState, type GraphSnapshot, type ImageRenderOptions, type LocalizedText, type NessoOperation, PluginError, type PluginI18n, type PluginManifest, type PluginStorage, type PluginStorageKey, type PluginStorageRecord, type PluginStorageScope, type RenderedImage, type SavedView, type Selection, type ThemeDefinition, type VocabDefinition, actionIconNames };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { C as PluginError, t as actionIconNames } from "./runtime-D6GosMdU.js";
1
+ export { S as PluginError, t as actionIconNames } from "./runtime-uvKgm2yV.js";
@@ -27,30 +27,6 @@ declare const themeDefinition: z.ZodObject<{
27
27
  'radius-object': z.ZodNumber;
28
28
  'duration-state': z.ZodNumber;
29
29
  }, z.core.$strict>;
30
- fonts: z.ZodObject<{
31
- sans: z.ZodObject<{
32
- faces: z.ZodArray<z.ZodObject<{
33
- path: z.ZodString;
34
- weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
35
- style: z.ZodEnum<{
36
- italic: "italic";
37
- normal: "normal";
38
- }>;
39
- unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
40
- }, z.core.$strict>>;
41
- }, z.core.$strict>;
42
- mono: z.ZodObject<{
43
- faces: z.ZodArray<z.ZodObject<{
44
- path: z.ZodString;
45
- weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
46
- style: z.ZodEnum<{
47
- italic: "italic";
48
- normal: "normal";
49
- }>;
50
- unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
51
- }, z.core.$strict>>;
52
- }, z.core.$strict>;
53
- }, z.core.$strict>;
54
30
  }, z.core.$strict>;
55
31
  export declare const vocabRelationType: z.ZodObject<{
56
32
  id: z.ZodString;
@@ -25,24 +25,6 @@ const contributionId = z
25
25
  .max(64)
26
26
  .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
27
27
  const color = z.string().regex(/^#[\da-fA-F]{6}([\da-fA-F]{2})?$/);
28
- const fontFace = z.strictObject({
29
- path: z
30
- .string()
31
- .max(240)
32
- .regex(/^(?:[\w-]+\/)*[\w-]+\.woff2$/),
33
- weight: z
34
- .tuple([z.number().int().min(1).max(1000), z.number().int().min(1).max(1000)])
35
- .refine(([min, max]) => min <= max),
36
- style: z.enum(['normal', 'italic']),
37
- unicodeRange: z
38
- .array(z
39
- .tuple([z.number().int().min(0).max(0x10ffff), z.number().int().min(0).max(0x10ffff)])
40
- .refine(([min, max]) => min <= max))
41
- .min(1)
42
- .max(64)
43
- .optional(),
44
- });
45
- const font = z.strictObject({ faces: z.array(fontFace).max(32) });
46
28
  const luminance = (value) => {
47
29
  const channels = [1, 3, 5].map((offset) => parseInt(value.slice(offset, offset + 2), 16) / 255);
48
30
  const linear = channels.map((value) => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4);
@@ -60,9 +42,8 @@ const themeDefinition = z
60
42
  'radius-object': z.number().min(0).max(16),
61
43
  'duration-state': z.number().int().min(0).max(300),
62
44
  }),
63
- fonts: z.strictObject({ sans: font, mono: font }),
64
45
  })
65
- .superRefine(({ colors, fonts }, context) => {
46
+ .superRefine(({ colors }, context) => {
66
47
  for (const key of ['background', 'canvas', 'sidebar']) {
67
48
  if (!opaque(colors[key]) || luminance(colors[key]) < 0.8)
68
49
  context.addIssue({
@@ -85,8 +66,6 @@ const themeDefinition = z
85
66
  path: ['colors', 'primary-foreground'],
86
67
  message: 'Insufficient primary contrast',
87
68
  });
88
- if (fonts.sans.faces.length + fonts.mono.faces.length > 32)
89
- context.addIssue({ code: 'custom', path: ['fonts'], message: 'Font face limit exceeded' });
90
69
  });
91
70
  export const vocabRelationType = z.strictObject({
92
71
  id: z.string().min(1).max(2048),
@@ -1,8 +1,6 @@
1
1
  import { type PluginI18n, type PluginManifest } from './runtime.ts';
2
2
  export declare const packageLimits: {
3
3
  readonly entry: number;
4
- readonly font: number;
5
- readonly fonts: 32;
6
4
  readonly record: number;
7
5
  readonly installed: 32;
8
6
  readonly total: number;
@@ -22,13 +20,8 @@ export type PreparedPlugin = {
22
20
  readonly nesso: PluginManifest;
23
21
  readonly i18n: PluginI18n;
24
22
  readonly code: string;
25
- readonly fonts: readonly {
26
- readonly path: string;
27
- readonly data: string;
28
- }[];
29
23
  readonly contentId: string;
30
24
  };
31
25
  export declare function parsePackageIdentity(value: unknown): any;
32
26
  export declare function preparePluginPackage(input: PluginPackageInput): Promise<PreparedPlugin>;
33
- export declare function packageFonts(value: PreparedPlugin): ReadonlyMap<string, Uint8Array>;
34
27
  export declare function verifyPluginPackage(value: PreparedPlugin): Promise<PreparedPlugin>;
@@ -4,8 +4,6 @@ import validateName from 'validate-npm-package-name';
4
4
  import { checkMessageSize, parseDefinition, parsePluginI18n, parsePluginManifest, parseOrThrow, PluginError, sha256Hex, } from './runtime.js';
5
5
  export const packageLimits = {
6
6
  entry: 16 * 1024 * 1024,
7
- font: 4 * 1024 * 1024,
8
- fonts: 32,
9
7
  record: 32 * 1024 * 1024,
10
8
  installed: 32,
11
9
  total: 128 * 1024 * 1024,
@@ -81,56 +79,21 @@ export async function preparePluginPackage(input) {
81
79
  const { name, version, author, repository, nesso: declaration, i18n: translations, } = parsePackageIdentity(input.manifest);
82
80
  const nesso = parsePluginManifest(declaration);
83
81
  const i18n = parsePluginI18n(translations);
84
- if (!Array.isArray(input.files) ||
85
- !input.files.length ||
86
- input.files.length > (nesso.kind === 'theme' ? packageLimits.fonts + 1 : 1))
82
+ if (!Array.isArray(input.files) || input.files.length !== 1)
87
83
  throw new PluginError('invalid-input', [
88
- { path: 'files', message: 'Expected one entry and supported local theme fonts only' },
84
+ { path: 'files', message: 'Expected one plugin entry only' },
89
85
  ]);
90
- const paths = new Set();
91
- const fonts = [];
92
- const files = [];
93
- let bytes;
94
- let admitted = 0;
95
- for (const file of input.files) {
96
- if (!file ||
97
- typeof file.path !== 'string' ||
98
- file.path.length > 240 ||
99
- paths.has(file.path) ||
100
- !(file.bytes instanceof Uint8Array) ||
101
- !file.bytes.byteLength ||
102
- file.bytes.byteLength > (file.path === nesso.entry ? packageLimits.entry : packageLimits.font))
103
- throw new PluginError('invalid-input', [
104
- { path: 'files', message: 'Invalid, duplicate, or oversized package file' },
105
- ]);
106
- paths.add(file.path);
107
- admitted +=
108
- file.path === nesso.entry ? file.bytes.byteLength : Math.ceil(file.bytes.byteLength / 3) * 4;
109
- if (admitted > packageLimits.record)
110
- throw new PluginError('invalid-input', [
111
- { path: 'files', message: 'Package record budget exceeded' },
112
- ]);
113
- const content = new Uint8Array(file.bytes);
114
- if (file.path === nesso.entry)
115
- bytes = content;
116
- else {
117
- if (nesso.kind !== 'theme' ||
118
- !/^(?:[\w-]+\/)*[\w-]+\.woff2$/.test(file.path) ||
119
- new TextDecoder().decode(content.subarray(0, 4)) !== 'wOF2')
120
- throw new PluginError('invalid-input', [
121
- { path: file.path, message: 'Expected a package-local WOFF2 font' },
122
- ]);
123
- let binary = '';
124
- for (let offset = 0; offset < content.length; offset += 32_768)
125
- binary += String.fromCharCode(...content.subarray(offset, offset + 32_768));
126
- fonts.push({ path: file.path, data: btoa(binary) });
127
- }
128
- files.push({ path: file.path, size: content.byteLength, sha256: await sha256Hex(content) });
129
- }
130
- if (!bytes)
86
+ const file = input.files[0];
87
+ if (!file ||
88
+ file.path !== nesso.entry ||
89
+ !(file.bytes instanceof Uint8Array) ||
90
+ !file.bytes.byteLength ||
91
+ file.bytes.byteLength > packageLimits.entry)
131
92
  throw new PluginError('invalid-input', [
132
- { path: 'nesso.entry', message: 'Missing plugin entry' },
93
+ { path: 'files', message: 'Expected the plugin entry within size limits' },
133
94
  ]);
95
+ const bytes = new Uint8Array(file.bytes);
96
+ const files = [{ path: file.path, size: bytes.byteLength, sha256: await sha256Hex(bytes) }];
134
97
  let code;
135
98
  try {
136
99
  code = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
@@ -152,8 +115,7 @@ export async function preparePluginPackage(input) {
152
115
  }
153
116
  parseDefinition(nesso.kind, raw);
154
117
  }
155
- const order = (left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0;
156
- const index = { name, version, author, repository, nesso, i18n, files: files.sort(order) };
118
+ const index = { name, version, author, repository, nesso, i18n, files };
157
119
  const prepared = {
158
120
  name,
159
121
  version,
@@ -162,7 +124,6 @@ export async function preparePluginPackage(input) {
162
124
  nesso,
163
125
  i18n,
164
126
  code,
165
- fonts: fonts.sort(order),
166
127
  contentId: await sha256Hex(new TextEncoder().encode(canonical(index))),
167
128
  };
168
129
  if (new TextEncoder().encode(JSON.stringify(prepared)).byteLength > packageLimits.record)
@@ -171,37 +132,11 @@ export async function preparePluginPackage(input) {
171
132
  ]);
172
133
  return prepared;
173
134
  }
174
- export function packageFonts(value) {
175
- if (!Array.isArray(value.fonts) || value.fonts.length > packageLimits.fonts)
176
- throw new PluginError('invalid-input', [
177
- { path: 'fonts', message: 'Invalid installed font assets' },
178
- ]);
179
- return new Map(value.fonts.map((font) => {
180
- if (!font ||
181
- typeof font.path !== 'string' ||
182
- typeof font.data !== 'string' ||
183
- font.data.length > Math.ceil(packageLimits.font / 3) * 4)
184
- throw new PluginError('invalid-input', [
185
- { path: 'fonts', message: 'Invalid font encoding or budget' },
186
- ]);
187
- try {
188
- return [font.path, Uint8Array.from(atob(font.data), (character) => character.charCodeAt(0))];
189
- }
190
- catch {
191
- throw new PluginError('invalid-input', [
192
- { path: 'fonts', message: 'Invalid font encoding' },
193
- ]);
194
- }
195
- }));
196
- }
197
135
  export async function verifyPluginPackage(value) {
198
136
  if (!value || typeof value.code !== 'string' || value.code.length > packageLimits.entry)
199
137
  throw new PluginError('invalid-input', [
200
138
  { path: 'package', message: 'Invalid installed plugin package' },
201
139
  ]);
202
- const fonts = packageFonts(value);
203
- if (fonts.size !== value.fonts.length)
204
- throw new PluginError('invalid-input', [{ path: 'fonts', message: 'Duplicate font assets' }]);
205
140
  const prepared = await preparePluginPackage({
206
141
  manifest: {
207
142
  name: value.name,
@@ -211,10 +146,7 @@ export async function verifyPluginPackage(value) {
211
146
  nesso: value.nesso,
212
147
  i18n: value.i18n,
213
148
  },
214
- files: [
215
- { path: value.nesso?.entry, bytes: new TextEncoder().encode(value.code) },
216
- ...[...fonts].map(([path, bytes]) => ({ path, bytes })),
217
- ],
149
+ files: [{ path: value.nesso?.entry, bytes: new TextEncoder().encode(value.code) }],
218
150
  });
219
151
  if (prepared.contentId !== value.contentId)
220
152
  throw new PluginError('denied', [
@@ -12,7 +12,6 @@ import { type PluginStorage, type PluginStorageRecord } from './storage.ts';
12
12
  export { checkMessageSize } from './data.ts';
13
13
  export { parsePluginStorageKey, parsePluginStorageRecord, parsePluginStorageSnapshot, pluginStorageLimits, } from './storage.ts';
14
14
  export { resolvePluginText, type LocalizedText } from './i18n.ts';
15
- export { fontFaces } from './theme-fonts.ts';
16
15
  export { parseOrThrow, PluginError } from './errors.ts';
17
16
  export { parseDefinition, themeColors, type Definition } from './definitions.ts';
18
17
  export { parseFileOptions, fileTextLimit, type FileOpenOptions, type FileSaveOptions, type FileOpenResult, } from './files.ts';
@@ -68,7 +67,7 @@ export type PluginI18n = DeepReadonly<{
68
67
  }>;
69
68
  export declare function parsePluginI18n(value: unknown): PluginI18n;
70
69
  declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
71
- apiVersion: z.ZodLiteral<2>;
70
+ apiVersion: z.ZodLiteral<3>;
72
71
  kind: z.ZodLiteral<"actions">;
73
72
  entry: z.ZodString;
74
73
  writes: z.ZodArray<z.ZodEnum<{
@@ -97,7 +96,7 @@ declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
97
96
  ui: "ui";
98
97
  }>>;
99
98
  }, z.core.$strict>, ...z.ZodObject<{
100
- apiVersion: z.ZodLiteral<2>;
99
+ apiVersion: z.ZodLiteral<3>;
101
100
  kind: z.ZodLiteral<"theme" | "vocab">;
102
101
  entry: z.ZodString;
103
102
  writes: z.ZodTuple<[], null>;
@@ -11,7 +11,6 @@ import { pluginStorageKey, pluginStorageRecord, pluginStorageRevision, pluginSto
11
11
  export { checkMessageSize } from './data.js';
12
12
  export { parsePluginStorageKey, parsePluginStorageRecord, parsePluginStorageSnapshot, pluginStorageLimits, } from './storage.js';
13
13
  export { resolvePluginText } from './i18n.js';
14
- export { fontFaces } from './theme-fonts.js';
15
14
  export { parseOrThrow, PluginError } from './errors.js';
16
15
  export { parseDefinition, themeColors } from './definitions.js';
17
16
  export { parseFileOptions, fileTextLimit, } from './files.js';
@@ -119,7 +118,7 @@ export function parsePluginI18n(value) {
119
118
  return parseOrThrow(pluginI18n, value, 'i18n.');
120
119
  }
121
120
  const manifestFields = {
122
- apiVersion: z.literal(2),
121
+ apiVersion: z.literal(3),
123
122
  };
124
123
  const jsEntry = z
125
124
  .string()
package/dist/package.d.ts CHANGED
@@ -1,9 +1,7 @@
1
- import { c as PluginI18n, l as PluginManifest } from "./runtime-DGDBGkWs.js";
1
+ import { c as PluginI18n, l as PluginManifest } from "./runtime-DCyJA620.js";
2
2
  //#region src/package.d.ts
3
3
  export declare const packageLimits: {
4
4
  readonly entry: number;
5
- readonly font: number;
6
- readonly fonts: 32;
7
5
  readonly record: number;
8
6
  readonly installed: 32;
9
7
  readonly total: number;
@@ -23,14 +21,9 @@ export type PreparedPlugin = {
23
21
  readonly nesso: PluginManifest;
24
22
  readonly i18n: PluginI18n;
25
23
  readonly code: string;
26
- readonly fonts: readonly {
27
- readonly path: string;
28
- readonly data: string;
29
- }[];
30
24
  readonly contentId: string;
31
25
  };
32
26
  export declare function parsePackageIdentity(value: unknown): any;
33
27
  export declare function preparePluginPackage(input: PluginPackageInput): Promise<PreparedPlugin>;
34
- export declare function packageFonts(value: PreparedPlugin): ReadonlyMap<string, Uint8Array>;
35
28
  export declare function verifyPluginPackage(value: PreparedPlugin): Promise<PreparedPlugin>;
36
29
  //#endregion
package/dist/package.js CHANGED
@@ -1,12 +1,10 @@
1
- import { C as PluginError, _ as checkMessageSize, o as parsePluginI18n, s as parsePluginManifest, u as sha256Hex, w as parseOrThrow, y as parseDefinition } from "./runtime-D6GosMdU.js";
1
+ import { C as parseOrThrow, S as PluginError, g as checkMessageSize, o as parsePluginI18n, s as parsePluginManifest, u as sha256Hex, v as parseDefinition } from "./runtime-uvKgm2yV.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";
5
5
  //#region src/package.ts
6
6
  const packageLimits = {
7
7
  entry: 16777216,
8
- font: 4194304,
9
- fonts: 32,
10
8
  record: 33554432,
11
9
  installed: 32,
12
10
  total: 134217728
@@ -48,50 +46,21 @@ async function preparePluginPackage(input) {
48
46
  const { name, version, author, repository, nesso: declaration, i18n: translations } = parsePackageIdentity(input.manifest);
49
47
  const nesso = parsePluginManifest(declaration);
50
48
  const i18n = parsePluginI18n(translations);
51
- if (!Array.isArray(input.files) || !input.files.length || input.files.length > (nesso.kind === "theme" ? packageLimits.fonts + 1 : 1)) throw new PluginError("invalid-input", [{
49
+ if (!Array.isArray(input.files) || input.files.length !== 1) throw new PluginError("invalid-input", [{
52
50
  path: "files",
53
- message: "Expected one entry and supported local theme fonts only"
51
+ message: "Expected one plugin entry only"
54
52
  }]);
55
- const paths = /* @__PURE__ */ new Set();
56
- const fonts = [];
57
- const files = [];
58
- let bytes;
59
- let admitted = 0;
60
- for (const file of input.files) {
61
- if (!file || typeof file.path !== "string" || file.path.length > 240 || paths.has(file.path) || !(file.bytes instanceof Uint8Array) || !file.bytes.byteLength || file.bytes.byteLength > (file.path === nesso.entry ? packageLimits.entry : packageLimits.font)) throw new PluginError("invalid-input", [{
62
- path: "files",
63
- message: "Invalid, duplicate, or oversized package file"
64
- }]);
65
- paths.add(file.path);
66
- admitted += file.path === nesso.entry ? file.bytes.byteLength : Math.ceil(file.bytes.byteLength / 3) * 4;
67
- if (admitted > packageLimits.record) throw new PluginError("invalid-input", [{
68
- path: "files",
69
- message: "Package record budget exceeded"
70
- }]);
71
- const content = new Uint8Array(file.bytes);
72
- if (file.path === nesso.entry) bytes = content;
73
- else {
74
- if (nesso.kind !== "theme" || !/^(?:[\w-]+\/)*[\w-]+\.woff2$/.test(file.path) || new TextDecoder().decode(content.subarray(0, 4)) !== "wOF2") throw new PluginError("invalid-input", [{
75
- path: file.path,
76
- message: "Expected a package-local WOFF2 font"
77
- }]);
78
- let binary = "";
79
- for (let offset = 0; offset < content.length; offset += 32768) binary += String.fromCharCode(...content.subarray(offset, offset + 32768));
80
- fonts.push({
81
- path: file.path,
82
- data: btoa(binary)
83
- });
84
- }
85
- files.push({
86
- path: file.path,
87
- size: content.byteLength,
88
- sha256: await sha256Hex(content)
89
- });
90
- }
91
- if (!bytes) throw new PluginError("invalid-input", [{
92
- path: "nesso.entry",
93
- message: "Missing plugin entry"
53
+ const file = input.files[0];
54
+ if (!file || file.path !== nesso.entry || !(file.bytes instanceof Uint8Array) || !file.bytes.byteLength || file.bytes.byteLength > packageLimits.entry) throw new PluginError("invalid-input", [{
55
+ path: "files",
56
+ message: "Expected the plugin entry within size limits"
94
57
  }]);
58
+ const bytes = new Uint8Array(file.bytes);
59
+ const files = [{
60
+ path: file.path,
61
+ size: bytes.byteLength,
62
+ sha256: await sha256Hex(bytes)
63
+ }];
95
64
  let code;
96
65
  try {
97
66
  code = new TextDecoder("utf-8", {
@@ -116,7 +85,6 @@ async function preparePluginPackage(input) {
116
85
  }
117
86
  parseDefinition(nesso.kind, raw);
118
87
  }
119
- const order = (left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0;
120
88
  const index = {
121
89
  name,
122
90
  version,
@@ -124,7 +92,7 @@ async function preparePluginPackage(input) {
124
92
  repository,
125
93
  nesso,
126
94
  i18n,
127
- files: files.sort(order)
95
+ files
128
96
  };
129
97
  const prepared = {
130
98
  name,
@@ -134,7 +102,6 @@ async function preparePluginPackage(input) {
134
102
  nesso,
135
103
  i18n,
136
104
  code,
137
- fonts: fonts.sort(order),
138
105
  contentId: await sha256Hex(new TextEncoder().encode(canonical(index)))
139
106
  };
140
107
  if (new TextEncoder().encode(JSON.stringify(prepared)).byteLength > packageLimits.record) throw new PluginError("invalid-input", [{
@@ -143,36 +110,11 @@ async function preparePluginPackage(input) {
143
110
  }]);
144
111
  return prepared;
145
112
  }
146
- function packageFonts(value) {
147
- if (!Array.isArray(value.fonts) || value.fonts.length > packageLimits.fonts) throw new PluginError("invalid-input", [{
148
- path: "fonts",
149
- message: "Invalid installed font assets"
150
- }]);
151
- return new Map(value.fonts.map((font) => {
152
- if (!font || typeof font.path !== "string" || typeof font.data !== "string" || font.data.length > Math.ceil(packageLimits.font / 3) * 4) throw new PluginError("invalid-input", [{
153
- path: "fonts",
154
- message: "Invalid font encoding or budget"
155
- }]);
156
- try {
157
- return [font.path, Uint8Array.from(atob(font.data), (character) => character.charCodeAt(0))];
158
- } catch {
159
- throw new PluginError("invalid-input", [{
160
- path: "fonts",
161
- message: "Invalid font encoding"
162
- }]);
163
- }
164
- }));
165
- }
166
113
  async function verifyPluginPackage(value) {
167
114
  if (!value || typeof value.code !== "string" || value.code.length > packageLimits.entry) throw new PluginError("invalid-input", [{
168
115
  path: "package",
169
116
  message: "Invalid installed plugin package"
170
117
  }]);
171
- const fonts = packageFonts(value);
172
- if (fonts.size !== value.fonts.length) throw new PluginError("invalid-input", [{
173
- path: "fonts",
174
- message: "Duplicate font assets"
175
- }]);
176
118
  const prepared = await preparePluginPackage({
177
119
  manifest: {
178
120
  name: value.name,
@@ -185,10 +127,7 @@ async function verifyPluginPackage(value) {
185
127
  files: [{
186
128
  path: value.nesso?.entry,
187
129
  bytes: new TextEncoder().encode(value.code)
188
- }, ...[...fonts].map(([path, bytes]) => ({
189
- path,
190
- bytes
191
- }))]
130
+ }]
192
131
  });
193
132
  if (prepared.contentId !== value.contentId) throw new PluginError("denied", [{
194
133
  path: "contentId",
@@ -197,4 +136,4 @@ async function verifyPluginPackage(value) {
197
136
  return prepared;
198
137
  }
199
138
  //#endregion
200
- export { packageFonts, packageLimits, parsePackageIdentity, preparePluginPackage, verifyPluginPackage };
139
+ export { packageLimits, parsePackageIdentity, preparePluginPackage, verifyPluginPackage };
@@ -167,6 +167,9 @@ type NessoOperation = {
167
167
  } | {
168
168
  readonly kind: 'preferences.locale';
169
169
  readonly value: Locale;
170
+ } | {
171
+ readonly kind: 'preferences.relationGroups';
172
+ readonly value: boolean;
170
173
  } | {
171
174
  readonly kind: 'preferences.panels';
172
175
  readonly value: PanelSizes;
@@ -214,6 +217,7 @@ type Preferences = {
214
217
  readonly activeThemeId: string;
215
218
  readonly panels: PanelSizes;
216
219
  readonly inspectorTab?: 'details' | 'chat';
220
+ readonly relationGroups?: boolean;
217
221
  readonly collapsedSections?: readonly SectionId[];
218
222
  };
219
223
  type NessoState = {
@@ -304,30 +308,6 @@ declare const themeDefinition: z.ZodObject<{
304
308
  'radius-object': z.ZodNumber;
305
309
  'duration-state': z.ZodNumber;
306
310
  }, z.core.$strict>;
307
- fonts: z.ZodObject<{
308
- sans: z.ZodObject<{
309
- faces: z.ZodArray<z.ZodObject<{
310
- path: z.ZodString;
311
- weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
312
- style: z.ZodEnum<{
313
- italic: "italic";
314
- normal: "normal";
315
- }>;
316
- unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
317
- }, z.core.$strict>>;
318
- }, z.core.$strict>;
319
- mono: z.ZodObject<{
320
- faces: z.ZodArray<z.ZodObject<{
321
- path: z.ZodString;
322
- weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
323
- style: z.ZodEnum<{
324
- italic: "italic";
325
- normal: "normal";
326
- }>;
327
- unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
328
- }, z.core.$strict>>;
329
- }, z.core.$strict>;
330
- }, z.core.$strict>;
331
311
  }, z.core.$strict>;
332
312
  type ThemeDefinition = DeepReadonly<z.infer<typeof themeDefinition>>;
333
313
  type Definition = ThemeDefinition | VocabDefinition;
@@ -460,9 +440,6 @@ declare function parsePluginStorageKey(value: unknown): PluginStorageKey;
460
440
  //#region src/data.d.ts
461
441
  declare function checkMessageSize(value: unknown, limit: number, maximumDepth?: number): void;
462
442
  //#endregion
463
- //#region src/theme-fonts.d.ts
464
- declare const fontFaces: (ranges: Record<string, string>, stem: string, weight: [number, number]) => ThemeDefinition['fonts']['sans'];
465
- //#endregion
466
443
  //#region src/runtime.d.ts
467
444
  declare const runtimeLimits: {
468
445
  readonly request: number;
@@ -516,7 +493,7 @@ type PluginI18n = DeepReadonly<{
516
493
  }>;
517
494
  declare function parsePluginI18n(value: unknown): PluginI18n;
518
495
  declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
519
- apiVersion: z.ZodLiteral<2>;
496
+ apiVersion: z.ZodLiteral<3>;
520
497
  kind: z.ZodLiteral<"actions">;
521
498
  entry: z.ZodString;
522
499
  writes: z.ZodArray<z.ZodEnum<{
@@ -545,7 +522,7 @@ declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
545
522
  ui: "ui";
546
523
  }>>;
547
524
  }, z.core.$strict>, ...z.ZodObject<{
548
- apiVersion: z.ZodLiteral<2>;
525
+ apiVersion: z.ZodLiteral<3>;
549
526
  kind: z.ZodLiteral<"theme" | "vocab">;
550
527
  entry: z.ZodString;
551
528
  writes: z.ZodTuple<[], null>;
@@ -1033,4 +1010,4 @@ declare function createPluginClient(port: MessagePort, initial: unknown): {
1033
1010
  getPresentation: () => Pick<ActionState, 'theme' | 'locale'>;
1034
1011
  };
1035
1012
  //#endregion
1036
- export { pluginStorageLimits as A, LocalizedText as B, PluginStorage as C, parsePluginStorageKey as D, PluginStorageScope as E, parseFileOptions as F, themeColors as G, Definition as H, ImageRenderOptions as I, SavedView as J, GraphSnapshot as K, RenderedImage as L, FileOpenResult as M, FileSaveOptions as N, parsePluginStorageRecord as O, fileTextLimit as P, PluginError as R, checkMessageSize as S, PluginStorageRecord as T, ThemeDefinition as U, resolvePluginText as V, parseDefinition as W, VocabDefinition as X, Selection as Y, 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, FileOpenOptions as j, parsePluginStorageSnapshot as k, PluginManifest as l, parseContribution as m, ActionBadgeResult as n, ActionIconName as o, parseActionBadgeResult as p, NessoOperation 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, parseOrThrow as z };
1013
+ export { FileOpenOptions as A, resolvePluginText as B, PluginStorageKey as C, parsePluginStorageRecord as D, parsePluginStorageKey as E, ImageRenderOptions as F, GraphSnapshot as G, ThemeDefinition as H, RenderedImage as I, Selection as J, NessoOperation as K, PluginError as L, FileSaveOptions as M, fileTextLimit as N, parsePluginStorageSnapshot as O, parseFileOptions as P, parseOrThrow as R, PluginStorage as S, PluginStorageScope as T, parseDefinition as U, Definition as V, themeColors as W, VocabDefinition as Y, 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, SavedView as q, ActionContext as r, ActionState as s, ActionBadgeInput as t, actionIconNames as u, runtimeLimits as v, PluginStorageRecord as w, checkMessageSize as x, sha256Hex as y, LocalizedText as z };
@@ -263,13 +263,6 @@ const themeColors = [
263
263
  ];
264
264
  const contributionId = z.string().max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
265
265
  const color = z.string().regex(/^#[\da-fA-F]{6}([\da-fA-F]{2})?$/);
266
- const fontFace = z.strictObject({
267
- path: z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.woff2$/),
268
- weight: z.tuple([z.number().int().min(1).max(1e3), z.number().int().min(1).max(1e3)]).refine(([min, max]) => min <= max),
269
- style: z.enum(["normal", "italic"]),
270
- unicodeRange: z.array(z.tuple([z.number().int().min(0).max(1114111), z.number().int().min(0).max(1114111)]).refine(([min, max]) => min <= max)).min(1).max(64).optional()
271
- });
272
- const font = z.strictObject({ faces: z.array(fontFace).max(32) });
273
266
  const luminance = (value) => {
274
267
  const linear = [
275
268
  1,
@@ -287,12 +280,8 @@ const themeDefinition = z.strictObject({
287
280
  "radius-control": z.number().min(0).max(16),
288
281
  "radius-object": z.number().min(0).max(16),
289
282
  "duration-state": z.number().int().min(0).max(300)
290
- }),
291
- fonts: z.strictObject({
292
- sans: font,
293
- mono: font
294
283
  })
295
- }).superRefine(({ colors, fonts }, context) => {
284
+ }).superRefine(({ colors }, context) => {
296
285
  for (const key of [
297
286
  "background",
298
287
  "canvas",
@@ -314,11 +303,6 @@ const themeDefinition = z.strictObject({
314
303
  path: ["colors", "primary-foreground"],
315
304
  message: "Insufficient primary contrast"
316
305
  });
317
- if (fonts.sans.faces.length + fonts.mono.faces.length > 32) context.addIssue({
318
- code: "custom",
319
- path: ["fonts"],
320
- message: "Font face limit exceeded"
321
- });
322
306
  });
323
307
  const vocabRelationType = z.strictObject({
324
308
  id: z.string().min(1).max(2048),
@@ -602,17 +586,6 @@ function parsePluginStorageKey(value) {
602
586
  return parseOrThrow(pluginStorageKey, value);
603
587
  }
604
588
  //#endregion
605
- //#region src/theme-fonts.ts
606
- const fontFaces = (ranges, stem, weight) => ({ faces: Object.entries(ranges).map(([subset, intervals]) => ({
607
- path: `fonts/${stem.replace("{subset}", subset)}.woff2`,
608
- weight,
609
- style: "normal",
610
- unicodeRange: intervals.split(",").map((interval) => {
611
- const [from, to = from] = interval.slice(2).split("-");
612
- return [parseInt(from, 16), parseInt(to, 16)];
613
- })
614
- })) });
615
- //#endregion
616
589
  //#region src/runtime.ts
617
590
  const runtimeLimits = {
618
591
  request: 33554432,
@@ -812,7 +785,7 @@ function parsePluginI18n(value) {
812
785
  checkMessageSize(value, 65536);
813
786
  return parseOrThrow(pluginI18n, value, "i18n.");
814
787
  }
815
- const manifestFields = { apiVersion: z.literal(2) };
788
+ const manifestFields = { apiVersion: z.literal(3) };
816
789
  const jsEntry = z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.js$/);
817
790
  const jsonEntry = z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.json$/);
818
791
  const operationDeclarations = z.array(z.enum([
@@ -1258,4 +1231,4 @@ function createPluginClient(port, initial) {
1258
1231
  };
1259
1232
  }
1260
1233
  //#endregion
1261
- export { PluginError as C, parseFileOptions as S, checkMessageSize as _, parseContribution as a, themeColors 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, fileTextLimit as x, parseDefinition as y };
1234
+ export { parseOrThrow as C, PluginError as S, resolvePluginText as _, parseContribution as a, fileTextLimit as b, parsePluginMessage as c, themeTokens as d, parsePluginStorageKey as f, checkMessageSize as g, pluginStorageLimits as h, parseActionBadgeResult as i, runtimeLimits as l, parsePluginStorageSnapshot as m, badgeLimits as n, parsePluginI18n as o, parsePluginStorageRecord as p, createPluginClient as r, parsePluginManifest as s, actionIconNames as t, sha256Hex as u, parseDefinition as v, parseFileOptions as x, themeColors as y };
package/dist/runtime.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as pluginStorageLimits, B as LocalizedText, D as parsePluginStorageKey, F as parseFileOptions, G as themeColors, H as Definition, I as ImageRenderOptions, L as RenderedImage, M as FileOpenResult, N as FileSaveOptions, O as parsePluginStorageRecord, P as fileTextLimit, R as PluginError, S as checkMessageSize, V as resolvePluginText, W 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 FileOpenOptions, k as parsePluginStorageSnapshot, 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 parseOrThrow } from "./runtime-DGDBGkWs.js";
2
- export { ActionBadgeInput, ActionBadgeResult, ActionContext, ActionContribution, ActionDescriptor, ActionIconName, ActionState, type Definition, type FileOpenOptions, type FileOpenResult, type FileSaveOptions, type ImageRenderOptions, type LocalizedText, PluginError, PluginI18n, PluginManifest, type RenderedImage, actionIconNames, badgeLimits, checkMessageSize, createPluginClient, fileTextLimit, fontFaces, parseActionBadgeResult, parseContribution, parseDefinition, parseFileOptions, parseOrThrow, parsePluginI18n, parsePluginManifest, parsePluginMessage, parsePluginStorageKey, parsePluginStorageRecord, parsePluginStorageSnapshot, pluginStorageLimits, resolvePluginText, runtimeLimits, sha256Hex, themeColors, themeTokens };
1
+ import { A as FileOpenOptions, B as resolvePluginText, D as parsePluginStorageRecord, E as parsePluginStorageKey, F as ImageRenderOptions, I as RenderedImage, L as PluginError, M as FileSaveOptions, N as fileTextLimit, O as parsePluginStorageSnapshot, P as parseFileOptions, R as parseOrThrow, U as parseDefinition, V as Definition, W as themeColors, _ 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 checkMessageSize, y as sha256Hex, z as LocalizedText } from "./runtime-DCyJA620.js";
2
+ export { ActionBadgeInput, ActionBadgeResult, ActionContext, ActionContribution, ActionDescriptor, ActionIconName, ActionState, type Definition, type FileOpenOptions, type FileOpenResult, type FileSaveOptions, type ImageRenderOptions, type LocalizedText, PluginError, PluginI18n, PluginManifest, type RenderedImage, actionIconNames, badgeLimits, checkMessageSize, createPluginClient, fileTextLimit, 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 { C as PluginError, t as actionIconNames, n as badgeLimits, _ as checkMessageSize, r as createPluginClient, x as fileTextLimit, f as fontFaces, i as parseActionBadgeResult, a as parseContribution, y as parseDefinition, S 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, b as themeColors, d as themeTokens } from "./runtime-D6GosMdU.js";
1
+ export { S as PluginError, t as actionIconNames, n as badgeLimits, g as checkMessageSize, r as createPluginClient, b as fileTextLimit, i as parseActionBadgeResult, a as parseContribution, v as parseDefinition, x as parseFileOptions, C as parseOrThrow, o as parsePluginI18n, s as parsePluginManifest, c as parsePluginMessage, f as parsePluginStorageKey, p as parsePluginStorageRecord, m as parsePluginStorageSnapshot, h as pluginStorageLimits, _ as resolvePluginText, l as runtimeLimits, u as sha256Hex, y as themeColors, d as themeTokens } from "./runtime-uvKgm2yV.js";
package/example/README.md CHANGED
@@ -1,39 +1,35 @@
1
1
  # Plugin Example
2
2
 
3
- The official Nesso plugin example: an **Uppercase labels** action and a React **Concept Quiz** with persistent progress. See [`src/index.ts`](src/index.ts) and [`src/Quiz.tsx`](src/Quiz.tsx).
3
+ Two actions built with the Nesso SDK:
4
+
5
+ - **Uppercase labels** changes concept labels in the current view. See [`src/index.ts`](src/index.ts).
6
+ - **Concept Quiz** uses React to quiz you on the view's relations and saves your progress. See [`src/Quiz.tsx`](src/Quiz.tsx).
4
7
 
5
8
  ## Install and try
6
9
 
7
- In the desktop app, open Settings → Plugins, search for `@nesso-how/plugin-example`, and install it. Approve its declared access to concept labels, interactive panels, and private storage. The panel example requires the SDK and app versions containing central-panel support; build from this checkout until that SDK release is published.
10
+ In the desktop app, open Settings → Plugins, search for `@nesso-how/plugin-example`, and install it. Approve access to concept labels, panels, and private storage.
8
11
 
9
12
  Run either action from a view's context menu in the Explorer, or from its actions in the Inspector with nothing selected.
10
13
 
11
14
  ## Build your own
12
15
 
13
- Copy this example into a separate project, then install dependencies and build:
16
+ Use Node.js 24. Copy this example into a separate project. Choose your own package name, update the metadata and action IDs/labels, and remove any permissions you do not use. Then install dependencies and build:
14
17
 
15
18
  ```sh
16
19
  npm install
17
20
  npm run build
18
21
  ```
19
22
 
20
- The Vite configuration bundles code and imported CSS into `dist/index.js`, leaving React and React DOM to Nesso. See the [UI contract](../README.md#action-ui) for runtime requirements.
23
+ The build runs TypeScript checks, then bundles code and CSS into `dist/index.js`. Nesso supplies React and React DOM at runtime. To typecheck without building, run `npm run check`.
21
24
 
22
- Choose your own package name, plugin metadata, and action IDs and labels before publishing.
25
+ See the SDK guide for [tests and package validation](../README.md#build-and-test) and [panel APIs and styling](../README.md#action-ui).
23
26
 
24
27
  ## Test an unpublished build
25
28
 
26
- Open `package.json` and `dist/index.js` in a text editor. In desktop DevTools, set `manifest` to the parsed package JSON and `compiledCode` to the bundled JavaScript as a string:
27
-
28
- ```ts
29
- const result = await window.nessoPlugins.propose(
30
- crypto.randomUUID(),
31
- {
32
- manifest,
33
- files: [{ path: manifest.nesso.entry, bytes: new TextEncoder().encode(compiledCode) }],
34
- },
35
- 'en',
36
- )
29
+ Follow the SDK guide to [connect your agent](../README.md#with-an-agent) and [install through MCP](../README.md#install-or-update-through-mcp). Pass your project's absolute root path to `propose_plugin`, not its `dist` directory:
30
+
31
+ ```json
32
+ { "directory": "/absolute/path/to/my-plugin" }
37
33
  ```
38
34
 
39
- Approve the Nesso access dialog. Installation persists. On success, `result.value` contains the installed package; it is `null` if approval is declined. Failures return `result.issues`. To replace a build, pass the installed package's `contentId` as the fourth argument; development proposals require fresh approval.
35
+ Approve the installation in Nesso when prompted. Rebuilding does not update the installed copy; use the SDK guide's replacement procedure for later builds. If the published example is already installed, your local copy needs a different package name.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nesso-how/plugin-example",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Official example showing how to build Nesso plugins with the SDK and plugin APIs",
5
5
  "keywords": [
6
6
  "nesso-plugin"
@@ -28,12 +28,12 @@
28
28
  "prepack": "npm run build"
29
29
  },
30
30
  "dependencies": {
31
- "@nesso-how/ui": "1.0.0-beta.2",
31
+ "@nesso-how/ui": "1.0.0-beta.8",
32
32
  "react": "^19.2.8",
33
33
  "react-dom": "^19.2.8"
34
34
  },
35
35
  "devDependencies": {
36
- "@nesso-how/plugin": "0.7.0",
36
+ "@nesso-how/plugin": "0.8.0",
37
37
  "@types/react": "^19.2.18",
38
38
  "@types/react-dom": "^19.2.7",
39
39
  "typescript": "~7.0.2",
@@ -54,7 +54,7 @@
54
54
  }
55
55
  },
56
56
  "nesso": {
57
- "apiVersion": 2,
57
+ "apiVersion": 3,
58
58
  "kind": "actions",
59
59
  "entry": "dist/index.js",
60
60
  "writes": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nesso-how/plugin",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Types, validation, and asynchronous clients for isolated Nesso plugins",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,2 +0,0 @@
1
- import type { ThemeDefinition } from './definitions.ts';
2
- export declare const fontFaces: (ranges: Record<string, string>, stem: string, weight: [number, number]) => ThemeDefinition['fonts']['sans'];
@@ -1,11 +0,0 @@
1
- export const fontFaces = (ranges, stem, weight) => ({
2
- faces: Object.entries(ranges).map(([subset, intervals]) => ({
3
- path: `fonts/${stem.replace('{subset}', subset)}.woff2`,
4
- weight,
5
- style: 'normal',
6
- unicodeRange: intervals.split(',').map((interval) => {
7
- const [from, to = from] = interval.slice(2).split('-');
8
- return [parseInt(from, 16), parseInt(to, 16)];
9
- }),
10
- })),
11
- });