@woosh/meep-engine 2.92.0 → 2.92.3
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/package.json +1 -1
- package/src/core/binary/data_view/DataType2DataViewReaders.d.ts +14 -0
- package/src/core/binary/data_view/DataType2DataViewReaders.d.ts.map +1 -0
- package/src/core/binary/data_view/DataType2DataViewReaders.js +21 -0
- package/src/core/binary/data_view/DataType2DataViewWriters.d.ts +14 -0
- package/src/core/binary/data_view/DataType2DataViewWriters.d.ts.map +1 -0
- package/src/core/binary/data_view/DataType2DataViewWriters.js +21 -0
- package/src/core/binary/data_view/DataViewStructAccessor.d.ts +17 -0
- package/src/core/binary/data_view/DataViewStructAccessor.d.ts.map +1 -0
- package/src/core/binary/data_view/DataViewStructAccessor.js +82 -0
- package/src/core/binary/data_view/DataViewStructAccessor.spec.d.ts +2 -0
- package/src/core/binary/data_view/DataViewStructAccessor.spec.d.ts.map +1 -0
- package/src/core/binary/data_view/DataViewStructAccessor.spec.js +20 -0
- package/src/core/collection/table/RowFirstTableSpec.d.ts +0 -36
- package/src/core/collection/table/RowFirstTableSpec.d.ts.map +1 -1
- package/src/core/collection/table/RowFirstTableSpec.js +6 -44
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type DataType2DataViewReaders = string;
|
|
2
|
+
export namespace DataType2DataViewReaders {
|
|
3
|
+
let uint8: string;
|
|
4
|
+
let uint16: string;
|
|
5
|
+
let uint32: string;
|
|
6
|
+
let uint64: string;
|
|
7
|
+
let int8: string;
|
|
8
|
+
let int16: string;
|
|
9
|
+
let int32: string;
|
|
10
|
+
let int64: string;
|
|
11
|
+
let float32: string;
|
|
12
|
+
let float64: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=DataType2DataViewReaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataType2DataViewReaders.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/data_view/DataType2DataViewReaders.js"],"names":[],"mappings":"uCAKU,MAAM"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BinaryDataType } from "../type/BinaryDataType.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
5
|
+
* @readonly
|
|
6
|
+
* @enum {string}
|
|
7
|
+
*/
|
|
8
|
+
export const DataType2DataViewReaders = {
|
|
9
|
+
[BinaryDataType.Uint8]: "getUint8",
|
|
10
|
+
[BinaryDataType.Uint16]: "getUint16",
|
|
11
|
+
[BinaryDataType.Uint32]: "getUint32",
|
|
12
|
+
[BinaryDataType.Uint64]: "getUint64",
|
|
13
|
+
|
|
14
|
+
[BinaryDataType.Int8]: "getInt8",
|
|
15
|
+
[BinaryDataType.Int16]: "getInt16",
|
|
16
|
+
[BinaryDataType.Int32]: "getInt32",
|
|
17
|
+
[BinaryDataType.Int64]: "getInt64",
|
|
18
|
+
|
|
19
|
+
[BinaryDataType.Float32]: "getFloat32",
|
|
20
|
+
[BinaryDataType.Float64]: "getFloat64"
|
|
21
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type DataType2DataViewWriters = string;
|
|
2
|
+
export namespace DataType2DataViewWriters {
|
|
3
|
+
let uint8: string;
|
|
4
|
+
let uint16: string;
|
|
5
|
+
let uint32: string;
|
|
6
|
+
let uint64: string;
|
|
7
|
+
let int8: string;
|
|
8
|
+
let int16: string;
|
|
9
|
+
let int32: string;
|
|
10
|
+
let int64: string;
|
|
11
|
+
let float32: string;
|
|
12
|
+
let float64: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=DataType2DataViewWriters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataType2DataViewWriters.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/data_view/DataType2DataViewWriters.js"],"names":[],"mappings":"uCAKU,MAAM"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BinaryDataType } from "../type/BinaryDataType.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
5
|
+
* @readonly
|
|
6
|
+
* @enum {string}
|
|
7
|
+
*/
|
|
8
|
+
export const DataType2DataViewWriters = {
|
|
9
|
+
[BinaryDataType.Uint8]: "setUint8",
|
|
10
|
+
[BinaryDataType.Uint16]: "setUint16",
|
|
11
|
+
[BinaryDataType.Uint32]: "setUint32",
|
|
12
|
+
[BinaryDataType.Uint64]: "setUint64",
|
|
13
|
+
|
|
14
|
+
[BinaryDataType.Int8]: "setInt8",
|
|
15
|
+
[BinaryDataType.Int16]: "setInt16",
|
|
16
|
+
[BinaryDataType.Int32]: "setInt32",
|
|
17
|
+
[BinaryDataType.Int64]: "setInt64",
|
|
18
|
+
|
|
19
|
+
[BinaryDataType.Float32]: "setFloat32",
|
|
20
|
+
[BinaryDataType.Float64]: "setFloat64"
|
|
21
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {BinaryDataType} from "../type/BinaryDataType";
|
|
2
|
+
|
|
3
|
+
interface IBinarySchema {
|
|
4
|
+
[k: string]: BinaryDataType
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export class DataViewStructAccessor<T extends IBinarySchema> {
|
|
9
|
+
|
|
10
|
+
constructor(type: T, little_endian?: boolean)
|
|
11
|
+
|
|
12
|
+
this: { [prop in keyof T]: number }
|
|
13
|
+
|
|
14
|
+
bind(view: DataView, offset: number): void
|
|
15
|
+
|
|
16
|
+
bind_by_index(view: DataView, index: number): void
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataViewStructAccessor.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/data_view/DataViewStructAccessor.js"],"names":[],"mappings":"AAOA;IAiBI;;;;OAIG;IACH,yCAFW,OAAO,EAiCjB;IApDD;;OAEG;IACH,OAFU,QAAQ,CAEZ;IAEN;;OAEG;IACH,SAFU,MAAM,CAEJ;IAEZ;;;OAGG;IACH,4BAFU,MAAM,CAEM;IAwCtB;;;;OAIG;IACH,gBAHW,QAAQ,eACR,MAAM,QAKhB;IAED;;;;OAIG;IACH,yBAHW,QAAQ,SACR,MAAM,QAKhB;CACJ"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { FunctionCompiler } from "../../function/FunctionCompiler.js";
|
|
3
|
+
import { BinaryDataType } from "../type/BinaryDataType.js";
|
|
4
|
+
import { DataTypeByteSizes } from "../type/DataTypeByteSizes.js";
|
|
5
|
+
import { DataType2DataViewReaders } from "./DataType2DataViewReaders.js";
|
|
6
|
+
import { DataType2DataViewWriters } from "./DataType2DataViewWriters.js";
|
|
7
|
+
|
|
8
|
+
export class DataViewStructAccessor {
|
|
9
|
+
/**
|
|
10
|
+
* @type {DataView}
|
|
11
|
+
*/
|
|
12
|
+
$data;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {number}
|
|
16
|
+
*/
|
|
17
|
+
$offset = 0;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @readonly
|
|
21
|
+
* @type {number}
|
|
22
|
+
*/
|
|
23
|
+
$record_byte_size = 0;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {Object<BinaryDataType>} schema
|
|
28
|
+
* @param {boolean} [little_endian]
|
|
29
|
+
*/
|
|
30
|
+
constructor(schema, little_endian = false) {
|
|
31
|
+
assert.defined(schema, 'schema');
|
|
32
|
+
assert.isBoolean(little_endian, 'little_endian');
|
|
33
|
+
|
|
34
|
+
const props = Object.keys(schema);
|
|
35
|
+
const property_count = props.length;
|
|
36
|
+
|
|
37
|
+
let offset = 0;
|
|
38
|
+
for (let i = 0; i < property_count; i++) {
|
|
39
|
+
const property = props[i];
|
|
40
|
+
const type = schema[property];
|
|
41
|
+
|
|
42
|
+
assert.enum(type, BinaryDataType, "type");
|
|
43
|
+
|
|
44
|
+
assert.arrayHasNo(["bind", "$data", "$offset", "this", "constructor"], property, `Illegal property name ${property}`);
|
|
45
|
+
|
|
46
|
+
//
|
|
47
|
+
Object.defineProperty(this, property, {
|
|
48
|
+
get: FunctionCompiler.INSTANCE.compile({
|
|
49
|
+
code: `return this.$data.${DataType2DataViewReaders[type]}(this.$offset + ${offset}, ${little_endian})`
|
|
50
|
+
}),
|
|
51
|
+
set: FunctionCompiler.INSTANCE.compile({
|
|
52
|
+
args: ["value"],
|
|
53
|
+
code: `this.$data.${DataType2DataViewWriters[type]}(this.$offset + ${offset}, value, ${little_endian})`
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
offset += DataTypeByteSizes[type];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.$record_byte_size = offset;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param {DataView} data_view
|
|
66
|
+
* @param {number} byte_offset
|
|
67
|
+
*/
|
|
68
|
+
bind(data_view, byte_offset) {
|
|
69
|
+
this.$data = data_view;
|
|
70
|
+
this.$offset = byte_offset;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param {DataView} data_view
|
|
76
|
+
* @param {number} index
|
|
77
|
+
*/
|
|
78
|
+
bind_by_index(data_view, index) {
|
|
79
|
+
this.$data = data_view;
|
|
80
|
+
this.$offset = index * this.$record_byte_size;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataViewStructAccessor.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/data_view/DataViewStructAccessor.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BinaryDataType } from "../type/BinaryDataType.js";
|
|
2
|
+
import { DataViewStructAccessor } from "./DataViewStructAccessor.js";
|
|
3
|
+
|
|
4
|
+
test("2 field schema", () => {
|
|
5
|
+
const accessor = new DataViewStructAccessor({
|
|
6
|
+
alice: BinaryDataType.Float32,
|
|
7
|
+
bob: BinaryDataType.Uint8
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const buffer = new ArrayBuffer(1024);
|
|
11
|
+
const dataView = new DataView(buffer);
|
|
12
|
+
|
|
13
|
+
accessor.bind(dataView, 1);
|
|
14
|
+
|
|
15
|
+
accessor.alice = -3.7;
|
|
16
|
+
accessor.bob = 7;
|
|
17
|
+
|
|
18
|
+
expect(dataView.getFloat32(1)).toBeCloseTo(-3.7);
|
|
19
|
+
expect(dataView.getUint8(5)).toBe(7);
|
|
20
|
+
});
|
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
export type DataType2DataViewReaders = string;
|
|
2
|
-
export namespace DataType2DataViewReaders {
|
|
3
|
-
let uint8: string;
|
|
4
|
-
let uint16: string;
|
|
5
|
-
let uint32: string;
|
|
6
|
-
let uint64: string;
|
|
7
|
-
let int8: string;
|
|
8
|
-
let int16: string;
|
|
9
|
-
let int32: string;
|
|
10
|
-
let int64: string;
|
|
11
|
-
let float32: string;
|
|
12
|
-
let float64: string;
|
|
13
|
-
}
|
|
14
|
-
export type DataType2DataViewWriters = string;
|
|
15
|
-
export namespace DataType2DataViewWriters {
|
|
16
|
-
let uint8_1: string;
|
|
17
|
-
export { uint8_1 as uint8 };
|
|
18
|
-
let uint16_1: string;
|
|
19
|
-
export { uint16_1 as uint16 };
|
|
20
|
-
let uint32_1: string;
|
|
21
|
-
export { uint32_1 as uint32 };
|
|
22
|
-
let uint64_1: string;
|
|
23
|
-
export { uint64_1 as uint64 };
|
|
24
|
-
let int8_1: string;
|
|
25
|
-
export { int8_1 as int8 };
|
|
26
|
-
let int16_1: string;
|
|
27
|
-
export { int16_1 as int16 };
|
|
28
|
-
let int32_1: string;
|
|
29
|
-
export { int32_1 as int32 };
|
|
30
|
-
let int64_1: string;
|
|
31
|
-
export { int64_1 as int64 };
|
|
32
|
-
let float32_1: string;
|
|
33
|
-
export { float32_1 as float32 };
|
|
34
|
-
let float64_1: string;
|
|
35
|
-
export { float64_1 as float64 };
|
|
36
|
-
}
|
|
37
1
|
/**
|
|
38
2
|
* This is a schema class for binary data tables of class {@link RowFirstTable}
|
|
39
3
|
* @class
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowFirstTableSpec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/RowFirstTableSpec.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RowFirstTableSpec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/RowFirstTableSpec.js"],"names":[],"mappings":"AA+HA;;;GAGG;AACH;IA6GI;;;;;OAKG;IACH,kBAJW,cAAc,EAAE,eAChB,UAAU,GACR,iBAAiB,CAgB7B;IAhID;;;;;OAKG;IACH,mBAJW,cAAc,EAAE,eAChB,UAAU,EAsEpB;IA9DG;;;OAGG;IACH,gBAFU,cAAc,EAAE,CAER;IAElB;;;OAGG;IACH,qBAFU,UAAU,CAEQ;IAE5B;;;OAGG;IACH,wBAFU,WAAW,CAEyB;IAc9C;;;OAGG;IACH,yBAFU,MAAM,CAEgB;IAEhC;;;OAGG;IACH,+BAFmB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAEA;IAEpD;;;OAGG;IACH,gCAFmB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAEC;IAIrD,mBAAsC;IACtC,mBAAsC;IAMtC;;;OAGG;IACH,8BAFU,OAAO,CAEc;IAGnC;;;OAGG;IACH,kBAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,QAFY,MAAM,CAQjB;IAED;;;;OAIG;IACH,cAHW,iBAAiB,GACf,OAAO,CAQnB;CAuBJ;+BA7P8B,qCAAqC;2BADzC,4BAA4B"}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* @enum {string}
|
|
4
4
|
*/
|
|
5
5
|
import { assert } from "../../assert.js";
|
|
6
|
+
import { DataType2DataViewReaders } from "../../binary/data_view/DataType2DataViewReaders.js";
|
|
7
|
+
import { DataType2DataViewWriters } from "../../binary/data_view/DataType2DataViewWriters.js";
|
|
6
8
|
import { EndianType } from "../../binary/EndianType.js";
|
|
7
9
|
import { BinaryDataType } from "../../binary/type/BinaryDataType.js";
|
|
8
10
|
import { DataTypeByteSizes } from "../../binary/type/DataTypeByteSizes.js";
|
|
@@ -12,46 +14,6 @@ import { computeStringHash } from "../../primitives/strings/computeStringHash.js
|
|
|
12
14
|
import { computeHashArray } from "../array/computeHashArray.js";
|
|
13
15
|
import { isArrayEqualStrict } from "../array/isArrayEqualStrict.js";
|
|
14
16
|
|
|
15
|
-
/**
|
|
16
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
17
|
-
* @readonly
|
|
18
|
-
* @enum {string}
|
|
19
|
-
*/
|
|
20
|
-
export const DataType2DataViewReaders = {
|
|
21
|
-
[BinaryDataType.Uint8]: "getUint8",
|
|
22
|
-
[BinaryDataType.Uint16]: "getUint16",
|
|
23
|
-
[BinaryDataType.Uint32]: "getUint32",
|
|
24
|
-
[BinaryDataType.Uint64]: "getUint64",
|
|
25
|
-
|
|
26
|
-
[BinaryDataType.Int8]: "getInt8",
|
|
27
|
-
[BinaryDataType.Int16]: "getInt16",
|
|
28
|
-
[BinaryDataType.Int32]: "getInt32",
|
|
29
|
-
[BinaryDataType.Int64]: "getInt64",
|
|
30
|
-
|
|
31
|
-
[BinaryDataType.Float32]: "getFloat32",
|
|
32
|
-
[BinaryDataType.Float64]: "getFloat64"
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
|
37
|
-
* @readonly
|
|
38
|
-
* @enum {string}
|
|
39
|
-
*/
|
|
40
|
-
export const DataType2DataViewWriters = {
|
|
41
|
-
[BinaryDataType.Uint8]: "setUint8",
|
|
42
|
-
[BinaryDataType.Uint16]: "setUint16",
|
|
43
|
-
[BinaryDataType.Uint32]: "setUint32",
|
|
44
|
-
[BinaryDataType.Uint64]: "setUint64",
|
|
45
|
-
|
|
46
|
-
[BinaryDataType.Int8]: "setInt8",
|
|
47
|
-
[BinaryDataType.Int16]: "setInt16",
|
|
48
|
-
[BinaryDataType.Int32]: "setInt32",
|
|
49
|
-
[BinaryDataType.Int64]: "setInt64",
|
|
50
|
-
|
|
51
|
-
[BinaryDataType.Float32]: "setFloat32",
|
|
52
|
-
[BinaryDataType.Float64]: "setFloat64"
|
|
53
|
-
};
|
|
54
|
-
|
|
55
17
|
/**
|
|
56
18
|
*
|
|
57
19
|
* @param {BinaryDataType[]} types
|
|
@@ -134,7 +96,7 @@ function genRowWriter(types, endianType = EndianType.BigEndian) {
|
|
|
134
96
|
* @param {EndianType} [endianType]
|
|
135
97
|
* @returns {function(data_view:DataView, byte_offset:number, value:number):void}
|
|
136
98
|
*/
|
|
137
|
-
function
|
|
99
|
+
function compileDataViewValueWriter(type, offset, endianType = EndianType.BigEndian) {
|
|
138
100
|
const writeMethod = DataType2DataViewWriters[type];
|
|
139
101
|
|
|
140
102
|
const littleEndianFlag = endianType === EndianType.BigEndian ? 'false' : 'true';
|
|
@@ -152,7 +114,7 @@ function genCellWriter(type, offset, endianType = EndianType.BigEndian) {
|
|
|
152
114
|
* @param {EndianType} [endianType]
|
|
153
115
|
* @returns {function(data_view:DataView, byte_offset:number):number}
|
|
154
116
|
*/
|
|
155
|
-
function
|
|
117
|
+
function compileDataViewValueReader(type, offset, endianType = EndianType.BigEndian) {
|
|
156
118
|
const readMethod = DataType2DataViewReaders[type];
|
|
157
119
|
|
|
158
120
|
const littleEndianFlag = endianType === EndianType.BigEndian ? 'false' : 'true';
|
|
@@ -233,8 +195,8 @@ export class RowFirstTableSpec {
|
|
|
233
195
|
this.cellReaders = new Array(numTypes);
|
|
234
196
|
|
|
235
197
|
for (let i = 0; i < numTypes; i++) {
|
|
236
|
-
this.cellReaders[i] =
|
|
237
|
-
this.cellWriters[i] =
|
|
198
|
+
this.cellReaders[i] = compileDataViewValueReader(types[i], this.columnOffsets[i], endianType);
|
|
199
|
+
this.cellWriters[i] = compileDataViewValueWriter(types[i], this.columnOffsets[i], endianType);
|
|
238
200
|
}
|
|
239
201
|
/**
|
|
240
202
|
* @readonly
|