@openremote/core 1.0.3 → 1.2.0-snapshot.20240512154942
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist → lib}/asset-mixin.d.ts +2 -0
- package/lib/asset-mixin.js +1 -0
- package/lib/asset-mixin.js.map +1 -0
- package/{dist → lib}/console.d.ts +14 -5
- package/lib/console.js +1 -0
- package/lib/console.js.map +1 -0
- package/lib/defaults.js +1 -0
- package/lib/defaults.js.map +1 -0
- package/{dist → lib}/event.d.ts +20 -19
- package/lib/event.js +1 -0
- package/lib/event.js.map +1 -0
- package/lib/index.d.ts +150 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/util.d.ts +92 -0
- package/lib/util.js +1 -0
- package/lib/util.js.map +1 -0
- package/package.json +24 -25
- package/.project +0 -17
- package/.settings/org.eclipse.buildship.core.prefs +0 -2
- package/@types/i18next-sprintf-postprocessor.d.ts +0 -1
- package/dist/asset-mixin.js +0 -156
- package/dist/console.js +0 -452
- package/dist/defaults.js +0 -16
- package/dist/event.js +0 -567
- package/dist/index.d.ts +0 -224
- package/dist/index.js +0 -996
- package/dist/mdi-icons.json +0 -1
- package/dist/or-icon-set.d.ts +0 -3
- package/dist/or-icon-set.js +0 -10
- package/dist/umd/index.bundle.js +0 -273
- package/dist/umd/index.js +0 -7
- package/dist/umd/index.orbundle.js +0 -280
- package/dist/util.d.ts +0 -41
- package/dist/util.js +0 -362
- package/mdi-iconset-generator.js +0 -34
- package/tsconfig.json +0 -16
- package/typedoc.js +0 -3
- package/webpack.config.js +0 -16
- /package/{dist → lib}/defaults.d.ts +0 -0
package/dist/util.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { GeofencePredicate, JsonRulesetDefinition, PushNotificationMessage, Asset, Attribute, AttributeEvent, MetaItem, AssetAttribute, AttributeDescriptor, MetaItemDescriptor, AttributeValueDescriptor } from "@openremote/model";
|
|
2
|
-
export declare class Deferred<T> {
|
|
3
|
-
protected _resolve: (value?: T | PromiseLike<T>) => void;
|
|
4
|
-
protected _reject: (reason?: any) => void;
|
|
5
|
-
protected _promise: Promise<T>;
|
|
6
|
-
get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
|
|
7
|
-
get reject(): (reason?: any) => void;
|
|
8
|
-
get promise(): Promise<T>;
|
|
9
|
-
constructor();
|
|
10
|
-
}
|
|
11
|
-
export interface GeoNotification {
|
|
12
|
-
predicate: GeofencePredicate;
|
|
13
|
-
notification?: PushNotificationMessage;
|
|
14
|
-
}
|
|
15
|
-
export declare function getQueryParameters(queryStr: string): any;
|
|
16
|
-
export declare function getQueryParameter(queryStr: string, parameter: string): any | undefined;
|
|
17
|
-
export declare function getGeoNotificationsFromRulesSet(rulesetDefinition: JsonRulesetDefinition): GeoNotification[];
|
|
18
|
-
export declare function isTimeDuration(time?: string): boolean;
|
|
19
|
-
export declare function isTimeDurationPositiveInfinity(time?: string): boolean;
|
|
20
|
-
export declare function isTimeDurationNegativeInfinity(time?: string): boolean;
|
|
21
|
-
export declare function isObject(object: any): boolean;
|
|
22
|
-
export declare function objectsEqual(obj1?: any, obj2?: any, deep?: boolean): boolean;
|
|
23
|
-
export declare function arrayRemove<T>(arr: T[], item: T): void;
|
|
24
|
-
export declare function enumContains(enm: object, val: string): boolean;
|
|
25
|
-
export declare function getEnumKeyAsString(enm: object, val: string): string;
|
|
26
|
-
export declare function getAssetAttribute(asset: Asset, attributeName: string): AssetAttribute | undefined;
|
|
27
|
-
export declare function getAssetAttributes(asset: Asset, exclude?: string[]): AssetAttribute[];
|
|
28
|
-
export declare function getFirstMetaItem(attribute: Attribute | undefined, name: string): MetaItem | undefined;
|
|
29
|
-
export declare function hasMetaItem(attribute: Attribute, name: string): boolean;
|
|
30
|
-
export declare function getMetaValue(metaItemUrn: string | MetaItemDescriptor, attribute: Attribute | undefined, descriptor: AttributeDescriptor | undefined, valueDescriptor?: AttributeValueDescriptor): any;
|
|
31
|
-
export declare function getAttributeLabel(attribute: Attribute | undefined, descriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined, showUnits: boolean, fallback?: string): string;
|
|
32
|
-
export declare function getMetaItemLabel(urn: string): string;
|
|
33
|
-
export declare function getAttributeValueFormat(attribute: Attribute | undefined, descriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined): string | undefined;
|
|
34
|
-
export declare function getAttributeValueFormatter(): ((value: any, format: string | undefined) => string);
|
|
35
|
-
export declare function getAttributeValueFormatted(attribute: Attribute, descriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined, fallback?: string): any;
|
|
36
|
-
/**
|
|
37
|
-
* Immutable update of an asset using the supplied attribute event
|
|
38
|
-
*/
|
|
39
|
-
export declare function updateAsset(asset: Asset, event: AttributeEvent): Asset;
|
|
40
|
-
export declare function loadJs(url: string): Promise<unknown>;
|
|
41
|
-
export declare function sortByString<T>(valueExtractor: (item: T) => string): (a: T, b: T) => number;
|
package/dist/util.js
DELETED
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import { MetaItemType } from "@openremote/model";
|
|
2
|
-
import i18next from "i18next";
|
|
3
|
-
import Qs from "qs";
|
|
4
|
-
import { AssetModelUtil } from "./index";
|
|
5
|
-
export class Deferred {
|
|
6
|
-
constructor() {
|
|
7
|
-
this._promise = new Promise((resolve1, reject1) => {
|
|
8
|
-
this._resolve = resolve1;
|
|
9
|
-
this._reject = reject1;
|
|
10
|
-
});
|
|
11
|
-
Object.freeze(this);
|
|
12
|
-
}
|
|
13
|
-
get resolve() {
|
|
14
|
-
return this._resolve;
|
|
15
|
-
}
|
|
16
|
-
get reject() {
|
|
17
|
-
return this._reject;
|
|
18
|
-
}
|
|
19
|
-
get promise() {
|
|
20
|
-
return this._promise;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export function getQueryParameters(queryStr) {
|
|
24
|
-
const parsed = Qs.parse(queryStr, { ignoreQueryPrefix: true });
|
|
25
|
-
return parsed;
|
|
26
|
-
}
|
|
27
|
-
export function getQueryParameter(queryStr, parameter) {
|
|
28
|
-
const parsed = getQueryParameters(queryStr);
|
|
29
|
-
return parsed ? parsed[parameter] : undefined;
|
|
30
|
-
}
|
|
31
|
-
export function getGeoNotificationsFromRulesSet(rulesetDefinition) {
|
|
32
|
-
const geoNotifications = [];
|
|
33
|
-
rulesetDefinition.rules.forEach((rule) => {
|
|
34
|
-
if (rule.when && rule.then && rule.then.length > 0) {
|
|
35
|
-
const geoNotificationMap = new Map();
|
|
36
|
-
addGeofencePredicatesFromRuleConditionCondition(rule.when, 0, geoNotificationMap);
|
|
37
|
-
if (geoNotificationMap.size > 0) {
|
|
38
|
-
rule.then.forEach((ruleAction) => addPushNotificationsFromRuleAction(ruleAction, geoNotificationMap));
|
|
39
|
-
}
|
|
40
|
-
for (const geoNotificationsArr of geoNotificationMap.values()) {
|
|
41
|
-
geoNotificationsArr.forEach((geoNotification) => {
|
|
42
|
-
if (geoNotification.notification) {
|
|
43
|
-
geoNotifications.push(geoNotification);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return geoNotifications;
|
|
50
|
-
}
|
|
51
|
-
function addGeofencePredicatesFromRuleConditionCondition(ruleCondition, index, geoNotificationMap) {
|
|
52
|
-
if (!ruleCondition) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const items = [];
|
|
56
|
-
if (ruleCondition.groups) {
|
|
57
|
-
ruleCondition.groups.forEach((ruleGroup) => {
|
|
58
|
-
if (ruleGroup.items) {
|
|
59
|
-
ruleGroup.items.forEach((ruleTrigger) => {
|
|
60
|
-
items.push(ruleTrigger);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (ruleCondition.items) {
|
|
66
|
-
ruleCondition.items.forEach((ruleTrigger) => {
|
|
67
|
-
items.push(ruleTrigger);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (items) {
|
|
71
|
-
items.forEach((ruleTrigger) => {
|
|
72
|
-
if (ruleTrigger.assets && ruleTrigger.assets.attributes) {
|
|
73
|
-
const geoNotifications = [];
|
|
74
|
-
addGeoNotificationsFromAttributePredicateCondition(ruleTrigger.assets.attributes, geoNotifications);
|
|
75
|
-
if (geoNotifications.length > 0) {
|
|
76
|
-
const tagName = ruleTrigger.tag || index.toString();
|
|
77
|
-
geoNotificationMap.set(tagName, geoNotifications);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function addGeoNotificationsFromAttributePredicateCondition(attributeCondition, geoNotifications) {
|
|
84
|
-
if (!attributeCondition) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
attributeCondition.items.forEach((predicate) => {
|
|
88
|
-
if (predicate.value && (predicate.value.predicateType === "radial" || predicate.value.predicateType === "rect")) {
|
|
89
|
-
geoNotifications.push({
|
|
90
|
-
predicate: predicate.value
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
if (attributeCondition.groups) {
|
|
95
|
-
attributeCondition.groups.forEach((condition) => addGeoNotificationsFromAttributePredicateCondition(condition, geoNotifications));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function addPushNotificationsFromRuleAction(ruleAction, geoPredicateMap) {
|
|
99
|
-
if (ruleAction && ruleAction.action === "notification") {
|
|
100
|
-
if (ruleAction.notification && ruleAction.notification.message && ruleAction.notification.message.type === "push") {
|
|
101
|
-
// Find applicable targets
|
|
102
|
-
const target = ruleAction.target;
|
|
103
|
-
if (target && target.ruleConditionTag) {
|
|
104
|
-
const geoNotifications = geoPredicateMap.get(target.ruleConditionTag);
|
|
105
|
-
if (geoNotifications) {
|
|
106
|
-
geoNotifications.forEach((geoNotification) => {
|
|
107
|
-
geoNotification.notification = ruleAction.notification.message;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// Applies to all LHS rule triggers
|
|
113
|
-
for (const geoNotifications of geoPredicateMap.values()) {
|
|
114
|
-
geoNotifications.forEach((geoNotification) => {
|
|
115
|
-
geoNotification.notification = ruleAction.notification.message;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const TIME_DURATION_REGEXP = /([+-])?((\d+)[Dd])?\s*((\d+)[Hh])?\s*((\d+)[Mm]$)?\s*((\d+)[Ss])?\s*((\d+)([Mm][Ss]$))?\s*((\d+)[Ww])?\s*((\d+)[Mm][Nn])?\s*((\d+)[Yy])?/;
|
|
123
|
-
export function isTimeDuration(time) {
|
|
124
|
-
if (!time) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
time = time.trim();
|
|
128
|
-
return time.length > 0
|
|
129
|
-
&& (TIME_DURATION_REGEXP.test(time)
|
|
130
|
-
|| isTimeDurationPositiveInfinity(time)
|
|
131
|
-
|| isTimeDurationNegativeInfinity(time));
|
|
132
|
-
}
|
|
133
|
-
export function isTimeDurationPositiveInfinity(time) {
|
|
134
|
-
time = time != null ? time.trim() : undefined;
|
|
135
|
-
return "*" === time || "+*" === time;
|
|
136
|
-
}
|
|
137
|
-
export function isTimeDurationNegativeInfinity(time) {
|
|
138
|
-
time = time != null ? time.trim() : undefined;
|
|
139
|
-
return "-*" === time;
|
|
140
|
-
}
|
|
141
|
-
export function isObject(object) {
|
|
142
|
-
if (!!object) {
|
|
143
|
-
return typeof object === "object";
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
export function objectsEqual(obj1, obj2, deep = true) {
|
|
148
|
-
if (obj1 === null || obj1 === undefined || obj2 === null || obj2 === undefined) {
|
|
149
|
-
return obj1 === obj2;
|
|
150
|
-
}
|
|
151
|
-
// after this just checking type of one would be enough
|
|
152
|
-
if (obj1.constructor !== obj2.constructor) {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
// if they are functions, they should exactly refer to same one (because of closures)
|
|
156
|
-
if (obj1 instanceof Function) {
|
|
157
|
-
return obj1 === obj2;
|
|
158
|
-
}
|
|
159
|
-
// if they are regexps, they should exactly refer to same one (it is hard to better equality check on current ES)
|
|
160
|
-
if (obj1 instanceof RegExp) {
|
|
161
|
-
return obj1 === obj2;
|
|
162
|
-
}
|
|
163
|
-
if (obj1 === obj2 || obj1.valueOf() === obj2.valueOf()) {
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
if (Array.isArray(obj1) && obj1.length !== obj2.length) {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
// if they are dates, they must had equal valueOf
|
|
170
|
-
if (obj1 instanceof Date) {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
// if they are strictly equal, they both need to be object at least
|
|
174
|
-
if (!(obj1 instanceof Object)) {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
if (!(obj2 instanceof Object)) {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
if (deep) {
|
|
181
|
-
// recursive object equality check
|
|
182
|
-
const p = Object.keys(obj1);
|
|
183
|
-
return Object.keys(obj2).every((i) => {
|
|
184
|
-
return p.indexOf(i) !== -1;
|
|
185
|
-
}) &&
|
|
186
|
-
p.every((i) => {
|
|
187
|
-
return objectsEqual(obj1[i], obj2[i]);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
export function arrayRemove(arr, item) {
|
|
193
|
-
if (arr.length === 0) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const index = arr.indexOf(item);
|
|
197
|
-
if (index >= 0) {
|
|
198
|
-
arr.splice(index, 1);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
export function enumContains(enm, val) {
|
|
202
|
-
return enm && Object.values(enm).includes(val);
|
|
203
|
-
}
|
|
204
|
-
export function getEnumKeyAsString(enm, val) {
|
|
205
|
-
// @ts-ignore
|
|
206
|
-
const key = Object.keys(enm).find((k) => enm[k] === val);
|
|
207
|
-
return key;
|
|
208
|
-
}
|
|
209
|
-
export function getAssetAttribute(asset, attributeName) {
|
|
210
|
-
if (asset && asset.attributes && asset.attributes.hasOwnProperty(attributeName)) {
|
|
211
|
-
const attr = Object.assign(Object.assign({}, asset.attributes[attributeName]), { name: attributeName, assetId: asset.id });
|
|
212
|
-
return attr;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
export function getAssetAttributes(asset, exclude) {
|
|
216
|
-
if (asset.attributes) {
|
|
217
|
-
return Object.entries(asset.attributes).filter(([name, attr]) => !exclude || exclude.indexOf(name) >= 0).map(([name, attr]) => {
|
|
218
|
-
attr = Object.assign(Object.assign({}, attr), { name: name, assetId: asset.id });
|
|
219
|
-
return attr;
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
return [];
|
|
223
|
-
}
|
|
224
|
-
export function getFirstMetaItem(attribute, name) {
|
|
225
|
-
if (!attribute || !attribute.meta) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
return attribute.meta.find((metaItem) => metaItem.name === name);
|
|
229
|
-
}
|
|
230
|
-
export function hasMetaItem(attribute, name) {
|
|
231
|
-
return !!getFirstMetaItem(attribute, name);
|
|
232
|
-
}
|
|
233
|
-
export function getMetaValue(metaItemUrn, attribute, descriptor, valueDescriptor) {
|
|
234
|
-
const urn = typeof metaItemUrn === "string" ? metaItemUrn : metaItemUrn.urn;
|
|
235
|
-
if (attribute && attribute.meta) {
|
|
236
|
-
const metaItem = attribute.meta.find((mi) => mi.name === urn);
|
|
237
|
-
if (metaItem) {
|
|
238
|
-
return metaItem.value;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (descriptor && descriptor.metaItemDescriptors) {
|
|
242
|
-
const metaItemDescriptor = descriptor.metaItemDescriptors.find((mid) => mid.urn === urn);
|
|
243
|
-
if (metaItemDescriptor) {
|
|
244
|
-
return metaItemDescriptor.initialValue;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
if (valueDescriptor && valueDescriptor.metaItemDescriptors) {
|
|
248
|
-
const metaItemDescriptor = valueDescriptor.metaItemDescriptors.find((mid) => mid.urn === urn);
|
|
249
|
-
if (metaItemDescriptor) {
|
|
250
|
-
return metaItemDescriptor.initialValue;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
export function getAttributeLabel(attribute, descriptor, valueDescriptor, showUnits, fallback) {
|
|
255
|
-
if (!attribute && !descriptor) {
|
|
256
|
-
return fallback || "";
|
|
257
|
-
}
|
|
258
|
-
const label = getMetaValue(MetaItemType.LABEL, attribute, descriptor, valueDescriptor);
|
|
259
|
-
let units = showUnits ? getMetaValue(MetaItemType.UNIT_TYPE, attribute, descriptor, valueDescriptor) : undefined;
|
|
260
|
-
units = units ? i18next.t(["units." + units, units]) : undefined;
|
|
261
|
-
const name = attribute ? attribute.name : descriptor.attributeName;
|
|
262
|
-
const keys = [];
|
|
263
|
-
if (name) {
|
|
264
|
-
keys.push("attribute." + name);
|
|
265
|
-
keys.push(name);
|
|
266
|
-
}
|
|
267
|
-
if (label) {
|
|
268
|
-
keys.push(label);
|
|
269
|
-
}
|
|
270
|
-
if (fallback) {
|
|
271
|
-
keys.push(fallback);
|
|
272
|
-
}
|
|
273
|
-
return i18next.t(keys) + (units ? " (" + units + ")" : "");
|
|
274
|
-
}
|
|
275
|
-
export function getMetaItemLabel(urn) {
|
|
276
|
-
return i18next.t(["metaItemType." + urn, urn], { nsSeparator: "@" });
|
|
277
|
-
}
|
|
278
|
-
export function getAttributeValueFormat(attribute, descriptor, valueDescriptor) {
|
|
279
|
-
let format = getMetaValue(MetaItemType.FORMAT, attribute, descriptor, valueDescriptor);
|
|
280
|
-
if (!format) {
|
|
281
|
-
let valueType;
|
|
282
|
-
if (attribute) {
|
|
283
|
-
valueType = attribute.type;
|
|
284
|
-
}
|
|
285
|
-
if (valueDescriptor) {
|
|
286
|
-
valueType = valueDescriptor.valueType;
|
|
287
|
-
}
|
|
288
|
-
else if (descriptor) {
|
|
289
|
-
valueDescriptor = descriptor.valueDescriptor;
|
|
290
|
-
// noinspection SuspiciousTypeOfGuard
|
|
291
|
-
if (typeof valueDescriptor === "string") {
|
|
292
|
-
valueDescriptor = AssetModelUtil.getAttributeValueDescriptor(valueDescriptor);
|
|
293
|
-
}
|
|
294
|
-
if (valueDescriptor) {
|
|
295
|
-
valueType = valueDescriptor.valueType;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
if (valueType) {
|
|
299
|
-
format = i18next.t("attributeValueType." + valueType);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
return format;
|
|
303
|
-
}
|
|
304
|
-
export function getAttributeValueFormatter() {
|
|
305
|
-
return (value, format) => {
|
|
306
|
-
return value === undefined || value === null ? "" : i18next.t((format ? [format, "%s"] : "%s"), { postProcess: "sprintf", sprintf: [value] });
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
export function getAttributeValueFormatted(attribute, descriptor, valueDescriptor, fallback) {
|
|
310
|
-
if (!attribute) {
|
|
311
|
-
return fallback || "";
|
|
312
|
-
}
|
|
313
|
-
if (attribute.value === undefined || attribute.value === null) {
|
|
314
|
-
return "";
|
|
315
|
-
}
|
|
316
|
-
const format = getAttributeValueFormat(attribute, descriptor, valueDescriptor);
|
|
317
|
-
return getAttributeValueFormatter()(attribute.value, format);
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Immutable update of an asset using the supplied attribute event
|
|
321
|
-
*/
|
|
322
|
-
export function updateAsset(asset, event) {
|
|
323
|
-
const attributeName = event.attributeState.attributeRef.attributeName;
|
|
324
|
-
if (asset.attributes) {
|
|
325
|
-
if (event.attributeState.deleted) {
|
|
326
|
-
delete asset.attributes[attributeName];
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
const attribute = getAssetAttribute(asset, attributeName);
|
|
330
|
-
if (attribute) {
|
|
331
|
-
attribute.value = event.attributeState.value;
|
|
332
|
-
attribute.valueTimestamp = event.timestamp;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return Object.assign({}, asset);
|
|
337
|
-
}
|
|
338
|
-
export function loadJs(url) {
|
|
339
|
-
return new Promise((resolve, reject) => {
|
|
340
|
-
const script = document.createElement('script');
|
|
341
|
-
script.type = 'text/javascript';
|
|
342
|
-
script.src = url;
|
|
343
|
-
script.addEventListener('load', (e) => resolve(e), false);
|
|
344
|
-
script.addEventListener('error', (e) => reject(e), false);
|
|
345
|
-
document.body.appendChild(script);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
;
|
|
349
|
-
export function sortByString(valueExtractor) {
|
|
350
|
-
return (a, b) => {
|
|
351
|
-
const v1 = valueExtractor(a);
|
|
352
|
-
const v2 = valueExtractor(b);
|
|
353
|
-
if (v1 > v2) {
|
|
354
|
-
return 1;
|
|
355
|
-
}
|
|
356
|
-
if (v1 < v2) {
|
|
357
|
-
return -1;
|
|
358
|
-
}
|
|
359
|
-
return 0;
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
//# sourceMappingURL=util.js.map
|
package/mdi-iconset-generator.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
var fs = require('fs');
|
|
2
|
-
var path = require("path");
|
|
3
|
-
var xpath = require('xpath');
|
|
4
|
-
var dom = require('xmldom').DOMParser;
|
|
5
|
-
|
|
6
|
-
if (!fs.existsSync("src")){
|
|
7
|
-
fs.mkdirSync("src");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
let mdiSvgDir = path.join(path.dirname(require.resolve("@mdi/svg/package.json")), "svg");
|
|
11
|
-
if (!fs.existsSync("dist")) {
|
|
12
|
-
fs.mkdirSync("dist");
|
|
13
|
-
}
|
|
14
|
-
let mdiStream = fs.createWriteStream("./dist/mdi-icons.json" ,{flags: "w+"});
|
|
15
|
-
mdiStream.write("{\"size\":24,\"icons\":{");
|
|
16
|
-
|
|
17
|
-
let files = fs.readdirSync(mdiSvgDir).sort();
|
|
18
|
-
|
|
19
|
-
for (let i=0; i<files.length; i++) {
|
|
20
|
-
|
|
21
|
-
let file = files[i];
|
|
22
|
-
let fullPath = path.join(mdiSvgDir, file);
|
|
23
|
-
let data = fs.readFileSync(fullPath, "utf8");
|
|
24
|
-
let svg = new dom().parseFromString(data);
|
|
25
|
-
let select = xpath.useNamespaces({"svg": "http://www.w3.org/2000/svg"});
|
|
26
|
-
let pathAttrs = select("//svg:path/@d", svg);
|
|
27
|
-
let pathData = pathAttrs[0].value;
|
|
28
|
-
let name = file.substr(0, file.length-4);
|
|
29
|
-
//name = name.replace(/-([\w])/g, function (g) { return g[1].toUpperCase(); });
|
|
30
|
-
mdiStream.write("\"" + name + "\":\"" + pathData + "\"" + (i < files.length-1 ? "," : ""));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
mdiStream.write("}}");
|
|
34
|
-
mdiStream.close();
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./dist",
|
|
5
|
-
"tsBuildInfoFile": "./dist/.tsbuildinfo",
|
|
6
|
-
"rootDir": "src"
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"./src",
|
|
10
|
-
"./@types"
|
|
11
|
-
],
|
|
12
|
-
"references": [
|
|
13
|
-
{ "path": "../model" },
|
|
14
|
-
{ "path": "../rest" }
|
|
15
|
-
]
|
|
16
|
-
}
|
package/typedoc.js
DELETED
package/webpack.config.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const util = require("../webpack.util");
|
|
2
|
-
|
|
3
|
-
bundles = {
|
|
4
|
-
"index": {
|
|
5
|
-
vendor: {
|
|
6
|
-
"moment": "moment"
|
|
7
|
-
},
|
|
8
|
-
excludeOr: true
|
|
9
|
-
},
|
|
10
|
-
"index.bundle": {
|
|
11
|
-
excludeOr: true,
|
|
12
|
-
},
|
|
13
|
-
"index.orbundle": undefined
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = util.generateExports(__dirname);
|
|
File without changes
|