saasufy-components 7.8.0 → 7.9.1
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/app-router.js +14 -5
- package/package.json +1 -1
- package/utils.js +32 -0
package/app-router.js
CHANGED
|
@@ -140,6 +140,15 @@ export class AppRouter extends SocketConsumer {
|
|
|
140
140
|
return route;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
replaceLocationHash(pagePath) {
|
|
144
|
+
let cleanPagePath = pagePath || '';
|
|
145
|
+
let firstChar = cleanPagePath.charAt(0);
|
|
146
|
+
if (firstChar !== '#') {
|
|
147
|
+
cleanPagePath = `#${cleanPagePath}`;
|
|
148
|
+
}
|
|
149
|
+
location.replace(cleanPagePath);
|
|
150
|
+
}
|
|
151
|
+
|
|
143
152
|
renderCurrentPage() {
|
|
144
153
|
let routerViewport = this.shadowRoot.querySelector('slot[name="viewport"]').assignedNodes()[0];
|
|
145
154
|
if (!routerViewport) return;
|
|
@@ -199,7 +208,7 @@ export class AppRouter extends SocketConsumer {
|
|
|
199
208
|
routeArgs = this.computeRouteArgs(pagePath, regExp, params);
|
|
200
209
|
pagePath = this.substituteRouteAgs(authRedirect, routeArgs);
|
|
201
210
|
if (hardRedirect) {
|
|
202
|
-
|
|
211
|
+
this.replaceLocationHash(pagePath);
|
|
203
212
|
return;
|
|
204
213
|
}
|
|
205
214
|
let result = this.getMatchingPage(pagePath, 'auth-redirect');
|
|
@@ -211,7 +220,7 @@ export class AppRouter extends SocketConsumer {
|
|
|
211
220
|
routeArgs = this.computeRouteArgs(pagePath, regExp, params);
|
|
212
221
|
pagePath = this.substituteRouteAgs(noAuthRedirect, routeArgs);
|
|
213
222
|
if (hardRedirect) {
|
|
214
|
-
|
|
223
|
+
this.replaceLocationHash(pagePath);
|
|
215
224
|
return;
|
|
216
225
|
}
|
|
217
226
|
let result = this.getMatchingPage(pagePath, 'no-auth-redirect');
|
|
@@ -220,12 +229,12 @@ export class AppRouter extends SocketConsumer {
|
|
|
220
229
|
regExp = result.regExp;
|
|
221
230
|
params = result.params;
|
|
222
231
|
} else {
|
|
232
|
+
routeArgs = this.computeRouteArgs(pagePath, regExp, params);
|
|
233
|
+
pagePath = this.substituteRouteAgs(redirect, routeArgs);
|
|
223
234
|
if (hardRedirect) {
|
|
224
|
-
|
|
235
|
+
this.replaceLocationHash(pagePath);
|
|
225
236
|
return;
|
|
226
237
|
}
|
|
227
|
-
routeArgs = this.computeRouteArgs(pagePath, regExp, params);
|
|
228
|
-
pagePath = this.substituteRouteAgs(redirect, routeArgs);
|
|
229
238
|
let result = this.getMatchingPage(pagePath, 'redirect');
|
|
230
239
|
pageTemplate = result.pageTemplate;
|
|
231
240
|
route = result.route;
|
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -484,6 +484,38 @@ export function formatError(error) {
|
|
|
484
484
|
return error.code === 1009 ? 'Resource exceeded the maximum size' : error.message;
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
+
export function logAttributeChanges(...elementSelectors) {
|
|
488
|
+
let domObserverCallback = (mutationList) => {
|
|
489
|
+
for (let mutation of mutationList) {
|
|
490
|
+
let matchingSelector = (elementSelectors || []).find(elementSelector => mutation.target?.matches(elementSelector));
|
|
491
|
+
let isWatchingElement = !elementSelectors.length || !!matchingSelector;
|
|
492
|
+
if (mutation.type === 'attributes' && isWatchingElement) {
|
|
493
|
+
let identifier = mutation.target.id || matchingSelector || mutation.target.nodeName?.toLowerCase();
|
|
494
|
+
console.log(
|
|
495
|
+
`[${identifier}] Attribute ${
|
|
496
|
+
mutation.attributeName
|
|
497
|
+
} changed to: ${
|
|
498
|
+
mutation.target.getAttribute(mutation.attributeName)
|
|
499
|
+
}`
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
let observer = new MutationObserver(domObserverCallback);
|
|
506
|
+
|
|
507
|
+
let config = {
|
|
508
|
+
attributes: true,
|
|
509
|
+
subtree: true,
|
|
510
|
+
attributeOldValue: true
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
observer.observe(document, config);
|
|
514
|
+
return () => {
|
|
515
|
+
observer.disconnect();
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
|
|
487
519
|
export function wait(duration) {
|
|
488
520
|
return new Promise((resolve) => setTimeout(resolve, duration));
|
|
489
521
|
}
|