@lightsparkdev/core 1.4.1 → 1.4.3
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/CHANGELOG.md +14 -0
- package/dist/{chunk-NV53XYAS.js → chunk-36QHRQJC.js} +1106 -12
- package/dist/{index-DZbfPQqd.d.cts → index-gUXiTlhb.d.cts} +30 -2
- package/dist/{index-DZbfPQqd.d.ts → index-gUXiTlhb.d.ts} +30 -2
- package/dist/index.cjs +1123 -15
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -4
- package/dist/utils/index.cjs +1111 -13
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +11 -3
- package/package.json +1 -1
- package/src/requester/Requester.ts +22 -5
- package/src/utils/currency.ts +63 -1
- package/src/utils/environment.ts +7 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/zipcodeToState.ts +1120 -0
|
@@ -27,6 +27,8 @@ declare const CurrencyUnit: {
|
|
|
27
27
|
readonly MXN: "MXN";
|
|
28
28
|
readonly PHP: "PHP";
|
|
29
29
|
readonly EUR: "EUR";
|
|
30
|
+
readonly GBP: "GBP";
|
|
31
|
+
readonly INR: "INR";
|
|
30
32
|
readonly Bitcoin: "BITCOIN";
|
|
31
33
|
readonly Microbitcoin: "MICROBITCOIN";
|
|
32
34
|
readonly Millibitcoin: "MILLIBITCOIN";
|
|
@@ -36,6 +38,8 @@ declare const CurrencyUnit: {
|
|
|
36
38
|
readonly Usd: "USD";
|
|
37
39
|
readonly Mxn: "MXN";
|
|
38
40
|
readonly Php: "PHP";
|
|
41
|
+
readonly Gbp: "GBP";
|
|
42
|
+
readonly Inr: "INR";
|
|
39
43
|
};
|
|
40
44
|
type CurrencyUnitType = (typeof CurrencyUnit)[keyof typeof CurrencyUnit];
|
|
41
45
|
type SDKCurrencyAmountType = {
|
|
@@ -61,6 +65,8 @@ type CurrencyMap = {
|
|
|
61
65
|
[CurrencyUnit.MXN]: number;
|
|
62
66
|
[CurrencyUnit.PHP]: number;
|
|
63
67
|
[CurrencyUnit.EUR]: number;
|
|
68
|
+
[CurrencyUnit.GBP]: number;
|
|
69
|
+
[CurrencyUnit.INR]: number;
|
|
64
70
|
[CurrencyUnit.FUTURE_VALUE]: number;
|
|
65
71
|
formatted: {
|
|
66
72
|
sats: string;
|
|
@@ -76,6 +82,8 @@ type CurrencyMap = {
|
|
|
76
82
|
[CurrencyUnit.MXN]: string;
|
|
77
83
|
[CurrencyUnit.PHP]: string;
|
|
78
84
|
[CurrencyUnit.EUR]: string;
|
|
85
|
+
[CurrencyUnit.GBP]: string;
|
|
86
|
+
[CurrencyUnit.INR]: string;
|
|
79
87
|
[CurrencyUnit.FUTURE_VALUE]: string;
|
|
80
88
|
};
|
|
81
89
|
isZero: boolean;
|
|
@@ -131,7 +139,7 @@ declare function getCurrencyAmount(currencyAmountArg: CurrencyAmountArg): {
|
|
|
131
139
|
};
|
|
132
140
|
declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, unitsPerBtc?: number): CurrencyMap;
|
|
133
141
|
declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
|
|
134
|
-
declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "MXN" | "PHP" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
|
|
142
|
+
declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "GBP" | "INR" | "MXN" | "PHP" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
|
|
135
143
|
type AppendUnitsOptions = {
|
|
136
144
|
plural?: boolean | undefined;
|
|
137
145
|
lowercase?: boolean | undefined;
|
|
@@ -149,10 +157,21 @@ declare function separateCurrencyStrParts(currencyStr: string): {
|
|
|
149
157
|
amount: string;
|
|
150
158
|
};
|
|
151
159
|
declare function localeToCurrencySymbol(locale: string): string;
|
|
160
|
+
/**
|
|
161
|
+
* Formats an amount from the smallest currency unit to a display string
|
|
162
|
+
* @param amount - The amount in the smallest currency unit (No decimals)
|
|
163
|
+
* @param currency - The currency object with code and decimals
|
|
164
|
+
* @returns Formatted string like "12.50 USD" or empty string if invalid
|
|
165
|
+
*/
|
|
166
|
+
declare function formatInviteAmount(amount: number | null | undefined, currency: UmaCurrency | null | undefined): string;
|
|
152
167
|
|
|
168
|
+
declare global {
|
|
169
|
+
const Bare: unknown;
|
|
170
|
+
}
|
|
153
171
|
declare const isBrowser: boolean;
|
|
154
172
|
declare const isNode: boolean;
|
|
155
173
|
declare const isTest: boolean;
|
|
174
|
+
declare const isBare: boolean;
|
|
156
175
|
|
|
157
176
|
type Maybe<T> = T | null | undefined;
|
|
158
177
|
type ExpandRecursively<T> = T extends object ? T extends infer O ? {
|
|
@@ -308,4 +327,13 @@ declare function isUint8Array(value: unknown): value is Uint8Array;
|
|
|
308
327
|
declare function isObject(value: unknown): value is object;
|
|
309
328
|
declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
310
329
|
|
|
311
|
-
|
|
330
|
+
type StateCode = "AK" | "AL" | "AR" | "AZ" | "CA" | "CO" | "CT" | "DE" | "FL" | "GA" | "HI" | "IA" | "ID" | "IL" | "IN" | "KS" | "KY" | "LA" | "MA" | "MD" | "ME" | "MI" | "MN" | "MO" | "MS" | "MT" | "NC" | "ND" | "NE" | "NV" | "NH" | "NJ" | "NM" | "NY" | "OH" | "OK" | "OR" | "PA" | "RI" | "SC" | "SD" | "TN" | "TX" | "UT" | "VA" | "VT" | "WA" | "WI" | "WV" | "WY" | "DC" | "GU" | "PR" | "VI" | "AE" | "AA" | "AP" | "AS" | "PW" | "FM" | "MP" | "MH";
|
|
331
|
+
declare const zipcodeToStateCode: Record<string, StateCode>;
|
|
332
|
+
/**
|
|
333
|
+
* Converts a US zipcode to its corresponding state code
|
|
334
|
+
* @param zipcode The zipcode to convert
|
|
335
|
+
* @returns The state code or null if not found
|
|
336
|
+
*/
|
|
337
|
+
declare function zipcodeToState(zipcode: string): StateCode | null;
|
|
338
|
+
|
|
339
|
+
export { setLocalStorageBoolean as $, type AppendUnitsOptions as A, formatCurrencyStr as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, separateCurrencyStrParts as E, localeToCurrencySymbol as F, formatInviteAmount as G, isBrowser as H, isNode as I, isTest as J, isBare as K, isError as L, isErrorWithMessage as M, getErrorMsg as N, isErrorMsg as O, errorToJSON as P, bytesToHex as Q, hexToBytes as R, type SDKCurrencyAmountType as S, getCurrentLocale as T, type UmaCurrency as U, countryCodesToCurrencyCodes as V, type CurrencyLocales as W, type CurrencyCodes as X, localeToCurrencyCode as Y, getLocalStorageConfigItem as Z, getLocalStorageBoolean as _, b64encode as a, deleteLocalStorageItem as a0, clamp as a1, linearInterpolate as a2, round as a3, isNumber as a4, pollUntil as a5, sleep as a6, lsidToUUID as a7, isUint8Array as a8, isObject as a9, isRecord as aa, type Maybe as ab, type ExpandRecursively as ac, type ById as ad, type OmitTypename as ae, isType as af, type ExtractByTypename as ag, type DeepPartial as ah, type JSONLiteral as ai, type JSONType as aj, type JSONObject as ak, type NN as al, notNullUndefined as am, type PartialBy as an, type Complete as ao, type RequiredKeys as ap, type StateCode as aq, zipcodeToStateCode as ar, zipcodeToState as as, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, ensureArray as e, CurrencyUnit as f, type CurrencyUnitType as g, convertCurrencyAmountValue as h, convertCurrencyAmount as i, type CurrencyMap as j, type CurrencyAmountInputObj as k, type UmaCurrencyAmount as l, type CurrencyAmountObj as m, type CurrencyAmountPreferenceObj as n, type CurrencyAmountArg as o, isCurrencyAmountInputObj as p, isUmaCurrencyAmount as q, isDeprecatedCurrencyAmountObj as r, isCurrencyAmountObj as s, isCurrencyAmountPreferenceObj as t, urlsafe_b64decode as u, isSDKCurrencyAmount as v, getCurrencyAmount as w, mapCurrencyAmount as x, isCurrencyMap as y, abbrCurrencyUnit as z };
|
|
@@ -27,6 +27,8 @@ declare const CurrencyUnit: {
|
|
|
27
27
|
readonly MXN: "MXN";
|
|
28
28
|
readonly PHP: "PHP";
|
|
29
29
|
readonly EUR: "EUR";
|
|
30
|
+
readonly GBP: "GBP";
|
|
31
|
+
readonly INR: "INR";
|
|
30
32
|
readonly Bitcoin: "BITCOIN";
|
|
31
33
|
readonly Microbitcoin: "MICROBITCOIN";
|
|
32
34
|
readonly Millibitcoin: "MILLIBITCOIN";
|
|
@@ -36,6 +38,8 @@ declare const CurrencyUnit: {
|
|
|
36
38
|
readonly Usd: "USD";
|
|
37
39
|
readonly Mxn: "MXN";
|
|
38
40
|
readonly Php: "PHP";
|
|
41
|
+
readonly Gbp: "GBP";
|
|
42
|
+
readonly Inr: "INR";
|
|
39
43
|
};
|
|
40
44
|
type CurrencyUnitType = (typeof CurrencyUnit)[keyof typeof CurrencyUnit];
|
|
41
45
|
type SDKCurrencyAmountType = {
|
|
@@ -61,6 +65,8 @@ type CurrencyMap = {
|
|
|
61
65
|
[CurrencyUnit.MXN]: number;
|
|
62
66
|
[CurrencyUnit.PHP]: number;
|
|
63
67
|
[CurrencyUnit.EUR]: number;
|
|
68
|
+
[CurrencyUnit.GBP]: number;
|
|
69
|
+
[CurrencyUnit.INR]: number;
|
|
64
70
|
[CurrencyUnit.FUTURE_VALUE]: number;
|
|
65
71
|
formatted: {
|
|
66
72
|
sats: string;
|
|
@@ -76,6 +82,8 @@ type CurrencyMap = {
|
|
|
76
82
|
[CurrencyUnit.MXN]: string;
|
|
77
83
|
[CurrencyUnit.PHP]: string;
|
|
78
84
|
[CurrencyUnit.EUR]: string;
|
|
85
|
+
[CurrencyUnit.GBP]: string;
|
|
86
|
+
[CurrencyUnit.INR]: string;
|
|
79
87
|
[CurrencyUnit.FUTURE_VALUE]: string;
|
|
80
88
|
};
|
|
81
89
|
isZero: boolean;
|
|
@@ -131,7 +139,7 @@ declare function getCurrencyAmount(currencyAmountArg: CurrencyAmountArg): {
|
|
|
131
139
|
};
|
|
132
140
|
declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, unitsPerBtc?: number): CurrencyMap;
|
|
133
141
|
declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
|
|
134
|
-
declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "MXN" | "PHP" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
|
|
142
|
+
declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "EUR" | "USD" | "GBP" | "INR" | "MXN" | "PHP" | "BTC" | "SAT" | "MSAT" | "mBTC" | "μBTC" | "Unsupported CurrencyUnit";
|
|
135
143
|
type AppendUnitsOptions = {
|
|
136
144
|
plural?: boolean | undefined;
|
|
137
145
|
lowercase?: boolean | undefined;
|
|
@@ -149,10 +157,21 @@ declare function separateCurrencyStrParts(currencyStr: string): {
|
|
|
149
157
|
amount: string;
|
|
150
158
|
};
|
|
151
159
|
declare function localeToCurrencySymbol(locale: string): string;
|
|
160
|
+
/**
|
|
161
|
+
* Formats an amount from the smallest currency unit to a display string
|
|
162
|
+
* @param amount - The amount in the smallest currency unit (No decimals)
|
|
163
|
+
* @param currency - The currency object with code and decimals
|
|
164
|
+
* @returns Formatted string like "12.50 USD" or empty string if invalid
|
|
165
|
+
*/
|
|
166
|
+
declare function formatInviteAmount(amount: number | null | undefined, currency: UmaCurrency | null | undefined): string;
|
|
152
167
|
|
|
168
|
+
declare global {
|
|
169
|
+
const Bare: unknown;
|
|
170
|
+
}
|
|
153
171
|
declare const isBrowser: boolean;
|
|
154
172
|
declare const isNode: boolean;
|
|
155
173
|
declare const isTest: boolean;
|
|
174
|
+
declare const isBare: boolean;
|
|
156
175
|
|
|
157
176
|
type Maybe<T> = T | null | undefined;
|
|
158
177
|
type ExpandRecursively<T> = T extends object ? T extends infer O ? {
|
|
@@ -308,4 +327,13 @@ declare function isUint8Array(value: unknown): value is Uint8Array;
|
|
|
308
327
|
declare function isObject(value: unknown): value is object;
|
|
309
328
|
declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
310
329
|
|
|
311
|
-
|
|
330
|
+
type StateCode = "AK" | "AL" | "AR" | "AZ" | "CA" | "CO" | "CT" | "DE" | "FL" | "GA" | "HI" | "IA" | "ID" | "IL" | "IN" | "KS" | "KY" | "LA" | "MA" | "MD" | "ME" | "MI" | "MN" | "MO" | "MS" | "MT" | "NC" | "ND" | "NE" | "NV" | "NH" | "NJ" | "NM" | "NY" | "OH" | "OK" | "OR" | "PA" | "RI" | "SC" | "SD" | "TN" | "TX" | "UT" | "VA" | "VT" | "WA" | "WI" | "WV" | "WY" | "DC" | "GU" | "PR" | "VI" | "AE" | "AA" | "AP" | "AS" | "PW" | "FM" | "MP" | "MH";
|
|
331
|
+
declare const zipcodeToStateCode: Record<string, StateCode>;
|
|
332
|
+
/**
|
|
333
|
+
* Converts a US zipcode to its corresponding state code
|
|
334
|
+
* @param zipcode The zipcode to convert
|
|
335
|
+
* @returns The state code or null if not found
|
|
336
|
+
*/
|
|
337
|
+
declare function zipcodeToState(zipcode: string): StateCode | null;
|
|
338
|
+
|
|
339
|
+
export { setLocalStorageBoolean as $, type AppendUnitsOptions as A, formatCurrencyStr as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, separateCurrencyStrParts as E, localeToCurrencySymbol as F, formatInviteAmount as G, isBrowser as H, isNode as I, isTest as J, isBare as K, isError as L, isErrorWithMessage as M, getErrorMsg as N, isErrorMsg as O, errorToJSON as P, bytesToHex as Q, hexToBytes as R, type SDKCurrencyAmountType as S, getCurrentLocale as T, type UmaCurrency as U, countryCodesToCurrencyCodes as V, type CurrencyLocales as W, type CurrencyCodes as X, localeToCurrencyCode as Y, getLocalStorageConfigItem as Z, getLocalStorageBoolean as _, b64encode as a, deleteLocalStorageItem as a0, clamp as a1, linearInterpolate as a2, round as a3, isNumber as a4, pollUntil as a5, sleep as a6, lsidToUUID as a7, isUint8Array as a8, isObject as a9, isRecord as aa, type Maybe as ab, type ExpandRecursively as ac, type ById as ad, type OmitTypename as ae, isType as af, type ExtractByTypename as ag, type DeepPartial as ah, type JSONLiteral as ai, type JSONType as aj, type JSONObject as ak, type NN as al, notNullUndefined as am, type PartialBy as an, type Complete as ao, type RequiredKeys as ap, type StateCode as aq, zipcodeToStateCode as ar, zipcodeToState as as, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, ensureArray as e, CurrencyUnit as f, type CurrencyUnitType as g, convertCurrencyAmountValue as h, convertCurrencyAmount as i, type CurrencyMap as j, type CurrencyAmountInputObj as k, type UmaCurrencyAmount as l, type CurrencyAmountObj as m, type CurrencyAmountPreferenceObj as n, type CurrencyAmountArg as o, isCurrencyAmountInputObj as p, isUmaCurrencyAmount as q, isDeprecatedCurrencyAmountObj as r, isCurrencyAmountObj as s, isCurrencyAmountPreferenceObj as t, urlsafe_b64decode as u, isSDKCurrencyAmount as v, getCurrencyAmount as w, mapCurrencyAmount as x, isCurrencyMap as y, abbrCurrencyUnit as z };
|