@take-out/helpers 0.2.9 → 0.3.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/dist/cjs/constants.cjs +1 -1
- package/dist/cjs/constants.native.js +1 -1
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/string/pluralize.cjs +4 -1
- package/dist/esm/async/abortable.mjs.map +1 -1
- package/dist/esm/constants.mjs +1 -1
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +1 -1
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/index.js +72 -74
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/string/pluralize.mjs +4 -1
- package/dist/esm/string/pluralize.mjs.map +1 -1
- package/package.json +3 -3
- package/src/async/abortable.ts +3 -3
- package/src/async/asyncContext.native.ts +5 -5
- package/src/async/asyncContext.ts +5 -5
- package/src/async/idle.ts +2 -2
- package/src/async/interval.ts +1 -1
- package/src/async/useAsync.ts +1 -1
- package/src/async/useAsyncEffect.ts +8 -8
- package/src/async/useLazyMount.ts +1 -1
- package/src/async/useLazyValue.ts +2 -2
- package/src/browser/clearIndexedDB.ts +1 -1
- package/src/browser/openPopup.ts +1 -1
- package/src/constants.ts +1 -1
- package/src/debug/debugUseState.ts +2 -2
- package/src/emitter.tsx +16 -16
- package/src/ensure/ensure.ts +2 -2
- package/src/function/throttle.ts +3 -3
- package/src/global/globalValue.ts +1 -1
- package/src/object/decorateObject.ts +1 -1
- package/src/object/mapObject.ts +1 -1
- package/src/object/object.ts +4 -4
- package/src/storage/storage.test.ts +1 -1
- package/src/string/pickLast.ts +1 -1
- package/src/string/pluralize.ts +5 -2
- package/src/string/truncateList.ts +1 -1
- package/src/time/formatDate.tsx +1 -1
- package/src/time/formatDateRelative.ts +4 -4
- package/src/time/useTimer.ts +2 -2
- package/src/url/urlValidate.ts +1 -1
- package/types/async/abortable.d.ts.map +1 -1
- package/types/async/asyncContext.d.ts.map +1 -1
- package/types/async/asyncContext.native.d.ts.map +1 -1
- package/types/async/idle.d.ts.map +1 -1
- package/types/async/interval.d.ts.map +1 -1
- package/types/async/useAsync.d.ts.map +1 -1
- package/types/async/useAsyncEffect.d.ts.map +1 -1
- package/types/async/useLazyMount.d.ts.map +1 -1
- package/types/async/useLazyValue.d.ts.map +1 -1
- package/types/browser/clearIndexedDB.d.ts.map +1 -1
- package/types/browser/openPopup.d.ts.map +1 -1
- package/types/constants.d.ts.map +1 -1
- package/types/debug/debugUseState.d.ts.map +1 -1
- package/types/emitter.d.ts.map +1 -1
- package/types/ensure/ensure.d.ts.map +1 -1
- package/types/function/throttle.d.ts.map +1 -1
- package/types/global/globalValue.d.ts.map +1 -1
- package/types/object/decorateObject.d.ts.map +1 -1
- package/types/object/mapObject.d.ts.map +1 -1
- package/types/object/object.d.ts.map +1 -1
- package/types/storage/storage.test.d.ts.map +1 -1
- package/types/string/pickLast.d.ts.map +1 -1
- package/types/string/pluralize.d.ts.map +2 -2
- package/types/string/truncateList.d.ts.map +1 -1
- package/types/time/formatDate.d.ts.map +1 -1
- package/types/time/formatDateRelative.d.ts.map +1 -1
- package/types/time/useTimer.d.ts.map +1 -1
- package/types/url/urlValidate.d.ts.map +1 -1
- package/dist/cjs/array/getRandomItem.js +0 -25
- package/dist/cjs/array/getRandomItem.js.map +0 -6
- package/dist/cjs/array/takeLast.js +0 -21
- package/dist/cjs/array/takeLast.js.map +0 -6
- package/dist/cjs/array/uniqBy.js +0 -28
- package/dist/cjs/array/uniqBy.js.map +0 -6
- package/dist/cjs/assert.js +0 -44
- package/dist/cjs/assert.js.map +0 -6
- package/dist/cjs/async/abortable.js +0 -47
- package/dist/cjs/async/abortable.js.map +0 -6
- package/dist/cjs/async/asyncContext.js +0 -101
- package/dist/cjs/async/asyncContext.js.map +0 -6
- package/dist/cjs/async/idle.js +0 -36
- package/dist/cjs/async/idle.js.map +0 -6
- package/dist/cjs/async/interval.js +0 -25
- package/dist/cjs/async/interval.js.map +0 -6
- package/dist/cjs/async/isAborted.js +0 -21
- package/dist/cjs/async/isAborted.js.map +0 -6
- package/dist/cjs/async/sleep.js +0 -25
- package/dist/cjs/async/sleep.js.map +0 -6
- package/dist/cjs/async/useAsync.js +0 -37
- package/dist/cjs/async/useAsync.js.map +0 -6
- package/dist/cjs/async/useAsyncEffect.js +0 -85
- package/dist/cjs/async/useAsyncEffect.js.map +0 -6
- package/dist/cjs/async/useLazyMount.js +0 -38
- package/dist/cjs/async/useLazyMount.js.map +0 -6
- package/dist/cjs/async/useLazyValue.js +0 -35
- package/dist/cjs/async/useLazyValue.js.map +0 -6
- package/dist/cjs/browser/clearIndexedDB.js +0 -31
- package/dist/cjs/browser/clearIndexedDB.js.map +0 -6
- package/dist/cjs/browser/isActiveElementFormField.js +0 -23
- package/dist/cjs/browser/isActiveElementFormField.js.map +0 -6
- package/dist/cjs/browser/openPopup.js +0 -31
- package/dist/cjs/browser/openPopup.js.map +0 -6
- package/dist/cjs/client-only.js +0 -2
- package/dist/cjs/client-only.js.map +0 -6
- package/dist/cjs/clipboard/clipboard.js +0 -27
- package/dist/cjs/clipboard/clipboard.js.map +0 -6
- package/dist/cjs/color/extractOpacityFromColor.js +0 -29
- package/dist/cjs/color/extractOpacityFromColor.js.map +0 -6
- package/dist/cjs/color/generateColors.js +0 -64
- package/dist/cjs/color/generateColors.js.map +0 -6
- package/dist/cjs/color/lum.js +0 -61
- package/dist/cjs/color/lum.js.map +0 -6
- package/dist/cjs/color/toHex.js +0 -27
- package/dist/cjs/color/toHex.js.map +0 -6
- package/dist/cjs/constants.js +0 -37
- package/dist/cjs/constants.js.map +0 -6
- package/dist/cjs/debug/debugLog.js +0 -24
- package/dist/cjs/debug/debugLog.js.map +0 -6
- package/dist/cjs/debug/debugUseState.js +0 -41
- package/dist/cjs/debug/debugUseState.js.map +0 -6
- package/dist/cjs/emitter.js +0 -183
- package/dist/cjs/emitter.js.map +0 -6
- package/dist/cjs/ensure/ensure.js +0 -40
- package/dist/cjs/ensure/ensure.js.map +0 -6
- package/dist/cjs/ensure/ensureOne.js +0 -27
- package/dist/cjs/ensure/ensureOne.js.map +0 -6
- package/dist/cjs/error/errors.js +0 -50
- package/dist/cjs/error/errors.js.map +0 -6
- package/dist/cjs/function/emptyFn.js +0 -22
- package/dist/cjs/function/emptyFn.js.map +0 -6
- package/dist/cjs/function/identityFn.js +0 -21
- package/dist/cjs/function/identityFn.js.map +0 -6
- package/dist/cjs/function/throttle.js +0 -40
- package/dist/cjs/function/throttle.js.map +0 -6
- package/dist/cjs/global/globalEffect.js +0 -26
- package/dist/cjs/global/globalEffect.js.map +0 -6
- package/dist/cjs/global/globalValue.js +0 -24
- package/dist/cjs/global/globalValue.js.map +0 -6
- package/dist/cjs/index.js +0 -91
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/number/formatNumber.js +0 -56
- package/dist/cjs/number/formatNumber.js.map +0 -6
- package/dist/cjs/object/decorateObject.js +0 -26
- package/dist/cjs/object/decorateObject.js.map +0 -6
- package/dist/cjs/object/isEqualDeep.js +0 -23
- package/dist/cjs/object/isEqualDeep.js.map +0 -6
- package/dist/cjs/object/isEqualIdentity.js +0 -21
- package/dist/cjs/object/isEqualIdentity.js.map +0 -6
- package/dist/cjs/object/isEqualJSON.js +0 -21
- package/dist/cjs/object/isEqualJSON.js.map +0 -6
- package/dist/cjs/object/isEqualNever.js +0 -21
- package/dist/cjs/object/isEqualNever.js.map +0 -6
- package/dist/cjs/object/mapObject.js +0 -26
- package/dist/cjs/object/mapObject.js.map +0 -6
- package/dist/cjs/object/object.js +0 -37
- package/dist/cjs/object/object.js.map +0 -6
- package/dist/cjs/object/objectUniqueKey.js +0 -24
- package/dist/cjs/object/objectUniqueKey.js.map +0 -6
- package/dist/cjs/react/createGlobalContext.js +0 -24
- package/dist/cjs/react/createGlobalContext.js.map +0 -6
- package/dist/cjs/react/getCurrentComponentStack.js +0 -51
- package/dist/cjs/react/getCurrentComponentStack.js.map +0 -6
- package/dist/cjs/server/ensureEnv.js +0 -31
- package/dist/cjs/server/ensureEnv.js.map +0 -6
- package/dist/cjs/server/getHeaders.js +0 -26
- package/dist/cjs/server/getHeaders.js.map +0 -6
- package/dist/cjs/server/isServerRuntime.js +0 -23
- package/dist/cjs/server/isServerRuntime.js.map +0 -6
- package/dist/cjs/server/prettyPrintRequest.js +0 -23
- package/dist/cjs/server/prettyPrintRequest.js.map +0 -6
- package/dist/cjs/server/prettyPrintResponse.js +0 -30
- package/dist/cjs/server/prettyPrintResponse.js.map +0 -6
- package/dist/cjs/server/streamToString.js +0 -36
- package/dist/cjs/server/streamToString.js.map +0 -6
- package/dist/cjs/server-only.js +0 -3
- package/dist/cjs/server-only.js.map +0 -6
- package/dist/cjs/storage/createStorage.js +0 -85
- package/dist/cjs/storage/createStorage.js.map +0 -6
- package/dist/cjs/storage/driver.js +0 -33
- package/dist/cjs/storage/driver.js.map +0 -6
- package/dist/cjs/storage/storage.test.js +0 -71
- package/dist/cjs/storage/storage.test.js.map +0 -6
- package/dist/cjs/storage/types.js +0 -14
- package/dist/cjs/storage/types.js.map +0 -6
- package/dist/cjs/string/dedent.js +0 -33
- package/dist/cjs/string/dedent.js.map +0 -6
- package/dist/cjs/string/ellipsis.js +0 -24
- package/dist/cjs/string/ellipsis.js.map +0 -6
- package/dist/cjs/string/hash.js +0 -27
- package/dist/cjs/string/hash.js.map +0 -6
- package/dist/cjs/string/insertAtIndex.js +0 -25
- package/dist/cjs/string/insertAtIndex.js.map +0 -6
- package/dist/cjs/string/nbspLastWord.js +0 -25
- package/dist/cjs/string/nbspLastWord.js.map +0 -6
- package/dist/cjs/string/pickLast.js +0 -24
- package/dist/cjs/string/pickLast.js.map +0 -6
- package/dist/cjs/string/pluralize.js +0 -38
- package/dist/cjs/string/pluralize.js.map +0 -6
- package/dist/cjs/string/randomId.js +0 -21
- package/dist/cjs/string/randomId.js.map +0 -6
- package/dist/cjs/string/slugify.js +0 -21
- package/dist/cjs/string/slugify.js.map +0 -6
- package/dist/cjs/string/truncateList.js +0 -26
- package/dist/cjs/string/truncateList.js.map +0 -6
- package/dist/cjs/time/formatDate.js +0 -51
- package/dist/cjs/time/formatDate.js.map +0 -6
- package/dist/cjs/time/formatDateRelative.js +0 -48
- package/dist/cjs/time/formatDateRelative.js.map +0 -6
- package/dist/cjs/time/formatDistanceToNow.js +0 -24
- package/dist/cjs/time/formatDistanceToNow.js.map +0 -6
- package/dist/cjs/time/time.js +0 -40
- package/dist/cjs/time/time.js.map +0 -6
- package/dist/cjs/time/useTimer.js +0 -51
- package/dist/cjs/time/useTimer.js.map +0 -6
- package/dist/cjs/types/NullToOptional.js +0 -14
- package/dist/cjs/types/NullToOptional.js.map +0 -6
- package/dist/cjs/types/object.js +0 -14
- package/dist/cjs/types/object.js.map +0 -6
- package/dist/cjs/types/react.js +0 -14
- package/dist/cjs/types/react.js.map +0 -6
- package/dist/cjs/types/timer.js +0 -14
- package/dist/cjs/types/timer.js.map +0 -6
- package/dist/cjs/types/tuple.js +0 -14
- package/dist/cjs/types/tuple.js.map +0 -6
- package/dist/cjs/url/urlSanitize.js +0 -31
- package/dist/cjs/url/urlSanitize.js.map +0 -6
- package/dist/cjs/url/urlValidate.js +0 -26
- package/dist/cjs/url/urlValidate.js.map +0 -6
- package/dist/esm/array/getRandomItem.js +0 -9
- package/dist/esm/array/getRandomItem.js.map +0 -6
- package/dist/esm/array/takeLast.js +0 -5
- package/dist/esm/array/takeLast.js.map +0 -6
- package/dist/esm/array/uniqBy.js +0 -12
- package/dist/esm/array/uniqBy.js.map +0 -6
- package/dist/esm/assert.js +0 -28
- package/dist/esm/assert.js.map +0 -6
- package/dist/esm/async/abortable.js +0 -31
- package/dist/esm/async/abortable.js.map +0 -6
- package/dist/esm/async/asyncContext.js +0 -85
- package/dist/esm/async/asyncContext.js.map +0 -6
- package/dist/esm/async/idle.js +0 -21
- package/dist/esm/async/idle.js.map +0 -6
- package/dist/esm/async/interval.js +0 -9
- package/dist/esm/async/interval.js.map +0 -6
- package/dist/esm/async/isAborted.js +0 -5
- package/dist/esm/async/isAborted.js.map +0 -6
- package/dist/esm/async/sleep.js +0 -9
- package/dist/esm/async/sleep.js.map +0 -6
- package/dist/esm/async/useAsync.js +0 -21
- package/dist/esm/async/useAsync.js.map +0 -6
- package/dist/esm/async/useAsyncEffect.js +0 -72
- package/dist/esm/async/useAsyncEffect.js.map +0 -6
- package/dist/esm/async/useLazyMount.js +0 -24
- package/dist/esm/async/useLazyMount.js.map +0 -6
- package/dist/esm/async/useLazyValue.js +0 -21
- package/dist/esm/async/useLazyValue.js.map +0 -6
- package/dist/esm/browser/clearIndexedDB.js +0 -15
- package/dist/esm/browser/clearIndexedDB.js.map +0 -6
- package/dist/esm/browser/isActiveElementFormField.js +0 -7
- package/dist/esm/browser/isActiveElementFormField.js.map +0 -6
- package/dist/esm/browser/openPopup.js +0 -15
- package/dist/esm/browser/openPopup.js.map +0 -6
- package/dist/esm/client-only.js +0 -2
- package/dist/esm/client-only.js.map +0 -6
- package/dist/esm/clipboard/clipboard.js +0 -11
- package/dist/esm/clipboard/clipboard.js.map +0 -6
- package/dist/esm/color/extractOpacityFromColor.js +0 -13
- package/dist/esm/color/extractOpacityFromColor.js.map +0 -6
- package/dist/esm/color/generateColors.js +0 -48
- package/dist/esm/color/generateColors.js.map +0 -6
- package/dist/esm/color/lum.js +0 -45
- package/dist/esm/color/lum.js.map +0 -6
- package/dist/esm/color/toHex.js +0 -11
- package/dist/esm/color/toHex.js.map +0 -6
- package/dist/esm/constants.js +0 -22
- package/dist/esm/constants.js.map +0 -6
- package/dist/esm/debug/debugLog.js +0 -8
- package/dist/esm/debug/debugLog.js.map +0 -6
- package/dist/esm/debug/debugUseState.js +0 -25
- package/dist/esm/debug/debugUseState.js.map +0 -6
- package/dist/esm/emitter.js +0 -167
- package/dist/esm/emitter.js.map +0 -6
- package/dist/esm/ensure/ensure.js +0 -24
- package/dist/esm/ensure/ensure.js.map +0 -6
- package/dist/esm/ensure/ensureOne.js +0 -11
- package/dist/esm/ensure/ensureOne.js.map +0 -6
- package/dist/esm/error/errors.js +0 -34
- package/dist/esm/error/errors.js.map +0 -6
- package/dist/esm/function/emptyFn.js +0 -6
- package/dist/esm/function/emptyFn.js.map +0 -6
- package/dist/esm/function/identityFn.js +0 -5
- package/dist/esm/function/identityFn.js.map +0 -6
- package/dist/esm/function/throttle.js +0 -24
- package/dist/esm/function/throttle.js.map +0 -6
- package/dist/esm/global/globalEffect.js +0 -10
- package/dist/esm/global/globalEffect.js.map +0 -6
- package/dist/esm/global/globalValue.js +0 -8
- package/dist/esm/global/globalValue.js.map +0 -6
- package/dist/esm/number/formatNumber.js +0 -40
- package/dist/esm/number/formatNumber.js.map +0 -6
- package/dist/esm/object/decorateObject.js +0 -10
- package/dist/esm/object/decorateObject.js.map +0 -6
- package/dist/esm/object/isEqualDeep.js +0 -8
- package/dist/esm/object/isEqualDeep.js.map +0 -6
- package/dist/esm/object/isEqualIdentity.js +0 -5
- package/dist/esm/object/isEqualIdentity.js.map +0 -6
- package/dist/esm/object/isEqualJSON.js +0 -5
- package/dist/esm/object/isEqualJSON.js.map +0 -6
- package/dist/esm/object/isEqualNever.js +0 -5
- package/dist/esm/object/isEqualNever.js.map +0 -6
- package/dist/esm/object/mapObject.js +0 -10
- package/dist/esm/object/mapObject.js.map +0 -6
- package/dist/esm/object/object.js +0 -21
- package/dist/esm/object/object.js.map +0 -6
- package/dist/esm/object/objectUniqueKey.js +0 -8
- package/dist/esm/object/objectUniqueKey.js.map +0 -6
- package/dist/esm/react/createGlobalContext.js +0 -9
- package/dist/esm/react/createGlobalContext.js.map +0 -6
- package/dist/esm/react/getCurrentComponentStack.js +0 -27
- package/dist/esm/react/getCurrentComponentStack.js.map +0 -6
- package/dist/esm/server/ensureEnv.js +0 -15
- package/dist/esm/server/ensureEnv.js.map +0 -6
- package/dist/esm/server/getHeaders.js +0 -10
- package/dist/esm/server/getHeaders.js.map +0 -6
- package/dist/esm/server/isServerRuntime.js +0 -7
- package/dist/esm/server/isServerRuntime.js.map +0 -6
- package/dist/esm/server/prettyPrintRequest.js +0 -7
- package/dist/esm/server/prettyPrintRequest.js.map +0 -6
- package/dist/esm/server/prettyPrintResponse.js +0 -15
- package/dist/esm/server/prettyPrintResponse.js.map +0 -6
- package/dist/esm/server/streamToString.js +0 -20
- package/dist/esm/server/streamToString.js.map +0 -6
- package/dist/esm/server-only.js +0 -3
- package/dist/esm/server-only.js.map +0 -6
- package/dist/esm/storage/createStorage.js +0 -69
- package/dist/esm/storage/createStorage.js.map +0 -6
- package/dist/esm/storage/driver.js +0 -17
- package/dist/esm/storage/driver.js.map +0 -6
- package/dist/esm/storage/storage.test.js +0 -73
- package/dist/esm/storage/storage.test.js.map +0 -6
- package/dist/esm/storage/types.js +0 -1
- package/dist/esm/storage/types.js.map +0 -6
- package/dist/esm/string/dedent.js +0 -17
- package/dist/esm/string/dedent.js.map +0 -6
- package/dist/esm/string/ellipsis.js +0 -8
- package/dist/esm/string/ellipsis.js.map +0 -6
- package/dist/esm/string/hash.js +0 -11
- package/dist/esm/string/hash.js.map +0 -6
- package/dist/esm/string/insertAtIndex.js +0 -9
- package/dist/esm/string/insertAtIndex.js.map +0 -6
- package/dist/esm/string/nbspLastWord.js +0 -9
- package/dist/esm/string/nbspLastWord.js.map +0 -6
- package/dist/esm/string/pickLast.js +0 -8
- package/dist/esm/string/pickLast.js.map +0 -6
- package/dist/esm/string/pluralize.js +0 -22
- package/dist/esm/string/pluralize.js.map +0 -6
- package/dist/esm/string/randomId.js +0 -5
- package/dist/esm/string/randomId.js.map +0 -6
- package/dist/esm/string/slugify.js +0 -5
- package/dist/esm/string/slugify.js.map +0 -6
- package/dist/esm/string/truncateList.js +0 -10
- package/dist/esm/string/truncateList.js.map +0 -6
- package/dist/esm/time/formatDate.js +0 -35
- package/dist/esm/time/formatDate.js.map +0 -6
- package/dist/esm/time/formatDateRelative.js +0 -32
- package/dist/esm/time/formatDateRelative.js.map +0 -6
- package/dist/esm/time/formatDistanceToNow.js +0 -8
- package/dist/esm/time/formatDistanceToNow.js.map +0 -6
- package/dist/esm/time/time.js +0 -24
- package/dist/esm/time/time.js.map +0 -6
- package/dist/esm/time/useTimer.js +0 -35
- package/dist/esm/time/useTimer.js.map +0 -6
- package/dist/esm/types/NullToOptional.js +0 -1
- package/dist/esm/types/NullToOptional.js.map +0 -6
- package/dist/esm/types/object.js +0 -1
- package/dist/esm/types/object.js.map +0 -6
- package/dist/esm/types/react.js +0 -1
- package/dist/esm/types/react.js.map +0 -6
- package/dist/esm/types/timer.js +0 -1
- package/dist/esm/types/timer.js.map +0 -6
- package/dist/esm/types/tuple.js +0 -1
- package/dist/esm/types/tuple.js.map +0 -6
- package/dist/esm/url/urlSanitize.js +0 -15
- package/dist/esm/url/urlSanitize.js.map +0 -6
- package/dist/esm/url/urlValidate.js +0 -10
- package/dist/esm/url/urlValidate.js.map +0 -6
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import { EnsureError } from '../error/errors'\n\nexport function ensureExists<T>(\n value: T | undefined | null,\n msg = ''
|
|
9
|
+
"import { EnsureError } from '../error/errors'\n\nexport function ensureExists<T>(\n value: T | undefined | null,\n msg = '',\n): asserts value is T {\n if (value === undefined || value === null) {\n throw new EnsureError(`Invalid nullish value (${value}): ${msg}`)\n }\n}\n\nexport function ensure<T>(\n value: T,\n msg = '',\n): asserts value is Exclude<T, null | undefined | false> {\n if (!value) {\n throw new EnsureError(`ensure() invalid: (${value}): ${msg} ${new Error().stack}`)\n }\n}\n\nexport function ensureError(val: unknown): asserts val is Error {\n if (!(val instanceof Error)) {\n throw val\n }\n}\n\nexport function ensureString(val: unknown, name = '(unnamed)'): asserts val is string {\n if (typeof val !== 'string') {\n throw new EnsureError(`No string ${name}`)\n }\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"// via @github/mini-throttle https://raw.githubusercontent.com/github/mini-throttle/refs/heads/main/index.ts\n\nimport type { Timer } from '../types/timer'\n\nexport interface ThrottleOptions {\n /**\n * Fire immediately on the first call.\n */\n start?: boolean\n /**\n * Fire as soon as `wait` has passed.\n */\n middle?: boolean\n /**\n * Cancel after the first successful call.\n */\n once?: boolean\n}\n\ninterface Throttler<T extends unknown[]> {\n (...args: T): void\n cancel(): void\n}\n\nexport function throttle<T extends unknown[]>(\n callback: (...args: T) => unknown,\n wait = 0,\n { start = true, middle = true, once = false }: ThrottleOptions = {}
|
|
9
|
+
"// via @github/mini-throttle https://raw.githubusercontent.com/github/mini-throttle/refs/heads/main/index.ts\n\nimport type { Timer } from '../types/timer'\n\nexport interface ThrottleOptions {\n /**\n * Fire immediately on the first call.\n */\n start?: boolean\n /**\n * Fire as soon as `wait` has passed.\n */\n middle?: boolean\n /**\n * Cancel after the first successful call.\n */\n once?: boolean\n}\n\ninterface Throttler<T extends unknown[]> {\n (...args: T): void\n cancel(): void\n}\n\nexport function throttle<T extends unknown[]>(\n callback: (...args: T) => unknown,\n wait = 0,\n { start = true, middle = true, once = false }: ThrottleOptions = {},\n): Throttler<T> {\n let innerStart = start\n let last = 0\n let timer: Timer\n let cancelled = false\n function fn(this: unknown, ...args: T) {\n if (cancelled) return\n const delta = Date.now() - last\n last = Date.now()\n\n if (start && middle && delta >= wait) {\n innerStart = true\n }\n\n if (innerStart) {\n innerStart = false\n callback.apply(this, args)\n if (once) fn.cancel()\n } else if ((middle && delta < wait) || !middle) {\n clearTimeout(timer)\n timer = setTimeout(\n () => {\n last = Date.now()\n callback.apply(this, args)\n if (once) fn.cancel()\n },\n !middle ? wait : wait - delta,\n )\n }\n }\n fn.cancel = () => {\n clearTimeout(timer)\n cancelled = true\n }\n return fn\n}\n\nexport function debounce<T extends unknown[]>(\n callback: (...args: T) => unknown,\n wait = 0,\n { start = false, middle = false, once = false }: ThrottleOptions = {},\n): Throttler<T> {\n return throttle(callback, wait, { start, middle, once })\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"/**\n * Helper to store a value that's not duplicated within the global context Uses\n * a symbol stored on `globalThis` to achieve it.\n *\n * There's two main uses for this (for us, so far):\n *\n * - in dev mode, HMR re-runs files, but you may want to preserve globals\n *\n * - in published node modules, sometimes Vite or other bundlers can cause\n * duplicate dependencies either through bad setup or heuristics, they may\n * compile a module but then another code path doesn't compile it, so you\n * have duplicate modules. in this case it can be good to just use a\n * globalValue and warn the end-user. because you can't account for ever\n * possible weird configuration, and often fixing that config can be a\n * massive pain in the ass, it's better to retain functionality while\n * warning them so they can fix it at their own pace. this often happens\n * with WeakMaps.\n *\n */\n\nexport function globalValue<T>(\n key: string,\n factory: () => T,\n opts?: {\n warnMessage?: string\n }
|
|
9
|
+
"/**\n * Helper to store a value that's not duplicated within the global context Uses\n * a symbol stored on `globalThis` to achieve it.\n *\n * There's two main uses for this (for us, so far):\n *\n * - in dev mode, HMR re-runs files, but you may want to preserve globals\n *\n * - in published node modules, sometimes Vite or other bundlers can cause\n * duplicate dependencies either through bad setup or heuristics, they may\n * compile a module but then another code path doesn't compile it, so you\n * have duplicate modules. in this case it can be good to just use a\n * globalValue and warn the end-user. because you can't account for ever\n * possible weird configuration, and often fixing that config can be a\n * massive pain in the ass, it's better to retain functionality while\n * warning them so they can fix it at their own pace. this often happens\n * with WeakMaps.\n *\n */\n\nexport function globalValue<T>(\n key: string,\n factory: () => T,\n opts?: {\n warnMessage?: string\n },\n): T {\n const symbolKey = Symbol.for(key)\n const g = globalThis as Record<symbol, unknown>\n\n if (!g[symbolKey]) {\n g[symbolKey] = factory()\n } else {\n if (opts?.warnMessage) {\n console.warn(`[globalValue] ${opts.warnMessage}`)\n }\n }\n\n return g[symbolKey] as T\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"export function decorateObject<T extends Record<string, any>>(\n obj: T,\n decorator: (fn: Function) => Function
|
|
9
|
+
"export function decorateObject<T extends Record<string, any>>(\n obj: T,\n decorator: (fn: Function) => Function,\n): T {\n const decorated = {} as T\n\n for (const [key, value] of Object.entries(obj)) {\n if (typeof value === 'function') {\n ;(decorated as any)[key] = decorator(value)\n } else {\n ;(decorated as any)[key] = value\n }\n }\n\n return decorated\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"export function mapObject<T extends Record<string, any>, R>(\n obj: T,\n fn: <K extends keyof T>(value: T[K], key: K) => R
|
|
9
|
+
"export function mapObject<T extends Record<string, any>, R>(\n obj: T,\n fn: <K extends keyof T>(value: T[K], key: K) => R,\n): { [K in keyof T]: R } {\n const result = {} as { [K in keyof T]: R }\n\n for (const key in obj) {\n if (Object.hasOwn(obj, key)) {\n result[key] = fn(obj[key], key)\n }\n }\n\n return result\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import type {\n EntriesToObject,\n EntriesType,\n ObjectEntries,\n ObjectType,\n} from '../types/object'\n\nexport function postfixObjKeys<A extends { [key: string]: string }, B extends string>(\n obj: A,\n postfix: B
|
|
9
|
+
"import type {\n EntriesToObject,\n EntriesType,\n ObjectEntries,\n ObjectType,\n} from '../types/object'\n\nexport function postfixObjKeys<A extends { [key: string]: string }, B extends string>(\n obj: A,\n postfix: B,\n): {\n [Key in `${keyof A extends string ? keyof A : never}${B}`]: string\n} {\n return Object.fromEntries(\n Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v]),\n ) as any\n}\n\nexport function objectFromEntries<ARR_T extends EntriesType>(\n arr: ARR_T,\n): EntriesToObject<ARR_T> {\n return Object.fromEntries(arr) as EntriesToObject<ARR_T>\n}\n\nexport function objectKeys<O extends object>(obj: O) {\n return Object.keys(obj) as Array<keyof O>\n}\n\nexport function objectEntries<OBJ_T extends ObjectType>(\n obj: OBJ_T,\n): ObjectEntries<OBJ_T> {\n return Object.entries(obj) as ObjectEntries<OBJ_T>\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import { beforeEach, describe, expect, it } from 'vitest'\n\nimport { createStorage } from './createStorage'\nimport { getStorageDriver, setStorageDriver } from './driver'\n\n// test the storage driver system to ensure it works correctly\n// this regression test validates that the storage system initializes properly\n// which is critical for native auth to work\n\ndescribe('storage driver system', () => {\n describe('driver initialization', () => {\n it('getStorageDriver should return localStorage fallback on web', () => {\n // web environment has localStorage which should be used as fallback\n const driver = getStorageDriver()\n // in node/vitest environment, localStorage might not exist\n // but if it does, the driver should work\n if (typeof localStorage !== 'undefined') {\n expect(driver).toBeTruthy()\n }\n })\n\n it('should use custom driver when set', () => {\n const mockStorage = new Map<string, string>()\n const mockDriver = {\n getItem: (key: string) => mockStorage.get(key) ?? null,\n setItem: (key: string, value: string) => mockStorage.set(key, value),\n removeItem: (key: string) => mockStorage.delete(key),\n getAllKeys: () => Array.from(mockStorage.keys()),\n }\n\n setStorageDriver(mockDriver)\n const driver = getStorageDriver()\n expect(driver).toBe(mockDriver)\n })\n })\n\n describe('createStorage with driver', () => {\n let mockStorage: Map<string, string>\n\n beforeEach(() => {\n mockStorage = new Map<string, string>()\n const mockDriver = {\n getItem: (key: string) => mockStorage.get(key) ?? null,\n setItem: (key: string, value: string) => mockStorage.set(key, value),\n removeItem: (key: string) => mockStorage.delete(key),\n getAllKeys: () => Array.from(mockStorage.keys()),\n }\n setStorageDriver(mockDriver)\n })\n\n it('should store and retrieve values', () => {\n const storage = createStorage<'token', string>(`test-${Date.now()}-1`)\n storage.set('token', 'test-value')\n expect(storage.get('token')).toBe('test-value')\n })\n\n it('should use namespace prefix', () => {\n const namespace = `test-${Date.now()}-2`\n const storage = createStorage<'key', string>(namespace)\n storage.set('key', 'value')\n\n // verify the key in the underlying storage has the namespace prefix\n expect(mockStorage.has(`${namespace}:key`)).toBe(true)\n })\n\n it('should handle JSON serialization', () => {\n const storage = createStorage<'obj', { name: string; count: number }>(\n `test-${Date.now()}-3
|
|
9
|
+
"import { beforeEach, describe, expect, it } from 'vitest'\n\nimport { createStorage } from './createStorage'\nimport { getStorageDriver, setStorageDriver } from './driver'\n\n// test the storage driver system to ensure it works correctly\n// this regression test validates that the storage system initializes properly\n// which is critical for native auth to work\n\ndescribe('storage driver system', () => {\n describe('driver initialization', () => {\n it('getStorageDriver should return localStorage fallback on web', () => {\n // web environment has localStorage which should be used as fallback\n const driver = getStorageDriver()\n // in node/vitest environment, localStorage might not exist\n // but if it does, the driver should work\n if (typeof localStorage !== 'undefined') {\n expect(driver).toBeTruthy()\n }\n })\n\n it('should use custom driver when set', () => {\n const mockStorage = new Map<string, string>()\n const mockDriver = {\n getItem: (key: string) => mockStorage.get(key) ?? null,\n setItem: (key: string, value: string) => mockStorage.set(key, value),\n removeItem: (key: string) => mockStorage.delete(key),\n getAllKeys: () => Array.from(mockStorage.keys()),\n }\n\n setStorageDriver(mockDriver)\n const driver = getStorageDriver()\n expect(driver).toBe(mockDriver)\n })\n })\n\n describe('createStorage with driver', () => {\n let mockStorage: Map<string, string>\n\n beforeEach(() => {\n mockStorage = new Map<string, string>()\n const mockDriver = {\n getItem: (key: string) => mockStorage.get(key) ?? null,\n setItem: (key: string, value: string) => mockStorage.set(key, value),\n removeItem: (key: string) => mockStorage.delete(key),\n getAllKeys: () => Array.from(mockStorage.keys()),\n }\n setStorageDriver(mockDriver)\n })\n\n it('should store and retrieve values', () => {\n const storage = createStorage<'token', string>(`test-${Date.now()}-1`)\n storage.set('token', 'test-value')\n expect(storage.get('token')).toBe('test-value')\n })\n\n it('should use namespace prefix', () => {\n const namespace = `test-${Date.now()}-2`\n const storage = createStorage<'key', string>(namespace)\n storage.set('key', 'value')\n\n // verify the key in the underlying storage has the namespace prefix\n expect(mockStorage.has(`${namespace}:key`)).toBe(true)\n })\n\n it('should handle JSON serialization', () => {\n const storage = createStorage<'obj', { name: string; count: number }>(\n `test-${Date.now()}-3`,\n )\n const obj = { name: 'test', count: 42 }\n storage.set('obj', obj)\n expect(storage.get('obj')).toEqual(obj)\n })\n\n it('should support raw string operations', () => {\n const storage = createStorage<'raw', string>(`test-${Date.now()}-4`)\n storage.setItem('raw', 'raw-value')\n expect(storage.getItem('raw')).toBe('raw-value')\n })\n\n it('should return undefined for missing keys', () => {\n const storage = createStorage<'missing', string>(`test-${Date.now()}-5`)\n expect(storage.get('missing')).toBeUndefined()\n })\n\n it('should support has() check', () => {\n const storage = createStorage<'exists', string>(`test-${Date.now()}-6`)\n expect(storage.has('exists')).toBe(false)\n storage.set('exists', 'value')\n expect(storage.has('exists')).toBe(true)\n })\n\n it('should support remove()', () => {\n const storage = createStorage<'removable', string>(`test-${Date.now()}-7`)\n storage.set('removable', 'value')\n expect(storage.has('removable')).toBe(true)\n storage.remove('removable')\n expect(storage.has('removable')).toBe(false)\n })\n\n it('should list keys in namespace', () => {\n const storage = createStorage<'a' | 'b' | 'c', string>(`test-${Date.now()}-8`)\n storage.set('a', '1')\n storage.set('b', '2')\n storage.set('c', '3')\n expect(storage.keys().sort()).toEqual(['a', 'b', 'c'])\n })\n\n it('should clear only namespace keys', () => {\n const ns1 = `test-${Date.now()}-9a`\n const ns2 = `test-${Date.now()}-9b`\n const storage1 = createStorage<'key', string>(ns1)\n const storage2 = createStorage<'key', string>(ns2)\n\n storage1.set('key', 'value1')\n storage2.set('key', 'value2')\n\n storage1.clear()\n\n expect(storage1.has('key')).toBe(false)\n expect(storage2.has('key')).toBe(true)\n })\n })\n\n describe('createStorage without driver (simulates native without setup)', () => {\n // this test simulates what happens on native when setupStorage.native.ts\n // is not imported before auth initialization\n\n it('should handle gracefully when operations fail', () => {\n // when driver returns null, operations should not throw\n // they should just silently fail (return undefined, do nothing)\n // this is the current behavior but we want to document it\n const storage = createStorage<'key', string>(`test-no-driver-${Date.now()}`)\n\n // these should not throw even without a driver\n expect(() => storage.get('key')).not.toThrow()\n expect(() => storage.set('key', 'value')).not.toThrow()\n expect(() => storage.remove('key')).not.toThrow()\n expect(() => storage.has('key')).not.toThrow()\n expect(() => storage.keys()).not.toThrow()\n expect(() => storage.clear()).not.toThrow()\n expect(() => storage.getItem('key')).not.toThrow()\n expect(() => storage.setItem('key', 'value')).not.toThrow()\n })\n })\n})\n\ndescribe('auth storage requirements', () => {\n // these tests document the requirements for auth storage to work correctly\n\n it('storage must be initialized before auth client creates storage instances', () => {\n // the expo auth client creates storage at module load time:\n // const expoStorage = createStorage('expo-auth-client')\n //\n // if setStorageDriver is not called before this, storage operations will fail\n // this is why setupClient.ts must run before any auth code\n\n // we verify this requirement is documented and understood\n expect(true).toBe(true)\n })\n\n it('native platforms require explicit storage driver setup', () => {\n // unlike web which has localStorage fallback, native platforms need\n // MMKV or AsyncStorage to be configured via setStorageDriver()\n //\n // this happens in setupStorage.native.ts which must be imported\n // before platformClient.native.ts creates its storage instance\n\n // we verify this requirement is documented and understood\n expect(true).toBe(true)\n })\n})\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"export function pickLast<T extends string | null | undefined>(\n a: T,\n b: T
|
|
9
|
+
"export function pickLast<T extends string | null | undefined>(\n a: T,\n b: T,\n): T extends string ? string : T {\n if (a == null && b == null) return undefined as any\n if (a == null) return b as any\n if (b == null) return a as any\n return (b.localeCompare(a) > 0 ? b : a) as any\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAEA,OAAO,iBAAS,UAAU,eAAe,kBAAkB;
|
|
2
|
+
"mappings": "AAEA,OAAO,iBAAS,UAAU,eAAe,kBAAkB;AAiB3D,OAAO,iBAAS,mBAAmB,QAAQ,KAAK;AAIhD,YAAY,qBAAqB",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/string/pluralize.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"let pluralRules = new Intl.PluralRules('en-US')\n\nexport function pluralize(count: number, singular: string, plural: string): string {\n const grammaticalNumber = pluralRules.select(count)\n switch (grammaticalNumber) {\n case 'one':\n return `${count} ${singular}`\n case 'other':\n return `${count} ${plural}`\n
|
|
9
|
+
"let pluralRules = new Intl.PluralRules('en-US')\n\nexport function pluralize(count: number, singular: string, plural: string): string {\n const grammaticalNumber = pluralRules.select(count)\n switch (grammaticalNumber) {\n case 'one':\n return `${count} ${singular}`\n case 'other':\n return `${count} ${plural}`\n case 'zero':\n case 'two':\n case 'few':\n case 'many':\n throw new Error(\n `Can't pluralize: ${grammaticalNumber} for ${count} / ${singular} / ${plural}`,\n )\n }\n}\n\nexport function setPluralizeLocale(locale: Intl.LocalesArgument): void {\n pluralRules = new Intl.PluralRules(locale)\n}\n\nexport type PluralizeFn = typeof pluralize\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"/**\n * Truncates a list of strings to show only the first N items,\n * with a \"+X\" indicator for any remaining items.\n *\n * @param items - Array of strings to truncate\n * @param maxItems - Maximum number of items to show before truncating\n * @param separator - String to use between items (default: ', ')\n * @returns Formatted string with truncation indicator if needed\n *\n * @example\n * truncateList(['jon', 'sal', 'bob', 'ted'], 3) // \"jon, sal, bob +1\"\n * truncateList(['alice', 'bob'], 3) // \"alice, bob\"\n * truncateList(['a', 'b', 'c', 'd', 'e'], 2) // \"a, b +3\"\n */\nexport const truncateList = (\n items: string[],\n maxItems: number,\n separator: string = ', '
|
|
9
|
+
"/**\n * Truncates a list of strings to show only the first N items,\n * with a \"+X\" indicator for any remaining items.\n *\n * @param items - Array of strings to truncate\n * @param maxItems - Maximum number of items to show before truncating\n * @param separator - String to use between items (default: ', ')\n * @returns Formatted string with truncation indicator if needed\n *\n * @example\n * truncateList(['jon', 'sal', 'bob', 'ted'], 3) // \"jon, sal, bob +1\"\n * truncateList(['alice', 'bob'], 3) // \"alice, bob\"\n * truncateList(['a', 'b', 'c', 'd', 'e'], 2) // \"a, b +3\"\n */\nexport const truncateList = (\n items: string[],\n maxItems: number,\n separator: string = ', ',\n): string => {\n if (items.length <= maxItems) {\n return items.join(separator)\n }\n\n const visibleItems = items.slice(0, maxItems)\n const remainingCount = items.length - maxItems\n\n return `${visibleItems.join(separator)} +${remainingCount}`\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"const currentYear = new Date().getFullYear()\n\nexport function formatDate(\n date: Date,\n options?: { daySuffix?: boolean }
|
|
9
|
+
"const currentYear = new Date().getFullYear()\n\nexport function formatDate(\n date: Date,\n options?: { daySuffix?: boolean },\n): [string, string] | [string, string, string] {\n const months = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ]\n\n const day = date.getDate()\n const month = months[date.getMonth()]\n const year = date.getFullYear()\n\n const dayString = options?.daySuffix ? getOrdinalSuffix(day) : `${day}`\n\n if (year === currentYear) {\n return [`${month}`, dayString]\n }\n\n return [`${month}`, dayString, `${year}`]\n}\n\nconst getOrdinalSuffix = (n: number) => {\n if (n >= 11 && n <= 13) return 'th'\n switch (n % 10) {\n case 1:\n return 'st'\n case 2:\n return 'nd'\n case 3:\n return 'rd'\n default:\n return 'th'\n }\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"/**\n * Formats a date relative to the current time:\n * - If within the last month: just show time (e.g., \"5:50pm\")\n * - If this year but older than a month: show \"Jun 2, 5:50pm\"\n * - If before this year: show \"Jun 2, 2025, 5:50pm\"\n */\n\nfunction lowerCaseTime(formatted: string): string {\n return formatted.replace(/\\s?(AM|PM)/g, (_, ampm) => ampm.toLowerCase())\n}\n\nexport function formatDateRelative(date: Date | string | number): string {\n const messageDate = new Date(date)\n const now = new Date()\n\n // if it's today\n const isToday =\n messageDate.getFullYear() === now.getFullYear() &&\n messageDate.getMonth() === now.getMonth() &&\n messageDate.getDate() === now.getDate()\n\n // check if it's within the last month\n const oneMonthAgo = new Date(now)\n oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1)\n const isWithinLastMonth = messageDate >= oneMonthAgo\n\n // if it's this year\n const isThisYear = messageDate.getFullYear() === now.getFullYear()\n\n if (isToday) {\n // just time for today\n return lowerCaseTime(\n new Intl.DateTimeFormat('en', {\n hour: 'numeric',\n minute: 'numeric',\n }).format(messageDate)
|
|
9
|
+
"/**\n * Formats a date relative to the current time:\n * - If within the last month: just show time (e.g., \"5:50pm\")\n * - If this year but older than a month: show \"Jun 2, 5:50pm\"\n * - If before this year: show \"Jun 2, 2025, 5:50pm\"\n */\n\nfunction lowerCaseTime(formatted: string): string {\n return formatted.replace(/\\s?(AM|PM)/g, (_, ampm) => ampm.toLowerCase())\n}\n\nexport function formatDateRelative(date: Date | string | number): string {\n const messageDate = new Date(date)\n const now = new Date()\n\n // if it's today\n const isToday =\n messageDate.getFullYear() === now.getFullYear() &&\n messageDate.getMonth() === now.getMonth() &&\n messageDate.getDate() === now.getDate()\n\n // check if it's within the last month\n const oneMonthAgo = new Date(now)\n oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1)\n const isWithinLastMonth = messageDate >= oneMonthAgo\n\n // if it's this year\n const isThisYear = messageDate.getFullYear() === now.getFullYear()\n\n if (isToday) {\n // just time for today\n return lowerCaseTime(\n new Intl.DateTimeFormat('en', {\n hour: 'numeric',\n minute: 'numeric',\n }).format(messageDate),\n )\n }\n\n if (isWithinLastMonth) {\n // just time for dates within the last month\n return lowerCaseTime(\n new Intl.DateTimeFormat('en', {\n hour: 'numeric',\n minute: 'numeric',\n }).format(messageDate),\n )\n }\n\n if (isThisYear) {\n // Show \"Jun 2, 5:50pm\" for this year\n return lowerCaseTime(\n new Intl.DateTimeFormat('en', {\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n }).format(messageDate),\n )\n }\n\n // Show \"Jun 2, 2025, 5:50pm\" for previous years\n return lowerCaseTime(\n new Intl.DateTimeFormat('en', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n }).format(messageDate),\n )\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import { useState, useEffect, useRef, useMemo, useCallback } from 'react'\n\ntype UseTimerReturn = {\n count: number\n start: (time: number, start: boolean) => void\n pause: () => void\n resume: () => void\n clear: () => void\n}\n\nexport const useTimer = (): UseTimerReturn => {\n const [timerCount, setTimer] = useState<number>(30)\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null)\n\n const clearTimer = useCallback(() => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current)\n intervalRef.current = null\n }\n }, [])\n\n const resetTimer = useCallback(\n (time: number, start: boolean) => {\n setTimer(time)\n clearTimer()\n if (start) {\n intervalRef.current = setInterval(() => {\n setTimer((lastTimerCount) => {\n if (lastTimerCount <= 1) {\n clearInterval(intervalRef.current!)\n intervalRef.current = null\n return 0\n }\n return lastTimerCount - 1\n })\n }, 1000)\n }\n },\n [clearTimer]
|
|
9
|
+
"import { useState, useEffect, useRef, useMemo, useCallback } from 'react'\n\ntype UseTimerReturn = {\n count: number\n start: (time: number, start: boolean) => void\n pause: () => void\n resume: () => void\n clear: () => void\n}\n\nexport const useTimer = (): UseTimerReturn => {\n const [timerCount, setTimer] = useState<number>(30)\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null)\n\n const clearTimer = useCallback(() => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current)\n intervalRef.current = null\n }\n }, [])\n\n const resetTimer = useCallback(\n (time: number, start: boolean) => {\n setTimer(time)\n clearTimer()\n if (start) {\n intervalRef.current = setInterval(() => {\n setTimer((lastTimerCount) => {\n if (lastTimerCount <= 1) {\n clearInterval(intervalRef.current!)\n intervalRef.current = null\n return 0\n }\n return lastTimerCount - 1\n })\n }, 1000)\n }\n },\n [clearTimer],\n )\n\n const pauseTimer = useCallback(() => {\n clearTimer()\n }, [clearTimer])\n\n const resumeTimer = useCallback(() => {\n if (!intervalRef.current) {\n intervalRef.current = setInterval(() => {\n setTimer((lastTimerCount) => {\n if (lastTimerCount <= 1) {\n clearInterval(intervalRef.current!)\n intervalRef.current = null\n return 0\n }\n return lastTimerCount - 1\n })\n }, 1000)\n }\n }, [])\n\n useEffect(() => {\n return () => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current)\n intervalRef.current = null\n }\n }\n }, [])\n\n return useMemo(\n () => ({\n count: timerCount,\n start: resetTimer,\n pause: pauseTimer,\n resume: resumeTimer,\n clear: clearTimer,\n }),\n [timerCount, clearTimer, pauseTimer, resetTimer, resumeTimer],\n )\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"// Source: https://stackoverflow.com/a/8234912/2013580\n\nconst urlRegExp = new RegExp(\n /((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=+$,\\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[+~%/.\\w-_]*)?\\??(?:[-+=&;%@.\\w_]*)#?(?:[\\w]*))?)
|
|
9
|
+
"// Source: https://stackoverflow.com/a/8234912/2013580\n\nconst urlRegExp = new RegExp(\n /((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=+$,\\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[+~%/.\\w-_]*)?\\??(?:[-+=&;%@.\\w_]*)#?(?:[\\w]*))?)/,\n)\n\nexport function urlValidate(url: string): boolean {\n // TODO Fix UI for link insertion; it should never default to an invalid URL such as https://.\n // Maybe show a dialog where they user can type the URL before inserting it.\n return url === 'https://' || urlRegExp.test(url)\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var getRandomItem_exports = {};
|
|
16
|
-
__export(getRandomItem_exports, {
|
|
17
|
-
getRandomItem: () => getRandomItem
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(getRandomItem_exports);
|
|
20
|
-
const getRandomItem = (items) => {
|
|
21
|
-
if (items.length === 0) return;
|
|
22
|
-
const randomIndex = Math.floor(Math.random() * items.length);
|
|
23
|
-
return items[randomIndex];
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=getRandomItem.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/array/getRandomItem.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,gBAAgB,CAAI,UAA8B;AAC7D,MAAI,MAAM,WAAW,EAAG;AACxB,QAAM,cAAc,KAAK,MAAM,KAAK,OAAO,IAAI,MAAM,MAAM;AAC3D,SAAO,MAAM,WAAW;AAC1B;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var takeLast_exports = {};
|
|
16
|
-
__export(takeLast_exports, {
|
|
17
|
-
takeLast: () => takeLast
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(takeLast_exports);
|
|
20
|
-
const takeLast = (arr, n) => arr.slice(-n);
|
|
21
|
-
//# sourceMappingURL=takeLast.js.map
|
package/dist/cjs/array/uniqBy.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var uniqBy_exports = {};
|
|
16
|
-
__export(uniqBy_exports, {
|
|
17
|
-
uniqBy: () => uniqBy
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(uniqBy_exports);
|
|
20
|
-
function uniqBy(array, keyFn) {
|
|
21
|
-
const seen = /* @__PURE__ */ new Map();
|
|
22
|
-
for (const item of array) {
|
|
23
|
-
const key = keyFn(item);
|
|
24
|
-
seen.has(key) || seen.set(key, item);
|
|
25
|
-
}
|
|
26
|
-
return Array.from(seen.values());
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=uniqBy.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/array/uniqBy.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,OAAa,OAAY,OAA4B;AACnE,QAAM,OAAO,oBAAI,IAAU;AAE3B,aAAW,QAAQ,OAAO;AACxB,UAAM,MAAM,MAAM,IAAI;AACtB,IAAK,KAAK,IAAI,GAAG,KACf,KAAK,IAAI,KAAK,IAAI;AAAA,EAEtB;AAEA,SAAO,MAAM,KAAK,KAAK,OAAO,CAAC;AACjC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/cjs/assert.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var assert_exports = {};
|
|
16
|
-
__export(assert_exports, {
|
|
17
|
-
assert: () => assert,
|
|
18
|
-
assertError: () => assertError,
|
|
19
|
-
assertExists: () => assertExists,
|
|
20
|
-
assertString: () => assertString
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(assert_exports);
|
|
23
|
-
var import_errors = require("./error/errors");
|
|
24
|
-
function assertExists(value, msg = "") {
|
|
25
|
-
if (value == null)
|
|
26
|
-
throw new import_errors.AbortError(`Invalid nullish value (${value}): ${msg}`);
|
|
27
|
-
return value;
|
|
28
|
-
}
|
|
29
|
-
function assert(value, msg = "") {
|
|
30
|
-
if (!value)
|
|
31
|
-
throw new import_errors.AbortError(`Invalid falsy value (${value}): ${msg}`);
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
function assertError(val) {
|
|
35
|
-
if (!(val instanceof Error))
|
|
36
|
-
throw val;
|
|
37
|
-
return val;
|
|
38
|
-
}
|
|
39
|
-
function assertString(val, name = "(unnamed)") {
|
|
40
|
-
if (typeof val != "string")
|
|
41
|
-
throw new import_errors.AbortError(`No string ${name}`);
|
|
42
|
-
return val;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=assert.js.map
|
package/dist/cjs/assert.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/assert.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAEpB,SAAS,aAAgB,OAA6B,MAAM,IAAO;AACxE,MAA2B,SAAU;AACnC,UAAM,IAAI,yBAAW,0BAA0B,KAAK,MAAM,GAAG,EAAE;AAEjE,SAAO;AACT;AAEO,SAAS,OAAU,OAAU,MAAM,IAA0C;AAClF,MAAI,CAAC;AACH,UAAM,IAAI,yBAAW,wBAAwB,KAAK,MAAM,GAAG,EAAE;AAE/D,SAAO;AACT;AAEO,SAAS,YAAY,KAAqB;AAC/C,MAAI,EAAE,eAAe;AACnB,UAAM;AAER,SAAO;AACT;AAEO,SAAS,aAAa,KAAc,OAAO,aAAqB;AACrE,MAAI,OAAO,OAAQ;AACjB,UAAM,IAAI,yBAAW,aAAa,IAAI,EAAE;AAE1C,SAAO;AACT;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var abortable_exports = {};
|
|
16
|
-
__export(abortable_exports, {
|
|
17
|
-
abortable: () => abortable,
|
|
18
|
-
didAbort: () => didAbort,
|
|
19
|
-
handleAbortError: () => handleAbortError
|
|
20
|
-
});
|
|
21
|
-
module.exports = __toCommonJS(abortable_exports);
|
|
22
|
-
var import_errors = require("../error/errors");
|
|
23
|
-
function abortable(cb, options) {
|
|
24
|
-
try {
|
|
25
|
-
const value = cb();
|
|
26
|
-
return value instanceof Promise ? value.catch((err) => {
|
|
27
|
-
if (!didAbort(err, options))
|
|
28
|
-
throw err;
|
|
29
|
-
}) : value;
|
|
30
|
-
} catch (err) {
|
|
31
|
-
if (didAbort(err, options))
|
|
32
|
-
return;
|
|
33
|
-
throw err;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function didAbort(err, options) {
|
|
37
|
-
return err instanceof import_errors.AbortError || err instanceof import_errors.EnsureError ? (options?.message && console.warn(`Aborted: ${options.message}`), !0) : !1;
|
|
38
|
-
}
|
|
39
|
-
function handleAbortError(error, debug) {
|
|
40
|
-
if (error instanceof import_errors.AbortError || error instanceof import_errors.EnsureError) {
|
|
41
|
-
(debug || process.env.DEBUG) && console.info(`\u{1F41B} useAsyncEffect aborted: ${error.message}`);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (!(typeof error == "object" && error.name === "AbortError"))
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=abortable.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/async/abortable.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAwC;AASjC,SAAS,UACd,IACA,SACwC;AACxC,MAAI;AACF,UAAM,QAAQ,GAAG;AAEjB,WAAI,iBAAiB,UACZ,MAAM,MAAM,CAAC,QAAQ;AAC1B,UAAI,UAAS,KAAK,OAAO;AAGzB,cAAM;AAAA,IACR,CAAC,IAGI;AAAA,EACT,SAAS,KAAK;AACZ,QAAI,SAAS,KAAK,OAAO;AACvB;AAEF,UAAM;AAAA,EACR;AACF;AAEO,SAAS,SAAS,KAAc,SAAqC;AAC1E,SAAI,eAAe,4BAAc,eAAe,6BAC1C,SAAS,WACX,QAAQ,KAAK,YAAY,QAAQ,OAAO,EAAE,GAErC,MAEF;AACT;AAEO,SAAS,iBAAiB,OAAY,OAAuB;AAClE,MAAI,iBAAiB,4BAAc,iBAAiB,2BAAa;AAC/D,KAAI,SAAS,QAAQ,IAAI,UACvB,QAAQ,KAAK,qCAA8B,MAAM,OAAO,EAAE;AAE5D;AAAA,EACF;AAIA,MAAI,SAAO,SAAU,YAAY,MAAM,SAAS;AAIhD,UAAM;AACR;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var asyncContext_exports = {};
|
|
16
|
-
__export(asyncContext_exports, {
|
|
17
|
-
createAsyncContext: () => createAsyncContext
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(asyncContext_exports);
|
|
20
|
-
var import_isServerRuntime = require("../server/isServerRuntime");
|
|
21
|
-
let nodeAsyncLocalStorageCache = null;
|
|
22
|
-
const nodeModuleId = ["node", "async_hooks"].join(":");
|
|
23
|
-
async function getNodeAsyncLocalStorage() {
|
|
24
|
-
if (!nodeAsyncLocalStorageCache)
|
|
25
|
-
try {
|
|
26
|
-
nodeAsyncLocalStorageCache = (await import(
|
|
27
|
-
/* @vite-ignore */
|
|
28
|
-
nodeModuleId
|
|
29
|
-
)).AsyncLocalStorage;
|
|
30
|
-
} catch {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
return nodeAsyncLocalStorageCache;
|
|
34
|
-
}
|
|
35
|
-
function createAsyncContext() {
|
|
36
|
-
if ((0, import_isServerRuntime.isServerRuntime)()) {
|
|
37
|
-
let storage = null;
|
|
38
|
-
return getNodeAsyncLocalStorage().then((AsyncLocalStorage) => {
|
|
39
|
-
AsyncLocalStorage && !storage && (storage = new AsyncLocalStorage());
|
|
40
|
-
}), {
|
|
41
|
-
get() {
|
|
42
|
-
if (!storage) {
|
|
43
|
-
console.warn("\u26A0\uFE0F called AsyncContext before load!");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
return storage.getStore();
|
|
47
|
-
},
|
|
48
|
-
async run(value, fn) {
|
|
49
|
-
if (!storage)
|
|
50
|
-
throw new Error("\u26A0\uFE0F called AsyncContext before load!");
|
|
51
|
-
return storage.run(value, fn);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
} else
|
|
55
|
-
return createBrowserAsyncContext();
|
|
56
|
-
}
|
|
57
|
-
function createBrowserAsyncContext() {
|
|
58
|
-
let currentContext;
|
|
59
|
-
const contextStack = [];
|
|
60
|
-
return {
|
|
61
|
-
get() {
|
|
62
|
-
return currentContext;
|
|
63
|
-
},
|
|
64
|
-
async run(value, fn) {
|
|
65
|
-
const prevContext = currentContext;
|
|
66
|
-
currentContext = value, contextStack.push(prevContext);
|
|
67
|
-
const OriginalPromise = Promise, OriginalThen = OriginalPromise.prototype.then, OriginalCatch = OriginalPromise.prototype.catch, OriginalFinally = OriginalPromise.prototype.finally;
|
|
68
|
-
function wrapCallback(callback, context) {
|
|
69
|
-
return callback && ((...args) => {
|
|
70
|
-
const prevContext2 = currentContext;
|
|
71
|
-
currentContext = context;
|
|
72
|
-
try {
|
|
73
|
-
return callback(...args);
|
|
74
|
-
} finally {
|
|
75
|
-
currentContext = prevContext2;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
OriginalPromise.prototype.then = function(onFulfilled, onRejected) {
|
|
80
|
-
const context = currentContext;
|
|
81
|
-
return OriginalThen.call(
|
|
82
|
-
this,
|
|
83
|
-
wrapCallback(onFulfilled, context),
|
|
84
|
-
wrapCallback(onRejected, context)
|
|
85
|
-
);
|
|
86
|
-
}, OriginalPromise.prototype.catch = function(onRejected) {
|
|
87
|
-
const context = currentContext;
|
|
88
|
-
return OriginalCatch.call(this, wrapCallback(onRejected, context));
|
|
89
|
-
}, OriginalPromise.prototype.finally = function(onFinally) {
|
|
90
|
-
const context = currentContext;
|
|
91
|
-
return OriginalFinally.call(this, wrapCallback(onFinally, context));
|
|
92
|
-
};
|
|
93
|
-
try {
|
|
94
|
-
return await fn();
|
|
95
|
-
} finally {
|
|
96
|
-
OriginalPromise.prototype.then = OriginalThen, OriginalPromise.prototype.catch = OriginalCatch, OriginalPromise.prototype.finally = OriginalFinally, contextStack.pop(), currentContext = prevContext;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=asyncContext.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/async/asyncContext.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAgC;AAgBhC,IAAI,6BAAkE;AAGtE,MAAM,eAAe,CAAC,QAAQ,aAAa,EAAE,KAAK,GAAG;AAErD,eAAe,2BAAyE;AACtF,MAAI,CAAC;AACH,QAAI;AAEF,oCADe,MAAM;AAAA;AAAA,QAA0B;AAAA,SAEtC;AAAA,IACX,QAAQ;AACN,aAAO;AAAA,IACT;AAEF,SAAO;AACT;AAEO,SAAS,qBAAyC;AACvD,UAAI,wCAAgB,GAAG;AACrB,QAAI,UAA2C;AAE/C,oCAAyB,EAAE,KAAK,CAAC,sBAAsB;AACrD,MAAI,qBAAqB,CAAC,YACxB,UAAU,IAAI,kBAAqB;AAAA,IAEvC,CAAC,GAEM;AAAA,MACL,MAAqB;AACnB,YAAI,CAAC,SAAS;AACZ,kBAAQ,KAAK,+CAAqC;AAClD;AAAA,QACF;AAEA,eAAO,QAAQ,SAAS;AAAA,MAC1B;AAAA,MAEA,MAAM,IAAO,OAAU,IAAsC;AAC3D,YAAI,CAAC;AACH,gBAAM,IAAI,MAAM,+CAAqC;AAEvD,eAAO,QAAQ,IAAI,OAAO,EAAE;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AAEE,WAAO,0BAA6B;AAExC;AAEA,SAAS,4BAAgD;AACvD,MAAI;AACJ,QAAM,eAAkC,CAAC;AAEzC,SAAO;AAAA,IACL,MAAqB;AACnB,aAAO;AAAA,IACT;AAAA,IACA,MAAM,IAAO,OAAU,IAAsC;AAC3D,YAAM,cAAc;AACpB,uBAAiB,OACjB,aAAa,KAAK,WAAW;AAG7B,YAAM,kBAAkB,SAClB,eAAe,gBAAgB,UAAU,MACzC,gBAAgB,gBAAgB,UAAU,OAC1C,kBAAkB,gBAAgB,UAAU;AAElD,eAAS,aACP,UACA,SAC6B;AAC7B,eAAK,aACE,IAAI,SAAgB;AACzB,gBAAMA,eAAc;AACpB,2BAAiB;AACjB,cAAI;AACF,mBAAO,SAAS,GAAG,IAAI;AAAA,UACzB,UAAE;AACA,6BAAiBA;AAAA,UACnB;AAAA,QACF;AAAA,MACF;AAIA,sBAAgB,UAAU,OAAO,SAE/B,aACA,YACc;AACd,cAAM,UAAU;AAChB,eAAO,aAAa;AAAA,UAClB;AAAA,UACA,aAAa,aAAa,OAAO;AAAA,UACjC,aAAa,YAAY,OAAO;AAAA,QAClC;AAAA,MACF,GAEA,gBAAgB,UAAU,QAAQ,SAEhC,YACc;AACd,cAAM,UAAU;AAChB,eAAO,cAAc,KAAK,MAAM,aAAa,YAAY,OAAO,CAAQ;AAAA,MAC1E,GAEA,gBAAgB,UAAU,UAAU,SAElC,WACc;AACd,cAAM,UAAU;AAChB,eAAO,gBAAgB,KAAK,MAAM,aAAa,WAAW,OAAO,CAAQ;AAAA,MAC3E;AAEA,UAAI;AAEF,eADe,MAAM,GAAG;AAAA,MAE1B,UAAE;AAGA,wBAAgB,UAAU,OAAO,cACjC,gBAAgB,UAAU,QAAQ,eAClC,gBAAgB,UAAU,UAAU,iBAEpC,aAAa,IAAI,GACjB,iBAAiB;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
|
-
"names": ["prevContext"]
|
|
6
|
-
}
|
package/dist/cjs/async/idle.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var idle_exports = {};
|
|
16
|
-
__export(idle_exports, {
|
|
17
|
-
idle: () => idle
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(idle_exports);
|
|
20
|
-
var import_errors = require("../error/errors"), import_sleep = require("./sleep");
|
|
21
|
-
const idleCb = typeof requestIdleCallback > "u" ? (cb) => setTimeout(cb, 1) : requestIdleCallback, idleAsync = () => new Promise((res) => {
|
|
22
|
-
idleCb(res);
|
|
23
|
-
}), idle = async (options, signal) => {
|
|
24
|
-
const { max, min, fully } = options || {}, idleFn = fully ? fullyIdle : idleAsync;
|
|
25
|
-
if (max && min && min < max ? await Promise.race([Promise.all([idleFn(), (0, import_sleep.sleep)(min)]), (0, import_sleep.sleep)(max)]) : max ? await Promise.race([idleFn(), (0, import_sleep.sleep)(max)]) : min ? await Promise.all([idleFn(), (0, import_sleep.sleep)(min)]) : await idleFn(), signal?.aborted)
|
|
26
|
-
throw new import_errors.AbortError();
|
|
27
|
-
}, fullyIdle = async (signal) => {
|
|
28
|
-
for (; ; ) {
|
|
29
|
-
const startTime = Date.now();
|
|
30
|
-
if (await idle({}, signal), Date.now() - startTime < 15)
|
|
31
|
-
break;
|
|
32
|
-
if (signal?.aborted)
|
|
33
|
-
throw new import_errors.AbortError();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=idle.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/async/idle.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B,4BAC3B,eAAsB;AAStB,MAAM,SACJ,OAAO,sBAAwB,MAC3B,CAAC,OAAmB,WAAW,IAAI,CAAC,IACpC,qBAEA,YAAY,MACT,IAAI,QAAQ,CAAC,QAAQ;AAC1B,SAAO,GAAG;AACZ,CAAC,GASU,OAAO,OAClB,SACA,WACkB;AAClB,QAAM,EAAE,KAAK,KAAK,MAAM,IAAI,WAAW,CAAC,GAElC,SAAS,QAAQ,YAAY;AAYnC,MAVI,OAAO,OAAO,MAAM,MACtB,MAAM,QAAQ,KAAK,CAAC,QAAQ,IAAI,CAAC,OAAO,OAAG,oBAAM,GAAG,CAAC,CAAC,OAAG,oBAAM,GAAG,CAAC,CAAC,IAC3D,MACT,MAAM,QAAQ,KAAK,CAAC,OAAO,OAAG,oBAAM,GAAG,CAAC,CAAC,IAChC,MACT,MAAM,QAAQ,IAAI,CAAC,OAAO,OAAG,oBAAM,GAAG,CAAC,CAAC,IAExC,MAAM,OAAO,GAGX,QAAQ;AACV,UAAM,IAAI,yBAAW;AAEzB,GAEM,YAAY,OAAO,WAAwC;AAC/D,aAAa;AACX,UAAM,YAAY,KAAK,IAAI;AAM3B,QALA,MAAM,KAAK,CAAC,GAAG,MAAM,GACL,KAAK,IAAI,IACE,YAGZ;AACb;AAIF,QAAI,QAAQ;AACV,YAAM,IAAI,yBAAW;AAAA,EAEzB;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var interval_exports = {};
|
|
16
|
-
__export(interval_exports, {
|
|
17
|
-
interval: () => interval
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(interval_exports);
|
|
20
|
-
var import_sleep = require("./sleep");
|
|
21
|
-
const interval = async (callback, ms, signal) => {
|
|
22
|
-
for (; ; )
|
|
23
|
-
callback(), await (0, import_sleep.sleep)(ms, signal);
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=interval.js.map
|