diff --git a/Cargo.toml b/Cargo.toml index 37722724..3021e5da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,6 @@ members = [ "packages/ducsvg/src/pdf2svg", ] -[workspace.dependencies] -duc = { version = "1" } [profile.release] lto = true diff --git a/bun.lock b/bun.lock index ecd09e4e..38f59eb5 100644 --- a/bun.lock +++ b/bun.lock @@ -116,13 +116,10 @@ "semantic-release": "^24.1.2", "typescript": "^5.8.3", "vite": "^6.0.0", + "vite-plugin-compression": "^0.5.1", "vitest": "^3.2.4", }, }, - "packages/pkg": { - "name": "duc2pdf", - "version": "0.0.0-development", - }, "packages/tsconfig": { "name": "@duc/tsconfig", "version": "0.0.0", @@ -603,7 +600,7 @@ "ansi-regex": ["ansi-regex@6.1.0", "", {}, "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA=="], - "ansi-styles": ["ansi-styles@3.2.1", "", { "dependencies": { "color-convert": "^1.9.0" } }, ""], + "ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, ""], "any-promise": ["any-promise@1.3.0", "", {}, ""], @@ -677,7 +674,7 @@ "chai": ["chai@5.3.3", "", { "dependencies": { "assertion-error": "^2.0.1", "check-error": "^2.1.1", "deep-eql": "^5.0.1", "loupe": "^3.1.0", "pathval": "^2.0.0" } }, "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw=="], - "chalk": ["chalk@5.4.1", "", {}, "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w=="], + "chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, ""], "char-regex": ["char-regex@1.0.2", "", {}, ""], @@ -711,9 +708,9 @@ "collapse-white-space": ["collapse-white-space@2.1.0", "", {}, ""], - "color-convert": ["color-convert@1.9.3", "", { "dependencies": { "color-name": "1.1.3" } }, ""], + "color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, ""], - "color-name": ["color-name@1.1.3", "", {}, ""], + "color-name": ["color-name@1.1.4", "", {}, ""], "comma-separated-tokens": ["comma-separated-tokens@2.0.3", "", {}, ""], @@ -787,8 +784,6 @@ "dot-prop": ["dot-prop@5.3.0", "", { "dependencies": { "is-obj": "^2.0.0" } }, ""], - "duc2pdf": ["duc2pdf@workspace:packages/pkg"], - "ducdxf": ["ducdxf@workspace:packages/ducdxf"], "ducjs": ["ducjs@workspace:packages/ducjs"], @@ -1791,6 +1786,8 @@ "vite-node": ["vite-node@3.2.4", "", { "dependencies": { "cac": "^6.7.14", "debug": "^4.4.1", "es-module-lexer": "^1.7.0", "pathe": "^2.0.3", "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" }, "bin": { "vite-node": "vite-node.mjs" } }, "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg=="], + "vite-plugin-compression": ["vite-plugin-compression@0.5.1", "", { "dependencies": { "chalk": "^4.1.2", "debug": "^4.3.3", "fs-extra": "^10.0.0" }, "peerDependencies": { "vite": ">=2.0.0" } }, "sha512-5QJKBDc+gNYVqL/skgFAP81Yuzo9R+EAf19d+EtsMF/i8kFUpNi3J/H01QD3Oo8zBQn+NzoCIFkpPLynoOzaJg=="], + "vitest": ["vitest@3.2.4", "", { "dependencies": { "@types/chai": "^5.2.2", "@vitest/expect": "3.2.4", "@vitest/mocker": "3.2.4", "@vitest/pretty-format": "^3.2.4", "@vitest/runner": "3.2.4", "@vitest/snapshot": "3.2.4", "@vitest/spy": "3.2.4", "@vitest/utils": "3.2.4", "chai": "^5.2.0", "debug": "^4.4.1", "expect-type": "^1.2.1", "magic-string": "^0.30.17", "pathe": "^2.0.3", "picomatch": "^4.0.2", "std-env": "^3.9.0", "tinybench": "^2.9.0", "tinyexec": "^0.3.2", "tinyglobby": "^0.2.14", "tinypool": "^1.1.1", "tinyrainbow": "^2.0.0", "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", "vite-node": "3.2.4", "why-is-node-running": "^2.3.0" }, "peerDependencies": { "@edge-runtime/vm": "*", "@types/debug": "^4.1.12", "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "@vitest/browser": "3.2.4", "@vitest/ui": "3.2.4", "happy-dom": "*", "jsdom": "*" }, "optionalPeers": ["@edge-runtime/vm", "@types/debug", "@types/node", "@vitest/browser", "@vitest/ui", "happy-dom", "jsdom"], "bin": { "vitest": "vitest.mjs" } }, "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A=="], "wasm-pack": ["wasm-pack@0.12.1", "", { "dependencies": { "binary-install": "^1.0.1" }, "bin": { "wasm-pack": "run.js" } }, "sha512-dIyKWUumPFsGohdndZjDXRFaokUT/kQS+SavbbiXVAvA/eN4riX5QNdB6AhXQx37zNxluxQkuixZUgJ8adKjOg=="], @@ -1945,8 +1942,6 @@ "body-parser/debug": ["debug@4.4.0", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA=="], - "cli-highlight/chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, ""], - "cli-highlight/yargs": ["yargs@16.2.0", "", { "dependencies": { "cliui": "^7.0.2", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.0", "y18n": "^5.0.5", "yargs-parser": "^20.2.2" } }, ""], "content-disposition/safe-buffer": ["safe-buffer@5.2.1", "", {}, "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="], @@ -2017,6 +2012,8 @@ "load-json-file/parse-json": ["parse-json@4.0.0", "", { "dependencies": { "error-ex": "^1.3.1", "json-parse-better-errors": "^1.0.1" } }, ""], + "marked-terminal/chalk": ["chalk@5.4.1", "", {}, "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w=="], + "micromark-extension-mdx-expression/@types/estree": ["@types/estree@1.0.6", "", {}, ""], "micromark-extension-mdx-jsx/@types/estree": ["@types/estree@1.0.6", "", {}, ""], @@ -2415,11 +2412,15 @@ "vite-node/vite": ["vite@7.1.10", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-CmuvUBzVJ/e3HGxhg6cYk88NGgTnBoOo7ogtfJJ0fefUWAxN/WDSUa50o+oVBxuIhO8FoEZW0j2eW7sfjs5EtA=="], + "vite-plugin-compression/debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="], + + "vite-plugin-compression/fs-extra": ["fs-extra@10.1.0", "", { "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", "universalify": "^2.0.0" } }, "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ=="], + "vitest/debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="], "vitest/vite": ["vite@7.1.10", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-CmuvUBzVJ/e3HGxhg6cYk88NGgTnBoOo7ogtfJJ0fefUWAxN/WDSUa50o+oVBxuIhO8FoEZW0j2eW7sfjs5EtA=="], - "wrap-ansi/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, ""], + "@babel/highlight/chalk/ansi-styles": ["ansi-styles@3.2.1", "", { "dependencies": { "color-convert": "^1.9.0" } }, ""], "@babel/highlight/chalk/escape-string-regexp": ["escape-string-regexp@1.0.5", "", {}, ""], @@ -2493,8 +2494,6 @@ "@tailwindcss/node/magic-string/@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.5", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="], - "cli-highlight/chalk/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, ""], - "cli-highlight/yargs/cliui": ["cliui@7.0.4", "", { "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", "wrap-ansi": "^7.0.0" } }, ""], "cli-highlight/yargs/yargs-parser": ["yargs-parser@20.2.9", "", {}, ""], @@ -2573,18 +2572,18 @@ "semantic-release/env-ci/execa": ["execa@8.0.1", "", { "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^8.0.1", "human-signals": "^5.0.0", "is-stream": "^3.0.0", "merge-stream": "^2.0.0", "npm-run-path": "^5.1.0", "onetime": "^6.0.0", "signal-exit": "^4.1.0", "strip-final-newline": "^3.0.0" } }, ""], + "signale/chalk/ansi-styles": ["ansi-styles@3.2.1", "", { "dependencies": { "color-convert": "^1.9.0" } }, ""], + "signale/chalk/escape-string-regexp": ["escape-string-regexp@1.0.5", "", {}, ""], "signale/chalk/supports-color": ["supports-color@5.5.0", "", { "dependencies": { "has-flag": "^3.0.0" } }, ""], "signale/figures/escape-string-regexp": ["escape-string-regexp@1.0.5", "", {}, ""], - "wrap-ansi/ansi-styles/color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, ""], + "@babel/highlight/chalk/ansi-styles/color-convert": ["color-convert@1.9.3", "", { "dependencies": { "color-name": "1.1.3" } }, ""], "@babel/highlight/chalk/supports-color/has-flag": ["has-flag@3.0.0", "", {}, ""], - "cli-highlight/chalk/ansi-styles/color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, ""], - "env-ci/execa/npm-run-path/path-key": ["path-key@4.0.0", "", {}, ""], "env-ci/execa/onetime/mimic-fn": ["mimic-fn@4.0.0", "", {}, ""], @@ -2977,11 +2976,11 @@ "semantic-release/env-ci/execa/strip-final-newline": ["strip-final-newline@3.0.0", "", {}, ""], - "signale/chalk/supports-color/has-flag": ["has-flag@3.0.0", "", {}, ""], + "signale/chalk/ansi-styles/color-convert": ["color-convert@1.9.3", "", { "dependencies": { "color-name": "1.1.3" } }, ""], - "wrap-ansi/ansi-styles/color-convert/color-name": ["color-name@1.1.4", "", {}, ""], + "signale/chalk/supports-color/has-flag": ["has-flag@3.0.0", "", {}, ""], - "cli-highlight/chalk/ansi-styles/color-convert/color-name": ["color-name@1.1.4", "", {}, ""], + "@babel/highlight/chalk/ansi-styles/color-convert/color-name": ["color-name@1.1.3", "", {}, ""], "read-package-up/read-pkg/normalize-package-data/hosted-git-info/lru-cache": ["lru-cache@10.4.3", "", {}, ""], @@ -3035,6 +3034,8 @@ "semantic-release/env-ci/execa/onetime/mimic-fn": ["mimic-fn@4.0.0", "", {}, ""], + "signale/chalk/ansi-styles/color-convert/color-name": ["color-name@1.1.3", "", {}, ""], + "semantic-release/@semantic-release/npm/npm/@isaacs/cliui/string-width/emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="], "semantic-release/@semantic-release/npm/npm/@isaacs/cliui/strip-ansi/ansi-regex": ["ansi-regex@6.1.0", "", {}, "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA=="], diff --git a/packages/ducpdf/src/duc2pdf/Cargo.toml b/packages/ducpdf/src/duc2pdf/Cargo.toml index e7479525..d46988e9 100644 --- a/packages/ducpdf/src/duc2pdf/Cargo.toml +++ b/packages/ducpdf/src/duc2pdf/Cargo.toml @@ -21,6 +21,7 @@ path = "src/lib.rs" crate-type = ["cdylib", "rlib"] [dependencies] +# Local dev: uses path. Publish: release script updates to crates.io version duc = { version = "0.0.0-development", path = "../../../ducrs" } hipdf = { version = "1.3.2", features = ["wasm_js"] } svg2pdf = "0.13.0" diff --git a/packages/ducpdf/src/duc2pdf/README.md b/packages/ducpdf/src/duc2pdf/README.md index 0b45a717..c1fe7e37 100644 --- a/packages/ducpdf/src/duc2pdf/README.md +++ b/packages/ducpdf/src/duc2pdf/README.md @@ -80,3 +80,4 @@ To ensure smooth releases with semantic-release, please follow [these guidelines --- *The duc format and libraries are constantly evolving, aiming to set new standards in the 2D CAD industry. Be a part of this transformation and help shape the future of design technology!* + diff --git a/packages/ducpdf/src/duc2pdf/release.config.cjs b/packages/ducpdf/src/duc2pdf/release.config.cjs index b1e6d292..24f52b09 100644 --- a/packages/ducpdf/src/duc2pdf/release.config.cjs +++ b/packages/ducpdf/src/duc2pdf/release.config.cjs @@ -18,9 +18,12 @@ module.exports = { [ "@semantic-release/exec", { - // Prepare step: Set the crate version and build the project + // Prepare step: + // 1. Update duc dependency to use crates.io version (not development) + // 2. Set the crate version + // 3. Build the project prepareCmd: - "cargo set-version ${nextRelease.version} && cargo build --release", + "node ../../../../scripts/cargo-set-duc-dep-version.js . 2 && cargo set-version ${nextRelease.version} && cargo build --release", // Publish step: Publish the crate to crates.io publishCmd: diff --git a/packages/ducsvg/package.json b/packages/ducsvg/package.json index e0b0fc36..e779eb21 100644 --- a/packages/ducsvg/package.json +++ b/packages/ducsvg/package.json @@ -42,6 +42,7 @@ "semantic-release": "^24.1.2", "typescript": "^5.8.3", "vite": "^6.0.0", + "vite-plugin-compression": "^0.5.1", "vitest": "^3.2.4" }, "files": [ diff --git a/packages/ducsvg/vite.config.mts b/packages/ducsvg/vite.config.mts index e1e8201c..e27ec967 100644 --- a/packages/ducsvg/vite.config.mts +++ b/packages/ducsvg/vite.config.mts @@ -1,6 +1,16 @@ import { defineConfig } from 'vite'; +import viteCompression from 'vite-plugin-compression'; export default defineConfig({ + plugins: [ + viteCompression({ + algorithm: 'brotliCompress', + ext: '.br', + filter: /\.(wasm|js)$/i, + threshold: 1024, // Only compress files > 1KB + deleteOriginFile: false, // Keep original files for compatibility + }), + ], build: { emptyOutDir: false, lib: { @@ -14,8 +24,10 @@ export default defineConfig({ rollupOptions: { // Externalize dependencies that have WASM runtimes or shouldn't be bundled external: [ - 'ducpdf', // Uses Rust WASM - let consuming app handle - 'ducjs', // Workspace dependency + 'ducpdf', // Uses Rust WASM - let consuming app handle + 'ducjs', // Workspace dependency + /pdf2svg/, // Externalize pdf2svg wasm bindings to prevent inline base64 bundling + /\.wasm$/, // Don't bundle WASM files inline ], output: { globals: { diff --git a/scripts/cargo-set-duc-dep-version.js b/scripts/cargo-set-duc-dep-version.js new file mode 100644 index 00000000..54e63cca --- /dev/null +++ b/scripts/cargo-set-duc-dep-version.js @@ -0,0 +1,51 @@ +#!/usr/bin/env node +/** + * Updates the 'duc' dependency version in a Cargo.toml file. + * Used during semantic-release to set the duc dependency to a crates.io-compatible version. + * + * Usage: node scripts/cargo-set-duc-dep-version.js + * Example: node scripts/cargo-set-duc-dep-version.js packages/ducpdf/src/duc2pdf/Cargo.toml 2 + */ +const fs = require("fs"); +const path = require("path"); + +const cargoTomlPath = process.argv[2]; +const version = process.argv[3]; + +if (!cargoTomlPath || !version) { + console.error("Usage: node scripts/cargo-set-duc-dep-version.js "); + console.error("Example: node scripts/cargo-set-duc-dep-version.js packages/ducpdf/src/duc2pdf/Cargo.toml 2"); + process.exit(1); +} + +let fullPath = path.resolve(process.cwd(), cargoTomlPath); + +// If path is a directory, append Cargo.toml +if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) { + fullPath = path.join(fullPath, "Cargo.toml"); +} + +if (!fs.existsSync(fullPath)) { + console.error(`File not found: ${fullPath}`); + process.exit(1); +} + +let content = fs.readFileSync(fullPath, "utf8"); + +// Match entire duc dependency line and replace with version-only format +// Handles variations like: +// duc = { version = "0.0.0-development", path = "..." } +// duc = { path = "...", version = "..." } +// Replaces with: duc = "VERSION" +const ducDepRegex = /^(#[^\n]*\n)*duc\s*=\s*\{[^}]+\}/m; + +if (!ducDepRegex.test(content)) { + console.error("Could not find duc dependency with version/path in Cargo.toml"); + process.exit(1); +} + +// Replace the entire duc dependency (including any comment above it) with simple version +content = content.replace(ducDepRegex, `duc = "${version}"`); + +fs.writeFileSync(fullPath, content); +console.log(`Updated duc dependency to "${version}" (removed path) in ${fullPath}`);