@woosh/meep-engine 2.113.6 → 2.113.7

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.
Files changed (66) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +168 -88
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +168 -88
  5. package/package.json +1 -1
  6. package/src/core/binary/Base64.d.ts.map +1 -1
  7. package/src/core/binary/Base64.js +73 -31
  8. package/src/core/binary/BitSet.d.ts +2 -2
  9. package/src/core/binary/BitSet.d.ts.map +1 -1
  10. package/src/core/binary/BitSet.js +8 -8
  11. package/src/core/binary/align_32.d.ts +2 -2
  12. package/src/core/binary/align_32.d.ts.map +1 -1
  13. package/src/core/binary/align_32.js +7 -3
  14. package/src/core/binary/dec2hex.d.ts +2 -2
  15. package/src/core/binary/dec2hex.d.ts.map +1 -1
  16. package/src/core/binary/dec2hex.js +7 -3
  17. package/src/core/binary/downloadAsFile.d.ts +7 -1
  18. package/src/core/binary/downloadAsFile.d.ts.map +1 -1
  19. package/src/core/binary/downloadAsFile.js +10 -7
  20. package/src/core/binary/downloadUrlAsFile.d.ts +1 -1
  21. package/src/core/binary/downloadUrlAsFile.d.ts.map +1 -1
  22. package/src/core/binary/downloadUrlAsFile.js +6 -1
  23. package/src/core/binary/int32_to_binary_string.d.ts +1 -2
  24. package/src/core/binary/int32_to_binary_string.d.ts.map +1 -1
  25. package/src/core/binary/int32_to_binary_string.js +4 -2
  26. package/src/core/binary/url_to_data_url.d.ts +2 -1
  27. package/src/core/binary/url_to_data_url.d.ts.map +1 -1
  28. package/src/core/binary/url_to_data_url.js +2 -1
  29. package/src/core/codegen/LineBuilder.d.ts +4 -3
  30. package/src/core/codegen/LineBuilder.d.ts.map +1 -1
  31. package/src/core/codegen/LineBuilder.js +35 -6
  32. package/src/core/collection/array/arrayIndexByEquality.d.ts +1 -1
  33. package/src/core/collection/array/arrayIndexByEquality.js +1 -1
  34. package/src/core/collection/array/array_push_if_unique.d.ts.map +1 -1
  35. package/src/core/collection/array/array_push_if_unique.js +4 -0
  36. package/src/core/collection/list/List.d.ts.map +1 -1
  37. package/src/core/collection/list/List.js +7 -2
  38. package/src/core/collection/table/RowFirstTable.d.ts +12 -12
  39. package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
  40. package/src/core/collection/table/RowFirstTable.js +39 -36
  41. package/src/core/collection/table/RowFirstTableSpec.d.ts +1 -0
  42. package/src/core/collection/table/RowFirstTableSpec.d.ts.map +1 -1
  43. package/src/core/collection/table/RowFirstTableSpec.js +1 -0
  44. package/src/core/collection/table/serializeRowFirstTable.d.ts.map +1 -1
  45. package/src/core/collection/table/serializeRowFirstTable.js +6 -4
  46. package/src/core/math/isPowerOfTwo.d.ts +1 -1
  47. package/src/core/math/isPowerOfTwo.d.ts.map +1 -1
  48. package/src/core/math/isPowerOfTwo.js +2 -4
  49. package/src/core/model/LinearValue.d.ts +5 -1
  50. package/src/core/model/LinearValue.d.ts.map +1 -1
  51. package/src/core/model/LinearValue.js +16 -5
  52. package/src/core/model/ModuleRegistry.d.ts.map +1 -1
  53. package/src/core/model/ModuleRegistry.js +33 -29
  54. package/src/core/model/ResourceAccessSpecification.d.ts.map +1 -1
  55. package/src/core/model/ResourceAccessSpecification.js +7 -1
  56. package/src/core/model/node-graph/Connection.d.ts.map +1 -1
  57. package/src/core/model/node-graph/Connection.js +13 -7
  58. package/src/core/model/node-graph/NodeGraph.d.ts +2 -1
  59. package/src/core/model/node-graph/NodeGraph.d.ts.map +1 -1
  60. package/src/core/model/node-graph/NodeGraph.js +1 -1
  61. package/src/core/model/node-graph/node/NodeDescription.d.ts.map +1 -1
  62. package/src/core/model/node-graph/node/NodeDescription.js +8 -0
  63. package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
  64. package/src/core/model/node-graph/node/NodeInstance.js +4 -0
  65. package/src/core/model/node-graph/node/NodeInstancePortReference.d.ts.map +1 -1
  66. package/src/core/model/node-graph/node/NodeInstancePortReference.js +6 -10
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Adapted from https://github.com/beatgammit/base64-js
3
3
  * @author Jameson Little
