mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
add inputmask
This commit is contained in:
parent
ab84f1e730
commit
e07838c6c7
203 changed files with 29712 additions and 5216 deletions
39
node_modules/.package-lock.json
generated
vendored
39
node_modules/.package-lock.json
generated
vendored
|
@ -141,9 +141,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@videojs/http-streaming": {
|
||||
"version": "2.14.2",
|
||||
"resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-2.14.2.tgz",
|
||||
"integrity": "sha512-K1raSfO/pq5r8iUas3OSYni0kXOj91n8ealIpV02khghzGv9LQ6O3YUqYd/eAhJ1HIrmZWOnrYpK/P+mhUExXQ==",
|
||||
"version": "2.14.3",
|
||||
"resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-2.14.3.tgz",
|
||||
"integrity": "sha512-2tFwxCaNbcEZzQugWf8EERwNMyNtspfHnvxRGRABQs09W/5SqmkWFuGWfUAm4wQKlXGfdPyAJ1338ASl459xAA==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@videojs/vhs-utils": "3.0.5",
|
||||
|
@ -452,9 +452,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/hls.js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.2.1.tgz",
|
||||
"integrity": "sha512-+m/5+ikSpmQQvb6FmVWZUZfzvTJMn/QVfiCGP1Oq9WW4RKrAvxlExkhhbcVGgGqLNPFk1kdFkVQur//wKu3JVw=="
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.2.3.tgz",
|
||||
"integrity": "sha512-CC/vHi82ldiiydIhliNI3whlcepRXxI2jdpd/KKb6lyEv+74e7lXs4cGk5PHfTLxZMKOj6+m5LX9VAbvV/r7AQ=="
|
||||
},
|
||||
"node_modules/ieee754": {
|
||||
"version": "1.2.1",
|
||||
|
@ -499,6 +499,11 @@
|
|||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
},
|
||||
"node_modules/inputmask": {
|
||||
"version": "5.0.7",
|
||||
"resolved": "https://registry.npmjs.org/inputmask/-/inputmask-5.0.7.tgz",
|
||||
"integrity": "sha512-rUxbRDS25KEib+c/Ow+K01oprU/+EK9t9SOPC8ov94/ftULGDqj1zOgRU/Hko6uzoKRMdwCfuhAafJ/Wk2wffQ=="
|
||||
},
|
||||
"node_modules/is-function": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.2.tgz",
|
||||
|
@ -999,9 +1004,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/tinymce": {
|
||||
"version": "6.1.2",
|
||||
"resolved": "https://registry.npmjs.org/tinymce/-/tinymce-6.1.2.tgz",
|
||||
"integrity": "sha512-tl4KbEKdPzyPTatJkblN2AqzRj9jaRGyATnwaSnsLFGKb4AI6B+4e0Gc8dUDXuqAjgSnHokhzamrQJLbSn4CmQ=="
|
||||
"version": "6.2.0",
|
||||
"resolved": "https://registry.npmjs.org/tinymce/-/tinymce-6.2.0.tgz",
|
||||
"integrity": "sha512-zLjbFrg0hbtJ6PxmZUjQY6zyIOM/mLrWGTvhBec7XwYwoW1E0xXMQzy2tgMTh3OvJpsclgqf2ZMjmwcv4Cludw=="
|
||||
},
|
||||
"node_modules/tinymce-langs": {
|
||||
"version": "1.0.0",
|
||||
|
@ -1053,12 +1058,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/video.js": {
|
||||
"version": "7.20.2",
|
||||
"resolved": "https://registry.npmjs.org/video.js/-/video.js-7.20.2.tgz",
|
||||
"integrity": "sha512-hdvAHKAyaL6bCDkeu0pPtFYKi1EDaOUovm7FN1xqBDolUxgH8FKy1WIgTS+Ouuaw7R54SCTcSeXjZEizhy9ouQ==",
|
||||
"version": "7.20.3",
|
||||
"resolved": "https://registry.npmjs.org/video.js/-/video.js-7.20.3.tgz",
|
||||
"integrity": "sha512-JMspxaK74LdfWcv69XWhX4rILywz/eInOVPdKefpQiZJSMD5O8xXYueqACP2Q5yqKstycgmmEKlJzZ+kVmDciw==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@videojs/http-streaming": "2.14.2",
|
||||
"@videojs/http-streaming": "2.14.3",
|
||||
"@videojs/vhs-utils": "^3.0.4",
|
||||
"@videojs/xhr": "2.6.0",
|
||||
"aes-decrypter": "3.1.3",
|
||||
|
@ -1069,7 +1074,7 @@
|
|||
"mux.js": "6.0.1",
|
||||
"safe-json-parse": "4.0.0",
|
||||
"videojs-font": "3.2.0",
|
||||
"videojs-vtt.js": "^0.15.3"
|
||||
"videojs-vtt.js": "^0.15.4"
|
||||
}
|
||||
},
|
||||
"node_modules/videojs-contrib-ads": {
|
||||
|
@ -1119,9 +1124,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/videojs-vtt.js": {
|
||||
"version": "0.15.3",
|
||||
"resolved": "https://registry.npmjs.org/videojs-vtt.js/-/videojs-vtt.js-0.15.3.tgz",
|
||||
"integrity": "sha512-5FvVsICuMRx6Hd7H/Y9s9GDeEtYcXQWzGMS+sl4UX3t/zoHp3y+isSfIPRochnTH7h+Bh1ILyC639xy9Z6kPag==",
|
||||
"version": "0.15.4",
|
||||
"resolved": "https://registry.npmjs.org/videojs-vtt.js/-/videojs-vtt.js-0.15.4.tgz",
|
||||
"integrity": "sha512-r6IhM325fcLb1D6pgsMkTQT1PpFdUdYZa1iqk7wJEu+QlibBwATPfPc9Bg8Jiym0GE5yP1AG2rMLu+QMVWkYtA==",
|
||||
"dependencies": {
|
||||
"global": "^4.3.1"
|
||||
}
|
||||
|
|
17
node_modules/@videojs/http-streaming/CHANGELOG.md
generated
vendored
17
node_modules/@videojs/http-streaming/CHANGELOG.md
generated
vendored
|
@ -1,3 +1,20 @@
|
|||
<a name="2.14.3"></a>
|
||||
## [2.14.3](https://github.com/videojs/http-streaming/compare/v2.14.2...v2.14.3) (2022-08-31)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* cache aes keys for text tracks ([#973](https://github.com/videojs/http-streaming/issues/973)) ([#1228](https://github.com/videojs/http-streaming/issues/1228)) ([721e1bf](https://github.com/videojs/http-streaming/commit/721e1bf))
|
||||
* output-restricted event handling for unplayable streams ([#1305](https://github.com/videojs/http-streaming/issues/1305)) ([23bbf84](https://github.com/videojs/http-streaming/commit/23bbf84))
|
||||
|
||||
### Chores
|
||||
|
||||
* **docs:** Remove outdated information in collaborators' guide ([#1271](https://github.com/videojs/http-streaming/issues/1271)) ([5223427](https://github.com/videojs/http-streaming/commit/5223427))
|
||||
|
||||
### Tests
|
||||
|
||||
* change source for live DASH playback test to fix test failures ([#1303](https://github.com/videojs/http-streaming/issues/1303)) ([e39e27d](https://github.com/videojs/http-streaming/commit/e39e27d))
|
||||
* fix IE11 encrypted VTT tests by using an actual encrypted VTT segment ([#1291](https://github.com/videojs/http-streaming/issues/1291)) ([97e02fb](https://github.com/videojs/http-streaming/commit/97e02fb))
|
||||
|
||||
<a name="2.14.2"></a>
|
||||
## [2.14.2](https://github.com/videojs/http-streaming/compare/v2.14.1...v2.14.2) (2022-04-13)
|
||||
|
||||
|
|
53
node_modules/@videojs/http-streaming/dist/videojs-http-streaming-sync-workers.js
generated
vendored
53
node_modules/@videojs/http-streaming/dist/videojs-http-streaming-sync-workers.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
/*! @name @videojs/http-streaming @version 2.14.2 @license Apache-2.0 */
|
||||
/*! @name @videojs/http-streaming @version 2.14.3 @license Apache-2.0 */
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('video.js'), require('@xmldom/xmldom')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', 'video.js', '@xmldom/xmldom'], factory) :
|
||||
|
@ -9928,7 +9928,7 @@
|
|||
return fn;
|
||||
};
|
||||
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/bclifford/Code/vhs-release-test/src/transmuxer-worker.js */
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/abarstow/videojs/http-streaming/src/transmuxer-worker.js */
|
||||
var workerCode$1 = transform(function (self) {
|
||||
/**
|
||||
* mux.js
|
||||
|
@ -18731,7 +18731,7 @@
|
|||
};
|
||||
});
|
||||
var TransmuxWorker = factory(workerCode$1);
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/bclifford/Code/vhs-release-test/src/transmuxer-worker.js */
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/abarstow/videojs/http-streaming/src/transmuxer-worker.js */
|
||||
|
||||
var handleData_ = function handleData_(event, transmuxedData, callback) {
|
||||
var _event$data$segment = event.data.segment,
|
||||
|
@ -25606,7 +25606,12 @@
|
|||
var segmentInfo = this.pendingSegment_; // although the VTT segment loader bandwidth isn't really used, it's good to
|
||||
// maintain functionality between segment loaders
|
||||
|
||||
this.saveBandwidthRelatedStats_(segmentInfo.duration, simpleSegment.stats);
|
||||
this.saveBandwidthRelatedStats_(segmentInfo.duration, simpleSegment.stats); // if this request included a segment key, save that data in the cache
|
||||
|
||||
if (simpleSegment.key) {
|
||||
this.segmentKey(simpleSegment.key, true);
|
||||
}
|
||||
|
||||
this.state = 'APPENDING'; // used for tests
|
||||
|
||||
this.trigger('appending');
|
||||
|
@ -26545,7 +26550,7 @@
|
|||
return TimelineChangeController;
|
||||
}(videojs__default["default"].EventTarget);
|
||||
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/bclifford/Code/vhs-release-test/src/decrypter-worker.js */
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/abarstow/videojs/http-streaming/src/decrypter-worker.js */
|
||||
var workerCode = transform(function (self) {
|
||||
|
||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||||
|
@ -27262,7 +27267,7 @@
|
|||
};
|
||||
});
|
||||
var Decrypter = factory(workerCode);
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/bclifford/Code/vhs-release-test/src/decrypter-worker.js */
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/abarstow/videojs/http-streaming/src/decrypter-worker.js */
|
||||
|
||||
/**
|
||||
* Convert the properties of an HLS track into an audioTrackKind.
|
||||
|
@ -31091,7 +31096,7 @@
|
|||
initPlugin(this, options);
|
||||
};
|
||||
|
||||
var version$4 = "2.14.2";
|
||||
var version$4 = "2.14.3";
|
||||
|
||||
var version$3 = "6.0.1";
|
||||
|
||||
|
@ -32114,12 +32119,34 @@
|
|||
audioMedia: audioPlaylistLoader && audioPlaylistLoader.media()
|
||||
});
|
||||
this.player_.tech_.on('keystatuschange', function (e) {
|
||||
if (e.status === 'output-restricted') {
|
||||
_this5.masterPlaylistController_.blacklistCurrentPlaylist({
|
||||
playlist: _this5.masterPlaylistController_.media(),
|
||||
message: "DRM keystatus changed to " + e.status + ". Playlist will fail to play. Check for HDCP content.",
|
||||
blacklistDuration: Infinity
|
||||
});
|
||||
if (e.status !== 'output-restricted') {
|
||||
return;
|
||||
}
|
||||
|
||||
var masterPlaylist = _this5.masterPlaylistController_.master();
|
||||
|
||||
if (!masterPlaylist || !masterPlaylist.playlists) {
|
||||
return;
|
||||
}
|
||||
|
||||
var excludedHDPlaylists = []; // Assume all HD streams are unplayable and exclude them from ABR selection
|
||||
|
||||
masterPlaylist.playlists.forEach(function (playlist) {
|
||||
if (playlist && playlist.attributes && playlist.attributes.RESOLUTION && playlist.attributes.RESOLUTION.height >= 720) {
|
||||
if (!playlist.excludeUntil || playlist.excludeUntil < Infinity) {
|
||||
playlist.excludeUntil = Infinity;
|
||||
excludedHDPlaylists.push(playlist);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (excludedHDPlaylists.length) {
|
||||
var _videojs$log;
|
||||
|
||||
(_videojs$log = videojs__default["default"].log).warn.apply(_videojs$log, ['DRM keystatus changed to "output-restricted." Removing the following HD playlists ' + 'that will most likely fail to play and clearing the buffer. ' + 'This may be due to HDCP restrictions on the stream and the capabilities of the current device.'].concat(excludedHDPlaylists)); // Clear the buffer before switching playlists, since it may already contain unplayable segments
|
||||
|
||||
|
||||
_this5.masterPlaylistController_.fastQualityChange_();
|
||||
}
|
||||
});
|
||||
this.handleWaitingForKey_ = this.handleWaitingForKey_.bind(this);
|
||||
|
|
53
node_modules/@videojs/http-streaming/dist/videojs-http-streaming.cjs.js
generated
vendored
53
node_modules/@videojs/http-streaming/dist/videojs-http-streaming.cjs.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
/*! @name @videojs/http-streaming @version 2.14.2 @license Apache-2.0 */
|
||||
/*! @name @videojs/http-streaming @version 2.14.3 @license Apache-2.0 */
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
@ -4084,7 +4084,7 @@ var getWorkerString = function getWorkerString(fn) {
|
|||
return fn.toString().replace(/^function.+?{/, '').slice(0, -1);
|
||||
};
|
||||
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/bclifford/Code/vhs-release-test/src/transmuxer-worker.js */
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/abarstow/videojs/http-streaming/src/transmuxer-worker.js */
|
||||
var workerCode$1 = transform(getWorkerString(function () {
|
||||
/**
|
||||
* mux.js
|
||||
|
@ -12887,7 +12887,7 @@ var workerCode$1 = transform(getWorkerString(function () {
|
|||
};
|
||||
}));
|
||||
var TransmuxWorker = factory(workerCode$1);
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/bclifford/Code/vhs-release-test/src/transmuxer-worker.js */
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/abarstow/videojs/http-streaming/src/transmuxer-worker.js */
|
||||
|
||||
var handleData_ = function handleData_(event, transmuxedData, callback) {
|
||||
var _event$data$segment = event.data.segment,
|
||||
|
@ -19702,7 +19702,12 @@ var VTTSegmentLoader = /*#__PURE__*/function (_SegmentLoader) {
|
|||
var segmentInfo = this.pendingSegment_; // although the VTT segment loader bandwidth isn't really used, it's good to
|
||||
// maintain functionality between segment loaders
|
||||
|
||||
this.saveBandwidthRelatedStats_(segmentInfo.duration, simpleSegment.stats);
|
||||
this.saveBandwidthRelatedStats_(segmentInfo.duration, simpleSegment.stats); // if this request included a segment key, save that data in the cache
|
||||
|
||||
if (simpleSegment.key) {
|
||||
this.segmentKey(simpleSegment.key, true);
|
||||
}
|
||||
|
||||
this.state = 'APPENDING'; // used for tests
|
||||
|
||||
this.trigger('appending');
|
||||
|
@ -20641,7 +20646,7 @@ var TimelineChangeController = /*#__PURE__*/function (_videojs$EventTarget) {
|
|||
return TimelineChangeController;
|
||||
}(videojs__default["default"].EventTarget);
|
||||
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/bclifford/Code/vhs-release-test/src/decrypter-worker.js */
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/abarstow/videojs/http-streaming/src/decrypter-worker.js */
|
||||
var workerCode = transform(getWorkerString(function () {
|
||||
|
||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||||
|
@ -21358,7 +21363,7 @@ var workerCode = transform(getWorkerString(function () {
|
|||
};
|
||||
}));
|
||||
var Decrypter = factory(workerCode);
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/bclifford/Code/vhs-release-test/src/decrypter-worker.js */
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/abarstow/videojs/http-streaming/src/decrypter-worker.js */
|
||||
|
||||
/**
|
||||
* Convert the properties of an HLS track into an audioTrackKind.
|
||||
|
@ -25187,7 +25192,7 @@ var reloadSourceOnError = function reloadSourceOnError(options) {
|
|||
initPlugin(this, options);
|
||||
};
|
||||
|
||||
var version$4 = "2.14.2";
|
||||
var version$4 = "2.14.3";
|
||||
|
||||
var version$3 = "6.0.1";
|
||||
|
||||
|
@ -26210,12 +26215,34 @@ var VhsHandler = /*#__PURE__*/function (_Component) {
|
|||
audioMedia: audioPlaylistLoader && audioPlaylistLoader.media()
|
||||
});
|
||||
this.player_.tech_.on('keystatuschange', function (e) {
|
||||
if (e.status === 'output-restricted') {
|
||||
_this5.masterPlaylistController_.blacklistCurrentPlaylist({
|
||||
playlist: _this5.masterPlaylistController_.media(),
|
||||
message: "DRM keystatus changed to " + e.status + ". Playlist will fail to play. Check for HDCP content.",
|
||||
blacklistDuration: Infinity
|
||||
});
|
||||
if (e.status !== 'output-restricted') {
|
||||
return;
|
||||
}
|
||||
|
||||
var masterPlaylist = _this5.masterPlaylistController_.master();
|
||||
|
||||
if (!masterPlaylist || !masterPlaylist.playlists) {
|
||||
return;
|
||||
}
|
||||
|
||||
var excludedHDPlaylists = []; // Assume all HD streams are unplayable and exclude them from ABR selection
|
||||
|
||||
masterPlaylist.playlists.forEach(function (playlist) {
|
||||
if (playlist && playlist.attributes && playlist.attributes.RESOLUTION && playlist.attributes.RESOLUTION.height >= 720) {
|
||||
if (!playlist.excludeUntil || playlist.excludeUntil < Infinity) {
|
||||
playlist.excludeUntil = Infinity;
|
||||
excludedHDPlaylists.push(playlist);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (excludedHDPlaylists.length) {
|
||||
var _videojs$log;
|
||||
|
||||
(_videojs$log = videojs__default["default"].log).warn.apply(_videojs$log, ['DRM keystatus changed to "output-restricted." Removing the following HD playlists ' + 'that will most likely fail to play and clearing the buffer. ' + 'This may be due to HDCP restrictions on the stream and the capabilities of the current device.'].concat(excludedHDPlaylists)); // Clear the buffer before switching playlists, since it may already contain unplayable segments
|
||||
|
||||
|
||||
_this5.masterPlaylistController_.fastQualityChange_();
|
||||
}
|
||||
});
|
||||
this.handleWaitingForKey_ = this.handleWaitingForKey_.bind(this);
|
||||
|
|
53
node_modules/@videojs/http-streaming/dist/videojs-http-streaming.es.js
generated
vendored
53
node_modules/@videojs/http-streaming/dist/videojs-http-streaming.es.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
/*! @name @videojs/http-streaming @version 2.14.2 @license Apache-2.0 */
|
||||
/*! @name @videojs/http-streaming @version 2.14.3 @license Apache-2.0 */
|
||||
import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
|
||||
import _inheritsLoose from '@babel/runtime/helpers/inheritsLoose';
|
||||
import document from 'global/document';
|
||||
|
@ -4070,7 +4070,7 @@ var getWorkerString = function getWorkerString(fn) {
|
|||
return fn.toString().replace(/^function.+?{/, '').slice(0, -1);
|
||||
};
|
||||
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/bclifford/Code/vhs-release-test/src/transmuxer-worker.js */
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/abarstow/videojs/http-streaming/src/transmuxer-worker.js */
|
||||
var workerCode$1 = transform(getWorkerString(function () {
|
||||
/**
|
||||
* mux.js
|
||||
|
@ -12873,7 +12873,7 @@ var workerCode$1 = transform(getWorkerString(function () {
|
|||
};
|
||||
}));
|
||||
var TransmuxWorker = factory(workerCode$1);
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/bclifford/Code/vhs-release-test/src/transmuxer-worker.js */
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/abarstow/videojs/http-streaming/src/transmuxer-worker.js */
|
||||
|
||||
var handleData_ = function handleData_(event, transmuxedData, callback) {
|
||||
var _event$data$segment = event.data.segment,
|
||||
|
@ -19688,7 +19688,12 @@ var VTTSegmentLoader = /*#__PURE__*/function (_SegmentLoader) {
|
|||
var segmentInfo = this.pendingSegment_; // although the VTT segment loader bandwidth isn't really used, it's good to
|
||||
// maintain functionality between segment loaders
|
||||
|
||||
this.saveBandwidthRelatedStats_(segmentInfo.duration, simpleSegment.stats);
|
||||
this.saveBandwidthRelatedStats_(segmentInfo.duration, simpleSegment.stats); // if this request included a segment key, save that data in the cache
|
||||
|
||||
if (simpleSegment.key) {
|
||||
this.segmentKey(simpleSegment.key, true);
|
||||
}
|
||||
|
||||
this.state = 'APPENDING'; // used for tests
|
||||
|
||||
this.trigger('appending');
|
||||
|
@ -20627,7 +20632,7 @@ var TimelineChangeController = /*#__PURE__*/function (_videojs$EventTarget) {
|
|||
return TimelineChangeController;
|
||||
}(videojs.EventTarget);
|
||||
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/bclifford/Code/vhs-release-test/src/decrypter-worker.js */
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/abarstow/videojs/http-streaming/src/decrypter-worker.js */
|
||||
var workerCode = transform(getWorkerString(function () {
|
||||
|
||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||||
|
@ -21344,7 +21349,7 @@ var workerCode = transform(getWorkerString(function () {
|
|||
};
|
||||
}));
|
||||
var Decrypter = factory(workerCode);
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/bclifford/Code/vhs-release-test/src/decrypter-worker.js */
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/abarstow/videojs/http-streaming/src/decrypter-worker.js */
|
||||
|
||||
/**
|
||||
* Convert the properties of an HLS track into an audioTrackKind.
|
||||
|
@ -25173,7 +25178,7 @@ var reloadSourceOnError = function reloadSourceOnError(options) {
|
|||
initPlugin(this, options);
|
||||
};
|
||||
|
||||
var version$4 = "2.14.2";
|
||||
var version$4 = "2.14.3";
|
||||
|
||||
var version$3 = "6.0.1";
|
||||
|
||||
|
@ -26196,12 +26201,34 @@ var VhsHandler = /*#__PURE__*/function (_Component) {
|
|||
audioMedia: audioPlaylistLoader && audioPlaylistLoader.media()
|
||||
});
|
||||
this.player_.tech_.on('keystatuschange', function (e) {
|
||||
if (e.status === 'output-restricted') {
|
||||
_this5.masterPlaylistController_.blacklistCurrentPlaylist({
|
||||
playlist: _this5.masterPlaylistController_.media(),
|
||||
message: "DRM keystatus changed to " + e.status + ". Playlist will fail to play. Check for HDCP content.",
|
||||
blacklistDuration: Infinity
|
||||
});
|
||||
if (e.status !== 'output-restricted') {
|
||||
return;
|
||||
}
|
||||
|
||||
var masterPlaylist = _this5.masterPlaylistController_.master();
|
||||
|
||||
if (!masterPlaylist || !masterPlaylist.playlists) {
|
||||
return;
|
||||
}
|
||||
|
||||
var excludedHDPlaylists = []; // Assume all HD streams are unplayable and exclude them from ABR selection
|
||||
|
||||
masterPlaylist.playlists.forEach(function (playlist) {
|
||||
if (playlist && playlist.attributes && playlist.attributes.RESOLUTION && playlist.attributes.RESOLUTION.height >= 720) {
|
||||
if (!playlist.excludeUntil || playlist.excludeUntil < Infinity) {
|
||||
playlist.excludeUntil = Infinity;
|
||||
excludedHDPlaylists.push(playlist);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (excludedHDPlaylists.length) {
|
||||
var _videojs$log;
|
||||
|
||||
(_videojs$log = videojs.log).warn.apply(_videojs$log, ['DRM keystatus changed to "output-restricted." Removing the following HD playlists ' + 'that will most likely fail to play and clearing the buffer. ' + 'This may be due to HDCP restrictions on the stream and the capabilities of the current device.'].concat(excludedHDPlaylists)); // Clear the buffer before switching playlists, since it may already contain unplayable segments
|
||||
|
||||
|
||||
_this5.masterPlaylistController_.fastQualityChange_();
|
||||
}
|
||||
});
|
||||
this.handleWaitingForKey_ = this.handleWaitingForKey_.bind(this);
|
||||
|
|
53
node_modules/@videojs/http-streaming/dist/videojs-http-streaming.js
generated
vendored
53
node_modules/@videojs/http-streaming/dist/videojs-http-streaming.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
/*! @name @videojs/http-streaming @version 2.14.2 @license Apache-2.0 */
|
||||
/*! @name @videojs/http-streaming @version 2.14.3 @license Apache-2.0 */
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('video.js'), require('@xmldom/xmldom')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', 'video.js', '@xmldom/xmldom'], factory) :
|
||||
|
@ -9875,7 +9875,7 @@
|
|||
return fn.toString().replace(/^function.+?{/, '').slice(0, -1);
|
||||
};
|
||||
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/bclifford/Code/vhs-release-test/src/transmuxer-worker.js */
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/abarstow/videojs/http-streaming/src/transmuxer-worker.js */
|
||||
var workerCode$1 = transform(getWorkerString(function () {
|
||||
/**
|
||||
* mux.js
|
||||
|
@ -18678,7 +18678,7 @@
|
|||
};
|
||||
}));
|
||||
var TransmuxWorker = factory(workerCode$1);
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/bclifford/Code/vhs-release-test/src/transmuxer-worker.js */
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/abarstow/videojs/http-streaming/src/transmuxer-worker.js */
|
||||
|
||||
var handleData_ = function handleData_(event, transmuxedData, callback) {
|
||||
var _event$data$segment = event.data.segment,
|
||||
|
@ -25553,7 +25553,12 @@
|
|||
var segmentInfo = this.pendingSegment_; // although the VTT segment loader bandwidth isn't really used, it's good to
|
||||
// maintain functionality between segment loaders
|
||||
|
||||
this.saveBandwidthRelatedStats_(segmentInfo.duration, simpleSegment.stats);
|
||||
this.saveBandwidthRelatedStats_(segmentInfo.duration, simpleSegment.stats); // if this request included a segment key, save that data in the cache
|
||||
|
||||
if (simpleSegment.key) {
|
||||
this.segmentKey(simpleSegment.key, true);
|
||||
}
|
||||
|
||||
this.state = 'APPENDING'; // used for tests
|
||||
|
||||
this.trigger('appending');
|
||||
|
@ -26492,7 +26497,7 @@
|
|||
return TimelineChangeController;
|
||||
}(videojs__default["default"].EventTarget);
|
||||
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/bclifford/Code/vhs-release-test/src/decrypter-worker.js */
|
||||
/* rollup-plugin-worker-factory start for worker!/Users/abarstow/videojs/http-streaming/src/decrypter-worker.js */
|
||||
var workerCode = transform(getWorkerString(function () {
|
||||
|
||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||||
|
@ -27209,7 +27214,7 @@
|
|||
};
|
||||
}));
|
||||
var Decrypter = factory(workerCode);
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/bclifford/Code/vhs-release-test/src/decrypter-worker.js */
|
||||
/* rollup-plugin-worker-factory end for worker!/Users/abarstow/videojs/http-streaming/src/decrypter-worker.js */
|
||||
|
||||
/**
|
||||
* Convert the properties of an HLS track into an audioTrackKind.
|
||||
|
@ -31038,7 +31043,7 @@
|
|||
initPlugin(this, options);
|
||||
};
|
||||
|
||||
var version$4 = "2.14.2";
|
||||
var version$4 = "2.14.3";
|
||||
|
||||
var version$3 = "6.0.1";
|
||||
|
||||
|
@ -32061,12 +32066,34 @@
|
|||
audioMedia: audioPlaylistLoader && audioPlaylistLoader.media()
|
||||
});
|
||||
this.player_.tech_.on('keystatuschange', function (e) {
|
||||
if (e.status === 'output-restricted') {
|
||||
_this5.masterPlaylistController_.blacklistCurrentPlaylist({
|
||||
playlist: _this5.masterPlaylistController_.media(),
|
||||
message: "DRM keystatus changed to " + e.status + ". Playlist will fail to play. Check for HDCP content.",
|
||||
blacklistDuration: Infinity
|
||||
});
|
||||
if (e.status !== 'output-restricted') {
|
||||
return;
|
||||
}
|
||||
|
||||
var masterPlaylist = _this5.masterPlaylistController_.master();
|
||||
|
||||
if (!masterPlaylist || !masterPlaylist.playlists) {
|
||||
return;
|
||||
}
|
||||
|
||||
var excludedHDPlaylists = []; // Assume all HD streams are unplayable and exclude them from ABR selection
|
||||
|
||||
masterPlaylist.playlists.forEach(function (playlist) {
|
||||
if (playlist && playlist.attributes && playlist.attributes.RESOLUTION && playlist.attributes.RESOLUTION.height >= 720) {
|
||||
if (!playlist.excludeUntil || playlist.excludeUntil < Infinity) {
|
||||
playlist.excludeUntil = Infinity;
|
||||
excludedHDPlaylists.push(playlist);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (excludedHDPlaylists.length) {
|
||||
var _videojs$log;
|
||||
|
||||
(_videojs$log = videojs__default["default"].log).warn.apply(_videojs$log, ['DRM keystatus changed to "output-restricted." Removing the following HD playlists ' + 'that will most likely fail to play and clearing the buffer. ' + 'This may be due to HDCP restrictions on the stream and the capabilities of the current device.'].concat(excludedHDPlaylists)); // Clear the buffer before switching playlists, since it may already contain unplayable segments
|
||||
|
||||
|
||||
_this5.masterPlaylistController_.fastQualityChange_();
|
||||
}
|
||||
});
|
||||
this.handleWaitingForKey_ = this.handleWaitingForKey_.bind(this);
|
||||
|
|
6
node_modules/@videojs/http-streaming/dist/videojs-http-streaming.min.js
generated
vendored
6
node_modules/@videojs/http-streaming/dist/videojs-http-streaming.min.js
generated
vendored
File diff suppressed because one or more lines are too long
46
node_modules/@videojs/http-streaming/docs/creating-content.md
generated
vendored
46
node_modules/@videojs/http-streaming/docs/creating-content.md
generated
vendored
|
@ -203,6 +203,52 @@ $ mv init-stream0.webm webmVideoInit.webm
|
|||
$ mv chunk-stream0-00001.webm webmVideo.webm
|
||||
```
|
||||
|
||||
### subtitlesEncrypted.vtt
|
||||
|
||||
Run subtitles.vtt through subtle crypto. As an example:
|
||||
|
||||
```javascript
|
||||
const fs = require('fs');
|
||||
const { subtle } = require('crypto').webcrypto;
|
||||
|
||||
// first segment has media index 0, so should have the following IV
|
||||
const DEFAULT_IV = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
const getCryptoKey = async (bytes, iv = DEFAULT_IV) => {
|
||||
const algorithm = { name: 'AES-CBC', iv };
|
||||
const extractable = true;
|
||||
const usages = ['encrypt', 'decrypt'];
|
||||
|
||||
return subtle.importKey('raw', bytes, algorithm, extractable, usages);
|
||||
};
|
||||
|
||||
const run = async () => {
|
||||
const keyFilePath = process.argv[2];
|
||||
const segmentFilePath = process.argv[3];
|
||||
|
||||
const keyBytes = fs.readFileSync(keyFilePath);
|
||||
const segmentBytes = fs.readFileSync(segmentFilePath);
|
||||
|
||||
const key = await getCryptoKey(keyBytes);
|
||||
const encryptedBytes = await subtle.encrypt({
|
||||
name: 'AES-CBC',
|
||||
iv: DEFAULT_IV,
|
||||
}, key, segmentBytes);
|
||||
|
||||
fs.writeFileSync('./encrypted.vtt', new Buffer(encryptedBytes));
|
||||
|
||||
console.log(`Wrote ${encryptedBytes.length} bytes to encrypted.vtt:`);
|
||||
};
|
||||
|
||||
run();
|
||||
```
|
||||
|
||||
To use the script:
|
||||
|
||||
```
|
||||
$ node index.js encryptionKey.key subtitles.vtt
|
||||
```
|
||||
|
||||
## Other useful commands
|
||||
|
||||
### Joined (audio and video) initialization segment (for HLS)
|
||||
|
|
2
node_modules/@videojs/http-streaming/package.json
generated
vendored
2
node_modules/@videojs/http-streaming/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@videojs/http-streaming",
|
||||
"version": "2.14.2",
|
||||
"version": "2.14.3",
|
||||
"description": "Play back HLS and DASH with Video.js, even where it's not natively supported",
|
||||
"main": "dist/videojs-http-streaming.cjs.js",
|
||||
"module": "dist/videojs-http-streaming.es.js",
|
||||
|
|
2
node_modules/@videojs/http-streaming/scripts/create-test-data.js
generated
vendored
2
node_modules/@videojs/http-streaming/scripts/create-test-data.js
generated
vendored
|
@ -21,7 +21,7 @@ const getManifests = () => (fs.readdirSync(manifestsDir) || [])
|
|||
.map((f) => path.resolve(manifestsDir, f));
|
||||
|
||||
const getSegments = () => (fs.readdirSync(segmentsDir) || [])
|
||||
.filter((f) => ((/\.(ts|mp4|key|webm|aac|ac3)/).test(path.extname(f))))
|
||||
.filter((f) => ((/\.(ts|mp4|key|webm|aac|ac3|vtt)/).test(path.extname(f))))
|
||||
.map((f) => path.resolve(segmentsDir, f));
|
||||
|
||||
const buildManifestString = function() {
|
||||
|
|
654
node_modules/@videojs/http-streaming/src/decrypter-worker.worker.js
generated
vendored
Normal file
654
node_modules/@videojs/http-streaming/src/decrypter-worker.worker.js
generated
vendored
Normal file
|
@ -0,0 +1,654 @@
|
|||
/*! @name @videojs/http-streaming @version 2.5.0 @license Apache-2.0 */
|
||||
var decrypterWorker = (function () {
|
||||
'use strict';
|
||||
|
||||
function _defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
var createClass = _createClass;
|
||||
|
||||
function _inheritsLoose(subClass, superClass) {
|
||||
subClass.prototype = Object.create(superClass.prototype);
|
||||
subClass.prototype.constructor = subClass;
|
||||
subClass.__proto__ = superClass;
|
||||
}
|
||||
|
||||
var inheritsLoose = _inheritsLoose;
|
||||
|
||||
/**
|
||||
* @file stream.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* A lightweight readable stream implemention that handles event dispatching.
|
||||
*
|
||||
* @class Stream
|
||||
*/
|
||||
var Stream = /*#__PURE__*/function () {
|
||||
function Stream() {
|
||||
this.listeners = {};
|
||||
}
|
||||
/**
|
||||
* Add a listener for a specified event type.
|
||||
*
|
||||
* @param {string} type the event name
|
||||
* @param {Function} listener the callback to be invoked when an event of
|
||||
* the specified type occurs
|
||||
*/
|
||||
|
||||
|
||||
var _proto = Stream.prototype;
|
||||
|
||||
_proto.on = function on(type, listener) {
|
||||
if (!this.listeners[type]) {
|
||||
this.listeners[type] = [];
|
||||
}
|
||||
|
||||
this.listeners[type].push(listener);
|
||||
}
|
||||
/**
|
||||
* Remove a listener for a specified event type.
|
||||
*
|
||||
* @param {string} type the event name
|
||||
* @param {Function} listener a function previously registered for this
|
||||
* type of event through `on`
|
||||
* @return {boolean} if we could turn it off or not
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.off = function off(type, listener) {
|
||||
if (!this.listeners[type]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var index = this.listeners[type].indexOf(listener); // TODO: which is better?
|
||||
// In Video.js we slice listener functions
|
||||
// on trigger so that it does not mess up the order
|
||||
// while we loop through.
|
||||
//
|
||||
// Here we slice on off so that the loop in trigger
|
||||
// can continue using it's old reference to loop without
|
||||
// messing up the order.
|
||||
|
||||
this.listeners[type] = this.listeners[type].slice(0);
|
||||
this.listeners[type].splice(index, 1);
|
||||
return index > -1;
|
||||
}
|
||||
/**
|
||||
* Trigger an event of the specified type on this stream. Any additional
|
||||
* arguments to this function are passed as parameters to event listeners.
|
||||
*
|
||||
* @param {string} type the event name
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.trigger = function trigger(type) {
|
||||
var callbacks = this.listeners[type];
|
||||
|
||||
if (!callbacks) {
|
||||
return;
|
||||
} // Slicing the arguments on every invocation of this method
|
||||
// can add a significant amount of overhead. Avoid the
|
||||
// intermediate object creation for the common case of a
|
||||
// single callback argument
|
||||
|
||||
|
||||
if (arguments.length === 2) {
|
||||
var length = callbacks.length;
|
||||
|
||||
for (var i = 0; i < length; ++i) {
|
||||
callbacks[i].call(this, arguments[1]);
|
||||
}
|
||||
} else {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
var _length = callbacks.length;
|
||||
|
||||
for (var _i = 0; _i < _length; ++_i) {
|
||||
callbacks[_i].apply(this, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Destroys the stream and cleans up.
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.dispose = function dispose() {
|
||||
this.listeners = {};
|
||||
}
|
||||
/**
|
||||
* Forwards all `data` events on this stream to the destination stream. The
|
||||
* destination stream should provide a method `push` to receive the data
|
||||
* events as they arrive.
|
||||
*
|
||||
* @param {Stream} destination the stream that will receive all `data` events
|
||||
* @see http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.pipe = function pipe(destination) {
|
||||
this.on('data', function (data) {
|
||||
destination.push(data);
|
||||
});
|
||||
};
|
||||
|
||||
return Stream;
|
||||
}();
|
||||
|
||||
/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */
|
||||
/**
|
||||
* Returns the subarray of a Uint8Array without PKCS#7 padding.
|
||||
*
|
||||
* @param padded {Uint8Array} unencrypted bytes that have been padded
|
||||
* @return {Uint8Array} the unpadded bytes
|
||||
* @see http://tools.ietf.org/html/rfc5652
|
||||
*/
|
||||
|
||||
function unpad(padded) {
|
||||
return padded.subarray(0, padded.byteLength - padded[padded.byteLength - 1]);
|
||||
}
|
||||
|
||||
/*! @name aes-decrypter @version 3.1.2 @license Apache-2.0 */
|
||||
/**
|
||||
* @file aes.js
|
||||
*
|
||||
* This file contains an adaptation of the AES decryption algorithm
|
||||
* from the Standford Javascript Cryptography Library. That work is
|
||||
* covered by the following copyright and permissions notice:
|
||||
*
|
||||
* Copyright 2009-2010 Emily Stark, Mike Hamburg, Dan Boneh.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation
|
||||
* are those of the authors and should not be interpreted as representing
|
||||
* official policies, either expressed or implied, of the authors.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Expand the S-box tables.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
var precompute = function precompute() {
|
||||
var tables = [[[], [], [], [], []], [[], [], [], [], []]];
|
||||
var encTable = tables[0];
|
||||
var decTable = tables[1];
|
||||
var sbox = encTable[4];
|
||||
var sboxInv = decTable[4];
|
||||
var i;
|
||||
var x;
|
||||
var xInv;
|
||||
var d = [];
|
||||
var th = [];
|
||||
var x2;
|
||||
var x4;
|
||||
var x8;
|
||||
var s;
|
||||
var tEnc;
|
||||
var tDec; // Compute double and third tables
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
th[(d[i] = i << 1 ^ (i >> 7) * 283) ^ i] = i;
|
||||
}
|
||||
|
||||
for (x = xInv = 0; !sbox[x]; x ^= x2 || 1, xInv = th[xInv] || 1) {
|
||||
// Compute sbox
|
||||
s = xInv ^ xInv << 1 ^ xInv << 2 ^ xInv << 3 ^ xInv << 4;
|
||||
s = s >> 8 ^ s & 255 ^ 99;
|
||||
sbox[x] = s;
|
||||
sboxInv[s] = x; // Compute MixColumns
|
||||
|
||||
x8 = d[x4 = d[x2 = d[x]]];
|
||||
tDec = x8 * 0x1010101 ^ x4 * 0x10001 ^ x2 * 0x101 ^ x * 0x1010100;
|
||||
tEnc = d[s] * 0x101 ^ s * 0x1010100;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
encTable[i][x] = tEnc = tEnc << 24 ^ tEnc >>> 8;
|
||||
decTable[i][s] = tDec = tDec << 24 ^ tDec >>> 8;
|
||||
}
|
||||
} // Compactify. Considerable speedup on Firefox.
|
||||
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
encTable[i] = encTable[i].slice(0);
|
||||
decTable[i] = decTable[i].slice(0);
|
||||
}
|
||||
|
||||
return tables;
|
||||
};
|
||||
|
||||
var aesTables = null;
|
||||
/**
|
||||
* Schedule out an AES key for both encryption and decryption. This
|
||||
* is a low-level class. Use a cipher mode to do bulk encryption.
|
||||
*
|
||||
* @class AES
|
||||
* @param key {Array} The key as an array of 4, 6 or 8 words.
|
||||
*/
|
||||
|
||||
var AES = /*#__PURE__*/function () {
|
||||
function AES(key) {
|
||||
/**
|
||||
* The expanded S-box and inverse S-box tables. These will be computed
|
||||
* on the client so that we don't have to send them down the wire.
|
||||
*
|
||||
* There are two tables, _tables[0] is for encryption and
|
||||
* _tables[1] is for decryption.
|
||||
*
|
||||
* The first 4 sub-tables are the expanded S-box with MixColumns. The
|
||||
* last (_tables[01][4]) is the S-box itself.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
// if we have yet to precompute the S-box tables
|
||||
// do so now
|
||||
if (!aesTables) {
|
||||
aesTables = precompute();
|
||||
} // then make a copy of that object for use
|
||||
|
||||
|
||||
this._tables = [[aesTables[0][0].slice(), aesTables[0][1].slice(), aesTables[0][2].slice(), aesTables[0][3].slice(), aesTables[0][4].slice()], [aesTables[1][0].slice(), aesTables[1][1].slice(), aesTables[1][2].slice(), aesTables[1][3].slice(), aesTables[1][4].slice()]];
|
||||
var i;
|
||||
var j;
|
||||
var tmp;
|
||||
var sbox = this._tables[0][4];
|
||||
var decTable = this._tables[1];
|
||||
var keyLen = key.length;
|
||||
var rcon = 1;
|
||||
|
||||
if (keyLen !== 4 && keyLen !== 6 && keyLen !== 8) {
|
||||
throw new Error('Invalid aes key size');
|
||||
}
|
||||
|
||||
var encKey = key.slice(0);
|
||||
var decKey = [];
|
||||
this._key = [encKey, decKey]; // schedule encryption keys
|
||||
|
||||
for (i = keyLen; i < 4 * keyLen + 28; i++) {
|
||||
tmp = encKey[i - 1]; // apply sbox
|
||||
|
||||
if (i % keyLen === 0 || keyLen === 8 && i % keyLen === 4) {
|
||||
tmp = sbox[tmp >>> 24] << 24 ^ sbox[tmp >> 16 & 255] << 16 ^ sbox[tmp >> 8 & 255] << 8 ^ sbox[tmp & 255]; // shift rows and add rcon
|
||||
|
||||
if (i % keyLen === 0) {
|
||||
tmp = tmp << 8 ^ tmp >>> 24 ^ rcon << 24;
|
||||
rcon = rcon << 1 ^ (rcon >> 7) * 283;
|
||||
}
|
||||
}
|
||||
|
||||
encKey[i] = encKey[i - keyLen] ^ tmp;
|
||||
} // schedule decryption keys
|
||||
|
||||
|
||||
for (j = 0; i; j++, i--) {
|
||||
tmp = encKey[j & 3 ? i : i - 4];
|
||||
|
||||
if (i <= 4 || j < 4) {
|
||||
decKey[j] = tmp;
|
||||
} else {
|
||||
decKey[j] = decTable[0][sbox[tmp >>> 24]] ^ decTable[1][sbox[tmp >> 16 & 255]] ^ decTable[2][sbox[tmp >> 8 & 255]] ^ decTable[3][sbox[tmp & 255]];
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Decrypt 16 bytes, specified as four 32-bit words.
|
||||
*
|
||||
* @param {number} encrypted0 the first word to decrypt
|
||||
* @param {number} encrypted1 the second word to decrypt
|
||||
* @param {number} encrypted2 the third word to decrypt
|
||||
* @param {number} encrypted3 the fourth word to decrypt
|
||||
* @param {Int32Array} out the array to write the decrypted words
|
||||
* into
|
||||
* @param {number} offset the offset into the output array to start
|
||||
* writing results
|
||||
* @return {Array} The plaintext.
|
||||
*/
|
||||
|
||||
|
||||
var _proto = AES.prototype;
|
||||
|
||||
_proto.decrypt = function decrypt(encrypted0, encrypted1, encrypted2, encrypted3, out, offset) {
|
||||
var key = this._key[1]; // state variables a,b,c,d are loaded with pre-whitened data
|
||||
|
||||
var a = encrypted0 ^ key[0];
|
||||
var b = encrypted3 ^ key[1];
|
||||
var c = encrypted2 ^ key[2];
|
||||
var d = encrypted1 ^ key[3];
|
||||
var a2;
|
||||
var b2;
|
||||
var c2; // key.length === 2 ?
|
||||
|
||||
var nInnerRounds = key.length / 4 - 2;
|
||||
var i;
|
||||
var kIndex = 4;
|
||||
var table = this._tables[1]; // load up the tables
|
||||
|
||||
var table0 = table[0];
|
||||
var table1 = table[1];
|
||||
var table2 = table[2];
|
||||
var table3 = table[3];
|
||||
var sbox = table[4]; // Inner rounds. Cribbed from OpenSSL.
|
||||
|
||||
for (i = 0; i < nInnerRounds; i++) {
|
||||
a2 = table0[a >>> 24] ^ table1[b >> 16 & 255] ^ table2[c >> 8 & 255] ^ table3[d & 255] ^ key[kIndex];
|
||||
b2 = table0[b >>> 24] ^ table1[c >> 16 & 255] ^ table2[d >> 8 & 255] ^ table3[a & 255] ^ key[kIndex + 1];
|
||||
c2 = table0[c >>> 24] ^ table1[d >> 16 & 255] ^ table2[a >> 8 & 255] ^ table3[b & 255] ^ key[kIndex + 2];
|
||||
d = table0[d >>> 24] ^ table1[a >> 16 & 255] ^ table2[b >> 8 & 255] ^ table3[c & 255] ^ key[kIndex + 3];
|
||||
kIndex += 4;
|
||||
a = a2;
|
||||
b = b2;
|
||||
c = c2;
|
||||
} // Last round.
|
||||
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
out[(3 & -i) + offset] = sbox[a >>> 24] << 24 ^ sbox[b >> 16 & 255] << 16 ^ sbox[c >> 8 & 255] << 8 ^ sbox[d & 255] ^ key[kIndex++];
|
||||
a2 = a;
|
||||
a = b;
|
||||
b = c;
|
||||
c = d;
|
||||
d = a2;
|
||||
}
|
||||
};
|
||||
|
||||
return AES;
|
||||
}();
|
||||
/**
|
||||
* A wrapper around the Stream class to use setTimeout
|
||||
* and run stream "jobs" Asynchronously
|
||||
*
|
||||
* @class AsyncStream
|
||||
* @extends Stream
|
||||
*/
|
||||
|
||||
|
||||
var AsyncStream = /*#__PURE__*/function (_Stream) {
|
||||
inheritsLoose(AsyncStream, _Stream);
|
||||
|
||||
function AsyncStream() {
|
||||
var _this;
|
||||
|
||||
_this = _Stream.call(this, Stream) || this;
|
||||
_this.jobs = [];
|
||||
_this.delay = 1;
|
||||
_this.timeout_ = null;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* process an async job
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
|
||||
var _proto = AsyncStream.prototype;
|
||||
|
||||
_proto.processJob_ = function processJob_() {
|
||||
this.jobs.shift()();
|
||||
|
||||
if (this.jobs.length) {
|
||||
this.timeout_ = setTimeout(this.processJob_.bind(this), this.delay);
|
||||
} else {
|
||||
this.timeout_ = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* push a job into the stream
|
||||
*
|
||||
* @param {Function} job the job to push into the stream
|
||||
*/
|
||||
;
|
||||
|
||||
_proto.push = function push(job) {
|
||||
this.jobs.push(job);
|
||||
|
||||
if (!this.timeout_) {
|
||||
this.timeout_ = setTimeout(this.processJob_.bind(this), this.delay);
|
||||
}
|
||||
};
|
||||
|
||||
return AsyncStream;
|
||||
}(Stream);
|
||||
/**
|
||||
* Convert network-order (big-endian) bytes into their little-endian
|
||||
* representation.
|
||||
*/
|
||||
|
||||
|
||||
var ntoh = function ntoh(word) {
|
||||
return word << 24 | (word & 0xff00) << 8 | (word & 0xff0000) >> 8 | word >>> 24;
|
||||
};
|
||||
/**
|
||||
* Decrypt bytes using AES-128 with CBC and PKCS#7 padding.
|
||||
*
|
||||
* @param {Uint8Array} encrypted the encrypted bytes
|
||||
* @param {Uint32Array} key the bytes of the decryption key
|
||||
* @param {Uint32Array} initVector the initialization vector (IV) to
|
||||
* use for the first round of CBC.
|
||||
* @return {Uint8Array} the decrypted bytes
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
|
||||
* @see http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_Block_Chaining_.28CBC.29
|
||||
* @see https://tools.ietf.org/html/rfc2315
|
||||
*/
|
||||
|
||||
|
||||
var decrypt = function decrypt(encrypted, key, initVector) {
|
||||
// word-level access to the encrypted bytes
|
||||
var encrypted32 = new Int32Array(encrypted.buffer, encrypted.byteOffset, encrypted.byteLength >> 2);
|
||||
var decipher = new AES(Array.prototype.slice.call(key)); // byte and word-level access for the decrypted output
|
||||
|
||||
var decrypted = new Uint8Array(encrypted.byteLength);
|
||||
var decrypted32 = new Int32Array(decrypted.buffer); // temporary variables for working with the IV, encrypted, and
|
||||
// decrypted data
|
||||
|
||||
var init0;
|
||||
var init1;
|
||||
var init2;
|
||||
var init3;
|
||||
var encrypted0;
|
||||
var encrypted1;
|
||||
var encrypted2;
|
||||
var encrypted3; // iteration variable
|
||||
|
||||
var wordIx; // pull out the words of the IV to ensure we don't modify the
|
||||
// passed-in reference and easier access
|
||||
|
||||
init0 = initVector[0];
|
||||
init1 = initVector[1];
|
||||
init2 = initVector[2];
|
||||
init3 = initVector[3]; // decrypt four word sequences, applying cipher-block chaining (CBC)
|
||||
// to each decrypted block
|
||||
|
||||
for (wordIx = 0; wordIx < encrypted32.length; wordIx += 4) {
|
||||
// convert big-endian (network order) words into little-endian
|
||||
// (javascript order)
|
||||
encrypted0 = ntoh(encrypted32[wordIx]);
|
||||
encrypted1 = ntoh(encrypted32[wordIx + 1]);
|
||||
encrypted2 = ntoh(encrypted32[wordIx + 2]);
|
||||
encrypted3 = ntoh(encrypted32[wordIx + 3]); // decrypt the block
|
||||
|
||||
decipher.decrypt(encrypted0, encrypted1, encrypted2, encrypted3, decrypted32, wordIx); // XOR with the IV, and restore network byte-order to obtain the
|
||||
// plaintext
|
||||
|
||||
decrypted32[wordIx] = ntoh(decrypted32[wordIx] ^ init0);
|
||||
decrypted32[wordIx + 1] = ntoh(decrypted32[wordIx + 1] ^ init1);
|
||||
decrypted32[wordIx + 2] = ntoh(decrypted32[wordIx + 2] ^ init2);
|
||||
decrypted32[wordIx + 3] = ntoh(decrypted32[wordIx + 3] ^ init3); // setup the IV for the next round
|
||||
|
||||
init0 = encrypted0;
|
||||
init1 = encrypted1;
|
||||
init2 = encrypted2;
|
||||
init3 = encrypted3;
|
||||
}
|
||||
|
||||
return decrypted;
|
||||
};
|
||||
/**
|
||||
* The `Decrypter` class that manages decryption of AES
|
||||
* data through `AsyncStream` objects and the `decrypt`
|
||||
* function
|
||||
*
|
||||
* @param {Uint8Array} encrypted the encrypted bytes
|
||||
* @param {Uint32Array} key the bytes of the decryption key
|
||||
* @param {Uint32Array} initVector the initialization vector (IV) to
|
||||
* @param {Function} done the function to run when done
|
||||
* @class Decrypter
|
||||
*/
|
||||
|
||||
|
||||
var Decrypter = /*#__PURE__*/function () {
|
||||
function Decrypter(encrypted, key, initVector, done) {
|
||||
var step = Decrypter.STEP;
|
||||
var encrypted32 = new Int32Array(encrypted.buffer);
|
||||
var decrypted = new Uint8Array(encrypted.byteLength);
|
||||
var i = 0;
|
||||
this.asyncStream_ = new AsyncStream(); // split up the encryption job and do the individual chunks asynchronously
|
||||
|
||||
this.asyncStream_.push(this.decryptChunk_(encrypted32.subarray(i, i + step), key, initVector, decrypted));
|
||||
|
||||
for (i = step; i < encrypted32.length; i += step) {
|
||||
initVector = new Uint32Array([ntoh(encrypted32[i - 4]), ntoh(encrypted32[i - 3]), ntoh(encrypted32[i - 2]), ntoh(encrypted32[i - 1])]);
|
||||
this.asyncStream_.push(this.decryptChunk_(encrypted32.subarray(i, i + step), key, initVector, decrypted));
|
||||
} // invoke the done() callback when everything is finished
|
||||
|
||||
|
||||
this.asyncStream_.push(function () {
|
||||
// remove pkcs#7 padding from the decrypted bytes
|
||||
done(null, unpad(decrypted));
|
||||
});
|
||||
}
|
||||
/**
|
||||
* a getter for step the maximum number of bytes to process at one time
|
||||
*
|
||||
* @return {number} the value of step 32000
|
||||
*/
|
||||
|
||||
|
||||
var _proto = Decrypter.prototype;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
||||
_proto.decryptChunk_ = function decryptChunk_(encrypted, key, initVector, decrypted) {
|
||||
return function () {
|
||||
var bytes = decrypt(encrypted, key, initVector);
|
||||
decrypted.set(bytes, encrypted.byteOffset);
|
||||
};
|
||||
};
|
||||
|
||||
createClass(Decrypter, null, [{
|
||||
key: "STEP",
|
||||
get: function get() {
|
||||
// 4 * 8000;
|
||||
return 32000;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Decrypter;
|
||||
}();
|
||||
|
||||
/**
|
||||
* @file bin-utils.js
|
||||
*/
|
||||
/**
|
||||
* Creates an object for sending to a web worker modifying properties that are TypedArrays
|
||||
* into a new object with seperated properties for the buffer, byteOffset, and byteLength.
|
||||
*
|
||||
* @param {Object} message
|
||||
* Object of properties and values to send to the web worker
|
||||
* @return {Object}
|
||||
* Modified message with TypedArray values expanded
|
||||
* @function createTransferableMessage
|
||||
*/
|
||||
|
||||
|
||||
var createTransferableMessage = function createTransferableMessage(message) {
|
||||
var transferable = {};
|
||||
Object.keys(message).forEach(function (key) {
|
||||
var value = message[key];
|
||||
|
||||
if (ArrayBuffer.isView(value)) {
|
||||
transferable[key] = {
|
||||
bytes: value.buffer,
|
||||
byteOffset: value.byteOffset,
|
||||
byteLength: value.byteLength
|
||||
};
|
||||
} else {
|
||||
transferable[key] = value;
|
||||
}
|
||||
});
|
||||
return transferable;
|
||||
};
|
||||
|
||||
/* global self */
|
||||
/**
|
||||
* Our web worker interface so that things can talk to aes-decrypter
|
||||
* that will be running in a web worker. the scope is passed to this by
|
||||
* webworkify.
|
||||
*
|
||||
* @param {Object} self
|
||||
* the scope for the web worker
|
||||
*/
|
||||
|
||||
var DecrypterWorker = function DecrypterWorker(self) {
|
||||
self.onmessage = function (event) {
|
||||
var data = event.data;
|
||||
var encrypted = new Uint8Array(data.encrypted.bytes, data.encrypted.byteOffset, data.encrypted.byteLength);
|
||||
var key = new Uint32Array(data.key.bytes, data.key.byteOffset, data.key.byteLength / 4);
|
||||
var iv = new Uint32Array(data.iv.bytes, data.iv.byteOffset, data.iv.byteLength / 4);
|
||||
/* eslint-disable no-new, handle-callback-err */
|
||||
|
||||
new Decrypter(encrypted, key, iv, function (err, bytes) {
|
||||
self.postMessage(createTransferableMessage({
|
||||
source: data.source,
|
||||
decrypted: bytes
|
||||
}), [bytes.buffer]);
|
||||
});
|
||||
/* eslint-enable */
|
||||
};
|
||||
};
|
||||
|
||||
var decrypterWorker = new DecrypterWorker(self);
|
||||
|
||||
return decrypterWorker;
|
||||
|
||||
}());
|
8110
node_modules/@videojs/http-streaming/src/transmuxer-worker.worker.js
generated
vendored
Normal file
8110
node_modules/@videojs/http-streaming/src/transmuxer-worker.worker.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
40
node_modules/@videojs/http-streaming/src/videojs-http-streaming.js
generated
vendored
40
node_modules/@videojs/http-streaming/src/videojs-http-streaming.js
generated
vendored
|
@ -1061,12 +1061,40 @@ class VhsHandler extends Component {
|
|||
});
|
||||
|
||||
this.player_.tech_.on('keystatuschange', (e) => {
|
||||
if (e.status === 'output-restricted') {
|
||||
this.masterPlaylistController_.blacklistCurrentPlaylist({
|
||||
playlist: this.masterPlaylistController_.media(),
|
||||
message: `DRM keystatus changed to ${e.status}. Playlist will fail to play. Check for HDCP content.`,
|
||||
blacklistDuration: Infinity
|
||||
});
|
||||
if (e.status !== 'output-restricted') {
|
||||
return;
|
||||
}
|
||||
|
||||
const masterPlaylist = this.masterPlaylistController_.master();
|
||||
|
||||
if (!masterPlaylist || !masterPlaylist.playlists) {
|
||||
return;
|
||||
}
|
||||
|
||||
const excludedHDPlaylists = [];
|
||||
|
||||
// Assume all HD streams are unplayable and exclude them from ABR selection
|
||||
masterPlaylist.playlists.forEach(playlist => {
|
||||
if (playlist && playlist.attributes && playlist.attributes.RESOLUTION &&
|
||||
playlist.attributes.RESOLUTION.height >= 720) {
|
||||
if (!playlist.excludeUntil || playlist.excludeUntil < Infinity) {
|
||||
|
||||
playlist.excludeUntil = Infinity;
|
||||
excludedHDPlaylists.push(playlist);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (excludedHDPlaylists.length) {
|
||||
videojs.log.warn(
|
||||
'DRM keystatus changed to "output-restricted." Removing the following HD playlists ' +
|
||||
'that will most likely fail to play and clearing the buffer. ' +
|
||||
'This may be due to HDCP restrictions on the stream and the capabilities of the current device.',
|
||||
...excludedHDPlaylists
|
||||
);
|
||||
|
||||
// Clear the buffer before switching playlists, since it may already contain unplayable segments
|
||||
this.masterPlaylistController_.fastQualityChange_();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
5
node_modules/@videojs/http-streaming/src/vtt-segment-loader.js
generated
vendored
5
node_modules/@videojs/http-streaming/src/vtt-segment-loader.js
generated
vendored
|
@ -280,6 +280,11 @@ export default class VTTSegmentLoader extends SegmentLoader {
|
|||
// maintain functionality between segment loaders
|
||||
this.saveBandwidthRelatedStats_(segmentInfo.duration, simpleSegment.stats);
|
||||
|
||||
// if this request included a segment key, save that data in the cache
|
||||
if (simpleSegment.key) {
|
||||
this.segmentKey(simpleSegment.key, true);
|
||||
}
|
||||
|
||||
this.state = 'APPENDING';
|
||||
|
||||
// used for tests
|
||||
|
|
542
node_modules/hls.js/dist/hls.js
generated
vendored
542
node_modules/hls.js/dist/hls.js
generated
vendored
File diff suppressed because it is too large
Load diff
20
node_modules/hls.js/dist/hls.js.d.ts
generated
vendored
20
node_modules/hls.js/dist/hls.js.d.ts
generated
vendored
|
@ -191,8 +191,8 @@ declare class BaseStreamController extends TaskLoop implements NetworkComponentA
|
|||
protected fragmentTracker: FragmentTracker;
|
||||
protected transmuxer: TransmuxerInterface | null;
|
||||
protected _state: string;
|
||||
protected media?: any;
|
||||
protected mediaBuffer?: any;
|
||||
protected media: HTMLMediaElement | null;
|
||||
protected mediaBuffer: Bufferable | null;
|
||||
protected config: HlsConfig;
|
||||
protected bitrateTest: boolean;
|
||||
protected lastCurrentTime: number;
|
||||
|
@ -223,6 +223,7 @@ declare class BaseStreamController extends TaskLoop implements NetworkComponentA
|
|||
protected onMediaSeeking(): void;
|
||||
protected onMediaEnded(): void;
|
||||
onKeyLoaded(event: Events.KEY_LOADED, data: KeyLoadedData): void;
|
||||
protected onLevelSwitching(event: Events.LEVEL_SWITCHING, data: LevelSwitchingData): void;
|
||||
protected onHandlerDestroying(): void;
|
||||
protected onHandlerDestroyed(): void;
|
||||
protected loadKey(frag: Fragment, details: LevelDetails): void;
|
||||
|
@ -232,6 +233,7 @@ declare class BaseStreamController extends TaskLoop implements NetworkComponentA
|
|||
protected _loadInitSegment(frag: Fragment): void;
|
||||
protected fragContextChanged(frag: Fragment | null): boolean;
|
||||
protected fragBufferedComplete(frag: Fragment, part: Part | null): void;
|
||||
protected seekToStartPos(): void;
|
||||
protected _handleFragmentLoadComplete(fragLoadedEndData: PartsLoadedData): void;
|
||||
protected _handleFragmentLoadProgress(frag: FragLoadedData): void;
|
||||
protected _doFragLoad(frag: Fragment, details?: LevelDetails, targetBufferTime?: number | null, progressCallback?: FragmentLoadProgressCallback): Promise<PartsLoadedData | FragLoadedData | null>;
|
||||
|
@ -245,7 +247,7 @@ declare class BaseStreamController extends TaskLoop implements NetworkComponentA
|
|||
} | null;
|
||||
protected bufferFragmentData(data: RemuxedTrack, frag: Fragment, part: Part | null, chunkMeta: ChunkMetadata): void;
|
||||
protected flushBufferGap(frag: Fragment): void;
|
||||
protected getFwdBufferInfo(bufferable: Bufferable, type: PlaylistLevelType): {
|
||||
protected getFwdBufferInfo(bufferable: Bufferable | null, type: PlaylistLevelType): {
|
||||
len: number;
|
||||
start: number;
|
||||
end: number;
|
||||
|
@ -269,7 +271,7 @@ declare class BaseStreamController extends TaskLoop implements NetworkComponentA
|
|||
protected onFragmentOrKeyLoadError(filterType: PlaylistLevelType, data: ErrorData): void;
|
||||
protected afterBufferFlushed(media: Bufferable, bufferType: SourceBufferName, playlistType: PlaylistLevelType): void;
|
||||
protected resetLoadingState(): void;
|
||||
protected resetLiveStartWhenNotLoaded(level: number): boolean;
|
||||
protected resetStartWhenNotLoaded(level: number): void;
|
||||
private updateLevelTiming;
|
||||
protected resetTransmuxer(): void;
|
||||
set state(nextState: string);
|
||||
|
@ -2506,9 +2508,8 @@ declare class StreamController extends BaseStreamController implements NetworkCo
|
|||
swapAudioCodec(): void;
|
||||
/**
|
||||
* Seeks to the set startPosition if not equal to the mediaElement's current time.
|
||||
* @private
|
||||
*/
|
||||
private seekToStartPos;
|
||||
protected seekToStartPos(): void;
|
||||
private _getAudioCodec;
|
||||
private _loadBitrateTestFrag;
|
||||
private _handleTransmuxComplete;
|
||||
|
@ -2591,7 +2592,7 @@ declare class SubtitleStreamController extends BaseStreamController implements N
|
|||
_handleFragmentLoadComplete(fragLoadedData: FragLoadedData): void;
|
||||
doTick(): void;
|
||||
protected loadFragment(frag: Fragment, levelDetails: LevelDetails, targetBufferTime: number): void;
|
||||
get mediaBufferTimeRanges(): TimeRange[];
|
||||
get mediaBufferTimeRanges(): Bufferable;
|
||||
}
|
||||
|
||||
declare class SubtitleTrackController extends BasePlaylistController {
|
||||
|
@ -2796,11 +2797,6 @@ export declare type TimelineControllerConfig = {
|
|||
renderTextTracksNatively: boolean;
|
||||
};
|
||||
|
||||
declare interface TimeRange {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
|
||||
export declare interface Track {
|
||||
id: 'audio' | 'main';
|
||||
buffer?: SourceBuffer;
|
||||
|
|
2
node_modules/hls.js/dist/hls.js.map
generated
vendored
2
node_modules/hls.js/dist/hls.js.map
generated
vendored
File diff suppressed because one or more lines are too long
484
node_modules/hls.js/dist/hls.light.js
generated
vendored
484
node_modules/hls.js/dist/hls.light.js
generated
vendored
File diff suppressed because it is too large
Load diff
2
node_modules/hls.js/dist/hls.light.js.map
generated
vendored
2
node_modules/hls.js/dist/hls.light.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/hls.js/dist/hls.light.min.js
generated
vendored
2
node_modules/hls.js/dist/hls.light.min.js
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/hls.js/dist/hls.light.min.js.map
generated
vendored
2
node_modules/hls.js/dist/hls.light.min.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/hls.js/dist/hls.min.js
generated
vendored
2
node_modules/hls.js/dist/hls.min.js
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/hls.js/dist/hls.min.js.map
generated
vendored
2
node_modules/hls.js/dist/hls.min.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/hls.js/package.json
generated
vendored
2
node_modules/hls.js/package.json
generated
vendored
|
@ -1 +1 @@
|
|||
{"name":"hls.js","license":"Apache-2.0","description":"JavaScript HLS client using MediaSourceExtension","homepage":"https://github.com/video-dev/hls.js","authors":"Guillaume du Pontavice <g.du.pontavice@gmail.com>","repository":{"type":"git","url":"https://github.com/video-dev/hls.js"},"bugs":{"url":"https://github.com/video-dev/hls.js/issues"},"main":"./dist/hls.js","types":"./dist/hls.js.d.ts","files":["dist/**/*","src/**/*"],"publishConfig":{"access":"public"},"scripts":{"build":"webpack --progress && npm run build:types","build:ci":"webpack && tsc --build tsconfig-lib.json && api-extractor run","build:debug":"webpack --progress --env debug --env demo","build:watch":"webpack --progress --env debug --env demo --watch","build:types":"tsc --build tsconfig-lib.json && api-extractor run --local","dev":"webpack serve --progress --env debug --env demo --port 8000 --static .","docs":"esdoc","lint":"eslint src/ tests/ --ext .js --ext .ts","lint:fix":"npm run lint -- --fix","lint:quiet":"npm run lint -- --quiet","lint:staged":"lint-staged","prettier":"prettier --write .","prettier:verify":"prettier --check .","pretest":"npm run lint","sanity-check":"npm run lint && npm run prettier:verify && npm run type-check && npm run docs && npm run build:types && npm run build && npm run test:unit","start":"npm run dev","test":"npm run test:unit && npm run test:func","test:unit":"karma start karma.conf.js","test:unit:debug":"DEBUG_UNIT_TESTS=1 karma start karma.conf.js --auto-watch --no-single-run --browsers Chrome","test:unit:watch":"karma start karma.conf.js --auto-watch --no-single-run","test:func":"BABEL_ENV=development mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit","test:func:light":"BABEL_ENV=development HLSJS_LIGHT=1 mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit","test:func:sauce":"SAUCE=1 UA=safari OS='OS X 10.15' BABEL_ENV=development mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit","type-check":"tsc --noEmit","type-check:watch":"npm run type-check -- --watch","prepare":"husky install"},"devDependencies":{"@babel/core":"7.18.10","@babel/helper-module-imports":"7.18.6","@babel/plugin-proposal-class-properties":"7.18.6","@babel/plugin-proposal-object-rest-spread":"7.18.9","@babel/plugin-proposal-optional-chaining":"7.18.9","@babel/plugin-transform-object-assign":"7.18.6","@babel/preset-env":"7.18.10","@babel/preset-typescript":"7.18.6","@babel/register":"7.18.9","@itsjamie/esdoc-cli":"0.5.0","@itsjamie/esdoc-core":"0.5.0","@itsjamie/esdoc-ecmascript-proposal-plugin":"0.5.0","@itsjamie/esdoc-standard-plugin":"0.5.0","@itsjamie/esdoc-typescript-plugin":"0.5.0","@microsoft/api-extractor":"7.28.6","@types/chai":"4.3.3","@types/chart.js":"2.9.37","@types/mocha":"9.1.1","@types/sinon-chai":"3.2.8","@typescript-eslint/eslint-plugin":"5.23.0","@typescript-eslint/parser":"5.23.0","babel-loader":"8.2.5","babel-plugin-transform-remove-console":"6.9.4","chai":"4.3.6","chart.js":"2.9.4","chromedriver":"104.0.0","eslint":"8.21.0","eslint-config-prettier":"8.5.0","eslint-plugin-import":"2.26.0","eslint-plugin-mocha":"10.1.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.0.0","eventemitter3":"4.0.7","http-server":"14.1.1","husky":"8.0.1","istanbul-instrumenter-loader":"3.0.1","jsonpack":"1.1.5","karma":"6.4.0","karma-chrome-launcher":"3.1.1","karma-coverage-istanbul-reporter":"3.0.3","karma-mocha":"2.0.1","karma-mocha-reporter":"2.2.5","karma-sinon-chai":"2.0.2","karma-sourcemap-loader":"0.3.8","karma-webpack":"4.0.2","lint-staged":"13.0.3","micromatch":"4.0.5","mocha":"10.0.0","netlify-cli":"10.7.1","prettier":"2.7.1","promise-polyfill":"8.2.3","sauce-connect-launcher":"1.3.2","selenium-webdriver":"4.4.0","semver":"7.3.7","sinon":"14.0.0","sinon-chai":"3.7.0","typescript":"4.7.4","url-toolkit":"2.2.5","webpack":"4.46.0","webpack-cli":"4.10.0","webpack-dev-server":"4.9.3","webpack-merge":"5.8.0","webworkify-webpack":"2.1.5"},"version":"1.2.1"}
|
||||
{"name":"hls.js","license":"Apache-2.0","description":"JavaScript HLS client using MediaSourceExtension","homepage":"https://github.com/video-dev/hls.js","authors":"Guillaume du Pontavice <g.du.pontavice@gmail.com>","repository":{"type":"git","url":"https://github.com/video-dev/hls.js"},"bugs":{"url":"https://github.com/video-dev/hls.js/issues"},"main":"./dist/hls.js","types":"./dist/hls.js.d.ts","files":["dist/**/*","src/**/*"],"publishConfig":{"access":"public"},"scripts":{"build":"webpack --progress && npm run build:types","build:ci":"webpack && tsc --build tsconfig-lib.json && api-extractor run","build:debug":"webpack --progress --env debug --env demo","build:watch":"webpack --progress --env debug --env demo --watch","build:types":"tsc --build tsconfig-lib.json && api-extractor run --local","dev":"webpack serve --progress --env debug --env demo --port 8000 --static .","docs":"esdoc","lint":"eslint src/ tests/ --ext .js --ext .ts","lint:fix":"npm run lint -- --fix","lint:quiet":"npm run lint -- --quiet","lint:staged":"lint-staged","prettier":"prettier --write .","prettier:verify":"prettier --check .","pretest":"npm run lint","sanity-check":"npm run lint && npm run prettier:verify && npm run type-check && npm run docs && npm run build:types && npm run build && npm run test:unit","start":"npm run dev","test":"npm run test:unit && npm run test:func","test:unit":"karma start karma.conf.js","test:unit:debug":"DEBUG_UNIT_TESTS=1 karma start karma.conf.js --auto-watch --no-single-run --browsers Chrome","test:unit:watch":"karma start karma.conf.js --auto-watch --no-single-run","test:func":"BABEL_ENV=development mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit","test:func:light":"BABEL_ENV=development HLSJS_LIGHT=1 mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit","test:func:sauce":"SAUCE=1 UA=safari OS='OS X 10.15' BABEL_ENV=development mocha --require @babel/register tests/functional/auto/setup.js --timeout 40000 --exit","type-check":"tsc --noEmit","type-check:watch":"npm run type-check -- --watch","prepare":"husky install"},"devDependencies":{"@babel/core":"7.18.13","@babel/helper-module-imports":"7.18.6","@babel/plugin-proposal-class-properties":"7.18.6","@babel/plugin-proposal-object-rest-spread":"7.18.9","@babel/plugin-proposal-optional-chaining":"7.18.9","@babel/plugin-transform-object-assign":"7.18.6","@babel/preset-env":"7.18.10","@babel/preset-typescript":"7.18.6","@babel/register":"7.18.9","@itsjamie/esdoc-cli":"0.5.0","@itsjamie/esdoc-core":"0.5.0","@itsjamie/esdoc-ecmascript-proposal-plugin":"0.5.0","@itsjamie/esdoc-standard-plugin":"0.5.0","@itsjamie/esdoc-typescript-plugin":"0.5.0","@microsoft/api-extractor":"7.29.5","@types/chai":"4.3.3","@types/chart.js":"2.9.37","@types/mocha":"9.1.1","@types/sinon-chai":"3.2.8","@typescript-eslint/eslint-plugin":"5.23.0","@typescript-eslint/parser":"5.23.0","babel-loader":"8.2.5","babel-plugin-transform-remove-console":"6.9.4","chai":"4.3.6","chart.js":"2.9.4","chromedriver":"104.0.0","eslint":"8.23.0","eslint-config-prettier":"8.5.0","eslint-plugin-import":"2.26.0","eslint-plugin-mocha":"10.1.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.0.1","eventemitter3":"4.0.7","http-server":"14.1.1","husky":"8.0.1","istanbul-instrumenter-loader":"3.0.1","jsonpack":"1.1.5","karma":"6.4.0","karma-chrome-launcher":"3.1.1","karma-coverage-istanbul-reporter":"3.0.3","karma-mocha":"2.0.1","karma-mocha-reporter":"2.2.5","karma-sinon-chai":"2.0.2","karma-sourcemap-loader":"0.3.8","karma-webpack":"4.0.2","lint-staged":"13.0.3","micromatch":"4.0.5","mocha":"10.0.0","netlify-cli":"10.18.0","node-fetch":"^3.2.10","prettier":"2.7.1","promise-polyfill":"8.2.3","sauce-connect-launcher":"1.3.2","selenium-webdriver":"4.4.0","semver":"7.3.7","sinon":"14.0.0","sinon-chai":"3.7.0","typescript":"4.8.2","url-toolkit":"2.2.5","webpack":"4.46.0","webpack-cli":"4.10.0","webpack-dev-server":"4.10.1","webpack-merge":"5.8.0","webworkify-webpack":"2.1.5"},"version":"1.2.3"}
|
10
node_modules/hls.js/src/controller/abr-controller.ts
generated
vendored
10
node_modules/hls.js/src/controller/abr-controller.ts
generated
vendored
|
@ -240,7 +240,6 @@ class AbrController implements ComponentAPI {
|
|||
id: frag.type,
|
||||
};
|
||||
this.onFragBuffered(Events.FRAG_BUFFERED, fragBufferedData);
|
||||
frag.bitrateTest = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,15 +293,16 @@ class AbrController implements ComponentAPI {
|
|||
const forcedAutoLevel = this._nextAutoLevel;
|
||||
const bwEstimator = this.bwEstimator;
|
||||
// in case next auto level has been forced, and bw not available or not reliable, return forced value
|
||||
if (
|
||||
forcedAutoLevel !== -1 &&
|
||||
(!bwEstimator || !bwEstimator.canEstimate())
|
||||
) {
|
||||
if (forcedAutoLevel !== -1 && !bwEstimator.canEstimate()) {
|
||||
return forcedAutoLevel;
|
||||
}
|
||||
|
||||
// compute next level using ABR logic
|
||||
let nextABRAutoLevel = this.getNextABRAutoLevel();
|
||||
// use forced auto level when ABR selected level has errored
|
||||
if (forcedAutoLevel !== -1 && this.hls.levels[nextABRAutoLevel].loadError) {
|
||||
return forcedAutoLevel;
|
||||
}
|
||||
// if forced auto level has been defined, use it to cap ABR computed quality level
|
||||
if (forcedAutoLevel !== -1) {
|
||||
nextABRAutoLevel = Math.min(forcedAutoLevel, nextABRAutoLevel);
|
||||
|
|
20
node_modules/hls.js/src/controller/audio-stream-controller.ts
generated
vendored
20
node_modules/hls.js/src/controller/audio-stream-controller.ts
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
import BaseStreamController, { State } from './base-stream-controller';
|
||||
import { Events } from '../events';
|
||||
import { BufferHelper } from '../utils/buffer-helper';
|
||||
import { Bufferable, BufferHelper } from '../utils/buffer-helper';
|
||||
import { FragmentState } from './fragment-tracker';
|
||||
import { Level } from '../types/level';
|
||||
import { PlaylistLevelType } from '../types/loader';
|
||||
|
@ -46,7 +46,7 @@ class AudioStreamController
|
|||
extends BaseStreamController
|
||||
implements NetworkComponentAPI
|
||||
{
|
||||
private videoBuffer: any | null = null;
|
||||
private videoBuffer: Bufferable | null = null;
|
||||
private videoTrackCC: number = -1;
|
||||
private waitingVideoCC: number = -1;
|
||||
private audioSwitch: boolean = false;
|
||||
|
@ -171,6 +171,7 @@ class AudioStreamController
|
|||
// if current time is gt than retryDate, or if media seeking let's switch to IDLE state to retry loading
|
||||
if (!retryDate || now >= retryDate || this.media?.seeking) {
|
||||
this.log('RetryDate reached, switch back to IDLE state');
|
||||
this.resetStartWhenNotLoaded(this.trackId);
|
||||
this.state = State.IDLE;
|
||||
}
|
||||
break;
|
||||
|
@ -289,17 +290,18 @@ class AudioStreamController
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.bufferFlushed) {
|
||||
const bufferable = this.mediaBuffer ? this.mediaBuffer : this.media;
|
||||
if (this.bufferFlushed && bufferable) {
|
||||
this.bufferFlushed = false;
|
||||
this.afterBufferFlushed(
|
||||
this.mediaBuffer ? this.mediaBuffer : this.media,
|
||||
bufferable,
|
||||
ElementaryStreamTypes.AUDIO,
|
||||
PlaylistLevelType.AUDIO
|
||||
);
|
||||
}
|
||||
|
||||
const bufferInfo = this.getFwdBufferInfo(
|
||||
this.mediaBuffer ? this.mediaBuffer : this.media,
|
||||
bufferable,
|
||||
PlaylistLevelType.AUDIO
|
||||
);
|
||||
if (bufferInfo === null) {
|
||||
|
@ -328,7 +330,7 @@ class AudioStreamController
|
|||
const start = fragments[0].start;
|
||||
let targetBufferTime = bufferInfo.end;
|
||||
|
||||
if (audioSwitch) {
|
||||
if (audioSwitch && media) {
|
||||
const pos = this.getLoadPosition();
|
||||
targetBufferTime = pos;
|
||||
// if currentTime (pos) is less than alt audio playlist start time, it means that alt audio is ahead of currentTime
|
||||
|
@ -587,10 +589,10 @@ class AudioStreamController
|
|||
onBufferCreated(event: Events.BUFFER_CREATED, data: BufferCreatedData) {
|
||||
const audioTrack = data.tracks.audio;
|
||||
if (audioTrack) {
|
||||
this.mediaBuffer = audioTrack.buffer;
|
||||
this.mediaBuffer = audioTrack.buffer || null;
|
||||
}
|
||||
if (data.tracks.video) {
|
||||
this.videoBuffer = data.tracks.video.buffer;
|
||||
this.videoBuffer = data.tracks.video.buffer || null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -694,7 +696,7 @@ class AudioStreamController
|
|||
this.warn(
|
||||
`The loading context changed while buffering fragment ${chunkMeta.sn} of level ${chunkMeta.level}. This chunk will not be buffered.`
|
||||
);
|
||||
this.resetLiveStartWhenNotLoaded(chunkMeta.level);
|
||||
this.resetStartWhenNotLoaded(chunkMeta.level);
|
||||
return;
|
||||
}
|
||||
const {
|
||||
|
|
89
node_modules/hls.js/src/controller/base-stream-controller.ts
generated
vendored
89
node_modules/hls.js/src/controller/base-stream-controller.ts
generated
vendored
|
@ -24,7 +24,10 @@ import FragmentLoader, {
|
|||
LoadError,
|
||||
} from '../loader/fragment-loader';
|
||||
import { LevelDetails } from '../loader/level-details';
|
||||
import {
|
||||
import Decrypter from '../crypt/decrypter';
|
||||
import TimeRanges from '../utils/time-ranges';
|
||||
import { PlaylistLevelType } from '../types/loader';
|
||||
import type {
|
||||
BufferAppendingData,
|
||||
ErrorData,
|
||||
FragLoadedData,
|
||||
|
@ -32,10 +35,8 @@ import {
|
|||
KeyLoadedData,
|
||||
MediaAttachingData,
|
||||
BufferFlushingData,
|
||||
LevelSwitchingData,
|
||||
} from '../types/events';
|
||||
import Decrypter from '../crypt/decrypter';
|
||||
import TimeRanges from '../utils/time-ranges';
|
||||
import { PlaylistLevelType } from '../types/loader';
|
||||
import type { FragmentTracker } from './fragment-tracker';
|
||||
import type { Level } from '../types/level';
|
||||
import type { RemuxedTrack } from '../types/remuxer';
|
||||
|
@ -74,8 +75,8 @@ export default class BaseStreamController
|
|||
protected fragmentTracker: FragmentTracker;
|
||||
protected transmuxer: TransmuxerInterface | null = null;
|
||||
protected _state: string = State.STOPPED;
|
||||
protected media?: any;
|
||||
protected mediaBuffer?: any;
|
||||
protected media: HTMLMediaElement | null = null;
|
||||
protected mediaBuffer: Bufferable | null = null;
|
||||
protected config: HlsConfig;
|
||||
protected bitrateTest: boolean = false;
|
||||
protected lastCurrentTime: number = 0;
|
||||
|
@ -108,6 +109,7 @@ export default class BaseStreamController
|
|||
this.config = hls.config;
|
||||
this.decrypter = new Decrypter(hls as HlsEventEmitter, hls.config);
|
||||
hls.on(Events.KEY_LOADED, this.onKeyLoaded, this);
|
||||
hls.on(Events.LEVEL_SWITCHING, this.onLevelSwitching, this);
|
||||
}
|
||||
|
||||
protected doTick() {
|
||||
|
@ -133,7 +135,7 @@ export default class BaseStreamController
|
|||
this.state = State.STOPPED;
|
||||
}
|
||||
|
||||
protected _streamEnded(bufferInfo, levelDetails: LevelDetails) {
|
||||
protected _streamEnded(bufferInfo, levelDetails: LevelDetails): boolean {
|
||||
const { fragCurrent, fragmentTracker } = this;
|
||||
// we just got done loading the final fragment and there is no other buffered range after ...
|
||||
// rationale is that in case there are any buffered ranges after, it means that there are unbuffered portion in between
|
||||
|
@ -141,6 +143,7 @@ export default class BaseStreamController
|
|||
if (
|
||||
!levelDetails.live &&
|
||||
fragCurrent &&
|
||||
this.media &&
|
||||
// NOTE: Because of the way parts are currently parsed/represented in the playlist, we can end up
|
||||
// in situations where the current fragment is actually greater than levelDetails.endSN. While
|
||||
// this feels like the "wrong place" to account for that, this is a narrower/safer change than
|
||||
|
@ -176,10 +179,10 @@ export default class BaseStreamController
|
|||
data: MediaAttachingData
|
||||
) {
|
||||
const media = (this.media = this.mediaBuffer = data.media);
|
||||
this.onvseeking = this.onMediaSeeking.bind(this);
|
||||
this.onvended = this.onMediaEnded.bind(this);
|
||||
media.addEventListener('seeking', this.onvseeking as EventListener);
|
||||
media.addEventListener('ended', this.onvended as EventListener);
|
||||
this.onvseeking = this.onMediaSeeking.bind(this) as EventListener;
|
||||
this.onvended = this.onMediaEnded.bind(this) as EventListener;
|
||||
media.addEventListener('seeking', this.onvseeking);
|
||||
media.addEventListener('ended', this.onvended);
|
||||
const config = this.config;
|
||||
if (this.levels && config.autoStartLoad && this.state === State.STOPPED) {
|
||||
this.startLoad(config.startPosition);
|
||||
|
@ -194,7 +197,7 @@ export default class BaseStreamController
|
|||
}
|
||||
|
||||
// remove video listeners
|
||||
if (media) {
|
||||
if (media && this.onvseeking && this.onvended) {
|
||||
media.removeEventListener('seeking', this.onvseeking);
|
||||
media.removeEventListener('ended', this.onvended);
|
||||
this.onvseeking = this.onvended = null;
|
||||
|
@ -209,7 +212,7 @@ export default class BaseStreamController
|
|||
const { config, fragCurrent, media, mediaBuffer, state } = this;
|
||||
const currentTime: number = media ? media.currentTime : 0;
|
||||
const bufferInfo = BufferHelper.bufferInfo(
|
||||
mediaBuffer || media,
|
||||
mediaBuffer ? mediaBuffer : media,
|
||||
currentTime,
|
||||
config.maxBufferHole
|
||||
);
|
||||
|
@ -274,6 +277,13 @@ export default class BaseStreamController
|
|||
}
|
||||
}
|
||||
|
||||
protected onLevelSwitching(
|
||||
event: Events.LEVEL_SWITCHING,
|
||||
data: LevelSwitchingData
|
||||
): void {
|
||||
this.fragLoadError = 0;
|
||||
}
|
||||
|
||||
protected onHandlerDestroying() {
|
||||
this.stopLoad();
|
||||
super.onHandlerDestroying();
|
||||
|
@ -282,6 +292,7 @@ export default class BaseStreamController
|
|||
protected onHandlerDestroyed() {
|
||||
this.state = State.STOPPED;
|
||||
this.hls.off(Events.KEY_LOADED, this.onKeyLoaded, this);
|
||||
this.hls.off(Events.LEVEL_SWITCHING, this.onLevelSwitching, this);
|
||||
if (this.fragmentLoader) {
|
||||
this.fragmentLoader.destroy();
|
||||
}
|
||||
|
@ -367,7 +378,7 @@ export default class BaseStreamController
|
|||
this._handleFragmentLoadComplete(data);
|
||||
})
|
||||
.catch((reason) => {
|
||||
if (this.state === State.STOPPED) {
|
||||
if (this.state === State.STOPPED || this.state === State.ERROR) {
|
||||
return;
|
||||
}
|
||||
this.warn(reason);
|
||||
|
@ -471,6 +482,9 @@ export default class BaseStreamController
|
|||
this.tick();
|
||||
})
|
||||
.catch((reason) => {
|
||||
if (this.state === State.STOPPED || this.state === State.ERROR) {
|
||||
return;
|
||||
}
|
||||
this.warn(reason);
|
||||
this.resetFragmentLoading(frag);
|
||||
});
|
||||
|
@ -494,12 +508,29 @@ export default class BaseStreamController
|
|||
part ? ' part: ' + part.index : ''
|
||||
} of ${this.logPrefix === '[stream-controller]' ? 'level' : 'track'} ${
|
||||
frag.level
|
||||
} ${TimeRanges.toString(BufferHelper.getBuffered(media))}`
|
||||
} ${
|
||||
media
|
||||
? TimeRanges.toString(BufferHelper.getBuffered(media))
|
||||
: '(detached)'
|
||||
}`
|
||||
);
|
||||
this.state = State.IDLE;
|
||||
if (!media) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!this.loadedmetadata &&
|
||||
media.buffered.length &&
|
||||
this.fragCurrent === this.fragPrevious
|
||||
) {
|
||||
this.loadedmetadata = true;
|
||||
this.seekToStartPos();
|
||||
}
|
||||
this.tick();
|
||||
}
|
||||
|
||||
protected seekToStartPos() {}
|
||||
|
||||
protected _handleFragmentLoadComplete(fragLoadedEndData: PartsLoadedData) {
|
||||
const { transmuxer } = this;
|
||||
if (!transmuxer) {
|
||||
|
@ -745,7 +776,7 @@ export default class BaseStreamController
|
|||
}
|
||||
|
||||
protected getFwdBufferInfo(
|
||||
bufferable: Bufferable,
|
||||
bufferable: Bufferable | null,
|
||||
type: PlaylistLevelType
|
||||
): {
|
||||
len: number;
|
||||
|
@ -1010,12 +1041,12 @@ export default class BaseStreamController
|
|||
|
||||
if (frag) {
|
||||
const curSNIdx = frag.sn - levelDetails.startSN;
|
||||
const sameLevel = fragPrevious && frag.level === fragPrevious.level;
|
||||
const nextFrag = fragments[curSNIdx + 1];
|
||||
if (fragPrevious && frag.sn === fragPrevious.sn && !loadingParts) {
|
||||
// Force the next fragment to load if the previous one was already selected. This can occasionally happen with
|
||||
// non-uniform fragment durations
|
||||
const sameLevel = fragPrevious && frag.level === fragPrevious.level;
|
||||
if (sameLevel) {
|
||||
const nextFrag = fragments[curSNIdx + 1];
|
||||
if (
|
||||
frag.sn < endSN &&
|
||||
this.fragmentTracker.getState(nextFrag) !== FragmentState.OK
|
||||
|
@ -1182,7 +1213,11 @@ export default class BaseStreamController
|
|||
}
|
||||
|
||||
protected resetFragmentLoading(frag: Fragment) {
|
||||
if (!this.fragCurrent || !this.fragContextChanged(frag)) {
|
||||
if (
|
||||
!this.fragCurrent ||
|
||||
(!this.fragContextChanged(frag) &&
|
||||
this.state !== State.FRAG_LOADING_WAITING_RETRY)
|
||||
) {
|
||||
this.state = State.IDLE;
|
||||
}
|
||||
}
|
||||
|
@ -1210,8 +1245,9 @@ export default class BaseStreamController
|
|||
const config = this.config;
|
||||
// keep retrying until the limit will be reached
|
||||
if (this.fragLoadError + 1 <= config.fragLoadingMaxRetry) {
|
||||
if (this.resetLiveStartWhenNotLoaded(frag.level)) {
|
||||
return;
|
||||
if (!this.loadedmetadata) {
|
||||
this.startFragRequested = false;
|
||||
this.nextLoadPosition = this.startPosition;
|
||||
}
|
||||
// exponential backoff capped to config.fragLoadingMaxRetryTimeout
|
||||
const delay = Math.min(
|
||||
|
@ -1271,22 +1307,21 @@ export default class BaseStreamController
|
|||
this.state = State.IDLE;
|
||||
}
|
||||
|
||||
protected resetLiveStartWhenNotLoaded(level: number): boolean {
|
||||
// if loadedmetadata is not set, it means that we are emergency switch down on first frag
|
||||
protected resetStartWhenNotLoaded(level: number): void {
|
||||
// if loadedmetadata is not set, it means that first frag request failed
|
||||
// in that case, reset startFragRequested flag
|
||||
if (!this.loadedmetadata) {
|
||||
this.startFragRequested = false;
|
||||
const details = this.levels ? this.levels[level].details : null;
|
||||
if (details?.live) {
|
||||
// We can't afford to retry after a delay in a live scenario. Update the start position and return to IDLE.
|
||||
// Update the start position and return to IDLE to recover live start
|
||||
this.startPosition = -1;
|
||||
this.setStartPosition(details, 0);
|
||||
this.resetLoadingState();
|
||||
return true;
|
||||
} else {
|
||||
this.nextLoadPosition = this.startPosition;
|
||||
}
|
||||
this.nextLoadPosition = this.startPosition;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private updateLevelTiming(
|
||||
|
|
1
node_modules/hls.js/src/controller/buffer-controller.ts
generated
vendored
1
node_modules/hls.js/src/controller/buffer-controller.ts
generated
vendored
|
@ -420,6 +420,7 @@ export default class BufferController implements ComponentAPI {
|
|||
`[buffer-controller]: Failed ${hls.config.appendErrorMaxRetry} times to append segment in sourceBuffer`
|
||||
);
|
||||
event.fatal = true;
|
||||
hls.stopLoad();
|
||||
}
|
||||
}
|
||||
hls.trigger(Events.ERROR, event);
|
||||
|
|
35
node_modules/hls.js/src/controller/level-controller.ts
generated
vendored
35
node_modules/hls.js/src/controller/level-controller.ts
generated
vendored
|
@ -344,15 +344,21 @@ export default class LevelController extends BasePlaylistController {
|
|||
case ErrorDetails.KEY_LOAD_ERROR:
|
||||
case ErrorDetails.KEY_LOAD_TIMEOUT:
|
||||
if (data.frag) {
|
||||
const level = this._levels[data.frag.level];
|
||||
// Share fragment error count accross media options (main, audio, subs)
|
||||
// This allows for level based rendition switching when media option assets fail
|
||||
const variantLevelIndex =
|
||||
data.frag.type === PlaylistLevelType.MAIN
|
||||
? data.frag.level
|
||||
: this.currentLevelIndex;
|
||||
const level = this._levels[variantLevelIndex];
|
||||
// Set levelIndex when we're out of fragment retries
|
||||
if (level) {
|
||||
level.fragmentError++;
|
||||
if (level.fragmentError > this.hls.config.fragLoadingMaxRetry) {
|
||||
levelIndex = data.frag.level;
|
||||
levelIndex = variantLevelIndex;
|
||||
}
|
||||
} else {
|
||||
levelIndex = data.frag.level;
|
||||
levelIndex = variantLevelIndex;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -369,7 +375,7 @@ export default class LevelController extends BasePlaylistController {
|
|||
levelError = true;
|
||||
break;
|
||||
case ErrorDetails.REMUX_ALLOC_ERROR:
|
||||
levelIndex = data.level;
|
||||
levelIndex = data.level ?? this.currentLevelIndex;
|
||||
levelError = true;
|
||||
break;
|
||||
}
|
||||
|
@ -412,13 +418,20 @@ export default class LevelController extends BasePlaylistController {
|
|||
errorEvent.levelRetry = true;
|
||||
this.redundantFailover(levelIndex);
|
||||
} else if (this.manualLevelIndex === -1) {
|
||||
// Search for available level in auto level selection mode, cycling from highest to lowest bitrate
|
||||
const nextLevel =
|
||||
levelIndex === 0 ? this._levels.length - 1 : levelIndex - 1;
|
||||
if (
|
||||
this.currentLevelIndex !== nextLevel &&
|
||||
this._levels[nextLevel].loadError === 0
|
||||
) {
|
||||
// Search for next level to retry
|
||||
let nextLevel = -1;
|
||||
const levels = this._levels;
|
||||
for (let i = levels.length; i--; ) {
|
||||
const candidate = (i + this.currentLevelIndex) % levels.length;
|
||||
if (
|
||||
candidate !== this.currentLevelIndex &&
|
||||
levels[candidate].loadError === 0
|
||||
) {
|
||||
nextLevel = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nextLevel > -1 && this.currentLevelIndex !== nextLevel) {
|
||||
this.warn(`${errorDetails}: switch to ${nextLevel}`);
|
||||
errorEvent.levelRetry = true;
|
||||
this.hls.nextAutoLevel = nextLevel;
|
||||
|
|
35
node_modules/hls.js/src/controller/stream-controller.ts
generated
vendored
35
node_modules/hls.js/src/controller/stream-controller.ts
generated
vendored
|
@ -120,7 +120,7 @@ export default class StreamController
|
|||
// determine load level
|
||||
let startLevel = hls.startLevel;
|
||||
if (startLevel === -1) {
|
||||
if (hls.config.testBandwidth) {
|
||||
if (hls.config.testBandwidth && this.levels.length > 1) {
|
||||
// -1 : guess start Level by doing a bitrate test by loading first fragment of lowest quality level
|
||||
startLevel = 0;
|
||||
this.bitrateTest = true;
|
||||
|
@ -183,6 +183,7 @@ export default class StreamController
|
|||
// if current time is gt than retryDate, or if media seeking let's switch to IDLE state to retry loading
|
||||
if (!retryDate || now >= retryDate || this.media?.seeking) {
|
||||
this.log('retryDate reached, switch back to IDLE state');
|
||||
this.resetStartWhenNotLoaded(this.level);
|
||||
this.state = State.IDLE;
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +308,9 @@ export default class StreamController
|
|||
this.audioOnly && !this.altAudio
|
||||
? ElementaryStreamTypes.AUDIO
|
||||
: ElementaryStreamTypes.VIDEO;
|
||||
this.afterBufferFlushed(media, type, PlaylistLevelType.MAIN);
|
||||
if (media) {
|
||||
this.afterBufferFlushed(media, type, PlaylistLevelType.MAIN);
|
||||
}
|
||||
frag = this.getNextFragment(this.nextLoadPosition, levelDetails);
|
||||
}
|
||||
if (!frag) {
|
||||
|
@ -334,14 +337,10 @@ export default class StreamController
|
|||
// Check if fragment is not loaded
|
||||
const fragState = this.fragmentTracker.getState(frag);
|
||||
this.fragCurrent = frag;
|
||||
if (
|
||||
fragState === FragmentState.NOT_LOADED ||
|
||||
fragState === FragmentState.PARTIAL
|
||||
) {
|
||||
if (fragState === FragmentState.NOT_LOADED) {
|
||||
if (frag.sn === 'initSegment') {
|
||||
this._loadInitSegment(frag);
|
||||
} else if (this.bitrateTest) {
|
||||
frag.bitrateTest = true;
|
||||
this.log(
|
||||
`Fragment ${frag.sn} of level ${frag.level} is being downloaded to test bitrate and will not be buffered`
|
||||
);
|
||||
|
@ -509,7 +508,7 @@ export default class StreamController
|
|||
|
||||
protected onMediaDetaching() {
|
||||
const { media } = this;
|
||||
if (media) {
|
||||
if (media && this.onvplaying && this.onvseeked) {
|
||||
media.removeEventListener('playing', this.onvplaying);
|
||||
media.removeEventListener('seeked', this.onvseeked);
|
||||
this.onvplaying = this.onvseeked = null;
|
||||
|
@ -532,7 +531,7 @@ export default class StreamController
|
|||
const media = this.media;
|
||||
const currentTime = media ? media.currentTime : null;
|
||||
if (Number.isFinite(currentTime)) {
|
||||
this.log(`Media seeked to ${currentTime.toFixed(3)}`);
|
||||
this.log(`Media seeked to ${(currentTime as number).toFixed(3)}`);
|
||||
}
|
||||
|
||||
// tick to speed up FRAG_CHANGED triggering
|
||||
|
@ -915,13 +914,7 @@ export default class StreamController
|
|||
return;
|
||||
}
|
||||
|
||||
// Check combined buffer
|
||||
const buffered = BufferHelper.getBuffered(media);
|
||||
|
||||
if (!this.loadedmetadata && buffered.length) {
|
||||
this.loadedmetadata = true;
|
||||
this.seekToStartPos();
|
||||
} else {
|
||||
if (this.loadedmetadata || !BufferHelper.getBuffered(media).length) {
|
||||
// Resolve gaps using the main buffer, whose ranges are the intersections of the A/V sourcebuffers
|
||||
const activeFrag = this.state !== State.IDLE ? this.fragCurrent : null;
|
||||
gapController.poll(this.lastCurrentTime, activeFrag);
|
||||
|
@ -970,10 +963,12 @@ export default class StreamController
|
|||
|
||||
/**
|
||||
* Seeks to the set startPosition if not equal to the mediaElement's current time.
|
||||
* @private
|
||||
*/
|
||||
private seekToStartPos() {
|
||||
protected seekToStartPos() {
|
||||
const { media } = this;
|
||||
if (!media) {
|
||||
return;
|
||||
}
|
||||
const currentTime = media.currentTime;
|
||||
let startPosition = this.startPosition;
|
||||
// only adjust currentTime if different from startPosition or if startPosition not buffered
|
||||
|
@ -1019,6 +1014,7 @@ export default class StreamController
|
|||
}
|
||||
|
||||
private _loadBitrateTestFrag(frag: Fragment) {
|
||||
frag.bitrateTest = true;
|
||||
this._doFragLoad(frag).then((data) => {
|
||||
const { hls } = this;
|
||||
if (!data || hls.nextLoadLevel || this.fragContextChanged(frag)) {
|
||||
|
@ -1036,6 +1032,7 @@ export default class StreamController
|
|||
stats.buffering.end =
|
||||
self.performance.now();
|
||||
hls.trigger(Events.FRAG_LOADED, data as FragLoadedData);
|
||||
frag.bitrateTest = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1049,7 +1046,7 @@ export default class StreamController
|
|||
this.warn(
|
||||
`The loading context changed while buffering fragment ${chunkMeta.sn} of level ${chunkMeta.level}. This chunk will not be buffered.`
|
||||
);
|
||||
this.resetLiveStartWhenNotLoaded(chunkMeta.level);
|
||||
this.resetStartWhenNotLoaded(chunkMeta.level);
|
||||
return;
|
||||
}
|
||||
const { frag, part, level } = context;
|
||||
|
|
53
node_modules/hls.js/src/controller/subtitle-stream-controller.ts
generated
vendored
53
node_modules/hls.js/src/controller/subtitle-stream-controller.ts
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
import { Events } from '../events';
|
||||
import { BufferHelper } from '../utils/buffer-helper';
|
||||
import { Bufferable, BufferHelper } from '../utils/buffer-helper';
|
||||
import { findFragmentByPTS } from './fragment-finders';
|
||||
import { alignMediaPlaylistByPDT } from '../utils/discontinuities';
|
||||
import { addSliding } from './level-helper';
|
||||
|
@ -351,7 +351,7 @@ export class SubtitleStreamController
|
|||
const targetDuration = trackDetails.targetduration;
|
||||
const { config, media } = this;
|
||||
const bufferedInfo = BufferHelper.bufferedInfo(
|
||||
this.mediaBufferTimeRanges,
|
||||
this.tracksBuffered[this.currentTrackId] || [],
|
||||
media.currentTime - targetDuration,
|
||||
config.maxBufferHole
|
||||
);
|
||||
|
@ -397,12 +397,16 @@ export class SubtitleStreamController
|
|||
return;
|
||||
}
|
||||
|
||||
// only load if fragment is not loaded
|
||||
if (
|
||||
this.fragmentTracker.getState(foundFrag) !== FragmentState.NOT_LOADED
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (foundFrag.encrypted) {
|
||||
this.loadKey(foundFrag, trackDetails);
|
||||
} else if (
|
||||
this.fragmentTracker.getState(foundFrag) === FragmentState.NOT_LOADED
|
||||
) {
|
||||
// only load if fragment is not loaded
|
||||
} else {
|
||||
this.loadFragment(foundFrag, trackDetails, targetBufferTime);
|
||||
}
|
||||
}
|
||||
|
@ -421,7 +425,40 @@ export class SubtitleStreamController
|
|||
}
|
||||
}
|
||||
|
||||
get mediaBufferTimeRanges(): TimeRange[] {
|
||||
return this.tracksBuffered[this.currentTrackId] || [];
|
||||
get mediaBufferTimeRanges(): Bufferable {
|
||||
return new BufferableInstance(
|
||||
this.tracksBuffered[this.currentTrackId] || []
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BufferableInstance implements Bufferable {
|
||||
public readonly buffered: TimeRanges;
|
||||
|
||||
constructor(timeranges: TimeRange[]) {
|
||||
const getRange = (
|
||||
name: 'start' | 'end',
|
||||
index: number,
|
||||
length: number
|
||||
): number => {
|
||||
index = index >>> 0;
|
||||
if (index > length - 1) {
|
||||
throw new DOMException(
|
||||
`Failed to execute '${name}' on 'TimeRanges': The index provided (${index}) is greater than the maximum bound (${length})`
|
||||
);
|
||||
}
|
||||
return timeranges[index][name];
|
||||
};
|
||||
this.buffered = {
|
||||
get length() {
|
||||
return timeranges.length;
|
||||
},
|
||||
end(index: number): number {
|
||||
return getRange('end', index, timeranges.length);
|
||||
},
|
||||
start(index: number): number {
|
||||
return getRange('start', index, timeranges.length);
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
2
node_modules/hls.js/src/controller/timeline-controller.ts
generated
vendored
2
node_modules/hls.js/src/controller/timeline-controller.ts
generated
vendored
|
@ -745,7 +745,7 @@ function newVTTCCs(): VTTCCs {
|
|||
0: {
|
||||
start: 0,
|
||||
prevCC: -1,
|
||||
new: false,
|
||||
new: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
1
node_modules/hls.js/src/demux/aacdemuxer.ts
generated
vendored
1
node_modules/hls.js/src/demux/aacdemuxer.ts
generated
vendored
|
@ -11,7 +11,6 @@ import type { HlsConfig } from '../config';
|
|||
class AACDemuxer extends BaseAudioDemuxer {
|
||||
private readonly observer: HlsEventEmitter;
|
||||
private readonly config: HlsConfig;
|
||||
static readonly minProbeByteLength: number = 9;
|
||||
|
||||
constructor(observer, config) {
|
||||
super();
|
||||
|
|
2
node_modules/hls.js/src/demux/mp3demuxer.ts
generated
vendored
2
node_modules/hls.js/src/demux/mp3demuxer.ts
generated
vendored
|
@ -7,8 +7,6 @@ import { logger } from '../utils/logger';
|
|||
import * as MpegAudio from './mpegaudio';
|
||||
|
||||
class MP3Demuxer extends BaseAudioDemuxer {
|
||||
static readonly minProbeByteLength: number = 4;
|
||||
|
||||
resetInitSegment(
|
||||
initSegment: Uint8Array | undefined,
|
||||
audioCodec: string | undefined,
|
||||
|
|
1
node_modules/hls.js/src/demux/mp4demuxer.ts
generated
vendored
1
node_modules/hls.js/src/demux/mp4demuxer.ts
generated
vendored
|
@ -27,7 +27,6 @@ import type { HlsConfig } from '../config';
|
|||
const emsgSchemePattern = /\/emsg[-/]ID3/i;
|
||||
|
||||
class MP4Demuxer implements Demuxer {
|
||||
static readonly minProbeByteLength = 1024;
|
||||
private remainderData: Uint8Array | null = null;
|
||||
private timeOffset: number = 0;
|
||||
private config: HlsConfig;
|
||||
|
|
92
node_modules/hls.js/src/demux/transmuxer.ts
generated
vendored
92
node_modules/hls.js/src/demux/transmuxer.ts
generated
vendored
|
@ -8,8 +8,6 @@ import TSDemuxer, { TypeSupported } from '../demux/tsdemuxer';
|
|||
import MP3Demuxer from '../demux/mp3demuxer';
|
||||
import MP4Remuxer from '../remux/mp4-remuxer';
|
||||
import PassThroughRemuxer from '../remux/passthrough-remuxer';
|
||||
import ChunkCache from './chunk-cache';
|
||||
import { appendUint8Array } from '../utils/mp4-tools';
|
||||
import { logger } from '../utils/logger';
|
||||
import type { Demuxer, DemuxerResult, KeyData } from '../types/demuxer';
|
||||
import type { Remuxer } from '../types/remuxer';
|
||||
|
@ -40,11 +38,6 @@ const muxConfig: MuxConfig[] = [
|
|||
{ demux: MP3Demuxer, remux: MP4Remuxer },
|
||||
];
|
||||
|
||||
let minProbeByteLength = 1024;
|
||||
muxConfig.forEach(({ demux }) => {
|
||||
minProbeByteLength = Math.max(minProbeByteLength, demux.minProbeByteLength);
|
||||
});
|
||||
|
||||
export default class Transmuxer {
|
||||
private observer: HlsEventEmitter;
|
||||
private typeSupported: TypeSupported;
|
||||
|
@ -58,7 +51,6 @@ export default class Transmuxer {
|
|||
private decryptionPromise: Promise<TransmuxerResult> | null = null;
|
||||
private transmuxConfig!: TransmuxConfig;
|
||||
private currentTransmuxState!: TransmuxState;
|
||||
private cache: ChunkCache = new ChunkCache();
|
||||
|
||||
constructor(
|
||||
observer: HlsEventEmitter,
|
||||
|
@ -91,11 +83,40 @@ export default class Transmuxer {
|
|||
stats.executeStart = now();
|
||||
|
||||
let uintData: Uint8Array = new Uint8Array(data);
|
||||
const { cache, config, currentTransmuxState, transmuxConfig } = this;
|
||||
const { config, currentTransmuxState, transmuxConfig } = this;
|
||||
if (state) {
|
||||
this.currentTransmuxState = state;
|
||||
}
|
||||
|
||||
const {
|
||||
contiguous,
|
||||
discontinuity,
|
||||
trackSwitch,
|
||||
accurateTimeOffset,
|
||||
timeOffset,
|
||||
initSegmentChange,
|
||||
} = state || currentTransmuxState;
|
||||
const {
|
||||
audioCodec,
|
||||
videoCodec,
|
||||
defaultInitPts,
|
||||
duration,
|
||||
initSegmentData,
|
||||
} = transmuxConfig;
|
||||
|
||||
// Reset muxers before probing to ensure that their state is clean, even if flushing occurs before a successful probe
|
||||
if (discontinuity || trackSwitch || initSegmentChange) {
|
||||
this.resetInitSegment(initSegmentData, audioCodec, videoCodec, duration);
|
||||
}
|
||||
|
||||
if (discontinuity || initSegmentChange) {
|
||||
this.resetInitialTimestamp(defaultInitPts);
|
||||
}
|
||||
|
||||
if (!contiguous) {
|
||||
this.resetContiguity();
|
||||
}
|
||||
|
||||
const keyData = getEncryptionType(uintData, decryptdata);
|
||||
if (keyData && keyData.method === 'AES-128') {
|
||||
const decrypter = this.getDecrypter();
|
||||
|
@ -131,40 +152,7 @@ export default class Transmuxer {
|
|||
}
|
||||
}
|
||||
|
||||
const {
|
||||
contiguous,
|
||||
discontinuity,
|
||||
trackSwitch,
|
||||
accurateTimeOffset,
|
||||
timeOffset,
|
||||
initSegmentChange,
|
||||
} = state || currentTransmuxState;
|
||||
const {
|
||||
audioCodec,
|
||||
videoCodec,
|
||||
defaultInitPts,
|
||||
duration,
|
||||
initSegmentData,
|
||||
} = transmuxConfig;
|
||||
|
||||
// Reset muxers before probing to ensure that their state is clean, even if flushing occurs before a successful probe
|
||||
if (discontinuity || trackSwitch || initSegmentChange) {
|
||||
this.resetInitSegment(initSegmentData, audioCodec, videoCodec, duration);
|
||||
}
|
||||
|
||||
if (discontinuity || initSegmentChange) {
|
||||
this.resetInitialTimestamp(defaultInitPts);
|
||||
}
|
||||
|
||||
if (!contiguous) {
|
||||
this.resetContiguity();
|
||||
}
|
||||
|
||||
if (this.needsProbing(uintData, discontinuity, trackSwitch)) {
|
||||
if (cache.dataLength) {
|
||||
const cachedData = cache.flush();
|
||||
uintData = appendUint8Array(cachedData, uintData);
|
||||
}
|
||||
this.configureTransmuxer(uintData, transmuxConfig);
|
||||
}
|
||||
|
||||
|
@ -192,7 +180,7 @@ export default class Transmuxer {
|
|||
const stats = chunkMeta.transmuxing;
|
||||
stats.executeStart = now();
|
||||
|
||||
const { decrypter, cache, currentTransmuxState, decryptionPromise } = this;
|
||||
const { decrypter, currentTransmuxState, decryptionPromise } = this;
|
||||
|
||||
if (decryptionPromise) {
|
||||
// Upon resolution, the decryption promise calls push() and returns its TransmuxerResult up the stack. Therefore
|
||||
|
@ -217,19 +205,15 @@ export default class Transmuxer {
|
|||
}
|
||||
}
|
||||
|
||||
const bytesSeen = cache.dataLength;
|
||||
cache.reset();
|
||||
const { demuxer, remuxer } = this;
|
||||
if (!demuxer || !remuxer) {
|
||||
// If probing failed, and each demuxer saw enough bytes to be able to probe, then Hls.js has been given content its not able to handle
|
||||
if (bytesSeen >= minProbeByteLength) {
|
||||
this.observer.emit(Events.ERROR, Events.ERROR, {
|
||||
type: ErrorTypes.MEDIA_ERROR,
|
||||
details: ErrorDetails.FRAG_PARSING_ERROR,
|
||||
fatal: true,
|
||||
reason: 'no demux matching with content found',
|
||||
});
|
||||
}
|
||||
// If probing failed, then Hls.js has been given content its not able to handle
|
||||
this.observer.emit(Events.ERROR, Events.ERROR, {
|
||||
type: ErrorTypes.MEDIA_ERROR,
|
||||
details: ErrorDetails.FRAG_PARSING_ERROR,
|
||||
fatal: true,
|
||||
reason: 'no demux matching with content found',
|
||||
});
|
||||
stats.executeEnd = now();
|
||||
return [emptyResult(chunkMeta)];
|
||||
}
|
||||
|
|
54
node_modules/hls.js/src/demux/tsdemuxer.ts
generated
vendored
54
node_modules/hls.js/src/demux/tsdemuxer.ts
generated
vendored
|
@ -57,8 +57,6 @@ export interface TypeSupported {
|
|||
}
|
||||
|
||||
class TSDemuxer implements Demuxer {
|
||||
static readonly minProbeByteLength = 188;
|
||||
|
||||
private readonly observer: HlsEventEmitter;
|
||||
private readonly config: HlsConfig;
|
||||
private typeSupported: TypeSupported;
|
||||
|
@ -89,37 +87,8 @@ class TSDemuxer implements Demuxer {
|
|||
}
|
||||
|
||||
static probe(data: Uint8Array) {
|
||||
const syncOffset = TSDemuxer.syncOffset(data);
|
||||
if (syncOffset < 0) {
|
||||
return false;
|
||||
} else {
|
||||
if (syncOffset) {
|
||||
logger.warn(
|
||||
`MPEG2-TS detected but first sync word found @ offset ${syncOffset}, junk ahead ?`
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static syncOffset(data: Uint8Array) {
|
||||
// scan 1000 first bytes
|
||||
const scanwindow = Math.min(1000, data.length - 3 * 188);
|
||||
let i = 0;
|
||||
while (i < scanwindow) {
|
||||
// a TS fragment should contain at least 3 TS packets, a PAT, a PMT, and one PID, each starting with 0x47
|
||||
if (
|
||||
data[i] === 0x47 &&
|
||||
data[i + 188] === 0x47 &&
|
||||
data[i + 2 * 188] === 0x47
|
||||
) {
|
||||
return i;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
// a TS init segment should contain at least 2 TS packets: PAT and PMT, each starting with 0x47
|
||||
return data[0] === 0x47 && data[188] === 0x47;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,6 +141,7 @@ class TSDemuxer implements Demuxer {
|
|||
// flush any partial content
|
||||
this.aacOverFlow = null;
|
||||
this.avcSample = null;
|
||||
this.remainderData = null;
|
||||
this.audioCodec = audioCodec;
|
||||
this.videoCodec = videoCodec;
|
||||
this._duration = trackDuration;
|
||||
|
@ -216,7 +186,7 @@ class TSDemuxer implements Demuxer {
|
|||
let id3Id = id3Track.pid;
|
||||
let audioData = audioTrack.pesData;
|
||||
let id3Data = id3Track.pesData;
|
||||
let unknownPIDs = false;
|
||||
let unknownPID: number | null = null;
|
||||
let pmtParsed = this.pmtParsed;
|
||||
let pmtId = this._pmtId;
|
||||
|
||||
|
@ -237,9 +207,7 @@ class TSDemuxer implements Demuxer {
|
|||
};
|
||||
}
|
||||
|
||||
const syncOffset = Math.max(0, TSDemuxer.syncOffset(data));
|
||||
|
||||
len -= (len + syncOffset) % 188;
|
||||
len -= len % 188;
|
||||
if (len < data.byteLength && !flush) {
|
||||
this.remainderData = new Uint8Array(
|
||||
data.buffer,
|
||||
|
@ -250,7 +218,7 @@ class TSDemuxer implements Demuxer {
|
|||
|
||||
// loop through TS packets
|
||||
let tsPacketErrors = 0;
|
||||
for (let start = syncOffset; start < len; start += 188) {
|
||||
for (let start = 0; start < len; start += 188) {
|
||||
if (data[start] === 0x47) {
|
||||
const stt = !!(data[start + 1] & 0x40);
|
||||
// pid is a 13-bit field starting at the last bit of TS[1]
|
||||
|
@ -354,11 +322,9 @@ class TSDemuxer implements Demuxer {
|
|||
id3Track.pid = id3Id;
|
||||
}
|
||||
|
||||
if (unknownPIDs && !pmtParsed) {
|
||||
logger.log('reparse from beginning');
|
||||
unknownPIDs = false;
|
||||
// we set it to -188, the += 188 in the for loop will reset start to 0
|
||||
start = syncOffset - 188;
|
||||
if (unknownPID !== null && !pmtParsed) {
|
||||
logger.log(`unknown PID '${unknownPID}' in TS found`);
|
||||
unknownPID = null;
|
||||
}
|
||||
pmtParsed = this.pmtParsed = true;
|
||||
break;
|
||||
|
@ -367,7 +333,7 @@ class TSDemuxer implements Demuxer {
|
|||
case 0x1fff:
|
||||
break;
|
||||
default:
|
||||
unknownPIDs = true;
|
||||
unknownPID = pid;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
9
node_modules/hls.js/src/hls.ts
generated
vendored
9
node_modules/hls.js/src/hls.ts
generated
vendored
|
@ -140,12 +140,15 @@ export default class Hls implements HlsEventEmitter {
|
|||
// fpsController uses streamController to switch when frames are being dropped
|
||||
fpsController.setStreamController(streamController);
|
||||
|
||||
const networkControllers = [levelController, streamController];
|
||||
const networkControllers = [
|
||||
playListLoader,
|
||||
keyLoader,
|
||||
levelController,
|
||||
streamController,
|
||||
];
|
||||
|
||||
this.networkControllers = networkControllers;
|
||||
const coreComponents = [
|
||||
playListLoader,
|
||||
keyLoader,
|
||||
abrController,
|
||||
bufferController,
|
||||
capLevelController,
|
||||
|
|
24
node_modules/hls.js/src/loader/key-loader.ts
generated
vendored
24
node_modules/hls.js/src/loader/key-loader.ts
generated
vendored
|
@ -15,14 +15,14 @@ import {
|
|||
Loader,
|
||||
FragmentLoaderContext,
|
||||
} from '../types/loader';
|
||||
import type { ComponentAPI } from '../types/component-api';
|
||||
import type { NetworkComponentAPI } from '../types/component-api';
|
||||
import type { KeyLoadingData } from '../types/events';
|
||||
|
||||
interface KeyLoaderContext extends LoaderContext {
|
||||
frag: Fragment;
|
||||
}
|
||||
|
||||
export default class KeyLoader implements ComponentAPI {
|
||||
export default class KeyLoader implements NetworkComponentAPI {
|
||||
private hls: Hls;
|
||||
public loaders = {};
|
||||
public decryptkey: Uint8Array | null = null;
|
||||
|
@ -31,19 +31,24 @@ export default class KeyLoader implements ComponentAPI {
|
|||
constructor(hls: Hls) {
|
||||
this.hls = hls;
|
||||
|
||||
this._registerListeners();
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
private _registerListeners() {
|
||||
public startLoad(startPosition: number): void {}
|
||||
|
||||
public stopLoad(): void {
|
||||
this.destroyInternalLoaders();
|
||||
}
|
||||
|
||||
private registerListeners() {
|
||||
this.hls.on(Events.KEY_LOADING, this.onKeyLoading, this);
|
||||
}
|
||||
|
||||
private _unregisterListeners() {
|
||||
private unregisterListeners() {
|
||||
this.hls.off(Events.KEY_LOADING, this.onKeyLoading);
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
this._unregisterListeners();
|
||||
private destroyInternalLoaders(): void {
|
||||
for (const loaderName in this.loaders) {
|
||||
const loader = this.loaders[loaderName];
|
||||
if (loader) {
|
||||
|
@ -53,6 +58,11 @@ export default class KeyLoader implements ComponentAPI {
|
|||
this.loaders = {};
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
this.unregisterListeners();
|
||||
this.destroyInternalLoaders();
|
||||
}
|
||||
|
||||
onKeyLoading(event: Events.KEY_LOADING, data: KeyLoadingData) {
|
||||
const { frag } = data;
|
||||
const type = frag.type;
|
||||
|
|
9
node_modules/hls.js/src/loader/playlist-loader.ts
generated
vendored
9
node_modules/hls.js/src/loader/playlist-loader.ts
generated
vendored
|
@ -33,6 +33,7 @@ import type {
|
|||
ManifestLoadingData,
|
||||
TrackLoadingData,
|
||||
} from '../types/events';
|
||||
import { NetworkComponentAPI } from '../types/component-api';
|
||||
|
||||
function mapContextToLevelType(
|
||||
context: PlaylistLoaderContext
|
||||
|
@ -63,7 +64,7 @@ function getResponseUrl(
|
|||
return url;
|
||||
}
|
||||
|
||||
class PlaylistLoader {
|
||||
class PlaylistLoader implements NetworkComponentAPI {
|
||||
private readonly hls: Hls;
|
||||
private readonly loaders: {
|
||||
[key: string]: Loader<LoaderContext>;
|
||||
|
@ -74,6 +75,12 @@ class PlaylistLoader {
|
|||
this.registerListeners();
|
||||
}
|
||||
|
||||
public startLoad(startPosition: number): void {}
|
||||
|
||||
public stopLoad(): void {
|
||||
this.destroyInternalLoaders();
|
||||
}
|
||||
|
||||
private registerListeners() {
|
||||
const { hls } = this;
|
||||
hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this);
|
||||
|
|
2
node_modules/hls.js/src/remux/mp4-generator.ts
generated
vendored
2
node_modules/hls.js/src/remux/mp4-generator.ts
generated
vendored
|
@ -1084,7 +1084,7 @@ class MP4 {
|
|||
offset += 8 + arraylen;
|
||||
array.set(
|
||||
[
|
||||
0x00, // version 0
|
||||
track.type === 'video' ? 0x01 : 0x00, // version 1 for video with signed-int sample_composition_time_offset
|
||||
0x00,
|
||||
0x0f,
|
||||
0x01, // flags
|
||||
|
|
124
node_modules/hls.js/src/remux/mp4-remuxer.ts
generated
vendored
124
node_modules/hls.js/src/remux/mp4-remuxer.ts
generated
vendored
|
@ -33,7 +33,6 @@ const MPEG_AUDIO_SAMPLE_PER_FRAME = 1152;
|
|||
|
||||
let chromeVersion: number | null = null;
|
||||
let safariWebkitVersion: number | null = null;
|
||||
let requiresPositiveDts: boolean = false;
|
||||
|
||||
export default class MP4Remuxer implements Remuxer {
|
||||
private observer: HlsEventEmitter;
|
||||
|
@ -68,10 +67,6 @@ export default class MP4Remuxer implements Remuxer {
|
|||
const result = navigator.userAgent.match(/Safari\/(\d+)/i);
|
||||
safariWebkitVersion = result ? parseInt(result[1]) : 0;
|
||||
}
|
||||
requiresPositiveDts = !(
|
||||
(!!chromeVersion && chromeVersion >= 75) ||
|
||||
(!!safariWebkitVersion && safariWebkitVersion >= 600)
|
||||
);
|
||||
}
|
||||
|
||||
destroy() {}
|
||||
|
@ -392,7 +387,6 @@ export default class MP4Remuxer implements Remuxer {
|
|||
let lastDTS;
|
||||
let minPTS: number = Number.POSITIVE_INFINITY;
|
||||
let maxPTS: number = Number.NEGATIVE_INFINITY;
|
||||
let ptsDtsShift = 0;
|
||||
let sortSamples = false;
|
||||
|
||||
// if parsed fragment is contiguous with last one, let's use last DTS value as reference
|
||||
|
@ -411,13 +405,6 @@ export default class MP4Remuxer implements Remuxer {
|
|||
const sample = inputSamples[i];
|
||||
sample.pts = normalizePts(sample.pts - initPTS, nextAvcDts);
|
||||
sample.dts = normalizePts(sample.dts - initPTS, nextAvcDts);
|
||||
if (sample.dts > sample.pts) {
|
||||
const PTS_DTS_SHIFT_TOLERANCE_90KHZ = 90000 * 0.2;
|
||||
ptsDtsShift = Math.max(
|
||||
Math.min(ptsDtsShift, sample.pts - sample.dts),
|
||||
-1 * PTS_DTS_SHIFT_TOLERANCE_90KHZ
|
||||
);
|
||||
}
|
||||
if (sample.dts < inputSamples[i > 0 ? i - 1 : i].dts) {
|
||||
sortSamples = true;
|
||||
}
|
||||
|
@ -436,49 +423,13 @@ export default class MP4Remuxer implements Remuxer {
|
|||
firstDTS = inputSamples[0].dts;
|
||||
lastDTS = inputSamples[inputSamples.length - 1].dts;
|
||||
|
||||
// on Safari let's signal the same sample duration for all samples
|
||||
// sample duration (as expected by trun MP4 boxes), should be the delta between sample DTS
|
||||
// Sample duration (as expected by trun MP4 boxes), should be the delta between sample DTS
|
||||
// set this constant duration as being the avg delta between consecutive DTS.
|
||||
const inputDuration = lastDTS - firstDTS;
|
||||
const averageSampleDuration = inputDuration
|
||||
? Math.round(inputDuration / (nbSamples - 1))
|
||||
: mp4SampleDuration || track.inputTimeScale / 30;
|
||||
|
||||
// handle broken streams with PTS < DTS, tolerance up 0.2 seconds
|
||||
if (ptsDtsShift < 0) {
|
||||
if (ptsDtsShift < averageSampleDuration * -2) {
|
||||
// Fix for "CNN special report, with CC" in test-streams (including Safari browser)
|
||||
// With large PTS < DTS errors such as this, we want to correct CTS while maintaining increasing DTS values
|
||||
logger.warn(
|
||||
`PTS < DTS detected in video samples, offsetting DTS from PTS by ${toMsFromMpegTsClock(
|
||||
-averageSampleDuration,
|
||||
true
|
||||
)} ms`
|
||||
);
|
||||
let lastDts = ptsDtsShift;
|
||||
for (let i = 0; i < nbSamples; i++) {
|
||||
inputSamples[i].dts = lastDts = Math.max(
|
||||
lastDts,
|
||||
inputSamples[i].pts - averageSampleDuration
|
||||
);
|
||||
inputSamples[i].pts = Math.max(lastDts, inputSamples[i].pts);
|
||||
}
|
||||
} else {
|
||||
// Fix for "Custom IV with bad PTS DTS" in test-streams
|
||||
// With smaller PTS < DTS errors we can simply move all DTS back. This increases CTS without causing buffer gaps or decode errors in Safari
|
||||
logger.warn(
|
||||
`PTS < DTS detected in video samples, shifting DTS by ${toMsFromMpegTsClock(
|
||||
ptsDtsShift,
|
||||
true
|
||||
)} ms to overcome this issue`
|
||||
);
|
||||
for (let i = 0; i < nbSamples; i++) {
|
||||
inputSamples[i].dts = inputSamples[i].dts + ptsDtsShift;
|
||||
}
|
||||
}
|
||||
firstDTS = inputSamples[0].dts;
|
||||
}
|
||||
|
||||
// if fragment are contiguous, detect hole/overlapping between fragments
|
||||
if (contiguous) {
|
||||
// check timestamp continuity across consecutive fragments (this is to remove inter-fragment gap/hole)
|
||||
|
@ -517,9 +468,8 @@ export default class MP4Remuxer implements Remuxer {
|
|||
}
|
||||
}
|
||||
|
||||
if (requiresPositiveDts) {
|
||||
firstDTS = Math.max(0, firstDTS);
|
||||
}
|
||||
firstDTS = Math.max(0, firstDTS);
|
||||
|
||||
let nbNalu = 0;
|
||||
let naluLen = 0;
|
||||
for (let i = 0; i < nbSamples; i++) {
|
||||
|
@ -536,11 +486,9 @@ export default class MP4Remuxer implements Remuxer {
|
|||
nbNalu += nbUnits;
|
||||
sample.length = sampleLen;
|
||||
|
||||
// normalize PTS/DTS
|
||||
// ensure sample monotonic DTS
|
||||
sample.dts = Math.max(sample.dts, firstDTS);
|
||||
// ensure that computed value is greater or equal than sample DTS
|
||||
sample.pts = Math.max(sample.pts, sample.dts, 0);
|
||||
|
||||
minPTS = Math.min(sample.pts, minPTS);
|
||||
maxPTS = Math.max(sample.pts, maxPTS);
|
||||
}
|
||||
|
@ -567,6 +515,10 @@ export default class MP4Remuxer implements Remuxer {
|
|||
mdat.set(MP4.types.mdat, 4);
|
||||
|
||||
let stretchedLastFrame = false;
|
||||
let minDtsDelta = Number.POSITIVE_INFINITY;
|
||||
let minPtsDelta = Number.POSITIVE_INFINITY;
|
||||
let maxDtsDelta = Number.NEGATIVE_INFINITY;
|
||||
let maxPtsDelta = Number.NEGATIVE_INFINITY;
|
||||
for (let i = 0; i < nbSamples; i++) {
|
||||
const avcSample = inputSamples[i];
|
||||
const avcSampleUnits = avcSample.units;
|
||||
|
@ -584,14 +536,20 @@ export default class MP4Remuxer implements Remuxer {
|
|||
}
|
||||
|
||||
// expected sample duration is the Decoding Timestamp diff of consecutive samples
|
||||
let ptsDelta;
|
||||
if (i < nbSamples - 1) {
|
||||
mp4SampleDuration = inputSamples[i + 1].dts - avcSample.dts;
|
||||
ptsDelta = inputSamples[i + 1].pts - avcSample.pts;
|
||||
} else {
|
||||
const config = this.config;
|
||||
const lastFrameDuration =
|
||||
i > 0
|
||||
? avcSample.dts - inputSamples[i - 1].dts
|
||||
: averageSampleDuration;
|
||||
ptsDelta =
|
||||
i > 0
|
||||
? avcSample.pts - inputSamples[i - 1].pts
|
||||
: averageSampleDuration;
|
||||
if (config.stretchShortVideoTrack && this.nextAudioPts !== null) {
|
||||
// In some cases, a segment's audio track duration may exceed the video track duration.
|
||||
// Since we've already remuxed audio, and we know how long the audio track is, we look to
|
||||
|
@ -627,6 +585,10 @@ export default class MP4Remuxer implements Remuxer {
|
|||
}
|
||||
}
|
||||
const compositionTimeOffset = Math.round(avcSample.pts - avcSample.dts);
|
||||
minDtsDelta = Math.min(minDtsDelta, mp4SampleDuration);
|
||||
maxDtsDelta = Math.max(maxDtsDelta, mp4SampleDuration);
|
||||
minPtsDelta = Math.min(minPtsDelta, ptsDelta);
|
||||
maxPtsDelta = Math.max(maxPtsDelta, ptsDelta);
|
||||
|
||||
outputSamples.push(
|
||||
new Mp4Sample(
|
||||
|
@ -638,12 +600,43 @@ export default class MP4Remuxer implements Remuxer {
|
|||
);
|
||||
}
|
||||
|
||||
if (outputSamples.length && chromeVersion && chromeVersion < 70) {
|
||||
// Chrome workaround, mark first sample as being a Random Access Point (keyframe) to avoid sourcebuffer append issue
|
||||
// https://code.google.com/p/chromium/issues/detail?id=229412
|
||||
const flags = outputSamples[0].flags;
|
||||
flags.dependsOn = 2;
|
||||
flags.isNonSync = 0;
|
||||
if (outputSamples.length) {
|
||||
if (chromeVersion) {
|
||||
if (chromeVersion < 70) {
|
||||
// Chrome workaround, mark first sample as being a Random Access Point (keyframe) to avoid sourcebuffer append issue
|
||||
// https://code.google.com/p/chromium/issues/detail?id=229412
|
||||
const flags = outputSamples[0].flags;
|
||||
flags.dependsOn = 2;
|
||||
flags.isNonSync = 0;
|
||||
}
|
||||
} else if (safariWebkitVersion) {
|
||||
// Fix for "CNN special report, with CC" in test-streams (Safari browser only)
|
||||
// Ignore DTS when frame durations are irregular. Safari MSE does not handle this leading to gaps.
|
||||
if (
|
||||
maxPtsDelta - minPtsDelta < maxDtsDelta - minDtsDelta &&
|
||||
averageSampleDuration / maxDtsDelta < 0.025 &&
|
||||
outputSamples[0].cts === 0
|
||||
) {
|
||||
logger.warn(
|
||||
'Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.'
|
||||
);
|
||||
let dts = firstDTS;
|
||||
for (let i = 0, len = outputSamples.length; i < len; i++) {
|
||||
const nextDts = dts + outputSamples[i].duration;
|
||||
const pts = dts + outputSamples[i].cts;
|
||||
if (i < len - 1) {
|
||||
const nextPts = nextDts + outputSamples[i + 1].cts;
|
||||
outputSamples[i].duration = nextPts - pts;
|
||||
} else {
|
||||
outputSamples[i].duration = i
|
||||
? outputSamples[i - 1].duration
|
||||
: averageSampleDuration;
|
||||
}
|
||||
outputSamples[i].cts = 0;
|
||||
dts = nextDts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.assert(
|
||||
|
@ -1096,7 +1089,12 @@ class Mp4Sample {
|
|||
public cts: number;
|
||||
public flags: Mp4SampleFlags;
|
||||
|
||||
constructor(isKeyframe: boolean, duration, size, cts) {
|
||||
constructor(
|
||||
isKeyframe: boolean,
|
||||
duration: number,
|
||||
size: number,
|
||||
cts: number
|
||||
) {
|
||||
this.duration = duration;
|
||||
this.size = size;
|
||||
this.cts = cts;
|
||||
|
|
37
node_modules/hls.js/src/remux/passthrough-remuxer.ts
generated
vendored
37
node_modules/hls.js/src/remux/passthrough-remuxer.ts
generated
vendored
|
@ -32,17 +32,17 @@ class PassThroughRemuxer implements Remuxer {
|
|||
private initData?: InitData;
|
||||
private initPTS?: number;
|
||||
private initTracks?: TrackSet;
|
||||
private lastEndDTS: number | null = null;
|
||||
private lastEndTime: number | null = null;
|
||||
|
||||
public destroy() {}
|
||||
|
||||
public resetTimeStamp(defaultInitPTS) {
|
||||
this.initPTS = defaultInitPTS;
|
||||
this.lastEndDTS = null;
|
||||
this.lastEndTime = null;
|
||||
}
|
||||
|
||||
public resetNextTimestamp() {
|
||||
this.lastEndDTS = null;
|
||||
this.lastEndTime = null;
|
||||
}
|
||||
|
||||
public resetInitSegment(
|
||||
|
@ -117,7 +117,7 @@ class PassThroughRemuxer implements Remuxer {
|
|||
textTrack: DemuxedUserdataTrack,
|
||||
timeOffset: number
|
||||
): RemuxerResult {
|
||||
let { initPTS, lastEndDTS } = this;
|
||||
let { initPTS, lastEndTime } = this;
|
||||
const result: RemuxerResult = {
|
||||
audio: undefined,
|
||||
video: undefined,
|
||||
|
@ -129,8 +129,8 @@ class PassThroughRemuxer implements Remuxer {
|
|||
// If we haven't yet set a lastEndDTS, or it was reset, set it to the provided timeOffset. We want to use the
|
||||
// lastEndDTS over timeOffset whenever possible; during progressive playback, the media source will not update
|
||||
// the media duration (which is what timeOffset is provided as) before we need to process the next chunk.
|
||||
if (!Number.isFinite(lastEndDTS!)) {
|
||||
lastEndDTS = this.lastEndDTS = timeOffset || 0;
|
||||
if (!Number.isFinite(lastEndTime!)) {
|
||||
lastEndTime = this.lastEndTime = timeOffset || 0;
|
||||
}
|
||||
|
||||
// The binary segment data is added to the videoTrack in the mp4demuxer. We don't check to see if the data is only
|
||||
|
@ -159,20 +159,20 @@ class PassThroughRemuxer implements Remuxer {
|
|||
this.emitInitSegment = false;
|
||||
}
|
||||
|
||||
const startDTS = getStartDTS(initData, data);
|
||||
if (!Number.isFinite(initPTS!)) {
|
||||
this.initPTS =
|
||||
initSegment.initPTS =
|
||||
initPTS =
|
||||
computeInitPTS(initData, data, lastEndDTS);
|
||||
this.initPTS = initSegment.initPTS = initPTS = startDTS - timeOffset;
|
||||
}
|
||||
|
||||
const duration = getDuration(data, initData);
|
||||
const startDTS = lastEndDTS as number;
|
||||
const endDTS = duration + startDTS;
|
||||
const startTime = audioTrack
|
||||
? startDTS - (initPTS as number)
|
||||
: (lastEndTime as number);
|
||||
const endTime = startTime + duration;
|
||||
offsetStartDTS(initData, data, initPTS as number);
|
||||
|
||||
if (duration > 0) {
|
||||
this.lastEndDTS = endDTS;
|
||||
this.lastEndTime = endTime;
|
||||
} else {
|
||||
logger.warn('Duration parsed from mp4 should be greater than zero');
|
||||
this.resetNextTimestamp();
|
||||
|
@ -192,10 +192,10 @@ class PassThroughRemuxer implements Remuxer {
|
|||
|
||||
const track: RemuxedTrack = {
|
||||
data1: data,
|
||||
startPTS: startDTS,
|
||||
startDTS,
|
||||
endPTS: endDTS,
|
||||
endDTS,
|
||||
startPTS: startTime,
|
||||
startDTS: startTime,
|
||||
endPTS: endTime,
|
||||
endDTS: endTime,
|
||||
type,
|
||||
hasAudio,
|
||||
hasVideo,
|
||||
|
@ -226,9 +226,6 @@ class PassThroughRemuxer implements Remuxer {
|
|||
}
|
||||
}
|
||||
|
||||
const computeInitPTS = (initData, data, timeOffset) =>
|
||||
getStartDTS(initData, data) - timeOffset;
|
||||
|
||||
function getParsedTrackCodec(
|
||||
track: InitDataTrack | undefined,
|
||||
type: ElementaryStreamTypes.AUDIO | ElementaryStreamTypes.VIDEO
|
||||
|
|
7
node_modules/inputmask/LICENSE.txt
generated
vendored
Normal file
7
node_modules/inputmask/LICENSE.txt
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
Copyright (c) 2010 - 2018 Robin Herbots
|
||||
|
||||
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.
|
1279
node_modules/inputmask/README.md
generated
vendored
Normal file
1279
node_modules/inputmask/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
6
node_modules/inputmask/bundle.js
generated
vendored
Normal file
6
node_modules/inputmask/bundle.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
import "./lib/extensions/inputmask.extensions";
|
||||
import "./lib/extensions/inputmask.date.extensions";
|
||||
import "./lib/extensions/inputmask.numeric.extensions";
|
||||
import "./lib/inputmaskElement";
|
||||
import Inputmask from "./lib/inputmask";
|
||||
export default Inputmask;
|
26
node_modules/inputmask/dist/bindings/inputmask.binding.js
generated
vendored
Normal file
26
node_modules/inputmask/dist/bindings/inputmask.binding.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
Input Mask plugin binding
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
factory(jQuery, window.Inputmask, window);
|
||||
}
|
||||
(function ($, Inputmask, window) {
|
||||
$(window.document).ajaxComplete(function (event, xmlHttpRequest, ajaxOptions) {
|
||||
if ($.inArray("html", ajaxOptions.dataTypes) !== -1) {
|
||||
$(".inputmask, [data-inputmask], [data-inputmask-mask], [data-inputmask-alias], [data-inputmask-regex]").each(function (ndx, lmnt) {
|
||||
if (lmnt.inputmask === undefined) {
|
||||
Inputmask().mask(lmnt);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).ready(function () {
|
||||
$(".inputmask, [data-inputmask], [data-inputmask-mask], [data-inputmask-alias],[data-inputmask-regex]").each(function (ndx, lmnt) {
|
||||
if (lmnt.inputmask === undefined) {
|
||||
Inputmask().mask(lmnt);
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
5
node_modules/inputmask/dist/inputmask.es6.js
generated
vendored
Normal file
5
node_modules/inputmask/dist/inputmask.es6.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import "./inputmask.js";
|
||||
|
||||
const inputmask = window.Inputmask;
|
||||
window.Inputmask = undefined;
|
||||
export default inputmask;
|
3031
node_modules/inputmask/dist/inputmask.js
generated
vendored
Normal file
3031
node_modules/inputmask/dist/inputmask.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
8
node_modules/inputmask/dist/inputmask.min.js
generated
vendored
Normal file
8
node_modules/inputmask/dist/inputmask.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2985
node_modules/inputmask/dist/jquery.inputmask.js
generated
vendored
Normal file
2985
node_modules/inputmask/dist/jquery.inputmask.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
8
node_modules/inputmask/dist/jquery.inputmask.min.js
generated
vendored
Normal file
8
node_modules/inputmask/dist/jquery.inputmask.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
26
node_modules/inputmask/lib/bindings/inputmask.binding.js
generated
vendored
Normal file
26
node_modules/inputmask/lib/bindings/inputmask.binding.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
Input Mask plugin binding
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
factory(jQuery, window.Inputmask, window);
|
||||
}
|
||||
(function ($, Inputmask, window) {
|
||||
$(window.document).ajaxComplete(function (event, xmlHttpRequest, ajaxOptions) {
|
||||
if ($.inArray("html", ajaxOptions.dataTypes) !== -1) {
|
||||
$(".inputmask, [data-inputmask], [data-inputmask-mask], [data-inputmask-alias], [data-inputmask-regex]").each(function (ndx, lmnt) {
|
||||
if (lmnt.inputmask === undefined) {
|
||||
Inputmask().mask(lmnt);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).ready(function () {
|
||||
$(".inputmask, [data-inputmask], [data-inputmask-mask], [data-inputmask-alias],[data-inputmask-regex]").each(function (ndx, lmnt) {
|
||||
if (lmnt.inputmask === undefined) {
|
||||
Inputmask().mask(lmnt);
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
5
node_modules/inputmask/lib/bindings/inputmask.es6.js
generated
vendored
Normal file
5
node_modules/inputmask/lib/bindings/inputmask.es6.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
import "./inputmask.js";
|
||||
|
||||
const inputmask = window.Inputmask;
|
||||
window.Inputmask = undefined;
|
||||
export default inputmask;
|
7
node_modules/inputmask/lib/canUseDOM.js
generated
vendored
Normal file
7
node_modules/inputmask/lib/canUseDOM.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
const canUseDOM = !!(
|
||||
typeof window !== "undefined" &&
|
||||
window.document &&
|
||||
window.document.createElement
|
||||
);
|
||||
|
||||
export default canUseDOM;
|
101
node_modules/inputmask/lib/defaults.js
generated
vendored
Normal file
101
node_modules/inputmask/lib/defaults.js
generated
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
import keyCode from "./keycode.json";
|
||||
|
||||
export default {
|
||||
_maxTestPos: 500,
|
||||
placeholder: "_",
|
||||
optionalmarker: ["[", "]"],
|
||||
quantifiermarker: ["{", "}"],
|
||||
groupmarker: ["(", ")"],
|
||||
alternatormarker: "|",
|
||||
escapeChar: "\\",
|
||||
mask: null, //needs tobe null instead of undefined as the extend method does not consider props with the undefined value
|
||||
regex: null, //regular expression as a mask
|
||||
oncomplete: () => {
|
||||
}, //executes when the mask is complete
|
||||
onincomplete: () => {
|
||||
}, //executes when the mask is incomplete and focus is lost
|
||||
oncleared: () => {
|
||||
}, //executes when the mask is cleared
|
||||
repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
|
||||
greedy: false, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
|
||||
autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
|
||||
removeMaskOnSubmit: false, //remove the mask before submitting the form.
|
||||
clearMaskOnLostFocus: true,
|
||||
insertMode: true, //insert the input or overwrite the input
|
||||
insertModeVisual: true, //show selected caret when insertmode = false
|
||||
clearIncomplete: false, //clear the incomplete input on blur
|
||||
alias: null,
|
||||
onKeyDown: () => {
|
||||
}, //callback to implement autocomplete on certain keys for example. args => event, buffer, caretPos, opts
|
||||
onBeforeMask: null, //executes before masking the initial value to allow preprocessing of the initial value. args => initialValue, opts => return processedValue
|
||||
onBeforePaste: function (pastedValue, opts) {
|
||||
return typeof opts.onBeforeMask === "function" ? opts.onBeforeMask.call(this, pastedValue, opts) : pastedValue;
|
||||
}, //executes before masking the pasted value to allow preprocessing of the pasted value. args => pastedValue, opts => return processedValue
|
||||
onBeforeWrite: null, //executes before writing to the masked element. args => event, opts
|
||||
onUnMask: null, //executes after unmasking to allow postprocessing of the unmaskedvalue. args => maskedValue, unmaskedValue, opts
|
||||
showMaskOnFocus: true, //show the mask-placeholder when the input has focus
|
||||
showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
|
||||
onKeyValidation: () => {
|
||||
}, //executes on every key-press with the result of isValid. Params: key, result, opts
|
||||
skipOptionalPartCharacter: " ", //a character which can be used to skip an optional part of a mask
|
||||
numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
|
||||
rightAlign: false, //align to the right
|
||||
undoOnEscape: true, //pressing escape reverts the value to the value before focus
|
||||
//numeric basic properties
|
||||
radixPoint: "", //".", // | ","
|
||||
_radixDance: false, //dance around the radixPoint
|
||||
groupSeparator: "", //",", // | "."
|
||||
//numeric basic properties
|
||||
keepStatic: null, //try to keep the mask static while typing. Decisions to alter the mask will be posponed if possible
|
||||
positionCaretOnTab: true, //when enabled the caret position is set after the latest valid position on TAB
|
||||
tabThrough: false, //allows for tabbing through the different parts of the masked field
|
||||
supportsInputType: ["text", "tel", "url", "password", "search"], //list with the supported input types
|
||||
//specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
|
||||
ignorables: [
|
||||
keyCode.BACKSPACE,
|
||||
keyCode.TAB,
|
||||
keyCode["PAUSE/BREAK"],
|
||||
keyCode.ESCAPE,
|
||||
keyCode.PAGE_UP,
|
||||
keyCode.PAGE_DOWN,
|
||||
keyCode.END,
|
||||
keyCode.HOME,
|
||||
keyCode.LEFT,
|
||||
keyCode.UP,
|
||||
keyCode.RIGHT,
|
||||
keyCode.DOWN,
|
||||
keyCode.INSERT,
|
||||
keyCode.DELETE,
|
||||
93,
|
||||
112,
|
||||
113,
|
||||
114,
|
||||
115,
|
||||
116,
|
||||
117,
|
||||
118,
|
||||
119,
|
||||
120,
|
||||
121,
|
||||
122,
|
||||
123,
|
||||
0,
|
||||
229
|
||||
],
|
||||
isComplete: null, //override for isComplete - args => buffer, opts - return true || false
|
||||
preValidation: null, //hook to preValidate the input. Usefull for validating regardless the definition. args => buffer, pos, char, isSelection, opts, maskset, caretPos, strict => return true/false/command object
|
||||
postValidation: null, //hook to postValidate the result from isValid. Usefull for validating the entry as a whole. args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval => return true/false/json
|
||||
staticDefinitionSymbol: undefined, //specify a definitionSymbol for static content, used to make matches for alternators
|
||||
jitMasking: false, //just in time masking ~ only mask while typing, can n (number), true or false
|
||||
nullable: true, //return nothing instead of the buffertemplate when the user hasn't entered anything.
|
||||
inputEventOnly: false, //dev option - testing inputfallback behavior
|
||||
noValuePatching: false, //disable value property patching
|
||||
positionCaretOnClick: "lvp", //none, lvp (based on the last valid position (default), radixFocus (position caret to radixpoint on initial click), select (select the whole input), ignore (ignore the click and continue the mask)
|
||||
casing: null, //mask-level casing. Options: null, "upper", "lower" or "title" or callback args => elem, test, pos, validPositions return charValue
|
||||
inputmode: "text", //specify the inputmode
|
||||
importDataAttributes: true, //import data-inputmask attributes
|
||||
shiftPositions: true, //shift position of the mask entries on entry and deletion.
|
||||
usePrototypeDefinitions: true, //use the default defined definitions from the prototype
|
||||
validationEventTimeOut: 3000, //Time to show validation error on form submit
|
||||
substitutes: {} //define character substitutes
|
||||
};
|
13
node_modules/inputmask/lib/definitions.js
generated
vendored
Normal file
13
node_modules/inputmask/lib/definitions.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
export default {
|
||||
"9": { //\uFF11-\uFF19 #1606
|
||||
validator: "[0-9\uFF10-\uFF19]",
|
||||
definitionSymbol: "*"
|
||||
},
|
||||
"a": { //\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5 #76
|
||||
validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
|
||||
definitionSymbol: "*"
|
||||
},
|
||||
"*": {
|
||||
validator: "[0-9\uFF10-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]"
|
||||
}
|
||||
};
|
8
node_modules/inputmask/lib/dependencyLibs/data.js
generated
vendored
Normal file
8
node_modules/inputmask/lib/dependencyLibs/data.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
export default function (owner, key, value) {
|
||||
if (value === undefined) {
|
||||
return owner.__data ? owner.__data[key] : null;
|
||||
} else {
|
||||
owner.__data = owner.__data || {};
|
||||
owner.__data[key] = value;
|
||||
}
|
||||
}
|
199
node_modules/inputmask/lib/dependencyLibs/events.js
generated
vendored
Normal file
199
node_modules/inputmask/lib/dependencyLibs/events.js
generated
vendored
Normal file
|
@ -0,0 +1,199 @@
|
|||
import extend from "./extend";
|
||||
import window from "../global/window";
|
||||
import DependencyLib from "./inputmask.dependencyLib";
|
||||
import canUseDOM from "../canUseDOM";
|
||||
|
||||
export {on, off, trigger, Event};
|
||||
|
||||
function isValidElement(elem) {
|
||||
return elem instanceof Element;
|
||||
}
|
||||
|
||||
let Event;
|
||||
if (typeof window.CustomEvent === "function") {
|
||||
Event = window.CustomEvent;
|
||||
} else {
|
||||
if (canUseDOM) {
|
||||
Event = function (event, params) {
|
||||
params = params || {bubbles: false, cancelable: false, detail: undefined};
|
||||
var evt = document.createEvent("CustomEvent");
|
||||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||||
return evt;
|
||||
};
|
||||
Event.prototype = window.Event.prototype;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function on(events, handler) {
|
||||
function addEvent(ev, namespace) {
|
||||
//register domevent
|
||||
if (elem.addEventListener) { // all browsers except IE before version 9
|
||||
elem.addEventListener(ev, handler, false);
|
||||
} else if (elem.attachEvent) { // IE before version 9
|
||||
elem.attachEvent("on" + ev, handler);
|
||||
}
|
||||
eventRegistry[ev] = eventRegistry[ev] || {};
|
||||
eventRegistry[ev][namespace] = eventRegistry[ev][namespace] || [];
|
||||
eventRegistry[ev][namespace].push(handler);
|
||||
}
|
||||
|
||||
if (isValidElement(this[0])) {
|
||||
var eventRegistry = this[0].eventRegistry,
|
||||
elem = this[0];
|
||||
|
||||
|
||||
var _events = events.split(" ");
|
||||
for (var endx = 0; endx < _events.length; endx++) {
|
||||
var nsEvent = _events[endx].split("."),
|
||||
ev = nsEvent[0],
|
||||
namespace = nsEvent[1] || "global";
|
||||
addEvent(ev, namespace);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
function off(events, handler) {
|
||||
var eventRegistry, elem;
|
||||
|
||||
function removeEvent(ev, namespace, handler) {
|
||||
if (ev in eventRegistry === true) {
|
||||
//unbind to dom events
|
||||
if (elem.removeEventListener) { // all browsers except IE before version 9
|
||||
elem.removeEventListener(ev, handler, false);
|
||||
} else if (elem.detachEvent) { // IE before version 9
|
||||
elem.detachEvent("on" + ev, handler);
|
||||
}
|
||||
if (namespace === "global") {
|
||||
for (var nmsp in eventRegistry[ev]) {
|
||||
eventRegistry[ev][nmsp].splice(eventRegistry[ev][nmsp].indexOf(handler), 1);
|
||||
}
|
||||
} else {
|
||||
eventRegistry[ev][namespace].splice(eventRegistry[ev][namespace].indexOf(handler), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resolveNamespace(ev, namespace) {
|
||||
var evts = [],
|
||||
hndx, hndL;
|
||||
if (ev.length > 0) {
|
||||
if (handler === undefined) {
|
||||
for (hndx = 0, hndL = eventRegistry[ev][namespace].length; hndx < hndL; hndx++) {
|
||||
evts.push({
|
||||
ev: ev,
|
||||
namespace: namespace && namespace.length > 0 ? namespace : "global",
|
||||
handler: eventRegistry[ev][namespace][hndx]
|
||||
});
|
||||
}
|
||||
} else {
|
||||
evts.push({
|
||||
ev: ev,
|
||||
namespace: namespace && namespace.length > 0 ? namespace : "global",
|
||||
handler: handler
|
||||
});
|
||||
}
|
||||
} else if (namespace.length > 0) {
|
||||
for (var evNdx in eventRegistry) {
|
||||
for (var nmsp in eventRegistry[evNdx]) {
|
||||
if (nmsp === namespace) {
|
||||
if (handler === undefined) {
|
||||
for (hndx = 0, hndL = eventRegistry[evNdx][nmsp].length; hndx < hndL; hndx++) {
|
||||
evts.push({
|
||||
ev: evNdx,
|
||||
namespace: nmsp,
|
||||
handler: eventRegistry[evNdx][nmsp][hndx]
|
||||
});
|
||||
}
|
||||
} else {
|
||||
evts.push({
|
||||
ev: evNdx,
|
||||
namespace: nmsp,
|
||||
handler: handler
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return evts;
|
||||
}
|
||||
|
||||
if (isValidElement(this[0]) && events) {
|
||||
eventRegistry = this[0].eventRegistry;
|
||||
elem = this[0];
|
||||
|
||||
|
||||
var _events = events.split(" ");
|
||||
for (var endx = 0; endx < _events.length; endx++) {
|
||||
var nsEvent = _events[endx].split("."),
|
||||
offEvents = resolveNamespace(nsEvent[0], nsEvent[1]);
|
||||
for (var i = 0, offEventsL = offEvents.length; i < offEventsL; i++) {
|
||||
removeEvent(offEvents[i].ev, offEvents[i].namespace, offEvents[i].handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
function trigger(events /* , args... */) {
|
||||
if (isValidElement(this[0])) {
|
||||
var eventRegistry = this[0].eventRegistry,
|
||||
elem = this[0];
|
||||
var _events = typeof events === "string" ? events.split(" ") : [events.type];
|
||||
for (var endx = 0; endx < _events.length; endx++) {
|
||||
var nsEvent = _events[endx].split("."),
|
||||
ev = nsEvent[0],
|
||||
namespace = nsEvent[1] || "global";
|
||||
if (document !== undefined && namespace === "global") {
|
||||
//trigger domevent
|
||||
var evnt, i, params = {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
detail: arguments[1]
|
||||
};
|
||||
// The custom event that will be created
|
||||
if (document.createEvent) {
|
||||
try {
|
||||
switch (ev) {
|
||||
case "input":
|
||||
params.inputType = "insertText";
|
||||
evnt = new InputEvent(ev, params);
|
||||
break;
|
||||
default:
|
||||
evnt = new CustomEvent(ev, params);
|
||||
}
|
||||
} catch (e) {
|
||||
evnt = document.createEvent("CustomEvent");
|
||||
evnt.initCustomEvent(ev, params.bubbles, params.cancelable, params.detail);
|
||||
}
|
||||
if (events.type) extend(evnt, events);
|
||||
elem.dispatchEvent(evnt);
|
||||
} else {
|
||||
evnt = document.createEventObject();
|
||||
evnt.eventType = ev;
|
||||
evnt.detail = arguments[1];
|
||||
if (events.type) extend(evnt, events);
|
||||
elem.fireEvent("on" + evnt.eventType, evnt);
|
||||
}
|
||||
} else if (eventRegistry[ev] !== undefined) {
|
||||
arguments[0] = arguments[0].type ? arguments[0] : DependencyLib.Event(arguments[0]);
|
||||
arguments[0].detail = arguments.slice(1);
|
||||
if (namespace === "global") {
|
||||
for (var nmsp in eventRegistry[ev]) {
|
||||
for (i = 0; i < eventRegistry[ev][nmsp].length; i++) {
|
||||
eventRegistry[ev][nmsp][i].apply(elem, arguments);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < eventRegistry[ev][namespace].length; i++) {
|
||||
eventRegistry[ev][namespace][i].apply(elem, arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
58
node_modules/inputmask/lib/dependencyLibs/extend.js
generated
vendored
Normal file
58
node_modules/inputmask/lib/dependencyLibs/extend.js
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
export default function extend() {
|
||||
let options, name, src, copy, copyIsArray, clone,
|
||||
target = arguments[0] || {},
|
||||
i = 1,
|
||||
length = arguments.length,
|
||||
deep = false;
|
||||
|
||||
// Handle a deep copy situation
|
||||
if (typeof target === "boolean") {
|
||||
deep = target;
|
||||
|
||||
// Skip the boolean and the target
|
||||
target = arguments[i] || {};
|
||||
i++;
|
||||
}
|
||||
|
||||
// Handle case when target is a string or something (possible in deep copy)
|
||||
if (typeof target !== "object" && typeof target !== "function") {
|
||||
target = {};
|
||||
}
|
||||
|
||||
for (; i < length; i++) {
|
||||
// Only deal with non-null/undefined values
|
||||
if ((options = arguments[i]) != null) {
|
||||
// Extend the base object
|
||||
for (name in options) {
|
||||
src = target[name];
|
||||
copy = options[name];
|
||||
|
||||
// Prevent never-ending loop
|
||||
if (target === copy) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Recurse if we're merging plain objects or arrays
|
||||
if (deep && copy && (Object.prototype.toString.call(copy) === "[object Object]" || (copyIsArray = Array.isArray(copy)))) {
|
||||
if (copyIsArray) {
|
||||
copyIsArray = false;
|
||||
clone = src && Array.isArray(src) ? src : [];
|
||||
|
||||
} else {
|
||||
clone = src && Object.prototype.toString.call(src) === "[object Object]" ? src : {};
|
||||
}
|
||||
|
||||
// Never move original objects, clone them
|
||||
target[name] = extend(deep, clone, copy);
|
||||
|
||||
// Don't bring in undefined values
|
||||
} else if (copy !== undefined) {
|
||||
target[name] = copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the modified object
|
||||
return target;
|
||||
}
|
13
node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jquery.js
generated
vendored
Normal file
13
node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jquery.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
Input Mask plugin dependencyLib
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
|
||||
import jQuery from "jquery";
|
||||
|
||||
if (jQuery === undefined) {
|
||||
throw "jQuery not loaded!";
|
||||
}
|
||||
export default jQuery;
|
41
node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.js
generated
vendored
Normal file
41
node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
Input Mask plugin dependencyLib
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
|
||||
import extend from "./extend";
|
||||
import window from "../global/window";
|
||||
import data from "./data";
|
||||
import { on, off, trigger, Event} from "./events";
|
||||
|
||||
const document = window.document;
|
||||
|
||||
function DependencyLib(elem) {
|
||||
if (elem instanceof DependencyLib) {
|
||||
return elem;
|
||||
}
|
||||
if (!(this instanceof DependencyLib)) {
|
||||
return new DependencyLib(elem);
|
||||
}
|
||||
if (elem !== undefined && elem !== null && elem !== window) {
|
||||
this[0] = elem.nodeName ? elem : (elem[0] !== undefined && elem[0].nodeName ? elem[0] : document.querySelector(elem));
|
||||
if (this[0] !== undefined && this[0] !== null) {
|
||||
this[0].eventRegistry = this[0].eventRegistry || {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DependencyLib.prototype = {
|
||||
on: on,
|
||||
off: off,
|
||||
trigger: trigger
|
||||
};
|
||||
|
||||
//static
|
||||
DependencyLib.extend = extend;
|
||||
DependencyLib.data = data;
|
||||
DependencyLib.Event = Event;
|
||||
|
||||
export default DependencyLib;
|
9
node_modules/inputmask/lib/environment.js
generated
vendored
Normal file
9
node_modules/inputmask/lib/environment.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
import window from "./global/window";
|
||||
|
||||
const ua = (window.navigator && window.navigator.userAgent) || "",
|
||||
ie = (ua.indexOf("MSIE ") > 0) || (ua.indexOf("Trident/") > 0),
|
||||
mobile = "ontouchstart" in window, //not entirely correct but will currently do
|
||||
iemobile = /iemobile/i.test(ua),
|
||||
iphone = /iphone/i.test(ua) && !iemobile;
|
||||
|
||||
export {ua, ie, mobile, iemobile, iphone};
|
4
node_modules/inputmask/lib/escapeRegex.js
generated
vendored
Normal file
4
node_modules/inputmask/lib/escapeRegex.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
const escapeRegexRegex = new RegExp("(\\" + ["/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^"].join("|\\") + ")", "gim");
|
||||
export default function (str) {
|
||||
return str.replace(escapeRegexRegex, "\\$1");
|
||||
}
|
513
node_modules/inputmask/lib/eventhandlers.js
generated
vendored
Normal file
513
node_modules/inputmask/lib/eventhandlers.js
generated
vendored
Normal file
|
@ -0,0 +1,513 @@
|
|||
import {
|
||||
caret, determineNewCaretPosition,
|
||||
getBuffer, getBufferTemplate,
|
||||
getLastValidPosition, isMask,
|
||||
resetMaskSet,
|
||||
seekNext,
|
||||
seekPrevious,
|
||||
translatePosition
|
||||
} from "./positioning";
|
||||
import keyCode from "./keycode.json";
|
||||
import { iemobile, iphone } from "./environment";
|
||||
import { handleRemove, isComplete, isSelection, isValid } from "./validation";
|
||||
import { applyInputValue, checkVal, clearOptionalTail, HandleNativePlaceholder, writeBuffer } from "./inputHandling";
|
||||
import { getPlaceholder, getTest } from "./validation-tests";
|
||||
|
||||
export { EventHandlers };
|
||||
|
||||
var EventHandlers = {
|
||||
keydownEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib,
|
||||
maskset = inputmask.maskset;
|
||||
|
||||
var input = this,
|
||||
$input = $(input),
|
||||
k = e.keyCode,
|
||||
pos = caret.call(inputmask, input);
|
||||
|
||||
var kdResult = opts.onKeyDown.call(this, e, getBuffer.call(inputmask), pos, opts);
|
||||
if (kdResult !== undefined) return kdResult;
|
||||
|
||||
//backspace, delete, and escape get special treatment
|
||||
if (k === keyCode.BACKSPACE || k === keyCode.DELETE || (iphone && k === keyCode.BACKSPACE_SAFARI) || (e.ctrlKey && k === keyCode.X && !("oncut" in input))) { //backspace/delete
|
||||
e.preventDefault(); //stop default action but allow propagation
|
||||
handleRemove.call(inputmask, input, k, pos);
|
||||
writeBuffer(input, getBuffer.call(inputmask, true), maskset.p, e, input.inputmask._valueGet() !== getBuffer.call(inputmask).join(""));
|
||||
} else if (k === keyCode.END || k === keyCode.PAGE_DOWN) { //when END or PAGE_DOWN pressed set position at lastmatch
|
||||
e.preventDefault();
|
||||
var caretPos = seekNext.call(inputmask, getLastValidPosition.call(inputmask));
|
||||
caret.call(inputmask, input, e.shiftKey ? pos.begin : caretPos, caretPos, true);
|
||||
} else if ((k === keyCode.HOME && !e.shiftKey) || k === keyCode.PAGE_UP) { //Home or page_up
|
||||
e.preventDefault();
|
||||
caret.call(inputmask, input, 0, e.shiftKey ? pos.begin : 0, true);
|
||||
} else if (((opts.undoOnEscape && k === keyCode.ESCAPE) || (false && k === keyCode.Z && e.ctrlKey)) && e.altKey !== true) { //escape && undo && #762
|
||||
checkVal(input, true, false, inputmask.undoValue.split(""));
|
||||
$input.trigger("click");
|
||||
} else if (k === keyCode.INSERT && !(e.shiftKey || e.ctrlKey) && inputmask.userOptions.insertMode === undefined) { //insert
|
||||
if (!isSelection.call(inputmask, pos)) {
|
||||
opts.insertMode = !opts.insertMode;
|
||||
caret.call(inputmask, input, pos.begin, pos.begin);
|
||||
} else opts.insertMode = !opts.insertMode;
|
||||
} else if (opts.tabThrough === true && k === keyCode.TAB) {
|
||||
if (e.shiftKey === true) {
|
||||
pos.end = seekPrevious.call(inputmask, pos.end, true);
|
||||
if (getTest.call(inputmask, pos.end - 1).match.static === true) {
|
||||
pos.end--;
|
||||
}
|
||||
pos.begin = seekPrevious.call(inputmask, pos.end, true);
|
||||
if (pos.begin >= 0 && pos.end > 0) {
|
||||
e.preventDefault();
|
||||
caret.call(inputmask, input, pos.begin, pos.end);
|
||||
}
|
||||
} else {
|
||||
pos.begin = seekNext.call(inputmask, pos.begin, true);
|
||||
pos.end = seekNext.call(inputmask, pos.begin, true);
|
||||
if (pos.end < maskset.maskLength) pos.end--;
|
||||
if (pos.begin <= maskset.maskLength) {
|
||||
e.preventDefault();
|
||||
caret.call(inputmask, input, pos.begin, pos.end);
|
||||
}
|
||||
}
|
||||
} else if (!e.shiftKey) {
|
||||
if (opts.insertModeVisual && opts.insertMode === false) {
|
||||
if (k === keyCode.RIGHT) {
|
||||
setTimeout(function () {
|
||||
var caretPos = caret.call(inputmask, input);
|
||||
caret.call(inputmask, input, caretPos.begin);
|
||||
}, 0);
|
||||
} else if (k === keyCode.LEFT) {
|
||||
setTimeout(function () {
|
||||
var caretPos = {
|
||||
begin: translatePosition.call(inputmask, input.inputmask.caretPos.begin),
|
||||
end: translatePosition.call(inputmask, input.inputmask.caretPos.end)
|
||||
};
|
||||
if (inputmask.isRTL) {
|
||||
caret.call(inputmask, input, caretPos.begin + (caretPos.begin === maskset.maskLength ? 0 : 1));
|
||||
} else {
|
||||
caret.call(inputmask, input, caretPos.begin - (caretPos.begin === 0 ? 0 : 1));
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inputmask.ignorable = opts.ignorables.includes(k);
|
||||
},
|
||||
keypressEvent: function (e, checkval, writeOut, strict, ndx) {
|
||||
const inputmask = this.inputmask || this, opts = inputmask.opts, $ = inputmask.dependencyLib,
|
||||
maskset = inputmask.maskset;
|
||||
|
||||
var input = inputmask.el,
|
||||
$input = $(input),
|
||||
k = e.keyCode;
|
||||
|
||||
if (checkval !== true && (!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || inputmask.ignorable))) {
|
||||
if (k === keyCode.ENTER && inputmask.undoValue !== inputmask._valueGet(true)) {
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
// e.preventDefault();
|
||||
setTimeout(function () {
|
||||
$input.trigger("change");
|
||||
}, 0);
|
||||
}
|
||||
inputmask.skipInputEvent = true; //skip the input as otherwise the skipped char could be picked up for validation by the inputfallback
|
||||
return true;
|
||||
} else if (k) {
|
||||
//special treat the decimal separator
|
||||
if ((k === 44 || k === 46) && e.location === 3 && opts.radixPoint !== "") k = opts.radixPoint.charCodeAt(0);
|
||||
var pos = checkval ? {
|
||||
begin: ndx,
|
||||
end: ndx
|
||||
} : caret.call(inputmask, input),
|
||||
forwardPosition, c = String.fromCharCode(k);
|
||||
|
||||
//allow for character substitution
|
||||
c = opts.substitutes[c] || c;
|
||||
maskset.writeOutBuffer = true;
|
||||
var valResult = isValid.call(inputmask, pos, c, strict, undefined, undefined, undefined, checkval);
|
||||
if (valResult !== false) {
|
||||
resetMaskSet.call(inputmask, true);
|
||||
forwardPosition = valResult.caret !== undefined ? valResult.caret : seekNext.call(inputmask, valResult.pos.begin ? valResult.pos.begin : valResult.pos);
|
||||
maskset.p = forwardPosition; //needed for checkval
|
||||
}
|
||||
|
||||
forwardPosition = ((opts.numericInput && valResult.caret === undefined) ? seekPrevious.call(inputmask, forwardPosition) : forwardPosition);
|
||||
if (writeOut !== false) {
|
||||
|
||||
setTimeout(function () {
|
||||
opts.onKeyValidation.call(input, k, valResult);
|
||||
}, 0);
|
||||
if (maskset.writeOutBuffer && valResult !== false) {
|
||||
var buffer = getBuffer.call(inputmask);
|
||||
writeBuffer(input, buffer, forwardPosition, e, checkval !== true);
|
||||
}
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (checkval) {
|
||||
if (valResult !== false) valResult.forwardPosition = forwardPosition;
|
||||
return valResult;
|
||||
}
|
||||
}
|
||||
},
|
||||
keyupEvent: function (e) {
|
||||
const inputmask = this.inputmask;
|
||||
|
||||
if (inputmask.isComposing && (e.keyCode === keyCode.KEY_229 || e.keyCode === keyCode.ENTER)) {
|
||||
inputmask.$el.trigger("input");
|
||||
}
|
||||
},
|
||||
pasteEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
|
||||
var input = this,
|
||||
inputValue = inputmask._valueGet(true),
|
||||
caretPos = caret.call(inputmask, input),
|
||||
tempValue;
|
||||
|
||||
if (inputmask.isRTL) {
|
||||
tempValue = caretPos.end;
|
||||
caretPos.end = translatePosition.call(inputmask, caretPos.begin);
|
||||
caretPos.begin = translatePosition.call(inputmask, tempValue);
|
||||
}
|
||||
|
||||
var valueBeforeCaret = inputValue.substr(0, caretPos.begin),
|
||||
valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
|
||||
|
||||
if (valueBeforeCaret == (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).slice(0, caretPos.begin).join("")) valueBeforeCaret = "";
|
||||
if (valueAfterCaret == (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).slice(caretPos.end).join("")) valueAfterCaret = "";
|
||||
|
||||
if (window.clipboardData && window.clipboardData.getData) { // IE
|
||||
inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret;
|
||||
} else if (e.clipboardData && e.clipboardData.getData) {
|
||||
inputValue = valueBeforeCaret + e.clipboardData.getData("text/plain") + valueAfterCaret;
|
||||
} else {
|
||||
return true;
|
||||
} //allow native paste event as fallback ~ masking will continue by inputfallback
|
||||
|
||||
var pasteValue = inputValue;
|
||||
if (inputmask.isRTL) {
|
||||
pasteValue = pasteValue.split("")
|
||||
for (let c of getBufferTemplate.call(inputmask)) {
|
||||
if (pasteValue[0] === c)
|
||||
pasteValue.shift();
|
||||
}
|
||||
pasteValue = pasteValue.join("");
|
||||
}
|
||||
if (typeof opts.onBeforePaste === "function") {
|
||||
pasteValue = opts.onBeforePaste.call(inputmask, pasteValue, opts);
|
||||
if (pasteValue === false) {
|
||||
return false;
|
||||
}
|
||||
if (!pasteValue) {
|
||||
pasteValue = inputValue;
|
||||
}
|
||||
}
|
||||
checkVal(input, true, false, pasteValue.toString().split(""), e);
|
||||
e.preventDefault()
|
||||
},
|
||||
inputFallBackEvent: function (e) { //fallback when keypress is not triggered
|
||||
const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
|
||||
|
||||
function ieMobileHandler(input, inputValue, caretPos) {
|
||||
if (iemobile) { //iemobile just sets the character at the end althought the caret position is correctly set
|
||||
var inputChar = inputValue.replace(getBuffer.call(inputmask).join(""), "");
|
||||
if (inputChar.length === 1) {
|
||||
var iv = inputValue.split("");
|
||||
iv.splice(caretPos.begin, 0, inputChar);
|
||||
inputValue = iv.join("");
|
||||
}
|
||||
}
|
||||
return inputValue;
|
||||
}
|
||||
|
||||
function analyseChanges(inputValue, buffer, caretPos) {
|
||||
var frontPart = inputValue.substr(0, caretPos.begin).split(""),
|
||||
backPart = inputValue.substr(caretPos.begin).split(""),
|
||||
frontBufferPart = buffer.substr(0, caretPos.begin).split(""),
|
||||
backBufferPart = buffer.substr(caretPos.begin).split("");
|
||||
|
||||
var fpl = frontPart.length >= frontBufferPart.length ? frontPart.length : frontBufferPart.length,
|
||||
bpl = backPart.length >= backBufferPart.length ? backPart.length : backBufferPart.length,
|
||||
bl, i, action = "", data = [], marker = "~", placeholder;
|
||||
|
||||
//align buffers
|
||||
while (frontPart.length < fpl) frontPart.push(marker);
|
||||
while (frontBufferPart.length < fpl) frontBufferPart.push(marker);
|
||||
while (backPart.length < bpl) backPart.unshift(marker);
|
||||
while (backBufferPart.length < bpl) backBufferPart.unshift(marker);
|
||||
|
||||
var newBuffer = frontPart.concat(backPart);
|
||||
var oldBuffer = frontBufferPart.concat(backBufferPart);
|
||||
|
||||
// console.log("N " + newBuffer);
|
||||
// console.log("O " + oldBuffer);
|
||||
|
||||
for (i = 0, bl = newBuffer.length; i < bl; i++) {
|
||||
placeholder = getPlaceholder.call(inputmask, translatePosition.call(inputmask, i));
|
||||
switch (action) {
|
||||
case "insertText":
|
||||
if (oldBuffer[i - 1] === newBuffer[i] && caretPos.begin == newBuffer.length - 1) {
|
||||
data.push(newBuffer[i]);
|
||||
}
|
||||
i = bl;
|
||||
break;
|
||||
case "insertReplacementText":
|
||||
if (newBuffer[i] === marker) { //extend selection
|
||||
caretPos.end++;
|
||||
} else {
|
||||
// breakout loop
|
||||
i = bl;
|
||||
}
|
||||
break;
|
||||
case "deleteContentBackward":
|
||||
if (newBuffer[i] === marker) {
|
||||
caretPos.end++;
|
||||
} else {
|
||||
//breakout loop
|
||||
i = bl;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (newBuffer[i] !== oldBuffer[i]) {
|
||||
if ((newBuffer[i + 1] === marker || newBuffer[i + 1] === placeholder || newBuffer[i + 1] === undefined) && ((oldBuffer[i] === placeholder && oldBuffer[i + 1] === marker) || oldBuffer[i] === marker)) { //basic insert
|
||||
action = "insertText";
|
||||
data.push(newBuffer[i]);
|
||||
caretPos.begin--;
|
||||
caretPos.end--;
|
||||
} else if (oldBuffer[i + 1] === marker && oldBuffer[i] === newBuffer[i + 1]) { //insert between
|
||||
action = "insertText";
|
||||
data.push(newBuffer[i]);
|
||||
caretPos.begin--;
|
||||
caretPos.end--;
|
||||
} else if (newBuffer[i] !== placeholder && newBuffer[i] !== marker &&
|
||||
(newBuffer[i + 1] === marker || (oldBuffer[i] !== newBuffer[i] && oldBuffer[i + 1] === newBuffer[i + 1] /*single char replacement*/))) { //replace selection
|
||||
action = "insertReplacementText";
|
||||
data.push(newBuffer[i]);
|
||||
caretPos.begin--;
|
||||
} else if (newBuffer[i] === marker) { //delete~backspace
|
||||
action = "deleteContentBackward";
|
||||
if (isMask.call(inputmask, translatePosition.call(inputmask, i), true) || oldBuffer[i] === opts.radixPoint) caretPos.end++;
|
||||
} else {
|
||||
i = bl;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
action: action,
|
||||
data: data,
|
||||
caret: caretPos
|
||||
};
|
||||
}
|
||||
|
||||
var input = this,
|
||||
inputValue = input.inputmask._valueGet(true),
|
||||
buffer = (inputmask.isRTL ? getBuffer.call(inputmask).slice().reverse() : getBuffer.call(inputmask)).join(""),
|
||||
caretPos = caret.call(inputmask, input, undefined, undefined, true);
|
||||
|
||||
if (buffer !== inputValue) {
|
||||
inputValue = ieMobileHandler(input, inputValue, caretPos);
|
||||
|
||||
var changes = analyseChanges(inputValue, buffer, caretPos);
|
||||
|
||||
// console.log(JSON.stringify(changes));
|
||||
if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
|
||||
input.focus();
|
||||
}
|
||||
writeBuffer(input, getBuffer.call(inputmask));
|
||||
caret.call(inputmask, input, caretPos.begin, caretPos.end, true);
|
||||
switch (changes.action) {
|
||||
case "insertText":
|
||||
case "insertReplacementText":
|
||||
changes.data.forEach(function (entry, ndx) {
|
||||
var keypress = new $.Event("keypress");
|
||||
keypress.keyCode = entry.charCodeAt(0);
|
||||
inputmask.ignorable = false; //make sure ignorable is ignored ;-)
|
||||
EventHandlers.keypressEvent.call(input, keypress);
|
||||
});
|
||||
setTimeout(function () { //#2195 trigger keyup to help some other plugins to track changes
|
||||
inputmask.$el.trigger("keyup");
|
||||
}, 0);
|
||||
break;
|
||||
case "deleteContentBackward":
|
||||
var keydown = new $.Event("keydown");
|
||||
keydown.keyCode = keyCode.BACKSPACE;
|
||||
EventHandlers.keydownEvent.call(input, keydown);
|
||||
break;
|
||||
default:
|
||||
applyInputValue(input, inputValue);
|
||||
break;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
compositionendEvent: function (e) {
|
||||
const inputmask = this.inputmask;
|
||||
|
||||
inputmask.isComposing = false;
|
||||
inputmask.$el.trigger("input");
|
||||
},
|
||||
setValueEvent: function (e) {
|
||||
const inputmask = this.inputmask;
|
||||
var input = this,
|
||||
value = (e && e.detail) ? e.detail[0] : arguments[1];
|
||||
|
||||
if (value === undefined) {
|
||||
value = input.inputmask._valueGet(true);
|
||||
}
|
||||
|
||||
applyInputValue(input, value);
|
||||
|
||||
if ((e.detail && e.detail[1] !== undefined) || arguments[2] !== undefined) {
|
||||
caret.call(inputmask, input, e.detail ? e.detail[1] : arguments[2]);
|
||||
}
|
||||
}
|
||||
,
|
||||
focusEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
var input = this,
|
||||
nptValue = input.inputmask._valueGet();
|
||||
|
||||
if (opts.showMaskOnFocus) {
|
||||
if (nptValue !== getBuffer.call(inputmask).join("")) {
|
||||
writeBuffer(input, getBuffer.call(inputmask), seekNext.call(inputmask, getLastValidPosition.call(inputmask)));
|
||||
} /*else if (mouseEnter === false) { //only executed on focus without mouseenter
|
||||
caret(input, seekNext(getLastValidPosition()));
|
||||
}*/
|
||||
}
|
||||
if (opts.positionCaretOnTab === true && inputmask.mouseEnter === false && (!isComplete.call(inputmask, getBuffer.call(inputmask)) || getLastValidPosition.call(inputmask) === -1)) {
|
||||
EventHandlers.clickEvent.apply(input, [e, true]);
|
||||
}
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
},
|
||||
invalidEvent: function (e) {
|
||||
this.inputmask.validationEvent = true;
|
||||
},
|
||||
mouseleaveEvent: function () {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
|
||||
var input = this;
|
||||
inputmask.mouseEnter = false;
|
||||
if (opts.clearMaskOnLostFocus && (input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
|
||||
HandleNativePlaceholder(input, inputmask.originalPlaceholder);
|
||||
}
|
||||
},
|
||||
clickEvent: function (e, tabbed) {
|
||||
const inputmask = this.inputmask;
|
||||
|
||||
var input = this;
|
||||
if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement === input) {
|
||||
var newCaretPosition = determineNewCaretPosition.call(inputmask, caret.call(inputmask, input), tabbed);
|
||||
if (newCaretPosition !== undefined) {
|
||||
caret.call(inputmask, input, newCaretPosition);
|
||||
}
|
||||
}
|
||||
},
|
||||
cutEvent: function (e) {
|
||||
const inputmask = this.inputmask, maskset = inputmask.maskset;
|
||||
|
||||
var input = this,
|
||||
pos = caret.call(inputmask, input);
|
||||
|
||||
//correct clipboardData
|
||||
var clipData = inputmask.isRTL ? getBuffer.call(inputmask).slice(pos.end, pos.begin) : getBuffer.call(inputmask).slice(pos.begin, pos.end),
|
||||
clipDataText = inputmask.isRTL ? clipData.reverse().join("") : clipData.join("");
|
||||
if (window.navigator.clipboard) window.navigator.clipboard.writeText(clipDataText);
|
||||
else if (window.clipboardData && window.clipboardData.getData) { // IE
|
||||
window.clipboardData.setData("Text", clipDataText);
|
||||
}
|
||||
handleRemove.call(inputmask, input, keyCode.DELETE, pos);
|
||||
writeBuffer(input, getBuffer.call(inputmask), maskset.p, e, inputmask.undoValue !== inputmask._valueGet(true));
|
||||
},
|
||||
blurEvent: function (e) {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
|
||||
|
||||
var $input = $(this),
|
||||
input = this;
|
||||
if (input.inputmask) {
|
||||
HandleNativePlaceholder(input, inputmask.originalPlaceholder);
|
||||
var nptValue = input.inputmask._valueGet(),
|
||||
buffer = getBuffer.call(inputmask).slice();
|
||||
|
||||
if (nptValue !== "") {
|
||||
if (opts.clearMaskOnLostFocus) {
|
||||
if (getLastValidPosition.call(inputmask) === -1 && nptValue === getBufferTemplate.call(inputmask).join("")) {
|
||||
buffer = [];
|
||||
} else { //clearout optional tail of the mask
|
||||
clearOptionalTail.call(inputmask, buffer);
|
||||
}
|
||||
}
|
||||
if (isComplete.call(inputmask, buffer) === false) {
|
||||
setTimeout(function () {
|
||||
$input.trigger("incomplete");
|
||||
}, 0);
|
||||
if (opts.clearIncomplete) {
|
||||
resetMaskSet.call(inputmask);
|
||||
if (opts.clearMaskOnLostFocus) {
|
||||
buffer = [];
|
||||
} else {
|
||||
buffer = getBufferTemplate.call(inputmask).slice();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
writeBuffer(input, buffer, undefined, e);
|
||||
}
|
||||
|
||||
if (inputmask.undoValue !== inputmask._valueGet(true)) {
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
$input.trigger("change");
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
mouseenterEvent: function () {
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
|
||||
var input = this;
|
||||
inputmask.mouseEnter = true;
|
||||
if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
|
||||
var bufferTemplate = (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join("");
|
||||
if (inputmask.placeholder !== bufferTemplate && input.placeholder !== inputmask.originalPlaceholder) {
|
||||
inputmask.originalPlaceholder = input.placeholder;
|
||||
}
|
||||
if (opts.showMaskOnHover) {
|
||||
HandleNativePlaceholder(input, bufferTemplate);
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
submitEvent: function () { //trigger change on submit if any
|
||||
const inputmask = this.inputmask, opts = inputmask.opts;
|
||||
|
||||
if (inputmask.undoValue !== inputmask._valueGet(true)) {
|
||||
inputmask.$el.trigger("change");
|
||||
}
|
||||
if (/*opts.clearMaskOnLostFocus && */getLastValidPosition.call(inputmask) === -1 && inputmask._valueGet && inputmask._valueGet() === getBufferTemplate.call(inputmask).join("")) {
|
||||
inputmask._valueSet(""); //clear masktemplete on submit and still has focus
|
||||
}
|
||||
if (opts.clearIncomplete && isComplete.call(inputmask, getBuffer.call(inputmask)) === false) {
|
||||
inputmask._valueSet("");
|
||||
}
|
||||
if (opts.removeMaskOnSubmit) {
|
||||
inputmask._valueSet(inputmask.unmaskedvalue(), true);
|
||||
setTimeout(function () {
|
||||
writeBuffer(inputmask.el, getBuffer.call(inputmask));
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
,
|
||||
resetEvent: function () {
|
||||
const inputmask = this.inputmask;
|
||||
|
||||
inputmask.refreshValue = true; //indicate a forced refresh when there is a call to the value before leaving the triggering event fn
|
||||
setTimeout(function () {
|
||||
applyInputValue(inputmask.el, inputmask._valueGet(true));
|
||||
}, 0);
|
||||
}
|
||||
};
|
124
node_modules/inputmask/lib/eventruler.js
generated
vendored
Normal file
124
node_modules/inputmask/lib/eventruler.js
generated
vendored
Normal file
|
@ -0,0 +1,124 @@
|
|||
import Inputmask from "./inputmask";
|
||||
import keyCode from "./keycode.json";
|
||||
import {getBufferTemplate} from "./positioning";
|
||||
import {HandleNativePlaceholder} from "./inputHandling";
|
||||
|
||||
export {EventRuler};
|
||||
|
||||
var EventRuler = {
|
||||
on: function (input, eventName, eventHandler) {
|
||||
const $ = input.inputmask.dependencyLib;
|
||||
|
||||
var ev = function (e) {
|
||||
if (e.originalEvent) {
|
||||
e = e.originalEvent || e; //get original event from jquery evenbt
|
||||
arguments[0] = e;
|
||||
}
|
||||
// console.log(e.type);
|
||||
var that = this, args, inputmask = that.inputmask, opts = inputmask ? inputmask.opts : undefined;
|
||||
if (inputmask === undefined && this.nodeName !== "FORM") { //happens when cloning an object with jquery.clone
|
||||
var imOpts = $.data(that, "_inputmask_opts");
|
||||
$(that).off(); //unbind all events
|
||||
if (imOpts) {
|
||||
(new Inputmask(imOpts)).mask(that);
|
||||
}
|
||||
} else if (!["submit", "reset", "setvalue"].includes(e.type) && this.nodeName !== "FORM" && (that.disabled || (that.readOnly && !(e.type === "keydown" && (e.ctrlKey && e.keyCode === 67) || (opts.tabThrough === false && e.keyCode === keyCode.TAB))))) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
switch (e.type) {
|
||||
case "input":
|
||||
if (inputmask.skipInputEvent === true || (e.inputType && e.inputType === "insertCompositionText")) {
|
||||
inputmask.skipInputEvent = false;
|
||||
return e.preventDefault();
|
||||
}
|
||||
|
||||
// if (mobile) { //this causes problem see #2220
|
||||
// args = arguments;
|
||||
// setTimeout(function () { //needed for caret selection when entering a char on Android 8 - #1818
|
||||
// eventHandler.apply(that, args);
|
||||
// caret(that, that.inputmask.caretPos, undefined, true);
|
||||
// }, 0);
|
||||
// return false;
|
||||
// }
|
||||
break;
|
||||
case "keydown":
|
||||
//Safari 5.1.x - modal dialog fires keypress twice workaround
|
||||
inputmask.skipKeyPressEvent = false;
|
||||
inputmask.skipInputEvent = inputmask.isComposing = e.keyCode === keyCode.KEY_229;
|
||||
break;
|
||||
case "keyup":
|
||||
case "compositionend":
|
||||
if (inputmask.isComposing) {
|
||||
inputmask.skipInputEvent = false;
|
||||
}
|
||||
break;
|
||||
case "keypress":
|
||||
if (inputmask.skipKeyPressEvent === true) {
|
||||
return e.preventDefault();
|
||||
}
|
||||
inputmask.skipKeyPressEvent = true;
|
||||
break;
|
||||
case "click":
|
||||
case "focus":
|
||||
if (inputmask.validationEvent) { // #841
|
||||
inputmask.validationEvent = false;
|
||||
input.blur();
|
||||
HandleNativePlaceholder(input, (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join(""));
|
||||
setTimeout(function () {
|
||||
input.focus();
|
||||
}, opts.validationEventTimeOut);
|
||||
return false;
|
||||
}
|
||||
args = arguments;
|
||||
setTimeout(function () { //needed for Chrome ~ initial selection clears after the clickevent
|
||||
if (!input.inputmask) {
|
||||
// `inputmask.remove()` was called before this callback
|
||||
return;
|
||||
}
|
||||
eventHandler.apply(that, args);
|
||||
}, 0);
|
||||
return false;
|
||||
}
|
||||
var returnVal = eventHandler.apply(that, arguments);
|
||||
if (returnVal === false) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
};
|
||||
if (["submit", "reset"].includes(eventName)) {
|
||||
ev = ev.bind(input); //bind creates a new eventhandler (wrap)
|
||||
if (input.form !== null) $(input.form).on(eventName, ev);
|
||||
} else {
|
||||
$(input).on(eventName, ev);
|
||||
}
|
||||
|
||||
//keep instance of the event
|
||||
input.inputmask.events[eventName] = input.inputmask.events[eventName] || [];
|
||||
input.inputmask.events[eventName].push(ev);
|
||||
|
||||
},
|
||||
off: function (input, event) {
|
||||
if (input.inputmask && input.inputmask.events) {
|
||||
const $ = input.inputmask.dependencyLib;
|
||||
let events = input.inputmask.events;
|
||||
if (event) {
|
||||
events = [];
|
||||
events[event] = input.inputmask.events[event];
|
||||
}
|
||||
for (let eventName in events) {
|
||||
let evArr = events[eventName];
|
||||
while (evArr.length > 0) {
|
||||
let ev = evArr.pop();
|
||||
if (["submit", "reset",].includes(eventName)) {
|
||||
if (input.form !== null) $(input.form).off(eventName, ev);
|
||||
} else {
|
||||
$(input).off(eventName, ev);
|
||||
}
|
||||
}
|
||||
delete input.inputmask.events[eventName];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
588
node_modules/inputmask/lib/extensions/inputmask.date.extensions.js
generated
vendored
Normal file
588
node_modules/inputmask/lib/extensions/inputmask.date.extensions.js
generated
vendored
Normal file
|
@ -0,0 +1,588 @@
|
|||
/*
|
||||
Input Mask plugin extensions
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
import Inputmask from "../inputmask";
|
||||
import keyCode from "../keycode.json";
|
||||
import escapeRegex from "../escapeRegex";
|
||||
import {seekNext} from "../positioning";
|
||||
import {getMaskTemplate} from "../validation-tests";
|
||||
|
||||
const $ = Inputmask.dependencyLib;
|
||||
|
||||
class DateObject {
|
||||
constructor(mask, format, opts) {
|
||||
this.mask = mask;
|
||||
this.format = format;
|
||||
this.opts = opts;
|
||||
this._date = new Date(1, 0, 1);
|
||||
this.initDateObject(mask, this.opts);
|
||||
}
|
||||
|
||||
get date() {
|
||||
if (this._date === undefined) {
|
||||
this._date = new Date(1, 0, 1);
|
||||
this.initDateObject(undefined, this.opts);
|
||||
}
|
||||
return this._date;
|
||||
}
|
||||
|
||||
initDateObject(mask, opts) {
|
||||
let match;
|
||||
getTokenizer(opts).lastIndex = 0;
|
||||
while ((match = getTokenizer(opts).exec(this.format))) {
|
||||
let dynMatches = new RegExp("\\d+$").exec(match[0]),
|
||||
fcode = dynMatches ? (match[0][0] + "x") : match[0],
|
||||
value;
|
||||
if (mask !== undefined) {
|
||||
if (dynMatches) {
|
||||
let lastIndex = getTokenizer(opts).lastIndex,
|
||||
tokanMatch = getTokenMatch(match.index, opts);
|
||||
getTokenizer(opts).lastIndex = lastIndex;
|
||||
value = mask.slice(0, mask.indexOf(tokanMatch.nextMatch[0]));
|
||||
} else {
|
||||
value = mask.slice(0, fcode.length);
|
||||
}
|
||||
mask = mask.slice(value.length);
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(formatCode, fcode)) {
|
||||
this.setValue(this, value, fcode, formatCode[fcode][2], formatCode[fcode][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setValue(dateObj, value, fcode, targetProp, dateOperation) {
|
||||
if (value !== undefined) {
|
||||
dateObj[targetProp] = targetProp === "ampm" ? value : value.replace(/[^0-9]/g, "0");
|
||||
dateObj["raw" + targetProp] = value.replace(/\s/g, "_");
|
||||
}
|
||||
if (dateOperation !== undefined) {
|
||||
let datavalue = dateObj[targetProp];
|
||||
if ((targetProp === "day" && parseInt(datavalue) === 29) || (targetProp === "month" && parseInt(datavalue) === 2)) {
|
||||
if (parseInt(dateObj.day) === 29 && parseInt(dateObj.month) === 2 && (dateObj.year === "" || dateObj.year === undefined)) {
|
||||
//set temporary leap year in dateObj
|
||||
dateObj._date.setFullYear(2012, 1, 29);
|
||||
}
|
||||
}
|
||||
if (targetProp === "day") {
|
||||
useDateObject = true;
|
||||
if (parseInt(datavalue) === 0)
|
||||
datavalue = 1;
|
||||
}
|
||||
if (targetProp === "month")
|
||||
useDateObject = true;
|
||||
if (targetProp === "year") {
|
||||
useDateObject = true;
|
||||
if (datavalue.length < 4)
|
||||
datavalue = pad(datavalue, 4, true);
|
||||
}
|
||||
if (datavalue !== "" && !isNaN(datavalue)) dateOperation.call(dateObj._date, datavalue);
|
||||
if (targetProp === "ampm")
|
||||
dateOperation.call(dateObj._date, datavalue);
|
||||
}
|
||||
}
|
||||
|
||||
reset() {
|
||||
this._date = new Date(1, 0, 1);
|
||||
}
|
||||
|
||||
reInit() {
|
||||
this._date = undefined;
|
||||
this.date;
|
||||
}
|
||||
}
|
||||
|
||||
let currentYear = new Date().getFullYear(),
|
||||
useDateObject = false,
|
||||
//supported codes for formatting
|
||||
//http://blog.stevenlevithan.com/archives/date-time-format
|
||||
//https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings?view=netframework-4.7
|
||||
formatCode = { //regex, valueSetter, type, displayformatter
|
||||
d: ["[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", Date.prototype.getDate], //Day of the month as digits; no leading zero for single-digit days.
|
||||
dd: ["0[1-9]|[12][0-9]|3[01]", Date.prototype.setDate, "day", function () {
|
||||
return pad(Date.prototype.getDate.call(this), 2);
|
||||
}], //Day of the month as digits; leading zero for single-digit days.
|
||||
ddd: [""], //Day of the week as a three-letter abbreviation.
|
||||
dddd: [""], //Day of the week as its full name.
|
||||
m: ["[1-9]|1[012]", function (val) {
|
||||
let mval = val ? parseInt(val) : 0;
|
||||
if (mval > 0) mval--;
|
||||
return Date.prototype.setMonth.call(this, mval);
|
||||
}, "month", function () {
|
||||
return Date.prototype.getMonth.call(this) + 1;
|
||||
}], //Month as digits; no leading zero for single-digit months.
|
||||
mm: ["0[1-9]|1[012]", function (val) {
|
||||
let mval = val ? parseInt(val) : 0;
|
||||
if (mval > 0) mval--;
|
||||
return Date.prototype.setMonth.call(this, mval);
|
||||
}, "month", function () {
|
||||
return pad(Date.prototype.getMonth.call(this) + 1, 2);
|
||||
}], //Month as digits; leading zero for single-digit months.
|
||||
mmm: [""], //Month as a three-letter abbreviation.
|
||||
mmmm: [""], //Month as its full name.
|
||||
yy: ["[0-9]{2}", Date.prototype.setFullYear, "year", function () {
|
||||
return pad(Date.prototype.getFullYear.call(this), 2);
|
||||
}], //Year as last two digits; leading zero for years less than 10.
|
||||
yyyy: ["[0-9]{4}", Date.prototype.setFullYear, "year", function () {
|
||||
return pad(Date.prototype.getFullYear.call(this), 4);
|
||||
}],
|
||||
h: ["[1-9]|1[0-2]", Date.prototype.setHours, "hours", Date.prototype.getHours], //Hours; no leading zero for single-digit hours (12-hour clock).
|
||||
hh: ["0[1-9]|1[0-2]", Date.prototype.setHours, "hours", function () {
|
||||
return pad(Date.prototype.getHours.call(this), 2);
|
||||
}], //Hours; leading zero for single-digit hours (12-hour clock).
|
||||
hx: [function (x) {
|
||||
return `[0-9]{${x}}`;
|
||||
}, Date.prototype.setHours, "hours", function (x) {
|
||||
return Date.prototype.getHours;
|
||||
}], //Hours; no limit; set maximum digits
|
||||
H: ["1?[0-9]|2[0-3]", Date.prototype.setHours, "hours", Date.prototype.getHours], //Hours; no leading zero for single-digit hours (24-hour clock).
|
||||
HH: ["0[0-9]|1[0-9]|2[0-3]", Date.prototype.setHours, "hours", function () {
|
||||
return pad(Date.prototype.getHours.call(this), 2);
|
||||
}], //Hours; leading zero for single-digit hours (24-hour clock).
|
||||
Hx: [function (x) {
|
||||
return `[0-9]{${x}}`;
|
||||
}, Date.prototype.setHours, "hours", function (x) {
|
||||
return function () {
|
||||
return pad(Date.prototype.getHours.call(this), x);
|
||||
};
|
||||
}], //Hours; no limit; set maximum digits
|
||||
M: ["[1-5]?[0-9]", Date.prototype.setMinutes, "minutes", Date.prototype.getMinutes], //Minutes; no leading zero for single-digit minutes. Uppercase M unlike CF timeFormat's m to avoid conflict with months.
|
||||
MM: ["0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]", Date.prototype.setMinutes, "minutes", function () {
|
||||
return pad(Date.prototype.getMinutes.call(this), 2);
|
||||
}], //Minutes; leading zero for single-digit minutes. Uppercase MM unlike CF timeFormat's mm to avoid conflict with months.
|
||||
s: ["[1-5]?[0-9]", Date.prototype.setSeconds, "seconds", Date.prototype.getSeconds], //Seconds; no leading zero for single-digit seconds.
|
||||
ss: ["0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]", Date.prototype.setSeconds, "seconds", function () {
|
||||
return pad(Date.prototype.getSeconds.call(this), 2);
|
||||
}], //Seconds; leading zero for single-digit seconds.
|
||||
l: ["[0-9]{3}", Date.prototype.setMilliseconds, "milliseconds", function () {
|
||||
return pad(Date.prototype.getMilliseconds.call(this), 3);
|
||||
}], //Milliseconds. 3 digits.
|
||||
L: ["[0-9]{2}", Date.prototype.setMilliseconds, "milliseconds", function () {
|
||||
return pad(Date.prototype.getMilliseconds.call(this), 2);
|
||||
}], //Milliseconds. 2 digits.
|
||||
t: ["[ap]", setAMPM, "ampm", getAMPM, 1], //Lowercase, single-character time marker string: a or p.
|
||||
tt: ["[ap]m", setAMPM, "ampm", getAMPM, 2], //two-character time marker string: am or pm.
|
||||
T: ["[AP]", setAMPM, "ampm", getAMPM, 1], //single-character time marker string: A or P.
|
||||
TT: ["[AP]M", setAMPM, "ampm", getAMPM, 2], //two-character time marker string: AM or PM.
|
||||
Z: [".*", undefined, "Z", getTimeZoneAbbreviated], //US timezone abbreviation, e.g. EST or MDT. With non-US timezones or in the Opera browser, the GMT/UTC offset is returned, e.g. GMT-0500
|
||||
o: [""], //GMT/UTC timezone offset, e.g. -0500 or +0230.
|
||||
S: [""] //The date's ordinal suffix (st, nd, rd, or th).
|
||||
},
|
||||
formatAlias = {
|
||||
isoDate: "yyyy-mm-dd", //2007-06-09
|
||||
isoTime: "HH:MM:ss", //17:46:21
|
||||
isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", //2007-06-09T17:46:21
|
||||
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" //2007-06-09T22:46:21Z
|
||||
};
|
||||
|
||||
function setAMPM(value) {
|
||||
const hours = this.getHours();
|
||||
if (value.toLowerCase().includes("p")) {
|
||||
this.setHours(hours + 12);
|
||||
// console.log("setAMPM + 12");
|
||||
} else if (value.toLowerCase().includes("a") && hours >= 12) {
|
||||
this.setHours(hours - 12);
|
||||
}
|
||||
}
|
||||
|
||||
function getAMPM() {
|
||||
let date = this,
|
||||
hours = date.getHours();
|
||||
hours = hours || 12;
|
||||
return hours >= 12 ? "PM" : "AM";
|
||||
}
|
||||
|
||||
function getTimeZoneAbbreviated() {
|
||||
//not perfect, but ok for now
|
||||
let date = this, {1: tz} = date.toString().match(/\((.+)\)/);
|
||||
if (tz.includes(" ")) {
|
||||
tz = tz.replace("-", " ").toUpperCase();
|
||||
tz = tz.split(" ").map(([first]) => first).join("");
|
||||
}
|
||||
return tz;
|
||||
}
|
||||
|
||||
function formatcode(match) {
|
||||
var dynMatches = new RegExp("\\d+$").exec(match[0]);
|
||||
if (dynMatches && dynMatches[0] !== undefined) {
|
||||
var fcode = formatCode[match[0][0] + "x"].slice("");
|
||||
fcode[0] = fcode[0](dynMatches[0]);
|
||||
fcode[3] = fcode[3](dynMatches[0]);
|
||||
|
||||
return fcode;
|
||||
} else if (formatCode[match[0]]) {
|
||||
return formatCode[match[0]];
|
||||
}
|
||||
}
|
||||
|
||||
function getTokenizer(opts) {
|
||||
if (!opts.tokenizer) {
|
||||
var tokens = [], dyntokens = [];
|
||||
for (var ndx in formatCode) {
|
||||
if (/\.*x$/.test(ndx)) {
|
||||
var dynToken = ndx[0] + "\\d+";
|
||||
if (dyntokens.indexOf(dynToken) === -1) {
|
||||
dyntokens.push(dynToken);
|
||||
}
|
||||
} else if (tokens.indexOf(ndx[0]) === -1) {
|
||||
tokens.push(ndx[0]);
|
||||
}
|
||||
}
|
||||
opts.tokenizer = "(" + (dyntokens.length > 0 ? dyntokens.join("|") + "|" : "") + tokens.join("+|") + ")+?|.";
|
||||
opts.tokenizer = new RegExp(opts.tokenizer, "g");
|
||||
}
|
||||
|
||||
return opts.tokenizer;
|
||||
}
|
||||
|
||||
function prefillYear(dateParts, currentResult, opts) {
|
||||
if (dateParts.year !== dateParts.rawyear) {
|
||||
var crrntyear = currentYear.toString(),
|
||||
enteredPart = dateParts.rawyear.replace(/[^0-9]/g, ""),
|
||||
currentYearPart = crrntyear.slice(0, enteredPart.length),
|
||||
currentYearNextPart = crrntyear.slice(enteredPart.length);
|
||||
if (enteredPart.length === 2 && enteredPart === currentYearPart) {
|
||||
const entryCurrentYear = new Date(currentYear, dateParts.month - 1, dateParts.day);
|
||||
if (dateParts.day == entryCurrentYear.getDate() && (!opts.max || opts.max.date.getTime() >= entryCurrentYear.getTime())) {
|
||||
//update dateParts
|
||||
dateParts.date.setFullYear(currentYear);
|
||||
dateParts.year = crrntyear;
|
||||
//update result
|
||||
currentResult.insert = [{
|
||||
pos: currentResult.pos + 1,
|
||||
c: currentYearNextPart[0]
|
||||
}, {
|
||||
pos: currentResult.pos + 2,
|
||||
c: currentYearNextPart[1]
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return currentResult;
|
||||
}
|
||||
|
||||
function isValidDate(dateParts, currentResult, opts) {
|
||||
if (!useDateObject) return true;
|
||||
if (dateParts.rawday === undefined
|
||||
|| (!isFinite(dateParts.rawday) && new Date(dateParts.date.getFullYear(), isFinite(dateParts.rawmonth) ? dateParts.month : dateParts.date.getMonth() + 1, 0).getDate() >= dateParts.day)
|
||||
|| (dateParts.day == "29" && (!isFinite(dateParts.rawyear) || dateParts.rawyear === undefined || dateParts.rawyear === ""))
|
||||
|| new Date(dateParts.date.getFullYear(), isFinite(dateParts.rawmonth) ? dateParts.month : dateParts.date.getMonth() + 1, 0).getDate() >= dateParts.day) {
|
||||
return currentResult;
|
||||
} else { //take corrective action if possible
|
||||
if (dateParts.day == "29") {
|
||||
var tokenMatch = getTokenMatch(currentResult.pos, opts);
|
||||
if (tokenMatch.targetMatch[0] === "yyyy" && currentResult.pos - tokenMatch.targetMatchIndex === 2) {
|
||||
currentResult.remove = currentResult.pos + 1;
|
||||
return currentResult;
|
||||
}
|
||||
} else if (dateParts.month == "02" && dateParts.day == "30" && currentResult.c !== undefined) {
|
||||
dateParts.day = "03";
|
||||
dateParts.date.setDate(3);
|
||||
dateParts.date.setMonth(1);
|
||||
currentResult.insert = [{pos: currentResult.pos, c: "0"}, {pos: currentResult.pos + 1, c: currentResult.c}];
|
||||
currentResult.caret = seekNext.call(this, currentResult.pos + 1);
|
||||
return currentResult;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isDateInRange(dateParts, result, opts, maskset, fromCheckval) {
|
||||
if (!result) return result;
|
||||
if (result && opts.min) {
|
||||
if (/*useDateObject && (dateParts["year"] === undefined || dateParts["yearSet"]) && */opts.min.date.getTime() === opts.min.date.getTime()) {
|
||||
let match;
|
||||
dateParts.reset();
|
||||
getTokenizer(opts).lastIndex = 0;
|
||||
while ((match = getTokenizer(opts).exec(opts.inputFormat))) {
|
||||
var fcode;
|
||||
if ((fcode = formatcode(match))) {
|
||||
if (fcode[3]) {
|
||||
var setFn = fcode[1];
|
||||
var current = dateParts[fcode[2]],
|
||||
minVal = opts.min[fcode[2]],
|
||||
maxVal = opts.max ? opts.max[fcode[2]] : minVal,
|
||||
curVal = [];
|
||||
|
||||
let forceCurrentValue = false;
|
||||
for (let i = 0; i < minVal.length; i++) {
|
||||
if (maskset.validPositions[i + match.index] === undefined && !forceCurrentValue) {
|
||||
curVal[i] = minVal[i];
|
||||
// ADD +1 to whoile
|
||||
if (fcode[2] === "year" && current.length - 1 == i && minVal != maxVal)
|
||||
curVal = (parseInt(curVal.join("")) + 1).toString().split("");
|
||||
if (fcode[2] === "ampm" && minVal != maxVal && opts.min.date.getTime() > dateParts.date.getTime())
|
||||
curVal[i] = maxVal[i];
|
||||
} else {
|
||||
curVal[i] = current[i];
|
||||
forceCurrentValue = forceCurrentValue || current[i] > minVal[i];
|
||||
}
|
||||
}
|
||||
|
||||
setFn.call(dateParts._date, curVal.join(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = opts.min.date.getTime() <= dateParts.date.getTime();
|
||||
dateParts.reInit();
|
||||
}
|
||||
}
|
||||
|
||||
if (result && opts.max) {
|
||||
if (opts.max.date.getTime() === opts.max.date.getTime()) {
|
||||
result = opts.max.date.getTime() >= dateParts.date.getTime();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//parse the given format and return a mask pattern
|
||||
//when a dateObjValue is passed a datestring in the requested format is returned
|
||||
function parse(format, dateObjValue, opts, raw) {
|
||||
//parse format to regex string
|
||||
var mask = "", match, fcode;
|
||||
getTokenizer(opts).lastIndex = 0;
|
||||
while ((match = getTokenizer(opts).exec(format))) {
|
||||
if (dateObjValue === undefined) {
|
||||
if ((fcode = formatcode(match))) {
|
||||
mask += "(" + fcode[0] + ")";
|
||||
} else {
|
||||
switch (match[0]) {
|
||||
case "[":
|
||||
mask += "(";
|
||||
break;
|
||||
case "]":
|
||||
mask += ")?";
|
||||
break;
|
||||
default:
|
||||
mask += escapeRegex(match[0]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((fcode = formatcode(match))) {
|
||||
if (raw !== true && fcode[3]) {
|
||||
var getFn = fcode[3];
|
||||
mask += getFn.call(dateObjValue.date);
|
||||
} else if (fcode[2]) {
|
||||
mask += dateObjValue["raw" + fcode[2]];
|
||||
} else {
|
||||
mask += match[0];
|
||||
}
|
||||
} else {
|
||||
mask += match[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
//padding function
|
||||
function pad(val, len, right) {
|
||||
val = String(val);
|
||||
len = len || 2;
|
||||
while (val.length < len) val = right ? val + "0" : "0" + val;
|
||||
return val;
|
||||
}
|
||||
|
||||
function analyseMask(mask, format, opts) {
|
||||
if (typeof mask === "string") {
|
||||
return new DateObject(mask, format, opts);
|
||||
} else if (mask && typeof mask === "object" && Object.prototype.hasOwnProperty.call(mask, "date")) {
|
||||
return mask;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function importDate(dateObj, opts) {
|
||||
return parse(opts.inputFormat, {date: dateObj}, opts);
|
||||
}
|
||||
|
||||
function getTokenMatch(pos, opts) {
|
||||
var calcPos = 0, targetMatch, match, matchLength = 0;
|
||||
getTokenizer(opts).lastIndex = 0;
|
||||
while ((match = getTokenizer(opts).exec(opts.inputFormat))) {
|
||||
var dynMatches = new RegExp("\\d+$").exec(match[0]);
|
||||
matchLength = dynMatches ? parseInt(dynMatches[0]) : match[0].length;
|
||||
calcPos += matchLength;
|
||||
if (calcPos >= pos + 1) {
|
||||
targetMatch = match;
|
||||
match = getTokenizer(opts).exec(opts.inputFormat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
targetMatchIndex: calcPos - matchLength,
|
||||
nextMatch: match,
|
||||
targetMatch: targetMatch
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Inputmask.extendAliases({
|
||||
"datetime": {
|
||||
mask: function (opts) {
|
||||
//do not allow numeric input in datetime alias
|
||||
opts.numericInput = false;
|
||||
|
||||
//localize
|
||||
formatCode.S = opts.i18n.ordinalSuffix.join("|");
|
||||
|
||||
opts.inputFormat = formatAlias[opts.inputFormat] || opts.inputFormat; //resolve possible formatAlias
|
||||
opts.displayFormat = formatAlias[opts.displayFormat] || opts.displayFormat || opts.inputFormat; //resolve possible formatAlias
|
||||
opts.outputFormat = formatAlias[opts.outputFormat] || opts.outputFormat || opts.inputFormat; //resolve possible formatAlias
|
||||
opts.placeholder = opts.placeholder !== "" ? opts.placeholder : opts.inputFormat.replace(/[[\]]/, "");
|
||||
opts.regex = parse(opts.inputFormat, undefined, opts);
|
||||
opts.min = analyseMask(opts.min, opts.inputFormat, opts);
|
||||
opts.max = analyseMask(opts.max, opts.inputFormat, opts);
|
||||
return null; //migrate to regex mask
|
||||
},
|
||||
placeholder: "", //set default as none (~ auto); when a custom placeholder is passed it will be used
|
||||
inputFormat: "isoDateTime", //format used to input the date
|
||||
displayFormat: null, //visual format when the input looses focus
|
||||
outputFormat: null, //unmasking format
|
||||
min: null, //needs to be in the same format as the inputfornat
|
||||
max: null, //needs to be in the same format as the inputfornat,
|
||||
skipOptionalPartCharacter: "",
|
||||
// Internationalization strings
|
||||
i18n: {
|
||||
dayNames: [
|
||||
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
|
||||
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
|
||||
],
|
||||
monthNames: [
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
|
||||
],
|
||||
ordinalSuffix: ["st", "nd", "rd", "th"]
|
||||
},
|
||||
preValidation: function (buffer, pos, c, isSelection, opts, maskset, caretPos, strict) {
|
||||
if (strict) return true;
|
||||
if (isNaN(c) && buffer[pos] !== c) {
|
||||
var tokenMatch = getTokenMatch(pos, opts);
|
||||
if (tokenMatch.nextMatch && tokenMatch.nextMatch[0] === c && tokenMatch.targetMatch[0].length > 1) {
|
||||
var validator = formatCode[tokenMatch.targetMatch[0]][0];
|
||||
if (new RegExp(validator).test("0" + buffer[pos - 1])) {
|
||||
buffer[pos] = buffer[pos - 1];
|
||||
buffer[pos - 1] = "0";
|
||||
return {
|
||||
fuzzy: true,
|
||||
buffer: buffer,
|
||||
refreshFromBuffer: {start: pos - 1, end: pos + 1},
|
||||
pos: pos + 1
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
postValidation: function (buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval) {
|
||||
const inputmask = this;
|
||||
|
||||
if (strict) return true;
|
||||
var tokenMatch, validator;
|
||||
if (currentResult === false) { //try some shifting
|
||||
tokenMatch = getTokenMatch(pos + 1, opts);
|
||||
if (tokenMatch.targetMatch && tokenMatch.targetMatchIndex === pos && tokenMatch.targetMatch[0].length > 1 && formatCode[tokenMatch.targetMatch[0]] !== undefined) {
|
||||
validator = formatCode[tokenMatch.targetMatch[0]][0];
|
||||
} else {
|
||||
tokenMatch = getTokenMatch(pos + 2, opts);
|
||||
if (tokenMatch.targetMatch && tokenMatch.targetMatchIndex === pos + 1 && tokenMatch.targetMatch[0].length > 1 && formatCode[tokenMatch.targetMatch[0]] !== undefined) {
|
||||
validator = formatCode[tokenMatch.targetMatch[0]][0];
|
||||
}
|
||||
}
|
||||
if (validator !== undefined) {
|
||||
if (maskset.validPositions[pos + 1] !== undefined && new RegExp(validator).test(c + "0")) {
|
||||
buffer[pos] = c;
|
||||
buffer[pos + 1] = "0";
|
||||
currentResult = {
|
||||
//insert: [{pos: pos, c: "0"}, {pos: pos + 1, c: c}],
|
||||
pos: pos + 2, //this will triggeer a refreshfrombuffer
|
||||
caret: pos
|
||||
};
|
||||
} else if (new RegExp(validator).test("0" + c)) {
|
||||
buffer[pos] = "0";
|
||||
buffer[pos + 1] = c;
|
||||
currentResult = {
|
||||
//insert: [{pos: pos, c: "0"}, {pos: pos + 1, c: c}],
|
||||
pos: pos + 2 //this will triggeer a refreshfrombuffer
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (currentResult === false) return currentResult;
|
||||
}
|
||||
|
||||
if (currentResult.fuzzy) {
|
||||
buffer = currentResult.buffer;
|
||||
pos = currentResult.pos;
|
||||
}
|
||||
|
||||
//full validate target
|
||||
tokenMatch = getTokenMatch(pos, opts);
|
||||
if (tokenMatch.targetMatch && tokenMatch.targetMatch[0] && formatCode[tokenMatch.targetMatch[0]] !== undefined) {
|
||||
let fcode = formatCode[tokenMatch.targetMatch[0]];
|
||||
validator = fcode[0];
|
||||
var part = buffer.slice(tokenMatch.targetMatchIndex, tokenMatch.targetMatchIndex + tokenMatch.targetMatch[0].length);
|
||||
if (new RegExp(validator).test(part.join("")) === false && tokenMatch.targetMatch[0].length === 2 && maskset.validPositions[tokenMatch.targetMatchIndex] && maskset.validPositions[tokenMatch.targetMatchIndex + 1]) {
|
||||
maskset.validPositions[tokenMatch.targetMatchIndex + 1].input = "0";
|
||||
}
|
||||
if (fcode[2] == "year") {
|
||||
var _buffer = getMaskTemplate.call(inputmask, false, 1, undefined, true);
|
||||
for (let i = pos + 1; i < buffer.length; i++) {
|
||||
buffer[i] = _buffer[i];
|
||||
delete maskset.validPositions[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var result = currentResult, dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts);
|
||||
if (result && dateParts.date.getTime() === dateParts.date.getTime()) { //check for a valid date ~ an invalid date returns NaN which isn't equal
|
||||
if (opts.prefillYear) result = prefillYear(dateParts, result, opts);
|
||||
result = isValidDate.call(inputmask, dateParts, result, opts);
|
||||
result = isDateInRange(dateParts, result, opts, maskset, fromCheckval);
|
||||
}
|
||||
|
||||
if (pos !== undefined && result && currentResult.pos !== pos) {
|
||||
return {
|
||||
buffer: parse(opts.inputFormat, dateParts, opts).split(""),
|
||||
refreshFromBuffer: {start: pos, end: currentResult.pos},
|
||||
pos: currentResult.caret || currentResult.pos //correct caret position
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
onKeyDown: function (e, buffer, caretPos, opts) {
|
||||
var input = this;
|
||||
if (e.ctrlKey && e.keyCode === keyCode.RIGHT) {
|
||||
input.inputmask._valueSet(importDate(new Date(), opts));
|
||||
$(input).trigger("setvalue");
|
||||
}
|
||||
},
|
||||
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
||||
return unmaskedValue ? parse(opts.outputFormat, analyseMask(maskedValue, opts.inputFormat, opts), opts, true) : unmaskedValue;
|
||||
},
|
||||
casing: function (elem, test, pos, validPositions) {
|
||||
if (test.nativeDef.indexOf("[ap]") == 0) return elem.toLowerCase();
|
||||
if (test.nativeDef.indexOf("[AP]") == 0) return elem.toUpperCase();
|
||||
return elem;
|
||||
},
|
||||
onBeforeMask: function (initialValue, opts) {
|
||||
if (Object.prototype.toString.call(initialValue) === "[object Date]") {
|
||||
initialValue = importDate(initialValue, opts);
|
||||
}
|
||||
|
||||
return initialValue;
|
||||
},
|
||||
insertMode: false,
|
||||
shiftPositions: false,
|
||||
keepStatic: false,
|
||||
inputmode: "numeric",
|
||||
prefillYear: true //Allows to disable prefill for datetime year.
|
||||
}
|
||||
});
|
133
node_modules/inputmask/lib/extensions/inputmask.extensions.js
generated
vendored
Normal file
133
node_modules/inputmask/lib/extensions/inputmask.extensions.js
generated
vendored
Normal file
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
Input Mask plugin extensions
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
import Inputmask from "../inputmask";
|
||||
import {getLastValidPosition} from "../positioning";
|
||||
import {getMaskTemplate} from "../validation-tests";
|
||||
//extra definitions
|
||||
Inputmask.extendDefinitions({
|
||||
"A": {
|
||||
validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
|
||||
casing: "upper" //auto uppercasing
|
||||
},
|
||||
"&": { //alfanumeric uppercasing
|
||||
validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
|
||||
casing: "upper"
|
||||
},
|
||||
"#": { //hexadecimal
|
||||
validator: "[0-9A-Fa-f]",
|
||||
casing: "upper"
|
||||
}
|
||||
});
|
||||
|
||||
var ipValidatorRegex = new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]");
|
||||
|
||||
function ipValidator(chrs, maskset, pos, strict, opts) {
|
||||
if (pos - 1 > -1 && maskset.buffer[pos - 1] !== ".") {
|
||||
chrs = maskset.buffer[pos - 1] + chrs;
|
||||
if (pos - 2 > -1 && maskset.buffer[pos - 2] !== ".") {
|
||||
chrs = maskset.buffer[pos - 2] + chrs;
|
||||
} else chrs = "0" + chrs;
|
||||
} else chrs = "00" + chrs;
|
||||
return ipValidatorRegex.test(chrs);
|
||||
}
|
||||
|
||||
|
||||
Inputmask.extendAliases({
|
||||
"cssunit": {
|
||||
regex: "[+-]?[0-9]+\\.?([0-9]+)?(px|em|rem|ex|%|in|cm|mm|pt|pc)"
|
||||
},
|
||||
"url": { //needs update => https://en.wikipedia.org/wiki/URL
|
||||
regex: "(https?|ftp)://.*",
|
||||
autoUnmask: false,
|
||||
keepStatic: false,
|
||||
tabThrough: true
|
||||
},
|
||||
"ip": { //ip-address mask
|
||||
mask: "i{1,3}.j{1,3}.k{1,3}.l{1,3}",
|
||||
definitions: {
|
||||
"i": {
|
||||
validator: ipValidator
|
||||
},
|
||||
"j": {
|
||||
validator: ipValidator
|
||||
},
|
||||
"k": {
|
||||
validator: ipValidator
|
||||
},
|
||||
"l": {
|
||||
validator: ipValidator
|
||||
}
|
||||
},
|
||||
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
||||
return maskedValue;
|
||||
},
|
||||
inputmode: "decimal",
|
||||
substitutes: {",": "."}
|
||||
},
|
||||
"email": {
|
||||
//https://en.wikipedia.org/wiki/Domain_name#Domain_name_space
|
||||
//https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
|
||||
//should be extended with the toplevel domains at the end
|
||||
mask: function (opts) {
|
||||
var emailMask = "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]";
|
||||
var mask = emailMask;
|
||||
if (opts.separator) {
|
||||
for (let i = 0; i < opts.quantifier; i++) {
|
||||
mask += `[${opts.separator}${emailMask}]`;
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
return opts.separator ? `${emailMask}(${opts.separator}${emailMask}){*}` : emailMask;
|
||||
},
|
||||
greedy: false,
|
||||
casing: "lower",
|
||||
separator: null,
|
||||
quantifier: 5,
|
||||
skipOptionalPartCharacter: "",
|
||||
onBeforePaste: function (pastedValue, opts) {
|
||||
pastedValue = pastedValue.toLowerCase();
|
||||
return pastedValue.replace("mailto:", "");
|
||||
},
|
||||
definitions: {
|
||||
"*": {
|
||||
validator: "[0-9\uFF11-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5!#$%&'*+/=?^_`{|}~-]"
|
||||
},
|
||||
"-": {
|
||||
validator: "[0-9A-Za-z-]"
|
||||
}
|
||||
},
|
||||
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
||||
return maskedValue;
|
||||
},
|
||||
inputmode: "email"
|
||||
},
|
||||
"mac": {
|
||||
mask: "##:##:##:##:##:##"
|
||||
},
|
||||
//https://en.wikipedia.org/wiki/Vehicle_identification_number
|
||||
// see issue #1199
|
||||
"vin": {
|
||||
mask: "V{13}9{4}",
|
||||
definitions: {
|
||||
"V": {
|
||||
validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
|
||||
casing: "upper"
|
||||
}
|
||||
},
|
||||
clearIncomplete: true,
|
||||
autoUnmask: true
|
||||
},
|
||||
//http://rion.io/2013/09/10/validating-social-security-numbers-through-regular-expressions-2/
|
||||
//https://en.wikipedia.org/wiki/Social_Security_number
|
||||
"ssn": {
|
||||
mask: "999-99-9999",
|
||||
postValidation: function (buffer, pos, c, currentResult, opts, maskset, strict) {
|
||||
var bffr = getMaskTemplate.call(this, true, getLastValidPosition.call(this), true, true);
|
||||
return /^(?!219-09-9999|078-05-1120)(?!666|000|9.{2}).{3}-(?!00).{2}-(?!0{4}).{4}$/.test(bffr.join(""));
|
||||
}
|
||||
},
|
||||
});
|
631
node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js
generated
vendored
Normal file
631
node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js
generated
vendored
Normal file
|
@ -0,0 +1,631 @@
|
|||
/*
|
||||
Input Mask plugin extensions
|
||||
http://github.com/RobinHerbots/jquery.inputmask
|
||||
Copyright (c) Robin Herbots
|
||||
Licensed under the MIT license
|
||||
*/
|
||||
import Inputmask from "../inputmask";
|
||||
import keyCode from "../keycode.json";
|
||||
import escapeRegex from "../escapeRegex";
|
||||
import {seekNext} from "../positioning";
|
||||
|
||||
const $ = Inputmask.dependencyLib;
|
||||
|
||||
function autoEscape(txt, opts) {
|
||||
var escapedTxt = "";
|
||||
for (var i = 0; i < txt.length; i++) {
|
||||
if (Inputmask.prototype.definitions[txt.charAt(i)] ||
|
||||
opts.definitions[txt.charAt(i)] ||
|
||||
opts.optionalmarker[0] === txt.charAt(i) ||
|
||||
opts.optionalmarker[1] === txt.charAt(i) ||
|
||||
opts.quantifiermarker[0] === txt.charAt(i) ||
|
||||
opts.quantifiermarker[1] === txt.charAt(i) ||
|
||||
opts.groupmarker[0] === txt.charAt(i) ||
|
||||
opts.groupmarker[1] === txt.charAt(i) ||
|
||||
opts.alternatormarker === txt.charAt(i)) {
|
||||
escapedTxt += "\\" + txt.charAt(i);
|
||||
} else {
|
||||
escapedTxt += txt.charAt(i);
|
||||
}
|
||||
}
|
||||
return escapedTxt;
|
||||
}
|
||||
|
||||
function alignDigits(buffer, digits, opts, force) {
|
||||
if (buffer.length > 0 && digits > 0 && (!opts.digitsOptional || force)) {
|
||||
var radixPosition = buffer.indexOf(opts.radixPoint), negationBack = false;
|
||||
if (opts.negationSymbol.back === buffer[buffer.length - 1]) {
|
||||
negationBack = true;
|
||||
buffer.length--;
|
||||
}
|
||||
|
||||
if (radixPosition === -1) {
|
||||
buffer.push(opts.radixPoint);
|
||||
radixPosition = buffer.length - 1;
|
||||
}
|
||||
for (var i = 1; i <= digits; i++) {
|
||||
if (!isFinite(buffer[radixPosition + i])) {
|
||||
buffer[radixPosition + i] = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (negationBack)
|
||||
buffer.push(opts.negationSymbol.back);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function findValidator(symbol, maskset) {
|
||||
var posNdx = 0;
|
||||
if (symbol === "+") {
|
||||
for (posNdx in maskset.validPositions) ;
|
||||
posNdx = seekNext.call(this, parseInt(posNdx));
|
||||
}
|
||||
for (var tstNdx in maskset.tests) {
|
||||
tstNdx = parseInt(tstNdx);
|
||||
if (tstNdx >= posNdx) {
|
||||
for (var ndx = 0, ndxl = maskset.tests[tstNdx].length; ndx < ndxl; ndx++) {
|
||||
if ((maskset.validPositions[tstNdx] === undefined || symbol === "-") && maskset.tests[tstNdx][ndx].match.def === symbol) {
|
||||
return tstNdx + ((maskset.validPositions[tstNdx] !== undefined && symbol !== "-") ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return posNdx;
|
||||
}
|
||||
|
||||
function findValid(symbol, maskset) {
|
||||
var ret = -1;
|
||||
for (let ndx in maskset.validPositions) {
|
||||
let tst = maskset.validPositions[ndx];
|
||||
if (tst && tst.match.def === symbol) {
|
||||
ret = parseInt(ndx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function parseMinMaxOptions(opts) {
|
||||
if (opts.parseMinMaxOptions === undefined) {
|
||||
// convert min and max options
|
||||
if (opts.min !== null) {
|
||||
opts.min = opts.min.toString().replace(new RegExp(escapeRegex(opts.groupSeparator), "g"), "");
|
||||
if (opts.radixPoint === ",") opts.min = opts.min.replace(opts.radixPoint, ".");
|
||||
opts.min = isFinite(opts.min) ? parseFloat(opts.min) : NaN;
|
||||
if (isNaN(opts.min)) opts.min = Number.MIN_VALUE;
|
||||
}
|
||||
if (opts.max !== null) {
|
||||
opts.max = opts.max.toString().replace(new RegExp(escapeRegex(opts.groupSeparator), "g"), "");
|
||||
if (opts.radixPoint === ",") opts.max = opts.max.replace(opts.radixPoint, ".");
|
||||
opts.max = isFinite(opts.max) ? parseFloat(opts.max) : NaN;
|
||||
if (isNaN(opts.max)) opts.max = Number.MAX_VALUE;
|
||||
}
|
||||
opts.parseMinMaxOptions = "done";
|
||||
}
|
||||
}
|
||||
|
||||
function genMask(opts) {
|
||||
opts.repeat = 0;
|
||||
//treat equal separator and radixpoint
|
||||
if (opts.groupSeparator === opts.radixPoint && opts.digits && opts.digits !== "0") {
|
||||
if (opts.radixPoint === ".") {
|
||||
opts.groupSeparator = ",";
|
||||
} else if (opts.radixPoint === ",") {
|
||||
opts.groupSeparator = ".";
|
||||
} else {
|
||||
opts.groupSeparator = "";
|
||||
}
|
||||
}
|
||||
//prevent conflict with default skipOptionalPartCharacter
|
||||
if (opts.groupSeparator === " ") {
|
||||
opts.skipOptionalPartCharacter = undefined;
|
||||
}
|
||||
|
||||
//enforce placeholder to single
|
||||
if (opts.placeholder.length > 1) {
|
||||
opts.placeholder = opts.placeholder.charAt(0);
|
||||
}
|
||||
//only allow radixfocus when placeholder = 0
|
||||
if (opts.positionCaretOnClick === "radixFocus" && opts.placeholder === "") {
|
||||
opts.positionCaretOnClick = "lvp";
|
||||
}
|
||||
|
||||
var decimalDef = "0", radixPointDef = opts.radixPoint;
|
||||
if (opts.numericInput === true && opts.__financeInput === undefined) { //finance people input style
|
||||
decimalDef = "1";
|
||||
opts.positionCaretOnClick = opts.positionCaretOnClick === "radixFocus" ? "lvp" : opts.positionCaretOnClick;
|
||||
opts.digitsOptional = false;
|
||||
if (isNaN(opts.digits)) opts.digits = 2;
|
||||
opts._radixDance = false;
|
||||
radixPointDef = (opts.radixPoint === "," ? "?" : "!");
|
||||
if (opts.radixPoint !== "" && opts.definitions[radixPointDef] === undefined) {
|
||||
//update separator definition
|
||||
opts.definitions[radixPointDef] = {};
|
||||
opts.definitions[radixPointDef].validator = "[" + opts.radixPoint + "]";
|
||||
opts.definitions[radixPointDef].placeholder = opts.radixPoint;
|
||||
opts.definitions[radixPointDef].static = true;
|
||||
opts.definitions[radixPointDef].generated = true; //forced marker as generated input
|
||||
}
|
||||
} else {
|
||||
opts.__financeInput = false; //needed to keep original selection when remasking
|
||||
opts.numericInput = true;
|
||||
}
|
||||
|
||||
var mask = "[+]", altMask;
|
||||
mask += autoEscape(opts.prefix, opts);
|
||||
if (opts.groupSeparator !== "") {
|
||||
if (opts.definitions[opts.groupSeparator] === undefined) {
|
||||
//update separatot definition
|
||||
opts.definitions[opts.groupSeparator] = {};
|
||||
opts.definitions[opts.groupSeparator].validator = "[" + opts.groupSeparator + "]";
|
||||
opts.definitions[opts.groupSeparator].placeholder = opts.groupSeparator;
|
||||
opts.definitions[opts.groupSeparator].static = true;
|
||||
opts.definitions[opts.groupSeparator].generated = true; //forced marker as generated input
|
||||
}
|
||||
mask += opts._mask(opts);
|
||||
} else {
|
||||
mask += "9{+}";
|
||||
}
|
||||
if (opts.digits !== undefined && opts.digits !== 0) {
|
||||
var dq = opts.digits.toString().split(",");
|
||||
if (isFinite(dq[0]) && dq[1] && isFinite(dq[1])) {
|
||||
mask += radixPointDef + decimalDef + "{" + opts.digits + "}";
|
||||
} else if (isNaN(opts.digits) || parseInt(opts.digits) > 0) {
|
||||
if (opts.digitsOptional || opts.jitMasking) {
|
||||
altMask = mask + radixPointDef + decimalDef + "{0," + opts.digits + "}";
|
||||
// mask += "[" + opts.radixPoint + "]";
|
||||
opts.keepStatic = true;
|
||||
} else {
|
||||
mask += radixPointDef + decimalDef + "{" + opts.digits + "}";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
opts.inputmode = "numeric";
|
||||
}
|
||||
mask += autoEscape(opts.suffix, opts);
|
||||
mask += "[-]";
|
||||
|
||||
if (altMask) {
|
||||
mask = [(altMask + autoEscape(opts.suffix, opts) + "[-]"), mask];
|
||||
}
|
||||
|
||||
|
||||
opts.greedy = false; //enforce greedy false
|
||||
|
||||
parseMinMaxOptions(opts);
|
||||
if (opts.radixPoint !== "")
|
||||
opts.substitutes[opts.radixPoint == "." ? "," : "."] = opts.radixPoint;
|
||||
// console.log(mask);
|
||||
return mask;
|
||||
}
|
||||
|
||||
function hanndleRadixDance(pos, c, radixPos, maskset, opts) {
|
||||
if (opts._radixDance && opts.numericInput && c !== opts.negationSymbol.back) {
|
||||
if (pos <= radixPos && (radixPos > 0 || c == opts.radixPoint) && (maskset.validPositions[pos - 1] === undefined || maskset.validPositions[pos - 1].input !== opts.negationSymbol.back)) {
|
||||
pos -= 1;
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
function decimalValidator(chrs, maskset, pos, strict, opts) {
|
||||
var radixPos = maskset.buffer ? maskset.buffer.indexOf(opts.radixPoint) : -1,
|
||||
result = (radixPos !== -1 || (strict && opts.jitMasking)) && new RegExp(opts.definitions["9"].validator).test(chrs);
|
||||
if (opts._radixDance && radixPos !== -1 && result && maskset.validPositions[radixPos] == undefined) {
|
||||
return {
|
||||
insert: {
|
||||
pos: radixPos === pos ? radixPos + 1 : radixPos,
|
||||
c: opts.radixPoint
|
||||
},
|
||||
pos: pos
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function checkForLeadingZeroes(buffer, opts) {
|
||||
//check leading zeros
|
||||
var numberMatches = new RegExp("(^" + (opts.negationSymbol.front !== "" ? escapeRegex(opts.negationSymbol.front) + "?" : "") + escapeRegex(opts.prefix) + ")(.*)(" + escapeRegex(opts.suffix) + (opts.negationSymbol.back != "" ? escapeRegex(opts.negationSymbol.back) + "?" : "") + "$)").exec(buffer.slice().reverse().join("")),
|
||||
number = numberMatches ? numberMatches[2] : "", leadingzeroes = false;
|
||||
if (number) {
|
||||
number = number.split(opts.radixPoint.charAt(0))[0];
|
||||
leadingzeroes = new RegExp("^[0" + opts.groupSeparator + "]*").exec(number);
|
||||
}
|
||||
return leadingzeroes && (leadingzeroes[0].length > 1 || leadingzeroes[0].length > 0 && leadingzeroes[0].length < number.length) ? leadingzeroes : false;
|
||||
}
|
||||
|
||||
//number aliases
|
||||
Inputmask.extendAliases({
|
||||
"numeric": {
|
||||
mask: genMask,
|
||||
_mask: function (opts) {
|
||||
return "(" + opts.groupSeparator + "999){+|1}";
|
||||
},
|
||||
digits: "*", //number of fractionalDigits
|
||||
digitsOptional: true,
|
||||
enforceDigitsOnBlur: false,
|
||||
radixPoint: ".",
|
||||
positionCaretOnClick: "radixFocus",
|
||||
_radixDance: true,
|
||||
groupSeparator: "",
|
||||
allowMinus: true,
|
||||
negationSymbol: {
|
||||
front: "-", //"("
|
||||
back: "" //")"
|
||||
},
|
||||
prefix: "",
|
||||
suffix: "",
|
||||
min: null, //minimum value
|
||||
max: null, //maximum value
|
||||
SetMaxOnOverflow: false,
|
||||
step: 1,
|
||||
inputType: "text", //number ~ specify that values which are set are in textform (radix point is same as in the options) or in numberform (radixpoint = .)
|
||||
unmaskAsNumber: false,
|
||||
roundingFN: Math.round, //Math.floor , fn(x)
|
||||
inputmode: "decimal",
|
||||
shortcuts: {k: "1000", m: "1000000"},
|
||||
//global options
|
||||
placeholder: "0",
|
||||
greedy: false,
|
||||
rightAlign: true,
|
||||
insertMode: true,
|
||||
autoUnmask: false,
|
||||
skipOptionalPartCharacter: "",
|
||||
usePrototypeDefinitions: false,
|
||||
stripLeadingZeroes: true,
|
||||
definitions: {
|
||||
"0": {
|
||||
validator: decimalValidator
|
||||
},
|
||||
"1": {
|
||||
validator: decimalValidator,
|
||||
definitionSymbol: "9"
|
||||
},
|
||||
"9": { //\uFF11-\uFF19 #1606
|
||||
validator: "[0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]",
|
||||
definitionSymbol: "*"
|
||||
},
|
||||
"+": {
|
||||
validator: function (chrs, maskset, pos, strict, opts) {
|
||||
return (opts.allowMinus && (chrs === "-" || chrs === opts.negationSymbol.front));
|
||||
|
||||
}
|
||||
},
|
||||
"-": {
|
||||
validator: function (chrs, maskset, pos, strict, opts) {
|
||||
return (opts.allowMinus && chrs === opts.negationSymbol.back);
|
||||
}
|
||||
}
|
||||
},
|
||||
preValidation: function (buffer, pos, c, isSelection, opts, maskset, caretPos, strict) {
|
||||
const inputmask = this;
|
||||
|
||||
if (opts.__financeInput !== false && c === opts.radixPoint) return false;
|
||||
var radixPos = buffer.indexOf(opts.radixPoint), initPos = pos;
|
||||
pos = hanndleRadixDance(pos, c, radixPos, maskset, opts);
|
||||
if (c === "-" || c === opts.negationSymbol.front) {
|
||||
if (opts.allowMinus !== true) return false;
|
||||
var isNegative = false,
|
||||
front = findValid("+", maskset), back = findValid("-", maskset);
|
||||
if (front !== -1) {
|
||||
isNegative = [front, back];
|
||||
}
|
||||
|
||||
return isNegative !== false ? {
|
||||
remove: isNegative,
|
||||
caret: initPos - opts.negationSymbol.back.length
|
||||
} : {
|
||||
insert: [
|
||||
{
|
||||
pos: findValidator.call(inputmask, "+", maskset),
|
||||
c: opts.negationSymbol.front,
|
||||
fromIsValid: true
|
||||
},
|
||||
{
|
||||
pos: findValidator.call(inputmask, "-", maskset),
|
||||
c: opts.negationSymbol.back,
|
||||
fromIsValid: undefined
|
||||
}],
|
||||
caret: initPos + opts.negationSymbol.back.length
|
||||
};
|
||||
}
|
||||
|
||||
if (c === opts.groupSeparator) {
|
||||
return {caret: initPos};
|
||||
}
|
||||
|
||||
if (strict) return true;
|
||||
if (radixPos !== -1 && (opts._radixDance === true && isSelection === false && c === opts.radixPoint && (opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) && radixPos !== pos)) {
|
||||
return {
|
||||
"caret": opts._radixDance && pos === radixPos - 1 ? radixPos + 1 : radixPos
|
||||
};
|
||||
}
|
||||
if (opts.__financeInput === false) {
|
||||
if (isSelection) {
|
||||
if (opts.digitsOptional) {
|
||||
return {rewritePosition: caretPos.end};
|
||||
} else if (!opts.digitsOptional) {
|
||||
if (caretPos.begin > radixPos && caretPos.end <= radixPos) {
|
||||
if (c === opts.radixPoint) {
|
||||
return {
|
||||
insert: {pos: radixPos + 1, c: "0", fromIsValid: true},
|
||||
rewritePosition: radixPos
|
||||
};
|
||||
} else {
|
||||
return {rewritePosition: radixPos + 1};
|
||||
}
|
||||
} else if (caretPos.begin < radixPos) {
|
||||
return {rewritePosition: caretPos.begin - 1};
|
||||
}
|
||||
}
|
||||
} else if (!opts.showMaskOnHover && !opts.showMaskOnFocus && !opts.digitsOptional && opts.digits > 0 && this.__valueGet.call(this.el) === "") {
|
||||
return {rewritePosition: radixPos};
|
||||
}
|
||||
}
|
||||
return {rewritePosition: pos};
|
||||
},
|
||||
postValidation: function (buffer, pos, c, currentResult, opts, maskset, strict) {
|
||||
if (currentResult === false) return currentResult;
|
||||
if (strict) return true;
|
||||
if (opts.min !== null || opts.max !== null) {
|
||||
var unmasked = opts.onUnMask(buffer.slice().reverse().join(""), undefined, $.extend({}, opts, {
|
||||
unmaskAsNumber: true
|
||||
}));
|
||||
if (opts.min !== null && unmasked < opts.min && (unmasked.toString().length > opts.min.toString().length || unmasked < 0)) {
|
||||
return false;
|
||||
// return {
|
||||
// refreshFromBuffer: true,
|
||||
// buffer: alignDigits(opts.min.toString().replace(".", opts.radixPoint).split(""), opts.digits, opts).reverse()
|
||||
// };
|
||||
}
|
||||
|
||||
if (opts.max !== null && unmasked > opts.max) {
|
||||
return opts.SetMaxOnOverflow ? {
|
||||
refreshFromBuffer: true,
|
||||
buffer: alignDigits(opts.max.toString().replace(".", opts.radixPoint).split(""), opts.digits, opts).reverse()
|
||||
} : false;
|
||||
}
|
||||
}
|
||||
|
||||
return currentResult;
|
||||
},
|
||||
onUnMask: function (maskedValue, unmaskedValue, opts) {
|
||||
if (unmaskedValue === "" && opts.nullable === true) {
|
||||
return unmaskedValue;
|
||||
}
|
||||
var processValue = maskedValue.replace(opts.prefix, "");
|
||||
processValue = processValue.replace(opts.suffix, "");
|
||||
processValue = processValue.replace(new RegExp(escapeRegex(opts.groupSeparator), "g"), "");
|
||||
if (opts.placeholder.charAt(0) !== "") {
|
||||
processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0");
|
||||
}
|
||||
if (opts.unmaskAsNumber) {
|
||||
if (opts.radixPoint !== "" && processValue.indexOf(opts.radixPoint) !== -1) processValue = processValue.replace(escapeRegex.call(this, opts.radixPoint), ".");
|
||||
processValue = processValue.replace(new RegExp("^" + escapeRegex(opts.negationSymbol.front)), "-");
|
||||
processValue = processValue.replace(new RegExp(escapeRegex(opts.negationSymbol.back) + "$"), "");
|
||||
return Number(processValue);
|
||||
}
|
||||
return processValue;
|
||||
}
|
||||
,
|
||||
isComplete: function (buffer, opts) {
|
||||
var maskedValue = (opts.numericInput ? buffer.slice().reverse() : buffer).join("");
|
||||
maskedValue = maskedValue.replace(new RegExp("^" + escapeRegex(opts.negationSymbol.front)), "-");
|
||||
maskedValue = maskedValue.replace(new RegExp(escapeRegex(opts.negationSymbol.back) + "$"), "");
|
||||
maskedValue = maskedValue.replace(opts.prefix, "");
|
||||
maskedValue = maskedValue.replace(opts.suffix, "");
|
||||
maskedValue = maskedValue.replace(new RegExp(escapeRegex(opts.groupSeparator) + "([0-9]{3})", "g"), "$1");
|
||||
if (opts.radixPoint === ",") maskedValue = maskedValue.replace(escapeRegex(opts.radixPoint), ".");
|
||||
return isFinite(maskedValue);
|
||||
},
|
||||
onBeforeMask: function (initialValue, opts) {
|
||||
var radixPoint = opts.radixPoint || ",";
|
||||
if (isFinite(opts.digits)) opts.digits = parseInt(opts.digits);
|
||||
|
||||
if ((typeof initialValue == "number" || opts.inputType === "number") && radixPoint !== "") {
|
||||
initialValue = initialValue.toString().replace(".", radixPoint);
|
||||
}
|
||||
var isNagtive = initialValue.charAt(0) === "-" || initialValue.charAt(0) === opts.negationSymbol.front;
|
||||
var valueParts = initialValue.split(radixPoint),
|
||||
integerPart = valueParts[0].replace(/[^\-0-9]/g, ""),
|
||||
decimalPart = valueParts.length > 1 ? valueParts[1].replace(/[^0-9]/g, "") : "",
|
||||
forceDigits = valueParts.length > 1;
|
||||
|
||||
initialValue = integerPart + (decimalPart !== "" ? radixPoint + decimalPart : decimalPart);
|
||||
|
||||
var digits = 0;
|
||||
if (radixPoint !== "") {
|
||||
digits = !opts.digitsOptional ? opts.digits : (opts.digits < decimalPart.length ? opts.digits : decimalPart.length);
|
||||
if (decimalPart !== "" || !opts.digitsOptional) {
|
||||
var digitsFactor = Math.pow(10, digits || 1);
|
||||
|
||||
//make the initialValue a valid javascript number for the parsefloat
|
||||
initialValue = initialValue.replace(escapeRegex(radixPoint), ".");
|
||||
if (!isNaN(parseFloat(initialValue))) {
|
||||
initialValue = (opts.roundingFN(parseFloat(initialValue) * digitsFactor) / digitsFactor).toFixed(digits);
|
||||
}
|
||||
initialValue = initialValue.toString().replace(".", radixPoint);
|
||||
}
|
||||
}
|
||||
//this needs to be in a separate part and not directly in decimalPart to allow rounding
|
||||
if (opts.digits === 0 && initialValue.indexOf(radixPoint) !== -1) {
|
||||
initialValue = initialValue.substring(0, initialValue.indexOf(radixPoint));
|
||||
}
|
||||
|
||||
if (opts.min !== null || opts.max !== null) {
|
||||
var numberValue = initialValue.toString().replace(radixPoint, ".");
|
||||
if (opts.min !== null && numberValue < opts.min) {
|
||||
initialValue = opts.min.toString().replace(".", radixPoint);
|
||||
} else if (opts.max !== null && numberValue > opts.max) {
|
||||
initialValue = opts.max.toString().replace(".", radixPoint);
|
||||
}
|
||||
}
|
||||
|
||||
if (isNagtive && initialValue.charAt(0) !== "-") {
|
||||
initialValue = "-" + initialValue;
|
||||
}
|
||||
return alignDigits(initialValue.toString().split(""), digits, opts, forceDigits).join("");
|
||||
}
|
||||
,
|
||||
onBeforeWrite: function (e, buffer, caretPos, opts) {
|
||||
function stripBuffer(buffer, stripRadix) {
|
||||
if (opts.__financeInput !== false || stripRadix) {
|
||||
var position = buffer.indexOf(opts.radixPoint);
|
||||
if (position !== -1) {
|
||||
buffer.splice(position, 1);
|
||||
}
|
||||
}
|
||||
if (opts.groupSeparator !== "") {
|
||||
while ((position = buffer.indexOf(opts.groupSeparator)) !== -1) {
|
||||
buffer.splice(position, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
let result, leadingzeroes;
|
||||
if (opts.stripLeadingZeroes && (leadingzeroes = checkForLeadingZeroes(buffer, opts))) {
|
||||
const caretNdx = buffer.join("").lastIndexOf(leadingzeroes[0].split("").reverse().join("")) - (leadingzeroes[0] == leadingzeroes.input ? 0 : 1),
|
||||
offset = (leadingzeroes[0] == leadingzeroes.input ? 1 : 0);
|
||||
for (let i = leadingzeroes[0].length - offset; i > 0; i--) {
|
||||
delete this.maskset.validPositions[caretNdx + i];
|
||||
delete buffer[caretNdx + i];
|
||||
}
|
||||
}
|
||||
|
||||
if (e) {
|
||||
switch (e.type) {
|
||||
case "blur":
|
||||
case "checkval":
|
||||
if (opts.min !== null) {
|
||||
var unmasked = opts.onUnMask(buffer.slice().reverse().join(""), undefined, $.extend({}, opts, {
|
||||
unmaskAsNumber: true
|
||||
}));
|
||||
if (opts.min !== null && unmasked < opts.min) {
|
||||
return {
|
||||
refreshFromBuffer: true,
|
||||
buffer: alignDigits(opts.min.toString().replace(".", opts.radixPoint).split(""), opts.digits, opts).reverse()
|
||||
};
|
||||
}
|
||||
}
|
||||
if (buffer[buffer.length - 1] === opts.negationSymbol.front) { //strip negation symbol on blur when value is 0
|
||||
var nmbrMtchs = new RegExp("(^" + (opts.negationSymbol.front != "" ? escapeRegex(opts.negationSymbol.front) + "?" : "") + escapeRegex(opts.prefix) + ")(.*)(" + escapeRegex(opts.suffix) + (opts.negationSymbol.back != "" ? escapeRegex(opts.negationSymbol.back) + "?" : "") + "$)").exec(stripBuffer(buffer.slice(), true).reverse().join("")),
|
||||
number = nmbrMtchs ? nmbrMtchs[2] : "";
|
||||
if (number == 0) {
|
||||
result = {refreshFromBuffer: true, buffer: [0]};
|
||||
}
|
||||
} else if (opts.radixPoint !== "") { //strip radixpoint on blur when it is the latest char
|
||||
var radixNDX = buffer.indexOf(opts.radixPoint);
|
||||
if (radixNDX === opts.suffix.length) {
|
||||
if (result && result.buffer) {
|
||||
result.buffer.splice(0, 1 + opts.suffix.length);
|
||||
} else {
|
||||
buffer.splice(0, 1 + opts.suffix.length);
|
||||
result =
|
||||
{refreshFromBuffer: true, buffer: stripBuffer(buffer)};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.enforceDigitsOnBlur) {
|
||||
result = result || {};
|
||||
var bffr = (result && result.buffer) || buffer.slice().reverse();
|
||||
result.refreshFromBuffer = true;
|
||||
result.buffer = alignDigits(bffr, opts.digits, opts, true).reverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
onKeyDown: function (e, buffer, caretPos, opts) {
|
||||
var $input = $(this), bffr;
|
||||
var pattern, c = String.fromCharCode(e.keyCode).toLowerCase();
|
||||
if ((pattern = (opts.shortcuts && opts.shortcuts[c]))) {
|
||||
if (pattern.length > 1) {
|
||||
this.inputmask.__valueSet.call(this, parseFloat(this.inputmask.unmaskedvalue()) * parseInt(pattern));
|
||||
$input.trigger("setvalue");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (e.ctrlKey) {
|
||||
switch (e.keyCode) {
|
||||
case keyCode.UP:
|
||||
this.inputmask.__valueSet.call(this, parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step));
|
||||
$input.trigger("setvalue");
|
||||
return false;
|
||||
case keyCode.DOWN:
|
||||
this.inputmask.__valueSet.call(this, parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step));
|
||||
$input.trigger("setvalue");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!e.shiftKey && (e.keyCode === keyCode.DELETE || e.keyCode === keyCode.BACKSPACE || e.keyCode === keyCode.BACKSPACE_SAFARI) && caretPos.begin !== buffer.length) {
|
||||
if (buffer[e.keyCode === keyCode.DELETE ? caretPos.begin - 1 : caretPos.end] === opts.negationSymbol.front) {
|
||||
bffr = buffer.slice().reverse();
|
||||
if (opts.negationSymbol.front !== "") bffr.shift();
|
||||
if (opts.negationSymbol.back !== "") bffr.pop();
|
||||
$input.trigger("setvalue", [bffr.join(""), caretPos.begin]);
|
||||
return false;
|
||||
} else if (opts._radixDance === true) {
|
||||
var radixPos = buffer.indexOf(opts.radixPoint);
|
||||
if (!opts.digitsOptional) {
|
||||
if (radixPos !== -1 && (caretPos.begin < radixPos || caretPos.end < radixPos || (e.keyCode === keyCode.DELETE && caretPos.begin === radixPos))) {
|
||||
if (caretPos.begin === caretPos.end && (e.keyCode === keyCode.BACKSPACE || e.keyCode === keyCode.BACKSPACE_SAFARI)) { //only adjust when not a selection
|
||||
caretPos.begin++;
|
||||
}
|
||||
bffr = buffer.slice().reverse();
|
||||
bffr.splice(bffr.length - caretPos.begin, caretPos.begin - caretPos.end + 1);
|
||||
// console.log(caretPos);
|
||||
bffr = alignDigits(bffr, opts.digits, opts).join("");
|
||||
$input.trigger("setvalue", [bffr, caretPos.begin >= bffr.length ? radixPos + 1 : caretPos.begin]);
|
||||
return false;
|
||||
}
|
||||
} else if (radixPos === 0) {
|
||||
bffr = buffer.slice().reverse();
|
||||
bffr.pop();
|
||||
$input.trigger("setvalue", [bffr.join(""), caretPos.begin >= bffr.length ? bffr.length : caretPos.begin]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"currency": {
|
||||
prefix: "", //"$ ",
|
||||
groupSeparator: ",",
|
||||
alias: "numeric",
|
||||
digits: 2,
|
||||
digitsOptional: false
|
||||
},
|
||||
"decimal": {
|
||||
alias: "numeric"
|
||||
},
|
||||
"integer": {
|
||||
alias: "numeric",
|
||||
inputmode: "numeric",
|
||||
digits: 0
|
||||
},
|
||||
"percentage": {
|
||||
alias: "numeric",
|
||||
min: 0,
|
||||
max: 100,
|
||||
suffix: " %",
|
||||
digits: 0,
|
||||
allowMinus: false
|
||||
},
|
||||
"indianns": { //indian numbering system
|
||||
alias: "numeric",
|
||||
_mask: function (opts) {
|
||||
return "(" + opts.groupSeparator + "99){*|1}(" + opts.groupSeparator + "999){1|1}";
|
||||
},
|
||||
groupSeparator: ",",
|
||||
radixPoint: ".",
|
||||
placeholder: "0",
|
||||
digits: 2,
|
||||
digitsOptional: false
|
||||
}
|
||||
});
|
3
node_modules/inputmask/lib/global/window.js
generated
vendored
Normal file
3
node_modules/inputmask/lib/global/window.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
import canUseDOM from "../canUseDOM";
|
||||
|
||||
export default canUseDOM ? window : {};
|
252
node_modules/inputmask/lib/inputHandling.js
generated
vendored
Normal file
252
node_modules/inputmask/lib/inputHandling.js
generated
vendored
Normal file
|
@ -0,0 +1,252 @@
|
|||
import keyCode from "./keycode.json";
|
||||
import {getMaskTemplate, getPlaceholder, getTest} from "./validation-tests";
|
||||
import {
|
||||
caret,
|
||||
determineNewCaretPosition,
|
||||
getBuffer, getBufferTemplate,
|
||||
getLastValidPosition,
|
||||
isMask,
|
||||
resetMaskSet,
|
||||
seekNext
|
||||
} from "./positioning";
|
||||
import {isComplete, refreshFromBuffer} from "./validation";
|
||||
import {ie} from "./environment";
|
||||
import {EventHandlers} from "./eventhandlers";
|
||||
|
||||
|
||||
export {applyInputValue, clearOptionalTail, checkVal, HandleNativePlaceholder, unmaskedvalue, writeBuffer};
|
||||
|
||||
function applyInputValue(input, value) {
|
||||
const inputmask = input ? input.inputmask : this, opts = inputmask.opts;
|
||||
|
||||
input.inputmask.refreshValue = false;
|
||||
if (typeof opts.onBeforeMask === "function") value = opts.onBeforeMask.call(inputmask, value, opts) || value;
|
||||
value = value.toString().split("");
|
||||
checkVal(input, true, false, value);
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
if ((opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate.call(inputmask).join("") && getLastValidPosition.call(inputmask) === -1) {
|
||||
input.inputmask._valueSet("");
|
||||
}
|
||||
}
|
||||
|
||||
//todo put on prototype?
|
||||
function clearOptionalTail(buffer) {
|
||||
const inputmask = this;
|
||||
|
||||
buffer.length = 0;
|
||||
var template = getMaskTemplate.call(inputmask, true, 0, true, undefined, true), lmnt;
|
||||
while ((lmnt = template.shift()) !== undefined) buffer.push(lmnt);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
|
||||
const inputmask = input ? input.inputmask : this,
|
||||
maskset = inputmask.maskset,
|
||||
opts = inputmask.opts, $ = inputmask.dependencyLib;
|
||||
|
||||
var inputValue = nptvl.slice(),
|
||||
charCodes = "",
|
||||
initialNdx = -1,
|
||||
result = undefined, skipOptionalPartCharacter = opts.skipOptionalPartCharacter;
|
||||
opts.skipOptionalPartCharacter = ""; //see issue #2311
|
||||
|
||||
function isTemplateMatch(ndx, charCodes) {
|
||||
var targetTemplate = getMaskTemplate.call(inputmask, true, 0).slice(ndx, seekNext.call(inputmask, ndx, false, false)).join("").replace(/'/g, ""),
|
||||
charCodeNdx = targetTemplate.indexOf(charCodes);
|
||||
//strip spaces from targetTemplate
|
||||
while (charCodeNdx > 0 && targetTemplate[charCodeNdx - 1] === " ") charCodeNdx--;
|
||||
|
||||
var match = charCodeNdx === 0 && !isMask.call(inputmask, ndx)
|
||||
&& (getTest.call(inputmask, ndx).match.nativeDef === charCodes.charAt(0)
|
||||
|| (getTest.call(inputmask, ndx).match.static === true && getTest.call(inputmask, ndx).match.nativeDef === ("'" + charCodes.charAt(0)))
|
||||
|| (getTest.call(inputmask, ndx).match.nativeDef === " " && (getTest.call(inputmask, ndx + 1).match.nativeDef === charCodes.charAt(0)
|
||||
|| (getTest.call(inputmask, ndx + 1).match.static === true && getTest.call(inputmask, ndx + 1).match.nativeDef === ("'" + charCodes.charAt(0))))));
|
||||
|
||||
if (!match && charCodeNdx > 0 && !isMask.call(inputmask, ndx, false, true)) {
|
||||
var nextPos = seekNext.call(inputmask, ndx);
|
||||
if (inputmask.caretPos.begin < nextPos) {
|
||||
inputmask.caretPos = {begin: nextPos};
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
resetMaskSet.call(inputmask);
|
||||
maskset.tests = {}; //reset tests ~ possible after alternating
|
||||
initialNdx = opts.radixPoint ? determineNewCaretPosition.call(inputmask, {
|
||||
begin: 0,
|
||||
end: 0
|
||||
}, false, opts.__financeInput === false ? "radixFocus" : undefined).begin : 0;
|
||||
maskset.p = initialNdx;
|
||||
inputmask.caretPos = {begin: initialNdx};
|
||||
|
||||
var staticMatches = [], prevCaretPos = inputmask.caretPos;
|
||||
inputValue.forEach(function (charCode, ndx) {
|
||||
if (charCode !== undefined) { //inputfallback strips some elements out of the inputarray. $.each logically presents them as undefined
|
||||
/*if (maskset.validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder.call(inputmask, ndx) && isMask.call(inputmask, ndx, true) &&
|
||||
isValid.call(inputmask, ndx, inputValue[ndx], true, undefined, true, true) === false) {
|
||||
inputmask.caretPos.begin++;
|
||||
} else*/
|
||||
{
|
||||
var keypress = new $.Event("_checkval");
|
||||
keypress.keyCode = charCode.toString().charCodeAt(0);
|
||||
charCodes += charCode;
|
||||
var lvp = getLastValidPosition.call(inputmask, undefined, true);
|
||||
if (!isTemplateMatch(initialNdx, charCodes)) {
|
||||
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, inputmask.caretPos.begin);
|
||||
|
||||
if (result) {
|
||||
initialNdx = inputmask.caretPos.begin + 1;
|
||||
charCodes = "";
|
||||
}
|
||||
} else {
|
||||
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, lvp + 1);
|
||||
}
|
||||
if (result) {
|
||||
if (result.pos !== undefined && maskset.validPositions[result.pos] && maskset.validPositions[result.pos].match.static === true && maskset.validPositions[result.pos].alternation === undefined) {
|
||||
staticMatches.push(result.pos);
|
||||
if (!inputmask.isRTL) {
|
||||
result.forwardPosition = result.pos + 1;
|
||||
}
|
||||
}
|
||||
writeBuffer.call(inputmask, undefined, getBuffer.call(inputmask), result.forwardPosition, keypress, false);
|
||||
inputmask.caretPos = {begin: result.forwardPosition, end: result.forwardPosition};
|
||||
prevCaretPos = inputmask.caretPos;
|
||||
} else {
|
||||
if (maskset.validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder.call(inputmask, ndx) && isMask.call(inputmask, ndx, true)) {
|
||||
inputmask.caretPos.begin++;
|
||||
} else inputmask.caretPos = prevCaretPos; //restore the caret position from before the failed validation
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (staticMatches.length > 0) {
|
||||
var sndx, validPos, nextValid = seekNext.call(inputmask, -1, undefined, false);
|
||||
if ((!isComplete.call(inputmask, getBuffer.call(inputmask)) && staticMatches.length <= nextValid)
|
||||
|| (isComplete.call(inputmask, getBuffer.call(inputmask)) && staticMatches.length > 0 && (staticMatches.length !== nextValid && staticMatches[0] === 0))) { //should check if is sequence starting from 0
|
||||
var nextSndx = nextValid;
|
||||
while ((sndx = staticMatches.shift()) !== undefined) {
|
||||
var keypress = new $.Event("_checkval");
|
||||
validPos = maskset.validPositions[sndx];
|
||||
validPos.generatedInput = true;
|
||||
keypress.keyCode = validPos.input.charCodeAt(0);
|
||||
result = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, strict, nextSndx);
|
||||
if (result && result.pos !== undefined && result.pos !== sndx && maskset.validPositions[result.pos] && maskset.validPositions[result.pos].match.static === true) {
|
||||
staticMatches.push(result.pos);
|
||||
} else if (!result) break;
|
||||
nextSndx++;
|
||||
}
|
||||
} else { //mark al statics as generated
|
||||
// while ((sndx = staticMatches.pop())) {
|
||||
// validPos = maskset.validPositions[sndx];
|
||||
// if (validPos) {
|
||||
// validPos.generatedInput = true;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (writeOut) {
|
||||
writeBuffer.call(
|
||||
inputmask,
|
||||
input,
|
||||
getBuffer.call(inputmask), result ? result.forwardPosition : inputmask.caretPos.begin,
|
||||
initiatingEvent || new $.Event("checkval"),
|
||||
initiatingEvent && ((initiatingEvent.type === "input" && inputmask.undoValue !== getBuffer.call(inputmask).join("")) || initiatingEvent.type === "paste"));
|
||||
// for (var vndx in maskset.validPositions) {
|
||||
// if (maskset.validPositions[vndx].match.generated !== true) { //only remove non forced generated
|
||||
// delete maskset.validPositions[vndx].generatedInput; //clear generated markings ~ consider initializing with a value as fully typed
|
||||
// }
|
||||
// }
|
||||
}
|
||||
opts.skipOptionalPartCharacter = skipOptionalPartCharacter;
|
||||
}
|
||||
|
||||
function HandleNativePlaceholder(npt, value) {
|
||||
const inputmask = npt ? npt.inputmask : this;
|
||||
|
||||
if (ie) {
|
||||
if (npt.inputmask._valueGet() !== value && (npt.placeholder !== value || npt.placeholder === "")) {
|
||||
var buffer = getBuffer.call(inputmask).slice(),
|
||||
nptValue = npt.inputmask._valueGet();
|
||||
if (nptValue !== value) {
|
||||
var lvp = getLastValidPosition.call(inputmask);
|
||||
if (lvp === -1 && nptValue === getBufferTemplate.call(inputmask).join("")) {
|
||||
buffer = [];
|
||||
} else if (lvp !== -1) { //clearout optional tail of the mask
|
||||
clearOptionalTail.call(inputmask, buffer);
|
||||
}
|
||||
writeBuffer(npt, buffer);
|
||||
}
|
||||
}
|
||||
} else if (npt.placeholder !== value) {
|
||||
npt.placeholder = value;
|
||||
if (npt.placeholder === "") npt.removeAttribute("placeholder");
|
||||
}
|
||||
}
|
||||
|
||||
function unmaskedvalue(input) {
|
||||
const inputmask = input ? input.inputmask : this,
|
||||
opts = inputmask.opts,
|
||||
maskset = inputmask.maskset;
|
||||
|
||||
if (input) {
|
||||
if (input.inputmask === undefined) {
|
||||
return input.value;
|
||||
}
|
||||
if (input.inputmask && input.inputmask.refreshValue) { //forced refresh from the value form.reset
|
||||
applyInputValue(input, input.inputmask._valueGet(true));
|
||||
}
|
||||
}
|
||||
var umValue = [],
|
||||
vps = maskset.validPositions;
|
||||
for (var pndx in vps) {
|
||||
if (vps[pndx] && vps[pndx].match && (vps[pndx].match.static != true || (Array.isArray(maskset.metadata) && vps[pndx].generatedInput !== true))) {
|
||||
//only include generated input with multiple masks (check on metadata)
|
||||
umValue.push(vps[pndx].input);
|
||||
}
|
||||
}
|
||||
var unmaskedValue = umValue.length === 0 ? "" : (inputmask.isRTL ? umValue.reverse() : umValue).join("");
|
||||
if (typeof opts.onUnMask === "function") {
|
||||
var bufferValue = (inputmask.isRTL ? getBuffer.call(inputmask).slice().reverse() : getBuffer.call(inputmask)).join("");
|
||||
unmaskedValue = opts.onUnMask.call(inputmask, bufferValue, unmaskedValue, opts);
|
||||
}
|
||||
return unmaskedValue;
|
||||
}
|
||||
|
||||
function writeBuffer(input, buffer, caretPos, event, triggerEvents) {
|
||||
const inputmask = input ? input.inputmask : this,
|
||||
opts = inputmask.opts,
|
||||
$ = inputmask.dependencyLib;
|
||||
|
||||
if (event && typeof opts.onBeforeWrite === "function") {
|
||||
// buffer = buffer.slice(); //prevent uncontrolled manipulation of the internal buffer
|
||||
var result = opts.onBeforeWrite.call(inputmask, event, buffer, caretPos, opts);
|
||||
if (result) {
|
||||
if (result.refreshFromBuffer) {
|
||||
var refresh = result.refreshFromBuffer;
|
||||
refreshFromBuffer.call(inputmask, refresh === true ? refresh : refresh.start, refresh.end, result.buffer || buffer);
|
||||
buffer = getBuffer.call(inputmask, true);
|
||||
}
|
||||
if (caretPos !== undefined) caretPos = result.caret !== undefined ? result.caret : caretPos;
|
||||
}
|
||||
}
|
||||
if (input !== undefined) {
|
||||
input.inputmask._valueSet(buffer.join(""));
|
||||
if (caretPos !== undefined && (event === undefined || event.type !== "blur")) {
|
||||
// console.log(caretPos);
|
||||
caret.call(inputmask, input, caretPos, undefined, undefined, (event !== undefined && event.type === "keydown" && (event.keyCode === keyCode.DELETE || event.keyCode === keyCode.BACKSPACE)));
|
||||
}
|
||||
if (triggerEvents === true) {
|
||||
var $input = $(input), nptVal = input.inputmask._valueGet();
|
||||
input.inputmask.skipInputEvent = true;
|
||||
$input.trigger("input");
|
||||
setTimeout(function () { //timeout needed for IE
|
||||
if (nptVal === getBufferTemplate.call(inputmask).join("")) {
|
||||
$input.trigger("cleared");
|
||||
} else if (isComplete.call(inputmask, buffer) === true) {
|
||||
$input.trigger("complete");
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
355
node_modules/inputmask/lib/inputmask.js
generated
vendored
Normal file
355
node_modules/inputmask/lib/inputmask.js
generated
vendored
Normal file
|
@ -0,0 +1,355 @@
|
|||
/*
|
||||
* Input Mask Core
|
||||
* http://github.com/RobinHerbots/jquery.inputmask
|
||||
* Copyright (c) Robin Herbots
|
||||
* Licensed under the MIT license
|
||||
*/
|
||||
import "./polyfills/Object.getPrototypeOf";
|
||||
import "./polyfills/Array.includes";
|
||||
|
||||
import {mask} from "./mask";
|
||||
import $ from "./dependencyLibs/inputmask.dependencyLib";
|
||||
import window from "./global/window";
|
||||
import {generateMaskSet, analyseMask} from "./mask-lexer";
|
||||
import {getMaskTemplate} from "./validation-tests";
|
||||
import {determineLastRequiredPosition, getBuffer, getBufferTemplate, isMask} from "./positioning";
|
||||
import {isComplete} from "./validation";
|
||||
import {checkVal, unmaskedvalue} from "./inputHandling";
|
||||
import {EventRuler} from "./eventruler";
|
||||
import definitions from "./definitions";
|
||||
import defaults from "./defaults";
|
||||
import canUseDOM from "./canUseDOM";
|
||||
|
||||
const document = window.document, dataKey = "_inputmask_opts";
|
||||
|
||||
function Inputmask(alias, options, internal) {
|
||||
if (!canUseDOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
//allow instanciating without new
|
||||
if (!(this instanceof Inputmask)) {
|
||||
return new Inputmask(alias, options, internal);
|
||||
}
|
||||
|
||||
this.dependencyLib = $;
|
||||
this.el = undefined;
|
||||
this.events = {};
|
||||
this.maskset = undefined;
|
||||
|
||||
if (internal !== true) {
|
||||
//init options
|
||||
if (Object.prototype.toString.call(alias) === "[object Object]") {
|
||||
options = alias;
|
||||
} else {
|
||||
options = options || {};
|
||||
if (alias) options.alias = alias;
|
||||
}
|
||||
this.opts = $.extend(true, {}, this.defaults, options);
|
||||
this.noMasksCache = options && options.definitions !== undefined;
|
||||
this.userOptions = options || {}; //user passed options
|
||||
resolveAlias(this.opts.alias, options, this.opts);
|
||||
}
|
||||
|
||||
//maskscope properties
|
||||
this.refreshValue = false; //indicate a refresh from the inputvalue is needed (form.reset)
|
||||
this.undoValue = undefined;
|
||||
this.$el = undefined;
|
||||
this.skipKeyPressEvent = false; //Safari 5.1.x - modal dialog fires keypress twice workaround
|
||||
this.skipInputEvent = false; //skip when triggered from within inputmask
|
||||
this.validationEvent = false;
|
||||
this.ignorable = false;
|
||||
this.maxLength;
|
||||
this.mouseEnter = false;
|
||||
this.originalPlaceholder = undefined; //needed for FF
|
||||
this.isComposing = false; //keydowncode == 229 compositionevent fallback
|
||||
}
|
||||
|
||||
Inputmask.prototype = {
|
||||
dataAttribute: "data-inputmask", //data attribute prefix used for attribute binding
|
||||
//options default
|
||||
defaults: defaults,
|
||||
definitions: definitions,
|
||||
aliases: {}, //aliases definitions
|
||||
masksCache: {},
|
||||
get isRTL() {
|
||||
return this.opts.isRTL || this.opts.numericInput;
|
||||
},
|
||||
mask: function (elems) {
|
||||
var that = this;
|
||||
if (typeof elems === "string") {
|
||||
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : (Array.isArray(elems) ? elems : Array.from(elems));
|
||||
elems.forEach(function (el, ndx) {
|
||||
var scopedOpts = $.extend(true, {}, that.opts);
|
||||
if (importAttributeOptions(el, scopedOpts, $.extend(true, {}, that.userOptions), that.dataAttribute)) {
|
||||
var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
|
||||
if (maskset !== undefined) {
|
||||
if (el.inputmask !== undefined) {
|
||||
el.inputmask.opts.autoUnmask = true; //force autounmasking when remasking
|
||||
el.inputmask.remove();
|
||||
}
|
||||
//store inputmask instance on the input with element reference
|
||||
el.inputmask = new Inputmask(undefined, undefined, true);
|
||||
el.inputmask.opts = scopedOpts;
|
||||
el.inputmask.noMasksCache = that.noMasksCache;
|
||||
el.inputmask.userOptions = $.extend(true, {}, that.userOptions);
|
||||
// el.inputmask.isRTL = scopedOpts.isRTL || scopedOpts.numericInput;
|
||||
el.inputmask.el = el;
|
||||
el.inputmask.$el = $(el);
|
||||
el.inputmask.maskset = maskset;
|
||||
|
||||
$.data(el, dataKey, that.userOptions);
|
||||
mask.call(el.inputmask);
|
||||
}
|
||||
}
|
||||
});
|
||||
return elems && elems[0] ? (elems[0].inputmask || this) : this;
|
||||
},
|
||||
option: function (options, noremask) { //set extra options || retrieve value of a current option
|
||||
if (typeof options === "string") {
|
||||
return this.opts[options];
|
||||
} else if (typeof options === "object") {
|
||||
$.extend(this.userOptions, options); //user passed options
|
||||
//remask
|
||||
if (this.el && noremask !== true) {
|
||||
this.mask(this.el);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
},
|
||||
unmaskedvalue: function (value) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
if (this.el === undefined || value !== undefined) {
|
||||
var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
|
||||
checkVal.call(this, undefined, false, false, valueBuffer);
|
||||
if (typeof this.opts.onBeforeWrite === "function") this.opts.onBeforeWrite.call(this, undefined, getBuffer.call(this), 0, this.opts);
|
||||
}
|
||||
return unmaskedvalue.call(this, this.el);
|
||||
},
|
||||
remove: function () {
|
||||
if (this.el) {
|
||||
$.data(this.el, dataKey, null); //invalidate
|
||||
//writeout the value
|
||||
var cv = this.opts.autoUnmask ? unmaskedvalue(this.el) : this._valueGet(this.opts.autoUnmask);
|
||||
if (cv !== getBufferTemplate.call(this).join("")) this._valueSet(cv, this.opts.autoUnmask); else this._valueSet("");
|
||||
//unbind all events
|
||||
EventRuler.off(this.el);
|
||||
|
||||
//restore the value property
|
||||
var valueProperty;
|
||||
if (Object.getOwnPropertyDescriptor && Object.getPrototypeOf) {
|
||||
valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.el), "value");
|
||||
if (valueProperty) {
|
||||
if (this.__valueGet) {
|
||||
Object.defineProperty(this.el, "value", {
|
||||
get: this.__valueGet,
|
||||
set: this.__valueSet,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (document.__lookupGetter__ && this.el.__lookupGetter__("value")) {
|
||||
if (this.__valueGet) {
|
||||
this.el.__defineGetter__("value", this.__valueGet);
|
||||
this.el.__defineSetter__("value", this.__valueSet);
|
||||
}
|
||||
}
|
||||
//clear data
|
||||
this.el.inputmask = undefined;
|
||||
}
|
||||
return this.el;
|
||||
},
|
||||
getemptymask: function () { //return the default (empty) mask value, usefull for setting the default value in validation
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
return getBufferTemplate.call(this).join("");
|
||||
},
|
||||
hasMaskedValue: function () { //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
|
||||
return !this.opts.autoUnmask;
|
||||
},
|
||||
isComplete: function () {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
return isComplete.call(this, getBuffer.call(this));
|
||||
},
|
||||
getmetadata: function () { //return mask metadata if exists
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
if (Array.isArray(this.maskset.metadata)) {
|
||||
var maskTarget = getMaskTemplate.call(this, true, 0, false).join("");
|
||||
this.maskset.metadata.forEach(function (mtdt) {
|
||||
if (mtdt.mask === maskTarget) {
|
||||
maskTarget = mtdt;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
return maskTarget;
|
||||
}
|
||||
return this.maskset.metadata;
|
||||
},
|
||||
isValid: function (value) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
if (value) {
|
||||
var valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
|
||||
checkVal.call(this, undefined, true, false, valueBuffer);
|
||||
} else {
|
||||
value = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
|
||||
}
|
||||
var buffer = getBuffer.call(this);
|
||||
var rl = determineLastRequiredPosition.call(this),
|
||||
lmib = buffer.length - 1;
|
||||
for (; lmib > rl; lmib--) {
|
||||
if (isMask.call(this, lmib)) break;
|
||||
}
|
||||
buffer.splice(rl, lmib + 1 - rl);
|
||||
|
||||
return isComplete.call(this, buffer) && value === (this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join(""));
|
||||
|
||||
},
|
||||
format: function (value, metadata) {
|
||||
this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache);
|
||||
let valueBuffer = (typeof this.opts.onBeforeMask === "function" ? (this.opts.onBeforeMask.call(this, value, this.opts) || value) : value).split("");
|
||||
checkVal.call(this, undefined, true, false, valueBuffer);
|
||||
let formattedValue = this.isRTL ? getBuffer.call(this).slice().reverse().join("") : getBuffer.call(this).join("");
|
||||
return metadata ? {
|
||||
value: formattedValue,
|
||||
metadata: this.getmetadata()
|
||||
} : formattedValue;
|
||||
},
|
||||
setValue: function (value) {
|
||||
if (this.el) {
|
||||
$(this.el).trigger("setvalue", [value]);
|
||||
}
|
||||
},
|
||||
analyseMask: analyseMask
|
||||
};
|
||||
|
||||
function resolveAlias(aliasStr, options, opts) {
|
||||
var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
|
||||
if (aliasDefinition) {
|
||||
if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); //alias is another alias
|
||||
$.extend(true, opts, aliasDefinition); //merge alias definition in the options
|
||||
$.extend(true, opts, options); //reapply extra given options
|
||||
return true;
|
||||
} else //alias not found - try as mask
|
||||
if (opts.mask === null) {
|
||||
opts.mask = aliasStr;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
|
||||
function importOption(option, optionData) {
|
||||
const attrOption = dataAttribute === "" ? option : dataAttribute + "-" + option;
|
||||
optionData = optionData !== undefined ? optionData : npt.getAttribute(attrOption);
|
||||
if (optionData !== null) {
|
||||
if (typeof optionData === "string") {
|
||||
if (option.indexOf("on") === 0) {
|
||||
optionData = window[optionData];
|
||||
}//get function definition
|
||||
else if (optionData === "false") {
|
||||
optionData = false;
|
||||
} else if (optionData === "true") optionData = true;
|
||||
}
|
||||
userOptions[option] = optionData;
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.importDataAttributes === true) {
|
||||
var attrOptions = npt.getAttribute(dataAttribute), option, dataoptions, optionData, p;
|
||||
|
||||
if (attrOptions && attrOptions !== "") {
|
||||
attrOptions = attrOptions.replace(/'/g, "\"");
|
||||
dataoptions = JSON.parse("{" + attrOptions + "}");
|
||||
}
|
||||
|
||||
//resolve aliases
|
||||
if (dataoptions) { //pickup alias from dataAttribute
|
||||
optionData = undefined;
|
||||
for (p in dataoptions) {
|
||||
if (p.toLowerCase() === "alias") {
|
||||
optionData = dataoptions[p];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
importOption("alias", optionData); //pickup alias from dataAttribute-alias
|
||||
if (userOptions.alias) {
|
||||
resolveAlias(userOptions.alias, userOptions, opts);
|
||||
}
|
||||
|
||||
for (option in opts) {
|
||||
if (dataoptions) {
|
||||
optionData = undefined;
|
||||
for (p in dataoptions) {
|
||||
if (p.toLowerCase() === option.toLowerCase()) {
|
||||
optionData = dataoptions[p];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
importOption(option, optionData);
|
||||
}
|
||||
}
|
||||
$.extend(true, opts, userOptions);
|
||||
|
||||
//handle dir=rtl
|
||||
if (npt.dir === "rtl" || opts.rightAlign) {
|
||||
npt.style.textAlign = "right";
|
||||
}
|
||||
|
||||
if (npt.dir === "rtl" || opts.numericInput) {
|
||||
npt.dir = "ltr";
|
||||
npt.removeAttribute("dir");
|
||||
opts.isRTL = true;
|
||||
}
|
||||
|
||||
return Object.keys(userOptions).length;
|
||||
}
|
||||
|
||||
//apply defaults, definitions, aliases
|
||||
Inputmask.extendDefaults = function (options) {
|
||||
$.extend(true, Inputmask.prototype.defaults, options);
|
||||
};
|
||||
Inputmask.extendDefinitions = function (definition) {
|
||||
$.extend(true, Inputmask.prototype.definitions, definition);
|
||||
};
|
||||
Inputmask.extendAliases = function (alias) {
|
||||
$.extend(true, Inputmask.prototype.aliases, alias);
|
||||
};
|
||||
//static fn on inputmask
|
||||
Inputmask.format = function (value, options, metadata) {
|
||||
return Inputmask(options).format(value, metadata);
|
||||
};
|
||||
Inputmask.unmask = function (value, options) {
|
||||
return Inputmask(options).unmaskedvalue(value);
|
||||
};
|
||||
Inputmask.isValid = function (value, options) {
|
||||
return Inputmask(options).isValid(value);
|
||||
};
|
||||
Inputmask.remove = function (elems) {
|
||||
if (typeof elems === "string") {
|
||||
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : elems;
|
||||
elems.forEach(function (el) {
|
||||
if (el.inputmask) el.inputmask.remove();
|
||||
});
|
||||
};
|
||||
Inputmask.setValue = function (elems, value) {
|
||||
if (typeof elems === "string") {
|
||||
elems = document.getElementById(elems) || document.querySelectorAll(elems);
|
||||
}
|
||||
elems = elems.nodeName ? [elems] : elems;
|
||||
elems.forEach(function (el) {
|
||||
if (el.inputmask) el.inputmask.setValue(value); else $(el).trigger("setvalue", [value]);
|
||||
});
|
||||
};
|
||||
|
||||
Inputmask.dependencyLib = $;
|
||||
|
||||
//make inputmask available
|
||||
window.Inputmask = Inputmask;
|
||||
export default Inputmask;
|
33
node_modules/inputmask/lib/inputmaskElement.js
generated
vendored
Normal file
33
node_modules/inputmask/lib/inputmaskElement.js
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
import window from "./global/window";
|
||||
import Inputmask from "./inputmask";
|
||||
import canUseDOM from "./canUseDOM";
|
||||
|
||||
const document = window.document;
|
||||
|
||||
// add check if it is supported by the browser
|
||||
// integrate shadowroot into maskcope
|
||||
if (canUseDOM && document && document.head && document.head.attachShadow && window.customElements && window.customElements.get("input-mask") === undefined) {
|
||||
class InputmaskElement extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
var attributeNames = this.getAttributeNames(),
|
||||
shadow = this.attachShadow({mode: "closed"}),
|
||||
input = document.createElement("input");
|
||||
input.type = "text";
|
||||
shadow.appendChild(input);
|
||||
|
||||
for (var attr in attributeNames) {
|
||||
if (Object.prototype.hasOwnProperty.call(attributeNames, attr)) {
|
||||
input.setAttribute(attributeNames[attr], this.getAttribute(attributeNames[attr]));
|
||||
}
|
||||
}
|
||||
|
||||
var im = new Inputmask();
|
||||
im.dataAttribute = "";
|
||||
im.mask(input);
|
||||
input.inputmask.shadowRoot = shadow; //make the shadowRoot available
|
||||
}
|
||||
}
|
||||
|
||||
window.customElements.define("input-mask", InputmaskElement);
|
||||
}
|
81
node_modules/inputmask/lib/jquery.inputmask.js
generated
vendored
Normal file
81
node_modules/inputmask/lib/jquery.inputmask.js
generated
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Input Mask plugin for jquery
|
||||
* http://github.com/RobinHerbots/jquery.inputmask
|
||||
* Copyright (c) Robin Herbots
|
||||
* Licensed under the MIT license
|
||||
*/
|
||||
import $ from "jquery";
|
||||
import Inputmask from "./inputmask";
|
||||
|
||||
if ($.fn.inputmask === undefined) {
|
||||
//jquery plugin
|
||||
$.fn.inputmask = function (fn, options) {
|
||||
var nptmask, input = this[0];
|
||||
if (options === undefined) options = {};
|
||||
if (typeof fn === "string") {
|
||||
switch (fn) {
|
||||
case "unmaskedvalue":
|
||||
return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
|
||||
case "remove":
|
||||
return this.each(function () {
|
||||
if (this.inputmask) this.inputmask.remove();
|
||||
});
|
||||
case "getemptymask":
|
||||
return input && input.inputmask ? input.inputmask.getemptymask() : "";
|
||||
case "hasMaskedValue": //check whether the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
|
||||
return input && input.inputmask ? input.inputmask.hasMaskedValue() : false;
|
||||
case "isComplete":
|
||||
return input && input.inputmask ? input.inputmask.isComplete() : true;
|
||||
case "getmetadata": //return mask metadata if exists
|
||||
return input && input.inputmask ? input.inputmask.getmetadata() : undefined;
|
||||
case "setvalue":
|
||||
Inputmask.setValue(input, options);
|
||||
break;
|
||||
case "option":
|
||||
if (typeof options === "string") {
|
||||
if (input && input.inputmask !== undefined) {
|
||||
return input.inputmask.option(options);
|
||||
}
|
||||
} else {
|
||||
return this.each(function () {
|
||||
if (this.inputmask !== undefined) {
|
||||
return this.inputmask.option(options);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
options.alias = fn;
|
||||
nptmask = new Inputmask(options);
|
||||
return this.each(function () {
|
||||
nptmask.mask(this);
|
||||
});
|
||||
}
|
||||
} else if (Array.isArray(fn)) {
|
||||
options.alias = fn;
|
||||
nptmask = new Inputmask(options);
|
||||
return this.each(function () {
|
||||
nptmask.mask(this);
|
||||
});
|
||||
} else if (typeof fn == "object") {
|
||||
nptmask = new Inputmask(fn);
|
||||
if (fn.mask === undefined && fn.alias === undefined) {
|
||||
return this.each(function () {
|
||||
if (this.inputmask !== undefined) {
|
||||
return this.inputmask.option(fn);
|
||||
} else nptmask.mask(this);
|
||||
});
|
||||
} else {
|
||||
return this.each(function () {
|
||||
nptmask.mask(this);
|
||||
});
|
||||
}
|
||||
} else if (fn === undefined) {
|
||||
//look for data-inputmask atributes
|
||||
return this.each(function () {
|
||||
nptmask = new Inputmask(options);
|
||||
nptmask.mask(this);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
25
node_modules/inputmask/lib/keycode.json
generated
vendored
Normal file
25
node_modules/inputmask/lib/keycode.json
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"BACKSPACE": 8,
|
||||
"BACKSPACE_SAFARI": 127,
|
||||
"DELETE": 46,
|
||||
"DOWN": 40,
|
||||
"END": 35,
|
||||
"ENTER": 13,
|
||||
"ESCAPE": 27,
|
||||
"HOME": 36,
|
||||
"INSERT": 45,
|
||||
"LEFT": 37,
|
||||
"PAGE_DOWN": 34,
|
||||
"PAGE_UP": 33,
|
||||
"RIGHT": 39,
|
||||
"SPACE": 32,
|
||||
"TAB": 9,
|
||||
"UP": 38,
|
||||
"X": 88,
|
||||
"Z": 90,
|
||||
"CONTROL": 17,
|
||||
"PAUSE/BREAK": 19,
|
||||
"WINDOWS_LEFT": 91,
|
||||
"WINDOWS_RIGHT": 92,
|
||||
"KEY_229": 229
|
||||
}
|
467
node_modules/inputmask/lib/mask-lexer.js
generated
vendored
Normal file
467
node_modules/inputmask/lib/mask-lexer.js
generated
vendored
Normal file
|
@ -0,0 +1,467 @@
|
|||
import $ from "./dependencyLibs/inputmask.dependencyLib";
|
||||
import MaskToken from "./masktoken";
|
||||
import Inputmask from "./inputmask";
|
||||
|
||||
export {generateMaskSet, analyseMask};
|
||||
|
||||
function generateMaskSet(opts, nocache) {
|
||||
var ms;
|
||||
|
||||
function generateMask(mask, metadata, opts) {
|
||||
var regexMask = false;
|
||||
if (mask === null || mask === "") {
|
||||
regexMask = opts.regex !== null;
|
||||
if (regexMask) {
|
||||
mask = opts.regex;
|
||||
mask = mask.replace(/^(\^)(.*)(\$)$/, "$2");
|
||||
} else {
|
||||
regexMask = true;
|
||||
mask = ".*";
|
||||
}
|
||||
}
|
||||
if (mask.length === 1 && opts.greedy === false && opts.repeat !== 0) {
|
||||
opts.placeholder = "";
|
||||
} //hide placeholder with single non-greedy mask
|
||||
if (opts.repeat > 0 || opts.repeat === "*" || opts.repeat === "+") {
|
||||
var repeatStart = opts.repeat === "*" ? 0 : (opts.repeat === "+" ? 1 : opts.repeat);
|
||||
mask = opts.groupmarker[0] + mask + opts.groupmarker[1] + opts.quantifiermarker[0] + repeatStart + "," + opts.repeat + opts.quantifiermarker[1];
|
||||
}
|
||||
|
||||
// console.log(mask);
|
||||
var masksetDefinition, maskdefKey;
|
||||
maskdefKey = regexMask ? "regex_" + opts.regex : opts.numericInput ? mask.split("").reverse().join("") : mask;
|
||||
if (opts.keepStatic !== null) { //keepstatic modifies the output from the testdefinitions ~ so differentiate in the maskcache
|
||||
maskdefKey = "ks_" + opts.keepStatic + maskdefKey;
|
||||
}
|
||||
|
||||
if (Inputmask.prototype.masksCache[maskdefKey] === undefined || nocache === true) {
|
||||
masksetDefinition = {
|
||||
"mask": mask,
|
||||
"maskToken": Inputmask.prototype.analyseMask(mask, regexMask, opts),
|
||||
"validPositions": {},
|
||||
"_buffer": undefined,
|
||||
"buffer": undefined,
|
||||
"tests": {},
|
||||
"excludes": {}, //excluded alternations
|
||||
"metadata": metadata,
|
||||
"maskLength": undefined,
|
||||
"jitOffset": {}
|
||||
};
|
||||
if (nocache !== true) {
|
||||
Inputmask.prototype.masksCache[maskdefKey] = masksetDefinition;
|
||||
masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]);
|
||||
}
|
||||
} else {
|
||||
masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]);
|
||||
}
|
||||
|
||||
return masksetDefinition;
|
||||
}
|
||||
|
||||
if (typeof opts.mask === "function") { //allow mask to be a preprocessing fn - should return a valid mask
|
||||
opts.mask = opts.mask(opts);
|
||||
}
|
||||
if (Array.isArray(opts.mask)) {
|
||||
if (opts.mask.length > 1) {
|
||||
if (opts.keepStatic === null) { //enable by default when passing multiple masks when the option is not explicitly specified
|
||||
opts.keepStatic = true;
|
||||
}
|
||||
var altMask = opts.groupmarker[0];
|
||||
(opts.isRTL ? opts.mask.reverse() : opts.mask).forEach(function (msk) {
|
||||
if (altMask.length > 1) {
|
||||
altMask += opts.alternatormarker;
|
||||
}
|
||||
if (msk.mask !== undefined && typeof msk.mask !== "function") {
|
||||
altMask += msk.mask;
|
||||
} else {
|
||||
altMask += msk;
|
||||
}
|
||||
});
|
||||
altMask += opts.groupmarker[1];
|
||||
// console.log(altMask);
|
||||
return generateMask(altMask, opts.mask, opts);
|
||||
} else {
|
||||
opts.mask = opts.mask.pop();
|
||||
}
|
||||
}
|
||||
if (opts.mask && opts.mask.mask !== undefined && typeof opts.mask.mask !== "function") {
|
||||
ms = generateMask(opts.mask.mask, opts.mask, opts);
|
||||
} else {
|
||||
ms = generateMask(opts.mask, opts.mask, opts);
|
||||
}
|
||||
if (opts.keepStatic === null) opts.keepStatic = false;
|
||||
return ms;
|
||||
}
|
||||
|
||||
function analyseMask(mask, regexMask, opts) {
|
||||
const tokenizer = /(?:[?*+]|\{[0-9+*]+(?:,[0-9+*]*)?(?:\|[0-9+*]*)?\})|[^.?*+^${[]()|\\]+|./g,
|
||||
//Thx to https://github.com/slevithan/regex-colorizer for the regexTokenizer regex
|
||||
regexTokenizer = /\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g;
|
||||
var escaped = false,
|
||||
currentToken = new MaskToken(),
|
||||
match,
|
||||
m,
|
||||
openenings = [],
|
||||
maskTokens = [],
|
||||
openingToken,
|
||||
currentOpeningToken,
|
||||
alternator,
|
||||
lastMatch,
|
||||
closeRegexGroup = false;
|
||||
|
||||
//test definition => {fn: RegExp/function, static: true/false optionality: bool, newBlockMarker: bool, casing: null/upper/lower, def: definitionSymbol, placeholder: placeholder, mask: real maskDefinition}
|
||||
function insertTestDefinition(mtoken, element, position) {
|
||||
position = position !== undefined ? position : mtoken.matches.length;
|
||||
var prevMatch = mtoken.matches[position - 1];
|
||||
if (regexMask) {
|
||||
if (element.indexOf("[") === 0 || (escaped && /\\d|\\s|\\w/i.test(element)) || element === ".") {
|
||||
mtoken.matches.splice(position++, 0, {
|
||||
fn: new RegExp(element, opts.casing ? "i" : ""),
|
||||
static: false,
|
||||
optionality: false,
|
||||
newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== element,
|
||||
casing: null,
|
||||
def: element,
|
||||
placeholder: undefined,
|
||||
nativeDef: element
|
||||
});
|
||||
} else {
|
||||
if (escaped) element = element[element.length - 1];
|
||||
element.split("").forEach(function (lmnt, ndx) {
|
||||
prevMatch = mtoken.matches[position - 1];
|
||||
mtoken.matches.splice(position++, 0, {
|
||||
fn: /[a-z]/i.test((opts.staticDefinitionSymbol || lmnt)) ? new RegExp("[" + (opts.staticDefinitionSymbol || lmnt) + "]", opts.casing ? "i" : "") : null,
|
||||
static: true,
|
||||
optionality: false,
|
||||
newBlockMarker: prevMatch === undefined ? "master" : (prevMatch.def !== lmnt && prevMatch.static !== true),
|
||||
casing: null,
|
||||
def: opts.staticDefinitionSymbol || lmnt,
|
||||
placeholder: opts.staticDefinitionSymbol !== undefined ? lmnt : undefined,
|
||||
nativeDef: (escaped ? "'" : "") + lmnt
|
||||
});
|
||||
});
|
||||
}
|
||||
escaped = false;
|
||||
} else {
|
||||
var maskdef = (opts.definitions && opts.definitions[element]) || (opts.usePrototypeDefinitions && Inputmask.prototype.definitions[element]);
|
||||
if (maskdef && !escaped) {
|
||||
mtoken.matches.splice(position++, 0, {
|
||||
fn: maskdef.validator ? typeof maskdef.validator == "string" ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function () {
|
||||
this.test = maskdef.validator;
|
||||
} : new RegExp("."),
|
||||
static: maskdef.static || false,
|
||||
optionality: maskdef.optional || false,
|
||||
newBlockMarker: (prevMatch === undefined || maskdef.optional) ? "master" : prevMatch.def !== (maskdef.definitionSymbol || element),
|
||||
casing: maskdef.casing,
|
||||
def: maskdef.definitionSymbol || element,
|
||||
placeholder: maskdef.placeholder,
|
||||
nativeDef: element,
|
||||
generated: maskdef.generated
|
||||
});
|
||||
} else {
|
||||
mtoken.matches.splice(position++, 0, {
|
||||
fn: /[a-z]/i.test((opts.staticDefinitionSymbol || element)) ? new RegExp("[" + (opts.staticDefinitionSymbol || element) + "]", opts.casing ? "i" : "") : null,
|
||||
static: true,
|
||||
optionality: false,
|
||||
newBlockMarker: prevMatch === undefined ? "master" : (prevMatch.def !== element && prevMatch.static !== true),
|
||||
casing: null,
|
||||
def: opts.staticDefinitionSymbol || element,
|
||||
placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined,
|
||||
nativeDef: (escaped ? "'" : "") + element
|
||||
});
|
||||
escaped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function verifyGroupMarker(maskToken) {
|
||||
if (maskToken && maskToken.matches) {
|
||||
maskToken.matches.forEach(function (token, ndx) {
|
||||
var nextToken = maskToken.matches[ndx + 1];
|
||||
if ((nextToken === undefined || (nextToken.matches === undefined || nextToken.isQuantifier === false)) && token && token.isGroup) { //this is not a group but a normal mask => convert
|
||||
token.isGroup = false;
|
||||
if (!regexMask) {
|
||||
insertTestDefinition(token, opts.groupmarker[0], 0);
|
||||
if (token.openGroup !== true) {
|
||||
insertTestDefinition(token, opts.groupmarker[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
verifyGroupMarker(token);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function defaultCase() {
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
insertTestDefinition(currentOpeningToken, m);
|
||||
if (currentOpeningToken.isAlternator) { //handle alternator a | b case
|
||||
alternator = openenings.pop();
|
||||
for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
|
||||
if (alternator.matches[mndx].isGroup) alternator.matches[mndx].isGroup = false; //don't mark alternate groups as group
|
||||
}
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
currentOpeningToken.matches.push(alternator);
|
||||
} else {
|
||||
currentToken.matches.push(alternator);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
insertTestDefinition(currentToken, m);
|
||||
}
|
||||
}
|
||||
|
||||
function reverseTokens(maskToken) {
|
||||
function reverseStatic(st) {
|
||||
if (st === opts.optionalmarker[0]) {
|
||||
st = opts.optionalmarker[1];
|
||||
} else if (st === opts.optionalmarker[1]) {
|
||||
st = opts.optionalmarker[0];
|
||||
} else if (st === opts.groupmarker[0]) {
|
||||
st = opts.groupmarker[1];
|
||||
} else if (st === opts.groupmarker[1]) st = opts.groupmarker[0];
|
||||
|
||||
return st;
|
||||
}
|
||||
|
||||
maskToken.matches = maskToken.matches.reverse();
|
||||
for (var match in maskToken.matches) {
|
||||
if (Object.prototype.hasOwnProperty.call(maskToken.matches, match)) {
|
||||
var intMatch = parseInt(match);
|
||||
if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) { //reposition quantifier
|
||||
var qt = maskToken.matches[match];
|
||||
maskToken.matches.splice(match, 1);
|
||||
maskToken.matches.splice(intMatch + 1, 0, qt);
|
||||
}
|
||||
if (maskToken.matches[match].matches !== undefined) {
|
||||
maskToken.matches[match] = reverseTokens(maskToken.matches[match]);
|
||||
} else {
|
||||
maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maskToken;
|
||||
}
|
||||
|
||||
function groupify(matches) {
|
||||
var groupToken = new MaskToken(true);
|
||||
groupToken.openGroup = false;
|
||||
groupToken.matches = matches;
|
||||
return groupToken;
|
||||
}
|
||||
|
||||
function closeGroup() {
|
||||
// Group closing
|
||||
openingToken = openenings.pop();
|
||||
openingToken.openGroup = false; //mark group as complete
|
||||
if (openingToken !== undefined) {
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
currentOpeningToken.matches.push(openingToken);
|
||||
if (currentOpeningToken.isAlternator) { //handle alternator (a) | (b) case
|
||||
alternator = openenings.pop();
|
||||
let altMatchesLength = alternator.matches[0].matches ? alternator.matches[0].matches.length : 1;
|
||||
for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
|
||||
alternator.matches[mndx].isGroup = false; //don't mark alternate groups as group
|
||||
alternator.matches[mndx].alternatorGroup = false;
|
||||
if (opts.keepStatic === null && altMatchesLength < (alternator.matches[mndx].matches ? alternator.matches[mndx].matches.length : 1)) { //enable by default when passing multiple masks when the option is not explicitly specified
|
||||
opts.keepStatic = true;
|
||||
}
|
||||
altMatchesLength = alternator.matches[mndx].matches ? alternator.matches[mndx].matches.length : 1;
|
||||
}
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
currentOpeningToken.matches.push(alternator);
|
||||
} else {
|
||||
currentToken.matches.push(alternator);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
currentToken.matches.push(openingToken);
|
||||
}
|
||||
} else {
|
||||
defaultCase();
|
||||
}
|
||||
}
|
||||
|
||||
function groupQuantifier(matches) {
|
||||
var lastMatch = matches.pop();
|
||||
if (lastMatch.isQuantifier) {
|
||||
lastMatch = groupify([matches.pop(), lastMatch]);
|
||||
}
|
||||
return lastMatch;
|
||||
}
|
||||
|
||||
if (regexMask) {
|
||||
opts.optionalmarker[0] = undefined;
|
||||
opts.optionalmarker[1] = undefined;
|
||||
}
|
||||
while ((match = regexMask ? regexTokenizer.exec(mask) : tokenizer.exec(mask))) {
|
||||
m = match[0];
|
||||
|
||||
if (regexMask) {
|
||||
switch (m.charAt(0)) {
|
||||
//Quantifier
|
||||
case "?":
|
||||
m = "{0,1}";
|
||||
break;
|
||||
case "+":
|
||||
case "*":
|
||||
m = "{" + m + "}";
|
||||
break;
|
||||
case "|":
|
||||
//regex mask alternator ex: [01][0-9]|2[0-3] => ([01][0-9]|2[0-3])
|
||||
if (openenings.length === 0) { //wrap the mask in a group to form a regex alternator ([01][0-9]|2[0-3])
|
||||
var altRegexGroup = groupify(currentToken.matches);
|
||||
altRegexGroup.openGroup = true;
|
||||
openenings.push(altRegexGroup);
|
||||
currentToken.matches = [];
|
||||
closeRegexGroup = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (m) {
|
||||
case "\\d":
|
||||
m = "[0-9]";
|
||||
break;
|
||||
case "(?=": //lookahead
|
||||
// openenings.push(new MaskToken(true));
|
||||
break;
|
||||
case "(?!": //negative lookahead
|
||||
// openenings.push(new MaskToken(true));
|
||||
break;
|
||||
case "(?<=": //lookbehind
|
||||
// openenings.push(new MaskToken(true));
|
||||
break;
|
||||
case "(?<!": //negative lookbehind
|
||||
// openenings.push(new MaskToken(true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (escaped) {
|
||||
defaultCase();
|
||||
continue;
|
||||
}
|
||||
switch (m.charAt(0)) {
|
||||
case "$":
|
||||
case "^":
|
||||
//ignore beginswith and endswith as in masking this makes no point
|
||||
if (!regexMask) {
|
||||
defaultCase();
|
||||
}
|
||||
break;
|
||||
case opts.escapeChar:
|
||||
escaped = true;
|
||||
if (regexMask) defaultCase();
|
||||
break;
|
||||
// optional closing
|
||||
case opts.optionalmarker[1]:
|
||||
case opts.groupmarker[1]:
|
||||
closeGroup();
|
||||
break;
|
||||
case opts.optionalmarker[0]:
|
||||
// optional opening
|
||||
openenings.push(new MaskToken(false, true));
|
||||
break;
|
||||
case opts.groupmarker[0]:
|
||||
// Group opening
|
||||
openenings.push(new MaskToken(true));
|
||||
break;
|
||||
case opts.quantifiermarker[0]:
|
||||
//Quantifier
|
||||
var quantifier = new MaskToken(false, false, true);
|
||||
|
||||
m = m.replace(/[{}?]/g, ""); //? matches lazy quantifiers
|
||||
var mqj = m.split("|"),
|
||||
mq = mqj[0].split(","),
|
||||
mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]),
|
||||
mq1 = mq.length === 1 ? mq0 : (isNaN(mq[1]) ? mq[1] : parseInt(mq[1])),
|
||||
mqJit = isNaN(mqj[1]) ? mqj[1] : parseInt(mqj[1]);
|
||||
if (mq0 === "*" || mq0 === "+") {
|
||||
mq0 = mq1 === "*" ? 0 : 1;
|
||||
}
|
||||
quantifier.quantifier = {
|
||||
min: mq0,
|
||||
max: mq1,
|
||||
jit: mqJit
|
||||
};
|
||||
var matches = openenings.length > 0 ? openenings[openenings.length - 1].matches : currentToken.matches;
|
||||
match = matches.pop();
|
||||
if (match.isAlternator) { //handle quantifier in an alternation [0-9]{2}|[0-9]{3}
|
||||
matches.push(match); //push back alternator
|
||||
matches = match.matches; //remap target matches
|
||||
var groupToken = new MaskToken(true);
|
||||
var tmpMatch = matches.pop();
|
||||
matches.push(groupToken); //push the group
|
||||
matches = groupToken.matches;
|
||||
match = tmpMatch;
|
||||
}
|
||||
if (!match.isGroup) {
|
||||
// if (regexMask && match.fn === null) { //why is this needed???
|
||||
// if (match.def === ".") match.fn = new RegExp(match.def, opts.casing ? "i" : "");
|
||||
// }
|
||||
|
||||
match = groupify([match]);
|
||||
}
|
||||
matches.push(match);
|
||||
matches.push(quantifier);
|
||||
|
||||
break;
|
||||
case opts.alternatormarker:
|
||||
if (openenings.length > 0) {
|
||||
currentOpeningToken = openenings[openenings.length - 1];
|
||||
var subToken = currentOpeningToken.matches[currentOpeningToken.matches.length - 1];
|
||||
if (currentOpeningToken.openGroup && //regexp alt syntax
|
||||
(subToken.matches === undefined || (subToken.isGroup === false && subToken.isAlternator === false))) { //alternations within group
|
||||
lastMatch = openenings.pop();
|
||||
} else {
|
||||
lastMatch = groupQuantifier(currentOpeningToken.matches);
|
||||
}
|
||||
} else {
|
||||
lastMatch = groupQuantifier(currentToken.matches);
|
||||
}
|
||||
if (lastMatch.isAlternator) {
|
||||
openenings.push(lastMatch);
|
||||
} else {
|
||||
if (lastMatch.alternatorGroup) {
|
||||
alternator = openenings.pop();
|
||||
lastMatch.alternatorGroup = false;
|
||||
} else {
|
||||
alternator = new MaskToken(false, false, false, true);
|
||||
}
|
||||
alternator.matches.push(lastMatch);
|
||||
openenings.push(alternator);
|
||||
if (lastMatch.openGroup) { //regexp alt syntax
|
||||
lastMatch.openGroup = false;
|
||||
var alternatorGroup = new MaskToken(true);
|
||||
alternatorGroup.alternatorGroup = true;
|
||||
openenings.push(alternatorGroup);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
defaultCase();
|
||||
}
|
||||
}
|
||||
|
||||
if (closeRegexGroup) closeGroup();
|
||||
|
||||
while (openenings.length > 0) {
|
||||
openingToken = openenings.pop();
|
||||
currentToken.matches.push(openingToken);
|
||||
}
|
||||
if (currentToken.matches.length > 0) {
|
||||
verifyGroupMarker(currentToken);
|
||||
maskTokens.push(currentToken);
|
||||
}
|
||||
|
||||
if (opts.numericInput || opts.isRTL) {
|
||||
reverseTokens(maskTokens[0]);
|
||||
}
|
||||
// console.log(JSON.stringify(maskTokens));
|
||||
return maskTokens;
|
||||
}
|
244
node_modules/inputmask/lib/mask.js
generated
vendored
Normal file
244
node_modules/inputmask/lib/mask.js
generated
vendored
Normal file
|
@ -0,0 +1,244 @@
|
|||
import keyCode from "./keycode.json";
|
||||
import {caret, getBuffer, getBufferTemplate, getLastValidPosition, resetMaskSet, seekNext} from "./positioning";
|
||||
import {applyInputValue, clearOptionalTail, writeBuffer} from "./inputHandling";
|
||||
import {EventRuler} from "./eventruler";
|
||||
import {iphone, mobile} from "./environment";
|
||||
import {isComplete} from "./validation";
|
||||
import {EventHandlers} from "./eventhandlers";
|
||||
|
||||
export{mask};
|
||||
|
||||
//todo put on the prototype?
|
||||
function mask() {
|
||||
const inputmask = this,
|
||||
opts= this.opts,
|
||||
el=this.el,$=this.dependencyLib;
|
||||
|
||||
|
||||
function isElementTypeSupported(input, opts) {
|
||||
function patchValueProperty(npt) {
|
||||
var valueGet;
|
||||
var valueSet;
|
||||
|
||||
function patchValhook(type) {
|
||||
if ($.valHooks && ($.valHooks[type] === undefined || $.valHooks[type].inputmaskpatch !== true)) {
|
||||
var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function (elem) {
|
||||
return elem.value;
|
||||
};
|
||||
var valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function (elem, value) {
|
||||
elem.value = value;
|
||||
return elem;
|
||||
};
|
||||
|
||||
$.valHooks[type] = {
|
||||
get: function (elem) {
|
||||
if (elem.inputmask) {
|
||||
if (elem.inputmask.opts.autoUnmask) {
|
||||
return elem.inputmask.unmaskedvalue();
|
||||
} else {
|
||||
var result = valhookGet(elem);
|
||||
return getLastValidPosition.call(inputmask, undefined, undefined, elem.inputmask.maskset.validPositions) !== -1 || opts.nullable !== true ? result : "";
|
||||
}
|
||||
} else {
|
||||
return valhookGet(elem);
|
||||
}
|
||||
},
|
||||
set: function (elem, value) {
|
||||
var result = valhookSet(elem, value);
|
||||
if (elem.inputmask) {
|
||||
applyInputValue(elem, value);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
inputmaskpatch: true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function getter() {
|
||||
if (this.inputmask) {
|
||||
return this.inputmask.opts.autoUnmask ?
|
||||
this.inputmask.unmaskedvalue() :
|
||||
(getLastValidPosition.call(inputmask) !== -1 || opts.nullable !== true ?
|
||||
(((this.inputmask.shadowRoot || this.ownerDocument).activeElement) === this && opts.clearMaskOnLostFocus ?
|
||||
(inputmask.isRTL ? clearOptionalTail.call(inputmask,getBuffer.call(inputmask).slice()).reverse() : clearOptionalTail.call(inputmask,getBuffer.call(inputmask).slice())).join("") :
|
||||
valueGet.call(this)) :
|
||||
"");
|
||||
} else {
|
||||
return valueGet.call(this);
|
||||
}
|
||||
}
|
||||
|
||||
function setter(value) {
|
||||
valueSet.call(this, value);
|
||||
if (this.inputmask) {
|
||||
applyInputValue(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
function installNativeValueSetFallback(npt) {
|
||||
EventRuler.on(npt, "mouseenter", function () {
|
||||
var input = this,
|
||||
value = input.inputmask._valueGet(true);
|
||||
if (value !== (inputmask.isRTL ? getBuffer.call(inputmask).reverse() : getBuffer.call(inputmask)).join("")) { //Is this correct? to apply RTL? TOCHECK
|
||||
applyInputValue(input, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!npt.inputmask.__valueGet) {
|
||||
if (opts.noValuePatching !== true) {
|
||||
if (Object.getOwnPropertyDescriptor) {
|
||||
var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : undefined;
|
||||
if (valueProperty && valueProperty.get && valueProperty.set) {
|
||||
valueGet = valueProperty.get;
|
||||
valueSet = valueProperty.set;
|
||||
Object.defineProperty(npt, "value", {
|
||||
get: getter,
|
||||
set: setter,
|
||||
configurable: true
|
||||
});
|
||||
} else if (npt.tagName.toLowerCase() !== "input") {
|
||||
valueGet = function () {
|
||||
return this.textContent;
|
||||
};
|
||||
valueSet = function (value) {
|
||||
this.textContent = value;
|
||||
};
|
||||
Object.defineProperty(npt, "value", {
|
||||
get: getter,
|
||||
set: setter,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
} else if (document.__lookupGetter__ && npt.__lookupGetter__("value")) {
|
||||
valueGet = npt.__lookupGetter__("value");
|
||||
valueSet = npt.__lookupSetter__("value");
|
||||
|
||||
npt.__defineGetter__("value", getter);
|
||||
npt.__defineSetter__("value", setter);
|
||||
}
|
||||
npt.inputmask.__valueGet = valueGet; //store native property getter
|
||||
npt.inputmask.__valueSet = valueSet; //store native property setter
|
||||
}
|
||||
npt.inputmask._valueGet = function (overruleRTL) {
|
||||
return inputmask.isRTL && overruleRTL !== true ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
|
||||
};
|
||||
npt.inputmask._valueSet = function (value, overruleRTL) { //null check is needed for IE8 => otherwise converts to "null"
|
||||
valueSet.call(this.el, (value === null || value === undefined) ? "" : ((overruleRTL !== true && inputmask.isRTL) ? value.split("").reverse().join("") : value));
|
||||
};
|
||||
|
||||
if (valueGet === undefined) { //jquery.val fallback
|
||||
valueGet = function () {
|
||||
return this.value;
|
||||
};
|
||||
valueSet = function (value) {
|
||||
this.value = value;
|
||||
};
|
||||
patchValhook(npt.type);
|
||||
installNativeValueSetFallback(npt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (input.tagName.toLowerCase() !== "textarea") {
|
||||
opts.ignorables.push(keyCode.ENTER);
|
||||
}
|
||||
|
||||
var elementType = input.getAttribute("type");
|
||||
var isSupported = (input.tagName.toLowerCase() === "input" && opts.supportsInputType.includes(elementType)) || input.isContentEditable || input.tagName.toLowerCase() === "textarea";
|
||||
if (!isSupported) {
|
||||
if (input.tagName.toLowerCase() === "input") {
|
||||
var el = document.createElement("input");
|
||||
el.setAttribute("type", elementType);
|
||||
isSupported = el.type === "text"; //apply mask only if the type is not natively supported
|
||||
el = null;
|
||||
} else {
|
||||
isSupported = "partial";
|
||||
}
|
||||
}
|
||||
if (isSupported !== false) {
|
||||
patchValueProperty(input);
|
||||
} else {
|
||||
input.inputmask = undefined;
|
||||
}
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
//unbind all events - to make sure that no other mask will interfere when re-masking
|
||||
EventRuler.off(el);
|
||||
var isSupported = isElementTypeSupported(el, opts);
|
||||
if (isSupported !== false) {
|
||||
inputmask.originalPlaceholder = el.placeholder;
|
||||
|
||||
//read maxlength prop from el
|
||||
inputmask.maxLength = el !== undefined ? el.maxLength : undefined;
|
||||
if (inputmask.maxLength === -1) inputmask.maxLength = undefined;
|
||||
if ("inputMode" in el && el.getAttribute("inputmode") === null) {
|
||||
el.inputMode = opts.inputmode;
|
||||
el.setAttribute("inputmode", opts.inputmode);
|
||||
}
|
||||
|
||||
|
||||
if (isSupported === true) {
|
||||
opts.showMaskOnFocus = opts.showMaskOnFocus && ["cc-number", "cc-exp"].indexOf(el.autocomplete) === -1;
|
||||
if (iphone) { //selecting the caret shows as a slection on iphone
|
||||
opts.insertModeVisual = false;
|
||||
}
|
||||
|
||||
//bind events
|
||||
EventRuler.on(el, "submit", EventHandlers.submitEvent);
|
||||
EventRuler.on(el, "reset", EventHandlers.resetEvent);
|
||||
EventRuler.on(el, "blur", EventHandlers.blurEvent);
|
||||
EventRuler.on(el, "focus", EventHandlers.focusEvent);
|
||||
EventRuler.on(el, "invalid", EventHandlers.invalidEvent);
|
||||
EventRuler.on(el, "click", EventHandlers.clickEvent);
|
||||
EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent);
|
||||
EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent);
|
||||
EventRuler.on(el, "paste", EventHandlers.pasteEvent);
|
||||
EventRuler.on(el, "cut", EventHandlers.cutEvent);
|
||||
EventRuler.on(el, "complete", opts.oncomplete);
|
||||
EventRuler.on(el, "incomplete", opts.onincomplete);
|
||||
EventRuler.on(el, "cleared", opts.oncleared);
|
||||
if (opts.inputEventOnly !== true) {
|
||||
EventRuler.on(el, "keydown", EventHandlers.keydownEvent);
|
||||
EventRuler.on(el, "keypress", EventHandlers.keypressEvent);
|
||||
EventRuler.on(el, "keyup", EventHandlers.keyupEvent);
|
||||
}
|
||||
if (mobile || opts.inputEventOnly) {
|
||||
el.removeAttribute("maxLength");
|
||||
}
|
||||
EventRuler.on(el, "input", EventHandlers.inputFallBackEvent);
|
||||
EventRuler.on(el, "compositionend", EventHandlers.compositionendEvent);
|
||||
// EventRuler.on(el, "beforeinput", EventHandlers.beforeInputEvent); //https://github.com/w3c/input-events - to implement
|
||||
}
|
||||
EventRuler.on(el, "setvalue", EventHandlers.setValueEvent);
|
||||
|
||||
//apply mask
|
||||
getBufferTemplate.call(inputmask).join(""); //initialize the buffer and getmasklength
|
||||
inputmask.undoValue = inputmask._valueGet(true);
|
||||
var activeElement = (el.inputmask.shadowRoot || el.ownerDocument).activeElement;
|
||||
if (el.inputmask._valueGet(true) !== "" || opts.clearMaskOnLostFocus === false || activeElement === el) {
|
||||
applyInputValue(el, el.inputmask._valueGet(true), opts);
|
||||
var buffer = getBuffer.call(inputmask).slice();
|
||||
if (isComplete.call(inputmask, buffer) === false) {
|
||||
if (opts.clearIncomplete) {
|
||||
resetMaskSet.call(inputmask);
|
||||
}
|
||||
}
|
||||
if (opts.clearMaskOnLostFocus && activeElement !== el) {
|
||||
if (getLastValidPosition.call(inputmask) === -1) {
|
||||
buffer = [];
|
||||
} else {
|
||||
clearOptionalTail.call(inputmask, buffer);
|
||||
}
|
||||
}
|
||||
if (opts.clearMaskOnLostFocus === false || (opts.showMaskOnFocus && activeElement === el) || el.inputmask._valueGet(true) !== "") {
|
||||
writeBuffer(el, buffer);
|
||||
}
|
||||
if (activeElement === el) { //position the caret when in focus
|
||||
caret.call(inputmask,el, seekNext.call(inputmask, getLastValidPosition.call(inputmask)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
node_modules/inputmask/lib/masktoken.js
generated
vendored
Normal file
13
node_modules/inputmask/lib/masktoken.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
export default function (isGroup, isOptional, isQuantifier, isAlternator) {
|
||||
this.matches = [];
|
||||
this.openGroup = isGroup || false;
|
||||
this.alternatorGroup = false;
|
||||
this.isGroup = isGroup || false;
|
||||
this.isOptional = isOptional || false;
|
||||
this.isQuantifier = isQuantifier || false;
|
||||
this.isAlternator = isAlternator || false;
|
||||
this.quantifier = {
|
||||
min: 1,
|
||||
max: 1
|
||||
};
|
||||
}
|
48
node_modules/inputmask/lib/polyfills/Array.includes.js
generated
vendored
Normal file
48
node_modules/inputmask/lib/polyfills/Array.includes.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// https://tc39.github.io/ecma262/#sec-array.prototype.includes
|
||||
if (!Array.prototype.includes) {
|
||||
Object.defineProperty(Array.prototype, "includes", {
|
||||
value: function(searchElement, fromIndex) {
|
||||
|
||||
// 1. Let O be ? ToObject(this value).
|
||||
if (this == null) {
|
||||
throw new TypeError("\"this\" is null or not defined");
|
||||
}
|
||||
|
||||
var o = Object(this);
|
||||
|
||||
// 2. Let len be ? ToLength(? Get(O, "length")).
|
||||
var len = o.length >>> 0;
|
||||
|
||||
// 3. If len is 0, return false.
|
||||
if (len === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 4. Let n be ? ToInteger(fromIndex).
|
||||
// (If fromIndex is undefined, this step produces the value 0.)
|
||||
var n = fromIndex | 0;
|
||||
|
||||
// 5. If n ≥ 0, then
|
||||
// a. Let k be n.
|
||||
// 6. Else n < 0,
|
||||
// a. Let k be len + n.
|
||||
// b. If k < 0, let k be 0.
|
||||
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
|
||||
|
||||
// 7. Repeat, while k < len
|
||||
while (k < len) {
|
||||
// a. Let elementK be the result of ? Get(O, ! ToString(k)).
|
||||
// b. If SameValueZero(searchElement, elementK) is true, return true.
|
||||
// c. Increase k by 1.
|
||||
// NOTE: === provides the correct "SameValueZero" comparison needed here.
|
||||
if (o[k] === searchElement) {
|
||||
return true;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
|
||||
// 8. Return false
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
7
node_modules/inputmask/lib/polyfills/Object.getPrototypeOf.js
generated
vendored
Normal file
7
node_modules/inputmask/lib/polyfills/Object.getPrototypeOf.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
if (typeof Object.getPrototypeOf !== "function") {
|
||||
Object.getPrototypeOf = typeof "test".__proto__ === "object" ? function (object) {
|
||||
return object.__proto__;
|
||||
} : function (object) {
|
||||
return object.constructor.prototype;
|
||||
};
|
||||
}
|
348
node_modules/inputmask/lib/positioning.js
generated
vendored
Normal file
348
node_modules/inputmask/lib/positioning.js
generated
vendored
Normal file
|
@ -0,0 +1,348 @@
|
|||
import {
|
||||
determineTestTemplate,
|
||||
getMaskTemplate,
|
||||
getPlaceholder,
|
||||
getTest,
|
||||
getTests,
|
||||
getTestTemplate
|
||||
} from "./validation-tests";
|
||||
import {checkAlternationMatch} from "./validation";
|
||||
|
||||
export {
|
||||
caret,
|
||||
determineLastRequiredPosition,
|
||||
determineNewCaretPosition,
|
||||
getBuffer,
|
||||
getBufferTemplate,
|
||||
getLastValidPosition,
|
||||
isMask,
|
||||
resetMaskSet,
|
||||
seekNext,
|
||||
seekPrevious,
|
||||
translatePosition
|
||||
};
|
||||
|
||||
//tobe put on prototype?
|
||||
function caret(input, begin, end, notranslate, isDelete) {
|
||||
const inputmask = this,
|
||||
opts = this.opts;
|
||||
|
||||
var range;
|
||||
if (begin !== undefined) {
|
||||
if (Array.isArray(begin)) {
|
||||
end = inputmask.isRTL ? begin[0] : begin[1];
|
||||
begin = inputmask.isRTL ? begin[1] : begin[0];
|
||||
}
|
||||
if (begin.begin !== undefined) {
|
||||
end = inputmask.isRTL ? begin.begin : begin.end;
|
||||
begin = inputmask.isRTL ? begin.end : begin.begin;
|
||||
}
|
||||
if (typeof begin === "number") {
|
||||
begin = notranslate ? begin : translatePosition.call(inputmask, begin);
|
||||
end = notranslate ? end : translatePosition.call(inputmask, end);
|
||||
end = (typeof end == "number") ? end : begin;
|
||||
// if (!$(input).is(":visible")) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
|
||||
input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0;
|
||||
input.inputmask.caretPos = {begin: begin, end: end}; //track caret internally
|
||||
if (opts.insertModeVisual && opts.insertMode === false && begin === end) {
|
||||
if (!isDelete) {
|
||||
end++; //set visualization for insert/overwrite mode
|
||||
}
|
||||
}
|
||||
if (input === (input.inputmask.shadowRoot || input.ownerDocument).activeElement) {
|
||||
if ("setSelectionRange" in input) {
|
||||
input.setSelectionRange(begin, end);
|
||||
} else if (window.getSelection) {
|
||||
range = document.createRange();
|
||||
if (input.firstChild === undefined || input.firstChild === null) {
|
||||
var textNode = document.createTextNode("");
|
||||
input.appendChild(textNode);
|
||||
}
|
||||
range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length);
|
||||
range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length);
|
||||
range.collapse(true);
|
||||
var sel = window.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
//input.focus();
|
||||
} else if (input.createTextRange) {
|
||||
range = input.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd("character", end);
|
||||
range.moveStart("character", begin);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("selectionStart" in input && "selectionEnd" in input) {
|
||||
begin = input.selectionStart;
|
||||
end = input.selectionEnd;
|
||||
} else if (window.getSelection) {
|
||||
range = window.getSelection().getRangeAt(0);
|
||||
if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
|
||||
begin = range.startOffset;
|
||||
end = range.endOffset;
|
||||
}
|
||||
} else if (document.selection && document.selection.createRange) {
|
||||
range = document.selection.createRange();
|
||||
begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length);
|
||||
end = begin + range.text.length;
|
||||
}
|
||||
|
||||
// if (opts.insertModeVisual && opts.insertMode === false && begin === (end - 1)) end--; //correct caret for insert/overwrite mode
|
||||
|
||||
/*eslint-disable consistent-return */
|
||||
return {
|
||||
"begin": notranslate ? begin : translatePosition.call(inputmask, begin),
|
||||
"end": notranslate ? end : translatePosition.call(inputmask, end)
|
||||
};
|
||||
/*eslint-enable consistent-return */
|
||||
}
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function determineLastRequiredPosition(returnDefinition) {
|
||||
const inputmask = this,
|
||||
maskset = this.maskset,
|
||||
$ = this.dependencyLib;
|
||||
|
||||
var buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true, true),
|
||||
bl = buffer.length,
|
||||
pos, lvp = getLastValidPosition.call(inputmask),
|
||||
positions = {},
|
||||
lvTest = maskset.validPositions[lvp],
|
||||
ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined,
|
||||
testPos;
|
||||
for (pos = lvp + 1; pos < buffer.length; pos++) {
|
||||
testPos = getTestTemplate.call(inputmask, pos, ndxIntlzr, pos - 1);
|
||||
ndxIntlzr = testPos.locator.slice();
|
||||
positions[pos] = $.extend(true, {}, testPos);
|
||||
}
|
||||
|
||||
var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined;
|
||||
for (pos = bl - 1; pos > lvp; pos--) {
|
||||
testPos = positions[pos];
|
||||
if ((testPos.match.optionality ||
|
||||
(testPos.match.optionalQuantifier && testPos.match.newBlockMarker) ||
|
||||
(lvTestAlt &&
|
||||
(
|
||||
(lvTestAlt !== positions[pos].locator[lvTest.alternation] && testPos.match.static != true) ||
|
||||
(testPos.match.static === true &&
|
||||
testPos.locator[lvTest.alternation] &&
|
||||
checkAlternationMatch.call(inputmask, testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) &&
|
||||
getTests.call(inputmask, pos)[0].def !== "")
|
||||
)
|
||||
)) &&
|
||||
buffer[pos] === getPlaceholder.call(inputmask, pos, testPos.match)) {
|
||||
bl--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnDefinition ? {
|
||||
"l": bl,
|
||||
"def": positions[bl] ? positions[bl].match : undefined
|
||||
} : bl;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function determineNewCaretPosition(selectedCaret, tabbed, positionCaretOnClick) {
|
||||
const inputmask = this,
|
||||
maskset = this.maskset,
|
||||
opts = this.opts;
|
||||
|
||||
function doRadixFocus(clickPos) {
|
||||
if (opts.radixPoint !== "" && opts.digits !== 0) {
|
||||
var vps = maskset.validPositions;
|
||||
if (vps[clickPos] === undefined || (vps[clickPos].input === getPlaceholder.call(inputmask, clickPos))) {
|
||||
if (clickPos < seekNext.call(inputmask, -1)) return true;
|
||||
var radixPos = getBuffer.call(inputmask).indexOf(opts.radixPoint);
|
||||
if (radixPos !== -1) {
|
||||
for (var vp in vps) {
|
||||
if (vps[vp] && radixPos < vp && vps[vp].input !== getPlaceholder.call(inputmask, vp)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tabbed) {
|
||||
if (inputmask.isRTL) {
|
||||
selectedCaret.end = selectedCaret.begin;
|
||||
} else {
|
||||
selectedCaret.begin = selectedCaret.end;
|
||||
}
|
||||
}
|
||||
if (selectedCaret.begin === selectedCaret.end) {
|
||||
positionCaretOnClick = positionCaretOnClick || opts.positionCaretOnClick;
|
||||
switch (positionCaretOnClick) {
|
||||
case "none":
|
||||
break;
|
||||
case "select":
|
||||
selectedCaret = {begin: 0, end: getBuffer.call(inputmask).length};
|
||||
break;
|
||||
case "ignore":
|
||||
selectedCaret.end = selectedCaret.begin = seekNext.call(inputmask, getLastValidPosition.call(inputmask));
|
||||
break;
|
||||
case "radixFocus":
|
||||
if (doRadixFocus(selectedCaret.begin)) {
|
||||
var radixPos = getBuffer.call(inputmask).join("").indexOf(opts.radixPoint);
|
||||
selectedCaret.end = selectedCaret.begin = opts.numericInput ? seekNext.call(inputmask, radixPos) : radixPos;
|
||||
break;
|
||||
} //fallback to lvp
|
||||
// eslint-disable-next-line no-fallthrough
|
||||
default: //lvp:
|
||||
var clickPosition = selectedCaret.begin,
|
||||
lvclickPosition = getLastValidPosition.call(inputmask, clickPosition, true),
|
||||
lastPosition = seekNext.call(inputmask, (lvclickPosition === -1 && !isMask.call(inputmask, 0)) ? -1 : lvclickPosition);
|
||||
|
||||
if (clickPosition <= lastPosition) {
|
||||
selectedCaret.end = selectedCaret.begin = !isMask.call(inputmask, clickPosition, false, true) ? seekNext.call(inputmask, clickPosition) : clickPosition;
|
||||
} else {
|
||||
var lvp = maskset.validPositions[lvclickPosition],
|
||||
tt = getTestTemplate.call(inputmask, lastPosition, lvp ? lvp.match.locator : undefined, lvp),
|
||||
placeholder = getPlaceholder.call(inputmask, lastPosition, tt.match);
|
||||
if ((placeholder !== "" && getBuffer.call(inputmask)[lastPosition] !== placeholder && tt.match.optionalQuantifier !== true && tt.match.newBlockMarker !== true) || (!isMask.call(inputmask, lastPosition, opts.keepStatic, true) && tt.match.def === placeholder)) {
|
||||
var newPos = seekNext.call(inputmask, lastPosition);
|
||||
if (clickPosition >= newPos || clickPosition === lastPosition) {
|
||||
lastPosition = newPos;
|
||||
}
|
||||
}
|
||||
selectedCaret.end = selectedCaret.begin = lastPosition;
|
||||
}
|
||||
}
|
||||
|
||||
return selectedCaret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//tobe put on prototype?
|
||||
function getBuffer(noCache) {
|
||||
const inputmask = this, maskset = this.maskset;
|
||||
|
||||
if (maskset.buffer === undefined || noCache === true) {
|
||||
maskset.buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true);
|
||||
if (maskset._buffer === undefined) maskset._buffer = maskset.buffer.slice();
|
||||
}
|
||||
return maskset.buffer;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function getBufferTemplate() {
|
||||
const inputmask = this, maskset = this.maskset;
|
||||
|
||||
if (maskset._buffer === undefined) {
|
||||
//generate template
|
||||
maskset._buffer = getMaskTemplate.call(inputmask, false, 1);
|
||||
if (maskset.buffer === undefined) maskset.buffer = maskset._buffer.slice();
|
||||
}
|
||||
return maskset._buffer;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function getLastValidPosition(closestTo, strict, validPositions) {
|
||||
const maskset = this.maskset;
|
||||
|
||||
var before = -1,
|
||||
after = -1,
|
||||
valids = validPositions || maskset.validPositions; //for use in valhook ~ context switch
|
||||
if (closestTo === undefined) closestTo = -1;
|
||||
for (var posNdx in valids) {
|
||||
var psNdx = parseInt(posNdx);
|
||||
if (valids[psNdx] && (strict || valids[psNdx].generatedInput !== true)) {
|
||||
if (psNdx <= closestTo) before = psNdx;
|
||||
if (psNdx >= closestTo) after = psNdx;
|
||||
}
|
||||
}
|
||||
return (before === -1 || before == closestTo) ? after : after == -1 ? before : (closestTo - before) < (after - closestTo) ? before : after;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function isMask(pos, strict, fuzzy) {
|
||||
const inputmask = this, maskset = this.maskset;
|
||||
|
||||
var test = getTestTemplate.call(inputmask, pos).match;
|
||||
if (test.def === "") test = getTest.call(inputmask, pos).match;
|
||||
|
||||
if (test.static !== true) {
|
||||
return test.fn;
|
||||
}
|
||||
if (fuzzy === true && (maskset.validPositions[pos] !== undefined && maskset.validPositions[pos].generatedInput !== true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strict !== true && pos > -1) {
|
||||
if (fuzzy) { //check on the number of tests
|
||||
var tests = getTests.call(inputmask, pos);
|
||||
return tests.length > (1 + (tests[tests.length - 1].match.def === "" ? 1 : 0));
|
||||
}
|
||||
//else based on the template
|
||||
var testTemplate = determineTestTemplate.call(inputmask, pos, getTests.call(inputmask, pos));
|
||||
var testPlaceHolder = getPlaceholder.call(inputmask, pos, testTemplate.match);
|
||||
return testTemplate.match.def !== testPlaceHolder;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function resetMaskSet(soft) {
|
||||
const maskset = this.maskset;
|
||||
|
||||
maskset.buffer = undefined;
|
||||
if (soft !== true) {
|
||||
maskset.validPositions = {};
|
||||
maskset.p = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function seekNext(pos, newBlock, fuzzy) {
|
||||
const inputmask = this;
|
||||
|
||||
if (fuzzy === undefined) fuzzy = true;
|
||||
var position = pos + 1;
|
||||
while (getTest.call(inputmask, position).match.def !== "" &&
|
||||
((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
|
||||
(newBlock !== true && !isMask.call(inputmask, position, undefined, fuzzy)))) {
|
||||
position++;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function seekPrevious(pos, newBlock) {
|
||||
const inputmask = this;
|
||||
|
||||
var position = pos - 1;
|
||||
if (pos <= 0) return 0;
|
||||
|
||||
while (position > 0 &&
|
||||
((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
|
||||
(newBlock !== true && !isMask.call(inputmask, position, undefined, true)))) {
|
||||
position--;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function translatePosition(pos) {
|
||||
const inputmask = this,
|
||||
opts = this.opts,
|
||||
el = this.el;
|
||||
|
||||
if (inputmask.isRTL && typeof pos === "number" && (!opts.greedy || opts.placeholder !== "") && el) {
|
||||
pos = Math.abs(inputmask._valueGet().length - pos);
|
||||
}
|
||||
return pos;
|
||||
}
|
597
node_modules/inputmask/lib/validation-tests.js
generated
vendored
Normal file
597
node_modules/inputmask/lib/validation-tests.js
generated
vendored
Normal file
|
@ -0,0 +1,597 @@
|
|||
export {
|
||||
determineTestTemplate,
|
||||
getDecisionTaker,
|
||||
getMaskTemplate,
|
||||
getPlaceholder,
|
||||
getTest,
|
||||
getTests,
|
||||
getTestTemplate,
|
||||
isSubsetOf
|
||||
};
|
||||
import Inputmask from "./inputmask";
|
||||
|
||||
function getLocator(tst, align) { //need to align the locators to be correct
|
||||
var locator = (tst.alternation != undefined ? tst.mloc[getDecisionTaker(tst)] : tst.locator).join("");
|
||||
if (locator !== "") while (locator.length < align) locator += "0";
|
||||
return locator;
|
||||
}
|
||||
|
||||
function getDecisionTaker(tst) {
|
||||
var decisionTaker = tst.locator[tst.alternation];
|
||||
if (typeof decisionTaker == "string" && decisionTaker.length > 0) { //no decision taken ~ take first one as decider
|
||||
decisionTaker = decisionTaker.split(",")[0];
|
||||
}
|
||||
return decisionTaker !== undefined ? decisionTaker.toString() : "";
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function getPlaceholder(pos, test, returnPL) {
|
||||
const inputmask = this,
|
||||
opts = this.opts,
|
||||
maskset = this.maskset;
|
||||
|
||||
test = test || getTest.call(inputmask, pos).match;
|
||||
if (test.placeholder !== undefined || returnPL === true) {
|
||||
return typeof test.placeholder === "function" ? test.placeholder(opts) : test.placeholder;
|
||||
} else if (test.static === true) {
|
||||
if (pos > -1 && maskset.validPositions[pos] === undefined) {
|
||||
var tests = getTests.call(inputmask, pos),
|
||||
staticAlternations = [],
|
||||
prevTest;
|
||||
if (tests.length > 1 + (tests[tests.length - 1].match.def === "" ? 1 : 0)) {
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
if (tests[i].match.def !== "" && tests[i].match.optionality !== true && tests[i].match.optionalQuantifier !== true &&
|
||||
(tests[i].match.static === true || (prevTest === undefined || tests[i].match.fn.test(prevTest.match.def, maskset, pos, true, opts) !== false))) {
|
||||
staticAlternations.push(tests[i]);
|
||||
if (tests[i].match.static === true) prevTest = tests[i];
|
||||
if (staticAlternations.length > 1) {
|
||||
if (/[0-9a-bA-Z]/.test(staticAlternations[0].match.def)) {
|
||||
return opts.placeholder.charAt(pos % opts.placeholder.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return test.def;
|
||||
}
|
||||
|
||||
return opts.placeholder.charAt(pos % opts.placeholder.length);
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function getMaskTemplate(baseOnInput, minimalPos, includeMode, noJit, clearOptionalTail) {
|
||||
//includeMode true => input, undefined => placeholder, false => mask
|
||||
|
||||
var inputmask = this,
|
||||
opts = this.opts,
|
||||
maskset = this.maskset;
|
||||
|
||||
|
||||
var greedy = opts.greedy;
|
||||
if (clearOptionalTail && opts.greedy) {
|
||||
opts.greedy = false;
|
||||
inputmask.maskset.tests = {};
|
||||
}
|
||||
minimalPos = minimalPos || 0;
|
||||
var maskTemplate = [],
|
||||
ndxIntlzr, pos = 0,
|
||||
test, testPos, jitRenderStatic;
|
||||
do {
|
||||
if (baseOnInput === true && maskset.validPositions[pos]) {
|
||||
testPos = (clearOptionalTail && maskset.validPositions[pos].match.optionality
|
||||
&& maskset.validPositions[pos + 1] === undefined
|
||||
&& (maskset.validPositions[pos].generatedInput === true || (maskset.validPositions[pos].input == opts.skipOptionalPartCharacter && pos > 0)))
|
||||
? determineTestTemplate.call(inputmask, pos, getTests.call(inputmask, pos, ndxIntlzr, pos - 1))
|
||||
: maskset.validPositions[pos];
|
||||
test = testPos.match;
|
||||
ndxIntlzr = testPos.locator.slice();
|
||||
maskTemplate.push(includeMode === true ? testPos.input : includeMode === false ? test.nativeDef : getPlaceholder.call(inputmask, pos, test));
|
||||
} else {
|
||||
testPos = getTestTemplate.call(inputmask, pos, ndxIntlzr, pos - 1);
|
||||
test = testPos.match;
|
||||
ndxIntlzr = testPos.locator.slice();
|
||||
var jitMasking = noJit === true ? false : (opts.jitMasking !== false ? opts.jitMasking : test.jit);
|
||||
//check for groupSeparator is a hack for the numerics as we don't want the render of the groupSeparator beforehand
|
||||
jitRenderStatic = ((jitRenderStatic && test.static && test.def !== opts.groupSeparator && test.fn === null) || (maskset.validPositions[pos - 1] && test.static && test.def !== opts.groupSeparator && test.fn === null)) && maskset.tests[pos] && maskset.tests[pos].length === 1;
|
||||
if (jitRenderStatic || jitMasking === false || jitMasking === undefined /*|| pos < lvp*/ || (typeof jitMasking === "number" && isFinite(jitMasking) && jitMasking > pos)) {
|
||||
maskTemplate.push(includeMode === false ? test.nativeDef : getPlaceholder.call(inputmask, pos, test));
|
||||
} else {
|
||||
jitRenderStatic = false;
|
||||
}
|
||||
}
|
||||
|
||||
pos++;
|
||||
} while ((test.static !== true || test.def !== "") || minimalPos > pos);
|
||||
if (maskTemplate[maskTemplate.length - 1] === "") {
|
||||
maskTemplate.pop(); //drop the last one which is empty
|
||||
}
|
||||
if (includeMode !== false || //do not alter the masklength when just retrieving the maskdefinition
|
||||
maskset.maskLength === undefined) //just make sure the maskLength gets initialized in all cases (needed for isValid)
|
||||
{
|
||||
maskset.maskLength = pos - 1;
|
||||
}
|
||||
|
||||
opts.greedy = greedy;
|
||||
return maskTemplate;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function getTestTemplate(pos, ndxIntlzr, tstPs) {
|
||||
var inputmask = this,
|
||||
maskset = this.maskset;
|
||||
|
||||
return maskset.validPositions[pos] || determineTestTemplate.call(inputmask, pos, getTests.call(inputmask, pos, ndxIntlzr ? ndxIntlzr.slice() : ndxIntlzr, tstPs));
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function determineTestTemplate(pos, tests) {
|
||||
var inputmask = this,
|
||||
opts = this.opts;
|
||||
var optionalityLevel = determineOptionalityLevel(pos, tests);
|
||||
pos = pos > 0 ? pos - 1 : 0;
|
||||
var altTest = getTest.call(inputmask, pos), targetLocator = getLocator(altTest), tstLocator, closest, bestMatch;
|
||||
if (opts.greedy && tests.length > 1 && tests[tests.length - 1].match.def === "")
|
||||
tests.pop();
|
||||
// console.log(" optionality = " + optionalityLevel);
|
||||
// console.log(" - " + JSON.stringify(tests));
|
||||
for (var ndx = 0; ndx < tests.length; ndx++) { //find best matching
|
||||
var tst = tests[ndx];
|
||||
tstLocator = getLocator(tst, targetLocator.length);
|
||||
var distance = Math.abs(tstLocator - targetLocator);
|
||||
|
||||
if (closest === undefined
|
||||
|| (tstLocator !== "" && distance < closest)
|
||||
|| (bestMatch && !opts.greedy &&
|
||||
(bestMatch.match.optionality && bestMatch.match.optionality - optionalityLevel > 0) &&
|
||||
bestMatch.match.newBlockMarker === "master" &&
|
||||
((!tst.match.optionality || tst.match.optionality - optionalityLevel < 1) || !tst.match.newBlockMarker))
|
||||
|| (bestMatch && !opts.greedy && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier)) {
|
||||
closest = distance;
|
||||
bestMatch = tst;
|
||||
}
|
||||
}
|
||||
return bestMatch;
|
||||
}
|
||||
|
||||
function determineOptionalityLevel(pos, tests) {
|
||||
let optionalityLevel = 0, differentOptionalLevels = false;
|
||||
tests.forEach(test => {
|
||||
if (test.match.optionality) {
|
||||
if (optionalityLevel !== 0 && optionalityLevel !== test.match.optionality)
|
||||
differentOptionalLevels = true;
|
||||
if (optionalityLevel === 0 || optionalityLevel > test.match.optionality) {
|
||||
optionalityLevel = test.match.optionality;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (optionalityLevel) {
|
||||
if (pos == 0) optionalityLevel = 0;
|
||||
else if (tests.length == 1) optionalityLevel = 0;
|
||||
else if (!differentOptionalLevels) optionalityLevel = 0;
|
||||
}
|
||||
return optionalityLevel;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function getTest(pos, tests) {
|
||||
var inputmask = this,
|
||||
maskset = this.maskset;
|
||||
|
||||
if (maskset.validPositions[pos]) {
|
||||
return maskset.validPositions[pos];
|
||||
}
|
||||
return (tests || getTests.call(inputmask, pos))[0];
|
||||
}
|
||||
|
||||
function isSubsetOf(source, target, opts) {
|
||||
function expand(pattern) {
|
||||
var expanded = [], start = -1, end;
|
||||
for (var i = 0, l = pattern.length; i < l; i++) {
|
||||
if (pattern.charAt(i) === "-") {
|
||||
end = pattern.charCodeAt(i + 1);
|
||||
while (++start < end) expanded.push(String.fromCharCode(start));
|
||||
} else {
|
||||
start = pattern.charCodeAt(i);
|
||||
expanded.push(pattern.charAt(i));
|
||||
}
|
||||
}
|
||||
return expanded.join("");
|
||||
}
|
||||
|
||||
if (source.match.def === target.match.nativeDef) return true;
|
||||
if ((opts.regex || (source.match.fn instanceof RegExp && target.match.fn instanceof RegExp)) && source.match.static !== true && target.match.static !== true) { //is regex a subset
|
||||
return expand(target.match.fn.toString().replace(/[[\]/]/g, "")).indexOf(expand(source.match.fn.toString().replace(/[[\]/]/g, ""))) !== -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function getTests(pos, ndxIntlzr, tstPs) {
|
||||
var inputmask = this,
|
||||
$ = this.dependencyLib,
|
||||
maskset = this.maskset,
|
||||
opts = this.opts,
|
||||
el = this.el,
|
||||
maskTokens = maskset.maskToken,
|
||||
testPos = ndxIntlzr ? tstPs : 0,
|
||||
ndxInitializer = ndxIntlzr ? ndxIntlzr.slice() : [0],
|
||||
matches = [],
|
||||
insertStop = false,
|
||||
latestMatch,
|
||||
cacheDependency = ndxIntlzr ? ndxIntlzr.join("") : "";
|
||||
|
||||
function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { //ndxInitializer contains a set of indexes to speedup searches in the mtokens
|
||||
function handleMatch(match, loopNdx, quantifierRecurse) {
|
||||
function isFirstMatch(latestMatch, tokenGroup) {
|
||||
var firstMatch = tokenGroup.matches.indexOf(latestMatch) === 0;
|
||||
if (!firstMatch) {
|
||||
tokenGroup.matches.every(function (match, ndx) {
|
||||
if (match.isQuantifier === true) {
|
||||
firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1]);
|
||||
} else if (Object.prototype.hasOwnProperty.call(match, "matches")) firstMatch = isFirstMatch(latestMatch, match);
|
||||
if (firstMatch) return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return firstMatch;
|
||||
}
|
||||
|
||||
function resolveNdxInitializer(pos, alternateNdx, targetAlternation) {
|
||||
var bestMatch, indexPos;
|
||||
|
||||
if (maskset.tests[pos] || maskset.validPositions[pos]) {
|
||||
(maskset.tests[pos] || [maskset.validPositions[pos]]).every(function (lmnt, ndx) {
|
||||
if (lmnt.mloc[alternateNdx]) {
|
||||
bestMatch = lmnt;
|
||||
return false; //break
|
||||
}
|
||||
var alternation = targetAlternation !== undefined ? targetAlternation : lmnt.alternation,
|
||||
ndxPos = lmnt.locator[alternation] !== undefined ? lmnt.locator[alternation].toString().indexOf(alternateNdx) : -1;
|
||||
if ((indexPos === undefined || ndxPos < indexPos) && ndxPos !== -1) {
|
||||
bestMatch = lmnt;
|
||||
indexPos = ndxPos;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
if (bestMatch) {
|
||||
var bestMatchAltIndex = bestMatch.locator[bestMatch.alternation];
|
||||
var locator = bestMatch.mloc[alternateNdx] || bestMatch.mloc[bestMatchAltIndex] || bestMatch.locator;
|
||||
return locator.slice((targetAlternation !== undefined ? targetAlternation : bestMatch.alternation) + 1);
|
||||
} else {
|
||||
return targetAlternation !== undefined ? resolveNdxInitializer(pos, alternateNdx) : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function staticCanMatchDefinition(source, target) {
|
||||
return source.match.static === true && target.match.static !== true ? target.match.fn.test(source.match.def, maskset, pos, false, opts, false) : false;
|
||||
}
|
||||
|
||||
//mergelocators for retrieving the correct locator match when merging
|
||||
function setMergeLocators(targetMatch, altMatch) {
|
||||
var alternationNdx = targetMatch.alternation,
|
||||
shouldMerge = altMatch === undefined || (alternationNdx === altMatch.alternation &&
|
||||
targetMatch.locator[alternationNdx].toString().indexOf(altMatch.locator[alternationNdx]) === -1);
|
||||
if (!shouldMerge && alternationNdx > altMatch.alternation) {
|
||||
for (var i = altMatch.alternation; i < alternationNdx; i++) {
|
||||
if (targetMatch.locator[i] !== altMatch.locator[i]) {
|
||||
alternationNdx = i;
|
||||
shouldMerge = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldMerge) {
|
||||
targetMatch.mloc = targetMatch.mloc || {};
|
||||
var locNdx = targetMatch.locator[alternationNdx];
|
||||
if (locNdx === undefined) {
|
||||
targetMatch.alternation = undefined;
|
||||
} else {
|
||||
if (typeof locNdx === "string") locNdx = locNdx.split(",")[0];
|
||||
if (targetMatch.mloc[locNdx] === undefined) targetMatch.mloc[locNdx] = targetMatch.locator.slice();
|
||||
if (altMatch !== undefined) {
|
||||
for (var ndx in altMatch.mloc) {
|
||||
if (typeof ndx === "string") ndx = ndx.split(",")[0];
|
||||
if (targetMatch.mloc[ndx] === undefined) targetMatch.mloc[ndx] = altMatch.mloc[ndx];
|
||||
}
|
||||
targetMatch.locator[alternationNdx] = Object.keys(targetMatch.mloc).join(",");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isSameLevel(targetMatch, altMatch) {
|
||||
if (targetMatch.locator.length !== altMatch.locator.length) {
|
||||
return false;
|
||||
}
|
||||
for (let locNdx = targetMatch.alternation + 1; locNdx < targetMatch.locator.length; locNdx++) {
|
||||
if (targetMatch.locator[locNdx] !== altMatch.locator[locNdx]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (testPos > (pos + opts._maxTestPos)) {
|
||||
throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + maskset.mask;
|
||||
}
|
||||
if (testPos === pos && match.matches === undefined) {
|
||||
matches.push({
|
||||
"match": match,
|
||||
"locator": loopNdx.reverse(),
|
||||
"cd": cacheDependency,
|
||||
"mloc": {}
|
||||
});
|
||||
if (match.optionality && quantifierRecurse === undefined &&
|
||||
((opts.definitions && opts.definitions[match.nativeDef] && opts.definitions[match.nativeDef].optional) ||
|
||||
(Inputmask.prototype.definitions[match.nativeDef] && Inputmask.prototype.definitions[match.nativeDef].optional))) { //prevent loop see #698
|
||||
insertStop = true; //insert a stop
|
||||
testPos = pos; //match the position after the group
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (match.matches !== undefined) {
|
||||
if (match.isGroup && quantifierRecurse !== match) { //when a group pass along to the quantifier
|
||||
match = handleMatch(maskToken.matches[maskToken.matches.indexOf(match) + 1], loopNdx, quantifierRecurse);
|
||||
if (match) return true;
|
||||
} else if (match.isOptional) {
|
||||
var optionalToken = match, mtchsNdx = matches.length;
|
||||
match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse);
|
||||
if (match) {
|
||||
//mark optionality in matches
|
||||
matches.forEach(function (mtch, ndx) {
|
||||
if (ndx >= mtchsNdx) {
|
||||
mtch.match.optionality = mtch.match.optionality ? mtch.match.optionality + 1 : 1;
|
||||
}
|
||||
});
|
||||
latestMatch = matches[matches.length - 1].match;
|
||||
|
||||
if (quantifierRecurse === undefined && isFirstMatch(latestMatch, optionalToken)) { //prevent loop see #698
|
||||
insertStop = true; //insert a stop
|
||||
testPos = pos; //match the position after the group
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (match.isAlternator) {
|
||||
var alternateToken = match,
|
||||
malternateMatches = [],
|
||||
maltMatches,
|
||||
currentMatches = matches.slice(),
|
||||
loopNdxCnt = loopNdx.length,
|
||||
unMatchedAlternation = false;
|
||||
var altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
|
||||
if (altIndex === -1 || typeof altIndex === "string") {
|
||||
var currentPos = testPos,
|
||||
ndxInitializerClone = ndxInitializer.slice(),
|
||||
altIndexArr = [],
|
||||
amndx;
|
||||
if (typeof altIndex == "string") {
|
||||
altIndexArr = altIndex.split(",");
|
||||
} else {
|
||||
for (amndx = 0; amndx < alternateToken.matches.length; amndx++) {
|
||||
altIndexArr.push(amndx.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (maskset.excludes[pos] !== undefined) {
|
||||
var altIndexArrClone = altIndexArr.slice();
|
||||
for (var i = 0, exl = maskset.excludes[pos].length; i < exl; i++) {
|
||||
var excludeSet = maskset.excludes[pos][i].toString().split(":");
|
||||
if (loopNdx.length == excludeSet[1]) {
|
||||
altIndexArr.splice(altIndexArr.indexOf(excludeSet[0]), 1);
|
||||
}
|
||||
}
|
||||
if (altIndexArr.length === 0) { //fully alternated => reset
|
||||
delete maskset.excludes[pos];
|
||||
altIndexArr = altIndexArrClone;
|
||||
}
|
||||
}
|
||||
if (opts.keepStatic === true || (isFinite(parseInt(opts.keepStatic)) && currentPos >= opts.keepStatic)) altIndexArr = altIndexArr.slice(0, 1);
|
||||
for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
|
||||
amndx = parseInt(altIndexArr[ndx]);
|
||||
matches = [];
|
||||
//set the correct ndxInitializer
|
||||
ndxInitializer = typeof altIndex === "string" ? resolveNdxInitializer(testPos, amndx, loopNdxCnt) || ndxInitializerClone.slice() : ndxInitializerClone.slice();
|
||||
var tokenMatch = alternateToken.matches[amndx];
|
||||
if (tokenMatch && handleMatch(tokenMatch, [amndx].concat(loopNdx), quantifierRecurse)) {
|
||||
match = true;
|
||||
} else {
|
||||
if (ndx === 0) {
|
||||
unMatchedAlternation = true;
|
||||
}
|
||||
if (tokenMatch && tokenMatch.matches && tokenMatch.matches.length > alternateToken.matches[0].matches.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
maltMatches = matches.slice();
|
||||
testPos = currentPos;
|
||||
matches = [];
|
||||
|
||||
//fuzzy merge matches
|
||||
for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
|
||||
var altMatch = maltMatches[ndx1],
|
||||
dropMatch = false;
|
||||
altMatch.match.jit = altMatch.match.jit || unMatchedAlternation; //mark jit when there are unmatched alternations ex: mask: "(a|aa)"
|
||||
altMatch.alternation = altMatch.alternation || loopNdxCnt;
|
||||
setMergeLocators(altMatch);
|
||||
for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
|
||||
var altMatch2 = malternateMatches[ndx2];
|
||||
if (typeof altIndex !== "string" || (altMatch.alternation !== undefined && altIndexArr.includes(altMatch.locator[altMatch.alternation].toString()))) {
|
||||
if (altMatch.match.nativeDef === altMatch2.match.nativeDef) {
|
||||
dropMatch = true;
|
||||
setMergeLocators(altMatch2, altMatch);
|
||||
break;
|
||||
} else if (isSubsetOf(altMatch, altMatch2, opts)) {
|
||||
if (setMergeLocators(altMatch, altMatch2)) {
|
||||
dropMatch = true;
|
||||
malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch);
|
||||
}
|
||||
break;
|
||||
} else if (isSubsetOf(altMatch2, altMatch, opts)) {
|
||||
setMergeLocators(altMatch2, altMatch);
|
||||
break;
|
||||
} else if (staticCanMatchDefinition(altMatch, altMatch2)) {
|
||||
if (!isSameLevel(altMatch, altMatch2) && el.inputmask.userOptions.keepStatic === undefined) {
|
||||
opts.keepStatic = true;
|
||||
} else if (setMergeLocators(altMatch, altMatch2)) {
|
||||
//insert match above general match
|
||||
dropMatch = true;
|
||||
malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!dropMatch) {
|
||||
malternateMatches.push(altMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matches = currentMatches.concat(malternateMatches);
|
||||
testPos = pos;
|
||||
insertStop = matches.length > 0; //insert a stopelemnt when there is an alternate - needed for non-greedy option
|
||||
match = malternateMatches.length > 0; //set correct match state
|
||||
|
||||
//cloneback
|
||||
ndxInitializer = ndxInitializerClone.slice();
|
||||
} else {
|
||||
match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [altIndex].concat(loopNdx), quantifierRecurse);
|
||||
}
|
||||
if (match) return true;
|
||||
} else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[maskToken.matches.indexOf(match) - 1]) {
|
||||
var qt = match;
|
||||
for (var qndx = (ndxInitializer.length > 0) ? ndxInitializer.shift() : 0; (qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max)) && testPos <= pos; qndx++) {
|
||||
var tokenGroup = maskToken.matches[maskToken.matches.indexOf(qt) - 1];
|
||||
match = handleMatch(tokenGroup, [qndx].concat(loopNdx), tokenGroup); //set the tokenGroup as quantifierRecurse marker
|
||||
if (match) {
|
||||
//get latest match
|
||||
latestMatch = matches[matches.length - 1].match;
|
||||
//mark optionality
|
||||
//TODO FIX RECURSIVE QUANTIFIERS
|
||||
latestMatch.optionalQuantifier = qndx >= qt.quantifier.min;
|
||||
// console.log(pos + " " + qt.quantifier.min + " " + latestMatch.optionalQuantifier);
|
||||
//qndx + 1 as the index starts from 0
|
||||
latestMatch.jit = (qndx + 1) * (tokenGroup.matches.indexOf(latestMatch) + 1) > qt.quantifier.jit;
|
||||
if (latestMatch.optionalQuantifier && isFirstMatch(latestMatch, tokenGroup)) {
|
||||
insertStop = true;
|
||||
testPos = pos; //match the position after the group
|
||||
break; //stop quantifierloop && search for next possible match
|
||||
}
|
||||
if (latestMatch.jit /*&& !latestMatch.optionalQuantifier*/) {
|
||||
//always set jitOffset, isvalid checks when to apply
|
||||
maskset.jitOffset[pos] = tokenGroup.matches.length - tokenGroup.matches.indexOf(latestMatch);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse);
|
||||
if (match) return true;
|
||||
}
|
||||
} else {
|
||||
testPos++;
|
||||
}
|
||||
}
|
||||
|
||||
//the offset is set in the quantifierloop when git masking is used
|
||||
for (var tndx = (ndxInitializer.length > 0 ? ndxInitializer.shift() : 0); tndx < maskToken.matches.length; tndx++) {
|
||||
if (maskToken.matches[tndx].isQuantifier !== true) {
|
||||
var match = handleMatch(maskToken.matches[tndx], [tndx].concat(loopNdx), quantifierRecurse);
|
||||
if (match && testPos === pos) {
|
||||
return match;
|
||||
} else if (testPos > pos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mergeLocators(pos, tests) {
|
||||
let locator = [], alternation;
|
||||
if (!Array.isArray(tests)) tests = [tests];
|
||||
|
||||
if (tests.length > 0) {
|
||||
if (tests[0].alternation === undefined || opts.keepStatic === true) {
|
||||
locator = determineTestTemplate.call(inputmask, pos, tests.slice()).locator.slice();
|
||||
if (locator.length === 0) locator = tests[0].locator.slice();
|
||||
} else {
|
||||
tests.forEach(function (tst) {
|
||||
if (tst.def !== "") {
|
||||
if (locator.length === 0) {
|
||||
alternation = tst.alternation;
|
||||
locator = tst.locator.slice();
|
||||
} else {
|
||||
if (tst.locator[alternation] && locator[alternation].toString().indexOf(tst.locator[alternation]) === -1) {
|
||||
locator[alternation] += "," + tst.locator[alternation];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return locator;
|
||||
}
|
||||
|
||||
if (pos > -1) {
|
||||
if (ndxIntlzr === undefined) { //determine index initializer
|
||||
var previousPos = pos - 1,
|
||||
test;
|
||||
while ((test = maskset.validPositions[previousPos] || maskset.tests[previousPos]) === undefined && previousPos > -1) {
|
||||
previousPos--;
|
||||
}
|
||||
if (test !== undefined && previousPos > -1) {
|
||||
ndxInitializer = mergeLocators(previousPos, test);
|
||||
cacheDependency = ndxInitializer.join("");
|
||||
testPos = previousPos;
|
||||
}
|
||||
}
|
||||
if (maskset.tests[pos] && maskset.tests[pos][0].cd === cacheDependency) { //cacheDependency is set on all tests, just check on the first
|
||||
return maskset.tests[pos];
|
||||
}
|
||||
for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
|
||||
var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [mtndx]);
|
||||
if ((match && testPos === pos) || testPos > pos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matches.length === 0 || insertStop) {
|
||||
matches.push({
|
||||
match: {
|
||||
fn: null,
|
||||
static: true,
|
||||
optionality: false,
|
||||
casing: null,
|
||||
def: "",
|
||||
placeholder: ""
|
||||
},
|
||||
locator: [],
|
||||
mloc: {},
|
||||
cd: cacheDependency
|
||||
});
|
||||
}
|
||||
var result;
|
||||
if (ndxIntlzr !== undefined && maskset.tests[pos]) { //prioritize full tests for caching
|
||||
result = $.extend(true, [], matches);
|
||||
} else {
|
||||
maskset.tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
|
||||
result = maskset.tests[pos];
|
||||
}
|
||||
|
||||
// console.log(pos + " - " + JSON.stringify(matches));
|
||||
//cleanup optionality marking
|
||||
matches.forEach(t => {
|
||||
t.match.optionality = false;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
664
node_modules/inputmask/lib/validation.js
generated
vendored
Normal file
664
node_modules/inputmask/lib/validation.js
generated
vendored
Normal file
|
@ -0,0 +1,664 @@
|
|||
import {
|
||||
determineTestTemplate,
|
||||
getDecisionTaker,
|
||||
getPlaceholder,
|
||||
getTest,
|
||||
getTests,
|
||||
getTestTemplate
|
||||
} from "./validation-tests";
|
||||
import keyCode from "./keycode.json";
|
||||
import {
|
||||
determineLastRequiredPosition, determineNewCaretPosition,
|
||||
getBuffer,
|
||||
getLastValidPosition,
|
||||
isMask,
|
||||
resetMaskSet,
|
||||
seekNext,
|
||||
seekPrevious
|
||||
} from "./positioning";
|
||||
import { EventHandlers } from "./eventhandlers";
|
||||
|
||||
export { alternate, checkAlternationMatch, isComplete, isSelection, isValid, refreshFromBuffer, revalidateMask, handleRemove };
|
||||
|
||||
//tobe put on prototype?
|
||||
function alternate(maskPos, c, strict, fromIsValid, rAltPos, selection) { //pos == true => generalize
|
||||
const inputmask = this,
|
||||
$ = this.dependencyLib,
|
||||
opts = this.opts,
|
||||
maskset = inputmask.maskset;
|
||||
|
||||
var validPsClone = $.extend(true, {}, maskset.validPositions),
|
||||
tstClone = $.extend(true, {}, maskset.tests),
|
||||
lastAlt,
|
||||
alternation,
|
||||
isValidRslt = false, returnRslt = false,
|
||||
altPos, prevAltPos, i, validPos,
|
||||
decisionPos,
|
||||
lAltPos = rAltPos !== undefined ? rAltPos : getLastValidPosition.call(inputmask), nextPos, input, begin, end;
|
||||
|
||||
if (selection) {
|
||||
begin = selection.begin;
|
||||
end = selection.end;
|
||||
if (selection.begin > selection.end) {
|
||||
begin = selection.end;
|
||||
end = selection.begin;
|
||||
}
|
||||
}
|
||||
if (lAltPos === -1 && rAltPos === undefined) { //do not recurse when already paste the beginning
|
||||
lastAlt = 0;
|
||||
prevAltPos = getTest.call(inputmask, lastAlt);
|
||||
alternation = prevAltPos.alternation;
|
||||
} else {
|
||||
//find last modified alternation
|
||||
for (; lAltPos >= 0; lAltPos--) {
|
||||
altPos = maskset.validPositions[lAltPos];
|
||||
if (altPos && altPos.alternation !== undefined) {
|
||||
if (prevAltPos && prevAltPos.locator[altPos.alternation] !== altPos.locator[altPos.alternation]) {
|
||||
break;
|
||||
}
|
||||
lastAlt = lAltPos;
|
||||
alternation = maskset.validPositions[lastAlt].alternation;
|
||||
prevAltPos = altPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (alternation !== undefined) {
|
||||
decisionPos = parseInt(lastAlt);
|
||||
maskset.excludes[decisionPos] = maskset.excludes[decisionPos] || [];
|
||||
if (maskPos !== true) { //generalize
|
||||
maskset.excludes[decisionPos].push(getDecisionTaker(prevAltPos) + ":" + prevAltPos.alternation);
|
||||
}
|
||||
|
||||
var validInputs = [], resultPos = -1;
|
||||
for (i = decisionPos; i < getLastValidPosition.call(inputmask, undefined, true) + 1; i++) {
|
||||
if (resultPos === -1 && maskPos <= i && c !== undefined) {
|
||||
validInputs.push(c);
|
||||
resultPos = validInputs.length - 1;
|
||||
}
|
||||
validPos = maskset.validPositions[i];
|
||||
if (validPos && validPos.generatedInput !== true && (selection === undefined || (i < begin || i >= end))) {
|
||||
validInputs.push(validPos.input);
|
||||
}
|
||||
delete maskset.validPositions[i];
|
||||
}
|
||||
if (resultPos === -1 && c !== undefined) {
|
||||
validInputs.push(c);
|
||||
resultPos = validInputs.length - 1;
|
||||
}
|
||||
|
||||
while (maskset.excludes[decisionPos] !== undefined && maskset.excludes[decisionPos].length < 10) {
|
||||
// maskset.tests[decisionPos] = undefined; //clear decisionPos
|
||||
maskset.tests = {}; //clear all
|
||||
resetMaskSet.call(inputmask, true); //clear getbuffer
|
||||
isValidRslt = true;
|
||||
for (i = 0; i < validInputs.length; i++) {
|
||||
nextPos = isValidRslt.caret || (getLastValidPosition.call(inputmask, undefined, true) + 1);
|
||||
input = validInputs[i];
|
||||
// nextPos = translatePosition.call(inputmask, nextPos);
|
||||
if (!(isValidRslt = isValid.call(inputmask, nextPos, input, false, fromIsValid, true))) {
|
||||
break;
|
||||
}
|
||||
if (i === resultPos) {
|
||||
returnRslt = isValidRslt;
|
||||
}
|
||||
if (maskPos == true && isValidRslt) { //return validposition on generalise
|
||||
returnRslt = { caretPos: i };
|
||||
}
|
||||
}
|
||||
if (!isValidRslt) {
|
||||
resetMaskSet.call(inputmask);
|
||||
prevAltPos = getTest.call(inputmask, decisionPos); //get the current decisionPos to exclude ~ needs to be before restoring the initial validation
|
||||
//reset & revert
|
||||
maskset.validPositions = $.extend(true, {}, validPsClone);
|
||||
maskset.tests = $.extend(true, {}, tstClone); //refresh tests after possible alternating
|
||||
if (maskset.excludes[decisionPos]) {
|
||||
var decisionTaker = getDecisionTaker(prevAltPos);
|
||||
if (maskset.excludes[decisionPos].indexOf(decisionTaker + ":" + prevAltPos.alternation) !== -1) {
|
||||
returnRslt = alternate.call(inputmask, maskPos, c, strict, fromIsValid, decisionPos - 1, selection);
|
||||
break;
|
||||
}
|
||||
maskset.excludes[decisionPos].push(decisionTaker + ":" + prevAltPos.alternation);
|
||||
for (i = decisionPos; i < getLastValidPosition.call(inputmask, undefined, true) + 1; i++) delete maskset.validPositions[i];
|
||||
} else { //latest alternation
|
||||
returnRslt = alternate.call(inputmask, maskPos, c, strict, fromIsValid, decisionPos - 1, selection);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//reset alternation excludes
|
||||
if (!returnRslt || opts.keepStatic !== false) {
|
||||
delete maskset.excludes[decisionPos];
|
||||
}
|
||||
return returnRslt;
|
||||
}
|
||||
|
||||
function casing(elem, test, pos) {
|
||||
const opts = this.opts,
|
||||
maskset = this.maskset;
|
||||
|
||||
switch (opts.casing || test.casing) {
|
||||
case "upper":
|
||||
elem = elem.toUpperCase();
|
||||
break;
|
||||
case "lower":
|
||||
elem = elem.toLowerCase();
|
||||
break;
|
||||
case "title":
|
||||
var posBefore = maskset.validPositions[pos - 1];
|
||||
if (pos === 0 || posBefore && posBefore.input === String.fromCharCode(keyCode.SPACE)) {
|
||||
elem = elem.toUpperCase();
|
||||
} else {
|
||||
elem = elem.toLowerCase();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (typeof opts.casing === "function") {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.push(maskset.validPositions);
|
||||
elem = opts.casing.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function checkAlternationMatch(altArr1, altArr2, na) {
|
||||
const opts = this.opts;
|
||||
|
||||
var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1),
|
||||
isMatch = false,
|
||||
naArr = na !== undefined ? na.split(",") : [],
|
||||
naNdx;
|
||||
|
||||
//remove no alternate indexes from alternation array
|
||||
for (var i = 0; i < naArr.length; i++) {
|
||||
if ((naNdx = altArr1.indexOf(naArr[i])) !== -1) {
|
||||
altArr1.splice(naNdx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (var alndx = 0; alndx < altArr1.length; alndx++) {
|
||||
if (altArrC.includes(altArr1[alndx])) {
|
||||
isMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isMatch;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function handleRemove(input, k, pos, strict, fromIsValid) {
|
||||
const inputmask = this, maskset = this.maskset, opts = this.opts;
|
||||
|
||||
if (opts.numericInput || inputmask.isRTL) {
|
||||
if (k === keyCode.BACKSPACE) {
|
||||
k = keyCode.DELETE;
|
||||
} else if (k === keyCode.DELETE) {
|
||||
k = keyCode.BACKSPACE;
|
||||
}
|
||||
|
||||
if (inputmask.isRTL) {
|
||||
var pend = pos.end;
|
||||
pos.end = pos.begin;
|
||||
pos.begin = pend;
|
||||
}
|
||||
}
|
||||
|
||||
var lvp = getLastValidPosition.call(inputmask, undefined, true);
|
||||
if (pos.end >= getBuffer.call(inputmask).length && lvp >= pos.end) { //handle numeric negate symbol offset, due to dynamic jit masking
|
||||
pos.end = lvp + 1;
|
||||
}
|
||||
|
||||
if (k === keyCode.BACKSPACE) {
|
||||
if ((pos.end - pos.begin < 1)) {
|
||||
pos.begin = seekPrevious.call(inputmask, pos.begin);
|
||||
}
|
||||
} else if (k === keyCode.DELETE) {
|
||||
if (pos.begin === pos.end) {
|
||||
pos.end = isMask.call(inputmask, pos.end, true, true) ? pos.end + 1 : seekNext.call(inputmask, pos.end) + 1;
|
||||
}
|
||||
}
|
||||
var offset;
|
||||
if ((offset = revalidateMask.call(inputmask, pos)) !== false) {
|
||||
if (strict !== true && opts.keepStatic !== false || (opts.regex !== null && getTest.call(inputmask, pos.begin).match.def.indexOf("|") !== -1)) { //TODO NEEDS BETTER CHECK WHEN TO ALTERNATE ~ opts regex isn"t good enough
|
||||
var result = alternate.call(inputmask, true);
|
||||
if (result) {
|
||||
var newPos = result.caret !== undefined ? result.caret : (result.pos ? seekNext.call(inputmask, result.pos.begin ? result.pos.begin : result.pos) : getLastValidPosition.call(inputmask, -1, true));
|
||||
if (k !== keyCode.DELETE || pos.begin > newPos) {
|
||||
pos.begin == newPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strict !== true) {
|
||||
maskset.p = k === keyCode.DELETE ? pos.begin + offset : pos.begin;
|
||||
maskset.p = determineNewCaretPosition.call(inputmask, {
|
||||
begin: maskset.p,
|
||||
end: maskset.p
|
||||
}, false, opts.insertMode === false && k === keyCode.BACKSPACE ? "none" : undefined).begin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function isComplete(buffer) { //return true / false / undefined (repeat *)
|
||||
const inputmask = this, opts = this.opts, maskset = this.maskset;
|
||||
|
||||
if (typeof opts.isComplete === "function") return opts.isComplete(buffer, opts);
|
||||
if (opts.repeat === "*") return undefined;
|
||||
var complete = false,
|
||||
lrp = determineLastRequiredPosition.call(inputmask, true),
|
||||
aml = seekPrevious.call(inputmask, lrp.l);
|
||||
|
||||
if (lrp.def === undefined || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
|
||||
complete = true;
|
||||
for (var i = 0; i <= aml; i++) {
|
||||
var test = getTestTemplate.call(inputmask, i).match;
|
||||
if ((test.static !== true && maskset.validPositions[i] === undefined && test.optionality !== true && test.optionalQuantifier !== true) || (test.static === true && buffer[i] !== getPlaceholder.call(inputmask, i, test))) {
|
||||
complete = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return complete;
|
||||
}
|
||||
|
||||
function isSelection(posObj) {
|
||||
const inputmask = this,
|
||||
opts = this.opts, insertModeOffset = opts.insertMode ? 0 : 1;
|
||||
return inputmask.isRTL ? (posObj.begin - posObj.end) > insertModeOffset : (posObj.end - posObj.begin) > insertModeOffset;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function isValid(pos, c, strict, fromIsValid, fromAlternate, validateOnly, fromCheckval) { //strict true ~ no correction or autofill
|
||||
const inputmask = this,
|
||||
$ = this.dependencyLib,
|
||||
opts = this.opts,
|
||||
maskset = inputmask.maskset;
|
||||
|
||||
strict = strict === true; //always set a value to strict to prevent possible strange behavior in the extensions
|
||||
|
||||
var maskPos = pos;
|
||||
if (pos.begin !== undefined) { //position was a position object - used to handle a delete by typing over a selection
|
||||
maskPos = inputmask.isRTL ? pos.end : pos.begin;
|
||||
}
|
||||
|
||||
function processCommandObject(commandObj) {
|
||||
if (commandObj !== undefined) {
|
||||
if (commandObj.remove !== undefined) { //remove position(s)
|
||||
if (!Array.isArray(commandObj.remove)) commandObj.remove = [commandObj.remove];
|
||||
commandObj.remove.sort(function (a, b) {
|
||||
return b.pos - a.pos;
|
||||
}).forEach(function (lmnt) {
|
||||
revalidateMask.call(inputmask, { begin: lmnt, end: lmnt + 1 });
|
||||
});
|
||||
commandObj.remove = undefined;
|
||||
}
|
||||
if (commandObj.insert !== undefined) { //insert position(s)
|
||||
if (!Array.isArray(commandObj.insert)) commandObj.insert = [commandObj.insert];
|
||||
commandObj.insert.sort(function (a, b) {
|
||||
return a.pos - b.pos;
|
||||
}).forEach(function (lmnt) {
|
||||
if (lmnt.c !== "") {
|
||||
isValid.call(inputmask, lmnt.pos, lmnt.c, lmnt.strict !== undefined ? lmnt.strict : true, lmnt.fromIsValid !== undefined ? lmnt.fromIsValid : fromIsValid);
|
||||
}
|
||||
});
|
||||
commandObj.insert = undefined;
|
||||
}
|
||||
|
||||
if (commandObj.refreshFromBuffer && commandObj.buffer) {
|
||||
var refresh = commandObj.refreshFromBuffer;
|
||||
refreshFromBuffer.call(inputmask, refresh === true ? refresh : refresh.start, refresh.end, commandObj.buffer);
|
||||
commandObj.refreshFromBuffer = undefined;
|
||||
}
|
||||
|
||||
if (commandObj.rewritePosition !== undefined) {
|
||||
maskPos = commandObj.rewritePosition;
|
||||
// commandObj.rewritePosition = undefined;
|
||||
commandObj = true;
|
||||
}
|
||||
}
|
||||
return commandObj;
|
||||
}
|
||||
|
||||
function _isValid(position, c, strict) {
|
||||
var rslt = false;
|
||||
getTests.call(inputmask, position).every(function (tst, ndx) {
|
||||
var test = tst.match;
|
||||
//make sure the buffer is set and correct
|
||||
getBuffer.call(inputmask, true);
|
||||
if (test.jit && maskset.validPositions[seekPrevious.call(inputmask, position)] === undefined) //ignore if jit is not desirable
|
||||
{
|
||||
rslt = false;
|
||||
} else {
|
||||
//return is false or a json object => { pos: ??, c: ??} or true
|
||||
rslt = test.fn != null ?
|
||||
test.fn.test(c, maskset, position, strict, opts, isSelection.call(inputmask, pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && test.def !== "" ? //non mask
|
||||
{
|
||||
c: getPlaceholder.call(inputmask, position, test, true) || test.def,
|
||||
pos: position
|
||||
} : false;
|
||||
}
|
||||
if (rslt !== false) {
|
||||
var elem = rslt.c !== undefined ? rslt.c : c, validatedPos = position;
|
||||
elem = (elem === opts.skipOptionalPartCharacter && test.static === true) ?
|
||||
(getPlaceholder.call(inputmask, position, test, true) || test.def) : elem;
|
||||
|
||||
rslt = processCommandObject(rslt);
|
||||
|
||||
if (rslt !== true && rslt.pos !== undefined && rslt.pos !== position) { //their is a position offset
|
||||
validatedPos = rslt.pos;
|
||||
}
|
||||
|
||||
if (rslt !== true && rslt.pos === undefined && rslt.c === undefined) {
|
||||
return false; //breakout if nothing to insert
|
||||
}
|
||||
|
||||
if (revalidateMask.call(inputmask, pos, $.extend({}, tst, {
|
||||
"input": casing.call(inputmask, elem, test, validatedPos)
|
||||
}), fromIsValid, validatedPos) === false) {
|
||||
rslt = false;
|
||||
}
|
||||
return false; //break from loop
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
return rslt;
|
||||
}
|
||||
|
||||
var result = true,
|
||||
positionsClone = $.extend(true, {}, maskset.validPositions); //clone the currentPositions
|
||||
|
||||
if (opts.keepStatic === false && maskset.excludes[maskPos] !== undefined && fromAlternate !== true && fromIsValid !== true) {
|
||||
for (var i = maskPos; i < (inputmask.isRTL ? pos.begin : pos.end); i++) {
|
||||
if (maskset.excludes[i] !== undefined) {
|
||||
maskset.excludes[i] = undefined;
|
||||
delete maskset.tests[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof opts.preValidation === "function" && fromIsValid !== true && validateOnly !== true) {
|
||||
result = opts.preValidation.call(inputmask, getBuffer.call(inputmask), maskPos, c, isSelection.call(inputmask, pos), opts, maskset, pos, strict || fromAlternate);
|
||||
result = processCommandObject(result);
|
||||
}
|
||||
if (result === true) { //preValidation result
|
||||
result = _isValid(maskPos, c, strict);
|
||||
if ((!strict || fromIsValid === true) && result === false && validateOnly !== true) {
|
||||
var currentPosValid = maskset.validPositions[maskPos];
|
||||
if (currentPosValid && currentPosValid.match.static === true && (currentPosValid.match.def === c || c === opts.skipOptionalPartCharacter)) {
|
||||
result = {
|
||||
"caret": seekNext.call(inputmask, maskPos)
|
||||
};
|
||||
} else {
|
||||
if (opts.insertMode || maskset.validPositions[seekNext.call(inputmask, maskPos)] === undefined || pos.end > maskPos) { //does the input match on a further position?
|
||||
var skip = false;
|
||||
if (maskset.jitOffset[maskPos] && maskset.validPositions[seekNext.call(inputmask, maskPos)] === undefined) {
|
||||
result = isValid.call(inputmask, maskPos + maskset.jitOffset[maskPos], c, true, true);
|
||||
if (result !== false) {
|
||||
if (fromAlternate !== true) result.caret = maskPos;
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
if (pos.end > maskPos) {
|
||||
maskset.validPositions[maskPos] = undefined;
|
||||
}
|
||||
if (!skip && !isMask.call(inputmask, maskPos, opts.keepStatic && maskPos === 0)) {
|
||||
for (var nPos = maskPos + 1, snPos = seekNext.call(inputmask, maskPos, false, maskPos !== 0); nPos <= snPos; nPos++) {
|
||||
// if (!isMask(nPos, true)) {
|
||||
// continue;
|
||||
// }
|
||||
result = _isValid(nPos, c, strict);
|
||||
if (result !== false) {
|
||||
result = trackbackPositions.call(inputmask, maskPos, result.pos !== undefined ? result.pos : nPos) || result;
|
||||
maskPos = nPos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result === false && opts.keepStatic && (isComplete.call(inputmask, getBuffer.call(inputmask)) || maskPos === 0) && !strict && fromAlternate !== true) { //try fuzzy alternator logic
|
||||
result = alternate.call(inputmask, maskPos, c, strict, fromIsValid, undefined, pos);
|
||||
} else if (isSelection.call(inputmask, pos) && maskset.tests[maskPos] && maskset.tests[maskPos].length > 1 && opts.keepStatic && !strict && fromAlternate !== true) { //selection clears an alternated keepstatic mask ~ #2189
|
||||
result = alternate.call(inputmask, true);
|
||||
}
|
||||
|
||||
if (result === true) {
|
||||
result = {
|
||||
"pos": maskPos
|
||||
};
|
||||
}
|
||||
}
|
||||
if (typeof opts.postValidation === "function" && fromIsValid !== true && validateOnly !== true) {
|
||||
var postResult = opts.postValidation.call(inputmask, getBuffer.call(inputmask, true), pos.begin !== undefined ? (inputmask.isRTL ? pos.end : pos.begin) : pos, c, result, opts, maskset, strict, fromCheckval);
|
||||
if (postResult !== undefined) {
|
||||
result = postResult === true ? result : postResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (result && result.pos === undefined) {
|
||||
result.pos = maskPos;
|
||||
}
|
||||
|
||||
if (result === false || validateOnly === true) {
|
||||
resetMaskSet.call(inputmask, true);
|
||||
maskset.validPositions = $.extend(true, {}, positionsClone); //revert validation changes
|
||||
} else {
|
||||
trackbackPositions.call(inputmask, undefined, maskPos, true);
|
||||
}
|
||||
|
||||
var endResult = processCommandObject(result);
|
||||
// console.log("returned result " + JSON.stringify(endResult));
|
||||
if (inputmask.maxLength !== undefined) {
|
||||
var buffer = getBuffer.call(inputmask);
|
||||
if (buffer.length > inputmask.maxLength && !fromIsValid) {
|
||||
resetMaskSet.call(inputmask, true);
|
||||
maskset.validPositions = $.extend(true, {}, positionsClone); //revert validation changes
|
||||
endResult = false;
|
||||
}
|
||||
}
|
||||
return endResult;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function positionCanMatchDefinition(pos, testDefinition, opts) {
|
||||
const inputmask = this,
|
||||
maskset = this.maskset;
|
||||
|
||||
var valid = false,
|
||||
tests = getTests.call(inputmask, pos);
|
||||
for (var tndx = 0; tndx < tests.length; tndx++) {
|
||||
if (tests[tndx].match &&
|
||||
((tests[tndx].match["nativeDef"] === testDefinition.match[opts.shiftPositions ? "def" : "nativeDef"] && (!opts.shiftPositions || !testDefinition.match.static)) ||
|
||||
tests[tndx].match["nativeDef"] === testDefinition.match["nativeDef"] || (opts.regex && !tests[tndx].match.static && tests[tndx].match.fn.test(testDefinition.input)))) {
|
||||
valid = true;
|
||||
break;
|
||||
} else if (tests[tndx].match && tests[tndx].match["def"] === testDefinition.match["nativeDef"]) {
|
||||
valid = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (valid === false) {
|
||||
if (maskset.jitOffset[pos] !== undefined) {
|
||||
valid = positionCanMatchDefinition.call(inputmask, pos + maskset.jitOffset[pos], testDefinition, opts);
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function refreshFromBuffer(start, end, buffer) {
|
||||
const inputmask = this,
|
||||
maskset = this.maskset,
|
||||
opts = this.opts,
|
||||
$ = this.dependencyLib;
|
||||
// checkVal.call(inputmask, el, false, true, isRTL ? buffer.reverse() : buffer);
|
||||
var i, p, skipOptionalPartCharacter = opts.skipOptionalPartCharacter,
|
||||
bffr = inputmask.isRTL ? buffer.slice().reverse() : buffer;
|
||||
opts.skipOptionalPartCharacter = "";
|
||||
if (start === true) {
|
||||
resetMaskSet.call(inputmask);
|
||||
maskset.tests = {}; //refresh tests after possible alternating
|
||||
start = 0;
|
||||
end = buffer.length;
|
||||
p = determineNewCaretPosition.call(inputmask, { begin: 0, end: 0 }, false).begin;
|
||||
} else {
|
||||
for (i = start; i < end; i++) {
|
||||
delete maskset.validPositions[i];
|
||||
}
|
||||
p = start;
|
||||
}
|
||||
|
||||
var keypress = new $.Event("keypress");
|
||||
for (i = start; i < end; i++) {
|
||||
keypress.keyCode = bffr[i].toString().charCodeAt(0);
|
||||
inputmask.ignorable = false; //make sure ignorable is ignored ;-)
|
||||
var valResult = EventHandlers.keypressEvent.call(inputmask, keypress, true, false, false, p);
|
||||
if (valResult !== false && valResult !== undefined) {
|
||||
p = valResult.forwardPosition;
|
||||
}
|
||||
}
|
||||
|
||||
opts.skipOptionalPartCharacter = skipOptionalPartCharacter;
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
//fill in best positions according the current input
|
||||
function trackbackPositions(originalPos, newPos, fillOnly) {
|
||||
const inputmask = this,
|
||||
maskset = this.maskset,
|
||||
$ = this.dependencyLib;
|
||||
|
||||
// console.log("trackbackPositions " + originalPos + " " + newPos);
|
||||
if (originalPos === undefined) {
|
||||
//find previous valid
|
||||
for (originalPos = newPos - 1; originalPos > 0; originalPos--) {
|
||||
if (maskset.validPositions[originalPos]) break;
|
||||
}
|
||||
}
|
||||
for (var ps = originalPos; ps < newPos; ps++) {
|
||||
if (maskset.validPositions[ps] === undefined && !isMask.call(inputmask, ps, false)) {
|
||||
var vp = ps == 0 ? getTest.call(inputmask, ps) : maskset.validPositions[ps - 1];
|
||||
if (vp) {
|
||||
var tests = getTests.call(inputmask, ps).slice();
|
||||
if (tests[tests.length - 1].match.def === "") tests.pop();
|
||||
var bestMatch = determineTestTemplate.call(inputmask, ps, tests), np;
|
||||
if (bestMatch && (bestMatch.match.jit !== true || (bestMatch.match.newBlockMarker === "master" && (np = maskset.validPositions[ps + 1]) && np.match.optionalQuantifier === true))) {
|
||||
bestMatch = $.extend({}, bestMatch, {
|
||||
"input": getPlaceholder.call(inputmask, ps, bestMatch.match, true) || bestMatch.match.def
|
||||
});
|
||||
bestMatch.generatedInput = true;
|
||||
revalidateMask.call(inputmask, ps, bestMatch, true);
|
||||
|
||||
if (fillOnly !== true) {
|
||||
//revalidate the new position to update the locator value
|
||||
var cvpInput = maskset.validPositions[newPos].input;
|
||||
maskset.validPositions[newPos] = undefined;
|
||||
return isValid.call(inputmask, newPos, cvpInput, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//tobe put on prototype?
|
||||
function revalidateMask(pos, validTest, fromIsValid, validatedPos) {
|
||||
const inputmask = this,
|
||||
maskset = this.maskset,
|
||||
opts = this.opts,
|
||||
$ = this.dependencyLib;
|
||||
|
||||
function IsEnclosedStatic(pos, valids, selection) {
|
||||
var posMatch = valids[pos];
|
||||
if (posMatch !== undefined && posMatch.match.static === true && posMatch.match.optionality !== true && (valids[0] === undefined || valids[0].alternation === undefined)) {
|
||||
var prevMatch = selection.begin <= pos - 1 ? valids[pos - 1] && valids[pos - 1].match.static === true && valids[pos - 1] : valids[pos - 1],
|
||||
nextMatch = selection.end > pos + 1 ? valids[pos + 1] && valids[pos + 1].match.static === true && valids[pos + 1] : valids[pos + 1];
|
||||
return prevMatch && nextMatch;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var offset = 0, begin = pos.begin !== undefined ? pos.begin : pos, end = pos.end !== undefined ? pos.end : pos,
|
||||
valid = true;
|
||||
if (pos.begin > pos.end) {
|
||||
begin = pos.end;
|
||||
end = pos.begin;
|
||||
}
|
||||
|
||||
validatedPos = validatedPos !== undefined ? validatedPos : begin;
|
||||
if (begin !== end || (opts.insertMode && maskset.validPositions[validatedPos] !== undefined && fromIsValid === undefined) || validTest === undefined || validTest.match.optionalQuantifier || validTest.match.optionality) {
|
||||
//reposition & revalidate others
|
||||
var positionsClone = $.extend(true, {}, maskset.validPositions),
|
||||
lvp = getLastValidPosition.call(inputmask, undefined, true),
|
||||
i;
|
||||
maskset.p = begin; //needed for alternated position after overtype selection
|
||||
|
||||
for (i = lvp; i >= begin; i--) {
|
||||
delete maskset.validPositions[i];
|
||||
if (validTest === undefined) delete maskset.tests[i + 1];
|
||||
}
|
||||
|
||||
var j = validatedPos,
|
||||
posMatch = j, t, canMatch, test;
|
||||
|
||||
if (validTest) {
|
||||
maskset.validPositions[validatedPos] = $.extend(true, {}, validTest);
|
||||
posMatch++;
|
||||
j++;
|
||||
}
|
||||
|
||||
for (i = validTest ? end : end - 1; i <= lvp; i++) {
|
||||
if ((t = positionsClone[i]) !== undefined && t.generatedInput !== true &&
|
||||
(i >= end || (i >= begin && IsEnclosedStatic(i, positionsClone, {
|
||||
begin: begin,
|
||||
end: end
|
||||
})))) {
|
||||
while (test = getTest.call(inputmask, posMatch), test.match.def !== "") { //loop needed to match further positions
|
||||
if ((canMatch = positionCanMatchDefinition.call(inputmask, posMatch, t, opts)) !== false || t.match.def === "+") { //validated match //we still need some hackery for the + validator (numeric alias)
|
||||
if (t.match.def === "+") getBuffer.call(inputmask, true);
|
||||
var result = isValid.call(inputmask, posMatch, t.input, t.match.def !== "+", /*t.match.def !== "+"*/ true);
|
||||
valid = result !== false;
|
||||
j = (result.pos || posMatch) + 1;
|
||||
if (!valid && canMatch) break;
|
||||
} else {
|
||||
valid = false;
|
||||
}
|
||||
if (valid) {
|
||||
if (validTest === undefined && t.match.static && i === pos.begin) offset++;
|
||||
break;
|
||||
}
|
||||
if (!valid && getBuffer.call(inputmask), posMatch > maskset.maskLength) {
|
||||
break;
|
||||
}
|
||||
posMatch++;
|
||||
}
|
||||
if (getTest.call(inputmask, posMatch).match.def == "") {
|
||||
valid = false;
|
||||
}
|
||||
//restore position
|
||||
posMatch = j;
|
||||
}
|
||||
if (!valid) break;
|
||||
}
|
||||
if (!valid) {
|
||||
maskset.validPositions = $.extend(true, {}, positionsClone);
|
||||
resetMaskSet.call(inputmask, true);
|
||||
return false;
|
||||
}
|
||||
} else if (validTest && getTest.call(inputmask, validatedPos).match.cd === validTest.match.cd) {
|
||||
maskset.validPositions[validatedPos] = $.extend(true, {}, validTest);
|
||||
}
|
||||
|
||||
resetMaskSet.call(inputmask, true);
|
||||
return offset;
|
||||
}
|
60
node_modules/inputmask/package.json
generated
vendored
Normal file
60
node_modules/inputmask/package.json
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"name": "inputmask",
|
||||
"version": "5.0.7",
|
||||
"description": "Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jqlite.",
|
||||
"main": "dist/inputmask.js",
|
||||
"files": [
|
||||
"bundle.js",
|
||||
"dist/",
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"start": "webpack --progress --watch --config-name main --config webpack.config.js",
|
||||
"jquery": "webpack --progress --watch --config-name jquery --config webpack.config.js",
|
||||
"test": "grunt validate"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobinHerbots/Inputmask.git"
|
||||
},
|
||||
"keywords": [
|
||||
"form",
|
||||
"input",
|
||||
"inputmask",
|
||||
"jquery",
|
||||
"jquery-plugin",
|
||||
"mask",
|
||||
"plugins"
|
||||
],
|
||||
"author": {
|
||||
"name": "Robin Herbots",
|
||||
"url": "https://github.com/RobinHerbots"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/RobinHerbots/Inputmask/issues"
|
||||
},
|
||||
"homepage": "https://github.com/RobinHerbots/Inputmask",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.5",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.16.5",
|
||||
"@babel/preset-env": "^7.16.5",
|
||||
"@babel/preset-typescript": "^7.16.5",
|
||||
"@robinherbots/grunt-available-tasks": "^0.6.4",
|
||||
"@robinherbots/grunt-nuget": "^0.3.2",
|
||||
"babel-loader": "^8.2.3",
|
||||
"grunt": "^1.4.1",
|
||||
"grunt-bump": "^0.8.0",
|
||||
"grunt-contrib-clean": "^2.0.0",
|
||||
"grunt-contrib-copy": "^1.0.0",
|
||||
"grunt-eslint": "^24.0.0",
|
||||
"grunt-release": "^0.14.0",
|
||||
"grunt-webpack": "^5.0.0",
|
||||
"jquery": "^3.6.0",
|
||||
"load-grunt-tasks": "^5.1.0",
|
||||
"lodash": "^4.17.21",
|
||||
"qunit": "^2.17.2",
|
||||
"webpack": "^5.65.0",
|
||||
"webpack-cli": "^4.9.1"
|
||||
}
|
||||
}
|
45
node_modules/tinymce/CHANGELOG.md
generated
vendored
45
node_modules/tinymce/CHANGELOG.md
generated
vendored
|
@ -6,6 +6,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## Unreleased
|
||||
|
||||
## 6.2.0 - 2022-09-08
|
||||
|
||||
### Added
|
||||
- New `text_patterns_lookup` option to provide additional text patterns dynamically. #TINY-8778
|
||||
- New promotion element has been added to the default UI. It can be disabled using the new `promotion` option. #TINY-8840
|
||||
- New `format_noneditable_selector` option to specify the `contenteditable="false"` elements that can be wrapped in a format. #TINY-8905
|
||||
- Added `allow` as a valid attribute for the `iframe` element in the editor schema. #TINY-8939
|
||||
- New `search` field in the `MenuButton` that shows a search field at the top of the menu, and refetches items when the search field updates. #TINY-8952
|
||||
|
||||
### Improved
|
||||
- The formatter can now apply a format to a `contenteditable="false"` element by wrapping it. Configurable using the `format_noneditable_selector` option. #TINY-8905
|
||||
- The autocompleter now supports a multiple character trigger using the new `trigger` configuration. #TINY-8887
|
||||
- The formatter now applies some inline formats, such as color and font size, to list item elements when the entire item content is selected. #TINY-8961
|
||||
- The installed and available plugin lists in the Help dialog are now sorted alphabetically. #TINY-9019
|
||||
- Alignment can now be applied to more types of embedded media elements. #TINY-8687
|
||||
|
||||
### Changed
|
||||
- The `@menubar-row-separator-color` oxide variable no longer affects the divider between the Menubar and Toolbar. It only controls the color of the separator lines drawn in multiline Menubars. #TINY-8632
|
||||
- The `@toolbar-separator-color` oxide variable now affects the color of the separator between the Menubar and Toolbar only. #TINY-8632
|
||||
- Available Premium plugins, which are listed by name in the Help dialog, are no longer translated. #TINY-9019
|
||||
|
||||
### Fixed
|
||||
- The Autolink plugin did not work when text nodes in the content were fragmented. #TINY-3723
|
||||
- Fixed multiple incorrect types on public APIs found while enabling TypeScript strict mode. #TINY-8806
|
||||
- The number of blank lines returned from `editor.getContent({format: 'text'})` differed between browsers. #TINY-8579
|
||||
- The editor focused via the `auto_focus` option was not scrolled into the viewport. #TINY-8785
|
||||
- Adding spaces immediately after a `contenteditable="false"` block did not work properly in some circumstances. #TINY-8814
|
||||
- Elements with only `data-*` custom attributes were sometimes removed when they should not be removed. #TINY-8755
|
||||
- Selecting a figure with `class="image"` incorrectly highlighted the link toolbar button. #TINY-8832
|
||||
- Specifying a single, non-default list style for the `advlist_bullet_styles` and `advlist_number_styles` options was not respected. #TINY-8721
|
||||
- Fixed multiple issues that occurred when formatting `contenteditable` elements. #TINY-8905
|
||||
- Spaces could be incorrectly added to `urlinput` dialog components (commonly but not exclusively presented in the *Insert/Edit Link* dialog) in certain cases. #TINY-8775
|
||||
- The text patterns logic threw an error when there were fragmented text nodes in a paragraph. #TINY-8779
|
||||
- Dragging a `contentEditable=false` element towards a document’s edge did not cause scrolling. #TINY-8874
|
||||
- Parsing large documents no longer throws a `Maximum call stack size exceeded` exception. #TINY-6945
|
||||
- DomParser filter matching was not checked between filters, which could lead to an exception in the parser. #TINY-8888
|
||||
- `contenteditable="false"` lists can no longer be toggled; and `contenteditable="true"` list elements within these lists can no longer be indented, split into another list element, or appended to the previous list element by deletion. #TINY-8920
|
||||
- Removed extra bottom padding in the context toolbar of the `tinymce-5` skin. #TINY-8980
|
||||
- Fixed a regression where pressing **Enter** added or deleted content outside the selection. #TINY-9101
|
||||
- Fixed a bug where pressing **Enter** deleted selected `contenteditable="false"` `<pre>` elements. #TINY-9101
|
||||
- The `editor.insertContent()` API did not respect the `no_events` argument. #TINY-9140
|
||||
|
||||
### Deprecated
|
||||
- The autocompleter configuration property, `ch`, has been deprecated. It will be removed in the next major release. Use the `trigger` property instead. #TINY-8887
|
||||
|
||||
## 6.1.2 - 2022-07-29
|
||||
|
||||
### Fixed
|
||||
|
|
2
node_modules/tinymce/composer.json
generated
vendored
2
node_modules/tinymce/composer.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tinymce/tinymce",
|
||||
"version": "6.1.2",
|
||||
"version": "6.2.0",
|
||||
"description": "Web based JavaScript HTML WYSIWYG editor control.",
|
||||
"license": [
|
||||
"MIT-only"
|
||||
|
|
2
node_modules/tinymce/icons/default/icons.js
generated
vendored
2
node_modules/tinymce/icons/default/icons.js
generated
vendored
|
@ -3,6 +3,7 @@ tinymce.IconManager.add('default', {
|
|||
'accessibility-check': '<svg width="24" height="24"><path d="M12 2a2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2c0-1.1.9-2 2-2Zm8 7h-5v12c0 .6-.4 1-1 1a1 1 0 0 1-1-1v-5c0-.6-.4-1-1-1a1 1 0 0 0-1 1v5c0 .6-.4 1-1 1a1 1 0 0 1-1-1V9H4a1 1 0 1 1 0-2h16c.6 0 1 .4 1 1s-.4 1-1 1Z" fill-rule="nonzero"/></svg>',
|
||||
'action-next': '<svg width="24" height="24"><path fill-rule="nonzero" d="M5.7 7.3a1 1 0 0 0-1.4 1.4l7.7 7.7 7.7-7.7a1 1 0 1 0-1.4-1.4L12 13.6 5.7 7.3Z"/></svg>',
|
||||
'action-prev': '<svg width="24" height="24"><path fill-rule="nonzero" d="M18.3 15.7a1 1 0 0 0 1.4-1.4L12 6.6l-7.7 7.7a1 1 0 0 0 1.4 1.4L12 9.4l6.3 6.3Z"/></svg>',
|
||||
'addtag': '<svg width="24" height="24"><path fill-rule="evenodd" clip-rule="evenodd" d="M15 5a2 2 0 0 1 1.6.8L21 12l-4.4 6.2a2 2 0 0 1-1.6.8h-3v-2h3l3.5-5L15 7H5v3H3V7c0-1.1.9-2 2-2h10Z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M6 12a1 1 0 0 0-1 1v2H3a1 1 0 1 0 0 2h2v2a1 1 0 1 0 2 0v-2h2a1 1 0 1 0 0-2H7v-2c0-.6-.4-1-1-1Z"/></svg>',
|
||||
'align-center': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm3 4h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 1 1 0-2Zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 0 1 0-2Zm-3-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"/></svg>',
|
||||
'align-justify': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Zm0 4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"/></svg>',
|
||||
'align-left': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"/></svg>',
|
||||
|
@ -56,6 +57,7 @@ tinymce.IconManager.add('default', {
|
|||
'fill': '<svg width="24" height="26"><path d="m16.6 12-9-9-1.4 1.4 2.4 2.4-5.2 5.1c-.5.6-.5 1.6 0 2.2L9 19.6a1.5 1.5 0 0 0 2.2 0l5.5-5.5c.5-.6.5-1.6 0-2.2ZM5.2 13 10 8.2l4.8 4.8H5.2ZM19 14.5s-2 2.2-2 3.5c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.3-2-3.5-2-3.5Z" fill-rule="nonzero"/></svg>',
|
||||
'flip-horizontally': '<svg width="24" height="24"><path d="M14 19h2v-2h-2v2Zm4-8h2V9h-2v2ZM4 7v10c0 1.1.9 2 2 2h3v-2H6V7h3V5H6a2 2 0 0 0-2 2Zm14-2v2h2a2 2 0 0 0-2-2Zm-7 16h2V3h-2v18Zm7-6h2v-2h-2v2Zm-4-8h2V5h-2v2Zm4 12a2 2 0 0 0 2-2h-2v2Z" fill-rule="nonzero"/></svg>',
|
||||
'flip-vertically': '<svg width="24" height="24"><path d="M5 14v2h2v-2H5Zm8 4v2h2v-2h-2Zm4-14H7a2 2 0 0 0-2 2v3h2V6h10v3h2V6a2 2 0 0 0-2-2Zm2 14h-2v2a2 2 0 0 0 2-2ZM3 11v2h18v-2H3Zm6 7v2h2v-2H9Zm8-4v2h2v-2h-2ZM5 18c0 1.1.9 2 2 2v-2H5Z" fill-rule="nonzero"/></svg>',
|
||||
'footnote': '<svg width="24" height="24"><path d="M19 13c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2h14Z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19 4v6h-1V5h-1.5V4h2.6Z"/><path d="M12 18c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2h7ZM14 8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2h9Z"/></svg>',
|
||||
'format-painter': '<svg width="24" height="24"><path d="M18 5V4c0-.5-.4-1-1-1H5a1 1 0 0 0-1 1v4c0 .6.5 1 1 1h12c.6 0 1-.4 1-1V7h1v4H9v9c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-7h8V5h-3Z" fill-rule="nonzero"/></svg>',
|
||||
'format': '<svg width="24" height="24"><path fill-rule="evenodd" d="M17 5a1 1 0 0 1 0 2h-4v11a1 1 0 0 1-2 0V7H7a1 1 0 1 1 0-2h10Z"/></svg>',
|
||||
'fullscreen': '<svg width="24" height="24"><path d="m15.3 10-1.2-1.3 2.9-3h-2.3a.9.9 0 1 1 0-1.7H19c.5 0 .9.4.9.9v4.4a.9.9 0 1 1-1.8 0V7l-2.9 3Zm0 4 3 3v-2.3a.9.9 0 1 1 1.7 0V19c0 .5-.4.9-.9.9h-4.4a.9.9 0 1 1 0-1.8H17l-3-2.9 1.3-1.2ZM10 15.4l-2.9 3h2.3a.9.9 0 1 1 0 1.7H5a.9.9 0 0 1-.9-.9v-4.4a.9.9 0 1 1 1.8 0V17l2.9-3 1.2 1.3ZM8.7 10 5.7 7v2.3a.9.9 0 0 1-1.7 0V5c0-.5.4-.9.9-.9h4.4a.9.9 0 0 1 0 1.8H7l3 2.9-1.3 1.2Z" fill-rule="nonzero"/></svg>',
|
||||
|
|
2
node_modules/tinymce/icons/default/icons.min.js
generated
vendored
2
node_modules/tinymce/icons/default/icons.min.js
generated
vendored
File diff suppressed because one or more lines are too long
24
node_modules/tinymce/models/dom/model.js
generated
vendored
24
node_modules/tinymce/models/dom/model.js
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
|
@ -35,6 +35,7 @@
|
|||
const isArray = isType$1('array');
|
||||
const isNull = eq$2(null);
|
||||
const isBoolean = isSimpleType('boolean');
|
||||
const isUndefined = eq$2(undefined);
|
||||
const isNullable = a => a === null || a === undefined;
|
||||
const isNonNullable = a => !isNullable(a);
|
||||
const isFunction = isSimpleType('function');
|
||||
|
@ -349,11 +350,9 @@
|
|||
r[i] = x;
|
||||
};
|
||||
const internalFilter = (obj, pred, onTrue, onFalse) => {
|
||||
const r = {};
|
||||
each$1(obj, (x, i) => {
|
||||
(pred(x, i) ? onTrue : onFalse)(x, i);
|
||||
});
|
||||
return r;
|
||||
};
|
||||
const filter$1 = (obj, pred) => {
|
||||
const t = {};
|
||||
|
@ -848,8 +847,13 @@
|
|||
const someIf = (b, a) => b ? Optional.some(a) : Optional.none();
|
||||
|
||||
const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
||||
const contains = (str, substr) => {
|
||||
return str.indexOf(substr) !== -1;
|
||||
const contains = (str, substr, start = 0, end) => {
|
||||
const idx = str.indexOf(substr, start);
|
||||
if (idx !== -1) {
|
||||
return isUndefined(end) ? true : idx + substr.length <= end;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const startsWith = (str, prefix) => {
|
||||
return checkRange(str, prefix, 0);
|
||||
|
@ -4742,8 +4746,8 @@
|
|||
|
||||
const TableActions = (editor, resizeHandler, cellSelectionHandler) => {
|
||||
const isTableBody = editor => name(getBody(editor)) === 'table';
|
||||
const lastRowGuard = table => isTableBody(editor) === false || getGridSize(table).rows > 1;
|
||||
const lastColumnGuard = table => isTableBody(editor) === false || getGridSize(table).columns > 1;
|
||||
const lastRowGuard = table => !isTableBody(editor) || getGridSize(table).rows > 1;
|
||||
const lastColumnGuard = table => !isTableBody(editor) || getGridSize(table).columns > 1;
|
||||
const cloneFormats = getTableCloneElements(editor);
|
||||
const colMutationOp = isResizeTableColumnResizing(editor) ? noop : halve;
|
||||
const getTableSectionType = table => {
|
||||
|
@ -5242,7 +5246,7 @@
|
|||
fireEvents(editor, table);
|
||||
selectFirstCellInTable(editor, table);
|
||||
return table.dom;
|
||||
}).getOr(null);
|
||||
}).getOrNull();
|
||||
};
|
||||
const insertTable = (editor, rows, columns, options = {}) => {
|
||||
const checkInput = val => isNumber(val) && val > 0;
|
||||
|
@ -6939,7 +6943,7 @@
|
|||
const bind = (element, event, handler) => bind$1(element, event, filter, handler);
|
||||
const fromRawEvent = fromRawEvent$1;
|
||||
|
||||
const hasInternalTarget = e => has(SugarElement.fromDom(e.target), 'ephox-snooker-resizer-bar') === false;
|
||||
const hasInternalTarget = e => !has(SugarElement.fromDom(e.target), 'ephox-snooker-resizer-bar');
|
||||
const TableCellSelectionHandler = (editor, resizeHandler) => {
|
||||
const cellSelection = Selections(() => SugarElement.fromDom(editor.getBody()), () => getSelectionCell(getSelectionStart(editor), getIsRoot(editor)), ephemera.selectedSelector);
|
||||
const onSelection = (cells, start, finish) => {
|
||||
|
@ -7811,7 +7815,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
const isTable = node => isNonNullable(node) && node.tagName === 'TABLE';
|
||||
const isTable = node => isNonNullable(node) && node.nodeName === 'TABLE';
|
||||
const barResizerPrefix = 'bar-';
|
||||
const isResizable = elm => get$b(elm, 'data-mce-resize') !== 'false';
|
||||
const syncPixels = table => {
|
||||
|
|
4
node_modules/tinymce/models/dom/model.min.js
generated
vendored
4
node_modules/tinymce/models/dom/model.min.js
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/tinymce/package.json
generated
vendored
2
node_modules/tinymce/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tinymce",
|
||||
"version": "6.1.2",
|
||||
"version": "6.2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tinymce/tinymce.git",
|
||||
|
|
25
node_modules/tinymce/plugins/advlist/plugin.js
generated
vendored
25
node_modules/tinymce/plugins/advlist/plugin.js
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
|
@ -36,11 +36,11 @@
|
|||
const getNumberStyles = option('advlist_number_styles');
|
||||
const getBulletStyles = option('advlist_bullet_styles');
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
const isNullable = a => a === null || a === undefined;
|
||||
const isNonNullable = a => !isNullable(a);
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
class Optional {
|
||||
constructor(tag, value) {
|
||||
this.tag = tag;
|
||||
|
@ -138,16 +138,21 @@
|
|||
return editor.dom.isChildOf(elm, editor.getBody());
|
||||
};
|
||||
const isTableCellNode = node => {
|
||||
return node && /^(TH|TD)$/.test(node.nodeName);
|
||||
return isNonNullable(node) && /^(TH|TD)$/.test(node.nodeName);
|
||||
};
|
||||
const isListNode = editor => node => {
|
||||
return node && /^(OL|UL|DL)$/.test(node.nodeName) && isChildOfBody(editor, node);
|
||||
return isNonNullable(node) && /^(OL|UL|DL)$/.test(node.nodeName) && isChildOfBody(editor, node);
|
||||
};
|
||||
const getSelectedStyleType = editor => {
|
||||
const listElm = editor.dom.getParent(editor.selection.getNode(), 'ol,ul');
|
||||
const style = editor.dom.getStyle(listElm, 'listStyleType');
|
||||
return Optional.from(style);
|
||||
};
|
||||
const isWithinNonEditable = (editor, element) => element !== null && editor.dom.getContentEditableParent(element) === 'false';
|
||||
const isWithinNonEditableList = (editor, element) => {
|
||||
const parentList = editor.dom.getParent(element, 'ol,ul,dl');
|
||||
return isWithinNonEditable(editor, parentList);
|
||||
};
|
||||
|
||||
const findIndex = (list, predicate) => {
|
||||
for (let index = 0; index < list.length; index++) {
|
||||
|
@ -163,6 +168,7 @@
|
|||
return chr.toUpperCase();
|
||||
});
|
||||
};
|
||||
const normalizeStyleValue = styleValue => isNullable(styleValue) || styleValue === 'default' ? '' : styleValue;
|
||||
const isWithinList = (editor, e, nodeName) => {
|
||||
const tableCellIndex = findIndex(e.parents, isTableCellNode);
|
||||
const parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents;
|
||||
|
@ -172,6 +178,7 @@
|
|||
const makeSetupHandler = (editor, nodeName) => api => {
|
||||
const nodeChangeHandler = e => {
|
||||
api.setActive(isWithinList(editor, e, nodeName));
|
||||
api.setEnabled(!isWithinNonEditableList(editor, e.element));
|
||||
};
|
||||
editor.on('NodeChange', nodeChangeHandler);
|
||||
return () => editor.off('NodeChange', nodeChangeHandler);
|
||||
|
@ -186,7 +193,7 @@
|
|||
const items = global.map(styles, styleValue => {
|
||||
const iconStyle = nodeName === 'OL' ? 'num' : 'bull';
|
||||
const iconName = styleValue === 'disc' || styleValue === 'decimal' ? 'default' : styleValue;
|
||||
const itemValue = styleValue === 'default' ? '' : styleValue;
|
||||
const itemValue = normalizeStyleValue(styleValue);
|
||||
const displayText = styleValueToText(styleValue);
|
||||
return {
|
||||
type: 'choiceitem',
|
||||
|
@ -208,20 +215,20 @@
|
|||
onSetup: makeSetupHandler(editor, nodeName)
|
||||
});
|
||||
};
|
||||
const addButton = (editor, id, tooltip, cmd, nodeName, _styles) => {
|
||||
const addButton = (editor, id, tooltip, cmd, nodeName, styleValue) => {
|
||||
editor.ui.registry.addToggleButton(id, {
|
||||
active: false,
|
||||
tooltip,
|
||||
icon: nodeName === 'OL' ? 'ordered-list' : 'unordered-list',
|
||||
onSetup: makeSetupHandler(editor, nodeName),
|
||||
onAction: () => editor.execCommand(cmd)
|
||||
onAction: () => editor.queryCommandState(cmd) || styleValue === '' ? editor.execCommand(cmd) : applyListFormat(editor, nodeName, styleValue)
|
||||
});
|
||||
};
|
||||
const addControl = (editor, id, tooltip, cmd, nodeName, styles) => {
|
||||
if (styles.length > 1) {
|
||||
addSplitButton(editor, id, tooltip, cmd, nodeName, styles);
|
||||
} else {
|
||||
addButton(editor, id, tooltip, cmd, nodeName);
|
||||
addButton(editor, id, tooltip, cmd, nodeName, normalizeStyleValue(styles[0]));
|
||||
}
|
||||
};
|
||||
const register = editor => {
|
||||
|
|
4
node_modules/tinymce/plugins/advlist/plugin.min.js
generated
vendored
4
node_modules/tinymce/plugins/advlist/plugin.min.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(t,e,r)=>{const s="UL"===e?"InsertUnorderedList":"InsertOrderedList";t.execCommand(s,!1,!1===r?null:{"list-style-type":r})},r=t=>e=>e.options.get(t),s=r("advlist_number_styles"),n=r("advlist_bullet_styles");var i=tinymce.util.Tools.resolve("tinymce.util.Tools");class l{constructor(t,e){this.tag=t,this.value=e}static some(t){return new l(!0,t)}static none(){return l.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?l.some(t(this.value)):l.none()}bind(t){return this.tag?t(this.value):l.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:l.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(null!=t?t:"Called getOrDie on None")}static from(t){return null==t?l.none():l.some(t)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}l.singletonNone=new l(!1);const o=t=>t&&/^(TH|TD)$/.test(t.nodeName),a=(t,e)=>r=>{const s=s=>{r.setActive(((t,e,r)=>{const s=((t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r]))return r;return-1})(e.parents,o),n=-1!==s?e.parents.slice(0,s):e.parents,l=i.grep(n,(t=>e=>e&&/^(OL|UL|DL)$/.test(e.nodeName)&&((t,e)=>t.dom.isChildOf(e,t.getBody()))(t,e))(t));return l.length>0&&l[0].nodeName===r})(t,s,e))};return t.on("NodeChange",s),()=>t.off("NodeChange",s)},u=(t,r,s,n,o,u)=>{u.length>1?((t,r,s,n,o,u)=>{t.ui.registry.addSplitButton(r,{tooltip:s,icon:"OL"===o?"ordered-list":"unordered-list",presets:"listpreview",columns:3,fetch:t=>{t(i.map(u,(t=>{const e="OL"===o?"num":"bull",r="disc"===t||"decimal"===t?"default":t,s="default"===t?"":t,n=(t=>t.replace(/\-/g," ").replace(/\b\w/g,(t=>t.toUpperCase())))(t);return{type:"choiceitem",value:s,icon:"list-"+e+"-"+r,text:n}})))},onAction:()=>t.execCommand(n),onItemAction:(r,s)=>{e(t,o,s)},select:e=>{const r=(t=>{const e=t.dom.getParent(t.selection.getNode(),"ol,ul"),r=t.dom.getStyle(e,"listStyleType");return l.from(r)})(t);return r.map((t=>e===t)).getOr(!1)},onSetup:a(t,o)})})(t,r,s,n,o,u):((t,e,r,s,n,i)=>{t.ui.registry.addToggleButton(e,{active:!1,tooltip:r,icon:"OL"===n?"ordered-list":"unordered-list",onSetup:a(t,n),onAction:()=>t.execCommand(s)})})(t,r,s,n,o)};t.add("advlist",(t=>{t.hasPlugin("lists")?((t=>{const e=t.options.register;e("advlist_number_styles",{processor:"string[]",default:"default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman".split(",")}),e("advlist_bullet_styles",{processor:"string[]",default:"default,circle,square".split(",")})})(t),(t=>{u(t,"numlist","Numbered list","InsertOrderedList","OL",s(t)),u(t,"bullist","Bullet list","InsertUnorderedList","UL",n(t))})(t),(t=>{t.addCommand("ApplyUnorderedListStyle",((r,s)=>{e(t,"UL",s["list-style-type"])})),t.addCommand("ApplyOrderedListStyle",((r,s)=>{e(t,"OL",s["list-style-type"])}))})(t)):console.error("Please use the Lists plugin together with the Advanced List plugin.")}))}();
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=(t,e,r)=>{const s="UL"===e?"InsertUnorderedList":"InsertOrderedList";t.execCommand(s,!1,!1===r?null:{"list-style-type":r})},r=t=>e=>e.options.get(t),s=r("advlist_number_styles"),n=r("advlist_bullet_styles"),l=t=>null==t,i=t=>!l(t);var o=tinymce.util.Tools.resolve("tinymce.util.Tools");class a{constructor(t,e){this.tag=t,this.value=e}static some(t){return new a(!0,t)}static none(){return a.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?a.some(t(this.value)):a.none()}bind(t){return this.tag?t(this.value):a.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:a.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(null!=t?t:"Called getOrDie on None")}static from(t){return i(t)?a.some(t):a.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}a.singletonNone=new a(!1);const u=t=>i(t)&&/^(TH|TD)$/.test(t.nodeName),d=t=>l(t)||"default"===t?"":t,g=(t,e)=>r=>{const s=s=>{r.setActive(((t,e,r)=>{const s=((t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r]))return r;return-1})(e.parents,u),n=-1!==s?e.parents.slice(0,s):e.parents,l=o.grep(n,(t=>e=>i(e)&&/^(OL|UL|DL)$/.test(e.nodeName)&&((t,e)=>t.dom.isChildOf(e,t.getBody()))(t,e))(t));return l.length>0&&l[0].nodeName===r})(t,s,e)),r.setEnabled(!((t,e)=>{const r=t.dom.getParent(e,"ol,ul,dl");return((t,e)=>null!==e&&"false"===t.dom.getContentEditableParent(e))(t,r)})(t,s.element))};return t.on("NodeChange",s),()=>t.off("NodeChange",s)},h=(t,r,s,n,l,i)=>{i.length>1?((t,r,s,n,l,i)=>{t.ui.registry.addSplitButton(r,{tooltip:s,icon:"OL"===l?"ordered-list":"unordered-list",presets:"listpreview",columns:3,fetch:t=>{t(o.map(i,(t=>{const e="OL"===l?"num":"bull",r="disc"===t||"decimal"===t?"default":t,s=d(t),n=(t=>t.replace(/\-/g," ").replace(/\b\w/g,(t=>t.toUpperCase())))(t);return{type:"choiceitem",value:s,icon:"list-"+e+"-"+r,text:n}})))},onAction:()=>t.execCommand(n),onItemAction:(r,s)=>{e(t,l,s)},select:e=>{const r=(t=>{const e=t.dom.getParent(t.selection.getNode(),"ol,ul"),r=t.dom.getStyle(e,"listStyleType");return a.from(r)})(t);return r.map((t=>e===t)).getOr(!1)},onSetup:g(t,l)})})(t,r,s,n,l,i):((t,r,s,n,l,i)=>{t.ui.registry.addToggleButton(r,{active:!1,tooltip:s,icon:"OL"===l?"ordered-list":"unordered-list",onSetup:g(t,l),onAction:()=>t.queryCommandState(n)||""===i?t.execCommand(n):e(t,l,i)})})(t,r,s,n,l,d(i[0]))};t.add("advlist",(t=>{t.hasPlugin("lists")?((t=>{const e=t.options.register;e("advlist_number_styles",{processor:"string[]",default:"default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman".split(",")}),e("advlist_bullet_styles",{processor:"string[]",default:"default,circle,square".split(",")})})(t),(t=>{h(t,"numlist","Numbered list","InsertOrderedList","OL",s(t)),h(t,"bullist","Bullet list","InsertUnorderedList","UL",n(t))})(t),(t=>{t.addCommand("ApplyUnorderedListStyle",((r,s)=>{e(t,"UL",s["list-style-type"])})),t.addCommand("ApplyOrderedListStyle",((r,s)=>{e(t,"OL",s["list-style-type"])}))})(t)):console.error("Please use the Lists plugin together with the Advanced List plugin.")}))}();
|
13
node_modules/tinymce/plugins/anchor/plugin.js
generated
vendored
13
node_modules/tinymce/plugins/anchor/plugin.js
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
|
@ -27,7 +27,7 @@
|
|||
const id = elm.getAttribute('id') || elm.getAttribute('name');
|
||||
return id || '';
|
||||
};
|
||||
const isAnchor = elm => elm && elm.nodeName.toLowerCase() === 'a';
|
||||
const isAnchor = elm => elm.nodeName.toLowerCase() === 'a';
|
||||
const isNamedAnchor = elm => isAnchor(elm) && !elm.getAttribute('href') && getIdFromAnchor(elm) !== '';
|
||||
const isEmptyNamedAnchor = elm => isNamedAnchor(elm) && !elm.firstChild;
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
editor.insertContent(editor.dom.createHTML('a', { id }));
|
||||
} else {
|
||||
removeEmptyNamedAnchorsInSelection(editor);
|
||||
editor.formatter.remove('namedAnchor', null, null, true);
|
||||
editor.formatter.remove('namedAnchor', undefined, undefined, true);
|
||||
editor.formatter.apply('namedAnchor', { value: id });
|
||||
editor.addVisual();
|
||||
}
|
||||
|
@ -133,7 +133,7 @@
|
|||
});
|
||||
};
|
||||
|
||||
const isNamedAnchorNode = node => node && isEmptyString(node.attr('href')) && !isEmptyString(node.attr('id') || node.attr('name'));
|
||||
const isNamedAnchorNode = node => isEmptyString(node.attr('href')) && !isEmptyString(node.attr('id') || node.attr('name'));
|
||||
const isEmptyNamedAnchorNode = node => isNamedAnchorNode(node) && !node.firstChild;
|
||||
const setContentEditable = state => nodes => {
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
|
@ -165,16 +165,17 @@
|
|||
};
|
||||
|
||||
const register = editor => {
|
||||
const onAction = () => editor.execCommand('mceAnchor');
|
||||
editor.ui.registry.addToggleButton('anchor', {
|
||||
icon: 'bookmark',
|
||||
tooltip: 'Anchor',
|
||||
onAction: () => editor.execCommand('mceAnchor'),
|
||||
onAction,
|
||||
onSetup: buttonApi => editor.selection.selectorChangedWithUnbind('a:not([href])', buttonApi.setActive).unbind
|
||||
});
|
||||
editor.ui.registry.addMenuItem('anchor', {
|
||||
icon: 'bookmark',
|
||||
text: 'Anchor...',
|
||||
onAction: () => editor.execCommand('mceAnchor')
|
||||
onAction
|
||||
});
|
||||
};
|
||||
|
||||
|
|
4
node_modules/tinymce/plugins/anchor/plugin.min.js
generated
vendored
4
node_modules/tinymce/plugins/anchor/plugin.min.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),n=tinymce.util.Tools.resolve("tinymce.util.Tools");const o=("allow_html_in_named_anchor",e=>e.options.get("allow_html_in_named_anchor"));const a="a:not([href])",r=e=>!e,i=e=>e.getAttribute("id")||e.getAttribute("name")||"",l=e=>(e=>e&&"a"===e.nodeName.toLowerCase())(e)&&!e.getAttribute("href")&&""!==i(e),s=e=>e.dom.getParent(e.selection.getStart(),a),c=(e,a)=>{const r=s(e);r?((e,t,n)=>{n.removeAttribute("name"),n.id=t,e.addVisual(),e.undoManager.add()})(e,a,r):((e,a)=>{e.undoManager.transact((()=>{o(e)||e.selection.collapse(!0),e.selection.isCollapsed()?e.insertContent(e.dom.createHTML("a",{id:a})):((e=>{const o=e.dom;t(o).walk(e.selection.getRng(),(e=>{n.each(e,(e=>{var t;l(t=e)&&!t.firstChild&&o.remove(e,!1)}))}))})(e),e.formatter.remove("namedAnchor",null,null,!0),e.formatter.apply("namedAnchor",{value:a}),e.addVisual())}))})(e,a),e.focus()},d=e=>(e=>e&&r(e.attr("href"))&&!r(e.attr("id")||e.attr("name")))(e)&&!e.firstChild,m=e=>t=>{for(let n=0;n<t.length;n++){const o=t[n];d(o)&&o.attr("contenteditable",e)}};e.add("anchor",(e=>{(e=>{(0,e.options.register)("allow_html_in_named_anchor",{processor:"boolean",default:!1})})(e),(e=>{e.on("PreInit",(()=>{e.parser.addNodeFilter("a",m("false")),e.serializer.addNodeFilter("a",m(null))}))})(e),(e=>{e.addCommand("mceAnchor",(()=>{(e=>{const t=(e=>{const t=s(e);return t?i(t):""})(e);e.windowManager.open({title:"Anchor",size:"normal",body:{type:"panel",items:[{name:"id",type:"input",label:"ID",placeholder:"example"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{id:t},onSubmit:t=>{((e,t)=>/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(t)?(c(e,t),!0):(e.windowManager.alert("ID should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),!1))(e,t.getData().id)&&t.close()}})})(e)}))})(e),(e=>{e.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:()=>e.execCommand("mceAnchor"),onSetup:t=>e.selection.selectorChangedWithUnbind("a:not([href])",t.setActive).unbind}),e.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor...",onAction:()=>e.execCommand("mceAnchor")})})(e),e.on("PreInit",(()=>{(e=>{e.formatter.register("namedAnchor",{inline:"a",selector:a,remove:"all",split:!0,deep:!0,attributes:{id:"%value"},onmatch:(e,t,n)=>l(e)})})(e)}))}))}();
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),o=tinymce.util.Tools.resolve("tinymce.util.Tools");const n=("allow_html_in_named_anchor",e=>e.options.get("allow_html_in_named_anchor"));const a="a:not([href])",r=e=>!e,i=e=>e.getAttribute("id")||e.getAttribute("name")||"",l=e=>(e=>"a"===e.nodeName.toLowerCase())(e)&&!e.getAttribute("href")&&""!==i(e),s=e=>e.dom.getParent(e.selection.getStart(),a),d=(e,a)=>{const r=s(e);r?((e,t,o)=>{o.removeAttribute("name"),o.id=t,e.addVisual(),e.undoManager.add()})(e,a,r):((e,a)=>{e.undoManager.transact((()=>{n(e)||e.selection.collapse(!0),e.selection.isCollapsed()?e.insertContent(e.dom.createHTML("a",{id:a})):((e=>{const n=e.dom;t(n).walk(e.selection.getRng(),(e=>{o.each(e,(e=>{var t;l(t=e)&&!t.firstChild&&n.remove(e,!1)}))}))})(e),e.formatter.remove("namedAnchor",void 0,void 0,!0),e.formatter.apply("namedAnchor",{value:a}),e.addVisual())}))})(e,a),e.focus()},c=e=>(e=>r(e.attr("href"))&&!r(e.attr("id")||e.attr("name")))(e)&&!e.firstChild,m=e=>t=>{for(let o=0;o<t.length;o++){const n=t[o];c(n)&&n.attr("contenteditable",e)}};e.add("anchor",(e=>{(e=>{(0,e.options.register)("allow_html_in_named_anchor",{processor:"boolean",default:!1})})(e),(e=>{e.on("PreInit",(()=>{e.parser.addNodeFilter("a",m("false")),e.serializer.addNodeFilter("a",m(null))}))})(e),(e=>{e.addCommand("mceAnchor",(()=>{(e=>{const t=(e=>{const t=s(e);return t?i(t):""})(e);e.windowManager.open({title:"Anchor",size:"normal",body:{type:"panel",items:[{name:"id",type:"input",label:"ID",placeholder:"example"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{id:t},onSubmit:t=>{((e,t)=>/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(t)?(d(e,t),!0):(e.windowManager.alert("ID should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),!1))(e,t.getData().id)&&t.close()}})})(e)}))})(e),(e=>{const t=()=>e.execCommand("mceAnchor");e.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:t,onSetup:t=>e.selection.selectorChangedWithUnbind("a:not([href])",t.setActive).unbind}),e.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor...",onAction:t})})(e),e.on("PreInit",(()=>{(e=>{e.formatter.register("namedAnchor",{inline:"a",selector:a,remove:"all",split:!0,deep:!0,attributes:{id:"%value"},onmatch:(e,t,o)=>l(e)})})(e)}))}))}();
|
198
node_modules/tinymce/plugins/autolink/plugin.js
generated
vendored
198
node_modules/tinymce/plugins/autolink/plugin.js
generated
vendored
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
const link = () => /(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-.~*+=!;:'%@$(),\/\w]*[-~*+=%@$()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g;
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
|||
const getAutoLinkPattern = option('autolink_pattern');
|
||||
const getDefaultLinkTarget = option('link_default_target');
|
||||
const getDefaultLinkProtocol = option('link_default_protocol');
|
||||
const allowUnsafeLinkTarget = option('allow_unsafe_link_target');
|
||||
|
||||
const hasProto = (v, constructor, predicate) => {
|
||||
var _a;
|
||||
|
@ -47,123 +48,113 @@
|
|||
}
|
||||
};
|
||||
const isType = type => value => typeOf(value) === type;
|
||||
const eq = t => a => t === a;
|
||||
const isString = isType('string');
|
||||
const isUndefined = eq(undefined);
|
||||
const isNullable = a => a === null || a === undefined;
|
||||
const isNonNullable = a => !isNullable(a);
|
||||
|
||||
const not = f => t => !f(t);
|
||||
|
||||
const hasOwnProperty = Object.hasOwnProperty;
|
||||
const has = (obj, key) => hasOwnProperty.call(obj, key);
|
||||
|
||||
const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
||||
const contains = (str, substr) => {
|
||||
return str.indexOf(substr) !== -1;
|
||||
const contains = (str, substr, start = 0, end) => {
|
||||
const idx = str.indexOf(substr, start);
|
||||
if (idx !== -1) {
|
||||
return isUndefined(end) ? true : idx + substr.length <= end;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const startsWith = (str, prefix) => {
|
||||
return checkRange(str, prefix, 0);
|
||||
};
|
||||
|
||||
const rangeEqualsBracketOrSpace = rangeString => /^[(\[{ \u00a0]$/.test(rangeString);
|
||||
const zeroWidth = '\uFEFF';
|
||||
const isZwsp = char => char === zeroWidth;
|
||||
const removeZwsp = s => s.replace(/\uFEFF/g, '');
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.dom.TextSeeker');
|
||||
|
||||
const isTextNode = node => node.nodeType === 3;
|
||||
const isElement = node => node.nodeType === 1;
|
||||
const scopeIndex = (container, index) => {
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
if (isTextNode(container)) {
|
||||
const len = container.data.length;
|
||||
if (index > len) {
|
||||
index = len;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
};
|
||||
const setStart = (rng, container, offset) => {
|
||||
if (!isElement(container) || container.hasChildNodes()) {
|
||||
rng.setStart(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setStartBefore(container);
|
||||
}
|
||||
};
|
||||
const setEnd = (rng, container, offset) => {
|
||||
if (!isElement(container) || container.hasChildNodes()) {
|
||||
rng.setEnd(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setEndAfter(container);
|
||||
}
|
||||
};
|
||||
const isBracketOrSpace = char => /^[(\[{ \u00a0]$/.test(char);
|
||||
const hasProtocol = url => /^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(url);
|
||||
const isPunctuation = char => /[?!,.;:]/.test(char);
|
||||
const parseCurrentLine = (editor, endOffset) => {
|
||||
let end, endContainer, text, prev, len, rngText;
|
||||
const findChar = (text, index, predicate) => {
|
||||
for (let i = index - 1; i >= 0; i--) {
|
||||
const char = text.charAt(i);
|
||||
if (!isZwsp(char) && predicate(char)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
const freefallRtl = (container, offset) => {
|
||||
let tempNode = container;
|
||||
let tempOffset = offset;
|
||||
while (isElement(tempNode) && tempNode.childNodes[tempOffset]) {
|
||||
tempNode = tempNode.childNodes[tempOffset];
|
||||
tempOffset = isTextNode(tempNode) ? tempNode.data.length : tempNode.childNodes.length;
|
||||
}
|
||||
return {
|
||||
container: tempNode,
|
||||
offset: tempOffset
|
||||
};
|
||||
};
|
||||
|
||||
const parseCurrentLine = (editor, offset) => {
|
||||
var _a;
|
||||
const voidElements = editor.schema.getVoidElements();
|
||||
const autoLinkPattern = getAutoLinkPattern(editor);
|
||||
if (editor.dom.getParent(editor.selection.getNode(), 'a[href]') !== null) {
|
||||
return;
|
||||
const {dom, selection} = editor;
|
||||
if (dom.getParent(selection.getNode(), 'a[href]') !== null) {
|
||||
return null;
|
||||
}
|
||||
const rng = editor.selection.getRng().cloneRange();
|
||||
if (rng.startOffset < 5) {
|
||||
prev = rng.endContainer.previousSibling;
|
||||
if (!prev) {
|
||||
if (!rng.endContainer.firstChild || !rng.endContainer.firstChild.nextSibling) {
|
||||
return;
|
||||
}
|
||||
prev = rng.endContainer.firstChild.nextSibling;
|
||||
}
|
||||
len = prev.length;
|
||||
setStart(rng, prev, len);
|
||||
setEnd(rng, prev, len);
|
||||
if (rng.endOffset < 5) {
|
||||
return;
|
||||
}
|
||||
end = rng.endOffset;
|
||||
endContainer = prev;
|
||||
const rng = selection.getRng();
|
||||
const textSeeker = global(dom, node => {
|
||||
return dom.isBlock(node) || has(voidElements, node.nodeName.toLowerCase()) || dom.getContentEditable(node) === 'false';
|
||||
});
|
||||
const {
|
||||
container: endContainer,
|
||||
offset: endOffset
|
||||
} = freefallRtl(rng.endContainer, rng.endOffset);
|
||||
const root = (_a = dom.getParent(endContainer, dom.isBlock)) !== null && _a !== void 0 ? _a : dom.getRoot();
|
||||
const endSpot = textSeeker.backwards(endContainer, endOffset + offset, (node, offset) => {
|
||||
const text = node.data;
|
||||
const idx = findChar(text, offset, not(isBracketOrSpace));
|
||||
return idx === -1 || isPunctuation(text[idx]) ? idx : idx + 1;
|
||||
}, root);
|
||||
if (!endSpot) {
|
||||
return null;
|
||||
}
|
||||
let lastTextNode = endSpot.container;
|
||||
const startSpot = textSeeker.backwards(endSpot.container, endSpot.offset, (node, offset) => {
|
||||
lastTextNode = node;
|
||||
const idx = findChar(node.data, offset, isBracketOrSpace);
|
||||
return idx === -1 ? idx : idx + 1;
|
||||
}, root);
|
||||
const newRng = dom.createRng();
|
||||
if (!startSpot) {
|
||||
newRng.setStart(lastTextNode, 0);
|
||||
} else {
|
||||
endContainer = rng.endContainer;
|
||||
if (!isTextNode(endContainer) && endContainer.firstChild) {
|
||||
while (!isTextNode(endContainer) && endContainer.firstChild) {
|
||||
endContainer = endContainer.firstChild;
|
||||
}
|
||||
if (isTextNode(endContainer)) {
|
||||
setStart(rng, endContainer, 0);
|
||||
setEnd(rng, endContainer, endContainer.nodeValue.length);
|
||||
}
|
||||
}
|
||||
if (rng.endOffset === 1) {
|
||||
end = 2;
|
||||
} else {
|
||||
end = rng.endOffset - 1 - endOffset;
|
||||
}
|
||||
newRng.setStart(startSpot.container, startSpot.offset);
|
||||
}
|
||||
const start = end;
|
||||
do {
|
||||
setStart(rng, endContainer, end >= 2 ? end - 2 : 0);
|
||||
setEnd(rng, endContainer, end >= 1 ? end - 1 : 0);
|
||||
end -= 1;
|
||||
rngText = rng.toString();
|
||||
} while (!rangeEqualsBracketOrSpace(rngText) && end - 2 >= 0);
|
||||
if (rangeEqualsBracketOrSpace(rng.toString())) {
|
||||
setStart(rng, endContainer, end);
|
||||
setEnd(rng, endContainer, start);
|
||||
end += 1;
|
||||
} else if (rng.startOffset === 0) {
|
||||
setStart(rng, endContainer, 0);
|
||||
setEnd(rng, endContainer, start);
|
||||
} else {
|
||||
setStart(rng, endContainer, end);
|
||||
setEnd(rng, endContainer, start);
|
||||
}
|
||||
text = rng.toString();
|
||||
if (isPunctuation(text.charAt(text.length - 1))) {
|
||||
setEnd(rng, endContainer, start - 1);
|
||||
}
|
||||
text = rng.toString().trim();
|
||||
const matches = text.match(autoLinkPattern);
|
||||
const protocol = getDefaultLinkProtocol(editor);
|
||||
newRng.setEnd(endSpot.container, endSpot.offset);
|
||||
const rngText = removeZwsp(newRng.toString());
|
||||
const matches = rngText.match(autoLinkPattern);
|
||||
if (matches) {
|
||||
let url = matches[0];
|
||||
if (startsWith(url, 'www.')) {
|
||||
const protocol = getDefaultLinkProtocol(editor);
|
||||
url = protocol + '://' + url;
|
||||
} else if (contains(url, '@') && !hasProtocol(url)) {
|
||||
url = 'mailto:' + url;
|
||||
}
|
||||
return {
|
||||
rng,
|
||||
rng: newRng,
|
||||
url
|
||||
};
|
||||
} else {
|
||||
|
@ -171,10 +162,10 @@
|
|||
}
|
||||
};
|
||||
const convertToLink = (editor, result) => {
|
||||
const defaultLinkTarget = getDefaultLinkTarget(editor);
|
||||
const {dom, selection} = editor;
|
||||
const {rng, url} = result;
|
||||
const bookmark = editor.selection.getBookmark();
|
||||
editor.selection.setRng(rng);
|
||||
const bookmark = selection.getBookmark();
|
||||
selection.setRng(rng);
|
||||
const command = 'createlink';
|
||||
const args = {
|
||||
command,
|
||||
|
@ -185,22 +176,27 @@
|
|||
if (!beforeExecEvent.isDefaultPrevented()) {
|
||||
editor.getDoc().execCommand(command, false, url);
|
||||
editor.dispatch('ExecCommand', args);
|
||||
const defaultLinkTarget = getDefaultLinkTarget(editor);
|
||||
if (isString(defaultLinkTarget)) {
|
||||
editor.dom.setAttrib(editor.selection.getNode(), 'target', defaultLinkTarget);
|
||||
const anchor = selection.getNode();
|
||||
dom.setAttrib(anchor, 'target', defaultLinkTarget);
|
||||
if (defaultLinkTarget === '_blank' && !allowUnsafeLinkTarget(editor)) {
|
||||
dom.setAttrib(anchor, 'rel', 'noopener');
|
||||
}
|
||||
}
|
||||
}
|
||||
editor.selection.moveToBookmark(bookmark);
|
||||
selection.moveToBookmark(bookmark);
|
||||
editor.nodeChanged();
|
||||
};
|
||||
const handleSpacebar = editor => {
|
||||
const result = parseCurrentLine(editor, 0);
|
||||
const result = parseCurrentLine(editor, -1);
|
||||
if (isNonNullable(result)) {
|
||||
convertToLink(editor, result);
|
||||
}
|
||||
};
|
||||
const handleBracket = handleSpacebar;
|
||||
const handleEnter = editor => {
|
||||
const result = parseCurrentLine(editor, -1);
|
||||
const result = parseCurrentLine(editor, 0);
|
||||
if (isNonNullable(result)) {
|
||||
convertToLink(editor, result);
|
||||
}
|
||||
|
@ -221,7 +217,7 @@
|
|||
};
|
||||
|
||||
var Plugin = () => {
|
||||
global.add('autolink', editor => {
|
||||
global$1.add('autolink', editor => {
|
||||
register(editor);
|
||||
setup(editor);
|
||||
});
|
||||
|
|
4
node_modules/tinymce/plugins/autolink/plugin.min.js
generated
vendored
4
node_modules/tinymce/plugins/autolink/plugin.min.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=t=>e=>e.options.get(t),n=e("autolink_pattern"),o=e("link_default_target"),r=e("link_default_protocol"),i=("string",t=>"string"===(t=>{const e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"object"===e&&(n=o=t,(r=String).prototype.isPrototypeOf(n)||(null===(i=o.constructor)||void 0===i?void 0:i.name)===r.name)?"string":e;var n,o,r,i})(t));const s=t=>!(t=>null==t)(t),l=t=>/^[(\[{ \u00a0]$/.test(t),a=t=>3===t.nodeType,d=t=>1===t.nodeType,c=(t,e)=>{if(e<0&&(e=0),a(t)){const n=t.data.length;e>n&&(e=n)}return e},f=(t,e,n)=>{!d(e)||e.hasChildNodes()?t.setStart(e,c(e,n)):t.setStartBefore(e)},g=(t,e,n)=>{!d(e)||e.hasChildNodes()?t.setEnd(e,c(e,n)):t.setEndAfter(e)},u=(t,e)=>{let o,i,s,d,c,u;const h=n(t);if(null!==t.dom.getParent(t.selection.getNode(),"a[href]"))return;const p=t.selection.getRng().cloneRange();if(p.startOffset<5){if(d=p.endContainer.previousSibling,!d){if(!p.endContainer.firstChild||!p.endContainer.firstChild.nextSibling)return;d=p.endContainer.firstChild.nextSibling}if(c=d.length,f(p,d,c),g(p,d,c),p.endOffset<5)return;o=p.endOffset,i=d}else{if(i=p.endContainer,!a(i)&&i.firstChild){for(;!a(i)&&i.firstChild;)i=i.firstChild;a(i)&&(f(p,i,0),g(p,i,i.nodeValue.length))}o=1===p.endOffset?2:p.endOffset-1-e}const m=o;do{f(p,i,o>=2?o-2:0),g(p,i,o>=1?o-1:0),o-=1,u=p.toString()}while(!l(u)&&o-2>=0);var C;l(p.toString())?(f(p,i,o),g(p,i,m),o+=1):0===p.startOffset?(f(p,i,0),g(p,i,m)):(f(p,i,o),g(p,i,m)),s=p.toString(),C=s.charAt(s.length-1),/[?!,.;:]/.test(C)&&g(p,i,m-1),s=p.toString().trim();const k=s.match(h),y=r(t);if(k){let t=k[0];return v="www.",(w=t).length>=v.length&&w.substr(0,0+v.length)===v?t=y+"://"+t:((t,e)=>-1!==t.indexOf("@"))(t)&&!(t=>/^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(t))(t)&&(t="mailto:"+t),{rng:p,url:t}}var w,v;return null},h=(t,e)=>{const n=o(t),{rng:r,url:s}=e,l=t.selection.getBookmark();t.selection.setRng(r);const a="createlink",d={command:a,ui:!1,value:s};t.dispatch("BeforeExecCommand",d).isDefaultPrevented()||(t.getDoc().execCommand(a,!1,s),t.dispatch("ExecCommand",d),i(n)&&t.dom.setAttrib(t.selection.getNode(),"target",n)),t.selection.moveToBookmark(l),t.nodeChanged()},p=t=>{const e=u(t,0);s(e)&&h(t,e)},m=p;t.add("autolink",(t=>{(t=>{const e=t.options.register;e("autolink_pattern",{processor:"regexp",default:new RegExp("^"+/(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-.~*+=!;:'%@$(),\/\w]*[-~*+=%@$()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g.source+"$","i")}),e("link_default_target",{processor:"string"}),e("link_default_protocol",{processor:"string",default:"https"})})(t),(t=>{t.on("keydown",(e=>{13!==e.keyCode||e.isDefaultPrevented()||(t=>{const e=u(t,-1);s(e)&&h(t,e)})(t)})),t.on("keyup",(e=>{32===e.keyCode?p(t):(48===e.keyCode&&e.shiftKey||221===e.keyCode)&&m(t)}))})(t)}))}();
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>t.options.get(e),n=t("autolink_pattern"),o=t("link_default_target"),r=t("link_default_protocol"),a=t("allow_unsafe_link_target"),s=("string",e=>"string"===(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(n=o=e,(r=String).prototype.isPrototypeOf(n)||(null===(a=o.constructor)||void 0===a?void 0:a.name)===r.name)?"string":t;var n,o,r,a})(e));const l=(void 0,e=>undefined===e);const i=e=>!(e=>null==e)(e),c=Object.hasOwnProperty,d=e=>"\ufeff"===e;var u=tinymce.util.Tools.resolve("tinymce.dom.TextSeeker");const f=e=>/^[(\[{ \u00a0]$/.test(e),g=(e,t,n)=>{for(let o=t-1;o>=0;o--){const t=e.charAt(o);if(!d(t)&&n(t))return o}return-1},m=(e,t)=>{var o;const a=e.schema.getVoidElements(),s=n(e),{dom:i,selection:d}=e;if(null!==i.getParent(d.getNode(),"a[href]"))return null;const m=d.getRng(),k=u(i,(e=>{return i.isBlock(e)||(t=a,n=e.nodeName.toLowerCase(),c.call(t,n))||"false"===i.getContentEditable(e);var t,n})),{container:p,offset:y}=((e,t)=>{let n=e,o=t;for(;1===n.nodeType&&n.childNodes[o];)n=n.childNodes[o],o=3===n.nodeType?n.data.length:n.childNodes.length;return{container:n,offset:o}})(m.endContainer,m.endOffset),h=null!==(o=i.getParent(p,i.isBlock))&&void 0!==o?o:i.getRoot(),w=k.backwards(p,y+t,((e,t)=>{const n=e.data,o=g(n,t,(r=f,e=>!r(e)));var r,a;return-1===o||(a=n[o],/[?!,.;:]/.test(a))?o:o+1}),h);if(!w)return null;let v=w.container;const _=k.backwards(w.container,w.offset,((e,t)=>{v=e;const n=g(e.data,t,f);return-1===n?n:n+1}),h),A=i.createRng();_?A.setStart(_.container,_.offset):A.setStart(v,0),A.setEnd(w.container,w.offset);const C=A.toString().replace(/\uFEFF/g,"").match(s);if(C){let t=C[0];return $="www.",(b=t).length>=$.length&&b.substr(0,0+$.length)===$?t=r(e)+"://"+t:((e,t,n=0,o)=>{const r=e.indexOf(t,n);return-1!==r&&(!!l(o)||r+t.length<=o)})(t,"@")&&!(e=>/^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(e))(t)&&(t="mailto:"+t),{rng:A,url:t}}var b,$;return null},k=(e,t)=>{const{dom:n,selection:r}=e,{rng:l,url:i}=t,c=r.getBookmark();r.setRng(l);const d="createlink",u={command:d,ui:!1,value:i};if(!e.dispatch("BeforeExecCommand",u).isDefaultPrevented()){e.getDoc().execCommand(d,!1,i),e.dispatch("ExecCommand",u);const t=o(e);if(s(t)){const o=r.getNode();n.setAttrib(o,"target",t),"_blank"!==t||a(e)||n.setAttrib(o,"rel","noopener")}}r.moveToBookmark(c),e.nodeChanged()},p=e=>{const t=m(e,-1);i(t)&&k(e,t)},y=p;e.add("autolink",(e=>{(e=>{const t=e.options.register;t("autolink_pattern",{processor:"regexp",default:new RegExp("^"+/(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-.~*+=!;:'%@$(),\/\w]*[-~*+=%@$()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g.source+"$","i")}),t("link_default_target",{processor:"string"}),t("link_default_protocol",{processor:"string",default:"https"})})(e),(e=>{e.on("keydown",(t=>{13!==t.keyCode||t.isDefaultPrevented()||(e=>{const t=m(e,0);i(t)&&k(e,t)})(e)})),e.on("keyup",(t=>{32===t.keyCode?p(e):(48===t.keyCode&&t.shiftKey||221===t.keyCode)&&y(e)}))})(e)}))}();
|
5
node_modules/tinymce/plugins/autoresize/plugin.js
generated
vendored
5
node_modules/tinymce/plugins/autoresize/plugin.js
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
|
@ -53,7 +53,8 @@
|
|||
}
|
||||
};
|
||||
const parseCssValueToInt = (dom, elm, name, computed) => {
|
||||
const value = parseInt(dom.getStyle(elm, name, computed), 10);
|
||||
var _a;
|
||||
const value = parseInt((_a = dom.getStyle(elm, name, computed)) !== null && _a !== void 0 ? _a : '', 10);
|
||||
return isNaN(value) ? 0 : value;
|
||||
};
|
||||
const shouldScrollIntoView = trigger => {
|
||||
|
|
4
node_modules/tinymce/plugins/autoresize/plugin.min.js
generated
vendored
4
node_modules/tinymce/plugins/autoresize/plugin.min.js
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.Env");const o=e=>t=>t.options.get(e),n=o("min_height"),s=o("max_height"),i=o("autoresize_overflow_padding"),r=o("autoresize_bottom_margin"),l=(e,t)=>{const o=e.getBody();o&&(o.style.overflowY=t?"":"hidden",t||(o.scrollTop=0))},a=(e,t,o,n)=>{const s=parseInt(e.getStyle(t,o,n),10);return isNaN(s)?0:s},g=(e,o,i)=>{var c;const u=e.dom,d=e.getDoc();if(!d)return;if((e=>e.plugins.fullscreen&&e.plugins.fullscreen.isFullscreen())(e))return void l(e,!0);const f=d.documentElement,m=r(e),p=null!==(c=n(e))&&void 0!==c?c:e.getElement().offsetHeight;let h=p;const y=a(u,f,"margin-top",!0),v=a(u,f,"margin-bottom",!0);let C=f.offsetHeight+y+v+m;C<0&&(C=0);const S=e.getContainer().offsetHeight-e.getContentAreaContainer().offsetHeight;C+S>p&&(h=C+S);const z=s(e);if(z&&h>z?(h=z,l(e,!0)):l(e,!1),h!==o.get()){const n=h-o.get();if(u.setStyle(e.getContainer(),"height",h+"px"),o.set(h),(e=>{e.dispatch("ResizeEditor")})(e),t.browser.isSafari()&&(t.os.isMacOS()||t.os.isiOS())){const t=e.getWin();t.scrollTo(t.pageXOffset,t.pageYOffset)}e.hasFocus()&&(e=>{if("setcontent"===(null==e?void 0:e.type.toLowerCase())){const t=e;return!0===t.selection||!0===t.paste}return!1})(i)&&e.selection.scrollIntoView(),(t.browser.isSafari()||t.browser.isChromium())&&n<0&&g(e,o,i)}};e.add("autoresize",(e=>{if((e=>{const t=e.options.register;t("autoresize_overflow_padding",{processor:"number",default:1}),t("autoresize_bottom_margin",{processor:"number",default:50})})(e),e.options.isSet("resize")||e.options.set("resize",!1),!e.inline){const t=(e=>{let t=0;return{get:()=>t,set:e=>{t=e}}})();((e,t)=>{e.addCommand("mceAutoResize",(()=>{g(e,t)}))})(e,t),((e,t)=>{e.on("init",(()=>{const t=i(e),o=e.dom;o.setStyles(e.getDoc().documentElement,{height:"auto"}),o.setStyles(e.getBody(),{paddingLeft:t,paddingRight:t,"min-height":0})})),e.on("NodeChange SetContent keyup FullscreenStateChanged ResizeContent",(o=>{g(e,t,o)}))})(e,t)}}))}();
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.Env");const o=e=>t=>t.options.get(e),n=o("min_height"),s=o("max_height"),i=o("autoresize_overflow_padding"),r=o("autoresize_bottom_margin"),l=(e,t)=>{const o=e.getBody();o&&(o.style.overflowY=t?"":"hidden",t||(o.scrollTop=0))},a=(e,t,o,n)=>{var s;const i=parseInt(null!==(s=e.getStyle(t,o,n))&&void 0!==s?s:"",10);return isNaN(i)?0:i},g=(e,o,i)=>{var c;const u=e.dom,d=e.getDoc();if(!d)return;if((e=>e.plugins.fullscreen&&e.plugins.fullscreen.isFullscreen())(e))return void l(e,!0);const f=d.documentElement,m=r(e),p=null!==(c=n(e))&&void 0!==c?c:e.getElement().offsetHeight;let h=p;const v=a(u,f,"margin-top",!0),y=a(u,f,"margin-bottom",!0);let C=f.offsetHeight+v+y+m;C<0&&(C=0);const S=e.getContainer().offsetHeight-e.getContentAreaContainer().offsetHeight;C+S>p&&(h=C+S);const z=s(e);if(z&&h>z?(h=z,l(e,!0)):l(e,!1),h!==o.get()){const n=h-o.get();if(u.setStyle(e.getContainer(),"height",h+"px"),o.set(h),(e=>{e.dispatch("ResizeEditor")})(e),t.browser.isSafari()&&(t.os.isMacOS()||t.os.isiOS())){const t=e.getWin();t.scrollTo(t.pageXOffset,t.pageYOffset)}e.hasFocus()&&(e=>{if("setcontent"===(null==e?void 0:e.type.toLowerCase())){const t=e;return!0===t.selection||!0===t.paste}return!1})(i)&&e.selection.scrollIntoView(),(t.browser.isSafari()||t.browser.isChromium())&&n<0&&g(e,o,i)}};e.add("autoresize",(e=>{if((e=>{const t=e.options.register;t("autoresize_overflow_padding",{processor:"number",default:1}),t("autoresize_bottom_margin",{processor:"number",default:50})})(e),e.options.isSet("resize")||e.options.set("resize",!1),!e.inline){const t=(e=>{let t=0;return{get:()=>t,set:e=>{t=e}}})();((e,t)=>{e.addCommand("mceAutoResize",(()=>{g(e,t)}))})(e,t),((e,t)=>{e.on("init",(()=>{const t=i(e),o=e.dom;o.setStyles(e.getDoc().documentElement,{height:"auto"}),o.setStyles(e.getBody(),{paddingLeft:t,paddingRight:t,"min-height":0})})),e.on("NodeChange SetContent keyup FullscreenStateChanged ResizeContent",(o=>{g(e,t,o)}))})(e,t)}}))}();
|
21
node_modules/tinymce/plugins/autosave/plugin.js
generated
vendored
21
node_modules/tinymce/plugins/autosave/plugin.js
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
|
@ -48,7 +48,7 @@
|
|||
m: 60000
|
||||
};
|
||||
const parsedTime = /^(\d+)([ms]?)$/.exec(timeString);
|
||||
return (parsedTime[2] ? multiples[parsedTime[2]] : 1) * parseInt(timeString, 10);
|
||||
return (parsedTime && parsedTime[2] ? multiples[parsedTime[2]] : 1) * parseInt(timeString, 10);
|
||||
};
|
||||
|
||||
const option = name => editor => editor.options.get(name);
|
||||
|
@ -112,7 +112,8 @@
|
|||
}
|
||||
};
|
||||
const hasDraft = editor => {
|
||||
const time = parseInt(global$2.getItem(getAutoSavePrefix(editor) + 'time'), 10) || 0;
|
||||
var _a;
|
||||
const time = parseInt((_a = global$2.getItem(getAutoSavePrefix(editor) + 'time')) !== null && _a !== void 0 ? _a : '0', 10) || 0;
|
||||
if (new Date().getTime() - time > getAutoSaveRetention(editor)) {
|
||||
removeDraft(editor, false);
|
||||
return false;
|
||||
|
@ -139,9 +140,10 @@
|
|||
}
|
||||
};
|
||||
const restoreDraft = editor => {
|
||||
var _a;
|
||||
const prefix = getAutoSavePrefix(editor);
|
||||
if (hasDraft(editor)) {
|
||||
editor.setContent(global$2.getItem(prefix + 'draft'), { format: 'raw' });
|
||||
editor.setContent((_a = global$2.getItem(prefix + 'draft')) !== null && _a !== void 0 ? _a : '', { format: 'raw' });
|
||||
fireRestoreDraft(editor);
|
||||
}
|
||||
};
|
||||
|
@ -195,20 +197,19 @@
|
|||
};
|
||||
const register = editor => {
|
||||
startStoreDraft(editor);
|
||||
const onAction = () => {
|
||||
restoreLastDraft(editor);
|
||||
};
|
||||
editor.ui.registry.addButton('restoredraft', {
|
||||
tooltip: 'Restore last draft',
|
||||
icon: 'restore-draft',
|
||||
onAction: () => {
|
||||
restoreLastDraft(editor);
|
||||
},
|
||||
onAction,
|
||||
onSetup: makeSetupHandler(editor)
|
||||
});
|
||||
editor.ui.registry.addMenuItem('restoredraft', {
|
||||
text: 'Restore last draft',
|
||||
icon: 'restore-draft',
|
||||
onAction: () => {
|
||||
restoreLastDraft(editor);
|
||||
},
|
||||
onAction,
|
||||
onSetup: makeSetupHandler(editor)
|
||||
});
|
||||
};
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue