first commit

This commit is contained in:
Warunee Tamkoo 2023-09-06 14:51:44 +07:00
commit eb2f504652
32490 changed files with 5731109 additions and 0 deletions

15
node_modules/amator/.npmignore generated vendored Normal file
View file

@ -0,0 +1,15 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
npm-debug.log
node_modules

21
node_modules/amator/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Andrei Kashcha
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

45
node_modules/amator/README.md generated vendored Normal file
View file

@ -0,0 +1,45 @@
# amator
Tiny animation library.
# usage
``` js
var animate = require('amator')
var from = { x: 0 }
var to = { x: 42 }
// This will animate from.x from 0 to 42 in 400ms, using cubic bezier easing
// function (same effect as default CSS `ease` function)
animate(from, to)
```
Overall the signature of the `animate()` function:
```js
animate(fromObj, toObj, options)
```
## options
This is a hash dictionary with the following keys:
* `duration` - sets animation duration in milliseconds. Default value is 400ms;
* `easing` - Easing function. Can accept predefined value similar to CSS animations:
`ease`, `easeIn`, `easeOut`, `easeInOut`, `linear`; NOTE: You can also have a
custom function instead of a string value. The function should take a single
argument `t` from range [0..1] and return value from 0 to 1.
* `step(fromObj)` - a function callback that is called after each animation frame.
the only argument to this function is `fromObj` that has current animation values.
* `done()` - a function callback that is called when animation is finished.
## return value
The return value of the `animate` is an object, which has just one key:
* `cancel()` - if you want to cancel animation before it completes, you can call
this method.
# license
MIT

1
node_modules/amator/demo/hash-chat/.npmignore generated vendored Normal file
View file

@ -0,0 +1 @@
bundle.js

107
node_modules/amator/demo/hash-chat/index.html generated vendored Normal file
View file

@ -0,0 +1,107 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta property="og:title" content="Hash chat" />
<meta property="og:image" content="https://raw.githubusercontent.com/anvaka/amator/master/demo/hash-chat/thumbnail_question.png" />
<meta property="og:description" content="Communicate via query string" />
<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'>
<meta http-equiv='X-UA-Compatible' content='IE=edge' >
<meta charset="utf-8">
<title>Hash chat - communicate via query string with style</title>
<meta name="Description" content="Chat via query string">
<style type="text/css" media="screen">
* {
box-sizing: border-box;
}
.scene {
font-size: 32px;
}
.letter {
display: inline-block;
white-space: pre;
}
body {
cursor: pointer;
overflow: hidden;
background: black;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 0;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
color: white;
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.edit-text {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
input#text-input {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
background: transparent;
opacity: 0;
color: white;
width: 500px;
border-width: 0px;
border-bottom: 1px dotted #3399aa;
text-align: center;
font-size: 34px;
outline: none;
margin-top: 22px;
}
input#text-input:focus {
opacity: 1;
}
.help-text {
opacity: 0;
color: #444;
padding-top: 3px;
}
input#text-input:focus ~ .help-text {
opacity: 1;
}
#current-url {
opacity: 0;
position: absolute;
left: -1000px;
}
@media (max-width: 740px) {
input#text-input:focus {
width: 100%;
}
}
</style>
</head>
<body>
<div class='scene'></div>
<div class='edit-text'>
<input type='text' id='text-input'></input>
<div class='help-text'>
Enter your response and send them the link.
</div>
</div>
<input id='current-url' tyle='text'></input>
<script src='bundle.js'></script>
</body>
</html>

109
node_modules/amator/demo/hash-chat/index.js generated vendored Normal file
View file

