bruce-models 1.9.8 → 1.9.9

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 (84) hide show
  1. package/dist/bruce-models.es5.js +20 -14
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +20 -14
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account-settings.js +2 -2
  6. package/dist/lib/account/account.js +185 -185
  7. package/dist/lib/ann-document/ann-document.js +86 -86
  8. package/dist/lib/api/abstract-api.js +246 -246
  9. package/dist/lib/api/api-getters.js +134 -134
  10. package/dist/lib/api/api.js +93 -93
  11. package/dist/lib/api/bruce-api.js +216 -216
  12. package/dist/lib/api/cam-api.js +85 -82
  13. package/dist/lib/api/cam-api.js.map +1 -1
  14. package/dist/lib/api/global-api.js +81 -81
  15. package/dist/lib/api/idm-api.js +85 -82
  16. package/dist/lib/api/idm-api.js.map +1 -1
  17. package/dist/lib/bruce-models.js +86 -86
  18. package/dist/lib/calculator/calculator.js +341 -341
  19. package/dist/lib/client-file/client-file.js +245 -245
  20. package/dist/lib/common/bounds.js +61 -61
  21. package/dist/lib/common/bruce-event.js +46 -46
  22. package/dist/lib/common/bruce-variable.js +60 -60
  23. package/dist/lib/common/cache.js +165 -165
  24. package/dist/lib/common/camera.js +11 -11
  25. package/dist/lib/common/cartes.js +123 -123
  26. package/dist/lib/common/carto.js +60 -60
  27. package/dist/lib/common/color.js +86 -86
  28. package/dist/lib/common/delay-queue.js +56 -56
  29. package/dist/lib/common/dictionary.js +2 -2
  30. package/dist/lib/common/geometry.js +120 -120
  31. package/dist/lib/common/transform.js +2 -2
  32. package/dist/lib/common/utc.js +39 -39
  33. package/dist/lib/custom-form/custom-form-content.js +26 -26
  34. package/dist/lib/custom-form/custom-form.js +106 -106
  35. package/dist/lib/data-lab/data-lab.js +49 -49
  36. package/dist/lib/entity/entity-attachment-type.js +83 -83
  37. package/dist/lib/entity/entity-attachment.js +122 -122
  38. package/dist/lib/entity/entity-attribute.js +29 -29
  39. package/dist/lib/entity/entity-comment.js +82 -82
  40. package/dist/lib/entity/entity-coords.js +149 -149
  41. package/dist/lib/entity/entity-link.js +82 -82
  42. package/dist/lib/entity/entity-lod-category.js +100 -100
  43. package/dist/lib/entity/entity-lod.js +185 -185
  44. package/dist/lib/entity/entity-relation-type.js +109 -109
  45. package/dist/lib/entity/entity-relation.js +132 -132
  46. package/dist/lib/entity/entity-source.js +136 -136
  47. package/dist/lib/entity/entity-tag.js +149 -149
  48. package/dist/lib/entity/entity-type-visual-settings.js +13 -13
  49. package/dist/lib/entity/entity-type.js +113 -113
  50. package/dist/lib/entity/entity.js +319 -319
  51. package/dist/lib/entity/getters/batched-data-getter.js +84 -84
  52. package/dist/lib/entity/getters/entity-filter-getter.js +303 -303
  53. package/dist/lib/entity/getters/entity-globe.js +211 -211
  54. package/dist/lib/entity/getters/view-monitor.js +2 -2
  55. package/dist/lib/import/import-cad.js +53 -53
  56. package/dist/lib/import/import-csv.js +23 -23
  57. package/dist/lib/import/import-json.js +23 -23
  58. package/dist/lib/import/import-kml.js +23 -23
  59. package/dist/lib/import/imported-file.js +91 -91
  60. package/dist/lib/internal/uploader.js +76 -76
  61. package/dist/lib/markup/markup.js +185 -185
  62. package/dist/lib/plugin/plugin.js +83 -83
  63. package/dist/lib/program-key/program-key.js +111 -111
  64. package/dist/lib/project/menu-item.js +121 -121
  65. package/dist/lib/project/project-view-bookmark.js +147 -147
  66. package/dist/lib/project/project-view-legacy-tile.js +77 -77
  67. package/dist/lib/project/project-view-tile.js +125 -125
  68. package/dist/lib/project/project-view.js +133 -133
  69. package/dist/lib/project/zoom-control.js +17 -17
  70. package/dist/lib/server/message-broker.js +142 -142
  71. package/dist/lib/server/pending-action.js +71 -71
  72. package/dist/lib/server/task.js +63 -63
  73. package/dist/lib/style/style.js +117 -117
  74. package/dist/lib/tileset/tileset.js +415 -415
  75. package/dist/lib/user/permission.js +20 -20
  76. package/dist/lib/user/session.js +137 -137
  77. package/dist/lib/user/user-group.js +94 -94
  78. package/dist/lib/user/user.js +446 -446
  79. package/dist/lib/util/encrypt-utils.js +19 -19
  80. package/dist/lib/util/math-utils.js +40 -40
  81. package/dist/lib/util/object-utils.js +17 -17
  82. package/dist/lib/util/path-utils.js +61 -61
  83. package/dist/lib/util/url-utils.js +94 -94
  84. package/package.json +3 -2
