ezjww 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/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # ezjww
2
+
3
+ TypeScript bindings for the Rust `ezjww` JWW parser and DXF converter.
4
+
5
+ ```ts
6
+ import { readFileSync } from "node:fs";
7
+ import { readDocument, toDxfString } from "ezjww";
8
+
9
+ const data = readFileSync("sample.jww");
10
+ const document = readDocument(data);
11
+ const dxf = toDxfString(data, { explodeInserts: true });
12
+ ```
13
+
14
+ ## Browser example
15
+
16
+ ```bash
17
+ cd packages/ezjww
18
+ pnpm install
19
+ pnpm run example:browser:dev
20
+ ```
21
+
22
+ The example app parses a dropped `.jww` file in the browser and shows summary
23
+ counts, layers, a simple drawing preview, and JSON output.
@@ -0,0 +1,189 @@
1
+ export interface LayerHeader {
2
+ state: number;
3
+ protect: number;
4
+ name: string;
5
+ }
6
+ export interface LayerGroupHeader {
7
+ state: number;
8
+ write_layer: number;
9
+ scale: number;
10
+ protect: number;
11
+ name: string;
12
+ layers: LayerHeader[];
13
+ }
14
+ export interface JwwHeader {
15
+ version: number;
16
+ memo: string;
17
+ paper_size: number;
18
+ write_layer_group: number;
19
+ layer_groups: LayerGroupHeader[];
20
+ }
21
+ export interface EntityBase {
22
+ group: number;
23
+ pen_style: number;
24
+ pen_color: number;
25
+ pen_width: number;
26
+ layer: number;
27
+ layer_group: number;
28
+ flag: number;
29
+ }
30
+ export interface LinePayload {
31
+ start_x: number;
32
+ start_y: number;
33
+ end_x: number;
34
+ end_y: number;
35
+ }
36
+ export interface PointPayload {
37
+ x: number;
38
+ y: number;
39
+ is_temporary: boolean;
40
+ code: number;
41
+ angle: number;
42
+ scale: number;
43
+ }
44
+ export interface TextPayload {
45
+ start_x: number;
46
+ start_y: number;
47
+ end_x: number;
48
+ end_y: number;
49
+ text_type: number;
50
+ size_x: number;
51
+ size_y: number;
52
+ spacing: number;
53
+ angle: number;
54
+ font_name: string;
55
+ content: string;
56
+ }
57
+ export interface JwwEntity {
58
+ type: string;
59
+ base: EntityBase;
60
+ start_x?: number;
61
+ start_y?: number;
62
+ end_x?: number;
63
+ end_y?: number;
64
+ center_x?: number;
65
+ center_y?: number;
66
+ radius?: number;
67
+ start_angle?: number;
68
+ arc_angle?: number;
69
+ tilt_angle?: number;
70
+ flatness?: number;
71
+ is_full_circle?: boolean;
72
+ x?: number;
73
+ y?: number;
74
+ is_temporary?: boolean;
75
+ code?: number;
76
+ angle?: number;
77
+ scale?: number;
78
+ text_type?: number;
79
+ size_x?: number;
80
+ size_y?: number;
81
+ spacing?: number;
82
+ font_name?: string;
83
+ content?: string;
84
+ point1_x?: number;
85
+ point1_y?: number;
86
+ point2_x?: number;
87
+ point2_y?: number;
88
+ point3_x?: number;
89
+ point3_y?: number;
90
+ point4_x?: number;
91
+ point4_y?: number;
92
+ color?: number | null;
93
+ ref_x?: number;
94
+ ref_y?: number;
95
+ scale_x?: number;
96
+ scale_y?: number;
97
+ rotation?: number;
98
+ def_number?: number;
99
+ line?: LinePayload;
100
+ text?: TextPayload;
101
+ sxf_mode?: number | null;
102
+ aux_lines?: LinePayload[];
103
+ aux_points?: PointPayload[];
104
+ }
105
+ export interface BlockDef {
106
+ number: number;
107
+ is_referenced: boolean;
108
+ name: string;
109
+ base: EntityBase;
110
+ entities: JwwEntity[];
111
+ }
112
+ export interface BlockReferenceValidation {
113
+ total_references: number;
114
+ resolved_references: number;
115
+ unresolved_def_numbers: number[];
116
+ has_unresolved: boolean;
117
+ }
118
+ export interface JwwDocument {
119
+ header: JwwHeader;
120
+ entities: JwwEntity[];
121
+ block_defs: BlockDef[];
122
+ block_def_names: Record<string, string>;
123
+ entity_counts: Record<string, number>;
124
+ validation: BlockReferenceValidation;
125
+ }
126
+ export interface DxfLayer {
127
+ name: string;
128
+ color: number;
129
+ line_type: string;
130
+ frozen: boolean;
131
+ locked: boolean;
132
+ }
133
+ export interface DxfEntity {
134
+ type: string;
135
+ layer: string;
136
+ color: number;
137
+ line_type: string;
138
+ x1?: number;
139
+ y1?: number;
140
+ x2?: number;
141
+ y2?: number;
142
+ center_x?: number;
143
+ center_y?: number;
144
+ radius?: number;
145
+ start_angle?: number;
146
+ end_angle?: number;
147
+ major_axis_x?: number;
148
+ major_axis_y?: number;
149
+ minor_ratio?: number;
150
+ start_param?: number;
151
+ end_param?: number;
152
+ x?: number;
153
+ y?: number;
154
+ height?: number;
155
+ rotation?: number;
156
+ content?: string;
157
+ style?: string;
158
+ x3?: number;
159
+ y3?: number;
160
+ x4?: number;
161
+ y4?: number;
162
+ block_name?: string;
163
+ scale_x?: number;
164
+ scale_y?: number;
165
+ }
166
+ export interface DxfBlock {
167
+ name: string;
168
+ base_x: number;
169
+ base_y: number;
170
+ entities: DxfEntity[];
171
+ }
172
+ export interface DxfDocument {
173
+ layers: DxfLayer[];
174
+ entities: DxfEntity[];
175
+ blocks: DxfBlock[];
176
+ unsupported_entities: string[];
177
+ }
178
+ export interface DxfOptions {
179
+ explodeInserts?: boolean;
180
+ maxBlockNesting?: number;
181
+ }
182
+ export type JwwInput = Uint8Array | ArrayBuffer | ArrayBufferView;
183
+ export declare function isJwwFile(input: JwwInput): boolean;
184
+ export declare function readHeader(input: JwwInput): JwwHeader;
185
+ export declare function readDocument(input: JwwInput): JwwDocument;
186
+ export declare function readDxfDocument(input: JwwInput, options?: DxfOptions): DxfDocument;
187
+ export declare function readDxfString(input: JwwInput, options?: DxfOptions): string;
188
+ export declare const toDxfString: typeof readDxfString;
189
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;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E,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,eAAe,CAAC;AAElE,wBAAgB,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAElD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAErD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,WAAW,CAEzD;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,QAAQ,EACf,OAAO,GAAE,UAAe,GACvB,WAAW,CAOb;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,QAAQ,EACf,OAAO,GAAE,UAAe,GACvB,MAAM,CAOR;AAED,eAAO,MAAM,WAAW,sBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.toDxfString = void 0;
37
+ exports.isJwwFile = isJwwFile;
38
+ exports.readHeader = readHeader;
39
+ exports.readDocument = readDocument;
40
+ exports.readDxfDocument = readDxfDocument;
41
+ exports.readDxfString = readDxfString;
42
+ const wasm = __importStar(require("../wasm/ezjww_wasm.js"));
43
+ function isJwwFile(input) {
44
+ return wasm.isJwwFile(toUint8Array(input));
45
+ }
46
+ function readHeader(input) {
47
+ return wasm.readHeader(toUint8Array(input));
48
+ }
49
+ function readDocument(input) {
50
+ return wasm.readDocument(toUint8Array(input));
51
+ }
52
+ function readDxfDocument(input, options = {}) {
53
+ const normalized = normalizeDxfOptions(options);
54
+ return wasm.readDxfDocument(toUint8Array(input), normalized.explodeInserts, normalized.maxBlockNesting);
55
+ }
56
+ function readDxfString(input, options = {}) {
57
+ const normalized = normalizeDxfOptions(options);
58
+ return wasm.readDxfString(toUint8Array(input), normalized.explodeInserts, normalized.maxBlockNesting);
59
+ }
60
+ exports.toDxfString = readDxfString;
61
+ function normalizeDxfOptions(options) {
62
+ const maxBlockNesting = options.maxBlockNesting ?? 32;
63
+ if (!Number.isInteger(maxBlockNesting) || maxBlockNesting < 1) {
64
+ throw new RangeError("maxBlockNesting must be an integer >= 1");
65
+ }
66
+ return {
67
+ explodeInserts: options.explodeInserts ?? false,
68
+ maxBlockNesting,
69
+ };
70
+ }
71
+ function toUint8Array(input) {
72
+ if (input instanceof Uint8Array) {
73
+ return input;
74
+ }
75
+ if (input instanceof ArrayBuffer) {
76
+ return new Uint8Array(input);
77
+ }
78
+ return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
79
+ }
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "ezjww",
3
+ "version": "0.2.0",
4
+ "description": "JWW parser and DXF converter for TypeScript, powered by Rust WebAssembly.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/monozukuri-ai/ezjww.git",
9
+ "directory": "packages/ezjww"
10
+ },
11
+ "main": "dist/index.js",
12
+ "types": "dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "wasm"
22
+ ],
23
+ "scripts": {
24
+ "build:wasm": "wasm-pack build ../../crates/ezjww-wasm --target nodejs --out-dir ../../packages/ezjww/wasm --out-name ezjww_wasm --release && node -e \"require('node:fs').rmSync('wasm/.gitignore', { force: true })\"",
25
+ "build:ts": "tsc -p tsconfig.json",
26
+ "build": "pnpm run build:wasm && pnpm run build:ts",
27
+ "example:browser:sample": "node -e \"const fs=require('node:fs'); fs.mkdirSync('examples/browser/public/samples', { recursive: true }); fs.copyFileSync('../../jww_samples/Test1.jww', 'examples/browser/public/samples/Test1.jww')\"",
28
+ "example:browser:wasm": "wasm-pack build ../../crates/ezjww-wasm --target web --out-dir ../../packages/ezjww/examples/browser/src/wasm --out-name ezjww_wasm --release && node -e \"require('node:fs').rmSync('examples/browser/src/wasm/.gitignore', { force: true })\"",
29
+ "example:browser:build": "pnpm run example:browser:sample && pnpm run example:browser:wasm && vite build examples/browser",
30
+ "example:browser:dev": "pnpm run example:browser:sample && pnpm run example:browser:wasm && vite --host 127.0.0.1 examples/browser",
31
+ "example:browser:preview": "vite preview --host 127.0.0.1 examples/browser",
32
+ "test": "pnpm run build && vitest run",
33
+ "test:parity": "node ../../scripts/check-python-ts-parity.mjs",
34
+ "typecheck": "tsc -p tsconfig.json --noEmit",
35
+ "prepack": "pnpm run build"
36
+ },
37
+ "keywords": [
38
+ "jww",
39
+ "jw-cad",
40
+ "jwcad",
41
+ "dxf",
42
+ "cad",
43
+ "parser",
44
+ "webassembly",
45
+ "wasm"
46
+ ],
47
+ "engines": {
48
+ "node": ">=18.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^22.0.0",
52
+ "typescript": "^5.6.0",
53
+ "vite": "^8.0.14",
54
+ "vitest": "^4.1.7",
55
+ "wasm-pack": "^0.15.0"
56
+ }
57
+ }
@@ -0,0 +1,12 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function isJwwFile(data: Uint8Array): boolean;
5
+
6
+ export function readDocument(data: Uint8Array): any;
7
+
8
+ export function readDxfDocument(data: Uint8Array, explode_inserts: boolean, max_block_nesting: number): any;
9
+
10
+ export function readDxfString(data: Uint8Array, explode_inserts: boolean, max_block_nesting: number): string;
11
+
12
+ export function readHeader(data: Uint8Array): any;
@@ -0,0 +1,259 @@
1
+ /* @ts-self-types="./ezjww_wasm.d.ts" */
2
+
3
+ /**
4
+ * @param {Uint8Array} data
5
+ * @returns {boolean}
6
+ */
7
+ function isJwwFile(data) {
8
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
9
+ const len0 = WASM_VECTOR_LEN;
10
+ const ret = wasm.isJwwFile(ptr0, len0);
11
+ return ret !== 0;
12
+ }
13
+ exports.isJwwFile = isJwwFile;
14
+
15
+ /**
16
+ * @param {Uint8Array} data
17
+ * @returns {any}
18
+ */
19
+ function readDocument(data) {
20
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
21
+ const len0 = WASM_VECTOR_LEN;
22
+ const ret = wasm.readDocument(ptr0, len0);
23
+ if (ret[2]) {
24
+ throw takeFromExternrefTable0(ret[1]);
25
+ }
26
+ return takeFromExternrefTable0(ret[0]);
27
+ }
28
+ exports.readDocument = readDocument;
29
+
30
+ /**
31
+ * @param {Uint8Array} data
32
+ * @param {boolean} explode_inserts
33
+ * @param {number} max_block_nesting
34
+ * @returns {any}
35
+ */
36
+ function readDxfDocument(data, explode_inserts, max_block_nesting) {
37
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
38
+ const len0 = WASM_VECTOR_LEN;
39
+ const ret = wasm.readDxfDocument(ptr0, len0, explode_inserts, max_block_nesting);
40
+ if (ret[2]) {
41
+ throw takeFromExternrefTable0(ret[1]);
42
+ }
43
+ return takeFromExternrefTable0(ret[0]);
44
+ }
45
+ exports.readDxfDocument = readDxfDocument;
46
+
47
+ /**
48
+ * @param {Uint8Array} data
49
+ * @param {boolean} explode_inserts
50
+ * @param {number} max_block_nesting
51
+ * @returns {string}
52
+ */
53
+ function readDxfString(data, explode_inserts, max_block_nesting) {
54
+ let deferred3_0;
55
+ let deferred3_1;
56
+ try {
57
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
58
+ const len0 = WASM_VECTOR_LEN;
59
+ const ret = wasm.readDxfString(ptr0, len0, explode_inserts, max_block_nesting);
60
+ var ptr2 = ret[0];
61
+ var len2 = ret[1];
62
+ if (ret[3]) {
63
+ ptr2 = 0; len2 = 0;
64
+ throw takeFromExternrefTable0(ret[2]);
65
+ }
66
+ deferred3_0 = ptr2;
67
+ deferred3_1 = len2;
68
+ return getStringFromWasm0(ptr2, len2);
69
+ } finally {
70
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
71
+ }
72
+ }
73
+ exports.readDxfString = readDxfString;
74
+
75
+ /**
76
+ * @param {Uint8Array} data
77
+ * @returns {any}
78
+ */
79
+ function readHeader(data) {
80
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
81
+ const len0 = WASM_VECTOR_LEN;
82
+ const ret = wasm.readHeader(ptr0, len0);
83
+ if (ret[2]) {
84
+ throw takeFromExternrefTable0(ret[1]);
85
+ }
86
+ return takeFromExternrefTable0(ret[0]);
87
+ }
88
+ exports.readHeader = readHeader;
89
+ function __wbg_get_imports() {
90
+ const import0 = {
91
+ __proto__: null,
92
+ __wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
93
+ const ret = Error(getStringFromWasm0(arg0, arg1));
94
+ return ret;
95
+ },
96
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
97
+ const ret = String(arg1);
98
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
99
+ const len1 = WASM_VECTOR_LEN;
100
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
101
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
102
+ },
103
+ __wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
104
+ const ret = typeof(arg0) === 'string';
105
+ return ret;
106
+ },
107
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
108
+ throw new Error(getStringFromWasm0(arg0, arg1));
109
+ },
110
+ __wbg_new_622fc80556be2e26: function() {
111
+ const ret = new Map();
112
+ return ret;
113
+ },
114
+ __wbg_new_ce1ab61c1c2b300d: function() {
115
+ const ret = new Object();
116
+ return ret;
117
+ },
118
+ __wbg_new_d90091b82fdf5b91: function() {
119
+ const ret = new Array();
120
+ return ret;
121
+ },
122
+ __wbg_set_52b1e1eb5bed906a: function(arg0, arg1, arg2) {
123
+ const ret = arg0.set(arg1, arg2);
124
+ return ret;
125
+ },
126
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
127
+ arg0[arg1] = arg2;
128
+ },
129
+ __wbg_set_dca99999bba88a9a: function(arg0, arg1, arg2) {
130
+ arg0[arg1 >>> 0] = arg2;
131
+ },
132
+ __wbindgen_cast_0000000000000001: function(arg0) {
133
+ // Cast intrinsic for `F64 -> Externref`.
134
+ const ret = arg0;
135
+ return ret;
136
+ },
137
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
138
+ // Cast intrinsic for `Ref(String) -> Externref`.
139
+ const ret = getStringFromWasm0(arg0, arg1);
140
+ return ret;
141
+ },
142
+ __wbindgen_cast_0000000000000003: function(arg0) {
143
+ // Cast intrinsic for `U64 -> Externref`.
144
+ const ret = BigInt.asUintN(64, arg0);
145
+ return ret;
146
+ },
147
+ __wbindgen_init_externref_table: function() {
148
+ const table = wasm.__wbindgen_externrefs;
149
+ const offset = table.grow(4);
150
+ table.set(0, undefined);
151
+ table.set(offset + 0, undefined);
152
+ table.set(offset + 1, null);
153
+ table.set(offset + 2, true);
154
+ table.set(offset + 3, false);
155
+ },
156
+ };
157
+ return {
158
+ __proto__: null,
159
+ "./ezjww_wasm_bg.js": import0,
160
+ };
161
+ }
162
+
163
+ let cachedDataViewMemory0 = null;
164
+ function getDataViewMemory0() {
165
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
166
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
167
+ }
168
+ return cachedDataViewMemory0;
169
+ }
170
+
171
+ function getStringFromWasm0(ptr, len) {
172
+ return decodeText(ptr >>> 0, len);
173
+ }
174
+
175
+ let cachedUint8ArrayMemory0 = null;
176
+ function getUint8ArrayMemory0() {
177
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
178
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
179
+ }
180
+ return cachedUint8ArrayMemory0;
181
+ }
182
+
183
+ function passArray8ToWasm0(arg, malloc) {
184
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
185
+ getUint8ArrayMemory0().set(arg, ptr / 1);
186
+ WASM_VECTOR_LEN = arg.length;
187
+ return ptr;
188
+ }
189
+
190
+ function passStringToWasm0(arg, malloc, realloc) {
191
+ if (realloc === undefined) {
192
+ const buf = cachedTextEncoder.encode(arg);
193
+ const ptr = malloc(buf.length, 1) >>> 0;
194
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
195
+ WASM_VECTOR_LEN = buf.length;
196
+ return ptr;
197
+ }
198
+
199
+ let len = arg.length;
200
+ let ptr = malloc(len, 1) >>> 0;
201
+
202
+ const mem = getUint8ArrayMemory0();
203
+
204
+ let offset = 0;
205
+
206
+ for (; offset < len; offset++) {
207
+ const code = arg.charCodeAt(offset);
208
+ if (code > 0x7F) break;
209
+ mem[ptr + offset] = code;
210
+ }
211
+ if (offset !== len) {
212
+ if (offset !== 0) {
213
+ arg = arg.slice(offset);
214
+ }
215
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
216
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
217
+ const ret = cachedTextEncoder.encodeInto(arg, view);
218
+
219
+ offset += ret.written;
220
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
221
+ }
222
+
223
+ WASM_VECTOR_LEN = offset;
224
+ return ptr;
225
+ }
226
+
227
+ function takeFromExternrefTable0(idx) {
228
+ const value = wasm.__wbindgen_externrefs.get(idx);
229
+ wasm.__externref_table_dealloc(idx);
230
+ return value;
231
+ }
232
+
233
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
234
+ cachedTextDecoder.decode();
235
+ function decodeText(ptr, len) {
236
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
237
+ }
238
+
239
+ const cachedTextEncoder = new TextEncoder();
240
+
241
+ if (!('encodeInto' in cachedTextEncoder)) {
242
+ cachedTextEncoder.encodeInto = function (arg, view) {
243
+ const buf = cachedTextEncoder.encode(arg);
244
+ view.set(buf);
245
+ return {
246
+ read: arg.length,
247
+ written: buf.length
248
+ };
249
+ };
250
+ }
251
+
252
+ let WASM_VECTOR_LEN = 0;
253
+
254
+ const wasmPath = `${__dirname}/ezjww_wasm_bg.wasm`;
255
+ const wasmBytes = require('fs').readFileSync(wasmPath);
256
+ const wasmModule = new WebAssembly.Module(wasmBytes);
257
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
258
+ let wasm = wasmInstance.exports;
259
+ wasm.__wbindgen_start();
Binary file
@@ -0,0 +1,14 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const isJwwFile: (a: number, b: number) => number;
5
+ export const readDocument: (a: number, b: number) => [number, number, number];
6
+ export const readDxfDocument: (a: number, b: number, c: number, d: number) => [number, number, number];
7
+ export const readDxfString: (a: number, b: number, c: number, d: number) => [number, number, number, number];
8
+ export const readHeader: (a: number, b: number) => [number, number, number];
9
+ export const __wbindgen_malloc: (a: number, b: number) => number;
10
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
11
+ export const __wbindgen_externrefs: WebAssembly.Table;
12
+ export const __externref_table_dealloc: (a: number) => void;
13
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
14
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "ezjww-wasm",
3
+ "description": "WebAssembly bindings for ezjww.",
4
+ "version": "0.2.0",
5
+ "license": "MIT",
6
+ "files": [
7
+ "ezjww_wasm_bg.wasm",
8
+ "ezjww_wasm.js",
9
+ "ezjww_wasm.d.ts"
10
+ ],
11
+ "main": "ezjww_wasm.js",
12
+ "types": "ezjww_wasm.d.ts"
13
+ }