@toon-protocol/hub 0.34.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.
@@ -0,0 +1,39 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __commonJS = (cb, mod) => function __require2() {
15
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
+ mod
32
+ ));
33
+
34
+ export {
35
+ __require,
36
+ __commonJS,
37
+ __toESM
38
+ };
39
+ //# sourceMappingURL=chunk-I2R4CRUX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,65 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+
3
+ // src/tui/format.ts
4
+ var DECIMAL_RE = /^-?\d+$/;
5
+ var MICRO_FRACTIONAL_DIGITS = 4;
6
+ function formatRelativeTime(iso, now = /* @__PURE__ */ new Date()) {
7
+ if (iso === null) return "\u2014";
8
+ const ms = Date.parse(iso);
9
+ if (!Number.isFinite(ms)) return "?";
10
+ const deltaSec = Math.max(0, Math.floor((now.getTime() - ms) / 1e3));
11
+ if (deltaSec < 60) return "<1m ago";
12
+ if (deltaSec < 3600) return `${Math.floor(deltaSec / 60)}m ago`;
13
+ if (deltaSec < 86400) return `${Math.floor(deltaSec / 3600)}h ago`;
14
+ if (deltaSec < 2592e3) return `${Math.floor(deltaSec / 86400)}d ago`;
15
+ return `${Math.floor(deltaSec / 2592e3)}mo ago`;
16
+ }
17
+ function formatUsdcMicro(decimalString, scale) {
18
+ if (!DECIMAL_RE.test(decimalString)) {
19
+ const env = process.env["NODE_ENV"];
20
+ if (env === "development" || env === "test") {
21
+ throw new Error(
22
+ `formatUsdcMicro: invalid decimal string: ${JSON.stringify(decimalString)}`
23
+ );
24
+ }
25
+ return "$?.????";
26
+ }
27
+ const negative = decimalString.startsWith("-");
28
+ const abs = negative ? decimalString.slice(1) : decimalString;
29
+ const divisor = BigInt(10) ** BigInt(scale);
30
+ const value = BigInt(abs);
31
+ const whole = value / divisor;
32
+ const remainder = value % divisor;
33
+ const fractionalStr = remainder.toString().padStart(scale, "0");
34
+ const cents = fractionalStr.slice(0, MICRO_FRACTIONAL_DIGITS).padEnd(MICRO_FRACTIONAL_DIGITS, "0");
35
+ const formatted = `$${whole.toString()}.${cents}`;
36
+ return negative && value !== 0n ? `-${formatted}` : formatted;
37
+ }
38
+ function formatUsdc(decimalString, scale) {
39
+ if (!DECIMAL_RE.test(decimalString)) {
40
+ const env = process.env["NODE_ENV"];
41
+ if (env === "development" || env === "test") {
42
+ throw new Error(
43
+ `formatUsdc: invalid decimal string: ${JSON.stringify(decimalString)}`
44
+ );
45
+ }
46
+ return "$?.??";
47
+ }
48
+ const negative = decimalString.startsWith("-");
49
+ const abs = negative ? decimalString.slice(1) : decimalString;
50
+ const divisor = BigInt(10) ** BigInt(scale);
51
+ const value = BigInt(abs);
52
+ const whole = value / divisor;
53
+ const remainder = value % divisor;
54
+ const fractionalStr = remainder.toString().padStart(scale, "0");
55
+ const cents = fractionalStr.slice(0, 2).padEnd(2, "0");
56
+ const formatted = `$${whole.toString()}.${cents}`;
57
+ return negative && value !== 0n ? `-${formatted}` : formatted;
58
+ }
59
+
60
+ export {
61
+ formatRelativeTime,
62
+ formatUsdcMicro,
63
+ formatUsdc
64
+ };
65
+ //# sourceMappingURL=chunk-JCOFMUPL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tui/format.ts"],"sourcesContent":["const DECIMAL_RE = /^-?\\d+$/;\nconst MICRO_FRACTIONAL_DIGITS = 4;\n\nexport function formatRelativeTime(\n iso: string | null,\n now: Date = new Date()\n): string {\n if (iso === null) return '—';\n const ms = Date.parse(iso);\n if (!Number.isFinite(ms)) return '?';\n // Clamp negative deltas (future-dated `at` from host/container clock skew) to 0.\n // Without the clamp, a claim ~hours in the future would silently render `<1m ago`\n // because every negative value already trips the `< 60` shortcut; the clamp makes\n // the future-tolerance contract explicit instead of incidental.\n const deltaSec = Math.max(0, Math.floor((now.getTime() - ms) / 1000));\n if (deltaSec < 60) return '<1m ago';\n if (deltaSec < 3600) return `${Math.floor(deltaSec / 60)}m ago`;\n if (deltaSec < 86_400) return `${Math.floor(deltaSec / 3600)}h ago`;\n if (deltaSec < 2_592_000) return `${Math.floor(deltaSec / 86_400)}d ago`;\n return `${Math.floor(deltaSec / 2_592_000)}mo ago`;\n}\n\nexport function formatUsdcMicro(decimalString: string, scale: number): string {\n if (!DECIMAL_RE.test(decimalString)) {\n const env = process.env['NODE_ENV'];\n if (env === 'development' || env === 'test') {\n throw new Error(\n `formatUsdcMicro: invalid decimal string: ${JSON.stringify(decimalString)}`\n );\n }\n return '$?.????';\n }\n\n const negative = decimalString.startsWith('-');\n const abs = negative ? decimalString.slice(1) : decimalString;\n\n const divisor = BigInt(10) ** BigInt(scale);\n const value = BigInt(abs);\n\n const whole = value / divisor;\n const remainder = value % divisor;\n\n const fractionalStr = remainder.toString().padStart(scale, '0');\n const cents = fractionalStr\n .slice(0, MICRO_FRACTIONAL_DIGITS)\n .padEnd(MICRO_FRACTIONAL_DIGITS, '0');\n\n const formatted = `$${whole.toString()}.${cents}`;\n return negative && value !== 0n ? `-${formatted}` : formatted;\n}\n\nexport function formatUsdc(decimalString: string, scale: number): string {\n if (!DECIMAL_RE.test(decimalString)) {\n const env = process.env['NODE_ENV'];\n if (env === 'development' || env === 'test') {\n throw new Error(\n `formatUsdc: invalid decimal string: ${JSON.stringify(decimalString)}`\n );\n }\n return '$?.??';\n }\n\n const negative = decimalString.startsWith('-');\n const abs = negative ? decimalString.slice(1) : decimalString;\n\n const divisor = BigInt(10) ** BigInt(scale);\n const value = BigInt(abs);\n\n // Truncate (do NOT round) — connector posture.\n const whole = value / divisor;\n const remainder = value % divisor;\n\n const fractionalStr = remainder.toString().padStart(scale, '0');\n const cents = fractionalStr.slice(0, 2).padEnd(2, '0');\n\n const formatted = `$${whole.toString()}.${cents}`;\n // Suppress `-$0.00` — value === 0n collapses negative zero.\n return negative && value !== 0n ? `-${formatted}` : formatted;\n}\n"],"mappings":";;;AAAA,IAAM,aAAa;AACnB,IAAM,0BAA0B;AAEzB,SAAS,mBACd,KACA,MAAY,oBAAI,KAAK,GACb;AACR,MAAI,QAAQ,KAAM,QAAO;AACzB,QAAM,KAAK,KAAK,MAAM,GAAG;AACzB,MAAI,CAAC,OAAO,SAAS,EAAE,EAAG,QAAO;AAKjC,QAAM,WAAW,KAAK,IAAI,GA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