@ -0,0 +1,109 @@
var amator = require('../../index.js');
var queryState = require('query-state');
var qs = queryState({
text: 'hello world'
});
var currentUrl = document.getElementById('current-url');
var inputText = document.getElementById('text-input');
inputText.addEventListener('keyup', updateQueryState);
inputText.addEventListener('blur', updateQueryState);
inputText.addEventListener('keydown', handleKeyDown);
document.body.addEventListener('click', function() {
inputText.focus();
})
function handleKeyDown(e) {
updateQueryState();
if (e.which === 13) {
animateText(qs.get('text'));
currentUrl.focus();
currentUrl.select();
}
}
function updateQueryState() {
qs.set('text', inputText.value);
currentUrl.value = window.location.href;
}
function updateInputBox(appState) {
inputText.value = appState.name || '';
}
qs.onChange(function(appState) {
animateText(appState.text);
updateInputBox(appState.text);
});
var scene = document.querySelector('.scene');
animateText(qs.get('text'));
function animateText(text) {
var letters = [];
amator.sharedScheduler.clearAll();
scene.innerHTML = '';
Array.from(text).forEach(function (letter, idx, arr){
let wrapper = document.createElement('span');
wrapper.classList.add('letter')
wrapper.innerText = letter;
scene.appendChild(wrapper);
letters.push(wrapper);
var translateDirection = idx < arr.length / 2 ? -1 : 1;
scheduleAnimation(wrapper, translateDirection);
});
}
function scheduleAnimation(dom, translateDirection) {
var fadeOutAfter = Math.random() * 1500 + 500;
var fadeOutDuration = Math.random() * 2000 + 500;
var offsetLength = translateDirection * (Math.random() * 35 + 35);
setTimeout(fadeOutAnimation, fadeOutAfter)
setTimeout(moveOutAnimation, fadeOutAfter * 1.1)
setTimeout(blurAnimation, fadeOutAfter * 0.9)
function fadeOutAnimation() {
amator(
{ opacity: 1.0 },
{ opacity: 0. },
{
scheduler: amator.sharedScheduler,
duration: fadeOutDuration,
step: function(v) {
dom.style.opacity = v.opacity;
}
}
);
}
function moveOutAnimation() {
amator(
{ left: 0.0 },
{ left: offsetLength },
{
scheduler: amator.sharedScheduler,
duration: fadeOutDuration,
step: function(v) {
dom.style.transform = 'translateX(' + v.left + 'px)';
}
});
}
function blurAnimation() {
amator(
{ blur: 0.0 },
{ blur: 5 },
{
scheduler: amator.sharedScheduler,
duration: fadeOutDuration,
step: function(v) {
dom.style.filter = 'blur(' + v.blur + 'px)';
}
});
}
}

8
node_modules/amator/demo/hash-chat/package.json generated vendored Normal file
View file