@@ -1,124 +1,124 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Cartes = void 0;
4
- /**
5
- * Describes 2d and 3d coordinates.
6
- *
7
- * In 2d the x/y typically refers to a window left/top offset.
8
- * In 3d the x/y/z, the units are in meters.
9
- */
10
- var Cartes;
11
- (function (Cartes) {
12
- function ValidateCartes2(cartes) {
13
- if (!cartes) {
14
- return false;
15
- }
16
- else if (!cartes.x && cartes.x != 0) {
17
- return false;
18
- }
19
- else if (!cartes.y && cartes.y != 0) {
20
- return false;
21
- }
22
- return true;
23
- }
24
- Cartes.ValidateCartes2 = ValidateCartes2;
25
- function ValidateCartes3(cartes) {
26
- if (!ValidateCartes2(cartes)) {
27
- return false;
28
- }
29
- else if (!cartes.z && cartes.z != 0) {
30
- return false;
31
- }
32
- return true;
33
- }
34
- Cartes.ValidateCartes3 = ValidateCartes3;
35
- function IsEqualCartes2(a, b) {
36
- if (a.x != b.x) {
37
- return false;
38
- }
39
- else if (a.y != b.y) {
40
- return false;
41
- }
42
- return true;
43
- }
44
- Cartes.IsEqualCartes2 = IsEqualCartes2;
45
- function IsEqualCartes3(a, b) {
46
- if (!IsEqualCartes2(a, b)) {
47
- return false;
48
- }
49
- else if (a.z != b.z) {
50
- return false;
51
- }
52
- return true;
53
- }
54
- Cartes.IsEqualCartes3 = IsEqualCartes3;
55
- /**
56
- * Returns true if the given ring is closed.
57
- * A ring is closed if the first and last point are equal.
58
- * A ring with less than 2 points is not closed.
59
- * @param points
60
- * @returns
61
- */
62
- function IsRing2Closed(points) {
63
- if (points.length < 2) {
64
- return false;
65
- }
66
- else if (!IsEqualCartes2(points[0], points[points.length - 1])) {
67
- return false;
68
- }
69
- return true;
70
- }
71
- Cartes.IsRing2Closed = IsRing2Closed;
72
- /**
73
- * Returns true if the given ring is closed.
74
- * A ring is closed if the first and last point are equal.
75
- * A ring with less than 2 points is not closed.
76
- * @param points
77
- * @returns
78
- */
79
- function IsRing3Closed(points) {
80
- if (points.length < 2) {
81
- return false;
82
- }
83
- else if (!IsEqualCartes3(points[0], points[points.length - 1])) {
84
- return false;
85
- }
86
- return true;
87
- }
88
- Cartes.IsRing3Closed = IsRing3Closed;
89
- /**
90
- * Closes given ring by adding the first point to the end of the array.
91
- * This will mutate the given array.
92
- * Will not do anything if the ring is already closed.
93
- * @param points
94
- * @returns
95
- */
96
- function CloseRing2(points) {
97
- if (points.length < 2) {
98
- return;
99
- }
100
- else if (IsRing2Closed(points)) {
101
- return;
102
- }
103
- points.push(points[0]);
104
- }
105
- Cartes.CloseRing2 = CloseRing2;
106
- /**
107
- * Closes given ring by adding the first point to the end of the array.
108
- * This will mutate the given array.
109
- * Will not do anything if the ring is already closed.
110
- * @param points
111
- * @returns
112
- */
113
- function CloseRing3(points) {
114
- if (points.length < 2) {
115
- return;
116
- }
117
- else if (IsRing3Closed(points)) {
118
- return;
119
- }
120
- points.push(points[0]);
121
- }
122
- Cartes.CloseRing3 = CloseRing3;
123
- })(Cartes = exports.Cartes || (exports.Cartes = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Cartes = void 0;
4
+ /**
5
+ * Describes 2d and 3d coordinates.
6
+ *
7
+ * In 2d the x/y typically refers to a window left/top offset.
8
+ * In 3d the x/y/z, the units are in meters.
9
+ */
10
+ var Cartes;
11
+ (function (Cartes) {
12
+ function ValidateCartes2(cartes) {
13
+ if (!cartes) {
14
+ return false;
15
+ }
16
+ else if (!cartes.x && cartes.x != 0) {
17
+ return false;
18
+ }
19
+ else if (!cartes.y && cartes.y != 0) {
20
+ return false;
21
+ }
22
+ return true;
23
+ }
24
+ Cartes.ValidateCartes2 = ValidateCartes2;
25
+ function ValidateCartes3(cartes) {
26
+ if (!ValidateCartes2(cartes)) {
27
+ return false;
28
+ }
29
+ else if (!cartes.z && cartes.z != 0) {
30
+ return false;
31
+ }
32
+ return true;
33
+ }
34
+ Cartes.ValidateCartes3 = ValidateCartes3;
35
+ function IsEqualCartes2(a, b) {
36
+ if (a.x != b.x) {
37
+ return false;
38
+ }
39
+ else if (a.y != b.y) {
40
+ return false;
41
+ }
42
+ return true;
43
+ }
44
+ Cartes.IsEqualCartes2 = IsEqualCartes2;
45
+ function IsEqualCartes3(a, b) {
46
+ if (!IsEqualCartes2(a, b)) {
47
+ return false;
48
+ }
49
+ else if (a.z != b.z) {
50
+ return false;
51
+ }
52
+ return true;
53
+ }
54
+ Cartes.IsEqualCartes3 = IsEqualCartes3;
55
+ /**
56
+ * Returns true if the given ring is closed.
57
+ * A ring is closed if the first and last point are equal.
58
+ * A ring with less than 2 points is not closed.
59
+ * @param points
60
+ * @returns
61
+ */
62
+ function IsRing2Closed(points) {
63
+ if (points.length < 2) {
64
+ return false;
65
+ }
66
+ else if (!IsEqualCartes2(points[0], points[points.length - 1])) {
67
+ return false;
68
+ }
69
+ return true;
70
+ }
71
+ Cartes.IsRing2Closed = IsRing2Closed;
72
+ /**
73
+ * Returns true if the given ring is closed.
74
+ * A ring is closed if the first and last point are equal.
75
+ * A ring with less than 2 points is not closed.
76
+ * @param points
77
+ * @returns
78
+ */
79
+ function IsRing3Closed(points) {
80
+ if (points.length < 2) {
81
+ return false;
82
+ }
83
+ else if (!IsEqualCartes3(points[0], points[points.length - 1])) {
84
+ return false;
85
+ }
86
+ return true;
87
+ }
88
+ Cartes.IsRing3Closed = IsRing3Closed;
89
+ /**
90
+ * Closes given ring by adding the first point to the end of the array.
91
+ * This will mutate the given array.
92
+ * Will not do anything if the ring is already closed.
93
+ * @param points
94
+ * @returns
95
+ */
96
+ function CloseRing2(points) {
97
+ if (points.length < 2) {
98
+ return;
99
+ }
100
+ else if (IsRing2Closed(points)) {
101
+ return;
102
+ }
103
+ points.push(points[0]);
104
+ }
105
+ Cartes.CloseRing2 = CloseRing2;
106
+ /**
107
+ * Closes given ring by adding the first point to the end of the array.
108
+ * This will mutate the given array.
109
+ * Will not do anything if the ring is already closed.
110
+ * @param points
111
+ * @returns
112
+ */
113
+ function CloseRing3(points) {
114
+ if (points.length < 2) {
115
+ return;
116
+ }
117
+ else if (IsRing3Closed(points)) {
118
+ return;
119
+ }
120
+ points.push(points[0]);
121
+ }
122
+ Cartes.CloseRing3 = CloseRing3;
123
+ })(Cartes = exports.Cartes || (exports.Cartes = {}));
124
124
  //# sourceMappingURL=cartes.js.map
@@ -1,61 +1,61 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Carto = void 0;
4
- /**
5
- * Describes a geographic point.
6
- * The units of the stored data should be in Degrees.
7
- * Utilities may use this in Radians for temporary calculations.
8
- */
9
- var Carto;
10
- (function (Carto) {
11
- function ValidateCarto(carto) {
12
- if (!carto) {
13
- return false;
14
- }
15
- else if (!carto.longitude && carto.longitude != 0) {
16
- return false;
17
- }
18
- else if (!carto.latitude && carto.latitude != 0) {
19
- return false;
20
- }
21
- return true;
22
- }
23
- Carto.ValidateCarto = ValidateCarto;
24
- function IsEqual(a, b) {
25
- if (a.longitude != b.longitude) {
26
- return false;
27
- }
28
- else if (a.latitude != b.latitude) {
29
- return false;
30
- }
31
- return true;
32
- }
33
- Carto.IsEqual = IsEqual;
34
- function GetCenter(list) {
35
- let center = {
36
- longitude: 0,
37
- latitude: 0,
38
- altitude: 0
39
- };
40
- for (let i = 0; i < list.length; i++) {
41
- const carto = list[i];
42
- center.longitude += carto.longitude;
43
- center.latitude += carto.latitude;
44
- if (carto.altitude) {
45
- center.altitude += carto.altitude;
46
- }
47
- }
48
- if (center.longitude) {
49
- center.longitude /= list.length;
50
- }
51
- if (center.latitude) {
52
- center.latitude /= list.length;
53
- }
54
- if (center.altitude) {
55
- center.altitude /= list.length;
56
- }
57
- return center;
58
- }
59
- Carto.GetCenter = GetCenter;
60
- })(Carto = exports.Carto || (exports.Carto = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Carto = void 0;
4
+ /**
5
+ * Describes a geographic point.
6
+ * The units of the stored data should be in Degrees.
7
+ * Utilities may use this in Radians for temporary calculations.
8
+ */
9
+ var Carto;
10
+ (function (Carto) {
11
+ function ValidateCarto(carto) {
12
+ if (!carto) {
13
+ return false;
14
+ }
15
+ else if (!carto.longitude && carto.longitude != 0) {
16
+ return false;
17
+ }
18
+ else if (!carto.latitude && carto.latitude != 0) {
19
+ return false;
20
+ }
21
+ return true;
22
+ }
23
+ Carto.ValidateCarto = ValidateCarto;
24
+ function IsEqual(a, b) {
25
+ if (a.longitude != b.longitude) {
26
+ return false;
27
+ }
28
+ else if (a.latitude != b.latitude) {
29
+ return false;
30
+ }
31
+ return true;
32
+ }
33
+ Carto.IsEqual = IsEqual;
34
+ function GetCenter(list) {
35
+ let center = {
36
+ longitude: 0,
37
+ latitude: 0,
38
+ altitude: 0
39
+ };
40
+ for (let i = 0; i < list.length; i++) {
41
+ const carto = list[i];
42
+ center.longitude += carto.longitude;
43
+ center.latitude += carto.latitude;
44
+ if (carto.altitude) {
45
+ center.altitude += carto.altitude;
46
+ }
47
+ }
48
+ if (center.longitude) {
49
+ center.longitude /= list.length;
50
+ }
51
+ if (center.latitude) {
52
+ center.latitude /= list.length;
53
+ }
54
+ if (center.altitude) {
55
+ center.altitude /= list.length;
56
+ }
57
+ return center;
58
+ }
59
+ Carto.GetCenter = GetCenter;
60
+ })(Carto = exports.Carto || (exports.Carto = {}));
61
61
  //# sourceMappingURL=carto.js.map
@@ -1,87 +1,87 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Color = void 0;
4
- var Color;
5
- (function (Color) {
6
- let EBlendMode;
7
- (function (EBlendMode) {
8
- EBlendMode[EBlendMode["HIGHLIGHT"] = 0] = "HIGHLIGHT";
9
- EBlendMode[EBlendMode["REPLACE"] = 1] = "REPLACE";
10
- EBlendMode[EBlendMode["MIX"] = 2] = "MIX";
11
- })(EBlendMode = Color.EBlendMode || (Color.EBlendMode = {}));
12
- function RandomColor() {
13
- // https://stackoverflow.com/a/7352887
14
- const brightness = 4;
15
- const rgb = [Math.random() * 256, Math.random() * 256, Math.random() * 256];
16
- const mix = [brightness * 51, brightness * 51, brightness * 51];
17
- const mixedrgb = [rgb[0] + mix[0], rgb[1] + mix[1], rgb[2] + mix[2]].map(function (x) {
18
- return Math.round(x / 2.0);
19
- });
20
- const str = "rgba(" + mixedrgb.join(",") + ",0.9" + ")";
21
- return ColorFromStr(str);
22
- }
23
- Color.RandomColor = RandomColor;
24
- /**
25
- * Attempts to parse a given color string into a model.
26
- * @param str
27
- * @returns
28
- */
29
- function ColorFromStr(str) {
30
- let r, g, b, a;
31
- const rgba = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([^\)]+)\s*)?\)$/.exec(str);
32
- if (rgba) {
33
- r = parseInt(rgba[1]);
34
- g = parseInt(rgba[2]);
35
- b = parseInt(rgba[3]);
36
- a = rgba[4] != null ? parseFloat(rgba[4]) : 1;
37
- return {
38
- red: r,
39
- green: g,
40
- blue: b,
41
- alpha: a
42
- };
43
- }
44
- if (str.charAt(0) == "#") {
45
- str = str.substring(1);
46
- }
47
- if (str.length == 6) {
48
- // rgb.
49
- const parsed = /^(.{2})(.{2})(.{2})/.exec(str);
50
- if (!parsed) {
51
- return null;
52
- }
53
- r = parseInt(parsed[1], 16);
54
- g = parseInt(parsed[2], 16);
55
- b = parseInt(parsed[3], 16);
56
- a = 1;
57
- }
58
- else if (str.length == 8) {
59
- // rgba.
60
- const parsed = /^(.{2})(.{2})(.{2})(.{2})/.exec(str);
61
- if (!parsed) {
62
- return null;
63
- }
64
- r = parseInt(parsed[1], 16);
65
- g = parseInt(parsed[2], 16);
66
- b = parseInt(parsed[3], 16);
67
- a = parseInt(parsed[4], 16);
68
- if (a != 0) {
69
- a = a / 255;
70
- }
71
- }
72
- else {
73
- return null;
74
- }
75
- if (a == null) {
76
- a = 1;
77
- }
78
- return {
79
- red: r,
80
- blue: b,
81
- green: g,
82
- alpha: a
83
- };
84
- }
85
- Color.ColorFromStr = ColorFromStr;
86
- })(Color = exports.Color || (exports.Color = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Color = void 0;
4
+ var Color;
5
+ (function (Color) {
6
+ let EBlendMode;
7
+ (function (EBlendMode) {
8
+ EBlendMode[EBlendMode["HIGHLIGHT"] = 0] = "HIGHLIGHT";
9
+ EBlendMode[EBlendMode["REPLACE"] = 1] = "REPLACE";
10
+ EBlendMode[EBlendMode["MIX"] = 2] = "MIX";
11
+ })(EBlendMode = Color.EBlendMode || (Color.EBlendMode = {}));
12
+ function RandomColor() {
13
+ // https://stackoverflow.com/a/7352887
14
+ const brightness = 4;
15
+ const rgb = [Math.random() * 256, Math.random() * 256, Math.random() * 256];
16
+ const mix = [brightness * 51, brightness * 51, brightness * 51];
17
+ const mixedrgb = [rgb[0] + mix[0], rgb[1] + mix[1], rgb[2] + mix[2]].map(function (x) {
18
+ return Math.round(x / 2.0);
19
+ });
20
+ const str = "rgba(" + mixedrgb.join(",") + ",0.9" + ")";
21
+ return ColorFromStr(str);
22
+ }
23
+ Color.RandomColor = RandomColor;
24
+ /**
25
+ * Attempts to parse a given color string into a model.
26
+ * @param str
27
+ * @returns
28
+ */
29
+ function ColorFromStr(str) {
30
+ let r, g, b, a;
31
+ const rgba = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([^\)]+)\s*)?\)$/.exec(str);
32
+ if (rgba) {
33
+ r = parseInt(rgba[1]);
34
+ g = parseInt(rgba[2]);
35
+ b = parseInt(rgba[3]);
36
+ a = rgba[4] != null ? parseFloat(rgba[4]) : 1;
37
+ return {
38
+ red: r,
39
+ green: g,
40
+ blue: b,
41
+ alpha: a
42
+ };
43
+ }
44
+ if (str.charAt(0) == "#") {
45
+ str = str.substring(1);
46
+ }
47
+ if (str.length == 6) {
48
+ // rgb.
49
+ const parsed = /^(.{2})(.{2})(.{2})/.exec(str);
50
+ if (!parsed) {
51
+ return null;
52
+ }
53
+ r = parseInt(parsed[1], 16);
54
+ g = parseInt(parsed[2], 16);
55
+ b = parseInt(parsed[3], 16);
56
+ a = 1;
57
+ }
58
+ else if (str.length == 8) {
59
+ // rgba.
60
+ const parsed = /^(.{2})(.{2})(.{2})(.{2})/.exec(str);
61
+ if (!parsed) {
62
+ return null;
63
+ }
64
+ r = parseInt(parsed[1], 16);
65
+ g = parseInt(parsed[2], 16);
66
+ b = parseInt(parsed[3], 16);
67
+ a = parseInt(parsed[4], 16);
68
+ if (a != 0) {
69
+ a = a / 255;
70
+ }
71
+ }
72
+ else {
73
+ return null;
74
+ }
75
+ if (a == null) {
76
+ a = 1;
77
+ }
78
+ return {
79
+ red: r,
80
+ blue: b,
81
+ green: g,
82
+ alpha: a
83
+ };
84
+ }
85
+ Color.ColorFromStr = ColorFromStr;
86
+ })(Color = exports.Color || (exports.Color = {}));
87
87
  //# sourceMappingURL=color.js.map
