animejs 4.1.4 → 4.2.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 +17 -8
- package/{lib → dist/bundles}/anime.esm.js +6476 -6106
- package/dist/bundles/anime.esm.min.js +7 -0
- package/dist/bundles/anime.umd.js +8809 -0
- package/dist/bundles/anime.umd.min.js +7 -0
- package/dist/modules/animatable/animatable.cjs +150 -0
- package/dist/modules/animatable/animatable.d.ts +28 -0
- package/dist/modules/animatable/animatable.js +147 -0
- package/dist/modules/animatable/index.cjs +15 -0
- package/dist/modules/animatable/index.d.ts +1 -0
- package/dist/modules/animatable/index.js +8 -0
- package/dist/modules/animation/additive.cjs +82 -0
- package/dist/modules/animation/additive.d.ts +15 -0
- package/dist/modules/animation/additive.js +79 -0
- package/dist/modules/animation/animation.cjs +667 -0
- package/dist/modules/animation/animation.d.ts +45 -0
- package/dist/modules/animation/animation.js +664 -0
- package/dist/modules/animation/composition.cjs +383 -0
- package/dist/modules/animation/composition.d.ts +10 -0
- package/dist/modules/animation/composition.js +377 -0
- package/dist/modules/animation/index.cjs +15 -0
- package/dist/modules/animation/index.d.ts +1 -0
- package/dist/modules/animation/index.js +8 -0
- package/dist/modules/core/clock.cjs +110 -0
- package/dist/modules/core/clock.d.ts +51 -0
- package/dist/modules/core/clock.js +108 -0
- package/dist/modules/core/colors.cjs +102 -0
- package/dist/modules/core/colors.d.ts +2 -0
- package/dist/modules/core/colors.js +100 -0
- package/dist/modules/core/consts.cjs +159 -0
- package/dist/modules/core/consts.d.ts +61 -0
- package/dist/modules/core/consts.js +124 -0
- package/dist/modules/core/globals.cjs +78 -0
- package/dist/modules/core/globals.d.ts +29 -0
- package/dist/modules/core/globals.js +73 -0
- package/dist/modules/core/helpers.cjs +304 -0
- package/dist/modules/core/helpers.d.ts +43 -0
- package/dist/modules/core/helpers.js +261 -0
- package/dist/modules/core/render.cjs +391 -0
- package/dist/modules/core/render.d.ts +4 -0
- package/dist/modules/core/render.js +388 -0
- package/dist/modules/core/styles.cjs +116 -0
- package/dist/modules/core/styles.d.ts +5 -0
- package/dist/modules/core/styles.js +113 -0
- package/dist/modules/core/targets.cjs +136 -0
- package/dist/modules/core/targets.d.ts +118 -0
- package/dist/modules/core/targets.js +132 -0
- package/dist/modules/core/transforms.cjs +49 -0
- package/dist/modules/core/transforms.d.ts +2 -0
- package/dist/modules/core/transforms.js +47 -0
- package/dist/modules/core/units.cjs +67 -0
- package/dist/modules/core/units.d.ts +3 -0
- package/dist/modules/core/units.js +65 -0
- package/dist/modules/core/values.cjs +226 -0
- package/dist/modules/core/values.d.ts +14 -0
- package/dist/modules/core/values.js +216 -0
- package/dist/modules/draggable/draggable.cjs +1226 -0
- package/dist/modules/draggable/draggable.d.ts +272 -0
- package/dist/modules/draggable/draggable.js +1223 -0
- package/dist/modules/draggable/index.cjs +15 -0
- package/dist/modules/draggable/index.d.ts +1 -0
- package/dist/modules/draggable/index.js +8 -0
- package/dist/modules/easings/cubic-bezier/index.cjs +64 -0
- package/dist/modules/easings/cubic-bezier/index.d.ts +2 -0
- package/dist/modules/easings/cubic-bezier/index.js +62 -0
- package/dist/modules/easings/eases/index.cjs +14 -0
- package/dist/modules/easings/eases/index.d.ts +1 -0
- package/dist/modules/easings/eases/index.js +8 -0
- package/dist/modules/easings/eases/parser.cjs +191 -0
- package/dist/modules/easings/eases/parser.d.ts +125 -0
- package/dist/modules/easings/eases/parser.js +185 -0
- package/dist/modules/easings/index.cjs +26 -0
- package/dist/modules/easings/index.d.ts +6 -0
- package/dist/modules/easings/index.js +13 -0
- package/dist/modules/easings/irregular/index.cjs +41 -0
- package/dist/modules/easings/irregular/index.d.ts +2 -0
- package/dist/modules/easings/irregular/index.js +39 -0
- package/dist/modules/easings/linear/index.cjs +59 -0
- package/dist/modules/easings/linear/index.d.ts +2 -0
- package/dist/modules/easings/linear/index.js +57 -0
- package/dist/modules/easings/none.cjs +19 -0
- package/dist/modules/easings/none.d.ts +8 -0
- package/dist/modules/easings/none.js +17 -0
- package/dist/modules/easings/spring/index.cjs +255 -0
- package/dist/modules/easings/spring/index.d.ts +53 -0
- package/dist/modules/easings/spring/index.js +251 -0
- package/dist/modules/easings/steps/index.cjs +30 -0
- package/dist/modules/easings/steps/index.d.ts +2 -0
- package/dist/modules/easings/steps/index.js +28 -0
- package/dist/modules/engine/engine.cjs +168 -0
- package/dist/modules/engine/engine.d.ts +21 -0
- package/dist/modules/engine/engine.js +166 -0
- package/dist/modules/engine/index.cjs +14 -0
- package/dist/modules/engine/index.d.ts +1 -0
- package/dist/modules/engine/index.js +8 -0
- package/dist/modules/events/index.cjs +16 -0
- package/dist/modules/events/index.d.ts +1 -0
- package/dist/modules/events/index.js +8 -0
- package/dist/modules/events/scroll.cjs +940 -0
- package/dist/modules/events/scroll.d.ts +191 -0
- package/dist/modules/events/scroll.js +936 -0
- package/dist/modules/index.cjs +102 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +41 -0
- package/dist/modules/scope/index.cjs +15 -0
- package/dist/modules/scope/index.d.ts +1 -0
- package/dist/modules/scope/index.js +8 -0
- package/dist/modules/scope/scope.cjs +254 -0
- package/dist/modules/scope/scope.d.ts +115 -0
- package/dist/modules/scope/scope.js +251 -0
- package/dist/modules/svg/drawable.cjs +119 -0
- package/dist/modules/svg/drawable.d.ts +3 -0
- package/dist/modules/svg/drawable.js +117 -0
- package/dist/modules/svg/helpers.cjs +30 -0
- package/dist/modules/svg/helpers.d.ts +2 -0
- package/dist/modules/svg/helpers.js +28 -0
- package/dist/modules/svg/index.cjs +18 -0
- package/dist/modules/svg/index.d.ts +3 -0
- package/dist/modules/svg/index.js +10 -0
- package/dist/modules/svg/morphto.cjs +58 -0
- package/dist/modules/svg/morphto.d.ts +3 -0
- package/dist/modules/svg/morphto.js +56 -0
- package/dist/modules/svg/motionpath.cjs +79 -0
- package/dist/modules/svg/motionpath.d.ts +7 -0
- package/dist/modules/svg/motionpath.js +77 -0
- package/dist/modules/text/index.cjs +16 -0
- package/dist/modules/text/index.d.ts +1 -0
- package/dist/modules/text/index.js +8 -0
- package/dist/modules/text/split.cjs +488 -0
- package/dist/modules/text/split.d.ts +62 -0
- package/dist/modules/text/split.js +484 -0
- package/dist/modules/timeline/index.cjs +15 -0
- package/dist/modules/timeline/index.d.ts +1 -0
- package/dist/modules/timeline/index.js +8 -0
- package/dist/modules/timeline/position.cjs +72 -0
- package/dist/modules/timeline/position.d.ts +3 -0
- package/dist/modules/timeline/position.js +70 -0
- package/dist/modules/timeline/timeline.cjs +312 -0
- package/dist/modules/timeline/timeline.d.ts +163 -0
- package/dist/modules/timeline/timeline.js +309 -0
- package/dist/modules/timer/index.cjs +15 -0
- package/dist/modules/timer/index.d.ts +1 -0
- package/dist/modules/timer/index.js +8 -0
- package/dist/modules/timer/timer.cjs +491 -0
- package/dist/modules/timer/timer.d.ts +141 -0
- package/dist/modules/timer/timer.js +488 -0
- package/dist/modules/types/index.d.ts +404 -0
- package/dist/modules/utils/chainable.cjs +190 -0
- package/dist/modules/utils/chainable.d.ts +135 -0
- package/dist/modules/utils/chainable.js +177 -0
- package/dist/modules/utils/index.cjs +43 -0
- package/dist/modules/utils/index.d.ts +5 -0
- package/dist/modules/utils/index.js +14 -0
- package/dist/modules/utils/number.cjs +97 -0
- package/dist/modules/utils/number.d.ts +9 -0
- package/dist/modules/utils/number.js +85 -0
- package/dist/modules/utils/random.cjs +77 -0
- package/dist/modules/utils/random.d.ts +22 -0
- package/dist/modules/utils/random.js +72 -0
- package/dist/modules/utils/stagger.cjs +122 -0
- package/dist/modules/utils/stagger.d.ts +30 -0
- package/dist/modules/utils/stagger.js +120 -0
- package/dist/modules/utils/target.cjs +130 -0
- package/dist/modules/utils/target.d.ts +126 -0
- package/dist/modules/utils/target.js +125 -0
- package/dist/modules/utils/time.cjs +57 -0
- package/dist/modules/utils/time.d.ts +5 -0
- package/dist/modules/utils/time.js +54 -0
- package/dist/modules/waapi/composition.cjs +95 -0
- package/dist/modules/waapi/composition.d.ts +4 -0
- package/dist/modules/waapi/composition.js +92 -0
- package/dist/modules/waapi/index.cjs +15 -0
- package/dist/modules/waapi/index.d.ts +1 -0
- package/dist/modules/waapi/index.js +8 -0
- package/dist/modules/waapi/waapi.cjs +492 -0
- package/dist/modules/waapi/waapi.d.ts +116 -0
- package/dist/modules/waapi/waapi.js +489 -0
- package/package.json +166 -33
- package/lib/anime.cjs +0 -9
- package/lib/anime.esm.min.js +0 -9
- package/lib/anime.iife.js +0 -9
- package/lib/anime.iife.min.js +0 -9
- package/lib/anime.min.cjs +0 -9
- package/lib/anime.umd.js +0 -9
- package/lib/anime.umd.min.js +0 -9
- package/lib/gui/index.js +0 -6341
- package/types/index.d.ts +0 -1127
- package/types/index.js +0 -7395
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime.js - CJS
|
|
3
|
+
* @version v4.2.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2025 - Julian Garnier
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var timer = require('./timer/timer.cjs');
|
|
11
|
+
var animation = require('./animation/animation.cjs');
|
|
12
|
+
var timeline = require('./timeline/timeline.cjs');
|
|
13
|
+
var animatable = require('./animatable/animatable.cjs');
|
|
14
|
+
var draggable = require('./draggable/draggable.cjs');
|
|
15
|
+
var scope = require('./scope/scope.cjs');
|
|
16
|
+
var scroll = require('./events/scroll.cjs');
|
|
17
|
+
var engine = require('./engine/engine.cjs');
|
|
18
|
+
var index = require('./easings/index.cjs');
|
|
19
|
+
var index$1 = require('./utils/index.cjs');
|
|
20
|
+
var index$2 = require('./svg/index.cjs');
|
|
21
|
+
var index$3 = require('./text/index.cjs');
|
|
22
|
+
var waapi = require('./waapi/waapi.cjs');
|
|
23
|
+
var index$4 = require('./easings/cubic-bezier/index.cjs');
|
|
24
|
+
var index$5 = require('./easings/steps/index.cjs');
|
|
25
|
+
var index$6 = require('./easings/linear/index.cjs');
|
|
26
|
+
var index$7 = require('./easings/irregular/index.cjs');
|
|
27
|
+
var index$8 = require('./easings/spring/index.cjs');
|
|
28
|
+
var parser = require('./easings/eases/parser.cjs');
|
|
29
|
+
var chainable = require('./utils/chainable.cjs');
|
|
30
|
+
var random = require('./utils/random.cjs');
|
|
31
|
+
var time = require('./utils/time.cjs');
|
|
32
|
+
var styles = require('./core/styles.cjs');
|
|
33
|
+
var targets = require('./core/targets.cjs');
|
|
34
|
+
var target = require('./utils/target.cjs');
|
|
35
|
+
var stagger = require('./utils/stagger.cjs');
|
|
36
|
+
var motionpath = require('./svg/motionpath.cjs');
|
|
37
|
+
var drawable = require('./svg/drawable.cjs');
|
|
38
|
+
var morphto = require('./svg/morphto.cjs');
|
|
39
|
+
var split = require('./text/split.cjs');
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
exports.Timer = timer.Timer;
|
|
44
|
+
exports.createTimer = timer.createTimer;
|
|
45
|
+
exports.JSAnimation = animation.JSAnimation;
|
|
46
|
+
exports.animate = animation.animate;
|
|
47
|
+
exports.Timeline = timeline.Timeline;
|
|
48
|
+
exports.createTimeline = timeline.createTimeline;
|
|
49
|
+
exports.Animatable = animatable.Animatable;
|
|
50
|
+
exports.createAnimatable = animatable.createAnimatable;
|
|
51
|
+
exports.Draggable = draggable.Draggable;
|
|
52
|
+
exports.createDraggable = draggable.createDraggable;
|
|
53
|
+
exports.Scope = scope.Scope;
|
|
54
|
+
exports.createScope = scope.createScope;
|
|
55
|
+
exports.ScrollObserver = scroll.ScrollObserver;
|
|
56
|
+
exports.onScroll = scroll.onScroll;
|
|
57
|
+
exports.scrollContainers = scroll.scrollContainers;
|
|
58
|
+
exports.engine = engine.engine;
|
|
59
|
+
exports.easings = index;
|
|
60
|
+
exports.utils = index$1;
|
|
61
|
+
exports.svg = index$2;
|
|
62
|
+
exports.text = index$3;
|
|
63
|
+
exports.WAAPIAnimation = waapi.WAAPIAnimation;
|
|
64
|
+
exports.waapi = waapi.waapi;
|
|
65
|
+
exports.cubicBezier = index$4.cubicBezier;
|
|
66
|
+
exports.steps = index$5.steps;
|
|
67
|
+
exports.linear = index$6.linear;
|
|
68
|
+
exports.irregular = index$7.irregular;
|
|
69
|
+
exports.Spring = index$8.Spring;
|
|
70
|
+
exports.createSpring = index$8.createSpring;
|
|
71
|
+
exports.spring = index$8.spring;
|
|
72
|
+
exports.eases = parser.eases;
|
|
73
|
+
exports.clamp = chainable.clamp;
|
|
74
|
+
exports.damp = chainable.damp;
|
|
75
|
+
exports.degToRad = chainable.degToRad;
|
|
76
|
+
exports.lerp = chainable.lerp;
|
|
77
|
+
exports.mapRange = chainable.mapRange;
|
|
78
|
+
exports.padEnd = chainable.padEnd;
|
|
79
|
+
exports.padStart = chainable.padStart;
|
|
80
|
+
exports.radToDeg = chainable.radToDeg;
|
|
81
|
+
exports.round = chainable.round;
|
|
82
|
+
exports.roundPad = chainable.roundPad;
|
|
83
|
+
exports.snap = chainable.snap;
|
|
84
|
+
exports.wrap = chainable.wrap;
|
|
85
|
+
exports.createSeededRandom = random.createSeededRandom;
|
|
86
|
+
exports.random = random.random;
|
|
87
|
+
exports.randomPick = random.randomPick;
|
|
88
|
+
exports.shuffle = random.shuffle;
|
|
89
|
+
exports.keepTime = time.keepTime;
|
|
90
|
+
exports.sync = time.sync;
|
|
91
|
+
exports.cleanInlineStyles = styles.cleanInlineStyles;
|
|
92
|
+
exports.$ = targets.registerTargets;
|
|
93
|
+
exports.get = target.get;
|
|
94
|
+
exports.remove = target.remove;
|
|
95
|
+
exports.set = target.set;
|
|
96
|
+
exports.stagger = stagger.stagger;
|
|
97
|
+
exports.createMotionPath = motionpath.createMotionPath;
|
|
98
|
+
exports.createDrawable = drawable.createDrawable;
|
|
99
|
+
exports.morphTo = morphto.morphTo;
|
|
100
|
+
exports.TextSplitter = split.TextSplitter;
|
|
101
|
+
exports.split = split.split;
|
|
102
|
+
exports.splitText = split.splitText;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./timer/index.js";
|
|
2
|
+
export * from "./animation/index.js";
|
|
3
|
+
export * from "./timeline/index.js";
|
|
4
|
+
export * from "./animatable/index.js";
|
|
5
|
+
export * from "./draggable/index.js";
|
|
6
|
+
export * from "./scope/index.js";
|
|
7
|
+
export * from "./events/index.js";
|
|
8
|
+
export * from "./engine/index.js";
|
|
9
|
+
export * from "./easings/index.js";
|
|
10
|
+
export * from "./utils/index.js";
|
|
11
|
+
export * from "./svg/index.js";
|
|
12
|
+
export * from "./text/index.js";
|
|
13
|
+
export * from "./waapi/index.js";
|
|
14
|
+
export * from "./types/index.js";
|
|
15
|
+
export * as easings from "./easings/index.js";
|
|
16
|
+
export * as utils from "./utils/index.js";
|
|
17
|
+
export * as svg from "./svg/index.js";
|
|
18
|
+
export * as text from "./text/index.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime.js - ESM
|
|
3
|
+
* @version v4.2.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2025 - Julian Garnier
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export { Timer, createTimer } from './timer/timer.js';
|
|
9
|
+
export { JSAnimation, animate } from './animation/animation.js';
|
|
10
|
+
export { Timeline, createTimeline } from './timeline/timeline.js';
|
|
11
|
+
export { Animatable, createAnimatable } from './animatable/animatable.js';
|
|
12
|
+
export { Draggable, createDraggable } from './draggable/draggable.js';
|
|
13
|
+
export { Scope, createScope } from './scope/scope.js';
|
|
14
|
+
export { ScrollObserver, onScroll, scrollContainers } from './events/scroll.js';
|
|
15
|
+
export { engine } from './engine/engine.js';
|
|
16
|
+
import * as index from './easings/index.js';
|
|
17
|
+
export { index as easings };
|
|
18
|
+
import * as index$1 from './utils/index.js';
|
|
19
|
+
export { index$1 as utils };
|
|
20
|
+
import * as index$2 from './svg/index.js';
|
|
21
|
+
export { index$2 as svg };
|
|
22
|
+
import * as index$3 from './text/index.js';
|
|
23
|
+
export { index$3 as text };
|
|
24
|
+
export { WAAPIAnimation, waapi } from './waapi/waapi.js';
|
|
25
|
+
export { cubicBezier } from './easings/cubic-bezier/index.js';
|
|
26
|
+
export { steps } from './easings/steps/index.js';
|
|
27
|
+
export { linear } from './easings/linear/index.js';
|
|
28
|
+
export { irregular } from './easings/irregular/index.js';
|
|
29
|
+
export { Spring, createSpring, spring } from './easings/spring/index.js';
|
|
30
|
+
export { eases } from './easings/eases/parser.js';
|
|
31
|
+
export { clamp, damp, degToRad, lerp, mapRange, padEnd, padStart, radToDeg, round, roundPad, snap, wrap } from './utils/chainable.js';
|
|
32
|
+
export { createSeededRandom, random, randomPick, shuffle } from './utils/random.js';
|
|
33
|
+
export { keepTime, sync } from './utils/time.js';
|
|
34
|
+
export { cleanInlineStyles } from './core/styles.js';
|
|
35
|
+
export { registerTargets as $ } from './core/targets.js';
|
|
36
|
+
export { get, remove, set } from './utils/target.js';
|
|
37
|
+
export { stagger } from './utils/stagger.js';
|
|
38
|
+
export { createMotionPath } from './svg/motionpath.js';
|
|
39
|
+
export { createDrawable } from './svg/drawable.js';
|
|
40
|
+
export { morphTo } from './svg/morphto.js';
|
|
41
|
+
export { TextSplitter, split, splitText } from './text/split.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime.js - scope - CJS
|
|
3
|
+
* @version v4.2.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2025 - Julian Garnier
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var scope = require('./scope.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.Scope = scope.Scope;
|
|
15
|
+
exports.createScope = scope.createScope;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./scope.js";
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime.js - scope - CJS
|
|
3
|
+
* @version v4.2.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2025 - Julian Garnier
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var consts = require('../core/consts.cjs');
|
|
11
|
+
var globals = require('../core/globals.cjs');
|
|
12
|
+
var helpers = require('../core/helpers.cjs');
|
|
13
|
+
var targets = require('../core/targets.cjs');
|
|
14
|
+
var time = require('../utils/time.cjs');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @import {
|
|
18
|
+
* Tickable,
|
|
19
|
+
* ScopeParams,
|
|
20
|
+
* DOMTarget,
|
|
21
|
+
* ReactRef,
|
|
22
|
+
* AngularRef,
|
|
23
|
+
* DOMTargetSelector,
|
|
24
|
+
* DefaultsParams,
|
|
25
|
+
* ScopeConstructorCallback,
|
|
26
|
+
* ScopeCleanupCallback,
|
|
27
|
+
* Revertible,
|
|
28
|
+
* ScopeMethod,
|
|
29
|
+
* ScopedCallback,
|
|
30
|
+
* } from '../types/index.js'
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
class Scope {
|
|
34
|
+
/** @param {ScopeParams} [parameters] */
|
|
35
|
+
constructor(parameters = {}) {
|
|
36
|
+
if (globals.scope.current) globals.scope.current.register(this);
|
|
37
|
+
const rootParam = parameters.root;
|
|
38
|
+
/** @type {Document|DOMTarget} */
|
|
39
|
+
let root = consts.doc;
|
|
40
|
+
if (rootParam) {
|
|
41
|
+
root = /** @type {ReactRef} */(rootParam).current ||
|
|
42
|
+
/** @type {AngularRef} */(rootParam).nativeElement ||
|
|
43
|
+
targets.parseTargets(/** @type {DOMTargetSelector} */(rootParam))[0] ||
|
|
44
|
+
consts.doc;
|
|
45
|
+
}
|
|
46
|
+
const scopeDefaults = parameters.defaults;
|
|
47
|
+
const globalDefault = globals.globals.defaults;
|
|
48
|
+
const mediaQueries = parameters.mediaQueries;
|
|
49
|
+
/** @type {DefaultsParams} */
|
|
50
|
+
this.defaults = scopeDefaults ? helpers.mergeObjects(scopeDefaults, globalDefault) : globalDefault;
|
|
51
|
+
/** @type {Document|DOMTarget} */
|
|
52
|
+
this.root = root;
|
|
53
|
+
/** @type {Array<ScopeConstructorCallback>} */
|
|
54
|
+
this.constructors = [];
|
|
55
|
+
/** @type {Array<ScopeCleanupCallback>} */
|
|
56
|
+
this.revertConstructors = [];
|
|
57
|
+
/** @type {Array<Revertible>} */
|
|
58
|
+
this.revertibles = [];
|
|
59
|
+
/** @type {Array<ScopeConstructorCallback | ((scope: this) => Tickable)>} */
|
|
60
|
+
this.constructorsOnce = [];
|
|
61
|
+
/** @type {Array<ScopeCleanupCallback>} */
|
|
62
|
+
this.revertConstructorsOnce = [];
|
|
63
|
+
/** @type {Array<Revertible>} */
|
|
64
|
+
this.revertiblesOnce = [];
|
|
65
|
+
/** @type {Boolean} */
|
|
66
|
+
this.once = false;
|
|
67
|
+
/** @type {Number} */
|
|
68
|
+
this.onceIndex = 0;
|
|
69
|
+
/** @type {Record<String, ScopeMethod>} */
|
|
70
|
+
this.methods = {};
|
|
71
|
+
/** @type {Record<String, Boolean>} */
|
|
72
|
+
this.matches = {};
|
|
73
|
+
/** @type {Record<String, MediaQueryList>} */
|
|
74
|
+
this.mediaQueryLists = {};
|
|
75
|
+
/** @type {Record<String, any>} */
|
|
76
|
+
this.data = {};
|
|
77
|
+
if (mediaQueries) {
|
|
78
|
+
for (let mq in mediaQueries) {
|
|
79
|
+
const _mq = consts.win.matchMedia(mediaQueries[mq]);
|
|
80
|
+
this.mediaQueryLists[mq] = _mq;
|
|
81
|
+
_mq.addEventListener('change', this);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {Revertible} revertible
|
|
88
|
+
*/
|
|
89
|
+
register(revertible) {
|
|
90
|
+
const store = this.once ? this.revertiblesOnce : this.revertibles;
|
|
91
|
+
store.push(revertible);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @template T
|
|
96
|
+
* @param {ScopedCallback<T>} cb
|
|
97
|
+
* @return {T}
|
|
98
|
+
*/
|
|
99
|
+
execute(cb) {
|
|
100
|
+
let activeScope = globals.scope.current;
|
|
101
|
+
let activeRoot = globals.scope.root;
|
|
102
|
+
let activeDefaults = globals.globals.defaults;
|
|
103
|
+
globals.scope.current = this;
|
|
104
|
+
globals.scope.root = this.root;
|
|
105
|
+
globals.globals.defaults = this.defaults;
|
|
106
|
+
const mqs = this.mediaQueryLists;
|
|
107
|
+
for (let mq in mqs) this.matches[mq] = mqs[mq].matches;
|
|
108
|
+
const returned = cb(this);
|
|
109
|
+
globals.scope.current = activeScope;
|
|
110
|
+
globals.scope.root = activeRoot;
|
|
111
|
+
globals.globals.defaults = activeDefaults;
|
|
112
|
+
return returned;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @return {this}
|
|
117
|
+
*/
|
|
118
|
+
refresh() {
|
|
119
|
+
this.onceIndex = 0;
|
|
120
|
+
this.execute(() => {
|
|
121
|
+
let i = this.revertibles.length;
|
|
122
|
+
let y = this.revertConstructors.length;
|
|
123
|
+
while (i--) this.revertibles[i].revert();
|
|
124
|
+
while (y--) this.revertConstructors[y](this);
|
|
125
|
+
this.revertibles.length = 0;
|
|
126
|
+
this.revertConstructors.length = 0;
|
|
127
|
+
this.constructors.forEach((/** @type {ScopeConstructorCallback} */constructor) => {
|
|
128
|
+
const revertConstructor = constructor(this);
|
|
129
|
+
if (helpers.isFnc(revertConstructor)) {
|
|
130
|
+
this.revertConstructors.push(revertConstructor);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @overload
|
|
139
|
+
* @param {String} a1
|
|
140
|
+
* @param {ScopeMethod} a2
|
|
141
|
+
* @return {this}
|
|
142
|
+
*
|
|
143
|
+
* @overload
|
|
144
|
+
* @param {ScopeConstructorCallback} a1
|
|
145
|
+
* @return {this}
|
|
146
|
+
*
|
|
147
|
+
* @param {String|ScopeConstructorCallback} a1
|
|
148
|
+
* @param {ScopeMethod} [a2]
|
|
149
|
+
*/
|
|
150
|
+
add(a1, a2) {
|
|
151
|
+
this.once = false;
|
|
152
|
+
if (helpers.isFnc(a1)) {
|
|
153
|
+
const constructor = /** @type {ScopeConstructorCallback} */(a1);
|
|
154
|
+
this.constructors.push(constructor);
|
|
155
|
+
this.execute(() => {
|
|
156
|
+
const revertConstructor = constructor(this);
|
|
157
|
+
if (helpers.isFnc(revertConstructor)) {
|
|
158
|
+
this.revertConstructors.push(revertConstructor);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
} else {
|
|
162
|
+
this.methods[/** @type {String} */(a1)] = (/** @type {any} */...args) => this.execute(() => a2(...args));
|
|
163
|
+
}
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @param {ScopeConstructorCallback} scopeConstructorCallback
|
|
169
|
+
* @return {this}
|
|
170
|
+
*/
|
|
171
|
+
addOnce(scopeConstructorCallback) {
|
|
172
|
+
this.once = true;
|
|
173
|
+
if (helpers.isFnc(scopeConstructorCallback)) {
|
|
174
|
+
const currentIndex = this.onceIndex++;
|
|
175
|
+
const tracked = this.constructorsOnce[currentIndex];
|
|
176
|
+
if (tracked) return this;
|
|
177
|
+
const constructor = /** @type {ScopeConstructorCallback} */(scopeConstructorCallback);
|
|
178
|
+
this.constructorsOnce[currentIndex] = constructor;
|
|
179
|
+
this.execute(() => {
|
|
180
|
+
const revertConstructor = constructor(this);
|
|
181
|
+
if (helpers.isFnc(revertConstructor)) {
|
|
182
|
+
this.revertConstructorsOnce.push(revertConstructor);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return this;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @param {(scope: this) => Tickable} cb
|
|
191
|
+
* @return {Tickable}
|
|
192
|
+
*/
|
|
193
|
+
keepTime(cb) {
|
|
194
|
+
this.once = true;
|
|
195
|
+
const currentIndex = this.onceIndex++;
|
|
196
|
+
const tracked = /** @type {(scope: this) => Tickable} */(this.constructorsOnce[currentIndex]);
|
|
197
|
+
if (helpers.isFnc(tracked)) return tracked(this);
|
|
198
|
+
const constructor = /** @type {(scope: this) => Tickable} */(time.keepTime(cb));
|
|
199
|
+
this.constructorsOnce[currentIndex] = constructor;
|
|
200
|
+
let trackedTickable;
|
|
201
|
+
this.execute(() => {
|
|
202
|
+
trackedTickable = constructor(this);
|
|
203
|
+
});
|
|
204
|
+
return trackedTickable;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @param {Event} e
|
|
209
|
+
*/
|
|
210
|
+
handleEvent(e) {
|
|
211
|
+
switch (e.type) {
|
|
212
|
+
case 'change':
|
|
213
|
+
this.refresh();
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
revert() {
|
|
219
|
+
const revertibles = this.revertibles;
|
|
220
|
+
const revertConstructors = this.revertConstructors;
|
|
221
|
+
const revertiblesOnce = this.revertiblesOnce;
|
|
222
|
+
const revertConstructorsOnce = this.revertConstructorsOnce;
|
|
223
|
+
const mqs = this.mediaQueryLists;
|
|
224
|
+
let i = revertibles.length;
|
|
225
|
+
let j = revertConstructors.length;
|
|
226
|
+
let k = revertiblesOnce.length;
|
|
227
|
+
let l = revertConstructorsOnce.length;
|
|
228
|
+
while (i--) revertibles[i].revert();
|
|
229
|
+
while (j--) revertConstructors[j](this);
|
|
230
|
+
while (k--) revertiblesOnce[k].revert();
|
|
231
|
+
while (l--) revertConstructorsOnce[l](this);
|
|
232
|
+
for (let mq in mqs) mqs[mq].removeEventListener('change', this);
|
|
233
|
+
revertibles.length = 0;
|
|
234
|
+
revertConstructors.length = 0;
|
|
235
|
+
this.constructors.length = 0;
|
|
236
|
+
revertiblesOnce.length = 0;
|
|
237
|
+
revertConstructorsOnce.length = 0;
|
|
238
|
+
this.constructorsOnce.length = 0;
|
|
239
|
+
this.onceIndex = 0;
|
|
240
|
+
this.matches = {};
|
|
241
|
+
this.methods = {};
|
|
242
|
+
this.mediaQueryLists = {};
|
|
243
|
+
this.data = {};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @param {ScopeParams} [params]
|
|
249
|
+
* @return {Scope}
|
|
250
|
+
*/
|
|
251
|
+
const createScope = params => new Scope(params);
|
|
252
|
+
|
|
253
|
+
exports.Scope = Scope;
|
|
254
|
+
exports.createScope = createScope;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {
|
|
3
|
+
* Tickable,
|
|
4
|
+
* ScopeParams,
|
|
5
|
+
* DOMTarget,
|
|
6
|
+
* ReactRef,
|
|
7
|
+
* AngularRef,
|
|
8
|
+
* DOMTargetSelector,
|
|
9
|
+
* DefaultsParams,
|
|
10
|
+
* ScopeConstructorCallback,
|
|
11
|
+
* ScopeCleanupCallback,
|
|
12
|
+
* Revertible,
|
|
13
|
+
* ScopeMethod,
|
|
14
|
+
* ScopedCallback,
|
|
15
|
+
* } from '../types/index.js'
|
|
16
|
+
*/
|
|
17
|
+
export class Scope {
|
|
18
|
+
/** @param {ScopeParams} [parameters] */
|
|
19
|
+
constructor(parameters?: ScopeParams);
|
|
20
|
+
/** @type {DefaultsParams} */
|
|
21
|
+
defaults: DefaultsParams;
|
|
22
|
+
/** @type {Document|DOMTarget} */
|
|
23
|
+
root: Document | DOMTarget;
|
|
24
|
+
/** @type {Array<ScopeConstructorCallback>} */
|
|
25
|
+
constructors: Array<ScopeConstructorCallback>;
|
|
26
|
+
/** @type {Array<ScopeCleanupCallback>} */
|
|
27
|
+
revertConstructors: Array<ScopeCleanupCallback>;
|
|
28
|
+
/** @type {Array<Revertible>} */
|
|
29
|
+
revertibles: Array<Revertible>;
|
|
30
|
+
/** @type {Array<ScopeConstructorCallback | ((scope: this) => Tickable)>} */
|
|
31
|
+
constructorsOnce: Array<ScopeConstructorCallback | ((scope: this) => Tickable)>;
|
|
32
|
+
/** @type {Array<ScopeCleanupCallback>} */
|
|
33
|
+
revertConstructorsOnce: Array<ScopeCleanupCallback>;
|
|
34
|
+
/** @type {Array<Revertible>} */
|
|
35
|
+
revertiblesOnce: Array<Revertible>;
|
|
36
|
+
/** @type {Boolean} */
|
|
37
|
+
once: boolean;
|
|
38
|
+
/** @type {Number} */
|
|
39
|
+
onceIndex: number;
|
|
40
|
+
/** @type {Record<String, ScopeMethod>} */
|
|
41
|
+
methods: Record<string, ScopeMethod>;
|
|
42
|
+
/** @type {Record<String, Boolean>} */
|
|
43
|
+
matches: Record<string, boolean>;
|
|
44
|
+
/** @type {Record<String, MediaQueryList>} */
|
|
45
|
+
mediaQueryLists: Record<string, MediaQueryList>;
|
|
46
|
+
/** @type {Record<String, any>} */
|
|
47
|
+
data: Record<string, any>;
|
|
48
|
+
/**
|
|
49
|
+
* @param {Revertible} revertible
|
|
50
|
+
*/
|
|
51
|
+
register(revertible: Revertible): void;
|
|
52
|
+
/**
|
|
53
|
+
* @template T
|
|
54
|
+
* @param {ScopedCallback<T>} cb
|
|
55
|
+
* @return {T}
|
|
56
|
+
*/
|
|
57
|
+
execute<T>(cb: ScopedCallback<T>): T;
|
|
58
|
+
/**
|
|
59
|
+
* @return {this}
|
|
60
|
+
*/
|
|
61
|
+
refresh(): this;
|
|
62
|
+
/**
|
|
63
|
+
* @overload
|
|
64
|
+
* @param {String} a1
|
|
65
|
+
* @param {ScopeMethod} a2
|
|
66
|
+
* @return {this}
|
|
67
|
+
*
|
|
68
|
+
* @overload
|
|
69
|
+
* @param {ScopeConstructorCallback} a1
|
|
70
|
+
* @return {this}
|
|
71
|
+
*
|
|
72
|
+
* @param {String|ScopeConstructorCallback} a1
|
|
73
|
+
* @param {ScopeMethod} [a2]
|
|
74
|
+
*/
|
|
75
|
+
add(a1: string, a2: ScopeMethod): this;
|
|
76
|
+
/**
|
|
77
|
+
* @overload
|
|
78
|
+
* @param {String} a1
|
|
79
|
+
* @param {ScopeMethod} a2
|
|
80
|
+
* @return {this}
|
|
81
|
+
*
|
|
82
|
+
* @overload
|
|
83
|
+
* @param {ScopeConstructorCallback} a1
|
|
84
|
+
* @return {this}
|
|
85
|
+
*
|
|
86
|
+
* @param {String|ScopeConstructorCallback} a1
|
|
87
|
+
* @param {ScopeMethod} [a2]
|
|
88
|
+
*/
|
|
89
|
+
add(a1: ScopeConstructorCallback): this;
|
|
90
|
+
/**
|
|
91
|
+
* @param {ScopeConstructorCallback} scopeConstructorCallback
|
|
92
|
+
* @return {this}
|
|
93
|
+
*/
|
|
94
|
+
addOnce(scopeConstructorCallback: ScopeConstructorCallback): this;
|
|
95
|
+
/**
|
|
96
|
+
* @param {(scope: this) => Tickable} cb
|
|
97
|
+
* @return {Tickable}
|
|
98
|
+
*/
|
|
99
|
+
keepTime(cb: (scope: this) => Tickable): Tickable;
|
|
100
|
+
/**
|
|
101
|
+
* @param {Event} e
|
|
102
|
+
*/
|
|
103
|
+
handleEvent(e: Event): void;
|
|
104
|
+
revert(): void;
|
|
105
|
+
}
|
|
106
|
+
export function createScope(params?: ScopeParams): Scope;
|
|
107
|
+
import type { DefaultsParams } from '../types/index.js';
|
|
108
|
+
import type { DOMTarget } from '../types/index.js';
|
|
109
|
+
import type { ScopeConstructorCallback } from '../types/index.js';
|
|
110
|
+
import type { ScopeCleanupCallback } from '../types/index.js';
|
|
111
|
+
import type { Revertible } from '../types/index.js';
|
|
112
|
+
import type { Tickable } from '../types/index.js';
|
|
113
|
+
import type { ScopeMethod } from '../types/index.js';
|
|
114
|
+
import type { ScopedCallback } from '../types/index.js';
|
|
115
|
+
import type { ScopeParams } from '../types/index.js';
|