@nesso-how/plugin 0.7.0 → 1.0.0-beta.12
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 +92 -30
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node/definitions.d.ts +0 -24
- package/dist/node/definitions.js +1 -22
- package/dist/node/package.d.ts +0 -7
- package/dist/node/package.js +13 -81
- package/dist/node/runtime.d.ts +2 -3
- package/dist/node/runtime.js +1 -2
- package/dist/package.d.ts +1 -8
- package/dist/package.js +16 -77
- package/dist/{runtime-DGDBGkWs.d.ts → runtime-DCyJA620.d.ts} +7 -30
- package/dist/{runtime-D6GosMdU.js → runtime-uvKgm2yV.js} +3 -30
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +1 -1
- package/example/README.md +13 -17
- package/example/package.json +4 -4
- package/package.json +1 -1
- package/dist/node/theme-fonts.d.ts +0 -2
- package/dist/node/theme-fonts.js +0 -11
package/README.md
CHANGED
|
@@ -4,21 +4,38 @@ Build Nesso plugins with TypeScript: **actions** read and edit graphs, **vocabul
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Use Node.js 24. During Nesso's beta, add the SDK to an existing TypeScript project with:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npm install --save-dev @nesso-how/plugin
|
|
10
|
+
npm install --save-dev @nesso-how/plugin@beta
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
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
|
+
|
|
15
|
+
The app, UI package, SDK, and official example share a release version and npm channel. Plugin compatibility is identified separately by `nesso.apiVersion`; matching the app's exact version is not required. Stable releases use npm's default `latest` channel instead of `beta`.
|
|
16
|
+
|
|
17
|
+
The desktop plugin catalog uses `latest` in stable apps. Beta apps also check `beta` and offer the newest compatible stable or beta version. Other prerelease channels are not included.
|
|
14
18
|
|
|
15
19
|
## Create a plugin
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
### With an agent
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
1. In the desktop app, open Settings → AI → MCP and start the server. If `plugins` and `propose_plugin` are not available, update Nesso.
|
|
26
|
+
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.
|
|
27
|
+
3. Describe the plugin you want, or use this prompt:
|
|
28
|
+
|
|
29
|
+
> 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.
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
### By hand
|
|
34
|
+
|
|
35
|
+
Copy the [standalone example](example/) into a separate project and install its dependencies:
|
|
18
36
|
|
|
19
37
|
```sh
|
|
20
38
|
npm install
|
|
21
|
-
npm run build
|
|
22
39
|
```
|
|
23
40
|
|
|
24
41
|
Choose your own package name and action ID, then edit `src/index.ts`:
|
|
@@ -49,13 +66,7 @@ export const create = (): readonly ActionContribution[] => {
|
|
|
49
66
|
}
|
|
50
67
|
```
|
|
51
68
|
|
|
52
|
-
|
|
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.
|
|
69
|
+
`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
70
|
|
|
60
71
|
### Package metadata and permissions
|
|
61
72
|
|
|
@@ -67,7 +78,7 @@ Keep the example's build configuration and set these fields in `package.json`:
|
|
|
67
78
|
"version": "1.0.0",
|
|
68
79
|
"keywords": ["nesso-plugin"],
|
|
69
80
|
"nesso": {
|
|
70
|
-
"apiVersion":
|
|
81
|
+
"apiVersion": 3,
|
|
71
82
|
"kind": "actions",
|
|
72
83
|
"entry": "dist/index.js",
|
|
73
84
|
"writes": ["concept.label"],
|
|
@@ -83,21 +94,65 @@ Keep the example's build configuration and set these fields in `package.json`:
|
|
|
83
94
|
}
|
|
84
95
|
```
|
|
85
96
|
|
|
86
|
-
Declare the operations your action uses in `writes`.
|
|
97
|
+
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
98
|
|
|
88
|
-
|
|
99
|
+
`nesso.apiVersion` identifies the plugin API, not the SDK version or your package's version.
|
|
89
100
|
|
|
90
101
|
`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
102
|
|
|
92
103
|
### Build and test
|
|
93
104
|
|
|
94
|
-
Run `npm run build
|
|
105
|
+
Run `npm run build` to typecheck and build the example. Use `npm run check` to typecheck without building.
|
|
106
|
+
|
|
107
|
+
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.
|
|
108
|
+
|
|
109
|
+
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.
|
|
110
|
+
|
|
111
|
+
Before installing, validate the built package with `preparePluginPackage`. Save this as `validate.ts` in the project root and run `node validate.ts` after building:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { readFile } from 'node:fs/promises'
|
|
115
|
+
import { preparePluginPackage } from '@nesso-how/plugin/package'
|
|
116
|
+
import { parsePluginManifest } from '@nesso-how/plugin/runtime'
|
|
117
|
+
|
|
118
|
+
const manifest = JSON.parse(await readFile('package.json', 'utf8'))
|
|
119
|
+
const nesso = parsePluginManifest(manifest.nesso)
|
|
120
|
+
const entry = new Uint8Array(await readFile(nesso.entry))
|
|
121
|
+
const files = [{ path: nesso.entry, bytes: entry }]
|
|
122
|
+
|
|
123
|
+
const prepared = await preparePluginPackage({ manifest, files })
|
|
124
|
+
console.log(prepared.name, prepared.version, prepared.contentId)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
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.
|
|
128
|
+
|
|
129
|
+
### Install or update through MCP
|
|
130
|
+
|
|
131
|
+
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:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{ "directory": "/absolute/path/to/nesso-plugin-my-action" }
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
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.
|
|
138
|
+
|
|
139
|
+
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
140
|
|
|
96
|
-
|
|
141
|
+
- `installed`: includes `name`, `version`, and `contentId`.
|
|
142
|
+
- `cancelled`: the proposal was not approved. Do not automatically propose again.
|
|
143
|
+
- `failed`: includes `{ path, message }[]` issues to fix before a new proposal.
|
|
144
|
+
|
|
145
|
+
If the client times out or disconnects, call `plugins` to check whether installation completed. Do not retry automatically or report success without confirmation.
|
|
146
|
+
|
|
147
|
+
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.
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
151
|
+
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
152
|
|
|
98
153
|
## Action API
|
|
99
154
|
|
|
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.
|
|
155
|
+
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
156
|
|
|
102
157
|
`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
158
|
|
|
@@ -137,7 +192,9 @@ Nesso supplies React, the `@nesso-how/ui` component stylesheet, and theme CSS va
|
|
|
137
192
|
|
|
138
193
|
#### Lifecycle
|
|
139
194
|
|
|
140
|
-
|
|
195
|
+
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.
|
|
196
|
+
|
|
197
|
+
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.
|
|
141
198
|
|
|
142
199
|
### Action badges
|
|
143
200
|
|
|
@@ -213,13 +270,13 @@ The invoked view is **not a write sandbox**: permitted writes can affect the who
|
|
|
213
270
|
|
|
214
271
|
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.
|
|
215
272
|
|
|
216
|
-
`images.renderView` captures the invoked view with the current theme and fonts, without selection or canvas controls. Scale defaults to `2`, or accepts `4
|
|
273
|
+
`images.renderView` captures the invoked view with the current theme and fonts, without selection or canvas controls. Scale defaults to `2`, or accepts `4`, and is a maximum: views 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 views, views over that budget at scale `1`, and PNGs over 16 MiB fail. Save the result separately with `files.save({ name: 'view.png', ...image })`; this also requires `files`.
|
|
217
274
|
|
|
218
275
|
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.
|
|
219
276
|
|
|
220
277
|
### Private persistent storage
|
|
221
278
|
|
|
222
|
-
Declare `storage` to read, write, or delete
|
|
279
|
+
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
280
|
|
|
224
281
|
```ts
|
|
225
282
|
const records = await storage.list()
|
|
@@ -241,20 +298,24 @@ await storage.delete('progress', { kind: 'concept', id: concept.id })
|
|
|
241
298
|
- With `{ kind: 'concept', id }`, it belongs to that concept. Its data is shared across all views containing the concept.
|
|
242
299
|
- With `{ kind: 'view', id }`, it belongs to that saved view, independently of its name or membership. Use a non-null `viewId`.
|
|
243
300
|
- 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
|
-
-
|
|
301
|
+
- Your plugin owns the payload format and any migrations. Version it independently of the SDK and package version; Nesso does not interpret its fields.
|
|
302
|
+
|
|
303
|
+
`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
304
|
|
|
246
|
-
|
|
305
|
+
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
306
|
|
|
248
|
-
|
|
307
|
+
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
308
|
|
|
250
|
-
|
|
309
|
+
Document and storage revisions are independent: reading one does not refresh the other. Graph edits and storage calls are separate transactions.
|
|
310
|
+
|
|
311
|
+
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
312
|
|
|
252
313
|
#### Data lifecycle
|
|
253
314
|
|
|
254
315
|
- 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
316
|
- Renaming a view or changing membership does not affect scoped records. Removing a view does not delete concept data.
|
|
256
317
|
- 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
|
|
318
|
+
- 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
319
|
- Disabling, uninstalling, replacing, or crashing a plugin does not delete its stored data.
|
|
259
320
|
|
|
260
321
|
#### Limits
|
|
@@ -271,7 +332,7 @@ Storage accepts finite JSON primitives, dense arrays, and plain objects, includi
|
|
|
271
332
|
| Record nesting | 24 levels |
|
|
272
333
|
| Record key | 1–128 characters |
|
|
273
334
|
|
|
274
|
-
|
|
335
|
+
Keys are logical identifiers, not file paths. Action channel size, deadline, rate, and cancellation limits also apply.
|
|
275
336
|
|
|
276
337
|
## Vocabularies
|
|
277
338
|
|
|
@@ -302,10 +363,11 @@ Set `nesso.kind` to `"theme"`, point `entry` to your JSON definition, and use em
|
|
|
302
363
|
- `id`: a lowercase kebab-case contribution ID.
|
|
303
364
|
- `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
365
|
- `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
366
|
|
|
307
|
-
Only light themes are supported. Use readable text contrast; arbitrary CSS and
|
|
367
|
+
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.
|
|
368
|
+
|
|
369
|
+
## API reference
|
|
308
370
|
|
|
309
|
-
|
|
371
|
+
Import graph and operation types from `@nesso-how/plugin`; no separate `@nesso-how/core` dependency is needed.
|
|
310
372
|
|
|
311
373
|
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 {
|
|
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 {
|
|
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;
|
package/dist/node/definitions.js
CHANGED
|
@@ -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
|
|
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),
|
package/dist/node/package.d.ts
CHANGED
|
@@ -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>;
|
package/dist/node/package.js
CHANGED
|
@@ -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
|
|
84
|
+
{ path: 'files', message: 'Expected one plugin entry only' },
|
|
89
85
|
]);
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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: '
|
|
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
|
|
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', [
|
package/dist/node/runtime.d.ts
CHANGED
|
@@ -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<
|
|
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<
|
|
99
|
+
apiVersion: z.ZodLiteral<3>;
|
|
101
100
|
kind: z.ZodLiteral<"theme" | "vocab">;
|
|
102
101
|
entry: z.ZodString;
|
|
103
102
|
writes: z.ZodTuple<[], null>;
|
package/dist/node/runtime.js
CHANGED
|
@@ -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(
|
|
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-
|
|
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,
|
|
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) ||
|
|
49
|
+
if (!Array.isArray(input.files) || input.files.length !== 1) throw new PluginError("invalid-input", [{
|
|
52
50
|
path: "files",
|
|
53
|
-
message: "Expected one entry
|
|
51
|
+
message: "Expected one plugin entry only"
|
|
54
52
|
}]);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
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
|
-
}
|
|
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 {
|
|
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<
|
|
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<
|
|
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 {
|
|
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
|
|
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(
|
|
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 {
|
|
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
|
|
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,
|
|
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 {
|
|
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
|
-
|
|
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
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
|
|
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
|
|
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.
|
package/example/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nesso-how/plugin-example",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.12",
|
|
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.
|
|
31
|
+
"@nesso-how/ui": "1.0.0-beta.12",
|
|
32
32
|
"react": "^19.2.8",
|
|
33
33
|
"react-dom": "^19.2.8"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@nesso-how/plugin": "0.
|
|
36
|
+
"@nesso-how/plugin": "1.0.0-beta.12",
|
|
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":
|
|
57
|
+
"apiVersion": 3,
|
|
58
58
|
"kind": "actions",
|
|
59
59
|
"entry": "dist/index.js",
|
|
60
60
|
"writes": [
|
package/package.json
CHANGED
package/dist/node/theme-fonts.js
DELETED
|
@@ -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
|
-
});
|