@@ -1,57 +1,57 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DelayQueue = void 0;
4
- /**
5
- * Controls the flow of method calls.
6
- * If you have a method that may be called often, but you don't want it to run often, use this.
7
- */
8
- class DelayQueue {
9
- constructor(callback, delay = 200) {
10
- // Millisecond delay.
11
- this.delay = 200;
12
- // Date-time stamp for the last callback call.
13
- this.lastCallTime = null;
14
- this.callback = callback;
15
- this.delay = delay;
16
- }
17
- Call(force = false) {
18
- if (this.lastCallTime == null) {
19
- force = true;
20
- }
21
- if (force) {
22
- let endDate = new Date().getTime();
23
- this.doCall(endDate);
24
- }
25
- else {
26
- const endDate = new Date().getTime();
27
- const seconds = (endDate - this.lastCallTime) / 1000;
28
- const delay = this.delay / 1000;
29
- if (seconds > delay) {
30
- this.doCall(endDate);
31
- }
32
- else if (this.delayTimeout == null) {
33
- const diff = (delay - seconds) * 1000;
34
- this.delayTimeout = setTimeout(() => {
35
- this.delayTimeout = null;
36
- this.Call();
37
- }, diff + 0.02);
38
- }
39
- }
40
- }
41
- doCall(endDate) {
42
- if (this.delayTimeout != null) {
43
- clearTimeout(this.delayTimeout);
44
- this.delayTimeout = null;
45
- }
46
- this.lastCallTime = endDate;
47
- this.callback();
48
- }
49
- Dispose() {
50
- if (this.delayTimeout != null) {
51
- clearTimeout(this.delayTimeout);
52
- this.delayTimeout = null;
53
- }
54
- }
55
- }
56
- exports.DelayQueue = DelayQueue;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DelayQueue = void 0;
4
+ /**
5
+ * Controls the flow of method calls.
6
+ * If you have a method that may be called often, but you don't want it to run often, use this.
7
+ */
8
+ class DelayQueue {
9
+ constructor(callback, delay = 200) {
10
+ // Millisecond delay.
11
+ this.delay = 200;
12
+ // Date-time stamp for the last callback call.
13
+ this.lastCallTime = null;
14
+ this.callback = callback;
15
+ this.delay = delay;
16
+ }
17
+ Call(force = false) {
18
+ if (this.lastCallTime == null) {
19
+ force = true;
20
+ }
21
+ if (force) {
22
+ let endDate = new Date().getTime();
23
+ this.doCall(endDate);
24
+ }
25
+ else {
26
+ const endDate = new Date().getTime();
27
+ const seconds = (endDate - this.lastCallTime) / 1000;
28
+ const delay = this.delay / 1000;
29
+ if (seconds > delay) {
30
+ this.doCall(endDate);
31
+ }
32
+ else if (this.delayTimeout == null) {
33
+ const diff = (delay - seconds) * 1000;
34
+ this.delayTimeout = setTimeout(() => {
35
+ this.delayTimeout = null;
36
+ this.Call();
37
+ }, diff + 0.02);
38
+ }
39
+ }
40
+ }
41
+ doCall(endDate) {
42
+ if (this.delayTimeout != null) {
43
+ clearTimeout(this.delayTimeout);
44
+ this.delayTimeout = null;
45
+ }
46
+ this.lastCallTime = endDate;
47
+ this.callback();
48
+ }
49
+ Dispose() {
50
+ if (this.delayTimeout != null) {
51
+ clearTimeout(this.delayTimeout);
52
+ this.delayTimeout = null;
53
+ }
54
+ }
55
+ }
56
+ exports.DelayQueue = DelayQueue;
57
57
  //# sourceMappingURL=delay-queue.js.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=dictionary.js.map