@easemate/web-kit 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.
- package/README.md +824 -0
- package/build/components/code/index.cjs +152 -0
- package/build/components/code/index.d.cts +11 -0
- package/build/components/code/index.d.ts +11 -0
- package/build/components/code/index.js +148 -0
- package/build/components/code/utils/highlight-api.cjs +18 -0
- package/build/components/code/utils/highlight-api.d.cts +7 -0
- package/build/components/code/utils/highlight-api.d.ts +7 -0
- package/build/components/code/utils/highlight-api.js +14 -0
- package/build/components/code/utils/syntax-grammars.cjs +62 -0
- package/build/components/code/utils/syntax-grammars.d.cts +7 -0
- package/build/components/code/utils/syntax-grammars.d.ts +7 -0
- package/build/components/code/utils/syntax-grammars.js +59 -0
- package/build/components/code/utils/syntax-highlighter-theme.cjs +27 -0
- package/build/components/code/utils/syntax-highlighter-theme.d.cts +3 -0
- package/build/components/code/utils/syntax-highlighter-theme.d.ts +3 -0
- package/build/components/code/utils/syntax-highlighter-theme.js +23 -0
- package/build/components/code/utils/syntax-highlighter-types.cjs +2 -0
- package/build/components/code/utils/syntax-highlighter-types.d.cts +12 -0
- package/build/components/code/utils/syntax-highlighter-types.d.ts +12 -0
- package/build/components/code/utils/syntax-highlighter-types.js +1 -0
- package/build/components/code/utils/syntax-tokenizer.cjs +63 -0
- package/build/components/code/utils/syntax-tokenizer.d.cts +3 -0
- package/build/components/code/utils/syntax-tokenizer.d.ts +3 -0
- package/build/components/code/utils/syntax-tokenizer.js +58 -0
- package/build/components/curve/bezier-conversion.cjs +23 -0
- package/build/components/curve/bezier-conversion.d.cts +2 -0
- package/build/components/curve/bezier-conversion.d.ts +2 -0
- package/build/components/curve/bezier-conversion.js +19 -0
- package/build/components/curve/canvas-controls.cjs +300 -0
- package/build/components/curve/canvas-controls.d.cts +12 -0
- package/build/components/curve/canvas-controls.d.ts +12 -0
- package/build/components/curve/canvas-controls.js +296 -0
- package/build/components/curve/canvas.cjs +1208 -0
- package/build/components/curve/canvas.d.cts +24 -0
- package/build/components/curve/canvas.d.ts +24 -0
- package/build/components/curve/canvas.js +1204 -0
- package/build/components/curve/constants.cjs +203 -0
- package/build/components/curve/constants.d.cts +23 -0
- package/build/components/curve/constants.d.ts +23 -0
- package/build/components/curve/constants.js +200 -0
- package/build/components/curve/controls.cjs +942 -0
- package/build/components/curve/controls.d.cts +37 -0
- package/build/components/curve/controls.d.ts +37 -0
- package/build/components/curve/controls.js +938 -0
- package/build/components/curve/index.cjs +335 -0
- package/build/components/curve/index.d.cts +31 -0
- package/build/components/curve/index.d.ts +31 -0
- package/build/components/curve/index.js +330 -0
- package/build/components/curve/output.cjs +141 -0
- package/build/components/curve/output.d.cts +19 -0
- package/build/components/curve/output.d.ts +19 -0
- package/build/components/curve/output.js +137 -0
- package/build/components/curve/styles.cjs +493 -0
- package/build/components/curve/styles.d.cts +6 -0
- package/build/components/curve/styles.d.ts +6 -0
- package/build/components/curve/styles.js +490 -0
- package/build/components/curve/svg-renderer.cjs +185 -0
- package/build/components/curve/svg-renderer.d.cts +9 -0
- package/build/components/curve/svg-renderer.d.ts +9 -0
- package/build/components/curve/svg-renderer.js +175 -0
- package/build/components/curve/toolbar.cjs +368 -0
- package/build/components/curve/toolbar.d.cts +26 -0
- package/build/components/curve/toolbar.d.ts +26 -0
- package/build/components/curve/toolbar.js +364 -0
- package/build/components/curve/types.cjs +10 -0
- package/build/components/curve/types.d.cts +33 -0
- package/build/components/curve/types.d.ts +33 -0
- package/build/components/curve/types.js +7 -0
- package/build/components/curve/utils.cjs +541 -0
- package/build/components/curve/utils.d.cts +33 -0
- package/build/components/curve/utils.d.ts +33 -0
- package/build/components/curve/utils.js +521 -0
- package/build/components/index.cjs +18 -0
- package/build/components/index.d.cts +2 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/decorators/Component.cjs +127 -0
- package/build/decorators/Component.d.cts +28 -0
- package/build/decorators/Component.d.ts +28 -0
- package/build/decorators/Component.js +123 -0
- package/build/decorators/Listen.cjs +154 -0
- package/build/decorators/Listen.d.cts +18 -0
- package/build/decorators/Listen.d.ts +18 -0
- package/build/decorators/Listen.js +151 -0
- package/build/decorators/OutsideClick.cjs +64 -0
- package/build/decorators/OutsideClick.d.cts +16 -0
- package/build/decorators/OutsideClick.d.ts +16 -0
- package/build/decorators/OutsideClick.js +59 -0
- package/build/decorators/Prop.cjs +273 -0
- package/build/decorators/Prop.d.cts +22 -0
- package/build/decorators/Prop.d.ts +22 -0
- package/build/decorators/Prop.js +270 -0
- package/build/decorators/Query.cjs +79 -0
- package/build/decorators/Query.d.cts +27 -0
- package/build/decorators/Query.d.ts +27 -0
- package/build/decorators/Query.js +76 -0
- package/build/decorators/Watch.cjs +52 -0
- package/build/decorators/Watch.d.cts +11 -0
- package/build/decorators/Watch.d.ts +11 -0
- package/build/decorators/Watch.js +49 -0
- package/build/decorators/index.cjs +15 -0
- package/build/decorators/index.d.cts +6 -0
- package/build/decorators/index.d.ts +6 -0
- package/build/decorators/index.js +6 -0
- package/build/elements/button/index.cjs +214 -0
- package/build/elements/button/index.d.cts +11 -0
- package/build/elements/button/index.d.ts +11 -0
- package/build/elements/button/index.js +210 -0
- package/build/elements/checkbox/index.cjs +316 -0
- package/build/elements/checkbox/index.d.cts +14 -0
- package/build/elements/checkbox/index.d.ts +14 -0
- package/build/elements/checkbox/index.js +312 -0
- package/build/elements/color/index.cjs +154 -0
- package/build/elements/color/index.d.cts +18 -0
- package/build/elements/color/index.d.ts +18 -0
- package/build/elements/color/index.js +150 -0
- package/build/elements/color/picker.cjs +544 -0
- package/build/elements/color/picker.d.cts +37 -0
- package/build/elements/color/picker.d.ts +37 -0
- package/build/elements/color/picker.js +540 -0
- package/build/elements/color/utils.cjs +235 -0
- package/build/elements/color/utils.d.cts +37 -0
- package/build/elements/color/utils.d.ts +37 -0
- package/build/elements/color/utils.js +218 -0
- package/build/elements/dropdown/index.cjs +875 -0
- package/build/elements/dropdown/index.d.cts +30 -0
- package/build/elements/dropdown/index.d.ts +30 -0
- package/build/elements/dropdown/index.js +871 -0
- package/build/elements/field/index.cjs +82 -0
- package/build/elements/field/index.d.cts +4 -0
- package/build/elements/field/index.d.ts +4 -0
- package/build/elements/field/index.js +78 -0
- package/build/elements/icons/animation/chevron.cjs +57 -0
- package/build/elements/icons/animation/chevron.d.cts +10 -0
- package/build/elements/icons/animation/chevron.d.ts +10 -0
- package/build/elements/icons/animation/chevron.js +53 -0
- package/build/elements/icons/animation/clear.cjs +74 -0
- package/build/elements/icons/animation/clear.d.cts +3 -0
- package/build/elements/icons/animation/clear.d.ts +3 -0
- package/build/elements/icons/animation/clear.js +70 -0
- package/build/elements/icons/animation/grid.cjs +77 -0
- package/build/elements/icons/animation/grid.d.cts +8 -0
- package/build/elements/icons/animation/grid.d.ts +8 -0
- package/build/elements/icons/animation/grid.js +73 -0
- package/build/elements/icons/animation/loading.cjs +68 -0
- package/build/elements/icons/animation/loading.d.cts +3 -0
- package/build/elements/icons/animation/loading.d.ts +3 -0
- package/build/elements/icons/animation/loading.js +64 -0
- package/build/elements/icons/animation/snap.cjs +133 -0
- package/build/elements/icons/animation/snap.d.cts +8 -0
- package/build/elements/icons/animation/snap.d.ts +8 -0
- package/build/elements/icons/animation/snap.js +129 -0
- package/build/elements/icons/index.cjs +40 -0
- package/build/elements/icons/index.d.cts +24 -0
- package/build/elements/icons/index.d.ts +24 -0
- package/build/elements/icons/index.js +24 -0
- package/build/elements/icons/interface/anchor-add.cjs +35 -0
- package/build/elements/icons/interface/anchor-add.d.cts +3 -0
- package/build/elements/icons/interface/anchor-add.d.ts +3 -0
- package/build/elements/icons/interface/anchor-add.js +31 -0
- package/build/elements/icons/interface/anchor-remove.cjs +34 -0
- package/build/elements/icons/interface/anchor-remove.d.cts +3 -0
- package/build/elements/icons/interface/anchor-remove.d.ts +3 -0
- package/build/elements/icons/interface/anchor-remove.js +30 -0
- package/build/elements/icons/interface/arrow-up.cjs +30 -0
- package/build/elements/icons/interface/arrow-up.d.cts +3 -0
- package/build/elements/icons/interface/arrow-up.d.ts +3 -0
- package/build/elements/icons/interface/arrow-up.js +26 -0
- package/build/elements/icons/interface/arrows-vertical.cjs +30 -0
- package/build/elements/icons/interface/arrows-vertical.d.cts +3 -0
- package/build/elements/icons/interface/arrows-vertical.d.ts +3 -0
- package/build/elements/icons/interface/arrows-vertical.js +26 -0
- package/build/elements/icons/interface/bezier-angle.cjs +33 -0
- package/build/elements/icons/interface/bezier-angle.d.cts +3 -0
- package/build/elements/icons/interface/bezier-angle.d.ts +3 -0
- package/build/elements/icons/interface/bezier-angle.js +29 -0
- package/build/elements/icons/interface/bezier-distribute.cjs +34 -0
- package/build/elements/icons/interface/bezier-distribute.d.cts +3 -0
- package/build/elements/icons/interface/bezier-distribute.d.ts +3 -0
- package/build/elements/icons/interface/bezier-distribute.js +30 -0
- package/build/elements/icons/interface/bezier-length.cjs +31 -0
- package/build/elements/icons/interface/bezier-length.d.cts +3 -0
- package/build/elements/icons/interface/bezier-length.d.ts +3 -0
- package/build/elements/icons/interface/bezier-length.js +27 -0
- package/build/elements/icons/interface/bezier-mirror.cjs +31 -0
- package/build/elements/icons/interface/bezier-mirror.d.cts +3 -0
- package/build/elements/icons/interface/bezier-mirror.d.ts +3 -0
- package/build/elements/icons/interface/bezier-mirror.js +27 -0
- package/build/elements/icons/interface/bezier.cjs +26 -0
- package/build/elements/icons/interface/bezier.d.cts +3 -0
- package/build/elements/icons/interface/bezier.d.ts +3 -0
- package/build/elements/icons/interface/bezier.js +22 -0
- package/build/elements/icons/interface/check.cjs +30 -0
- package/build/elements/icons/interface/check.d.cts +3 -0
- package/build/elements/icons/interface/check.d.ts +3 -0
- package/build/elements/icons/interface/check.js +26 -0
- package/build/elements/icons/interface/circle-arrow-left.cjs +30 -0
- package/build/elements/icons/interface/circle-arrow-left.d.cts +3 -0
- package/build/elements/icons/interface/circle-arrow-left.d.ts +3 -0
- package/build/elements/icons/interface/circle-arrow-left.js +26 -0
- package/build/elements/icons/interface/circle-arrow-right.cjs +30 -0
- package/build/elements/icons/interface/circle-arrow-right.d.cts +3 -0
- package/build/elements/icons/interface/circle-arrow-right.d.ts +3 -0
- package/build/elements/icons/interface/circle-arrow-right.js +26 -0
- package/build/elements/icons/interface/code.cjs +30 -0
- package/build/elements/icons/interface/code.d.cts +3 -0
- package/build/elements/icons/interface/code.d.ts +3 -0
- package/build/elements/icons/interface/code.js +26 -0
- package/build/elements/icons/interface/dots.cjs +32 -0
- package/build/elements/icons/interface/dots.d.cts +3 -0
- package/build/elements/icons/interface/dots.d.ts +3 -0
- package/build/elements/icons/interface/dots.js +28 -0
- package/build/elements/icons/interface/mention.cjs +30 -0
- package/build/elements/icons/interface/mention.d.cts +3 -0
- package/build/elements/icons/interface/mention.d.ts +3 -0
- package/build/elements/icons/interface/mention.js +26 -0
- package/build/elements/icons/interface/minus.cjs +30 -0
- package/build/elements/icons/interface/minus.d.cts +3 -0
- package/build/elements/icons/interface/minus.d.ts +3 -0
- package/build/elements/icons/interface/minus.js +26 -0
- package/build/elements/icons/interface/picker.cjs +34 -0
- package/build/elements/icons/interface/picker.d.cts +3 -0
- package/build/elements/icons/interface/picker.d.ts +3 -0
- package/build/elements/icons/interface/picker.js +30 -0
- package/build/elements/icons/interface/plus.cjs +30 -0
- package/build/elements/icons/interface/plus.d.cts +3 -0
- package/build/elements/icons/interface/plus.d.ts +3 -0
- package/build/elements/icons/interface/plus.js +26 -0
- package/build/elements/icons/interface/settings.cjs +30 -0
- package/build/elements/icons/interface/settings.d.cts +3 -0
- package/build/elements/icons/interface/settings.d.ts +3 -0
- package/build/elements/icons/interface/settings.js +26 -0
- package/build/elements/index.cjs +62 -0
- package/build/elements/index.d.cts +22 -0
- package/build/elements/index.d.ts +22 -0
- package/build/elements/index.js +22 -0
- package/build/elements/input/index.cjs +273 -0
- package/build/elements/input/index.d.cts +17 -0
- package/build/elements/input/index.d.ts +17 -0
- package/build/elements/input/index.js +269 -0
- package/build/elements/logo/index.cjs +732 -0
- package/build/elements/logo/index.d.cts +17 -0
- package/build/elements/logo/index.d.ts +17 -0
- package/build/elements/logo/index.js +728 -0
- package/build/elements/monitor/fps.cjs +432 -0
- package/build/elements/monitor/fps.d.cts +21 -0
- package/build/elements/monitor/fps.d.ts +21 -0
- package/build/elements/monitor/fps.js +428 -0
- package/build/elements/monitor/index.cjs +670 -0
- package/build/elements/monitor/index.d.cts +112 -0
- package/build/elements/monitor/index.d.ts +112 -0
- package/build/elements/monitor/index.js +666 -0
- package/build/elements/number/index.cjs +173 -0
- package/build/elements/number/index.d.cts +19 -0
- package/build/elements/number/index.d.ts +19 -0
- package/build/elements/number/index.js +169 -0
- package/build/elements/origin/index.cjs +169 -0
- package/build/elements/origin/index.d.cts +12 -0
- package/build/elements/origin/index.d.ts +12 -0
- package/build/elements/origin/index.js +165 -0
- package/build/elements/popover/index.cjs +209 -0
- package/build/elements/popover/index.d.cts +19 -0
- package/build/elements/popover/index.d.ts +19 -0
- package/build/elements/popover/index.js +205 -0
- package/build/elements/radio/index.cjs +301 -0
- package/build/elements/radio/index.d.cts +13 -0
- package/build/elements/radio/index.d.ts +13 -0
- package/build/elements/radio/index.js +283 -0
- package/build/elements/radio/input.cjs +329 -0
- package/build/elements/radio/input.d.cts +15 -0
- package/build/elements/radio/input.d.ts +15 -0
- package/build/elements/radio/input.js +325 -0
- package/build/elements/radio/option.cjs +15 -0
- package/build/elements/radio/option.d.cts +3 -0
- package/build/elements/radio/option.d.ts +3 -0
- package/build/elements/radio/option.js +11 -0
- package/build/elements/shared.cjs +66 -0
- package/build/elements/shared.d.cts +40 -0
- package/build/elements/shared.d.ts +40 -0
- package/build/elements/shared.js +59 -0
- package/build/elements/slider/index.cjs +232 -0
- package/build/elements/slider/index.d.cts +20 -0
- package/build/elements/slider/index.d.ts +20 -0
- package/build/elements/slider/index.js +228 -0
- package/build/elements/state/index.cjs +681 -0
- package/build/elements/state/index.d.cts +86 -0
- package/build/elements/state/index.d.ts +86 -0
- package/build/elements/state/index.js +677 -0
- package/build/elements/toggle/index.cjs +151 -0
- package/build/elements/toggle/index.d.cts +9 -0
- package/build/elements/toggle/index.d.ts +9 -0
- package/build/elements/toggle/index.js +147 -0
- package/build/elements/tooltip/index.cjs +187 -0
- package/build/elements/tooltip/index.d.cts +17 -0
- package/build/elements/tooltip/index.d.ts +17 -0
- package/build/elements/tooltip/index.js +183 -0
- package/build/index.cjs +40 -0
- package/build/index.d.cts +6 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +12 -0
- package/build/init.cjs +325 -0
- package/build/init.d.cts +157 -0
- package/build/init.d.ts +157 -0
- package/build/init.js +289 -0
- package/build/internal/component-loaders.cjs +206 -0
- package/build/internal/component-loaders.d.cts +52 -0
- package/build/internal/component-loaders.d.ts +52 -0
- package/build/internal/component-loaders.js +167 -0
- package/build/internal/fonts.cjs +128 -0
- package/build/internal/fonts.d.cts +32 -0
- package/build/internal/fonts.d.ts +32 -0
- package/build/internal/fonts.js +123 -0
- package/build/internal/lazy-load.cjs +89 -0
- package/build/internal/lazy-load.d.cts +32 -0
- package/build/internal/lazy-load.d.ts +32 -0
- package/build/internal/lazy-load.js +86 -0
- package/build/internal/style-inject.cjs +236 -0
- package/build/internal/style-inject.d.cts +44 -0
- package/build/internal/style-inject.d.ts +44 -0
- package/build/internal/style-inject.js +226 -0
- package/build/register.cjs +36 -0
- package/build/register.d.cts +32 -0
- package/build/register.d.ts +32 -0
- package/build/register.js +34 -0
- package/build/theme/index.cjs +452 -0
- package/build/theme/index.d.cts +146 -0
- package/build/theme/index.d.ts +146 -0
- package/build/theme/index.js +423 -0
- package/build/theme/presets.cjs +54 -0
- package/build/theme/presets.d.cts +19 -0
- package/build/theme/presets.d.ts +19 -0
- package/build/theme/presets.js +51 -0
- package/build/theme/registry.cjs +204 -0
- package/build/theme/registry.d.cts +99 -0
- package/build/theme/registry.d.ts +99 -0
- package/build/theme/registry.js +194 -0
- package/build/theme/tokens.cjs +148 -0
- package/build/theme/tokens.d.cts +163 -0
- package/build/theme/tokens.d.ts +163 -0
- package/build/theme/tokens.js +145 -0
- package/build/utils/dismiss-controller.cjs +77 -0
- package/build/utils/dismiss-controller.d.cts +14 -0
- package/build/utils/dismiss-controller.d.ts +14 -0
- package/build/utils/dismiss-controller.js +73 -0
- package/build/utils/index.cjs +18 -0
- package/build/utils/index.d.cts +3 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.js +3 -0
- package/build/utils/outside-click.cjs +82 -0
- package/build/utils/outside-click.d.cts +18 -0
- package/build/utils/outside-click.d.ts +18 -0
- package/build/utils/outside-click.js +74 -0
- package/build/utils/template-helpers.cjs +39 -0
- package/build/utils/template-helpers.d.cts +13 -0
- package/build/utils/template-helpers.d.ts +13 -0
- package/build/utils/template-helpers.js +28 -0
- package/package.json +96 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.smoothLinearPoints = exports.normalizeVector = exports.vectorLength = exports.parseLinearTimingFunction = exports.parseCubicBezierValue = exports.normalizeLinearPoints = exports.validateLinearPoints = exports.validateCubicBezierPoints = exports.cubicBezierToLinear = exports.generateLinearCSS = exports.getLinearApproximation = exports.generateCubicBezierCSS = exports.linearDisplayPath = exports.cubicBezierPath = exports.cloneLinearPoint = exports.ensureLinearPointId = exports.MIN_LINEAR_DELTA = exports.clampPoint = void 0;
|
|
4
|
+
const clampPoint = (point, bounds) => {
|
|
5
|
+
const minX = bounds?.minX ?? 0;
|
|
6
|
+
const maxX = bounds?.maxX ?? 1;
|
|
7
|
+
const minY = bounds?.minY ?? 0;
|
|
8
|
+
const maxY = bounds?.maxY ?? 1;
|
|
9
|
+
return {
|
|
10
|
+
x: Math.max(minX, Math.min(maxX, point.x)),
|
|
11
|
+
y: Math.max(minY, Math.min(maxY, point.y))
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.clampPoint = clampPoint;
|
|
15
|
+
exports.MIN_LINEAR_DELTA = 0.0001;
|
|
16
|
+
let linearPointIdCounter = 0;
|
|
17
|
+
const nextLinearPointId = () => {
|
|
18
|
+
linearPointIdCounter += 1;
|
|
19
|
+
return `linear-point-${linearPointIdCounter}`;
|
|
20
|
+
};
|
|
21
|
+
const ensureLinearPointId = (point) => {
|
|
22
|
+
if (!point.id) {
|
|
23
|
+
point.id = nextLinearPointId();
|
|
24
|
+
}
|
|
25
|
+
return point.id;
|
|
26
|
+
};
|
|
27
|
+
exports.ensureLinearPointId = ensureLinearPointId;
|
|
28
|
+
const cloneLinearPoint = (point) => {
|
|
29
|
+
const sourceId = (0, exports.ensureLinearPointId)(point);
|
|
30
|
+
return {
|
|
31
|
+
...point,
|
|
32
|
+
id: sourceId
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.cloneLinearPoint = cloneLinearPoint;
|
|
36
|
+
const cubicBezierPath = (points) => {
|
|
37
|
+
const { p1, p2 } = points;
|
|
38
|
+
const startX = 0;
|
|
39
|
+
const startY = 300;
|
|
40
|
+
const endX = 400;
|
|
41
|
+
const endY = 0;
|
|
42
|
+
const cp1x = p1.x * 400;
|
|
43
|
+
const cp1y = (1 - p1.y) * 300;
|
|
44
|
+
const cp2x = p2.x * 400;
|
|
45
|
+
const cp2y = (1 - p2.y) * 300;
|
|
46
|
+
return `M ${startX} ${startY} C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${endX} ${endY}`;
|
|
47
|
+
};
|
|
48
|
+
exports.cubicBezierPath = cubicBezierPath;
|
|
49
|
+
const linearDisplayPath = (points) => {
|
|
50
|
+
if (points.length < 2) {
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
53
|
+
const toSvg = (p) => {
|
|
54
|
+
return {
|
|
55
|
+
x: p.x * 400,
|
|
56
|
+
y: (1 - p.y) * 300
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const startPoint = points[0];
|
|
60
|
+
if (!startPoint) {
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
const start = toSvg(startPoint);
|
|
64
|
+
let d = `M ${start.x} ${start.y}`;
|
|
65
|
+
for (let index = 0; index < points.length - 1; index += 1) {
|
|
66
|
+
const p1 = points[index];
|
|
67
|
+
const p2 = points[index + 1];
|
|
68
|
+
if (!p1 || !p2) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const cp1 = {
|
|
72
|
+
x: p1.x + (p1.cpOutX ?? 0),
|
|
73
|
+
y: p1.y + (p1.cpOutY ?? 0)
|
|
74
|
+
};
|
|
75
|
+
const cp2 = {
|
|
76
|
+
x: p2.x + (p2.cpInX ?? 0),
|
|
77
|
+
y: p2.y + (p2.cpInY ?? 0)
|
|
78
|
+
};
|
|
79
|
+
if (cp1.x === p1.x && cp1.y === p1.y && cp2.x === p2.x && cp2.y === p2.y) {
|
|
80
|
+
const end = toSvg(p2);
|
|
81
|
+
d += ` L ${end.x} ${end.y}`;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const svgCp1 = toSvg(cp1);
|
|
85
|
+
const svgCp2 = toSvg(cp2);
|
|
86
|
+
const end = toSvg(p2);
|
|
87
|
+
d += ` C ${svgCp1.x} ${svgCp1.y}, ${svgCp2.x} ${svgCp2.y}, ${end.x} ${end.y}`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return d;
|
|
91
|
+
};
|
|
92
|
+
exports.linearDisplayPath = linearDisplayPath;
|
|
93
|
+
const perpendicularDistance = (point, lineStart, lineEnd) => {
|
|
94
|
+
const dx = lineEnd.x - lineStart.x;
|
|
95
|
+
const dy = lineEnd.y - lineStart.y;
|
|
96
|
+
if (dx === 0 && dy === 0) {
|
|
97
|
+
return Math.sqrt((point.x - lineStart.x) ** 2 + (point.y - lineStart.y) ** 2);
|
|
98
|
+
}
|
|
99
|
+
const numerator = Math.abs(dy * point.x - dx * point.y + lineEnd.x * lineStart.y - lineEnd.y * lineStart.x);
|
|
100
|
+
const denominator = Math.sqrt(dx * dx + dy * dy);
|
|
101
|
+
return numerator / denominator;
|
|
102
|
+
};
|
|
103
|
+
const simplifyPoints = (points, epsilon) => {
|
|
104
|
+
if (points.length < 3) {
|
|
105
|
+
return points;
|
|
106
|
+
}
|
|
107
|
+
let dmax = 0;
|
|
108
|
+
let index = 0;
|
|
109
|
+
const end = points.length - 1;
|
|
110
|
+
const startPoint = points[0];
|
|
111
|
+
const endPoint = points[end];
|
|
112
|
+
if (!startPoint || !endPoint) {
|
|
113
|
+
return points;
|
|
114
|
+
}
|
|
115
|
+
for (let i = 1; i < end; i++) {
|
|
116
|
+
const point = points[i];
|
|
117
|
+
if (!point) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const d = perpendicularDistance(point, startPoint, endPoint);
|
|
121
|
+
if (d > dmax) {
|
|
122
|
+
index = i;
|
|
123
|
+
dmax = d;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (dmax > epsilon) {
|
|
127
|
+
const recResults1 = simplifyPoints(points.slice(0, index + 1), epsilon);
|
|
128
|
+
const recResults2 = simplifyPoints(points.slice(index, end + 1), epsilon);
|
|
129
|
+
return [...recResults1.slice(0, -1), ...recResults2];
|
|
130
|
+
}
|
|
131
|
+
return [startPoint, endPoint];
|
|
132
|
+
};
|
|
133
|
+
const generateCubicBezierCSS = (points, name, variant = 'animation') => {
|
|
134
|
+
const { p1, p2 } = points;
|
|
135
|
+
const timingFunction = `cubic-bezier(${p1.x.toFixed(3)}, ${p1.y.toFixed(3)}, ${p2.x.toFixed(3)}, ${p2.y.toFixed(3)})`;
|
|
136
|
+
const code = `
|
|
137
|
+
.${name} {
|
|
138
|
+
${variant}-timing-function: ${timingFunction};
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
return {
|
|
142
|
+
code,
|
|
143
|
+
timingFunction
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
exports.generateCubicBezierCSS = generateCubicBezierCSS;
|
|
147
|
+
const getLinearApproximation = (points, options = {}) => {
|
|
148
|
+
const { simplify = 0, round = 5 } = options;
|
|
149
|
+
const samples = [];
|
|
150
|
+
const numSamplesPerSegment = 20;
|
|
151
|
+
const sortedPoints = [...points].sort((a, b) => a.x - b.x);
|
|
152
|
+
for (let index = 0; index < sortedPoints.length - 1; index += 1) {
|
|
153
|
+
const p1 = sortedPoints[index];
|
|
154
|
+
const p2 = sortedPoints[index + 1];
|
|
155
|
+
if (!p1 || !p2) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (index === 0) {
|
|
159
|
+
samples.push({ x: p1.x, y: p1.y });
|
|
160
|
+
}
|
|
161
|
+
const cp1 = {
|
|
162
|
+
x: p1.x + (p1.cpOutX ?? 0),
|
|
163
|
+
y: p1.y + (p1.cpOutY ?? 0)
|
|
164
|
+
};
|
|
165
|
+
const cp2 = {
|
|
166
|
+
x: p2.x + (p2.cpInX ?? 0),
|
|
167
|
+
y: p2.y + (p2.cpInY ?? 0)
|
|
168
|
+
};
|
|
169
|
+
for (let step = 1; step <= numSamplesPerSegment; step += 1) {
|
|
170
|
+
const t = step / numSamplesPerSegment;
|
|
171
|
+
const x = cubicBezier(t, p1.x, cp1.x, cp2.x, p2.x);
|
|
172
|
+
const y = cubicBezier(t, p1.y, cp1.y, cp2.y, p2.y);
|
|
173
|
+
samples.push({ x, y });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const normalizedSamples = [];
|
|
177
|
+
let lastX = -Infinity;
|
|
178
|
+
for (const sample of samples) {
|
|
179
|
+
const clampedX = Math.max(0, Math.min(1, sample.x));
|
|
180
|
+
const clampedY = Math.max(-2, Math.min(3, sample.y));
|
|
181
|
+
if (clampedX > lastX + exports.MIN_LINEAR_DELTA) {
|
|
182
|
+
normalizedSamples.push({ x: clampedX, y: clampedY });
|
|
183
|
+
lastX = clampedX;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (normalizedSamples.length < 2) {
|
|
187
|
+
return [
|
|
188
|
+
{ x: 0, y: 0 },
|
|
189
|
+
{ x: 1, y: 1 }
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
const firstPoint = sortedPoints[0];
|
|
193
|
+
if (firstPoint && Math.abs(firstPoint.x) < exports.MIN_LINEAR_DELTA && normalizedSamples.length > 0) {
|
|
194
|
+
const firstSample = normalizedSamples[0];
|
|
195
|
+
if (firstSample) {
|
|
196
|
+
firstSample.x = 0;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const lastPoint = sortedPoints[sortedPoints.length - 1];
|
|
200
|
+
if (lastPoint && Math.abs(lastPoint.x - 1) < exports.MIN_LINEAR_DELTA && normalizedSamples.length > 0) {
|
|
201
|
+
const lastSample = normalizedSamples[normalizedSamples.length - 1];
|
|
202
|
+
if (lastSample) {
|
|
203
|
+
lastSample.x = 1;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let finalSamples = normalizedSamples;
|
|
207
|
+
if (simplify > 0) {
|
|
208
|
+
finalSamples = simplifyPoints(normalizedSamples, simplify);
|
|
209
|
+
}
|
|
210
|
+
return finalSamples.map((sample) => {
|
|
211
|
+
return {
|
|
212
|
+
x: sample.x,
|
|
213
|
+
y: Number(sample.y.toFixed(round))
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
exports.getLinearApproximation = getLinearApproximation;
|
|
218
|
+
const generateLinearCSS = (points, name, variant = 'animation', options = {}) => {
|
|
219
|
+
if (!Array.isArray(points) || points.length < 2) {
|
|
220
|
+
return { code: '', timingFunction: '' };
|
|
221
|
+
}
|
|
222
|
+
const finalSamples = (0, exports.getLinearApproximation)(points, options);
|
|
223
|
+
const parts = finalSamples.map((sample) => {
|
|
224
|
+
const y = sample.y;
|
|
225
|
+
const x = Number((sample.x * 100).toFixed(2));
|
|
226
|
+
return `${y} ${x}%`;
|
|
227
|
+
});
|
|
228
|
+
const timingFunction = `linear(${parts.join(', ')})`;
|
|
229
|
+
const code = `
|
|
230
|
+
.${name} {
|
|
231
|
+
${variant}-timing-function: ${timingFunction};
|
|
232
|
+
}
|
|
233
|
+
`;
|
|
234
|
+
return { code, timingFunction };
|
|
235
|
+
};
|
|
236
|
+
exports.generateLinearCSS = generateLinearCSS;
|
|
237
|
+
const cubicBezierToLinear = (points, steps = 20) => {
|
|
238
|
+
const linearPoints = [];
|
|
239
|
+
for (let i = 0; i <= steps; i++) {
|
|
240
|
+
const t = i / steps;
|
|
241
|
+
const x = cubicBezier(t, 0, points.p1.x, points.p2.x, 1);
|
|
242
|
+
const y = cubicBezier(t, 0, points.p1.y, points.p2.y, 1);
|
|
243
|
+
linearPoints.push({ x, y });
|
|
244
|
+
}
|
|
245
|
+
return linearPoints;
|
|
246
|
+
};
|
|
247
|
+
exports.cubicBezierToLinear = cubicBezierToLinear;
|
|
248
|
+
const cubicBezier = (t, p0, p1, p2, p3) => {
|
|
249
|
+
const u = 1 - t;
|
|
250
|
+
const tt = t * t;
|
|
251
|
+
const uu = u * u;
|
|
252
|
+
const uuu = uu * u;
|
|
253
|
+
const ttt = tt * t;
|
|
254
|
+
return uuu * p0 + 3 * uu * t * p1 + 3 * u * tt * p2 + ttt * p3;
|
|
255
|
+
};
|
|
256
|
+
const validateCubicBezierPoints = (points) => {
|
|
257
|
+
const { p1, p2 } = points;
|
|
258
|
+
return p1.x >= 0 && p1.x <= 1 && p2.x >= 0 && p2.x <= 1;
|
|
259
|
+
};
|
|
260
|
+
exports.validateCubicBezierPoints = validateCubicBezierPoints;
|
|
261
|
+
const validateLinearPoints = (points) => {
|
|
262
|
+
if (points.length < 2) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
const sortedPoints = [...points].sort((a, b) => a.x - b.x);
|
|
266
|
+
for (let index = 0; index < sortedPoints.length; index += 1) {
|
|
267
|
+
const point = sortedPoints[index];
|
|
268
|
+
if (!point) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
if (point.x < 0 || point.x > 1) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
if (index >= sortedPoints.length - 1) {
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
const next = sortedPoints[index + 1];
|
|
278
|
+
if (!next) {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
if (next.x <= point.x + exports.MIN_LINEAR_DELTA) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const first = sortedPoints[0];
|
|
286
|
+
const last = sortedPoints[sortedPoints.length - 1];
|
|
287
|
+
if (first && Math.abs(first.x) > exports.MIN_LINEAR_DELTA) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
if (last && Math.abs(last.x - 1) > exports.MIN_LINEAR_DELTA) {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
return true;
|
|
294
|
+
};
|
|
295
|
+
exports.validateLinearPoints = validateLinearPoints;
|
|
296
|
+
const normalizeLinearPoints = (points) => {
|
|
297
|
+
if (points.length === 0) {
|
|
298
|
+
return [];
|
|
299
|
+
}
|
|
300
|
+
const normalized = [...points].sort((a, b) => a.x - b.x).map((point) => (0, exports.cloneLinearPoint)(point));
|
|
301
|
+
const first = normalized[0];
|
|
302
|
+
if (first) {
|
|
303
|
+
first.x = 0;
|
|
304
|
+
}
|
|
305
|
+
const last = normalized[normalized.length - 1];
|
|
306
|
+
if (last) {
|
|
307
|
+
last.x = 1;
|
|
308
|
+
}
|
|
309
|
+
for (let index = 0; index < normalized.length; index += 1) {
|
|
310
|
+
const point = normalized[index];
|
|
311
|
+
if (!point) {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
const minY = -2;
|
|
315
|
+
const maxY = 3;
|
|
316
|
+
point.y = Math.max(minY, Math.min(maxY, point.y));
|
|
317
|
+
if ((point.cpInX ?? 0) > 0) {
|
|
318
|
+
point.cpInX = 0;
|
|
319
|
+
}
|
|
320
|
+
if ((point.cpOutX ?? 0) < 0) {
|
|
321
|
+
point.cpOutX = 0;
|
|
322
|
+
}
|
|
323
|
+
const handleThreshold = 0;
|
|
324
|
+
if (Math.abs(point.cpInX ?? 0) < handleThreshold && Math.abs(point.cpInY ?? 0) < handleThreshold) {
|
|
325
|
+
delete point.cpInX;
|
|
326
|
+
delete point.cpInY;
|
|
327
|
+
}
|
|
328
|
+
if (Math.abs(point.cpOutX ?? 0) < handleThreshold && Math.abs(point.cpOutY ?? 0) < handleThreshold) {
|
|
329
|
+
delete point.cpOutX;
|
|
330
|
+
delete point.cpOutY;
|
|
331
|
+
}
|
|
332
|
+
if (point.cpInX === undefined && point.cpOutX === undefined) {
|
|
333
|
+
delete point.isLinked;
|
|
334
|
+
delete point.mirrorLength;
|
|
335
|
+
}
|
|
336
|
+
else if (point.isLinked !== true) {
|
|
337
|
+
point.mirrorLength = false;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return normalized;
|
|
341
|
+
};
|
|
342
|
+
exports.normalizeLinearPoints = normalizeLinearPoints;
|
|
343
|
+
const clamp01 = (value) => {
|
|
344
|
+
if (Number.isNaN(value)) {
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
|
347
|
+
return Math.min(1, Math.max(0, value));
|
|
348
|
+
};
|
|
349
|
+
const parseCubicBezierValue = (input) => {
|
|
350
|
+
const match = input.trim().match(/^cubic-bezier\s*\((.+)\)$/i);
|
|
351
|
+
if (!match) {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
const body = match[1];
|
|
355
|
+
if (!body) {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
const parts = body
|
|
359
|
+
.split(',')
|
|
360
|
+
.map((part) => Number.parseFloat(part.trim()))
|
|
361
|
+
.filter((value) => Number.isFinite(value));
|
|
362
|
+
if (parts.length !== 4) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
const [x1, y1, x2, y2] = parts;
|
|
366
|
+
if ([x1, y1, x2, y2].some((value) => Number.isNaN(value))) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
p1: { x: clamp01(x1), y: y1 },
|
|
371
|
+
p2: { x: clamp01(x2), y: y2 }
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
exports.parseCubicBezierValue = parseCubicBezierValue;
|
|
375
|
+
const ensureStopPositions = (stops) => {
|
|
376
|
+
if (stops.length === 0) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
const first = stops[0];
|
|
380
|
+
if (first && first.x == null) {
|
|
381
|
+
first.x = 0;
|
|
382
|
+
}
|
|
383
|
+
const lastIndex = stops.length - 1;
|
|
384
|
+
const last = stops[lastIndex];
|
|
385
|
+
if (last && last.x == null) {
|
|
386
|
+
last.x = 1;
|
|
387
|
+
}
|
|
388
|
+
const assignBetween = (startIndex, endIndex) => {
|
|
389
|
+
const startStop = stops[startIndex];
|
|
390
|
+
const endStop = stops[endIndex];
|
|
391
|
+
if (!startStop || !endStop || startStop.x == null || endStop.x == null) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const span = endStop.x - startStop.x;
|
|
395
|
+
const segments = endIndex - startIndex;
|
|
396
|
+
if (segments <= 1) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
for (let offset = 1; offset < segments; offset += 1) {
|
|
400
|
+
const index = startIndex + offset;
|
|
401
|
+
const ratio = offset / segments;
|
|
402
|
+
const target = stops[index];
|
|
403
|
+
if (target) {
|
|
404
|
+
target.x = startStop.x + span * ratio;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
let lastDefined = 0;
|
|
409
|
+
for (let index = 1; index < stops.length; index += 1) {
|
|
410
|
+
if (stops[index]?.x != null) {
|
|
411
|
+
assignBetween(lastDefined, index);
|
|
412
|
+
lastDefined = index;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (lastDefined < stops.length - 1) {
|
|
416
|
+
assignBetween(lastDefined, stops.length - 1);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
const parseLinearTimingFunction = (input) => {
|
|
420
|
+
const match = input.trim().match(/^linear\s*\((.+)\)$/is);
|
|
421
|
+
if (!match) {
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
const body = match[1];
|
|
425
|
+
if (!body) {
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
const segments = body
|
|
429
|
+
.split(',')
|
|
430
|
+
.map((segment) => segment.trim())
|
|
431
|
+
.filter((segment) => segment.length > 0);
|
|
432
|
+
if (segments.length < 2) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
const stops = [];
|
|
436
|
+
for (const segment of segments) {
|
|
437
|
+
const parts = segment.split(/\s+/).filter((part) => part.length > 0);
|
|
438
|
+
if (parts.length === 0) {
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const valueToken = parts[0];
|
|
442
|
+
if (!valueToken) {
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
const value = Number.parseFloat(valueToken);
|
|
446
|
+
if (Number.isNaN(value)) {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
let position = null;
|
|
450
|
+
for (let index = 1; index < parts.length; index += 1) {
|
|
451
|
+
const token = parts[index];
|
|
452
|
+
if (!token) {
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
const percentMatch = token.match(/^(-?\d+(?:\.\d+)?)%$/);
|
|
456
|
+
if (percentMatch) {
|
|
457
|
+
const [, percentValue] = percentMatch;
|
|
458
|
+
if (percentValue === undefined) {
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
const parsed = Number.parseFloat(percentValue);
|
|
462
|
+
if (!Number.isNaN(parsed)) {
|
|
463
|
+
position = clamp01(parsed / 100);
|
|
464
|
+
}
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
stops.push({ y: value, x: position });
|
|
469
|
+
}
|
|
470
|
+
if (stops.length < 2) {
|
|
471
|
+
return null;
|
|
472
|
+
}
|
|
473
|
+
ensureStopPositions(stops);
|
|
474
|
+
const rawPoints = stops.map((stop) => {
|
|
475
|
+
const x = stop.x ?? 0;
|
|
476
|
+
return { x: clamp01(x), y: stop.y };
|
|
477
|
+
});
|
|
478
|
+
return (0, exports.normalizeLinearPoints)(rawPoints);
|
|
479
|
+
};
|
|
480
|
+
exports.parseLinearTimingFunction = parseLinearTimingFunction;
|
|
481
|
+
const vectorLength = (dx, dy) => Math.sqrt(dx * dx + dy * dy);
|
|
482
|
+
exports.vectorLength = vectorLength;
|
|
483
|
+
const normalizeVector = (dx, dy) => {
|
|
484
|
+
const length = (0, exports.vectorLength)(dx, dy);
|
|
485
|
+
if (length === 0) {
|
|
486
|
+
return { dx: 0, dy: 0 };
|
|
487
|
+
}
|
|
488
|
+
return { dx: dx / length, dy: dy / length };
|
|
489
|
+
};
|
|
490
|
+
exports.normalizeVector = normalizeVector;
|
|
491
|
+
const smoothLinearPoints = (points, tension = 0.25) => {
|
|
492
|
+
if (points.length < 2) {
|
|
493
|
+
return points;
|
|
494
|
+
}
|
|
495
|
+
return points.map((point, index) => {
|
|
496
|
+
const prev = points[index - 1];
|
|
497
|
+
const next = points[index + 1];
|
|
498
|
+
const smoothedPoint = { ...point, isLinked: true, mirrorLength: true };
|
|
499
|
+
if (index === 0 && next) {
|
|
500
|
+
const dx = next.x - point.x;
|
|
501
|
+
const dy = next.y - point.y;
|
|
502
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
503
|
+
const handleLength = length * tension;
|
|
504
|
+
if (length > 0) {
|
|
505
|
+
smoothedPoint.cpOutX = (dx / length) * handleLength;
|
|
506
|
+
smoothedPoint.cpOutY = (dy / length) * handleLength;
|
|
507
|
+
}
|
|
508
|
+
return smoothedPoint;
|
|
509
|
+
}
|
|
510
|
+
if (index === points.length - 1 && prev) {
|
|
511
|
+
const dx = point.x - prev.x;
|
|
512
|
+
const dy = point.y - prev.y;
|
|
513
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
514
|
+
const handleLength = length * tension;
|
|
515
|
+
if (length > 0) {
|
|
516
|
+
smoothedPoint.cpInX = -(dx / length) * handleLength;
|
|
517
|
+
smoothedPoint.cpInY = -(dy / length) * handleLength;
|
|
518
|
+
}
|
|
519
|
+
return smoothedPoint;
|
|
520
|
+
}
|
|
521
|
+
if (prev && next) {
|
|
522
|
+
const tangentX = next.x - prev.x;
|
|
523
|
+
const tangentY = next.y - prev.y;
|
|
524
|
+
const tangentLength = Math.sqrt(tangentX * tangentX + tangentY * tangentY);
|
|
525
|
+
if (tangentLength > 0) {
|
|
526
|
+
const normalizedTx = tangentX / tangentLength;
|
|
527
|
+
const normalizedTy = tangentY / tangentLength;
|
|
528
|
+
const distToPrev = Math.sqrt((point.x - prev.x) ** 2 + (point.y - prev.y) ** 2);
|
|
529
|
+
const distToNext = Math.sqrt((next.x - point.x) ** 2 + (next.y - point.y) ** 2);
|
|
530
|
+
const inHandleLength = distToPrev * tension;
|
|
531
|
+
const outHandleLength = distToNext * tension;
|
|
532
|
+
smoothedPoint.cpInX = -normalizedTx * inHandleLength;
|
|
533
|
+
smoothedPoint.cpInY = -normalizedTy * inHandleLength;
|
|
534
|
+
smoothedPoint.cpOutX = normalizedTx * outHandleLength;
|
|
535
|
+
smoothedPoint.cpOutY = normalizedTy * outHandleLength;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return smoothedPoint;
|
|
539
|
+
});
|
|
540
|
+
};
|
|
541
|
+
exports.smoothLinearPoints = smoothLinearPoints;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CSSCode, CubicBezierPoints, LinearPoint, LinearPoints, Point } from "./types.cjs";
|
|
2
|
+
export declare const clampPoint: (point: Point, bounds?: {
|
|
3
|
+
minX?: number;
|
|
4
|
+
maxX?: number;
|
|
5
|
+
minY?: number;
|
|
6
|
+
maxY?: number;
|
|
7
|
+
}) => Point;
|
|
8
|
+
export declare const MIN_LINEAR_DELTA = 0.0001;
|
|
9
|
+
export declare const ensureLinearPointId: (point: LinearPoint) => string;
|
|
10
|
+
export declare const cloneLinearPoint: (point: LinearPoint) => LinearPoint;
|
|
11
|
+
export declare const cubicBezierPath: (points: CubicBezierPoints) => string;
|
|
12
|
+
export declare const linearDisplayPath: (points: LinearPoints) => string;
|
|
13
|
+
export declare const generateCubicBezierCSS: (points: CubicBezierPoints, name: string, variant?: "animation" | "transition") => CSSCode;
|
|
14
|
+
export declare const getLinearApproximation: (points: LinearPoints, options?: {
|
|
15
|
+
simplify?: number;
|
|
16
|
+
round?: number;
|
|
17
|
+
}) => Point[];
|
|
18
|
+
export declare const generateLinearCSS: (points: LinearPoints | undefined, name: string, variant?: "animation" | "transition", options?: {
|
|
19
|
+
simplify?: number;
|
|
20
|
+
round?: number;
|
|
21
|
+
}) => CSSCode;
|
|
22
|
+
export declare const cubicBezierToLinear: (points: CubicBezierPoints, steps?: number) => LinearPoints;
|
|
23
|
+
export declare const validateCubicBezierPoints: (points: CubicBezierPoints) => boolean;
|
|
24
|
+
export declare const validateLinearPoints: (points: LinearPoints) => boolean;
|
|
25
|
+
export declare const normalizeLinearPoints: (points: LinearPoints) => LinearPoints;
|
|
26
|
+
export declare const parseCubicBezierValue: (input: string) => CubicBezierPoints | null;
|
|
27
|
+
export declare const parseLinearTimingFunction: (input: string) => LinearPoints | null;
|
|
28
|
+
export declare const vectorLength: (dx: number, dy: number) => number;
|
|
29
|
+
export declare const normalizeVector: (dx: number, dy: number) => {
|
|
30
|
+
dx: number;
|
|
31
|
+
dy: number;
|
|
32
|
+
};
|
|
33
|
+
export declare const smoothLinearPoints: (points: LinearPoints, tension?: number) => LinearPoints;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CSSCode, CubicBezierPoints, LinearPoint, LinearPoints, Point } from "./types.js";
|
|
2
|
+
export declare const clampPoint: (point: Point, bounds?: {
|
|
3
|
+
minX?: number;
|
|
4
|
+
maxX?: number;
|
|
5
|
+
minY?: number;
|
|
6
|
+
maxY?: number;
|
|
7
|
+
}) => Point;
|
|
8
|
+
export declare const MIN_LINEAR_DELTA = 0.0001;
|
|
9
|
+
export declare const ensureLinearPointId: (point: LinearPoint) => string;
|
|
10
|
+
export declare const cloneLinearPoint: (point: LinearPoint) => LinearPoint;
|
|
11
|
+
export declare const cubicBezierPath: (points: CubicBezierPoints) => string;
|
|
12
|
+
export declare const linearDisplayPath: (points: LinearPoints) => string;
|
|
13
|
+
export declare const generateCubicBezierCSS: (points: CubicBezierPoints, name: string, variant?: "animation" | "transition") => CSSCode;
|
|
14
|
+
export declare const getLinearApproximation: (points: LinearPoints, options?: {
|
|
15
|
+
simplify?: number;
|
|
16
|
+
round?: number;
|
|
17
|
+
}) => Point[];
|
|
18
|
+
export declare const generateLinearCSS: (points: LinearPoints | undefined, name: string, variant?: "animation" | "transition", options?: {
|
|
19
|
+
simplify?: number;
|
|
20
|
+
round?: number;
|
|
21
|
+
}) => CSSCode;
|
|
22
|
+
export declare const cubicBezierToLinear: (points: CubicBezierPoints, steps?: number) => LinearPoints;
|
|
23
|
+
export declare const validateCubicBezierPoints: (points: CubicBezierPoints) => boolean;
|
|
24
|
+
export declare const validateLinearPoints: (points: LinearPoints) => boolean;
|
|
25
|
+
export declare const normalizeLinearPoints: (points: LinearPoints) => LinearPoints;
|
|
26
|
+
export declare const parseCubicBezierValue: (input: string) => CubicBezierPoints | null;
|
|
27
|
+
export declare const parseLinearTimingFunction: (input: string) => LinearPoints | null;
|
|
28
|
+
export declare const vectorLength: (dx: number, dy: number) => number;
|
|
29
|
+
export declare const normalizeVector: (dx: number, dy: number) => {
|
|
30
|
+
dx: number;
|
|
31
|
+
dy: number;
|
|
32
|
+
};
|
|
33
|
+
export declare const smoothLinearPoints: (points: LinearPoints, tension?: number) => LinearPoints;
|