@metacensus/library-research 0.0.0-stage → 0.8.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 +661 -0
- package/README.md +24 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +25 -0
- package/dist/commands/add.d.ts +1 -0
- package/dist/commands/add.js +46 -0
- package/dist/commands/check.d.ts +1 -0
- package/dist/commands/check.js +73 -0
- package/dist/commands/dev.d.ts +1 -0
- package/dist/commands/dev.js +140 -0
- package/dist/dev/host.d.ts +1 -0
- package/dist/dev/host.js +53 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/papers.d.ts +11 -0
- package/dist/papers.js +80 -0
- package/dist/react.d.ts +17 -0
- package/dist/react.js +73 -0
- package/dist/roles.d.ts +5 -0
- package/dist/roles.js +42 -0
- package/dist/root.d.ts +1 -0
- package/dist/root.js +9 -0
- package/dist/schema.d.ts +38 -0
- package/dist/schema.js +25 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.js +1 -0
- package/dist/vite-config.d.ts +2 -0
- package/dist/vite-config.js +33 -0
- package/dist/vite.d.ts +6 -0
- package/dist/vite.js +232 -0
- package/package.json +64 -4
- package/schema/corpus.schema.json +44 -0
- package/schema/kinds.json +14 -0
- package/schema/research.schema.json +26 -0
- package/src/virtual.d.ts +8 -0
- package/tsconfig.project.json +15 -0
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const kinds: {
|
|
3
|
+
readonly pdf: "application/pdf";
|
|
4
|
+
readonly doc: "application/msword";
|
|
5
|
+
readonly docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
6
|
+
readonly xls: "application/vnd.ms-excel";
|
|
7
|
+
readonly xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
8
|
+
readonly zip: "application/zip";
|
|
9
|
+
readonly gif: "image/gif";
|
|
10
|
+
readonly jpg: "image/jpeg";
|
|
11
|
+
readonly tif: "image/tiff";
|
|
12
|
+
readonly txt: "text/plain";
|
|
13
|
+
readonly html: "text/plain";
|
|
14
|
+
readonly xml: "text/plain";
|
|
15
|
+
};
|
|
16
|
+
export declare const Research: z.ZodObject<{
|
|
17
|
+
title: z.ZodString;
|
|
18
|
+
data: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export declare const Corpus: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
21
|
+
kind: z.ZodEnum<{
|
|
22
|
+
pdf: "pdf";
|
|
23
|
+
doc: "doc";
|
|
24
|
+
docx: "docx";
|
|
25
|
+
xls: "xls";
|
|
26
|
+
xlsx: "xlsx";
|
|
27
|
+
zip: "zip";
|
|
28
|
+
gif: "gif";
|
|
29
|
+
jpg: "jpg";
|
|
30
|
+
tif: "tif";
|
|
31
|
+
txt: "txt";
|
|
32
|
+
html: "html";
|
|
33
|
+
xml: "xml";
|
|
34
|
+
}>;
|
|
35
|
+
title: z.ZodOptional<z.ZodString>;
|
|
36
|
+
citation: z.ZodOptional<z.ZodString>;
|
|
37
|
+
open: z.ZodOptional<z.ZodLiteral<true>>;
|
|
38
|
+
}, z.core.$strict>>;
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const kinds = {
|
|
3
|
+
pdf: 'application/pdf',
|
|
4
|
+
doc: 'application/msword',
|
|
5
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
6
|
+
xls: 'application/vnd.ms-excel',
|
|
7
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
8
|
+
zip: 'application/zip',
|
|
9
|
+
gif: 'image/gif',
|
|
10
|
+
jpg: 'image/jpeg',
|
|
11
|
+
tif: 'image/tiff',
|
|
12
|
+
txt: 'text/plain',
|
|
13
|
+
html: 'text/plain',
|
|
14
|
+
xml: 'text/plain',
|
|
15
|
+
};
|
|
16
|
+
export const Research = z.strictObject({
|
|
17
|
+
title: z.string().min(1),
|
|
18
|
+
data: z.record(z.string().regex(/^(?!corpus$)[a-z][A-Za-z0-9]*$/), z.string().regex(/^(?!\/)(?!.*\.\.).+$/)),
|
|
19
|
+
});
|
|
20
|
+
export const Corpus = z.record(z.string().regex(/^[0-9a-f]{64}$/), z.strictObject({
|
|
21
|
+
kind: z.enum(Object.keys(kinds)),
|
|
22
|
+
title: z.string().optional(),
|
|
23
|
+
citation: z.string().optional(),
|
|
24
|
+
open: z.literal(true).optional(),
|
|
25
|
+
}));
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { Corpus as CorpusSchema, kinds } from './schema.js';
|
|
4
|
+
export type Project = ComponentType;
|
|
5
|
+
export interface Host {
|
|
6
|
+
reader: Reader;
|
|
7
|
+
base: string;
|
|
8
|
+
location: Location;
|
|
9
|
+
navigate(to: string, options?: {
|
|
10
|
+
replace?: boolean;
|
|
11
|
+
}): void;
|
|
12
|
+
data(role: string): string;
|
|
13
|
+
paper(sha: string): string;
|
|
14
|
+
}
|
|
15
|
+
export interface Reader {
|
|
16
|
+
username: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Location {
|
|
19
|
+
path: string;
|
|
20
|
+
search: string;
|
|
21
|
+
hash: string;
|
|
22
|
+
}
|
|
23
|
+
export type Kind = keyof typeof kinds;
|
|
24
|
+
export type Corpus = z.infer<typeof CorpusSchema>;
|
|
25
|
+
export type Paper = Corpus[string];
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import react from '@vitejs/plugin-react';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import tailwind from 'tailwindcss';
|
|
5
|
+
import { research, tailwindContent } from './vite.js';
|
|
6
|
+
export function hostConfig(root) {
|
|
7
|
+
const projects = { project: root };
|
|
8
|
+
const preset = createRequire(import.meta.url)('@metacensus/library-ui/tailwind3');
|
|
9
|
+
return {
|
|
10
|
+
root: join(root, 'ui'),
|
|
11
|
+
configFile: false,
|
|
12
|
+
plugins: [react(), research({ projects })],
|
|
13
|
+
css: {
|
|
14
|
+
postcss: {
|
|
15
|
+
plugins: [
|
|
16
|
+
tailwind({ presets: [preset], content: tailwindContent(projects) }),
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
// The kit's modules stay unbundled so the host and the project share one
|
|
21
|
+
// copy; Vite reads no imports inside node_modules, so theirs are listed.
|
|
22
|
+
optimizeDeps: {
|
|
23
|
+
include: [
|
|
24
|
+
'@metacensus/library-ui',
|
|
25
|
+
'@metacensus/library-ui/pdf',
|
|
26
|
+
'@tanstack/react-query',
|
|
27
|
+
'react-dom/client',
|
|
28
|
+
'zod',
|
|
29
|
+
],
|
|
30
|
+
exclude: ['@metacensus/library-research'],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Plugin } from 'vite';
|
|
2
|
+
/** Compiles each project, by slug and path from the Vite root, into the host. */
|
|
3
|
+
export declare function research({ projects, }: {
|
|
4
|
+
projects: Record<string, string>;
|
|
5
|
+
}): Plugin[];
|
|
6
|
+
export declare function tailwindContent(projects: Record<string, string>): string[];
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, realpathSync, statSync, } from 'node:fs';
|
|
2
|
+
import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { isCSSRequest, preprocessCSS, searchForWorkspaceRoot, } from 'vite';
|
|
4
|
+
import { project } from './roles.js';
|
|
5
|
+
const prefix = 'projects';
|
|
6
|
+
const dataPath = new RegExp(`^${prefix}/([^/]+)/data/([^/]+)\\.json$`);
|
|
7
|
+
const virtual = 'virtual:research-projects';
|
|
8
|
+
const cssImport = /@(?:import|use|forward)\b/;
|
|
9
|
+
const cssComposes = /\bcomposes\s*:[^;}]*?\bfrom\s+(['"])([^'"]+)\1/g;
|
|
10
|
+
const canary = (slug) => `research-canary:${slug}`;
|
|
11
|
+
const cssCode = (id) => isCSSRequest(id) && !/[?&](?:worker|sharedworker|raw|url)\b/.test(id);
|
|
12
|
+
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
13
|
+
const inside = (path, dir) => (path + sep).startsWith(dir + sep);
|
|
14
|
+
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
15
|
+
const shared = [pkg.name, ...Object.keys(pkg.peerDependencies)];
|
|
16
|
+
/** Compiles each project, by slug and path from the Vite root, into the host. */
|
|
17
|
+
export function research({ projects, }) {
|
|
18
|
+
let config;
|
|
19
|
+
let dirs = [];
|
|
20
|
+
const owner = (file) => dirs.find(([, dir]) => inside(file, dir))?.[0];
|
|
21
|
+
const scope = (files) => {
|
|
22
|
+
const owned = files.filter(owner).sort();
|
|
23
|
+
const slugs = [...new Set(owned.map(owner))];
|
|
24
|
+
if (slugs.length > 1)
|
|
25
|
+
throw new Error(`${owned.join(', ')}: mixes ${slugs.join(' and ')}`);
|
|
26
|
+
return slugs[0];
|
|
27
|
+
};
|
|
28
|
+
const place = (files, pattern, info) => {
|
|
29
|
+
const slug = scope(files);
|
|
30
|
+
const name = typeof pattern === 'string' ? pattern : pattern(info);
|
|
31
|
+
return slug ? `${prefix}/${slug}/assets/${basename(name)}` : name;
|
|
32
|
+
};
|
|
33
|
+
const sources = (asset) => asset.originalFileNames.map((file) => resolve(config.root, file));
|
|
34
|
+
/**
|
|
35
|
+
* Marks each project module for the output scan, before vite:css-post
|
|
36
|
+
* while CSS is still CSS, and there as a rule: CSS minifiers drop comments.
|
|
37
|
+
*/
|
|
38
|
+
const stamp = {
|
|
39
|
+
name: 'research:canary',
|
|
40
|
+
transform(code, id) {
|
|
41
|
+
const slug = owner(id);
|
|
42
|
+
if (!slug || config.command === 'serve')
|
|
43
|
+
return;
|
|
44
|
+
const mark = cssCode(id)
|
|
45
|
+
? `research-canary{--${canary(slug)}}`
|
|
46
|
+
: `/*! ${canary(slug)} */`;
|
|
47
|
+
return { code: `${code}\n${mark}`, map: null };
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
name: 'research',
|
|
53
|
+
config(user) {
|
|
54
|
+
const from = resolve(user.root ?? '');
|
|
55
|
+
dirs = Object.entries(projects).map(([slug, path]) => [
|
|
56
|
+
slug,
|
|
57
|
+
realpathSync(resolve(from, path)),
|
|
58
|
+
]);
|
|
59
|
+
return {
|
|
60
|
+
resolve: { dedupe: shared },
|
|
61
|
+
worker: {
|
|
62
|
+
plugins: () => [...(user.worker?.plugins?.() ?? []), stamp],
|
|
63
|
+
},
|
|
64
|
+
server: {
|
|
65
|
+
fs: {
|
|
66
|
+
allow: [searchForWorkspaceRoot(from), ...dirs.map(([, d]) => d)],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
configResolved(resolved) {
|
|
72
|
+
config = resolved;
|
|
73
|
+
},
|
|
74
|
+
resolveId: (id) => (id === virtual ? '\0' + virtual : undefined),
|
|
75
|
+
load(id) {
|
|
76
|
+
if (id !== '\0' + virtual)
|
|
77
|
+
return;
|
|
78
|
+
const loader = (file) => `() => import(${JSON.stringify(file)})`;
|
|
79
|
+
const entries = dirs.map(([slug, dir]) => {
|
|
80
|
+
const local = join(dir, 'ui/local/index.tsx');
|
|
81
|
+
const fields = [
|
|
82
|
+
`title: ${JSON.stringify(project(dir).title)}`,
|
|
83
|
+
`root: ${loader(join(dir, 'ui/index.tsx'))}`,
|
|
84
|
+
...(config.command === 'serve' && existsSync(local)
|
|
85
|
+
? [`local: ${loader(local)}`]
|
|
86
|
+
: []),
|
|
87
|
+
];
|
|
88
|
+
return `${JSON.stringify(slug)}: { ${fields.join(', ')} }`;
|
|
89
|
+
});
|
|
90
|
+
return `export default { ${entries.join(', ')} }`;
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
stamp,
|
|
94
|
+
{
|
|
95
|
+
name: 'research:checks',
|
|
96
|
+
apply: 'build',
|
|
97
|
+
configResolved({ build, publicDir }) {
|
|
98
|
+
const fail = (why) => {
|
|
99
|
+
throw new Error(`research() ${why}`);
|
|
100
|
+
};
|
|
101
|
+
if (build.minify !== 'oxc')
|
|
102
|
+
fail('needs the default build.minify, which keeps its canary');
|
|
103
|
+
if (!build.cssCodeSplit)
|
|
104
|
+
fail("needs build.cssCodeSplit, to keep each project's CSS apart");
|
|
105
|
+
if ([build.rolldownOptions.output].flat().some((o) => o?.manualChunks))
|
|
106
|
+
fail('refuses manualChunks, which can mix host and project modules');
|
|
107
|
+
const pub = existsSync(publicDir) && realpathSync(publicDir);
|
|
108
|
+
if (pub && dirs.some(([, dir]) => inside(pub, dir) || inside(dir, pub)))
|
|
109
|
+
fail(`refuses publicDir ${pub}, which would copy a project whole`);
|
|
110
|
+
},
|
|
111
|
+
resolveId: {
|
|
112
|
+
order: 'pre',
|
|
113
|
+
async handler(source, importer, options) {
|
|
114
|
+
if (!importer || importer === '\0' + virtual || owner(importer))
|
|
115
|
+
return;
|
|
116
|
+
const resolved = await this.resolve(source, importer, {
|
|
117
|
+
...options,
|
|
118
|
+
skipSelf: true,
|
|
119
|
+
});
|
|
120
|
+
if (resolved && owner(resolved.id))
|
|
121
|
+
this.error(`${importer}: imports ${resolved.id}, inside a project`);
|
|
122
|
+
return resolved;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
transform: {
|
|
126
|
+
order: 'pre',
|
|
127
|
+
// Vite inlines CSS @import and composes without asking plugins to resolve them.
|
|
128
|
+
async handler(code, id) {
|
|
129
|
+
if (owner(id) || !isCSSRequest(id))
|
|
130
|
+
return;
|
|
131
|
+
const file = id.split('?')[0];
|
|
132
|
+
const reached = [...code.matchAll(cssComposes)].map(([, , from]) => resolve(dirname(file), from));
|
|
133
|
+
if (cssImport.test(code)) {
|
|
134
|
+
const { deps = [] } = await preprocessCSS(code, file, config);
|
|
135
|
+
reached.push(...[...deps].filter(isCSSRequest));
|
|
136
|
+
}
|
|
137
|
+
if (reached.some(owner))
|
|
138
|
+
this.error(`${id}: imports ${reached.filter(owner).join(', ')}, inside a project`);
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'research:build',
|
|
144
|
+
apply: 'build',
|
|
145
|
+
enforce: 'post',
|
|
146
|
+
buildStart() {
|
|
147
|
+
for (const [slug, dir] of dirs)
|
|
148
|
+
for (const [role, json] of Object.entries(project(dir).roles))
|
|
149
|
+
this.emitFile({
|
|
150
|
+
type: 'asset',
|
|
151
|
+
fileName: `${prefix}/${slug}/data/${role}.json`,
|
|
152
|
+
source: JSON.stringify(json()),
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
buildEnd() {
|
|
156
|
+
const local = dirs.map(([, dir]) => join(dir, 'ui/local') + sep);
|
|
157
|
+
for (const id of this.getModuleIds())
|
|
158
|
+
if (local.some((dir) => id.startsWith(dir)))
|
|
159
|
+
this.error(`${id}: imported by ${this.getModuleInfo(id)?.importers.join(', ')}, under ui/local/`);
|
|
160
|
+
},
|
|
161
|
+
outputOptions(options) {
|
|
162
|
+
const chunks = options.chunkFileNames ?? '[name]-[hash].js';
|
|
163
|
+
const assets = options.assetFileNames ?? '[name]-[hash][extname]';
|
|
164
|
+
const comments = options.comments;
|
|
165
|
+
return {
|
|
166
|
+
...options,
|
|
167
|
+
// Minifying drops legal comments, the JS canary among them, by default.
|
|
168
|
+
comments: {
|
|
169
|
+
...(typeof comments === 'object' && comments),
|
|
170
|
+
legal: true,
|
|
171
|
+
},
|
|
172
|
+
chunkFileNames: (chunk) => place(chunk.moduleIds, chunks, chunk),
|
|
173
|
+
assetFileNames: (asset) => place(sources(asset), assets, asset),
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
/** Rolldown merges a byte-identical asset into one it already named. */
|
|
177
|
+
generateBundle(_options, bundle) {
|
|
178
|
+
for (const file of Object.values(bundle))
|
|
179
|
+
if (file.type === 'asset')
|
|
180
|
+
scope(sources(file));
|
|
181
|
+
},
|
|
182
|
+
writeBundle({ dir: out = '' }) {
|
|
183
|
+
const marks = dirs.map(([slug, dir]) => {
|
|
184
|
+
const mark = canary(escape(slug)).replace(':', ':\\s*');
|
|
185
|
+
const ui = relative(config.root, dir).replace(/^(\.\.\/)+/, '') + '/ui/';
|
|
186
|
+
const paths = `${escape(dir + sep)}|(?:^|[^\\w.-])${escape(ui)}`;
|
|
187
|
+
return [slug, new RegExp(`${mark}(?![\\w-])|${paths}`)];
|
|
188
|
+
});
|
|
189
|
+
for (const file of readdirSync(out, {
|
|
190
|
+
recursive: true,
|
|
191
|
+
encoding: 'utf8',
|
|
192
|
+
})) {
|
|
193
|
+
const path = join(out, file);
|
|
194
|
+
if (!statSync(path).isFile())
|
|
195
|
+
continue;
|
|
196
|
+
const text = readFileSync(path, 'utf8');
|
|
197
|
+
for (const [slug, mark] of marks)
|
|
198
|
+
if (!inside(file, `${prefix}/${slug}`) && mark.test(text))
|
|
199
|
+
this.error(`${file}: holds project ${slug}, outside ${prefix}/${slug}/`);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'research:serve',
|
|
205
|
+
apply: 'serve',
|
|
206
|
+
configureServer(server) {
|
|
207
|
+
server.middlewares.use((req, res, next) => {
|
|
208
|
+
const path = req.url?.split('?')[0] ?? '';
|
|
209
|
+
const [, slug, role = ''] = (path.startsWith(config.base) &&
|
|
210
|
+
path.slice(config.base.length).match(dataPath)) ||
|
|
211
|
+
[];
|
|
212
|
+
const dir = dirs.find(([s]) => s === slug)?.[1];
|
|
213
|
+
if (!dir)
|
|
214
|
+
return next();
|
|
215
|
+
const { roles } = project(dir);
|
|
216
|
+
if (!Object.hasOwn(roles, role)) {
|
|
217
|
+
res.statusCode = 404;
|
|
218
|
+
return res.end(`${slug} has no role "${role}"`);
|
|
219
|
+
}
|
|
220
|
+
res.setHeader('Content-Type', 'application/json');
|
|
221
|
+
res.end(JSON.stringify(roles[role]()));
|
|
222
|
+
});
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
];
|
|
226
|
+
}
|
|
227
|
+
export function tailwindContent(projects) {
|
|
228
|
+
return Object.values(projects).flatMap((path) => [
|
|
229
|
+
`${path}/ui/**/*.{ts,tsx}`,
|
|
230
|
+
`!${path}/ui/node_modules/**`,
|
|
231
|
+
]);
|
|
232
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metacensus/library-research",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"license": "AGPL-3.0-only",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/metacensus/library-research.git"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=24"
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"library-research": "./dist/cli.js"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./schema": {
|
|
22
|
+
"types": "./dist/schema.d.ts",
|
|
23
|
+
"default": "./dist/schema.js"
|
|
24
|
+
},
|
|
25
|
+
"./schema/*.json": "./schema/*.json",
|
|
26
|
+
"./vite": {
|
|
27
|
+
"types": "./dist/vite.d.ts",
|
|
28
|
+
"default": "./dist/vite.js"
|
|
29
|
+
},
|
|
30
|
+
"./virtual": {
|
|
31
|
+
"types": "./src/virtual.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./tsconfig.json": "./tsconfig.project.json"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"schema",
|
|
38
|
+
"src/virtual.d.ts",
|
|
39
|
+
"tsconfig.project.json"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@types/react": "^18.3.31",
|
|
43
|
+
"@types/react-dom": "^18.3.7",
|
|
44
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
45
|
+
"tailwindcss": "^3.4.19",
|
|
46
|
+
"typescript": "^6.0.3",
|
|
47
|
+
"vite": "^8.3.8",
|
|
48
|
+
"zod": "^4.6.7"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@metacensus/library-ui": ">=0.6.0 <1",
|
|
52
|
+
"@tanstack/react-query": "^5",
|
|
53
|
+
"react": "^18.3.1",
|
|
54
|
+
"react-dom": "^18.3.1"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@metacensus/library-ui": "^0.6.0",
|
|
58
|
+
"@tanstack/react-query": "^5.108.0",
|
|
59
|
+
"@types/jsdom": "^30.0.0",
|
|
60
|
+
"@types/node": "^24.19.2",
|
|
61
|
+
"jsdom": "^31.0.1",
|
|
62
|
+
"prettier": "^3.10.1",
|
|
63
|
+
"react": "^18.3.1",
|
|
64
|
+
"react-dom": "^18.3.1"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"propertyNames": {
|
|
5
|
+
"type": "string",
|
|
6
|
+
"pattern": "^[0-9a-f]{64}$"
|
|
7
|
+
},
|
|
8
|
+
"additionalProperties": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"kind": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"enum": [
|
|
14
|
+
"pdf",
|
|
15
|
+
"doc",
|
|
16
|
+
"docx",
|
|
17
|
+
"xls",
|
|
18
|
+
"xlsx",
|
|
19
|
+
"zip",
|
|
20
|
+
"gif",
|
|
21
|
+
"jpg",
|
|
22
|
+
"tif",
|
|
23
|
+
"txt",
|
|
24
|
+
"html",
|
|
25
|
+
"xml"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"title": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"citation": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"open": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"const": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"required": [
|
|
40
|
+
"kind"
|
|
41
|
+
],
|
|
42
|
+
"additionalProperties": false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pdf": "application/pdf",
|
|
3
|
+
"doc": "application/msword",
|
|
4
|
+
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
5
|
+
"xls": "application/vnd.ms-excel",
|
|
6
|
+
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
7
|
+
"zip": "application/zip",
|
|
8
|
+
"gif": "image/gif",
|
|
9
|
+
"jpg": "image/jpeg",
|
|
10
|
+
"tif": "image/tiff",
|
|
11
|
+
"txt": "text/plain",
|
|
12
|
+
"html": "text/plain",
|
|
13
|
+
"xml": "text/plain"
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"title": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"minLength": 1
|
|
8
|
+
},
|
|
9
|
+
"data": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"propertyNames": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"pattern": "^(?!corpus$)[a-z][A-Za-z0-9]*$"
|
|
14
|
+
},
|
|
15
|
+
"additionalProperties": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"pattern": "^(?!\\/)(?!.*\\.\\.).+$"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": [
|
|
22
|
+
"title",
|
|
23
|
+
"data"
|
|
24
|
+
],
|
|
25
|
+
"additionalProperties": false
|
|
26
|
+
}
|
package/src/virtual.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare module 'virtual:research-projects' {
|
|
2
|
+
import type { Project } from '@metacensus/library-research'
|
|
3
|
+
|
|
4
|
+
type Root = () => Promise<{ default: Project }>
|
|
5
|
+
/** `local` only under `vite serve`, where `ui/local/index.tsx` exists. */
|
|
6
|
+
const projects: Record<string, { title: string; root: Root; local?: Root }>
|
|
7
|
+
export default projects
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"types": ["vite/client"],
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noUncheckedIndexedAccess": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"noEmit": true
|
|
14
|
+
}
|
|
15
|
+
}
|