From 89352b85fab74c28e44354fa7130d8a6cadcce6b Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Sat, 9 Nov 2024 00:20:00 +0100 Subject: [PATCH] fix: broken util --- package.json | 5 +- pnpm-lock.yaml | 446 ++----------------------------------- src/utils/content/index.ts | 32 ++- 3 files changed, 52 insertions(+), 431 deletions(-) diff --git a/package.json b/package.json index 43da23e1e..ba259fddf 100644 --- a/package.json +++ b/package.json @@ -72,14 +72,15 @@ "ufo": "^1.5.4", "unified": "^11.0.5", "unist-util-stringify-position": "^4.0.0", + "unist-util-visit": "^5.0.0", "ws": "^8.18.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.23.5", "zod-to-ts": "^1.2.0" }, "peerDependencies": { - "pg": "*", - "@libsql/client": "*" + "@libsql/client": "*", + "pg": "*" }, "devDependencies": { "@cloudflare/workers-types": "^4.20241106.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a193510eb..ceedc2c55 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,10 +18,10 @@ importers: version: 0.14.0 '@nuxt/kit': specifier: ^3.14.159 - version: 3.14.159(magicast@0.3.5)(rollup@3.29.5) + version: 3.14.159(magicast@0.3.5)(rollup@4.24.4) '@nuxtjs/mdc': specifier: ^0.9.2 - version: 0.9.2(magicast@0.3.5)(rollup@3.29.5) + version: 0.9.2(magicast@0.3.5)(rollup@4.24.4) '@sqlite.org/sqlite-wasm': specifier: 3.47.0-build1 version: 3.47.0-build1 @@ -115,6 +115,9 @@ importers: unist-util-stringify-position: specifier: ^4.0.0 version: 4.0.0 + unist-util-visit: + specifier: ^5.0.0 + version: 5.0.0 ws: specifier: ^8.18.0 version: 8.18.0 @@ -136,19 +139,19 @@ importers: version: 'link:' '@nuxt/devtools': specifier: ^1.6.0 - version: 1.6.0(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue@3.5.12(typescript@5.6.3)) + version: 1.6.0(rollup@4.24.4)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue@3.5.12(typescript@5.6.3)) '@nuxt/eslint-config': specifier: ^0.6.1 version: 0.6.1(eslint@9.14.0(jiti@2.4.0))(typescript@5.6.3) '@nuxt/module-builder': specifier: ^0.8.4 - version: 0.8.4(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(nuxi@3.15.0)(typescript@5.6.3)(vue-tsc@2.1.10(typescript@5.6.3)) + version: 0.8.4(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@4.24.4))(nuxi@3.15.0)(typescript@5.6.3)(vue-tsc@2.1.10(typescript@5.6.3)) '@nuxt/schema': specifier: ^3.14.159 - version: 3.14.159(magicast@0.3.5)(rollup@3.29.5) + version: 3.14.159(magicast@0.3.5)(rollup@4.24.4) '@nuxt/test-utils': specifier: ^3.14.4 - version: 3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)) + version: 3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@4.24.4)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)) '@types/better-sqlite3': specifier: ^7.6.11 version: 7.6.11 @@ -175,7 +178,7 @@ importers: version: 2.0.0 nuxt: specifier: ^3.14.159 - version: 3.14.159(@libsql/client@0.14.0)(@parcel/watcher@2.5.0)(@types/node@22.9.0)(better-sqlite3@11.5.0)(eslint@9.14.0(jiti@2.4.0))(ioredis@5.4.1)(lightningcss@1.28.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@3.29.5)(terser@5.36.0)(typescript@5.6.3)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.6.3)) + version: 3.14.159(@libsql/client@0.14.0)(@parcel/watcher@2.5.0)(@types/node@22.9.0)(better-sqlite3@11.5.0)(eslint@9.14.0(jiti@2.4.0))(ioredis@5.4.1)(lightningcss@1.28.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.24.4)(terser@5.36.0)(typescript@5.6.3)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.6.3)) release-it: specifier: ^17.10.0 version: 17.10.0(typescript@5.6.3) @@ -7641,18 +7644,6 @@ snapshots: '@nuxt/devalue@2.0.2': {} - '@nuxt/devtools-kit@1.6.0(magicast@0.3.5)(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))': - dependencies: - '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - '@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - execa: 7.2.0 - vite: 5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0) - transitivePeerDependencies: - - magicast - - rollup - - supports-color - - webpack-sources - '@nuxt/devtools-kit@1.6.0(magicast@0.3.5)(rollup@4.24.4)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))': dependencies: '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.24.4) @@ -7678,54 +7669,6 @@ snapshots: rc9: 2.1.2 semver: 7.6.3 - '@nuxt/devtools@1.6.0(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue@3.5.12(typescript@5.6.3))': - dependencies: - '@antfu/utils': 0.7.10 - '@nuxt/devtools-kit': 1.6.0(magicast@0.3.5)(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0)) - '@nuxt/devtools-wizard': 1.6.0 - '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - '@vue/devtools-core': 7.4.4(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue@3.5.12(typescript@5.6.3)) - '@vue/devtools-kit': 7.4.4 - birpc: 0.2.19 - consola: 3.2.3 - cronstrue: 2.51.0 - destr: 2.0.3 - error-stack-parser-es: 0.1.5 - execa: 7.2.0 - fast-npm-meta: 0.2.2 - flatted: 3.3.1 - get-port-please: 3.1.2 - hookable: 5.5.3 - image-meta: 0.2.1 - is-installed-globally: 1.0.0 - launch-editor: 2.9.1 - local-pkg: 0.5.0 - magicast: 0.3.5 - nypm: 0.3.12 - ohash: 1.1.4 - pathe: 1.1.2 - perfect-debounce: 1.0.0 - pkg-types: 1.2.1 - rc9: 2.1.2 - scule: 1.3.0 - semver: 7.6.3 - simple-git: 3.27.0 - sirv: 2.0.4 - tinyglobby: 0.2.10 - unimport: 3.13.1(rollup@3.29.5) - vite: 5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0) - vite-plugin-inspect: 0.8.7(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0)) - vite-plugin-vue-inspector: 5.1.3(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0)) - which: 3.0.1 - ws: 8.18.0 - transitivePeerDependencies: - - bufferutil - - rollup - - supports-color - - utf-8-validate - - vue - - webpack-sources - '@nuxt/devtools@1.6.0(rollup@4.24.4)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue@3.5.12(typescript@5.6.3))': dependencies: '@antfu/utils': 0.7.10 @@ -7905,34 +7848,6 @@ snapshots: - supports-color - webpack-sources - '@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5)': - dependencies: - '@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - c12: 2.0.1(magicast@0.3.5) - consola: 3.2.3 - defu: 6.1.4 - destr: 2.0.3 - globby: 14.0.2 - hash-sum: 2.0.0 - ignore: 6.0.2 - jiti: 2.4.0 - klona: 2.0.6 - knitwork: 1.1.0 - mlly: 1.7.2 - pathe: 1.1.2 - pkg-types: 1.2.1 - scule: 1.3.0 - semver: 7.6.3 - ufo: 1.5.4 - unctx: 2.3.1 - unimport: 3.13.1(rollup@3.29.5) - untyped: 1.5.1 - transitivePeerDependencies: - - magicast - - rollup - - supports-color - - webpack-sources - '@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@4.24.4)': dependencies: '@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@4.24.4) @@ -7961,9 +7876,9 @@ snapshots: - supports-color - webpack-sources - '@nuxt/module-builder@0.8.4(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(nuxi@3.15.0)(typescript@5.6.3)(vue-tsc@2.1.10(typescript@5.6.3))': + '@nuxt/module-builder@0.8.4(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@4.24.4))(nuxi@3.15.0)(typescript@5.6.3)(vue-tsc@2.1.10(typescript@5.6.3))': dependencies: - '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5) + '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.24.4) citty: 0.1.6 consola: 3.2.3 defu: 6.1.4 @@ -7981,27 +7896,6 @@ snapshots: - vue-tsc - webpack-sources - '@nuxt/schema@3.14.159(magicast@0.3.5)(rollup@3.29.5)': - dependencies: - c12: 2.0.1(magicast@0.3.5) - compatx: 0.1.8 - consola: 3.2.3 - defu: 6.1.4 - hookable: 5.5.3 - pathe: 1.1.2 - pkg-types: 1.2.1 - scule: 1.3.0 - std-env: 3.7.0 - ufo: 1.5.4 - uncrypto: 0.1.3 - unimport: 3.13.1(rollup@3.29.5) - untyped: 1.5.1 - transitivePeerDependencies: - - magicast - - rollup - - supports-color - - webpack-sources - '@nuxt/schema@3.14.159(magicast@0.3.5)(rollup@4.24.4)': dependencies: c12: 2.0.1(magicast@0.3.5) @@ -8023,32 +7917,6 @@ snapshots: - supports-color - webpack-sources - '@nuxt/telemetry@2.6.0(magicast@0.3.5)(rollup@3.29.5)': - dependencies: - '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - ci-info: 4.0.0 - consola: 3.2.3 - create-require: 1.1.1 - defu: 6.1.4 - destr: 2.0.3 - dotenv: 16.4.5 - git-url-parse: 15.0.0 - is-docker: 3.0.0 - jiti: 1.21.6 - mri: 1.2.0 - nanoid: 5.0.8 - ofetch: 1.4.1 - package-manager-detector: 0.2.2 - parse-git-config: 3.0.0 - pathe: 1.1.2 - rc9: 2.1.2 - std-env: 3.7.0 - transitivePeerDependencies: - - magicast - - rollup - - supports-color - - webpack-sources - '@nuxt/telemetry@2.6.0(magicast@0.3.5)(rollup@4.24.4)': dependencies: '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.24.4) @@ -8075,10 +7943,10 @@ snapshots: - supports-color - webpack-sources - '@nuxt/test-utils@3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3))': + '@nuxt/test-utils@3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@4.24.4)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3))': dependencies: - '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - '@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@3.29.5) + '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.24.4) + '@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@4.24.4) c12: 2.0.1(magicast@0.3.5) consola: 3.2.3 defu: 6.1.4 @@ -8102,7 +7970,7 @@ snapshots: unenv: 1.10.0 unplugin: 1.15.0 vite: 5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0) - vitest-environment-nuxt: 1.0.1(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)) + vitest-environment-nuxt: 1.0.1(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@4.24.4)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)) vue: 3.5.12(typescript@5.6.3) vue-router: 4.4.5(vue@3.5.12(typescript@5.6.3)) optionalDependencies: @@ -8240,66 +8108,6 @@ snapshots: - vue - webpack-sources - '@nuxt/vite-builder@3.14.159(@types/node@22.9.0)(eslint@9.14.0(jiti@2.4.0))(lightningcss@1.28.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@3.29.5)(terser@5.36.0)(typescript@5.6.3)(vue-tsc@2.1.10(typescript@5.6.3))(vue@3.5.12(typescript@5.6.3))': - dependencies: - '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - '@rollup/plugin-replace': 6.0.1(rollup@3.29.5) - '@vitejs/plugin-vue': 5.1.4(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue@3.5.12(typescript@5.6.3)) - '@vitejs/plugin-vue-jsx': 4.0.1(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue@3.5.12(typescript@5.6.3)) - autoprefixer: 10.4.20(postcss@8.4.47) - clear: 0.1.0 - consola: 3.2.3 - cssnano: 7.0.6(postcss@8.4.47) - defu: 6.1.4 - esbuild: 0.24.0 - escape-string-regexp: 5.0.0 - estree-walker: 3.0.3 - externality: 1.0.2 - get-port-please: 3.1.2 - h3: 1.13.0 - jiti: 2.4.0 - knitwork: 1.1.0 - magic-string: 0.30.12 - mlly: 1.7.2 - ohash: 1.1.4 - pathe: 1.1.2 - perfect-debounce: 1.0.0 - pkg-types: 1.2.1 - postcss: 8.4.47 - rollup-plugin-visualizer: 5.12.0(rollup@3.29.5) - std-env: 3.7.0 - strip-literal: 2.1.0 - ufo: 1.5.4 - unenv: 1.10.0 - unplugin: 1.15.0 - vite: 5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0) - vite-node: 2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0) - vite-plugin-checker: 0.8.0(eslint@9.14.0(jiti@2.4.0))(optionator@0.9.4)(typescript@5.6.3)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.6.3)) - vue: 3.5.12(typescript@5.6.3) - vue-bundle-renderer: 2.1.1 - transitivePeerDependencies: - - '@biomejs/biome' - - '@types/node' - - eslint - - less - - lightningcss - - magicast - - meow - - optionator - - rollup - - sass - - sass-embedded - - stylelint - - stylus - - sugarss - - supports-color - - terser - - typescript - - vls - - vti - - vue-tsc - - webpack-sources - '@nuxt/vite-builder@3.14.159(@types/node@22.9.0)(eslint@9.14.0(jiti@2.4.0))(lightningcss@1.28.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.24.4)(terser@5.36.0)(typescript@5.6.3)(vue-tsc@2.1.10(typescript@5.6.3))(vue@3.5.12(typescript@5.6.3))': dependencies: '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.24.4) @@ -8413,9 +8221,9 @@ snapshots: - supports-color - webpack-sources - '@nuxtjs/mdc@0.9.2(magicast@0.3.5)(rollup@3.29.5)': + '@nuxtjs/mdc@0.9.2(magicast@0.3.5)(rollup@4.24.4)': dependencies: - '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5) + '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@4.24.4) '@shikijs/transformers': 1.22.2 '@types/hast': 3.0.4 '@types/mdast': 4.0.4 @@ -8826,13 +8634,6 @@ snapshots: optionalDependencies: rollup: 3.29.5 - '@rollup/plugin-replace@6.0.1(rollup@3.29.5)': - dependencies: - '@rollup/pluginutils': 5.1.3(rollup@3.29.5) - magic-string: 0.30.12 - optionalDependencies: - rollup: 3.29.5 - '@rollup/plugin-replace@6.0.1(rollup@4.24.4)': dependencies: '@rollup/pluginutils': 5.1.3(rollup@4.24.4) @@ -9357,19 +9158,6 @@ snapshots: path-browserify: 1.0.1 vscode-uri: 3.0.8 - '@vue-macros/common@1.15.0(rollup@3.29.5)(vue@3.5.12(typescript@5.6.3))': - dependencies: - '@babel/types': 7.26.0 - '@rollup/pluginutils': 5.1.3(rollup@3.29.5) - '@vue/compiler-sfc': 3.5.12 - ast-kit: 1.3.1 - local-pkg: 0.5.0 - magic-string-ast: 0.6.2 - optionalDependencies: - vue: 3.5.12(typescript@5.6.3) - transitivePeerDependencies: - - rollup - '@vue-macros/common@1.15.0(rollup@4.24.4)(vue@3.5.12(typescript@5.6.3))': dependencies: '@babel/types': 7.26.0 @@ -11295,17 +11083,6 @@ snapshots: parent-module: 1.0.1 resolve-from: 4.0.0 - impound@0.2.0(rollup@3.29.5): - dependencies: - '@rollup/pluginutils': 5.1.3(rollup@3.29.5) - mlly: 1.7.2 - pathe: 1.1.2 - unenv: 1.10.0 - unplugin: 1.15.0 - transitivePeerDependencies: - - rollup - - webpack-sources - impound@0.2.0(rollup@4.24.4): dependencies: '@rollup/pluginutils': 5.1.3(rollup@4.24.4) @@ -12513,120 +12290,6 @@ snapshots: - vue - webpack-sources - nuxt@3.14.159(@libsql/client@0.14.0)(@parcel/watcher@2.5.0)(@types/node@22.9.0)(better-sqlite3@11.5.0)(eslint@9.14.0(jiti@2.4.0))(ioredis@5.4.1)(lightningcss@1.28.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@3.29.5)(terser@5.36.0)(typescript@5.6.3)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.6.3)): - dependencies: - '@nuxt/devalue': 2.0.2 - '@nuxt/devtools': 1.6.0(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue@3.5.12(typescript@5.6.3)) - '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - '@nuxt/schema': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - '@nuxt/telemetry': 2.6.0(magicast@0.3.5)(rollup@3.29.5) - '@nuxt/vite-builder': 3.14.159(@types/node@22.9.0)(eslint@9.14.0(jiti@2.4.0))(lightningcss@1.28.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@3.29.5)(terser@5.36.0)(typescript@5.6.3)(vue-tsc@2.1.10(typescript@5.6.3))(vue@3.5.12(typescript@5.6.3)) - '@unhead/dom': 1.11.11 - '@unhead/shared': 1.11.11 - '@unhead/ssr': 1.11.11 - '@unhead/vue': 1.11.11(vue@3.5.12(typescript@5.6.3)) - '@vue/shared': 3.5.12 - acorn: 8.14.0 - c12: 2.0.1(magicast@0.3.5) - chokidar: 4.0.1 - compatx: 0.1.8 - consola: 3.2.3 - cookie-es: 1.2.2 - defu: 6.1.4 - destr: 2.0.3 - devalue: 5.1.1 - errx: 0.1.0 - esbuild: 0.24.0 - escape-string-regexp: 5.0.0 - estree-walker: 3.0.3 - globby: 14.0.2 - h3: 1.13.0 - hookable: 5.5.3 - ignore: 6.0.2 - impound: 0.2.0(rollup@3.29.5) - jiti: 2.4.0 - klona: 2.0.6 - knitwork: 1.1.0 - magic-string: 0.30.12 - mlly: 1.7.2 - nanotar: 0.1.1 - nitropack: 2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3) - nuxi: 3.15.0 - nypm: 0.3.12 - ofetch: 1.4.1 - ohash: 1.1.4 - pathe: 1.1.2 - perfect-debounce: 1.0.0 - pkg-types: 1.2.1 - radix3: 1.1.2 - scule: 1.3.0 - semver: 7.6.3 - std-env: 3.7.0 - strip-literal: 2.1.0 - tinyglobby: 0.2.10 - ufo: 1.5.4 - ultrahtml: 1.5.3 - uncrypto: 0.1.3 - unctx: 2.3.1 - unenv: 1.10.0 - unhead: 1.11.11 - unimport: 3.13.1(rollup@3.29.5) - unplugin: 1.15.0 - unplugin-vue-router: 0.10.8(rollup@3.29.5)(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)) - unstorage: 1.13.1(ioredis@5.4.1) - untyped: 1.5.1 - vue: 3.5.12(typescript@5.6.3) - vue-bundle-renderer: 2.1.1 - vue-devtools-stub: 0.1.0 - vue-router: 4.4.5(vue@3.5.12(typescript@5.6.3)) - optionalDependencies: - '@parcel/watcher': 2.5.0 - '@types/node': 22.9.0 - transitivePeerDependencies: - - '@azure/app-configuration' - - '@azure/cosmos' - - '@azure/data-tables' - - '@azure/identity' - - '@azure/keyvault-secrets' - - '@azure/storage-blob' - - '@biomejs/biome' - - '@capacitor/preferences' - - '@electric-sql/pglite' - - '@libsql/client' - - '@netlify/blobs' - - '@planetscale/database' - - '@upstash/redis' - - '@vercel/kv' - - better-sqlite3 - - bufferutil - - drizzle-orm - - encoding - - eslint - - idb-keyval - - ioredis - - less - - lightningcss - - magicast - - meow - - mysql2 - - optionator - - rollup - - sass - - sass-embedded - - stylelint - - stylus - - sugarss - - supports-color - - terser - - typescript - - utf-8-validate - - vite - - vls - - vti - - vue-tsc - - webpack-sources - - xml2js - nuxt@3.14.159(@libsql/client@0.14.0)(@parcel/watcher@2.5.0)(@types/node@22.9.0)(better-sqlite3@11.5.0)(eslint@9.14.0(jiti@2.4.0))(ioredis@5.4.1)(lightningcss@1.28.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.24.4)(terser@5.36.0)(typescript@5.6.3)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-tsc@2.1.10(typescript@5.6.3)): dependencies: '@nuxt/devalue': 2.0.2 @@ -13630,15 +13293,6 @@ snapshots: dependencies: rollup-plugin-inject: 3.0.2 - rollup-plugin-visualizer@5.12.0(rollup@3.29.5): - dependencies: - open: 8.4.2 - picomatch: 2.3.1 - source-map: 0.7.4 - yargs: 17.7.2 - optionalDependencies: - rollup: 3.29.5 - rollup-plugin-visualizer@5.12.0(rollup@4.24.4): dependencies: open: 8.4.2 @@ -14311,25 +13965,6 @@ snapshots: css-tree: 3.0.1 ohash: 1.1.4 - unimport@3.13.1(rollup@3.29.5): - dependencies: - '@rollup/pluginutils': 5.1.3(rollup@3.29.5) - acorn: 8.12.1 - escape-string-regexp: 5.0.0 - estree-walker: 3.0.3 - fast-glob: 3.3.2 - local-pkg: 0.5.0 - magic-string: 0.30.12 - mlly: 1.7.2 - pathe: 1.1.2 - pkg-types: 1.2.1 - scule: 1.3.0 - strip-literal: 2.1.0 - unplugin: 1.15.0 - transitivePeerDependencies: - - rollup - - webpack-sources - unimport@3.13.1(rollup@4.24.4): dependencies: '@rollup/pluginutils': 5.1.3(rollup@4.24.4) @@ -14420,29 +14055,6 @@ snapshots: - supports-color - webpack-sources - unplugin-vue-router@0.10.8(rollup@3.29.5)(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)): - dependencies: - '@babel/types': 7.26.0 - '@rollup/pluginutils': 5.1.3(rollup@3.29.5) - '@vue-macros/common': 1.15.0(rollup@3.29.5)(vue@3.5.12(typescript@5.6.3)) - ast-walker-scope: 0.6.2 - chokidar: 3.6.0 - fast-glob: 3.3.2 - json5: 2.2.3 - local-pkg: 0.5.0 - magic-string: 0.30.12 - mlly: 1.7.2 - pathe: 1.1.2 - scule: 1.3.0 - unplugin: 1.15.0 - yaml: 2.6.0 - optionalDependencies: - vue-router: 4.4.5(vue@3.5.12(typescript@5.6.3)) - transitivePeerDependencies: - - rollup - - vue - - webpack-sources - unplugin-vue-router@0.10.8(rollup@4.24.4)(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)): dependencies: '@babel/types': 7.26.0 @@ -14624,24 +14236,6 @@ snapshots: typescript: 5.6.3 vue-tsc: 2.1.10(typescript@5.6.3) - vite-plugin-inspect@0.8.7(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@3.29.5))(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0)): - dependencies: - '@antfu/utils': 0.7.10 - '@rollup/pluginutils': 5.1.3(rollup@3.29.5) - debug: 4.3.7(supports-color@9.4.0) - error-stack-parser-es: 0.1.5 - fs-extra: 11.2.0 - open: 10.1.0 - perfect-debounce: 1.0.0 - picocolors: 1.1.1 - sirv: 2.0.4 - vite: 5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0) - optionalDependencies: - '@nuxt/kit': 3.14.159(magicast@0.3.5)(rollup@3.29.5) - transitivePeerDependencies: - - rollup - - supports-color - vite-plugin-inspect@0.8.7(@nuxt/kit@3.14.159(magicast@0.3.5)(rollup@4.24.4))(rollup@4.24.4)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0)): dependencies: '@antfu/utils': 0.7.10 @@ -14686,9 +14280,9 @@ snapshots: lightningcss: 1.28.1 terser: 5.36.0 - vitest-environment-nuxt@1.0.1(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)): + vitest-environment-nuxt@1.0.1(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@4.24.4)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)): dependencies: - '@nuxt/test-utils': 3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@3.29.5)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)) + '@nuxt/test-utils': 3.14.4(h3@1.13.0)(magicast@0.3.5)(nitropack@2.10.3(@libsql/client@0.14.0)(better-sqlite3@11.5.0)(typescript@5.6.3))(playwright-core@1.48.2)(rollup@4.24.4)(vite@5.4.10(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vitest@2.1.4(@types/node@22.9.0)(lightningcss@1.28.1)(terser@5.36.0))(vue-router@4.4.5(vue@3.5.12(typescript@5.6.3)))(vue@3.5.12(typescript@5.6.3)) transitivePeerDependencies: - '@cucumber/cucumber' - '@jest/globals' diff --git a/src/utils/content/index.ts b/src/utils/content/index.ts index aae857e74..c3a6c2b41 100644 --- a/src/utils/content/index.ts +++ b/src/utils/content/index.ts @@ -4,6 +4,7 @@ import type { Highlighter, MdcConfig, ModuleOptions as MDCModuleOptions } from ' import type { Nuxt } from '@nuxt/schema' import { defu } from 'defu' import { createOnigurumaEngine } from 'shiki/engine/oniguruma' +import { visit } from 'unist-util-visit' import type { ResolvedCollection } from '../../types/collection' import type { ModuleOptions } from '../../types/module' import { transformContent } from './transformers' @@ -15,7 +16,8 @@ export function setParserOptions(opts: Partial) { parserOptions = defu(opts, parserOptions) } -type HighlighterOptions = Exclude +type HighlighterOptions = Exclude & { compress: boolean } +type HighlightedNode = { type: 'element', properties?: Record } let highlightPlugin: { instance: unknown @@ -59,7 +61,31 @@ async function _getHighlightPlugin(options: HighlighterOptions) { key, instance: rehypeHighlight, ...options, - highlighter, + highlighter: async (code, lang, theme, opts) => { + const result = await highlighter(code, lang, theme, opts) + const visitTree = { + type: 'element', + children: result.tree as Array, + } + if (options.compress) { + const stylesMap: Record = {} + visit( + visitTree, + node => !!(node as HighlightedNode).properties?.style, + (_node) => { + const node = _node as HighlightedNode + const style = node.properties!.style! + stylesMap[style] = stylesMap[style] || 's' + hash(style).substring(0, 4) + node.properties!.class = `${node.properties!.class || ''} ${stylesMap[style]}`.trim() + node.properties!.style = undefined + }, + ) + + result.style = Object.entries(stylesMap).map(([style, cls]) => `.${cls}{${style}}`).join('') + result.style + } + + return result + }, theme: Object.fromEntries(bundledThemes), } } @@ -76,7 +102,7 @@ export async function parseContent(key: string, content: string, collection: Res rehypePlugins: { highlight: mdcOptions.highlight === false ? undefined - : await getHighlightPluginInstance(mdcOptions.highlight || {}), + : await getHighlightPluginInstance({ ...mdcOptions.highlight, compress: true }), ...mdcOptions?.rehypePlugins, ...contentOptions?.rehypePlugins, },