mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-09 17:51:46 +00:00
feat(synced-lyrics): romanization (#2790)
* feat(synced-lyrics): init romanization! * remove debug logs and add TODO * feat(synced-lyrics/romanization): Mandarin! * feat(synced-lyrics/romanization): improve japanese detection * feat(synced-lyrics/romanization): Korean! * qol(synced-lyrics/romanization): canonicalize punctuation and symbols * feat(synced-lyrics/romanization): handle japanese+korean and korean+chinese lyrics * revert formatting on electron.vite.config.mts * feat(synced-lyrics/romanization): romanize plain lyrics * apply fix by @kimjammer * fix lockfile due to rebase * feat(synced-lyrics): improve lyric processing and formatting; * feat(synced-lyrics/romanization): add option to enable/disable romanization * chore: move default value for --lyrics-duration to the declaration * update lockfile * fix: improvement 1. improved language detection logic 2. changed code to work in the renderer process * fix: fix regression (canonicalize) --------- Co-authored-by: JellyBrick <shlee1503@naver.com>
This commit is contained in:
@ -1,161 +0,0 @@
|
||||
diff --git a/lib/importDeclaration.js b/lib/importDeclaration.js
|
||||
index afb4de779034cfea080825a5f4320661c48bee32..f10b0a11a39577fbd42569e6b0e768255c1ef276 100644
|
||||
--- a/lib/importDeclaration.js
|
||||
+++ b/lib/importDeclaration.js
|
||||
@@ -1,5 +1,5 @@
|
||||
-"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports["default"] = importDeclaration;function importDeclaration(context) {
|
||||
- var ancestors = context.getAncestors();
|
||||
+"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports["default"] = importDeclaration;function importDeclaration(context, node) {
|
||||
+ var ancestors = context.getSourceCode().getAncestors(node);
|
||||
return ancestors[ancestors.length - 1];
|
||||
}
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbXBvcnREZWNsYXJhdGlvbi5qcyJdLCJuYW1lcyI6WyJpbXBvcnREZWNsYXJhdGlvbiIsImNvbnRleHQiLCJhbmNlc3RvcnMiLCJnZXRBbmNlc3RvcnMiLCJsZW5ndGgiXSwibWFwcGluZ3MiOiJnR0FBd0JBLGlCLENBQVQsU0FBU0EsaUJBQVQsQ0FBMkJDLE9BQTNCLEVBQW9DO0FBQ2pELE1BQU1DLFlBQVlELFFBQVFFLFlBQVIsRUFBbEI7QUFDQSxTQUFPRCxVQUFVQSxVQUFVRSxNQUFWLEdBQW1CLENBQTdCLENBQVA7QUFDRCIsImZpbGUiOiJpbXBvcnREZWNsYXJhdGlvbi5qcyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGltcG9ydERlY2xhcmF0aW9uKGNvbnRleHQpIHtcbiAgY29uc3QgYW5jZXN0b3JzID0gY29udGV4dC5nZXRBbmNlc3RvcnMoKTtcbiAgcmV0dXJuIGFuY2VzdG9yc1thbmNlc3RvcnMubGVuZ3RoIC0gMV07XG59XG4iXX0=
|
||||
\ No newline at end of file
|
||||
diff --git a/lib/rules/first.js b/lib/rules/first.js
|
||||
index a77168660cf32c8c3e96f3ff4b8240a36d7de3a6..c0e00d75f9989916057fef3999eeee8d21820292 100644
|
||||
--- a/lib/rules/first.js
|
||||
+++ b/lib/rules/first.js
|
||||
@@ -66,7 +66,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
if (nonImportCount > 0) {var _iteratorNormalCompletion = true;var _didIteratorError = false;var _iteratorError = undefined;try {
|
||||
- for (var _iterator = context.getDeclaredVariables(node)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {var variable = _step.value;
|
||||
+ for (var _iterator = sourceCode.getDeclaredVariables(node)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {var variable = _step.value;
|
||||
if (!shouldSort) {break;}
|
||||
var references = variable.references;
|
||||
if (references.length) {var _iteratorNormalCompletion2 = true;var _didIteratorError2 = false;var _iteratorError2 = undefined;try {
|
||||
diff --git a/lib/rules/namespace.js b/lib/rules/namespace.js
|
||||
index 574d89a60d15c7e0e712956ea6a3ad2d0eac7f08..82e7cb3cff4246592d762cce86323f2b72de92e4 100644
|
||||
--- a/lib/rules/namespace.js
|
||||
+++ b/lib/rules/namespace.js
|
||||
@@ -86,7 +86,7 @@ module.exports = {
|
||||
|
||||
// same as above, but does not add names to local map
|
||||
ExportNamespaceSpecifier: function () {function ExportNamespaceSpecifier(namespace) {
|
||||
- var declaration = (0, _importDeclaration2['default'])(context);
|
||||
+ var declaration = (0, _importDeclaration2['default'])(context, namespace);
|
||||
|
||||
var imports = _ExportMap2['default'].get(declaration.source.value, context);
|
||||
if (imports == null) {return null;}
|
||||
diff --git a/lib/rules/newline-after-import.js b/lib/rules/newline-after-import.js
|
||||
index 6cc15686464a17803a0b976c35b99627cdbfabee..520eec6d9a375527ab72c459960fe4416c046c17 100644
|
||||
--- a/lib/rules/newline-after-import.js
|
||||
+++ b/lib/rules/newline-after-import.js
|
||||
@@ -194,7 +194,7 @@ module.exports = {
|
||||
}return CallExpression;}(),
|
||||
'Program:exit': function () {function ProgramExit() {
|
||||
log('exit processing for', context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename());
|
||||
- var scopeBody = getScopeBody(context.getScope());
|
||||
+ var scopeBody = getScopeBody(context.getSourceCode().getScope(node));
|
||||
log('got scope:', scopeBody);
|
||||
|
||||
requireCalls.forEach(function (node, index) {
|
||||
diff --git a/lib/rules/no-amd.js b/lib/rules/no-amd.js
|
||||
index 7ac108bf812ca4f78bfa6fe5ae8b9cf38e2ff497..346c3105dc70f72c4d76fcc6b96b946d1d4ec6d5 100644
|
||||
--- a/lib/rules/no-amd.js
|
||||
+++ b/lib/rules/no-amd.js
|
||||
@@ -23,7 +23,7 @@ module.exports = {
|
||||
create: function () {function create(context) {
|
||||
return {
|
||||
CallExpression: function () {function CallExpression(node) {
|
||||
- if (context.getScope().type !== 'module') {return;}
|
||||
+ if (context.getSourceCode().getScope(node).type !== 'module') {return;}
|
||||
|
||||
if (node.callee.type !== 'Identifier') {return;}
|
||||
if (node.callee.name !== 'require' && node.callee.name !== 'define') {return;}
|
||||
diff --git a/lib/rules/no-commonjs.js b/lib/rules/no-commonjs.js
|
||||
index befeff0026d61d3ac1e6bbcea29f5c471dc1d353..e91c5ed34e968d5867e884ea800e166cda345aef 100644
|
||||
--- a/lib/rules/no-commonjs.js
|
||||
+++ b/lib/rules/no-commonjs.js
|
||||
@@ -107,7 +107,7 @@ module.exports = {
|
||||
|
||||
// exports.
|
||||
if (node.object.name === 'exports') {
|
||||
- var isInScope = context.getScope().
|
||||
+ var isInScope = context.getSourceCode().getScope(node).
|
||||
variables.
|
||||
some(function (variable) {return variable.name === 'exports';});
|
||||
if (!isInScope) {
|
||||
@@ -117,7 +117,7 @@ module.exports = {
|
||||
|
||||
}return MemberExpression;}(),
|
||||
CallExpression: function () {function CallExpression(call) {
|
||||
- if (!validateScope(context.getScope())) {return;}
|
||||
+ if (!validateScope(context.getSourceCode().getScope(call))) {return;}
|
||||
|
||||
if (call.callee.type !== 'Identifier') {return;}
|
||||
if (call.callee.name !== 'require') {return;}
|
||||
diff --git a/lib/rules/no-mutable-exports.js b/lib/rules/no-mutable-exports.js
|
||||
index 40bd1b4cfa95d41732bb13bba0ed1969a91cc7ff..8a25abfbfadb299204b36a6cbf283259bcc2e790 100644
|
||||
--- a/lib/rules/no-mutable-exports.js
|
||||
+++ b/lib/rules/no-mutable-exports.js
|
||||
@@ -32,7 +32,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
function handleExportDefault(node) {
|
||||
- var scope = context.getScope();
|
||||
+ var scope = context.getSourceCode().getScope(node);
|
||||
|
||||
if (node.declaration.name) {
|
||||
checkDeclarationsInScope(scope, node.declaration.name);
|
||||
@@ -40,7 +40,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
function handleExportNamed(node) {
|
||||
- var scope = context.getScope();
|
||||
+ var scope = context.getSourceCode().getScope(node);
|
||||
|
||||
if (node.declaration) {
|
||||
checkDeclaration(node.declaration);
|
||||
diff --git a/lib/rules/no-named-as-default-member.js b/lib/rules/no-named-as-default-member.js
|
||||
index 0c15051e027ad7d1d45f1b51c20be1c000b0af01..5b3d6ba415511b7f9f83a52e1acfebe5a1045a7b 100644
|
||||
--- a/lib/rules/no-named-as-default-member.js
|
||||
+++ b/lib/rules/no-named-as-default-member.js
|
||||
@@ -35,7 +35,7 @@ module.exports = {
|
||||
|
||||
return {
|
||||
ImportDefaultSpecifier: function () {function ImportDefaultSpecifier(node) {
|
||||
- var declaration = (0, _importDeclaration2['default'])(context);
|
||||
+ var declaration = (0, _importDeclaration2['default'])(context, node);
|
||||
var exportMap = _ExportMap2['default'].get(declaration.source.value, context);
|
||||
if (exportMap == null) {return;}
|
||||
|
||||
diff --git a/lib/rules/no-named-as-default.js b/lib/rules/no-named-as-default.js
|
||||
index 63378a33a1c7da004c57a524cec1a1cddf23e210..c81b1f93b11628676158b79f1c4015911943cc7d 100644
|
||||
--- a/lib/rules/no-named-as-default.js
|
||||
+++ b/lib/rules/no-named-as-default.js
|
||||
@@ -18,7 +18,7 @@ module.exports = {
|
||||
// #566: default is a valid specifier
|
||||
if (defaultSpecifier[nameKey].name === 'default') {return;}
|
||||
|
||||
- var declaration = (0, _importDeclaration2['default'])(context);
|
||||
+ var declaration = (0, _importDeclaration2['default'])(context, defaultSpecifier);
|
||||
|
||||
var imports = _ExportMap2['default'].get(declaration.source.value, context);
|
||||
if (imports == null) {return;}
|
||||
diff --git a/lib/rules/no-namespace.js b/lib/rules/no-namespace.js
|
||||
index 2b0c783adea788101b779b17f977bbcb582cfd3f..a7f7b202ac7c4a342febef2a993586c4cc84fc7a 100644
|
||||
--- a/lib/rules/no-namespace.js
|
||||
+++ b/lib/rules/no-namespace.js
|
||||
@@ -43,7 +43,7 @@ var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_doc
|
||||
return;
|
||||
}
|
||||
|
||||
- var scopeVariables = context.getScope().variables;
|
||||
+ var scopeVariables = context.getSourceCode().getScope(node).variables;
|
||||
var namespaceVariable = scopeVariables.find(function (variable) {return variable.defs[0].node === node;});
|
||||
var namespaceReferences = namespaceVariable.references;
|
||||
var namespaceIdentifiers = namespaceReferences.map(function (reference) {return reference.identifier;});
|
||||
diff --git a/package.json b/package.json
|
||||
index 5c0af48543483a21791fa23a4a583071d3551772..5deeac3d0accc3878ef0fc93dfb52a8ca7c46e84 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -72,7 +72,7 @@
|
||||
"chai": "^4.3.10",
|
||||
"cross-env": "^4.0.0",
|
||||
"escope": "^3.6.0",
|
||||
- "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8",
|
||||
+ "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9",
|
||||
"eslint-doc-generator": "^1.6.1",
|
||||
"eslint-import-resolver-node": "file:./resolvers/node",
|
||||
"eslint-import-resolver-typescript": "^1.0.2 || ^1.1.1",
|
||||
580
patches/kuromoji@0.1.2.patch
Normal file
580
patches/kuromoji@0.1.2.patch
Normal file
@ -0,0 +1,580 @@
|
||||
diff --git a/build/kuromoji.js b/build/kuromoji.js
|
||||
index f0f4ae9183ff8965fda64a2042f29936f76506d1..8912a754d184742d2768854c7bba83d66f9ff95f 100644
|
||||
--- a/build/kuromoji.js
|
||||
+++ b/build/kuromoji.js
|
||||
@@ -1,5 +1,5 @@
|
||||
-(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.kuromoji = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
|
||||
-(function (process,global){
|
||||
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.kuromoji = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
+(function (process,global,setImmediate){(function (){
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
@@ -666,10 +666,13 @@ var reIsUint = /^(?:0|[1-9]\d*)$/;
|
||||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||||
*/
|
||||
function isIndex(value, length) {
|
||||
+ var type = typeof value;
|
||||
length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
||||
+
|
||||
return !!length &&
|
||||
- (typeof value == 'number' || reIsUint.test(value)) &&
|
||||
- (value > -1 && value % 1 == 0 && value < length);
|
||||
+ (type == 'number' ||
|
||||
+ (type != 'symbol' && reIsUint.test(value))) &&
|
||||
+ (value > -1 && value % 1 == 0 && value < length);
|
||||
}
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
@@ -755,6 +758,14 @@ var freeProcess = moduleExports$1 && freeGlobal.process;
|
||||
/** Used to access faster Node.js helpers. */
|
||||
var nodeUtil = (function() {
|
||||
try {
|
||||
+ // Use `util.types` for Node.js 10+.
|
||||
+ var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
|
||||
+
|
||||
+ if (types) {
|
||||
+ return types;
|
||||
+ }
|
||||
+
|
||||
+ // Legacy `process.binding('util')` for Node.js < 10.
|
||||
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
||||
} catch (e) {}
|
||||
}());
|
||||
@@ -939,6 +950,9 @@ function createObjectIterator(obj) {
|
||||
var len = okeys.length;
|
||||
return function next() {
|
||||
var key = okeys[++i];
|
||||
+ if (key === '__proto__') {
|
||||
+ return next();
|
||||
+ }
|
||||
return i < len ? {value: obj[key], key: key} : null;
|
||||
};
|
||||
}
|
||||
@@ -970,6 +984,7 @@ function _eachOfLimit(limit) {
|
||||
var nextElem = iterator(obj);
|
||||
var done = false;
|
||||
var running = 0;
|
||||
+ var looping = false;
|
||||
|
||||
function iterateeCallback(err, value) {
|
||||
running -= 1;
|
||||
@@ -981,12 +996,13 @@ function _eachOfLimit(limit) {
|
||||
done = true;
|
||||
return callback(null);
|
||||
}
|
||||
- else {
|
||||
+ else if (!looping) {
|
||||
replenish();
|
||||
}
|
||||
}
|
||||
|
||||
function replenish () {
|
||||
+ looping = true;
|
||||
while (running < limit && !done) {
|
||||
var elem = nextElem();
|
||||
if (elem === null) {
|
||||
@@ -999,6 +1015,7 @@ function _eachOfLimit(limit) {
|
||||
running += 1;
|
||||
iteratee(elem.value, elem.key, onlyOnce(iterateeCallback));
|
||||
}
|
||||
+ looping = false;
|
||||
}
|
||||
|
||||
replenish();
|
||||
@@ -3819,7 +3836,7 @@ function memoize(fn, hasher) {
|
||||
|
||||
/**
|
||||
* Calls `callback` on a later loop around the event loop. In Node.js this just
|
||||
- * calls `process.nextTicl`. In the browser it will use `setImmediate` if
|
||||
+ * calls `process.nextTick`. In the browser it will use `setImmediate` if
|
||||
* available, otherwise `setTimeout(callback, 0)`, which means other higher
|
||||
* priority events may precede the execution of `callback`.
|
||||
*
|
||||
@@ -5596,8 +5613,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
|
||||
-}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
-},{"_process":4}],2:[function(require,module,exports){
|
||||
+}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
|
||||
+},{"_process":3,"timers":4}],2:[function(require,module,exports){
|
||||
// Copyright (c) 2014 Takuya Asano All Rights Reserved.
|
||||
|
||||
(function () {
|
||||
@@ -6391,234 +6408,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
})();
|
||||
|
||||
},{}],3:[function(require,module,exports){
|
||||
-(function (process){
|
||||
-// Copyright Joyent, Inc. and other Node contributors.
|
||||
-//
|
||||
-// 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.
|
||||
-
|
||||
-// resolves . and .. elements in a path array with directory names there
|
||||
-// must be no slashes, empty elements, or device names (c:\) in the array
|
||||
-// (so also no leading and trailing slashes - it does not distinguish
|
||||
-// relative and absolute paths)
|
||||
-function normalizeArray(parts, allowAboveRoot) {
|
||||
- // if the path tries to go above the root, `up` ends up > 0
|
||||
- var up = 0;
|
||||
- for (var i = parts.length - 1; i >= 0; i--) {
|
||||
- var last = parts[i];
|
||||
- if (last === '.') {
|
||||
- parts.splice(i, 1);
|
||||
- } else if (last === '..') {
|
||||
- parts.splice(i, 1);
|
||||
- up++;
|
||||
- } else if (up) {
|
||||
- parts.splice(i, 1);
|
||||
- up--;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- // if the path is allowed to go above the root, restore leading ..s
|
||||
- if (allowAboveRoot) {
|
||||
- for (; up--; up) {
|
||||
- parts.unshift('..');
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return parts;
|
||||
-}
|
||||
-
|
||||
-// Split a filename into [root, dir, basename, ext], unix version
|
||||
-// 'root' is just a slash, or nothing.
|
||||
-var splitPathRe =
|
||||
- /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
||||
-var splitPath = function(filename) {
|
||||
- return splitPathRe.exec(filename).slice(1);
|
||||
-};
|
||||
-
|
||||
-// path.resolve([from ...], to)
|
||||
-// posix version
|
||||
-exports.resolve = function() {
|
||||
- var resolvedPath = '',
|
||||
- resolvedAbsolute = false;
|
||||
-
|
||||
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
||||
- var path = (i >= 0) ? arguments[i] : process.cwd();
|
||||
-
|
||||
- // Skip empty and invalid entries
|
||||
- if (typeof path !== 'string') {
|
||||
- throw new TypeError('Arguments to path.resolve must be strings');
|
||||
- } else if (!path) {
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- resolvedPath = path + '/' + resolvedPath;
|
||||
- resolvedAbsolute = path.charAt(0) === '/';
|
||||
- }
|
||||
-
|
||||
- // At this point the path should be resolved to a full absolute path, but
|
||||
- // handle relative paths to be safe (might happen when process.cwd() fails)
|
||||
-
|
||||
- // Normalize the path
|
||||
- resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
||||
- return !!p;
|
||||
- }), !resolvedAbsolute).join('/');
|
||||
-
|
||||
- return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
||||
-};
|
||||
-
|
||||
-// path.normalize(path)
|
||||
-// posix version
|
||||
-exports.normalize = function(path) {
|
||||
- var isAbsolute = exports.isAbsolute(path),
|
||||
- trailingSlash = substr(path, -1) === '/';
|
||||
-
|
||||
- // Normalize the path
|
||||
- path = normalizeArray(filter(path.split('/'), function(p) {
|
||||
- return !!p;
|
||||
- }), !isAbsolute).join('/');
|
||||
-
|
||||
- if (!path && !isAbsolute) {
|
||||
- path = '.';
|
||||
- }
|
||||
- if (path && trailingSlash) {
|
||||
- path += '/';
|
||||
- }
|
||||
-
|
||||
- return (isAbsolute ? '/' : '') + path;
|
||||
-};
|
||||
-
|
||||
-// posix version
|
||||
-exports.isAbsolute = function(path) {
|
||||
- return path.charAt(0) === '/';
|
||||
-};
|
||||
-
|
||||
-// posix version
|
||||
-exports.join = function() {
|
||||
- var paths = Array.prototype.slice.call(arguments, 0);
|
||||
- return exports.normalize(filter(paths, function(p, index) {
|
||||
- if (typeof p !== 'string') {
|
||||
- throw new TypeError('Arguments to path.join must be strings');
|
||||
- }
|
||||
- return p;
|
||||
- }).join('/'));
|
||||
-};
|
||||
-
|
||||
-
|
||||
-// path.relative(from, to)
|
||||
-// posix version
|
||||
-exports.relative = function(from, to) {
|
||||
- from = exports.resolve(from).substr(1);
|
||||
- to = exports.resolve(to).substr(1);
|
||||
-
|
||||
- function trim(arr) {
|
||||
- var start = 0;
|
||||
- for (; start < arr.length; start++) {
|
||||
- if (arr[start] !== '') break;
|
||||
- }
|
||||
-
|
||||
- var end = arr.length - 1;
|
||||
- for (; end >= 0; end--) {
|
||||
- if (arr[end] !== '') break;
|
||||
- }
|
||||
-
|
||||
- if (start > end) return [];
|
||||
- return arr.slice(start, end - start + 1);
|
||||
- }
|
||||
-
|
||||
- var fromParts = trim(from.split('/'));
|
||||
- var toParts = trim(to.split('/'));
|
||||
-
|
||||
- var length = Math.min(fromParts.length, toParts.length);
|
||||
- var samePartsLength = length;
|
||||
- for (var i = 0; i < length; i++) {
|
||||
- if (fromParts[i] !== toParts[i]) {
|
||||
- samePartsLength = i;
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- var outputParts = [];
|
||||
- for (var i = samePartsLength; i < fromParts.length; i++) {
|
||||
- outputParts.push('..');
|
||||
- }
|
||||
-
|
||||
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
||||
-
|
||||
- return outputParts.join('/');
|
||||
-};
|
||||
-
|
||||
-exports.sep = '/';
|
||||
-exports.delimiter = ':';
|
||||
-
|
||||
-exports.dirname = function(path) {
|
||||
- var result = splitPath(path),
|
||||
- root = result[0],
|
||||
- dir = result[1];
|
||||
-
|
||||
- if (!root && !dir) {
|
||||
- // No dirname whatsoever
|
||||
- return '.';
|
||||
- }
|
||||
-
|
||||
- if (dir) {
|
||||
- // It has a dirname, strip trailing slash
|
||||
- dir = dir.substr(0, dir.length - 1);
|
||||
- }
|
||||
-
|
||||
- return root + dir;
|
||||
-};
|
||||
-
|
||||
-
|
||||
-exports.basename = function(path, ext) {
|
||||
- var f = splitPath(path)[2];
|
||||
- // TODO: make this comparison case-insensitive on windows?
|
||||
- if (ext && f.substr(-1 * ext.length) === ext) {
|
||||
- f = f.substr(0, f.length - ext.length);
|
||||
- }
|
||||
- return f;
|
||||
-};
|
||||
-
|
||||
-
|
||||
-exports.extname = function(path) {
|
||||
- return splitPath(path)[3];
|
||||
-};
|
||||
-
|
||||
-function filter (xs, f) {
|
||||
- if (xs.filter) return xs.filter(f);
|
||||
- var res = [];
|
||||
- for (var i = 0; i < xs.length; i++) {
|
||||
- if (f(xs[i], i, xs)) res.push(xs[i]);
|
||||
- }
|
||||
- return res;
|
||||
-}
|
||||
-
|
||||
-// String.prototype.substr - negative index don't work in IE8
|
||||
-var substr = 'ab'.substr(-1) === 'b'
|
||||
- ? function (str, start, len) { return str.substr(start, len) }
|
||||
- : function (str, start, len) {
|
||||
- if (start < 0) start = str.length + start;
|
||||
- return str.substr(start, len);
|
||||
- }
|
||||
-;
|
||||
-
|
||||
-}).call(this,require('_process'))
|
||||
-},{"_process":4}],4:[function(require,module,exports){
|
||||
// shim for using process in browser
|
||||
var process = module.exports = {};
|
||||
|
||||
@@ -6804,7 +6593,86 @@ process.chdir = function (dir) {
|
||||
};
|
||||
process.umask = function() { return 0; };
|
||||
|
||||
-},{}],5:[function(require,module,exports){
|
||||
+},{}],4:[function(require,module,exports){
|
||||
+(function (setImmediate,clearImmediate){(function (){
|
||||
+var nextTick = require('process/browser.js').nextTick;
|
||||
+var apply = Function.prototype.apply;
|
||||
+var slice = Array.prototype.slice;
|
||||
+var immediateIds = {};
|
||||
+var nextImmediateId = 0;
|
||||
+
|
||||
+// DOM APIs, for completeness
|
||||
+
|
||||
+exports.setTimeout = function() {
|
||||
+ return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
|
||||
+};
|
||||
+exports.setInterval = function() {
|
||||
+ return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
|
||||
+};
|
||||
+exports.clearTimeout =
|
||||
+exports.clearInterval = function(timeout) { timeout.close(); };
|
||||
+
|
||||
+function Timeout(id, clearFn) {
|
||||
+ this._id = id;
|
||||
+ this._clearFn = clearFn;
|
||||
+}
|
||||
+Timeout.prototype.unref = Timeout.prototype.ref = function() {};
|
||||
+Timeout.prototype.close = function() {
|
||||
+ this._clearFn.call(window, this._id);
|
||||
+};
|
||||
+
|
||||
+// Does not start the time, just sets up the members needed.
|
||||
+exports.enroll = function(item, msecs) {
|
||||
+ clearTimeout(item._idleTimeoutId);
|
||||
+ item._idleTimeout = msecs;
|
||||
+};
|
||||
+
|
||||
+exports.unenroll = function(item) {
|
||||
+ clearTimeout(item._idleTimeoutId);
|
||||
+ item._idleTimeout = -1;
|
||||
+};
|
||||
+
|
||||
+exports._unrefActive = exports.active = function(item) {
|
||||
+ clearTimeout(item._idleTimeoutId);
|
||||
+
|
||||
+ var msecs = item._idleTimeout;
|
||||
+ if (msecs >= 0) {
|
||||
+ item._idleTimeoutId = setTimeout(function onTimeout() {
|
||||
+ if (item._onTimeout)
|
||||
+ item._onTimeout();
|
||||
+ }, msecs);
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+// That's not how node.js implements it but the exposed api is the same.
|
||||
+exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
|
||||
+ var id = nextImmediateId++;
|
||||
+ var args = arguments.length < 2 ? false : slice.call(arguments, 1);
|
||||
+
|
||||
+ immediateIds[id] = true;
|
||||
+
|
||||
+ nextTick(function onNextTick() {
|
||||
+ if (immediateIds[id]) {
|
||||
+ // fn.call() is faster so we optimize for the common use-case
|
||||
+ // @see http://jsperf.com/call-apply-segu
|
||||
+ if (args) {
|
||||
+ fn.apply(null, args);
|
||||
+ } else {
|
||||
+ fn.call(null);
|
||||
+ }
|
||||
+ // Prevent ids from leaking
|
||||
+ exports.clearImmediate(id);
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
+ return id;
|
||||
+};
|
||||
+
|
||||
+exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
|
||||
+ delete immediateIds[id];
|
||||
+};
|
||||
+}).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
|
||||
+},{"process/browser.js":3,"timers":4}],5:[function(require,module,exports){
|
||||
/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';function n(e){throw e;}var p=void 0,aa=this;function t(e,b){var d=e.split("."),c=aa;!(d[0]in c)&&c.execScript&&c.execScript("var "+d[0]);for(var a;d.length&&(a=d.shift());)!d.length&&b!==p?c[a]=b:c=c[a]?c[a]:c[a]={}};var x="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;new (x?Uint8Array:Array)(256);var y;for(y=0;256>y;++y)for(var A=y,ba=7,A=A>>>1;A;A>>>=1)--ba;function B(e,b,d){var c,a="number"===typeof b?b:b=0,f="number"===typeof d?d:e.length;c=-1;for(a=f&7;a--;++b)c=c>>>8^C[(c^e[b])&255];for(a=f>>3;a--;b+=8)c=c>>>8^C[(c^e[b])&255],c=c>>>8^C[(c^e[b+1])&255],c=c>>>8^C[(c^e[b+2])&255],c=c>>>8^C[(c^e[b+3])&255],c=c>>>8^C[(c^e[b+4])&255],c=c>>>8^C[(c^e[b+5])&255],c=c>>>8^C[(c^e[b+6])&255],c=c>>>8^C[(c^e[b+7])&255];return(c^4294967295)>>>0}
|
||||
var D=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,
|
||||
2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,
|
||||
@@ -6984,7 +6852,7 @@ module.exports = Tokenizer;
|
||||
"use strict";
|
||||
|
||||
var Tokenizer = require("./Tokenizer");
|
||||
-var DictionaryLoader = require("./loader/NodeDictionaryLoader");
|
||||
+var BrowserDictionaryLoader = require("./loader/BrowserDictionaryLoader");
|
||||
|
||||
/**
|
||||
* TokenizerBuilder create Tokenizer instance.
|
||||
@@ -7005,7 +6873,7 @@ function TokenizerBuilder(option) {
|
||||
* @param {TokenizerBuilder~onLoad} callback Callback function
|
||||
*/
|
||||
TokenizerBuilder.prototype.build = function (callback) {
|
||||
- var loader = new DictionaryLoader(this.dic_path);
|
||||
+ var loader = new BrowserDictionaryLoader(this.dic_path);
|
||||
loader.load(function (err, dic) {
|
||||
callback(err, new Tokenizer(dic));
|
||||
});
|
||||
@@ -7020,7 +6888,7 @@ TokenizerBuilder.prototype.build = function (callback) {
|
||||
|
||||
module.exports = TokenizerBuilder;
|
||||
|
||||
-},{"./Tokenizer":6,"./loader/NodeDictionaryLoader":19}],8:[function(require,module,exports){
|
||||
+},{"./Tokenizer":6,"./loader/BrowserDictionaryLoader":19}],8:[function(require,module,exports){
|
||||
/*
|
||||
* Copyright 2014 Takuya Asano
|
||||
* Copyright 2010-2014 Atilika Inc. and contributors
|
||||
@@ -8163,7 +8031,6 @@ module.exports = BrowserDictionaryLoader;
|
||||
|
||||
"use strict";
|
||||
|
||||
-var path = require("path");
|
||||
var async = require("async");
|
||||
var DynamicDictionaries = require("../dict/DynamicDictionaries");
|
||||
|
||||
@@ -8194,7 +8061,7 @@ DictionaryLoader.prototype.load = function (load_callback) {
|
||||
// Trie
|
||||
function (callback) {
|
||||
async.map([ "base.dat.gz", "check.dat.gz" ], function (filename, _callback) {
|
||||
- loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
|
||||
+ loadArrayBuffer(dic_path + filename, function (err, buffer) {
|
||||
if(err) {
|
||||
return _callback(err);
|
||||
}
|
||||
@@ -8214,7 +8081,7 @@ DictionaryLoader.prototype.load = function (load_callback) {
|
||||
// Token info dictionaries
|
||||
function (callback) {
|
||||
async.map([ "tid.dat.gz", "tid_pos.dat.gz", "tid_map.dat.gz" ], function (filename, _callback) {
|
||||
- loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
|
||||
+ loadArrayBuffer(dic_path + filename, function (err, buffer) {
|
||||
if(err) {
|
||||
return _callback(err);
|
||||
}
|
||||
@@ -8234,7 +8101,7 @@ DictionaryLoader.prototype.load = function (load_callback) {
|
||||
},
|
||||
// Connection cost matrix
|
||||
function (callback) {
|
||||
- loadArrayBuffer(path.join(dic_path, "cc.dat.gz"), function (err, buffer) {
|
||||
+ loadArrayBuffer(dic_path + "cc.dat.gz", function (err, buffer) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -8246,7 +8113,7 @@ DictionaryLoader.prototype.load = function (load_callback) {
|
||||
// Unknown dictionaries
|
||||
function (callback) {
|
||||
async.map([ "unk.dat.gz", "unk_pos.dat.gz", "unk_map.dat.gz", "unk_char.dat.gz", "unk_compat.dat.gz", "unk_invoke.dat.gz" ], function (filename, _callback) {
|
||||
- loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
|
||||
+ loadArrayBuffer(dic_path + filename, function (err, buffer) {
|
||||
if(err) {
|
||||
return _callback(err);
|
||||
}
|
||||
@@ -8282,7 +8149,7 @@ DictionaryLoader.prototype.load = function (load_callback) {
|
||||
|
||||
module.exports = DictionaryLoader;
|
||||
|
||||
-},{"../dict/DynamicDictionaries":11,"async":1,"path":3}],21:[function(require,module,exports){
|
||||
+},{"../dict/DynamicDictionaries":11,"async":1}],21:[function(require,module,exports){
|
||||
/*
|
||||
* Copyright 2014 Takuya Asano
|
||||
* Copyright 2010-2014 Atilika Inc. and contributors
|
||||
diff --git a/src/TokenizerBuilder.js b/src/TokenizerBuilder.js
|
||||
index 9ef5c6a2efc63e8b12735a8a9f1cb08d6c52c20c..98881e9fd731047c3fca848a71ede7e381e74f51 100644
|
||||
--- a/src/TokenizerBuilder.js
|
||||
+++ b/src/TokenizerBuilder.js
|
||||
@@ -18,7 +18,7 @@
|
||||
"use strict";
|
||||
|
||||
var Tokenizer = require("./Tokenizer");
|
||||
-var DictionaryLoader = require("./loader/NodeDictionaryLoader");
|
||||
+var BrowserDictionaryLoader = require("./loader/BrowserDictionaryLoader");
|
||||
|
||||
/**
|
||||
* TokenizerBuilder create Tokenizer instance.
|
||||
@@ -39,7 +39,7 @@ function TokenizerBuilder(option) {
|
||||
* @param {TokenizerBuilder~onLoad} callback Callback function
|
||||
*/
|
||||
TokenizerBuilder.prototype.build = function (callback) {
|
||||
- var loader = new DictionaryLoader(this.dic_path);
|
||||
+ var loader = new BrowserDictionaryLoader(this.dic_path);
|
||||
loader.load(function (err, dic) {
|
||||
callback(err, new Tokenizer(dic));
|
||||
});
|
||||
diff --git a/src/loader/DictionaryLoader.js b/src/loader/DictionaryLoader.js
|
||||
index 5f88c0b7f9a786dd8c072a7b84ae86a6f31412cb..3d6f8a67e16d251b3e4ba4dbbbc947679c364382 100644
|
||||
--- a/src/loader/DictionaryLoader.js
|
||||
+++ b/src/loader/DictionaryLoader.js
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
-var path = require("path");
|
||||
var async = require("async");
|
||||
var DynamicDictionaries = require("../dict/DynamicDictionaries");
|
||||
|
||||
@@ -48,7 +47,7 @@ DictionaryLoader.prototype.load = function (load_callback) {
|
||||
// Trie
|
||||
function (callback) {
|
||||
async.map([ "base.dat.gz", "check.dat.gz" ], function (filename, _callback) {
|
||||
- loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
|
||||
+ loadArrayBuffer(dic_path + filename, function (err, buffer) {
|
||||
if(err) {
|
||||
return _callback(err);
|
||||
}
|
||||
@@ -68,7 +67,7 @@ DictionaryLoader.prototype.load = function (load_callback) {
|
||||
// Token info dictionaries
|
||||
function (callback) {
|
||||
async.map([ "tid.dat.gz", "tid_pos.dat.gz", "tid_map.dat.gz" ], function (filename, _callback) {
|
||||
- loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
|
||||
+ loadArrayBuffer(dic_path + filename, function (err, buffer) {
|
||||
if(err) {
|
||||
return _callback(err);
|
||||
}
|
||||
@@ -88,7 +87,7 @@ DictionaryLoader.prototype.load = function (load_callback) {
|
||||
},
|
||||
// Connection cost matrix
|
||||
function (callback) {
|
||||
- loadArrayBuffer(path.join(dic_path, "cc.dat.gz"), function (err, buffer) {
|
||||
+ loadArrayBuffer(dic_path + "cc.dat.gz", function (err, buffer) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -100,7 +99,7 @@ DictionaryLoader.prototype.load = function (load_callback) {
|
||||
// Unknown dictionaries
|
||||
function (callback) {
|
||||
async.map([ "unk.dat.gz", "unk_pos.dat.gz", "unk_map.dat.gz", "unk_char.dat.gz", "unk_compat.dat.gz", "unk_invoke.dat.gz" ], function (filename, _callback) {
|
||||
- loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
|
||||
+ loadArrayBuffer(dic_path + filename, function (err, buffer) {
|
||||
if(err) {
|
||||
return _callback(err);
|
||||
}
|
||||
diff --git a/src/loader/NodeDictionaryLoader.js b/src/loader/NodeDictionaryLoader.js
|
||||
deleted file mode 100644
|
||||
index 26eb79249121efe39bd5ae77c17e1caa197fb4ce..0000000000000000000000000000000000000000
|
||||
Reference in New Issue
Block a user