@ -0,0 +1,8 @@
{
"scripts": {
"start": "browserify index.js > bundle.js"
},
"dependencies": {
"query-state": "^3.0.4"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

264
node_modules/amator/dist/amator.js generated vendored Normal file
View file

@ -0,0 +1,264 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.amator = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var BezierEasing = require('bezier-easing')
// Predefined set of animations. Similar to CSS easing functions
var animations = {
ease: BezierEasing(0.25, 0.1, 0.25, 1),
easeIn: BezierEasing(0.42, 0, 1, 1),
easeOut: BezierEasing(0, 0, 0.58, 1),
easeInOut: BezierEasing(0.42, 0, 0.58, 1),
linear: BezierEasing(0, 0, 1, 1)
}
module.exports = animate;
module.exports.makeAggregateRaf = makeAggregateRaf;
module.exports.sharedScheduler = makeAggregateRaf();
function animate(source, target, options) {
var start = Object.create(null)
var diff = Object.create(null)
options = options || {}
// We let clients specify their own easing function
var easing = (typeof options.easing === 'function') ? options.easing : animations[options.easing]
// if nothing is specified, default to ease (similar to CSS animations)
if (!easing) {
if (options.easing) {
console.warn('Unknown easing function in amator: ' + options.easing);
}
easing = animations.ease
}
var step = typeof options.step === 'function' ? options.step : noop
var done = typeof options.done === 'function' ? options.done : noop
var scheduler = getScheduler(options.scheduler)
var keys = Object.keys(target)
keys.forEach(function(key) {
start[key] = source[key]
diff[key] = target[key] - source[key]
})
var durationInMs = typeof options.duration === 'number' ? options.duration : 400
var durationInFrames = Math.max(1, durationInMs * 0.06) // 0.06 because 60 frames pers 1,000 ms
var previousAnimationId
var frame = 0
previousAnimationId = scheduler.next(loop)
return {
cancel: cancel
}
function cancel() {
scheduler.cancel(previousAnimationId)
previousAnimationId = 0
}
function loop() {
var t = easing(frame/durationInFrames)
frame += 1
setValues(t)
if (frame <= durationInFrames) {
previousAnimationId = scheduler.next(loop)
step(source)
} else {
previousAnimationId = 0
setTimeout(function() { done(source) }, 0)
}
}
function setValues(t) {
keys.forEach(function(key) {
source[key] = diff[key] * t + start[key]
})
}
}
function noop() { }
function getScheduler(scheduler) {
if (!scheduler) {
var canRaf = typeof window !== 'undefined' && window.requestAnimationFrame
return canRaf ? rafScheduler() : timeoutScheduler()
}
if (typeof scheduler.next !== 'function') throw new Error('Scheduler is supposed to have next(cb) function')
if (typeof scheduler.cancel !== 'function') throw new Error('Scheduler is supposed to have cancel(handle) function')
return scheduler
}
function rafScheduler() {
return {
next: window.requestAnimationFrame.bind(window),
cancel: window.cancelAnimationFrame.bind(window)
}
}
function timeoutScheduler() {
return {
next: function(cb) {
return setTimeout(cb, 1000/60)
},
cancel: function (id) {
return clearTimeout(id)
}
}
}
function makeAggregateRaf() {
var frontBuffer = new Set();
var backBuffer = new Set();
var frameToken = 0;
return {
next: next,
cancel: next,
clearAll: clearAll
}
function clearAll() {
frontBuffer.clear();
backBuffer.clear();
cancelAnimationFrame(frameToken);
frameToken = 0;
}
function next(callback) {
backBuffer.add(callback);
renderNextFrame();
}
function renderNextFrame() {
if (!frameToken) frameToken = requestAnimationFrame(renderFrame);
}
function renderFrame() {
frameToken = 0;
var t = backBuffer;
backBuffer = frontBuffer;
frontBuffer = t;
frontBuffer.forEach(function(callback) {
callback();
});
frontBuffer.clear();
}
function cancel(callback) {
backBuffer.delete(callback);
}
}
},{"bezier-easing":2}],2:[function(require,module,exports){
/**
* https://github.com/gre/bezier-easing
* BezierEasing - use bezier curve for transition easing function
* by Gaëtan Renaudeau 2014 - 2015 MIT License
*/
// These values are established by empiricism with tests (tradeoff: performance VS precision)
var NEWTON_ITERATIONS = 4;
var NEWTON_MIN_SLOPE = 0.001;
var SUBDIVISION_PRECISION = 0.0000001;
var SUBDIVISION_MAX_ITERATIONS = 10;
var kSplineTableSize = 11;
var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
var float32ArraySupported = typeof Float32Array === 'function';
function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; }
function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; }
function C (aA1) { return 3.0 * aA1; }
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; }
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); }
function binarySubdivide (aX, aA, aB, mX1, mX2) {
var currentX, currentT, i = 0;
do {
currentT = aA + (aB - aA) / 2.0;
currentX = calcBezier(currentT, mX1, mX2) - aX;
if (currentX > 0.0) {
aB = currentT;
} else {
aA = currentT;
}
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
return currentT;
}
function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
var currentSlope = getSlope(aGuessT, mX1, mX2);
if (currentSlope === 0.0) {
return aGuessT;
}
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
aGuessT -= currentX / currentSlope;
}
return aGuessT;
}
module.exports = function bezier (mX1, mY1, mX2, mY2) {
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
throw new Error('bezier x values must be in [0, 1] range');
}
// Precompute samples table
var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
if (mX1 !== mY1 || mX2 !== mY2) {
for (var i = 0; i < kSplineTableSize; ++i) {
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
}
}
function getTForX (aX) {
var intervalStart = 0.0;
var currentSample = 1;
var lastSample = kSplineTableSize - 1;
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
intervalStart += kSampleStepSize;
}
--currentSample;
// Interpolate to provide an initial guess for t
var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
var guessForT = intervalStart + dist * kSampleStepSize;
var initialSlope = getSlope(guessForT, mX1, mX2);
if (initialSlope >= NEWTON_MIN_SLOPE) {
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
} else if (initialSlope === 0.0) {
return guessForT;
} else {
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
}
}
return function BezierEasing (x) {
if (mX1 === mY1 && mX2 === mY2) {
return x; // linear
}
// Because JavaScript number are imprecise, we should guarantee the extremes are right.
if (x === 0) {
return 0;
}
if (x === 1) {
return 1;
}
return calcBezier(getTForX(x), mY1, mY2);
};
};
},{}]},{},[1])(1)
});

1
node_modules/amator/dist/amator.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

154
node_modules/amator/index.js generated vendored Normal file
View file

