@baleada/logic 0.20.11 → 0.20.12

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/lib/index.cjs CHANGED
@@ -6,6 +6,8 @@ var lazyCollections = require('lazy-collections');
6
6
  var slugify = require('@sindresorhus/slugify');
7
7
  var BezierEasing = require('bezier-easing');
8
8
  var color = require('@snigo.dev/color');
9
+ var perfectFreehand = require('perfect-freehand');
10
+ var polygonClipping = require('polygon-clipping');
9
11
  var createDOMPurify = require('dompurify');
10
12
  var fastFuzzy = require('fast-fuzzy');
11
13
 
@@ -13,6 +15,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
13
15
 
14
16
  var slugify__default = /*#__PURE__*/_interopDefaultLegacy(slugify);
15
17
  var BezierEasing__default = /*#__PURE__*/_interopDefaultLegacy(BezierEasing);
18
+ var polygonClipping__default = /*#__PURE__*/_interopDefaultLegacy(polygonClipping);
16
19
  var createDOMPurify__default = /*#__PURE__*/_interopDefaultLegacy(createDOMPurify);
17
20
 
18
21
  function createReduceAsync(reduce, initialValue) {
@@ -1086,7 +1089,7 @@ const observerAssertionsByType = {
1086
1089
  resize: (observer) => observer instanceof ResizeObserver
1087
1090
  };
1088
1091
 
1089
- const defaultOptions$4 = {
1092
+ const defaultOptions$5 = {
1090
1093
  duration: 0,
1091
1094
  timing: [
1092
1095
  0,
@@ -1099,10 +1102,10 @@ const defaultOptions$4 = {
1099
1102
  };
1100
1103
  class Animateable {
1101
1104
  constructor(keyframes, options = {}) {
1102
- this.initialDuration = options?.duration || defaultOptions$4.duration;
1103
- this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$4.timing);
1104
- this.iterationLimit = options?.iterations || defaultOptions$4.iterations;
1105
- this.alternates = options?.alternates || defaultOptions$4.alternates;
1105
+ this.initialDuration = options?.duration || defaultOptions$5.duration;
1106
+ this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$5.timing);
1107
+ this.iterationLimit = options?.iterations || defaultOptions$5.iterations;
1108
+ this.alternates = options?.alternates || defaultOptions$5.alternates;
1106
1109
  this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
1107
1110
  this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
1108
1111
  this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
@@ -1767,8 +1770,188 @@ function toInterpolated({ previous, next, progress }, options = {}) {
1767
1770
  return createSlice({ from: 0, to: sliceEnd })(sliceTarget);
1768
1771
  }
1769
1772
  }
1773
+ const linear = [
1774
+ 0,
1775
+ 0,
1776
+ 1,
1777
+ 1
1778
+ ];
1779
+ const materialStandard = [
1780
+ 0.4,
1781
+ 0,
1782
+ 0.2,
1783
+ 1
1784
+ ];
1785
+ const materialDecelerated = [
1786
+ 0,
1787
+ 0,
1788
+ 0.2,
1789
+ 1
1790
+ ];
1791
+ const materialAccelerated = [
1792
+ 0.4,
1793
+ 0,
1794
+ 1,
1795
+ 1
1796
+ ];
1797
+ const verouEase = [
1798
+ 0.25,
1799
+ 0.1,
1800
+ 0.25,
1801
+ 1
1802
+ ];
1803
+ const verouEaseIn = [
1804
+ 0.42,
1805
+ 0,
1806
+ 1,
1807
+ 1
1808
+ ];
1809
+ const verouEaseOut = [
1810
+ 0,
1811
+ 0,
1812
+ 0.58,
1813
+ 1
1814
+ ];
1815
+ const verouEaseInOut = [
1816
+ 0.42,
1817
+ 0,
1818
+ 0.58,
1819
+ 1
1820
+ ];
1821
+ const easingsNetInSine = [
1822
+ 0.12,
1823
+ 0,
1824
+ 0.39,
1825
+ 0
1826
+ ];
1827
+ const easingsNetOutSine = [
1828
+ 0.61,
1829
+ 1,
1830
+ 0.88,
1831
+ 1
1832
+ ];
1833
+ const easingsNetInOutSine = [
1834
+ 0.37,
1835
+ 0,
1836
+ 0.63,
1837
+ 1
1838
+ ];
1839
+ const easingsNetInQuad = [
1840
+ 0.11,
1841
+ 0,
1842
+ 0.5,
1843
+ 0
1844
+ ];
1845
+ const easingsNetOutQuad = [
1846
+ 0.5,
1847
+ 1,
1848
+ 0.89,
1849
+ 1
1850
+ ];
1851
+ const easingsNetInOutQuad = [
1852
+ 0.45,
1853
+ 0,
1854
+ 0.55,
1855
+ 1
1856
+ ];
1857
+ const easingsNetInCubic = [
1858
+ 0.32,
1859
+ 0,
1860
+ 0.67,
1861
+ 0
1862
+ ];
1863
+ const easingsNetOutCubic = [
1864
+ 0.33,
1865
+ 1,
1866
+ 0.68,
1867
+ 1
1868
+ ];
1869
+ const easingsNetInOutCubic = [
1870
+ 0.65,
1871
+ 0,
1872
+ 0.35,
1873
+ 1
1874
+ ];
1875
+ const easingsNetInQuart = [
1876
+ 0.5,
1877
+ 0,
1878
+ 0.75,
1879
+ 0
1880
+ ];
1881
+ const easingsNetInQuint = [
1882
+ 0.64,
1883
+ 0,
1884
+ 0.78,
1885
+ 0
1886
+ ];
1887
+ const easingsNetOutQuint = [
1888
+ 0.22,
1889
+ 1,
1890
+ 0.36,
1891
+ 1
1892
+ ];
1893
+ const easingsNetInOutQuint = [
1894
+ 0.83,
1895
+ 0,
1896
+ 0.17,
1897
+ 1
1898
+ ];
1899
+ const easingsNetInExpo = [
1900
+ 0.7,
1901
+ 0,
1902
+ 0.84,
1903
+ 0
1904
+ ];
1905
+ const easingsNetOutExpo = [
1906
+ 0.16,
1907
+ 1,
1908
+ 0.3,
1909
+ 1
1910
+ ];
1911
+ const easingsNetInOutExpo = [
1912
+ 0.87,
1913
+ 0,
1914
+ 0.13,
1915
+ 1
1916
+ ];
1917
+ const easingsNetInCirc = [
1918
+ 0.55,
1919
+ 0,
1920
+ 1,
1921
+ 0.45
1922
+ ];
1923
+ const easingsNetOutCirc = [
1924
+ 0,
1925
+ 0.55,
1926
+ 0.45,
1927
+ 1
1928
+ ];
1929
+ const easingsNetInOutCirc = [
1930
+ 0.85,
1931
+ 0,
1932
+ 0.15,
1933
+ 1
1934
+ ];
1935
+ const easingsNetInBack = [
1936
+ 0.36,
1937
+ 0,
1938
+ 0.66,
1939
+ -0.56
1940
+ ];
1941
+ const easingsNetOutBack = [
1942
+ 0.34,
1943
+ 1.56,
1944
+ 0.64,
1945
+ 1
1946
+ ];
1947
+ const easingsNetInOutBack = [
1948
+ 0.68,
1949
+ -0.6,
1950
+ 0.32,
1951
+ 1.6
1952
+ ];
1770
1953
 
1771
- const defaultOptions$3 = {
1954
+ const defaultOptions$4 = {
1772
1955
  segment: {
1773
1956
  from: "start",
1774
1957
  to: "end"
@@ -1781,9 +1964,9 @@ const defaultCompleteOptions = {
1781
1964
  class Completeable {
1782
1965
  constructor(string, options = {}) {
1783
1966
  this.constructing();
1784
- this.segmentFrom = options?.segment?.from || defaultOptions$3.segment.from;
1785
- this.segmentTo = options?.segment?.to || defaultOptions$3.segment.to;
1786
- this.divider = options?.divider || defaultOptions$3.divider;
1967
+ this.segmentFrom = options?.segment?.from || defaultOptions$4.segment.from;
1968
+ this.segmentTo = options?.segment?.to || defaultOptions$4.segment.to;
1969
+ this.divider = options?.divider || defaultOptions$4.divider;
1787
1970
  this.computedDividerIndices = { before: 0, after: 0 };
1788
1971
  this.setString(string);
1789
1972
  this.setSelection(options?.initialSelection || { start: string.length, end: string.length, direction: "none" });
@@ -2013,7 +2196,7 @@ class Copyable {
2013
2196
  }
2014
2197
  }
2015
2198
 
2016
- const defaultOptions$2 = {
2199
+ const defaultOptions$3 = {
2017
2200
  delay: 0,
2018
2201
  executions: 1
2019
2202
  };
@@ -2023,8 +2206,8 @@ class Delayable {
2023
2206
  { progress: 0, properties: { progress: 0 } },
2024
2207
  { progress: 1, properties: { progress: 1 } }
2025
2208
  ], {
2026
- duration: options?.delay ?? defaultOptions$2.delay,
2027
- iterations: options?.executions ?? defaultOptions$2.executions
2209
+ duration: options?.delay ?? defaultOptions$3.delay,
2210
+ iterations: options?.executions ?? defaultOptions$3.executions
2028
2211
  });
2029
2212
  this.setEffect(effect);
2030
2213
  this.ready();
@@ -2188,6 +2371,66 @@ class Dispatchable {
2188
2371
  }
2189
2372
  }
2190
2373
 
2374
+ const defaultOptions$2 = {
2375
+ toD: (stroke) => stroke.length === 0 ? "" : toD(stroke)
2376
+ };
2377
+ class Drawable {
2378
+ constructor(stroke, options = {}) {
2379
+ this.toD = options?.toD || defaultOptions$2.toD;
2380
+ this.setStroke(stroke);
2381
+ this.ready();
2382
+ }
2383
+ ready() {
2384
+ this.computedStatus = "ready";
2385
+ }
2386
+ get stroke() {
2387
+ return this.computedStroke;
2388
+ }
2389
+ set stroke(stroke) {
2390
+ this.setStroke(stroke);
2391
+ }
2392
+ get status() {
2393
+ return this.computedStatus;
2394
+ }
2395
+ get d() {
2396
+ return this.computedD;
2397
+ }
2398
+ setStroke(stroke) {
2399
+ this.computedStroke = stroke;
2400
+ this.computedD = this.toD(stroke);
2401
+ return this;
2402
+ }
2403
+ draw(points, options) {
2404
+ this.drawing();
2405
+ this.stroke = perfectFreehand.getStroke(points, options);
2406
+ this.drawn();
2407
+ return this;
2408
+ }
2409
+ drawing() {
2410
+ this.computedStatus = "drawing";
2411
+ }
2412
+ drawn() {
2413
+ this.computedStatus = "drawn";
2414
+ }
2415
+ }
2416
+ function toD(stroke) {
2417
+ return createReduce((d, [x0, y0], index) => {
2418
+ const [x1, y1] = stroke[(index + 1) % stroke.length];
2419
+ return `${d} ${x0} ${y0} ${(x0 + x1) / 2} ${(y0 + y1) / 2}`;
2420
+ }, `M ${stroke[0][0]} ${stroke[0][1]} Q`)(stroke) + "Z";
2421
+ }
2422
+ function toFlattenedD(stroke) {
2423
+ if (stroke.length === 0) {
2424
+ return "";
2425
+ }
2426
+ const multiPolygon = polygonClipping__default['default'].union([stroke]);
2427
+ return createReduce((dFromMultiPolygon, polygon) => {
2428
+ return dFromMultiPolygon + createReduce((dFromRing, points) => {
2429
+ return dFromRing + toD(points);
2430
+ }, "")(polygon);
2431
+ }, "")(multiPolygon);
2432
+ }
2433
+
2191
2434
  class Resolveable {
2192
2435
  constructor(getPromise, options = {}) {
2193
2436
  this.setGetPromise(getPromise);
@@ -2774,6 +3017,7 @@ exports.Completeable = Completeable;
2774
3017
  exports.Copyable = Copyable;
2775
3018
  exports.Delayable = Delayable;
2776
3019
  exports.Dispatchable = Dispatchable;
3020
+ exports.Drawable = Drawable;
2777
3021
  exports.Fetchable = Fetchable;
2778
3022
  exports.Fullscreenable = Fullscreenable;
2779
3023
  exports.Grantable = Grantable;
@@ -2805,5 +3049,37 @@ exports.createSlice = createSlice;
2805
3049
  exports.createSlug = createSlug;
2806
3050
  exports.createSwap = createSwap;
2807
3051
  exports.createUnique = createUnique;
3052
+ exports.easingsNetInBack = easingsNetInBack;
3053
+ exports.easingsNetInCirc = easingsNetInCirc;
3054
+ exports.easingsNetInCubic = easingsNetInCubic;
3055
+ exports.easingsNetInExpo = easingsNetInExpo;
3056
+ exports.easingsNetInOutBack = easingsNetInOutBack;
3057
+ exports.easingsNetInOutCirc = easingsNetInOutCirc;
3058
+ exports.easingsNetInOutCubic = easingsNetInOutCubic;
3059
+ exports.easingsNetInOutExpo = easingsNetInOutExpo;
3060
+ exports.easingsNetInOutQuad = easingsNetInOutQuad;
3061
+ exports.easingsNetInOutQuint = easingsNetInOutQuint;
3062
+ exports.easingsNetInOutSine = easingsNetInOutSine;
3063
+ exports.easingsNetInQuad = easingsNetInQuad;
3064
+ exports.easingsNetInQuart = easingsNetInQuart;
3065
+ exports.easingsNetInQuint = easingsNetInQuint;
3066
+ exports.easingsNetInSine = easingsNetInSine;
3067
+ exports.easingsNetOutBack = easingsNetOutBack;
3068
+ exports.easingsNetOutCirc = easingsNetOutCirc;
3069
+ exports.easingsNetOutCubic = easingsNetOutCubic;
3070
+ exports.easingsNetOutExpo = easingsNetOutExpo;
3071
+ exports.easingsNetOutQuad = easingsNetOutQuad;
3072
+ exports.easingsNetOutQuint = easingsNetOutQuint;
3073
+ exports.easingsNetOutSine = easingsNetOutSine;
2808
3074
  exports.ensureKeycombo = ensureKeycombo;
2809
3075
  exports.eventMatchesKeycombo = eventMatchesKeycombo;
3076
+ exports.linear = linear;
3077
+ exports.materialAccelerated = materialAccelerated;
3078
+ exports.materialDecelerated = materialDecelerated;
3079
+ exports.materialStandard = materialStandard;
3080
+ exports.toD = toD;
3081
+ exports.toFlattenedD = toFlattenedD;
3082
+ exports.verouEase = verouEase;
3083
+ exports.verouEaseIn = verouEaseIn;
3084
+ exports.verouEaseInOut = verouEaseInOut;
3085
+ exports.verouEaseOut = verouEaseOut;
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { getStroke, StrokeOptions } from 'perfect-freehand';
1
2
  import createDOMPurify, { Config } from 'dompurify';
2
3
  import { FullOptions, MatchData, Searcher } from 'fast-fuzzy';
3
4
  import { Options } from '@sindresorhus/slugify';
@@ -111,6 +112,36 @@ declare class Animateable {
111
112
  stop(): this;
112
113
  private stopped;
113
114
  }
115
+ declare const linear: AnimateableKeyframe['timing'];
116
+ declare const materialStandard: AnimateableKeyframe['timing'];
117
+ declare const materialDecelerated: AnimateableKeyframe['timing'];
118
+ declare const materialAccelerated: AnimateableKeyframe['timing'];
119
+ declare const verouEase: AnimateableKeyframe['timing'];
120
+ declare const verouEaseIn: AnimateableKeyframe['timing'];
121
+ declare const verouEaseOut: AnimateableKeyframe['timing'];
122
+ declare const verouEaseInOut: AnimateableKeyframe['timing'];
123
+ declare const easingsNetInSine: AnimateableKeyframe['timing'];
124
+ declare const easingsNetOutSine: AnimateableKeyframe['timing'];
125
+ declare const easingsNetInOutSine: AnimateableKeyframe['timing'];
126
+ declare const easingsNetInQuad: AnimateableKeyframe['timing'];
127
+ declare const easingsNetOutQuad: AnimateableKeyframe['timing'];
128
+ declare const easingsNetInOutQuad: AnimateableKeyframe['timing'];
129
+ declare const easingsNetInCubic: AnimateableKeyframe['timing'];
130
+ declare const easingsNetOutCubic: AnimateableKeyframe['timing'];
131
+ declare const easingsNetInOutCubic: AnimateableKeyframe['timing'];
132
+ declare const easingsNetInQuart: AnimateableKeyframe['timing'];
133
+ declare const easingsNetInQuint: AnimateableKeyframe['timing'];
134
+ declare const easingsNetOutQuint: AnimateableKeyframe['timing'];
135
+ declare const easingsNetInOutQuint: AnimateableKeyframe['timing'];
136
+ declare const easingsNetInExpo: AnimateableKeyframe['timing'];
137
+ declare const easingsNetOutExpo: AnimateableKeyframe['timing'];
138
+ declare const easingsNetInOutExpo: AnimateableKeyframe['timing'];
139
+ declare const easingsNetInCirc: AnimateableKeyframe['timing'];
140
+ declare const easingsNetOutCirc: AnimateableKeyframe['timing'];
141
+ declare const easingsNetInOutCirc: AnimateableKeyframe['timing'];
142
+ declare const easingsNetInBack: AnimateableKeyframe['timing'];
143
+ declare const easingsNetOutBack: AnimateableKeyframe['timing'];
144
+ declare const easingsNetInOutBack: AnimateableKeyframe['timing'];
114
145
 
115
146
  declare type CompleteableOptions = {
116
147
  segment?: {
@@ -534,6 +565,29 @@ declare type DocumentEventInitMap = {
534
565
  "visibilitychange": EventInit;
535
566
  };
536
567
 
568
+ declare type DrawableOptions = {
569
+ toD?: (stroke: ReturnType<typeof getStroke>) => string;
570
+ };
571
+ declare type DrawableStatus = 'ready' | 'drawing' | 'drawn';
572
+ declare class Drawable {
573
+ private computedD;
574
+ private toD;
575
+ constructor(stroke: ReturnType<typeof getStroke>, options?: DrawableOptions);
576
+ computedStatus: DrawableStatus;
577
+ private ready;
578
+ get stroke(): number[][];
579
+ set stroke(stroke: number[][]);
580
+ get status(): DrawableStatus;
581
+ get d(): string;
582
+ private computedStroke;
583
+ setStroke(stroke: ReturnType<typeof getStroke>): this;
584
+ draw(points: Parameters<typeof getStroke>[0], options?: StrokeOptions): this;
585
+ private drawing;
586
+ private drawn;
587
+ }
588
+ declare function toD(stroke: number[][]): string;
589
+ declare function toFlattenedD(stroke: number[][]): string;
590
+
537
591
  declare type ResolveableOptions = Record<string, never>;
538
592
  declare type ResolveableGetPromise<Value> = (...args: any[]) => (Promise<Value> | Promise<Value>[]);
539
593
  declare type ResolveableStatus = 'ready' | 'resolving' | 'resolved' | 'errored';
@@ -808,4 +862,4 @@ declare class Pipeable {
808
862
  pipeAsync(...fns: ((...args: any[]) => Promise<any>)[]): Promise<any>;
809
863
  }
810
864
 
811
- export { AnimateFrame, AnimateFrameEffect, AnimateOptions, Animateable, AnimateableKeyframe, AnimateableOptions, AnimateableStatus, ArrayFunction, ArrayFunctionAsync, CompleteOptions, Completeable, CompleteableOptions, CompleteableStatus, Copyable, CopyableOptions, CopyableStatus, Delayable, DelayableEffect, DelayableOptions, DelayableStatus, DispatchOptions, Dispatchable, DispatchableOptions, DispatchableStatus, FetchOptions, FetchOptionsApi, Fetchable, FetchableOptions, FetchableStatus, Fullscreenable, FullscreenableGetElement, FullscreenableOptions, FullscreenableStatus, Grantable, GrantableOptions, GrantableStatus, ListenEffect, ListenEffectParam, ListenOptions, Listenable, ListenableActive, ListenableClickcombo, ListenableKeycombo, ListenableKeycomboItem, ListenableOptions, ListenablePointercombo, ListenableStatus, ListenableSupportedEventType, ListenableSupportedType, MapFunction, Navigateable, NavigateableOptions, NavigateableStatus, NumberFunction, Pipeable, RecognizeOptions, Recognizeable, RecognizeableEffectApi, RecognizeableOptions, RecognizeableStatus, Resolveable, ResolveableGetPromise, ResolveableOptions, ResolveableStatus, Sanitizeable, SanitizeableOptions, SanitizeableStatus, Searchable, SearchableOptions, SearchableStatus, Storeable, StoreableOptions, StoreableStatus, StringFunction, createClamp, createClip, createConcat, createDelete, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSwap, createUnique, ensureKeycombo, eventMatchesKeycombo };
865
+ export { AnimateFrame, AnimateFrameEffect, AnimateOptions, Animateable, AnimateableKeyframe, AnimateableOptions, AnimateableStatus, ArrayFunction, ArrayFunctionAsync, CompleteOptions, Completeable, CompleteableOptions, CompleteableStatus, Copyable, CopyableOptions, CopyableStatus, Delayable, DelayableEffect, DelayableOptions, DelayableStatus, DispatchOptions, Dispatchable, DispatchableOptions, DispatchableStatus, Drawable, DrawableOptions, DrawableStatus, FetchOptions, FetchOptionsApi, Fetchable, FetchableOptions, FetchableStatus, Fullscreenable, FullscreenableGetElement, FullscreenableOptions, FullscreenableStatus, Grantable, GrantableOptions, GrantableStatus, ListenEffect, ListenEffectParam, ListenOptions, Listenable, ListenableActive, ListenableClickcombo, ListenableKeycombo, ListenableKeycomboItem, ListenableOptions, ListenablePointercombo, ListenableStatus, ListenableSupportedEventType, ListenableSupportedType, MapFunction, Navigateable, NavigateableOptions, NavigateableStatus, NumberFunction, Pipeable, RecognizeOptions, Recognizeable, RecognizeableEffectApi, RecognizeableOptions, RecognizeableStatus, Resolveable, ResolveableGetPromise, ResolveableOptions, ResolveableStatus, Sanitizeable, SanitizeableOptions, SanitizeableStatus, Searchable, SearchableOptions, SearchableStatus, Storeable, StoreableOptions, StoreableStatus, StringFunction, createClamp, createClip, createConcat, createDelete, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSwap, createUnique, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, ensureKeycombo, eventMatchesKeycombo, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
package/lib/index.js CHANGED
@@ -2,6 +2,8 @@ import { reduce, pipe, filter, toArray, findIndex, slice, concat, unique as uniq
2
2
  import slugify from '@sindresorhus/slugify';
3
3
  import BezierEasing from 'bezier-easing';
4
4
  import { mix } from '@snigo.dev/color';
5
+ import { getStroke } from 'perfect-freehand';
6
+ import polygonClipping from 'polygon-clipping';
5
7
  import createDOMPurify from 'dompurify';
6
8
  import { Searcher } from 'fast-fuzzy';
7
9
 
@@ -1076,7 +1078,7 @@ const observerAssertionsByType = {
1076
1078
  resize: (observer) => observer instanceof ResizeObserver
1077
1079
  };
1078
1080
 
1079
- const defaultOptions$4 = {
1081
+ const defaultOptions$5 = {
1080
1082
  duration: 0,
1081
1083
  timing: [
1082
1084
  0,
@@ -1089,10 +1091,10 @@ const defaultOptions$4 = {
1089
1091
  };
1090
1092
  class Animateable {
1091
1093
  constructor(keyframes, options = {}) {
1092
- this.initialDuration = options?.duration || defaultOptions$4.duration;
1093
- this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$4.timing);
1094
- this.iterationLimit = options?.iterations || defaultOptions$4.iterations;
1095
- this.alternates = options?.alternates || defaultOptions$4.alternates;
1094
+ this.initialDuration = options?.duration || defaultOptions$5.duration;
1095
+ this.controlPoints = fromTimingToControlPoints(options?.timing || defaultOptions$5.timing);
1096
+ this.iterationLimit = options?.iterations || defaultOptions$5.iterations;
1097
+ this.alternates = options?.alternates || defaultOptions$5.alternates;
1096
1098
  this.reversedControlPoints = fromControlPointsToReversedControlPoints(this.controlPoints);
1097
1099
  this.toAnimationProgress = createToAnimationProgress(this.controlPoints);
1098
1100
  this.reversedToAnimationProgress = createToAnimationProgress(this.reversedControlPoints);
@@ -1757,8 +1759,188 @@ function toInterpolated({ previous, next, progress }, options = {}) {
1757
1759
  return createSlice({ from: 0, to: sliceEnd })(sliceTarget);
1758
1760
  }
1759
1761
  }
1762
+ const linear = [
1763
+ 0,
1764
+ 0,
1765
+ 1,
1766
+ 1
1767
+ ];
1768
+ const materialStandard = [
1769
+ 0.4,
1770
+ 0,
1771
+ 0.2,
1772
+ 1
1773
+ ];
1774
+ const materialDecelerated = [
1775
+ 0,
1776
+ 0,
1777
+ 0.2,
1778
+ 1
1779
+ ];
1780
+ const materialAccelerated = [
1781
+ 0.4,
1782
+ 0,
1783
+ 1,
1784
+ 1
1785
+ ];
1786
+ const verouEase = [
1787
+ 0.25,
1788
+ 0.1,
1789
+ 0.25,
1790
+ 1
1791
+ ];
1792
+ const verouEaseIn = [
1793
+ 0.42,
1794
+ 0,
1795
+ 1,
1796
+ 1
1797
+ ];
1798
+ const verouEaseOut = [
1799
+ 0,
1800
+ 0,
1801
+ 0.58,
1802
+ 1
1803
+ ];
1804
+ const verouEaseInOut = [
1805
+ 0.42,
1806
+ 0,
1807
+ 0.58,
1808
+ 1
1809
+ ];
1810
+ const easingsNetInSine = [
1811
+ 0.12,
1812
+ 0,
1813
+ 0.39,
1814
+ 0
1815
+ ];
1816
+ const easingsNetOutSine = [
1817
+ 0.61,
1818
+ 1,
1819
+ 0.88,
1820
+ 1
1821
+ ];
1822
+ const easingsNetInOutSine = [
1823
+ 0.37,
1824
+ 0,
1825
+ 0.63,
1826
+ 1
1827
+ ];
1828
+ const easingsNetInQuad = [
1829
+ 0.11,
1830
+ 0,
1831
+ 0.5,
1832
+ 0
1833
+ ];
1834
+ const easingsNetOutQuad = [
1835
+ 0.5,
1836
+ 1,
1837
+ 0.89,
1838
+ 1
1839
+ ];
1840
+ const easingsNetInOutQuad = [
1841
+ 0.45,
1842
+ 0,
1843
+ 0.55,
1844
+ 1
1845
+ ];
1846
+ const easingsNetInCubic = [
1847
+ 0.32,
1848
+ 0,
1849
+ 0.67,
1850
+ 0
1851
+ ];
1852
+ const easingsNetOutCubic = [
1853
+ 0.33,
1854
+ 1,
1855
+ 0.68,
1856
+ 1
1857
+ ];
1858
+ const easingsNetInOutCubic = [
1859
+ 0.65,
1860
+ 0,
1861
+ 0.35,
1862
+ 1
1863
+ ];
1864
+ const easingsNetInQuart = [
1865
+ 0.5,
1866
+ 0,
1867
+ 0.75,
1868
+ 0
1869
+ ];
1870
+ const easingsNetInQuint = [
1871
+ 0.64,
1872
+ 0,
1873
+ 0.78,
1874
+ 0
1875
+ ];
1876
+ const easingsNetOutQuint = [
1877
+ 0.22,
1878
+ 1,
1879
+ 0.36,
1880
+ 1
1881
+ ];
1882
+ const easingsNetInOutQuint = [
1883
+ 0.83,
1884
+ 0,
1885
+ 0.17,
1886
+ 1
1887
+ ];
1888
+ const easingsNetInExpo = [
1889
+ 0.7,
1890
+ 0,
1891
+ 0.84,
1892
+ 0
1893
+ ];
1894
+ const easingsNetOutExpo = [
1895
+ 0.16,
1896
+ 1,
1897
+ 0.3,
1898
+ 1
1899
+ ];
1900
+ const easingsNetInOutExpo = [
1901
+ 0.87,
1902
+ 0,
1903
+ 0.13,
1904
+ 1
1905
+ ];
1906
+ const easingsNetInCirc = [
1907
+ 0.55,
1908
+ 0,
1909
+ 1,
1910
+ 0.45
1911
+ ];
1912
+ const easingsNetOutCirc = [
1913
+ 0,
1914
+ 0.55,
1915
+ 0.45,
1916
+ 1
1917
+ ];
1918
+ const easingsNetInOutCirc = [
1919
+ 0.85,
1920
+ 0,
1921
+ 0.15,
1922
+ 1
1923
+ ];
1924
+ const easingsNetInBack = [
1925
+ 0.36,
1926
+ 0,
1927
+ 0.66,
1928
+ -0.56
1929
+ ];
1930
+ const easingsNetOutBack = [
1931
+ 0.34,
1932
+ 1.56,
1933
+ 0.64,
1934
+ 1
1935
+ ];
1936
+ const easingsNetInOutBack = [
1937
+ 0.68,
1938
+ -0.6,
1939
+ 0.32,
1940
+ 1.6
1941
+ ];
1760
1942
 
1761
- const defaultOptions$3 = {
1943
+ const defaultOptions$4 = {
1762
1944
  segment: {
1763
1945
  from: "start",
1764
1946
  to: "end"
@@ -1771,9 +1953,9 @@ const defaultCompleteOptions = {
1771
1953
  class Completeable {
1772
1954
  constructor(string, options = {}) {
1773
1955
  this.constructing();
1774
- this.segmentFrom = options?.segment?.from || defaultOptions$3.segment.from;
1775
- this.segmentTo = options?.segment?.to || defaultOptions$3.segment.to;
1776
- this.divider = options?.divider || defaultOptions$3.divider;
1956
+ this.segmentFrom = options?.segment?.from || defaultOptions$4.segment.from;
1957
+ this.segmentTo = options?.segment?.to || defaultOptions$4.segment.to;
1958
+ this.divider = options?.divider || defaultOptions$4.divider;
1777
1959
  this.computedDividerIndices = { before: 0, after: 0 };
1778
1960
  this.setString(string);
1779
1961
  this.setSelection(options?.initialSelection || { start: string.length, end: string.length, direction: "none" });
@@ -2003,7 +2185,7 @@ class Copyable {
2003
2185
  }
2004
2186
  }
2005
2187
 
2006
- const defaultOptions$2 = {
2188
+ const defaultOptions$3 = {
2007
2189
  delay: 0,
2008
2190
  executions: 1
2009
2191
  };
@@ -2013,8 +2195,8 @@ class Delayable {
2013
2195
  { progress: 0, properties: { progress: 0 } },
2014
2196
  { progress: 1, properties: { progress: 1 } }
2015
2197
  ], {
2016
- duration: options?.delay ?? defaultOptions$2.delay,
2017
- iterations: options?.executions ?? defaultOptions$2.executions
2198
+ duration: options?.delay ?? defaultOptions$3.delay,
2199
+ iterations: options?.executions ?? defaultOptions$3.executions
2018
2200
  });
2019
2201
  this.setEffect(effect);
2020
2202
  this.ready();
@@ -2178,6 +2360,66 @@ class Dispatchable {
2178
2360
  }
2179
2361
  }
2180
2362
 
2363
+ const defaultOptions$2 = {
2364
+ toD: (stroke) => stroke.length === 0 ? "" : toD(stroke)
2365
+ };
2366
+ class Drawable {
2367
+ constructor(stroke, options = {}) {
2368
+ this.toD = options?.toD || defaultOptions$2.toD;
2369
+ this.setStroke(stroke);
2370
+ this.ready();
2371
+ }
2372
+ ready() {
2373
+ this.computedStatus = "ready";
2374
+ }
2375
+ get stroke() {
2376
+ return this.computedStroke;
2377
+ }
2378
+ set stroke(stroke) {
2379
+ this.setStroke(stroke);
2380
+ }
2381
+ get status() {
2382
+ return this.computedStatus;
2383
+ }
2384
+ get d() {
2385
+ return this.computedD;
2386
+ }
2387
+ setStroke(stroke) {
2388
+ this.computedStroke = stroke;
2389
+ this.computedD = this.toD(stroke);
2390
+ return this;
2391
+ }
2392
+ draw(points, options) {
2393
+ this.drawing();
2394
+ this.stroke = getStroke(points, options);
2395
+ this.drawn();
2396
+ return this;
2397
+ }
2398
+ drawing() {
2399
+ this.computedStatus = "drawing";
2400
+ }
2401
+ drawn() {
2402
+ this.computedStatus = "drawn";
2403
+ }
2404
+ }
2405
+ function toD(stroke) {
2406
+ return createReduce((d, [x0, y0], index) => {
2407
+ const [x1, y1] = stroke[(index + 1) % stroke.length];
2408
+ return `${d} ${x0} ${y0} ${(x0 + x1) / 2} ${(y0 + y1) / 2}`;
2409
+ }, `M ${stroke[0][0]} ${stroke[0][1]} Q`)(stroke) + "Z";
2410
+ }
2411
+ function toFlattenedD(stroke) {
2412
+ if (stroke.length === 0) {
2413
+ return "";
2414
+ }
2415
+ const multiPolygon = polygonClipping.union([stroke]);
2416
+ return createReduce((dFromMultiPolygon, polygon) => {
2417
+ return dFromMultiPolygon + createReduce((dFromRing, points) => {
2418
+ return dFromRing + toD(points);
2419
+ }, "")(polygon);
2420
+ }, "")(multiPolygon);
2421
+ }
2422
+
2181
2423
  class Resolveable {
2182
2424
  constructor(getPromise, options = {}) {
2183
2425
  this.setGetPromise(getPromise);
@@ -2759,4 +3001,4 @@ class Storeable {
2759
3001
  }
2760
3002
  }
2761
3003
 
2762
- export { Animateable, Completeable, Copyable, Delayable, Dispatchable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Storeable, createClamp, createClip, createConcat, createDelete, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSwap, createUnique, ensureKeycombo, eventMatchesKeycombo };
3004
+ export { Animateable, Completeable, Copyable, Delayable, Dispatchable, Drawable, Fetchable, Fullscreenable, Grantable, Listenable, Navigateable, Pipeable, Recognizeable, Resolveable, Sanitizeable, Searchable, Storeable, createClamp, createClip, createConcat, createDelete, createFilter, createFilterAsync, createForEachAsync, createInsert, createMap, createMapAsync, createReduce, createReduceAsync, createRename, createReorder, createReplace, createReverse, createSlice, createSlug, createSwap, createUnique, easingsNetInBack, easingsNetInCirc, easingsNetInCubic, easingsNetInExpo, easingsNetInOutBack, easingsNetInOutCirc, easingsNetInOutCubic, easingsNetInOutExpo, easingsNetInOutQuad, easingsNetInOutQuint, easingsNetInOutSine, easingsNetInQuad, easingsNetInQuart, easingsNetInQuint, easingsNetInSine, easingsNetOutBack, easingsNetOutCirc, easingsNetOutCubic, easingsNetOutExpo, easingsNetOutQuad, easingsNetOutQuint, easingsNetOutSine, ensureKeycombo, eventMatchesKeycombo, linear, materialAccelerated, materialDecelerated, materialStandard, toD, toFlattenedD, verouEase, verouEaseIn, verouEaseInOut, verouEaseOut };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baleada/logic",
3
- "version": "0.20.11",
3
+ "version": "0.20.12",
4
4
  "description": "UI logic for the Baleada toolkit",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",
@@ -54,7 +54,7 @@
54
54
  "typescript": "^4.4.3",
55
55
  "uvu": "^0.5.1",
56
56
  "vite": "^2.4.4",
57
- "vue": "^3.2.9",
57
+ "vue": "^3.2.12",
58
58
  "vue-router": "^4.0.3"
59
59
  },
60
60
  "dependencies": {
@@ -67,7 +67,9 @@
67
67
  "bezier-easing": "^2.1.0",
68
68
  "dompurify": "^2.2.6",
69
69
  "fast-fuzzy": "^1.10.8",
70
- "lazy-collections": "^0.8.0"
70
+ "lazy-collections": "^0.8.0",
71
+ "perfect-freehand": "^1.0.4",
72
+ "polygon-clipping": "^0.15.3"
71
73
  },
72
74
  "sideEffects": false
73
75
  }