bruce-models 0.7.1 → 0.7.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.
Files changed (94) hide show
  1. package/dist/bruce-models.es5.js +182 -137
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +179 -129
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account.js +244 -244
  6. package/dist/lib/ann-document/ann-document.js +116 -116
  7. package/dist/lib/api/abstract-api.js +267 -267
  8. package/dist/lib/api/api.js +85 -85
  9. package/dist/lib/api/api.js.map +1 -1
  10. package/dist/lib/api/bruce-api.js +202 -202
  11. package/dist/lib/api/cam-api.js +132 -132
  12. package/dist/lib/api/global-api.js +131 -131
  13. package/dist/lib/api/idm-api.js +132 -132
  14. package/dist/lib/bruce-models.js +83 -83
  15. package/dist/lib/bruce-models.js.map +1 -1
  16. package/dist/lib/calculator/calculator.js +158 -158
  17. package/dist/lib/client-file/client-file.js +188 -188
  18. package/dist/lib/common/bounds.js +2 -2
  19. package/dist/lib/common/bruce-event.js +48 -48
  20. package/dist/lib/common/bruce-variable.js +54 -54
  21. package/dist/lib/common/cache.js +86 -86
  22. package/dist/lib/common/camera.js +11 -11
  23. package/dist/lib/common/cartes.js +55 -55
  24. package/dist/lib/common/carto.js +60 -60
  25. package/dist/lib/common/color.js +86 -86
  26. package/dist/lib/common/delay-queue.js +60 -60
  27. package/dist/lib/common/dictionary.js +2 -2
  28. package/dist/lib/common/geometry.js +120 -120
  29. package/dist/lib/common/transform.js +2 -2
  30. package/dist/lib/common/utc.js +39 -39
  31. package/dist/lib/custom-form/custom-form.js +136 -136
  32. package/dist/lib/data-lab/data-lab.js +90 -90
  33. package/dist/lib/entity/entity-attachment-type.js +132 -132
  34. package/dist/lib/entity/entity-attachment.js +208 -208
  35. package/dist/lib/entity/entity-comment.js +132 -132
  36. package/dist/lib/entity/entity-coords.js +182 -0
  37. package/dist/lib/entity/entity-coords.js.map +1 -0
  38. package/dist/lib/entity/entity-link.js +132 -132
  39. package/dist/lib/entity/entity-lod.js +189 -189
  40. package/dist/lib/entity/entity-relation-type.js +150 -150
  41. package/dist/lib/entity/entity-relation.js +189 -189
  42. package/dist/lib/entity/entity-source.js +176 -176
  43. package/dist/lib/entity/entity-tag.js +229 -229
  44. package/dist/lib/entity/entity-type.js +163 -163
  45. package/dist/lib/entity/entity-type.js.map +1 -1
  46. package/dist/lib/entity/entity.js +349 -349
  47. package/dist/lib/entity/entity.js.map +1 -1
  48. package/dist/lib/entity/getters/batched-data-getter.js +91 -91
  49. package/dist/lib/entity/getters/entity-filter-getter.js +344 -344
  50. package/dist/lib/entity/getters/entity-globe.js +135 -135
  51. package/dist/lib/entity/getters/view-monitor.js +2 -2
  52. package/dist/lib/import/import-cad.js +82 -82
  53. package/dist/lib/import/import-csv.js +51 -51
  54. package/dist/lib/import/import-json.js +51 -51
  55. package/dist/lib/import/import-kml.js +51 -51
  56. package/dist/lib/import/imported-file.js +121 -121
  57. package/dist/lib/markup/markup.js +40 -40
  58. package/dist/lib/program-key/program-key.js +152 -152
  59. package/dist/lib/project/menu-item.js +115 -115
  60. package/dist/lib/project/project-view-bookmark.js +172 -172
  61. package/dist/lib/project/project-view-tile-source.js +115 -115
  62. package/dist/lib/project/project-view.js +166 -166
  63. package/dist/lib/project/zoom-control.js +17 -17
  64. package/dist/lib/server/pending-action.js +106 -106
  65. package/dist/lib/server/task.js +113 -113
  66. package/dist/lib/style/style.js +152 -152
  67. package/dist/lib/tileset/tileset-cad.js +2 -2
  68. package/dist/lib/tileset/tileset-entities-map-tiles.js +18 -18
  69. package/dist/lib/tileset/tileset-entities.js +2 -2
  70. package/dist/lib/tileset/tileset-ext-map-tiles.js +17 -17
  71. package/dist/lib/tileset/tileset-ext-terrain-tiles.js +2 -2
  72. package/dist/lib/tileset/tileset-map-tiles.js +2 -2
  73. package/dist/lib/tileset/tileset-pointcloud.js +2 -2
  74. package/dist/lib/tileset/tileset-terrain-tiles.js +2 -2
  75. package/dist/lib/tileset/tileset.js +403 -403
  76. package/dist/lib/user/permission.js +20 -20
  77. package/dist/lib/user/session.js +160 -160
  78. package/dist/lib/user/user-group.js +139 -139
  79. package/dist/lib/user/user.js +451 -451
  80. package/dist/lib/util/encrypt-utils.js +20 -20
  81. package/dist/lib/util/math-utils.js +41 -41
  82. package/dist/lib/util/object-utils.js +17 -17
  83. package/dist/lib/util/path-utils.js +61 -61
  84. package/dist/lib/util/url-utils.js +107 -107
  85. package/dist/types/api/api.d.ts +1 -1
  86. package/dist/types/bruce-models.d.ts +1 -1
  87. package/dist/types/common/transform.d.ts +3 -0
  88. package/dist/types/entity/entity-coords.d.ts +37 -0
  89. package/dist/types/entity/entity-type.d.ts +1 -0
  90. package/dist/types/entity/entity.d.ts +1 -1
  91. package/package.json +1 -1
  92. package/dist/lib/ucs/ucs.js +0 -136
  93. package/dist/lib/ucs/ucs.js.map +0 -1
  94. package/dist/types/ucs/ucs.d.ts +0 -30