@ -0,0 +1,154 @@
var BezierEasing = require('bezier-easing')
// Predefined set of animations. Similar to CSS easing functions
var animations = {
ease: BezierEasing(0.25, 0.1, 0.25, 1),
easeIn: BezierEasing(0.42, 0, 1, 1),
easeOut: BezierEasing(0, 0, 0.58, 1),
easeInOut: BezierEasing(0.42, 0, 0.58, 1),
linear: BezierEasing(0, 0, 1, 1)
}
module.exports = animate;
module.exports.makeAggregateRaf = makeAggregateRaf;
module.exports.sharedScheduler = makeAggregateRaf();
function animate(source, target, options) {
var start = Object.create(null)
var diff = Object.create(null)
options = options || {}
// We let clients specify their own easing function
var easing = (typeof options.easing === 'function') ? options.easing : animations[options.easing]
// if nothing is specified, default to ease (similar to CSS animations)
if (!easing) {
if (options.easing) {
console.warn('Unknown easing function in amator: ' + options.easing);
}
easing = animations.ease
}
var step = typeof options.step === 'function' ? options.step : noop
var done = typeof options.done === 'function' ? options.done : noop
var scheduler = getScheduler(options.scheduler)
var keys = Object.keys(target)
keys.forEach(function(key) {
start[key] = source[key]
diff[key] = target[key] - source[key]
})
var durationInMs = typeof options.duration === 'number' ? options.duration : 400
var durationInFrames = Math.max(1, durationInMs * 0.06) // 0.06 because 60 frames pers 1,000 ms
var previousAnimationId
var frame = 0
previousAnimationId = scheduler.next(loop)
return {
cancel: cancel
}
function cancel() {
scheduler.cancel(previousAnimationId)
previousAnimationId = 0
}
function loop() {
var t = easing(frame/durationInFrames)
frame += 1
setValues(t)
if (frame <= durationInFrames) {
previousAnimationId = scheduler.next(loop)
step(source)
} else {
previousAnimationId = 0
setTimeout(function() { done(source) }, 0)
}
}
function setValues(t) {
keys.forEach(function(key) {
source[key] = diff[key] * t + start[key]
})
}
}
function noop() { }
function getScheduler(scheduler) {
if (!scheduler) {
var canRaf = typeof window !== 'undefined' && window.requestAnimationFrame
return canRaf ? rafScheduler() : timeoutScheduler()
}
if (typeof scheduler.next !== 'function') throw new Error('Scheduler is supposed to have next(cb) function')
if (typeof scheduler.cancel !== 'function') throw new Error('Scheduler is supposed to have cancel(handle) function')
return scheduler
}
function rafScheduler() {
return {
next: window.requestAnimationFrame.bind(window),
cancel: window.cancelAnimationFrame.bind(window)
}
}
function timeoutScheduler() {
return {
next: function(cb) {
return setTimeout(cb, 1000/60)
},
cancel: function (id) {
return clearTimeout(id)
}
}
}
function makeAggregateRaf() {
var frontBuffer = new Set();
var backBuffer = new Set();
var frameToken = 0;
return {
next: next,
cancel: next,
clearAll: clearAll
}
function clearAll() {
frontBuffer.clear();
backBuffer.clear();
cancelAnimationFrame(frameToken);
frameToken = 0;
}
function next(callback) {
backBuffer.add(callback);
renderNextFrame();
}
function renderNextFrame() {
if (!frameToken) frameToken = requestAnimationFrame(renderFrame);
}
function renderFrame() {
frameToken = 0;
var t = backBuffer;
backBuffer = frontBuffer;
frontBuffer = t;
frontBuffer.forEach(function(callback) {
callback();
});
frontBuffer.clear();
}
function cancel(callback) {
backBuffer.delete(callback);
}
}

27
node_modules/amator/package.json generated vendored Normal file
View file

@ -0,0 +1,27 @@
{
"name": "amator",
"version": "1.1.0",
"description": "Tiny animation library",
"main": "index.js",
"scripts": {
"test": "tap test/*.js",
"build": "browserify -s amator ./index.js > dist/amator.js && uglifyjs dist/amator.js > dist/amator.min.js"
},
"keywords": [
"animation",
"small",
"library"
],
"author": "Andrei Kashcha",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/anvaka/amator"
},
"dependencies": {
"bezier-easing": "^2.0.3"
},
"devDependencies": {
"tap": "^5.7.1"
}
}

61
node_modules/amator/test/index.js generated vendored Normal file
View file

@ -0,0 +1,61 @@
var test = require('tap').test;
var animate = require('../');
test('it can animate objects', function(t) {
var source = {
x: 0
};
var target = {
x: 42
}
animate(source, target, {
duration: 100,
done: function() {
t.equals(source.x, 42, 'it animated source to target');
t.end();
}
})
});
test('it can animate objects even when duration is 0', function(t) {
var source = {
x: 0
};
var target = {
x: 42
}
animate(source, target, {
duration: 0,
done: function() {
t.equals(source.x, 42, 'it animated source to target');
t.end();
}
})
});
test('it notifies about each animation step', function(t) {
var source = {
x: 0
};
var target = {
x: 42
};
var invokedCount = 0;
animate(source, target, {
duration: 10,
step: function(currentValue) {
t.ok(currentValue === source, 'source value is passed as an argument')
invokedCount += 1;
},
done: function() {
t.equals(source.x, 42, 'it animated source to target');
t.ok(invokedCount > 0, 'It invoked step() at least once');
t.end();
}
})
});