@metacensus/library-research 0.10.0 → 0.12.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 +99 -13
- package/csp.json +10 -0
- package/dist/cli.js +1 -1
- package/dist/commands/add.js +2 -1
- package/dist/commands/candidate.js +12 -1
- package/dist/commands/check.js +22 -13
- package/dist/commands/dev.js +92 -9
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +131 -0
- package/dist/context.d.ts +4 -0
- package/dist/context.js +4 -0
- package/dist/data.d.ts +22 -0
- package/dist/data.js +76 -0
- package/dist/dev/host.d.ts +1 -1
- package/dist/dev/host.js +38 -41
- package/dist/document-store.d.ts +14 -0
- package/dist/document-store.js +78 -0
- package/dist/documents.d.ts +10 -0
- package/dist/documents.js +22 -0
- package/dist/host.d.ts +17 -0
- package/dist/host.js +31 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/mount.d.ts +14 -0
- package/dist/mount.js +15 -0
- package/dist/papers.d.ts +0 -6
- package/dist/papers.js +8 -21
- package/dist/pdf.d.ts +2 -0
- package/dist/pdf.js +2 -0
- package/dist/playwright.d.ts +3 -1
- package/dist/playwright.js +50 -10
- package/dist/react.d.ts +32 -9
- package/dist/react.js +170 -36
- package/dist/reader.d.ts +2 -0
- package/dist/reader.js +2 -0
- package/dist/roles.d.ts +7 -5
- package/dist/roles.js +103 -36
- package/dist/router.d.ts +4 -0
- package/dist/router.js +16 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +15 -2
- package/dist/testing.d.ts +29 -0
- package/dist/testing.js +46 -0
- package/dist/types.d.ts +22 -12
- package/dist/vite-config.js +4 -2
- package/dist/vite.js +29 -3
- package/package.json +28 -4
- package/schema/research.schema.json +11 -0
- package/src/virtual.d.ts +2 -2
- package/tsconfig.project.json +3 -1
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, realpathSync, statSync, } from 'node:fs';
|
|
2
2
|
import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { satisfies } from 'semver';
|
|
3
4
|
import { isCSSRequest, preprocessCSS, searchForWorkspaceRoot, } from 'vite';
|
|
4
|
-
import { project } from './
|
|
5
|
+
import { project, read } from './data.js';
|
|
5
6
|
const prefix = 'projects';
|
|
6
7
|
const dataPath = new RegExp(`^${prefix}/([^/]+)/data/([^/]+)\\.json$`);
|
|
7
8
|
const virtual = 'virtual:research-projects';
|
|
@@ -13,6 +14,14 @@ const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
|
13
14
|
const inside = (path, dir) => (path + sep).startsWith(dir + sep);
|
|
14
15
|
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
15
16
|
const shared = [pkg.name, ...Object.keys(pkg.peerDependencies)];
|
|
17
|
+
const declared = (file) => {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(readFileSync(file, 'utf8')).dependencies?.[pkg.name];
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
16
25
|
/** Compiles each project, by slug and path from the Vite root, into the host. */
|
|
17
26
|
export function research({ projects, }) {
|
|
18
27
|
let config;
|
|
@@ -52,6 +61,14 @@ export function research({ projects, }) {
|
|
|
52
61
|
slug,
|
|
53
62
|
realpathSync(resolve(from, path)),
|
|
54
63
|
]);
|
|
64
|
+
for (const [slug, dir] of dirs) {
|
|
65
|
+
const file = join(dir, 'ui/package.json');
|
|
66
|
+
const range = declared(file);
|
|
67
|
+
if (typeof range !== 'string')
|
|
68
|
+
throw new Error(`${file}: project ${slug} does not declare ${pkg.name}`);
|
|
69
|
+
if (!satisfies(pkg.version, range))
|
|
70
|
+
throw new Error(`${file}: project ${slug} declares ${pkg.name} ${range}, excluding the host's ${pkg.version}`);
|
|
71
|
+
}
|
|
55
72
|
return {
|
|
56
73
|
resolve: { dedupe: shared },
|
|
57
74
|
worker: {
|
|
@@ -142,13 +159,22 @@ export function research({ projects, }) {
|
|
|
142
159
|
apply: 'build',
|
|
143
160
|
enforce: 'post',
|
|
144
161
|
buildStart() {
|
|
145
|
-
for (const [slug, dir] of dirs)
|
|
146
|
-
|
|
162
|
+
for (const [slug, dir] of dirs) {
|
|
163
|
+
const { roles, pages } = project(dir);
|
|
164
|
+
for (const [role, json] of Object.entries(roles))
|
|
147
165
|
this.emitFile({
|
|
148
166
|
type: 'asset',
|
|
149
167
|
fileName: `${prefix}/${slug}/data/${role}.json`,
|
|
150
168
|
source: JSON.stringify(json()),
|
|
151
169
|
});
|
|
170
|
+
for (const [role, held] of Object.entries(pages))
|
|
171
|
+
for (const [page, file] of Object.entries(held()))
|
|
172
|
+
this.emitFile({
|
|
173
|
+
type: 'asset',
|
|
174
|
+
fileName: `${prefix}/${slug}/private/${page}/${role}.json`,
|
|
175
|
+
source: JSON.stringify(read(dir, file)),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
152
178
|
},
|
|
153
179
|
buildEnd() {
|
|
154
180
|
const local = dirs.map(([, dir]) => join(dir, 'ui/local') + sep);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metacensus/library-research",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,6 +18,19 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"default": "./dist/index.js"
|
|
20
20
|
},
|
|
21
|
+
"./host": {
|
|
22
|
+
"types": "./dist/host.d.ts",
|
|
23
|
+
"default": "./dist/host.js"
|
|
24
|
+
},
|
|
25
|
+
"./testing": {
|
|
26
|
+
"types": "./dist/testing.d.ts",
|
|
27
|
+
"default": "./dist/testing.js"
|
|
28
|
+
},
|
|
29
|
+
"./roles": {
|
|
30
|
+
"types": "./dist/roles.d.ts",
|
|
31
|
+
"default": "./dist/roles.js"
|
|
32
|
+
},
|
|
33
|
+
"./csp.json": "./csp.json",
|
|
21
34
|
"./schema": {
|
|
22
35
|
"types": "./dist/schema.d.ts",
|
|
23
36
|
"default": "./dist/schema.js"
|
|
@@ -37,6 +50,7 @@
|
|
|
37
50
|
"./tsconfig.json": "./tsconfig.project.json"
|
|
38
51
|
},
|
|
39
52
|
"files": [
|
|
53
|
+
"csp.json",
|
|
40
54
|
"dist",
|
|
41
55
|
"schema",
|
|
42
56
|
"src/virtual.d.ts",
|
|
@@ -48,25 +62,35 @@
|
|
|
48
62
|
"@types/react": "^18.3.31",
|
|
49
63
|
"@types/react-dom": "^18.3.7",
|
|
50
64
|
"@vitejs/plugin-react": "^6.3.0",
|
|
65
|
+
"semver": "^7.8.6",
|
|
51
66
|
"tailwindcss": "^3.4.19",
|
|
52
67
|
"typescript": "^6.0.3",
|
|
53
|
-
"vite": "^8.3.8",
|
|
54
68
|
"zod": "^4.6.7"
|
|
55
69
|
},
|
|
56
70
|
"peerDependencies": {
|
|
57
71
|
"@metacensus/library-ui": ">=0.6.0 <1",
|
|
58
72
|
"@tanstack/react-query": "^5",
|
|
73
|
+
"@tanstack/react-router": "^1",
|
|
59
74
|
"react": "^18.3.1",
|
|
60
|
-
"react-dom": "^18.3.1"
|
|
75
|
+
"react-dom": "^18.3.1",
|
|
76
|
+
"vite": "~8.3.8"
|
|
61
77
|
},
|
|
62
78
|
"devDependencies": {
|
|
79
|
+
"@eslint/js": "^9.39.5",
|
|
63
80
|
"@metacensus/library-ui": "^0.12.0",
|
|
64
81
|
"@tanstack/react-query": "^5.108.0",
|
|
82
|
+
"@tanstack/react-router": "^1.170.46",
|
|
65
83
|
"@types/jsdom": "^30.0.0",
|
|
66
84
|
"@types/node": "^24.19.2",
|
|
85
|
+
"@types/semver": "^7.8.0",
|
|
86
|
+
"eslint": "^9.39.5",
|
|
87
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
67
88
|
"jsdom": "^31.0.1",
|
|
89
|
+
"postcss": "^8.5.33",
|
|
68
90
|
"prettier": "^3.10.1",
|
|
69
91
|
"react": "^18.3.1",
|
|
70
|
-
"react-dom": "^18.3.1"
|
|
92
|
+
"react-dom": "^18.3.1",
|
|
93
|
+
"typescript-eslint": "^8.73.0",
|
|
94
|
+
"vite": "~8.3.8"
|
|
71
95
|
}
|
|
72
96
|
}
|
|
@@ -16,6 +16,17 @@
|
|
|
16
16
|
"type": "string",
|
|
17
17
|
"pattern": "^(?!\\/)(?!.*\\.\\.).+$"
|
|
18
18
|
}
|
|
19
|
+
},
|
|
20
|
+
"private": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"propertyNames": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"pattern": "^(?!corpus$)[a-z][A-Za-z0-9]*$"
|
|
25
|
+
},
|
|
26
|
+
"additionalProperties": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"pattern": "^(?!\\/)(?!.*\\.\\.).+$"
|
|
29
|
+
}
|
|
19
30
|
}
|
|
20
31
|
},
|
|
21
32
|
"required": [
|
package/src/virtual.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare module 'virtual:research-projects' {
|
|
2
|
-
import type {
|
|
2
|
+
import type { Routes } from '@metacensus/library-research'
|
|
3
3
|
|
|
4
|
-
type Root = () => Promise<{ default:
|
|
4
|
+
type Root = () => Promise<{ default: Routes }>
|
|
5
5
|
/** `local` only under `vite serve`, where `ui/local/index.tsx` exists. */
|
|
6
6
|
const projects: Record<string, { title: string; root: Root; local?: Root }>
|
|
7
7
|
export default projects
|
package/tsconfig.project.json
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
"target": "ES2022",
|
|
4
4
|
"module": "ESNext",
|
|
5
5
|
"moduleResolution": "Bundler",
|
|
6
|
-
"lib": ["ES2022", "DOM"],
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
"types": ["vite/client"],
|
|
9
9
|
"strict": true,
|
|
10
10
|
"noUncheckedIndexedAccess": true,
|
|
11
11
|
"isolatedModules": true,
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"erasableSyntaxOnly": true,
|
|
12
14
|
"skipLibCheck": true,
|
|
13
15
|
"noEmit": true
|
|
14
16
|
}
|