@nesso-how/plugin-example 0.5.0 → 0.7.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/package.json CHANGED
@@ -1,50 +1,68 @@
1
1
  {
2
2
  "name": "@nesso-how/plugin-example",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Official example showing how to build Nesso plugins with the SDK and plugin APIs",
5
+ "keywords": [
6
+ "nesso-plugin"
7
+ ],
5
8
  "license": "MIT",
6
9
  "repository": {
7
10
  "type": "git",
8
11
  "url": "git+https://github.com/nesso-how/nesso.git",
9
12
  "directory": "packages/plugin/example"
10
13
  },
14
+ "files": [
15
+ "dist",
16
+ "src",
17
+ "tsconfig.json",
18
+ "vite.config.ts"
19
+ ],
11
20
  "type": "module",
12
- "keywords": ["nesso-plugin"],
13
- "files": ["dist", "src", "tsconfig.json", "vite.config.ts"],
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "registry": "https://registry.npmjs.org/"
24
+ },
14
25
  "scripts": {
15
26
  "check": "tsc",
16
27
  "build": "npm run check && vite build",
17
28
  "prepack": "npm run build"
18
29
  },
19
- "publishConfig": {
20
- "access": "public",
21
- "registry": "https://registry.npmjs.org/"
22
- },
23
30
  "dependencies": {
24
- "@nesso-how/ui": "1.0.0-alpha.31",
31
+ "@nesso-how/ui": "1.0.0-beta.2",
25
32
  "react": "^19.2.8",
26
33
  "react-dom": "^19.2.8"
27
34
  },
28
35
  "devDependencies": {
29
- "@nesso-how/plugin": "0.5.0",
36
+ "@nesso-how/plugin": "0.7.0",
30
37
  "@types/react": "^19.2.18",
31
38
  "@types/react-dom": "^19.2.7",
32
39
  "typescript": "~7.0.2",
33
40
  "vite": "^8.3.0",
34
41
  "vite-plugin-css-injected-by-js": "^5.0.3"
35
42
  },
36
- "nesso": {
37
- "apiVersion": 1,
38
- "kind": "actions",
39
- "entry": "dist/index.js",
40
- "writes": ["concept.label"],
41
- "capabilities": ["ui", "storage"]
42
- },
43
43
  "i18n": {
44
44
  "metadata": {
45
- "name": { "en": "Plugin Example" },
46
- "description": { "en": "Learn how to build Nesso plugins with the SDK and plugin APIs." },
47
- "documentation": { "en": "A reference plugin for developers, with practical examples of using Nesso's SDK and plugin APIs to define actions, interact with graph data, and build custom interfaces." }
45
+ "name": {
46
+ "en": "Plugin Example"
47
+ },
48
+ "description": {
49
+ "en": "Learn how to build Nesso plugins with the SDK and plugin APIs."
50
+ },
51
+ "documentation": {
52
+ "en": "A reference plugin for developers, with practical examples of using Nesso's SDK and plugin APIs to define actions, interact with graph data, and build custom interfaces."
53
+ }
48
54
  }
55
+ },
56
+ "nesso": {
57
+ "apiVersion": 2,
58
+ "kind": "actions",
59
+ "entry": "dist/index.js",
60
+ "writes": [
61
+ "concept.label"
62
+ ],
63
+ "capabilities": [
64
+ "ui",
65
+ "storage"
66
+ ]
49
67
  }
50
68
  }
