iconplease 0.4.0 → 0.4.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/ICONS-LICENSE.md +53 -0
- package/LICENSE +30 -0
- package/README.md +8 -0
- package/dist/animation.d.ts +9 -2
- package/dist/animation.js +59 -8
- package/dist/iconplease.min.js +1 -1
- package/dist/player.js +42 -8
- package/package.json +7 -4
package/ICONS-LICENSE.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# iconplease Icon License
|
|
2
|
+
|
|
3
|
+
Version 1.0 — 2026
|
|
4
|
+
|
|
5
|
+
This licence covers the icons in the public iconplease catalogue (served from
|
|
6
|
+
`cdn.iconplease.com` and shown on iconplease.com/icons). It does not cover
|
|
7
|
+
private icons; see "Private icons" below.
|
|
8
|
+
|
|
9
|
+
## You may
|
|
10
|
+
|
|
11
|
+
- Use the icons for free in personal and commercial work: websites, apps,
|
|
12
|
+
software, products you sell, marketing, print, video, slides and documents.
|
|
13
|
+
- Change them: recolour, resize, re-stroke, edit and combine them.
|
|
14
|
+
- Ship them inside your own product, website or app, including in source code
|
|
15
|
+
and builds that other people can download.
|
|
16
|
+
|
|
17
|
+
No attribution is required. A link back to iconplease.com is appreciated.
|
|
18
|
+
|
|
19
|
+
## You may not
|
|
20
|
+
|
|
21
|
+
- Redistribute the icons as an icon set, icon font, icon pack or library — on
|
|
22
|
+
their own or as the main part of another product — whether free or paid.
|
|
23
|
+
- Use them to build a product that competes with iconplease (an icon library,
|
|
24
|
+
icon marketplace or icon design service).
|
|
25
|
+
- Sell or license the icons themselves, as they are or modified, for example as
|
|
26
|
+
stock assets, templates or NFTs.
|
|
27
|
+
- Use them in a logo or trademark, or in a way that suggests iconplease
|
|
28
|
+
endorses you.
|
|
29
|
+
|
|
30
|
+
## Private icons
|
|
31
|
+
|
|
32
|
+
Private icons are not covered by this licence, by the MIT licence of the
|
|
33
|
+
iconplease code, or by any other open licence. Private icons are:
|
|
34
|
+
|
|
35
|
+
- icons drawn in the iconplease designer and saved to an account ("My icons");
|
|
36
|
+
- icons in a private set, including catalogue icons that a set owner changed;
|
|
37
|
+
- icons in a file written by `npx iconplease pull` from a private set.
|
|
38
|
+
|
|
39
|
+
A private icon belongs to the person who made it (or their employer or client,
|
|
40
|
+
as they agree between themselves). iconplease does not own it and only stores
|
|
41
|
+
and serves it to do the job the owner asked for. Seeing, downloading or
|
|
42
|
+
receiving a private icon, through a website, an API key, a token, a build file
|
|
43
|
+
or a Figma file, gives you no right to use it. Only its owner can grant one.
|
|
44
|
+
|
|
45
|
+
A catalogue icon that someone has only recoloured or resized stays a catalogue
|
|
46
|
+
icon, and this licence still applies to it.
|
|
47
|
+
|
|
48
|
+
## No warranty
|
|
49
|
+
|
|
50
|
+
The icons are provided "as is", without warranty of any kind. iconplease is
|
|
51
|
+
not liable for any claim or damage arising from their use.
|
|
52
|
+
|
|
53
|
+
Questions: hello@iconplease.com
|
package/LICENSE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TECHNOLOGYPLEASE Co., Ltd.
|
|
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.
|
|
22
|
+
|
|
23
|
+
This licence covers the code in this package only. It does not cover any icon
|
|
24
|
+
the code loads, renders or writes, including:
|
|
25
|
+
|
|
26
|
+
- the public catalogue icons from cdn.iconplease.com, which are covered by the
|
|
27
|
+
iconplease Icon License (ICONS-LICENSE.md);
|
|
28
|
+
- private icons: icons in a private set, icons people draw in the iconplease
|
|
29
|
+
designer, and icons in a file written by `npx iconplease pull`. These belong
|
|
30
|
+
to their owners. Nothing in this licence grants anyone any right to them.
|
package/README.md
CHANGED
|
@@ -144,3 +144,11 @@ await load(["heart", "star"]);
|
|
|
144
144
|
import { init } from "iconplease";
|
|
145
145
|
init({ revalidate: 600 });
|
|
146
146
|
```
|
|
147
|
+
|
|
148
|
+
## Licence
|
|
149
|
+
|
|
150
|
+
The code is MIT (see `LICENSE`). The catalogue icons are free for personal and
|
|
151
|
+
commercial use, with no attribution, under the iconplease Icon License (see
|
|
152
|
+
`ICONS-LICENSE.md`). Just don't redistribute them as an icon set of your own.
|
|
153
|
+
Private icons (your own drawings, private sets, files from `npx iconplease pull`)
|
|
154
|
+
are not covered by either licence. They belong to their owners.
|
package/dist/animation.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type AnimationPreset = "draw" | "fade" | "pop" | "spin" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "bounce" | "pulse" | "shake" | "follow";
|
|
1
|
+
export type AnimationPreset = "draw" | "fade" | "pop" | "spin" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "bounce" | "pulse" | "shake" | "spin-back" | "fade-out" | "pop-out" | "slide-out-up" | "slide-out-down" | "follow";
|
|
2
2
|
export type AnimationEasing = "linear" | "ease-in" | "ease-out" | "ease-in-out" | "spring";
|
|
3
|
-
export type AnimationTrigger = "load" | "hover" | "click" | "visible";
|
|
3
|
+
export type AnimationTrigger = "load" | "hover" | "click" | "toggle" | "visible";
|
|
4
4
|
export type AnimationClip = {
|
|
5
5
|
id: string;
|
|
6
6
|
target: string;
|
|
@@ -16,6 +16,7 @@ export type IconAnimation = {
|
|
|
16
16
|
trigger: AnimationTrigger;
|
|
17
17
|
loop: boolean;
|
|
18
18
|
loopGap: number;
|
|
19
|
+
reverse?: boolean;
|
|
19
20
|
clips: AnimationClip[];
|
|
20
21
|
};
|
|
21
22
|
type Frame = {
|
|
@@ -56,6 +57,12 @@ export type Playback = {
|
|
|
56
57
|
cancel: () => void;
|
|
57
58
|
readonly period: number;
|
|
58
59
|
readonly animations: Animation[];
|
|
60
|
+
/** Plays backwards from wherever it is, then calls done once it is back at the start. */
|
|
61
|
+
reverse: (done?: () => void) => void;
|
|
62
|
+
/** Plays forwards again after a reverse, from wherever it is. */
|
|
63
|
+
forward: () => void;
|
|
64
|
+
/** Maps an animation's raw currentTime to a moment on the designer's ruler (0..total). */
|
|
65
|
+
readonly clock: (raw: number) => number;
|
|
59
66
|
};
|
|
60
67
|
export declare const animate: (animation: IconAnimation, targetsOf: (target: string) => Element[], options?: {
|
|
61
68
|
paused?: boolean;
|
package/dist/animation.js
CHANGED
|
@@ -31,6 +31,11 @@ export const PRESETS = {
|
|
|
31
31
|
{ offset: 1, transform: "scale(1)" },
|
|
32
32
|
],
|
|
33
33
|
},
|
|
34
|
+
"spin-back": { label: "Spin back", hint: "One full turn, anticlockwise", duration: 800, easing: "ease-in-out", frames: [{ offset: 0, transform: "rotate(0deg)" }, { offset: 1, transform: "rotate(-360deg)" }] },
|
|
35
|
+
"fade-out": { label: "Fade out", hint: "From visible to invisible", duration: 400, easing: "ease-in", frames: [{ offset: 0, opacity: 1 }, { offset: 1, opacity: 0 }] },
|
|
36
|
+
"pop-out": { label: "Pop out", hint: "Shrinks away to nothing", duration: 350, easing: "ease-in", frames: [{ offset: 0, transform: "scale(1)" }, { offset: 1, transform: "scale(0)" }] },
|
|
37
|
+
"slide-out-up": { label: "Slide out up", hint: "Rises and fades away", duration: 400, easing: "ease-in", frames: [{ offset: 0, transform: "translateY(0px)", opacity: 1 }, { offset: 1, transform: "translateY(-4px)", opacity: 0 }] },
|
|
38
|
+
"slide-out-down": { label: "Slide out down", hint: "Drops and fades away", duration: 400, easing: "ease-in", frames: [{ offset: 0, transform: "translateY(0px)", opacity: 1 }, { offset: 1, transform: "translateY(4px)", opacity: 0 }] },
|
|
34
39
|
follow: { label: "Move along path", hint: "The shape's centre travels along a route you drew", duration: 1200, easing: "ease-in-out", route: true },
|
|
35
40
|
shake: {
|
|
36
41
|
label: "Shake",
|
|
@@ -60,12 +65,13 @@ export const TRIGGERS = {
|
|
|
60
65
|
load: "When it appears",
|
|
61
66
|
hover: "On hover",
|
|
62
67
|
click: "On click",
|
|
68
|
+
toggle: "Click to toggle",
|
|
63
69
|
visible: "When scrolled into view",
|
|
64
70
|
};
|
|
65
71
|
export const MAX_CLIPS = 64;
|
|
66
72
|
export const MAX_TIME = 10000;
|
|
67
73
|
export const MIN_DURATION = 50;
|
|
68
|
-
const PRESET_SET = new Set(
|
|
74
|
+
const PRESET_SET = new Set(Object.keys(PRESETS));
|
|
69
75
|
const ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
70
76
|
const ms = (value, low, high) => typeof value === "number" && Number.isFinite(value) ? Math.round(Math.min(Math.max(value, low), high)) : undefined;
|
|
71
77
|
export const cleanAnimation = (value) => {
|
|
@@ -104,6 +110,7 @@ export const cleanAnimation = (value) => {
|
|
|
104
110
|
trigger: raw.trigger && raw.trigger in TRIGGERS ? raw.trigger : "load",
|
|
105
111
|
loop: raw.loop === true,
|
|
106
112
|
loopGap: ms(raw.loopGap, 0, MAX_TIME) ?? 0,
|
|
113
|
+
...(raw.reverse === true ? { reverse: true } : {}),
|
|
107
114
|
clips,
|
|
108
115
|
};
|
|
109
116
|
};
|
|
@@ -171,9 +178,9 @@ const routeFrames = (root, d, orient) => {
|
|
|
171
178
|
guide.remove();
|
|
172
179
|
}
|
|
173
180
|
};
|
|
174
|
-
const onTimeline = (frames, clip, period, neutral) => {
|
|
175
|
-
const begin = clip.start / period;
|
|
176
|
-
const end = (clip.start + clip.duration) / period;
|
|
181
|
+
const onTimeline = (frames, clip, period, neutral, lead = 0) => {
|
|
182
|
+
const begin = (clip.start + lead) / period;
|
|
183
|
+
const end = (clip.start + lead + clip.duration) / period;
|
|
177
184
|
const easing = EASINGS[clip.easing].css;
|
|
178
185
|
const placed = frames.map((frame, index) => ({
|
|
179
186
|
...frame,
|
|
@@ -197,8 +204,15 @@ export const animate = (animation, targetsOf, options = {}) => {
|
|
|
197
204
|
const total = Math.max(totalDuration(animation), MIN_DURATION);
|
|
198
205
|
const loop = options.loop ?? animation.loop;
|
|
199
206
|
const period = loop ? total + animation.loopGap : total;
|
|
207
|
+
const backAndForth = loop && animation.reverse === true;
|
|
208
|
+
const lead = backAndForth ? animation.loopGap / 2 : 0;
|
|
200
209
|
const animations = [];
|
|
201
|
-
const timing = {
|
|
210
|
+
const timing = {
|
|
211
|
+
duration: period,
|
|
212
|
+
iterations: loop ? Infinity : 1,
|
|
213
|
+
fill: "both",
|
|
214
|
+
direction: backAndForth ? "alternate" : "normal",
|
|
215
|
+
};
|
|
202
216
|
for (const clip of animation.clips) {
|
|
203
217
|
const spec = PRESETS[clip.preset];
|
|
204
218
|
const follows = animation.clips.some((other) => other.target === clip.target && other.start < clip.start);
|
|
@@ -211,7 +225,7 @@ export const animate = (animation, targetsOf, options = {}) => {
|
|
|
211
225
|
{ offset: 1, strokeDasharray: `${length} ${length}`, strokeDashoffset: 0 },
|
|
212
226
|
];
|
|
213
227
|
const shown = follows ? { offset: 0, strokeDasharray: `${length} ${length}`, strokeDashoffset: 0 } : undefined;
|
|
214
|
-
animations.push(stroke.animate(onTimeline(frames, clip, period, shown), timing));
|
|
228
|
+
animations.push(stroke.animate(onTimeline(frames, clip, period, shown, lead), timing));
|
|
215
229
|
}
|
|
216
230
|
continue;
|
|
217
231
|
}
|
|
@@ -226,18 +240,55 @@ export const animate = (animation, targetsOf, options = {}) => {
|
|
|
226
240
|
const shown = follows
|
|
227
241
|
? { offset: 0, ...(moves ? { transform: "translate(0px, 0px)" } : {}), ...(fades ? { opacity: 1 } : {}) }
|
|
228
242
|
: undefined;
|
|
229
|
-
animations.push(element.animate(onTimeline(frames, clip, period, shown), { ...timing, composite: moves ? "add" : "replace" }));
|
|
243
|
+
animations.push(element.animate(onTimeline(frames, clip, period, shown, lead), { ...timing, composite: moves ? "add" : "replace" }));
|
|
230
244
|
}
|
|
231
245
|
}
|
|
232
246
|
const each = (fn) => animations.forEach(fn);
|
|
247
|
+
const clock = (raw) => {
|
|
248
|
+
if (!loop)
|
|
249
|
+
return Math.min(raw, total);
|
|
250
|
+
const cycle = Math.floor(raw / period);
|
|
251
|
+
const within = raw - cycle * period;
|
|
252
|
+
const forward = backAndForth && cycle % 2 === 1 ? period - within : within;
|
|
253
|
+
return Math.min(total, Math.max(0, forward - lead));
|
|
254
|
+
};
|
|
233
255
|
if (options.paused)
|
|
234
256
|
each((item) => item.pause());
|
|
235
257
|
return {
|
|
236
258
|
play: () => each((item) => item.play()),
|
|
237
259
|
pause: () => each((item) => item.pause()),
|
|
238
|
-
|
|
260
|
+
reverse: (done) => {
|
|
261
|
+
const first = animations[0];
|
|
262
|
+
if (!first)
|
|
263
|
+
return done?.();
|
|
264
|
+
const at = clock(Number(first.currentTime ?? 0)) + lead;
|
|
265
|
+
if (at <= 1)
|
|
266
|
+
return done?.();
|
|
267
|
+
try {
|
|
268
|
+
each((item) => {
|
|
269
|
+
item.currentTime = at;
|
|
270
|
+
item.playbackRate = -1;
|
|
271
|
+
item.play();
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
return done?.();
|
|
276
|
+
}
|
|
277
|
+
first.onfinish = () => {
|
|
278
|
+
first.onfinish = null;
|
|
279
|
+
done?.();
|
|
280
|
+
};
|
|
281
|
+
},
|
|
282
|
+
forward: () => {
|
|
283
|
+
if (animations[0])
|
|
284
|
+
animations[0].onfinish = null;
|
|
285
|
+
each((item) => (item.playbackRate = 1));
|
|
286
|
+
each((item) => item.play());
|
|
287
|
+
},
|
|
288
|
+
seek: (time) => each((item) => (item.currentTime = Math.max(0, time + lead))),
|
|
239
289
|
cancel: () => each((item) => item.cancel()),
|
|
240
290
|
period,
|
|
241
291
|
animations,
|
|
292
|
+
clock,
|
|
242
293
|
};
|
|
243
294
|
};
|
package/dist/iconplease.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var M={cdnUrl:"https://cdn.iconplease.com",apiUrl:"https://api.iconplease.com",revalidate:3600},k={...M},Z=(e={})=>{if(e.apiKey&&e.apiKey.startsWith("ip_sk_"))throw new Error("iconplease: that is a secret key. init() runs in the browser, where the key is readable by anyone \u2014 use the publishable key (ip_pk_\u2026).");if(e.apiKey&&!/^ip_pk_[A-Za-z0-9]{32}$/.test(e.apiKey)&&console.warn("iconplease: that does not look like a publishable key (ip_pk_ followed by 32 characters). Set icons will not load."),e.token!==void 0&&typeof e.token!="function")throw new Error('iconplease: token must be a function that asks your server for a fresh token, e.g. () => fetch("/api/iconplease-token").then((r) => r.json()).');return k={...M,...e},k};var Q=()=>{var e;return((e=k.cdnUrl)!=null?e:M.cdnUrl).replace(/\/+$/,"")},ee=()=>{var e;return Math.max(0,(e=k.revalidate)!=null?e:M.revalidate)*1e3},te=()=>{var e;return((e=k.apiUrl)!=null?e:M.apiUrl).replace(/\/+$/,"")},ne=()=>k.apiKey||void 0,$=()=>k.token,ve=()=>k.set;var et=/<\s*(script|foreignObject|iframe|object|embed|style)\b[\s\S]*?(<\s*\/\s*\1\s*>|\/>)/gi,tt=/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,nt=/\s+(?:xlink:)?href\s*=\s*("\s*javascript:[^"]*"|'\s*javascript:[^']*')/gi,ot=/^[a-z][a-z0-9-]*$/,rt=/^[^"<>]*$/,st=e=>e.replace(et,"").replace(tt,"").replace(nt,""),oe=e=>{var r;if(!e||typeof e!="object")return;let t=e;if(typeof t.body!="string"||typeof t.viewBox!="string"||!/^[0-9.\s-]+$/.test(t.viewBox))return;let n={};for(let[o,s]of Object.entries((r=t.attrs)!=null?r:{}))ot.test(o)&&!o.startsWith("on")&&typeof s=="string"&&rt.test(s)&&(n[o]=s);return{viewBox:t.viewBox,attrs:n,body:st(t.body)}};var Oe="iconplease:index:v2",Pe="iconplease:icons:v2",Me="iconplease:set:v1",it=1e3,C=/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/,g={status:"idle",revision:0},Y=0,z,Ae=!1,Se=!1,re,I=new Map,T=new Map,ie,_=0,O=!1,R,ae=!1,se=new Map,P=null,ce=0,at=6e4,D,U=null,le=new Map,F=new Map,ct=()=>{let e=ve();if(e!==D&&(D=e,le.clear(),F.clear(),U=null,!(!e||e.format!==1||typeof e.icons!="object"))){U=typeof e.version=="number"?e.version:null;for(let[t,n]of Object.entries(e.icons)){if(!C.test(t)||typeof(n==null?void 0:n.svg)!="string")continue;let r=q(n.svg);r&&(n.source==="public"?F:le).set(t,r)}}},lt=()=>P!==null&&(U===null||P>U),E=e=>{var t,n;return D?lt()?(t=T.get(e))!=null?t:F.get(e):(n=le.get(e))!=null?n:F.get(e):T.get(e)};var fe=new Set,L=()=>{try{return typeof localStorage=="undefined"?void 0:localStorage}catch{return}},A=(e={})=>{g={...g,...e,revision:g.revision+1};for(let t of fe)t()},V=(e,t)=>`${e}@${t}`,$e=e=>{if(!e||typeof e!="object")return;let t=e;if(t.format!==2||typeof t.hash!="string"||!t.icons||typeof t.icons!="object")return;let n=Object.entries(t.icons).filter(([r,o])=>C.test(r)&&Number.isInteger(o)&&o>0);return{format:2,hash:t.hash,icons:Object.fromEntries(n)}},ft=e=>e.slice(0,14),j=()=>{if($())return"token";let e=ne();return e?ft(e):void 0},dt=6e4,ut=9*6e4,K,N,pt=(e=!1)=>{let t=$();return t?!e&&K&&K.expiresAt-dt>Date.now()?Promise.resolve(K.token):N||(N=t().then(n=>{let r=typeof n=="string"?n:n==null?void 0:n.token;if(typeof r!="string"||!r.startsWith("ipt_"))throw new Error("your token function did not return an iconplease token (ipt_\u2026).");let o=typeof n=="string"?void 0:n.expiresAt,s=typeof o=="number"?o:o?Date.parse(o):NaN;return K={token:r,expiresAt:Number.isFinite(s)?s:Date.now()+ut},r}).finally(()=>{N=void 0}),N):Promise.reject(new Error("no token source"))},gt=()=>{var t,n,r;let e=j();if(e!==ie&&(ie=e,T.clear(),_=0,O=!1,R=void 0,ae=!1,P=null,ce=0,!!e))try{if(e==="token")return;let o=JSON.parse((n=(t=L())==null?void 0:t.getItem(Me))!=null?n:"null");if(!o||o.tag!==e)return;for(let[s,i]of Object.entries((r=o.icons)!=null?r:{})){let a=C.test(s)&&typeof(i==null?void 0:i.svg)=="string"?q(i.svg):void 0;a&&T.set(s,a)}_=typeof o.checkedAt=="number"?o.checkedAt:0,P=typeof o.version=="number"?o.version:null,O=!0}catch{return}},S=()=>{var t,n;if(ct(),gt(),Ae)return;Ae=!0;let e=L();if(e){try{let r=JSON.parse((t=e.getItem(Oe))!=null?t:"null"),o=$e(r==null?void 0:r.index);o&&(g={status:"ready",index:o,revision:g.revision},Y=typeof(r==null?void 0:r.checkedAt)=="number"?r.checkedAt:0)}catch{return}try{let r=JSON.parse((n=e.getItem(Pe))!=null?n:"{}");for(let[o,s]of Object.entries(r)){let i=oe(s);i&&I.set(o,i)}}catch{return}}},Ee=()=>{var e;try{(e=L())==null||e.setItem(Oe,JSON.stringify({index:g.index,checkedAt:Y}))}catch{return}},Ne=()=>{re||(re=setTimeout(()=>{var n,r,o;re=void 0;let e=(r=(n=g.index)==null?void 0:n.icons)!=null?r:{},t=[...I.entries()].filter(([s])=>{let i=s.lastIndexOf("@");return e[s.slice(0,i)]===Number(s.slice(i+1))});try{(o=L())==null||o.setItem(Pe,JSON.stringify(Object.fromEntries(t.slice(-it))))}catch{return}},0))},Ie=async e=>{let t=await fetch(e);if(!t.ok)throw new Error(`${t.status} for ${e}`);return t.json()},Re=e=>{Se||(Se=!0,console.warn("iconplease: could not reach the icon CDN.",e))},mt=async()=>{var o;let e=Q(),t=await Ie(`${e}/catalogue/latest.json`);if((t==null?void 0:t.format)!==2||typeof t.hash!="string"||typeof t.index!="string")throw new Error("iconplease: the catalogue pointer is malformed");if(Y=Date.now(),((o=g.index)==null?void 0:o.hash)===t.hash){Ee();return}let n=t.index.replace(/^\/+/,"");if(!/^catalogue\/index-[a-z0-9]+\.json$/.test(n))throw new Error("iconplease: unexpected index location");let r=$e(await Ie(`${e}/${n}`));if(!r)throw new Error("iconplease: the icon index is malformed");A({status:"ready",index:r}),Ee(),Ne()},de=(e={})=>{if(S(),g.index&&Date.now()-Y<ee()&&!e.force)return Promise.resolve();if(z)return z;let n=mt().catch(r=>{g.index||A({status:"error"}),Re(r)}).finally(()=>{z=void 0});return z=n,!g.index&&g.status!=="loading"&&A({status:"loading"}),n},q=e=>{let t=/<svg\b([^>]*)>([\s\S]*)<\/svg>\s*$/.exec(e.trim());if(!t)return;let n={},r="0 0 24 24";for(let[,o,s]of t[1].matchAll(/([a-zA-Z:-]+)="([^"]*)"/g))o==="viewBox"?r=s:["xmlns","width","height","aria-hidden","role","class","style"].includes(o)||(n[o]=s);return oe({viewBox:r,attrs:n,body:t[2]})},ht=(e,t)=>{let n=V(e,t),r=se.get(n);if(r)return r;let o=fetch(`${Q()}/v${t}/${e}.svg`).then(async s=>{if(!s.ok)throw new Error(`${s.status} for ${e}`);let i=q(await s.text());if(!i)throw new Error(`iconplease: "${e}" is not a valid SVG`);I.set(n,i),Ne(),A()}).catch(Re).finally(()=>{se.delete(n)});return se.set(n,o),o},Te=async(e=!1)=>{var n;if(!$()){let r=(n=ne())!=null?n:"";return fetch(`${te()}/sdk/set?key=${encodeURIComponent(r)}`)}let t=await pt(e);return fetch(`${te()}/sdk/set`,{headers:{Authorization:`Bearer ${t}`}})},yt=async e=>{var s,i;let t=await Te();t.status===401&&$()&&(t=await Te(!0));let n=await t.json().catch(()=>({}));if(!t.ok)throw new Error(n.error||`HTTP ${t.status}`);let r=new Map,o={};for(let[a,c]of Object.entries((s=n.icons)!=null?s:{})){if(!C.test(a)||typeof(c==null?void 0:c.svg)!="string")continue;let u=q(c.svg);u&&(r.set(a,u),o[a]={version:Number(c.version)||1,svg:c.svg})}if(e===ie){T.clear();for(let[a,c]of r)T.set(a,c);_=Date.now(),O=!0,P=typeof n.version=="number"?n.version:null;try{e!=="token"&&((i=L())==null||i.setItem(Me,JSON.stringify({tag:e,checkedAt:_,version:P,icons:o})))}catch{A();return}A()}},ue=(e={})=>{S();let t=j();if(!t||O&&Date.now()-_<ee()&&!e.force||!e.force&&Date.now()<ce)return Promise.resolve();if(R)return R;let r=yt(t).catch(o=>{O=!0,ce=Date.now()+at,ae||(ae=!0,console.warn(`iconplease: could not load your icon set \u2014 ${o instanceof Error?o.message:String(o)} Falling back to public icons.`)),A()}).finally(()=>{R=void 0});return R=r,r},pe=async e=>{var r,o;if(!C.test(e))return;if(S(),j()){if(E(e)){ue();return}if(await ue(),E(e))return}else if(E(e))return;let t=(r=g.index)==null?void 0:r.icons[e];if(t&&I.has(V(e,t))){de();return}await de();let n=(o=g.index)==null?void 0:o.icons[e];n&&!I.has(V(e,n))&&await ht(e,n)},ge=async(e={})=>{let{icons:t=[],force:n=!1}=Array.isArray(e)?{icons:e}:e;S(),!(D&&!j()&&t.every(o=>E(o)))&&(await Promise.all([D?Promise.resolve():de({force:n}),ue({force:n})]),await Promise.all(t.map(pe)))},_e=e=>(S(),fe.add(e),()=>fe.delete(e));var J=e=>{var r;S();let t=E(e);if(t)return t;let n=(r=g.index)==null?void 0:r.icons[e];return n?I.get(V(e,n)):void 0},De=e=>(S(),E(e)||j()&&!O?!1:g.status==="ready"&&!!g.index&&!(e in g.index.icons));var bt=/^[#a-zA-Z0-9(),.%\s-]{1,64}$/,xt=/[<>"&]/g,wt={"<":"<",">":">",'"':""","&":"&"},kt=e=>e.replace(xt,t=>wt[t]),Ce=e=>String(Number(e.toFixed(3))),vt=(e,t)=>e.replace(/\b(fill|stroke)="currentColor"/g,`$1="${t}"`),At=(e,t)=>e.replace(/\bstroke-width="([0-9]*\.?[0-9]+)"/g,(n,r)=>`stroke-width="${Ce(Number(r)*t)}"`),me=(e,t={})=>{var d;let{size:n=24,color:r,strokeScale:o,motion:s,label:i,className:a}=t,c=r&&bt.test(r)?r:void 0,u=typeof o=="number"&&Number.isFinite(o)&&o>0&&o!==1?o:void 0,l={...(d=e.attrs)!=null?d:{}};if(c)for(let f of["fill","stroke"])l[f]==="currentColor"&&(l[f]=c);u&&l["stroke-width"]&&(l["stroke-width"]=Ce(Number(l["stroke-width"])*u));let p=e.body;return c&&(p=vt(p,c)),u&&(p=At(p,u)),l.width=String(n),l.height=String(n),l.viewBox=e.viewBox,s&&s!=="none"&&(l["data-motion"]=s),i?(l.role="img",l["aria-label"]=i):l["aria-hidden"]="true",a&&(l.class=a),{attrs:l,body:p}},he=({attrs:e,body:t})=>`<svg xmlns="http://www.w3.org/2000/svg" ${Object.entries(e).map(([r,o])=>`${r}="${kt(o)}"`).join(" ")}>${t}</svg>`,Le=(e,t={})=>{let n=typeof e=="string"?J(e):e;return n?he(me(n,t)):void 0};var B={draw:{label:"Draw on",hint:"Strokes draw themselves",duration:700,easing:"ease-in-out",draw:!0},fade:{label:"Fade in",hint:"From invisible to visible",duration:400,easing:"ease-out",frames:[{offset:0,opacity:0},{offset:1,opacity:1}]},pop:{label:"Pop in",hint:"Grows from nothing with a little overshoot",duration:450,easing:"spring",frames:[{offset:0,transform:"scale(0)"},{offset:1,transform:"scale(1)"}]},spin:{label:"Spin",hint:"One full turn",duration:800,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:1,transform:"rotate(360deg)"}]},"slide-up":{label:"Slide up",hint:"Rises into place",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateY(4px)",opacity:0},{offset:1,transform:"translateY(0px)",opacity:1}]},"slide-down":{label:"Slide down",hint:"Drops into place",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateY(-4px)",opacity:0},{offset:1,transform:"translateY(0px)",opacity:1}]},"slide-left":{label:"Slide left",hint:"Comes in from the right",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateX(4px)",opacity:0},{offset:1,transform:"translateX(0px)",opacity:1}]},"slide-right":{label:"Slide right",hint:"Comes in from the left",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateX(-4px)",opacity:0},{offset:1,transform:"translateX(0px)",opacity:1}]},bounce:{label:"Bounce",hint:"Hops up and lands",duration:700,easing:"ease-out",frames:[{offset:0,transform:"translateY(0px)"},{offset:.35,transform:"translateY(-4px)"},{offset:.65,transform:"translateY(0px)"},{offset:.82,transform:"translateY(-1.5px)"},{offset:1,transform:"translateY(0px)"}]},pulse:{label:"Pulse",hint:"Swells and settles",duration:600,easing:"ease-in-out",frames:[{offset:0,transform:"scale(1)"},{offset:.5,transform:"scale(1.18)"},{offset:1,transform:"scale(1)"}]},follow:{label:"Move along path",hint:"The shape's centre travels along a route you drew",duration:1200,easing:"ease-in-out",route:!0},shake:{label:"Shake",hint:"A quick wobble",duration:600,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:.2,transform:"rotate(-14deg)"},{offset:.4,transform:"rotate(12deg)"},{offset:.6,transform:"rotate(-8deg)"},{offset:.8,transform:"rotate(4deg)"},{offset:1,transform:"rotate(0deg)"}]}},St=Object.keys(B).filter(e=>!B[e].route),Et=/^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s+-]{1,8000}$/,Ge={linear:{label:"Linear",css:"linear"},"ease-in":{label:"Ease in",css:"cubic-bezier(0.4, 0, 1, 1)"},"ease-out":{label:"Ease out",css:"cubic-bezier(0, 0, 0.2, 1)"},"ease-in-out":{label:"Ease in-out",css:"cubic-bezier(0.4, 0, 0.2, 1)"},spring:{label:"Spring",css:"cubic-bezier(0.34, 1.56, 0.64, 1)"}},It={load:"When it appears",hover:"On hover",click:"On click",visible:"When scrolled into view"},Tt=64,ye=1e4,ze=50,Ot=new Set(St),je=/^[A-Za-z0-9_-]{1,64}$/,be=(e,t,n)=>typeof e=="number"&&Number.isFinite(e)?Math.round(Math.min(Math.max(e,t),n)):void 0,Pt=e=>{var r;if(!e||typeof e!="object")return;let t=e,n=[];for(let o of Array.isArray(t.clips)?t.clips.slice(0,Tt):[]){if(!o||typeof o!="object")continue;let s=be(o.start,0,ye),i=be(o.duration,ze,ye);if(typeof o.id!="string"||!je.test(o.id)||typeof o.target!="string"||!je.test(o.target)||!Ot.has(o.preset)||s===void 0||i===void 0)continue;let a=B[o.preset].route;a&&(typeof o.path!="string"||!Et.test(o.path)||!/^\s*[Mm]/.test(o.path))||n.push({id:o.id,target:o.target,preset:o.preset,start:s,duration:i,easing:o.easing&&o.easing in Ge?o.easing:B[o.preset].easing,...a?{path:o.path,orient:o.orient===!0}:{}})}if(n.length)return{version:1,trigger:t.trigger&&t.trigger in It?t.trigger:"load",loop:t.loop===!0,loopGap:(r=be(t.loopGap,0,ye))!=null?r:0,clips:n}},we="data-ip-animation",Ke="data-ip";var Mt=e=>atob(e.replace(/-/g,"+").replace(/_/g,"/"));var Ue=e=>{if(!(!e||e.length>6e4||!/^[A-Za-z0-9_-]+$/.test(e)))try{return Pt(JSON.parse(Mt(e)))}catch{return}},$t=e=>e.clips.reduce((t,n)=>Math.max(t,n.start+n.duration),0),Nt="path, line, rect, ellipse, circle, polyline, polygon",Rt=e=>[...e.querySelectorAll(Nt)].filter(t=>{var r;if(t.closest("defs, clipPath, mask"))return!1;let n=(r=t.getAttribute("stroke"))!=null?r:getComputedStyle(t).stroke;return!!n&&n!=="none"&&n!=="transparent"&&typeof t.getTotalLength=="function"}),_t="http://www.w3.org/2000/svg",xe=48,Dt=(e,t,n)=>{var s;let r=(s=e.ownerSVGElement)!=null?s:e.closest("svg");if(!r||typeof e.getBBox!="function")return[];let o=document.createElementNS(_t,"path");o.setAttribute("d",t),o.setAttribute("visibility","hidden"),r.appendChild(o);try{let i=o.getTotalLength(),a=e.getBBox(),c=a.x+a.width/2,u=a.y+a.height/2,l=h=>o.getPointAtLength(Math.min(Math.max(h,0),i)),p=h=>{let m=Math.max(i/400,.01),b=l(h-m),y=l(h+m);return Math.atan2(y.y-b.y,y.x-b.x)*180/Math.PI},d=p(0),f=0;return Array.from({length:xe+1},(h,m)=>{let b=m/xe*i,y=l(b),x=p(b)-d;for(;x-f>180;)x-=360;for(;x-f<-180;)x+=360;f=x;let G=`translate(${(y.x-c).toFixed(3)}px, ${(y.y-u).toFixed(3)}px)`;return{offset:m/xe,transform:n?`${G} rotate(${x.toFixed(2)}deg)`:G}})}finally{o.remove()}},Be=(e,t,n,r)=>{let o=t.start/n,s=(t.start+t.duration)/n,i=Ge[t.easing].css,a=e.map((p,d)=>({...p,offset:o+p.offset*(s-o),easing:d<e.length-1?i:"linear"})),c={...r!=null?r:e[0],offset:0,easing:"linear"},u={...e[e.length-1],offset:1,easing:"linear"},l=[];return a[0].offset>0&&(l.push(c),r&&l.push({...r,offset:a[0].offset,easing:"linear"})),l.push(...a),a[a.length-1].offset<1&&l.push(u),l},Fe=(e,t,n={})=>{var u,l,p;let r=Math.max($t(e),ze),o=(u=n.loop)!=null?u:e.loop,s=o?r+e.loopGap:r,i=[],a={duration:s,iterations:o?1/0:1,fill:"both"};for(let d of e.clips){let f=B[d.preset],h=e.clips.some(m=>m.target===d.target&&m.start<d.start);for(let m of t(d.target)){if(f.draw){for(let w of Rt(m)){let v=Math.max(w.getTotalLength(),.01),Ze=[{offset:0,strokeDasharray:`${v} ${v}`,strokeDashoffset:v},{offset:1,strokeDasharray:`${v} ${v}`,strokeDashoffset:0}],Qe=h?{offset:0,strokeDasharray:`${v} ${v}`,strokeDashoffset:0}:void 0;i.push(w.animate(Be(Ze,d,s,Qe),a))}continue}let b=m;b.style.transformBox="fill-box",b.style.transformOrigin="center";let y=f.route?Dt(m,(l=d.path)!=null?l:"",d.orient===!0):((p=f.frames)!=null?p:[]).map(w=>({...w}));if(!y.length)continue;let x=y.some(w=>w.transform!==void 0),G=y.some(w=>w.opacity!==void 0),We=h?{offset:0,...x?{transform:"translate(0px, 0px)"}:{},...G?{opacity:1}:{}}:void 0;i.push(b.animate(Be(y,d,s,We),{...a,composite:x?"add":"replace"}))}}let c=d=>i.forEach(d);return n.paused&&c(d=>d.pause()),{play:()=>c(d=>d.play()),pause:()=>c(d=>d.pause()),seek:d=>c(f=>f.currentTime=Math.max(0,d)),cancel:()=>c(d=>d.cancel()),period:s,animations:i}};var H=new WeakMap,Ct=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,Ve=e=>{var t,n;return(n=(t=e.closest("a, button, [role=button], label, summary"))!=null?t:e.parentElement)!=null?n:e},X=(e,t={})=>{var l,p,d;(l=H.get(e))==null||l();let n=Ue(e.getAttribute(we));if(!n||typeof e.animate!="function")return()=>{};if((p=t.reducedMotion)!=null?p:Ct())return()=>{};let r=(d=t.trigger)!=null?d:n.trigger,o=f=>[...e.querySelectorAll(`[${Ke}="${f}"]`)],s,i=[],a=()=>{s==null||s.cancel(),s=void 0},c=()=>{a(),s=Fe(n,o)};if(r==="load"&&c(),r==="hover"){let f=Ve(e);f.addEventListener("pointerenter",c),f.addEventListener("pointerleave",a),f.addEventListener("focusin",c),f.addEventListener("focusout",a),i.push(()=>{f.removeEventListener("pointerenter",c),f.removeEventListener("pointerleave",a),f.removeEventListener("focusin",c),f.removeEventListener("focusout",a)})}if(r==="click"){let f=Ve(e);f.addEventListener("click",c),i.push(()=>f.removeEventListener("click",c))}if(r==="visible")if(typeof IntersectionObserver=="function"){let f=new IntersectionObserver(h=>{h.some(m=>m.isIntersecting)&&(f.disconnect(),c())},{threshold:.5});f.observe(e),i.push(()=>f.disconnect())}else c();let u=()=>{a(),i.forEach(f=>f()),H.delete(e)};return H.set(e,u),u},Ye=(e=document)=>{e.querySelectorAll(`svg[${we}]`).forEach(t=>{H.has(t)||X(t)})};var qe="[data-icon], i.ip[class*='ip-']",Lt=new Set(["none","wiggle","pop","bounce","draw"]),Je=new Set,jt=e=>{let t=e.getAttribute("data-icon");if(t)return t;for(let n of Array.from(e.classList))if(n.startsWith("ip-")&&n.length>3)return n.slice(3)},He=e=>{if(e===null)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0},ke=e=>{var c,u,l,p;let t=jt(e);if(!t)return;let n=J(t),r=e.getAttribute("data-motion"),o=r&&Lt.has(r)?r:void 0,s={size:(c=He(e.getAttribute("data-size")))!=null?c:24,color:(u=e.getAttribute("data-color"))!=null?u:void 0,strokeScale:He(e.getAttribute("data-stroke")),motion:o,label:(l=e.getAttribute("data-label"))!=null?l:void 0},i=JSON.stringify([t,s,n?"1":"0"]);if(e.getAttribute("data-ip-rendered")===i)return;if(!n){De(t)?Je.has(t)||(Je.add(t),console.warn(`iconplease: no icon named "${t}".`)):pe(t);return}e.innerHTML=he(me(n,s)),e.setAttribute("data-ip-rendered",i);let a=e.querySelector("svg");a&&X(a),e.tagName==="I"&&((p=e.style).display||(p.display="inline-flex"))},W=(e=document)=>{e instanceof Element&&e.matches(qe)&&ke(e),e.querySelectorAll(qe).forEach(ke)},Xe=()=>{let e=window.iconpleaseConfig;e&&Z(e),_e(()=>W()),W(),ge(),new MutationObserver(t=>{for(let n of t)n.type==="attributes"&&n.target instanceof Element&&ke(n.target),n.addedNodes.forEach(r=>{r instanceof Element&&W(r)})}).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-icon","data-size","data-color","data-stroke","data-motion","data-label","class"]})};window.iconplease={init:Z,load:ge,renderSVG:Le,attachAnimation:X,attachAll:Ye,refresh:()=>W()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Xe,{once:!0}):Xe();})();
|
|
1
|
+
"use strict";(()=>{var $={cdnUrl:"https://cdn.iconplease.com",apiUrl:"https://api.iconplease.com",revalidate:3600},v={...$},Q=(e={})=>{if(e.apiKey&&e.apiKey.startsWith("ip_sk_"))throw new Error("iconplease: that is a secret key. init() runs in the browser, where the key is readable by anyone \u2014 use the publishable key (ip_pk_\u2026).");if(e.apiKey&&!/^ip_pk_[A-Za-z0-9]{32}$/.test(e.apiKey)&&console.warn("iconplease: that does not look like a publishable key (ip_pk_ followed by 32 characters). Set icons will not load."),e.token!==void 0&&typeof e.token!="function")throw new Error('iconplease: token must be a function that asks your server for a fresh token, e.g. () => fetch("/api/iconplease-token").then((r) => r.json()).');return v={...$,...e},v};var ee=()=>{var e;return((e=v.cdnUrl)!=null?e:$.cdnUrl).replace(/\/+$/,"")},te=()=>{var e;return Math.max(0,(e=v.revalidate)!=null?e:$.revalidate)*1e3},ne=()=>{var e;return((e=v.apiUrl)!=null?e:$.apiUrl).replace(/\/+$/,"")},oe=()=>v.apiKey||void 0,N=()=>v.token,Ee=()=>v.set;var ot=/<\s*(script|foreignObject|iframe|object|embed|style)\b[\s\S]*?(<\s*\/\s*\1\s*>|\/>)/gi,rt=/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,st=/\s+(?:xlink:)?href\s*=\s*("\s*javascript:[^"]*"|'\s*javascript:[^']*')/gi,it=/^[a-z][a-z0-9-]*$/,at=/^[^"<>]*$/,ct=e=>e.replace(ot,"").replace(rt,"").replace(st,""),re=e=>{var r;if(!e||typeof e!="object")return;let t=e;if(typeof t.body!="string"||typeof t.viewBox!="string"||!/^[0-9.\s-]+$/.test(t.viewBox))return;let n={};for(let[o,s]of Object.entries((r=t.attrs)!=null?r:{}))it.test(o)&&!o.startsWith("on")&&typeof s=="string"&&at.test(s)&&(n[o]=s);return{viewBox:t.viewBox,attrs:n,body:ct(t.body)}};var Re="iconplease:index:v2",$e="iconplease:icons:v2",Ne="iconplease:set:v1",lt=1e3,j=/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/,h={status:"idle",revision:0},q=0,z,Ie=!1,Te=!1,se,T=new Map,O=new Map,ae,C=0,P=!1,D,ce=!1,ie=new Map,M=null,le=0,ft=6e4,L,U=null,fe=new Map,Y=new Map,ut=()=>{let e=Ee();if(e!==L&&(L=e,fe.clear(),Y.clear(),U=null,!(!e||e.format!==1||typeof e.icons!="object"))){U=typeof e.version=="number"?e.version:null;for(let[t,n]of Object.entries(e.icons)){if(!j.test(t)||typeof(n==null?void 0:n.svg)!="string")continue;let r=J(n.svg);r&&(n.source==="public"?Y:fe).set(t,r)}}},dt=()=>M!==null&&(U===null||M>U),I=e=>{var t,n;return L?dt()?(t=O.get(e))!=null?t:Y.get(e):(n=fe.get(e))!=null?n:Y.get(e):O.get(e)};var ue=new Set,B=()=>{try{return typeof localStorage=="undefined"?void 0:localStorage}catch{return}},S=(e={})=>{h={...h,...e,revision:h.revision+1};for(let t of ue)t()},V=(e,t)=>`${e}@${t}`,_e=e=>{if(!e||typeof e!="object")return;let t=e;if(t.format!==2||typeof t.hash!="string"||!t.icons||typeof t.icons!="object")return;let n=Object.entries(t.icons).filter(([r,o])=>j.test(r)&&Number.isInteger(o)&&o>0);return{format:2,hash:t.hash,icons:Object.fromEntries(n)}},pt=e=>e.slice(0,14),G=()=>{if(N())return"token";let e=oe();return e?pt(e):void 0},gt=6e4,mt=9*6e4,K,_,ht=(e=!1)=>{let t=N();return t?!e&&K&&K.expiresAt-gt>Date.now()?Promise.resolve(K.token):_||(_=t().then(n=>{let r=typeof n=="string"?n:n==null?void 0:n.token;if(typeof r!="string"||!r.startsWith("ipt_"))throw new Error("your token function did not return an iconplease token (ipt_\u2026).");let o=typeof n=="string"?void 0:n.expiresAt,s=typeof o=="number"?o:o?Date.parse(o):NaN;return K={token:r,expiresAt:Number.isFinite(s)?s:Date.now()+mt},r}).finally(()=>{_=void 0}),_):Promise.reject(new Error("no token source"))},bt=()=>{var t,n,r;let e=G();if(e!==ae&&(ae=e,O.clear(),C=0,P=!1,D=void 0,ce=!1,M=null,le=0,!!e))try{if(e==="token")return;let o=JSON.parse((n=(t=B())==null?void 0:t.getItem(Ne))!=null?n:"null");if(!o||o.tag!==e)return;for(let[s,c]of Object.entries((r=o.icons)!=null?r:{})){let u=j.test(s)&&typeof(c==null?void 0:c.svg)=="string"?J(c.svg):void 0;u&&O.set(s,u)}C=typeof o.checkedAt=="number"?o.checkedAt:0,M=typeof o.version=="number"?o.version:null,P=!0}catch{return}},E=()=>{var t,n;if(ut(),bt(),Ie)return;Ie=!0;let e=B();if(e){try{let r=JSON.parse((t=e.getItem(Re))!=null?t:"null"),o=_e(r==null?void 0:r.index);o&&(h={status:"ready",index:o,revision:h.revision},q=typeof(r==null?void 0:r.checkedAt)=="number"?r.checkedAt:0)}catch{return}try{let r=JSON.parse((n=e.getItem($e))!=null?n:"{}");for(let[o,s]of Object.entries(r)){let c=re(s);c&&T.set(o,c)}}catch{return}}},Oe=()=>{var e;try{(e=B())==null||e.setItem(Re,JSON.stringify({index:h.index,checkedAt:q}))}catch{return}},De=()=>{se||(se=setTimeout(()=>{var n,r,o;se=void 0;let e=(r=(n=h.index)==null?void 0:n.icons)!=null?r:{},t=[...T.entries()].filter(([s])=>{let c=s.lastIndexOf("@");return e[s.slice(0,c)]===Number(s.slice(c+1))});try{(o=B())==null||o.setItem($e,JSON.stringify(Object.fromEntries(t.slice(-lt))))}catch{return}},0))},Pe=async e=>{let t=await fetch(e);if(!t.ok)throw new Error(`${t.status} for ${e}`);return t.json()},Ce=e=>{Te||(Te=!0,console.warn("iconplease: could not reach the icon CDN.",e))},yt=async()=>{var o;let e=ee(),t=await Pe(`${e}/catalogue/latest.json`);if((t==null?void 0:t.format)!==2||typeof t.hash!="string"||typeof t.index!="string")throw new Error("iconplease: the catalogue pointer is malformed");if(q=Date.now(),((o=h.index)==null?void 0:o.hash)===t.hash){Oe();return}let n=t.index.replace(/^\/+/,"");if(!/^catalogue\/index-[a-z0-9]+\.json$/.test(n))throw new Error("iconplease: unexpected index location");let r=_e(await Pe(`${e}/${n}`));if(!r)throw new Error("iconplease: the icon index is malformed");S({status:"ready",index:r}),Oe(),De()},de=(e={})=>{if(E(),h.index&&Date.now()-q<te()&&!e.force)return Promise.resolve();if(z)return z;let n=yt().catch(r=>{h.index||S({status:"error"}),Ce(r)}).finally(()=>{z=void 0});return z=n,!h.index&&h.status!=="loading"&&S({status:"loading"}),n},J=e=>{let t=/<svg\b([^>]*)>([\s\S]*)<\/svg>\s*$/.exec(e.trim());if(!t)return;let n={},r="0 0 24 24";for(let[,o,s]of t[1].matchAll(/([a-zA-Z:-]+)="([^"]*)"/g))o==="viewBox"?r=s:["xmlns","width","height","aria-hidden","role","class","style"].includes(o)||(n[o]=s);return re({viewBox:r,attrs:n,body:t[2]})},xt=(e,t)=>{let n=V(e,t),r=ie.get(n);if(r)return r;let o=fetch(`${ee()}/v${t}/${e}.svg`).then(async s=>{if(!s.ok)throw new Error(`${s.status} for ${e}`);let c=J(await s.text());if(!c)throw new Error(`iconplease: "${e}" is not a valid SVG`);T.set(n,c),De(),S()}).catch(Ce).finally(()=>{ie.delete(n)});return ie.set(n,o),o},Me=async(e=!1)=>{var n;if(!N()){let r=(n=oe())!=null?n:"";return fetch(`${ne()}/sdk/set?key=${encodeURIComponent(r)}`)}let t=await ht(e);return fetch(`${ne()}/sdk/set`,{headers:{Authorization:`Bearer ${t}`}})},wt=async e=>{var s,c;let t=await Me();t.status===401&&N()&&(t=await Me(!0));let n=await t.json().catch(()=>({}));if(!t.ok)throw new Error(n.error||`HTTP ${t.status}`);let r=new Map,o={};for(let[u,l]of Object.entries((s=n.icons)!=null?s:{})){if(!j.test(u)||typeof(l==null?void 0:l.svg)!="string")continue;let p=J(l.svg);p&&(r.set(u,p),o[u]={version:Number(l.version)||1,svg:l.svg})}if(e===ae){O.clear();for(let[u,l]of r)O.set(u,l);C=Date.now(),P=!0,M=typeof n.version=="number"?n.version:null;try{e!=="token"&&((c=B())==null||c.setItem(Ne,JSON.stringify({tag:e,checkedAt:C,version:M,icons:o})))}catch{S();return}S()}},pe=(e={})=>{E();let t=G();if(!t||P&&Date.now()-C<te()&&!e.force||!e.force&&Date.now()<le)return Promise.resolve();if(D)return D;let r=wt(t).catch(o=>{P=!0,le=Date.now()+ft,ce||(ce=!0,console.warn(`iconplease: could not load your icon set \u2014 ${o instanceof Error?o.message:String(o)} Falling back to public icons.`)),S()}).finally(()=>{D=void 0});return D=r,r},ge=async e=>{var r,o;if(!j.test(e))return;if(E(),G()){if(I(e)){pe();return}if(await pe(),I(e))return}else if(I(e))return;let t=(r=h.index)==null?void 0:r.icons[e];if(t&&T.has(V(e,t))){de();return}await de();let n=(o=h.index)==null?void 0:o.icons[e];n&&!T.has(V(e,n))&&await xt(e,n)},me=async(e={})=>{let{icons:t=[],force:n=!1}=Array.isArray(e)?{icons:e}:e;E(),!(L&&!G()&&t.every(o=>I(o)))&&(await Promise.all([L?Promise.resolve():de({force:n}),pe({force:n})]),await Promise.all(t.map(ge)))},Le=e=>(E(),ue.add(e),()=>ue.delete(e));var H=e=>{var r;E();let t=I(e);if(t)return t;let n=(r=h.index)==null?void 0:r.icons[e];return n?T.get(V(e,n)):void 0},je=e=>(E(),I(e)||G()&&!P?!1:h.status==="ready"&&!!h.index&&!(e in h.index.icons));var kt=/^[#a-zA-Z0-9(),.%\s-]{1,64}$/,vt=/[<>"&]/g,At={"<":"<",">":">",'"':""","&":"&"},St=e=>e.replace(vt,t=>At[t]),Be=e=>String(Number(e.toFixed(3))),Et=(e,t)=>e.replace(/\b(fill|stroke)="currentColor"/g,`$1="${t}"`),It=(e,t)=>e.replace(/\bstroke-width="([0-9]*\.?[0-9]+)"/g,(n,r)=>`stroke-width="${Be(Number(r)*t)}"`),he=(e,t={})=>{var y;let{size:n=24,color:r,strokeScale:o,motion:s,label:c,className:u}=t,l=r&&kt.test(r)?r:void 0,p=typeof o=="number"&&Number.isFinite(o)&&o>0&&o!==1?o:void 0,f={...(y=e.attrs)!=null?y:{}};if(l)for(let b of["fill","stroke"])f[b]==="currentColor"&&(f[b]=l);p&&f["stroke-width"]&&(f["stroke-width"]=Be(Number(f["stroke-width"])*p));let d=e.body;return l&&(d=Et(d,l)),p&&(d=It(d,p)),f.width=String(n),f.height=String(n),f.viewBox=e.viewBox,s&&s!=="none"&&(f["data-motion"]=s),c?(f.role="img",f["aria-label"]=c):f["aria-hidden"]="true",u&&(f.class=u),{attrs:f,body:d}},be=({attrs:e,body:t})=>`<svg xmlns="http://www.w3.org/2000/svg" ${Object.entries(e).map(([r,o])=>`${r}="${St(o)}"`).join(" ")}>${t}</svg>`,Ge=(e,t={})=>{let n=typeof e=="string"?H(e):e;return n?be(he(n,t)):void 0};var R={draw:{label:"Draw on",hint:"Strokes draw themselves",duration:700,easing:"ease-in-out",draw:!0},fade:{label:"Fade in",hint:"From invisible to visible",duration:400,easing:"ease-out",frames:[{offset:0,opacity:0},{offset:1,opacity:1}]},pop:{label:"Pop in",hint:"Grows from nothing with a little overshoot",duration:450,easing:"spring",frames:[{offset:0,transform:"scale(0)"},{offset:1,transform:"scale(1)"}]},spin:{label:"Spin",hint:"One full turn",duration:800,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:1,transform:"rotate(360deg)"}]},"slide-up":{label:"Slide up",hint:"Rises into place",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateY(4px)",opacity:0},{offset:1,transform:"translateY(0px)",opacity:1}]},"slide-down":{label:"Slide down",hint:"Drops into place",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateY(-4px)",opacity:0},{offset:1,transform:"translateY(0px)",opacity:1}]},"slide-left":{label:"Slide left",hint:"Comes in from the right",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateX(4px)",opacity:0},{offset:1,transform:"translateX(0px)",opacity:1}]},"slide-right":{label:"Slide right",hint:"Comes in from the left",duration:450,easing:"ease-out",frames:[{offset:0,transform:"translateX(-4px)",opacity:0},{offset:1,transform:"translateX(0px)",opacity:1}]},bounce:{label:"Bounce",hint:"Hops up and lands",duration:700,easing:"ease-out",frames:[{offset:0,transform:"translateY(0px)"},{offset:.35,transform:"translateY(-4px)"},{offset:.65,transform:"translateY(0px)"},{offset:.82,transform:"translateY(-1.5px)"},{offset:1,transform:"translateY(0px)"}]},pulse:{label:"Pulse",hint:"Swells and settles",duration:600,easing:"ease-in-out",frames:[{offset:0,transform:"scale(1)"},{offset:.5,transform:"scale(1.18)"},{offset:1,transform:"scale(1)"}]},"spin-back":{label:"Spin back",hint:"One full turn, anticlockwise",duration:800,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:1,transform:"rotate(-360deg)"}]},"fade-out":{label:"Fade out",hint:"From visible to invisible",duration:400,easing:"ease-in",frames:[{offset:0,opacity:1},{offset:1,opacity:0}]},"pop-out":{label:"Pop out",hint:"Shrinks away to nothing",duration:350,easing:"ease-in",frames:[{offset:0,transform:"scale(1)"},{offset:1,transform:"scale(0)"}]},"slide-out-up":{label:"Slide out up",hint:"Rises and fades away",duration:400,easing:"ease-in",frames:[{offset:0,transform:"translateY(0px)",opacity:1},{offset:1,transform:"translateY(-4px)",opacity:0}]},"slide-out-down":{label:"Slide out down",hint:"Drops and fades away",duration:400,easing:"ease-in",frames:[{offset:0,transform:"translateY(0px)",opacity:1},{offset:1,transform:"translateY(4px)",opacity:0}]},follow:{label:"Move along path",hint:"The shape's centre travels along a route you drew",duration:1200,easing:"ease-in-out",route:!0},shake:{label:"Shake",hint:"A quick wobble",duration:600,easing:"ease-in-out",frames:[{offset:0,transform:"rotate(0deg)"},{offset:.2,transform:"rotate(-14deg)"},{offset:.4,transform:"rotate(12deg)"},{offset:.6,transform:"rotate(-8deg)"},{offset:.8,transform:"rotate(4deg)"},{offset:1,transform:"rotate(0deg)"}]}},Jt=Object.keys(R).filter(e=>!R[e].route),Tt=/^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s+-]{1,8000}$/,Ke={linear:{label:"Linear",css:"linear"},"ease-in":{label:"Ease in",css:"cubic-bezier(0.4, 0, 1, 1)"},"ease-out":{label:"Ease out",css:"cubic-bezier(0, 0, 0.2, 1)"},"ease-in-out":{label:"Ease in-out",css:"cubic-bezier(0.4, 0, 0.2, 1)"},spring:{label:"Spring",css:"cubic-bezier(0.34, 1.56, 0.64, 1)"}},Ot={load:"When it appears",hover:"On hover",click:"On click",toggle:"Click to toggle",visible:"When scrolled into view"},Pt=64,ye=1e4,Ue=50,Mt=new Set(Object.keys(R)),Fe=/^[A-Za-z0-9_-]{1,64}$/,xe=(e,t,n)=>typeof e=="number"&&Number.isFinite(e)?Math.round(Math.min(Math.max(e,t),n)):void 0,Rt=e=>{var r;if(!e||typeof e!="object")return;let t=e,n=[];for(let o of Array.isArray(t.clips)?t.clips.slice(0,Pt):[]){if(!o||typeof o!="object")continue;let s=xe(o.start,0,ye),c=xe(o.duration,Ue,ye);if(typeof o.id!="string"||!Fe.test(o.id)||typeof o.target!="string"||!Fe.test(o.target)||!Mt.has(o.preset)||s===void 0||c===void 0)continue;let u=R[o.preset].route;u&&(typeof o.path!="string"||!Tt.test(o.path)||!/^\s*[Mm]/.test(o.path))||n.push({id:o.id,target:o.target,preset:o.preset,start:s,duration:c,easing:o.easing&&o.easing in Ke?o.easing:R[o.preset].easing,...u?{path:o.path,orient:o.orient===!0}:{}})}if(n.length)return{version:1,trigger:t.trigger&&t.trigger in Ot?t.trigger:"load",loop:t.loop===!0,loopGap:(r=xe(t.loopGap,0,ye))!=null?r:0,...t.reverse===!0?{reverse:!0}:{},clips:n}},ke="data-ip-animation",Ye="data-ip";var $t=e=>atob(e.replace(/-/g,"+").replace(/_/g,"/"));var Ve=e=>{if(!(!e||e.length>6e4||!/^[A-Za-z0-9_-]+$/.test(e)))try{return Rt(JSON.parse($t(e)))}catch{return}},Nt=e=>e.clips.reduce((t,n)=>Math.max(t,n.start+n.duration),0),_t="path, line, rect, ellipse, circle, polyline, polygon",Dt=e=>[...e.querySelectorAll(_t)].filter(t=>{var r;if(t.closest("defs, clipPath, mask"))return!1;let n=(r=t.getAttribute("stroke"))!=null?r:getComputedStyle(t).stroke;return!!n&&n!=="none"&&n!=="transparent"&&typeof t.getTotalLength=="function"}),Ct="http://www.w3.org/2000/svg",we=48,Lt=(e,t,n)=>{var s;let r=(s=e.ownerSVGElement)!=null?s:e.closest("svg");if(!r||typeof e.getBBox!="function")return[];let o=document.createElementNS(Ct,"path");o.setAttribute("d",t),o.setAttribute("visibility","hidden"),r.appendChild(o);try{let c=o.getTotalLength(),u=e.getBBox(),l=u.x+u.width/2,p=u.y+u.height/2,f=x=>o.getPointAtLength(Math.min(Math.max(x,0),c)),d=x=>{let i=Math.max(c/400,.01),a=f(x-i),m=f(x+i);return Math.atan2(m.y-a.y,m.x-a.x)*180/Math.PI},y=d(0),b=0;return Array.from({length:we+1},(x,i)=>{let a=i/we*c,m=f(a),g=d(a)-y;for(;g-b>180;)g-=360;for(;g-b<-180;)g+=360;b=g;let w=`translate(${(m.x-l).toFixed(3)}px, ${(m.y-p).toFixed(3)}px)`;return{offset:i/we,transform:n?`${w} rotate(${g.toFixed(2)}deg)`:w}})}finally{o.remove()}},ze=(e,t,n,r,o=0)=>{let s=(t.start+o)/n,c=(t.start+o+t.duration)/n,u=Ke[t.easing].css,l=e.map((y,b)=>({...y,offset:s+y.offset*(c-s),easing:b<e.length-1?u:"linear"})),p={...r!=null?r:e[0],offset:0,easing:"linear"},f={...e[e.length-1],offset:1,easing:"linear"},d=[];return l[0].offset>0&&(d.push(p),r&&d.push({...r,offset:l[0].offset,easing:"linear"})),d.push(...l),l[l.length-1].offset<1&&d.push(f),d},qe=(e,t,n={})=>{var y,b,x;let r=Math.max(Nt(e),Ue),o=(y=n.loop)!=null?y:e.loop,s=o?r+e.loopGap:r,c=o&&e.reverse===!0,u=c?e.loopGap/2:0,l=[],p={duration:s,iterations:o?1/0:1,fill:"both",direction:c?"alternate":"normal"};for(let i of e.clips){let a=R[i.preset],m=e.clips.some(g=>g.target===i.target&&g.start<i.start);for(let g of t(i.target)){if(a.draw){for(let k of Dt(g)){let A=Math.max(k.getTotalLength(),.01),tt=[{offset:0,strokeDasharray:`${A} ${A}`,strokeDashoffset:A},{offset:1,strokeDasharray:`${A} ${A}`,strokeDashoffset:0}],nt=m?{offset:0,strokeDasharray:`${A} ${A}`,strokeDashoffset:0}:void 0;l.push(k.animate(ze(tt,i,s,nt,u),p))}continue}let w=g;w.style.transformBox="fill-box",w.style.transformOrigin="center";let F=a.route?Lt(g,(b=i.path)!=null?b:"",i.orient===!0):((x=a.frames)!=null?x:[]).map(k=>({...k}));if(!F.length)continue;let Se=F.some(k=>k.transform!==void 0),Qe=F.some(k=>k.opacity!==void 0),et=m?{offset:0,...Se?{transform:"translate(0px, 0px)"}:{},...Qe?{opacity:1}:{}}:void 0;l.push(w.animate(ze(F,i,s,et,u),{...p,composite:Se?"add":"replace"}))}}let f=i=>l.forEach(i),d=i=>{if(!o)return Math.min(i,r);let a=Math.floor(i/s),m=i-a*s,g=c&&a%2===1?s-m:m;return Math.min(r,Math.max(0,g-u))};return n.paused&&f(i=>i.pause()),{play:()=>f(i=>i.play()),pause:()=>f(i=>i.pause()),reverse:i=>{var g;let a=l[0];if(!a)return i==null?void 0:i();let m=d(Number((g=a.currentTime)!=null?g:0))+u;if(m<=1)return i==null?void 0:i();try{f(w=>{w.currentTime=m,w.playbackRate=-1,w.play()})}catch{return i==null?void 0:i()}a.onfinish=()=>{a.onfinish=null,i==null||i()}},forward:()=>{l[0]&&(l[0].onfinish=null),f(i=>i.playbackRate=1),f(i=>i.play())},seek:i=>f(a=>a.currentTime=Math.max(0,i+u)),cancel:()=>f(i=>i.cancel()),period:s,animations:l,clock:d}};var X=new WeakMap,jt=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,ve=e=>{var t,n;return(n=(t=e.closest("a, button, [role=button], label, summary"))!=null?t:e.parentElement)!=null?n:e},W=(e,t={})=>{var b,x,i;(b=X.get(e))==null||b();let n=Ve(e.getAttribute(ke));if(!n||typeof e.animate!="function")return()=>{};if((x=t.reducedMotion)!=null?x:jt())return()=>{};let r=(i=t.trigger)!=null?i:n.trigger,o=a=>[...e.querySelectorAll(`[${Ye}="${a}"]`)],s,c=[],u=()=>{s==null||s.cancel(),s=void 0},l=()=>{u(),s=qe(n,o)};r==="load"&&l();let p=!1,f=()=>{if(s&&p){p=!1,s.forward();return}s||l()},d=()=>{s&&(p=!0,s.reverse(()=>{p&&(p=!1,u())}))};if(r==="hover"){let a=ve(e);a.addEventListener("pointerenter",f),a.addEventListener("pointerleave",d),a.addEventListener("focusin",f),a.addEventListener("focusout",d),c.push(()=>{a.removeEventListener("pointerenter",f),a.removeEventListener("pointerleave",d),a.removeEventListener("focusin",f),a.removeEventListener("focusout",d)})}if(r==="toggle"){let a=ve(e),m=!1,g=()=>{m=!m,m?f():d()};a.addEventListener("click",g),c.push(()=>a.removeEventListener("click",g))}if(r==="click"){let a=ve(e);a.addEventListener("click",l),c.push(()=>a.removeEventListener("click",l))}if(r==="visible")if(typeof IntersectionObserver=="function"){let a=new IntersectionObserver(m=>{m.some(g=>g.isIntersecting)&&(a.disconnect(),l())},{threshold:.5});a.observe(e),c.push(()=>a.disconnect())}else l();let y=()=>{u(),c.forEach(a=>a()),X.delete(e)};return X.set(e,y),y},Je=(e=document)=>{e.querySelectorAll(`svg[${ke}]`).forEach(t=>{X.has(t)||W(t)})};var He="[data-icon], i.ip[class*='ip-']",Bt=new Set(["none","wiggle","pop","bounce","draw"]),Xe=new Set,Gt=e=>{let t=e.getAttribute("data-icon");if(t)return t;for(let n of Array.from(e.classList))if(n.startsWith("ip-")&&n.length>3)return n.slice(3)},We=e=>{if(e===null)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0},Ae=e=>{var l,p,f,d;let t=Gt(e);if(!t)return;let n=H(t),r=e.getAttribute("data-motion"),o=r&&Bt.has(r)?r:void 0,s={size:(l=We(e.getAttribute("data-size")))!=null?l:24,color:(p=e.getAttribute("data-color"))!=null?p:void 0,strokeScale:We(e.getAttribute("data-stroke")),motion:o,label:(f=e.getAttribute("data-label"))!=null?f:void 0},c=JSON.stringify([t,s,n?"1":"0"]);if(e.getAttribute("data-ip-rendered")===c)return;if(!n){je(t)?Xe.has(t)||(Xe.add(t),console.warn(`iconplease: no icon named "${t}".`)):ge(t);return}e.innerHTML=be(he(n,s)),e.setAttribute("data-ip-rendered",c);let u=e.querySelector("svg");u&&W(u),e.tagName==="I"&&((d=e.style).display||(d.display="inline-flex"))},Z=(e=document)=>{e instanceof Element&&e.matches(He)&&Ae(e),e.querySelectorAll(He).forEach(Ae)},Ze=()=>{let e=window.iconpleaseConfig;e&&Q(e),Le(()=>Z()),Z(),me(),new MutationObserver(t=>{for(let n of t)n.type==="attributes"&&n.target instanceof Element&&Ae(n.target),n.addedNodes.forEach(r=>{r instanceof Element&&Z(r)})}).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-icon","data-size","data-color","data-stroke","data-motion","data-label","class"]})};window.iconplease={init:Q,load:me,renderSVG:Ge,attachAnimation:W,attachAll:Je,refresh:()=>Z()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ze,{once:!0}):Ze();})();
|
package/dist/player.js
CHANGED
|
@@ -23,19 +23,53 @@ export const attachAnimation = (svg, options = {}) => {
|
|
|
23
23
|
};
|
|
24
24
|
if (trigger === "load")
|
|
25
25
|
start();
|
|
26
|
+
let backwards = false;
|
|
27
|
+
const enter = () => {
|
|
28
|
+
if (playback && backwards) {
|
|
29
|
+
backwards = false;
|
|
30
|
+
playback.forward();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!playback)
|
|
34
|
+
start();
|
|
35
|
+
};
|
|
36
|
+
const leave = () => {
|
|
37
|
+
if (!playback)
|
|
38
|
+
return;
|
|
39
|
+
backwards = true;
|
|
40
|
+
playback.reverse(() => {
|
|
41
|
+
if (!backwards)
|
|
42
|
+
return;
|
|
43
|
+
backwards = false;
|
|
44
|
+
stop();
|
|
45
|
+
});
|
|
46
|
+
};
|
|
26
47
|
if (trigger === "hover") {
|
|
27
48
|
const host = hoverHost(svg);
|
|
28
|
-
host.addEventListener("pointerenter",
|
|
29
|
-
host.addEventListener("pointerleave",
|
|
30
|
-
host.addEventListener("focusin",
|
|
31
|
-
host.addEventListener("focusout",
|
|
49
|
+
host.addEventListener("pointerenter", enter);
|
|
50
|
+
host.addEventListener("pointerleave", leave);
|
|
51
|
+
host.addEventListener("focusin", enter);
|
|
52
|
+
host.addEventListener("focusout", leave);
|
|
32
53
|
cleanups.push(() => {
|
|
33
|
-
host.removeEventListener("pointerenter",
|
|
34
|
-
host.removeEventListener("pointerleave",
|
|
35
|
-
host.removeEventListener("focusin",
|
|
36
|
-
host.removeEventListener("focusout",
|
|
54
|
+
host.removeEventListener("pointerenter", enter);
|
|
55
|
+
host.removeEventListener("pointerleave", leave);
|
|
56
|
+
host.removeEventListener("focusin", enter);
|
|
57
|
+
host.removeEventListener("focusout", leave);
|
|
37
58
|
});
|
|
38
59
|
}
|
|
60
|
+
if (trigger === "toggle") {
|
|
61
|
+
const host = hoverHost(svg);
|
|
62
|
+
let on = false;
|
|
63
|
+
const flip = () => {
|
|
64
|
+
on = !on;
|
|
65
|
+
if (on)
|
|
66
|
+
enter();
|
|
67
|
+
else
|
|
68
|
+
leave();
|
|
69
|
+
};
|
|
70
|
+
host.addEventListener("click", flip);
|
|
71
|
+
cleanups.push(() => host.removeEventListener("click", flip));
|
|
72
|
+
}
|
|
39
73
|
if (trigger === "click") {
|
|
40
74
|
const host = hoverHost(svg);
|
|
41
75
|
host.addEventListener("click", start);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iconplease",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Icons you can draw yourself. Pages load only the icons they show from the iconplease CDN; private sets via a key, a token or a build-time file.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"icons",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"icon-library"
|
|
11
11
|
],
|
|
12
12
|
"homepage": "https://iconplease.com",
|
|
13
|
-
"
|
|
13
|
+
"author": "TECHNOLOGYPLEASE Co., Ltd.",
|
|
14
|
+
"license": "MIT",
|
|
14
15
|
"type": "module",
|
|
15
16
|
"sideEffects": [
|
|
16
17
|
"*.css"
|
|
@@ -35,7 +36,9 @@
|
|
|
35
36
|
"files": [
|
|
36
37
|
"dist",
|
|
37
38
|
"bin",
|
|
38
|
-
"README.md"
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"ICONS-LICENSE.md"
|
|
39
42
|
],
|
|
40
43
|
"engines": {
|
|
41
44
|
"node": ">=18"
|
|
@@ -64,6 +67,6 @@
|
|
|
64
67
|
"typescript": "^5.8.3"
|
|
65
68
|
},
|
|
66
69
|
"bin": {
|
|
67
|
-
"iconplease": "
|
|
70
|
+
"iconplease": "bin/iconplease.mjs"
|
|
68
71
|
}
|
|
69
72
|
}
|