@@ -1,189 +1,189 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ClientFile = void 0;
40
- var api_1 = require("../api/api");
41
- /**
42
- * Describes the "Client File" concept within Bruce.
43
- * A client file is a record of a file uploaded to Bruce.
44
- */
45
- var ClientFile;
46
- (function (ClientFile) {
47
- function GetCacheKey(fileId) {
48
- return "" + api_1.Api.ECacheKey.ClientFile + api_1.Api.ECacheKey.Id + fileId;
49
- }
50
- ClientFile.GetCacheKey = GetCacheKey;
51
- function GetUrl(api, fileId) {
52
- return api.GetBaseUrl() + "/file/" + fileId;
53
- }
54
- ClientFile.GetUrl = GetUrl;
55
- function GetUrlWithExt(api, file) {
56
- return api.GetBaseUrl() + "/file/" + file.ID + (file.FileExt ? file.FileExt : "");
57
- }
58
- ClientFile.GetUrlWithExt = GetUrlWithExt;
59
- function Get(api, fileId) {
60
- return __awaiter(this, void 0, void 0, function () {
61
- var key, cacheData, req;
62
- return __generator(this, function (_a) {
63
- if (!fileId) {
64
- throw ("File ID is required.");
65
- }
66
- key = GetCacheKey(fileId);
67
- cacheData = api.Cache.Get(key);
68
- if (cacheData) {
69
- return [2 /*return*/, cacheData];
70
- }
71
- req = api.GET("file/" + fileId + "/details", api_1.Api.PrepReqParams());
72
- api.Cache.Set(key, req, api_1.Api.DEFAULT_CACHE_DURATION);
73
- return [2 /*return*/, req];
74
- });
75
- });
76
- }
77
- ClientFile.Get = Get;
78
- function Delete(api, fileIds) {
79
- return __awaiter(this, void 0, void 0, function () {
80
- var data, i, key;
81
- return __generator(this, function (_a) {
82
- switch (_a.label) {
83
- case 0:
84
- if (!fileIds.length) {
85
- throw ("File IDs are required.");
86
- }
87
- data = {
88
- Items: fileIds
89
- };
90
- return [4 /*yield*/, api.POST("deleteFiles", data, api_1.Api.PrepReqParams())];
91
- case 1:
92
- _a.sent();
93
- for (i = 0; i < fileIds.length; i++) {
94
- key = GetCacheKey(fileIds[i]);
95
- api.Cache.Remove(key);
96
- }
97
- return [2 /*return*/];
98
- }
99
- });
100
- });
101
- }
102
- ClientFile.Delete = Delete;
103
- function Upload(api, file, purpose, onProgress) {
104
- return __awaiter(this, void 0, void 0, function () {
105
- var formData, params;
106
- return __generator(this, function (_a) {
107
- if (!file) {
108
- throw ("File is required.");
109
- }
110
- formData = null;
111
- if (purpose) {
112
- formData = {
113
- "Purpose": purpose
114
- };
115
- }
116
- params = api_1.Api.PrepReqParams();
117
- params.onProgress = onProgress;
118
- params.formData = formData;
119
- return [2 /*return*/, api.UPLOAD("file/uploadNew", file, params)];
120
- });
121
- });
122
- }
123
- ClientFile.Upload = Upload;
124
- var Filter;
125
- (function (Filter) {
126
- var V1;
127
- (function (V1) {
128
- var EColumn;
129
- (function (EColumn) {
130
- EColumn["ID"] = "id";
131
- EColumn["Name"] = "name";
132
- EColumn["DateTime"] = "datetime";
133
- EColumn["MIMEType"] = "mimeType";
134
- EColumn["Size"] = "size";
135
- EColumn["User"] = "user";
136
- EColumn["Extension"] = "extension";
137
- })(EColumn = V1.EColumn || (V1.EColumn = {}));
138
- var ESortOrder;
139
- (function (ESortOrder) {
140
- ESortOrder["ASC"] = "asc";
141
- ESortOrder["DEC"] = "desc";
142
- })(ESortOrder = V1.ESortOrder || (V1.ESortOrder = {}));
143
- var ERowOperator;
144
- (function (ERowOperator) {
145
- ERowOperator["AND"] = "AND";
146
- ERowOperator["OR"] = "OR";
147
- })(ERowOperator = V1.ERowOperator || (V1.ERowOperator = {}));
148
- function GetList(api, filter) {
149
- return __awaiter(this, void 0, void 0, function () {
150
- var data;
151
- return __generator(this, function (_a) {
152
- switch (_a.label) {
153
- case 0: return [4 /*yield*/, api.POST("files/filtered", filter, api_1.Api.PrepReqParams())];
154
- case 1:
155
- data = _a.sent();
156
- return [2 /*return*/, data.Items];
157
- }
158
- });
159
- });
160
- }
161
- V1.GetList = GetList;
162
- })(V1 = Filter.V1 || (Filter.V1 = {}));
163
- // TODO: Helpers for constructing the filter.
164
- })(Filter = ClientFile.Filter || (ClientFile.Filter = {}));
165
- var Processor;
166
- (function (Processor) {
167
- var EConvertExt;
168
- (function (EConvertExt) {
169
- EConvertExt["GLB"] = ".glb";
170
- EConvertExt["SKP"] = ".skp";
171
- })(EConvertExt = Processor.EConvertExt || (Processor.EConvertExt = {}));
172
- function ConvertFormat(api, clientFileId, ext) {
173
- return __awaiter(this, void 0, void 0, function () {
174
- return __generator(this, function (_a) {
175
- if (!clientFileId || !ext) {
176
- throw ("Client File ID and extension are required.");
177
- }
178
- return [2 /*return*/, api.POST("convertFileToFile", {
179
- clientFileId: clientFileId,
180
- destinationFormat: ext,
181
- operations: []
182
- })];
183
- });
184
- });
185
- }
186
- Processor.ConvertFormat = ConvertFormat;
187
- })(Processor = ClientFile.Processor || (ClientFile.Processor = {}));
188
- })(ClientFile = exports.ClientFile || (exports.ClientFile = {}));
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ClientFile = void 0;
40
+ var api_1 = require("../api/api");
41
+ /**
42
+ * Describes the "Client File" concept within Bruce.
43
+ * A client file is a record of a file uploaded to Bruce.
44
+ */
45
+ var ClientFile;
46
+ (function (ClientFile) {
47
+ function GetCacheKey(fileId) {
48
+ return "" + api_1.Api.ECacheKey.ClientFile + api_1.Api.ECacheKey.Id + fileId;
49
+ }
50
+ ClientFile.GetCacheKey = GetCacheKey;
51
+ function GetUrl(api, fileId) {
52
+ return api.GetBaseUrl() + "/file/" + fileId;
53
+ }
54
+ ClientFile.GetUrl = GetUrl;
55
+ function GetUrlWithExt(api, file) {
56
+ return api.GetBaseUrl() + "/file/" + file.ID + (file.FileExt ? file.FileExt : "");
57
+ }
58
+ ClientFile.GetUrlWithExt = GetUrlWithExt;
59
+ function Get(api, fileId) {
60
+ return __awaiter(this, void 0, void 0, function () {
61
+ var key, cacheData, req;
62
+ return __generator(this, function (_a) {
63
+ if (!fileId) {
64
+ throw ("File ID is required.");
65
+ }
66
+ key = GetCacheKey(fileId);
67
+ cacheData = api.Cache.Get(key);
68
+ if (cacheData) {
69
+ return [2 /*return*/, cacheData];
70
+ }
71
+ req = api.GET("file/" + fileId + "/details", api_1.Api.PrepReqParams());
72
+ api.Cache.Set(key, req, api_1.Api.DEFAULT_CACHE_DURATION);
73
+ return [2 /*return*/, req];
74
+ });
75
+ });
76
+ }
77
+ ClientFile.Get = Get;
78
+ function Delete(api, fileIds) {
79
+ return __awaiter(this, void 0, void 0, function () {
80
+ var data, i, key;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0:
84
+ if (!fileIds.length) {
85
+ throw ("File IDs are required.");
86
+ }
87
+ data = {
88
+ Items: fileIds
89
+ };
90
+ return [4 /*yield*/, api.POST("deleteFiles", data, api_1.Api.PrepReqParams())];
91
+ case 1:
92
+ _a.sent();
93
+ for (i = 0; i < fileIds.length; i++) {
94
+ key = GetCacheKey(fileIds[i]);
95
+ api.Cache.Remove(key);
96
+ }
97
+ return [2 /*return*/];
98
+ }
99
+ });
100
+ });
101
+ }
102
+ ClientFile.Delete = Delete;
103
+ function Upload(api, file, purpose, onProgress) {
104
+ return __awaiter(this, void 0, void 0, function () {
105
+ var formData, params;
106
+ return __generator(this, function (_a) {
107
+ if (!file) {
108
+ throw ("File is required.");
109
+ }
110
+ formData = null;
111
+ if (purpose) {
112
+ formData = {
113
+ "Purpose": purpose
114
+ };
115
+ }
116
+ params = api_1.Api.PrepReqParams();
117
+ params.onProgress = onProgress;
118
+ params.formData = formData;
119
+ return [2 /*return*/, api.UPLOAD("file/uploadNew", file, params)];
120
+ });
121
+ });
122
+ }
123
+ ClientFile.Upload = Upload;
124
+ var Filter;
125
+ (function (Filter) {
126
+ var V1;
127
+ (function (V1) {
128
+ var EColumn;
129
+ (function (EColumn) {
130
+ EColumn["ID"] = "id";
131
+ EColumn["Name"] = "name";
132
+ EColumn["DateTime"] = "datetime";
133
+ EColumn["MIMEType"] = "mimeType";
134
+ EColumn["Size"] = "size";
135
+ EColumn["User"] = "user";
136
+ EColumn["Extension"] = "extension";
137
+ })(EColumn = V1.EColumn || (V1.EColumn = {}));
138
+ var ESortOrder;
139
+ (function (ESortOrder) {
140
+ ESortOrder["ASC"] = "asc";
141
+ ESortOrder["DEC"] = "desc";
142
+ })(ESortOrder = V1.ESortOrder || (V1.ESortOrder = {}));
143
+ var ERowOperator;
144
+ (function (ERowOperator) {
145
+ ERowOperator["AND"] = "AND";
146
+ ERowOperator["OR"] = "OR";
147
+ })(ERowOperator = V1.ERowOperator || (V1.ERowOperator = {}));
148
+ function GetList(api, filter) {
149
+ return __awaiter(this, void 0, void 0, function () {
150
+ var data;
151
+ return __generator(this, function (_a) {
152
+ switch (_a.label) {
153
+ case 0: return [4 /*yield*/, api.POST("files/filtered", filter, api_1.Api.PrepReqParams())];
154
+ case 1:
155
+ data = _a.sent();
156
+ return [2 /*return*/, data.Items];
157
+ }
158
+ });
159
+ });
160
+ }
161
+ V1.GetList = GetList;
162
+ })(V1 = Filter.V1 || (Filter.V1 = {}));
163
+ // TODO: Helpers for constructing the filter.
164
+ })(Filter = ClientFile.Filter || (ClientFile.Filter = {}));
165
+ var Processor;
166
+ (function (Processor) {
167
+ var EConvertExt;
168
+ (function (EConvertExt) {
169
+ EConvertExt["GLB"] = ".glb";
170
+ EConvertExt["SKP"] = ".skp";
171
+ })(EConvertExt = Processor.EConvertExt || (Processor.EConvertExt = {}));
172
+ function ConvertFormat(api, clientFileId, ext) {
173
+ return __awaiter(this, void 0, void 0, function () {
174
+ return __generator(this, function (_a) {
175
+ if (!clientFileId || !ext) {
176
+ throw ("Client File ID and extension are required.");
177
+ }
178
+ return [2 /*return*/, api.POST("convertFileToFile", {
179
+ clientFileId: clientFileId,
180
+ destinationFormat: ext,
181
+ operations: []
182
+ })];
183
+ });
184
+ });
185
+ }
186
+ Processor.ConvertFormat = ConvertFormat;
187
+ })(Processor = ClientFile.Processor || (ClientFile.Processor = {}));
188
+ })(ClientFile = exports.ClientFile || (exports.ClientFile = {}));
189
189
  //# sourceMappingURL=client-file.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=bounds.js.map
