@nesso-how/plugin-example 0.2.0 → 0.4.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
@@ -10,41 +10,27 @@ Run **Uppercase labels** from a view's context menu in the Explorer, or from the
10
10
 
11
11
  ## Build your own
12
12
 
13
- Copy this directory outside the workspace, then install the published SDK and build:
13
+ Copy this example into a separate project, then install dependencies and build:
14
14
 
15
15
  ```sh
16
16
  npm install
17
17
  npm run build
18
18
  ```
19
19
 
20
- The build typechecks and bundles `src/index.ts` and its package metadata into `dist/index.js`. The SDK is a development dependency; the installed plugin needs only the bundled module and its manifest. Source files are included in the npm package so the example can also be inspected and adapted after downloading it.
20
+ The build typechecks `src/index.ts` and bundles it with the package metadata into a self-contained `dist/index.js`.
21
21
 
22
22
  Choose your own package name and action ID before publishing a derived plugin.
23
23
 
24
24
  ## Test an unpublished build
25
25
 
26
- To try it in desktop DevTools, set `manifest` to your parsed `package.json` and `compiledCode` to the text of `dist/index.js`:
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
27
 
28
28
  ```ts
29
- await window.nessoPlugins.propose(
29
+ const result = await window.nessoPlugins.propose(
30
30
  crypto.randomUUID(),
31
31
  { manifest, files: [{ path: manifest.nesso.entry, bytes: new TextEncoder().encode(compiledCode) }] },
32
32
  'en'
33
33
  )
34
34
  ```
35
35
 
36
- Approve the Nesso access dialog. Installation persists; disable or remove it in Settings. To replace a build, pass its installed `contentId` as the fourth argument; development proposals require fresh approval.
37
-
38
- ## Publish
39
-
40
- The official example shares the SDK's version and is released with it using `pnpm release:plugin` from the repository root. The release script updates both versions and pins the example to that SDK version. CI publishes the SDK first, then builds and publishes the standalone example against the published SDK.
41
-
42
- Maintainers bootstrap the example with `npm publish` from this directory using an npm account with access to the `@nesso-how` scope, once its SDK version is available. Configure npm Trusted Publishing for `nesso-how/nesso` and workflow `plugin-release.yml` on the new package before subsequent CI releases. Do not republish an existing SDK version to bootstrap the example.
43
-
44
- To inspect the example package locally after installing its dependencies:
45
-
46
- ```sh
47
- npm pack --dry-run
48
- ```
49
-
50
- Packing and publishing run the typecheck and build automatically. Authors of derived plugins use their own package name and version and publish independently with `npm publish`.
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 CHANGED
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@nesso-how/plugin-example",
4
- version: "0.2.0",
4
+ version: "0.4.0",
5
5
  description: "Uppercase concept labels in the invoked Nesso view",
6
6
  license: "MIT",
7
7
  repository: {
@@ -22,7 +22,7 @@ var package_default = {
22
22
  registry: "https://registry.npmjs.org/"
23
23
  },
24
24
  devDependencies: {
25
- "@nesso-how/plugin": "0.2.0",
25
+ "@nesso-how/plugin": "0.4.0",
26
26
  esbuild: "^0.28.2",
27
27
  typescript: "~7.0.2"
28
28
  },
@@ -43,16 +43,22 @@ var package_default = {
43
43
  };
44
44
 
45
45
  // src/index.ts
46
- var create = ({ store }) => [{
47
- id: "uppercase-labels",
48
- label: package_default.i18n.metadata.name,
49
- run: async () => {
50
- const state = store.getState();
51
- if (!("viewGraph" in state)) return;
52
- const operations = state.viewGraph.concepts.map(({ id, label }) => ({ kind: "concept.label", id, value: label.toUpperCase() }));
53
- await store.applyOperations(operations, { atRevision: state.revision });
54
- }
55
- }];
46
+ var create = () => {
47
+ const action = {
48
+ id: "uppercase-labels",
49
+ label: package_default.i18n.metadata.name,
50
+ run: async ({ document }) => {
51
+ const state = document.getState();
52
+ const operations = state.viewGraph.concepts.map(({ id, label }) => ({
53
+ kind: "concept.label",
54
+ id,
55
+ value: label.toUpperCase()
56
+ }));
57
+ await document.applyOperations(operations);
58
+ }
59
+ };
60
+ return [action];
61
+ };
56
62
  export {
57
63
  create
58
64
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nesso-how/plugin-example",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Uppercase concept labels in the invoked Nesso view",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "registry": "https://registry.npmjs.org/"
22
22
  },
23
23
  "devDependencies": {
24
- "@nesso-how/plugin": "0.2.0",
24
+ "@nesso-how/plugin": "0.4.0",
25
25
  "esbuild": "^0.28.2",
26
26
  "typescript": "~7.0.2"
27
27
  },
package/src/index.ts CHANGED
@@ -1,13 +1,22 @@
1
- import type { ActionContext, ActionContribution, NessoOperation } from '@nesso-how/plugin'
1
+ import type { ActionContribution, NessoOperation } from '@nesso-how/plugin'
2
2
  import source from '../package.json' with { type: 'json' }
3
3
 
4
- export const create = ({ store }: ActionContext): readonly ActionContribution[] => [{
5
- id: 'uppercase-labels',
6
- label: source.i18n.metadata.name,
7
- run: async () => {
8
- const state = store.getState()
9
- if (!('viewGraph' in state)) return
10
- const operations: readonly NessoOperation[] = state.viewGraph.concepts.map(({ id, label }) => ({ kind: 'concept.label', id, value: label.toUpperCase() }))
11
- await store.applyOperations(operations, { atRevision: state.revision })
12
- },
13
- }]
4
+ export const create = (): readonly ActionContribution[] => {
5
+ const action: ActionContribution = {
6
+ id: 'uppercase-labels',
7
+ label: source.i18n.metadata.name,
8
+ run: async ({ document }) => {
9
+ const state = document.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 document.applyOperations(operations)
18
+ },
19
+ }
20
+
21
+ return [action]
22
+ }