ravnur-player-public 3.4.4 → 3.4.6
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/dist/RavnurMediaPlayer.min.js +1 -1
- package/dist/cdn/RavnurMediaPlayer.min.js +1 -1
- package/package.json +72 -68
- package/.eslintignore +0 -7
- package/.eslintrc.js +0 -206
- package/.flowconfig +0 -3
- package/.vscode/extensions.json +0 -7
- package/.vscode/launch.json +0 -37
- package/.vscode/settings.json +0 -4
- package/README-Private.md +0 -54
- package/babel.config.js +0 -28
- package/bitbucket-pipelines.yml +0 -61
- package/cert.pem +0 -23
- package/demo/BaseM.mp4 +0 -0
- package/demo/HD.mp4 +0 -0
- package/demo/annotations.json +0 -50
- package/demo/annotations_ge.json +0 -50
- package/demo/base.mp3 +0 -0
- package/demo/cc_2125en.vtt +0 -4958
- package/demo/cc_en.vtt +0 -171
- package/demo/cc_ge.vtt +0 -178
- package/demo/chapters_en.vtt +0 -38
- package/demo/chapters_ge.vtt +0 -5
- package/demo/chapters_ge1.json +0 -23
- package/demo/hls/audio/stereo/en/128kbit.m3u8 +0 -912
- package/demo/hls/audio/stereo/none/128kbit.m3u8 +0 -912
- package/demo/hls/audio/surround/en/320kbit.m3u8 +0 -912
- package/demo/hls/playlist.m3u8 +0 -31
- package/demo/hls/video/10000kbit.m3u8 +0 -894
- package/demo/hls/video/1100kbit.m3u8 +0 -894
- package/demo/hls/video/1500kbit.m3u8 +0 -894
- package/demo/hls/video/250kbit.m3u8 +0 -894
- package/demo/hls/video/4000kbit.m3u8 +0 -894
- package/demo/hls/video/500kbit.m3u8 +0 -894
- package/demo/hls/video/6000kbit.m3u8 +0 -894
- package/demo/hls/video/800kbit.m3u8 +0 -894
- package/demo/hls.js +0 -5
- package/demo/hls.js.map +0 -1
- package/demo/hls.min.js +0 -2
- package/demo/hls.min.js.map +0 -1
- package/demo/playlist.m3u8 +0 -31
- package/demo/ravnur-flash-audio.swf +0 -0
- package/demo/ravnur-flash-video-hls.swf +0 -0
- package/demo/ravnur-flash-video.swf +0 -0
- package/demo/shaka/shaka-player.foo.debug.d.ts +0 -4532
- package/demo/shaka/shaka-player.foo.debug.externs.js +0 -3886
- package/demo/shaka/shaka-player.foo.debug.js +0 -1746
- package/demo/shaka/shaka-player.foo.debug.map +0 -8
- package/demo/shaka/wrapper.js +0 -7
- package/demo/test.html +0 -458
- package/jest.config.js +0 -4
- package/key.pem +0 -27
- package/lib/es5.js +0 -344
- package/lib/images/Spinner-small.gif +0 -0
- package/lib/images/close.png +0 -0
- package/lib/images/ic_check_box_black_24dp_1x.png +0 -0
- package/lib/images/ic_check_box_outline_blank_black_24dp_1x.png +0 -0
- package/lib/images/ic_chevron_left_white_24dp_1x.png +0 -0
- package/lib/images/ic_chevron_right_white_24dp_1x.png +0 -0
- package/lib/images/ic_closed_caption_white_24dp_1x.png +0 -0
- package/lib/images/ic_fast_forward_white_24dp_1x.png +0 -0
- package/lib/images/ic_fast_rewind_white_24dp_1x.png +0 -0
- package/lib/images/ic_fullscreen_exit_white_24dp_1x.png +0 -0
- package/lib/images/ic_fullscreen_white_24dp_1x.png +0 -0
- package/lib/images/ic_hd_white_24dp_1x.png +0 -0
- package/lib/images/ic_keyboard_arrow_left_black_24dp_1x.png +0 -0
- package/lib/images/ic_keyboard_arrow_right_black_24dp_1x.png +0 -0
- package/lib/images/ic_pause_white_24dp_1x.png +0 -0
- package/lib/images/ic_photo_white_24dp_1x.png +0 -0
- package/lib/images/ic_play_arrow_white_24dp_1x.png +0 -0
- package/lib/images/ic_refresh_white_24dp_1x.png +0 -0
- package/lib/images/ic_settings_white_24dp_1x.png +0 -0
- package/lib/images/ic_skip_next_white_24dp_1x.png +0 -0
- package/lib/images/ic_skip_previous_white_24dp_1x.png +0 -0
- package/lib/images/ic_toc_white_24dp_1x.png +0 -0
- package/lib/images/ic_volume_off_white_24dp_1x.png +0 -0
- package/lib/images/ic_volume_up_white_24dp_1x.png +0 -0
- package/lib/player4ie8.css +0 -225
- package/server.js +0 -29
- package/src/config/cc.js +0 -56
- package/src/config/i18n.js +0 -101
- package/src/config/options.js +0 -123
- package/src/config/playlist.js +0 -9
- package/src/config/source.js +0 -23
- package/src/config/statuses.js +0 -8
- package/src/config/styles.js +0 -16
- package/src/entity.js +0 -27
- package/src/events.js +0 -5
- package/src/extensions/annotations.js +0 -142
- package/src/extensions/audio-tarcks.js +0 -115
- package/src/extensions/backward.js +0 -45
- package/src/extensions/base.js +0 -73
- package/src/extensions/bottom-next.js +0 -50
- package/src/extensions/bottom-prev.js +0 -50
- package/src/extensions/buffering.js +0 -78
- package/src/extensions/c2pa.js +0 -350
- package/src/extensions/caption-search.js +0 -230
- package/src/extensions/cc.js +0 -874
- package/src/extensions/crawl.js +0 -118
- package/src/extensions/download.js +0 -411
- package/src/extensions/error.js +0 -47
- package/src/extensions/forward.js +0 -44
- package/src/extensions/fullscreen.js +0 -84
- package/src/extensions/help.js +0 -201
- package/src/extensions/helpers/FileSaver.js +0 -157
- package/src/extensions/helpers/clickOpener.js +0 -180
- package/src/extensions/helpers/opener.js +0 -30
- package/src/extensions/helpers/openerHeightChecker.js +0 -13
- package/src/extensions/helpers/popover.js +0 -33
- package/src/extensions/helpers/popoverPosition.js +0 -30
- package/src/extensions/helpers/scrollIntoView.js +0 -9
- package/src/extensions/helpers/storage.js +0 -20
- package/src/extensions/helpers/textContent.js +0 -6
- package/src/extensions/helpers/timeCodeToSeconds.js +0 -44
- package/src/extensions/helpers/transport.js +0 -43
- package/src/extensions/helpers/vtt-loader.js +0 -42
- package/src/extensions/index.js +0 -87
- package/src/extensions/live.js +0 -76
- package/src/extensions/mux.js +0 -57
- package/src/extensions/next-frame.js +0 -44
- package/src/extensions/next.js +0 -48
- package/src/extensions/placeholder.js +0 -241
- package/src/extensions/play.js +0 -102
- package/src/extensions/poster.js +0 -47
- package/src/extensions/prev-frame.js +0 -44
- package/src/extensions/prev.js +0 -48
- package/src/extensions/progress.js +0 -465
- package/src/extensions/resizer.js +0 -37
- package/src/extensions/settings.js +0 -367
- package/src/extensions/theater.js +0 -56
- package/src/extensions/title.js +0 -38
- package/src/extensions/toc.js +0 -334
- package/src/extensions/volume.js +0 -196
- package/src/flash/FlashPlugin.js +0 -301
- package/src/flash/MediaElement.js +0 -361
- package/src/flash/plugins.js +0 -32
- package/src/flash-detector.js +0 -66
- package/src/helpers/$t.js +0 -10
- package/src/helpers/binder.js +0 -11
- package/src/helpers/isAndroid.js +0 -5
- package/src/helpers/isBlackBerry.js +0 -5
- package/src/helpers/isCanvasSupported.js +0 -6
- package/src/helpers/isIE.js +0 -21
- package/src/helpers/isMobile.js +0 -10
- package/src/helpers/isWindows.js +0 -5
- package/src/helpers/isWindowsPhone.js +0 -5
- package/src/helpers/isiOS.js +0 -5
- package/src/html5media.js +0 -19
- package/src/index.js +0 -2
- package/src/logger.js +0 -31
- package/src/microevent.js +0 -65
- package/src/normalize-options.js +0 -139
- package/src/player.js +0 -864
- package/src/players/base.js +0 -209
- package/src/players/flash.js +0 -172
- package/src/players/hls.js +0 -278
- package/src/players/html.js +0 -205
- package/src/players/index.js +0 -59
- package/src/players/shaka.js +0 -219
- package/src/playlist.js +0 -362
- package/src/screenfull.js +0 -121
- package/src/state.js +0 -474
- package/src/static/es5.js +0 -344
- package/src/static/images/Spinner-small.gif +0 -0
- package/src/static/images/close.png +0 -0
- package/src/static/images/ic_check_box_black_24dp_1x.png +0 -0
- package/src/static/images/ic_check_box_outline_blank_black_24dp_1x.png +0 -0
- package/src/static/images/ic_chevron_left_white_24dp_1x.png +0 -0
- package/src/static/images/ic_chevron_right_white_24dp_1x.png +0 -0
- package/src/static/images/ic_closed_caption_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fast_forward_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fast_rewind_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fullscreen_exit_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fullscreen_white_24dp_1x.png +0 -0
- package/src/static/images/ic_hd_white_24dp_1x.png +0 -0
- package/src/static/images/ic_keyboard_arrow_left_black_24dp_1x.png +0 -0
- package/src/static/images/ic_keyboard_arrow_right_black_24dp_1x.png +0 -0
- package/src/static/images/ic_pause_white_24dp_1x.png +0 -0
- package/src/static/images/ic_play_arrow_white_24dp_1x.png +0 -0
- package/src/static/images/ic_refresh_white_24dp_1x.png +0 -0
- package/src/static/images/ic_settings_white_24dp_1x.png +0 -0
- package/src/static/images/ic_skip_next_white_24dp_1x.png +0 -0
- package/src/static/images/ic_skip_previous_white_24dp_1x.png +0 -0
- package/src/static/images/ic_toc_white_24dp_1x.png +0 -0
- package/src/static/images/ic_volume_off_white_24dp_1x.png +0 -0
- package/src/static/images/ic_volume_up_white_24dp_1x.png +0 -0
- package/src/static/player4ie8.css +0 -225
- package/src/styles/bplaylist.css.js +0 -124
- package/src/styles/index.js +0 -1966
- package/src/styles/playlist.css.js +0 -84
- package/src/styles/rplaylist.css.js +0 -98
- package/src/svgs.js +0 -111
- package/src/types/Logger.js +0 -10
- package/src/types/Options.js +0 -179
- package/src/types/Playlist.js +0 -3
- package/src/types/Source.js +0 -28
- package/src/types/State.js +0 -46
- package/src/types/Styles.js +0 -11
- package/src/types/TimeData.js +0 -8
- package/src/types/Translation.js +0 -69
- package/src/utils/absolutizeUrl.js +0 -9
- package/src/utils/addClass.js +0 -9
- package/src/utils/addEvent.js +0 -31
- package/src/utils/addProperty.js +0 -65
- package/src/utils/appendChild.js +0 -14
- package/src/utils/buff2hex.js +0 -5
- package/src/utils/contains.js +0 -33
- package/src/utils/createElement.js +0 -24
- package/src/utils/each.js +0 -34
- package/src/utils/escapeHTML.js +0 -8
- package/src/utils/existy.js +0 -4
- package/src/utils/extend.js +0 -17
- package/src/utils/filter.js +0 -16
- package/src/utils/find.js +0 -11
- package/src/utils/findIndex.js +0 -20
- package/src/utils/first.js +0 -5
- package/src/utils/get.js +0 -19
- package/src/utils/has.js +0 -5
- package/src/utils/hasClass.js +0 -6
- package/src/utils/head.js +0 -11
- package/src/utils/inRange.js +0 -16
- package/src/utils/index.js +0 -73
- package/src/utils/isArray.js +0 -4
- package/src/utils/isBoolean.js +0 -3
- package/src/utils/isElement.js +0 -7
- package/src/utils/isEmpty.js +0 -6
- package/src/utils/isEqual.js +0 -33
- package/src/utils/isEqualBuffer.js +0 -13
- package/src/utils/isFunction.js +0 -3
- package/src/utils/isNotEmpty.js +0 -5
- package/src/utils/isObject.js +0 -5
- package/src/utils/isString.js +0 -9
- package/src/utils/last.js +0 -4
- package/src/utils/map.js +0 -11
- package/src/utils/negate.js +0 -8
- package/src/utils/noop.js +0 -1
- package/src/utils/notExisty.js +0 -5
- package/src/utils/reduce.js +0 -8
- package/src/utils/remove.js +0 -7
- package/src/utils/removeClass.js +0 -8
- package/src/utils/removeEvent.js +0 -7
- package/src/utils/toArray.js +0 -7
- package/src/utils/toggleClass.js +0 -16
- package/src/utils/uidGenerator.js +0 -8
- package/src/utils/upperFirst.js +0 -4
- package/tests/extensions/__snapshots__/download.spec.js.snap +0 -226
- package/tests/extensions/__snapshots__/fullscreen.spec.js.snap +0 -30
- package/tests/extensions/__snapshots__/title.spec.js.snap +0 -16
- package/tests/extensions/download.spec.js +0 -111
- package/tests/extensions/fullscreen.spec.js +0 -56
- package/tests/extensions/title.spec.js +0 -35
- package/tests/mocks/assets/BaseM.mp4 +0 -0
- package/tests/mocks/assets/hls.min.js +0 -5
- package/tests/mocks/assets/styleMock.js +0 -1
- package/tests/mocks/base-player-options.js +0 -47
- package/tests/mocks/sources.js +0 -58
- package/tests/mocks/timedata/cc_en.vtt +0 -171
- package/tests/mocks/timedata/cc_ge.vtt +0 -178
- package/tests/utils/wait.js +0 -1
- package/webpack.config.js +0 -78
package/src/utils/addClass.js
DELETED
package/src/utils/addEvent.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// add event cross browser
|
|
2
|
-
export default function addEvent(elem, event, fn, useCapture = false) {
|
|
3
|
-
if (elem.addEventListener) {
|
|
4
|
-
elem.addEventListener(event, listenHandler, useCapture);
|
|
5
|
-
return { elem, handler: listenHandler, event };
|
|
6
|
-
}
|
|
7
|
-
elem.attachEvent('on' + event, attachHandler);
|
|
8
|
-
return { elem, handler: attachHandler, event };
|
|
9
|
-
|
|
10
|
-
// avoid memory overhead of new anonymous functions for every event handler that's installed
|
|
11
|
-
// by using local functions
|
|
12
|
-
function listenHandler(e) {
|
|
13
|
-
var ret = fn.apply(elem, arguments);
|
|
14
|
-
if (ret === false) {
|
|
15
|
-
e.stopPropagation();
|
|
16
|
-
e.preventDefault();
|
|
17
|
-
}
|
|
18
|
-
return ret;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function attachHandler() {
|
|
22
|
-
// set the this pointer same as addEventListener when fn is called
|
|
23
|
-
// and make sure the event is passed to the fn also so that works the same too
|
|
24
|
-
var ret = fn.call(elem, window.event);
|
|
25
|
-
if (ret === false) {
|
|
26
|
-
window.event.returnValue = false;
|
|
27
|
-
window.event.cancelBubble = true;
|
|
28
|
-
}
|
|
29
|
-
return ret;
|
|
30
|
-
}
|
|
31
|
-
}
|
package/src/utils/addProperty.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* add property to object
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} obj object
|
|
5
|
-
* @param {String} name name of property
|
|
6
|
-
* @param {Function} onGet get's function
|
|
7
|
-
* @param {Function} onSet set's function
|
|
8
|
-
* @returns {void}
|
|
9
|
-
*/
|
|
10
|
-
export default function addProperty(obj, name, onGet, onSet) {
|
|
11
|
-
|
|
12
|
-
// wrapper functions
|
|
13
|
-
const
|
|
14
|
-
oldValue = obj[name],
|
|
15
|
-
getFn = () => onGet.apply(obj, [oldValue]),
|
|
16
|
-
setFn = newValue => onSet.apply(obj, [newValue]);
|
|
17
|
-
|
|
18
|
-
// Modern browsers, IE9+ (IE8 only works on DOM objects, not normal JS objects)
|
|
19
|
-
if (Object.defineProperty) {
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(obj, name, {
|
|
22
|
-
get: getFn,
|
|
23
|
-
set: setFn
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Older Firefox
|
|
27
|
-
} else if (obj.__defineGetter__) {
|
|
28
|
-
|
|
29
|
-
obj.__defineGetter__(name, getFn);
|
|
30
|
-
obj.__defineSetter__(name, setFn);
|
|
31
|
-
|
|
32
|
-
// IE6-7
|
|
33
|
-
// must be a real DOM object (to have attachEvent) and must be attached to document (for onpropertychange to fire)
|
|
34
|
-
} else {
|
|
35
|
-
|
|
36
|
-
const onPropertyChange = (event) => {
|
|
37
|
-
|
|
38
|
-
if (event.propertyName === name) {
|
|
39
|
-
|
|
40
|
-
// temporarily remove the event so it doesn't fire again and create a loop
|
|
41
|
-
obj.detachEvent('onpropertychange', onPropertyChange);
|
|
42
|
-
|
|
43
|
-
// get the changed value, run it through the set function
|
|
44
|
-
setFn(obj[name]);
|
|
45
|
-
|
|
46
|
-
// restore the get function
|
|
47
|
-
obj[name] = getFn;
|
|
48
|
-
obj[name].toString = () => getFn().toString();
|
|
49
|
-
|
|
50
|
-
// restore the event
|
|
51
|
-
obj.attachEvent('onpropertychange', onPropertyChange);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
obj[name] = getFn;
|
|
57
|
-
obj[name].toString = () => getFn().toString();
|
|
58
|
-
} catch (ex) {
|
|
59
|
-
//
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// add the property event change only once
|
|
63
|
-
obj.attachEvent('onpropertychange', onPropertyChange);
|
|
64
|
-
}
|
|
65
|
-
}
|
package/src/utils/appendChild.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import existy from './existy';
|
|
3
|
-
import isElement from './isElement';
|
|
4
|
-
|
|
5
|
-
/* Append child node */
|
|
6
|
-
export default function append(parent: Node, child: Node, before: ?Node) {
|
|
7
|
-
if (!parent) return;
|
|
8
|
-
|
|
9
|
-
if (existy(before) && isElement(before)) {
|
|
10
|
-
parent.insertBefore(child, before);
|
|
11
|
-
} else {
|
|
12
|
-
parent.appendChild(child);
|
|
13
|
-
}
|
|
14
|
-
}
|
package/src/utils/buff2hex.js
DELETED
package/src/utils/contains.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import isString from './isString';
|
|
2
|
-
import isFunction from './isFunction';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* check if item contains in some array
|
|
6
|
-
*
|
|
7
|
-
* @export
|
|
8
|
-
* @param {Array|String} etalon array
|
|
9
|
-
* @param {Function|String} cond condition
|
|
10
|
-
* @returns {Boolean} `true` if item contains in array
|
|
11
|
-
*/
|
|
12
|
-
export default function contains(etalon, cond) {
|
|
13
|
-
if (isString(etalon) && isString(cond)) {
|
|
14
|
-
return _containsInString(etalon, cond);
|
|
15
|
-
}
|
|
16
|
-
const condFnc = isFunction(cond) ? cond : obj => obj === cond;
|
|
17
|
-
return _containsInArray(etalon, condFnc);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _containsInString(string, substring) {
|
|
21
|
-
// eslint-disable-next-line no-magic-numbers
|
|
22
|
-
return string.indexOf(substring) > -1;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function _containsInArray(array, cond) {
|
|
26
|
-
for (let i = 0; i < array.length; i++) {
|
|
27
|
-
if (cond(array[i])) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import each from './each';
|
|
2
|
-
import append from './appendChild';
|
|
3
|
-
import isElement from './isElement';
|
|
4
|
-
import existy from './existy';
|
|
5
|
-
|
|
6
|
-
export default function createElement(tagName, props = {}, parent = null, namespace = 'http://www.w3.org/1999/xhtml') {
|
|
7
|
-
|
|
8
|
-
let el;
|
|
9
|
-
if ( existy(document.createElementNS) ) {
|
|
10
|
-
el = document.createElementNS(namespace, tagName);
|
|
11
|
-
} else {
|
|
12
|
-
el = document.createElement(tagName);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
each(props, (val, key) => {
|
|
16
|
-
el.setAttribute(key, val);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
if ( existy(parent) && isElement(parent) ) {
|
|
20
|
-
append(parent, el);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return el;
|
|
24
|
-
}
|
package/src/utils/each.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
// import isArray from './isArray';
|
|
3
|
-
// import isObject from './isObject';
|
|
4
|
-
import has from './has';
|
|
5
|
-
|
|
6
|
-
type ObjMap<T> = {
|
|
7
|
-
[key: $Subtype<string>]: T
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type Iterable<T> = Array<T> | ObjMap<T>
|
|
11
|
-
type Callback<T> = (T, number | string, Iterable<T>) => void
|
|
12
|
-
|
|
13
|
-
export default function each<T>(iterable: Iterable<T>, callback: Callback<T>) {
|
|
14
|
-
if (iterable instanceof Array) {
|
|
15
|
-
eachOfArray(iterable, callback);
|
|
16
|
-
} else {
|
|
17
|
-
eachOfObject(iterable, callback);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function eachOfObject<T>(obj: ObjMap<T>, callback: Callback<T>) {
|
|
22
|
-
// eslint-disable-next-line no-unused-vars
|
|
23
|
-
for (const key in obj) {
|
|
24
|
-
if (has(obj, key)) {
|
|
25
|
-
callback(obj[key], key, obj);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function eachOfArray<T>(arr: T[], callback: Callback<T>) {
|
|
31
|
-
for (let i = 0; i < arr.length; i++) {
|
|
32
|
-
callback(arr[i], i, arr);
|
|
33
|
-
}
|
|
34
|
-
}
|
package/src/utils/escapeHTML.js
DELETED
package/src/utils/existy.js
DELETED
package/src/utils/extend.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import each from './each';
|
|
2
|
-
import notExisty from './notExisty';
|
|
3
|
-
|
|
4
|
-
// Merge the contents of two or more objects together into the first object
|
|
5
|
-
export default function extend(target, ...args) {
|
|
6
|
-
each(args, options => {
|
|
7
|
-
if (notExisty(options)) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
each(options, (val, key) => {
|
|
11
|
-
target[key] = val;
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// Return the modified object
|
|
16
|
-
return target;
|
|
17
|
-
}
|
package/src/utils/filter.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import isNotEmpty from './isNotEmpty';
|
|
4
|
-
import each from './each';
|
|
5
|
-
|
|
6
|
-
export default function filter<T>(array: T[], cond?: (T) => boolean = isNotEmpty): T[] {
|
|
7
|
-
const res = [];
|
|
8
|
-
|
|
9
|
-
each(array, o => {
|
|
10
|
-
if (cond(o)) {
|
|
11
|
-
res.push(o);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
return res;
|
|
16
|
-
}
|
package/src/utils/find.js
DELETED
package/src/utils/findIndex.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import isFunction from './isFunction';
|
|
2
|
-
|
|
3
|
-
const NON_FOUND_IDX = -1;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Find index of element by condition
|
|
7
|
-
* @export
|
|
8
|
-
* @param {Array} array array
|
|
9
|
-
* @param {Function|Object} condition some condition
|
|
10
|
-
* @returns {Number} index of object, or `-1` if cond not returned true
|
|
11
|
-
*/
|
|
12
|
-
export default function findIndex(array, condition) {
|
|
13
|
-
const cond = isFunction(condition) ? condition : (c) => c === condition;
|
|
14
|
-
for (let i = 0; i < array.length; i++) {
|
|
15
|
-
if (cond(array[i])) {
|
|
16
|
-
return i;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return NON_FOUND_IDX;
|
|
20
|
-
}
|
package/src/utils/first.js
DELETED
package/src/utils/get.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import existy from './existy';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get valur fromm object by path
|
|
5
|
-
* @export
|
|
6
|
-
* @param {Object} source object
|
|
7
|
-
* @param {String} path path to props (use `.` as delim)
|
|
8
|
-
* @param {any} defaultValue return this attr if result is not exists
|
|
9
|
-
* @returns {any} value
|
|
10
|
-
*/
|
|
11
|
-
export default function get(source, path = '', defaultValue = null) {
|
|
12
|
-
const pathes = path.split('.');
|
|
13
|
-
|
|
14
|
-
while (existy(source) && pathes.length) {
|
|
15
|
-
source = source[pathes.shift()];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return existy(source) ? source : defaultValue;
|
|
19
|
-
}
|
package/src/utils/has.js
DELETED
package/src/utils/hasClass.js
DELETED
package/src/utils/head.js
DELETED
package/src/utils/inRange.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const DEFAULT_MIN = 0;
|
|
2
|
-
const DEFAULT_MAX = Number.MAX_VALUE;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Checks if n is between start and up to, but not including, end. If end is not specified,
|
|
6
|
-
* it's set to start with start then set to 0.
|
|
7
|
-
* If start is greater than end the params are swapped to support negative ranges.
|
|
8
|
-
* @export
|
|
9
|
-
* @param {number} number The number to check.
|
|
10
|
-
* @param {number} [from=0] The start of the range.
|
|
11
|
-
* @param {number} [to] The end of the range.
|
|
12
|
-
* @returns {Boolean} Returns true if number is in the range, else false.
|
|
13
|
-
*/
|
|
14
|
-
export default function inRange(number, from = DEFAULT_MIN, to = DEFAULT_MAX) {
|
|
15
|
-
return number >= from && number < to;
|
|
16
|
-
}
|
package/src/utils/index.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import isElement from './isElement';
|
|
3
|
-
import isArray from './isArray';
|
|
4
|
-
import isObject from './isObject';
|
|
5
|
-
import isString from './isString';
|
|
6
|
-
import isFunction from './isFunction';
|
|
7
|
-
import isBoolean from './isBoolean';
|
|
8
|
-
import isEqual from './isEqual';
|
|
9
|
-
import isEqualBuffer from './isEqualBuffer';
|
|
10
|
-
|
|
11
|
-
// utils
|
|
12
|
-
import noop from './noop';
|
|
13
|
-
import inRange from './inRange';
|
|
14
|
-
import existy from './existy';
|
|
15
|
-
import negate from './negate';
|
|
16
|
-
import notExisty from './notExisty';
|
|
17
|
-
import isEmpty from './isEmpty';
|
|
18
|
-
import isNotEmpty from './isNotEmpty';
|
|
19
|
-
import absolutizeUrl from './absolutizeUrl';
|
|
20
|
-
import escapeHTML from './escapeHTML';
|
|
21
|
-
import uidGenerator from './uidGenerator';
|
|
22
|
-
|
|
23
|
-
// DOM
|
|
24
|
-
import createElement from './createElement';
|
|
25
|
-
import addEvent from './addEvent';
|
|
26
|
-
import removeEvent from './removeEvent';
|
|
27
|
-
import addClass from './addClass';
|
|
28
|
-
import hasClass from './hasClass';
|
|
29
|
-
import removeClass from './removeClass';
|
|
30
|
-
import toggleClass from './toggleClass';
|
|
31
|
-
import append from './appendChild';
|
|
32
|
-
|
|
33
|
-
// collections
|
|
34
|
-
import each from './each';
|
|
35
|
-
import contains from './contains';
|
|
36
|
-
import filter from './filter';
|
|
37
|
-
import find from './find';
|
|
38
|
-
import map from './map';
|
|
39
|
-
|
|
40
|
-
// array
|
|
41
|
-
import head from './head';
|
|
42
|
-
import last from './last';
|
|
43
|
-
import first from './first';
|
|
44
|
-
import findIndex from './findIndex';
|
|
45
|
-
import remove from './remove';
|
|
46
|
-
import toArray from './toArray';
|
|
47
|
-
import reduce from './reduce';
|
|
48
|
-
|
|
49
|
-
// Object
|
|
50
|
-
import has from './has';
|
|
51
|
-
import extend from './extend';
|
|
52
|
-
import get from './get';
|
|
53
|
-
import addProperty from './addProperty';
|
|
54
|
-
|
|
55
|
-
// String
|
|
56
|
-
import upperFirst from './upperFirst';
|
|
57
|
-
|
|
58
|
-
export {
|
|
59
|
-
isArray, isElement, isObject, isString, isFunction, isBoolean, isEqual, isEqualBuffer,
|
|
60
|
-
|
|
61
|
-
noop, existy, negate, notExisty, isEmpty, isNotEmpty, inRange, absolutizeUrl, escapeHTML,
|
|
62
|
-
uidGenerator,
|
|
63
|
-
|
|
64
|
-
createElement, append, addEvent, removeEvent, hasClass, addClass, removeClass, toggleClass,
|
|
65
|
-
|
|
66
|
-
each, contains, filter, find, map, reduce,
|
|
67
|
-
|
|
68
|
-
head, findIndex, first, last, remove, toArray,
|
|
69
|
-
|
|
70
|
-
has, extend, get, addProperty,
|
|
71
|
-
|
|
72
|
-
upperFirst
|
|
73
|
-
};
|
package/src/utils/isArray.js
DELETED
package/src/utils/isBoolean.js
DELETED
package/src/utils/isElement.js
DELETED
package/src/utils/isEmpty.js
DELETED
package/src/utils/isEqual.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import isArray from './isArray';
|
|
2
|
-
import contains from './contains';
|
|
3
|
-
import isObject from './isObject';
|
|
4
|
-
import reduce from './reduce';
|
|
5
|
-
|
|
6
|
-
export default function isEqual(value, other) {
|
|
7
|
-
if (value === other) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if ( isArray(value) && isArray(other) ) {
|
|
12
|
-
if ( value.length !== other.length ) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return reduce(value, (memo, o) => memo && contains(other, o), true);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if ( isObject(value) && isObject(other) ) {
|
|
20
|
-
const valueKeys = Object.keys(value);
|
|
21
|
-
const otherKeys = Object.keys(other);
|
|
22
|
-
|
|
23
|
-
if ( !isEqual(valueKeys, otherKeys) ) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return reduce(value, (memo, v, k) => {
|
|
28
|
-
return memo && isEqual(v, other[k]);
|
|
29
|
-
}, true);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return false;
|
|
33
|
-
}
|
package/src/utils/isFunction.js
DELETED
package/src/utils/isNotEmpty.js
DELETED
package/src/utils/isObject.js
DELETED
package/src/utils/isString.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if `value` is classified as a `String` primitive or object.
|
|
3
|
-
*
|
|
4
|
-
* @param {*} value The value to check.
|
|
5
|
-
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
|
|
6
|
-
*/
|
|
7
|
-
export default function isString(value) {
|
|
8
|
-
return typeof value === 'string';
|
|
9
|
-
}
|
package/src/utils/last.js
DELETED
package/src/utils/map.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import each from './each';
|
|
3
|
-
|
|
4
|
-
type Callback<T, K> = (T, number, Array<T>) => K
|
|
5
|
-
|
|
6
|
-
export default function map<T, K>(array: Array<T>, callback: Callback<T, K>): Array<K> {
|
|
7
|
-
const memo = [];
|
|
8
|
-
// $FlowFixMe
|
|
9
|
-
each(array, (val, key, arr) => memo.push(callback(val, key, arr)) );
|
|
10
|
-
return memo;
|
|
11
|
-
}
|
package/src/utils/negate.js
DELETED
package/src/utils/noop.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function noop() { /* */ }
|
package/src/utils/notExisty.js
DELETED
package/src/utils/reduce.js
DELETED
package/src/utils/remove.js
DELETED
package/src/utils/removeClass.js
DELETED
package/src/utils/removeEvent.js
DELETED
package/src/utils/toArray.js
DELETED
package/src/utils/toggleClass.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import hasClass from './hasClass';
|
|
2
|
-
import addClass from './addClass';
|
|
3
|
-
import removeClass from './removeClass';
|
|
4
|
-
import notExisty from './notExisty';
|
|
5
|
-
|
|
6
|
-
export default function toggleClass(el, className, state) {
|
|
7
|
-
if ( notExisty(state) ) {
|
|
8
|
-
state = !hasClass(el, className);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (state) {
|
|
12
|
-
addClass(el, className);
|
|
13
|
-
} else {
|
|
14
|
-
removeClass(el, className);
|
|
15
|
-
}
|
|
16
|
-
}
|