libraries-dev-svelte 0.1.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.
@@ -0,0 +1,7 @@
1
+ import type { GooeyRadialMenuProps } from './types';
2
+ type $$ComponentProps = GooeyRadialMenuProps & {
3
+ fill?: string;
4
+ };
5
+ declare const GooeyRadialMenu: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type GooeyRadialMenu = ReturnType<typeof GooeyRadialMenu>;
7
+ export default GooeyRadialMenu;
@@ -0,0 +1,2 @@
1
+ /** Eases the Goey radial menu uses to keep its DOM pieces and SVG blobs in sync. */
2
+ export declare function easingFunction(spec: string): (t: number) => number;
@@ -0,0 +1,34 @@
1
+ /** Eases the Goey radial menu uses to keep its DOM pieces and SVG blobs in sync. */
2
+ export function easingFunction(spec) {
3
+ const bezier = /^cubic-bezier\(([^)]+)\)$/.exec(spec.trim());
4
+ if (bezier) {
5
+ const [x1, y1, x2, y2] = bezier[1].split(',').map(Number);
6
+ return (t) => {
7
+ if (t <= 0)
8
+ return 0;
9
+ if (t >= 1)
10
+ return 1;
11
+ let lo = 0;
12
+ let hi = 1;
13
+ for (let i = 0; i < 24; i++) {
14
+ const mid = (lo + hi) / 2;
15
+ const x = 3 * mid * (1 - mid) * (1 - mid) * x1 + 3 * mid * mid * (1 - mid) * x2 + mid ** 3;
16
+ if (x < t)
17
+ lo = mid;
18
+ else
19
+ hi = mid;
20
+ }
21
+ const u = (lo + hi) / 2;
22
+ return 3 * u * (1 - u) * (1 - u) * y1 + 3 * u * u * (1 - u) * y2 + u ** 3;
23
+ };
24
+ }
25
+ if (spec === 'ease-in-out')
26
+ return easingFunction('cubic-bezier(0.42, 0, 0.58, 1)');
27
+ if (spec === 'ease')
28
+ return easingFunction('cubic-bezier(0.25, 0.1, 0.25, 1)');
29
+ if (spec === 'ease-in')
30
+ return easingFunction('cubic-bezier(0.42, 0, 1, 1)');
31
+ if (spec === 'ease-out')
32
+ return easingFunction('cubic-bezier(0, 0, 0.58, 1)');
33
+ return (t) => Math.min(1, Math.max(0, t));
34
+ }
@@ -0,0 +1,10 @@
1
+ /** Parsed box-shadow layers, painted against the merged liquid silhouette. */
2
+ export interface ShadowLayer {
3
+ x: number;
4
+ y: number;
5
+ blur: number;
6
+ spread: number;
7
+ color: string;
8
+ inset: boolean;
9
+ }
10
+ export declare function parseShadow(input?: string | null): ShadowLayer[];
@@ -0,0 +1,54 @@
1
+ function splitTop(value, separator) {
2
+ const parts = [];
3
+ let depth = 0;
4
+ let current = '';
5
+ for (const char of value) {
6
+ if (char === '(')
7
+ depth++;
8
+ else if (char === ')')
9
+ depth--;
10
+ if (depth === 0 && (separator === ',' ? char === ',' : /\s/.test(char))) {
11
+ if (current.trim())
12
+ parts.push(current.trim());
13
+ current = '';
14
+ }
15
+ else {
16
+ current += char;
17
+ }
18
+ }
19
+ if (current.trim())
20
+ parts.push(current.trim());
21
+ return parts;
22
+ }
23
+ const LENGTH = /^[+-]?(\d+\.?\d*|\.\d+)(px)?$/;
24
+ export function parseShadow(input) {
25
+ if (!input || input.trim() === '' || input.trim() === 'none')
26
+ return [];
27
+ const shadows = [];
28
+ for (const layer of splitTop(input, ',')) {
29
+ const tokens = splitTop(layer, ' ');
30
+ if (tokens.length === 0)
31
+ continue;
32
+ const inset = tokens.includes('inset');
33
+ const numbers = [];
34
+ const colorParts = [];
35
+ for (const token of tokens) {
36
+ if (token === 'inset')
37
+ continue;
38
+ if (numbers.length < 4 && LENGTH.test(token))
39
+ numbers.push(parseFloat(token));
40
+ else
41
+ colorParts.push(token);
42
+ }
43
+ const [x = 0, y = 0, blur = 0, spread = 0] = numbers;
44
+ shadows.push({
45
+ x,
46
+ y,
47
+ blur,
48
+ spread,
49
+ color: colorParts.join(' ') || 'rgba(0, 0, 0, 0.35)',
50
+ inset,
51
+ });
52
+ }
53
+ return shadows;
54
+ }
@@ -0,0 +1,28 @@
1
+ /** Inputs accepted by the Goey radial-menu playground component. */
2
+ export interface GooeyRadialMenuProps {
3
+ /** Goo filter blur sigma in px. */
4
+ blur?: number;
5
+ /** Alpha-contrast slope controlling the liquid edge. */
6
+ contrast?: number;
7
+ /** CSS box-shadow layers drawn on the merged liquid silhouette. */
8
+ shadow?: string;
9
+ /** Surface color for the merged liquid. Defaults to the host theme's modal color. */
10
+ fill?: string;
11
+ /** Show all raw tuning controls, export, and reset controls. */
12
+ pro?: boolean;
13
+ /** Render only the menu stage for embedding in a host layout. */
14
+ bare?: boolean;
15
+ }
16
+ export interface GooeyMenuSettings {
17
+ openDur: number;
18
+ openEase: string;
19
+ openStagger: number;
20
+ closeDur: number;
21
+ closeEase: string;
22
+ closeStagger: number;
23
+ spread: number;
24
+ iconDur: number;
25
+ iconDelay: number;
26
+ anticipDist: number;
27
+ anticipDur: number;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ export { default as BotAvatar } from './bot-avatars/BotAvatar.svelte';
2
+ export { default } from './bot-avatars/BotAvatar.svelte';
3
+ export { default as GooeyRadialMenu } from './gooey-radial-menu/GooeyRadialMenu.svelte';
4
+ export type { GooeyMenuSettings, GooeyRadialMenuProps } from './gooey-radial-menu/types';
5
+ export { botAvatarPresets, botAvatarPalette, botAvatarTypes, botAvatarFaces, botAvatarStates, } from './bot-avatars/presets';
6
+ export { SHAPE_PATHS as botAvatarShapes, SHAPE_PARTS as botAvatarParts } from './bot-avatars/shapes';
7
+ export { autoInk, luminance, parseColor, shade } from './bot-avatars/color';
8
+ export { Sim as BotAvatarSim, restPose } from './bot-avatars/engine';
9
+ export { draw as drawBotAvatarFrame, OVERSCAN as BOT_AVATAR_OVERSCAN, RISE as BOT_AVATAR_RISE, } from './bot-avatars/draw';
10
+ export { warmPlastic as warmBotAvatarPlastic } from './bot-avatars/plastic';
11
+ export { buildForm as bakeBotAvatarForm, buildMatcap as buildBotAvatarMatcap, shadeTexels as shadeBotAvatarTexels, capFrame as botAvatarCapFrame, tierFor as botAvatarTier, PAD as BOT_AVATAR_PAD, SPAN as BOT_AVATAR_SPAN, MATCAP_SIZE as BOT_AVATAR_MATCAP_SIZE, } from './bot-avatars/plastic';
12
+ export type { Form as BotAvatarForm, Frame as BotAvatarFrame, Material as BotAvatarMaterial, Rig as BotAvatarRig, } from './bot-avatars/plastic';
13
+ export { JUMP_DEFAULTS as botAvatarJumpDefaults } from './bot-avatars/engine';
14
+ export type { JumpConfig as BotAvatarJumpConfig } from './bot-avatars/engine';
15
+ export type { DrawConfig as BotAvatarDrawConfig } from './bot-avatars/draw';
16
+ export type { Pose as BotAvatarPose } from './bot-avatars/engine';
17
+ export type { BotAvatarProps, BotAvatarClickEvent, BotAvatarType, BotAvatarFace, BotAvatarState, BotAvatarShading, BotAvatarSquashEase, BotAvatarPreset, BotAvatarStyle, BotAvatarRef, } from './bot-avatars/types';
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ export { default as BotAvatar } from './bot-avatars/BotAvatar.svelte';
2
+ export { default } from './bot-avatars/BotAvatar.svelte';
3
+ export { default as GooeyRadialMenu } from './gooey-radial-menu/GooeyRadialMenu.svelte';
4
+ export { botAvatarPresets, botAvatarPalette, botAvatarTypes, botAvatarFaces, botAvatarStates, } from './bot-avatars/presets';
5
+ export { SHAPE_PATHS as botAvatarShapes, SHAPE_PARTS as botAvatarParts } from './bot-avatars/shapes';
6
+ export { autoInk, luminance, parseColor, shade } from './bot-avatars/color';
7
+ export { Sim as BotAvatarSim, restPose } from './bot-avatars/engine';
8
+ export { draw as drawBotAvatarFrame, OVERSCAN as BOT_AVATAR_OVERSCAN, RISE as BOT_AVATAR_RISE, } from './bot-avatars/draw';
9
+ export { warmPlastic as warmBotAvatarPlastic } from './bot-avatars/plastic';
10
+ /* The plastic material's building blocks, for renderers on other canvases. */
11
+ export { buildForm as bakeBotAvatarForm, buildMatcap as buildBotAvatarMatcap, shadeTexels as shadeBotAvatarTexels, capFrame as botAvatarCapFrame, tierFor as botAvatarTier, PAD as BOT_AVATAR_PAD, SPAN as BOT_AVATAR_SPAN, MATCAP_SIZE as BOT_AVATAR_MATCAP_SIZE, } from './bot-avatars/plastic';
12
+ export { JUMP_DEFAULTS as botAvatarJumpDefaults } from './bot-avatars/engine';
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "libraries-dev-svelte",
3
+ "version": "0.1.0",
4
+ "description": "Svelte ports of Bot Avatars and the Gooey radial menu from Libraries.dev",
5
+ "license": "MIT",
6
+ "scripts": {
7
+ "dev": "vite dev",
8
+ "build": "vite build && bun run prepack",
9
+ "preview": "vite preview",
10
+ "prepare": "svelte-kit sync || echo ''",
11
+ "prepack": "svelte-kit sync && svelte-package && publint",
12
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
13
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "!dist/**/*.test.*",
18
+ "!dist/**/*.spec.*"
19
+ ],
20
+ "sideEffects": ["**/*.css"],
21
+ "svelte": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "svelte": "./dist/index.js"
28
+ }
29
+ },
30
+ "peerDependencies": {
31
+ "svelte": "^5.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@sveltejs/adapter-auto": "^7.0.1",
35
+ "@sveltejs/kit": "^2.63.0",
36
+ "@sveltejs/package": "^2.5.8",
37
+ "@sveltejs/vite-plugin-svelte": "^7.1.2",
38
+ "publint": "^0.3.21",
39
+ "svelte": "^5.56.1",
40
+ "svelte-check": "^4.6.0",
41
+ "typescript": "^6.0.3",
42
+ "vite": "^8.0.16"
43
+ },
44
+ "keywords": ["svelte", "bot-avatar", "radial-menu", "gooey", "liquid", "animation"],
45
+ "author": "Jakub Antalik"
46
+ }