lit-ui-router 1.16.1 → 1.16.2
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/development/router-subscription.js +11 -3
- package/dist/development/router-subscription.js.map +1 -1
- package/dist/router-subscription.d.ts +6 -1
- package/dist/router-subscription.d.ts.map +1 -1
- package/dist/router-subscription.js +11 -3
- package/dist/router-subscription.js.map +1 -1
- package/package.json +1 -1
- package/src/router-subscription.ts +27 -4
|
@@ -16,18 +16,26 @@ export class RouterSubscribers {
|
|
|
16
16
|
callback(router, () => this.pending.delete(deliver));
|
|
17
17
|
}
|
|
18
18
|
deliver(router) {
|
|
19
|
+
const failures = [];
|
|
19
20
|
for (const deliver of [...this.pending]) {
|
|
20
21
|
if (!this.pending.delete(deliver)) continue;
|
|
21
22
|
try {
|
|
22
23
|
deliver(router);
|
|
23
24
|
} catch (thrown) {
|
|
24
|
-
|
|
25
|
-
throw thrown;
|
|
26
|
-
});
|
|
25
|
+
failures.push(thrown);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
28
|
+
reportFailures(failures);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
const reportFailures = (failures) => {
|
|
32
|
+
if (!failures.length) return;
|
|
33
|
+
if (typeof globalThis.reportError === "function") {
|
|
34
|
+
failures.forEach((failure) => globalThis.reportError(failure));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
throw failures.length === 1 ? failures[0] : new AggregateError(failures, "router upgrade subscribers threw");
|
|
38
|
+
};
|
|
31
39
|
export const subscribeRouter = (target, onReplaced) => {
|
|
32
40
|
let seeking = true;
|
|
33
41
|
let unsubscribe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-subscription.js","mappings":"AACA,SAAS,wBAAwB,qBAAqB;AAEtD,SAAS,gCAAgC;AAIzC,OAAO,MAAM,sBAA4B,CAAC;AAQ1C,OAAO,MAAM,kBAAkB;;iBACF,IAAI,IAAmC;;C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EAChD,SAAS,SAAS,YAAY,WAAW,YAAY,OAAO,CAAC;EAC7D;CACF;CACA,MAAM,SAAS,WAAW,IACtB,SAAS,KACT,IAAI,eAAe,UAAU,kCAAkC;AACrE;AAsBA,OAAO,MAAM,mBACX,QACA,eACuB;CACvB,IAAI,UAAU;CACd,IAAI;CACJ,MAAM,SAAS,cAAc,QAAQ;EACnC,WAAW;EACX,WAAW,OAAO,YAAY;GAC5B,cAAc,YAAY,gBAAgB,SAAY;GACtD,IAAI,CAAC,SACH,WAAW,KAAK;EAEpB;CACF,CAAC;CACD,UAAU;CACV,IAAI,QACF,OAAO;EAAE;EAAQ;CAAY;CAE/B,MAAM,QAA8B,IAAI,YACtC,0BACA;EAAE,SAAS;EAAM,UAAU;EAAM,QAAQ,CAAC;CAAE,CAC9C;CACA,OAAO,cAAc,KAAK;CAC1B,OAAO;EAAE,QAAQ,MAAM,OAAO;EAAU,aAAa;CAAU;AACjE","names":[],"ignoreList":[],"sources":["../../src/router-subscription.ts"]}
|
|
@@ -15,7 +15,12 @@ export declare class RouterSubscribers {
|
|
|
15
15
|
* {@link noUnsubscribe}.
|
|
16
16
|
*/
|
|
17
17
|
answer(event: Event, router: UIRouterLit | undefined, provisional: boolean): void;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Hands every kept subscriber `router`, once, and forgets them.
|
|
20
|
+
*
|
|
21
|
+
* A subscriber that throws does not keep the router from the others; its
|
|
22
|
+
* error goes to {@link reportFailures} once all have it.
|
|
23
|
+
*/
|
|
19
24
|
deliver(router: UIRouterLit): void;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-subscription.d.ts","mappings":"AAEA,cAAc,mBAAmB;;AAKjC,OAAO,cAAM;;;;;;;AAQb,OAAO,cAAM,kBAAkB;CAC7B,iBAAiB;;;;;;CAOjB,OACE,OAAO,OACP,QAAQ,yBACR
|
|
1
|
+
{"version":3,"file":"router-subscription.d.ts","mappings":"AAEA,cAAc,mBAAmB;;AAKjC,OAAO,cAAM;;;;;;;AAQb,OAAO,cAAM,kBAAkB;CAC7B,iBAAiB;;;;;;CAOjB,OACE,OAAO,OACP,QAAQ,yBACR;;;;;;;CAyBF,QAAQ,QAAQ;AAelB;;;;;;;AA0BA,iBAAiB,mBAAmB;CAClC,QAAQ;CACR;AACF;;;;;;;;;;AAWA,OAAO,cAAM,kBACX,QAAQ,SACR,aAAa,QAAQ,yBACpB","names":[],"ignoreList":[],"sources":["../src/router-subscription.ts"]}
|
|
@@ -16,18 +16,26 @@ export class RouterSubscribers {
|
|
|
16
16
|
callback(router, () => this.pending.delete(deliver));
|
|
17
17
|
}
|
|
18
18
|
deliver(router) {
|
|
19
|
+
const failures = [];
|
|
19
20
|
for (const deliver of [...this.pending]) {
|
|
20
21
|
if (!this.pending.delete(deliver)) continue;
|
|
21
22
|
try {
|
|
22
23
|
deliver(router);
|
|
23
24
|
} catch (thrown) {
|
|
24
|
-
|
|
25
|
-
throw thrown;
|
|
26
|
-
});
|
|
25
|
+
failures.push(thrown);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
28
|
+
reportFailures(failures);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
const reportFailures = (failures) => {
|
|
32
|
+
if (!failures.length) return;
|
|
33
|
+
if (typeof globalThis.reportError === "function") {
|
|
34
|
+
failures.forEach((failure) => globalThis.reportError(failure));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
throw failures.length === 1 ? failures[0] : new AggregateError(failures, "router upgrade subscribers threw");
|
|
38
|
+
};
|
|
31
39
|
export const subscribeRouter = (target, onReplaced) => {
|
|
32
40
|
let seeking = true;
|
|
33
41
|
let unsubscribe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-subscription.js","mappings":"AACA,SAAS,wBAAwB,qBAAqB;AAEtD,SAAS,gCAAgC;AAIzC,OAAO,MAAM,sBAA4B,CAAC;AAQ1C,OAAO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CAEF,IAAI,OAAO,WAAW,gBAAgB,YAAY;EAChD,SAAS,SAAS,YAAY,WAAW,YAAY,OAAO,CAAC;EAC7D;CACF;CACA,MAAM,SAAS,WAAW,IACtB,SAAS,KACT,IAAI,eAAe,UAAU,kCAAkC;AACrE;AAsBA,OAAO,MAAM,mBACX,QACA,eACuB;CACvB,IAAI,UAAU;CACd,IAAI;CACJ,MAAM,SAAS,cAAc,QAAQ;EACnC,WAAW;EACX,WAAW,OAAO,YAAY;GAC5B,cAAc,YAAY,gBAAgB,SAAY;GACtD,IAAI,CAAC,SACH,WAAW,KAAK;EAEpB;CACF,CAAC;CACD,UAAU;CACV,IAAI,QACF,OAAO;EAAE;EAAQ;CAAY;CAE/B,MAAM,QAA8B,IAAI,YACtC,0BACA;EAAE,SAAS;EAAM,UAAU;EAAM,QAAQ,CAAC;CAAE,CAC9C;CACA,OAAO,cAAc,KAAK;CAC1B,OAAO;EAAE,QAAQ,MAAM,OAAO;EAAU,aAAa;CAAU;AACjE","names":[],"ignoreList":[],"sources":["../src/router-subscription.ts"]}
|
package/package.json
CHANGED
|
@@ -43,8 +43,14 @@ export class RouterSubscribers {
|
|
|
43
43
|
callback(router, () => this.pending.delete(deliver));
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Hands every kept subscriber `router`, once, and forgets them.
|
|
48
|
+
*
|
|
49
|
+
* A subscriber that throws does not keep the router from the others; its
|
|
50
|
+
* error goes to {@link reportFailures} once all have it.
|
|
51
|
+
*/
|
|
47
52
|
deliver(router: UIRouterLit): void {
|
|
53
|
+
const failures: unknown[] = [];
|
|
48
54
|
for (const deliver of [...this.pending]) {
|
|
49
55
|
// An earlier subscriber may have disconnected this one, unsubscribing it.
|
|
50
56
|
if (!this.pending.delete(deliver)) {
|
|
@@ -53,14 +59,31 @@ export class RouterSubscribers {
|
|
|
53
59
|
try {
|
|
54
60
|
deliver(router);
|
|
55
61
|
} catch (thrown) {
|
|
56
|
-
|
|
57
|
-
throw thrown;
|
|
58
|
-
});
|
|
62
|
+
failures.push(thrown);
|
|
59
63
|
}
|
|
60
64
|
}
|
|
65
|
+
reportFailures(failures);
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Reports each failure through `reportError`, as the platform reports a
|
|
71
|
+
* throwing event listener. Without it (Node, DOM emulators) throws instead:
|
|
72
|
+
* the one error, or an `AggregateError` of several.
|
|
73
|
+
*/
|
|
74
|
+
const reportFailures = (failures: unknown[]): void => {
|
|
75
|
+
if (!failures.length) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (typeof globalThis.reportError === 'function') {
|
|
79
|
+
failures.forEach((failure) => globalThis.reportError(failure));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
throw failures.length === 1
|
|
83
|
+
? failures[0]
|
|
84
|
+
: new AggregateError(failures, 'router upgrade subscribers threw');
|
|
85
|
+
};
|
|
86
|
+
|
|
64
87
|
/**
|
|
65
88
|
* What {@link subscribeRouter} found: the router, and the unsubscribe to call
|
|
66
89
|
* on disconnect, absent when the provider's router is final.
|