@@ -1,49 +1,49 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BruceEvent = void 0;
4
- /**
5
- * Simple event utility.
6
- * Instantiate the model, then subscribe and trigger events.
7
- */
8
- var BruceEvent = /** @class */ (function () {
9
- function BruceEvent() {
10
- // Counter to help differentiate subscriptions.
11
- this._counter = 0;
12
- // Record of all callback subscriptions for this event.
13
- this.callbacks = [];
14
- }
15
- BruceEvent.prototype.Subscribe = function (callback) {
16
- var _this = this;
17
- var id = this._counter++;
18
- var newBruceEventCallback = {
19
- _id: id,
20
- removeCallback: function () {
21
- _this.Unsubscribe(id);
22
- },
23
- callback: callback
24
- };
25
- this.callbacks.push(newBruceEventCallback);
26
- return newBruceEventCallback.removeCallback;
27
- };
28
- BruceEvent.prototype.Unsubscribe = function (id) {
29
- var index = this.callbacks.findIndex(function (x) { return x._id == id; });
30
- if (index > -1) {
31
- this.callbacks.splice(index, 1);
32
- }
33
- };
34
- BruceEvent.prototype.Trigger = function (data) {
35
- var callbacks = this.callbacks;
36
- for (var i = 0; i < callbacks.length; i++) {
37
- var callback = callbacks[i];
38
- if (callback.callback) {
39
- callback.callback(data);
40
- }
41
- }
42
- };
43
- BruceEvent.prototype.Clear = function () {
44
- this.callbacks = [];
45
- };
46
- return BruceEvent;
47
- }());
48
- exports.BruceEvent = BruceEvent;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BruceEvent = void 0;
4
+ /**
5
+ * Simple event utility.
6
+ * Instantiate the model, then subscribe and trigger events.
7
+ */
8
+ var BruceEvent = /** @class */ (function () {
9
+ function BruceEvent() {
10
+ // Counter to help differentiate subscriptions.
11
+ this._counter = 0;
12
+ // Record of all callback subscriptions for this event.
13
+ this.callbacks = [];
14
+ }
15
+ BruceEvent.prototype.Subscribe = function (callback) {
16
+ var _this = this;
17
+ var id = this._counter++;
18
+ var newBruceEventCallback = {
19
+ _id: id,
20
+ removeCallback: function () {
21
+ _this.Unsubscribe(id);
22
+ },
23
+ callback: callback
24
+ };
25
+ this.callbacks.push(newBruceEventCallback);
26
+ return newBruceEventCallback.removeCallback;
27
+ };
28
+ BruceEvent.prototype.Unsubscribe = function (id) {
29
+ var index = this.callbacks.findIndex(function (x) { return x._id == id; });
30
+ if (index > -1) {
31
+ this.callbacks.splice(index, 1);
32
+ }
33
+ };
34
+ BruceEvent.prototype.Trigger = function (data) {
35
+ var callbacks = this.callbacks;
36
+ for (var i = 0; i < callbacks.length; i++) {
37
+ var callback = callbacks[i];
38
+ if (callback.callback) {
39
+ callback.callback(data);
40
+ }
41
+ }
42
+ };
43
+ BruceEvent.prototype.Clear = function () {
44
+ this.callbacks = [];
45
+ };
46
+ return BruceEvent;
47
+ }());
48
+ exports.BruceEvent = BruceEvent;
49
49
  //# sourceMappingURL=bruce-event.js.map
