@metabase/custom-viz 0.0.1-alpha.6 → 0.0.1-alpha.8
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/dist/cli.js +42 -38
- package/dist/column-types.d.ts.map +1 -1
- package/dist/lib/defineSetting.d.ts +4 -3
- package/dist/lib/defineSetting.d.ts.map +1 -1
- package/dist/templates/index.tsx +66 -63
- package/dist/templates/package-lock.json +939 -0
- package/dist/templates/vite.config.ts +28 -14
- package/dist/types/date-time.d.ts +1 -1
- package/dist/types/date-time.d.ts.map +1 -1
- package/dist/types/viz-settings.d.ts +1 -1
- package/dist/types/viz-settings.d.ts.map +1 -1
- package/dist/types/viz.d.ts +3 -8
- package/dist/types/viz.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6,37 +6,40 @@ import { createInterface as o } from "node:readline";
|
|
|
6
6
|
import { Command as s } from "commander";
|
|
7
7
|
import { fileURLToPath as c } from "node:url";
|
|
8
8
|
//#region package.json
|
|
9
|
-
var l = "0.0.1-alpha.6", u = "node_modules/\n.DS_Store\n# dist must be committed\n", d = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M1.79978 6.86661C1.65041 7.01583 1.53192 7.19302 1.45107 7.38806C1.37023 7.58309 1.32861 7.79215 1.32861 8.00328C1.32861 8.21441 1.37023 8.42347 1.45107 8.61851C1.53192 8.81354 1.65041 8.99073 1.79978 9.13995L6.85978 14.1999C7.00899 14.3493 7.18618 14.4678 7.38122 14.5487C7.57626 14.6295 7.78531 14.6711 7.99644 14.6711C8.20757 14.6711 8.41663 14.6295 8.61167 14.5487C8.80671 14.4678 8.9839 14.3493 9.13311 14.1999L14.1931 9.13995C14.3425 8.99073 14.461 8.81354 14.5418 8.61851C14.6227 8.42347 14.6643 8.21441 14.6643 8.00328C14.6643 7.79215 14.6227 7.58309 14.5418 7.38806C14.461 7.19302 14.3425 7.01583 14.1931 6.86661L9.13311 1.80661C8.9839 1.65725 8.80671 1.53875 8.61167 1.45791C8.41663 1.37706 8.20757 1.33545 7.99644 1.33545C7.78531 1.33545 7.57626 1.37706 7.38122 1.45791C7.18618 1.53875 7.00899 1.65725 6.85978 1.80661L1.79978 6.86661Z\" stroke=\"white\" stroke-width=\"1.33333\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n", f = "import type {\n CreateCustomVisualization,\n CustomStaticVisualizationProps,\n CustomVisualizationProps,\n} from \"@metabase/custom-viz\";\n\ntype Settings = {\n threshold?: number;\n};\n\nconst createVisualization: CreateCustomVisualization<Settings> = ({\n getAssetUrl,\n}) => {\n return {\n id: \"__CUSTOM_VIZ_NAME__\",\n getName: () => \"__CUSTOM_VIZ_NAME__\",\n minSize: { width: 1, height: 1 },\n defaultSize: { width: 2, height: 2 },\n isSensible({ cols, rows }) {\n return cols.length === 1 && rows.length === 1 && typeof rows[0][0] === \"number\";\n },\n checkRenderable(series, settings) {\n if (series.length !== 1) {\n throw new Error(\"Only 1 series is supported\");\n }\n\n const [\n {\n data: { cols, rows },\n },\n ] = series;\n\n if (cols.length !== 1) {\n throw new Error(\"Query results should only have 1 column\");\n }\n\n if (rows.length !== 1) {\n throw new Error(\"Query results should only have 1 row\");\n }\n\n if (typeof rows[0][0] !== \"number\") {\n throw new Error(\"Result is not a number\");\n }\n\n if (typeof settings.threshold !== \"number\") {\n throw new Error(\"Threshold setting is not set\");\n }\n },\n settings: {\n threshold: {\n id: \"1\",\n title: \"Threshold\",\n widget: \"number\",\n getDefault() {\n return 0;\n },\n getProps() {\n return {\n options: {\n isInteger: false,\n isNonNegative: false,\n },\n placeholder: \"Set threshold\",\n };\n },\n },\n },\n VisualizationComponent: makeVisualizationComponent(getAssetUrl),\n StaticVisualizationComponent: makeStaticVisualizationComponent(getAssetUrl),\n };\n};\n\nconst makeVisualizationComponent = (getAssetUrl: (path: string) => string) => (props: CustomVisualizationProps<Settings>) => {\n const { height, series, settings, width } = props;\n const { threshold } = settings;\n const value = series[0].data.rows[0][0];\n\n if (typeof value !== \"number\" || typeof threshold !== \"number\") {\n throw new Error(\"Value and threshold need to be numbers\");\n }\n\n const emoji = value >= threshold ? \"👍\" : \"👎\";\n\n return (\n <div\n style={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n width,\n height,\n fontSize: \"10rem\",\n }}\n >\n {emoji}\n </div>\n );\n};\n\nconst makeStaticVisualizationComponent = (getAssetUrl: (path: string) => string) => (\n props: CustomStaticVisualizationProps<Settings>,\n) => {\n const width = 540;\n const height = 360;\n const { series, settings } = props;\n const { threshold } = settings;\n const value = series[0].data.rows[0][0];\n\n if (typeof value !== \"number\" || typeof threshold !== \"number\") {\n throw new Error(\"Value and threshold need to be numbers\");\n }\n\n const emoji =\n value >= threshold ? (\n <img src={getAssetUrl(\"thumbs-up.png\")} />\n ) : (\n <img src={getAssetUrl(\"thumbs-down.png\")} />\n );\n\n return (\n <div\n style={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n width,\n height,\n fontSize: \"10rem\",\n }}\n >\n {emoji}\n </div>\n );\n};\n\nexport default createVisualization;\n", p = "{\n \"name\": \"__CUSTOM_VIZ_NAME__\",\n \"icon\": \"icon.svg\",\n \"assets\": [\"icon.svg\", \"thumbs-up.png\", \"thumbs-down.png\"],\n \"metabase\": {\n \"version\": \">=59\"\n }\n}\n", m = "{\n \"name\": \"__CUSTOM_VIZ_NAME__\",\n \"version\": \"0.0.1\",\n \"private\": true,\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"vite build\",\n \"dev\": \"vite build --watch\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@metabase/custom-viz\": \"__CUSTOM_VIZ_VERSION__\",\n \"@types/react\": \"^19.2.14\",\n \"react\": \"^19.1.0\",\n \"typescript\": \"^5.9.3\",\n \"vite\": \"^8.0.0\"\n }\n}\n", h = "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"module\": \"ESNext\",\n \"moduleResolution\": \"bundler\",\n \"jsx\": \"react-jsx\",\n \"strict\": true,\n \"esModuleInterop\": true,\n \"skipLibCheck\": true,\n \"outDir\": \"dist\",\n \"declaration\": true\n },\n \"include\": [\"src\"]\n}\n", g = "import { resolve } from \"path\";\nimport { createServer } from \"http\";\nimport { watch, cpSync, existsSync } from \"fs\";\nimport { defineConfig } from \"vite\";\n\n/**\n * Vite plugin that replaces `react` and `react/jsx-runtime` imports with\n * virtual modules that read from Metabase's `window.__METABASE_VIZ_API__`.\n *\n * This is necessary because the ES module output format cannot use\n * `output.globals`, and bare `import 'react'` would fail in the browser.\n */\nfunction metabaseVizExternals() {\n const VIRTUAL_REACT = \"\\0virtual:react\";\n const VIRTUAL_JSX_RUNTIME = \"\\0virtual:react/jsx-runtime\";\n return {\n name: \"metabase-viz-externals\",\n enforce: \"pre\" as const,\n\n resolveId(source) {\n if (source === \"react\") {\n return VIRTUAL_REACT;\n }\n if (source === \"react/jsx-runtime\") {\n return VIRTUAL_JSX_RUNTIME;\n }\n return null;\n },\n\n load(id) {\n if (id === VIRTUAL_REACT) {\n return [\n \"const React = window.__METABASE_VIZ_API__.React;\",\n \"export default React;\",\n \"export const { useState, useEffect, useRef, useCallback, useMemo, useReducer, useContext, createElement, Fragment } = React;\",\n ].join(\"\\n\");\n }\n if (id === VIRTUAL_JSX_RUNTIME) {\n return [\n \"const jsxRuntime = window.__METABASE_VIZ_API__.jsxRuntime;\",\n \"export const { jsx, jsxs, Fragment } = jsxRuntime;\",\n ].join(\"\\n\");\n }\n return null;\n },\n };\n}\n\nconst DEV_PORT = 5174;\n\n/**\n * Vite plugin that starts a dev server serving both static files from dist/\n * and an SSE endpoint at /__sse for hot-reload notifications.\n * Metabase's frontend connects to /__sse on the same origin as dev_bundle_url.\n */\nfunction metabaseDevServer() {\n const clients = new Set<import(\"http\").ServerResponse>();\n let server: ReturnType<typeof createServer> | null = null;\n\n return {\n name: \"metabase-dev-server\",\n\n buildStart() {\n if (server) {\n return;\n }\n\n const distDir = resolve(__dirname, \"dist\");\n\n server = createServer((req, res) => {\n const url = req.url ?? \"/\";\n\n // SSE endpoint for hot-reload\n if (url === \"/__sse\") {\n res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n \"Access-Control-Allow-Origin\": \"*\",\n });\n clients.add(res);\n req.on(\"close\", () => clients.delete(res));\n return;\n }\n\n // CORS headers for all static responses\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n\n // Serve static files from dist/\n const { readFile, stat } = require(\"fs\");\n const { join, extname } = require(\"path\");\n\n const filePath = url === \"/\" ? join(distDir, \"index.html\") : join(distDir, url);\n\n // Prevent directory traversal\n if (!filePath.startsWith(distDir)) {\n res.writeHead(403);\n res.end(\"Forbidden\");\n return;\n }\n\n stat(filePath, (err: NodeJS.ErrnoException | null) => {\n if (err) {\n res.writeHead(404);\n res.end(\"Not found\");\n return;\n }\n\n const mimeTypes: Record<string, string> = {\n \".html\": \"text/html\",\n \".js\": \"application/javascript\",\n \".css\": \"text/css\",\n \".json\": \"application/json\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".svg\": \"image/svg+xml\",\n \".ico\": \"image/x-icon\",\n };\n const contentType = mimeTypes[extname(filePath)] ?? \"application/octet-stream\";\n\n readFile(filePath, (readErr: NodeJS.ErrnoException | null, data: Buffer) => {\n if (readErr) {\n res.writeHead(500);\n res.end(\"Internal server error\");\n return;\n }\n res.writeHead(200, { \"Content-Type\": contentType });\n res.end(data);\n });\n });\n });\n\n server.listen(DEV_PORT, () => {\n console.log(\n `[custom-viz] Dev server listening on http://localhost:${DEV_PORT}`,\n );\n });\n\n // Watch public/assets/ for changes — copy to dist/assets/ and notify\n const assetsDir = resolve(__dirname, \"public/assets\");\n if (existsSync(assetsDir)) {\n watch(assetsDir, { recursive: true }, (_event, filename) => {\n if (!filename) {\n return;\n }\n cpSync(resolve(assetsDir, filename), resolve(__dirname, \"dist/assets\", filename));\n for (const client of clients) {\n client.write(\"data: reload\\n\\n\");\n }\n console.log(`[custom-viz] Asset changed: ${filename}, notified ${clients.size} client(s)`);\n });\n }\n },\n\n closeBundle() {\n for (const client of clients) {\n client.write(\"data: reload\\n\\n\");\n }\n console.log(\n `[custom-viz] Build complete, notified ${clients.size} client(s)`,\n );\n },\n };\n}\n\nconst isWatch = process.argv.includes(\"--watch\");\n\nexport default defineConfig({\n plugins: [metabaseVizExternals(), ...(isWatch ? [metabaseDevServer()] : [])],\n publicDir: \"public\",\n build: {\n outDir: \"dist\",\n lib: {\n entry: resolve(__dirname, \"src/index.tsx\"),\n formats: [\"iife\"],\n fileName: () => \"index.js\",\n name: \"__customVizPlugin__\",\n },\n },\n});\n", _ = "__CUSTOM_VIZ_NAME__", v = "__CUSTOM_VIZ_VERSION__";
|
|
10
|
-
function
|
|
11
|
-
return e.split(
|
|
9
|
+
var l = "0.0.1-alpha.8", u = "node_modules/\n.DS_Store\n# dist must be committed\n", d = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M1.79978 6.86661C1.65041 7.01583 1.53192 7.19302 1.45107 7.38806C1.37023 7.58309 1.32861 7.79215 1.32861 8.00328C1.32861 8.21441 1.37023 8.42347 1.45107 8.61851C1.53192 8.81354 1.65041 8.99073 1.79978 9.13995L6.85978 14.1999C7.00899 14.3493 7.18618 14.4678 7.38122 14.5487C7.57626 14.6295 7.78531 14.6711 7.99644 14.6711C8.20757 14.6711 8.41663 14.6295 8.61167 14.5487C8.80671 14.4678 8.9839 14.3493 9.13311 14.1999L14.1931 9.13995C14.3425 8.99073 14.461 8.81354 14.5418 8.61851C14.6227 8.42347 14.6643 8.21441 14.6643 8.00328C14.6643 7.79215 14.6227 7.58309 14.5418 7.38806C14.461 7.19302 14.3425 7.01583 14.1931 6.86661L9.13311 1.80661C8.9839 1.65725 8.80671 1.53875 8.61167 1.45791C8.41663 1.37706 8.20757 1.33545 7.99644 1.33545C7.78531 1.33545 7.57626 1.37706 7.38122 1.45791C7.18618 1.53875 7.00899 1.65725 6.85978 1.80661L1.79978 6.86661Z\" stroke=\"white\" stroke-width=\"1.33333\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n", f = "import type {\n CreateCustomVisualization,\n CustomStaticVisualizationProps,\n CustomVisualizationProps,\n} from \"@metabase/custom-viz\";\n\ntype Settings = {\n threshold?: number;\n};\n\nconst createVisualization: CreateCustomVisualization<Settings> = ({\n getAssetUrl,\n}) => {\n return {\n id: \"__CUSTOM_VIZ_NAME__\",\n getName: () => \"__CUSTOM_VIZ_NAME__\",\n minSize: { width: 1, height: 1 },\n defaultSize: { width: 2, height: 2 },\n checkRenderable(series, settings) {\n if (series.length !== 1) {\n throw new Error(\"Only 1 series is supported\");\n }\n\n const [\n {\n data: { cols, rows },\n },\n ] = series;\n\n if (cols.length !== 1) {\n throw new Error(\"Query results should only have 1 column\");\n }\n\n if (rows.length !== 1) {\n throw new Error(\"Query results should only have 1 row\");\n }\n\n if (typeof rows[0][0] !== \"number\") {\n throw new Error(\"Result is not a number\");\n }\n\n if (typeof settings.threshold !== \"number\") {\n throw new Error(\"Threshold setting is not set\");\n }\n },\n settings: {\n threshold: {\n id: \"1\",\n title: \"Threshold\",\n widget: \"number\",\n getDefault() {\n return 0;\n },\n getProps() {\n return {\n options: {\n isInteger: false,\n isNonNegative: false,\n },\n placeholder: \"Set threshold\",\n };\n },\n },\n },\n VisualizationComponent: makeVisualizationComponent(getAssetUrl),\n StaticVisualizationComponent: makeStaticVisualizationComponent(getAssetUrl),\n };\n};\n\nconst makeVisualizationComponent =\n (_getAssetUrl: (path: string) => string) =>\n (props: CustomVisualizationProps<Settings>) => {\n const { height, series, settings, width } = props;\n const { threshold } = settings;\n const value = series[0].data.rows[0][0];\n\n if (!height || !width) {\n return null;\n }\n\n if (typeof value !== \"number\" || typeof threshold !== \"number\") {\n throw new Error(\"Value and threshold need to be numbers\");\n }\n\n const emoji = value >= threshold ? \"👍\" : \"👎\";\n\n return (\n <div\n style={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n width,\n height,\n fontSize: \"10rem\",\n }}\n >\n {emoji}\n </div>\n );\n };\n\nconst makeStaticVisualizationComponent =\n (getAssetUrl: (path: string) => string) =>\n (props: CustomStaticVisualizationProps<Settings>) => {\n const width = 540;\n const height = 360;\n const { series, settings } = props;\n const { threshold } = settings;\n const value = series[0].data.rows[0][0];\n\n if (typeof value !== \"number\" || typeof threshold !== \"number\") {\n throw new Error(\"Value and threshold need to be numbers\");\n }\n\n const emoji =\n value >= threshold ? (\n <img src={getAssetUrl(\"thumbs-up.png\")} />\n ) : (\n <img src={getAssetUrl(\"thumbs-down.png\")} />\n );\n\n return (\n <div\n style={{\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n width,\n height,\n fontSize: \"10rem\",\n }}\n >\n {emoji}\n </div>\n );\n };\n\nexport default createVisualization;\n", p = "{\n \"name\": \"__CUSTOM_VIZ_NAME__\",\n \"icon\": \"icon.svg\",\n \"assets\": [\"icon.svg\", \"thumbs-up.png\", \"thumbs-down.png\"],\n \"metabase\": {\n \"version\": \">=59\"\n }\n}\n", m = "{\n \"name\": \"__CUSTOM_VIZ_NAME__\",\n \"version\": \"0.0.1\",\n \"lockfileVersion\": 3,\n \"requires\": true,\n \"packages\": {\n \"\": {\n \"name\": \"__CUSTOM_VIZ_NAME__\",\n \"version\": \"0.0.1\",\n \"devDependencies\": {\n \"@metabase/custom-viz\": \"__CUSTOM_VIZ_VERSION__\",\n \"@types/react\": \"^19.2.14\",\n \"react\": \"^19.1.0\",\n \"typescript\": \"^5.9.3\",\n \"vite\": \"^8.0.0\"\n }\n },\n \"node_modules/@emnapi/core\": {\n \"version\": \"1.9.1\",\n \"resolved\": \"https://registry.npmjs.org/@emnapi/core/-/core-1.9.1.tgz\",\n \"integrity\": \"sha512-mukuNALVsoix/w1BJwFzwXBN/dHeejQtuVzcDsfOEsdpCumXb/E9j8w11h5S54tT1xhifGfbbSm/ICrObRb3KA==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"peer\": true,\n \"dependencies\": {\n \"@emnapi/wasi-threads\": \"1.2.0\",\n \"tslib\": \"^2.4.0\"\n }\n },\n \"node_modules/@emnapi/runtime\": {\n \"version\": \"1.9.1\",\n \"resolved\": \"https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.1.tgz\",\n \"integrity\": \"sha512-VYi5+ZVLhpgK4hQ0TAjiQiZ6ol0oe4mBx7mVv7IflsiEp0OWoVsp/+f9Vc1hOhE0TtkORVrI1GvzyreqpgWtkA==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"peer\": true,\n \"dependencies\": {\n \"tslib\": \"^2.4.0\"\n }\n },\n \"node_modules/@emnapi/wasi-threads\": {\n \"version\": \"1.2.0\",\n \"resolved\": \"https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.0.tgz\",\n \"integrity\": \"sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"peer\": true,\n \"dependencies\": {\n \"tslib\": \"^2.4.0\"\n }\n },\n \"node_modules/@metabase/custom-viz\": {\n \"version\": \"__CUSTOM_VIZ_VERSION__\",\n \"resolved\": \"https://registry.npmjs.org/@metabase/custom-viz/-/custom-viz-__CUSTOM_VIZ_VERSION__.tgz\",\n \"dev\": true,\n \"dependencies\": {\n \"commander\": \"^13.1.0\"\n },\n \"bin\": {\n \"metabase-custom-viz\": \"dist/cli.js\"\n }\n },\n \"node_modules/@napi-rs/wasm-runtime\": {\n \"version\": \"1.1.2\",\n \"resolved\": \"https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.2.tgz\",\n \"integrity\": \"sha512-sNXv5oLJ7ob93xkZ1XnxisYhGYXfaG9f65/ZgYuAu3qt7b3NadcOEhLvx28hv31PgX8SZJRYrAIPQilQmFpLVw==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"dependencies\": {\n \"@tybys/wasm-util\": \"^0.10.1\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/Brooooooklyn\"\n },\n \"peerDependencies\": {\n \"@emnapi/core\": \"^1.7.1\",\n \"@emnapi/runtime\": \"^1.7.1\"\n }\n },\n \"node_modules/@oxc-project/types\": {\n \"version\": \"0.122.0\",\n \"resolved\": \"https://registry.npmjs.org/@oxc-project/types/-/types-0.122.0.tgz\",\n \"integrity\": \"sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"funding\": {\n \"url\": \"https://github.com/sponsors/Boshen\"\n }\n },\n \"node_modules/@rolldown/binding-android-arm64\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-pv1y2Fv0JybcykuiiD3qBOBdz6RteYojRFY1d+b95WVuzx211CRh+ytI/+9iVyWQ6koTh5dawe4S/yRfOFjgaA==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"android\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-darwin-arm64\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-cFYr6zTG/3PXXF3pUO+umXxt1wkRK/0AYT8lDwuqvRC+LuKYWSAQAQZjCWDQpAH172ZV6ieYrNnFzVVcnSflAg==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"darwin\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-darwin-x64\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-ZCsYknnHzeXYps0lGBz8JrF37GpE9bFVefrlmDrAQhOEi4IOIlcoU1+FwHEtyXGx2VkYAvhu7dyBf75EJQffBw==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"darwin\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-freebsd-x64\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-dMLeprcVsyJsKolRXyoTH3NL6qtsT0Y2xeuEA8WQJquWFXkEC4bcu1rLZZSnZRMtAqwtrF/Ib9Ddtpa/Gkge9Q==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"freebsd\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-linux-arm-gnueabihf\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-YqWjAgGC/9M1lz3GR1r1rP79nMgo3mQiiA+Hfo+pvKFK1fAJ1bCi0ZQVh8noOqNacuY1qIcfyVfP6HoyBRZ85Q==\",\n \"cpu\": [\n \"arm\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-linux-arm64-gnu\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-/I5AS4cIroLpslsmzXfwbe5OmWvSsrFuEw3mwvbQ1kDxJ822hFHIx+vsN/TAzNVyepI/j/GSzrtCIwQPeKCLIg==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-linux-arm64-musl\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-V6/wZztnBqlx5hJQqNWwFdxIKN0m38p8Jas+VoSfgH54HSj9tKTt1dZvG6JRHcjh6D7TvrJPWFGaY9UBVOaWPw==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-linux-ppc64-gnu\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-AP3E9BpcUYliZCxa3w5Kwj9OtEVDYK6sVoUzy4vTOJsjPOgdaJZKFmN4oOlX0Wp0RPV2ETfmIra9x1xuayFB7g==\",\n \"cpu\": [\n \"ppc64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-linux-s390x-gnu\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-nWwpvUSPkoFmZo0kQazZYOrT7J5DGOJ/+QHHzjvNlooDZED8oH82Yg67HvehPPLAg5fUff7TfWFHQS8IV1n3og==\",\n \"cpu\": [\n \"s390x\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-linux-x64-gnu\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-RNrafz5bcwRy+O9e6P8Z/OCAJW/A+qtBczIqVYwTs14pf4iV1/+eKEjdOUta93q2TsT/FI0XYDP3TCky38LMAg==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-linux-x64-musl\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-Jpw/0iwoKWx3LJ2rc1yjFrj+T7iHZn2JDg1Yny1ma0luviFS4mhAIcd1LFNxK3EYu3DHWCps0ydXQ5i/rrJ2ig==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-openharmony-arm64\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-vRugONE4yMfVn0+7lUKdKvN4D5YusEiPilaoO2sgUWpCvrncvWgPMzK00ZFFJuiPgLwgFNP5eSiUlv2tfc+lpA==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"openharmony\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-wasm32-wasi\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-ykGiLr/6kkiHc0XnBfmFJuCjr5ZYKKofkx+chJWDjitX+KsJuAmrzWhwyOMSHzPhzOHOy7u9HlFoa5MoAOJ/Zg==\",\n \"cpu\": [\n \"wasm32\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"dependencies\": {\n \"@napi-rs/wasm-runtime\": \"^1.1.1\"\n },\n \"engines\": {\n \"node\": \">=14.0.0\"\n }\n },\n \"node_modules/@rolldown/binding-win32-arm64-msvc\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-5eOND4duWkwx1AzCxadcOrNeighiLwMInEADT0YM7xeEOOFcovWZCq8dadXgcRHSf3Ulh1kFo/qvzoFiCLOL1Q==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"win32\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/binding-win32-x64-msvc\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-PyqoipaswDLAZtot351MLhrlrh6lcZPo2LSYE+VDxbVk24LVKAGOuE4hb8xZQmrPAuEtTZW8E6D2zc5EUZX4Lw==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"win32\"\n ],\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n }\n },\n \"node_modules/@rolldown/pluginutils\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-HHMwmarRKvoFsJorqYlFeFRzXZqCt2ETQlEDOb9aqssrnVBB1/+xgTGtuTrIk5vzLNX1MjMtTf7W9z3tsSbrxw==\",\n \"dev\": true,\n \"license\": \"MIT\"\n },\n \"node_modules/@tybys/wasm-util\": {\n \"version\": \"0.10.1\",\n \"resolved\": \"https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz\",\n \"integrity\": \"sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"dependencies\": {\n \"tslib\": \"^2.4.0\"\n }\n },\n \"node_modules/@types/react\": {\n \"version\": \"19.2.14\",\n \"resolved\": \"https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz\",\n \"integrity\": \"sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"dependencies\": {\n \"csstype\": \"^3.2.2\"\n }\n },\n \"node_modules/commander\": {\n \"version\": \"13.1.0\",\n \"resolved\": \"https://registry.npmjs.org/commander/-/commander-13.1.0.tgz\",\n \"integrity\": \"sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"engines\": {\n \"node\": \">=18\"\n }\n },\n \"node_modules/csstype\": {\n \"version\": \"3.2.3\",\n \"resolved\": \"https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz\",\n \"integrity\": \"sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==\",\n \"dev\": true,\n \"license\": \"MIT\"\n },\n \"node_modules/detect-libc\": {\n \"version\": \"2.1.2\",\n \"resolved\": \"https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz\",\n \"integrity\": \"sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==\",\n \"dev\": true,\n \"license\": \"Apache-2.0\",\n \"engines\": {\n \"node\": \">=8\"\n }\n },\n \"node_modules/fdir\": {\n \"version\": \"6.5.0\",\n \"resolved\": \"https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz\",\n \"integrity\": \"sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"engines\": {\n \"node\": \">=12.0.0\"\n },\n \"peerDependencies\": {\n \"picomatch\": \"^3 || ^4\"\n },\n \"peerDependenciesMeta\": {\n \"picomatch\": {\n \"optional\": true\n }\n }\n },\n \"node_modules/fsevents\": {\n \"version\": \"2.3.3\",\n \"resolved\": \"https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz\",\n \"integrity\": \"sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==\",\n \"dev\": true,\n \"hasInstallScript\": true,\n \"license\": \"MIT\",\n \"optional\": true,\n \"os\": [\n \"darwin\"\n ],\n \"engines\": {\n \"node\": \"^8.16.0 || ^10.6.0 || >=11.0.0\"\n }\n },\n \"node_modules/lightningcss\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz\",\n \"integrity\": \"sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==\",\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"dependencies\": {\n \"detect-libc\": \"^2.0.3\"\n },\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n },\n \"optionalDependencies\": {\n \"lightningcss-android-arm64\": \"1.32.0\",\n \"lightningcss-darwin-arm64\": \"1.32.0\",\n \"lightningcss-darwin-x64\": \"1.32.0\",\n \"lightningcss-freebsd-x64\": \"1.32.0\",\n \"lightningcss-linux-arm-gnueabihf\": \"1.32.0\",\n \"lightningcss-linux-arm64-gnu\": \"1.32.0\",\n \"lightningcss-linux-arm64-musl\": \"1.32.0\",\n \"lightningcss-linux-x64-gnu\": \"1.32.0\",\n \"lightningcss-linux-x64-musl\": \"1.32.0\",\n \"lightningcss-win32-arm64-msvc\": \"1.32.0\",\n \"lightningcss-win32-x64-msvc\": \"1.32.0\"\n }\n },\n \"node_modules/lightningcss-android-arm64\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz\",\n \"integrity\": \"sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"android\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-darwin-arm64\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz\",\n \"integrity\": \"sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"darwin\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-darwin-x64\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz\",\n \"integrity\": \"sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"darwin\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-freebsd-x64\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz\",\n \"integrity\": \"sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"freebsd\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-linux-arm-gnueabihf\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz\",\n \"integrity\": \"sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==\",\n \"cpu\": [\n \"arm\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-linux-arm64-gnu\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz\",\n \"integrity\": \"sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-linux-arm64-musl\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz\",\n \"integrity\": \"sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-linux-x64-gnu\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz\",\n \"integrity\": \"sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-linux-x64-musl\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz\",\n \"integrity\": \"sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"linux\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-win32-arm64-msvc\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz\",\n \"integrity\": \"sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==\",\n \"cpu\": [\n \"arm64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"win32\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/lightningcss-win32-x64-msvc\": {\n \"version\": \"1.32.0\",\n \"resolved\": \"https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz\",\n \"integrity\": \"sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==\",\n \"cpu\": [\n \"x64\"\n ],\n \"dev\": true,\n \"license\": \"MPL-2.0\",\n \"optional\": true,\n \"os\": [\n \"win32\"\n ],\n \"engines\": {\n \"node\": \">= 12.0.0\"\n },\n \"funding\": {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/parcel\"\n }\n },\n \"node_modules/nanoid\": {\n \"version\": \"3.3.11\",\n \"resolved\": \"https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz\",\n \"integrity\": \"sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==\",\n \"dev\": true,\n \"funding\": [\n {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/ai\"\n }\n ],\n \"license\": \"MIT\",\n \"bin\": {\n \"nanoid\": \"bin/nanoid.cjs\"\n },\n \"engines\": {\n \"node\": \"^10 || ^12 || ^13.7 || ^14 || >=15.0.1\"\n }\n },\n \"node_modules/picocolors\": {\n \"version\": \"1.1.1\",\n \"resolved\": \"https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz\",\n \"integrity\": \"sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==\",\n \"dev\": true,\n \"license\": \"ISC\"\n },\n \"node_modules/picomatch\": {\n \"version\": \"4.0.4\",\n \"resolved\": \"https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz\",\n \"integrity\": \"sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"engines\": {\n \"node\": \">=12\"\n },\n \"funding\": {\n \"url\": \"https://github.com/sponsors/jonschlinkert\"\n }\n },\n \"node_modules/postcss\": {\n \"version\": \"8.5.8\",\n \"resolved\": \"https://registry.npmjs.org/postcss/-/postcss-8.5.8.tgz\",\n \"integrity\": \"sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==\",\n \"dev\": true,\n \"funding\": [\n {\n \"type\": \"opencollective\",\n \"url\": \"https://opencollective.com/postcss/\"\n },\n {\n \"type\": \"tidelift\",\n \"url\": \"https://tidelift.com/funding/github/npm/postcss\"\n },\n {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/ai\"\n }\n ],\n \"license\": \"MIT\",\n \"dependencies\": {\n \"nanoid\": \"^3.3.11\",\n \"picocolors\": \"^1.1.1\",\n \"source-map-js\": \"^1.2.1\"\n },\n \"engines\": {\n \"node\": \"^10 || ^12 || >=14\"\n }\n },\n \"node_modules/react\": {\n \"version\": \"19.2.4\",\n \"resolved\": \"https://registry.npmjs.org/react/-/react-19.2.4.tgz\",\n \"integrity\": \"sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"engines\": {\n \"node\": \">=0.10.0\"\n }\n },\n \"node_modules/rolldown\": {\n \"version\": \"1.0.0-rc.12\",\n \"resolved\": \"https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.12.tgz\",\n \"integrity\": \"sha512-yP4USLIMYrwpPHEFB5JGH1uxhcslv6/hL0OyvTuY+3qlOSJvZ7ntYnoWpehBxufkgN0cvXxppuTu5hHa/zPh+A==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"dependencies\": {\n \"@oxc-project/types\": \"=0.122.0\",\n \"@rolldown/pluginutils\": \"1.0.0-rc.12\"\n },\n \"bin\": {\n \"rolldown\": \"bin/cli.mjs\"\n },\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n },\n \"optionalDependencies\": {\n \"@rolldown/binding-android-arm64\": \"1.0.0-rc.12\",\n \"@rolldown/binding-darwin-arm64\": \"1.0.0-rc.12\",\n \"@rolldown/binding-darwin-x64\": \"1.0.0-rc.12\",\n \"@rolldown/binding-freebsd-x64\": \"1.0.0-rc.12\",\n \"@rolldown/binding-linux-arm-gnueabihf\": \"1.0.0-rc.12\",\n \"@rolldown/binding-linux-arm64-gnu\": \"1.0.0-rc.12\",\n \"@rolldown/binding-linux-arm64-musl\": \"1.0.0-rc.12\",\n \"@rolldown/binding-linux-ppc64-gnu\": \"1.0.0-rc.12\",\n \"@rolldown/binding-linux-s390x-gnu\": \"1.0.0-rc.12\",\n \"@rolldown/binding-linux-x64-gnu\": \"1.0.0-rc.12\",\n \"@rolldown/binding-linux-x64-musl\": \"1.0.0-rc.12\",\n \"@rolldown/binding-openharmony-arm64\": \"1.0.0-rc.12\",\n \"@rolldown/binding-wasm32-wasi\": \"1.0.0-rc.12\",\n \"@rolldown/binding-win32-arm64-msvc\": \"1.0.0-rc.12\",\n \"@rolldown/binding-win32-x64-msvc\": \"1.0.0-rc.12\"\n }\n },\n \"node_modules/source-map-js\": {\n \"version\": \"1.2.1\",\n \"resolved\": \"https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz\",\n \"integrity\": \"sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==\",\n \"dev\": true,\n \"license\": \"BSD-3-Clause\",\n \"engines\": {\n \"node\": \">=0.10.0\"\n }\n },\n \"node_modules/tinyglobby\": {\n \"version\": \"0.2.15\",\n \"resolved\": \"https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz\",\n \"integrity\": \"sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"dependencies\": {\n \"fdir\": \"^6.5.0\",\n \"picomatch\": \"^4.0.3\"\n },\n \"engines\": {\n \"node\": \">=12.0.0\"\n },\n \"funding\": {\n \"url\": \"https://github.com/sponsors/SuperchupuDev\"\n }\n },\n \"node_modules/tslib\": {\n \"version\": \"2.8.1\",\n \"resolved\": \"https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz\",\n \"integrity\": \"sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==\",\n \"dev\": true,\n \"license\": \"0BSD\",\n \"optional\": true\n },\n \"node_modules/typescript\": {\n \"version\": \"5.9.3\",\n \"resolved\": \"https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz\",\n \"integrity\": \"sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==\",\n \"dev\": true,\n \"license\": \"Apache-2.0\",\n \"bin\": {\n \"tsc\": \"bin/tsc\",\n \"tsserver\": \"bin/tsserver\"\n },\n \"engines\": {\n \"node\": \">=14.17\"\n }\n },\n \"node_modules/vite\": {\n \"version\": \"8.0.3\",\n \"resolved\": \"https://registry.npmjs.org/vite/-/vite-8.0.3.tgz\",\n \"integrity\": \"sha512-B9ifbFudT1TFhfltfaIPgjo9Z3mDynBTJSUYxTjOQruf/zHH+ezCQKcoqO+h7a9Pw9Nm/OtlXAiGT1axBgwqrQ==\",\n \"dev\": true,\n \"license\": \"MIT\",\n \"dependencies\": {\n \"lightningcss\": \"^1.32.0\",\n \"picomatch\": \"^4.0.4\",\n \"postcss\": \"^8.5.8\",\n \"rolldown\": \"1.0.0-rc.12\",\n \"tinyglobby\": \"^0.2.15\"\n },\n \"bin\": {\n \"vite\": \"bin/vite.js\"\n },\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n },\n \"funding\": {\n \"url\": \"https://github.com/vitejs/vite?sponsor=1\"\n },\n \"optionalDependencies\": {\n \"fsevents\": \"~2.3.3\"\n },\n \"peerDependencies\": {\n \"@types/node\": \"^20.19.0 || >=22.12.0\",\n \"@vitejs/devtools\": \"^0.1.0\",\n \"esbuild\": \"^0.27.0\",\n \"jiti\": \">=1.21.0\",\n \"less\": \"^4.0.0\",\n \"sass\": \"^1.70.0\",\n \"sass-embedded\": \"^1.70.0\",\n \"stylus\": \">=0.54.8\",\n \"sugarss\": \"^5.0.0\",\n \"terser\": \"^5.16.0\",\n \"tsx\": \"^4.8.1\",\n \"yaml\": \"^2.4.2\"\n },\n \"peerDependenciesMeta\": {\n \"@types/node\": {\n \"optional\": true\n },\n \"@vitejs/devtools\": {\n \"optional\": true\n },\n \"esbuild\": {\n \"optional\": true\n },\n \"jiti\": {\n \"optional\": true\n },\n \"less\": {\n \"optional\": true\n },\n \"sass\": {\n \"optional\": true\n },\n \"sass-embedded\": {\n \"optional\": true\n },\n \"stylus\": {\n \"optional\": true\n },\n \"sugarss\": {\n \"optional\": true\n },\n \"terser\": {\n \"optional\": true\n },\n \"tsx\": {\n \"optional\": true\n },\n \"yaml\": {\n \"optional\": true\n }\n }\n }\n }\n}\n", h = "{\n \"name\": \"__CUSTOM_VIZ_NAME__\",\n \"version\": \"0.0.1\",\n \"private\": true,\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"vite build\",\n \"dev\": \"vite build --watch\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"devDependencies\": {\n \"@metabase/custom-viz\": \"__CUSTOM_VIZ_VERSION__\",\n \"@types/react\": \"^19.2.14\",\n \"react\": \"^19.1.0\",\n \"typescript\": \"^5.9.3\",\n \"vite\": \"^8.0.0\"\n }\n}\n", g = "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"module\": \"ESNext\",\n \"moduleResolution\": \"bundler\",\n \"jsx\": \"react-jsx\",\n \"strict\": true,\n \"esModuleInterop\": true,\n \"skipLibCheck\": true,\n \"outDir\": \"dist\",\n \"declaration\": true\n },\n \"include\": [\"src\"]\n}\n", _ = "import { resolve } from \"path\";\nimport { createServer } from \"http\";\nimport { watch, cpSync, existsSync } from \"fs\";\nimport { defineConfig } from \"vite\";\n\n/**\n * Vite plugin that replaces `react` and `react/jsx-runtime` imports with\n * virtual modules that read from Metabase's `window.__METABASE_VIZ_API__`.\n *\n * This is necessary because the ES module output format cannot use\n * `output.globals`, and bare `import 'react'` would fail in the browser.\n */\nfunction metabaseVizExternals() {\n const VIRTUAL_REACT = \"\\0virtual:react\";\n const VIRTUAL_JSX_RUNTIME = \"\\0virtual:react/jsx-runtime\";\n return {\n name: \"metabase-viz-externals\",\n enforce: \"pre\" as const,\n\n resolveId(source) {\n if (source === \"react\") {\n return VIRTUAL_REACT;\n }\n if (source === \"react/jsx-runtime\") {\n return VIRTUAL_JSX_RUNTIME;\n }\n return null;\n },\n\n load(id) {\n if (id === VIRTUAL_REACT) {\n return [\n \"const React = window.__METABASE_VIZ_API__.React;\",\n \"export default React;\",\n \"export const { useState, useEffect, useRef, useCallback, useMemo, useReducer, useContext, createElement, Fragment } = React;\",\n ].join(\"\\n\");\n }\n if (id === VIRTUAL_JSX_RUNTIME) {\n return [\n \"const jsxRuntime = window.__METABASE_VIZ_API__.jsxRuntime;\",\n \"export const { jsx, jsxs, Fragment } = jsxRuntime;\",\n ].join(\"\\n\");\n }\n return null;\n },\n };\n}\n\nconst DEV_PORT = 5174;\n\n/**\n * Vite plugin that starts a dev server serving both static files from dist/\n * and an SSE endpoint at /__sse for hot-reload notifications.\n * Metabase's frontend connects to /__sse on the same origin as dev_bundle_url.\n */\nfunction metabaseDevServer() {\n const clients = new Set<import(\"http\").ServerResponse>();\n let server: ReturnType<typeof createServer> | null = null;\n\n return {\n name: \"metabase-dev-server\",\n\n buildStart() {\n if (server) {\n return;\n }\n\n const distDir = resolve(__dirname, \"dist\");\n\n server = createServer((req, res) => {\n const url = req.url ?? \"/\";\n\n // SSE endpoint for hot-reload\n if (url === \"/__sse\") {\n res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n \"Access-Control-Allow-Origin\": \"*\",\n });\n clients.add(res);\n req.on(\"close\", () => clients.delete(res));\n return;\n }\n\n // CORS headers for all static responses\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n\n // Serve static files from dist/\n const { readFile, stat } = require(\"fs\");\n const { join, extname } = require(\"path\");\n\n const filePath =\n url === \"/\" ? join(distDir, \"index.html\") : join(distDir, url);\n\n // Prevent directory traversal\n if (!filePath.startsWith(distDir)) {\n res.writeHead(403);\n res.end(\"Forbidden\");\n return;\n }\n\n stat(filePath, (err: NodeJS.ErrnoException | null) => {\n if (err) {\n res.writeHead(404);\n res.end(\"Not found\");\n return;\n }\n\n const mimeTypes: Record<string, string> = {\n \".html\": \"text/html\",\n \".js\": \"application/javascript\",\n \".css\": \"text/css\",\n \".json\": \"application/json\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".svg\": \"image/svg+xml\",\n \".ico\": \"image/x-icon\",\n };\n const contentType =\n mimeTypes[extname(filePath)] ?? \"application/octet-stream\";\n\n readFile(\n filePath,\n (readErr: NodeJS.ErrnoException | null, data: Buffer) => {\n if (readErr) {\n res.writeHead(500);\n res.end(\"Internal server error\");\n return;\n }\n res.writeHead(200, { \"Content-Type\": contentType });\n res.end(data);\n },\n );\n });\n });\n\n server.listen(DEV_PORT, () => {\n console.log(\n `[custom-viz] Dev server listening on http://localhost:${DEV_PORT}`,\n );\n });\n\n // Watch public/assets/ for changes — copy to dist/assets/ and notify\n const assetsDir = resolve(__dirname, \"public/assets\");\n if (existsSync(assetsDir)) {\n watch(assetsDir, { recursive: true }, (_event, filename) => {\n if (!filename) {\n return;\n }\n cpSync(\n resolve(assetsDir, filename),\n resolve(__dirname, \"dist/assets\", filename),\n );\n for (const client of clients) {\n client.write(\"data: reload\\n\\n\");\n }\n console.log(\n `[custom-viz] Asset changed: ${filename}, notified ${clients.size} client(s)`,\n );\n });\n }\n },\n\n closeBundle() {\n for (const client of clients) {\n client.write(\"data: reload\\n\\n\");\n }\n console.log(\n `[custom-viz] Build complete, notified ${clients.size} client(s)`,\n );\n },\n };\n}\n\nconst isWatch = process.argv.includes(\"--watch\");\n\nexport default defineConfig({\n plugins: [metabaseVizExternals(), ...(isWatch ? [metabaseDevServer()] : [])],\n publicDir: \"public\",\n define: {\n \"process.env.NODE_ENV\": JSON.stringify(\"production\"),\n \"process.env\": JSON.stringify({}),\n },\n build: {\n outDir: \"dist\",\n lib: {\n entry: resolve(__dirname, \"src/index.tsx\"),\n formats: [\"iife\"],\n fileName: () => \"index.js\",\n name: \"__customVizPlugin__\",\n },\n },\n});\n", v = "__CUSTOM_VIZ_NAME__", y = "__CUSTOM_VIZ_VERSION__";
|
|
10
|
+
function b(e, t) {
|
|
11
|
+
return e.split(v).join(t);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
13
|
+
function x(e) {
|
|
14
|
+
return b(h, e).split(y).join(l);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
16
|
+
function S(e) {
|
|
17
|
+
return b(m, e).split(y).join(l);
|
|
18
|
+
}
|
|
19
|
+
function C() {
|
|
20
|
+
return _;
|
|
18
21
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
22
|
+
function w() {
|
|
23
|
+
return g;
|
|
21
24
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
25
|
+
function T(e) {
|
|
26
|
+
return b(f, e);
|
|
24
27
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
28
|
+
function E(e) {
|
|
29
|
+
return b(p, e);
|
|
27
30
|
}
|
|
28
|
-
function
|
|
31
|
+
function D() {
|
|
29
32
|
return d;
|
|
30
33
|
}
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
return t(a(
|
|
34
|
+
var O = a(i(c(import.meta.url)), "templates");
|
|
35
|
+
function k(e) {
|
|
36
|
+
return t(a(O, e));
|
|
34
37
|
}
|
|
35
|
-
function
|
|
38
|
+
function A() {
|
|
36
39
|
return u;
|
|
37
40
|
}
|
|
38
|
-
function
|
|
39
|
-
let t = JSON.parse(e), n = JSON.parse(
|
|
41
|
+
function j(e) {
|
|
42
|
+
let t = JSON.parse(e), n = JSON.parse(h.split(v).join("__placeholder__").split(y).join(l));
|
|
40
43
|
return t.devDependencies = {
|
|
41
44
|
...t.devDependencies,
|
|
42
45
|
...n.devDependencies
|
|
@@ -47,21 +50,22 @@ function k(e) {
|
|
|
47
50
|
}
|
|
48
51
|
//#endregion
|
|
49
52
|
//#region src/cli.ts
|
|
50
|
-
var
|
|
51
|
-
|
|
53
|
+
var M = new s();
|
|
54
|
+
M.name("metabase-custom-viz").description("CLI for creating custom visualizations for Metabase").version(l), M.command("init").description("Scaffold a new custom visualization").argument("<name>", "Name of the custom visualization").action(async (t) => {
|
|
52
55
|
let i = t.trim().replace(/\s+/g, "-").toLowerCase();
|
|
53
56
|
(!i || !/^[a-z0-9@][a-z0-9._\-/]*$/.test(i)) && (console.error(`Error: "${t}" is not a valid project name. Use letters, numbers, hyphens, and dots.`), process.exit(1)), e(i) && (console.error(`Error: Directory "${i}" already exists.`), process.exit(1)), console.log(`Scaffolding custom visualization: ${i}\n`), await Promise.all([n(a(i, "src"), { recursive: !0 }), n(a(i, "public", "assets"), { recursive: !0 })]), await Promise.all([
|
|
54
|
-
r(a(i, "package.json"),
|
|
55
|
-
r(a(i, "
|
|
56
|
-
r(a(i, "
|
|
57
|
-
r(a(i, "
|
|
58
|
-
r(a(i, "
|
|
59
|
-
r(a(i, "
|
|
60
|
-
r(a(i, "public", "assets", "
|
|
61
|
-
r(a(i, "public", "assets", "thumbs-
|
|
62
|
-
r(a(i, ".
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
r(a(i, "package.json"), x(i)),
|
|
58
|
+
r(a(i, "package-lock.json"), S(i)),
|
|
59
|
+
r(a(i, "vite.config.ts"), C()),
|
|
60
|
+
r(a(i, "tsconfig.json"), w()),
|
|
61
|
+
r(a(i, "src", "index.tsx"), T(i)),
|
|
62
|
+
r(a(i, "metabase-plugin.json"), E(i)),
|
|
63
|
+
r(a(i, "public", "assets", "icon.svg"), D()),
|
|
64
|
+
r(a(i, "public", "assets", "thumbs-up.png"), k("thumbs-up.png")),
|
|
65
|
+
r(a(i, "public", "assets", "thumbs-down.png"), k("thumbs-down.png")),
|
|
66
|
+
r(a(i, ".gitignore"), A())
|
|
67
|
+
]), console.log("Created files:"), console.log(` ${i}/package.json`), console.log(` ${i}/package-lock.json`), console.log(` ${i}/vite.config.ts`), console.log(` ${i}/tsconfig.json`), console.log(` ${i}/src/index.tsx`), console.log(` ${i}/metabase-plugin.json`), console.log(` ${i}/public/assets/icon.svg`), console.log(` ${i}/public/assets/thumbs-up.png`), console.log(` ${i}/public/assets/thumbs-down.png`), console.log(` ${i}/.gitignore`), console.log(), console.log("Next steps:"), console.log(` cd ${i}`), console.log(" npm install"), console.log(" npm run dev # Watch mode"), console.log(" npm run build # Production build");
|
|
68
|
+
}), M.command("upgrade").description("Upgrade an existing custom visualization to the latest template version").action(async () => {
|
|
65
69
|
let n = process.cwd(), i = a(n, "package.json");
|
|
66
70
|
e(i) || (console.error("Error: No package.json found. Run this command from the root of a custom visualization project."), process.exit(1));
|
|
67
71
|
let o;
|
|
@@ -71,21 +75,21 @@ A.name("metabase-custom-viz").description("CLI for creating custom visualization
|
|
|
71
75
|
console.error("Error: Could not parse package.json."), process.exit(1);
|
|
72
76
|
}
|
|
73
77
|
let s = o.devDependencies?.["@metabase/custom-viz"];
|
|
74
|
-
if (s || (console.error("Error: @metabase/custom-viz not found in devDependencies. Is this a custom visualization project?"), process.exit(1)), s === "0.0.1-alpha.
|
|
78
|
+
if (s || (console.error("Error: @metabase/custom-viz not found in devDependencies. Is this a custom visualization project?"), process.exit(1)), s === "0.0.1-alpha.8") {
|
|
75
79
|
console.log(`Already up to date (v${l}). No changes needed.`);
|
|
76
80
|
return;
|
|
77
81
|
}
|
|
78
|
-
if (console.log(`Upgrading from @metabase/custom-viz ${s} → ${l}\n`), console.log("The following changes will be made:\n"), console.log(" vite.config.ts — Replace with the latest build configuration"), console.log(" tsconfig.json — Replace with the latest TypeScript configuration"), console.log(" .gitignore — Replace with the latest gitignore rules"), console.log(" package.json — Update devDependencies and scripts to latest versions"), console.log(), console.log("Your source code (src/), assets (public/), and metabase-plugin.json will NOT be modified.\n"), !await
|
|
82
|
+
if (console.log(`Upgrading from @metabase/custom-viz ${s} → ${l}\n`), console.log("The following changes will be made:\n"), console.log(" vite.config.ts — Replace with the latest build configuration"), console.log(" tsconfig.json — Replace with the latest TypeScript configuration"), console.log(" .gitignore — Replace with the latest gitignore rules"), console.log(" package.json — Update devDependencies and scripts to latest versions"), console.log(), console.log("Your source code (src/), assets (public/), and metabase-plugin.json will NOT be modified.\n"), !await N("Proceed with upgrade?")) {
|
|
79
83
|
console.log("Upgrade cancelled.");
|
|
80
84
|
return;
|
|
81
85
|
}
|
|
82
86
|
console.log();
|
|
83
87
|
let c = [];
|
|
84
|
-
await r(a(n, "vite.config.ts"),
|
|
88
|
+
await r(a(n, "vite.config.ts"), C()), c.push("vite.config.ts"), await r(a(n, "tsconfig.json"), w()), c.push("tsconfig.json"), await r(a(n, ".gitignore"), A()), c.push(".gitignore"), await r(i, j(t(i, "utf-8"))), c.push("package.json"), console.log("Updated files:");
|
|
85
89
|
for (let e of c) console.log(` ${e}`);
|
|
86
90
|
console.log(), console.log("Next steps:"), console.log(" npm install # Install updated dependencies");
|
|
87
91
|
});
|
|
88
|
-
function
|
|
92
|
+
function N(e) {
|
|
89
93
|
let t = o({
|
|
90
94
|
input: process.stdin,
|
|
91
95
|
output: process.stdout
|
|
@@ -96,5 +100,5 @@ function j(e) {
|
|
|
96
100
|
});
|
|
97
101
|
});
|
|
98
102
|
}
|
|
99
|
-
|
|
103
|
+
M.parse();
|
|
100
104
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-types.d.ts","sourceRoot":"","sources":["../src/column-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAQ3C,eAAO,MAAM,MAAM,EAAE,eAA2C,CAAC;AACjE,eAAO,MAAM,SAAS,EAAE,eAA8C,CAAC;AACvE,eAAO,MAAM,SAAS,EAAE,eAA8C,CAAC;AACvE,eAAO,MAAM,SAAS,EAAE,eAA8C,CAAC;AACvE,eAAO,MAAM,QAAQ,EAAE,eAA6C,CAAC;AACrE,eAAO,MAAM,YAAY,EAAE,eAAiD,CAAC;AAC7E,eAAO,MAAM,UAAU,EAAE,eAA+C,CAAC;AACzE,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"column-types.d.ts","sourceRoot":"","sources":["../src/column-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAQ3C,eAAO,MAAM,MAAM,EAAE,eAA2C,CAAC;AACjE,eAAO,MAAM,SAAS,EAAE,eAA8C,CAAC;AACvE,eAAO,MAAM,SAAS,EAAE,eAA8C,CAAC;AACvE,eAAO,MAAM,SAAS,EAAE,eAA8C,CAAC;AACvE,eAAO,MAAM,QAAQ,EAAE,eAA6C,CAAC;AACrE,eAAO,MAAM,YAAY,EAAE,eAAiD,CAAC;AAC7E,eAAO,MAAM,UAAU,EAAE,eAA+C,CAAC;AACzE,eAAO,MAAM,iBAAiB,EAAE,eACH,CAAC;AAC9B,eAAO,MAAM,iBAAiB,EAAE,eACH,CAAC;AAC9B,eAAO,MAAM,QAAQ,EAAE,eAA6C,CAAC;AACrE,eAAO,MAAM,OAAO,EAAE,eAA4C,CAAC;AACnE,eAAO,MAAM,MAAM,EAAE,eAA2C,CAAC;AACjE,eAAO,MAAM,IAAI,EAAE,eAAyC,CAAC;AAC7D,eAAO,MAAM,IAAI,EAAE,eAAyC,CAAC;AAC7D,eAAO,MAAM,YAAY,EAAE,eAAiD,CAAC;AAC7E,eAAO,MAAM,OAAO,EAAE,eAA4C,CAAC;AACnE,eAAO,MAAM,SAAS,EAAE,eAA8C,CAAC;AACvE,eAAO,MAAM,QAAQ,EAAE,eAA6C,CAAC;AACrE,eAAO,MAAM,SAAS,EAAE,eAA8C,CAAC;AACvE,eAAO,MAAM,OAAO,EAAE,eAA4C,CAAC;AACnE,eAAO,MAAM,UAAU,EAAE,eAA+C,CAAC;AACzE,eAAO,MAAM,UAAU,EAAE,eAA+C,CAAC;AACzE,eAAO,MAAM,KAAK,EAAE,eAA0C,CAAC;AAC/D,eAAO,MAAM,OAAO,EAAE,eAA4C,CAAC;AACnE,eAAO,MAAM,SAAS,EAAE,eAA8C,CAAC;AACvE,eAAO,MAAM,YAAY,EAAE,eAAiD,CAAC;AAC7E,eAAO,MAAM,UAAU,EAAE,eAA+C,CAAC;AACzE,eAAO,MAAM,WAAW,EAAE,eAAgD,CAAC;AAC3E,eAAO,MAAM,UAAU,EAAE,eAA+C,CAAC;AACzE,eAAO,MAAM,YAAY,EAAE,eAAiD,CAAC;AAC7E,eAAO,MAAM,IAAI,EAAE,eAAyC,CAAC;AAC7D,eAAO,MAAM,KAAK,EAAE,eAA0C,CAAC;AAC/D,eAAO,MAAM,OAAO,EAAE,eAA4C,CAAC;AACnE,eAAO,MAAM,WAAW,EAAE,eAAgD,CAAC;AAC3E,eAAO,MAAM,UAAU,EAAE,eAA+C,CAAC;AACzE,eAAO,MAAM,8BAA8B,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAEnB,CAAC;AAE/C,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { CustomVisualizationSettingDefinition, Series, WidgetName, Widgets } from '../types';
|
|
2
|
-
type
|
|
1
|
+
import { BaseWidgetProps, CustomVisualizationSettingDefinition, Series, WidgetName, Widgets } from '../types';
|
|
2
|
+
type OmitBaseWidgetProps<P> = keyof BaseWidgetProps<unknown, unknown> extends keyof P ? Omit<P, keyof BaseWidgetProps<unknown, unknown>> : P;
|
|
3
|
+
type PropsFromWidget<W> = W extends WidgetName ? Widgets[W] : W extends (props: infer P) => any ? OmitBaseWidgetProps<P> : never;
|
|
3
4
|
export declare function defineSetting<CustomVisualizationSettings extends Record<string, unknown>, TValue, W extends WidgetName | ((props: any) => any)>(settingDefinition: {
|
|
4
5
|
id: string;
|
|
5
6
|
section?: string;
|
|
@@ -15,7 +16,7 @@ export declare function defineSetting<CustomVisualizationSettings extends Record
|
|
|
15
16
|
widget: W;
|
|
16
17
|
isValid?: (series: Series, settings: CustomVisualizationSettings) => boolean;
|
|
17
18
|
getDefault?: (series: Series, settings: CustomVisualizationSettings) => TValue;
|
|
18
|
-
getProps(object: Series, vizSettings: CustomVisualizationSettings)
|
|
19
|
+
getProps?: PropsFromWidget<W> extends never ? never : (object: Series, vizSettings: CustomVisualizationSettings) => PropsFromWidget<W>;
|
|
19
20
|
getValue?: (series: Series, settings: CustomVisualizationSettings) => TValue;
|
|
20
21
|
}): CustomVisualizationSettingDefinition<CustomVisualizationSettings>;
|
|
21
22
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineSetting.d.ts","sourceRoot":"","sources":["../../src/lib/defineSetting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,MAAM,EACN,UAAU,EACV,OAAO,EACR,MAAM,UAAU,CAAC;AAElB,KAAK,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,GAC1C,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,GAC/B,CAAC,
|
|
1
|
+
{"version":3,"file":"defineSetting.d.ts","sourceRoot":"","sources":["../../src/lib/defineSetting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oCAAoC,EACpC,MAAM,EACN,UAAU,EACV,OAAO,EACR,MAAM,UAAU,CAAC;AAElB,KAAK,mBAAmB,CAAC,CAAC,IAAI,MAAM,eAAe,CACjD,OAAO,EACP,OAAO,CACR,SAAS,MAAM,CAAC,GACb,IAAI,CAAC,CAAC,EAAE,MAAM,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,GAChD,CAAC,CAAC;AAEN,KAAK,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,GAC1C,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,GAC/B,mBAAmB,CAAC,CAAC,CAAC,GACtB,KAAK,CAAC;AAEZ,wBAAgB,aAAa,CAC3B,2BAA2B,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,MAAM,EACN,CAAC,SAAS,UAAU,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,EAC5C,iBAAiB,EAAE;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B,MAAM,EAAE,CAAC,CAAC;IAEV,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,2BAA2B,KAAK,OAAO,CAAC;IAC7E,UAAU,CAAC,EAAE,CACX,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,2BAA2B,KAClC,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,KAAK,GACvC,KAAK,GACL,CACE,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,2BAA2B,KACrC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,2BAA2B,KAAK,MAAM,CAAC;CAC9E,GAAG,oCAAoC,CAAC,2BAA2B,CAAC,CAEpE"}
|
package/dist/templates/index.tsx
CHANGED
|
@@ -16,9 +16,6 @@ const createVisualization: CreateCustomVisualization<Settings> = ({
|
|
|
16
16
|
getName: () => "__CUSTOM_VIZ_NAME__",
|
|
17
17
|
minSize: { width: 1, height: 1 },
|
|
18
18
|
defaultSize: { width: 2, height: 2 },
|
|
19
|
-
isSensible({ cols, rows }) {
|
|
20
|
-
return cols.length === 1 && rows.length === 1 && typeof rows[0][0] === "number";
|
|
21
|
-
},
|
|
22
19
|
checkRenderable(series, settings) {
|
|
23
20
|
if (series.length !== 1) {
|
|
24
21
|
throw new Error("Only 1 series is supported");
|
|
@@ -70,67 +67,73 @@ const createVisualization: CreateCustomVisualization<Settings> = ({
|
|
|
70
67
|
};
|
|
71
68
|
};
|
|
72
69
|
|
|
73
|
-
const makeVisualizationComponent =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const width = 540;
|
|
104
|
-
const height = 360;
|
|
105
|
-
const { series, settings } = props;
|
|
106
|
-
const { threshold } = settings;
|
|
107
|
-
const value = series[0].data.rows[0][0];
|
|
108
|
-
|
|
109
|
-
if (typeof value !== "number" || typeof threshold !== "number") {
|
|
110
|
-
throw new Error("Value and threshold need to be numbers");
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const emoji =
|
|
114
|
-
value >= threshold ? (
|
|
115
|
-
<img src={getAssetUrl("thumbs-up.png")} />
|
|
116
|
-
) : (
|
|
117
|
-
<img src={getAssetUrl("thumbs-down.png")} />
|
|
70
|
+
const makeVisualizationComponent =
|
|
71
|
+
(_getAssetUrl: (path: string) => string) =>
|
|
72
|
+
(props: CustomVisualizationProps<Settings>) => {
|
|
73
|
+
const { height, series, settings, width } = props;
|
|
74
|
+
const { threshold } = settings;
|
|
75
|
+
const value = series[0].data.rows[0][0];
|
|
76
|
+
|
|
77
|
+
if (!height || !width) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (typeof value !== "number" || typeof threshold !== "number") {
|
|
82
|
+
throw new Error("Value and threshold need to be numbers");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const emoji = value >= threshold ? "👍" : "👎";
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div
|
|
89
|
+
style={{
|
|
90
|
+
display: "flex",
|
|
91
|
+
justifyContent: "center",
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
width,
|
|
94
|
+
height,
|
|
95
|
+
fontSize: "10rem",
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{emoji}
|
|
99
|
+
</div>
|
|
118
100
|
);
|
|
101
|
+
};
|
|
119
102
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
103
|
+
const makeStaticVisualizationComponent =
|
|
104
|
+
(getAssetUrl: (path: string) => string) =>
|
|
105
|
+
(props: CustomStaticVisualizationProps<Settings>) => {
|
|
106
|
+
const width = 540;
|
|
107
|
+
const height = 360;
|
|
108
|
+
const { series, settings } = props;
|
|
109
|
+
const { threshold } = settings;
|
|
110
|
+
const value = series[0].data.rows[0][0];
|
|
111
|
+
|
|
112
|
+
if (typeof value !== "number" || typeof threshold !== "number") {
|
|
113
|
+
throw new Error("Value and threshold need to be numbers");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const emoji =
|
|
117
|
+
value >= threshold ? (
|
|
118
|
+
<img src={getAssetUrl("thumbs-up.png")} />
|
|
119
|
+
) : (
|
|
120
|
+
<img src={getAssetUrl("thumbs-down.png")} />
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div
|
|
125
|
+
style={{
|
|
126
|
+
display: "flex",
|
|
127
|
+
justifyContent: "center",
|
|
128
|
+
alignItems: "center",
|
|
129
|
+
width,
|
|
130
|
+
height,
|
|
131
|
+
fontSize: "10rem",
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
{emoji}
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
135
138
|
|
|
136
139
|
export default createVisualization;
|