@cadview/svelte 0.1.0 → 0.2.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/dist/CadViewer.svelte +32 -12
- package/dist/CadViewer.svelte.d.ts +3 -1
- package/dist/CadViewer.svelte.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +14 -27
package/dist/CadViewer.svelte
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
CadViewer as CoreCadViewer,
|
|
5
5
|
type CadViewerOptions,
|
|
6
|
+
type FormatConverter,
|
|
6
7
|
type DxfLayer,
|
|
7
8
|
type SelectEvent,
|
|
8
9
|
type MeasureEvent,
|
|
@@ -16,6 +17,8 @@
|
|
|
16
17
|
theme?: Theme;
|
|
17
18
|
tool?: Tool;
|
|
18
19
|
options?: Omit<CadViewerOptions, 'theme' | 'initialTool'>;
|
|
20
|
+
/** Format converters for non-DXF file formats (e.g. DWG via @cadview/dwg). */
|
|
21
|
+
formatConverters?: FormatConverter[];
|
|
19
22
|
class?: string;
|
|
20
23
|
onselect?: (event: SelectEvent) => void;
|
|
21
24
|
onmeasure?: (event: MeasureEvent) => void;
|
|
@@ -28,6 +31,7 @@
|
|
|
28
31
|
theme = 'dark',
|
|
29
32
|
tool = 'pan',
|
|
30
33
|
options = {},
|
|
34
|
+
formatConverters,
|
|
31
35
|
class: className = '',
|
|
32
36
|
onselect,
|
|
33
37
|
onmeasure,
|
|
@@ -46,9 +50,12 @@
|
|
|
46
50
|
const initialTool = untrack(() => tool);
|
|
47
51
|
const initialOptions = untrack(() => options);
|
|
48
52
|
|
|
53
|
+
const initialConverters = untrack(() => formatConverters);
|
|
54
|
+
|
|
49
55
|
const v = new CoreCadViewer(canvas, {
|
|
50
56
|
theme: initialTheme,
|
|
51
57
|
initialTool: initialTool,
|
|
58
|
+
formatConverters: initialConverters,
|
|
52
59
|
...initialOptions,
|
|
53
60
|
});
|
|
54
61
|
viewer = v;
|
|
@@ -73,19 +80,32 @@
|
|
|
73
80
|
$effect(() => {
|
|
74
81
|
if (!viewer || !file) return;
|
|
75
82
|
const v = viewer;
|
|
83
|
+
let cancelled = false;
|
|
84
|
+
|
|
85
|
+
const load = async () => {
|
|
86
|
+
try {
|
|
87
|
+
if (file instanceof File) {
|
|
88
|
+
await v.loadFile(file);
|
|
89
|
+
} else if (file instanceof ArrayBuffer) {
|
|
90
|
+
await v.loadBuffer(file);
|
|
91
|
+
} else if (typeof file === 'string') {
|
|
92
|
+
v.loadString(file);
|
|
93
|
+
}
|
|
94
|
+
if (!cancelled) {
|
|
95
|
+
untrack(() => onlayersloaded)?.(v.getLayers());
|
|
96
|
+
}
|
|
97
|
+
} catch (err: unknown) {
|
|
98
|
+
if (!cancelled) {
|
|
99
|
+
console.error('CadViewer: failed to load file', err);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
76
103
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} else if (file instanceof ArrayBuffer) {
|
|
83
|
-
v.loadArrayBuffer(file);
|
|
84
|
-
untrack(() => onlayersloaded)?.(v.getLayers());
|
|
85
|
-
} else if (typeof file === 'string') {
|
|
86
|
-
v.loadString(file);
|
|
87
|
-
untrack(() => onlayersloaded)?.(v.getLayers());
|
|
88
|
-
}
|
|
104
|
+
load();
|
|
105
|
+
|
|
106
|
+
return () => {
|
|
107
|
+
cancelled = true;
|
|
108
|
+
};
|
|
89
109
|
});
|
|
90
110
|
|
|
91
111
|
// Event listener management
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { CadViewer as CoreCadViewer, type CadViewerOptions, type DxfLayer, type SelectEvent, type MeasureEvent, type ViewTransform, type Tool, type Theme } from '@cadview/core';
|
|
1
|
+
import { CadViewer as CoreCadViewer, type CadViewerOptions, type FormatConverter, type DxfLayer, type SelectEvent, type MeasureEvent, type ViewTransform, type Tool, type Theme } from '@cadview/core';
|
|
2
2
|
interface Props {
|
|
3
3
|
file?: File | ArrayBuffer | string | null;
|
|
4
4
|
theme?: Theme;
|
|
5
5
|
tool?: Tool;
|
|
6
6
|
options?: Omit<CadViewerOptions, 'theme' | 'initialTool'>;
|
|
7
|
+
/** Format converters for non-DXF file formats (e.g. DWG via @cadview/dwg). */
|
|
8
|
+
formatConverters?: FormatConverter[];
|
|
7
9
|
class?: string;
|
|
8
10
|
onselect?: (event: SelectEvent) => void;
|
|
9
11
|
onmeasure?: (event: MeasureEvent) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CadViewer.svelte.d.ts","sourceRoot":"","sources":["../src/lib/CadViewer.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,SAAS,IAAI,aAAa,EAC1B,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,IAAI,EACT,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AAGvB,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,IAAI,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IAC1C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,aAAa,CAAC,CAAC;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;CAC/C;
|
|
1
|
+
{"version":3,"file":"CadViewer.svelte.d.ts","sourceRoot":"","sources":["../src/lib/CadViewer.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,SAAS,IAAI,aAAa,EAC1B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,IAAI,EACT,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AAGvB,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,IAAI,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IAC1C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,aAAa,CAAC,CAAC;IAC1D,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;CAC/C;AAsIH,QAAA,MAAM,SAAS;qBAvBU,aAAa,GAAG,IAAI;qBAIpB,IAAI;qBAIJ,QAAQ,EAAE;4BAID,MAAM,WAAW,OAAO,KAAG,IAAI;MAWV,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default as CadViewer } from './CadViewer.svelte';
|
|
2
|
-
export type { SelectEvent, MeasureEvent, ViewTransform, DxfLayer, DxfDocument, DxfEntity, Tool, Theme, CadViewerOptions, } from '@cadview/core';
|
|
2
|
+
export type { FormatConverter, SelectEvent, MeasureEvent, ViewTransform, DxfLayer, DxfDocument, DxfEntity, Tool, Theme, CadViewerOptions, } from '@cadview/core';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG1D,YAAY,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,WAAW,EACX,SAAS,EACT,IAAI,EACJ,KAAK,EACL,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG1D,YAAY,EACV,eAAe,EACf,WAAW,EACX,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,WAAW,EACX,SAAS,EACT,IAAI,EACJ,KAAK,EACL,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cadview/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Svelte 5 wrapper for @cadview/core — CAD/DXF file viewer component",
|
|
7
7
|
"author": "Wisnu Wicaksono",
|
|
8
|
-
"keywords": [
|
|
9
|
-
"cad",
|
|
10
|
-
"dxf",
|
|
11
|
-
"viewer",
|
|
12
|
-
"svelte",
|
|
13
|
-
"svelte5",
|
|
14
|
-
"component",
|
|
15
|
-
"canvas"
|
|
16
|
-
],
|
|
8
|
+
"keywords": ["cad", "dxf", "viewer", "svelte", "svelte5", "component", "canvas"],
|
|
17
9
|
"repository": {
|
|
18
10
|
"type": "git",
|
|
19
11
|
"url": "git+https://github.com/wiscaksono/cadview.git",
|
|
@@ -36,27 +28,22 @@
|
|
|
36
28
|
"default": "./dist/index.js"
|
|
37
29
|
}
|
|
38
30
|
},
|
|
39
|
-
"files": [
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
31
|
+
"files": ["dist", "LICENSE", "README.md", "!dist/**/*.test.*"],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "svelte-package",
|
|
34
|
+
"dev": "svelte-package --watch",
|
|
35
|
+
"typecheck": "svelte-check"
|
|
36
|
+
},
|
|
45
37
|
"peerDependencies": {
|
|
46
|
-
"
|
|
47
|
-
"
|
|
38
|
+
"@cadview/core": "workspace:*",
|
|
39
|
+
"svelte": "^5.0.0"
|
|
48
40
|
},
|
|
49
41
|
"devDependencies": {
|
|
42
|
+
"@cadview/core": "workspace:*",
|
|
50
43
|
"@sveltejs/package": "^2.0.0",
|
|
51
44
|
"svelte": "^5.0.0",
|
|
52
45
|
"svelte-check": "^4.0.0",
|
|
53
|
-
"typescript": "^5.7.0"
|
|
54
|
-
"@cadview/core": "0.1.0"
|
|
46
|
+
"typescript": "^5.7.0"
|
|
55
47
|
},
|
|
56
|
-
"sideEffects": false
|
|
57
|
-
|
|
58
|
-
"build": "svelte-package",
|
|
59
|
-
"dev": "svelte-package --watch",
|
|
60
|
-
"typecheck": "svelte-check"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
48
|
+
"sideEffects": false
|
|
49
|
+
}
|