@plurnk/plurnk-web 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +337 -2
- package/SPEC.md +869 -0
- package/ai.plurnk/.env.defaults +38 -0
- package/ai.plurnk/assets.json +193 -0
- package/ai.plurnk/creations.js +65 -0
- package/ai.plurnk/diagram-compiler.js +15 -0
- package/ai.plurnk/diagrams.js +130 -0
- package/ai.plurnk/directory-addresses.js +35 -0
- package/ai.plurnk/dist/assets/Temml-CCjoacWt.woff2 +0 -0
- package/ai.plurnk/dist/assets/index-DQK23MMn.js +2 -0
- package/ai.plurnk/dist/assets/index-DQK23MMn.js.br +0 -0
- package/ai.plurnk/dist/assets/index-DQK23MMn.js.gz +0 -0
- package/ai.plurnk/dist/assets/index-DgGvOprn.css +1 -0
- package/ai.plurnk/dist/assets/index-DgGvOprn.css.br +0 -0
- package/ai.plurnk/dist/assets/index-DgGvOprn.css.gz +0 -0
- package/ai.plurnk/dist/assets/math-renderer-CZ_XtOMq.css +1 -0
- package/ai.plurnk/dist/assets/math-renderer-CZ_XtOMq.css.br +0 -0
- package/ai.plurnk/dist/assets/math-renderer-CZ_XtOMq.css.gz +0 -0
- package/ai.plurnk/dist/assets/math-renderer-CnlgS6FH.js +96 -0
- package/ai.plurnk/dist/assets/math-renderer-CnlgS6FH.js.br +0 -0
- package/ai.plurnk/dist/assets/math-renderer-CnlgS6FH.js.gz +0 -0
- package/ai.plurnk/dist/assets/overview-IkhWTlh2.js +1 -0
- package/ai.plurnk/dist/assets/overview-IkhWTlh2.js.br +0 -0
- package/ai.plurnk/dist/assets/overview-IkhWTlh2.js.gz +0 -0
- package/ai.plurnk/dist/assets/preload-helper-BjS5LQBu.js +1 -0
- package/ai.plurnk/dist/assets/preload-helper-BjS5LQBu.js.br +0 -0
- package/ai.plurnk/dist/assets/preload-helper-BjS5LQBu.js.gz +0 -0
- package/ai.plurnk/dist/assets/session-BgePzPYk.js +4 -0
- package/ai.plurnk/dist/assets/session-BgePzPYk.js.br +0 -0
- package/ai.plurnk/dist/assets/session-BgePzPYk.js.gz +0 -0
- package/ai.plurnk/dist/assets/session-agent-DWERfauE.js +111 -0
- package/ai.plurnk/dist/assets/session-agent-DWERfauE.js.br +0 -0
- package/ai.plurnk/dist/assets/session-agent-DWERfauE.js.gz +0 -0
- package/ai.plurnk/dist/assets/src-BdHyjaXT.js +1 -0
- package/ai.plurnk/dist/assets/src-BdHyjaXT.js.br +0 -0
- package/ai.plurnk/dist/assets/src-Vt7-ppeC.js +6 -0
- package/ai.plurnk/dist/assets/src-Vt7-ppeC.js.br +0 -0
- package/ai.plurnk/dist/assets/src-Vt7-ppeC.js.gz +0 -0
- package/ai.plurnk/dist/icons/APACHE-2.0.txt +202 -0
- package/ai.plurnk/dist/icons/APACHE-2.0.txt.br +0 -0
- package/ai.plurnk/dist/icons/APACHE-2.0.txt.gz +0 -0
- package/ai.plurnk/dist/icons/NOTO-NOTICE.txt +10 -0
- package/ai.plurnk/dist/icons/NOTO-NOTICE.txt.br +0 -0
- package/ai.plurnk/dist/icons/NOTO-NOTICE.txt.gz +0 -0
- package/ai.plurnk/dist/icons/plurnk-maskable.svg +64 -0
- package/ai.plurnk/dist/icons/plurnk-maskable.svg.br +0 -0
- package/ai.plurnk/dist/icons/plurnk-maskable.svg.gz +0 -0
- package/ai.plurnk/dist/icons/plurnk.svg +63 -0
- package/ai.plurnk/dist/icons/plurnk.svg.br +0 -0
- package/ai.plurnk/dist/icons/plurnk.svg.gz +0 -0
- package/ai.plurnk/dist/index.html +421 -0
- package/ai.plurnk/dist/manifest.webmanifest +27 -0
- package/ai.plurnk/dist/manifest.webmanifest.br +0 -0
- package/ai.plurnk/dist/manifest.webmanifest.gz +0 -0
- package/ai.plurnk/dist/vendor/CFWORKER-JSON-SCHEMA-LICENSE.txt +25 -0
- package/ai.plurnk/dist/vendor/CFWORKER-JSON-SCHEMA-LICENSE.txt.br +0 -0
- package/ai.plurnk/dist/vendor/CFWORKER-JSON-SCHEMA-LICENSE.txt.gz +0 -0
- package/ai.plurnk/dist/vendor/DEPENDENCIES-LICENSE.txt +571 -0
- package/ai.plurnk/dist/vendor/DEPENDENCIES-LICENSE.txt.br +0 -0
- package/ai.plurnk/dist/vendor/DEPENDENCIES-LICENSE.txt.gz +0 -0
- package/ai.plurnk/dist/vendor/MARKED-FOOTNOTE-LICENSE.txt +25 -0
- package/ai.plurnk/dist/vendor/MARKED-FOOTNOTE-LICENSE.txt.br +0 -0
- package/ai.plurnk/dist/vendor/MARKED-FOOTNOTE-LICENSE.txt.gz +0 -0
- package/ai.plurnk/dist/vendor/OTM-LICENSE.txt +21 -0
- package/ai.plurnk/dist/vendor/OTM-LICENSE.txt.br +0 -0
- package/ai.plurnk/dist/vendor/OTM-LICENSE.txt.gz +0 -0
- package/ai.plurnk/dist/vendor/PICO-LICENSE.txt +21 -0
- package/ai.plurnk/dist/vendor/PICO-LICENSE.txt.br +0 -0
- package/ai.plurnk/dist/vendor/PICO-LICENSE.txt.gz +0 -0
- package/ai.plurnk/documents.js +483 -0
- package/ai.plurnk/http.js +69 -0
- package/ai.plurnk/index-document.js +5 -0
- package/ai.plurnk/module.js +326 -0
- package/ai.plurnk/session.js +319 -0
- package/ai.plurnk/static-assets.js +40 -0
- package/package.json +92 -5
- package/plugin.json +13 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import Negotiator from "negotiator";
|
|
3
|
+
import { RequestError } from "./http.js";
|
|
4
|
+
|
|
5
|
+
/** @typedef {[string, string, string, Record<string, string>]} AssetEntry */
|
|
6
|
+
|
|
7
|
+
/** {§web-asset-encoding} Load all declared representations before admitting requests.
|
|
8
|
+
* @param {string} file @param {string} mediaType @param {Record<string, string>} encoded
|
|
9
|
+
*/
|
|
10
|
+
export async function readAsset(file, mediaType, encoded) {
|
|
11
|
+
const body = await readFile(new URL(`dist/${file}`, import.meta.url));
|
|
12
|
+
const variants = await Promise.all(Object.entries(encoded).map(async ([encoding, path]) =>
|
|
13
|
+
/** @type {const} */ ([encoding, await readFile(new URL(`dist/${path}`, import.meta.url))])));
|
|
14
|
+
const representations = new Map([["identity", body], ...variants]);
|
|
15
|
+
const preferred = [...representations].toSorted(([, a], [, b]) => a.byteLength - b.byteLength).map(([encoding]) => encoding);
|
|
16
|
+
return { body, mediaType, representations, preferred };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** {§web-asset-encoding} No response wrapper: only admitted static resources reach this path.
|
|
20
|
+
* @param {import("node:http").IncomingMessage} req
|
|
21
|
+
* @param {import("node:http").ServerResponse} res
|
|
22
|
+
* @param {Awaited<ReturnType<typeof readAsset>>} asset
|
|
23
|
+
*/
|
|
24
|
+
export function sendAsset(req, res, asset) {
|
|
25
|
+
res.appendHeader("vary", "Accept-Encoding");
|
|
26
|
+
const negotiator = new Negotiator(req);
|
|
27
|
+
// Published typings omit the documented same-quality preference option.
|
|
28
|
+
const choose = /** @type {(available: string[], options: { preferred: string[] }) => string | undefined} */ (negotiator.encoding);
|
|
29
|
+
const encoding = choose.call(negotiator, asset.preferred, { preferred: asset.preferred });
|
|
30
|
+
if (encoding === undefined) throw new RequestError(406, "No acceptable content encoding.");
|
|
31
|
+
const body = asset.representations.get(encoding);
|
|
32
|
+
if (body === undefined) throw new Error("Negotiated an undeclared asset representation.");
|
|
33
|
+
res.writeHead(200, {
|
|
34
|
+
"content-type": asset.mediaType.startsWith("text/") ? `${asset.mediaType}; charset=utf-8` : asset.mediaType,
|
|
35
|
+
"content-length": body.byteLength,
|
|
36
|
+
"x-content-type-options": "nosniff",
|
|
37
|
+
...(encoding === "identity" ? {} : { "content-encoding": encoding }),
|
|
38
|
+
});
|
|
39
|
+
res.end(req.method === "HEAD" ? undefined : body);
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,93 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@plurnk/plurnk-web",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Plurnk daemon module serving an OTM document.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=26"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/plurnk/plurnk-web#readme",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/plurnk/plurnk-web.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://repo.possumtech.com/plurnk/plurnk-web/issues"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"plugin.json",
|
|
23
|
+
"ai.plurnk/module.js",
|
|
24
|
+
"ai.plurnk/index-document.js",
|
|
25
|
+
"ai.plurnk/directory-addresses.js",
|
|
26
|
+
"ai.plurnk/creations.js",
|
|
27
|
+
"ai.plurnk/documents.js",
|
|
28
|
+
"ai.plurnk/session.js",
|
|
29
|
+
"ai.plurnk/http.js",
|
|
30
|
+
"ai.plurnk/static-assets.js",
|
|
31
|
+
"ai.plurnk/diagrams.js",
|
|
32
|
+
"ai.plurnk/diagram-compiler.js",
|
|
33
|
+
"ai.plurnk/.env.defaults",
|
|
34
|
+
"ai.plurnk/assets.json",
|
|
35
|
+
"ai.plurnk/dist/",
|
|
36
|
+
"README.md",
|
|
37
|
+
"SPEC.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@plurnk/plurnk-meta": "^2.1.6",
|
|
42
|
+
"negotiator": "1.1.0",
|
|
43
|
+
"oauth4webapi": "3.8.8",
|
|
44
|
+
"ondine": "0.0.1",
|
|
45
|
+
"piscina": "5.3.2"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@plurnk/plurnk-acp": "^1.3.1",
|
|
49
|
+
"@plurnk/plurnk-auth": "^1.0.1",
|
|
50
|
+
"@plurnk/plurnk-contracts": "^7.2.1",
|
|
51
|
+
"@plurnk/plurnk-modules": "^4.1.1"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@agentclientprotocol/sdk": "2.4.0",
|
|
55
|
+
"@eslint/js": "10.0.1",
|
|
56
|
+
"@fullhuman/postcss-purgecss": "8.0.0",
|
|
57
|
+
"@picocss/pico": "2.1.1",
|
|
58
|
+
"@plurnk/plurnk-spec-check": "0.2.0",
|
|
59
|
+
"@types/negotiator": "0.6.5",
|
|
60
|
+
"@types/node": "^26.1.1",
|
|
61
|
+
"@xterm/headless": "6.0.0",
|
|
62
|
+
"dompurify": "3.4.17",
|
|
63
|
+
"eslint": "10.12.0",
|
|
64
|
+
"eslint-plugin-no-unsanitized": "4.1.5",
|
|
65
|
+
"globals": "17.13.0",
|
|
66
|
+
"marked": "18.1.1",
|
|
67
|
+
"marked-footnote": "1.4.0",
|
|
68
|
+
"node-pty": "1.1.0",
|
|
69
|
+
"on_the_money": "0.11.0",
|
|
70
|
+
"playwright": "1.64.0",
|
|
71
|
+
"stylelint": "17.16.0",
|
|
72
|
+
"stylelint-config-standard": "40.0.0",
|
|
73
|
+
"temml": "0.14.0",
|
|
74
|
+
"typescript": "^7.0.2",
|
|
75
|
+
"vite": "8.3.4",
|
|
76
|
+
"zod": "3.25.76"
|
|
77
|
+
},
|
|
78
|
+
"allowScripts": {
|
|
79
|
+
"node-pty@1.1.0": true
|
|
80
|
+
},
|
|
81
|
+
"scripts": {
|
|
82
|
+
"dev": "node scripts/assets.mjs && vite",
|
|
83
|
+
"build": "node scripts/build.mjs",
|
|
84
|
+
"preview": "vite preview",
|
|
85
|
+
"test:lint": "plurnk-spec-check && tsc && tsc -p tsconfig.browser.json && tsc -p tsconfig.test.json && eslint . && otm-lint --check web && stylelint 'web/styles/*.css'",
|
|
86
|
+
"test:unit": "node --env-file=ai.plurnk/.env.defaults --test test/module.test.js test/creations.test.js test/workspace-creation.test.js test/route-settlement.test.js test/diagrams.test.js test/build.test.js test/development.test.js test/authoring.test.js test/directory-addresses.test.js test/session.test.js test/token.test.js test/documents.test.js test/session-status.test.js test/history-pages.test.js test/conversation.test.js test/package.test.js",
|
|
87
|
+
"test:installation": "node --test test/installation.test.js",
|
|
88
|
+
"test:candidate": "node scripts/test-candidate.mjs",
|
|
89
|
+
"test": "npm run build && npm run test:lint && npm run test:unit",
|
|
90
|
+
"prepack": "npm run build",
|
|
91
|
+
"prepublishOnly": "npm test"
|
|
92
|
+
}
|
|
93
|
+
}
|
package/plugin.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
|
+
"name": "plurnk-web",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Serve an OTM document through the Plurnk daemon's HTTP listener.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"extensions": {
|
|
8
|
+
"ai.plurnk": {
|
|
9
|
+
"kind": "module",
|
|
10
|
+
"module": "ai.plurnk/module.js"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|