package/src/Quiz.css CHANGED
@@ -1,8 +1,50 @@
1
- .quiz { display: grid; min-height: 100dvh; place-items: center; padding: 24px; color: var(--foreground); font: 13px/1.5 var(--font-sans), system-ui, sans-serif; }
2
- .quiz-card { width: 100%; max-width: 560px; overflow-wrap: anywhere; text-align: center; }
3
- .quiz h1 { margin: 0 0 4px; font-size: 20px; font-weight: 500; }
4
- .quiz [data-step] { margin: 0 0 16px; color: var(--muted-foreground); }
5
- .quiz [data-question] { margin: 0; color: var(--muted-foreground); }
6
- .quiz [data-answer] { min-height: 1.5em; margin: 16px 0; font-size: 18px; }
7
- .quiz [data-result] { width: fit-content; margin: 8px auto 24px; padding: 16px 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--muted); font-size: 18px; font-weight: 500; }
8
- .quiz footer { display: flex; justify-content: center; gap: 8px; }
1
+ .quiz {
2
+ display: grid;
3
+ min-height: 100dvh;
4
+ place-items: center;
5
+ padding: 24px;
6
+ color: var(--foreground);
7
+ font:
8
+ 13px/1.5 var(--font-sans),
9
+ system-ui,
10
+ sans-serif;
11
+ }
12
+ .quiz-card {
13
+ width: 100%;
14
+ max-width: 560px;
15
+ overflow-wrap: anywhere;
16
+ text-align: center;
17
+ }
18
+ .quiz h1 {
19
+ margin: 0 0 4px;
20
+ font-size: 20px;
21
+ font-weight: 500;
22
+ }
23
+ .quiz [data-step] {
24
+ margin: 0 0 16px;
25
+ color: var(--muted-foreground);
26
+ }
27
+ .quiz [data-question] {
28
+ margin: 0;
29
+ color: var(--muted-foreground);
30
+ }
31
+ .quiz [data-answer] {
32
+ min-height: 1.5em;
33
+ margin: 16px 0;
34
+ font-size: 18px;
35
+ }
36
+ .quiz [data-result] {
37
+ width: fit-content;
38
+ margin: 8px auto 24px;
39
+ padding: 16px 24px;
40
+ border: 1px solid var(--border);
41
+ border-radius: 12px;
42
+ background: var(--muted);
43
+ font-size: 18px;
44
+ font-weight: 500;
45
+ }
46
+ .quiz footer {
47
+ display: flex;
48
+ justify-content: center;
49
+ gap: 8px;
50
+ }
package/src/Quiz.tsx CHANGED
@@ -10,7 +10,9 @@ export function Quiz({ document, storage, viewId }: ActionContext) {
10
10
 
11
11
  useEffect(() => {
12
12
  void storage.list().then((records) => {
13
- const value = records.find((record) => record.key === key && record.conceptId === undefined)?.value
13
+ const value = records.find(
14
+ (record) => record.key === key && record.scope === undefined,
15
+ )?.value
14
16
  setStep(typeof value === 'number' ? value : 0)
15
17
  })
16
18
  }, [storage, key])
@@ -34,14 +36,33 @@ export function Quiz({ document, storage, viewId }: ActionContext) {
34
36
  <section className="quiz">
35
37
  <div className="quiz-card">
36
38
  <h1>Concept Quiz</h1>
37
- <p data-step>Step {Math.min(step + 1, relations.length)} / {relations.length}</p>
38
- {relation ? <>
39
- <p data-question>{conceptLabel(relation.source)} — {relationType?.label || relation.predicate} → ?</p>
40
- <p data-answer role="status">{revealed ? conceptLabel(relation.target) : ''}</p>
41
- </> : <p data-result role="status">{relations.length ? 'Quiz complete!' : 'This view has no relations.'}</p>}
39
+ <p data-step>
40
+ Step {Math.min(step + 1, relations.length)} / {relations.length}
41
+ </p>
42
+ {relation ? (
43
+ <>
44
+ <p data-question>
45
+ {conceptLabel(relation.source)} — {relationType?.label || relation.predicate} → ?
46
+ </p>
47
+ <p data-answer role="status">
48
+ {revealed ? conceptLabel(relation.target) : ''}
49
+ </p>
50
+ </>
51
+ ) : (
52
+ <p data-result role="status">
53
+ {relations.length ? 'Quiz complete!' : 'This view has no relations.'}
54
+ </p>
55
+ )}
42
56
  <footer>
43
- <Button variant="outline" onClick={() => void saveStep(0)}>Reset</Button>
44
- <Button disabled={!relation} onClick={() => revealed ? void saveStep(step + 1) : setRevealed(true)}>{buttonLabel}</Button>
57
+ <Button variant="outline" onClick={() => void saveStep(0)}>
58
+ Reset
59
+ </Button>
60
+ <Button
61
+ disabled={!relation}
62
+ onClick={() => (revealed ? void saveStep(step + 1) : setRevealed(true))}
63
+ >
64
+ {buttonLabel}
65
+ </Button>
45
66
  </footer>
46
67
  </div>
47
68
  </section>
package/src/index.ts CHANGED
@@ -8,11 +8,13 @@ export const create = (): readonly ActionContribution[] => {
8
8
  run: async ({ document }) => {
9
9
  const state = document.getState()
10
10
 
11
- const operations: readonly NessoOperation[] = state.viewGraph.concepts.map(({ id, label }) => ({
12
- kind: 'concept.label',
13
- id,
14
- value: label.toUpperCase(),
15
- }))
11
+ const operations: readonly NessoOperation[] = state.viewGraph.concepts.map(
12
+ ({ id, label }) => ({
13
+ kind: 'concept.label',
14
+ id,
15
+ value: label.toUpperCase(),
16
+ }),
17
+ )
16
18
 
17
19
  await document.applyOperations(operations)
18
20
  },