@kitsuyui/react-binary 0.2.0 → 0.2.2
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 +18 -0
- package/dist/Binary.cjs +1 -65
- package/dist/Binary.cjs.map +1 -1
- package/dist/Binary.d.cts +16 -13
- package/dist/Binary.d.ts +16 -13
- package/dist/Binary.js +1 -6
- package/dist/Binary.js.map +1 -1
- package/dist/Detailed.cjs +1 -131
- package/dist/Detailed.cjs.map +1 -1
- package/dist/Detailed.d.cts +17 -12
- package/dist/Detailed.d.ts +17 -12
- package/dist/Detailed.js +1 -9
- package/dist/Detailed.js.map +1 -1
- package/dist/Simple.cjs +1 -82
- package/dist/Simple.cjs.map +1 -1
- package/dist/Simple.d.cts +13 -8
- package/dist/Simple.d.ts +13 -8
- package/dist/Simple.js +1 -9
- package/dist/Simple.js.map +1 -1
- package/dist/chunk-Bmb41Sf3.cjs +1 -0
- package/dist/index.cjs +1 -151
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -19
- package/package.json +12 -13
- package/LICENSE +0 -21
- package/dist/chunk-76L6HIHJ.js +0 -32
- package/dist/chunk-76L6HIHJ.js.map +0 -1
- package/dist/chunk-EIJS7GKA.js +0 -22
- package/dist/chunk-EIJS7GKA.js.map +0 -1
- package/dist/chunk-KC5B3ZDB.js +0 -71
- package/dist/chunk-KC5B3ZDB.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
This is a React component representing a binary value.
|
|
6
6
|
|
|
7
|
+
## Design role
|
|
8
|
+
|
|
9
|
+
This package provides binary/text visualization primitives.
|
|
10
|
+
`Bits` is the structural primitive, and `SimpleBitString` / `DetailedBitString` are concrete visualizations built on top of it.
|
|
11
|
+
|
|
7
12
|
## Demo
|
|
8
13
|
|
|
9
14
|
Storybook: https://react-playground.docs.kitsuyui.com/storybook/
|
|
@@ -28,6 +33,19 @@ yarn add @kitsuyui/react-binary
|
|
|
28
33
|
pnpm add @kitsuyui/react-binary
|
|
29
34
|
```
|
|
30
35
|
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import {
|
|
40
|
+
Bits,
|
|
41
|
+
DetailedBitString,
|
|
42
|
+
SimpleBitString,
|
|
43
|
+
type BitsProps,
|
|
44
|
+
type DetailedBitStringProps,
|
|
45
|
+
type SimpleBitStringProps,
|
|
46
|
+
} from '@kitsuyui/react-binary'
|
|
47
|
+
```
|
|
48
|
+
|
|
31
49
|
## License
|
|
32
50
|
|
|
33
51
|
MIT
|
package/dist/Binary.cjs
CHANGED
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
|
|
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 __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/Binary.tsx
|
|
31
|
-
var Binary_exports = {};
|
|
32
|
-
__export(Binary_exports, {
|
|
33
|
-
Bits: () => Bits
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(Binary_exports);
|
|
36
|
-
var import_react = __toESM(require("react"), 1);
|
|
37
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
-
var Bits = (props) => {
|
|
39
|
-
const { value, bitElement } = props;
|
|
40
|
-
const bits = (value | 0).toString(2).split("");
|
|
41
|
-
const bitLength = bits.length;
|
|
42
|
-
const length = props.length ?? bitLength;
|
|
43
|
-
const overflowLength = Math.max(0, bitLength - length);
|
|
44
|
-
const zeroPaddingLength = Math.max(0, length - bitLength);
|
|
45
|
-
const representLength = Math.max(length, bitLength);
|
|
46
|
-
const elements = Array.from(Array(representLength)).map((_, index) => {
|
|
47
|
-
const stand = bits[bitLength - representLength + index] === "1";
|
|
48
|
-
const bigEndianBitOrder = index;
|
|
49
|
-
const overflow = bigEndianBitOrder < overflowLength;
|
|
50
|
-
const zeroPadding = bigEndianBitOrder < zeroPaddingLength;
|
|
51
|
-
return import_react.default.createElement(bitElement, {
|
|
52
|
-
key: index,
|
|
53
|
-
stand,
|
|
54
|
-
overflow,
|
|
55
|
-
zeroPadding,
|
|
56
|
-
littleEndianBitOrder: representLength - index - 1,
|
|
57
|
-
bigEndianBitOrder
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: elements });
|
|
61
|
-
};
|
|
62
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
-
0 && (module.exports = {
|
|
64
|
-
Bits
|
|
65
|
-
});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-Bmb41Sf3.cjs`);let t=require(`react`);t=e.t(t);let n=require(`react/jsx-runtime`);const r=e=>{let{value:r,bitElement:i}=e,a=(r|0).toString(2).split(``),o=a.length,s=e.length??o,c=Math.max(0,o-s),l=Math.max(0,s-o),u=Math.max(s,o);return(0,n.jsx)(n.Fragment,{children:Array.from(Array(u)).map((e,n)=>{let r=a[o-u+n]===`1`,s=n,d=s<c,f=s<l;return t.default.createElement(i,{key:n,stand:r,overflow:d,zeroPadding:f,littleEndianBitOrder:u-n-1,bigEndianBitOrder:s})})})};exports.Bits=r;
|
|
66
2
|
//# sourceMappingURL=Binary.cjs.map
|
package/dist/Binary.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Binary.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * BitProps is a type that represents the properties of a bit.\n */\nexport type BitProps = {\n stand: boolean\n}\n\n/**\n * EnhancedBitProps is a type that adds the following properties to BitProps.\n * - overflow: If true, this means that bit is out of range.\n * - zeroPadding: If true, this means that bit is padded with zero.\n */\nexport type EnhancedBitProps = BitProps & {\n overflow?: boolean\n zeroPadding?: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}\n\nexport type BitElement = React.FC<EnhancedBitProps>\n\n/**\n * Bit is a component that displays a bit.\n * This component supports the behavior of zero padding and overflow.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const Bits = (props:
|
|
1
|
+
{"version":3,"file":"Binary.cjs","names":["React"],"sources":["../src/Binary.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * BitProps is a type that represents the properties of a bit.\n */\nexport type BitProps = {\n stand: boolean\n}\n\n/**\n * EnhancedBitProps is a type that adds the following properties to BitProps.\n * - overflow: If true, this means that bit is out of range.\n * - zeroPadding: If true, this means that bit is padded with zero.\n */\nexport type EnhancedBitProps = BitProps & {\n overflow?: boolean\n zeroPadding?: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}\n\nexport type BitElement = React.FC<EnhancedBitProps>\n\nexport type BitsProps = {\n value: number\n bitElement: BitElement\n length?: number | undefined\n}\n\n/**\n * Bit is a component that displays a bit.\n * This component supports the behavior of zero padding and overflow.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const Bits = (props: BitsProps): React.JSX.Element => {\n const { value, bitElement } = props\n const bits = (value | 0).toString(2).split('')\n const bitLength = bits.length\n const length = props.length ?? bitLength\n const overflowLength = Math.max(0, bitLength - length)\n const zeroPaddingLength = Math.max(0, length - bitLength)\n const representLength = Math.max(length, bitLength)\n const elements = Array.from(Array(representLength)).map((_, index) => {\n const stand = bits[bitLength - representLength + index] === '1'\n const bigEndianBitOrder = index\n const overflow = bigEndianBitOrder < overflowLength\n const zeroPadding = bigEndianBitOrder < zeroPaddingLength\n return React.createElement(bitElement, {\n key: index,\n stand,\n overflow,\n zeroPadding,\n littleEndianBitOrder: representLength - index - 1,\n bigEndianBitOrder,\n })\n })\n return <>{elements}</>\n}\n"],"mappings":"8KAmCA,MAAa,EAAQ,GAAwC,CAC3D,GAAM,CAAE,QAAO,cAAe,EACxB,GAAQ,EAAQ,GAAG,SAAS,EAAE,CAAC,MAAM,GAAG,CACxC,EAAY,EAAK,OACjB,EAAS,EAAM,QAAU,EACzB,EAAiB,KAAK,IAAI,EAAG,EAAY,EAAO,CAChD,EAAoB,KAAK,IAAI,EAAG,EAAS,EAAU,CACnD,EAAkB,KAAK,IAAI,EAAQ,EAAU,CAenD,OAAO,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAdU,MAAM,KAAK,MAAM,EAAgB,CAAC,CAAC,KAAK,EAAG,IAAU,CACpE,IAAM,EAAQ,EAAK,EAAY,EAAkB,KAAW,IACtD,EAAoB,EACpB,EAAW,EAAoB,EAC/B,EAAc,EAAoB,EACxC,OAAOA,EAAAA,QAAM,cAAc,EAAY,CACrC,IAAK,EACL,QACA,WACA,cACA,qBAAsB,EAAkB,EAAQ,EAChD,oBACD,CAAC,EACF,CAAA,CACoB"}
|
package/dist/Binary.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
|
+
//#region src/Binary.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* BitProps is a type that represents the properties of a bit.
|
|
5
6
|
*/
|
|
6
7
|
type BitProps = {
|
|
7
|
-
|
|
8
|
+
stand: boolean;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* EnhancedBitProps is a type that adds the following properties to BitProps.
|
|
@@ -12,22 +13,24 @@ type BitProps = {
|
|
|
12
13
|
* - zeroPadding: If true, this means that bit is padded with zero.
|
|
13
14
|
*/
|
|
14
15
|
type EnhancedBitProps = BitProps & {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
overflow?: boolean;
|
|
17
|
+
zeroPadding?: boolean;
|
|
18
|
+
littleEndianBitOrder: number;
|
|
19
|
+
bigEndianBitOrder: number;
|
|
19
20
|
};
|
|
20
21
|
type BitElement = React.FC<EnhancedBitProps>;
|
|
22
|
+
type BitsProps = {
|
|
23
|
+
value: number;
|
|
24
|
+
bitElement: BitElement;
|
|
25
|
+
length?: number | undefined;
|
|
26
|
+
};
|
|
21
27
|
/**
|
|
22
28
|
* Bit is a component that displays a bit.
|
|
23
29
|
* This component supports the behavior of zero padding and overflow.
|
|
24
30
|
* @param props
|
|
25
31
|
* @returns A component that displays a bit.
|
|
26
32
|
*/
|
|
27
|
-
declare const Bits: (props:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}) => React.JSX.Element;
|
|
32
|
-
|
|
33
|
-
export { type BitElement, type BitProps, Bits, type EnhancedBitProps };
|
|
33
|
+
declare const Bits: (props: BitsProps) => React.JSX.Element;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { BitElement, BitProps, Bits, BitsProps, EnhancedBitProps };
|
|
36
|
+
//# sourceMappingURL=Binary.d.cts.map
|
package/dist/Binary.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
|
+
//#region src/Binary.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* BitProps is a type that represents the properties of a bit.
|
|
5
6
|
*/
|
|
6
7
|
type BitProps = {
|
|
7
|
-
|
|
8
|
+
stand: boolean;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* EnhancedBitProps is a type that adds the following properties to BitProps.
|
|
@@ -12,22 +13,24 @@ type BitProps = {
|
|
|
12
13
|
* - zeroPadding: If true, this means that bit is padded with zero.
|
|
13
14
|
*/
|
|
14
15
|
type EnhancedBitProps = BitProps & {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
overflow?: boolean;
|
|
17
|
+
zeroPadding?: boolean;
|
|
18
|
+
littleEndianBitOrder: number;
|
|
19
|
+
bigEndianBitOrder: number;
|
|
19
20
|
};
|
|
20
21
|
type BitElement = React.FC<EnhancedBitProps>;
|
|
22
|
+
type BitsProps = {
|
|
23
|
+
value: number;
|
|
24
|
+
bitElement: BitElement;
|
|
25
|
+
length?: number | undefined;
|
|
26
|
+
};
|
|
21
27
|
/**
|
|
22
28
|
* Bit is a component that displays a bit.
|
|
23
29
|
* This component supports the behavior of zero padding and overflow.
|
|
24
30
|
* @param props
|
|
25
31
|
* @returns A component that displays a bit.
|
|
26
32
|
*/
|
|
27
|
-
declare const Bits: (props:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}) => React.JSX.Element;
|
|
32
|
-
|
|
33
|
-
export { type BitElement, type BitProps, Bits, type EnhancedBitProps };
|
|
33
|
+
declare const Bits: (props: BitsProps) => React.JSX.Element;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { BitElement, BitProps, Bits, BitsProps, EnhancedBitProps };
|
|
36
|
+
//# sourceMappingURL=Binary.d.ts.map
|
package/dist/Binary.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Bits
|
|
3
|
-
} from "./chunk-76L6HIHJ.js";
|
|
4
|
-
export {
|
|
5
|
-
Bits
|
|
6
|
-
};
|
|
1
|
+
import e from"react";import{Fragment as t,jsx as n}from"react/jsx-runtime";const r=r=>{let{value:i,bitElement:a}=r,o=(i|0).toString(2).split(``),s=o.length,c=r.length??s,l=Math.max(0,s-c),u=Math.max(0,c-s),d=Math.max(c,s);return n(t,{children:Array.from(Array(d)).map((t,n)=>{let r=o[s-d+n]===`1`,i=n,c=i<l,f=i<u;return e.createElement(a,{key:n,stand:r,overflow:c,zeroPadding:f,littleEndianBitOrder:d-n-1,bigEndianBitOrder:i})})})};export{r as Bits};
|
|
7
2
|
//# sourceMappingURL=Binary.js.map
|
package/dist/Binary.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Binary.js","names":[],"sources":["../src/Binary.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * BitProps is a type that represents the properties of a bit.\n */\nexport type BitProps = {\n stand: boolean\n}\n\n/**\n * EnhancedBitProps is a type that adds the following properties to BitProps.\n * - overflow: If true, this means that bit is out of range.\n * - zeroPadding: If true, this means that bit is padded with zero.\n */\nexport type EnhancedBitProps = BitProps & {\n overflow?: boolean\n zeroPadding?: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}\n\nexport type BitElement = React.FC<EnhancedBitProps>\n\nexport type BitsProps = {\n value: number\n bitElement: BitElement\n length?: number | undefined\n}\n\n/**\n * Bit is a component that displays a bit.\n * This component supports the behavior of zero padding and overflow.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const Bits = (props: BitsProps): React.JSX.Element => {\n const { value, bitElement } = props\n const bits = (value | 0).toString(2).split('')\n const bitLength = bits.length\n const length = props.length ?? bitLength\n const overflowLength = Math.max(0, bitLength - length)\n const zeroPaddingLength = Math.max(0, length - bitLength)\n const representLength = Math.max(length, bitLength)\n const elements = Array.from(Array(representLength)).map((_, index) => {\n const stand = bits[bitLength - representLength + index] === '1'\n const bigEndianBitOrder = index\n const overflow = bigEndianBitOrder < overflowLength\n const zeroPadding = bigEndianBitOrder < zeroPaddingLength\n return React.createElement(bitElement, {\n key: index,\n stand,\n overflow,\n zeroPadding,\n littleEndianBitOrder: representLength - index - 1,\n bigEndianBitOrder,\n })\n })\n return <>{elements}</>\n}\n"],"mappings":"2EAmCA,MAAa,EAAQ,GAAwC,CAC3D,GAAM,CAAE,QAAO,cAAe,EACxB,GAAQ,EAAQ,GAAG,SAAS,EAAE,CAAC,MAAM,GAAG,CACxC,EAAY,EAAK,OACjB,EAAS,EAAM,QAAU,EACzB,EAAiB,KAAK,IAAI,EAAG,EAAY,EAAO,CAChD,EAAoB,KAAK,IAAI,EAAG,EAAS,EAAU,CACnD,EAAkB,KAAK,IAAI,EAAQ,EAAU,CAenD,OAAO,EAAA,EAAA,CAAA,SAdU,MAAM,KAAK,MAAM,EAAgB,CAAC,CAAC,KAAK,EAAG,IAAU,CACpE,IAAM,EAAQ,EAAK,EAAY,EAAkB,KAAW,IACtD,EAAoB,EACpB,EAAW,EAAoB,EAC/B,EAAc,EAAoB,EACxC,OAAO,EAAM,cAAc,EAAY,CACrC,IAAK,EACL,QACA,WACA,cACA,qBAAsB,EAAkB,EAAQ,EAChD,oBACD,CAAC,EACF,CAAA,CACoB"}
|
package/dist/Detailed.cjs
CHANGED
|
@@ -1,132 +1,2 @@
|
|
|
1
|
-
|
|
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 __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/Detailed.tsx
|
|
31
|
-
var Detailed_exports = {};
|
|
32
|
-
__export(Detailed_exports, {
|
|
33
|
-
DetailedBit: () => DetailedBit,
|
|
34
|
-
DetailedBitString: () => DetailedBitString
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(Detailed_exports);
|
|
37
|
-
|
|
38
|
-
// src/Binary.tsx
|
|
39
|
-
var import_react = __toESM(require("react"), 1);
|
|
40
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
-
var Bits = (props) => {
|
|
42
|
-
const { value, bitElement } = props;
|
|
43
|
-
const bits = (value | 0).toString(2).split("");
|
|
44
|
-
const bitLength = bits.length;
|
|
45
|
-
const length = props.length ?? bitLength;
|
|
46
|
-
const overflowLength = Math.max(0, bitLength - length);
|
|
47
|
-
const zeroPaddingLength = Math.max(0, length - bitLength);
|
|
48
|
-
const representLength = Math.max(length, bitLength);
|
|
49
|
-
const elements = Array.from(Array(representLength)).map((_, index) => {
|
|
50
|
-
const stand = bits[bitLength - representLength + index] === "1";
|
|
51
|
-
const bigEndianBitOrder = index;
|
|
52
|
-
const overflow = bigEndianBitOrder < overflowLength;
|
|
53
|
-
const zeroPadding = bigEndianBitOrder < zeroPaddingLength;
|
|
54
|
-
return import_react.default.createElement(bitElement, {
|
|
55
|
-
key: index,
|
|
56
|
-
stand,
|
|
57
|
-
overflow,
|
|
58
|
-
zeroPadding,
|
|
59
|
-
littleEndianBitOrder: representLength - index - 1,
|
|
60
|
-
bigEndianBitOrder
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: elements });
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// src/Detailed.tsx
|
|
67
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
68
|
-
var DetailedBit = (props) => {
|
|
69
|
-
const { stand, overflow, zeroPadding } = props;
|
|
70
|
-
const displayLittleEndianBitOrder = props.displayLittleEndianBitOrder ?? false;
|
|
71
|
-
const displayBigEndianBitOrder = props.displayBigEndianBitOrder ?? false;
|
|
72
|
-
const text = stand ? "1" : "0";
|
|
73
|
-
const border = overflow ? "1px dotted red" : zeroPadding ? "1px dotted gray" : "1px solid #cccccc";
|
|
74
|
-
const margin = "0.5px";
|
|
75
|
-
const color = stand ? "#999999" : "#cccccc";
|
|
76
|
-
const backgroundColor = stand ? "#000000" : "#ffffff";
|
|
77
|
-
const fontFamily = "monospace";
|
|
78
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "inline-block", fontFamily, margin }, children: [
|
|
79
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
80
|
-
"div",
|
|
81
|
-
{
|
|
82
|
-
style: {
|
|
83
|
-
color,
|
|
84
|
-
backgroundColor,
|
|
85
|
-
border
|
|
86
|
-
},
|
|
87
|
-
children: text
|
|
88
|
-
}
|
|
89
|
-
),
|
|
90
|
-
displayLittleEndianBitOrder && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IndexLabel, { index: props.littleEndianBitOrder }),
|
|
91
|
-
displayBigEndianBitOrder && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IndexLabel, { index: props.bigEndianBitOrder })
|
|
92
|
-
] });
|
|
93
|
-
};
|
|
94
|
-
var IndexLabel = (props) => {
|
|
95
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
96
|
-
"div",
|
|
97
|
-
{
|
|
98
|
-
style: {
|
|
99
|
-
userSelect: "none",
|
|
100
|
-
fontSize: "0.5em",
|
|
101
|
-
textAlign: "center",
|
|
102
|
-
lineHeight: "1em"
|
|
103
|
-
},
|
|
104
|
-
children: props.index
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
var DetailedBitString = (props) => {
|
|
109
|
-
const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false;
|
|
110
|
-
const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false;
|
|
111
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
112
|
-
Bits,
|
|
113
|
-
{
|
|
114
|
-
value: props.value,
|
|
115
|
-
length: props.length,
|
|
116
|
-
bitElement: (props2) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
117
|
-
DetailedBit,
|
|
118
|
-
{
|
|
119
|
-
...props2,
|
|
120
|
-
displayLittleEndianBitOrder: showLittleEndianBitOrder,
|
|
121
|
-
displayBigEndianBitOrder: showBigEndianBitOrder
|
|
122
|
-
}
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
-
0 && (module.exports = {
|
|
129
|
-
DetailedBit,
|
|
130
|
-
DetailedBitString
|
|
131
|
-
});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./Binary.cjs`);let t=require(`react/jsx-runtime`);const n=e=>{let{border:n,color:a,backgroundColor:s,text:c}=r(e.stand,e.overflow,e.zeroPadding),{displayLittleEndianBitOrder:l,displayBigEndianBitOrder:u}=i(e);return(0,t.jsxs)(`div`,{style:{display:`inline-block`,fontFamily:`monospace`,margin:`0.5px`},children:[(0,t.jsx)(`div`,{style:{color:a,backgroundColor:s,border:n},children:c}),(0,t.jsx)(o,{displayLittleEndianBitOrder:l,displayBigEndianBitOrder:u,littleEndianBitOrder:e.littleEndianBitOrder,bigEndianBitOrder:e.bigEndianBitOrder})]})},r=(e,t,n)=>({text:e?`1`:`0`,border:a(t,n),color:e?`#999999`:`#cccccc`,backgroundColor:e?`#000000`:`#ffffff`}),i=e=>({displayLittleEndianBitOrder:e.showLittleEndianBitOrder??e.displayLittleEndianBitOrder??!1,displayBigEndianBitOrder:e.showBigEndianBitOrder??e.displayBigEndianBitOrder??!1}),a=(e,t)=>e?`1px dotted red`:t?`1px dotted gray`:`1px solid #cccccc`,o=e=>{let{displayLittleEndianBitOrder:n,displayBigEndianBitOrder:r,littleEndianBitOrder:i,bigEndianBitOrder:a}=e;return(0,t.jsxs)(t.Fragment,{children:[n?(0,t.jsx)(s,{index:i}):null,r?(0,t.jsx)(s,{index:a}):null]})},s=e=>(0,t.jsx)(`div`,{style:{userSelect:`none`,fontSize:`0.5em`,textAlign:`center`,lineHeight:`1em`},children:e.index}),c=r=>{let i=r.showLittleEndianBitOrder??!1,a=r.showBigEndianBitOrder??!1;return(0,t.jsx)(e.Bits,{value:r.value,length:r.length,bitElement:e=>(0,t.jsx)(n,{...e,showLittleEndianBitOrder:i,showBigEndianBitOrder:a})})};exports.DetailedBit=n,exports.DetailedBitString=c;
|
|
132
2
|
//# sourceMappingURL=Detailed.cjs.map
|
package/dist/Detailed.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Detailed.cjs","names":["Bits"],"sources":["../src/Detailed.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type DetailedBitProps = EnhancedBitProps & {\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n displayLittleEndianBitOrder?: boolean | undefined\n displayBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBit = (props: DetailedBitProps): React.JSX.Element => {\n const { border, color, backgroundColor, text } = getDetailedBitPalette(\n props.stand,\n props.overflow,\n props.zeroPadding\n )\n const { displayLittleEndianBitOrder, displayBigEndianBitOrder } =\n getDetailedBitDisplayOptions(props)\n const margin = '0.5px'\n const fontFamily = 'monospace'\n return (\n <div style={{ display: 'inline-block', fontFamily, margin }}>\n <div\n style={{\n color,\n backgroundColor,\n border,\n }}\n >\n {text}\n </div>\n <DetailedBitLabels\n displayLittleEndianBitOrder={displayLittleEndianBitOrder}\n displayBigEndianBitOrder={displayBigEndianBitOrder}\n littleEndianBitOrder={props.littleEndianBitOrder}\n bigEndianBitOrder={props.bigEndianBitOrder}\n />\n </div>\n )\n}\n\nconst getDetailedBitPalette = (\n stand: boolean,\n overflow: boolean | undefined,\n zeroPadding: boolean | undefined\n) => {\n return {\n text: stand ? '1' : '0',\n border: getDetailedBitBorder(overflow, zeroPadding),\n color: stand ? '#999999' : '#cccccc',\n backgroundColor: stand ? '#000000' : '#ffffff',\n }\n}\n\nconst getDetailedBitDisplayOptions = (props: DetailedBitProps) => {\n return {\n displayLittleEndianBitOrder:\n props.showLittleEndianBitOrder ?? props.displayLittleEndianBitOrder ?? false,\n displayBigEndianBitOrder:\n props.showBigEndianBitOrder ?? props.displayBigEndianBitOrder ?? false,\n }\n}\n\nconst getDetailedBitBorder = (\n overflow: boolean | undefined,\n zeroPadding: boolean | undefined\n) => {\n if (overflow) return '1px dotted red'\n if (zeroPadding) return '1px dotted gray'\n return '1px solid #cccccc'\n}\n\nconst DetailedBitLabels = (props: {\n displayLittleEndianBitOrder: boolean\n displayBigEndianBitOrder: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}) => {\n const {\n displayLittleEndianBitOrder,\n displayBigEndianBitOrder,\n littleEndianBitOrder,\n bigEndianBitOrder,\n } = props\n\n return (\n <>\n {displayLittleEndianBitOrder ? (\n <IndexLabel index={littleEndianBitOrder} />\n ) : null}\n {displayBigEndianBitOrder ? (\n <IndexLabel index={bigEndianBitOrder} />\n ) : null}\n </>\n )\n}\n\nconst IndexLabel = (props: { index: number }): React.JSX.Element => {\n return (\n <div\n style={{\n userSelect: 'none',\n fontSize: '0.5em',\n textAlign: 'center',\n lineHeight: '1em',\n }}\n >\n {props.index}\n </div>\n )\n}\n\nexport type DetailedBitStringProps = {\n value: number\n length?: number\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBitString = (props: DetailedBitStringProps): React.JSX.Element => {\n const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false\n const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false\n return (\n <Bits\n value={props.value}\n length={props.length}\n bitElement={(props) => (\n <DetailedBit\n {...props}\n showLittleEndianBitOrder={showLittleEndianBitOrder}\n showBigEndianBitOrder={showBigEndianBitOrder}\n />\n )}\n />\n )\n}\n"],"mappings":"sKAUA,MAAa,EAAe,GAA+C,CACzE,GAAM,CAAE,SAAQ,QAAO,kBAAiB,QAAS,EAC/C,EAAM,MACN,EAAM,SACN,EAAM,YACP,CACK,CAAE,8BAA6B,4BACnC,EAA6B,EAAM,CAGrC,OACE,EAAA,EAAA,MAAC,MAAA,CAAI,MAAO,CAAE,QAAS,eAAgB,WAFtB,YAEkC,OAHtC,QAG8C,YACzD,EAAA,EAAA,KAAC,MAAA,CACC,MAAO,CACL,QACA,kBACA,SACD,UAEA,GACG,EACN,EAAA,EAAA,KAAC,EAAA,CAC8B,8BACH,2BAC1B,qBAAsB,EAAM,qBAC5B,kBAAmB,EAAM,mBACzB,CAAA,EACE,EAIJ,GACJ,EACA,EACA,KAEO,CACL,KAAM,EAAQ,IAAM,IACpB,OAAQ,EAAqB,EAAU,EAAY,CACnD,MAAO,EAAQ,UAAY,UAC3B,gBAAiB,EAAQ,UAAY,UACtC,EAGG,EAAgC,IAC7B,CACL,4BACE,EAAM,0BAA4B,EAAM,6BAA+B,GACzE,yBACE,EAAM,uBAAyB,EAAM,0BAA4B,GACpE,EAGG,GACJ,EACA,IAEI,EAAiB,iBACjB,EAAoB,kBACjB,oBAGH,EAAqB,GAKrB,CACJ,GAAM,CACJ,8BACA,2BACA,uBACA,qBACE,EAEJ,OACE,EAAA,EAAA,MAAA,EAAA,SAAA,CAAA,SAAA,CACG,GACC,EAAA,EAAA,KAAC,EAAA,CAAW,MAAO,EAAA,CAAwB,CACzC,KACH,GACC,EAAA,EAAA,KAAC,EAAA,CAAW,MAAO,EAAA,CAAqB,CACtC,KAAA,CAAA,CACH,EAID,EAAc,IAEhB,EAAA,EAAA,KAAC,MAAA,CACC,MAAO,CACL,WAAY,OACZ,SAAU,QACV,UAAW,SACX,WAAY,MACb,UAEA,EAAM,OACH,CAWG,EAAqB,GAAqD,CACrF,IAAM,EAA2B,EAAM,0BAA4B,GAC7D,EAAwB,EAAM,uBAAyB,GAC7D,OACE,EAAA,EAAA,KAACA,EAAAA,KAAAA,CACC,MAAO,EAAM,MACb,OAAQ,EAAM,OACd,WAAa,IACX,EAAA,EAAA,KAAC,EAAA,CACC,GAAI,EACsB,2BACH,yBACvB,EAEJ"}
|
package/dist/Detailed.d.cts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { EnhancedBitProps } from "./Binary.cjs";
|
|
2
|
+
import React from "react";
|
|
3
3
|
|
|
4
|
+
//#region src/Detailed.d.ts
|
|
4
5
|
type DetailedBitProps = EnhancedBitProps & {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
showLittleEndianBitOrder?: boolean | undefined;
|
|
7
|
+
showBigEndianBitOrder?: boolean | undefined;
|
|
8
|
+
displayLittleEndianBitOrder?: boolean | undefined;
|
|
9
|
+
displayBigEndianBitOrder?: boolean | undefined;
|
|
7
10
|
};
|
|
8
11
|
declare const DetailedBit: (props: DetailedBitProps) => React.JSX.Element;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
type DetailedBitStringProps = {
|
|
13
|
+
value: number;
|
|
14
|
+
length?: number;
|
|
15
|
+
showLittleEndianBitOrder?: boolean | undefined;
|
|
16
|
+
showBigEndianBitOrder?: boolean | undefined;
|
|
17
|
+
};
|
|
18
|
+
declare const DetailedBitString: (props: DetailedBitStringProps) => React.JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps };
|
|
21
|
+
//# sourceMappingURL=Detailed.d.cts.map
|
package/dist/Detailed.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { EnhancedBitProps } from "./Binary.js";
|
|
2
|
+
import React from "react";
|
|
3
3
|
|
|
4
|
+
//#region src/Detailed.d.ts
|
|
4
5
|
type DetailedBitProps = EnhancedBitProps & {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
showLittleEndianBitOrder?: boolean | undefined;
|
|
7
|
+
showBigEndianBitOrder?: boolean | undefined;
|
|
8
|
+
displayLittleEndianBitOrder?: boolean | undefined;
|
|
9
|
+
displayBigEndianBitOrder?: boolean | undefined;
|
|
7
10
|
};
|
|
8
11
|
declare const DetailedBit: (props: DetailedBitProps) => React.JSX.Element;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
type DetailedBitStringProps = {
|
|
13
|
+
value: number;
|
|
14
|
+
length?: number;
|
|
15
|
+
showLittleEndianBitOrder?: boolean | undefined;
|
|
16
|
+
showBigEndianBitOrder?: boolean | undefined;
|
|
17
|
+
};
|
|
18
|
+
declare const DetailedBitString: (props: DetailedBitStringProps) => React.JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps };
|
|
21
|
+
//# sourceMappingURL=Detailed.d.ts.map
|
package/dist/Detailed.js
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DetailedBit,
|
|
3
|
-
DetailedBitString
|
|
4
|
-
} from "./chunk-KC5B3ZDB.js";
|
|
5
|
-
import "./chunk-76L6HIHJ.js";
|
|
6
|
-
export {
|
|
7
|
-
DetailedBit,
|
|
8
|
-
DetailedBitString
|
|
9
|
-
};
|
|
1
|
+
import{Bits as e}from"./Binary.js";import{Fragment as t,jsx as n,jsxs as r}from"react/jsx-runtime";const i=e=>{let{border:t,color:i,backgroundColor:s,text:l}=a(e.stand,e.overflow,e.zeroPadding),{displayLittleEndianBitOrder:u,displayBigEndianBitOrder:d}=o(e);return r(`div`,{style:{display:`inline-block`,fontFamily:`monospace`,margin:`0.5px`},children:[n(`div`,{style:{color:i,backgroundColor:s,border:t},children:l}),n(c,{displayLittleEndianBitOrder:u,displayBigEndianBitOrder:d,littleEndianBitOrder:e.littleEndianBitOrder,bigEndianBitOrder:e.bigEndianBitOrder})]})},a=(e,t,n)=>({text:e?`1`:`0`,border:s(t,n),color:e?`#999999`:`#cccccc`,backgroundColor:e?`#000000`:`#ffffff`}),o=e=>({displayLittleEndianBitOrder:e.showLittleEndianBitOrder??e.displayLittleEndianBitOrder??!1,displayBigEndianBitOrder:e.showBigEndianBitOrder??e.displayBigEndianBitOrder??!1}),s=(e,t)=>e?`1px dotted red`:t?`1px dotted gray`:`1px solid #cccccc`,c=e=>{let{displayLittleEndianBitOrder:i,displayBigEndianBitOrder:a,littleEndianBitOrder:o,bigEndianBitOrder:s}=e;return r(t,{children:[i?n(l,{index:o}):null,a?n(l,{index:s}):null]})},l=e=>n(`div`,{style:{userSelect:`none`,fontSize:`0.5em`,textAlign:`center`,lineHeight:`1em`},children:e.index}),u=t=>{let r=t.showLittleEndianBitOrder??!1,a=t.showBigEndianBitOrder??!1;return n(e,{value:t.value,length:t.length,bitElement:e=>n(i,{...e,showLittleEndianBitOrder:r,showBigEndianBitOrder:a})})};export{i as DetailedBit,u as DetailedBitString};
|
|
10
2
|
//# sourceMappingURL=Detailed.js.map
|
package/dist/Detailed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Detailed.js","names":[],"sources":["../src/Detailed.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type DetailedBitProps = EnhancedBitProps & {\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n displayLittleEndianBitOrder?: boolean | undefined\n displayBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBit = (props: DetailedBitProps): React.JSX.Element => {\n const { border, color, backgroundColor, text } = getDetailedBitPalette(\n props.stand,\n props.overflow,\n props.zeroPadding\n )\n const { displayLittleEndianBitOrder, displayBigEndianBitOrder } =\n getDetailedBitDisplayOptions(props)\n const margin = '0.5px'\n const fontFamily = 'monospace'\n return (\n <div style={{ display: 'inline-block', fontFamily, margin }}>\n <div\n style={{\n color,\n backgroundColor,\n border,\n }}\n >\n {text}\n </div>\n <DetailedBitLabels\n displayLittleEndianBitOrder={displayLittleEndianBitOrder}\n displayBigEndianBitOrder={displayBigEndianBitOrder}\n littleEndianBitOrder={props.littleEndianBitOrder}\n bigEndianBitOrder={props.bigEndianBitOrder}\n />\n </div>\n )\n}\n\nconst getDetailedBitPalette = (\n stand: boolean,\n overflow: boolean | undefined,\n zeroPadding: boolean | undefined\n) => {\n return {\n text: stand ? '1' : '0',\n border: getDetailedBitBorder(overflow, zeroPadding),\n color: stand ? '#999999' : '#cccccc',\n backgroundColor: stand ? '#000000' : '#ffffff',\n }\n}\n\nconst getDetailedBitDisplayOptions = (props: DetailedBitProps) => {\n return {\n displayLittleEndianBitOrder:\n props.showLittleEndianBitOrder ?? props.displayLittleEndianBitOrder ?? false,\n displayBigEndianBitOrder:\n props.showBigEndianBitOrder ?? props.displayBigEndianBitOrder ?? false,\n }\n}\n\nconst getDetailedBitBorder = (\n overflow: boolean | undefined,\n zeroPadding: boolean | undefined\n) => {\n if (overflow) return '1px dotted red'\n if (zeroPadding) return '1px dotted gray'\n return '1px solid #cccccc'\n}\n\nconst DetailedBitLabels = (props: {\n displayLittleEndianBitOrder: boolean\n displayBigEndianBitOrder: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}) => {\n const {\n displayLittleEndianBitOrder,\n displayBigEndianBitOrder,\n littleEndianBitOrder,\n bigEndianBitOrder,\n } = props\n\n return (\n <>\n {displayLittleEndianBitOrder ? (\n <IndexLabel index={littleEndianBitOrder} />\n ) : null}\n {displayBigEndianBitOrder ? (\n <IndexLabel index={bigEndianBitOrder} />\n ) : null}\n </>\n )\n}\n\nconst IndexLabel = (props: { index: number }): React.JSX.Element => {\n return (\n <div\n style={{\n userSelect: 'none',\n fontSize: '0.5em',\n textAlign: 'center',\n lineHeight: '1em',\n }}\n >\n {props.index}\n </div>\n )\n}\n\nexport type DetailedBitStringProps = {\n value: number\n length?: number\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBitString = (props: DetailedBitStringProps): React.JSX.Element => {\n const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false\n const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false\n return (\n <Bits\n value={props.value}\n length={props.length}\n bitElement={(props) => (\n <DetailedBit\n {...props}\n showLittleEndianBitOrder={showLittleEndianBitOrder}\n showBigEndianBitOrder={showBigEndianBitOrder}\n />\n )}\n />\n )\n}\n"],"mappings":"mGAUA,MAAa,EAAe,GAA+C,CACzE,GAAM,CAAE,SAAQ,QAAO,kBAAiB,QAAS,EAC/C,EAAM,MACN,EAAM,SACN,EAAM,YACP,CACK,CAAE,8BAA6B,4BACnC,EAA6B,EAAM,CAGrC,OACE,EAAC,MAAA,CAAI,MAAO,CAAE,QAAS,eAAgB,WAFtB,YAEkC,OAHtC,QAG8C,WACzD,EAAC,MAAA,CACC,MAAO,CACL,QACA,kBACA,SACD,UAEA,GACG,CACN,EAAC,EAAA,CAC8B,8BACH,2BAC1B,qBAAsB,EAAM,qBAC5B,kBAAmB,EAAM,mBACzB,CAAA,EACE,EAIJ,GACJ,EACA,EACA,KAEO,CACL,KAAM,EAAQ,IAAM,IACpB,OAAQ,EAAqB,EAAU,EAAY,CACnD,MAAO,EAAQ,UAAY,UAC3B,gBAAiB,EAAQ,UAAY,UACtC,EAGG,EAAgC,IAC7B,CACL,4BACE,EAAM,0BAA4B,EAAM,6BAA+B,GACzE,yBACE,EAAM,uBAAyB,EAAM,0BAA4B,GACpE,EAGG,GACJ,EACA,IAEI,EAAiB,iBACjB,EAAoB,kBACjB,oBAGH,EAAqB,GAKrB,CACJ,GAAM,CACJ,8BACA,2BACA,uBACA,qBACE,EAEJ,OACE,EAAA,EAAA,CAAA,SAAA,CACG,EACC,EAAC,EAAA,CAAW,MAAO,EAAA,CAAwB,CACzC,KACH,EACC,EAAC,EAAA,CAAW,MAAO,EAAA,CAAqB,CACtC,KAAA,CAAA,CACH,EAID,EAAc,GAEhB,EAAC,MAAA,CACC,MAAO,CACL,WAAY,OACZ,SAAU,QACV,UAAW,SACX,WAAY,MACb,UAEA,EAAM,OACH,CAWG,EAAqB,GAAqD,CACrF,IAAM,EAA2B,EAAM,0BAA4B,GAC7D,EAAwB,EAAM,uBAAyB,GAC7D,OACE,EAAC,EAAA,CACC,MAAO,EAAM,MACb,OAAQ,EAAM,OACd,WAAa,GACX,EAAC,EAAA,CACC,GAAI,EACsB,2BACH,yBACvB,EAEJ"}
|
package/dist/Simple.cjs
CHANGED
|
@@ -1,83 +1,2 @@
|
|
|
1
|
-
|
|
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 __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/Simple.tsx
|
|
31
|
-
var Simple_exports = {};
|
|
32
|
-
__export(Simple_exports, {
|
|
33
|
-
Simple8BitString: () => Simple8BitString,
|
|
34
|
-
SimpleBit: () => SimpleBit
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(Simple_exports);
|
|
37
|
-
|
|
38
|
-
// src/Binary.tsx
|
|
39
|
-
var import_react = __toESM(require("react"), 1);
|
|
40
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
-
var Bits = (props) => {
|
|
42
|
-
const { value, bitElement } = props;
|
|
43
|
-
const bits = (value | 0).toString(2).split("");
|
|
44
|
-
const bitLength = bits.length;
|
|
45
|
-
const length = props.length ?? bitLength;
|
|
46
|
-
const overflowLength = Math.max(0, bitLength - length);
|
|
47
|
-
const zeroPaddingLength = Math.max(0, length - bitLength);
|
|
48
|
-
const representLength = Math.max(length, bitLength);
|
|
49
|
-
const elements = Array.from(Array(representLength)).map((_, index) => {
|
|
50
|
-
const stand = bits[bitLength - representLength + index] === "1";
|
|
51
|
-
const bigEndianBitOrder = index;
|
|
52
|
-
const overflow = bigEndianBitOrder < overflowLength;
|
|
53
|
-
const zeroPadding = bigEndianBitOrder < zeroPaddingLength;
|
|
54
|
-
return import_react.default.createElement(bitElement, {
|
|
55
|
-
key: index,
|
|
56
|
-
stand,
|
|
57
|
-
overflow,
|
|
58
|
-
zeroPadding,
|
|
59
|
-
littleEndianBitOrder: representLength - index - 1,
|
|
60
|
-
bigEndianBitOrder
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: elements });
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// src/Simple.tsx
|
|
67
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
68
|
-
var SimpleBit = (props) => {
|
|
69
|
-
const { stand, overflow } = props;
|
|
70
|
-
const baseText = stand ? "1" : "0";
|
|
71
|
-
const isOverflowVisible = overflow ?? false;
|
|
72
|
-
const text = isOverflowVisible ? "" : baseText;
|
|
73
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: text });
|
|
74
|
-
};
|
|
75
|
-
var Simple8BitString = (props) => {
|
|
76
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Bits, { value: props.value, length: 8, bitElement: SimpleBit });
|
|
77
|
-
};
|
|
78
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
-
0 && (module.exports = {
|
|
80
|
-
Simple8BitString,
|
|
81
|
-
SimpleBit
|
|
82
|
-
});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./Binary.cjs`);let t=require(`react/jsx-runtime`);const n=e=>{let{stand:n,overflow:r}=e;return(0,t.jsx)(t.Fragment,{children:r??!1?``:n?`1`:`0`})},r=r=>(0,t.jsx)(e.Bits,{value:r.value,length:r.length??8,bitElement:n});exports.SimpleBit=n,exports.SimpleBitString=r;
|
|
83
2
|
//# sourceMappingURL=Simple.cjs.map
|
package/dist/Simple.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Simple.cjs","names":["Bits"],"sources":["../src/Simple.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type SimpleBitProps = EnhancedBitProps\n\n/**\n * SimpleBit is a simple component that displays a bit.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const SimpleBit = (props: SimpleBitProps): React.JSX.Element => {\n const { stand, overflow } = props\n const baseText = stand ? '1' : '0'\n const isOverflowVisible = overflow ?? false\n const text = isOverflowVisible ? '' : baseText\n return <>{text}</>\n}\n\nexport type SimpleBitStringProps = {\n value: number\n length?: number\n}\n\nexport const SimpleBitString = (props: SimpleBitStringProps): React.JSX.Element => {\n return <Bits value={props.value} length={props.length ?? 8} bitElement={SimpleBit} />\n}\n"],"mappings":"sKAUA,MAAa,EAAa,GAA6C,CACrE,GAAM,CAAE,QAAO,YAAa,EAI5B,OAAO,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAFmB,GAAY,GACL,GAFhB,EAAQ,IAAM,IAAA,CAGb,EAQP,EAAmB,IACvB,EAAA,EAAA,KAACA,EAAAA,KAAAA,CAAK,MAAO,EAAM,MAAO,OAAQ,EAAM,QAAU,EAAG,WAAY,GAAa"}
|
package/dist/Simple.d.cts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { EnhancedBitProps } from "./Binary.cjs";
|
|
2
|
+
import React from "react";
|
|
3
3
|
|
|
4
|
+
//#region src/Simple.d.ts
|
|
5
|
+
type SimpleBitProps = EnhancedBitProps;
|
|
4
6
|
/**
|
|
5
7
|
* SimpleBit is a simple component that displays a bit.
|
|
6
8
|
* @param props
|
|
7
9
|
* @returns A component that displays a bit.
|
|
8
10
|
*/
|
|
9
|
-
declare const SimpleBit: (props:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
declare const SimpleBit: (props: SimpleBitProps) => React.JSX.Element;
|
|
12
|
+
type SimpleBitStringProps = {
|
|
13
|
+
value: number;
|
|
14
|
+
length?: number;
|
|
15
|
+
};
|
|
16
|
+
declare const SimpleBitString: (props: SimpleBitStringProps) => React.JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps };
|
|
19
|
+
//# sourceMappingURL=Simple.d.cts.map
|
package/dist/Simple.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { EnhancedBitProps } from "./Binary.js";
|
|
2
|
+
import React from "react";
|
|
3
3
|
|
|
4
|
+
//#region src/Simple.d.ts
|
|
5
|
+
type SimpleBitProps = EnhancedBitProps;
|
|
4
6
|
/**
|
|
5
7
|
* SimpleBit is a simple component that displays a bit.
|
|
6
8
|
* @param props
|
|
7
9
|
* @returns A component that displays a bit.
|
|
8
10
|
*/
|
|
9
|
-
declare const SimpleBit: (props:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
declare const SimpleBit: (props: SimpleBitProps) => React.JSX.Element;
|
|
12
|
+
type SimpleBitStringProps = {
|
|
13
|
+
value: number;
|
|
14
|
+
length?: number;
|
|
15
|
+
};
|
|
16
|
+
declare const SimpleBitString: (props: SimpleBitStringProps) => React.JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps };
|
|
19
|
+
//# sourceMappingURL=Simple.d.ts.map
|
package/dist/Simple.js
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Simple8BitString,
|
|
3
|
-
SimpleBit
|
|
4
|
-
} from "./chunk-EIJS7GKA.js";
|
|
5
|
-
import "./chunk-76L6HIHJ.js";
|
|
6
|
-
export {
|
|
7
|
-
Simple8BitString,
|
|
8
|
-
SimpleBit
|
|
9
|
-
};
|
|
1
|
+
import{Bits as e}from"./Binary.js";import{Fragment as t,jsx as n}from"react/jsx-runtime";const r=e=>{let{stand:r,overflow:i}=e;return n(t,{children:i??!1?``:r?`1`:`0`})},i=t=>n(e,{value:t.value,length:t.length??8,bitElement:r});export{r as SimpleBit,i as SimpleBitString};
|
|
10
2
|
//# sourceMappingURL=Simple.js.map
|
package/dist/Simple.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Simple.js","names":[],"sources":["../src/Simple.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type SimpleBitProps = EnhancedBitProps\n\n/**\n * SimpleBit is a simple component that displays a bit.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const SimpleBit = (props: SimpleBitProps): React.JSX.Element => {\n const { stand, overflow } = props\n const baseText = stand ? '1' : '0'\n const isOverflowVisible = overflow ?? false\n const text = isOverflowVisible ? '' : baseText\n return <>{text}</>\n}\n\nexport type SimpleBitStringProps = {\n value: number\n length?: number\n}\n\nexport const SimpleBitString = (props: SimpleBitStringProps): React.JSX.Element => {\n return <Bits value={props.value} length={props.length ?? 8} bitElement={SimpleBit} />\n}\n"],"mappings":"yFAUA,MAAa,EAAa,GAA6C,CACrE,GAAM,CAAE,QAAO,YAAa,EAI5B,OAAO,EAAA,EAAA,CAAA,SAFmB,GAAY,GACL,GAFhB,EAAQ,IAAM,IAAA,CAGb,EAQP,EAAmB,GACvB,EAAC,EAAA,CAAK,MAAO,EAAM,MAAO,OAAQ,EAAM,QAAU,EAAG,WAAY,GAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
|
package/dist/index.cjs
CHANGED
|
@@ -1,151 +1 @@
|
|
|
1
|
-
|
|
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 __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
Bits: () => Bits,
|
|
34
|
-
DetailedBit: () => DetailedBit,
|
|
35
|
-
DetailedBitString: () => DetailedBitString,
|
|
36
|
-
Simple8BitString: () => Simple8BitString,
|
|
37
|
-
SimpleBit: () => SimpleBit
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(index_exports);
|
|
40
|
-
|
|
41
|
-
// src/Binary.tsx
|
|
42
|
-
var import_react = __toESM(require("react"), 1);
|
|
43
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
-
var Bits = (props) => {
|
|
45
|
-
const { value, bitElement } = props;
|
|
46
|
-
const bits = (value | 0).toString(2).split("");
|
|
47
|
-
const bitLength = bits.length;
|
|
48
|
-
const length = props.length ?? bitLength;
|
|
49
|
-
const overflowLength = Math.max(0, bitLength - length);
|
|
50
|
-
const zeroPaddingLength = Math.max(0, length - bitLength);
|
|
51
|
-
const representLength = Math.max(length, bitLength);
|
|
52
|
-
const elements = Array.from(Array(representLength)).map((_, index) => {
|
|
53
|
-
const stand = bits[bitLength - representLength + index] === "1";
|
|
54
|
-
const bigEndianBitOrder = index;
|
|
55
|
-
const overflow = bigEndianBitOrder < overflowLength;
|
|
56
|
-
const zeroPadding = bigEndianBitOrder < zeroPaddingLength;
|
|
57
|
-
return import_react.default.createElement(bitElement, {
|
|
58
|
-
key: index,
|
|
59
|
-
stand,
|
|
60
|
-
overflow,
|
|
61
|
-
zeroPadding,
|
|
62
|
-
littleEndianBitOrder: representLength - index - 1,
|
|
63
|
-
bigEndianBitOrder
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: elements });
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// src/Simple.tsx
|
|
70
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
71
|
-
var SimpleBit = (props) => {
|
|
72
|
-
const { stand, overflow } = props;
|
|
73
|
-
const baseText = stand ? "1" : "0";
|
|
74
|
-
const isOverflowVisible = overflow ?? false;
|
|
75
|
-
const text = isOverflowVisible ? "" : baseText;
|
|
76
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: text });
|
|
77
|
-
};
|
|
78
|
-
var Simple8BitString = (props) => {
|
|
79
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Bits, { value: props.value, length: 8, bitElement: SimpleBit });
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// src/Detailed.tsx
|
|
83
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
84
|
-
var DetailedBit = (props) => {
|
|
85
|
-
const { stand, overflow, zeroPadding } = props;
|
|
86
|
-
const displayLittleEndianBitOrder = props.displayLittleEndianBitOrder ?? false;
|
|
87
|
-
const displayBigEndianBitOrder = props.displayBigEndianBitOrder ?? false;
|
|
88
|
-
const text = stand ? "1" : "0";
|
|
89
|
-
const border = overflow ? "1px dotted red" : zeroPadding ? "1px dotted gray" : "1px solid #cccccc";
|
|
90
|
-
const margin = "0.5px";
|
|
91
|
-
const color = stand ? "#999999" : "#cccccc";
|
|
92
|
-
const backgroundColor = stand ? "#000000" : "#ffffff";
|
|
93
|
-
const fontFamily = "monospace";
|
|
94
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "inline-block", fontFamily, margin }, children: [
|
|
95
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
96
|
-
"div",
|
|
97
|
-
{
|
|
98
|
-
style: {
|
|
99
|
-
color,
|
|
100
|
-
backgroundColor,
|
|
101
|
-
border
|
|
102
|
-
},
|
|
103
|
-
children: text
|
|
104
|
-
}
|
|
105
|
-
),
|
|
106
|
-
displayLittleEndianBitOrder && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IndexLabel, { index: props.littleEndianBitOrder }),
|
|
107
|
-
displayBigEndianBitOrder && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IndexLabel, { index: props.bigEndianBitOrder })
|
|
108
|
-
] });
|
|
109
|
-
};
|
|
110
|
-
var IndexLabel = (props) => {
|
|
111
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
112
|
-
"div",
|
|
113
|
-
{
|
|
114
|
-
style: {
|
|
115
|
-
userSelect: "none",
|
|
116
|
-
fontSize: "0.5em",
|
|
117
|
-
textAlign: "center",
|
|
118
|
-
lineHeight: "1em"
|
|
119
|
-
},
|
|
120
|
-
children: props.index
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
var DetailedBitString = (props) => {
|
|
125
|
-
const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false;
|
|
126
|
-
const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false;
|
|
127
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
128
|
-
Bits,
|
|
129
|
-
{
|
|
130
|
-
value: props.value,
|
|
131
|
-
length: props.length,
|
|
132
|
-
bitElement: (props2) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
133
|
-
DetailedBit,
|
|
134
|
-
{
|
|
135
|
-
...props2,
|
|
136
|
-
displayLittleEndianBitOrder: showLittleEndianBitOrder,
|
|
137
|
-
displayBigEndianBitOrder: showBigEndianBitOrder
|
|
138
|
-
}
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
};
|
|
143
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
-
0 && (module.exports = {
|
|
145
|
-
Bits,
|
|
146
|
-
DetailedBit,
|
|
147
|
-
DetailedBitString,
|
|
148
|
-
Simple8BitString,
|
|
149
|
-
SimpleBit
|
|
150
|
-
});
|
|
151
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./Binary.cjs`),t=require(`./Detailed.cjs`),n=require(`./Simple.cjs`);exports.Bits=e.Bits,exports.DetailedBit=t.DetailedBit,exports.DetailedBitString=t.DetailedBitString,exports.SimpleBit=n.SimpleBit,exports.SimpleBitString=n.SimpleBitString;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { BitElement, BitProps, Bits, BitsProps, EnhancedBitProps } from "./Binary.cjs";
|
|
2
|
+
import { DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps } from "./Detailed.cjs";
|
|
3
|
+
import { SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps } from "./Simple.cjs";
|
|
4
|
+
export { BitElement, BitProps, Bits, BitsProps, DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps, EnhancedBitProps, SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { BitElement, BitProps, Bits, BitsProps, EnhancedBitProps } from "./Binary.js";
|
|
2
|
+
import { DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps } from "./Detailed.js";
|
|
3
|
+
import { SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps } from "./Simple.js";
|
|
4
|
+
export { BitElement, BitProps, Bits, BitsProps, DetailedBit, DetailedBitProps, DetailedBitString, DetailedBitStringProps, EnhancedBitProps, SimpleBit, SimpleBitProps, SimpleBitString, SimpleBitStringProps };
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DetailedBit,
|
|
3
|
-
DetailedBitString
|
|
4
|
-
} from "./chunk-KC5B3ZDB.js";
|
|
5
|
-
import {
|
|
6
|
-
Simple8BitString,
|
|
7
|
-
SimpleBit
|
|
8
|
-
} from "./chunk-EIJS7GKA.js";
|
|
9
|
-
import {
|
|
10
|
-
Bits
|
|
11
|
-
} from "./chunk-76L6HIHJ.js";
|
|
12
|
-
export {
|
|
13
|
-
Bits,
|
|
14
|
-
DetailedBit,
|
|
15
|
-
DetailedBitString,
|
|
16
|
-
Simple8BitString,
|
|
17
|
-
SimpleBit
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{Bits as e}from"./Binary.js";import{DetailedBit as t,DetailedBitString as n}from"./Detailed.js";import{SimpleBit as r,SimpleBitString as i}from"./Simple.js";export{e as Bits,t as DetailedBit,n as DetailedBitString,r as SimpleBit,i as SimpleBitString};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitsuyui/react-binary",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Binary representation of number for React",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,26 +22,25 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"main": "./dist/index.js",
|
|
25
|
-
"module": "./dist/index.js",
|
|
26
25
|
"types": "./dist/index.d.ts",
|
|
27
26
|
"files": [
|
|
28
27
|
"dist",
|
|
29
28
|
"package.json"
|
|
30
29
|
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsdown",
|
|
32
|
+
"dev": "tsdown --no-clean --watch",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"validate": "validate-package-exports --check"
|
|
35
|
+
},
|
|
31
36
|
"devDependencies": {
|
|
32
|
-
"@types/react": "^19.
|
|
33
|
-
"@types/react-dom": "^19.
|
|
34
|
-
"react": "^19.
|
|
35
|
-
"react-dom": "^19.
|
|
37
|
+
"@types/react": "^19.2.14",
|
|
38
|
+
"@types/react-dom": "^19.2.3",
|
|
39
|
+
"react": "^19.2.4",
|
|
40
|
+
"react-dom": "^19.2.4"
|
|
36
41
|
},
|
|
37
42
|
"peerDependencies": {
|
|
38
43
|
"react": "*",
|
|
39
44
|
"react-dom": "*"
|
|
40
|
-
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "tsup --clean",
|
|
43
|
-
"dev": "tsup --watch",
|
|
44
|
-
"test": "vitest run",
|
|
45
|
-
"validate": "validate-package-exports --check --verify"
|
|
46
45
|
}
|
|
47
|
-
}
|
|
46
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Yui KITSU
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/chunk-76L6HIHJ.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// src/Binary.tsx
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
-
var Bits = (props) => {
|
|
5
|
-
const { value, bitElement } = props;
|
|
6
|
-
const bits = (value | 0).toString(2).split("");
|
|
7
|
-
const bitLength = bits.length;
|
|
8
|
-
const length = props.length ?? bitLength;
|
|
9
|
-
const overflowLength = Math.max(0, bitLength - length);
|
|
10
|
-
const zeroPaddingLength = Math.max(0, length - bitLength);
|
|
11
|
-
const representLength = Math.max(length, bitLength);
|
|
12
|
-
const elements = Array.from(Array(representLength)).map((_, index) => {
|
|
13
|
-
const stand = bits[bitLength - representLength + index] === "1";
|
|
14
|
-
const bigEndianBitOrder = index;
|
|
15
|
-
const overflow = bigEndianBitOrder < overflowLength;
|
|
16
|
-
const zeroPadding = bigEndianBitOrder < zeroPaddingLength;
|
|
17
|
-
return React.createElement(bitElement, {
|
|
18
|
-
key: index,
|
|
19
|
-
stand,
|
|
20
|
-
overflow,
|
|
21
|
-
zeroPadding,
|
|
22
|
-
littleEndianBitOrder: representLength - index - 1,
|
|
23
|
-
bigEndianBitOrder
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
return /* @__PURE__ */ jsx(Fragment, { children: elements });
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
Bits
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=chunk-76L6HIHJ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Binary.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * BitProps is a type that represents the properties of a bit.\n */\nexport type BitProps = {\n stand: boolean\n}\n\n/**\n * EnhancedBitProps is a type that adds the following properties to BitProps.\n * - overflow: If true, this means that bit is out of range.\n * - zeroPadding: If true, this means that bit is padded with zero.\n */\nexport type EnhancedBitProps = BitProps & {\n overflow?: boolean\n zeroPadding?: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}\n\nexport type BitElement = React.FC<EnhancedBitProps>\n\n/**\n * Bit is a component that displays a bit.\n * This component supports the behavior of zero padding and overflow.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const Bits = (props: {\n value: number\n bitElement: BitElement\n length?: number | undefined\n}): React.JSX.Element => {\n const { value, bitElement } = props\n const bits = (value | 0).toString(2).split('')\n const bitLength = bits.length\n const length = props.length ?? bitLength\n const overflowLength = Math.max(0, bitLength - length)\n const zeroPaddingLength = Math.max(0, length - bitLength)\n const representLength = Math.max(length, bitLength)\n const elements = Array.from(Array(representLength)).map((_, index) => {\n const stand = bits[bitLength - representLength + index] === '1'\n const bigEndianBitOrder = index\n const overflow = bigEndianBitOrder < overflowLength\n const zeroPadding = bigEndianBitOrder < zeroPaddingLength\n return React.createElement(bitElement, {\n key: index,\n stand,\n overflow,\n zeroPadding,\n littleEndianBitOrder: representLength - index - 1,\n bigEndianBitOrder,\n })\n })\n return <>{elements}</>\n}\n"],"mappings":";AAAA,OAAO,WAAW;AAuDT;AA1BF,IAAM,OAAO,CAAC,UAII;AACvB,QAAM,EAAE,OAAO,WAAW,IAAI;AAC9B,QAAM,QAAQ,QAAQ,GAAG,SAAS,CAAC,EAAE,MAAM,EAAE;AAC7C,QAAM,YAAY,KAAK;AACvB,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,iBAAiB,KAAK,IAAI,GAAG,YAAY,MAAM;AACrD,QAAM,oBAAoB,KAAK,IAAI,GAAG,SAAS,SAAS;AACxD,QAAM,kBAAkB,KAAK,IAAI,QAAQ,SAAS;AAClD,QAAM,WAAW,MAAM,KAAK,MAAM,eAAe,CAAC,EAAE,IAAI,CAAC,GAAG,UAAU;AACpE,UAAM,QAAQ,KAAK,YAAY,kBAAkB,KAAK,MAAM;AAC5D,UAAM,oBAAoB;AAC1B,UAAM,WAAW,oBAAoB;AACrC,UAAM,cAAc,oBAAoB;AACxC,WAAO,MAAM,cAAc,YAAY;AAAA,MACrC,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,sBAAsB,kBAAkB,QAAQ;AAAA,MAChD;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACD,SAAO,gCAAG,oBAAS;AACrB;","names":[]}
|
package/dist/chunk-EIJS7GKA.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Bits
|
|
3
|
-
} from "./chunk-76L6HIHJ.js";
|
|
4
|
-
|
|
5
|
-
// src/Simple.tsx
|
|
6
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
7
|
-
var SimpleBit = (props) => {
|
|
8
|
-
const { stand, overflow } = props;
|
|
9
|
-
const baseText = stand ? "1" : "0";
|
|
10
|
-
const isOverflowVisible = overflow ?? false;
|
|
11
|
-
const text = isOverflowVisible ? "" : baseText;
|
|
12
|
-
return /* @__PURE__ */ jsx(Fragment, { children: text });
|
|
13
|
-
};
|
|
14
|
-
var Simple8BitString = (props) => {
|
|
15
|
-
return /* @__PURE__ */ jsx(Bits, { value: props.value, length: 8, bitElement: SimpleBit });
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
SimpleBit,
|
|
20
|
-
Simple8BitString
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=chunk-EIJS7GKA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Simple.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\n/**\n * SimpleBit is a simple component that displays a bit.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const SimpleBit = (props: EnhancedBitProps): React.JSX.Element => {\n const { stand, overflow } = props\n const baseText = stand ? '1' : '0'\n const isOverflowVisible = overflow ?? false\n const text = isOverflowVisible ? '' : baseText\n return <>{text}</>\n}\n\nexport const Simple8BitString = (props: { value: number }): React.JSX.Element => {\n return <Bits value={props.value} length={8} bitElement={SimpleBit} />\n}\n"],"mappings":";;;;;AAaS;AALF,IAAM,YAAY,CAAC,UAA+C;AACvE,QAAM,EAAE,OAAO,SAAS,IAAI;AAC5B,QAAM,WAAW,QAAQ,MAAM;AAC/B,QAAM,oBAAoB,YAAY;AACtC,QAAM,OAAO,oBAAoB,KAAK;AACtC,SAAO,gCAAG,gBAAK;AACjB;AAEO,IAAM,mBAAmB,CAAC,UAAgD;AAC/E,SAAO,oBAAC,QAAK,OAAO,MAAM,OAAO,QAAQ,GAAG,YAAY,WAAW;AACrE;","names":[]}
|
package/dist/chunk-KC5B3ZDB.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Bits
|
|
3
|
-
} from "./chunk-76L6HIHJ.js";
|
|
4
|
-
|
|
5
|
-
// src/Detailed.tsx
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
var DetailedBit = (props) => {
|
|
8
|
-
const { stand, overflow, zeroPadding } = props;
|
|
9
|
-
const displayLittleEndianBitOrder = props.displayLittleEndianBitOrder ?? false;
|
|
10
|
-
const displayBigEndianBitOrder = props.displayBigEndianBitOrder ?? false;
|
|
11
|
-
const text = stand ? "1" : "0";
|
|
12
|
-
const border = overflow ? "1px dotted red" : zeroPadding ? "1px dotted gray" : "1px solid #cccccc";
|
|
13
|
-
const margin = "0.5px";
|
|
14
|
-
const color = stand ? "#999999" : "#cccccc";
|
|
15
|
-
const backgroundColor = stand ? "#000000" : "#ffffff";
|
|
16
|
-
const fontFamily = "monospace";
|
|
17
|
-
return /* @__PURE__ */ jsxs("div", { style: { display: "inline-block", fontFamily, margin }, children: [
|
|
18
|
-
/* @__PURE__ */ jsx(
|
|
19
|
-
"div",
|
|
20
|
-
{
|
|
21
|
-
style: {
|
|
22
|
-
color,
|
|
23
|
-
backgroundColor,
|
|
24
|
-
border
|
|
25
|
-
},
|
|
26
|
-
children: text
|
|
27
|
-
}
|
|
28
|
-
),
|
|
29
|
-
displayLittleEndianBitOrder && /* @__PURE__ */ jsx(IndexLabel, { index: props.littleEndianBitOrder }),
|
|
30
|
-
displayBigEndianBitOrder && /* @__PURE__ */ jsx(IndexLabel, { index: props.bigEndianBitOrder })
|
|
31
|
-
] });
|
|
32
|
-
};
|
|
33
|
-
var IndexLabel = (props) => {
|
|
34
|
-
return /* @__PURE__ */ jsx(
|
|
35
|
-
"div",
|
|
36
|
-
{
|
|
37
|
-
style: {
|
|
38
|
-
userSelect: "none",
|
|
39
|
-
fontSize: "0.5em",
|
|
40
|
-
textAlign: "center",
|
|
41
|
-
lineHeight: "1em"
|
|
42
|
-
},
|
|
43
|
-
children: props.index
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
var DetailedBitString = (props) => {
|
|
48
|
-
const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false;
|
|
49
|
-
const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false;
|
|
50
|
-
return /* @__PURE__ */ jsx(
|
|
51
|
-
Bits,
|
|
52
|
-
{
|
|
53
|
-
value: props.value,
|
|
54
|
-
length: props.length,
|
|
55
|
-
bitElement: (props2) => /* @__PURE__ */ jsx(
|
|
56
|
-
DetailedBit,
|
|
57
|
-
{
|
|
58
|
-
...props2,
|
|
59
|
-
displayLittleEndianBitOrder: showLittleEndianBitOrder,
|
|
60
|
-
displayBigEndianBitOrder: showBigEndianBitOrder
|
|
61
|
-
}
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export {
|
|
68
|
-
DetailedBit,
|
|
69
|
-
DetailedBitString
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=chunk-KC5B3ZDB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Detailed.tsx"],"sourcesContent":["import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type DetailedBitProps = EnhancedBitProps & {\n displayLittleEndianBitOrder?: boolean | undefined\n displayBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBit = (props: DetailedBitProps): React.JSX.Element => {\n const { stand, overflow, zeroPadding } = props\n const displayLittleEndianBitOrder = props.displayLittleEndianBitOrder ?? false\n const displayBigEndianBitOrder = props.displayBigEndianBitOrder ?? false\n const text = stand ? '1' : '0'\n const border = overflow\n ? '1px dotted red'\n : zeroPadding\n ? '1px dotted gray'\n : '1px solid #cccccc'\n const margin = '0.5px'\n const color = stand ? '#999999' : '#cccccc'\n const backgroundColor = stand ? '#000000' : '#ffffff'\n const fontFamily = 'monospace'\n return (\n <div style={{ display: 'inline-block', fontFamily, margin }}>\n <div\n style={{\n color,\n backgroundColor,\n border,\n }}\n >\n {text}\n </div>\n {displayLittleEndianBitOrder && (\n <IndexLabel index={props.littleEndianBitOrder} />\n )}\n {displayBigEndianBitOrder && (\n <IndexLabel index={props.bigEndianBitOrder} />\n )}\n </div>\n )\n}\n\nconst IndexLabel = (props: { index: number }): React.JSX.Element => {\n return (\n <div\n style={{\n userSelect: 'none',\n fontSize: '0.5em',\n textAlign: 'center',\n lineHeight: '1em',\n }}\n >\n {props.index}\n </div>\n )\n}\n\nexport const DetailedBitString = (props: {\n value: number\n length?: number\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n}): React.JSX.Element => {\n const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false\n const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false\n return (\n <Bits\n value={props.value}\n length={props.length}\n bitElement={(props) => (\n <DetailedBit\n {...props}\n displayLittleEndianBitOrder={showLittleEndianBitOrder}\n displayBigEndianBitOrder={showBigEndianBitOrder}\n />\n )}\n />\n )\n}\n"],"mappings":";;;;;AAuBI,SACE,KADF;AAfG,IAAM,cAAc,CAAC,UAA+C;AACzE,QAAM,EAAE,OAAO,UAAU,YAAY,IAAI;AACzC,QAAM,8BAA8B,MAAM,+BAA+B;AACzE,QAAM,2BAA2B,MAAM,4BAA4B;AACnE,QAAM,OAAO,QAAQ,MAAM;AAC3B,QAAM,SAAS,WACX,mBACA,cACE,oBACA;AACN,QAAM,SAAS;AACf,QAAM,QAAQ,QAAQ,YAAY;AAClC,QAAM,kBAAkB,QAAQ,YAAY;AAC5C,QAAM,aAAa;AACnB,SACE,qBAAC,SAAI,OAAO,EAAE,SAAS,gBAAgB,YAAY,OAAO,GACxD;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,IACC,+BACC,oBAAC,cAAW,OAAO,MAAM,sBAAsB;AAAA,IAEhD,4BACC,oBAAC,cAAW,OAAO,MAAM,mBAAmB;AAAA,KAEhD;AAEJ;AAEA,IAAM,aAAa,CAAC,UAAgD;AAClE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,WAAW;AAAA,QACX,YAAY;AAAA,MACd;AAAA,MAEC,gBAAM;AAAA;AAAA,EACT;AAEJ;AAEO,IAAM,oBAAoB,CAAC,UAKT;AACvB,QAAM,2BAA2B,MAAM,4BAA4B;AACnE,QAAM,wBAAwB,MAAM,yBAAyB;AAC7D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,MAAM;AAAA,MACb,QAAQ,MAAM;AAAA,MACd,YAAY,CAACA,WACX;AAAA,QAAC;AAAA;AAAA,UACE,GAAGA;AAAA,UACJ,6BAA6B;AAAA,UAC7B,0BAA0B;AAAA;AAAA,MAC5B;AAAA;AAAA,EAEJ;AAEJ;","names":["props"]}
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/Binary.tsx","../src/Simple.tsx","../src/Detailed.tsx"],"sourcesContent":["export * from './Binary'\nexport * from './Simple'\nexport * from './Detailed'\n","import React from 'react'\n\n/**\n * BitProps is a type that represents the properties of a bit.\n */\nexport type BitProps = {\n stand: boolean\n}\n\n/**\n * EnhancedBitProps is a type that adds the following properties to BitProps.\n * - overflow: If true, this means that bit is out of range.\n * - zeroPadding: If true, this means that bit is padded with zero.\n */\nexport type EnhancedBitProps = BitProps & {\n overflow?: boolean\n zeroPadding?: boolean\n littleEndianBitOrder: number\n bigEndianBitOrder: number\n}\n\nexport type BitElement = React.FC<EnhancedBitProps>\n\n/**\n * Bit is a component that displays a bit.\n * This component supports the behavior of zero padding and overflow.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const Bits = (props: {\n value: number\n bitElement: BitElement\n length?: number | undefined\n}): React.JSX.Element => {\n const { value, bitElement } = props\n const bits = (value | 0).toString(2).split('')\n const bitLength = bits.length\n const length = props.length ?? bitLength\n const overflowLength = Math.max(0, bitLength - length)\n const zeroPaddingLength = Math.max(0, length - bitLength)\n const representLength = Math.max(length, bitLength)\n const elements = Array.from(Array(representLength)).map((_, index) => {\n const stand = bits[bitLength - representLength + index] === '1'\n const bigEndianBitOrder = index\n const overflow = bigEndianBitOrder < overflowLength\n const zeroPadding = bigEndianBitOrder < zeroPaddingLength\n return React.createElement(bitElement, {\n key: index,\n stand,\n overflow,\n zeroPadding,\n littleEndianBitOrder: representLength - index - 1,\n bigEndianBitOrder,\n })\n })\n return <>{elements}</>\n}\n","import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\n/**\n * SimpleBit is a simple component that displays a bit.\n * @param props\n * @returns A component that displays a bit.\n */\nexport const SimpleBit = (props: EnhancedBitProps): React.JSX.Element => {\n const { stand, overflow } = props\n const baseText = stand ? '1' : '0'\n const isOverflowVisible = overflow ?? false\n const text = isOverflowVisible ? '' : baseText\n return <>{text}</>\n}\n\nexport const Simple8BitString = (props: { value: number }): React.JSX.Element => {\n return <Bits value={props.value} length={8} bitElement={SimpleBit} />\n}\n","import type React from 'react'\nimport { Bits, type EnhancedBitProps } from './Binary'\n\nexport type DetailedBitProps = EnhancedBitProps & {\n displayLittleEndianBitOrder?: boolean | undefined\n displayBigEndianBitOrder?: boolean | undefined\n}\n\nexport const DetailedBit = (props: DetailedBitProps): React.JSX.Element => {\n const { stand, overflow, zeroPadding } = props\n const displayLittleEndianBitOrder = props.displayLittleEndianBitOrder ?? false\n const displayBigEndianBitOrder = props.displayBigEndianBitOrder ?? false\n const text = stand ? '1' : '0'\n const border = overflow\n ? '1px dotted red'\n : zeroPadding\n ? '1px dotted gray'\n : '1px solid #cccccc'\n const margin = '0.5px'\n const color = stand ? '#999999' : '#cccccc'\n const backgroundColor = stand ? '#000000' : '#ffffff'\n const fontFamily = 'monospace'\n return (\n <div style={{ display: 'inline-block', fontFamily, margin }}>\n <div\n style={{\n color,\n backgroundColor,\n border,\n }}\n >\n {text}\n </div>\n {displayLittleEndianBitOrder && (\n <IndexLabel index={props.littleEndianBitOrder} />\n )}\n {displayBigEndianBitOrder && (\n <IndexLabel index={props.bigEndianBitOrder} />\n )}\n </div>\n )\n}\n\nconst IndexLabel = (props: { index: number }): React.JSX.Element => {\n return (\n <div\n style={{\n userSelect: 'none',\n fontSize: '0.5em',\n textAlign: 'center',\n lineHeight: '1em',\n }}\n >\n {props.index}\n </div>\n )\n}\n\nexport const DetailedBitString = (props: {\n value: number\n length?: number\n showLittleEndianBitOrder?: boolean | undefined\n showBigEndianBitOrder?: boolean | undefined\n}): React.JSX.Element => {\n const showLittleEndianBitOrder = props.showLittleEndianBitOrder ?? false\n const showBigEndianBitOrder = props.showBigEndianBitOrder ?? false\n return (\n <Bits\n value={props.value}\n length={props.length}\n bitElement={(props) => (\n <DetailedBit\n {...props}\n displayLittleEndianBitOrder={showLittleEndianBitOrder}\n displayBigEndianBitOrder={showBigEndianBitOrder}\n />\n )}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAuDT;AA1BF,IAAM,OAAO,CAAC,UAII;AACvB,QAAM,EAAE,OAAO,WAAW,IAAI;AAC9B,QAAM,QAAQ,QAAQ,GAAG,SAAS,CAAC,EAAE,MAAM,EAAE;AAC7C,QAAM,YAAY,KAAK;AACvB,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,iBAAiB,KAAK,IAAI,GAAG,YAAY,MAAM;AACrD,QAAM,oBAAoB,KAAK,IAAI,GAAG,SAAS,SAAS;AACxD,QAAM,kBAAkB,KAAK,IAAI,QAAQ,SAAS;AAClD,QAAM,WAAW,MAAM,KAAK,MAAM,eAAe,CAAC,EAAE,IAAI,CAAC,GAAG,UAAU;AACpE,UAAM,QAAQ,KAAK,YAAY,kBAAkB,KAAK,MAAM;AAC5D,UAAM,oBAAoB;AAC1B,UAAM,WAAW,oBAAoB;AACrC,UAAM,cAAc,oBAAoB;AACxC,WAAO,aAAAA,QAAM,cAAc,YAAY;AAAA,MACrC,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,sBAAsB,kBAAkB,QAAQ;AAAA,MAChD;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACD,SAAO,2EAAG,oBAAS;AACrB;;;AC3CS,IAAAC,sBAAA;AALF,IAAM,YAAY,CAAC,UAA+C;AACvE,QAAM,EAAE,OAAO,SAAS,IAAI;AAC5B,QAAM,WAAW,QAAQ,MAAM;AAC/B,QAAM,oBAAoB,YAAY;AACtC,QAAM,OAAO,oBAAoB,KAAK;AACtC,SAAO,6EAAG,gBAAK;AACjB;AAEO,IAAM,mBAAmB,CAAC,UAAgD;AAC/E,SAAO,6CAAC,QAAK,OAAO,MAAM,OAAO,QAAQ,GAAG,YAAY,WAAW;AACrE;;;ACKI,IAAAC,sBAAA;AAfG,IAAM,cAAc,CAAC,UAA+C;AACzE,QAAM,EAAE,OAAO,UAAU,YAAY,IAAI;AACzC,QAAM,8BAA8B,MAAM,+BAA+B;AACzE,QAAM,2BAA2B,MAAM,4BAA4B;AACnE,QAAM,OAAO,QAAQ,MAAM;AAC3B,QAAM,SAAS,WACX,mBACA,cACE,oBACA;AACN,QAAM,SAAS;AACf,QAAM,QAAQ,QAAQ,YAAY;AAClC,QAAM,kBAAkB,QAAQ,YAAY;AAC5C,QAAM,aAAa;AACnB,SACE,8CAAC,SAAI,OAAO,EAAE,SAAS,gBAAgB,YAAY,OAAO,GACxD;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,IACC,+BACC,6CAAC,cAAW,OAAO,MAAM,sBAAsB;AAAA,IAEhD,4BACC,6CAAC,cAAW,OAAO,MAAM,mBAAmB;AAAA,KAEhD;AAEJ;AAEA,IAAM,aAAa,CAAC,UAAgD;AAClE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,WAAW;AAAA,QACX,YAAY;AAAA,MACd;AAAA,MAEC,gBAAM;AAAA;AAAA,EACT;AAEJ;AAEO,IAAM,oBAAoB,CAAC,UAKT;AACvB,QAAM,2BAA2B,MAAM,4BAA4B;AACnE,QAAM,wBAAwB,MAAM,yBAAyB;AAC7D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,MAAM;AAAA,MACb,QAAQ,MAAM;AAAA,MACd,YAAY,CAACC,WACX;AAAA,QAAC;AAAA;AAAA,UACE,GAAGA;AAAA,UACJ,6BAA6B;AAAA,UAC7B,0BAA0B;AAAA;AAAA,MAC5B;AAAA;AAAA,EAEJ;AAEJ;","names":["React","import_jsx_runtime","import_jsx_runtime","props"]}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|