@nesso-how/plugin 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/README.md +102 -58
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/node/data.d.ts +1 -0
- package/dist/node/data.js +39 -0
- package/dist/node/definitions.d.ts +69 -0
- package/dist/node/definitions.js +124 -0
- package/dist/node/errors.d.ts +12 -0
- package/dist/node/errors.js +60 -0
- package/dist/node/files.d.ts +25 -0
- package/dist/node/files.js +53 -0
- package/dist/node/i18n.d.ts +12 -0
- package/dist/node/i18n.js +11 -0
- package/dist/node/images.d.ts +11 -0
- package/dist/node/images.js +10 -0
- package/dist/node/index.d.ts +7 -0
- package/dist/node/index.js +2 -0
- package/dist/node/package.d.ts +34 -0
- package/dist/node/package.js +224 -0
- package/dist/node/runtime.d.ts +586 -0
- package/dist/node/runtime.js +511 -0
- package/dist/node/storage.d.ts +72 -0
- package/dist/node/storage.js +71 -0
- package/dist/node/theme-fonts.d.ts +2 -0
- package/dist/node/theme-fonts.js +11 -0
- package/dist/package.d.ts +1 -1
- package/dist/package.js +1 -1
- package/dist/{runtime-CJPU4o4h.js → runtime-D6GosMdU.js} +375 -252
- package/dist/{runtime-D4jO7tbm.d.ts → runtime-DGDBGkWs.d.ts} +228 -133
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +1 -1
- package/example/README.md +5 -2
- package/example/package.json +37 -19
- package/example/src/Quiz.css +50 -8
- package/example/src/Quiz.tsx +29 -8
- package/example/src/index.ts +7 -5
- package/package.json +4 -3
package/example/package.json
CHANGED
|
@@ -1,50 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nesso-how/plugin-example",
|
|
3
|
-
"version": "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
|
-
"
|
|
13
|
-
|
|
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-
|
|
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.
|
|
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": {
|
|
46
|
-
|
|
47
|
-
|
|
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/example/src/Quiz.css
CHANGED
|
@@ -1,8 +1,50 @@
|
|
|
1
|
-
.quiz {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.
|
|
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/example/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(
|
|
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>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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)}>
|
|
44
|
-
|
|
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/example/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(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nesso-how/plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Types, validation, and asynchronous clients for isolated Nesso plugins",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"url": "git+https://github.com/nesso-how/nesso.git",
|
|
9
9
|
"directory": "packages/plugin"
|
|
10
10
|
},
|
|
11
|
-
"type": "module",
|
|
12
11
|
"files": [
|
|
13
12
|
"dist",
|
|
14
13
|
"example"
|
|
15
14
|
],
|
|
15
|
+
"type": "module",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"zod": "^4.6.5"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
+
"@nesso-how/core": "0.0.0",
|
|
41
42
|
"@nesso-how/errors": "0.0.0",
|
|
42
43
|
"@nesso-how/i18n": "0.0.0",
|
|
43
44
|
"@nesso-how/schema": "0.0.0",
|
|
@@ -50,6 +51,6 @@
|
|
|
50
51
|
"tsdown": "^0.23.1"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
53
|
-
"build": "tsc -p ../../tsconfig.plugin.json && tsdown"
|
|
54
|
+
"build": "tsc -p ../../tsconfig.plugin.json && tsdown && tsc -p tsconfig.json"
|
|
54
55
|
}
|
|
55
56
|
}
|