@cos-design/scramble-text 3.5.1

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) 2021-present jiaxiantao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});require('./index.css');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));let c=require("react");c=s(c,1);let l=require("react/jsx-runtime");var u={scrambleText:`cos-scrambleText-hN4Wm`,text:`cos-text-frsHs`,cursor:`cos-cursor-3zQOy`,blink:`cos-blink-OcKXu`},d=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*`,f=({text:e=`DECRYPTED`,duration:t=2e3,charset:n=d})=>{let[r,i]=(0,c.useState)(``),a=(0,c.useRef)(0),o=(0,c.useRef)(0);return(0,c.useEffect)(()=>{let r=n.length>0?n:d,s=e;o.current=performance.now();let c=e=>{let n=e-o.current,l=Math.min(n/t,1),u=Math.floor(l*s.length);i(s.split(``).map((e,t)=>e===` `?` `:t<u?e:r[Math.floor(Math.random()*r.length)]).join(``)),l<1?a.current=requestAnimationFrame(c):i(s)};return a.current=requestAnimationFrame(c),()=>cancelAnimationFrame(a.current)},[e,t,n]),(0,l.jsx)(`div`,{className:u.scrambleText,children:(0,l.jsxs)(`p`,{className:u.text,children:[r,(0,l.jsx)(`span`,{className:u.cursor})]})})};exports.ScrambleText=f,exports.default=f;
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .cos-scrambleText-hN4Wm{background:#0a0a0a;border-radius:12px;justify-content:center;align-items:center;min-height:200px;padding:40px;display:flex}.cos-text-frsHs{color:#22d3ee;letter-spacing:.08em;text-shadow:0 0 20px #22d3ee80;margin:0;font-family:Courier New,Courier,monospace;font-size:48px;font-weight:700}.cos-cursor-3zQOy{vertical-align:text-bottom;background:#22d3ee;width:3px;height:.9em;margin-left:4px;animation:.8s step-end infinite cos-blink-OcKXu;display:inline-block}@keyframes cos-blink-OcKXu{50%{opacity:0}}
@@ -0,0 +1,3 @@
1
+ export { default } from './src/components/scrambleText/index';
2
+ export { default as ScrambleText } from './src/components/scrambleText/index';
3
+ export type * from './src/components/scrambleText/index';
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ import { useEffect as e, useRef as t, useState as n } from "react";
2
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ import './index.css';var a = {
4
+ scrambleText: "cos-scrambleText-hN4Wm",
5
+ text: "cos-text-frsHs",
6
+ cursor: "cos-cursor-3zQOy",
7
+ blink: "cos-blink-OcKXu"
8
+ }, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*", s = ({ text: s = "DECRYPTED", duration: c = 2e3, charset: l = o }) => {
9
+ let [u, d] = n(""), f = t(0), p = t(0);
10
+ return e(() => {
11
+ let e = l.length > 0 ? l : o, t = s;
12
+ p.current = performance.now();
13
+ let n = (r) => {
14
+ let i = r - p.current, a = Math.min(i / c, 1), o = Math.floor(a * t.length);
15
+ d(t.split("").map((t, n) => t === " " ? " " : n < o ? t : e[Math.floor(Math.random() * e.length)]).join("")), a < 1 ? f.current = requestAnimationFrame(n) : d(t);
16
+ };
17
+ return f.current = requestAnimationFrame(n), () => cancelAnimationFrame(f.current);
18
+ }, [
19
+ s,
20
+ c,
21
+ l
22
+ ]), /* @__PURE__ */ r("div", {
23
+ className: a.scrambleText,
24
+ children: /* @__PURE__ */ i("p", {
25
+ className: a.text,
26
+ children: [u, /* @__PURE__ */ r("span", { className: a.cursor })]
27
+ })
28
+ });
29
+ };
30
+ //#endregion
31
+ export { s as ScrambleText, s as default };
@@ -0,0 +1,3 @@
1
+ export { default } from '../../../src/components/scrambleText';
2
+ export { default as ScrambleText } from '../../../src/components/scrambleText';
3
+ export type * from '../../../src/components/scrambleText';
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ export interface ScrambleTextProps {
3
+ /** 目标文字 */
4
+ text?: string;
5
+ /** 解密动画时长(毫秒) */
6
+ duration?: number;
7
+ /** 随机字符集 */
8
+ charset?: string;
9
+ }
10
+ declare const ScrambleText: React.FC<ScrambleTextProps>;
11
+ export default ScrambleText;
@@ -0,0 +1,39 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module '*.module.less' {
4
+ const classes: { readonly [key: string]: string };
5
+ export default classes;
6
+ }
7
+
8
+ declare module '*.less' {
9
+ const classes: { readonly [key: string]: string };
10
+ export default classes;
11
+ }
12
+
13
+ declare module '*.png' {
14
+ const src: string;
15
+ export default src;
16
+ }
17
+
18
+ declare module '*.jpg' {
19
+ const src: string;
20
+ export default src;
21
+ }
22
+
23
+ declare module '*.mp4' {
24
+ const src: string;
25
+ export default src;
26
+ }
27
+
28
+ declare module '*.mp3' {
29
+ const src: string;
30
+ export default src;
31
+ }
32
+
33
+ declare module '*.svg' {
34
+ import type { FC, SVGProps } from 'react';
35
+
36
+ export const ReactComponent: FC<SVGProps<SVGSVGElement>>;
37
+ const src: string;
38
+ export default src;
39
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@cos-design/scramble-text",
3
+ "version": "3.5.1",
4
+ "description": "ScrambleText component from cos-design",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "LICENSE"
24
+ ],
25
+ "sideEffects": [
26
+ "**/*.css",
27
+ "**/*.less"
28
+ ],
29
+ "keywords": [
30
+ "cos-design",
31
+ "react",
32
+ "scrambleText",
33
+ "ScrambleText"
34
+ ],
35
+ "homepage": "https://jiaxiantao.github.io/cos-design/",
36
+ "bugs": {
37
+ "url": "https://github.com/jiaxiantao/cos-design/issues"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/jiaxiantao/cos-design.git",
42
+ "directory": "packages/scrambleText"
43
+ },
44
+ "author": "jiaxiantao <jiaxiantao@souche.com>",
45
+ "license": "MIT",
46
+ "peerDependencies": {
47
+ "react": ">=18.0.0",
48
+ "react-dom": ">=18.0.0"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public",
52
+ "registry": "https://registry.npmjs.org"
53
+ }
54
+ }