From e71c797f6597b480d6892facb0eb79f91e891af6 Mon Sep 17 00:00:00 2001 From: Juan Hoyos Date: Tue, 13 Aug 2024 14:33:36 -0500 Subject: [PATCH] chore: improves example index page --- index.html | 94 +++++++++++++++++++++++++++++++++++--------------- package.json | 1 + vite.config.ts | 63 +++++++++++++++++++++++++++++++++ yarn.lock | 17 +++++++++ 4 files changed, 148 insertions(+), 27 deletions(-) create mode 100644 vite.config.ts diff --git a/index.html b/index.html index a3ff4bae8..afe995e1f 100644 --- a/index.html +++ b/index.html @@ -1,29 +1,69 @@ - - - - - - + + + + + + + Examples Index + + + + +
+

Choose an example

+ front/VolumeMeasurement +front/LengthMeasurement +front/FaceMeasurement +front/EdgeMeasurement +front/AreaMeasurement +front/AngleMeasurement +front/Plans +front/IfcStreamer +front/Highlighter +front/ShadowDropper +front/PostproductionRenderer +front/Marker +front/ClipEdges +front/CivilPlanNavigator +front/CivilElevationNavigator +front/CivilCrossSectionNavigator +front/Civil3DNavigator +core/MeasurementUtils +core/IfcRelationsIndexer +core/IfcPropertiesManager +core/IfcJsonExporter +core/IfcPropertiesTiler +core/IfcLoader +core/IfcGeometryTiler +core/Hider +core/FragmentsManager +core/Exploder +core/Classifier +core/BoundingBoxer +core/Worlds +core/ShadowedScene +core/Raycasters +core/OrthoPerspectiveCamera +core/MiniMap +core/Grids +core/Cullers +core/Clipper - -

- If you're developing, append the package and component folder to the URL in order to see the example working without - compiling. For example: -

-

- To see the compiled example after you run yarn build, append the name of the component at the end of the URL. For - example: -

- - - - \ No newline at end of file +
+ + + + \ No newline at end of file diff --git a/package.json b/package.json index ae93c18a5..d2cc41ba0 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "./packages/*" ], "devDependencies": { + "@types/node": "latest", "@typescript-eslint/eslint-plugin": "7.2.0", "@typescript-eslint/parser": "7.2.0", "eslint": "8.57.0", diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 000000000..bf7d8e189 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,63 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import * as fs from "fs"; +import * as path from "path"; +import { defineConfig } from "vite"; +import { globSync } from "glob"; + +const writeIndexHTML = () => { + let links: string = ""; + const examplePaths = globSync("packages/**/src/**/example.html"); + for (const examplePath of examplePaths) { + const directory = path.dirname(examplePath); + const packageNameMatch = directory.match(/packages\\([^\\]+)/); + if (!(packageNameMatch && packageNameMatch.length > 1)) continue; + const packageName = packageNameMatch[1]; + const exampleName = path.basename(directory); + links += `${packageName}/${exampleName}\n`; + } + const index = ` + + + + + + + Examples Index + + + + +
+

Choose an example

+ ${links} +
+ + + + `; + fs.writeFileSync("./index.html", index); +}; + +const createIndex = () => ({ + name: "create-index", + configureServer() { + // fs.watch("./packages", { recursive: true }, writeIndexHTML); + writeIndexHTML(); + }, +}); + +export default defineConfig({ + plugins: [createIndex()], +}); diff --git a/yarn.lock b/yarn.lock index c0fc421dd..a230062ac 100644 --- a/yarn.lock +++ b/yarn.lock @@ -733,6 +733,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:latest": + version: 22.2.0 + resolution: "@types/node@npm:22.2.0" + dependencies: + undici-types: ~6.13.0 + checksum: 63724799337bfb57719a1992690e738341d824e1744a2ac52c5278a008fbfadf99765519c19858feb80418cc7da0d5c8bdf7ea4d82973869b3882bd602c48ade + languageName: node + linkType: hard + "@types/semver@npm:^7.5.0": version: 7.5.8 resolution: "@types/semver@npm:7.5.8" @@ -3614,6 +3623,7 @@ __metadata: version: 0.0.0-use.local resolution: "root-workspace-0b6124@workspace:." dependencies: + "@types/node": latest "@typescript-eslint/eslint-plugin": 7.2.0 "@typescript-eslint/parser": 7.2.0 eslint: 8.57.0 @@ -4159,6 +4169,13 @@ __metadata: languageName: node linkType: hard +"undici-types@npm:~6.13.0": + version: 6.13.0 + resolution: "undici-types@npm:6.13.0" + checksum: 9d0ef6bf58994bebbea6a4ab75f381c69a89a7ed151bfbae0d4ef95450d56502c9eccb323abf17b7d099c1d9c1cbae62e909e4dfeb8d204612d2f1fdada24707 + languageName: node + linkType: hard + "unique-filename@npm:^3.0.0": version: 3.0.0 resolution: "unique-filename@npm:3.0.0"