@jfk-solutions/demo3d-file-format 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/README.md +107 -0
- package/dist/binary.d.ts +10 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +78 -0
- package/dist/binary.js.map +1 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +27 -0
- package/dist/errors.js.map +1 -0
- package/dist/fast-xml.d.ts +3 -0
- package/dist/fast-xml.d.ts.map +1 -0
- package/dist/fast-xml.js +256 -0
- package/dist/fast-xml.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/model.d.ts +96 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +336 -0
- package/dist/model.js.map +1 -0
- package/dist/parser.d.ts +9 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +74 -0
- package/dist/parser.js.map +1 -0
- package/dist/three/index.d.ts +51 -0
- package/dist/three/index.d.ts.map +1 -0
- package/dist/three/index.js +1317 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/renderer.d.ts +31 -0
- package/dist/three/renderer.d.ts.map +1 -0
- package/dist/three/renderer.js +74 -0
- package/dist/three/renderer.js.map +1 -0
- package/dist/xml.d.ts +36 -0
- package/dist/xml.d.ts.map +1 -0
- package/dist/xml.js +139 -0
- package/dist/xml.js.map +1 -0
- package/dist/zip.d.ts +30 -0
- package/dist/zip.d.ts.map +1 -0
- package/dist/zip.js +129 -0
- package/dist/zip.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# demo3d-file-format
|
|
2
|
+
|
|
3
|
+
Browser-first TypeScript parser for Demo3D/Emulate3D `.demo3d` project files.
|
|
4
|
+
|
|
5
|
+
The parser accepts an `ArrayBuffer`, `Uint8Array`, or `DataView`, reads the outer ZIP package, extracts the nested XML model document, and returns a lossless object structure with typed helpers for the pieces most useful to rendering adapters.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install
|
|
11
|
+
npm run build
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { parseDemo3D } from "demo3d-file-format";
|
|
18
|
+
|
|
19
|
+
const file = input.files![0];
|
|
20
|
+
const parsed = await parseDemo3D(await file.arrayBuffer());
|
|
21
|
+
|
|
22
|
+
console.log(parsed.model.header.product);
|
|
23
|
+
console.log(parsed.model.meshes.length);
|
|
24
|
+
console.log(parsed.model.visuals.length);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Runtime code has no production dependencies and uses browser APIs only. ZIP method `8` entries are decompressed with `DecompressionStream("deflate-raw")`.
|
|
28
|
+
|
|
29
|
+
The default single-pass XML parser builds the Demo3D object tree directly, avoiding the time and memory cost of an intermediate browser DOM. For unusual XML inputs, callers can opt into the browser parser or inject another DOM implementation:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
await parseDemo3D(bytes, { xmlParser: "dom" });
|
|
33
|
+
await parseDemo3D(bytes, { parseXml: customParseXml });
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The fast parser supports the XML constructs used by Demo3D files but intentionally rejects document type declarations.
|
|
37
|
+
|
|
38
|
+
## Three Renderer Demo
|
|
39
|
+
|
|
40
|
+
The Three.js smoke demo must be opened through a local HTTP server, not directly through `file://`, because browsers block module imports from unique file origins.
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npm run demo:three
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then open the printed `http://127.0.0.1:.../examples/three-render-smoke.html` URL and choose a `.demo3d` file.
|
|
47
|
+
|
|
48
|
+
The parser root remains independent of Three.js. Renderer features that require
|
|
49
|
+
procedural reconstruction are opt-in through the `demo3d-file-format/three`
|
|
50
|
+
subpath:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { createDemo3DThreeGroup } from "demo3d-file-format/three";
|
|
54
|
+
|
|
55
|
+
const group = await createDemo3DThreeGroup(parsed, {
|
|
56
|
+
renderProceduralBelts: true
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`renderProceduralBelts` reconstructs `StraightBeltConveyor` surfaces from their
|
|
61
|
+
serialized dimensions, cap types, and surface/side materials. It defaults to
|
|
62
|
+
`false`.
|
|
63
|
+
|
|
64
|
+
### WebGPU With WebGL Fallback
|
|
65
|
+
|
|
66
|
+
Tools can lazily select a canvas renderer before creating the Demo3D scene. The
|
|
67
|
+
factory probes for a WebGPU adapter and imports `three/webgpu` only when one is
|
|
68
|
+
available. Otherwise, or when WebGPU initialization fails, it falls back to
|
|
69
|
+
WebGL:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import {
|
|
73
|
+
createDemo3DThreeGroup,
|
|
74
|
+
createDemo3DThreeRenderer
|
|
75
|
+
} from "demo3d-file-format/three";
|
|
76
|
+
|
|
77
|
+
const selected = await createDemo3DThreeRenderer({
|
|
78
|
+
canvas,
|
|
79
|
+
antialias: true,
|
|
80
|
+
powerPreference: "high-performance"
|
|
81
|
+
});
|
|
82
|
+
const group = await createDemo3DThreeGroup(parsed, {
|
|
83
|
+
three: selected.three
|
|
84
|
+
});
|
|
85
|
+
const scene = new selected.three.Scene();
|
|
86
|
+
scene.add(group);
|
|
87
|
+
const camera = new selected.three.PerspectiveCamera(45, width / height, 0.1, 100000);
|
|
88
|
+
|
|
89
|
+
selected.renderer.render(scene, camera);
|
|
90
|
+
console.log(selected.backend); // "webgpu" or "webgl"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Always pass `selected.three` into the scene adapter so WebGPU materials and
|
|
94
|
+
lights come from the same Three.js module as the renderer. Set
|
|
95
|
+
`preferWebGPU: false` to force the existing `WebGLRenderer` path.
|
|
96
|
+
|
|
97
|
+
WebGPU can improve repeated rendering of complex scenes, but it does not speed
|
|
98
|
+
up archive/XML parsing and may have higher first-frame shader compilation cost.
|
|
99
|
+
|
|
100
|
+
## Current Scope
|
|
101
|
+
|
|
102
|
+
- Read-only parser.
|
|
103
|
+
- Outer ZIP package parsing.
|
|
104
|
+
- Stored and DEFLATE ZIP entries.
|
|
105
|
+
- Full XML tree preservation.
|
|
106
|
+
- Core typed classes for project header, visuals, meshes, materials, resources, and unknown typed entries.
|
|
107
|
+
- Vendor-specific object types are preserved as `Demo3DUnknownObject` until explicit classes are added.
|
package/dist/binary.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Demo3DInput = ArrayBuffer | Uint8Array | DataView;
|
|
2
|
+
export declare function toUint8Array(input: Demo3DInput): Uint8Array;
|
|
3
|
+
export declare function sliceBytes(bytes: Uint8Array, offset: number, length: number): Uint8Array;
|
|
4
|
+
export declare function readUInt16LE(bytes: Uint8Array, offset: number): number;
|
|
5
|
+
export declare function readUInt32LE(bytes: Uint8Array, offset: number): number;
|
|
6
|
+
export declare function concatBytes(chunks: Uint8Array[]): Uint8Array;
|
|
7
|
+
export declare function decodeText(bytes: Uint8Array, encoding?: "utf-8" | "latin1"): string;
|
|
8
|
+
export declare function encodeBase64ToBytes(base64: string): Uint8Array;
|
|
9
|
+
export declare function inflateRawDeflate(compressed: Uint8Array): Promise<Uint8Array>;
|
|
10
|
+
//# sourceMappingURL=binary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../src/binary.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE9D,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAU3D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAExF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOtE;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAS5D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,GAAE,OAAO,GAAG,QAAkB,GAAG,MAAM,CAM5F;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAuB9D;AAED,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CA8BnF"}
|
package/dist/binary.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Demo3DUnsupportedError } from "./errors.js";
|
|
2
|
+
export function toUint8Array(input) {
|
|
3
|
+
if (input instanceof Uint8Array) {
|
|
4
|
+
return input;
|
|
5
|
+
}
|
|
6
|
+
if (input instanceof DataView) {
|
|
7
|
+
return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
8
|
+
}
|
|
9
|
+
return new Uint8Array(input);
|
|
10
|
+
}
|
|
11
|
+
export function sliceBytes(bytes, offset, length) {
|
|
12
|
+
return bytes.subarray(offset, offset + length);
|
|
13
|
+
}
|
|
14
|
+
export function readUInt16LE(bytes, offset) {
|
|
15
|
+
return bytes[offset] | (bytes[offset + 1] << 8);
|
|
16
|
+
}
|
|
17
|
+
export function readUInt32LE(bytes, offset) {
|
|
18
|
+
return (bytes[offset] |
|
|
19
|
+
(bytes[offset + 1] << 8) |
|
|
20
|
+
(bytes[offset + 2] << 16) |
|
|
21
|
+
(bytes[offset + 3] << 24)) >>> 0;
|
|
22
|
+
}
|
|
23
|
+
export function concatBytes(chunks) {
|
|
24
|
+
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
25
|
+
const out = new Uint8Array(totalLength);
|
|
26
|
+
let offset = 0;
|
|
27
|
+
for (const chunk of chunks) {
|
|
28
|
+
out.set(chunk, offset);
|
|
29
|
+
offset += chunk.length;
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
export function decodeText(bytes, encoding = "utf-8") {
|
|
34
|
+
if (encoding === "latin1") {
|
|
35
|
+
return new TextDecoder("windows-1252").decode(bytes);
|
|
36
|
+
}
|
|
37
|
+
return new TextDecoder("utf-8", { fatal: false }).decode(bytes);
|
|
38
|
+
}
|
|
39
|
+
export function encodeBase64ToBytes(base64) {
|
|
40
|
+
const clean = base64.replace(/\s+/g, "");
|
|
41
|
+
const typedArrayConstructor = Uint8Array;
|
|
42
|
+
if (typeof typedArrayConstructor.fromBase64 === "function") {
|
|
43
|
+
return typedArrayConstructor.fromBase64(clean);
|
|
44
|
+
}
|
|
45
|
+
if (typeof atob !== "function") {
|
|
46
|
+
throw new Demo3DUnsupportedError("Base64 decoding requires atob() or Uint8Array.fromBase64().", "DEMO3D_BASE64_UNSUPPORTED");
|
|
47
|
+
}
|
|
48
|
+
const binary = atob(clean);
|
|
49
|
+
const out = new Uint8Array(binary.length);
|
|
50
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
51
|
+
out[index] = binary.charCodeAt(index);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
export async function inflateRawDeflate(compressed) {
|
|
56
|
+
if (typeof DecompressionStream !== "function") {
|
|
57
|
+
throw new Demo3DUnsupportedError('DEFLATE entries require DecompressionStream("deflate-raw") in this runtime.', "DEMO3D_DEFLATE_UNSUPPORTED");
|
|
58
|
+
}
|
|
59
|
+
let stream;
|
|
60
|
+
try {
|
|
61
|
+
stream = new DecompressionStream("deflate-raw");
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw new Demo3DUnsupportedError(`DEFLATE entries require DecompressionStream("deflate-raw"): ${String(error)}`, "DEMO3D_DEFLATE_UNSUPPORTED");
|
|
65
|
+
}
|
|
66
|
+
const readable = new Blob([compressed]).stream().pipeThrough(stream);
|
|
67
|
+
const reader = readable.getReader();
|
|
68
|
+
const chunks = [];
|
|
69
|
+
for (;;) {
|
|
70
|
+
const result = await reader.read();
|
|
71
|
+
if (result.done) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
chunks.push(result.value);
|
|
75
|
+
}
|
|
76
|
+
return concatBytes(chunks);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=binary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../src/binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAIrD,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC7C,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAiB,EAAE,MAAc,EAAE,MAAc;IAC1E,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAiB,EAAE,MAAc;IAC5D,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC;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,MAAM,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;IACpC,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,SAAS,CAAC;QACR,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,MAAM;QACR,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class Demo3DError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
constructor(message: string, code: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class Demo3DZipError extends Demo3DError {
|
|
6
|
+
constructor(message: string, code?: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class Demo3DUnsupportedError extends Demo3DError {
|
|
9
|
+
constructor(message: string, code?: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class Demo3DXmlError extends Demo3DError {
|
|
12
|
+
constructor(message: string, code?: string);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;aACS,IAAI,EAAE,MAAM;gBAA7C,OAAO,EAAE,MAAM,EAAkB,IAAI,EAAE,MAAM;CAI1D;AAED,qBAAa,cAAe,SAAQ,WAAW;gBACjC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAqB;CAIvD;AAED,qBAAa,sBAAuB,SAAQ,WAAW;gBACzC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAuB;CAIzD;AAED,qBAAa,cAAe,SAAQ,WAAW;gBACjC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAqB;CAIvD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class Demo3DError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
constructor(message, code) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.name = "Demo3DError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class Demo3DZipError extends Demo3DError {
|
|
10
|
+
constructor(message, code = "DEMO3D_ZIP_ERROR") {
|
|
11
|
+
super(message, code);
|
|
12
|
+
this.name = "Demo3DZipError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class Demo3DUnsupportedError extends Demo3DError {
|
|
16
|
+
constructor(message, code = "DEMO3D_UNSUPPORTED") {
|
|
17
|
+
super(message, code);
|
|
18
|
+
this.name = "Demo3DUnsupportedError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class Demo3DXmlError extends Demo3DError {
|
|
22
|
+
constructor(message, code = "DEMO3D_XML_ERROR") {
|
|
23
|
+
super(message, code);
|
|
24
|
+
this.name = "Demo3DXmlError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACS;IAA7C,YAAY,OAAe,EAAkB,IAAY;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,SAAI,GAAJ,IAAI,CAAQ;QAEvD,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,OAAe,EAAE,IAAI,GAAG,kBAAkB;QACpD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACrD,YAAY,OAAe,EAAE,IAAI,GAAG,oBAAoB;QACtD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,OAAe,EAAE,IAAI,GAAG,kBAAkB;QACpD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-xml.d.ts","sourceRoot":"","sources":["../src/fast-xml.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gBAAgB,EAEjB,MAAM,UAAU,CAAC;AAyBlB,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAgFhE"}
|
package/dist/fast-xml.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { Demo3DXmlError } from "./errors.js";
|
|
2
|
+
import { coerceDemo3DXmlValue, Demo3DXmlElement } from "./xml.js";
|
|
3
|
+
const XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance";
|
|
4
|
+
const XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
|
|
5
|
+
const XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
|
|
6
|
+
export function parseDemo3DXmlFast(xml) {
|
|
7
|
+
const stack = [];
|
|
8
|
+
let root;
|
|
9
|
+
let cursor = 0;
|
|
10
|
+
while (cursor < xml.length) {
|
|
11
|
+
const tagStart = xml.indexOf("<", cursor);
|
|
12
|
+
if (tagStart < 0) {
|
|
13
|
+
appendText(stack, decodeXmlEntities(xml.slice(cursor)));
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
if (tagStart > cursor) {
|
|
17
|
+
appendText(stack, decodeXmlEntities(xml.slice(cursor, tagStart)));
|
|
18
|
+
}
|
|
19
|
+
if (xml.startsWith("<!--", tagStart)) {
|
|
20
|
+
cursor = endDelimited(xml, tagStart + 4, "-->");
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (xml.startsWith("<![CDATA[", tagStart)) {
|
|
24
|
+
const end = xml.indexOf("]]>", tagStart + 9);
|
|
25
|
+
if (end < 0) {
|
|
26
|
+
throw new Demo3DXmlError("Unterminated XML CDATA section.");
|
|
27
|
+
}
|
|
28
|
+
if (stack.length > 0) {
|
|
29
|
+
stack[stack.length - 1].text += xml.slice(tagStart + 9, end);
|
|
30
|
+
}
|
|
31
|
+
cursor = end + 3;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (xml.startsWith("<?", tagStart)) {
|
|
35
|
+
cursor = endDelimited(xml, tagStart + 2, "?>");
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (xml.startsWith("<!DOCTYPE", tagStart) || xml.startsWith("<!doctype", tagStart)) {
|
|
39
|
+
throw new Demo3DXmlError("XML document type declarations are not supported by the fast parser.");
|
|
40
|
+
}
|
|
41
|
+
if (xml.startsWith("</", tagStart)) {
|
|
42
|
+
const tagEnd = xml.indexOf(">", tagStart + 2);
|
|
43
|
+
if (tagEnd < 0) {
|
|
44
|
+
throw new Demo3DXmlError("Unterminated XML closing tag.");
|
|
45
|
+
}
|
|
46
|
+
const closingName = xml.slice(tagStart + 2, tagEnd).trim();
|
|
47
|
+
const frame = stack.pop();
|
|
48
|
+
if (!frame || frame.name !== closingName) {
|
|
49
|
+
throw new Demo3DXmlError(`Unexpected XML closing tag </${closingName}>.`);
|
|
50
|
+
}
|
|
51
|
+
root = finishFrame(frame, stack, root);
|
|
52
|
+
cursor = tagEnd + 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (xml.startsWith("<!", tagStart)) {
|
|
56
|
+
throw new Demo3DXmlError("Unsupported XML declaration in Demo3D model.");
|
|
57
|
+
}
|
|
58
|
+
const tagEnd = findTagEnd(xml, tagStart + 1);
|
|
59
|
+
let tag = xml.slice(tagStart + 1, tagEnd);
|
|
60
|
+
const selfClosing = tag.trimEnd().endsWith("/");
|
|
61
|
+
if (selfClosing) {
|
|
62
|
+
tag = tag.trimEnd().slice(0, -1);
|
|
63
|
+
}
|
|
64
|
+
const parent = stack[stack.length - 1];
|
|
65
|
+
const frame = createFrame(tag, parent);
|
|
66
|
+
if (selfClosing) {
|
|
67
|
+
root = finishFrame(frame, stack, root);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
stack.push(frame);
|
|
71
|
+
}
|
|
72
|
+
cursor = tagEnd + 1;
|
|
73
|
+
}
|
|
74
|
+
if (stack.length > 0) {
|
|
75
|
+
throw new Demo3DXmlError(`Unclosed XML element <${stack[stack.length - 1].name}>.`);
|
|
76
|
+
}
|
|
77
|
+
if (!root) {
|
|
78
|
+
throw new Demo3DXmlError("Demo3D XML document has no root element.");
|
|
79
|
+
}
|
|
80
|
+
return root;
|
|
81
|
+
}
|
|
82
|
+
function createFrame(tag, parent) {
|
|
83
|
+
let cursor = skipWhitespace(tag, 0);
|
|
84
|
+
const nameStart = cursor;
|
|
85
|
+
while (cursor < tag.length && !isWhitespace(tag.charCodeAt(cursor))) {
|
|
86
|
+
cursor += 1;
|
|
87
|
+
}
|
|
88
|
+
const name = tag.slice(nameStart, cursor);
|
|
89
|
+
if (!name) {
|
|
90
|
+
throw new Demo3DXmlError("XML element has no name.");
|
|
91
|
+
}
|
|
92
|
+
const rawAttributes = [];
|
|
93
|
+
while (cursor < tag.length) {
|
|
94
|
+
cursor = skipWhitespace(tag, cursor);
|
|
95
|
+
if (cursor >= tag.length) {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
const attributeStart = cursor;
|
|
99
|
+
while (cursor < tag.length && !isWhitespace(tag.charCodeAt(cursor)) && tag[cursor] !== "=") {
|
|
100
|
+
cursor += 1;
|
|
101
|
+
}
|
|
102
|
+
const attributeName = tag.slice(attributeStart, cursor);
|
|
103
|
+
cursor = skipWhitespace(tag, cursor);
|
|
104
|
+
if (tag[cursor] !== "=") {
|
|
105
|
+
throw new Demo3DXmlError(`XML attribute ${attributeName} has no value.`);
|
|
106
|
+
}
|
|
107
|
+
cursor = skipWhitespace(tag, cursor + 1);
|
|
108
|
+
const quote = tag[cursor];
|
|
109
|
+
if (quote !== '"' && quote !== "'") {
|
|
110
|
+
throw new Demo3DXmlError(`XML attribute ${attributeName} is not quoted.`);
|
|
111
|
+
}
|
|
112
|
+
const valueEnd = tag.indexOf(quote, cursor + 1);
|
|
113
|
+
if (valueEnd < 0) {
|
|
114
|
+
throw new Demo3DXmlError(`XML attribute ${attributeName} is unterminated.`);
|
|
115
|
+
}
|
|
116
|
+
rawAttributes.push({ name: attributeName, value: decodeXmlEntities(tag.slice(cursor + 1, valueEnd)) });
|
|
117
|
+
cursor = valueEnd + 1;
|
|
118
|
+
}
|
|
119
|
+
let namespaces;
|
|
120
|
+
for (const attribute of rawAttributes) {
|
|
121
|
+
if (attribute.name === "xmlns") {
|
|
122
|
+
(namespaces ??= {})[""] = attribute.value;
|
|
123
|
+
}
|
|
124
|
+
else if (attribute.name.startsWith("xmlns:")) {
|
|
125
|
+
(namespaces ??= {})[attribute.name.slice(6)] = attribute.value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const [prefix, localName] = splitName(name);
|
|
129
|
+
const namespaceUri = resolveNamespace(prefix ?? "", namespaces, parent);
|
|
130
|
+
const attributes = rawAttributes.map((attribute) => {
|
|
131
|
+
const [attributePrefix, attributeLocalName] = splitName(attribute.name);
|
|
132
|
+
const attributeNamespace = attribute.name === "xmlns" || attributePrefix === "xmlns"
|
|
133
|
+
? XMLNS_NAMESPACE
|
|
134
|
+
: attributePrefix
|
|
135
|
+
? resolveNamespace(attributePrefix, namespaces, parent)
|
|
136
|
+
: null;
|
|
137
|
+
return {
|
|
138
|
+
name: attribute.name,
|
|
139
|
+
localName: attributeLocalName,
|
|
140
|
+
prefix: attributePrefix,
|
|
141
|
+
namespaceUri: attributeNamespace,
|
|
142
|
+
value: attribute.value
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
const xsiType = attributes.find((attribute) => attribute.localName === "type" && attribute.namespaceUri === XSI_NAMESPACE)?.value ?? attributes.find((attribute) => attribute.name === "xsi:type")?.value ?? null;
|
|
146
|
+
const path = parent
|
|
147
|
+
? `${parent.path}/${localName}[${parent.children.length}]`
|
|
148
|
+
: `/${localName}`;
|
|
149
|
+
return {
|
|
150
|
+
name,
|
|
151
|
+
localName,
|
|
152
|
+
prefix,
|
|
153
|
+
namespaceUri,
|
|
154
|
+
path,
|
|
155
|
+
attributes,
|
|
156
|
+
xsiType,
|
|
157
|
+
namespaces,
|
|
158
|
+
parent,
|
|
159
|
+
children: [],
|
|
160
|
+
text: ""
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function finishFrame(frame, stack, currentRoot) {
|
|
164
|
+
const text = frame.text.trim();
|
|
165
|
+
const element = new Demo3DXmlElement(frame.name, frame.localName, frame.prefix, frame.namespaceUri, frame.path, frame.attributes, frame.children, text, frame.xsiType, coerceDemo3DXmlValue(frame.localName, frame.xsiType, text, frame.children.length));
|
|
166
|
+
const parent = stack[stack.length - 1];
|
|
167
|
+
if (parent) {
|
|
168
|
+
parent.children.push(element);
|
|
169
|
+
return currentRoot;
|
|
170
|
+
}
|
|
171
|
+
if (currentRoot) {
|
|
172
|
+
throw new Demo3DXmlError("Demo3D XML document has multiple root elements.");
|
|
173
|
+
}
|
|
174
|
+
return element;
|
|
175
|
+
}
|
|
176
|
+
function appendText(stack, value) {
|
|
177
|
+
if (stack.length > 0) {
|
|
178
|
+
stack[stack.length - 1].text += value;
|
|
179
|
+
}
|
|
180
|
+
else if (value.trim().length > 0) {
|
|
181
|
+
throw new Demo3DXmlError("Unexpected text outside the XML root element.");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function resolveNamespace(prefix, own, parent) {
|
|
185
|
+
if (prefix === "xml") {
|
|
186
|
+
return XML_NAMESPACE;
|
|
187
|
+
}
|
|
188
|
+
if (own?.[prefix] !== undefined) {
|
|
189
|
+
return own[prefix];
|
|
190
|
+
}
|
|
191
|
+
for (let frame = parent; frame; frame = frame.parent) {
|
|
192
|
+
if (frame.namespaces?.[prefix] !== undefined) {
|
|
193
|
+
return frame.namespaces[prefix];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
function splitName(name) {
|
|
199
|
+
const separator = name.indexOf(":");
|
|
200
|
+
return separator < 0 ? [null, name] : [name.slice(0, separator), name.slice(separator + 1)];
|
|
201
|
+
}
|
|
202
|
+
function findTagEnd(xml, start) {
|
|
203
|
+
let quote = "";
|
|
204
|
+
for (let cursor = start; cursor < xml.length; cursor += 1) {
|
|
205
|
+
const character = xml[cursor];
|
|
206
|
+
if (quote) {
|
|
207
|
+
if (character === quote) {
|
|
208
|
+
quote = "";
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else if (character === '"' || character === "'") {
|
|
212
|
+
quote = character;
|
|
213
|
+
}
|
|
214
|
+
else if (character === ">") {
|
|
215
|
+
return cursor;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
throw new Demo3DXmlError("Unterminated XML opening tag.");
|
|
219
|
+
}
|
|
220
|
+
function endDelimited(xml, start, delimiter) {
|
|
221
|
+
const end = xml.indexOf(delimiter, start);
|
|
222
|
+
if (end < 0) {
|
|
223
|
+
throw new Demo3DXmlError(`Unterminated XML ${delimiter} section.`);
|
|
224
|
+
}
|
|
225
|
+
return end + delimiter.length;
|
|
226
|
+
}
|
|
227
|
+
function skipWhitespace(value, cursor) {
|
|
228
|
+
while (cursor < value.length && isWhitespace(value.charCodeAt(cursor))) {
|
|
229
|
+
cursor += 1;
|
|
230
|
+
}
|
|
231
|
+
return cursor;
|
|
232
|
+
}
|
|
233
|
+
function isWhitespace(code) {
|
|
234
|
+
return code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0d;
|
|
235
|
+
}
|
|
236
|
+
function decodeXmlEntities(value) {
|
|
237
|
+
if (!value.includes("&")) {
|
|
238
|
+
return value;
|
|
239
|
+
}
|
|
240
|
+
return value.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g, (_, entity) => {
|
|
241
|
+
switch (entity) {
|
|
242
|
+
case "amp": return "&";
|
|
243
|
+
case "lt": return "<";
|
|
244
|
+
case "gt": return ">";
|
|
245
|
+
case "quot": return '"';
|
|
246
|
+
case "apos": return "'";
|
|
247
|
+
default: {
|
|
248
|
+
const codePoint = entity.startsWith("#x")
|
|
249
|
+
? Number.parseInt(entity.slice(2), 16)
|
|
250
|
+
: Number.parseInt(entity.slice(1), 10);
|
|
251
|
+
return String.fromCodePoint(codePoint);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=fast-xml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-xml.js","sourceRoot":"","sources":["../src/fast-xml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAEjB,MAAM,UAAU,CAAC;AAElB,MAAM,aAAa,GAAG,2CAA2C,CAAC;AAClE,MAAM,aAAa,GAAG,sCAAsC,CAAC;AAC7D,MAAM,eAAe,GAAG,+BAA+B,CAAC;AAqBxD,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,IAAI,IAAkC,CAAC;IACvC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,OAAO,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,GAAG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R,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;oBACvC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;oBACtC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACzC,OAAO,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { parseDemo3D, type ParseDemo3DOptions } from "./parser.js";
|
|
2
|
+
export { Demo3DPackage, Demo3DProject, Demo3DHeader, Demo3DLayer, Demo3DVisual, Demo3DMesh, Demo3DMaterial, Demo3DResource, Demo3DReference, Demo3DTypedObject, Demo3DUnknownObject, registerDemo3DType, type Demo3DTypeConstructor } from "./model.js";
|
|
3
|
+
export { Demo3DBinaryBlock, Demo3DXmlElement, type Demo3DScalarValue, type Demo3DXmlAttribute, type ParseXmlDocument } from "./xml.js";
|
|
4
|
+
export { parseDemo3DXmlFast } from "./fast-xml.js";
|
|
5
|
+
export { ZipArchive, ZipEntry, parseZip, normalizeZipPath, type ZipEntryInfo } from "./zip.js";
|
|
6
|
+
export { Demo3DError, Demo3DUnsupportedError, Demo3DXmlError, Demo3DZipError } from "./errors.js";
|
|
7
|
+
export type { Demo3DInput } from "./binary.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClG,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { parseDemo3D } from "./parser.js";
|
|
2
|
+
export { Demo3DPackage, Demo3DProject, Demo3DHeader, Demo3DLayer, Demo3DVisual, Demo3DMesh, Demo3DMaterial, Demo3DResource, Demo3DReference, Demo3DTypedObject, Demo3DUnknownObject, registerDemo3DType } from "./model.js";
|
|
3
|
+
export { Demo3DBinaryBlock, Demo3DXmlElement } from "./xml.js";
|
|
4
|
+
export { parseDemo3DXmlFast } from "./fast-xml.js";
|
|
5
|
+
export { ZipArchive, ZipEntry, parseZip, normalizeZipPath } from "./zip.js";
|
|
6
|
+
export { Demo3DError, Demo3DUnsupportedError, Demo3DXmlError, Demo3DZipError } from "./errors.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA2B,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAEnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAIjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAqB,MAAM,UAAU,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|