iconplease 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation.d.ts +64 -0
- package/dist/animation.js +243 -0
- package/dist/iconplease.min.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/player.d.ts +7 -0
- package/dist/player.js +72 -0
- package/dist/react.js +11 -2
- package/dist/script.js +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type AnimationPreset = "draw" | "fade" | "pop" | "spin" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "bounce" | "pulse" | "shake" | "follow";
|
|
2
|
+
export type AnimationEasing = "linear" | "ease-in" | "ease-out" | "ease-in-out" | "spring";
|
|
3
|
+
export type AnimationTrigger = "load" | "hover" | "click" | "visible";
|
|
4
|
+
export type AnimationClip = {
|
|
5
|
+
id: string;
|
|
6
|
+
target: string;
|
|
7
|
+
preset: AnimationPreset;
|
|
8
|
+
start: number;
|
|
9
|
+
duration: number;
|
|
10
|
+
easing: AnimationEasing;
|
|
11
|
+
path?: string;
|
|
12
|
+
orient?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type IconAnimation = {
|
|
15
|
+
version: 1;
|
|
16
|
+
trigger: AnimationTrigger;
|
|
17
|
+
loop: boolean;
|
|
18
|
+
loopGap: number;
|
|
19
|
+
clips: AnimationClip[];
|
|
20
|
+
};
|
|
21
|
+
type Frame = {
|
|
22
|
+
offset: number;
|
|
23
|
+
transform?: string;
|
|
24
|
+
opacity?: number;
|
|
25
|
+
};
|
|
26
|
+
type PresetSpec = {
|
|
27
|
+
label: string;
|
|
28
|
+
hint: string;
|
|
29
|
+
duration: number;
|
|
30
|
+
easing: AnimationEasing;
|
|
31
|
+
frames?: Frame[];
|
|
32
|
+
draw?: boolean;
|
|
33
|
+
route?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export declare const PRESETS: Record<AnimationPreset, PresetSpec>;
|
|
36
|
+
export declare const PRESET_ORDER: AnimationPreset[];
|
|
37
|
+
export declare const ROUTE_PATH: RegExp;
|
|
38
|
+
export declare const EASINGS: Record<AnimationEasing, {
|
|
39
|
+
label: string;
|
|
40
|
+
css: string;
|
|
41
|
+
}>;
|
|
42
|
+
export declare const TRIGGERS: Record<AnimationTrigger, string>;
|
|
43
|
+
export declare const MAX_CLIPS = 64;
|
|
44
|
+
export declare const MAX_TIME = 10000;
|
|
45
|
+
export declare const MIN_DURATION = 50;
|
|
46
|
+
export declare const cleanAnimation: (value: unknown) => IconAnimation | undefined;
|
|
47
|
+
export declare const ANIMATION_ATTRIBUTE = "data-ip-animation";
|
|
48
|
+
export declare const MARKER_ATTRIBUTE = "data-ip";
|
|
49
|
+
export declare const encodeAnimation: (animation: IconAnimation) => string;
|
|
50
|
+
export declare const decodeAnimation: (value: string | undefined | null) => IconAnimation | undefined;
|
|
51
|
+
export declare const totalDuration: (animation: Pick<IconAnimation, "clips">) => number;
|
|
52
|
+
export type Playback = {
|
|
53
|
+
play: () => void;
|
|
54
|
+
pause: () => void;
|
|
55
|
+
seek: (time: number) => void;
|
|
56
|
+
cancel: () => void;
|
|
57
|
+
readonly period: number;
|
|
58
|
+
readonly animations: Animation[];
|
|
59
|
+
};
|
|
60
|
+
export declare const animate: (animation: IconAnimation, targetsOf: (target: string) => Element[], options?: {
|
|
61
|
+
paused?: boolean;
|
|
62
|
+
loop?: boolean;
|
|
63
|
+
}) => Playback;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
export const PRESETS = {
|
|
2
|
+
draw: { label: "Draw on", hint: "Strokes draw themselves", duration: 700, easing: "ease-in-out", draw: true },
|
|
3
|
+
fade: { label: "Fade in", hint: "From invisible to visible", duration: 400, easing: "ease-out", frames: [{ offset: 0, opacity: 0 }, { offset: 1, opacity: 1 }] },
|
|
4
|
+
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)" }] },
|
|
5
|
+
spin: { label: "Spin", hint: "One full turn", duration: 800, easing: "ease-in-out", frames: [{ offset: 0, transform: "rotate(0deg)" }, { offset: 1, transform: "rotate(360deg)" }] },
|
|
6
|
+
"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 }] },
|
|
7
|
+
"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 }] },
|
|
8
|
+
"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 }] },
|
|
9
|
+
"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 }] },
|
|
10
|
+
bounce: {
|
|
11
|
+
label: "Bounce",
|
|
12
|
+
hint: "Hops up and lands",
|
|
13
|
+
duration: 700,
|
|
14
|
+
easing: "ease-out",
|
|
15
|
+
frames: [
|
|
16
|
+
{ offset: 0, transform: "translateY(0px)" },
|
|
17
|
+
{ offset: 0.35, transform: "translateY(-4px)" },
|
|
18
|
+
{ offset: 0.65, transform: "translateY(0px)" },
|
|
19
|
+
{ offset: 0.82, transform: "translateY(-1.5px)" },
|
|
20
|
+
{ offset: 1, transform: "translateY(0px)" },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
pulse: {
|
|
24
|
+
label: "Pulse",
|
|
25
|
+
hint: "Swells and settles",
|
|
26
|
+
duration: 600,
|
|
27
|
+
easing: "ease-in-out",
|
|
28
|
+
frames: [
|
|
29
|
+
{ offset: 0, transform: "scale(1)" },
|
|
30
|
+
{ offset: 0.5, transform: "scale(1.18)" },
|
|
31
|
+
{ offset: 1, transform: "scale(1)" },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
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
|
+
shake: {
|
|
36
|
+
label: "Shake",
|
|
37
|
+
hint: "A quick wobble",
|
|
38
|
+
duration: 600,
|
|
39
|
+
easing: "ease-in-out",
|
|
40
|
+
frames: [
|
|
41
|
+
{ offset: 0, transform: "rotate(0deg)" },
|
|
42
|
+
{ offset: 0.2, transform: "rotate(-14deg)" },
|
|
43
|
+
{ offset: 0.4, transform: "rotate(12deg)" },
|
|
44
|
+
{ offset: 0.6, transform: "rotate(-8deg)" },
|
|
45
|
+
{ offset: 0.8, transform: "rotate(4deg)" },
|
|
46
|
+
{ offset: 1, transform: "rotate(0deg)" },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export const PRESET_ORDER = Object.keys(PRESETS).filter((preset) => !PRESETS[preset].route);
|
|
51
|
+
export const ROUTE_PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s+-]{1,8000}$/;
|
|
52
|
+
export const EASINGS = {
|
|
53
|
+
linear: { label: "Linear", css: "linear" },
|
|
54
|
+
"ease-in": { label: "Ease in", css: "cubic-bezier(0.4, 0, 1, 1)" },
|
|
55
|
+
"ease-out": { label: "Ease out", css: "cubic-bezier(0, 0, 0.2, 1)" },
|
|
56
|
+
"ease-in-out": { label: "Ease in-out", css: "cubic-bezier(0.4, 0, 0.2, 1)" },
|
|
57
|
+
spring: { label: "Spring", css: "cubic-bezier(0.34, 1.56, 0.64, 1)" },
|
|
58
|
+
};
|
|
59
|
+
export const TRIGGERS = {
|
|
60
|
+
load: "When it appears",
|
|
61
|
+
hover: "On hover",
|
|
62
|
+
click: "On click",
|
|
63
|
+
visible: "When scrolled into view",
|
|
64
|
+
};
|
|
65
|
+
export const MAX_CLIPS = 64;
|
|
66
|
+
export const MAX_TIME = 10000;
|
|
67
|
+
export const MIN_DURATION = 50;
|
|
68
|
+
const PRESET_SET = new Set(PRESET_ORDER);
|
|
69
|
+
const ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
70
|
+
const ms = (value, low, high) => typeof value === "number" && Number.isFinite(value) ? Math.round(Math.min(Math.max(value, low), high)) : undefined;
|
|
71
|
+
export const cleanAnimation = (value) => {
|
|
72
|
+
if (!value || typeof value !== "object")
|
|
73
|
+
return undefined;
|
|
74
|
+
const raw = value;
|
|
75
|
+
const clips = [];
|
|
76
|
+
for (const clip of Array.isArray(raw.clips) ? raw.clips.slice(0, MAX_CLIPS) : []) {
|
|
77
|
+
if (!clip || typeof clip !== "object")
|
|
78
|
+
continue;
|
|
79
|
+
const start = ms(clip.start, 0, MAX_TIME);
|
|
80
|
+
const duration = ms(clip.duration, MIN_DURATION, MAX_TIME);
|
|
81
|
+
if (typeof clip.id !== "string" || !ID.test(clip.id))
|
|
82
|
+
continue;
|
|
83
|
+
if (typeof clip.target !== "string" || !ID.test(clip.target))
|
|
84
|
+
continue;
|
|
85
|
+
if (!PRESET_SET.has(clip.preset) || start === undefined || duration === undefined)
|
|
86
|
+
continue;
|
|
87
|
+
const route = PRESETS[clip.preset].route;
|
|
88
|
+
if (route && (typeof clip.path !== "string" || !ROUTE_PATH.test(clip.path) || !/^\s*[Mm]/.test(clip.path)))
|
|
89
|
+
continue;
|
|
90
|
+
clips.push({
|
|
91
|
+
id: clip.id,
|
|
92
|
+
target: clip.target,
|
|
93
|
+
preset: clip.preset,
|
|
94
|
+
start,
|
|
95
|
+
duration,
|
|
96
|
+
easing: clip.easing && clip.easing in EASINGS ? clip.easing : PRESETS[clip.preset].easing,
|
|
97
|
+
...(route ? { path: clip.path, orient: clip.orient === true } : {}),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (!clips.length)
|
|
101
|
+
return undefined;
|
|
102
|
+
return {
|
|
103
|
+
version: 1,
|
|
104
|
+
trigger: raw.trigger && raw.trigger in TRIGGERS ? raw.trigger : "load",
|
|
105
|
+
loop: raw.loop === true,
|
|
106
|
+
loopGap: ms(raw.loopGap, 0, MAX_TIME) ?? 0,
|
|
107
|
+
clips,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export const ANIMATION_ATTRIBUTE = "data-ip-animation";
|
|
111
|
+
export const MARKER_ATTRIBUTE = "data-ip";
|
|
112
|
+
const toBase64Url = (text) => btoa(text).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
113
|
+
const fromBase64Url = (value) => atob(value.replace(/-/g, "+").replace(/_/g, "/"));
|
|
114
|
+
export const encodeAnimation = (animation) => toBase64Url(JSON.stringify(animation));
|
|
115
|
+
export const decodeAnimation = (value) => {
|
|
116
|
+
if (!value || value.length > 60000 || !/^[A-Za-z0-9_-]+$/.test(value))
|
|
117
|
+
return undefined;
|
|
118
|
+
try {
|
|
119
|
+
return cleanAnimation(JSON.parse(fromBase64Url(value)));
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
export const totalDuration = (animation) => animation.clips.reduce((end, clip) => Math.max(end, clip.start + clip.duration), 0);
|
|
126
|
+
const GEOMETRY = "path, line, rect, ellipse, circle, polyline, polygon";
|
|
127
|
+
const strokesOf = (root) => [...root.querySelectorAll(GEOMETRY)].filter((node) => {
|
|
128
|
+
if (node.closest("defs, clipPath, mask"))
|
|
129
|
+
return false;
|
|
130
|
+
const stroke = node.getAttribute("stroke") ?? getComputedStyle(node).stroke;
|
|
131
|
+
return Boolean(stroke) && stroke !== "none" && stroke !== "transparent" && typeof node.getTotalLength === "function";
|
|
132
|
+
});
|
|
133
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
134
|
+
const ROUTE_SAMPLES = 48;
|
|
135
|
+
const routeFrames = (root, d, orient) => {
|
|
136
|
+
const host = root.ownerSVGElement ?? root.closest("svg");
|
|
137
|
+
if (!host || typeof root.getBBox !== "function")
|
|
138
|
+
return [];
|
|
139
|
+
const guide = document.createElementNS(SVG_NS, "path");
|
|
140
|
+
guide.setAttribute("d", d);
|
|
141
|
+
guide.setAttribute("visibility", "hidden");
|
|
142
|
+
host.appendChild(guide);
|
|
143
|
+
try {
|
|
144
|
+
const length = guide.getTotalLength();
|
|
145
|
+
const box = root.getBBox();
|
|
146
|
+
const cx = box.x + box.width / 2;
|
|
147
|
+
const cy = box.y + box.height / 2;
|
|
148
|
+
const at = (distance) => guide.getPointAtLength(Math.min(Math.max(distance, 0), length));
|
|
149
|
+
const angle = (distance) => {
|
|
150
|
+
const step = Math.max(length / 400, 0.01);
|
|
151
|
+
const a = at(distance - step);
|
|
152
|
+
const b = at(distance + step);
|
|
153
|
+
return (Math.atan2(b.y - a.y, b.x - a.x) * 180) / Math.PI;
|
|
154
|
+
};
|
|
155
|
+
const first = angle(0);
|
|
156
|
+
let previous = 0;
|
|
157
|
+
return Array.from({ length: ROUTE_SAMPLES + 1 }, (_, index) => {
|
|
158
|
+
const distance = (index / ROUTE_SAMPLES) * length;
|
|
159
|
+
const point = at(distance);
|
|
160
|
+
let turn = angle(distance) - first;
|
|
161
|
+
while (turn - previous > 180)
|
|
162
|
+
turn -= 360;
|
|
163
|
+
while (turn - previous < -180)
|
|
164
|
+
turn += 360;
|
|
165
|
+
previous = turn;
|
|
166
|
+
const move = `translate(${(point.x - cx).toFixed(3)}px, ${(point.y - cy).toFixed(3)}px)`;
|
|
167
|
+
return { offset: index / ROUTE_SAMPLES, transform: orient ? `${move} rotate(${turn.toFixed(2)}deg)` : move };
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
guide.remove();
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const onTimeline = (frames, clip, period, neutral) => {
|
|
175
|
+
const begin = clip.start / period;
|
|
176
|
+
const end = (clip.start + clip.duration) / period;
|
|
177
|
+
const easing = EASINGS[clip.easing].css;
|
|
178
|
+
const placed = frames.map((frame, index) => ({
|
|
179
|
+
...frame,
|
|
180
|
+
offset: begin + frame.offset * (end - begin),
|
|
181
|
+
easing: index < frames.length - 1 ? easing : "linear",
|
|
182
|
+
}));
|
|
183
|
+
const first = { ...(neutral ?? frames[0]), offset: 0, easing: "linear" };
|
|
184
|
+
const last = { ...frames[frames.length - 1], offset: 1, easing: "linear" };
|
|
185
|
+
const out = [];
|
|
186
|
+
if (placed[0].offset > 0) {
|
|
187
|
+
out.push(first);
|
|
188
|
+
if (neutral)
|
|
189
|
+
out.push({ ...neutral, offset: placed[0].offset, easing: "linear" });
|
|
190
|
+
}
|
|
191
|
+
out.push(...placed);
|
|
192
|
+
if (placed[placed.length - 1].offset < 1)
|
|
193
|
+
out.push(last);
|
|
194
|
+
return out;
|
|
195
|
+
};
|
|
196
|
+
export const animate = (animation, targetsOf, options = {}) => {
|
|
197
|
+
const total = Math.max(totalDuration(animation), MIN_DURATION);
|
|
198
|
+
const loop = options.loop ?? animation.loop;
|
|
199
|
+
const period = loop ? total + animation.loopGap : total;
|
|
200
|
+
const animations = [];
|
|
201
|
+
const timing = { duration: period, iterations: loop ? Infinity : 1, fill: "both" };
|
|
202
|
+
for (const clip of animation.clips) {
|
|
203
|
+
const spec = PRESETS[clip.preset];
|
|
204
|
+
const follows = animation.clips.some((other) => other.target === clip.target && other.start < clip.start);
|
|
205
|
+
for (const root of targetsOf(clip.target)) {
|
|
206
|
+
if (spec.draw) {
|
|
207
|
+
for (const stroke of strokesOf(root)) {
|
|
208
|
+
const length = Math.max(stroke.getTotalLength(), 0.01);
|
|
209
|
+
const frames = [
|
|
210
|
+
{ offset: 0, strokeDasharray: `${length} ${length}`, strokeDashoffset: length },
|
|
211
|
+
{ offset: 1, strokeDasharray: `${length} ${length}`, strokeDashoffset: 0 },
|
|
212
|
+
];
|
|
213
|
+
const shown = follows ? { offset: 0, strokeDasharray: `${length} ${length}`, strokeDashoffset: 0 } : undefined;
|
|
214
|
+
animations.push(stroke.animate(onTimeline(frames, clip, period, shown), timing));
|
|
215
|
+
}
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
const element = root;
|
|
219
|
+
element.style.transformBox = "fill-box";
|
|
220
|
+
element.style.transformOrigin = "center";
|
|
221
|
+
const frames = spec.route ? routeFrames(root, clip.path ?? "", clip.orient === true) : (spec.frames ?? []).map((frame) => ({ ...frame }));
|
|
222
|
+
if (!frames.length)
|
|
223
|
+
continue;
|
|
224
|
+
const moves = frames.some((frame) => frame.transform !== undefined);
|
|
225
|
+
const fades = frames.some((frame) => frame.opacity !== undefined);
|
|
226
|
+
const shown = follows
|
|
227
|
+
? { offset: 0, ...(moves ? { transform: "translate(0px, 0px)" } : {}), ...(fades ? { opacity: 1 } : {}) }
|
|
228
|
+
: undefined;
|
|
229
|
+
animations.push(element.animate(onTimeline(frames, clip, period, shown), { ...timing, composite: moves ? "add" : "replace" }));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const each = (fn) => animations.forEach(fn);
|
|
233
|
+
if (options.paused)
|
|
234
|
+
each((item) => item.pause());
|
|
235
|
+
return {
|
|
236
|
+
play: () => each((item) => item.play()),
|
|
237
|
+
pause: () => each((item) => item.pause()),
|
|
238
|
+
seek: (time) => each((item) => (item.currentTime = Math.max(0, time))),
|
|
239
|
+
cancel: () => each((item) => item.cancel()),
|
|
240
|
+
period,
|
|
241
|
+
animations,
|
|
242
|
+
};
|
|
243
|
+
};
|
package/dist/iconplease.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var v={cdnUrl:"https://cdn.iconplease.com",apiUrl:"https://api.iconplease.com",revalidate:3600},l={...v},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 l={...v,...e},l};var L=()=>{var e;return((e=l.cdnUrl)!=null?e:v.cdnUrl).replace(/\/+$/,"")},K=()=>{var e;return Math.max(0,(e=l.revalidate)!=null?e:v.revalidate)*1e3},U=()=>{var e;return((e=l.apiUrl)!=null?e:v.apiUrl).replace(/\/+$/,"")},F=()=>l.apiKey||void 0,x=()=>l.token,ce=()=>l.set;var Oe=/<\s*(script|foreignObject|iframe|object|embed|style)\b[\s\S]*?(<\s*\/\s*\1\s*>|\/>)/gi,Ne=/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,$e=/\s+(?:xlink:)?href\s*=\s*("\s*javascript:[^"]*"|'\s*javascript:[^']*')/gi,Pe=/^[a-z][a-z0-9-]*$/,De=/^[^"<>]*$/,je=e=>e.replace(Oe,"").replace(Ne,"").replace($e,""),J=e=>{var o;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[r,s]of Object.entries((o=t.attrs)!=null?o:{}))Pe.test(r)&&!r.startsWith("on")&&typeof s=="string"&&De.test(s)&&(n[r]=s);return{viewBox:t.viewBox,attrs:n,body:je(t.body)}};var pe="iconplease:index:v2",ge="iconplease:icons:v2",me="iconplease:set:v1",Ce=1e3,O=/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/,c={status:"idle",revision:0},T=0,P,ae=!1,de=!1,q,y=new Map,h=new Map,H,E=0,b=!1,I,G=!1,V=new Map,w=null,W=0,_e=6e4,A,j=null,Y=new Map,C=new Map,Te=()=>{let e=ce();if(e!==A&&(A=e,Y.clear(),C.clear(),j=null,!(!e||e.format!==1||typeof e.icons!="object"))){j=typeof e.version=="number"?e.version:null;for(let[t,n]of Object.entries(e.icons)){if(!O.test(t)||typeof(n==null?void 0:n.svg)!="string")continue;let o=M(n.svg);o&&(n.source==="public"?C:Y).set(t,o)}}},Me=()=>w!==null&&(j===null||w>j),m=e=>{var t,n;return A?Me()?(t=h.get(e))!=null?t:C.get(e):(n=Y.get(e))!=null?n:C.get(e):h.get(e)};var X=new Set,N=()=>{try{return typeof localStorage=="undefined"?void 0:localStorage}catch{return}},p=(e={})=>{c={...c,...e,revision:c.revision+1};for(let t of X)t()},_=(e,t)=>`${e}@${t}`,ye=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(([o,r])=>O.test(o)&&Number.isInteger(r)&&r>0);return{format:2,hash:t.hash,icons:Object.fromEntries(n)}},Re=e=>e.slice(0,14),$=()=>{if(x())return"token";let e=F();return e?Re(e):void 0},Be=6e4,ze=9*6e4,D,S,Le=(e=!1)=>{let t=x();return t?!e&&D&&D.expiresAt-Be>Date.now()?Promise.resolve(D.token):S||(S=t().then(n=>{let o=typeof n=="string"?n:n==null?void 0:n.token;if(typeof o!="string"||!o.startsWith("ipt_"))throw new Error("your token function did not return an iconplease token (ipt_\u2026).");let r=typeof n=="string"?void 0:n.expiresAt,s=typeof r=="number"?r:r?Date.parse(r):NaN;return D={token:o,expiresAt:Number.isFinite(s)?s:Date.now()+ze},o}).finally(()=>{S=void 0}),S):Promise.reject(new Error("no token source"))},Ke=()=>{var t,n,o;let e=$();if(e!==H&&(H=e,h.clear(),E=0,b=!1,I=void 0,G=!1,w=null,W=0,!!e))try{if(e==="token")return;let r=JSON.parse((n=(t=N())==null?void 0:t.getItem(me))!=null?n:"null");if(!r||r.tag!==e)return;for(let[s,i]of Object.entries((o=r.icons)!=null?o:{})){let u=O.test(s)&&typeof(i==null?void 0:i.svg)=="string"?M(i.svg):void 0;u&&h.set(s,u)}E=typeof r.checkedAt=="number"?r.checkedAt:0,w=typeof r.version=="number"?r.version:null,b=!0}catch{return}},g=()=>{var t,n;if(Te(),Ke(),ae)return;ae=!0;let e=N();if(e){try{let o=JSON.parse((t=e.getItem(pe))!=null?t:"null"),r=ye(o==null?void 0:o.index);r&&(c={status:"ready",index:r,revision:c.revision},T=typeof(o==null?void 0:o.checkedAt)=="number"?o.checkedAt:0)}catch{return}try{let o=JSON.parse((n=e.getItem(ge))!=null?n:"{}");for(let[r,s]of Object.entries(o)){let i=J(s);i&&y.set(r,i)}}catch{return}}},ue=()=>{var e;try{(e=N())==null||e.setItem(pe,JSON.stringify({index:c.index,checkedAt:T}))}catch{return}},he=()=>{q||(q=setTimeout(()=>{var n,o,r;q=void 0;let e=(o=(n=c.index)==null?void 0:n.icons)!=null?o:{},t=[...y.entries()].filter(([s])=>{let i=s.lastIndexOf("@");return e[s.slice(0,i)]===Number(s.slice(i+1))});try{(r=N())==null||r.setItem(ge,JSON.stringify(Object.fromEntries(t.slice(-Ce))))}catch{return}},0))},fe=async e=>{let t=await fetch(e);if(!t.ok)throw new Error(`${t.status} for ${e}`);return t.json()},be=e=>{de||(de=!0,console.warn("iconplease: could not reach the icon CDN.",e))},Ue=async()=>{var r;let e=L(),t=await fe(`${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(T=Date.now(),((r=c.index)==null?void 0:r.hash)===t.hash){ue();return}let n=t.index.replace(/^\/+/,"");if(!/^catalogue\/index-[a-z0-9]+\.json$/.test(n))throw new Error("iconplease: unexpected index location");let o=ye(await fe(`${e}/${n}`));if(!o)throw new Error("iconplease: the icon index is malformed");p({status:"ready",index:o}),ue(),he()},Z=(e={})=>{if(g(),c.index&&Date.now()-T<K()&&!e.force)return Promise.resolve();if(P)return P;let n=Ue().catch(o=>{c.index||p({status:"error"}),be(o)}).finally(()=>{P=void 0});return P=n,!c.index&&c.status!=="loading"&&p({status:"loading"}),n},M=e=>{let t=/<svg\b([^>]*)>([\s\S]*)<\/svg>\s*$/.exec(e.trim());if(!t)return;let n={},o="0 0 24 24";for(let[,r,s]of t[1].matchAll(/([a-zA-Z:-]+)="([^"]*)"/g))r==="viewBox"?o=s:["xmlns","width","height","aria-hidden","role","class","style"].includes(r)||(n[r]=s);return J({viewBox:o,attrs:n,body:t[2]})},Fe=(e,t)=>{let n=_(e,t),o=V.get(n);if(o)return o;let r=fetch(`${L()}/v${t}/${e}.svg`).then(async s=>{if(!s.ok)throw new Error(`${s.status} for ${e}`);let i=M(await s.text());if(!i)throw new Error(`iconplease: "${e}" is not a valid SVG`);y.set(n,i),he(),p()}).catch(be).finally(()=>{V.delete(n)});return V.set(n,r),r},le=async(e=!1)=>{var n;if(!x()){let o=(n=F())!=null?n:"";return fetch(`${U()}/sdk/set?key=${encodeURIComponent(o)}`)}let t=await Le(e);return fetch(`${U()}/sdk/set`,{headers:{Authorization:`Bearer ${t}`}})},Je=async e=>{var s,i;let t=await le();t.status===401&&x()&&(t=await le(!0));let n=await t.json().catch(()=>({}));if(!t.ok)throw new Error(n.error||`HTTP ${t.status}`);let o=new Map,r={};for(let[u,d]of Object.entries((s=n.icons)!=null?s:{})){if(!O.test(u)||typeof(d==null?void 0:d.svg)!="string")continue;let f=M(d.svg);f&&(o.set(u,f),r[u]={version:Number(d.version)||1,svg:d.svg})}if(e===H){h.clear();for(let[u,d]of o)h.set(u,d);E=Date.now(),b=!0,w=typeof n.version=="number"?n.version:null;try{e!=="token"&&((i=N())==null||i.setItem(me,JSON.stringify({tag:e,checkedAt:E,version:w,icons:r})))}catch{p();return}p()}},Q=(e={})=>{g();let t=$();if(!t||b&&Date.now()-E<K()&&!e.force||!e.force&&Date.now()<W)return Promise.resolve();if(I)return I;let o=Je(t).catch(r=>{b=!0,W=Date.now()+_e,G||(G=!0,console.warn(`iconplease: could not load your icon set \u2014 ${r instanceof Error?r.message:String(r)} Falling back to public icons.`)),p()}).finally(()=>{I=void 0});return I=o,o},ee=async e=>{var o,r;if(!O.test(e))return;if(g(),$()){if(m(e)){Q();return}if(await Q(),m(e))return}else if(m(e))return;let t=(o=c.index)==null?void 0:o.icons[e];if(t&&y.has(_(e,t))){Z();return}await Z();let n=(r=c.index)==null?void 0:r.icons[e];n&&!y.has(_(e,n))&&await Fe(e,n)},te=async(e={})=>{let{icons:t=[],force:n=!1}=Array.isArray(e)?{icons:e}:e;g(),!(A&&!$()&&t.every(r=>m(r)))&&(await Promise.all([A?Promise.resolve():Z({force:n}),Q({force:n})]),await Promise.all(t.map(ee)))},we=e=>(g(),X.add(e),()=>X.delete(e));var R=e=>{var o;g();let t=m(e);if(t)return t;let n=(o=c.index)==null?void 0:o.icons[e];return n?y.get(_(e,n)):void 0},ke=e=>(g(),m(e)||$()&&!b?!1:c.status==="ready"&&!!c.index&&!(e in c.index.icons));var qe=/^[#a-zA-Z0-9(),.%\s-]{1,64}$/,Ve=/[<>"&]/g,He={"<":"<",">":">",'"':""","&":"&"},Ge=e=>e.replace(Ve,t=>He[t]),ve=e=>String(Number(e.toFixed(3))),We=(e,t)=>e.replace(/\b(fill|stroke)="currentColor"/g,`$1="${t}"`),Ye=(e,t)=>e.replace(/\bstroke-width="([0-9]*\.?[0-9]+)"/g,(n,o)=>`stroke-width="${ve(Number(o)*t)}"`),ne=(e,t={})=>{var se;let{size:n=24,color:o,strokeScale:r,motion:s,label:i,className:u}=t,d=o&&qe.test(o)?o:void 0,f=typeof r=="number"&&Number.isFinite(r)&&r>0&&r!==1?r:void 0,a={...(se=e.attrs)!=null?se:{}};if(d)for(let ie of["fill","stroke"])a[ie]==="currentColor"&&(a[ie]=d);f&&a["stroke-width"]&&(a["stroke-width"]=ve(Number(a["stroke-width"])*f));let k=e.body;return d&&(k=We(k,d)),f&&(k=Ye(k,f)),a.width=String(n),a.height=String(n),a.viewBox=e.viewBox,s&&s!=="none"&&(a["data-motion"]=s),i?(a.role="img",a["aria-label"]=i):a["aria-hidden"]="true",u&&(a.class=u),{attrs:a,body:k}},oe=({attrs:e,body:t})=>`<svg xmlns="http://www.w3.org/2000/svg" ${Object.entries(e).map(([o,r])=>`${o}="${Ge(r)}"`).join(" ")}>${t}</svg>`,xe=(e,t={})=>{let n=typeof e=="string"?R(e):e;return n?oe(ne(n,t)):void 0};var Se="[data-icon], i.ip[class*='ip-']",Xe=new Set(["none","wiggle","pop","bounce","draw"]),Ie=new Set,Ze=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)},Ee=e=>{if(e===null)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0},re=e=>{var u,d,f,a;let t=Ze(e);if(!t)return;let n=R(t),o=e.getAttribute("data-motion"),r=o&&Xe.has(o)?o:void 0,s={size:(u=Ee(e.getAttribute("data-size")))!=null?u:24,color:(d=e.getAttribute("data-color"))!=null?d:void 0,strokeScale:Ee(e.getAttribute("data-stroke")),motion:r,label:(f=e.getAttribute("data-label"))!=null?f:void 0},i=JSON.stringify([t,s,n?"1":"0"]);if(e.getAttribute("data-ip-rendered")!==i){if(!n){ke(t)?Ie.has(t)||(Ie.add(t),console.warn(`iconplease: no icon named "${t}".`)):ee(t);return}e.innerHTML=oe(ne(n,s)),e.setAttribute("data-ip-rendered",i),e.tagName==="I"&&((a=e.style).display||(a.display="inline-flex"))}},B=(e=document)=>{e instanceof Element&&e.matches(Se)&&re(e),e.querySelectorAll(Se).forEach(re)},Ae=()=>{let e=window.iconpleaseConfig;e&&z(e),we(()=>B()),B(),te(),new MutationObserver(t=>{for(let n of t)n.type==="attributes"&&n.target instanceof Element&&re(n.target),n.addedNodes.forEach(o=>{o instanceof Element&&B(o)})}).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:te,renderSVG:xe,refresh:()=>B()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ae,{once:!0}):Ae();})();
|
|
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();})();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { init, getConfig } from "./config.js";
|
|
2
2
|
export { load, loadSet, requestIcon, subscribe, getIcon, getStatus, iconNames, setIconNames, isUnknown, bundledIcon } from "./store.js";
|
|
3
3
|
export { renderSVG, prepare } from "./render.js";
|
|
4
|
+
export { attachAnimation, attachAll } from "./player.js";
|
|
5
|
+
export { decodeAnimation, encodeAnimation, cleanAnimation, PRESETS } from "./animation.js";
|
|
6
|
+
export type { IconAnimation, AnimationClip, AnimationPreset, AnimationTrigger } from "./animation.js";
|
|
4
7
|
export type { RenderOptions, Prepared } from "./render.js";
|
|
5
8
|
export type { LoadOptions } from "./store.js";
|
|
6
9
|
export type { Config, IconData, IconIndex, IconMotion, Status, BundledSet, BundledIcon, TokenSource } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { init, getConfig } from "./config.js";
|
|
2
2
|
export { load, loadSet, requestIcon, subscribe, getIcon, getStatus, iconNames, setIconNames, isUnknown, bundledIcon } from "./store.js";
|
|
3
3
|
export { renderSVG, prepare } from "./render.js";
|
|
4
|
+
export { attachAnimation, attachAll } from "./player.js";
|
|
5
|
+
export { decodeAnimation, encodeAnimation, cleanAnimation, PRESETS } from "./animation.js";
|
package/dist/player.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type IconAnimation } from "./animation.js";
|
|
2
|
+
export type AttachOptions = {
|
|
3
|
+
trigger?: IconAnimation["trigger"];
|
|
4
|
+
reducedMotion?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const attachAnimation: (svg: Element, options?: AttachOptions) => (() => void);
|
|
7
|
+
export declare const attachAll: (root?: ParentNode) => void;
|
package/dist/player.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ANIMATION_ATTRIBUTE, MARKER_ATTRIBUTE, animate, decodeAnimation } from "./animation.js";
|
|
2
|
+
const attached = new WeakMap();
|
|
3
|
+
const prefersReduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
4
|
+
const hoverHost = (svg) => svg.closest("a, button, [role=button], label, summary") ?? svg.parentElement ?? svg;
|
|
5
|
+
export const attachAnimation = (svg, options = {}) => {
|
|
6
|
+
attached.get(svg)?.();
|
|
7
|
+
const animation = decodeAnimation(svg.getAttribute(ANIMATION_ATTRIBUTE));
|
|
8
|
+
if (!animation || typeof svg.animate !== "function")
|
|
9
|
+
return () => { };
|
|
10
|
+
if (options.reducedMotion ?? prefersReduced())
|
|
11
|
+
return () => { };
|
|
12
|
+
const trigger = options.trigger ?? animation.trigger;
|
|
13
|
+
const targets = (marker) => [...svg.querySelectorAll(`[${MARKER_ATTRIBUTE}="${marker}"]`)];
|
|
14
|
+
let playback;
|
|
15
|
+
const cleanups = [];
|
|
16
|
+
const stop = () => {
|
|
17
|
+
playback?.cancel();
|
|
18
|
+
playback = undefined;
|
|
19
|
+
};
|
|
20
|
+
const start = () => {
|
|
21
|
+
stop();
|
|
22
|
+
playback = animate(animation, targets);
|
|
23
|
+
};
|
|
24
|
+
if (trigger === "load")
|
|
25
|
+
start();
|
|
26
|
+
if (trigger === "hover") {
|
|
27
|
+
const host = hoverHost(svg);
|
|
28
|
+
host.addEventListener("pointerenter", start);
|
|
29
|
+
host.addEventListener("pointerleave", stop);
|
|
30
|
+
host.addEventListener("focusin", start);
|
|
31
|
+
host.addEventListener("focusout", stop);
|
|
32
|
+
cleanups.push(() => {
|
|
33
|
+
host.removeEventListener("pointerenter", start);
|
|
34
|
+
host.removeEventListener("pointerleave", stop);
|
|
35
|
+
host.removeEventListener("focusin", start);
|
|
36
|
+
host.removeEventListener("focusout", stop);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (trigger === "click") {
|
|
40
|
+
const host = hoverHost(svg);
|
|
41
|
+
host.addEventListener("click", start);
|
|
42
|
+
cleanups.push(() => host.removeEventListener("click", start));
|
|
43
|
+
}
|
|
44
|
+
if (trigger === "visible") {
|
|
45
|
+
if (typeof IntersectionObserver === "function") {
|
|
46
|
+
const observer = new IntersectionObserver((entries) => {
|
|
47
|
+
if (!entries.some((entry) => entry.isIntersecting))
|
|
48
|
+
return;
|
|
49
|
+
observer.disconnect();
|
|
50
|
+
start();
|
|
51
|
+
}, { threshold: 0.5 });
|
|
52
|
+
observer.observe(svg);
|
|
53
|
+
cleanups.push(() => observer.disconnect());
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
start();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const detach = () => {
|
|
60
|
+
stop();
|
|
61
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
62
|
+
attached.delete(svg);
|
|
63
|
+
};
|
|
64
|
+
attached.set(svg, detach);
|
|
65
|
+
return detach;
|
|
66
|
+
};
|
|
67
|
+
export const attachAll = (root = document) => {
|
|
68
|
+
root.querySelectorAll(`svg[${ANIMATION_ATTRIBUTE}]`).forEach((svg) => {
|
|
69
|
+
if (!attached.has(svg))
|
|
70
|
+
attachAnimation(svg);
|
|
71
|
+
});
|
|
72
|
+
};
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useSyncExternalStore } from "react";
|
|
2
|
+
import { useEffect, useRef, useSyncExternalStore } from "react";
|
|
3
|
+
import { attachAnimation } from "./player.js";
|
|
3
4
|
import { prepare } from "./render.js";
|
|
4
5
|
import { bundledIcon, getIcon, getSnapshot, isUnknown, requestIcon, subscribe } from "./store.js";
|
|
5
6
|
const serverSnapshot = { status: "idle", revision: 0 };
|
|
@@ -20,6 +21,7 @@ const toProps = (attrs) => Object.fromEntries(Object.entries(attrs).map(([name,
|
|
|
20
21
|
const warned = new Set();
|
|
21
22
|
export const Iconplease = ({ icon, size = 24, className, label, ...options }) => {
|
|
22
23
|
const state = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
24
|
+
const ref = useRef(null);
|
|
23
25
|
useEffect(() => {
|
|
24
26
|
void requestIcon(icon);
|
|
25
27
|
}, [icon]);
|
|
@@ -32,6 +34,13 @@ export const Iconplease = ({ icon, size = 24, className, label, ...options }) =>
|
|
|
32
34
|
return (_jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", "aria-hidden": label ? undefined : true, role: label ? "img" : undefined, "aria-label": label, className: className, "data-iconplease-pending": "" }));
|
|
33
35
|
}
|
|
34
36
|
const { attrs, body } = prepare(data, { size, className, label, ...options });
|
|
35
|
-
return _jsx(
|
|
37
|
+
return _jsx(Animated, { attrs: attrs, body: body, svgRef: ref });
|
|
38
|
+
};
|
|
39
|
+
const Animated = ({ attrs, body, svgRef }) => {
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const svg = svgRef.current;
|
|
42
|
+
return svg ? attachAnimation(svg) : undefined;
|
|
43
|
+
}, [body, attrs["data-ip-animation"], svgRef]);
|
|
44
|
+
return _jsx("svg", { ref: svgRef, xmlns: "http://www.w3.org/2000/svg", ...toProps(attrs), dangerouslySetInnerHTML: { __html: body } });
|
|
36
45
|
};
|
|
37
46
|
export default Iconplease;
|
package/dist/script.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { init } from "./config.js";
|
|
2
2
|
import { load, requestIcon, subscribe, getIcon, isUnknown } from "./store.js";
|
|
3
3
|
import { prepare, renderSVG, toMarkup } from "./render.js";
|
|
4
|
+
import { attachAll, attachAnimation } from "./player.js";
|
|
4
5
|
const SELECTOR = "[data-icon], i.ip[class*='ip-']";
|
|
5
6
|
const MOTIONS = new Set(["none", "wiggle", "pop", "bounce", "draw"]);
|
|
6
7
|
const warned = new Set();
|
|
@@ -51,6 +52,9 @@ const paint = (element) => {
|
|
|
51
52
|
}
|
|
52
53
|
element.innerHTML = toMarkup(prepare(icon, options));
|
|
53
54
|
element.setAttribute("data-ip-rendered", key);
|
|
55
|
+
const svg = element.querySelector("svg");
|
|
56
|
+
if (svg)
|
|
57
|
+
attachAnimation(svg);
|
|
54
58
|
if (element.tagName === "I")
|
|
55
59
|
(_a = element.style).display || (_a.display = "inline-flex");
|
|
56
60
|
};
|
|
@@ -82,7 +86,7 @@ const start = () => {
|
|
|
82
86
|
attributeFilter: ["data-icon", "data-size", "data-color", "data-stroke", "data-motion", "data-label", "class"],
|
|
83
87
|
});
|
|
84
88
|
};
|
|
85
|
-
window.iconplease = { init, load, renderSVG, refresh: () => paintAll() };
|
|
89
|
+
window.iconplease = { init, load, renderSVG, attachAnimation, attachAll, refresh: () => paintAll() };
|
|
86
90
|
if (document.readyState === "loading")
|
|
87
91
|
document.addEventListener("DOMContentLoaded", start, { once: true });
|
|
88
92
|
else
|
package/package.json
CHANGED