@woosh/meep-engine 2.102.0 → 2.104.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.
Files changed (71) hide show
  1. package/build/meep.cjs +57 -40
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +57 -40
  4. package/package.json +1 -1
  5. package/src/core/geom/2d/circle/Circle.d.ts +0 -8
  6. package/src/core/geom/2d/circle/Circle.d.ts.map +1 -1
  7. package/src/core/geom/2d/circle/Circle.js +85 -85
  8. package/src/core/geom/ConicRay.d.ts +3 -1
  9. package/src/core/geom/ConicRay.d.ts.map +1 -1
  10. package/src/core/geom/ConicRay.js +7 -5
  11. package/src/core/geom/Vector1.d.ts.map +1 -1
  12. package/src/core/geom/Vector1.js +3 -0
  13. package/src/core/geom/Vector2.d.ts.map +1 -1
  14. package/src/core/geom/Vector2.js +6 -3
  15. package/src/core/geom/Vector3.js +1 -1
  16. package/src/core/geom/vec3/v3_angle_cos_between.spec.d.ts +2 -0
  17. package/src/core/geom/vec3/v3_angle_cos_between.spec.d.ts.map +1 -0
  18. package/src/core/geom/vec3/v3_angle_cos_between.spec.js +124 -0
  19. package/src/core/geom/vec3/v3_distance_above_plane.d.ts +13 -4
  20. package/src/core/geom/vec3/v3_distance_sqr.d.ts +12 -1
  21. package/src/core/geom/vec3/v3_length.d.ts +9 -1
  22. package/src/core/lang/reactive/compileReactiveExpression.d.ts.map +1 -1
  23. package/src/core/lang/reactive/compileReactiveExpression.js +1 -3
  24. package/src/core/lang/reactive/pegjs/ReactivePegCompiler.d.ts.map +1 -1
  25. package/src/core/lang/reactive/pegjs/ReactivePegCompiler.js +11 -5
  26. package/src/core/math/PI_RECIPROCAL.d.ts +6 -0
  27. package/src/core/math/PI_RECIPROCAL.d.ts.map +1 -0
  28. package/src/core/math/PI_RECIPROCAL.js +5 -0
  29. package/src/core/math/newton_solver_1d.d.ts +4 -3
  30. package/src/core/math/newton_solver_1d.d.ts.map +1 -1
  31. package/src/core/math/newton_solver_1d.js +4 -3
  32. package/src/core/math/physics/brdf/D_GGX.d.ts.map +1 -1
  33. package/src/core/math/physics/brdf/D_GGX.js +4 -1
  34. package/src/core/math/physics/brdf/brdf_burley.d.ts.map +1 -1
  35. package/src/core/math/physics/brdf/brdf_burley.js +5 -1
  36. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.d.ts.map +1 -1
  37. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.js +3 -3
  38. package/src/core/primitives/strings/insert_after.spec.d.ts +2 -0
  39. package/src/core/primitives/strings/insert_after.spec.d.ts.map +1 -0
  40. package/src/core/primitives/strings/insert_after.spec.js +16 -0
  41. package/src/core/primitives/strings/insert_before.spec.d.ts +2 -0
  42. package/src/core/primitives/strings/insert_before.spec.d.ts.map +1 -0
  43. package/src/core/primitives/strings/insert_before.spec.js +16 -0
  44. package/src/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
  45. package/src/core/process/executor/ConcurrentExecutor.js +10 -4
  46. package/src/core/time/current_time_in_seconds.d.ts.map +1 -1
  47. package/src/core/time/current_time_in_seconds.js +1 -1
  48. package/src/engine/animation/curve/compute_curve_aabb.d.ts.map +1 -1
  49. package/src/engine/animation/curve/compute_curve_aabb.js +19 -16
  50. package/src/engine/ecs/fow/FogOfWar.d.ts.map +1 -1
  51. package/src/engine/ecs/fow/FogOfWar.js +10 -10
  52. package/src/engine/ecs/fow/FogOfWar.spec.js +5 -6
  53. package/src/engine/google/loadGTAG.d.ts +7 -0
  54. package/src/engine/google/loadGTAG.d.ts.map +1 -0
  55. package/src/engine/google/loadGTAG.js +32 -0
  56. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.d.ts.map +1 -1
  57. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js +6 -1
  58. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.d.ts.map +1 -1
  59. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js +17 -1
  60. package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
  61. package/src/engine/input/devices/PointerDevice.js +15 -5
  62. package/src/engine/metrics/GoogleAnalyticsMetrics.d.ts +2 -1
  63. package/src/engine/metrics/GoogleAnalyticsMetrics.d.ts.map +1 -1
  64. package/src/engine/metrics/GoogleAnalyticsMetrics.js +4 -39
  65. package/src/engine/notify/NotificationLog.d.ts +1 -2
  66. package/src/engine/notify/NotificationLog.d.ts.map +1 -1
  67. package/src/engine/notify/NotificationLog.js +33 -32
  68. package/src/core/lang/reactive/nearley/Reactive.ne +0 -87
  69. package/src/engine/compression/CompressionService.d.ts +0 -19
  70. package/src/engine/compression/CompressionService.d.ts.map +0 -1
  71. package/src/engine/compression/CompressionService.js +0 -144
