@chainvibe/components 0.2.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/README.md +1 -0
- package/dist/_virtual/config.js +4 -0
- package/dist/_virtual/core.js +4 -0
- package/dist/_virtual/debug.js +4 -0
- package/dist/_virtual/encode.js +4 -0
- package/dist/_virtual/helpers.js +4 -0
- package/dist/_virtual/index.js +5 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/_virtual/memory.js +4 -0
- package/dist/_virtual/number.js +4 -0
- package/dist/components/NotificationBox/NotificationBox.d.ts +41 -0
- package/dist/components/NotificationBox/NotificationBox.d.ts.map +1 -0
- package/dist/components/NotificationBox/NotificationBox.js +86 -0
- package/dist/components/NotificationBox/NotificationBox.module.css +1 -0
- package/dist/components/NotificationBox/NotificationBox.module.css.js +29 -0
- package/dist/components/NotificationBox/index.d.ts +3 -0
- package/dist/components/NotificationBox/index.d.ts.map +1 -0
- package/dist/components/NotificationBoxAmount/NotificationBoxAmount.d.ts +13 -0
- package/dist/components/NotificationBoxAmount/NotificationBoxAmount.d.ts.map +1 -0
- package/dist/components/NotificationBoxAmount/NotificationBoxAmount.js +45 -0
- package/dist/components/NotificationBoxAmount/NotificationBoxAmount.module.css +1 -0
- package/dist/components/NotificationBoxAmount/NotificationBoxAmount.module.css.js +11 -0
- package/dist/components/NotificationBoxAmount/index.d.ts +2 -0
- package/dist/components/NotificationBoxAmount/index.d.ts.map +1 -0
- package/dist/components/NotificationBoxStack/NotificationBoxStack.d.ts +14 -0
- package/dist/components/NotificationBoxStack/NotificationBoxStack.d.ts.map +1 -0
- package/dist/components/NotificationBoxStack/NotificationBoxStack.js +47 -0
- package/dist/components/NotificationBoxStack/index.d.ts +3 -0
- package/dist/components/NotificationBoxStack/index.d.ts.map +1 -0
- package/dist/components/utils/cn.d.ts +2 -0
- package/dist/components/utils/cn.d.ts.map +1 -0
- package/dist/components/utils/cn.js +4 -0
- package/dist/dev/utils.js +55 -0
- package/dist/hooks/useChainVibeStream.js +60 -0
- package/dist/index.js +10 -0
- package/dist/node_modules/@number-flow/react/dist/NumberFlow-client-48rw3j0J.js +111 -0
- package/dist/node_modules/compress-json/dist/config.js +16 -0
- package/dist/node_modules/compress-json/dist/core.js +92 -0
- package/dist/node_modules/compress-json/dist/debug.js +19 -0
- package/dist/node_modules/compress-json/dist/encode.js +58 -0
- package/dist/node_modules/compress-json/dist/helpers.js +27 -0
- package/dist/node_modules/compress-json/dist/index.js +38 -0
- package/dist/node_modules/compress-json/dist/memory.js +128 -0
- package/dist/node_modules/compress-json/dist/number.js +119 -0
- package/dist/node_modules/number-flow/dist/lite-BtgQ9jUv.js +435 -0
- package/dist/node_modules/sonner/dist/index.js +744 -0
- package/dist/types/events.d.ts +22 -0
- package/dist/types/events.d.ts.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { f as st, N as q, d as it } from "../../../number-flow/dist/lite-BtgQ9jUv.js";
|
|
3
|
+
const REACT_MAJOR = parseInt(React.version.match(/^(\d+)\./)?.[1]), isReact19 = REACT_MAJOR >= 19, OBSERVED_ATTRIBUTES = [
|
|
4
|
+
"data",
|
|
5
|
+
"digits"
|
|
6
|
+
];
|
|
7
|
+
class NumberFlowElement extends q {
|
|
8
|
+
attributeChangedCallback(attr, _oldValue, newValue) {
|
|
9
|
+
this[attr] = JSON.parse(newValue);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
NumberFlowElement.observedAttributes = isReact19 ? [] : OBSERVED_ATTRIBUTES;
|
|
13
|
+
it("number-flow-react", NumberFlowElement);
|
|
14
|
+
const formatters = {}, serialize = isReact19 ? (p) => p : JSON.stringify;
|
|
15
|
+
function splitProps(props) {
|
|
16
|
+
const { transformTiming, spinTiming, opacityTiming, animated, respectMotionPreference, trend, plugins, ...rest } = props;
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
transformTiming,
|
|
20
|
+
spinTiming,
|
|
21
|
+
opacityTiming,
|
|
22
|
+
animated,
|
|
23
|
+
respectMotionPreference,
|
|
24
|
+
trend,
|
|
25
|
+
plugins
|
|
26
|
+
},
|
|
27
|
+
rest
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
class NumberFlowImpl extends React.Component {
|
|
31
|
+
// Update the non-`data` props to avoid JSON serialization
|
|
32
|
+
// Data needs to be set in render still:
|
|
33
|
+
updateProperties(prevProps) {
|
|
34
|
+
if (!this.el) return;
|
|
35
|
+
this.el.batched = !this.props.isolate;
|
|
36
|
+
const [nonData] = splitProps(this.props);
|
|
37
|
+
Object.entries(nonData).forEach(([k, v]) => {
|
|
38
|
+
this.el[k] = v ?? NumberFlowElement.defaultProps[k];
|
|
39
|
+
}), prevProps?.onAnimationsStart && this.el.removeEventListener("animationsstart", prevProps.onAnimationsStart), this.props.onAnimationsStart && this.el.addEventListener("animationsstart", this.props.onAnimationsStart), prevProps?.onAnimationsFinish && this.el.removeEventListener("animationsfinish", prevProps.onAnimationsFinish), this.props.onAnimationsFinish && this.el.addEventListener("animationsfinish", this.props.onAnimationsFinish);
|
|
40
|
+
}
|
|
41
|
+
componentDidMount() {
|
|
42
|
+
this.updateProperties(), isReact19 && this.el && (this.el.digits = this.props.digits, this.el.data = this.props.data);
|
|
43
|
+
}
|
|
44
|
+
getSnapshotBeforeUpdate(prevProps) {
|
|
45
|
+
if (this.updateProperties(prevProps), prevProps.data !== this.props.data) {
|
|
46
|
+
if (this.props.group)
|
|
47
|
+
return this.props.group.willUpdate(), () => this.props.group?.didUpdate();
|
|
48
|
+
if (!this.props.isolate)
|
|
49
|
+
return this.el?.willUpdate(), () => this.el?.didUpdate();
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
componentDidUpdate(_, __, didUpdate) {
|
|
54
|
+
didUpdate?.();
|
|
55
|
+
}
|
|
56
|
+
handleRef(el) {
|
|
57
|
+
this.props.innerRef && (this.props.innerRef.current = el), this.el = el;
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
const [_, { innerRef, className, data, willChange, isolate, group, digits, onAnimationsStart, onAnimationsFinish, ...rest }] = splitProps(this.props);
|
|
61
|
+
return (
|
|
62
|
+
// @ts-expect-error missing types
|
|
63
|
+
/* @__PURE__ */ React.createElement("number-flow-react", {
|
|
64
|
+
ref: this.handleRef,
|
|
65
|
+
"data-will-change": willChange ? "" : void 0,
|
|
66
|
+
// Have to rename this:
|
|
67
|
+
class: className,
|
|
68
|
+
...rest,
|
|
69
|
+
dangerouslySetInnerHTML: {
|
|
70
|
+
__html: ""
|
|
71
|
+
},
|
|
72
|
+
suppressHydrationWarning: !0,
|
|
73
|
+
digits: serialize(digits),
|
|
74
|
+
// Make sure data is set last, everything else is updated:
|
|
75
|
+
data: serialize(data)
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
constructor(props) {
|
|
80
|
+
super(props), this.handleRef = this.handleRef.bind(this);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const NumberFlow = /* @__PURE__ */ React.forwardRef(function({ value, locales, format, prefix, suffix, ...props }, _ref) {
|
|
84
|
+
React.useImperativeHandle(_ref, () => ref.current, []);
|
|
85
|
+
const ref = React.useRef(), group = React.useContext(NumberFlowGroupContext);
|
|
86
|
+
group?.useRegister(ref);
|
|
87
|
+
const localesString = React.useMemo(() => locales ? JSON.stringify(locales) : "", [
|
|
88
|
+
locales
|
|
89
|
+
]), formatString = React.useMemo(() => format ? JSON.stringify(format) : "", [
|
|
90
|
+
format
|
|
91
|
+
]), data = React.useMemo(() => {
|
|
92
|
+
const formatter = formatters[`${localesString}:${formatString}`] ??= new Intl.NumberFormat(locales, format);
|
|
93
|
+
return st(value, formatter, prefix, suffix);
|
|
94
|
+
}, [
|
|
95
|
+
value,
|
|
96
|
+
localesString,
|
|
97
|
+
formatString,
|
|
98
|
+
prefix,
|
|
99
|
+
suffix
|
|
100
|
+
]);
|
|
101
|
+
return /* @__PURE__ */ React.createElement(NumberFlowImpl, {
|
|
102
|
+
...props,
|
|
103
|
+
group,
|
|
104
|
+
data,
|
|
105
|
+
innerRef: ref
|
|
106
|
+
});
|
|
107
|
+
}), NumberFlowGroupContext = /* @__PURE__ */ React.createContext(void 0);
|
|
108
|
+
export {
|
|
109
|
+
NumberFlow as N,
|
|
110
|
+
NumberFlowElement as a
|
|
111
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __exports as config } from "../../../_virtual/config.js";
|
|
2
|
+
var hasRequiredConfig;
|
|
3
|
+
function requireConfig() {
|
|
4
|
+
return hasRequiredConfig ? config : (hasRequiredConfig = 1, Object.defineProperty(config, "__esModule", { value: !0 }), config.config = void 0, config.config = {
|
|
5
|
+
// default will not sort the object key
|
|
6
|
+
sort_key: !1,
|
|
7
|
+
// default will convert into null silently like JSON.stringify
|
|
8
|
+
preserve_nan: !1,
|
|
9
|
+
error_on_nan: !1,
|
|
10
|
+
preserve_infinite: !1,
|
|
11
|
+
error_on_infinite: !1
|
|
12
|
+
}, config);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
requireConfig as __require
|
|
16
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { __exports as core } from "../../../_virtual/core.js";
|
|
2
|
+
import { __require as requireDebug } from "./debug.js";
|
|
3
|
+
import { __require as requireEncode } from "./encode.js";
|
|
4
|
+
import { __require as requireMemory } from "./memory.js";
|
|
5
|
+
import { __require as requireNumber } from "./number.js";
|
|
6
|
+
var hasRequiredCore;
|
|
7
|
+
function requireCore() {
|
|
8
|
+
if (hasRequiredCore) return core;
|
|
9
|
+
hasRequiredCore = 1, Object.defineProperty(core, "__esModule", { value: !0 }), core.compress = compress, core.decode = decode, core.decompress = decompress;
|
|
10
|
+
const debug_1 = requireDebug(), encode_1 = requireEncode(), memory_1 = requireMemory(), number_1 = requireNumber();
|
|
11
|
+
function compress(o) {
|
|
12
|
+
const mem = (0, memory_1.makeInMemoryMemory)(), root = (0, memory_1.addValue)(mem, o, void 0);
|
|
13
|
+
return [(0, memory_1.memToValues)(mem), root];
|
|
14
|
+
}
|
|
15
|
+
function decodeObject(values, s) {
|
|
16
|
+
if (s === "o|")
|
|
17
|
+
return {};
|
|
18
|
+
const o = {}, vs = s.split("|"), key_id = vs[1];
|
|
19
|
+
let keys = decode(values, key_id);
|
|
20
|
+
const n = vs.length;
|
|
21
|
+
n - 2 === 1 && !Array.isArray(keys) && (keys = [keys]);
|
|
22
|
+
for (let i = 2; i < n; i++) {
|
|
23
|
+
const k = keys[i - 2];
|
|
24
|
+
let v = vs[i];
|
|
25
|
+
v = decode(values, v), o[k] = v;
|
|
26
|
+
}
|
|
27
|
+
return o;
|
|
28
|
+
}
|
|
29
|
+
function decodeArray(values, s) {
|
|
30
|
+
if (s === "a|")
|
|
31
|
+
return [];
|
|
32
|
+
const vs = s.split("|"), n = vs.length - 1, xs = new Array(n);
|
|
33
|
+
for (let i = 0; i < n; i++) {
|
|
34
|
+
let v = vs[i + 1];
|
|
35
|
+
v = decode(values, v), xs[i] = v;
|
|
36
|
+
}
|
|
37
|
+
return xs;
|
|
38
|
+
}
|
|
39
|
+
function decode(values, key) {
|
|
40
|
+
if (key === "" || key === "_")
|
|
41
|
+
return null;
|
|
42
|
+
const id = (0, encode_1.decodeKey)(key), v = values[id];
|
|
43
|
+
if (v === null)
|
|
44
|
+
return v;
|
|
45
|
+
switch (typeof v) {
|
|
46
|
+
case "undefined":
|
|
47
|
+
return v;
|
|
48
|
+
case "number":
|
|
49
|
+
return v;
|
|
50
|
+
case "string":
|
|
51
|
+
if (v[1] === "|")
|
|
52
|
+
switch (v[0]) {
|
|
53
|
+
case "b":
|
|
54
|
+
switch (v[2]) {
|
|
55
|
+
case "T":
|
|
56
|
+
return !0;
|
|
57
|
+
case "F":
|
|
58
|
+
return !1;
|
|
59
|
+
default:
|
|
60
|
+
return (0, debug_1.throwUnknownDataType)(v);
|
|
61
|
+
}
|
|
62
|
+
case "o":
|
|
63
|
+
return decodeObject(values, v);
|
|
64
|
+
case "n":
|
|
65
|
+
return (0, number_1.s_to_num)(v.slice(2));
|
|
66
|
+
case "N":
|
|
67
|
+
switch (v[2]) {
|
|
68
|
+
case "+":
|
|
69
|
+
return 1 / 0;
|
|
70
|
+
case "-":
|
|
71
|
+
return -1 / 0;
|
|
72
|
+
case "0":
|
|
73
|
+
return NaN;
|
|
74
|
+
default:
|
|
75
|
+
return (0, debug_1.throwUnknownDataType)(v);
|
|
76
|
+
}
|
|
77
|
+
case "a":
|
|
78
|
+
return decodeArray(values, v);
|
|
79
|
+
}
|
|
80
|
+
return (0, encode_1.decodeStr)(v);
|
|
81
|
+
}
|
|
82
|
+
return (0, debug_1.throwUnknownDataType)(v);
|
|
83
|
+
}
|
|
84
|
+
function decompress(c) {
|
|
85
|
+
const [values, root] = c;
|
|
86
|
+
return decode(values, root);
|
|
87
|
+
}
|
|
88
|
+
return core;
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
requireCore as __require
|
|
92
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __exports as debug } from "../../../_virtual/debug.js";
|
|
2
|
+
var hasRequiredDebug;
|
|
3
|
+
function requireDebug() {
|
|
4
|
+
if (hasRequiredDebug) return debug;
|
|
5
|
+
hasRequiredDebug = 1, Object.defineProperty(debug, "__esModule", { value: !0 }), debug.getType = getType, debug.throwUnknownDataType = throwUnknownDataType, debug.throwUnsupportedData = throwUnsupportedData;
|
|
6
|
+
function getType(o) {
|
|
7
|
+
return Object.prototype.toString.call(o);
|
|
8
|
+
}
|
|
9
|
+
function throwUnknownDataType(o) {
|
|
10
|
+
throw new TypeError("unsupported data type: " + getType(o));
|
|
11
|
+
}
|
|
12
|
+
function throwUnsupportedData(name) {
|
|
13
|
+
throw new TypeError("unsupported data type: " + name);
|
|
14
|
+
}
|
|
15
|
+
return debug;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
requireDebug as __require
|
|
19
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { __exports as encode } from "../../../_virtual/encode.js";
|
|
2
|
+
import { __require as requireNumber } from "./number.js";
|
|
3
|
+
var hasRequiredEncode;
|
|
4
|
+
function requireEncode() {
|
|
5
|
+
if (hasRequiredEncode) return encode;
|
|
6
|
+
hasRequiredEncode = 1, Object.defineProperty(encode, "__esModule", { value: !0 }), encode.encodeNum = encodeNum, encode.decodeNum = decodeNum, encode.decodeKey = decodeKey, encode.encodeBool = encodeBool, encode.decodeBool = decodeBool, encode.encodeStr = encodeStr, encode.decodeStr = decodeStr;
|
|
7
|
+
const number_1 = requireNumber();
|
|
8
|
+
function encodeNum(num) {
|
|
9
|
+
return num === 1 / 0 ? "N|+" : num === -1 / 0 ? "N|-" : Number.isNaN(num) ? "N|0" : "n|" + (0, number_1.num_to_s)(num);
|
|
10
|
+
}
|
|
11
|
+
function decodeNum(s) {
|
|
12
|
+
if (s.length === 3 && s[0] === "N" && s[1] === "|")
|
|
13
|
+
switch (s[2]) {
|
|
14
|
+
case "+":
|
|
15
|
+
return 1 / 0;
|
|
16
|
+
case "-":
|
|
17
|
+
return -1 / 0;
|
|
18
|
+
case "0":
|
|
19
|
+
return NaN;
|
|
20
|
+
}
|
|
21
|
+
return (0, number_1.s_to_num)(s.slice(2));
|
|
22
|
+
}
|
|
23
|
+
function decodeKey(key) {
|
|
24
|
+
return typeof key == "number" ? key : (0, number_1.s_to_int)(key);
|
|
25
|
+
}
|
|
26
|
+
function encodeBool(b) {
|
|
27
|
+
return b ? "b|T" : "b|F";
|
|
28
|
+
}
|
|
29
|
+
function decodeBool(s) {
|
|
30
|
+
if (s.length === 3 && s[0] === "b" && s[1] === "|")
|
|
31
|
+
switch (s[2]) {
|
|
32
|
+
case "T":
|
|
33
|
+
return !0;
|
|
34
|
+
case "F":
|
|
35
|
+
return !1;
|
|
36
|
+
}
|
|
37
|
+
return !!s;
|
|
38
|
+
}
|
|
39
|
+
function encodeStr(str) {
|
|
40
|
+
if (str[1] === "|")
|
|
41
|
+
switch (str[0]) {
|
|
42
|
+
case "b":
|
|
43
|
+
case "o":
|
|
44
|
+
case "n":
|
|
45
|
+
case "a":
|
|
46
|
+
case "s":
|
|
47
|
+
return "s|" + str;
|
|
48
|
+
}
|
|
49
|
+
return str;
|
|
50
|
+
}
|
|
51
|
+
function decodeStr(s) {
|
|
52
|
+
return s[0] === "s" && s[1] === "|" ? s.substr(2) : s;
|
|
53
|
+
}
|
|
54
|
+
return encode;
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
requireEncode as __require
|
|
58
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __exports as helpers } from "../../../_virtual/helpers.js";
|
|
2
|
+
var hasRequiredHelpers;
|
|
3
|
+
function requireHelpers() {
|
|
4
|
+
if (hasRequiredHelpers) return helpers;
|
|
5
|
+
hasRequiredHelpers = 1, Object.defineProperty(helpers, "__esModule", { value: !0 }), helpers.trimUndefined = trimUndefined, helpers.trimUndefinedRecursively = trimUndefinedRecursively;
|
|
6
|
+
function trimUndefined(object) {
|
|
7
|
+
for (const key in object)
|
|
8
|
+
object[key] === void 0 && delete object[key];
|
|
9
|
+
}
|
|
10
|
+
function trimUndefinedRecursively(object) {
|
|
11
|
+
trimUndefinedRecursivelyLoop(object, /* @__PURE__ */ new Set());
|
|
12
|
+
}
|
|
13
|
+
function trimUndefinedRecursivelyLoop(object, tracks) {
|
|
14
|
+
tracks.add(object);
|
|
15
|
+
for (const key in object)
|
|
16
|
+
if (object[key] === void 0)
|
|
17
|
+
delete object[key];
|
|
18
|
+
else {
|
|
19
|
+
const value = object[key];
|
|
20
|
+
value && typeof value == "object" && !tracks.has(value) && trimUndefinedRecursivelyLoop(value, tracks);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return helpers;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
requireHelpers as __require
|
|
27
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __exports as dist } from "../../../_virtual/index2.js";
|
|
2
|
+
import { __require as requireCore } from "./core.js";
|
|
3
|
+
import { __require as requireMemory } from "./memory.js";
|
|
4
|
+
import { __require as requireHelpers } from "./helpers.js";
|
|
5
|
+
import { __require as requireConfig } from "./config.js";
|
|
6
|
+
var hasRequiredDist;
|
|
7
|
+
function requireDist() {
|
|
8
|
+
return hasRequiredDist ? dist : (hasRequiredDist = 1, (function(exports$1) {
|
|
9
|
+
Object.defineProperty(exports$1, "__esModule", { value: !0 }), exports$1.config = exports$1.trimUndefinedRecursively = exports$1.trimUndefined = exports$1.addValue = exports$1.decode = exports$1.decompress = exports$1.compress = void 0;
|
|
10
|
+
var core_1 = requireCore();
|
|
11
|
+
Object.defineProperty(exports$1, "compress", { enumerable: !0, get: function() {
|
|
12
|
+
return core_1.compress;
|
|
13
|
+
} }), Object.defineProperty(exports$1, "decompress", { enumerable: !0, get: function() {
|
|
14
|
+
return core_1.decompress;
|
|
15
|
+
} });
|
|
16
|
+
var core_2 = requireCore();
|
|
17
|
+
Object.defineProperty(exports$1, "decode", { enumerable: !0, get: function() {
|
|
18
|
+
return core_2.decode;
|
|
19
|
+
} });
|
|
20
|
+
var memory_1 = requireMemory();
|
|
21
|
+
Object.defineProperty(exports$1, "addValue", { enumerable: !0, get: function() {
|
|
22
|
+
return memory_1.addValue;
|
|
23
|
+
} });
|
|
24
|
+
var helpers_1 = requireHelpers();
|
|
25
|
+
Object.defineProperty(exports$1, "trimUndefined", { enumerable: !0, get: function() {
|
|
26
|
+
return helpers_1.trimUndefined;
|
|
27
|
+
} }), Object.defineProperty(exports$1, "trimUndefinedRecursively", { enumerable: !0, get: function() {
|
|
28
|
+
return helpers_1.trimUndefinedRecursively;
|
|
29
|
+
} });
|
|
30
|
+
var config_1 = requireConfig();
|
|
31
|
+
Object.defineProperty(exports$1, "config", { enumerable: !0, get: function() {
|
|
32
|
+
return config_1.config;
|
|
33
|
+
} });
|
|
34
|
+
})(dist), dist);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
requireDist as __require
|
|
38
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { __exports as memory } from "../../../_virtual/memory.js";
|
|
2
|
+
import { __require as requireConfig } from "./config.js";
|
|
3
|
+
import { __require as requireDebug } from "./debug.js";
|
|
4
|
+
import { __require as requireEncode } from "./encode.js";
|
|
5
|
+
import { __require as requireNumber } from "./number.js";
|
|
6
|
+
var hasRequiredMemory;
|
|
7
|
+
function requireMemory() {
|
|
8
|
+
if (hasRequiredMemory) return memory;
|
|
9
|
+
hasRequiredMemory = 1, Object.defineProperty(memory, "__esModule", { value: !0 }), memory.memToValues = memToValues, memory.makeInMemoryStore = makeInMemoryStore, memory.makeInMemoryCache = makeInMemoryCache, memory.makeInMemoryMemory = makeInMemoryMemory, memory.addValue = addValue;
|
|
10
|
+
const config_1 = requireConfig(), debug_1 = requireDebug(), encode_1 = requireEncode(), number_1 = requireNumber();
|
|
11
|
+
function memToValues(mem) {
|
|
12
|
+
return mem.store.toArray();
|
|
13
|
+
}
|
|
14
|
+
function makeInMemoryStore() {
|
|
15
|
+
const mem = [];
|
|
16
|
+
return {
|
|
17
|
+
forEach(cb) {
|
|
18
|
+
for (let i = 0; i < mem.length; i++)
|
|
19
|
+
if (cb(mem[i]) === "break")
|
|
20
|
+
return;
|
|
21
|
+
},
|
|
22
|
+
add(value) {
|
|
23
|
+
mem.push(value);
|
|
24
|
+
},
|
|
25
|
+
toArray() {
|
|
26
|
+
return mem;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function makeInMemoryCache() {
|
|
31
|
+
const valueMem = /* @__PURE__ */ Object.create(null), schemaMem = /* @__PURE__ */ Object.create(null);
|
|
32
|
+
return {
|
|
33
|
+
getValue(key) {
|
|
34
|
+
return valueMem[key];
|
|
35
|
+
},
|
|
36
|
+
getSchema(key) {
|
|
37
|
+
return schemaMem[key];
|
|
38
|
+
},
|
|
39
|
+
forEachValue(cb) {
|
|
40
|
+
for (const [key, value] of Object.entries(valueMem))
|
|
41
|
+
if (cb(key, value) === "break")
|
|
42
|
+
return;
|
|
43
|
+
},
|
|
44
|
+
forEachSchema(cb) {
|
|
45
|
+
for (const [key, value] of Object.entries(schemaMem))
|
|
46
|
+
if (cb(key, value) === "break")
|
|
47
|
+
return;
|
|
48
|
+
},
|
|
49
|
+
setValue(key, value) {
|
|
50
|
+
valueMem[key] = value;
|
|
51
|
+
},
|
|
52
|
+
setSchema(key, value) {
|
|
53
|
+
schemaMem[key] = value;
|
|
54
|
+
},
|
|
55
|
+
hasValue(key) {
|
|
56
|
+
return key in valueMem;
|
|
57
|
+
},
|
|
58
|
+
hasSchema(key) {
|
|
59
|
+
return key in schemaMem;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function makeInMemoryMemory() {
|
|
64
|
+
return {
|
|
65
|
+
store: makeInMemoryStore(),
|
|
66
|
+
cache: makeInMemoryCache(),
|
|
67
|
+
keyCount: 0
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function getValueKey(mem, value) {
|
|
71
|
+
if (mem.cache.hasValue(value))
|
|
72
|
+
return mem.cache.getValue(value);
|
|
73
|
+
const id = mem.keyCount++, key = (0, number_1.num_to_s)(id);
|
|
74
|
+
return mem.store.add(value), mem.cache.setValue(value, key), key;
|
|
75
|
+
}
|
|
76
|
+
function getSchema(mem, keys) {
|
|
77
|
+
config_1.config.sort_key && keys.sort();
|
|
78
|
+
const schema = keys.join(",");
|
|
79
|
+
if (mem.cache.hasSchema(schema))
|
|
80
|
+
return mem.cache.getSchema(schema);
|
|
81
|
+
const key_id = addValue(mem, keys, void 0);
|
|
82
|
+
return mem.cache.setSchema(schema, key_id), key_id;
|
|
83
|
+
}
|
|
84
|
+
function addValue(mem, o, parent) {
|
|
85
|
+
if (o === null)
|
|
86
|
+
return "";
|
|
87
|
+
switch (typeof o) {
|
|
88
|
+
case "undefined":
|
|
89
|
+
if (Array.isArray(parent))
|
|
90
|
+
return addValue(mem, null, parent);
|
|
91
|
+
break;
|
|
92
|
+
case "object":
|
|
93
|
+
if (o === null)
|
|
94
|
+
return getValueKey(mem, null);
|
|
95
|
+
if (Array.isArray(o)) {
|
|
96
|
+
let acc = "a";
|
|
97
|
+
for (let i = 0; i < o.length; i++) {
|
|
98
|
+
const v = o[i], key = v === null ? "_" : addValue(mem, v, o);
|
|
99
|
+
acc += "|" + key;
|
|
100
|
+
}
|
|
101
|
+
return acc === "a" && (acc = "a|"), getValueKey(mem, acc);
|
|
102
|
+
} else {
|
|
103
|
+
const keys = Object.keys(o);
|
|
104
|
+
if (keys.length === 0)
|
|
105
|
+
return getValueKey(mem, "o|");
|
|
106
|
+
let acc = "o";
|
|
107
|
+
const key_id = getSchema(mem, keys);
|
|
108
|
+
acc += "|" + key_id;
|
|
109
|
+
for (const key of keys) {
|
|
110
|
+
const value = o[key], v = addValue(mem, value, o);
|
|
111
|
+
acc += "|" + v;
|
|
112
|
+
}
|
|
113
|
+
return getValueKey(mem, acc);
|
|
114
|
+
}
|
|
115
|
+
case "boolean":
|
|
116
|
+
return getValueKey(mem, (0, encode_1.encodeBool)(o));
|
|
117
|
+
case "number":
|
|
118
|
+
return Number.isNaN(o) ? config_1.config.preserve_nan ? getValueKey(mem, "N|0") : (config_1.config.error_on_nan && (0, debug_1.throwUnsupportedData)("[number NaN]"), "") : Number.POSITIVE_INFINITY === o ? config_1.config.preserve_infinite ? getValueKey(mem, "N|+") : (config_1.config.error_on_infinite && (0, debug_1.throwUnsupportedData)("[number Infinity]"), "") : Number.NEGATIVE_INFINITY === o ? config_1.config.preserve_infinite ? getValueKey(mem, "N|-") : (config_1.config.error_on_infinite && (0, debug_1.throwUnsupportedData)("[number -Infinity]"), "") : getValueKey(mem, (0, encode_1.encodeNum)(o));
|
|
119
|
+
case "string":
|
|
120
|
+
return getValueKey(mem, (0, encode_1.encodeStr)(o));
|
|
121
|
+
}
|
|
122
|
+
return (0, debug_1.throwUnknownDataType)(o);
|
|
123
|
+
}
|
|
124
|
+
return memory;
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
requireMemory as __require
|
|
128
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { __exports as number } from "../../../_virtual/number.js";
|
|
2
|
+
var hasRequiredNumber;
|
|
3
|
+
function requireNumber() {
|
|
4
|
+
if (hasRequiredNumber) return number;
|
|
5
|
+
hasRequiredNumber = 1, Object.defineProperty(number, "__esModule", { value: !0 }), number.s_to_int = s_to_int, number.s_to_big_int = s_to_big_int, number.int_to_s = int_to_s, number.big_int_to_s = big_int_to_s, number.num_to_s = num_to_s, number.int_str_to_s = int_str_to_s, number.s_to_num = s_to_num;
|
|
6
|
+
let i_to_s = "";
|
|
7
|
+
for (let i = 0; i < 10; i++) {
|
|
8
|
+
const c = String.fromCharCode(48 + i);
|
|
9
|
+
i_to_s += c;
|
|
10
|
+
}
|
|
11
|
+
for (let i = 0; i < 26; i++) {
|
|
12
|
+
const c = String.fromCharCode(65 + i);
|
|
13
|
+
i_to_s += c;
|
|
14
|
+
}
|
|
15
|
+
for (let i = 0; i < 26; i++) {
|
|
16
|
+
const c = String.fromCharCode(97 + i);
|
|
17
|
+
i_to_s += c;
|
|
18
|
+
}
|
|
19
|
+
const N = i_to_s.length, s_to_i = {};
|
|
20
|
+
for (let i = 0; i < N; i++) {
|
|
21
|
+
const s = i_to_s[i];
|
|
22
|
+
s_to_i[s] = i;
|
|
23
|
+
}
|
|
24
|
+
function s_to_int(s) {
|
|
25
|
+
let acc = 0, pow = 1;
|
|
26
|
+
for (let i = s.length - 1; i >= 0; i--) {
|
|
27
|
+
const c = s[i];
|
|
28
|
+
let x = s_to_i[c];
|
|
29
|
+
x *= pow, acc += x, pow *= N;
|
|
30
|
+
}
|
|
31
|
+
return acc;
|
|
32
|
+
}
|
|
33
|
+
function s_to_big_int(s) {
|
|
34
|
+
let acc = BigInt(0), pow = BigInt(1);
|
|
35
|
+
const n = BigInt(N);
|
|
36
|
+
for (let i = s.length - 1; i >= 0; i--) {
|
|
37
|
+
const c = s[i];
|
|
38
|
+
let x = BigInt(s_to_i[c]);
|
|
39
|
+
x *= pow, acc += x, pow *= n;
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}
|
|
43
|
+
function int_to_s(int) {
|
|
44
|
+
if (int === 0)
|
|
45
|
+
return i_to_s[0];
|
|
46
|
+
const acc = [];
|
|
47
|
+
for (; int !== 0; ) {
|
|
48
|
+
const i = int % N, c = i_to_s[i];
|
|
49
|
+
acc.push(c), int -= i, int /= N;
|
|
50
|
+
}
|
|
51
|
+
return acc.reverse().join("");
|
|
52
|
+
}
|
|
53
|
+
function big_int_to_s(int) {
|
|
54
|
+
const zero = BigInt(0), n = BigInt(N);
|
|
55
|
+
if (int === zero)
|
|
56
|
+
return i_to_s[0];
|
|
57
|
+
const acc = [];
|
|
58
|
+
for (; int !== zero; ) {
|
|
59
|
+
const i = int % n, c = i_to_s[Number(i)];
|
|
60
|
+
acc.push(c), int /= n;
|
|
61
|
+
}
|
|
62
|
+
return acc.reverse().join("");
|
|
63
|
+
}
|
|
64
|
+
function reverse(s) {
|
|
65
|
+
return s.split("").reverse().join("");
|
|
66
|
+
}
|
|
67
|
+
function num_to_s(num) {
|
|
68
|
+
if (num < 0)
|
|
69
|
+
return "-" + num_to_s(-num);
|
|
70
|
+
let [a, b] = num.toString().split(".");
|
|
71
|
+
if (!b)
|
|
72
|
+
if (a.includes("e")) {
|
|
73
|
+
const [a1, a2] = a.split("e");
|
|
74
|
+
a = a1, b = "0e" + a2;
|
|
75
|
+
} else
|
|
76
|
+
return int_to_s(num);
|
|
77
|
+
let c;
|
|
78
|
+
b && ([b, c] = b.split("e")), a = int_str_to_s(a), b = reverse(b), b = int_str_to_s(b);
|
|
79
|
+
let str = a + "." + b;
|
|
80
|
+
if (c) {
|
|
81
|
+
switch (str += ".", c[0]) {
|
|
82
|
+
case "+":
|
|
83
|
+
c = c.slice(1);
|
|
84
|
+
break;
|
|
85
|
+
case "-":
|
|
86
|
+
str += "-", c = c.slice(1);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
c = int_str_to_s(c), str += c;
|
|
90
|
+
}
|
|
91
|
+
return str;
|
|
92
|
+
}
|
|
93
|
+
function int_str_to_s(int_str) {
|
|
94
|
+
const num = +int_str;
|
|
95
|
+
return num.toString() === int_str && num + 1 !== num && num - 1 !== num ? int_to_s(num) : ":" + big_int_to_s(BigInt(int_str));
|
|
96
|
+
}
|
|
97
|
+
function s_to_int_str(s) {
|
|
98
|
+
return s[0] === ":" ? s_to_big_int(s.substring(1)).toString() : s_to_int(s).toString();
|
|
99
|
+
}
|
|
100
|
+
function s_to_num(s) {
|
|
101
|
+
if (s[0] === "-")
|
|
102
|
+
return -s_to_num(s.substr(1));
|
|
103
|
+
let [a, b, c] = s.split(".");
|
|
104
|
+
if (!b)
|
|
105
|
+
return s_to_int(a);
|
|
106
|
+
a = s_to_int_str(a), b = s_to_int_str(b), b = reverse(b);
|
|
107
|
+
let str = a + "." + b;
|
|
108
|
+
if (c) {
|
|
109
|
+
str += "e";
|
|
110
|
+
let neg = !1;
|
|
111
|
+
c[0] === "-" && (neg = !0, c = c.slice(1)), c = s_to_int_str(c), str += neg ? -c : +c;
|
|
112
|
+
}
|
|
113
|
+
return +str;
|
|
114
|
+
}
|
|
115
|
+
return number;
|
|
116
|
+
}
|
|
117
|
+
export {
|
|
118
|
+
requireNumber as __require
|
|
119
|
+
};
|