ducsvg 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ducflair
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ <p align="center">
2
+ <br/>
3
+ <a href="https://duc.ducflair.com" target="_blank"><img width="256px" src="https://raw.githubusercontent.com/ducflair/assets/refs/heads/main/src/duc/duc-extended.png" /></a>
4
+ <p align="center">SVG Adapter for the duc 2D CAD File Format</p>
5
+ <p align="center" style="align: center;">
6
+ <a href="https://www.npmjs.com/package/ducsvg"><img src="https://shields.io/badge/NPM-cc3534?logo=Npm&logoColor=white&style=round-square" alt="NPM" /></a>
7
+ <a href="https://www.npmjs.com/package/ducsvg"><img src="https://img.shields.io/npm/v/ducsvg/latest?style=round-square&label=latest%20stable" alt="NPM ducsvg@latest release" /></a>
8
+ <a href="https://www.npmtrends.com/ducsvg"><img src="https://img.shields.io/npm/dm/ducsvg?style=round-square&color=salmon" alt="Downloads" /></a>
9
+ <img src="https://shields.io/badge/TypeScript-3178C6?logo=TypeScript&logoColor=fff&style=round-square" alt="TypeScript" />
10
+ </p>
11
+ </p>
12
+
13
+ # ducsvg
14
+
15
+ `ducsvg` is a lightweight adapter for rendering `duc` CAD documents to SVG. It’s built on top of `ducjs` and focuses on accurate, standards-compliant SVG output you can embed in browsers or export from Node.js.
16
+
17
+ - Convert duc files to SVG strings
18
+ - Strongly typed with TypeScript
19
+
20
+ > A more realistic approach to `ducsvg` would be to use `PDF.js` from mozilla in combination with the `ducpdf` library to convert the duc to PDF and then to SVG so that we have a more modular and robust solution.
21
+
22
+ ## Documentation
23
+
24
+ For detailed documentation, including all available types and utility functions, visit our [Documentation](https://duc.ducflair.com).
25
+
26
+ ## Tools
27
+
28
+ - [Playground](https://ducflair.com/core): Experiment with the `duc` format in a live environment.
29
+ - [Documentation](https://duc.ducflair.com): Comprehensive guides and API references.
30
+
31
+ ## Contributing
32
+
33
+ At the moment we are not accepting contributions to this package. However, we welcome feedback and suggestions for future improvements. Feel free to open an issue or contact us at [Ducflair Support](https://www.ducflair.com/support).
34
+
35
+ ## License
36
+
37
+ This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.
38
+
39
+
40
+ ## Commit Message Guidelines
41
+
42
+ To ensure smooth releases with semantic-release, please follow [these guidelines](https://semantic-release.gitbook.io/semantic-release#how-does-it-work).
43
+
44
+ ---
45
+
46
+ *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!*
@@ -0,0 +1,15 @@
1
+ import { DucElement, DucFrameLikeElement, DucGlobalState, DucLocalState, ElementBackground, ElementStroke, RestoredDataState, Scope } from "ducjs";
2
+ export type PartialDucState = Partial<DucLocalState & DucGlobalState>;
3
+ export type FrameRendering = {
4
+ enabled: boolean;
5
+ outline: boolean;
6
+ name: boolean;
7
+ clip: boolean;
8
+ };
9
+ export declare const ducToSvg: (elements: RestoredDataState["elements"], localState: RestoredDataState["localState"], globalState: RestoredDataState["globalState"], files: RestoredDataState["files"], opts?: {
10
+ exportingFrame?: DucFrameLikeElement | null;
11
+ exportWithDarkMode?: boolean;
12
+ skipInliningFonts?: boolean;
13
+ }) => Promise<string>;
14
+ export declare const renderElementToSvg: (_element: DucElement, elementsMap: Map<string, DucElement>, ducState: PartialDucState, files: RestoredDataState["files"], defs: SVGDefsElement, currentScope: Scope) => SVGElement | null;
15
+ export declare const applyStyles: (element: SVGElement, strokes: readonly ElementStroke[], backgrounds: readonly ElementBackground[]) => void;