@leavittsoftware/web 9.3.0 → 9.4.0
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/package.json +2 -2
- package/titanium/helpers/helpers.d.ts +1 -0
- package/titanium/helpers/helpers.js +1 -0
- package/titanium/helpers/helpers.js.map +1 -1
- package/titanium/helpers/promise-tracking.d.ts +24 -0
- package/titanium/helpers/promise-tracking.js +45 -0
- package/titanium/helpers/promise-tracking.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leavittsoftware/web",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"files": [
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"url": "https://github.com/LeavittSoftware/titanium-elements/issues"
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/LeavittSoftware/titanium-elements/#readme",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "4f119b3ace4944d7845f7d22b279bbf9469de34a"
|
|
48
48
|
}
|
|
@@ -6,6 +6,7 @@ export { installMediaQueryWatcher } from './install-media-query-watcher';
|
|
|
6
6
|
export { getSearchTokens } from './get-search-token';
|
|
7
7
|
export { Debouncer } from './debouncer';
|
|
8
8
|
export { LoadWhile } from './load-while';
|
|
9
|
+
export { promiseTracking } from './promise-tracking';
|
|
9
10
|
export { join } from './join';
|
|
10
11
|
export { delay } from './delay';
|
|
11
12
|
export { middleEllipsis } from './middle-ellipsis';
|
|
@@ -6,6 +6,7 @@ export { installMediaQueryWatcher } from './install-media-query-watcher';
|
|
|
6
6
|
export { getSearchTokens } from './get-search-token';
|
|
7
7
|
export { Debouncer } from './debouncer';
|
|
8
8
|
export { LoadWhile } from './load-while';
|
|
9
|
+
export { promiseTracking } from './promise-tracking';
|
|
9
10
|
export { join } from './join';
|
|
10
11
|
export { delay } from './delay';
|
|
11
12
|
export { middleEllipsis } from './middle-ellipsis';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorates a reactive boolean accessor so that calling the generated method
|
|
3
|
+
* sets the property to `true` while the supplied promise is pending, and
|
|
4
|
+
* back to `false` once it resolves or rejects. Re-throws errors.
|
|
5
|
+
*
|
|
6
|
+
* Reentrancy: if the method is called multiple times concurrently, the
|
|
7
|
+
* property only flips back to `false` after ALL outstanding promises settle.
|
|
8
|
+
*
|
|
9
|
+
* Because the method name is a runtime string, TypeScript can't see it on
|
|
10
|
+
* the host class. Consumers add a one-line `declare` next to the accessor.
|
|
11
|
+
*
|
|
12
|
+
* @param methodName The name of the method to add to the host prototype.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* \@promiseTracking('trackLoadingPromise')
|
|
17
|
+
* \@state() accessor isLoading = false;
|
|
18
|
+
* declare trackLoadingPromise: (p: Promise<unknown>) => Promise<void>;
|
|
19
|
+
*
|
|
20
|
+
* await this.trackLoadingPromise(api.load());
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function promiseTracking(methodName: string): (target: object, propertyKey: string | symbol, _descriptor: PropertyDescriptor) => void;
|
|
24
|
+
//# sourceMappingURL=promise-tracking.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorates a reactive boolean accessor so that calling the generated method
|
|
3
|
+
* sets the property to `true` while the supplied promise is pending, and
|
|
4
|
+
* back to `false` once it resolves or rejects. Re-throws errors.
|
|
5
|
+
*
|
|
6
|
+
* Reentrancy: if the method is called multiple times concurrently, the
|
|
7
|
+
* property only flips back to `false` after ALL outstanding promises settle.
|
|
8
|
+
*
|
|
9
|
+
* Because the method name is a runtime string, TypeScript can't see it on
|
|
10
|
+
* the host class. Consumers add a one-line `declare` next to the accessor.
|
|
11
|
+
*
|
|
12
|
+
* @param methodName The name of the method to add to the host prototype.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* \@promiseTracking('trackLoadingPromise')
|
|
17
|
+
* \@state() accessor isLoading = false;
|
|
18
|
+
* declare trackLoadingPromise: (p: Promise<unknown>) => Promise<void>;
|
|
19
|
+
*
|
|
20
|
+
* await this.trackLoadingPromise(api.load());
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function promiseTracking(methodName) {
|
|
24
|
+
return function (target, propertyKey, _descriptor) {
|
|
25
|
+
const counterKey = Symbol(`__${String(propertyKey)}_count__`);
|
|
26
|
+
Object.defineProperty(target, methodName, {
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: async function (promise) {
|
|
30
|
+
this[counterKey] = (this[counterKey] ?? 0) + 1;
|
|
31
|
+
this[propertyKey] = true;
|
|
32
|
+
try {
|
|
33
|
+
await promise;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
this[counterKey]--;
|
|
37
|
+
if (this[counterKey] === 0) {
|
|
38
|
+
this[propertyKey] = false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=promise-tracking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-tracking.js","sourceRoot":"","sources":["promise-tracking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,OAAO,UAAU,MAAc,EAAE,WAA4B,EAAE,WAA+B;QAC5F,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAE9D,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE;YACxC,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,KAAK,WAAsB,OAAyB;gBACzD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBAC/C,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;gBACzB,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC;gBAChB,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;oBACnB,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;wBAC3B,IAAI,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;oBAC5B,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|