@markandre13/usd.js 0.0.4 → 0.0.6
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 +10 -2
- package/dist/compression/compress.js +5 -2
- package/dist/compression/compress.js.map +1 -1
- package/dist/compression/integers.js +13 -0
- package/dist/compression/integers.js.map +1 -1
- package/dist/compression/lz4.d.ts +18 -1
- package/dist/compression/lz4.js +100 -17
- package/dist/compression/lz4.js.map +1 -1
- package/dist/crate/BootStrap.js +2 -0
- package/dist/crate/BootStrap.js.map +1 -1
- package/dist/crate/Crate.d.ts +10 -1
- package/dist/crate/Crate.js +72 -8
- package/dist/crate/Crate.js.map +1 -1
- package/dist/crate/CrateDataType.d.ts +1 -1
- package/dist/crate/CrateDataType.js +3 -0
- package/dist/crate/CrateDataType.js.map +1 -1
- package/dist/crate/Field.d.ts +2 -1
- package/dist/crate/Field.js +2 -2
- package/dist/crate/Field.js.map +1 -1
- package/dist/crate/FieldSets.js +1 -0
- package/dist/crate/FieldSets.js.map +1 -1
- package/dist/crate/Fields.d.ts +2 -10
- package/dist/crate/Fields.js +35 -4
- package/dist/crate/Fields.js.map +1 -1
- package/dist/crate/ListOp.d.ts +29 -0
- package/dist/crate/ListOp.js +22 -0
- package/dist/crate/ListOp.js.map +1 -0
- package/dist/crate/Paths.d.ts +1 -1
- package/dist/crate/Paths.js +16 -2
- package/dist/crate/Paths.js.map +1 -1
- package/dist/crate/Reader.js +3 -3
- package/dist/crate/Reader.js.map +1 -1
- package/dist/crate/SpecType.d.ts +3 -3
- package/dist/crate/SpecType.js +2 -0
- package/dist/crate/SpecType.js.map +1 -1
- package/dist/crate/Specifier.d.ts +1 -1
- package/dist/crate/Specs.js +1 -0
- package/dist/crate/Specs.js.map +1 -1
- package/dist/crate/Stage.d.ts +1 -1
- package/dist/crate/Stage.js +1 -0
- package/dist/crate/Stage.js.map +1 -1
- package/dist/crate/Strings.js +5 -0
- package/dist/crate/Strings.js.map +1 -1
- package/dist/crate/Tokens.js +47 -1
- package/dist/crate/Tokens.js.map +1 -1
- package/dist/crate/ValueRep.d.ts +2 -2
- package/dist/crate/ValueRep.js +33 -6
- package/dist/crate/ValueRep.js.map +1 -1
- package/dist/crate/Variability.d.ts +1 -1
- package/dist/crate/Writer.d.ts +3 -0
- package/dist/crate/Writer.js +21 -0
- package/dist/crate/Writer.js.map +1 -1
- package/dist/detail/hexdump.js +1 -0
- package/dist/detail/hexdump.js.map +1 -1
- package/dist/nodes/attributes/AssetPathAttr.d.ts +1 -1
- package/dist/nodes/attributes/AssetPathAttr.js +1 -1
- package/dist/nodes/attributes/AssetPathAttr.js.map +1 -1
- package/dist/nodes/attributes/Attribute.d.ts +1 -1
- package/dist/nodes/attributes/Attribute.js +1 -1
- package/dist/nodes/attributes/Attribute.js.map +1 -1
- package/dist/nodes/attributes/BooleanAttr.d.ts +1 -1
- package/dist/nodes/attributes/BooleanAttr.js +1 -1
- package/dist/nodes/attributes/BooleanAttr.js.map +1 -1
- package/dist/nodes/attributes/Color3fAttr.d.ts +3 -3
- package/dist/nodes/attributes/Color3fAttr.js +1 -1
- package/dist/nodes/attributes/Color3fAttr.js.map +1 -1
- package/dist/nodes/attributes/FloatArrayAttr.d.ts +6 -0
- package/dist/nodes/attributes/FloatArrayAttr.js +18 -0
- package/dist/nodes/attributes/FloatArrayAttr.js.map +1 -0
- package/dist/nodes/attributes/FloatAttr.d.ts +1 -1
- package/dist/nodes/attributes/FloatAttr.js +1 -1
- package/dist/nodes/attributes/FloatAttr.js.map +1 -1
- package/dist/nodes/attributes/IntArrayAttr.d.ts +4 -2
- package/dist/nodes/attributes/IntArrayAttr.js +6 -2
- package/dist/nodes/attributes/IntArrayAttr.js.map +1 -1
- package/dist/nodes/attributes/Relationship.d.ts +2 -2
- package/dist/nodes/attributes/Relationship.js +1 -1
- package/dist/nodes/attributes/Relationship.js.map +1 -1
- package/dist/nodes/attributes/StringAttr.d.ts +1 -1
- package/dist/nodes/attributes/StringAttr.js +1 -1
- package/dist/nodes/attributes/StringAttr.js.map +1 -1
- package/dist/nodes/attributes/TokenAttr.d.ts +3 -3
- package/dist/nodes/attributes/TokenAttr.js +13 -3
- package/dist/nodes/attributes/TokenAttr.js.map +1 -1
- package/dist/nodes/attributes/VariabilityAttr.d.ts +1 -1
- package/dist/nodes/attributes/VariabilityAttr.js +1 -1
- package/dist/nodes/attributes/VariabilityAttr.js.map +1 -1
- package/dist/nodes/attributes/Vec2fArrayAttr.d.ts +1 -1
- package/dist/nodes/attributes/Vec2fArrayAttr.js +1 -1
- package/dist/nodes/attributes/Vec2fArrayAttr.js.map +1 -1
- package/dist/nodes/attributes/Vec3fArrayAttr.d.ts +4 -2
- package/dist/nodes/attributes/Vec3fArrayAttr.js +6 -2
- package/dist/nodes/attributes/Vec3fArrayAttr.js.map +1 -1
- package/dist/nodes/geometry/Boundable.d.ts +6 -0
- package/dist/nodes/geometry/Boundable.js +6 -0
- package/dist/nodes/geometry/Boundable.js.map +1 -1
- package/dist/nodes/geometry/Camera.d.ts +7 -2
- package/dist/nodes/geometry/Camera.js +36 -0
- package/dist/nodes/geometry/Camera.js.map +1 -1
- package/dist/nodes/geometry/GeomSubset.d.ts +67 -2
- package/dist/nodes/geometry/GeomSubset.js +101 -8
- package/dist/nodes/geometry/GeomSubset.js.map +1 -1
- package/dist/nodes/geometry/Gprim.d.ts +28 -0
- package/dist/nodes/geometry/Gprim.js +30 -0
- package/dist/nodes/geometry/Gprim.js.map +1 -1
- package/dist/nodes/geometry/Imageable.d.ts +9 -0
- package/dist/nodes/geometry/Imageable.js +9 -0
- package/dist/nodes/geometry/Imageable.js.map +1 -1
- package/dist/nodes/geometry/Mesh.d.ts +75 -10
- package/dist/nodes/geometry/Mesh.js +121 -8
- package/dist/nodes/geometry/Mesh.js.map +1 -1
- package/dist/nodes/geometry/PointBased.d.ts +20 -2
- package/dist/nodes/geometry/PointBased.js +35 -11
- package/dist/nodes/geometry/PointBased.js.map +1 -1
- package/dist/nodes/geometry/Scope.d.ts +9 -1
- package/dist/nodes/geometry/Scope.js +8 -0
- package/dist/nodes/geometry/Scope.js.map +1 -1
- package/dist/nodes/geometry/SkelBindingAPI.d.ts +70 -0
- package/dist/nodes/geometry/SkelBindingAPI.js +2 -0
- package/dist/nodes/geometry/SkelBindingAPI.js.map +1 -0
- package/dist/nodes/geometry/Xform.d.ts +6 -1
- package/dist/nodes/geometry/Xform.js +5 -0
- package/dist/nodes/geometry/Xform.js.map +1 -1
- package/dist/nodes/geometry/Xformable.d.ts +9 -3
- package/dist/nodes/geometry/Xformable.js +6 -0
- package/dist/nodes/geometry/Xformable.js.map +1 -1
- package/dist/nodes/lux/BoundableLightBase.d.ts +8 -0
- package/dist/nodes/lux/BoundableLightBase.js +8 -0
- package/dist/nodes/lux/BoundableLightBase.js.map +1 -1
- package/dist/nodes/lux/DomeLight.d.ts +11 -1
- package/dist/nodes/lux/DomeLight.js +10 -0
- package/dist/nodes/lux/DomeLight.js.map +1 -1
- package/dist/nodes/lux/NonboundableLightBase.d.ts +1 -1
- package/dist/nodes/lux/NonboundableLightBase.js +10 -1
- package/dist/nodes/lux/NonboundableLightBase.js.map +1 -1
- package/dist/nodes/lux/SphereLight.d.ts +9 -1
- package/dist/nodes/lux/SphereLight.js +8 -0
- package/dist/nodes/lux/SphereLight.js.map +1 -1
- package/dist/nodes/shader/Material.d.ts +8 -1
- package/dist/nodes/shader/Material.js +19 -0
- package/dist/nodes/shader/Material.js.map +1 -1
- package/dist/nodes/shader/NodeGraph.d.ts +7 -0
- package/dist/nodes/shader/NodeGraph.js +7 -0
- package/dist/nodes/shader/NodeGraph.js.map +1 -1
- package/dist/nodes/shader/Shader.d.ts +9 -1
- package/dist/nodes/shader/Shader.js +8 -0
- package/dist/nodes/shader/Shader.js.map +1 -1
- package/dist/nodes/shader/blender/ImageTexture.d.ts +12 -0
- package/dist/nodes/shader/blender/ImageTexture.js +59 -0
- package/dist/nodes/shader/blender/ImageTexture.js.map +1 -0
- package/dist/nodes/shader/blender/PrincipledBSDF.d.ts +14 -0
- package/dist/nodes/shader/blender/PrincipledBSDF.js +82 -0
- package/dist/nodes/shader/blender/PrincipledBSDF.js.map +1 -0
- package/dist/nodes/shader/blender/UVMap.d.ts +9 -0
- package/dist/nodes/shader/blender/UVMap.js +32 -0
- package/dist/nodes/shader/blender/UVMap.js.map +1 -0
- package/dist/nodes/skeleton/BlendShape.d.ts +21 -0
- package/dist/nodes/skeleton/BlendShape.js +46 -0
- package/dist/nodes/skeleton/BlendShape.js.map +1 -0
- package/dist/nodes/skeleton/SkelAnimation.d.ts +26 -0
- package/dist/nodes/skeleton/SkelAnimation.js +50 -0
- package/dist/nodes/skeleton/SkelAnimation.js.map +1 -0
- package/dist/nodes/skeleton/SkelRoot.d.ts +6 -1
- package/dist/nodes/skeleton/SkelRoot.js +5 -0
- package/dist/nodes/skeleton/SkelRoot.js.map +1 -1
- package/dist/nodes/skeleton/Skeleton.d.ts +51 -4
- package/dist/nodes/skeleton/Skeleton.js +51 -0
- package/dist/nodes/skeleton/Skeleton.js.map +1 -1
- package/dist/nodes/usd/PseudoRoot.d.ts +1 -1
- package/dist/nodes/usd/PseudoRoot.js +21 -1
- package/dist/nodes/usd/PseudoRoot.js.map +1 -1
- package/dist/nodes/usd/SchemaBase.d.ts +1 -1
- package/dist/nodes/usd/SchemaBase.js +1 -1
- package/dist/nodes/usd/SchemaBase.js.map +1 -1
- package/dist/nodes/usd/Typed.d.ts +10 -0
- package/dist/nodes/usd/Typed.js +10 -0
- package/dist/nodes/usd/Typed.js.map +1 -1
- package/dist/{crate → nodes/usd}/UsdNode.d.ts +21 -9
- package/dist/{crate → nodes/usd}/UsdNode.js +56 -2
- package/dist/nodes/usd/UsdNode.js.map +1 -0
- package/package.json +8 -8
- package/dist/crate/UsdNode.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Universal Scene Description for TypeScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Tiny, dependency-free USDC library written in TypeScript.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
_Tiny_ also means that only a tiny subset of USD has been implemented.
|
|
6
|
+
|
|
7
|
+
* Mesh
|
|
8
|
+
* Skeleton
|
|
9
|
+
* Material
|
|
10
|
+
* Camera
|
|
11
|
+
* DomeLight, SphereLight
|
|
12
|
+
|
|
13
|
+
See the [blender.spec.ts](./spec/blender.spec.ts) for examples.
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// git clone https://github.com/PixarAnimationStudios/OpenUSD.git
|
|
2
|
+
// pxr/usd/sdf/crateFile.h
|
|
3
|
+
import { compressBlock, compressBound, decompressBlock, LZ4_MAX_INPUT_SIZE } from "./lz4";
|
|
4
|
+
// OpenUSD/pxr/base/tf/fastCompression.cpp: TfFastCompression::DecompressFromBuffer(...)
|
|
5
|
+
// tinyusdz/src/lz4-compression.cc: LZ4Compression::DecompressFromBuffer(...)
|
|
2
6
|
export function decompressFromBuffer(src, dst) {
|
|
3
7
|
const nChunks = src.at(0);
|
|
4
8
|
if (nChunks > 127) {
|
|
@@ -14,7 +18,6 @@ export function decompressFromBuffer(src, dst) {
|
|
|
14
18
|
throw Error("decompressFromBuffer(): chunks are not implemented yet");
|
|
15
19
|
}
|
|
16
20
|
export function compressToBuffer(src, dst) {
|
|
17
|
-
const LZ4_MAX_INPUT_SIZE = 0x7E000000;
|
|
18
21
|
if (src.length < LZ4_MAX_INPUT_SIZE) {
|
|
19
22
|
if (dst.length < compressBound(src.length) + 1) {
|
|
20
23
|
throw Error(`compressToBuffer(): dst has ${dst.length} octets but at least ${compressBound(src.length) + 1} are needed`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.js","sourceRoot":"","sources":["../../src/compression/compress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compress.js","sourceRoot":"","sources":["../../src/compression/compress.ts"],"names":[],"mappings":"AAAA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G,EAAE,aAAa,EAAE,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;QAC9D,OAAO,CAAC,GAAG,CAAC,CAAA;IAChB,CAAC;IACD,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAA;AACrE,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// encode / decode int32
|
|
2
|
+
// int32: common value
|
|
3
|
+
// sequence of uint8 containing 4 Codes
|
|
4
|
+
// sequence of int8|int16|int32 as defined by the codes
|
|
5
|
+
// encoded values are the difference to the previous value
|
|
1
6
|
var Code;
|
|
2
7
|
(function (Code) {
|
|
3
8
|
Code[Code["Common"] = 0] = "Common";
|
|
@@ -51,6 +56,7 @@ export function encodeIntegers(input, output) {
|
|
|
51
56
|
if (input.length === 0) {
|
|
52
57
|
return 0;
|
|
53
58
|
}
|
|
59
|
+
// First find the most common element value.
|
|
54
60
|
let commonValue = 0;
|
|
55
61
|
{
|
|
56
62
|
let commonCount = 0;
|
|
@@ -71,11 +77,15 @@ export function encodeIntegers(input, output) {
|
|
|
71
77
|
commonCount = count;
|
|
72
78
|
}
|
|
73
79
|
else if (count == commonCount && val > commonValue) {
|
|
80
|
+
// Take the largest common value in case of a tie -- this gives
|
|
81
|
+
// the biggest potential savings in the encoded stream.
|
|
74
82
|
commonValue = val;
|
|
75
83
|
}
|
|
76
84
|
prevVal = input[cur];
|
|
77
85
|
}
|
|
78
86
|
}
|
|
87
|
+
// Now code the values.
|
|
88
|
+
// Write most common value.
|
|
79
89
|
output.setInt32(0, commonValue, true);
|
|
80
90
|
let numInts = input.length;
|
|
81
91
|
const arg = {
|
|
@@ -109,6 +119,7 @@ export function encodeIntegers(input, output) {
|
|
|
109
119
|
}
|
|
110
120
|
function decodeNHelper(N, arg) {
|
|
111
121
|
const codeByte = arg.src.getUint8(arg.codesIn++);
|
|
122
|
+
// console.log(`decodeNHelper(N=${N}): codeByte=${codeByte}`)
|
|
112
123
|
for (let i = 0; i != N; ++i) {
|
|
113
124
|
const x = (codeByte & (3 << (2 * i))) >> (2 * i);
|
|
114
125
|
switch (x) {
|
|
@@ -154,6 +165,8 @@ export function decodeIntegers(src, numInts) {
|
|
|
154
165
|
if (intsLeft > 0) {
|
|
155
166
|
decodeNHelper(intsLeft, arg);
|
|
156
167
|
}
|
|
168
|
+
// console.log(`_DecodeIntegers(..., ${numInts})`)
|
|
169
|
+
// console.log(JSON.stringify(arg.result))
|
|
157
170
|
return arg.result;
|
|
158
171
|
}
|
|
159
172
|
//# sourceMappingURL=integers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integers.js","sourceRoot":"","sources":["../../src/compression/integers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integers.js","sourceRoot":"","sources":["../../src/compression/integers.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,sBAAsB;AACtB,uCAAuC;AACvC,uDAAuD;AACvD,0DAA0D;AAC1D,IAAK,IAAmC;AAAxC,WAAK,IAAI;IAAG,mCAAM,CAAA;IAAE,+BAAI,CAAA;IAAE,iCAAK,CAAA;IAAE,iCAAK,CAAA;AAAC,CAAC,EAAnC,IAAI,KAAJ,IAAI,QAA+B;AAAA,CAAC;AAYzC,SAAS,aAAa,CAAC,CAAS,EAAE,GAAS;IACvC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE;QAC1B,IAAI,CAAC,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,MAAM,CAAA;QAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,IAAI,CAAA;QAAC,CAAC;QAC/C,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;YAAC,OAAO,IAAI,CAAC,KAAK,CAAA;QAAC,CAAC;QACpD,OAAO,IAAI,CAAC,KAAK,CAAA;IACrB,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,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC,GAAG,aAAa;QAC1B,WAAW;QACX,OAAO;KACV,CAAA;IACD,OAAO,QAAQ,IAAI,CAAC,EAAE,CAAC;QACnB,aAAa,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;QACrB,QAAQ,IAAI,CAAC,CAAA;IACjB,CAAC;IACD,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QACf,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IAChC,CAAC;IAED,kDAAkD;IAClD,0CAA0C;IAE1C,OAAO,GAAG,CAAC,MAAM,CAAA;AACrB,CAAC"}
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
export declare const LZ4_MAX_INPUT_SIZE = 2113929216;
|
|
1
2
|
export declare function decompressBlock(src: Uint8Array, dst: Uint8Array, sIndex: number, sLength: number, dIndex: number): number;
|
|
2
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
|
|
5
|
+
* This function is primarily useful for memory allocation purposes (destination buffer size).
|
|
6
|
+
*
|
|
7
|
+
* @param inputSize max supported value is LZ4_MAX_INPUT_SIZE
|
|
8
|
+
* @returns maximum output size in a "worst case" scenario or 0, if input size is incorrect (too large or negative)
|
|
9
|
+
*/
|
|
10
|
+
export declare function compressBound(inputSize: number): number;
|
|
11
|
+
/**
|
|
12
|
+
* compress src into dst
|
|
13
|
+
*
|
|
14
|
+
* @param src
|
|
15
|
+
* @param dst
|
|
16
|
+
* @param sIndex
|
|
17
|
+
* @param sLength
|
|
18
|
+
* @returns size of compressed data in dst
|
|
19
|
+
*/
|
|
3
20
|
export declare function compressBlock(src: Uint8Array, dst: Uint8Array, sIndex: number, sLength: number): number;
|
package/dist/compression/lz4.js
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//
|
|
2
|
+
// copied on 2025-11-30 from https://github.com/Benzinga/lz4js
|
|
3
|
+
// copyright 2018 John Chadwick, licensed under ISC
|
|
4
|
+
// with the following changes
|
|
5
|
+
// * compressBlock():
|
|
6
|
+
// * fix: return something when input which can't be compressed
|
|
7
|
+
// * fix: increase size of remaining literals to compatible with lz4.org's decompressBlock()
|
|
8
|
+
// * added comments
|
|
9
|
+
// * use capital letters for constants
|
|
10
|
+
// * remove hashtable argument
|
|
11
|
+
// * decompressBlock()
|
|
12
|
+
// * add additional restrictions from lz4.org to validate compressBlock()'s correctness
|
|
13
|
+
// Compression format parameters/constants.
|
|
14
|
+
const LZ4_MIN_MATCH = 4; // we are looking for matches of at least 4 bytes
|
|
15
|
+
const LZ4_MIN_LENGTH = 13; // don't compress when input is less than 13 bytes
|
|
3
16
|
const LZ4_SEARCH_LIMIT = 5;
|
|
4
17
|
const LZ4_SKIP_TRIGGER = 6;
|
|
5
|
-
const LZ4_HASH_TABLE_SIZE = 1 << 16;
|
|
18
|
+
const LZ4_HASH_TABLE_SIZE = 1 << 16; // hash table has space for uint32_t entries (64k entries)
|
|
19
|
+
export const LZ4_MAX_INPUT_SIZE = 0x7E000000; // 2 113 929 216 bytes
|
|
20
|
+
// Token constants.
|
|
6
21
|
const LZ4_ML_BITS = 4;
|
|
7
22
|
const LZ4_ML_MASK = (1 << LZ4_ML_BITS) - 1;
|
|
8
23
|
const LZ4_RUN_BITS = 4;
|
|
9
24
|
const LZ4_RUN_MASK = (1 << LZ4_RUN_BITS) - 1;
|
|
25
|
+
// Shared buffers
|
|
10
26
|
const hashTable = new Uint32Array(LZ4_HASH_TABLE_SIZE);
|
|
11
27
|
const util = {
|
|
12
28
|
hashU32: function hashU32(a) {
|
|
@@ -28,11 +44,15 @@ const util = {
|
|
|
28
44
|
};
|
|
29
45
|
export function decompressBlock(src, dst, sIndex, sLength, dIndex) {
|
|
30
46
|
let mLength, mOffset, sEnd, n, i;
|
|
47
|
+
// Setup initial state.
|
|
31
48
|
sEnd = sIndex + sLength;
|
|
49
|
+
// Consume entire input block.
|
|
32
50
|
while (sIndex < sEnd) {
|
|
33
51
|
var token = src[sIndex++];
|
|
52
|
+
// Copy literals.
|
|
34
53
|
var literalCount = (token >> 4);
|
|
35
54
|
if (literalCount > 0) {
|
|
55
|
+
// Parse length.
|
|
36
56
|
if (literalCount === 0xf) {
|
|
37
57
|
while (true) {
|
|
38
58
|
literalCount += src[sIndex];
|
|
@@ -41,10 +61,12 @@ export function decompressBlock(src, dst, sIndex, sLength, dIndex) {
|
|
|
41
61
|
}
|
|
42
62
|
}
|
|
43
63
|
}
|
|
64
|
+
// Copy literals
|
|
44
65
|
for (n = sIndex + literalCount; sIndex < n;) {
|
|
45
66
|
dst[dIndex++] = src[sIndex++];
|
|
46
67
|
}
|
|
47
68
|
}
|
|
69
|
+
// additional condition from lz4.c not needed for this implementation
|
|
48
70
|
{
|
|
49
71
|
const ip = sIndex - literalCount;
|
|
50
72
|
const op = dIndex - literalCount;
|
|
@@ -54,7 +76,11 @@ export function decompressBlock(src, dst, sIndex, sLength, dIndex) {
|
|
|
54
76
|
const iend = sEnd;
|
|
55
77
|
const MFLIMIT = 12;
|
|
56
78
|
const LASTLITERALS = 5;
|
|
79
|
+
// if end of output or input buffer
|
|
57
80
|
if ((cpy > oend - MFLIMIT) || (ip + length > iend - (2 + 1 + LASTLITERALS))) {
|
|
81
|
+
/* We must be on the last sequence (or invalid) because of the parsing limitations
|
|
82
|
+
* so check that we exactly consume the input and don't overrun the output buffer.
|
|
83
|
+
*/
|
|
58
84
|
if ((ip + length != iend) || (cpy > oend)) {
|
|
59
85
|
return -ip - 1;
|
|
60
86
|
}
|
|
@@ -63,8 +89,11 @@ export function decompressBlock(src, dst, sIndex, sLength, dIndex) {
|
|
|
63
89
|
if (sIndex >= sEnd) {
|
|
64
90
|
break;
|
|
65
91
|
}
|
|
92
|
+
// Copy match.
|
|
66
93
|
mLength = (token & 0xf);
|
|
94
|
+
// Parse offset.
|
|
67
95
|
mOffset = src[sIndex++] | (src[sIndex++] << 8);
|
|
96
|
+
// Parse length.
|
|
68
97
|
if (mLength === 0xf) {
|
|
69
98
|
while (true) {
|
|
70
99
|
mLength += src[sIndex];
|
|
@@ -74,6 +103,7 @@ export function decompressBlock(src, dst, sIndex, sLength, dIndex) {
|
|
|
74
103
|
}
|
|
75
104
|
}
|
|
76
105
|
mLength += LZ4_MIN_MATCH;
|
|
106
|
+
// Copy match.
|
|
77
107
|
for (i = dIndex - mOffset, n = i + mLength; i < n;) {
|
|
78
108
|
dst[dIndex++] = dst[i++] | 0;
|
|
79
109
|
}
|
|
@@ -81,69 +111,121 @@ export function decompressBlock(src, dst, sIndex, sLength, dIndex) {
|
|
|
81
111
|
return dIndex;
|
|
82
112
|
}
|
|
83
113
|
;
|
|
84
|
-
|
|
85
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
|
|
116
|
+
* This function is primarily useful for memory allocation purposes (destination buffer size).
|
|
117
|
+
*
|
|
118
|
+
* @param inputSize max supported value is LZ4_MAX_INPUT_SIZE
|
|
119
|
+
* @returns maximum output size in a "worst case" scenario or 0, if input size is incorrect (too large or negative)
|
|
120
|
+
*/
|
|
121
|
+
export function compressBound(inputSize) {
|
|
122
|
+
if (inputSize > LZ4_MAX_INPUT_SIZE) {
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
// (unsigned)(inputSize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
|
|
126
|
+
return (inputSize + (inputSize / 255) + 16) | 0;
|
|
86
127
|
}
|
|
87
128
|
;
|
|
129
|
+
/**
|
|
130
|
+
* compress src into dst
|
|
131
|
+
*
|
|
132
|
+
* @param src
|
|
133
|
+
* @param dst
|
|
134
|
+
* @param sIndex
|
|
135
|
+
* @param sLength
|
|
136
|
+
* @returns size of compressed data in dst
|
|
137
|
+
*/
|
|
88
138
|
export function compressBlock(src, dst, sIndex, sLength) {
|
|
89
|
-
var mIndex, mAnchor, mLength, mOffset;
|
|
139
|
+
var mIndex, mAnchor, mLength, mOffset; //, mStep = 1
|
|
90
140
|
var literalCount, dIndex, sEnd, n;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
141
|
+
// Setup initial state.
|
|
142
|
+
dIndex = 0; // destination index for output
|
|
143
|
+
sEnd = sLength + sIndex; // end of source
|
|
144
|
+
mAnchor = sIndex; // match anchor: position after which there wasn't a match yet
|
|
145
|
+
// Process only if block is large enough.
|
|
94
146
|
if (sLength >= LZ4_MIN_LENGTH) {
|
|
95
147
|
hashTable.fill(0);
|
|
96
148
|
let searchMatchNb = (1 << LZ4_SKIP_TRIGGER) + 3;
|
|
149
|
+
// Consume until last n literals (Lz4 spec limitation.)
|
|
150
|
+
// while (sIndex + LZ4_MIN_MATCH < sEnd - LZ4_SEARCH_LIMIT) { // 4 5 2 = 11
|
|
97
151
|
while (sIndex + LZ4_MIN_MATCH < sEnd - LZ4_SEARCH_LIMIT - 2) {
|
|
98
152
|
var seq = util.readU32(src, sIndex);
|
|
153
|
+
// console.log(`step=${mStep}, searchMatchNb=${searchMatchNb}, seq[${sIndex.toString().padStart(4, ' ')}] = 0x${seq.toString(16).padStart(8, '0')}`)
|
|
99
154
|
var hash = util.hashU32(seq) >>> 0;
|
|
155
|
+
// Crush hash to 16 bits.
|
|
100
156
|
hash = ((hash >> 16) ^ hash) >>> 0 & 0xffff;
|
|
157
|
+
// Look for a match in the hashtable. NOTE: remove one; see below.
|
|
101
158
|
mIndex = hashTable[hash] - 1;
|
|
159
|
+
// Put pos in hash table. NOTE: add one so that zero = invalid.
|
|
102
160
|
hashTable[hash] = sIndex + 1;
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
161
|
+
// Determine if there is a match (within range.)
|
|
162
|
+
// continue looking for a match when
|
|
163
|
+
if (mIndex < 0 // seq not found in hashtable
|
|
164
|
+
|| ((sIndex - mIndex) >>> 16) > 0 // OR distance between match and source exceeds 16 bits
|
|
165
|
+
|| util.readU32(src, mIndex) !== seq) // OR value referenced by hashtable actually differs
|
|
166
|
+
{
|
|
167
|
+
// speed up search the longer the search takes
|
|
106
168
|
const mStep = searchMatchNb++ >> LZ4_SKIP_TRIGGER;
|
|
107
169
|
sIndex += mStep;
|
|
108
|
-
continue;
|
|
170
|
+
continue; // keep looking for match
|
|
109
171
|
}
|
|
172
|
+
// console.log(`matched sequence with earlier one at ${mIndex}`)
|
|
110
173
|
searchMatchNb = (1 << LZ4_SKIP_TRIGGER) + 3;
|
|
111
|
-
|
|
112
|
-
|
|
174
|
+
// Calculate literal count and offset.
|
|
175
|
+
literalCount = sIndex - mAnchor; // number of bytes since the last match
|
|
176
|
+
mOffset = sIndex - mIndex; // offset from current source position to the matched position
|
|
177
|
+
// We've already matched one word, so get that out of the way.
|
|
113
178
|
sIndex += LZ4_MIN_MATCH;
|
|
114
179
|
mIndex += LZ4_MIN_MATCH;
|
|
115
|
-
|
|
180
|
+
// Determine match length.
|
|
181
|
+
// N.B.: mLength does not include minMatch, Lz4 adds it back in decoding.
|
|
182
|
+
// console.log(`compare match at mIndex=${mIndex} with at sIndex=${sIndex}`)
|
|
183
|
+
mLength = sIndex; // sIndex when starting to calculate length
|
|
116
184
|
while (sIndex < sEnd - LZ4_SEARCH_LIMIT && src[sIndex] === src[mIndex]) {
|
|
117
185
|
sIndex++;
|
|
118
186
|
mIndex++;
|
|
119
187
|
}
|
|
120
|
-
|
|
188
|
+
// console.log(`sIndex=${sIndex}, mIndex=${mIndex}`)
|
|
189
|
+
mLength = sIndex - mLength; // sIndex after calculating length - sIndex when starting calculating length
|
|
190
|
+
// write token containing the lengths
|
|
191
|
+
// console.log(`literalsToFollow := mLength ${mLength} < mlMask ${LZ4_ML_MASK} ? mLength : mlMask`)
|
|
121
192
|
var literalsToFollow = mLength < LZ4_ML_MASK ? mLength : LZ4_ML_MASK;
|
|
122
193
|
if (literalCount >= LZ4_RUN_MASK) {
|
|
194
|
+
// console.log(`dst[${dIndex}] := token: 0x${LZ4_RUN_MASK.toString(16)}${literalsToFollow.toString(16)}`)
|
|
123
195
|
dst[dIndex++] = (LZ4_RUN_MASK << LZ4_ML_BITS) + literalsToFollow;
|
|
124
196
|
for (n = literalCount - LZ4_RUN_MASK; n >= 0xff; n -= 0xff) {
|
|
197
|
+
// console.log(`dst[${dIndex}] := token: 0xff`)
|
|
125
198
|
dst[dIndex++] = 0xff;
|
|
126
199
|
}
|
|
200
|
+
// console.log(`dst[${dIndex}] := token: 0x${n.toString(16).padStart(2, '0')}`)
|
|
127
201
|
dst[dIndex++] = n;
|
|
128
202
|
}
|
|
129
203
|
else {
|
|
204
|
+
// console.log(`dst[${dIndex}] := token: ${literalCount.toString(16)} / ${literalsToFollow.toString(16)}`)
|
|
130
205
|
dst[dIndex++] = (literalCount << LZ4_ML_BITS) + literalsToFollow;
|
|
131
206
|
}
|
|
207
|
+
// copy literals inside which the match was found
|
|
132
208
|
for (var i = 0; i < literalCount; i++) {
|
|
133
209
|
dst[dIndex++] = src[mAnchor + i];
|
|
134
210
|
}
|
|
211
|
+
// write offset where to find the match relative to current position
|
|
135
212
|
dst[dIndex++] = mOffset;
|
|
136
213
|
dst[dIndex++] = (mOffset >> 8);
|
|
214
|
+
// write length of the match
|
|
137
215
|
if (mLength >= LZ4_ML_MASK) {
|
|
138
216
|
for (n = mLength - LZ4_ML_MASK; n >= 0xff; n -= 0xff) {
|
|
139
217
|
dst[dIndex++] = 0xff;
|
|
140
218
|
}
|
|
141
219
|
dst[dIndex++] = n;
|
|
142
220
|
}
|
|
221
|
+
// move the anchor
|
|
143
222
|
mAnchor = sIndex;
|
|
144
223
|
}
|
|
145
224
|
}
|
|
225
|
+
// write remaining literals for which no match was found
|
|
226
|
+
// write token with the length
|
|
146
227
|
literalCount = sEnd - mAnchor;
|
|
228
|
+
// console.log(`literalCount=${literalCount}`)
|
|
147
229
|
if (literalCount >= LZ4_RUN_MASK) {
|
|
148
230
|
dst[dIndex++] = (LZ4_RUN_MASK << LZ4_ML_BITS);
|
|
149
231
|
for (n = literalCount - LZ4_RUN_MASK; n >= 0xff; n -= 0xff) {
|
|
@@ -154,6 +236,7 @@ export function compressBlock(src, dst, sIndex, sLength) {
|
|
|
154
236
|
else {
|
|
155
237
|
dst[dIndex++] = (literalCount << LZ4_ML_BITS);
|
|
156
238
|
}
|
|
239
|
+
// copy the remaining literals
|
|
157
240
|
sIndex = mAnchor;
|
|
158
241
|
while (sIndex < sEnd) {
|
|
159
242
|
dst[dIndex++] = src[sIndex++];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lz4.js","sourceRoot":"","sources":["../../src/compression/lz4.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lz4.js","sourceRoot":"","sources":["../../src/compression/lz4.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,8DAA8D;AAC9D,6EAA6E;AAC7E,6BAA6B;AAC7B,qBAAqB;AACrB,iEAAiE;AACjE,8FAA8F;AAC9F,qBAAqB;AACrB,wCAAwC;AACxC,gCAAgC;AAChC,sBAAsB;AACtB,yFAAyF;AAEzF,2CAA2C;AAC3C,MAAM,aAAa,GAAG,CAAC,CAAA,CAAC,iDAAiD;AACzE,MAAM,cAAc,GAAG,EAAE,CAAA,CAAC,kDAAkD;AAC5E,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAC1B,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAC1B,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,CAAA,CAAC,0DAA0D;AAC9F,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAA,CAAC,sBAAsB;AAEnE,mBAAmB;AACnB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,CAAA;AAC1C,MAAM,YAAY,GAAG,CAAC,CAAA;AACtB,MAAM,YAAY,GAAG,CAAC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;QAClC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,MAAc;QACf,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACnB,CAAC;IACD,SAAS,CAAC,MAAc;QACpB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACrC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACrC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACrC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;QAChC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACtC,CAAC;IAED,OAAO;QACH,IAAI,CAAC,MAAO,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;IACxC,CAAC;CAEJ"}
|
package/dist/crate/Crate.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BootStrap } from "./BootStrap";
|
|
2
2
|
import type { Reader } from "./Reader";
|
|
3
3
|
import { TableOfContents } from "./TableOfContents";
|
|
4
|
-
import { UsdNode } from "
|
|
4
|
+
import { UsdNode } from "../nodes/usd/UsdNode";
|
|
5
5
|
import { Tokens } from "./Tokens";
|
|
6
6
|
import { Fields } from "./Fields";
|
|
7
7
|
import { Paths } from "./Paths";
|
|
@@ -21,9 +21,18 @@ export declare class Crate {
|
|
|
21
21
|
specs: Specs;
|
|
22
22
|
reader: Reader;
|
|
23
23
|
writer: Writer;
|
|
24
|
+
root?: UsdNode;
|
|
24
25
|
constructor(reader?: Reader);
|
|
26
|
+
/**
|
|
27
|
+
* Serialize root into this.writer
|
|
28
|
+
*
|
|
29
|
+
* NOTE: not idempotent
|
|
30
|
+
*
|
|
31
|
+
* @param root
|
|
32
|
+
*/
|
|
25
33
|
serialize(root: UsdNode): void;
|
|
26
34
|
forEachField(fieldSetIndex: number, block: (name: string, value: ValueRep) => void): void;
|
|
27
35
|
private buildNodeTree;
|
|
36
|
+
printTree(node?: UsdNode | undefined, depth?: number): void;
|
|
28
37
|
print(): void;
|
|
29
38
|
}
|
package/dist/crate/Crate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BootStrap } from "./BootStrap";
|
|
2
2
|
import { TableOfContents } from "./TableOfContents";
|
|
3
|
-
import { UsdNode } from "
|
|
3
|
+
import { UsdNode } from "../nodes/usd/UsdNode";
|
|
4
4
|
import { Tokens } from "./Tokens";
|
|
5
5
|
import { Fields } from "./Fields";
|
|
6
6
|
import { JUMP_NEXT_IS_CHILD_NO_SIBLINGS, JUMP_NO_CHILD_NEXT_IS_SIBLING, JUMP_NO_CHILD_NO_SIBLINGS, Paths } from "./Paths";
|
|
@@ -30,15 +30,30 @@ export class Crate {
|
|
|
30
30
|
this.paths = new Paths(reader);
|
|
31
31
|
this.toc.seek(SectionName.SPECS);
|
|
32
32
|
this.specs = new Specs(reader);
|
|
33
|
+
// build node tree
|
|
33
34
|
this.paths._nodes = new Array(this.paths.num_nodes);
|
|
35
|
+
// for(let i = 0; i<this.paths.pathIndexes.length; ++i) {
|
|
36
|
+
// const idx = this.paths.pathIndexes[i]
|
|
37
|
+
// let tkn = this.paths.tokenIndexes[i]
|
|
38
|
+
// if (tkn < 0) {
|
|
39
|
+
// tkn = -tkn
|
|
40
|
+
// }
|
|
41
|
+
// const jmp = this.paths.jumps[i]
|
|
42
|
+
// console.log(` ${i} ${idx} ${this.tokens.get(tkn)} ${jmp} `)
|
|
43
|
+
// }
|
|
34
44
|
const node = this.buildNodeTree({
|
|
35
45
|
pathIndexes: this.paths.pathIndexes,
|
|
36
46
|
tokenIndexes: this.paths.tokenIndexes,
|
|
37
47
|
jumps: this.paths.jumps,
|
|
38
48
|
depth: 0
|
|
39
49
|
});
|
|
50
|
+
this.root = node;
|
|
51
|
+
//
|
|
52
|
+
// copy this.specs into this.paths._nodes[]
|
|
53
|
+
//
|
|
40
54
|
for (let i = 0; i < this.specs.pathIndexes.length; ++i) {
|
|
41
|
-
|
|
55
|
+
const idx = this.specs.pathIndexes[i];
|
|
56
|
+
if (this.paths._nodes[idx] === undefined) {
|
|
42
57
|
for (let j = 0; j < this.paths._nodes.length; ++j) {
|
|
43
58
|
if (this.paths._nodes[j] === undefined) {
|
|
44
59
|
console.log(`this.paths._nodes[${j}] === undefined`);
|
|
@@ -46,9 +61,8 @@ export class Crate {
|
|
|
46
61
|
}
|
|
47
62
|
throw Error("yikes: Crate(reader): some paths._nodes[...] are undefined");
|
|
48
63
|
}
|
|
49
|
-
|
|
50
|
-
this.paths._nodes[
|
|
51
|
-
this.paths._nodes[i].spec_type = this.specs.specTypeIndexes[idx];
|
|
64
|
+
this.paths._nodes[idx].fieldset_index = this.specs.fieldsetIndexes[i];
|
|
65
|
+
this.paths._nodes[idx].spec_type = this.specs.specTypeIndexes[i];
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
68
|
else {
|
|
@@ -63,12 +77,20 @@ export class Crate {
|
|
|
63
77
|
this.specs = new Specs();
|
|
64
78
|
}
|
|
65
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Serialize root into this.writer
|
|
82
|
+
*
|
|
83
|
+
* NOTE: not idempotent
|
|
84
|
+
*
|
|
85
|
+
* @param root
|
|
86
|
+
*/
|
|
66
87
|
serialize(root) {
|
|
67
|
-
this.strings.add(";-)");
|
|
88
|
+
this.strings.add(";-)"); // this seems to be by convention
|
|
68
89
|
const writer = this.writer;
|
|
69
|
-
this.bootstrap.skip(writer);
|
|
90
|
+
this.bootstrap.skip(writer); // leave room for bootstrap
|
|
70
91
|
this.paths.encode(this.tokens, root);
|
|
71
92
|
root.encode();
|
|
93
|
+
// WRITE SECTIONS
|
|
72
94
|
let start, size;
|
|
73
95
|
start = writer.tell();
|
|
74
96
|
this.tokens.serialize(writer);
|
|
@@ -124,39 +146,68 @@ export class Crate {
|
|
|
124
146
|
else {
|
|
125
147
|
isPrimPropertyPath = true;
|
|
126
148
|
}
|
|
149
|
+
// console.log(`thisIndex = ${thisIndex}, pathIndexes.size = ${arg.pathIndexes.length}`)
|
|
127
150
|
if (parentNode === undefined) {
|
|
128
151
|
if (thisIndex >= arg.pathIndexes.length) {
|
|
129
152
|
throw Error("yikes: Index exceeds pathIndexes.size()");
|
|
130
153
|
}
|
|
131
154
|
root = parentNode = new UsdNode(this, undefined, idx, "/", true);
|
|
132
155
|
root.depth = 0;
|
|
156
|
+
// console.log(`buildNodeTree(): this.paths._nodes![${idx}] := /`)
|
|
133
157
|
this.paths._nodes[idx] = parentNode;
|
|
134
158
|
}
|
|
135
159
|
else {
|
|
136
160
|
if (thisIndex >= arg.tokenIndexes.length) {
|
|
137
161
|
throw Error(`Index ${thisIndex} exceeds tokenIndexes.length = ${arg.tokenIndexes.length}. $}`);
|
|
138
162
|
}
|
|
163
|
+
// console.log(`tokenIndex = ${tokenIndex}, _tokens.size = ${this.tokens!.length}`)
|
|
139
164
|
const elemToken = this.tokens.get(tokenIndex);
|
|
140
165
|
if (this.paths._nodes[idx] !== undefined) {
|
|
141
166
|
console.warn(`Crate.buildNodeTree(): node[${idx}] is already set at ${parentNode.getFullPathName()}, can't set ${elemToken}, already set to ${this.paths._nodes[idx].getFullPathName()}`);
|
|
167
|
+
// throw Error(`yikes: node[${idx}] is already set at ${parentNode.getFullPathName()}, can't set ${elemToken}, already set to ${this.paths._nodes![idx].name}`)
|
|
142
168
|
}
|
|
143
169
|
else {
|
|
144
170
|
this.paths._nodes[idx] = new UsdNode(this, parentNode, idx, elemToken, isPrimPropertyPath);
|
|
145
171
|
this.paths._nodes[idx].depth = parentNode.depth + 1;
|
|
172
|
+
// console.log(`buildNodeTree(): this.paths._nodes![${idx}] := ${" ".repeat(parentNode.depth!+1)}${elemToken}`)
|
|
146
173
|
}
|
|
147
174
|
}
|
|
175
|
+
// console.log(`${idx} ${" ".repeat(this.paths._nodes![idx].depth!)} ${this.paths._nodes![idx].name}`)
|
|
176
|
+
// if (this.tokens[tokenIndex] === undefined) {
|
|
177
|
+
// console.log(`BUMMER at tokenIndex ${tokenIndex}`)
|
|
178
|
+
// console.log(this.tokens)
|
|
179
|
+
// }
|
|
148
180
|
hasChild = jump > 0 || jump === -1;
|
|
149
181
|
hasSibling = jump >= 0;
|
|
150
182
|
if (hasChild) {
|
|
151
183
|
if (hasSibling) {
|
|
152
184
|
const siblingIndex = thisIndex + jump;
|
|
185
|
+
// ++arg.depth
|
|
153
186
|
this.buildNodeTree(arg, parentNode, siblingIndex);
|
|
187
|
+
// --arg.depth
|
|
154
188
|
}
|
|
155
|
-
parentNode = this.paths._nodes[idx];
|
|
189
|
+
parentNode = this.paths._nodes[idx]; // reset parent path
|
|
156
190
|
}
|
|
157
191
|
}
|
|
158
192
|
return root;
|
|
159
193
|
}
|
|
194
|
+
printTree(node = this.root, depth = 0) {
|
|
195
|
+
if (node === undefined) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
let fields = [];
|
|
199
|
+
for (let i = node.fieldset_index; this.fieldsets.fieldset_indices[i] > 0; ++i) {
|
|
200
|
+
fields.push(this.fieldsets.fieldset_indices[i]);
|
|
201
|
+
}
|
|
202
|
+
console.log(`${" ".repeat(depth)}[${node.index}] ${node.name} fieldSetIndex=${node.fieldset_index}, fields=[${fields.join(", ")}]`);
|
|
203
|
+
for (const field of fields) {
|
|
204
|
+
const f = this.fields.fields[field];
|
|
205
|
+
console.log(`${" ".repeat(depth)} ${f.toString(this.tokens.tokens, this)}`);
|
|
206
|
+
}
|
|
207
|
+
for (const child of node.children) {
|
|
208
|
+
this.printTree(child, depth + 1);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
160
211
|
print() {
|
|
161
212
|
console.log(`Path.print()`);
|
|
162
213
|
const numEncodedPaths = this.paths.pathIndexes.length;
|
|
@@ -182,10 +233,23 @@ export class Crate {
|
|
|
182
233
|
const fieldset_index = this.specs.fieldsetIndexes[idx];
|
|
183
234
|
const spec_type = this.specs.specTypeIndexes[idx];
|
|
184
235
|
let fields = "";
|
|
236
|
+
// console.log(`fieldset indices lenght: ${this.fieldsets.fieldset_indices.length}`)
|
|
185
237
|
for (let i = fieldset_index; this.fieldsets.fieldset_indices[i] >= 0; ++i) {
|
|
186
238
|
const fieldIndex = this.fieldsets.fieldset_indices[i];
|
|
187
239
|
fields = `${fields}${fieldIndex},`;
|
|
240
|
+
// console.log(` fieldIndex=${fieldIndex}`)
|
|
241
|
+
// console.log(this.fields)
|
|
242
|
+
// const field = this.fields.fields![fieldIndex]
|
|
243
|
+
// const token = this.tokens.get(field.tokenIndex)
|
|
244
|
+
// fields = `${fields}${token},`
|
|
188
245
|
}
|
|
246
|
+
// for (let j = fieldset_index!; this.fieldsets.fieldset_indices[j] >= 0; ++j) {
|
|
247
|
+
// const fieldIndex = this.fieldsets.fieldset_indices[i]
|
|
248
|
+
// // const field = this.fields.fields![fieldIndex]
|
|
249
|
+
// // this.fields.tokenIndices[f]
|
|
250
|
+
// // const token = this.tokens.get(field.tokenIndex)
|
|
251
|
+
// fields = `${fieldIndex};`
|
|
252
|
+
// }
|
|
189
253
|
console.log(` ${i} ${node.index} ${" ".repeat(node.depth)} ${node.name} (${jumpName}), ${SpecType[spec_type]}, fields @ ${fieldset_index}: ${fields}`);
|
|
190
254
|
}
|
|
191
255
|
}
|