4
+ * @author Alex Goldring
4
5
  */
5
6
 
6
7
  /**
@@ -8,12 +9,12 @@
8
9
  * @type {string[]}
9
10
  */
10
11
  const lookup = [];
12
+
11
13
  /**
12
14
  *
13
15
  * @type {number[]}
14
16
  */
15
17
  const revLookup = [];
16
- const Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
17
18
 
18
19
  const code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
19
20
 
@@ -33,7 +34,7 @@ revLookup['_'.charCodeAt(0)] = 63;
33
34
  * @return {number[]}
34
35
  */
35
36
  function getLens(b64) {
36
- var len = b64.length;
37
+ const len = b64.length;
37
38
 
38
39
  if (len % 4 > 0) {
39
40
  throw new Error('Invalid string. Length must be a multiple of 4');
@@ -41,63 +42,88 @@ function getLens(b64) {
41
42
 
42
43
  // Trim off extra bytes after placeholder bytes are found
43
44
  // See: https://github.com/beatgammit/base64-js/issues/42
44
- var validLen = b64.indexOf('=');
45
+ let validLen = b64.indexOf('=');
46
+
45
47
  if (validLen === -1) {
46
48
  validLen = len;
47
49
  }
48
50
 
49
- var placeHoldersLen = validLen === len
51
+ const placeHoldersLen = validLen === len
50
52
  ? 0
51
53
  : 4 - (validLen % 4);
52
54
 
53
55
  return [validLen, placeHoldersLen];
54
56
  }
55
57
 
56
- // base64 is 4/3 + up to two characters of the original data
57
-
58
- function _byteLength(b64, validLen, placeHoldersLen) {
58
+ /**
59
+ * base64 is 4/3 + up to two characters of the original data
60
+ * @param {number} validLen
61
+ * @param {number} placeHoldersLen
62
+ */
63
+ function _byteLength(validLen, placeHoldersLen) {
59
64
  return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen;
60
65
  }
61
66
 
67
+ /**
68
+ *
69
+ * @param {string} b64
70
+ * @return {Uint8Array}
71
+ */
62
72
  function toByteArray(b64) {
63
- var tmp;
64
- var lens = getLens(b64);
65
- var validLen = lens[0];
66
- var placeHoldersLen = lens[1];
73
+ let tmp;
74
+ const lens = getLens(b64);
75
+ const validLen = lens[0];
76
+ const placeHoldersLen = lens[1];
67
77
 
68
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
78
+ const arr = new Uint8Array(_byteLength(validLen, placeHoldersLen));
69
79
 
70
- var curByte = 0;
80
+ let curByte = 0;
71
81
 
72
82
  // if there are placeholders, only get up to the last complete 4 chars
73
- var len = placeHoldersLen > 0
83
+ const len = placeHoldersLen > 0
74
84
  ? validLen - 4
75
85
  : validLen;
76
86
 
77
- var i;
78
- for (i = 0; i < len; i += 4) {
87
+ let i = 0;
88
+
89
+ for (; i < len; i += 4) {
90
+ const char_0 = b64.charCodeAt(i);
91
+ const char_1 = b64.charCodeAt(i + 1);
92
+ const char_2 = b64.charCodeAt(i + 2);
93
+ const char_3 = b64.charCodeAt(i + 3);
94
+
79
95
  tmp =
80
- (revLookup[b64.charCodeAt(i)] << 18) |
81
- (revLookup[b64.charCodeAt(i + 1)] << 12) |
82
- (revLookup[b64.charCodeAt(i + 2)] << 6) |
83
- revLookup[b64.charCodeAt(i + 3)];
96
+ (revLookup[char_0] << 18) |
97
+ (revLookup[char_1] << 12) |
98
+ (revLookup[char_2] << 6) |
99
+ revLookup[char_3];
100
+
84
101
  arr[curByte++] = (tmp >> 16) & 0xFF;
85
102
  arr[curByte++] = (tmp >> 8) & 0xFF;
86
103
  arr[curByte++] = tmp & 0xFF;
87
104
  }
88
105
 
89
106
  if (placeHoldersLen === 2) {
107
+ const char_0 = b64.charCodeAt(i);
108
+ const char_1 = b64.charCodeAt(i + 1);
109
+
90
110
  tmp =
91
- (revLookup[b64.charCodeAt(i)] << 2) |
92
- (revLookup[b64.charCodeAt(i + 1)] >> 4);
111
+ (revLookup[char_0] << 2) |
112
+ (revLookup[char_1] >> 4);
113
+
93
114
  arr[curByte++] = tmp & 0xFF;
94
115
  }
95
116
 
96
117
  if (placeHoldersLen === 1) {
118
+ const char_0 = b64.charCodeAt(i);
119
+ const char_1 = b64.charCodeAt(i + 1);
120
+ const char_2 = b64.charCodeAt(i + 2);
121
+
97
122
  tmp =
98
- (revLookup[b64.charCodeAt(i)] << 10) |
99
- (revLookup[b64.charCodeAt(i + 1)] << 4) |
100
- (revLookup[b64.charCodeAt(i + 2)] >> 2);
123
+ (revLookup[char_0] << 10) |
124
+ (revLookup[char_1] << 4) |
125
+ (revLookup[char_2] >> 2);
126
+
101
127
  arr[curByte++] = (tmp >> 8) & 0xFF;
102
128
  arr[curByte++] = tmp & 0xFF;
103
129
  }
@@ -105,6 +131,11 @@ function toByteArray(b64) {
105
131
  return arr;
106
132
  }
107
133
 
134
+ /**
135
+ *
136
+ * @param {number} num
137
+ * @return {string}
138
+ */
108
139
  function tripletToBase64(num) {
109
140
  return lookup[num >> 18 & 0x3F]
110
141
  + lookup[num >> 12 & 0x3F]
@@ -135,24 +166,29 @@ function encodeChunk(uint8, start, end) {
135
166
  return output.join('');
136
167
  }
137
168
 
169
+ /**
170
+ * must be multiple of 3
171
+ */
172
+ const MAX_CHUNK_LENGTH = 16383;
173
+
138
174
  /**
139
175
  *
140
176
  * @param {Uint8Array} uint8
141
177
  * @return {string}
142
178
  */
143
179
  function fromByteArray(uint8) {
144
- let tmp;
145
180
 
146
181
  const len = uint8.length;
182
+
147
183
  const extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
184
+
148
185
  const parts = [];
149
- const maxChunkLength = 16383; // must be multiple of 3
150
186
 
151
187
  // go through the array every three bytes, we'll deal with trailing stuff later
152
188
  const len2 = len - extraBytes;
153
189
 
154
- for (let i = 0; i < len2; i += maxChunkLength) {
155
- const end = (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength);
190
+ for (let i = 0; i < len2; i += MAX_CHUNK_LENGTH) {
191
+ const end = (i + MAX_CHUNK_LENGTH) > len2 ? len2 : (i + MAX_CHUNK_LENGTH);
156
192
 
157
193
  const chunk = encodeChunk(uint8, i, end);
158
194
 
@@ -161,20 +197,26 @@ function fromByteArray(uint8) {
161
197
 
162
198
  // pad the end with zeros, but make sure to not forget the extra bytes
163
199
  if (extraBytes === 1) {
164
- tmp = uint8[len - 1];
200
+
201
+ const tmp = uint8[len - 1];
202
+
165
203
  parts.push(
166
204
  lookup[tmp >> 2] +
167
205
  lookup[(tmp << 4) & 0x3F] +
168
206
  '=='
169
207
  );
208
+
170
209
  } else if (extraBytes === 2) {
171
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
210
+
211
+ const tmp = (uint8[len - 2] << 8) + uint8[len - 1];
212
+
172
213
  parts.push(
173
214
  lookup[tmp >> 10] +
174
215
  lookup[(tmp >> 4) & 0x3F] +
175
216
  lookup[(tmp << 2) & 0x3F] +
176
217
  '='
177
218
  );
219
+
178
220
  }
179
221
 
180
222
  return parts.join('');
@@ -87,10 +87,10 @@ export class BitSet {
87
87
  nextClearBit(fromIndex: int): number;
88
88
  /**
89
89
  *
90
- * @param {int} bitIndex
90
+ * @param {int} bit_index
91
91
  * @param {boolean} value
92
92
  */
93
- set(bitIndex: int, value: boolean): void;
93
+ set(bit_index: int, value: boolean): void;
94
94
  /**
95
95
  * Sets the bit specified by the index to false.
96
96
  * @param {int} bitIndex
@@ -1 +1 @@
1
- {"version":3,"file":"BitSet.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/BitSet.js"],"names":[],"mappings":"AAgCA;IAyiBI;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CASlB;IApjBD;;;;OAIG;IACH,+BAFW,MAAM,EA8BhB;IAzBG;;;;OAIG;IACH,iBAAiB;IAEjB;;;;OAIG;IACH,mBAA4C;IAE5C;;;;OAIG;IACH,sBAA0D;IAE1D;;OAEG;IACH,gBAFU,MAAM,CAEmB;IAGvC,sBAEC;IAED;;;OAGG;IACH,mBAFW,MAAM,QAOhB;IAED;;;OAGG;IACH,uBAFW,MAAM,QAUhB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAsBC;IAED,uBAMC;IAED;;;;OAIG;IACH,oBAyBC;IAED;;;;OAIG;IACH,oCAqCC;IAED;;;;OAIG;IACH,4BAFa,MAAM,CAuDlB;IAED;;;;OAIG;IACH,8BAFa,MAAM,CAkDlB;IAED;;;;OAIG;IACH,0BAFW,OAAO,QAmCjB;IAED;;;OAGG;IACH,2BAEC;IAED;;;;OAIG;IACH,qBAHW,MAAM,YACN,MAAM,QAWhB;IAED;;;;OAIG;IACH,uBAHW,MAAM,YACN,MAAM,QAShB;IAED;;;OAGG;IACH,SAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,oBAFa,OAAO,CAkBnB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAUnB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,OAAO,CAUnB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAShB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAShB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAQhB;IAED;;OAEG;IACH,cAgBC;IAED;;;OAGG;IACH,YAFW,MAAM,QAoChB;CAeJ"}
1
+ {"version":3,"file":"BitSet.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/BitSet.js"],"names":[],"mappings":"AAgCA;IAyiBI;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CASlB;IApjBD;;;;OAIG;IACH,+BAFW,MAAM,EA8BhB;IAzBG;;;;OAIG;IACH,iBAAiB;IAEjB;;;;OAIG;IACH,mBAA4C;IAE5C;;;;OAIG;IACH,sBAA0D;IAE1D;;OAEG;IACH,gBAFU,MAAM,CAEmB;IAGvC,sBAEC;IAED;;;OAGG;IACH,mBAFW,MAAM,QAOhB;IAED;;;OAGG;IACH,uBAFW,MAAM,QAUhB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAsBC;IAED,uBAMC;IAED;;;;OAIG;IACH,oBAyBC;IAED;;;;OAIG;IACH,oCAqCC;IAED;;;;OAIG;IACH,4BAFa,MAAM,CAuDlB;IAED;;;;OAIG;IACH,8BAFa,MAAM,CAkDlB;IAED;;;;OAIG;IACH,2BAFW,OAAO,QAmCjB;IAED;;;OAGG;IACH,2BAEC;IAED;;;;OAIG;IACH,qBAHW,MAAM,YACN,MAAM,QAWhB;IAED;;;;OAIG;IACH,uBAHW,MAAM,YACN,MAAM,QAShB;IAED;;;OAGG;IACH,SAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,oBAFa,OAAO,CAkBnB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAUnB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,OAAO,CAUnB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAShB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAShB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,eACN,MAAM,aACN,MAAM,QAQhB;IAED;;OAEG;IACH,cAgBC;IAED;;;OAGG;IACH,YAFW,MAAM,QAoChB;CAeJ"}
@@ -341,22 +341,22 @@ export class BitSet {
341
341
 
342
342
  /**
343
343
  *
344
- * @param {int} bitIndex
344
+ * @param {int} bit_index
345
345
  * @param {boolean} value
346
346
  */
347
- set(bitIndex, value) {
348
- //assert.ok(typeof bitIndex, 'number', `bitIndex must be a number, instead was '${typeof bitIndex}'`);
349
- //assert.ok(typeof value, 'boolean', `value must be a boolean, instead was '${typeof bitIndex}'`);
347
+ set(bit_index, value) {
348
+ assert.isNonNegativeInteger(bit_index, 'bit_index');
349
+ assert.isBoolean(value, 'value');
350
350
 
351
- const word_offset = bitIndex >> 5;
352
- const bit_offset = bitIndex & 31;
351
+ const word_offset = bit_index >> 5;
352
+ const bit_offset = bit_index & 31;
353
353
 
354
354
  //const oldLength = this.__length;
355
355
 
356
356
  const word_mask = 1 << bit_offset;
357
357
 
358
358
  if (value) {
359
- const bitIndexInc = bitIndex + 1;
359
+ const bitIndexInc = bit_index + 1;
360
360
 
361
361
  if (bitIndexInc > this.__length) {
362
362
  // ensure capacity
@@ -367,7 +367,7 @@ export class BitSet {
367
367
  this.__data_uint32[word_offset] |= word_mask;
368
368
 
369
369
 
370
- } else if (bitIndex < this.__length) {
370
+ } else if (bit_index < this.__length) {
371
371
  //clear
372
372
  this.__data_uint32[word_offset] &= ~word_mask;
373
373
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Align to the nearest number divisible by 32, rounding up
3
- * @param {number} n
3
+ * @param {number} x must be a non-negative integer
4
4
  * @returns {number}
5
5
  */
6
- export function align_32(n: number): number;
6
+ export function align_32(x: number): number;
7
7
  //# sourceMappingURL=align_32.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"align_32.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/align_32.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,4BAHW,MAAM,GACJ,MAAM,CAIlB"}
1
+ {"version":3,"file":"align_32.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/align_32.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,4BAHW,MAAM,GACJ,MAAM,CAMlB"}
@@ -1,8 +1,12 @@
1
+ import { assert } from "../assert.js";
2
+
1
3
  /**
2
4
  * Align to the nearest number divisible by 32, rounding up
3
- * @param {number} n
5
+ * @param {number} x must be a non-negative integer
4
6
  * @returns {number}
5
7
  */
6
- export function align_32(n) {
7
- return ((n + 31) >>> 5) << 5
8
+ export function align_32(x) {
9
+ assert.isNonNegativeInteger(x, 'n');
10
+
11
+ return ((x + 31) >>> 5) << 5
8
12
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Convert a decimal value to hex
3
- * @param {number} c generally expects b byte value, 0-255
3
+ * @param {number} x generally expects b byte value, 0-255
4
4
  * @returns {string} zero-padded value, for example instead of "0", will return "00" and instead of "F" will return "0F"
5
5
  */
6
- export function dec2hex(c: number): string;
6
+ export function dec2hex(x: number): string;
7
7
  //# sourceMappingURL=dec2hex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dec2hex.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/dec2hex.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,2BAHW,MAAM,GACJ,MAAM,CAKlB"}
1
+ {"version":3,"file":"dec2hex.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/dec2hex.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,2BAHW,MAAM,GACJ,MAAM,CAOlB"}
@@ -1,9 +1,13 @@
1
+ import { assert } from "../assert.js";
2
+
1
3
  /**
2
4
  * Convert a decimal value to hex
3
- * @param {number} c generally expects b byte value, 0-255
5
+ * @param {number} x generally expects b byte value, 0-255
4
6
  * @returns {string} zero-padded value, for example instead of "0", will return "00" and instead of "F" will return "0F"
5
7
  */
6
- export function dec2hex(c) {
7
- const hex = Math.round(c).toString(16);
8
+ export function dec2hex(x) {
9
+ assert.greaterThanOrEqual(x, 0);
10
+
11
+ const hex = Math.round(x).toString(16);
8
12
  return hex.length === 1 ? "0" + hex : hex;
9
13
  }
@@ -1,2 +1,8 @@
1
- export function downloadAsFile(data: any, filename: any, type?: string): void;
1
+ /**
2
+ *
3
+ * @param {ArrayBuffer|Uint8Array|Array|Blob|string} data
4
+ * @param {string} [filename]
5
+ * @param {string} [type]
6
+ */
7
+ export function downloadAsFile(data: ArrayBuffer | Uint8Array | any[] | Blob | string, filename?: string, type?: string): void;
2
8
  //# sourceMappingURL=downloadAsFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"downloadAsFile.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/downloadAsFile.js"],"names":[],"mappings":"AAEA,8EAyBC"}
1
+ {"version":3,"file":"downloadAsFile.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/downloadAsFile.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,qCAJW,WAAW,GAAC,UAAU,WAAO,IAAI,GAAC,MAAM,aACxC,MAAM,SACN,MAAM,QAwBhB"}
@@ -1,5 +1,11 @@
1
- import {downloadUrlAsFile} from "./downloadUrlAsFile.js";
1
+ import { downloadUrlAsFile } from "./downloadUrlAsFile.js";
2
2
 
3
+ /**
4
+ *
5
+ * @param {ArrayBuffer|Uint8Array|Array|Blob|string} data
6
+ * @param {string} [filename]
7
+ * @param {string} [type]
8
+ */
3
9
  export function downloadAsFile(data, filename, type = 'text/json') {
4
10
 
5
11
  let blobContent;
@@ -19,10 +25,7 @@ export function downloadAsFile(data, filename, type = 'text/json') {
19
25
  blobContent = [data]
20
26
  }
21
27
 
22
- const blob = new Blob(blobContent, {type});
23
- if (window.navigator.msSaveOrOpenBlob) {
24
- window.navigator.msSaveBlob(blob, filename);
25
- } else {
26
- downloadUrlAsFile(window.URL.createObjectURL(blob), filename);
27
- }
28
+ const blob = new Blob(blobContent, { type });
29
+
30
+ downloadUrlAsFile(window.URL.createObjectURL(blob), filename);
28
31
  }
@@ -3,5 +3,5 @@
3
3
  * @param {string} url
4
4
  * @param {string} filename
5
5
  */
6
- export function downloadUrlAsFile(url: string, filename: string): void;
6
+ export function downloadUrlAsFile(url: string, filename?: string): void;
7
7
  //# sourceMappingURL=downloadUrlAsFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"downloadUrlAsFile.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/downloadUrlAsFile.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,uCAHW,MAAM,YACN,MAAM,QAWhB"}
1
+ {"version":3,"file":"downloadUrlAsFile.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/downloadUrlAsFile.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,uCAHW,MAAM,aACN,MAAM,QAchB"}
@@ -1,9 +1,14 @@
1
+ import { assert } from "../assert.js";
2
+
1
3
  /**
2
4
  *
3
5
  * @param {string} url
4
6
  * @param {string} filename
5
7
  */
6
- export function downloadUrlAsFile(url, filename) {
8
+ export function downloadUrlAsFile(url, filename = "file") {
9
+ assert.isString(url,'url');
10
+ assert.isString(filename,'filename');
11
+
7
12
  const elem = document.createElement('a');
8
13
  elem.href = url;
9
14
  elem.download = filename;
@@ -1,10 +1,9 @@
1
1
  /**
2
2
  * Converts an integer to easily readable binary string representation
3
- * @see https://stackoverflow.com/questions/9939760/how-do-i-convert-an-integer-to-binary-in-javascript
4
3
  * @example 1024 -> "00000000 00000000 00000100 00000000"
5
4
  * @example -1 -> "11111111 11111111 11111111 11111111"
6
5
  * @param {number} input_value
7
- * @param {string} [byte_separator] insert this string between each group of 8 bits
6
+ * @param {string} [byte_separator] insert this string between each group of 8 bits, defaults to a space
8
7
  * @returns {string}
9
8
  */
10
9
  export function int32_to_binary_string(input_value: number, byte_separator?: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"int32_to_binary_string.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/int32_to_binary_string.js"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,oDAJW,MAAM,mBACN,MAAM,GACJ,MAAM,CA4BlB"}
1
+ {"version":3,"file":"int32_to_binary_string.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/int32_to_binary_string.js"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AACH,oDAJW,MAAM,mBACN,MAAM,GACJ,MAAM,CA+BlB"}
@@ -14,14 +14,16 @@ const MIN_VALUE = -1 * (2 ** 31);
14
14
 
15
15
  /**
16
16
  * Converts an integer to easily readable binary string representation
17
- * @see https://stackoverflow.com/questions/9939760/how-do-i-convert-an-integer-to-binary-in-javascript
18
17
  * @example 1024 -> "00000000 00000000 00000100 00000000"
19
18
  * @example -1 -> "11111111 11111111 11111111 11111111"
20
19
  * @param {number} input_value
21
- * @param {string} [byte_separator] insert this string between each group of 8 bits
20
+ * @param {string} [byte_separator] insert this string between each group of 8 bits, defaults to a space
22
21
  * @returns {string}
23
22
  */
24
23
  export function int32_to_binary_string(input_value, byte_separator = " ") {
24
+
25
+ // @see https://stackoverflow.com/questions/9939760/how-do-i-convert-an-integer-to-binary-in-javascript
26
+
25
27
  // nMask must be between -2147483648 and 2147483647
26
28
  if (input_value > MAX_VALUE) {
27
29
  throw "number too large. number shouldn't be > 2**31-1";//added
@@ -1,5 +1,6 @@
1
1
  /**
2
- *
2
+ * Resolve URL to content and create a data URL from the content
3
+ * @example 'cat.png' -> 'data:image/png;base64,....'
3
4
  * @param {string} url
4
5
  * @returns {string}
5
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"url_to_data_url.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/url_to_data_url.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qCAHW,MAAM,GACJ,MAAM,CAwBlB"}
1
+ {"version":3,"file":"url_to_data_url.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/url_to_data_url.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qCAHW,MAAM,GACJ,MAAM,CAwBlB"}
@@ -1,5 +1,6 @@
1
1
  /**
2
- *
2
+ * Resolve URL to content and create a data URL from the content
3
+ * @example 'cat.png' -> 'data:image/png;base64,....'
3
4
  * @param {string} url
4
5
  * @returns {string}
5
6
  */
@@ -4,13 +4,13 @@ export default LineBuilder;
4
4
  */
5
5
  declare class LineBuilder {
6
6
  /**
7
- *
8
7
  * @param {string} text
8
+ * @param {string} [line_separator] defaults to new-line character
9
9
  * @returns {LineBuilder}
10
10
  */
11
- static fromText(text: string): LineBuilder;
11
+ static fromText(text: string, line_separator?: string): LineBuilder;
12
12
  /**
13
- *
13
+ * TODO replace with indent string, that is tab, space or any combination or something else entirely
14
14
  * @type {number}
15
15
  */
16
16
  indentSpaces: number;
@@ -52,6 +52,7 @@ declare class LineBuilder {
52
52
  * @returns {string}
53
53
  */
54
54
  build(): string;
55
+ toString(): string;
55
56
  #private;
56
57
  }
57
58
  //# sourceMappingURL=LineBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/codegen/LineBuilder.js"],"names":[],"mappings":";AAeA;;GAEG;AACH;IAoII;;;;OAIG;IACH,sBAHW,MAAM,GACJ,WAAW,CAoBvB;IA7ID;;;OAGG;IACH,cAFU,MAAM,CAEqB;IAErC;;;OAGG;IACH,oBAEC;IAED;;;;OAIG;IACH,wBAFW,MAAM,GADL,OAAO,CAiBlB;IAED;;;OAGG;IACH,UAFa,WAAW,CAKvB;IAED;;;OAGG;IACH,UAFa,WAAW,CAKvB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,WAAW,CASvB;IAED;;;OAGG;IACH,gBAFW,WAAW,QAgBrB;IAED,cAGC;IAED;;;OAGG;IACH,SAFa,MAAM,CAsBlB;;CA0BJ"}
1
+ {"version":3,"file":"LineBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/codegen/LineBuilder.js"],"names":[],"mappings":";AA+BA;;GAEG;AACH;IA0II;;;;OAIG;IACH,sBAJW,MAAM,mBACN,MAAM,GACJ,WAAW,CAuBvB;IAtJD;;;OAGG;IACH,cAFU,MAAM,CAEqB;IAErC;;;OAGG;IACH,oBAEC;IAED;;;;OAIG;IACH,wBAFW,MAAM,GADL,OAAO,CAoBlB;IAED;;;OAGG;IACH,UAFa,WAAW,CAKvB;IAED;;;OAGG;IACH,UAFa,WAAW,CAOvB;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,WAAW,CASvB;IAED;;;OAGG;IACH,gBAFW,WAAW,QAiBrB;IAED,cAGC;IAED;;;OAGG;IACH,SAFa,MAAM,CAsBlB;IA8BD,mBAEC;;CACJ"}
@@ -1,14 +1,30 @@
1
+ import { assert } from "../assert.js";
2
+
1
3
  class Line {
2
4
  /**
3
5
  *
4
6
  * @param {string} text
5
7
  * @param {number} indent
6
- * @constructor
7
8
  */
8
9
  constructor(text, indent) {
10
+ assert.isString(text, 'text');
11
+ assert.isNonNegativeInteger(indent, 'index');
12
+
13
+ /**
14
+ *
15
+ * @type {string}
16
+ */
9
17
  this.text = text;
18
+ /**
19
+ *
20
+ * @type {number}
21
+ */
10
22
  this.indentation = indent;
11
23
  }
24
+
25
+ toString() {
26
+ return `Line{ indentation=${this.indentation}, text="${this.text}" }`
27
+ }
12
28
  }
13
29
 
14
30
  const DEFAULT_INDENT_SPACES = 4;
@@ -25,13 +41,13 @@ class LineBuilder {
25
41
  #lines = [];
26
42
 
27
43
  /**
28
- *
44
+ * Current indent level
29
45
  * @type {number}
30
46
  */
31
47
  #indentation = 0;
32
48
 
33
49
  /**
34
- *
50
+ * TODO replace with indent string, that is tab, space or any combination or something else entirely
35
51
  * @type {number}
36
52
  */
37
53
  indentSpaces = DEFAULT_INDENT_SPACES;
@@ -50,8 +66,11 @@ class LineBuilder {
50
66
  * @param {string} term
51
67
  */
52
68
  containsSubstring(term) {
69
+ assert.isString(term, 'term');
70
+
53
71
  const lines = this.#lines;
54
72
  const n = lines.length;
73
+
55
74
  for (let i = 0; i < n; i++) {
56
75
  const line = lines[i];
57
76
 
@@ -79,6 +98,8 @@ class LineBuilder {
79
98
  * @returns {LineBuilder}
80
99
  */
81
100
  dedent() {
101
+ assert.greaterThan(this.#indentation, 0, 'indentation is already at 0');
102
+
82
103
  this.#indentation--;
83
104
  return this;
84
105
  }
@@ -102,6 +123,7 @@ class LineBuilder {
102
123
  * @param {LineBuilder} lines
103
124
  */
104
125
  addLines(lines) {
126
+ assert.defined(lines, 'lines');
105
127
 
106
128
  const other_lines = lines.#lines;
107
129
 
@@ -149,14 +171,17 @@ class LineBuilder {
149
171
  }
150
172
 
151
173
  /**
152
- *
153
174
  * @param {string} text
175
+ * @param {string} [line_separator] defaults to new-line character
154
176
  * @returns {LineBuilder}
155
177
  */
156
- static fromText(text) {
178
+ static fromText(text, line_separator = '\n') {
179
+ assert.isString(text, 'text');
180
+ assert.isString(line_separator, 'line_separator');
181
+
157
182
  const r = new LineBuilder();
158
183
 
159
- const lines = text.split('\n');
184
+ const lines = text.split(line_separator);
160
185
 
161
186
  const n = lines.length;
162
187
 
@@ -172,6 +197,10 @@ class LineBuilder {
172
197
 
173
198
  return r;
174
199
  }
200
+
201
+ toString() {
202
+ return this.build();
203
+ }
175
204
  }
176
205
 
177
206
  export default LineBuilder;
@@ -4,7 +4,7 @@
4
4
  * @param {T[]} array
5
5
  * @param {T} element
6
6
  * @param {function(a:T,b:T):boolean} equals
7
- * @returns {number}
7
+ * @returns {number} index of first match or -1 if no matches found
8
8
  */
9
9
  export function arrayIndexByEquality<T>(array: T[], element: T, equals: any): number;
10
10
  //# sourceMappingURL=arrayIndexByEquality.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * @param {T[]} array
5
5
  * @param {T} element
6
6
  * @param {function(a:T,b:T):boolean} equals
7
- * @returns {number}
7
+ * @returns {number} index of first match or -1 if no matches found
8
8
  */
9
9
  export function arrayIndexByEquality(array, element, equals) {
10
10
  const n = array.length;
@@ -1 +1 @@
1
- {"version":3,"file":"array_push_if_unique.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_push_if_unique.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,iEAFY,OAAO,CAWlB"}
1
+ {"version":3,"file":"array_push_if_unique.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_push_if_unique.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,iEAFY,OAAO,CAalB"}
@@ -1,3 +1,5 @@
1
+ import { assert } from "../../assert.js";
2
+
1
3
  /**
2
4
  * @template T
3
5
  * @param {T[]} array
@@ -5,6 +7,8 @@
5
7
  * @return {boolean}
6
8
  */
7
9
  export function array_push_if_unique(array, element) {
10
+ assert.isArray(array, 'array');
11
+
8
12
  const i = array.indexOf(element);
9
13
 
10
14
  if (i === -1) {