@@ -5,6 +5,11 @@ import { computeUnsignedDistanceField_Chamfer } from "./computeUnsignedDistanceF
5
5
  * @param {Sampler2D} distanceField
6
6
  * @param {number} emptyValue
7
7
  */
8
- export function computeUnsignedDistanceField(source, distanceField, emptyValue) {
8
+ export function computeUnsignedDistanceField(
9
+ source,
10
+ distanceField,
11
+ emptyValue
12
+ ) {
13
+
9
14
  computeUnsignedDistanceField_Chamfer(source, distanceField, emptyValue, 1, 1, 255);
10
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"computeUnsignedDistanceField_Chamfer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,8GALW,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,QA0HhB"}
1
+ {"version":3,"file":"computeUnsignedDistanceField_Chamfer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,8GALW,MAAM,MACN,MAAM,MACN,MAAM,QACN,MAAM,QAyIhB"}
@@ -1,3 +1,4 @@
1
+ import { assert } from "../../../../../core/assert.js";
1
2
  import { max2 } from "../../../../../core/math/max2.js";
2
3
  import { min2 } from "../../../../../core/math/min2.js";
3
4
 
@@ -10,7 +11,22 @@ import { min2 } from "../../../../../core/math/min2.js";
10
11
  * @param {number} d2 distance between two diagonally adjacent pixels
11
12
  * @param {number} maxD highest value that distance field can hold
12
13
  */
13
- export function computeUnsignedDistanceField_Chamfer(source, distanceField, emptyValue, d1, d2, maxD) {
14
+ export function computeUnsignedDistanceField_Chamfer(
15
+ source,
16
+ distanceField,
17
+ emptyValue,
18
+ d1,
19
+ d2,
20
+ maxD
21
+ ) {
22
+
23
+ assert.defined(source, 'source');
24
+ assert.defined(distanceField, 'distanceField');
25
+ assert.isNumber(emptyValue, 'emptyValue');
26
+ assert.isNumber(d1, 'd1');
27
+ assert.isNumber(d2, 'd2');
28
+ assert.isNumber(maxD, 'maxD');
29
+
14
30
  const sourceData = source.data;
15
31
  const distanceFieldData = distanceField.data;
16
32
 
@@ -1 +1 @@
1
- {"version":3,"file":"PointerDevice.d.ts","sourceRoot":"","sources":["../../../../../src/engine/input/devices/PointerDevice.js"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,wDAFY,OAAO,EAAE,CAapB;AAiRD;;;;;GAKG;AACH,mDAJW,OAAO,SACP,UAAU,WACV,OAAO,QAejB;AAED;;GAEG;AACH;IAqFI;;;;OAIG;IACH,wBAHW,WAAW,EA0CrB;IA/HD;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;IAczB;;OAEG;IACH;;;;QAII;;WAEG;aADO,OAAO,OAAO,EAAE,CAAC,UAAU,GAAC,UAAU,CAAC,CAAC;;;;;;;;MAUpD;IASF;;;OAGG;IACH,kBAAkB;IAElB;;;;OAIG;IACH,kBAFU,iBAAiB,EAAE,CAEL;IAExB;;;OAGG;IACH,yCAEC;IAED;;;OAGG;IACH,0CAEC;IAED;;;OAGG;IACH,2CAEC;IAeG;;;OAGG;IACH,YAFU,WAAW,CAEO;IA6JhC;;;OAGG;IACH,oBAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,qBAFW,OAAO,QAwBjB;IAED;;;;OAIG;IACH,qCAHW,OAAO,SACP,UAAU,GAAC,UAAU,QAI/B;IAED,cAkCC;IAED,aA2BC;;CACJ;oBAlrBmB,+BAA+B;mBADhC,uCAAuC;kCAMxB,wBAAwB"}
1
+ {"version":3,"file":"PointerDevice.d.ts","sourceRoot":"","sources":["../../../../../src/engine/input/devices/PointerDevice.js"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,wDAFY,OAAO,EAAE,CAapB;AAiRD;;;;;GAKG;AACH,mDAJW,OAAO,SACP,UAAU,WACV,OAAO,QAejB;AAED;;GAEG;AACH;IA2FI;;;;OAIG;IACH,wBAHW,WAAW,EA0CrB;IArID;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;IAczB;;OAEG;IACH;;;;QAII;;WAEG;aADO,OAAO,OAAO,EAAE,CAAC,UAAU,GAAC,UAAU,CAAC,CAAC;;;;;;;;MAUpD;IAeF;;;OAGG;IACH,kBAAkB;IAElB;;;;OAIG;IACH,kBAFU,iBAAiB,EAAE,CAEL;IAExB;;;OAGG;IACH,yCAEC;IAED;;;OAGG;IACH,0CAEC;IAED;;;OAGG;IACH,2CAEC;IAgLD;;;OAGG;IACH,oBAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,6BAsBC;IAED,0BAEC;IAED;;;;OAIG;IACH,qCAHW,OAAO,SACP,UAAU,GAAC,UAAU,QAI/B;IAED,cAkCC;IAED,aA2BC;;CACJ;oBA5rBmB,+BAA+B;mBADhC,uCAAuC;kCAMxB,wBAAwB"}
@@ -373,6 +373,12 @@ export class PointerDevice {
373
373
  */
374
374
  #target = null;
375
375
 
376
+ /**
377
+ *
378
+ * @type {Element|null}
379
+ */
380
+ #domElement = null;
381
+
376
382
  /**
377
383
  * @private
378
384
  * @type {boolean}
@@ -427,7 +433,7 @@ export class PointerDevice {
427
433
  *
428
434
  * @type {EventTarget}
429
435
  */
430
- this.domElement = domElement;
436
+ this.#domElement = domElement;
431
437
 
432
438
 
433
439
  this.#touchStart.add((param0, param1, param2) => {
@@ -596,11 +602,11 @@ export class PointerDevice {
596
602
  *
597
603
  * @param {Element} el
598
604
  */
599
- setTargetElement(el) {
605
+ set domElement(el) {
600
606
  assert.defined(el, 'el');
601
607
  assert.notNull(el, 'el');
602
608
 
603
- if (this.#target === el) {
609
+ if (this.#domElement === el) {
604
610
  // no change
605
611
  return;
606
612
  }
@@ -612,7 +618,7 @@ export class PointerDevice {
612
618
  this.stop();
613
619
  }
614
620
 
615
- this.#target = el;
621
+ this.#domElement = el;
616
622
 
617
623
  if (was_running) {
618
624
  // restart to maintain original state
@@ -620,6 +626,10 @@ export class PointerDevice {
620
626
  }
621
627
  }
622
628
 
629
+ get domElement() {
630
+ return this.#domElement;
631
+ }
632
+
623
633
  /**
624
634
  *
625
635
  * @param {Vector2} result
@@ -639,7 +649,7 @@ export class PointerDevice {
639
649
 
640
650
  // console.warn("PointerDevice.start");
641
651
 
642
- const domElement = this.domElement;
652
+ const domElement = this.#domElement;
643
653
 
644
654
  assert.notEqual(domElement, null, "domElement is null");
645
655
  assert.notEqual(domElement, undefined, "domElement is undefined");
@@ -1,6 +1,7 @@
1
1
  export class GoogleAnalyticsMetrics extends MetricsGateway {
2
+ constructor(key: any);
2
3
  api: {
3
- gtag: (...args: any[]) => void;
4
+ gtag: Function;
4
5
  };
5
6
  record(type: any, event: any): void;
6
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleAnalyticsMetrics.d.ts","sourceRoot":"","sources":["../../../../src/engine/metrics/GoogleAnalyticsMetrics.js"],"names":[],"mappings":"AAkCA;IAIQ;;MAEC;IAKL,oCAgBC;CACJ;+BA9D8B,qBAAqB"}
1
+ {"version":3,"file":"GoogleAnalyticsMetrics.d.ts","sourceRoot":"","sources":["../../../../src/engine/metrics/GoogleAnalyticsMetrics.js"],"names":[],"mappings":"AAIA;IACI,sBAOC;IAJG;;MAEC;IAIL,oCAYC;CACJ;+BA1B8B,qBAAqB"}
@@ -1,46 +1,15 @@
1
+ import { loadGTAG } from "../google/loadGTAG.js";
1
2
  import { MetricsGateway } from "./MetricsGateway.js";
2
3
 
3
- // const GOOGLE_ANALYTICS_KEY = 'UA-66021000-1'; //Lazy-Kitty.com
4
- // const GOOGLE_ANALYTICS_KEY = 'UA-138821093-1'; //Itch.com
5
- const GOOGLE_ANALYTICS_KEY = 'G-ZBGZD4ZMZ1'; //ASKARA
6
-
7
- function loadGTAG(MEASUREMENT_ID) {
8
-
9
- (function (target, s, domTag, sourceURL) {
10
-
11
- const a = s.createElement(domTag);
12
- const m = s.getElementsByTagName(domTag)[0];
13
-
14
- a.async = 1;
15
- a.src = sourceURL;
16
-
17
- m.parentNode.insertBefore(a, m)
18
- })(document, document, 'script', `https://www.googletagmanager.com/gtag/js?id=${MEASUREMENT_ID}`);
19
-
20
-
21
- window.dataLayer = window.dataLayer || [];
22
-
23
- function gtag() {
24
- dataLayer.push(arguments);
25
- }
26
-
27
- gtag('js', new Date());
28
-
29
- gtag('config', MEASUREMENT_ID);
30
-
31
-
32
- return gtag;
33
- }
34
4
 
35
5
  export class GoogleAnalyticsMetrics extends MetricsGateway {
36
- constructor() {
6
+ constructor(key) {
37
7
  super();
38
8
 
39
9
  this.api = {
40
- gtag: loadGTAG(GOOGLE_ANALYTICS_KEY)
10
+ gtag: loadGTAG(key)
41
11
  };
42
12
 
43
-
44
13
  }
45
14
 
46
15
  record(type, event) {
@@ -54,10 +23,6 @@ export class GoogleAnalyticsMetrics extends MetricsGateway {
54
23
  payload.event_label = event.label;
55
24
  }
56
25
 
57
- if (ENV_PRODUCTION) {
58
- this.api.gtag('event', type, payload);
59
- } else {
60
- console.log("[DEBUG] metric would be sent", type, payload);
61
- }
26
+ this.api.gtag('event', type, payload);
62
27
  }
63
28
  }
@@ -1,5 +1,4 @@
1
1
  export default NotificationLog;
2
- declare function NotificationLog(): void;
3
2
  declare class NotificationLog {
4
3
  /**
5
4
  * @readonly
@@ -13,7 +12,7 @@ declare class NotificationLog {
13
12
  maxLength: number;
14
13
  /**
15
14
  *
16
- * @param {{}} options See Notification.constructor for details
15
+ * @param {{}} options See {@link Notification.constructor} for details
17
16
  * @returns {Notification}
18
17
  */
19
18
  add(options: {}): Notification;
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationLog.d.ts","sourceRoot":"","sources":["../../../../src/engine/notify/NotificationLog.js"],"names":[],"mappings":";AASA,yCAYC;;IAXG;;;OAGG;IACH,mBAFU,KAAK,YAAY,CAAC,CAEF;IAE1B;;;OAGG;IACH,WAFU,MAAM,CAEK;IAGzB;;;;OAIG;IACH,aAHW,EAAE,GACA,YAAY,CAQxB;IAED;;;OAGG;IACH,8BAFW,YAAY,QAkBtB;;iBAlDgB,oCAAoC;6BADxB,mBAAmB"}
1
+ {"version":3,"file":"NotificationLog.d.ts","sourceRoot":"","sources":["../../../../src/engine/notify/NotificationLog.js"],"names":[],"mappings":";AASA;IACI;;;OAGG;IACH,mBAFU,KAAK,YAAY,CAAC,CAEN;IAEtB;;;OAGG;IACH,WAFU,MAAM,CAEC;IAEjB;;;;OAIG;IACH,aAHW,EAAE,GACA,YAAY,CAQxB;IAED;;;OAGG;IACH,8BAFW,YAAY,QAmBtB;CACJ;iBAnDgB,oCAAoC;6BACxB,mBAAmB"}
@@ -3,57 +3,58 @@
3
3
  */
4
4
 
5
5
 
6
- import { Notification } from './Notification.js';
7
- import List from '../../core/collection/list/List.js';
8
6
  import { assert } from "../../core/assert.js";
7
+ import List from '../../core/collection/list/List.js';
8
+ import { Notification } from './Notification.js';
9
9
 
10
- function NotificationLog() {
10
+ class NotificationLog {
11
11
  /**
12
12
  * @readonly
13
13
  * @type {List<Notification>}
14
14
  */
15
- this.elements = new List();
15
+ elements = new List();
16
16
 
17
17
  /**
18
18
  * Once number of entries in the log reaches this amount, the earliest entries will be removed to make space for new ones
19
19
  * @type {number}
20
20
  */
21
- this.maxLength = 1000;
22
- }
21
+ maxLength = 1000;
23
22
 
24
- /**
25
- *
26
- * @param {{}} options See Notification.constructor for details
27
- * @returns {Notification}
28
- */
29
- NotificationLog.prototype.add = function (options) {
30
- const notification = new Notification(options);
23
+ /**
24
+ *
25
+ * @param {{}} options See {@link Notification.constructor} for details
26
+ * @returns {Notification}
27
+ */
28
+ add(options) {
29
+ const notification = new Notification(options);
31
30
 
32
- this.addNotification(notification);
31
+ this.addNotification(notification);
33
32
 
34
- return notification;
35
- };
33
+ return notification;
34
+ }
36
35
 
37
- /**
38
- *
39
- * @param {Notification} notification
40
- */
41
- NotificationLog.prototype.addNotification = function (notification) {
42
- assert.notEqual(notification, undefined, 'notification is undefined');
43
- assert.notEqual(notification, null, 'notification is null');
36
+ /**
37
+ *
38
+ * @param {Notification} notification
39
+ */
40
+ addNotification(notification) {
41
+ assert.defined(notification, 'notification');
42
+ assert.notNull(notification, 'notification');
44
43
 
45
- assert.ok(notification.isNotification, 'not a Notification');
44
+ assert.ok(notification.isNotification, 'not a Notification');
46
45
 
47
- // Crop notification log to size
48
- const length = this.elements.length;
46
+ // Crop notification log to size
47
+ const length = this.elements.length;
49
48
 
50
- const target = this.maxLength - 1;
49
+ const target = this.maxLength - 1;
51
50
 
52
- if (length > target) {
53
- this.elements.crop(length - target, length);
54
- }
51
+ if (length > target) {
52
+ // too many elements, drop some
53
+ this.elements.crop(length - target, length);
54
+ }
55
55
 
56
- this.elements.add(notification);
57
- };
56
+ this.elements.add(notification);
57
+ }
58
+ }
58
59
 
59
60
  export default NotificationLog;
@@ -1,87 +0,0 @@
1
- @builtin "whitespace.ne"
2
- @builtin "number.ne"
3
-
4
- expression -> binary_expression_add {% id %}
5
-
6
- group_expression -> "(" _ expression _ ")" {% (a) => a[2] %}
7
- | atomic {% id %}
8
-
9
- #####################
10
- # Unary Expressions
11
- #####################
12
-
13
- unary_expression_negate -> "-" _ expression {% (d)=> {return {type:'UnaryNegate', value: d[2]}} %}
14
- | group_expression {% id %}
15
-
16
-
17
- unary_expression_not -> "!" _ expression {% (d)=> {return {type:'UnaryNot', value: d[2]}} %}
18
- | unary_expression_negate {% id %}
19
-
20
- #####################
21
- # Binary Expressions
22
- #####################
23
-
24
- # Logic
25
-
26
- binary_expression_or -> binary_expression_or _ "||" _ unary_expression_not {% (d)=> {return {type:'BinaryOr', left: d[0], right: d[4]}} %}
27
- | unary_expression_not {% id %}
28
-
29
- binary_expression_and -> binary_expression_and _ "&&" _ binary_expression_or {% (d)=> {return {type:'BinaryAnd', left: d[0], right: d[4]}} %}
30
- | binary_expression_or {% id %}
31
-
32
- # Equality
33
-
34
- binary_expression_equals -> binary_expression_equals _ "==" _ binary_expression_and {% (d)=> {return {type:'BinaryEqual', left: d[0], right: d[4]}} %}
35
- | binary_expression_and {% id %}
36
-
37
- binary_expression_not_equals -> binary_expression_not_equals _ "!=" _ binary_expression_equals {% (d)=> {return {type:'BinaryNotEqual', left: d[0], right: d[4]}} %}
38
- | binary_expression_equals {% id %}
39
-
40
- # Comparison
41
-
42
- binary_expression_lte -> binary_expression_lte _ "<=" _ binary_expression_not_equals {% (d)=> {return {type:'BinaryLessOrEqual', left: d[0], right: d[4]}} %}
43
- | binary_expression_not_equals {% id %}
44
-
45
- binary_expression_gte -> binary_expression_gte _ ">=" _ binary_expression_lte {% (d)=> {return {type:'BinaryGreaterOrEqual', left: d[0], right: d[4]}} %}
46
- | binary_expression_lte {% id %}
47
-
48
- binary_expression_lt -> binary_expression_lt _ "<" _ binary_expression_gte {% (d)=> {return {type:'BinaryLess', left: d[0], right: d[4]}} %}
49
- | binary_expression_gte {% id %}
50
-
51
- binary_expression_gt -> binary_expression_gt _ ">" _ binary_expression_lt {% (d)=> {return {type:'BinaryGreater', left: d[0], right: d[4]}} %}
52
- | binary_expression_lt {% id %}
53
-
54
- # Multiplication
55
-
56
- binary_expression_multiply -> binary_expression_multiply _ "*" _ binary_expression_gt {% (d)=> {return {type:'BinaryMultiply', left: d[0], right: d[4]}} %}
57
- | binary_expression_gt {% id %}
58
-
59
- binary_expression_divide -> binary_expression_divide _ "/" _ binary_expression_multiply {% (d)=> {return {type:'BinaryDivide', left: d[0], right: d[4]}} %}
60
- | binary_expression_multiply {% id %}
61
-
62
- # Addition
63
-
64
- binary_expression_subtract -> binary_expression_subtract _ "-" _ binary_expression_divide {% (d)=> {return {type:'BinarySubtract', left: d[0], right: d[4]}} %}
65
- | binary_expression_divide {% id %}
66
-
67
- binary_expression_add -> binary_expression_add _ "+" _ binary_expression_subtract {% (d)=> {return {type:'BinaryAdd', left: d[0], right: d[4]}} %}
68
- | binary_expression_subtract {% id %}
69
-
70
-
71
- #####################
72
- # Primitives
73
- #####################
74
-
75
- atomic -> literal {% id %}
76
- | reference {% (d,l,r)=> { return {type:'Reference', value: d[0] } } %}
77
-
78
- reference -> identifier ("." identifier {% (a)=>a[1] %}):* {% (a,l,r) => [a[0]].concat(a[1]) %}
79
-
80
- identifier -> [a-zA-Z_] [a-zA-Z_0-9]:* {% (d,l,r) => { const value =d[0]+d[1].join(""); if(value === 'true' || value === 'false'){return r}else{return value} } %}
81
-
82
- literal -> decimal {% (d)=> {return {type:'LiteralNumber', value: d[0] }} %}
83
- | literal_boolean {% (d) => { return {type:'LiteralBoolean', value:d[0]} } %}
84
-
85
-
86
- literal_boolean -> "true" {% ()=> true %}
87
- | "false" {% ()=> false %}
@@ -1,19 +0,0 @@
1
- export default CompressionService;
2
- declare class CompressionService {
3
- private __incrementRequestCount;
4
- private __decrementRequestCount;
5
- /**
6
- *
7
- * @param data
8
- * @param level
9
- * @returns {Promise}
10
- */
11
- encode(data: any, level: any): Promise<any>;
12
- /**
13
- *
14
- * @param data
15
- * @returns {Promise}
16
- */
17
- decode(data: any): Promise<any>;
18
- }
19
- //# sourceMappingURL=CompressionService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CompressionService.d.ts","sourceRoot":"","sources":["../../../../src/engine/compression/CompressionService.js"],"names":[],"mappings":";;IA2FuD,gCAetD;IAMsD,gCAKtD;IAED;;;;;OAKG;IACH,4CAIC;IAED;;;;OAIG;IACH,gCAIC"}
@@ -1,144 +0,0 @@
1
- /**
2
- * Created by Alex on 03/11/2016.
3
- */
4
-
5
-
6
- import WorkerBuilder from '../../core/process/worker/WorkerBuilder.js';
7
-
8
- function buildWorker() {
9
- const workerBuilder = new WorkerBuilder();
10
- workerBuilder.importScript('lib/lzma_worker.js');
11
-
12
- workerBuilder.addMethod('encode', function encode(data, level) {
13
- return new Promise(function (resolve, reject) {
14
- //Validate data type
15
- if (typeof data !== "string" && !(data instanceof Uint8Array)) {
16
- reject("data must be a string or a Uint8Array, instead got '" + (typeof data) + "'");
17
- }
18
-
19
- let compressionLevel;
20
- if (typeof level === 'number') {
21
- if (level < 1) {
22
- compressionLevel = 1;
23
- console.warn('Requested compression level(' + level + ') < minimum(1), using 1 instead');
24
- } else if (level > 9) {
25
- compressionLevel = 9;
26
- console.warn('Requested compression level(' + level + ') > maximum(9), using 9 instead');
27
- } else if (level % 1 !== 0) {
28
- compressionLevel = level | 0;
29
- console.warn('Requested compression level(' + level + ') is not integer, using ' + compressionLevel + ' instead');
30
- } else {
31
- compressionLevel = level;
32
- }
33
- } else {
34
- if (level !== undefined && typeof level !== 'number') {
35
- console.warn('Supplied compression level must be a number, was ' + (typeof level) + ' instead. Defaulting to minimum(1)');
36
- }
37
- //no valid compression level specified
38
- compressionLevel = 1;
39
- }
40
-
41
- console.time("Compression");
42
- LZMA.compress(data, compressionLevel, function on_finish(result, error) {
43
- console.timeEnd("Compression");
44
- if (error) {
45
- reject(error);
46
- } else {
47
- if (result instanceof Array) {
48
- resolve(new Uint8Array(result));
49
- } else {
50
- resolve(result);
51
- }
52
- }
53
- }, function on_progress(percent) {
54
- });
55
- });
56
- });
57
-
58
- workerBuilder.addMethod('decode', function decode(data) {
59
- return new Promise(function (resolve, reject) {
60
- LZMA.decompress(data, function on_finish(result, error) {
61
- if (error) {
62
- reject(error);
63
- } else {
64
- if (result instanceof Array) {
65
- resolve(new Uint8Array(result));
66
- } else {
67
- resolve(result);
68
- }
69
- }
70
- }, function on_progress(percent) {
71
- });
72
- });
73
- });
74
- return workerBuilder.build();
75
- }
76
-
77
- /**
78
- * @property {WorkerProxy} __workerProxy
79
- * @property {number} __requestCount
80
- * @constructor
81
- */
82
- const CompressionService = function () {
83
- this.__workerProxy = buildWorker();
84
- this.__requestCount = 0;
85
- };
86
-
87
- /**
88
- *
89
- * @param {Promise} r
90
- * @private
91
- */
92
- CompressionService.prototype.__incrementRequestCount = function (r) {
93
- this.__requestCount++;
94
-
95
-
96
- const self = this;
97
-
98
- function d() {
99
- self.__decrementRequestCount();
100
- }
101
-
102
- r.then(d, d);
103
-
104
- if (!this.__workerProxy.isRunning()) {
105
- this.__workerProxy.start();
106
- }
107
- };
108
-
109
- /**
110
- *
111
- * @private
112
- */
113
- CompressionService.prototype.__decrementRequestCount = function () {
114
- this.__requestCount--;
115
- if (this.__requestCount <= 0 && this.__workerProxy.isRunning()) {
116
- this.__workerProxy.stop();
117
- }
118
- };
119
-
120
- /**
121
- *
122
- * @param data
123
- * @param level
124
- * @returns {Promise}
125
- */
126
- CompressionService.prototype.encode = function (data, level) {
127
- const result = this.__workerProxy.encode(data, level);
128
- this.__incrementRequestCount(result);
129
- return result;
130
- };
131
-
132
- /**
133
- *
134
- * @param data
135
- * @returns {Promise}
136
- */
137
- CompressionService.prototype.decode = function (data) {
138
- const result = this.__workerProxy.decode(data);
139
- this.__incrementRequestCount(result);
140
- return result;
141
- };
142
-
143
-
144
- export default CompressionService;