@dotglitch/ngx-common 1.0.47 → 1.0.49
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/esm2020/components/lazy-loader/lazy-loader.service.mjs +3 -3
- package/esm2020/components/react-magic-wrapper/react-magic-wrapper.component.mjs +1 -3
- package/esm2020/public-api.mjs +2 -1
- package/esm2020/services/dialog.service.mjs +3 -3
- package/esm2020/services/navigation.service.mjs +3 -3
- package/esm2020/utils/index.mjs +172 -15
- package/fesm2015/dotglitch-ngx-common.mjs +175 -20
- package/fesm2015/dotglitch-ngx-common.mjs.map +1 -1
- package/fesm2020/dotglitch-ngx-common.mjs +175 -20
- package/fesm2020/dotglitch-ngx-common.mjs.map +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/utils/index.d.ts +107 -6
|
@@ -1068,24 +1068,133 @@ const saveObjectAsFile = (name, data) => {
|
|
|
1068
1068
|
a.click();
|
|
1069
1069
|
a.remove();
|
|
1070
1070
|
};
|
|
1071
|
+
class Emoticon {
|
|
1072
|
+
constructor(icon) {
|
|
1073
|
+
this.icon = icon;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* authorization 🔐 \
|
|
1078
|
+
* user 🪪 \
|
|
1079
|
+
* security 🛡 \
|
|
1080
|
+
* system 🖥 \
|
|
1081
|
+
* toolbox 🧰 \
|
|
1082
|
+
* chore ⚙ \
|
|
1083
|
+
* config 🛠 \
|
|
1084
|
+
* renderer 📐 \
|
|
1085
|
+
* package 📦 \
|
|
1086
|
+
* time ⏳ \
|
|
1087
|
+
* download 📥 \
|
|
1088
|
+
* upload 📤 \
|
|
1089
|
+
* bug 🦠 \
|
|
1090
|
+
* bomb 💣 \
|
|
1091
|
+
* tnt 🧨 \
|
|
1092
|
+
* warning ⚠️ \
|
|
1093
|
+
* chart 📊 \
|
|
1094
|
+
* chart_up 📈 \
|
|
1095
|
+
* chart_down 📉 \
|
|
1096
|
+
* circle_red 🔴 \
|
|
1097
|
+
* circle_orange 🟠 \
|
|
1098
|
+
* circle_yellow 🟡 \
|
|
1099
|
+
* circle_green 🟢 \
|
|
1100
|
+
* circle_blue 🔵 \
|
|
1101
|
+
* circle_violet 🟣 \
|
|
1102
|
+
* circle_black ⚫️ \
|
|
1103
|
+
* circle_white ⚪️ \
|
|
1104
|
+
* circle_brown 🟤 \
|
|
1105
|
+
* square_red 🟥 \
|
|
1106
|
+
* square_orange 🟧 \
|
|
1107
|
+
* square_yellow 🟨 \
|
|
1108
|
+
* square_green 🟩 \
|
|
1109
|
+
* square_blue 🟦 \
|
|
1110
|
+
* square_violet 🟪 \
|
|
1111
|
+
* square_black ⬛️ \
|
|
1112
|
+
* square_white ⬜️ \
|
|
1113
|
+
* square_brown 🟫
|
|
1114
|
+
*/
|
|
1115
|
+
const LogIcon = {
|
|
1116
|
+
authorization: new Emoticon("🔐"),
|
|
1117
|
+
user: new Emoticon("🪪"),
|
|
1118
|
+
security: new Emoticon("🛡"),
|
|
1119
|
+
system: new Emoticon("🖥"),
|
|
1120
|
+
toolbox: new Emoticon("🧰"),
|
|
1121
|
+
chore: new Emoticon("⚙"),
|
|
1122
|
+
config: new Emoticon("🛠"),
|
|
1123
|
+
renderer: new Emoticon("📐"),
|
|
1124
|
+
package: new Emoticon("📦"),
|
|
1125
|
+
time: new Emoticon("⏳"),
|
|
1126
|
+
download: new Emoticon("📥"),
|
|
1127
|
+
upload: new Emoticon("📤"),
|
|
1128
|
+
bug: new Emoticon("🦠"),
|
|
1129
|
+
bomb: new Emoticon("💣"),
|
|
1130
|
+
tnt: new Emoticon("🧨"),
|
|
1131
|
+
warning: new Emoticon("⚠️"),
|
|
1132
|
+
chart: new Emoticon("📊"),
|
|
1133
|
+
chart_up: new Emoticon("📈"),
|
|
1134
|
+
chart_down: new Emoticon("📉"),
|
|
1135
|
+
circle_red: new Emoticon("🔴"),
|
|
1136
|
+
circle_orange: new Emoticon("🟠"),
|
|
1137
|
+
circle_yellow: new Emoticon("🟡"),
|
|
1138
|
+
circle_green: new Emoticon("🟢"),
|
|
1139
|
+
circle_blue: new Emoticon("🔵"),
|
|
1140
|
+
circle_violet: new Emoticon("🟣"),
|
|
1141
|
+
circle_black: new Emoticon("⚫️"),
|
|
1142
|
+
circle_white: new Emoticon("⚪️"),
|
|
1143
|
+
circle_brown: new Emoticon("🟤"),
|
|
1144
|
+
square_red: new Emoticon("🟥"),
|
|
1145
|
+
square_orange: new Emoticon("🟧"),
|
|
1146
|
+
square_yellow: new Emoticon("🟨"),
|
|
1147
|
+
square_green: new Emoticon("🟩"),
|
|
1148
|
+
square_blue: new Emoticon("🟦"),
|
|
1149
|
+
square_violet: new Emoticon("🟪"),
|
|
1150
|
+
square_black: new Emoticon("⬛️"),
|
|
1151
|
+
square_white: new Emoticon("⬜️"),
|
|
1152
|
+
square_brown: new Emoticon("🟫")
|
|
1153
|
+
};
|
|
1154
|
+
class Log {
|
|
1155
|
+
constructor(context, contextColor, textColor) {
|
|
1156
|
+
this.context = context;
|
|
1157
|
+
this.contextColor = contextColor;
|
|
1158
|
+
this.textColor = textColor;
|
|
1159
|
+
}
|
|
1160
|
+
log(iconOrMessage, messageText, ...args) {
|
|
1161
|
+
if (iconOrMessage instanceof Emoticon) {
|
|
1162
|
+
console.log(`${iconOrMessage} %c[${this.context}] %c${messageText}`, 'color: ' + this.contextColor, 'color: ' + this.textColor, ...args);
|
|
1163
|
+
}
|
|
1164
|
+
else {
|
|
1165
|
+
console.log(`%c[${this.context}] %c${iconOrMessage}`, 'color: ' + this.contextColor, 'color: ' + this.textColor, ...args);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
warn(iconOrMessage, messageText, ...args) {
|
|
1169
|
+
if (iconOrMessage instanceof Emoticon) {
|
|
1170
|
+
console.warn(`${iconOrMessage} %c[${this.context}] %c${messageText}`, 'color: ' + this.contextColor, 'color: ' + this.textColor, ...args);
|
|
1171
|
+
}
|
|
1172
|
+
else {
|
|
1173
|
+
console.warn(`%c[${this.context}] %c${iconOrMessage}`, 'color: ' + this.contextColor, 'color: ' + this.textColor, ...args);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
err(iconOrMessage, messageText, ...args) {
|
|
1177
|
+
if (iconOrMessage instanceof Emoticon) {
|
|
1178
|
+
console.error(`${iconOrMessage} %c[${this.context}] %c${messageText}`, 'color: ' + this.contextColor, 'color: ' + this.textColor, ...args);
|
|
1179
|
+
}
|
|
1180
|
+
else {
|
|
1181
|
+
console.error(`%c[${this.context}] %c${iconOrMessage}`, 'color: ' + this.contextColor, 'color: ' + this.textColor, ...args);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
error(iconOrMessage, messageText, ...args) {
|
|
1185
|
+
if (iconOrMessage instanceof Emoticon) {
|
|
1186
|
+
console.error(`${iconOrMessage} %c[${this.context}] %c${messageText}`, 'color: ' + this.contextColor, 'color: ' + this.textColor, ...args);
|
|
1187
|
+
}
|
|
1188
|
+
else {
|
|
1189
|
+
console.error(`%c[${this.context}] %c${iconOrMessage}`, 'color: ' + this.contextColor, 'color: ' + this.textColor, ...args);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1071
1193
|
/**
|
|
1072
1194
|
* Formatted logger that will print a bit of context before the message.
|
|
1073
1195
|
* @returns
|
|
1074
1196
|
*/
|
|
1075
|
-
const
|
|
1076
|
-
log: (message, ...args) => {
|
|
1077
|
-
console.log(`%c[${context}] %c${message}`, 'color: ' + contextColor, 'color: ' + textColor, ...args);
|
|
1078
|
-
},
|
|
1079
|
-
warn: (message, ...args) => {
|
|
1080
|
-
console.warn(`%c[${context}] %c${message}`, 'color: ' + contextColor, 'color: ' + textColor, ...args);
|
|
1081
|
-
},
|
|
1082
|
-
err: (message, ...args) => {
|
|
1083
|
-
console.error(`%c[${context}] %c${message}`, 'color: ' + contextColor, 'color: ' + textColor, ...args);
|
|
1084
|
-
},
|
|
1085
|
-
error: (message, ...args) => {
|
|
1086
|
-
console.error(`%c[${context}] %c${message}`, 'color: ' + contextColor, 'color: ' + textColor, ...args);
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1197
|
+
const ConsoleLogger = (context, contextColor, textColor = "#03a9f4") => new Log(context, contextColor, textColor);
|
|
1089
1198
|
/**
|
|
1090
1199
|
* Convert a string `fooBAR baz_160054''"1]"` into a slug: `foobar-baz-1600541`
|
|
1091
1200
|
*/
|
|
@@ -1094,6 +1203,54 @@ const stringToSlug = (text) => (text || '')
|
|
|
1094
1203
|
.toLowerCase()
|
|
1095
1204
|
.replace(/[\-_+ ]/g, '-')
|
|
1096
1205
|
.replace(/[^a-z0-9\-]/g, '');
|
|
1206
|
+
/**
|
|
1207
|
+
* Helper to update the page URL.
|
|
1208
|
+
* @param page component page ID to load.
|
|
1209
|
+
* @param data string or JSON data for query params.
|
|
1210
|
+
*/
|
|
1211
|
+
const updateUrl = (page, data = {}, replaceState = false) => {
|
|
1212
|
+
const [oldHash, qstring] = location.hash.split('?');
|
|
1213
|
+
if (!page)
|
|
1214
|
+
page = oldHash.split('/')[1];
|
|
1215
|
+
const hash = `#/${page}`;
|
|
1216
|
+
// Convert the data object to JSON.
|
|
1217
|
+
if (data instanceof URLSearchParams) {
|
|
1218
|
+
data = [...data.entries()].map(([k, v]) => ({ [k]: v })).reduce((a, b) => ({ ...a, ...b }), {});
|
|
1219
|
+
}
|
|
1220
|
+
const query = new URLSearchParams(data);
|
|
1221
|
+
const prevParams = new URLSearchParams(qstring);
|
|
1222
|
+
// If the hash is the same, retain params.
|
|
1223
|
+
if (hash == oldHash) {
|
|
1224
|
+
replaceState = true;
|
|
1225
|
+
for (const [key, value] of prevParams.entries())
|
|
1226
|
+
if (!query.has(key))
|
|
1227
|
+
query.set(key, prevParams.get(key));
|
|
1228
|
+
}
|
|
1229
|
+
for (const [key, val] of query.entries()) {
|
|
1230
|
+
if (val == null ||
|
|
1231
|
+
val == undefined ||
|
|
1232
|
+
val == '' ||
|
|
1233
|
+
val == 'null' ||
|
|
1234
|
+
Number.isNaN(val) ||
|
|
1235
|
+
val == 'NaN')
|
|
1236
|
+
query.delete(key);
|
|
1237
|
+
}
|
|
1238
|
+
if (!(hash.toLowerCase() == "#/frame") || data['id'] == -1)
|
|
1239
|
+
query.delete('id');
|
|
1240
|
+
const strQuery = query.toString();
|
|
1241
|
+
console.log(data, hash, strQuery);
|
|
1242
|
+
if (replaceState) {
|
|
1243
|
+
window.history.replaceState(data, '', hash + (strQuery ? ('?' + strQuery) : ''));
|
|
1244
|
+
}
|
|
1245
|
+
else {
|
|
1246
|
+
window.history.pushState(data, '', hash + (strQuery ? ('?' + strQuery) : ''));
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
const getUrlData = (source = window.location.hash) => {
|
|
1250
|
+
const [hash, query] = source.split('?');
|
|
1251
|
+
let data = new URLSearchParams(query);
|
|
1252
|
+
return [...data.entries()].map(([k, v]) => ({ [k]: v })).reduce((a, b) => ({ ...a, ...b }), {});
|
|
1253
|
+
};
|
|
1097
1254
|
|
|
1098
1255
|
const SCRIPT_INIT_TIMEOUT = 500; // ms
|
|
1099
1256
|
/**
|
|
@@ -1185,7 +1342,7 @@ class LazyLoaderService {
|
|
|
1185
1342
|
LazyLoaderService.configure(config);
|
|
1186
1343
|
}
|
|
1187
1344
|
static configure(config) {
|
|
1188
|
-
const { log, warn, err } =
|
|
1345
|
+
const { log, warn, err } = ConsoleLogger("ngx-lazy-loader", "#009688");
|
|
1189
1346
|
this.config = {
|
|
1190
1347
|
componentResolveStrategy: ComponentResolveStrategy.PickFirst,
|
|
1191
1348
|
logger: {
|
|
@@ -1740,7 +1897,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
1740
1897
|
type: Output
|
|
1741
1898
|
}] } });
|
|
1742
1899
|
|
|
1743
|
-
const { log: log$1, warn: warn$1, err: err$1 } =
|
|
1900
|
+
const { log: log$1, warn: warn$1, err: err$1 } = ConsoleLogger("DialogService", "#607d8b");
|
|
1744
1901
|
class DialogService {
|
|
1745
1902
|
constructor(dialog, lazyLoader) {
|
|
1746
1903
|
this.dialog = dialog;
|
|
@@ -2059,7 +2216,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
2059
2216
|
}]
|
|
2060
2217
|
}], ctorParameters: function () { return []; } });
|
|
2061
2218
|
|
|
2062
|
-
const { log, warn, err } =
|
|
2219
|
+
const { log, warn, err } = ConsoleLogger("NavigationService", "#ff9800");
|
|
2063
2220
|
class NavigationService {
|
|
2064
2221
|
constructor(lazyLoader) {
|
|
2065
2222
|
this.lazyLoader = lazyLoader;
|
|
@@ -10561,8 +10718,6 @@ class ReactMagicWrapperComponent {
|
|
|
10561
10718
|
this.ngOnChanges();
|
|
10562
10719
|
})
|
|
10563
10720
|
];
|
|
10564
|
-
if (!this.ngReactComponent)
|
|
10565
|
-
throw new Error("ReactMagicWrapperComponent cannot start without a provided ngReactComponent!");
|
|
10566
10721
|
}
|
|
10567
10722
|
ngOnInit() {
|
|
10568
10723
|
if (!this.ngReactComponent)
|
|
@@ -10622,5 +10777,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
10622
10777
|
* Generated bundle index. Do not edit.
|
|
10623
10778
|
*/
|
|
10624
10779
|
|
|
10625
|
-
export { ComponentResolveStrategy, DependencyService, DialogService, DynamicHTMLComponent, DynamicHTMLOptions, DynamicHTMLRenderer, Fetch, FileService, FilemanagerComponent, HtmlBypass, InstallMonacoUMD, KeyboardService, LazyLoaderComponent, LazyLoaderModule, LazyLoaderService, MenuDirective, NGX_DYNAMIC_CONFIG, NGX_LAZY_LOADER_CONFIG, NGX_WEB_COMPONENTS_CONFIG, NavigationService, NgxDynamicHTMLModule, OnMount, ReactMagicWrapperComponent, ResourceBypass, ScriptBypass, StyleBypass, TabulatorComponent, ThemeService, TooltipDirective, UrlBypass, VscodeComponent, openMenu, openTooltip };
|
|
10780
|
+
export { ComponentResolveStrategy, ConsoleLogger, DependencyService, DialogService, DynamicHTMLComponent, DynamicHTMLOptions, DynamicHTMLRenderer, Fetch, FileService, FilemanagerComponent, HtmlBypass, InstallMonacoUMD, KeyboardService, LazyLoaderComponent, LazyLoaderModule, LazyLoaderService, LogIcon, MenuDirective, NGX_DYNAMIC_CONFIG, NGX_LAZY_LOADER_CONFIG, NGX_WEB_COMPONENTS_CONFIG, NavigationService, NgxDynamicHTMLModule, OnMount, ReactMagicWrapperComponent, ResourceBypass, ScriptBypass, StyleBypass, TabulatorComponent, ThemeService, TooltipDirective, UrlBypass, VscodeComponent, openMenu, openTooltip };
|
|
10626
10781
|
//# sourceMappingURL=dotglitch-ngx-common.mjs.map
|