tangled
alpha
login
or
join now
tylur.dev
/
prototypey
prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey
1
fork
atom
overview
issues
pulls
pipelines
fixed .d.ts
Tyler
3 months ago
c6156874
678fed17
+8
-38
3 changed files
expand all
collapse all
unified
split
packages
prototypey
package.json
site
src
components
Editor.tsx
vite.config.ts
+1
-2
packages/prototypey/package.json
···
16
16
"main": "lib/index.js",
17
17
"exports": {
18
18
".": "./lib/index.js",
19
19
-
"./infer": "./lib/infer.js",
20
20
-
"./lib/lib.d.ts": "./lib/lib.d.ts"
19
19
+
"./lib/*.d.ts": "./lib/*.d.ts"
21
20
},
22
21
"files": [
23
22
"lib/",
+7
-7
packages/site/src/components/Editor.tsx
···
55
55
});
56
56
57
57
Promise.all([
58
58
-
fetch("/types/type-utils.d.ts").then((r) => r.text()),
59
59
-
fetch("/types/infer.d.ts").then((r) => r.text()),
60
60
-
fetch("/types/lib.d.ts").then((r) => r.text()),
61
61
-
]).then(([typeUtilsDts, inferDts, libDts]) => {
58
58
+
import("prototypey/lib/type-utils.d.ts?raw"),
59
59
+
import("prototypey/lib/infer.d.ts?raw"),
60
60
+
import("prototypey/lib/lib.d.ts?raw"),
61
61
+
]).then(([typeUtilsModule, inferModule, libModule]) => {
62
62
const stripImportsExports = (content: string) =>
63
63
content
64
64
.replace(/import\s+{[^}]*}\s+from\s+['""][^'"]*['""];?\s*/g, "")
···
70
70
.replace(/\/\/#endregion.*\n?/g, "");
71
71
72
72
const combinedTypes = `
73
73
-
${stripImportsExports(typeUtilsDts)}
74
74
-
${stripImportsExports(inferDts)}
75
75
-
${stripImportsExports(libDts)}
73
73
+
${stripImportsExports(typeUtilsModule.default)}
74
74
+
${stripImportsExports(inferModule.default)}
75
75
+
${stripImportsExports(libModule.default)}
76
76
`;
77
77
78
78
const moduleDeclaration = `declare module "prototypey" {
-29
packages/site/vite.config.ts
···
1
1
import { defineConfig } from "vite";
2
2
import react from "@vitejs/plugin-react";
3
3
-
import { readFileSync } from "fs";
4
4
-
import { resolve } from "path";
5
5
-
6
6
-
// TODO replace this, it's gross and idek if it's being used
7
7
-
function servePrototypeyTypes() {
8
8
-
return {
9
9
-
name: "serve-prototypey-types",
10
10
-
configureServer(server) {
11
11
-
server.middlewares.use((req, res, next) => {
12
12
-
if (req.url?.startsWith("/types/") && req.url.endsWith(".d.ts")) {
13
13
-
const fileName = req.url.slice(7);
14
14
-
try {
15
15
-
const filePath = resolve(__dirname, "../prototypey/lib", fileName);
16
16
-
const content = readFileSync(filePath, "utf-8");
17
17
-
res.setHeader("Content-Type", "application/typescript");
18
18
-
res.end(content);
19
19
-
return;
20
20
-
} catch (e) {
21
21
-
res.statusCode = 404;
22
22
-
res.end("Type file not found");
23
23
-
return;
24
24
-
}
25
25
-
}
26
26
-
next();
27
27
-
});
28
28
-
},
29
29
-
};
30
30
-
}
31
3
32
4
export default defineConfig({
33
5
plugins: [
···
36
8
plugins: [["babel-plugin-react-compiler", {}]],
37
9
},
38
10
}),
39
39
-
servePrototypeyTypes(),
40
11
],
41
12
});