@nesso-how/plugin-example 0.0.0-stage → 0.3.1
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/LICENSE +21 -0
- package/README.md +35 -2
- package/dist/index.js +64 -0
- package/package.json +40 -4
- package/src/index.ts +22 -0
- package/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Omar Desogus and Paolo Manfredotti
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Uppercase labels
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official Nesso action plugin example, published as [`@nesso-how/plugin-example`](https://www.npmjs.com/package/@nesso-how/plugin-example). It uppercases labels in the invoked view with one undoable batch. Shared concepts change in every view containing them.
|
|
4
|
+
|
|
5
|
+
## Install and try
|
|
6
|
+
|
|
7
|
+
In the desktop app, open Settings → Plugins, search for `@nesso-how/plugin-example`, and install it. Approve its declared access to concept labels.
|
|
8
|
+
|
|
9
|
+
Run **Uppercase labels** from a view's context menu in the Explorer, or from the view's actions in the Inspector with no concepts or relations selected. Use Undo to restore the original labels.
|
|
10
|
+
|
|
11
|
+
## Build your own
|
|
12
|
+
|
|
13
|
+
Copy this example into a separate project, then install dependencies and build:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install
|
|
17
|
+
npm run build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The build typechecks `src/index.ts` and bundles it with the package metadata into a self-contained `dist/index.js`.
|
|
21
|
+
|
|
22
|
+
Choose your own package name and action ID before publishing a derived plugin.
|
|
23
|
+
|
|
24
|
+
## Test an unpublished build
|
|
25
|
+
|
|
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
|
+
{ manifest, files: [{ path: manifest.nesso.entry, bytes: new TextEncoder().encode(compiledCode) }] },
|
|
32
|
+
'en'
|
|
33
|
+
)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
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.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// package.json
|
|
2
|
+
var package_default = {
|
|
3
|
+
name: "@nesso-how/plugin-example",
|
|
4
|
+
version: "0.3.1",
|
|
5
|
+
description: "Uppercase concept labels in the invoked Nesso view",
|
|
6
|
+
license: "MIT",
|
|
7
|
+
repository: {
|
|
8
|
+
type: "git",
|
|
9
|
+
url: "git+https://github.com/nesso-how/nesso.git",
|
|
10
|
+
directory: "packages/plugin/example"
|
|
11
|
+
},
|
|
12
|
+
type: "module",
|
|
13
|
+
keywords: ["nesso-plugin"],
|
|
14
|
+
files: ["dist", "src", "tsconfig.json"],
|
|
15
|
+
scripts: {
|
|
16
|
+
check: "tsc",
|
|
17
|
+
build: "npm run check && esbuild src/index.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=dist/index.js",
|
|
18
|
+
prepack: "npm run build"
|
|
19
|
+
},
|
|
20
|
+
publishConfig: {
|
|
21
|
+
access: "public",
|
|
22
|
+
registry: "https://registry.npmjs.org/"
|
|
23
|
+
},
|
|
24
|
+
devDependencies: {
|
|
25
|
+
"@nesso-how/plugin": "0.3.1",
|
|
26
|
+
esbuild: "^0.28.2",
|
|
27
|
+
typescript: "~7.0.2"
|
|
28
|
+
},
|
|
29
|
+
nesso: {
|
|
30
|
+
apiVersion: 1,
|
|
31
|
+
kind: "actions",
|
|
32
|
+
entry: "dist/index.js",
|
|
33
|
+
writes: ["concept.label"],
|
|
34
|
+
capabilities: []
|
|
35
|
+
},
|
|
36
|
+
i18n: {
|
|
37
|
+
metadata: {
|
|
38
|
+
name: { en: "Uppercase labels" },
|
|
39
|
+
description: { en: "Uppercase concept labels in the invoked view." },
|
|
40
|
+
documentation: { en: "Changes the labels of concepts in the invoked view in one undoable transaction. Concepts shared with other views change there too." }
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/index.ts
|
|
46
|
+
var create = () => {
|
|
47
|
+
const action = {
|
|
48
|
+
id: "uppercase-labels",
|
|
49
|
+
label: package_default.i18n.metadata.name,
|
|
50
|
+
run: async ({ store }) => {
|
|
51
|
+
const state = store.getState();
|
|
52
|
+
const operations = state.viewGraph.concepts.map(({ id, label }) => ({
|
|
53
|
+
kind: "concept.label",
|
|
54
|
+
id,
|
|
55
|
+
value: label.toUpperCase()
|
|
56
|
+
}));
|
|
57
|
+
await store.applyOperations(operations);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return [action];
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
create
|
|
64
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nesso-how/plugin-example",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Uppercase concept labels in the invoked Nesso view",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/nesso-how/nesso.git",
|
|
9
|
+
"directory": "packages/plugin/example"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"keywords": ["nesso-plugin"],
|
|
13
|
+
"files": ["dist", "src", "tsconfig.json"],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"check": "tsc",
|
|
16
|
+
"build": "npm run check && esbuild src/index.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=dist/index.js",
|
|
17
|
+
"prepack": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public",
|
|
21
|
+
"registry": "https://registry.npmjs.org/"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@nesso-how/plugin": "0.3.1",
|
|
25
|
+
"esbuild": "^0.28.2",
|
|
26
|
+
"typescript": "~7.0.2"
|
|
27
|
+
},
|
|
28
|
+
"nesso": {
|
|
29
|
+
"apiVersion": 1,
|
|
30
|
+
"kind": "actions",
|
|
31
|
+
"entry": "dist/index.js",
|
|
32
|
+
"writes": ["concept.label"],
|
|
33
|
+
"capabilities": []
|
|
34
|
+
},
|
|
35
|
+
"i18n": {
|
|
36
|
+
"metadata": {
|
|
37
|
+
"name": { "en": "Uppercase labels" },
|
|
38
|
+
"description": { "en": "Uppercase concept labels in the invoked view." },
|
|
39
|
+
"documentation": { "en": "Changes the labels of concepts in the invoked view in one undoable transaction. Concepts shared with other views change there too." }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ActionContribution, NessoOperation } from '@nesso-how/plugin'
|
|
2
|
+
import source from '../package.json' with { type: 'json' }
|
|
3
|
+
|
|
4
|
+
export const create = (): readonly ActionContribution[] => {
|
|
5
|
+
const action: ActionContribution = {
|
|
6
|
+
id: 'uppercase-labels',
|
|
7
|
+
label: source.i18n.metadata.name,
|
|
8
|
+
run: async ({ store }) => {
|
|
9
|
+
const state = store.getState()
|
|
10
|
+
|
|
11
|
+
const operations: readonly NessoOperation[] = state.viewGraph.concepts.map(({ id, label }) => ({
|
|
12
|
+
kind: 'concept.label',
|
|
13
|
+
id,
|
|
14
|
+
value: label.toUpperCase(),
|
|
15
|
+
}))
|
|
16
|
+
|
|
17
|
+
await store.applyOperations(operations)
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return [action]
|
|
22
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022", "WebWorker"],
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"verbatimModuleSyntax": true,
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
"types": []
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|