@talismn/util 2.2.0 → 2.3.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/dist/index.d.mts +85 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +85 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +318 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +313 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -157,12 +157,16 @@ export declare const formatCurrencyToParts: (amount: number, currency: string, o
|
|
|
157
157
|
export declare const formatCurrency: (amount: number, currency: string, options?: FormatCurrencyOptions) => string;
|
|
158
158
|
export declare const MAX_DECIMALS_FORMAT = 12;
|
|
159
159
|
/**
|
|
160
|
-
* Custom decimal number formatting for Talisman
|
|
160
|
+
* Custom decimal number formatting for Talisman: `digits` digits, counting the integer part, the
|
|
161
|
+
* last one rounded half away from zero. At 4 digits, 1.23456 is "1.235", 0.0005966 is "0.0006"
|
|
162
|
+
* and 12345 is "12.35K": a value below 1 keeps at most `digits` decimal places, and a value above
|
|
163
|
+
* 9999 takes compact notation. A value closer to zero than the last digit reads "< 0.0001", or
|
|
164
|
+
* "> -0.0001" below zero. A negative value reads as its positive value with a minus sign.
|
|
161
165
|
* note that the NumberFormat().format() call is the ressource heavy part, it's not worth trying to optimize other parts
|
|
162
166
|
* @param num input number
|
|
163
|
-
* @param digits number of
|
|
167
|
+
* @param digits number of digits to display, at least 4
|
|
168
|
+
* @param options formatting options, passed to Intl.NumberFormat
|
|
164
169
|
* @param locale locale used to format the number
|
|
165
|
-
* @param options formatting options
|
|
166
170
|
* @returns the formatted value
|
|
167
171
|
*/
|
|
168
172
|
export declare const formatDecimals: (num?: string | number | null | bignumber_default, digits?: number, options?: Partial<Intl.NumberFormatOptions>, locale?: string) => string;
|
|
@@ -421,6 +425,84 @@ export declare function splitSubject<T>(subject: Subject<T>): readonly [(value:
|
|
|
421
425
|
* stripHexPrefix("1234") // "1234"
|
|
422
426
|
**/
|
|
423
427
|
export declare const stripHexPrefix: (str: string) => string;
|
|
428
|
+
/**
|
|
429
|
+
* Detects when the JS runtime has been suspended, and provides timeouts that count only the
|
|
430
|
+
* time it was running.
|
|
431
|
+
*
|
|
432
|
+
* A mobile OS freezes an app that goes to the background, its webviews included, and a
|
|
433
|
+
* browser can freeze a tab or put a laptop to sleep. No timer fires while the runtime is
|
|
434
|
+
* frozen, and on resume every timer that came due in the meantime fires at once, before the
|
|
435
|
+
* socket messages that arrived while it was frozen. A 30s request timeout armed shortly
|
|
436
|
+
* before a 90s suspension therefore fails its request the moment the runtime resumes,
|
|
437
|
+
* although the answer may already be waiting.
|
|
438
|
+
*
|
|
439
|
+
* A one-second ticker runs while anything is watching. A gap between two ticks longer than
|
|
440
|
+
* `SUSPENSION_GAP_MS` (`HOST_SUSPENSION_GAP_MS` once a host marks suspensions) is taken to be
|
|
441
|
+
* a suspension. Timer callbacks call `checkSuspension()` first, because on resume a due timer
|
|
442
|
+
* can run before the ticker does.
|
|
443
|
+
*
|
|
444
|
+
* A page that is hidden can't tell a freeze from timer throttling: browsers run the timers of
|
|
445
|
+
* a hidden tab once a second, and Chrome once a minute after five minutes. Both leave gaps
|
|
446
|
+
* between ticks while socket messages keep arriving. In a hidden page, the first gap starts a
|
|
447
|
+
* suspension that lasts until the page is shown again, or until its ticks run on time again
|
|
448
|
+
* (a frozen page that resumes while hidden, or an extension's background page, which is never
|
|
449
|
+
* shown). Taking each gap for a resume would restart every timeout once a minute, so that
|
|
450
|
+
* none ever fires.
|
|
451
|
+
*
|
|
452
|
+
* A runtime can also be cut off while it keeps running: a webview whose network traffic goes
|
|
453
|
+
* through its app's native code stays alive while the app is frozen in the background. Its
|
|
454
|
+
* host marks that time with `setSuspended()`. An app can mark its own runtime the same way
|
|
455
|
+
* from the OS's background and foreground events.
|
|
456
|
+
*/
|
|
457
|
+
type ResumeListener = (suspendedMs: number) => void;
|
|
458
|
+
/**
|
|
459
|
+
* Records that the JS runtime is running now. When it last ran longer than
|
|
460
|
+
* `SUSPENSION_GAP_MS` (or `HOST_SUSPENSION_GAP_MS`) ago, it was suspended in between, and the resume listeners run before
|
|
461
|
+
* this returns. When the host or a hidden page holds the suspension, they run once it ends.
|
|
462
|
+
* Cheap enough to call at the start of every timer callback that measures time.
|
|
463
|
+
*/
|
|
464
|
+
export declare const checkSuspension: () => void;
|
|
465
|
+
/**
|
|
466
|
+
* Marks the JS runtime suspended (`true`) or running again (`false`), for a host that knows
|
|
467
|
+
* when the runtime is frozen or cut off (it may keep running). While suspended,
|
|
468
|
+
* `setAwakeTimeout` timeouts don't fire. `setSuspended(false)` is a resume: the timeouts start
|
|
469
|
+
* over, and the resume listeners run with the time since `setSuspended(true)`. When the page
|
|
470
|
+
* is also held suspended (hidden, with a gap between ticks), the resume waits until it is
|
|
471
|
+
* shown or its ticks run on time again.
|
|
472
|
+
*
|
|
473
|
+
* From the first call on, a gap between ticks counts as a suspension only from
|
|
474
|
+
* `HOST_SUSPENSION_GAP_MS` (15s), so that a stall of the JS thread doesn't restart the
|
|
475
|
+
* timeouts. A host calls it at startup with the runtime's state, for that to apply from then.
|
|
476
|
+
*
|
|
477
|
+
* The state is global to the module: the mark reaches the code that reads it (such as
|
|
478
|
+
* `ChainConnectorDot`) only when both load the same copy of `@talismn/util`. A second copy in
|
|
479
|
+
* the bundle, from mismatched `@talismn/*` versions or from CJS and ESM builds side by side,
|
|
480
|
+
* keeps a state of its own, without an error.
|
|
481
|
+
*/
|
|
482
|
+
export declare const setSuspended: (suspended: boolean) => void;
|
|
483
|
+
/**
|
|
484
|
+
* Whether the runtime is held suspended until a later resume: marked by the host
|
|
485
|
+
* (`setSuspended(true)`), or a hidden page whose timers have stopped or been throttled
|
|
486
|
+
*/
|
|
487
|
+
export declare const isSuspended: () => boolean;
|
|
488
|
+
/**
|
|
489
|
+
* When the JS runtime last resumed from a suspension (`Date.now()` time), or -Infinity when
|
|
490
|
+
* no suspension has been seen. A freeze is only seen while something is watching (an
|
|
491
|
+
* `onResume` listener or a pending `setAwakeTimeout`); the end of a suspension the host
|
|
492
|
+
* marked (`setSuspended(false)`) is a resume in any case.
|
|
493
|
+
*/
|
|
494
|
+
export declare const getLastResumedAt: () => number;
|
|
495
|
+
/**
|
|
496
|
+
* Calls `listener` each time the JS runtime resumes from a suspension, with how long it was
|
|
497
|
+
* suspended for. Returns the function that removes it.
|
|
498
|
+
*/
|
|
499
|
+
export declare const onResume: (listener: ResumeListener) => (() => void);
|
|
500
|
+
/**
|
|
501
|
+
* Like `setTimeout`, but time the JS runtime spends suspended does not count. When the runtime
|
|
502
|
+
* resumes from a suspension before the timeout is up, the timeout starts over from the resume,
|
|
503
|
+
* so the work it guards gets its full time again. Returns the function that cancels it.
|
|
504
|
+
*/
|
|
505
|
+
export declare const setAwakeTimeout: (callback: () => void, ms: number) => (() => void);
|
|
424
506
|
export declare const throwAfter: (ms: number, reason: string) => Promise<never>;
|
|
425
507
|
export declare function tokensToPlanck(tokens: string, tokenDecimals: number): string;
|
|
426
508
|
export declare function tokensToPlanck(tokens: string, tokenDecimals?: number): string | undefined;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["BigNumber"],"sources":["../src/addTrailingSlash.ts","../src/assert.ts","../src/BigMath.ts","../src/isHexString.ts","../src/bytes.ts","../src/timeSlicer.ts","../src/chunkedArray.ts","../src/deferred.ts","../src/FunctionPropertyNames.ts","../src/firstThenDebounce.ts","../src/formatCurrency.ts","../src/formatDecimals.ts","../src/formatPrice.ts","../src/getErrorMessage.ts","../src/getLoadable.ts","../src/getLoadableQuery.ts","../src/getQuery.ts","../src/getSharedObservable.ts","../src/hasOwnProperty.ts","../src/isAbortError.ts","../src/isArrayOf.ts","../src/isAscii.ts","../src/isBigInt.ts","../src/isBooleanTrue.ts","../src/isErrorOfName.ts","../src/isNotNil.ts","../src/isPromise.ts","../src/isSubject.ts","../src/isTruthy.ts","../src/jsActivityHook.ts","../src/keepAlive.ts","../src/lruMap.ts","../src/mapChunked.ts","../src/Prettify.ts","../src/planckToTokens.ts","../src/replaySubjectFrom.ts","../src/sleep.ts","../src/splitSubject.ts","../src/stripHexPrefix.ts","../src/throwAfter.ts","../src/tokensToPlanck.ts","../src/validateArrayWithYield.ts","../src/validateHexString.ts","../src/yieldToEventLoop.ts"],"mappings":";;qBAAa,mBAAgB;;;;;;;wBCMb,OAAO,oBAAoB,2CAA2C;;;;;qBCFzE;EACX,IAAG;EAGH,KAAI;EAIJ,IAAG,kBAAc;EAIjB,IAAG,kBAAc;;YChBP;qBAEC,kBAAgB;qBAEhB,cAAW,mBAAqB,SAAS;;;;;qBCGzC,WAAQ,wBAA0B;qBAalC,WAAQ,QAAY,sBAAoB;qBAOxC,cAAW,0BAA4B;qBAGvC,cAAW,QAAY;qBAGvB,cAAW;qBAEX,cAAW;qBAEX,cAAW,0BAA4B;;qBAOvC,WAAQ,4BAAgC,sBAAoB;qBAO5D,eAAS,4BAAmC,kBAAgB;qBAW5D,QAAK,YAAgB,YAAU,YAAc;qBAO7C,SAAM,YAAgB,YAAU,YAAc;;;;;qBAe9C,mBAAgB,iBAAqB;;qBAgBrC,eAAY,gBAAoB,eAAa;qBAK7C,iBAAc,gBAAoB,eAAa;;;;;qBClG/C;YAED;;EAEV;;EAEA,SAAS;;EAET;;EAEA;;YAGU;WACD,SAAS;;EAElB;;EAEA,SAAS;;;;;;;;;;;;EAYT,iBAAiB;;EAEjB;;;;;;qBAOW,qBAAoB;;;;;;;;qBAapB,qBAAgB,UAAA,QAAA,KAAA,UAK1B,sBAAyB;YC5DhB;;EAEV;;EAEA,SAAS;;EAET,SAAS;;EAET;;;;;;;;;qBAcW,mBAA0B,GAAC,gBACtB,KAAG,KACd,MAAM,GAAG,wBAAsB,UAC1B,mBACT;;qBAeU,eAAsB,GAAG,GAAC,gBACrB,KAAG,KACd,MAAM,GAAG,kBAAkB,GAAC,UACvB,mBACT,QAAQ;;qBAOE,iBAAwB,GAAC,gBACpB,KAAG,QACX,MAAM,GAAG,0BAAwB,UAC/B,mBACT,QAAQ,eAAe;;;;;;qBAWb,2BAAkC,GAAC,YAClC,iBAAe,YACf,iBAAe,UACjB;EAAmB,eAAe,GAAG,GAAG,GAAG;MACpD;;;;;;;;wBCpEa,SAAS;EACvB,SAAS,QAAQ;EACjB,UAAU,OAAO,IAAI,YAAY;EACjC,SAAS;EACT;EACA;EACA;;;YCVU,sBAAsB,QAC/B,WAAW,IAAI,EAAE,WAAW,WAAW,mBAClC;YACI,mBAAmB,KAAK,KAAK,GAAG,sBAAsB;YAEtD,yBAAyB,QAClC,WAAW,IAAI,EAAE,WAAW,mBAAmB,WAC1C;YACI,sBAAsB,KAAK,KAAK,GAAG,yBAAyB;;;;;;;qBCH3D,oBACV,GAAC,oBAAoB,iBAAiB,GAAG;KCEvC,wBAAwB,KAAK,KAAK;qBAO1B,4BAAyB;qBA4CzB,wBAAqB,gBAClB,kBACE,UACP,0BACR,KAAK;qBAuCK,iBAAc,gBACX,kBACE,UACP;qBCzGE
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["BigNumber"],"sources":["../src/addTrailingSlash.ts","../src/assert.ts","../src/BigMath.ts","../src/isHexString.ts","../src/bytes.ts","../src/timeSlicer.ts","../src/chunkedArray.ts","../src/deferred.ts","../src/FunctionPropertyNames.ts","../src/firstThenDebounce.ts","../src/formatCurrency.ts","../src/formatDecimals.ts","../src/formatPrice.ts","../src/getErrorMessage.ts","../src/getLoadable.ts","../src/getLoadableQuery.ts","../src/getQuery.ts","../src/getSharedObservable.ts","../src/hasOwnProperty.ts","../src/isAbortError.ts","../src/isArrayOf.ts","../src/isAscii.ts","../src/isBigInt.ts","../src/isBooleanTrue.ts","../src/isErrorOfName.ts","../src/isNotNil.ts","../src/isPromise.ts","../src/isSubject.ts","../src/isTruthy.ts","../src/jsActivityHook.ts","../src/keepAlive.ts","../src/lruMap.ts","../src/mapChunked.ts","../src/Prettify.ts","../src/planckToTokens.ts","../src/replaySubjectFrom.ts","../src/sleep.ts","../src/splitSubject.ts","../src/stripHexPrefix.ts","../src/suspension.ts","../src/throwAfter.ts","../src/tokensToPlanck.ts","../src/validateArrayWithYield.ts","../src/validateHexString.ts","../src/yieldToEventLoop.ts"],"mappings":";;qBAAa,mBAAgB;;;;;;;wBCMb,OAAO,oBAAoB,2CAA2C;;;;;qBCFzE;EACX,IAAG;EAGH,KAAI;EAIJ,IAAG,kBAAc;EAIjB,IAAG,kBAAc;;YChBP;qBAEC,kBAAgB;qBAEhB,cAAW,mBAAqB,SAAS;;;;;qBCGzC,WAAQ,wBAA0B;qBAalC,WAAQ,QAAY,sBAAoB;qBAOxC,cAAW,0BAA4B;qBAGvC,cAAW,QAAY;qBAGvB,cAAW;qBAEX,cAAW;qBAEX,cAAW,0BAA4B;;qBAOvC,WAAQ,4BAAgC,sBAAoB;qBAO5D,eAAS,4BAAmC,kBAAgB;qBAW5D,QAAK,YAAgB,YAAU,YAAc;qBAO7C,SAAM,YAAgB,YAAU,YAAc;;;;;qBAe9C,mBAAgB,iBAAqB;;qBAgBrC,eAAY,gBAAoB,eAAa;qBAK7C,iBAAc,gBAAoB,eAAa;;;;;qBClG/C;YAED;;EAEV;;EAEA,SAAS;;EAET;;EAEA;;YAGU;WACD,SAAS;;EAElB;;EAEA,SAAS;;;;;;;;;;;;EAYT,iBAAiB;;EAEjB;;;;;;qBAOW,qBAAoB;;;;;;;;qBAapB,qBAAgB,UAAA,QAAA,KAAA,UAK1B,sBAAyB;YC5DhB;;EAEV;;EAEA,SAAS;;EAET,SAAS;;EAET;;;;;;;;;qBAcW,mBAA0B,GAAC,gBACtB,KAAG,KACd,MAAM,GAAG,wBAAsB,UAC1B,mBACT;;qBAeU,eAAsB,GAAG,GAAC,gBACrB,KAAG,KACd,MAAM,GAAG,kBAAkB,GAAC,UACvB,mBACT,QAAQ;;qBAOE,iBAAwB,GAAC,gBACpB,KAAG,QACX,MA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ency: string, o
|
|
|
157
157
|
export declare const formatCurrency: (amount: number, currency: string, options?: FormatCurrencyOptions) => string;
|
|
158
158
|
export declare const MAX_DECIMALS_FORMAT = 12;
|
|
159
159
|
/**
|
|
160
|
-
* Custom decimal number formatting for Talisman
|
|
160
|
+
* Custom decimal number formatting for Talisman: `digits` digits, counting the integer part, the
|
|
161
|
+
* last one rounded half away from zero. At 4 digits, 1.23456 is "1.235", 0.0005966 is "0.0006"
|
|
162
|
+
* and 12345 is "12.35K": a value below 1 keeps at most `digits` decimal places, and a value above
|
|
163
|
+
* 9999 takes compact notation. A value closer to zero than the last digit reads "< 0.0001", or
|
|
164
|
+
* "> -0.0001" below zero. A negative value reads as its positive value with a minus sign.
|
|
161
165
|
* note that the NumberFormat().format() call is the ressource heavy part, it's not worth trying to optimize other parts
|
|
162
166
|
* @param num input number
|
|
163
|
-
* @param digits number of
|
|
167
|
+
* @param digits number of digits to display, at least 4
|
|
168
|
+
* @param options formatting options, passed to Intl.NumberFormat
|
|
164
169
|
* @param locale locale used to format the number
|
|
165
|
-
* @param options formatting options
|
|
166
170
|
* @returns the formatted value
|
|
167
171
|
*/
|
|
168
172
|
export declare const formatDecimals: (num?: string | number | null | bignumber_default, digits?: number, options?: Partial<Intl.NumberFormatOptions>, locale?: string) => string;
|
|
@@ -421,6 +425,84 @@ export declare function splitSubject<T>(subject: Subject<T>): readonly [(value:
|
|
|
421
425
|
* stripHexPrefix("1234") // "1234"
|
|
422
426
|
**/
|
|
423
427
|
export declare const stripHexPrefix: (str: string) => string;
|
|
428
|
+
/**
|
|
429
|
+
* Detects when the JS runtime has been suspended, and provides timeouts that count only the
|
|
430
|
+
* time it was running.
|
|
431
|
+
*
|
|
432
|
+
* A mobile OS freezes an app that goes to the background, its webviews included, and a
|
|
433
|
+
* browser can freeze a tab or put a laptop to sleep. No timer fires while the runtime is
|
|
434
|
+
* frozen, and on resume every timer that came due in the meantime fires at once, before the
|
|
435
|
+
* socket messages that arrived while it was frozen. A 30s request timeout armed shortly
|
|
436
|
+
* before a 90s suspension therefore fails its request the moment the runtime resumes,
|
|
437
|
+
* although the answer may already be waiting.
|
|
438
|
+
*
|
|
439
|
+
* A one-second ticker runs while anything is watching. A gap between two ticks longer than
|
|
440
|
+
* `SUSPENSION_GAP_MS` (`HOST_SUSPENSION_GAP_MS` once a host marks suspensions) is taken to be
|
|
441
|
+
* a suspension. Timer callbacks call `checkSuspension()` first, because on resume a due timer
|
|
442
|
+
* can run before the ticker does.
|
|
443
|
+
*
|
|
444
|
+
* A page that is hidden can't tell a freeze from timer throttling: browsers run the timers of
|
|
445
|
+
* a hidden tab once a second, and Chrome once a minute after five minutes. Both leave gaps
|
|
446
|
+
* between ticks while socket messages keep arriving. In a hidden page, the first gap starts a
|
|
447
|
+
* suspension that lasts until the page is shown again, or until its ticks run on time again
|
|
448
|
+
* (a frozen page that resumes while hidden, or an extension's background page, which is never
|
|
449
|
+
* shown). Taking each gap for a resume would restart every timeout once a minute, so that
|
|
450
|
+
* none ever fires.
|
|
451
|
+
*
|
|
452
|
+
* A runtime can also be cut off while it keeps running: a webview whose network traffic goes
|
|
453
|
+
* through its app's native code stays alive while the app is frozen in the background. Its
|
|
454
|
+
* host marks that time with `setSuspended()`. An app can mark its own runtime the same way
|
|
455
|
+
* from the OS's background and foreground events.
|
|
456
|
+
*/
|
|
457
|
+
type ResumeListener = (suspendedMs: number) => void;
|
|
458
|
+
/**
|
|
459
|
+
* Records that the JS runtime is running now. When it last ran longer than
|
|
460
|
+
* `SUSPENSION_GAP_MS` (or `HOST_SUSPENSION_GAP_MS`) ago, it was suspended in between, and the resume listeners run before
|
|
461
|
+
* this returns. When the host or a hidden page holds the suspension, they run once it ends.
|
|
462
|
+
* Cheap enough to call at the start of every timer callback that measures time.
|
|
463
|
+
*/
|
|
464
|
+
export declare const checkSuspension: () => void;
|
|
465
|
+
/**
|
|
466
|
+
* Marks the JS runtime suspended (`true`) or running again (`false`), for a host that knows
|
|
467
|
+
* when the runtime is frozen or cut off (it may keep running). While suspended,
|
|
468
|
+
* `setAwakeTimeout` timeouts don't fire. `setSuspended(false)` is a resume: the timeouts start
|
|
469
|
+
* over, and the resume listeners run with the time since `setSuspended(true)`. When the page
|
|
470
|
+
* is also held suspended (hidden, with a gap between ticks), the resume waits until it is
|
|
471
|
+
* shown or its ticks run on time again.
|
|
472
|
+
*
|
|
473
|
+
* From the first call on, a gap between ticks counts as a suspension only from
|
|
474
|
+
* `HOST_SUSPENSION_GAP_MS` (15s), so that a stall of the JS thread doesn't restart the
|
|
475
|
+
* timeouts. A host calls it at startup with the runtime's state, for that to apply from then.
|
|
476
|
+
*
|
|
477
|
+
* The state is global to the module: the mark reaches the code that reads it (such as
|
|
478
|
+
* `ChainConnectorDot`) only when both load the same copy of `@talismn/util`. A second copy in
|
|
479
|
+
* the bundle, from mismatched `@talismn/*` versions or from CJS and ESM builds side by side,
|
|
480
|
+
* keeps a state of its own, without an error.
|
|
481
|
+
*/
|
|
482
|
+
export declare const setSuspended: (suspended: boolean) => void;
|
|
483
|
+
/**
|
|
484
|
+
* Whether the runtime is held suspended until a later resume: marked by the host
|
|
485
|
+
* (`setSuspended(true)`), or a hidden page whose timers have stopped or been throttled
|
|
486
|
+
*/
|
|
487
|
+
export declare const isSuspended: () => boolean;
|
|
488
|
+
/**
|
|
489
|
+
* When the JS runtime last resumed from a suspension (`Date.now()` time), or -Infinity when
|
|
490
|
+
* no suspension has been seen. A freeze is only seen while something is watching (an
|
|
491
|
+
* `onResume` listener or a pending `setAwakeTimeout`); the end of a suspension the host
|
|
492
|
+
* marked (`setSuspended(false)`) is a resume in any case.
|
|
493
|
+
*/
|
|
494
|
+
export declare const getLastResumedAt: () => number;
|
|
495
|
+
/**
|
|
496
|
+
* Calls `listener` each time the JS runtime resumes from a suspension, with how long it was
|
|
497
|
+
* suspended for. Returns the function that removes it.
|
|
498
|
+
*/
|
|
499
|
+
export declare const onResume: (listener: ResumeListener) => (() => void);
|
|
500
|
+
/**
|
|
501
|
+
* Like `setTimeout`, but time the JS runtime spends suspended does not count. When the runtime
|
|
502
|
+
* resumes from a suspension before the timeout is up, the timeout starts over from the resume,
|
|
503
|
+
* so the work it guards gets its full time again. Returns the function that cancels it.
|
|
504
|
+
*/
|
|
505
|
+
export declare const setAwakeTimeout: (callback: () => void, ms: number) => (() => void);
|
|
424
506
|
export declare const throwAfter: (ms: number, reason: string) => Promise<never>;
|
|
425
507
|
export declare function tokensToPlanck(tokens: string, tokenDecimals: number): string;
|
|
426
508
|
export declare function tokensToPlanck(tokens: string, tokenDecimals?: number): string | undefined;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["BigNumber"],"sources":["../src/addTrailingSlash.ts","../src/assert.ts","../src/BigMath.ts","../src/isHexString.ts","../src/bytes.ts","../src/timeSlicer.ts","../src/chunkedArray.ts","../src/deferred.ts","../src/FunctionPropertyNames.ts","../src/firstThenDebounce.ts","../src/formatCurrency.ts","../src/formatDecimals.ts","../src/formatPrice.ts","../src/getErrorMessage.ts","../src/getLoadable.ts","../src/getLoadableQuery.ts","../src/getQuery.ts","../src/getSharedObservable.ts","../src/hasOwnProperty.ts","../src/isAbortError.ts","../src/isArrayOf.ts","../src/isAscii.ts","../src/isBigInt.ts","../src/isBooleanTrue.ts","../src/isErrorOfName.ts","../src/isNotNil.ts","../src/isPromise.ts","../src/isSubject.ts","../src/isTruthy.ts","../src/jsActivityHook.ts","../src/keepAlive.ts","../src/lruMap.ts","../src/mapChunked.ts","../src/Prettify.ts","../src/planckToTokens.ts","../src/replaySubjectFrom.ts","../src/sleep.ts","../src/splitSubject.ts","../src/stripHexPrefix.ts","../src/throwAfter.ts","../src/tokensToPlanck.ts","../src/validateArrayWithYield.ts","../src/validateHexString.ts","../src/yieldToEventLoop.ts"],"mappings":";;qBAAa,mBAAgB;;;;;;;wBCMb,OAAO,oBAAoB,2CAA2C;;;;;qBCFzE;EACX,IAAG;EAGH,KAAI;EAIJ,I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I,mBAAmB,KAAK,KAAK,GAAG,sBAAsB;YAEtD,yBAAyB,QAClC,WAAW,IAAI,EAAE,WAAW,mBAAmB,WAC1C;YACI,sBAAsB,KAAK,KAAK,GAAG,yBAAyB;;;;;;;qBCH3D,oBACV,GAAC,oBAAoB,iBAAiB,GAAG;KCEvC,wBAAwB,KAAK,KAAK;qBAO1B,4BAAyB;qBA4CzB,wBAAqB,gBAClB,kBACE,UACP,0BACR,KAAK;qBAuCK,iBAAc,gBACX,kBACE,UACP;qBCzGE
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["BigNumber"],"sources":["../src/addTrailingSlash.ts","../src/assert.ts","../src/BigMath.ts","../src/isHexString.ts","../src/bytes.ts","../src/timeSlicer.ts","../src/chunkedArray.ts","../src/deferred.ts","../src/FunctionPropertyNames.ts","../src/firstThenDebounce.ts","../src/formatCurrency.ts","../src/formatDecimals.ts","../src/formatPrice.ts","../src/getErrorMessage.ts","../src/getLoadable.ts","../src/getLoadableQuery.ts","../src/getQuery.ts","../src/getSharedObservable.ts","../src/hasOwnProperty.ts","../src/isAbortError.ts","../src/isArrayOf.ts","../src/isAscii.ts","../src/isBigInt.ts","../src/isBooleanTrue.ts","../src/isErrorOfName.ts","../src/isNotNil.ts","../src/isPromise.ts","../src/isSubject.ts","../src/isTruthy.ts","../src/jsActivityHook.ts","../src/keepAlive.ts","../src/lruMap.ts","../src/mapChunked.ts","../src/Prettify.ts","../src/planckToTokens.ts","../src/replaySubjectFrom.ts","../src/sleep.ts","../src/splitSubject.ts","../src/stripHexPrefix.ts","../src/suspension.ts","../src/throwAfter.ts","../src/tokensToPlanck.ts","../src/validateArrayWithYield.ts","../src/validateHexString.ts","../src/yieldToEventLoop.ts"],"mappings":";;qBAAa,mBAAgB;;;;;;;wBCMb,OAAO,oBAAoB,2CAA2C;;;;;qBCFzE;EACX,IAAG;EAGH,KAAI;EAIJ,IAAG,kBAAc;EAIjB,IAAG,kBAAc;;YChBP;qBAEC,kBAAgB;qBAEhB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iBAAiB;;;;;;;;;;;qBCUnC,oBAAqB,GAAC,cACnB,IAAI,QAAQ,KAAK,cAAc,OAC5C,cAAc;qBChBJ,QAAK,eAAc;;;;;;;;;;wBCWhB,aAAa,GAAG,SAAS,QAAQ,gBAAE,OAC5B,YAAC,WAAA;;;;;;;;;;qBCHX,iBAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KCgDtB,kBAAkB;;;;;;;qBA+IV;;;;;;;;;;;;;;;;;;qBA8CA,eAAY;;;;;qBAqBZ;;;;;;;qBAWA;;;;;qBASA,WAAQ,UAAc;;;;;;qBAiBtB,kBAAe,sBAAwB;qBChTvC,aAAU,YAAc,mBAAgB;wBCErC,eAAe,gBAAgB;wBAC/B,eAAe,gBAAgB;wBAC/B,eAAe,iBAAiB;YCFpC,gBAAgB,GAAG;EAAO;EAAe,MAAM;;EAAQ;EAAgB,OAAO;;YAE9E,sBAAsB,GAAG;EAC/B;EAAe,MAAM;;EACrB;EAAgB;IAAU;IAAe,OAAO;;;;;;;;;;;qBAUzC,yBAAgC,GAAG,GAAC,2BACtB,YACb,eAAe,kBAAkB,gBAAgB,GAAG,IAAE,UACxD,mBACT,QAAQ,sBAAsB,GAAG;;;;;;;;;;;qBCVvB,oBAAiB;qBCkBjB,wBAAuB"}
|
package/dist/index.js
CHANGED
|
@@ -399,12 +399,16 @@ const formatCurrency = (amount, currency, options = {}) => formatCurrencyToParts
|
|
|
399
399
|
const MIN_DIGITS = 4;
|
|
400
400
|
const MAX_DECIMALS_FORMAT = 12;
|
|
401
401
|
/**
|
|
402
|
-
* Custom decimal number formatting for Talisman
|
|
402
|
+
* Custom decimal number formatting for Talisman: `digits` digits, counting the integer part, the
|
|
403
|
+
* last one rounded half away from zero. At 4 digits, 1.23456 is "1.235", 0.0005966 is "0.0006"
|
|
404
|
+
* and 12345 is "12.35K": a value below 1 keeps at most `digits` decimal places, and a value above
|
|
405
|
+
* 9999 takes compact notation. A value closer to zero than the last digit reads "< 0.0001", or
|
|
406
|
+
* "> -0.0001" below zero. A negative value reads as its positive value with a minus sign.
|
|
403
407
|
* note that the NumberFormat().format() call is the ressource heavy part, it's not worth trying to optimize other parts
|
|
404
408
|
* @param num input number
|
|
405
|
-
* @param digits number of
|
|
409
|
+
* @param digits number of digits to display, at least 4
|
|
410
|
+
* @param options formatting options, passed to Intl.NumberFormat
|
|
406
411
|
* @param locale locale used to format the number
|
|
407
|
-
* @param options formatting options
|
|
408
412
|
* @returns the formatted value
|
|
409
413
|
*/
|
|
410
414
|
const formatDecimals = (num, digits = MIN_DIGITS, options = {}, locale = "en-US") => {
|
|
@@ -412,20 +416,21 @@ const formatDecimals = (num, digits = MIN_DIGITS, options = {}, locale = "en-US"
|
|
|
412
416
|
if (digits < MIN_DIGITS) digits = MIN_DIGITS;
|
|
413
417
|
const value = new configureBigNumber_default(num);
|
|
414
418
|
const minDisplayVal = 1 / 10 ** digits;
|
|
415
|
-
if (value.gt(0) && value.lt(minDisplayVal)) return `< ${formatDecimals(minDisplayVal)}`;
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
+
if (value.gt(0) && value.lt(minDisplayVal)) return `< ${formatDecimals(minDisplayVal, digits, options, locale)}`;
|
|
420
|
+
if (value.lt(0) && value.gt(-minDisplayVal)) return `> ${formatDecimals(-minDisplayVal, digits, options, locale)}`;
|
|
421
|
+
const integerPart = value.abs().integerValue();
|
|
422
|
+
const intDigits = integerPart.isEqualTo(0) ? 0 : integerPart.toString().length;
|
|
423
|
+
let roundedValue = value;
|
|
419
424
|
const excessFractionDigitsPow10 = new configureBigNumber_default(10).pow(digits > intDigits ? digits - intDigits : 0);
|
|
420
|
-
|
|
425
|
+
roundedValue = roundedValue.multipliedBy(excessFractionDigitsPow10).integerValue().dividedBy(excessFractionDigitsPow10);
|
|
421
426
|
const excessIntegerDigits = new configureBigNumber_default(intDigits > digits ? intDigits - digits : 0);
|
|
422
427
|
const excessIntegerDigitsPow10 = new configureBigNumber_default(10).pow(excessIntegerDigits);
|
|
423
|
-
if (excessIntegerDigits.gt(0))
|
|
428
|
+
if (excessIntegerDigits.gt(0)) roundedValue = roundedValue.dividedBy(excessIntegerDigitsPow10).integerValue().multipliedBy(excessIntegerDigitsPow10);
|
|
424
429
|
return Intl.NumberFormat(locale, {
|
|
425
|
-
notation:
|
|
426
|
-
maximumSignificantDigits: Math.max(1, Math.min(digits + (
|
|
430
|
+
notation: roundedValue.abs().gt(9999) ? "compact" : "standard",
|
|
431
|
+
maximumSignificantDigits: Math.max(1, Math.min(digits + (roundedValue.abs().lt(1) ? 1 : 0), 21)),
|
|
427
432
|
...options
|
|
428
|
-
}).format(
|
|
433
|
+
}).format(roundedValue.isZero() ? 0 : roundedValue.toNumber());
|
|
429
434
|
};
|
|
430
435
|
// src/formatPrice.ts
|
|
431
436
|
const getPriceOptions = (price, compact) => ({
|
|
@@ -879,6 +884,301 @@ function splitSubject(subject) {
|
|
|
879
884
|
* stripHexPrefix("1234") // "1234"
|
|
880
885
|
**/
|
|
881
886
|
const stripHexPrefix = (str) => str.startsWith("0x") ? str.slice(2) : str;
|
|
887
|
+
// src/suspension.ts
|
|
888
|
+
/**
|
|
889
|
+
* Detects when the JS runtime has been suspended, and provides timeouts that count only the
|
|
890
|
+
* time it was running.
|
|
891
|
+
*
|
|
892
|
+
* A mobile OS freezes an app that goes to the background, its webviews included, and a
|
|
893
|
+
* browser can freeze a tab or put a laptop to sleep. No timer fires while the runtime is
|
|
894
|
+
* frozen, and on resume every timer that came due in the meantime fires at once, before the
|
|
895
|
+
* socket messages that arrived while it was frozen. A 30s request timeout armed shortly
|
|
896
|
+
* before a 90s suspension therefore fails its request the moment the runtime resumes,
|
|
897
|
+
* although the answer may already be waiting.
|
|
898
|
+
*
|
|
899
|
+
* A one-second ticker runs while anything is watching. A gap between two ticks longer than
|
|
900
|
+
* `SUSPENSION_GAP_MS` (`HOST_SUSPENSION_GAP_MS` once a host marks suspensions) is taken to be
|
|
901
|
+
* a suspension. Timer callbacks call `checkSuspension()` first, because on resume a due timer
|
|
902
|
+
* can run before the ticker does.
|
|
903
|
+
*
|
|
904
|
+
* A page that is hidden can't tell a freeze from timer throttling: browsers run the timers of
|
|
905
|
+
* a hidden tab once a second, and Chrome once a minute after five minutes. Both leave gaps
|
|
906
|
+
* between ticks while socket messages keep arriving. In a hidden page, the first gap starts a
|
|
907
|
+
* suspension that lasts until the page is shown again, or until its ticks run on time again
|
|
908
|
+
* (a frozen page that resumes while hidden, or an extension's background page, which is never
|
|
909
|
+
* shown). Taking each gap for a resume would restart every timeout once a minute, so that
|
|
910
|
+
* none ever fires.
|
|
911
|
+
*
|
|
912
|
+
* A runtime can also be cut off while it keeps running: a webview whose network traffic goes
|
|
913
|
+
* through its app's native code stays alive while the app is frozen in the background. Its
|
|
914
|
+
* host marks that time with `setSuspended()`. An app can mark its own runtime the same way
|
|
915
|
+
* from the OS's background and foreground events.
|
|
916
|
+
*/
|
|
917
|
+
const TICK_MS = 1e3;
|
|
918
|
+
/**
|
|
919
|
+
* A gap between ticks longer than this is a suspension. Well above the longest stall the JS
|
|
920
|
+
* thread is expected to have while it runs, so that a busy thread is not taken for a frozen
|
|
921
|
+
* one.
|
|
922
|
+
*/
|
|
923
|
+
const SUSPENSION_GAP_MS = 5e3;
|
|
924
|
+
/**
|
|
925
|
+
* A gap between ticks longer than this is a suspension once a host has marked suspensions
|
|
926
|
+
* (`setSuspended`). The marks cover the freezes the host knows of, and a gap only has to
|
|
927
|
+
* catch one whose mark arrived too late, such as a webview frozen before its app's message
|
|
928
|
+
* reached it. A stall of the JS thread under this long (a metadata parse on a slow phone)
|
|
929
|
+
* then doesn't restart the timeouts.
|
|
930
|
+
*/
|
|
931
|
+
const HOST_SUSPENSION_GAP_MS = 15e3;
|
|
932
|
+
/**
|
|
933
|
+
* A tick that comes `TICK_MS / 2` to this long after the one before is on time. Browsers
|
|
934
|
+
* align a hidden page's timers to whole seconds, so its ticks can be up to two seconds apart.
|
|
935
|
+
*/
|
|
936
|
+
const ON_TIME_TICK_GAP_MS = 3e3;
|
|
937
|
+
/** On-time ticks in a row that end a hidden page's suspension */
|
|
938
|
+
const ON_TIME_TICKS_TO_RESUME = 5;
|
|
939
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
940
|
+
let holds = 0;
|
|
941
|
+
let ticker = null;
|
|
942
|
+
let lastRunAt = 0;
|
|
943
|
+
/** when the ticker last ran */
|
|
944
|
+
let lastTickAt = 0;
|
|
945
|
+
/** on-time ticks in a row since a hidden page's suspension started */
|
|
946
|
+
let onTimeTicks = 0;
|
|
947
|
+
/** how far the clock has moved back in all, for the timeouts to shift their start by */
|
|
948
|
+
let clockMovedBackMs = 0;
|
|
949
|
+
let lastResumedAt = Number.NEGATIVE_INFINITY;
|
|
950
|
+
/** when the host marked the runtime suspended (`setSuspended(true)`), or null */
|
|
951
|
+
let suspendedSince = null;
|
|
952
|
+
/** whether the page (when there is one) is hidden */
|
|
953
|
+
let pageHidden = false;
|
|
954
|
+
/** the longest gap between ticks since the page was hidden */
|
|
955
|
+
let hiddenGapMs = 0;
|
|
956
|
+
/** a suspension that has ended for the host or the page while the other still holds it */
|
|
957
|
+
let pending = null;
|
|
958
|
+
let watchingPage = false;
|
|
959
|
+
/** whether a host has marked suspensions (`setSuspended`) */
|
|
960
|
+
let hostMarksSuspensions = false;
|
|
961
|
+
const suspensionGapMs = () => hostMarksSuspensions ? HOST_SUSPENSION_GAP_MS : SUSPENSION_GAP_MS;
|
|
962
|
+
const getPage = () => {
|
|
963
|
+
const page = globalThis.document;
|
|
964
|
+
return typeof page?.addEventListener === "function" ? page : void 0;
|
|
965
|
+
};
|
|
966
|
+
const isHeld = () => suspendedSince !== null || pageHidden && hiddenGapMs > suspensionGapMs();
|
|
967
|
+
/** Ends the host's or the page's part of a suspension, and resumes once neither holds it */
|
|
968
|
+
const endHold = (now, ms, byHost) => {
|
|
969
|
+
pending = {
|
|
970
|
+
ms: Math.max(pending?.ms ?? 0, ms),
|
|
971
|
+
byHost: (pending?.byHost ?? false) || byHost
|
|
972
|
+
};
|
|
973
|
+
if (isHeld()) return;
|
|
974
|
+
const ended = pending;
|
|
975
|
+
pending = null;
|
|
976
|
+
lastRunAt = now;
|
|
977
|
+
if (ended.byHost || ended.ms > suspensionGapMs()) resume(now, ended.ms);
|
|
978
|
+
};
|
|
979
|
+
const handleVisibilityChange = () => {
|
|
980
|
+
const hidden = getPage()?.visibilityState === "hidden";
|
|
981
|
+
if (hidden === pageHidden) return;
|
|
982
|
+
if (hidden) {
|
|
983
|
+
checkSuspension();
|
|
984
|
+
pageHidden = true;
|
|
985
|
+
hiddenGapMs = 0;
|
|
986
|
+
onTimeTicks = 0;
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
const now = Date.now();
|
|
990
|
+
followClock(now);
|
|
991
|
+
const ms = Math.max(hiddenGapMs, ticker ? now - lastRunAt : 0);
|
|
992
|
+
pageHidden = false;
|
|
993
|
+
endPageHold(now, ms);
|
|
994
|
+
};
|
|
995
|
+
const endPageHold = (now, ms) => {
|
|
996
|
+
hiddenGapMs = 0;
|
|
997
|
+
onTimeTicks = 0;
|
|
998
|
+
endHold(now, ms, false);
|
|
999
|
+
};
|
|
1000
|
+
/**
|
|
1001
|
+
* Ends a hidden page's suspension once its ticks have run on time for a while: its timers run
|
|
1002
|
+
* at their normal pace again. A tick that runs right after another (the timers that came due
|
|
1003
|
+
* during a freeze, run together) counts neither way.
|
|
1004
|
+
*/
|
|
1005
|
+
const tick = () => {
|
|
1006
|
+
const now = Date.now();
|
|
1007
|
+
const sinceLastTick = now - lastTickAt;
|
|
1008
|
+
lastTickAt = now;
|
|
1009
|
+
checkSuspension();
|
|
1010
|
+
if (!pageHidden || hiddenGapMs <= suspensionGapMs()) return;
|
|
1011
|
+
if (sinceLastTick > ON_TIME_TICK_GAP_MS) onTimeTicks = 0;
|
|
1012
|
+
else if (sinceLastTick >= TICK_MS / 2) onTimeTicks++;
|
|
1013
|
+
if (onTimeTicks >= ON_TIME_TICKS_TO_RESUME) endPageHold(now, hiddenGapMs);
|
|
1014
|
+
};
|
|
1015
|
+
const watchPage = () => {
|
|
1016
|
+
const page = getPage();
|
|
1017
|
+
if (watchingPage || !page) return;
|
|
1018
|
+
watchingPage = true;
|
|
1019
|
+
pageHidden = page.visibilityState === "hidden";
|
|
1020
|
+
page.addEventListener("visibilitychange", handleVisibilityChange);
|
|
1021
|
+
};
|
|
1022
|
+
const hold = () => {
|
|
1023
|
+
holds++;
|
|
1024
|
+
if (ticker) return;
|
|
1025
|
+
watchPage();
|
|
1026
|
+
const now = Date.now();
|
|
1027
|
+
followClock(now);
|
|
1028
|
+
lastRunAt = now;
|
|
1029
|
+
lastTickAt = now;
|
|
1030
|
+
ticker = setInterval(tick, TICK_MS);
|
|
1031
|
+
};
|
|
1032
|
+
const release = () => {
|
|
1033
|
+
holds--;
|
|
1034
|
+
if (holds > 0 || !ticker) return;
|
|
1035
|
+
clearInterval(ticker);
|
|
1036
|
+
ticker = null;
|
|
1037
|
+
};
|
|
1038
|
+
/**
|
|
1039
|
+
* Shifts the times kept here when the clock has moved back since the runtime last ran, so that
|
|
1040
|
+
* time since a resume, or since the host marked a suspension, keeps counting from where it was
|
|
1041
|
+
*/
|
|
1042
|
+
const followClock = (now) => {
|
|
1043
|
+
if (now >= lastRunAt) return;
|
|
1044
|
+
const movedBackMs = lastRunAt - now;
|
|
1045
|
+
clockMovedBackMs += movedBackMs;
|
|
1046
|
+
lastRunAt = now;
|
|
1047
|
+
lastTickAt -= movedBackMs;
|
|
1048
|
+
lastResumedAt -= movedBackMs;
|
|
1049
|
+
if (suspendedSince !== null) suspendedSince -= movedBackMs;
|
|
1050
|
+
};
|
|
1051
|
+
/**
|
|
1052
|
+
* Records that the JS runtime is running now. When it last ran longer than
|
|
1053
|
+
* `SUSPENSION_GAP_MS` (or `HOST_SUSPENSION_GAP_MS`) ago, it was suspended in between, and the resume listeners run before
|
|
1054
|
+
* this returns. When the host or a hidden page holds the suspension, they run once it ends.
|
|
1055
|
+
* Cheap enough to call at the start of every timer callback that measures time.
|
|
1056
|
+
*/
|
|
1057
|
+
const checkSuspension = () => {
|
|
1058
|
+
const now = Date.now();
|
|
1059
|
+
followClock(now);
|
|
1060
|
+
const suspendedMs = ticker ? now - lastRunAt : 0;
|
|
1061
|
+
lastRunAt = now;
|
|
1062
|
+
if (pageHidden) {
|
|
1063
|
+
hiddenGapMs = Math.max(hiddenGapMs, suspendedMs);
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
if (suspendedSince !== null || suspendedMs <= suspensionGapMs()) return;
|
|
1067
|
+
resume(now, suspendedMs);
|
|
1068
|
+
};
|
|
1069
|
+
const resume = (now, suspendedMs) => {
|
|
1070
|
+
lastResumedAt = now;
|
|
1071
|
+
for (const listener of [...listeners]) try {
|
|
1072
|
+
listener(suspendedMs);
|
|
1073
|
+
} catch (error) {
|
|
1074
|
+
queueMicrotask(() => {
|
|
1075
|
+
throw error;
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
/**
|
|
1080
|
+
* Marks the JS runtime suspended (`true`) or running again (`false`), for a host that knows
|
|
1081
|
+
* when the runtime is frozen or cut off (it may keep running). While suspended,
|
|
1082
|
+
* `setAwakeTimeout` timeouts don't fire. `setSuspended(false)` is a resume: the timeouts start
|
|
1083
|
+
* over, and the resume listeners run with the time since `setSuspended(true)`. When the page
|
|
1084
|
+
* is also held suspended (hidden, with a gap between ticks), the resume waits until it is
|
|
1085
|
+
* shown or its ticks run on time again.
|
|
1086
|
+
*
|
|
1087
|
+
* From the first call on, a gap between ticks counts as a suspension only from
|
|
1088
|
+
* `HOST_SUSPENSION_GAP_MS` (15s), so that a stall of the JS thread doesn't restart the
|
|
1089
|
+
* timeouts. A host calls it at startup with the runtime's state, for that to apply from then.
|
|
1090
|
+
*
|
|
1091
|
+
* The state is global to the module: the mark reaches the code that reads it (such as
|
|
1092
|
+
* `ChainConnectorDot`) only when both load the same copy of `@talismn/util`. A second copy in
|
|
1093
|
+
* the bundle, from mismatched `@talismn/*` versions or from CJS and ESM builds side by side,
|
|
1094
|
+
* keeps a state of its own, without an error.
|
|
1095
|
+
*/
|
|
1096
|
+
const setSuspended = (suspended) => {
|
|
1097
|
+
hostMarksSuspensions = true;
|
|
1098
|
+
if (suspended) {
|
|
1099
|
+
checkSuspension();
|
|
1100
|
+
suspendedSince ??= Date.now();
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
if (suspendedSince === null) return;
|
|
1104
|
+
const now = Date.now();
|
|
1105
|
+
followClock(now);
|
|
1106
|
+
const suspendedMs = now - suspendedSince;
|
|
1107
|
+
suspendedSince = null;
|
|
1108
|
+
endHold(now, suspendedMs, true);
|
|
1109
|
+
};
|
|
1110
|
+
/**
|
|
1111
|
+
* Whether the runtime is held suspended until a later resume: marked by the host
|
|
1112
|
+
* (`setSuspended(true)`), or a hidden page whose timers have stopped or been throttled
|
|
1113
|
+
*/
|
|
1114
|
+
const isSuspended = () => {
|
|
1115
|
+
checkSuspension();
|
|
1116
|
+
return isHeld();
|
|
1117
|
+
};
|
|
1118
|
+
/**
|
|
1119
|
+
* When the JS runtime last resumed from a suspension (`Date.now()` time), or -Infinity when
|
|
1120
|
+
* no suspension has been seen. A freeze is only seen while something is watching (an
|
|
1121
|
+
* `onResume` listener or a pending `setAwakeTimeout`); the end of a suspension the host
|
|
1122
|
+
* marked (`setSuspended(false)`) is a resume in any case.
|
|
1123
|
+
*/
|
|
1124
|
+
const getLastResumedAt = () => {
|
|
1125
|
+
checkSuspension();
|
|
1126
|
+
return lastResumedAt;
|
|
1127
|
+
};
|
|
1128
|
+
/**
|
|
1129
|
+
* Calls `listener` each time the JS runtime resumes from a suspension, with how long it was
|
|
1130
|
+
* suspended for. Returns the function that removes it.
|
|
1131
|
+
*/
|
|
1132
|
+
const onResume = (listener) => {
|
|
1133
|
+
listeners.add(listener);
|
|
1134
|
+
hold();
|
|
1135
|
+
let removed = false;
|
|
1136
|
+
return () => {
|
|
1137
|
+
if (removed) return;
|
|
1138
|
+
removed = true;
|
|
1139
|
+
listeners.delete(listener);
|
|
1140
|
+
release();
|
|
1141
|
+
};
|
|
1142
|
+
};
|
|
1143
|
+
/**
|
|
1144
|
+
* Like `setTimeout`, but time the JS runtime spends suspended does not count. When the runtime
|
|
1145
|
+
* resumes from a suspension before the timeout is up, the timeout starts over from the resume,
|
|
1146
|
+
* so the work it guards gets its full time again. Returns the function that cancels it.
|
|
1147
|
+
*/
|
|
1148
|
+
const setAwakeTimeout = (callback, ms) => {
|
|
1149
|
+
hold();
|
|
1150
|
+
let startedAt = Date.now();
|
|
1151
|
+
let clockMovedBackAtStartMs = clockMovedBackMs;
|
|
1152
|
+
let token = null;
|
|
1153
|
+
let done = false;
|
|
1154
|
+
const finish = () => {
|
|
1155
|
+
if (done) return;
|
|
1156
|
+
done = true;
|
|
1157
|
+
if (token) clearTimeout(token);
|
|
1158
|
+
token = null;
|
|
1159
|
+
release();
|
|
1160
|
+
};
|
|
1161
|
+
const fire = () => {
|
|
1162
|
+
checkSuspension();
|
|
1163
|
+
if (done) return;
|
|
1164
|
+
if (isHeld()) {
|
|
1165
|
+
token = setTimeout(fire, ms);
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
startedAt -= clockMovedBackMs - clockMovedBackAtStartMs;
|
|
1169
|
+
clockMovedBackAtStartMs = clockMovedBackMs;
|
|
1170
|
+
const now = Date.now();
|
|
1171
|
+
const remaining = ms - (now - Math.min(now, Math.max(startedAt, lastResumedAt)));
|
|
1172
|
+
if (remaining > 0) {
|
|
1173
|
+
token = setTimeout(fire, remaining);
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
finish();
|
|
1177
|
+
callback();
|
|
1178
|
+
};
|
|
1179
|
+
token = setTimeout(fire, ms);
|
|
1180
|
+
return finish;
|
|
1181
|
+
};
|
|
882
1182
|
// src/throwAfter.ts
|
|
883
1183
|
const throwAfter = (ms, reason) => new Promise((_, reject) => setTimeout(() => reject(new Error(reason)), ms));
|
|
884
1184
|
// src/tokensToPlanck.ts
|
|
@@ -940,6 +1240,7 @@ exports.REGEX_HEX_STRING = REGEX_HEX_STRING;
|
|
|
940
1240
|
exports.addTrailingSlash = addTrailingSlash;
|
|
941
1241
|
exports.arrayItemsEqualWithYield = arrayItemsEqualWithYield;
|
|
942
1242
|
exports.assert = assert;
|
|
1243
|
+
exports.checkSuspension = checkSuspension;
|
|
943
1244
|
exports.concatMapChunked = concatMapChunked;
|
|
944
1245
|
exports.createTimeSlicer = createTimeSlicer;
|
|
945
1246
|
exports.firstThenDebounce = firstThenDebounce;
|
|
@@ -951,6 +1252,7 @@ exports.formatDecimals = formatDecimals;
|
|
|
951
1252
|
exports.formatPrice = formatPrice;
|
|
952
1253
|
exports.getCurrencyFractionDigits = getCurrencyFractionDigits;
|
|
953
1254
|
exports.getErrorMessage = getErrorMessage;
|
|
1255
|
+
exports.getLastResumedAt = getLastResumedAt;
|
|
954
1256
|
exports.getLoadable$ = getLoadable$;
|
|
955
1257
|
exports.getLoadableQuery$ = getLoadableQuery$;
|
|
956
1258
|
exports.getQuery$ = getQuery$;
|
|
@@ -970,15 +1272,19 @@ exports.isHexString = isHexString;
|
|
|
970
1272
|
exports.isNotNil = isNotNil;
|
|
971
1273
|
exports.isPromise = isPromise;
|
|
972
1274
|
exports.isSubject = isSubject;
|
|
1275
|
+
exports.isSuspended = isSuspended;
|
|
973
1276
|
exports.isTruthy = isTruthy;
|
|
974
1277
|
exports.keepAlive = keepAlive;
|
|
975
1278
|
exports.keyByWithYield = keyByWithYield;
|
|
976
1279
|
exports.mapWithYield = mapWithYield;
|
|
977
1280
|
exports.newAbortError = newAbortError;
|
|
978
1281
|
exports.numberToU8a = numberToU8a;
|
|
1282
|
+
exports.onResume = onResume;
|
|
979
1283
|
exports.planckToTokens = planckToTokens;
|
|
980
1284
|
exports.replaySubjectFrom = replaySubjectFrom;
|
|
981
1285
|
exports.reportJsActivity = reportJsActivity;
|
|
1286
|
+
exports.setAwakeTimeout = setAwakeTimeout;
|
|
1287
|
+
exports.setSuspended = setSuspended;
|
|
982
1288
|
exports.sleep = sleep;
|
|
983
1289
|
exports.splitSubject = splitSubject;
|
|
984
1290
|
exports.stringToU8a = stringToU8a;
|