@lofcz/streamdown-effects 0.0.0-bootstrap.0 → 1.0.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 +13 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +1 -0
- package/package.json +36 -4
- package/styles.css +89 -0
- package/README.md +0 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matches `AnimationEffect` in streamdown. Declared here so this package has
|
|
3
|
+
* no runtime or type dependency on it.
|
|
4
|
+
*/
|
|
5
|
+
export interface AnimationEffect {
|
|
6
|
+
decorate?: (text: string, seed: number) => Record<`data-${string}`, string>;
|
|
7
|
+
duration?: number;
|
|
8
|
+
name: string;
|
|
9
|
+
scatter?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Same-shape noise for a word: letters and digits become random characters
|
|
13
|
+
* of the same class; punctuation and spacing are kept. Deterministic for a
|
|
14
|
+
* given seed.
|
|
15
|
+
*/
|
|
16
|
+
export declare const noise: (text: string, seed: number) => string;
|
|
17
|
+
/** Words sharpen out of a blur, in scattered order. */
|
|
18
|
+
export declare const diffuse: AnimationEffect;
|
|
19
|
+
/**
|
|
20
|
+
* Words start as noise glyphs that change once, then resolve to the real
|
|
21
|
+
* text, in scattered order. The real text stays in the DOM throughout.
|
|
22
|
+
*/
|
|
23
|
+
export declare const scramble: AnimationEffect;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=/\p{Lu}/u,u=/\p{L}/u,f=/\p{N}/u,c="abcdefghijklmnopqrstuvwxyz",m=c.toUpperCase(),l="0123456789",d=(e,t)=>{let n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},o=(e,t,n)=>e.charAt(Math.floor(d(t,n)*e.length)),a=(e,t)=>{let n="",r=0;for(let s of e)i.test(s)?n+=o(m,t,r):u.test(s)?n+=o(c,t,r):f.test(s)?n+=o(l,t,r):n+=s,r+=1;return n},p={duration:420,name:"diffuse",scatter:140},E={decorate:(e,t)=>({"data-sd-glyphs":a(e,t),"data-sd-glyphs-alt":a(e,t+1)}),duration:320,name:"scramble",scatter:160};export{p as diffuse,a as noise,E as scramble};
|
package/package.json
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/streamdown-effects",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Streaming text effects for Streamdown's animated prop
|
|
5
|
-
"license": "Apache-2.0",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Streaming text effects for Streamdown's animated prop",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
8
7
|
"url": "git+https://github.com/lofcz/streamdown-ng.git",
|
|
9
8
|
"directory": "packages/streamdown-effects"
|
|
9
|
+
},
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./styles.css": "./styles.css"
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"module": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"styles.css"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": [
|
|
27
|
+
"*.css"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
34
|
+
"tsup": "^8.5.1",
|
|
35
|
+
"typescript": "^7.0.2",
|
|
36
|
+
"vitest": "^4.1.10"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "node scripts/build.mjs",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:coverage": "vitest --coverage run"
|
|
10
42
|
}
|
|
11
|
-
}
|
|
43
|
+
}
|
package/styles.css
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
@keyframes sd-diffuse {
|
|
2
|
+
from {
|
|
3
|
+
opacity: 0;
|
|
4
|
+
filter: blur(8px);
|
|
5
|
+
}
|
|
6
|
+
55% {
|
|
7
|
+
opacity: 0.75;
|
|
8
|
+
filter: blur(2px);
|
|
9
|
+
}
|
|
10
|
+
to {
|
|
11
|
+
opacity: 1;
|
|
12
|
+
filter: blur(0);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* scramble: the real word is laid out but unpainted while noise glyphs,
|
|
18
|
+
* drawn over it from data attributes, change once and then resolve. The text
|
|
19
|
+
* stays in the DOM, so selection, copy and assistive tech get real words; the
|
|
20
|
+
* glyphs use empty alt text.
|
|
21
|
+
*/
|
|
22
|
+
@keyframes sd-scramble {
|
|
23
|
+
from {
|
|
24
|
+
-webkit-text-fill-color: transparent;
|
|
25
|
+
animation-timing-function: step-end;
|
|
26
|
+
}
|
|
27
|
+
to {
|
|
28
|
+
-webkit-text-fill-color: currentcolor;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@keyframes sd-glyphs {
|
|
33
|
+
from {
|
|
34
|
+
opacity: 1;
|
|
35
|
+
}
|
|
36
|
+
50%,
|
|
37
|
+
to {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@keyframes sd-glyphs-alt {
|
|
43
|
+
from {
|
|
44
|
+
opacity: 0;
|
|
45
|
+
}
|
|
46
|
+
50% {
|
|
47
|
+
opacity: 1;
|
|
48
|
+
}
|
|
49
|
+
to {
|
|
50
|
+
opacity: 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
[data-sd-glyphs] {
|
|
55
|
+
position: relative;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[data-sd-glyphs]::before,
|
|
59
|
+
[data-sd-glyphs]::after {
|
|
60
|
+
/* Block offset stays auto: the static position starts at the top of the
|
|
61
|
+
line box, so the glyphs share the text's baseline. */
|
|
62
|
+
position: absolute;
|
|
63
|
+
inset-inline-start: 0;
|
|
64
|
+
-webkit-text-fill-color: currentcolor;
|
|
65
|
+
white-space: pre;
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
animation: sd-glyphs var(--sd-duration, 320ms) step-end var(--sd-delay, 0ms)
|
|
68
|
+
both;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[data-sd-glyphs]::before {
|
|
72
|
+
content: attr(data-sd-glyphs) / "";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[data-sd-glyphs]::after {
|
|
76
|
+
content: attr(data-sd-glyphs-alt) / "";
|
|
77
|
+
animation-name: sd-glyphs-alt;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@media (prefers-reduced-motion: reduce) {
|
|
81
|
+
[data-sd-glyphs] {
|
|
82
|
+
animation-name: sd-fadeIn;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[data-sd-glyphs]::before,
|
|
86
|
+
[data-sd-glyphs]::after {
|
|
87
|
+
content: none;
|
|
88
|
+
}
|
|
89
|
+
}
|
package/README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# @lofcz/streamdown-effects
|
|
2
|
-
|
|
3
|
-
This version (`0.0.0-bootstrap.0`, dist-tag `bootstrap`) is a name claim so npm
|
|
4
|
-
trusted publishing can be attached to the package. Real releases are published
|
|
5
|
-
from CI: https://github.com/lofcz/streamdown-ng (packages/streamdown-effects).
|