@@ -1,55 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BruceVariable = void 0;
4
- var entity_1 = require("../entity/entity");
5
- var path_utils_1 = require("../util/path-utils");
6
- function getVariable(str) {
7
- var start = str.indexOf("${");
8
- if (start > -1) {
9
- var end = str.indexOf("}");
10
- if (end > -1) {
11
- if (start < end) {
12
- return { path: str.substring(start + 2, end), text: str.substring(start, end) };
13
- }
14
- }
15
- }
16
- return null;
17
- }
18
- /**
19
- * Utilities for parsing "Bruce variables", typically within strings.
20
- *
21
- * A Bruce variable is a string that starts with "${" and ends with "}".
22
- * Within those brackets is a path to an attribute in an entity.
23
- */
24
- var BruceVariable;
25
- (function (BruceVariable) {
26
- /**
27
- * Replaces all Bruce variables in a string with the value of the attribute.
28
- * @param str
29
- * @param data
30
- * @param legacyParse
31
- * @returns
32
- */
33
- function SwapValues(str, data, legacyParse) {
34
- if (!legacyParse) {
35
- legacyParse = false;
36
- }
37
- while (true) {
38
- var variable = getVariable(str);
39
- if (variable) {
40
- var path = legacyParse ? path_utils_1.PathUtils.ParseLegacy(variable.path) : path_utils_1.PathUtils.Parse(variable.path);
41
- var value = "";
42
- if (path.length > 0) {
43
- value = entity_1.Entity.GetValue(data, path);
44
- }
45
- str = str.replace(variable.text, value);
46
- }
47
- else {
48
- break;
49
- }
50
- }
51
- return str;
52
- }
53
- BruceVariable.SwapValues = SwapValues;
54
- })(BruceVariable = exports.BruceVariable || (exports.BruceVariable = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BruceVariable = void 0;
4
+ var entity_1 = require("../entity/entity");
5
+ var path_utils_1 = require("../util/path-utils");
6
+ function getVariable(str) {
7
+ var start = str.indexOf("${");
8
+ if (start > -1) {
9
+ var end = str.indexOf("}");
10
+ if (end > -1) {
11
+ if (start < end) {
12
+ return { path: str.substring(start + 2, end), text: str.substring(start, end) };
13
+ }
14
+ }
15
+ }
16
+ return null;
17
+ }
18
+ /**
19
+ * Utilities for parsing "Bruce variables", typically within strings.
20
+ *
21
+ * A Bruce variable is a string that starts with "${" and ends with "}".
22
+ * Within those brackets is a path to an attribute in an entity.
23
+ */
24
+ var BruceVariable;
25
+ (function (BruceVariable) {
26
+ /**
27
+ * Replaces all Bruce variables in a string with the value of the attribute.
28
+ * @param str
29
+ * @param data
30
+ * @param legacyParse
31
+ * @returns
32
+ */
33
+ function SwapValues(str, data, legacyParse) {
34
+ if (!legacyParse) {
35
+ legacyParse = false;
36
+ }
37
+ while (true) {
38
+ var variable = getVariable(str);
39
+ if (variable) {
40
+ var path = legacyParse ? path_utils_1.PathUtils.ParseLegacy(variable.path) : path_utils_1.PathUtils.Parse(variable.path);
41
+ var value = "";
42
+ if (path.length > 0) {
43
+ value = entity_1.Entity.GetValue(data, path);
44
+ }
45
+ str = str.replace(variable.text, value);
46
+ }
47
+ else {
48
+ break;
49
+ }
50
+ }
51
+ return str;
52
+ }
53
+ BruceVariable.SwapValues = SwapValues;
54
+ })(BruceVariable = exports.BruceVariable || (exports.BruceVariable = {}));
55
55
  //# sourceMappingURL=bruce-variable.js.map