From 4bfe7ae5f73a0670ed50a7fdd7839c617004c9ab Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Tue, 6 Aug 2024 19:40:17 +0900 Subject: [PATCH] Add `@samchon/openapi` types to playground editor. --- website/build/raw.js | 32 +++++++++++++-------- website/package-lock.json | 9 +++--- website/package.json | 1 + website/src/compilers/TypeScriptCompiler.ts | 4 +-- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/website/build/raw.js b/website/build/raw.js index 578e41d162..046d7e41e1 100644 --- a/website/build/raw.js +++ b/website/build/raw.js @@ -1,25 +1,28 @@ const fs = require("fs"); +const emendName = (name) => + name.replaceAll("@", "_at_").replaceAll("/", "_slash_"); + const external = (container) => (config) => (lib) => { const write = (variable) => (file) => (content) => fs.writeFileSync( file, - `export const ${variable}: string = ${JSON.stringify(content)};`, + `export const ${variable.replace("@", "_dollar_")}: string = ${JSON.stringify(content)};`, "utf8", ); const packageJson = () => { const location = `${__dirname}/../node_modules/${lib}/package.json`; const directory = `${__dirname}/../raw/${lib}`; - fs.mkdirSync(directory); + fs.mkdirSync(directory, { recursive: true }); if (config.packageJson) { - write(`${lib}_packageJson`)(`${directory}/packageJson.ts`)( + write(`${emendName(lib)}_packageJson`)(`${directory}/packageJson.ts`)( fs.readFileSync(location, "utf8"), ); container.push({ format: "json", - name: `${lib}_packageJson`, + name: `${emendName(lib)}_packageJson`, import: `./${lib}/packageJson`, url: `file:///node_modules/${lib}/package.json`, }); @@ -40,7 +43,7 @@ const external = (container) => (config) => (lib) => { // CHECK DIRECTORY AND EXTENSION const stats = fs.statSync(from); if (stats.isDirectory()) { - fs.mkdirSync(link); + fs.mkdirSync(link, { recursive: true }); iterate(location); continue; } else if ( @@ -53,7 +56,7 @@ const external = (container) => (config) => (lib) => { // COPY TEXT FILE const extension = location.endsWith(".d.ts") ? ".d.ts" : ".js"; const alias = `${lib}/${location.replace(extension, extension === ".d.ts" ? "_d_ts" : "_js")}`; - const name = alias.split("/").join("_").split(".").join("_"); + const name = emendName(alias.split("/").join("_").split(".").join("_")); const content = fs.readFileSync(from, "utf8"); write(name)( link.replace(extension, extension === ".d.ts" ? "_d_ts.ts" : "_js.ts"), @@ -68,19 +71,19 @@ const external = (container) => (config) => (lib) => { }; return (path) => { if (path.length) { - fs.mkdirSync(`${__dirname}/../raw/${lib}/${path}`); + fs.mkdirSync(`${__dirname}/../raw/${lib}/${path}`, { recursive: true }); if (config.index) { - write(`${lib}_index`)(`${__dirname}/../raw/${lib}/index.ts`)( + write(`${emendName(lib)}_index`)(`${__dirname}/../raw/${lib}/index.ts`)( [ - `import * as ${lib} from "./${path}";`, + `import * as ${emendName(lib)} from "./${path}";`, `export * from "./${path}";`, - `export default ${lib};`, + `export default ${emendName(lib)};`, ].join("\n"), ); container.push({ format: "ts", import: `./${lib}/index`, - name: `${lib}_index`, + name: `${emendName(lib)}_index`, url: `file:///node_modules/${lib}/index.d.ts`, }); } @@ -92,7 +95,7 @@ const external = (container) => (config) => (lib) => { // PREPARE DIRECTORIES if (fs.existsSync(__dirname + "/../raw")) fs.rmSync(__dirname + "/../raw", { recursive: true }); -fs.mkdirSync(__dirname + "/../raw"); +fs.mkdirSync(__dirname + "/../raw", { recursive: true }); //---- // CLONE DEFINITIONS @@ -100,9 +103,14 @@ fs.mkdirSync(__dirname + "/../raw"); // CREATE RAW TEXT FILES const bucket = []; external(bucket)({ + index: true, packageJson: true, javaScript: false, +})("@samchon/openapi")("lib"); +external(bucket)({ index: true, + packageJson: true, + javaScript: false, })("typia")("lib"); external(bucket)({ packageJson: false, diff --git a/website/package-lock.json b/website/package-lock.json index de494ced3a..01dce12360 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -15,6 +15,7 @@ "@mui/icons-material": "^5.15.4", "@mui/material": "^5.12.0", "@rollup/browser": "^4.13.0", + "@samchon/openapi": "^0.4.3", "lz-string": "^1.5.0", "monaco-editor": "^0.50.0", "next": "^14.2.3", @@ -27,7 +28,7 @@ "tgrid": "^1.0.3", "tstl": "^3.0.0", "typescript": "^5.5.4", - "typia": "^6.7.0" + "typia": "^6.7.2" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.3.0", @@ -8872,9 +8873,9 @@ } }, "node_modules/typia": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/typia/-/typia-6.7.0.tgz", - "integrity": "sha512-lXipD7asf2TSYPAT8ZkTzcV5E7ophz2Q+TxD+8nQLb/v+Mzj4UxOAr7Twf7ODc4HXe80dfLPuf3amkqbLIvuSA==", + "version": "6.7.2", + "resolved": "https://registry.npmjs.org/typia/-/typia-6.7.2.tgz", + "integrity": "sha512-FP3VBdEu9yPFeUg4TYFKh055HNZJjQbr1WyWdyNjhG/Vb4TxRDtcx5v1JDqaje4XvJe8TGLeozH4QutQQUy8Sw==", "dependencies": { "@samchon/openapi": "^0.4.3", "commander": "^10.0.0", diff --git a/website/package.json b/website/package.json index ca7ec429f2..64e4a41a6c 100644 --- a/website/package.json +++ b/website/package.json @@ -26,6 +26,7 @@ "@mui/icons-material": "^5.15.4", "@mui/material": "^5.12.0", "@rollup/browser": "^4.13.0", + "@samchon/openapi": "^0.4.3", "lz-string": "^1.5.0", "monaco-editor": "^0.50.0", "next": "^14.2.3", diff --git a/website/src/compilers/TypeScriptCompiler.ts b/website/src/compilers/TypeScriptCompiler.ts index daaac290a5..1d51ddb3c0 100644 --- a/website/src/compilers/TypeScriptCompiler.ts +++ b/website/src/compilers/TypeScriptCompiler.ts @@ -50,9 +50,7 @@ export namespace TypeScriptCompiler { file.startsWith("node_modules/") && file.endsWith("/package.json") ? RAW.find((r) => r[0] === `file:///${file}`)![1] : undefined, - getSourceFile: (file: string) => { - return dict.get(file); - }, + getSourceFile: (file: string) => dict.get(file), // ADDITIONAL OPTIONS getDefaultLibFileName: () =>