prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey

fixed .d.ts

Tyler c6156874 678fed17

+8 -38
+1 -2
packages/prototypey/package.json
··· 16 16 "main": "lib/index.js", 17 17 "exports": { 18 18 ".": "./lib/index.js", 19 - "./infer": "./lib/infer.js", 20 - "./lib/lib.d.ts": "./lib/lib.d.ts" 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 - fetch("/types/type-utils.d.ts").then((r) => r.text()), 59 - fetch("/types/infer.d.ts").then((r) => r.text()), 60 - fetch("/types/lib.d.ts").then((r) => r.text()), 61 - ]).then(([typeUtilsDts, inferDts, libDts]) => { 58 + import("prototypey/lib/type-utils.d.ts?raw"), 59 + import("prototypey/lib/infer.d.ts?raw"), 60 + import("prototypey/lib/lib.d.ts?raw"), 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 - ${stripImportsExports(typeUtilsDts)} 74 - ${stripImportsExports(inferDts)} 75 - ${stripImportsExports(libDts)} 73 + ${stripImportsExports(typeUtilsModule.default)} 74 + ${stripImportsExports(inferModule.default)} 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 - import { readFileSync } from "fs"; 4 - import { resolve } from "path"; 5 - 6 - // TODO replace this, it's gross and idek if it's being used 7 - function servePrototypeyTypes() { 8 - return { 9 - name: "serve-prototypey-types", 10 - configureServer(server) { 11 - server.middlewares.use((req, res, next) => { 12 - if (req.url?.startsWith("/types/") && req.url.endsWith(".d.ts")) { 13 - const fileName = req.url.slice(7); 14 - try { 15 - const filePath = resolve(__dirname, "../prototypey/lib", fileName); 16 - const content = readFileSync(filePath, "utf-8"); 17 - res.setHeader("Content-Type", "application/typescript"); 18 - res.end(content); 19 - return; 20 - } catch (e) { 21 - res.statusCode = 404; 22 - res.end("Type file not found"); 23 - return; 24 - } 25 - } 26 - next(); 27 - }); 28 - }, 29 - }; 30 - } 31 3 32 4 export default defineConfig({ 33 5 plugins: [ ··· 36 8 plugins: [["babel-plugin-react-compiler", {}]], 37 9 }, 38 10 }), 39 - servePrototypeyTypes(), 40 11 ], 41 12 });