(global["webpackJsonp"] = global["webpackJsonp"] || []).push([["common/vendor"],[
/* 0 */,
/* 1 */
/*!*********************************************************!*\
!*** ./node_modules/@dcloudio/uni-mp-weixin/dist/wx.js ***!
\*********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var objectKeys = ['qy', 'env', 'error', 'version', 'lanDebug', 'cloud', 'serviceMarket', 'router', 'worklet', '__webpack_require_UNI_MP_PLUGIN__'];
var singlePageDisableKey = ['lanDebug', 'router', 'worklet'];
var target = typeof globalThis !== 'undefined' ? globalThis : function () {
return this;
}();
var key = ['w', 'x'].join('');
var oldWx = target[key];
var launchOption = oldWx.getLaunchOptionsSync ? oldWx.getLaunchOptionsSync() : null;
function isWxKey(key) {
if (launchOption && launchOption.scene === 1154 && singlePageDisableKey.includes(key)) {
return false;
}
return objectKeys.indexOf(key) > -1 || typeof oldWx[key] === 'function';
}
function initWx() {
var newWx = {};
for (var _key in oldWx) {
if (isWxKey(_key)) {
// TODO wrapper function
newWx[_key] = oldWx[_key];
}
}
return newWx;
}
target[key] = initWx();
var _default = target[key];
exports.default = _default;
/***/ }),
/* 2 */
/*!************************************************************!*\
!*** ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(wx, global) {
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createApp = createApp;
exports.createComponent = createComponent;
exports.createPage = createPage;
exports.createPlugin = createPlugin;
exports.createSubpackageApp = createSubpackageApp;
exports.default = void 0;
var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ 5));
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
var _construct2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/construct */ 15));
var _toConsumableArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ 18));
var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ 13));
var _uniI18n = __webpack_require__(/*! @dcloudio/uni-i18n */ 22);
var _vue = _interopRequireDefault(__webpack_require__(/*! vue */ 25));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var realAtob;
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
if (typeof atob !== 'function') {
realAtob = function realAtob(str) {
str = String(str).replace(/[\t\n\f\r ]+/g, '');
if (!b64re.test(str)) {
throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
}
// Adding the padding if missing, for semplicity
str += '=='.slice(2 - (str.length & 3));
var bitmap;
var result = '';
var r1;
var r2;
var i = 0;
for (; i < str.length;) {
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 | (r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
}
return result;
};
} else {
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob = atob;
}
function b64DecodeUnicode(str) {
return decodeURIComponent(realAtob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
function getCurrentUserInfo() {
var token = wx.getStorageSync('uni_id_token') || '';
var tokenArr = token.split('.');
if (!token || tokenArr.length !== 3) {
return {
uid: null,
role: [],
permission: [],
tokenExpired: 0
};
}
var userInfo;
try {
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
} catch (error) {
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message);
}
userInfo.tokenExpired = userInfo.exp * 1000;
delete userInfo.exp;
delete userInfo.iat;
return userInfo;
}
function uniIdMixin(Vue) {
Vue.prototype.uniIDHasRole = function (roleId) {
var _getCurrentUserInfo = getCurrentUserInfo(),
role = _getCurrentUserInfo.role;
return role.indexOf(roleId) > -1;
};
Vue.prototype.uniIDHasPermission = function (permissionId) {
var _getCurrentUserInfo2 = getCurrentUserInfo(),
permission = _getCurrentUserInfo2.permission;
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1;
};
Vue.prototype.uniIDTokenValid = function () {
var _getCurrentUserInfo3 = getCurrentUserInfo(),
tokenExpired = _getCurrentUserInfo3.tokenExpired;
return tokenExpired > Date.now();
};
}
var _toString = Object.prototype.toString;
var hasOwnProperty = Object.prototype.hasOwnProperty;
function isFn(fn) {
return typeof fn === 'function';
}
function isStr(str) {
return typeof str === 'string';
}
function isObject(obj) {
return obj !== null && (0, _typeof2.default)(obj) === 'object';
}
function isPlainObject(obj) {
return _toString.call(obj) === '[object Object]';
}
function hasOwn(obj, key) {
return hasOwnProperty.call(obj, key);
}
function noop() {}
/**
* Create a cached version of a pure function.
*/
function cached(fn) {
var cache = Object.create(null);
return function cachedFn(str) {
var hit = cache[str];
return hit || (cache[str] = fn(str));
};
}
/**
* Camelize a hyphen-delimited string.
*/
var camelizeRE = /-(\w)/g;
var camelize = cached(function (str) {
return str.replace(camelizeRE, function (_, c) {
return c ? c.toUpperCase() : '';
});
});
function sortObject(obj) {
var sortObj = {};
if (isPlainObject(obj)) {
Object.keys(obj).sort().forEach(function (key) {
sortObj[key] = obj[key];
});
}
return !Object.keys(sortObj) ? obj : sortObj;
}
var HOOKS = ['invoke', 'success', 'fail', 'complete', 'returnValue'];
var globalInterceptors = {};
var scopedInterceptors = {};
function mergeHook(parentVal, childVal) {
var res = childVal ? parentVal ? parentVal.concat(childVal) : Array.isArray(childVal) ? childVal : [childVal] : parentVal;
return res ? dedupeHooks(res) : res;
}
function dedupeHooks(hooks) {
var res = [];
for (var i = 0; i < hooks.length; i++) {
if (res.indexOf(hooks[i]) === -1) {
res.push(hooks[i]);
}
}
return res;
}
function removeHook(hooks, hook) {
var index = hooks.indexOf(hook);
if (index !== -1) {
hooks.splice(index, 1);
}
}
function mergeInterceptorHook(interceptor, option) {
Object.keys(option).forEach(function (hook) {
if (HOOKS.indexOf(hook) !== -1 && isFn(option[hook])) {
interceptor[hook] = mergeHook(interceptor[hook], option[hook]);
}
});
}
function removeInterceptorHook(interceptor, option) {
if (!interceptor || !option) {
return;
}
Object.keys(option).forEach(function (hook) {
if (HOOKS.indexOf(hook) !== -1 && isFn(option[hook])) {
removeHook(interceptor[hook], option[hook]);
}
});
}
function addInterceptor(method, option) {
if (typeof method === 'string' && isPlainObject(option)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), option);
} else if (isPlainObject(method)) {
mergeInterceptorHook(globalInterceptors, method);
}
}
function removeInterceptor(method, option) {
if (typeof method === 'string') {
if (isPlainObject(option)) {
removeInterceptorHook(scopedInterceptors[method], option);
} else {
delete scopedInterceptors[method];
}
} else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}
function wrapperHook(hook, params) {
return function (data) {
return hook(data, params) || data;
};
}
function isPromise(obj) {
return !!obj && ((0, _typeof2.default)(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
}
function queue(hooks, data, params) {
var promise = false;
for (var i = 0; i < hooks.length; i++) {
var hook = hooks[i];
if (promise) {
promise = Promise.resolve(wrapperHook(hook, params));
} else {
var res = hook(data, params);
if (isPromise(res)) {
promise = Promise.resolve(res);
}
if (res === false) {
return {
then: function then() {}
};
}
}
}
return promise || {
then: function then(callback) {
return callback(data);
}
};
}
function wrapperOptions(interceptor) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
['success', 'fail', 'complete'].forEach(function (name) {
if (Array.isArray(interceptor[name])) {
var oldCallback = options[name];
options[name] = function callbackInterceptor(res) {
queue(interceptor[name], res, options).then(function (res) {
/* eslint-disable no-mixed-operators */
return isFn(oldCallback) && oldCallback(res) || res;
});
};
}
});
return options;
}
function wrapperReturnValue(method, returnValue) {
var returnValueHooks = [];
if (Array.isArray(globalInterceptors.returnValue)) {
returnValueHooks.push.apply(returnValueHooks, (0, _toConsumableArray2.default)(globalInterceptors.returnValue));
}
var interceptor = scopedInterceptors[method];
if (interceptor && Array.isArray(interceptor.returnValue)) {
returnValueHooks.push.apply(returnValueHooks, (0, _toConsumableArray2.default)(interceptor.returnValue));
}
returnValueHooks.forEach(function (hook) {
returnValue = hook(returnValue) || returnValue;
});
return returnValue;
}
function getApiInterceptorHooks(method) {
var interceptor = Object.create(null);
Object.keys(globalInterceptors).forEach(function (hook) {
if (hook !== 'returnValue') {
interceptor[hook] = globalInterceptors[hook].slice();
}
});
var scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(function (hook) {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
});
}
return interceptor;
}
function invokeApi(method, api, options) {
for (var _len = arguments.length, params = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
params[_key - 3] = arguments[_key];
}
var interceptor = getApiInterceptorHooks(method);
if (interceptor && Object.keys(interceptor).length) {
if (Array.isArray(interceptor.invoke)) {
var res = queue(interceptor.invoke, options);
return res.then(function (options) {
// 重新访问 getApiInterceptorHooks, 允许 invoke 中再次调用 addInterceptor,removeInterceptor
return api.apply(void 0, [wrapperOptions(getApiInterceptorHooks(method), options)].concat(params));
});
} else {
return api.apply(void 0, [wrapperOptions(interceptor, options)].concat(params));
}
}
return api.apply(void 0, [options].concat(params));
}
var promiseInterceptor = {
returnValue: function returnValue(res) {
if (!isPromise(res)) {
return res;
}
return new Promise(function (resolve, reject) {
res.then(function (res) {
if (res[0]) {
reject(res[0]);
} else {
resolve(res[1]);
}
});
});
}
};
var SYNC_API_RE = /^\$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting|initUTS|requireUTS|registerUTS/;
var CONTEXT_API_RE = /^create|Manager$/;
// Context例外情况
var CONTEXT_API_RE_EXC = ['createBLEConnection'];
// 同步例外情况
var ASYNC_API = ['createBLEConnection', 'createPushMessage'];
var CALLBACK_API_RE = /^on|^off/;
function isContextApi(name) {
return CONTEXT_API_RE.test(name) && CONTEXT_API_RE_EXC.indexOf(name) === -1;
}
function isSyncApi(name) {
return SYNC_API_RE.test(name) && ASYNC_API.indexOf(name) === -1;
}
function isCallbackApi(name) {
return CALLBACK_API_RE.test(name) && name !== 'onPush';
}
function handlePromise(promise) {
return promise.then(function (data) {
return [null, data];
}).catch(function (err) {
return [err];
});
}
function shouldPromise(name) {
if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
return false;
}
return true;
}
/* eslint-disable no-extend-native */
if (!Promise.prototype.finally) {
Promise.prototype.finally = function (callback) {
var promise = this.constructor;
return this.then(function (value) {
return promise.resolve(callback()).then(function () {
return value;
});
}, function (reason) {
return promise.resolve(callback()).then(function () {
throw reason;
});
});
};
}
function promisify(name, api) {
if (!shouldPromise(name) || !isFn(api)) {
return api;
}
return function promiseApi() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
params[_key2 - 1] = arguments[_key2];
}
if (isFn(options.success) || isFn(options.fail) || isFn(options.complete)) {
return wrapperReturnValue(name, invokeApi.apply(void 0, [name, api, options].concat(params)));
}
return wrapperReturnValue(name, handlePromise(new Promise(function (resolve, reject) {
invokeApi.apply(void 0, [name, api, Object.assign({}, options, {
success: resolve,
fail: reject
})].concat(params));
})));
};
}
var EPS = 1e-4;
var BASE_DEVICE_WIDTH = 750;
var isIOS = false;
var deviceWidth = 0;
var deviceDPR = 0;
function checkDeviceWidth() {
var _wx$getSystemInfoSync = wx.getSystemInfoSync(),
platform = _wx$getSystemInfoSync.platform,
pixelRatio = _wx$getSystemInfoSync.pixelRatio,
windowWidth = _wx$getSystemInfoSync.windowWidth; // uni=>wx runtime 编译目标是 uni 对象,内部不允许直接使用 uni
deviceWidth = windowWidth;
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px(number, newDeviceWidth) {
if (deviceWidth === 0) {
checkDeviceWidth();
}
number = Number(number);
if (number === 0) {
return 0;
}
var result = number / BASE_DEVICE_WIDTH * (newDeviceWidth || deviceWidth);
if (result < 0) {
result = -result;
}
result = Math.floor(result + EPS);
if (result === 0) {
if (deviceDPR === 1 || !isIOS) {
result = 1;
} else {
result = 0.5;
}
}
return number < 0 ? -result : result;
}
var LOCALE_ZH_HANS = 'zh-Hans';
var LOCALE_ZH_HANT = 'zh-Hant';
var LOCALE_EN = 'en';
var LOCALE_FR = 'fr';
var LOCALE_ES = 'es';
var messages = {};
var locale;
{
locale = normalizeLocale(wx.getSystemInfoSync().language) || LOCALE_EN;
}
function initI18nMessages() {
if (!isEnableLocale()) {
return;
}
var localeKeys = Object.keys(__uniConfig.locales);
if (localeKeys.length) {
localeKeys.forEach(function (locale) {
var curMessages = messages[locale];
var userMessages = __uniConfig.locales[locale];
if (curMessages) {
Object.assign(curMessages, userMessages);
} else {
messages[locale] = userMessages;
}
});
}
}
initI18nMessages();
var i18n = (0, _uniI18n.initVueI18n)(locale, {});
var t = i18n.t;
var i18nMixin = i18n.mixin = {
beforeCreate: function beforeCreate() {
var _this = this;
var unwatch = i18n.i18n.watchLocale(function () {
_this.$forceUpdate();
});
this.$once('hook:beforeDestroy', function () {
unwatch();
});
},
methods: {
$$t: function $$t(key, values) {
return t(key, values);
}
}
};
var setLocale = i18n.setLocale;
var getLocale = i18n.getLocale;
function initAppLocale(Vue, appVm, locale) {
var state = Vue.observable({
locale: locale || i18n.getLocale()
});
var localeWatchers = [];
appVm.$watchLocale = function (fn) {
localeWatchers.push(fn);
};
Object.defineProperty(appVm, '$locale', {
get: function get() {
return state.locale;
},
set: function set(v) {
state.locale = v;
localeWatchers.forEach(function (watch) {
return watch(v);
});
}
});
}
function isEnableLocale() {
return typeof __uniConfig !== 'undefined' && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length;
}
function include(str, parts) {
return !!parts.find(function (part) {
return str.indexOf(part) !== -1;
});
}
function startsWith(str, parts) {
return parts.find(function (part) {
return str.indexOf(part) === 0;
});
}
function normalizeLocale(locale, messages) {
if (!locale) {
return;
}
locale = locale.trim().replace(/_/g, '-');
if (messages && messages[locale]) {
return locale;
}
locale = locale.toLowerCase();
if (locale === 'chinese') {
// 支付宝
return LOCALE_ZH_HANS;
}
if (locale.indexOf('zh') === 0) {
if (locale.indexOf('-hans') > -1) {
return LOCALE_ZH_HANS;
}
if (locale.indexOf('-hant') > -1) {
return LOCALE_ZH_HANT;
}
if (include(locale, ['-tw', '-hk', '-mo', '-cht'])) {
return LOCALE_ZH_HANT;
}
return LOCALE_ZH_HANS;
}
var lang = startsWith(locale, [LOCALE_EN, LOCALE_FR, LOCALE_ES]);
if (lang) {
return lang;
}
}
// export function initI18n() {
// const localeKeys = Object.keys(__uniConfig.locales || {})
// if (localeKeys.length) {
// localeKeys.forEach((locale) =>
// i18n.add(locale, __uniConfig.locales[locale])
// )
// }
// }
function getLocale$1() {
// 优先使用 $locale
if (isFn(getApp)) {
var app = getApp({
allowDefault: true
});
if (app && app.$vm) {
return app.$vm.$locale;
}
}
return normalizeLocale(wx.getSystemInfoSync().language) || LOCALE_EN;
}
function setLocale$1(locale) {
var app = isFn(getApp) ? getApp() : false;
if (!app) {
return false;
}
var oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
app.$vm.$locale = locale;
onLocaleChangeCallbacks.forEach(function (fn) {
return fn({
locale: locale
});
});
return true;
}
return false;
}
var onLocaleChangeCallbacks = [];
function onLocaleChange(fn) {
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
onLocaleChangeCallbacks.push(fn);
}
}
if (typeof global !== 'undefined') {
global.getLocale = getLocale$1;
}
var interceptors = {
promiseInterceptor: promiseInterceptor
};
var baseApi = /*#__PURE__*/Object.freeze({
__proto__: null,
upx2px: upx2px,
getLocale: getLocale$1,
setLocale: setLocale$1,
onLocaleChange: onLocaleChange,
addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor,
interceptors: interceptors
});
function findExistsPageIndex(url) {
var pages = getCurrentPages();
var len = pages.length;
while (len--) {
var page = pages[len];
if (page.$page && page.$page.fullPath === url) {
return len;
}
}
return -1;
}
var redirectTo = {
name: function name(fromArgs) {
if (fromArgs.exists === 'back' && fromArgs.delta) {
return 'navigateBack';
}
return 'redirectTo';
},
args: function args(fromArgs) {
if (fromArgs.exists === 'back' && fromArgs.url) {
var existsPageIndex = findExistsPageIndex(fromArgs.url);
if (existsPageIndex !== -1) {
var delta = getCurrentPages().length - 1 - existsPageIndex;
if (delta > 0) {
fromArgs.delta = delta;
}
}
}
}
};
var previewImage = {
args: function args(fromArgs) {
var currentIndex = parseInt(fromArgs.current);
if (isNaN(currentIndex)) {
return;
}
var urls = fromArgs.urls;
if (!Array.isArray(urls)) {
return;
}
var len = urls.length;
if (!len) {
return;
}
if (currentIndex < 0) {
currentIndex = 0;
} else if (currentIndex >= len) {
currentIndex = len - 1;
}
if (currentIndex > 0) {
fromArgs.current = urls[currentIndex];
fromArgs.urls = urls.filter(function (item, index) {
return index < currentIndex ? item !== urls[currentIndex] : true;
});
} else {
fromArgs.current = urls[0];
}
return {
indicator: false,
loop: false
};
}
};
var UUID_KEY = '__DC_STAT_UUID';
var deviceId;
function useDeviceId(result) {
deviceId = deviceId || wx.getStorageSync(UUID_KEY);
if (!deviceId) {
deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7);
wx.setStorage({
key: UUID_KEY,
data: deviceId
});
}
result.deviceId = deviceId;
}
function addSafeAreaInsets(result) {
if (result.safeArea) {
var safeArea = result.safeArea;
result.safeAreaInsets = {
top: safeArea.top,
left: safeArea.left,
right: result.windowWidth - safeArea.right,
bottom: result.screenHeight - safeArea.bottom
};
}
}
function populateParameters(result) {
var _result$brand = result.brand,
brand = _result$brand === void 0 ? '' : _result$brand,
_result$model = result.model,
model = _result$model === void 0 ? '' : _result$model,
_result$system = result.system,
system = _result$system === void 0 ? '' : _result$system,
_result$language = result.language,
language = _result$language === void 0 ? '' : _result$language,
theme = result.theme,
version = result.version,
platform = result.platform,
fontSizeSetting = result.fontSizeSetting,
SDKVersion = result.SDKVersion,
pixelRatio = result.pixelRatio,
deviceOrientation = result.deviceOrientation;
// const isQuickApp = "mp-weixin".indexOf('quickapp-webview') !== -1
var extraParam = {};
// osName osVersion
var osName = '';
var osVersion = '';
{
osName = system.split(' ')[0] || '';
osVersion = system.split(' ')[1] || '';
}
var hostVersion = version;
// deviceType
var deviceType = getGetDeviceType(result, model);
// deviceModel
var deviceBrand = getDeviceBrand(brand);
// hostName
var _hostName = getHostName(result);
// deviceOrientation
var _deviceOrientation = deviceOrientation; // 仅 微信 百度 支持
// devicePixelRatio
var _devicePixelRatio = pixelRatio;
// SDKVersion
var _SDKVersion = SDKVersion;
// hostLanguage
var hostLanguage = language.replace(/_/g, '-');
// wx.getAccountInfoSync
var parameters = {
appId: "__UNI__9BF1085",
appName: "daoyou",
appVersion: "1.0.0",
appVersionCode: "100",
appLanguage: getAppLanguage(hostLanguage),
uniCompileVersion: "4.15",
uniRuntimeVersion: "4.15",
uniPlatform: undefined || "mp-weixin",
deviceBrand: deviceBrand,
deviceModel: model,
deviceType: deviceType,
devicePixelRatio: _devicePixelRatio,
deviceOrientation: _deviceOrientation,
osName: osName.toLocaleLowerCase(),
osVersion: osVersion,
hostTheme: theme,
hostVersion: hostVersion,
hostLanguage: hostLanguage,
hostName: _hostName,
hostSDKVersion: _SDKVersion,
hostFontSizeSetting: fontSizeSetting,
windowTop: 0,
windowBottom: 0,
// TODO
osLanguage: undefined,
osTheme: undefined,
ua: undefined,
hostPackageName: undefined,
browserName: undefined,
browserVersion: undefined
};
Object.assign(result, parameters, extraParam);
}
function getGetDeviceType(result, model) {
var deviceType = result.deviceType || 'phone';
{
var deviceTypeMaps = {
ipad: 'pad',
windows: 'pc',
mac: 'pc'
};
var deviceTypeMapsKeys = Object.keys(deviceTypeMaps);
var _model = model.toLocaleLowerCase();
for (var index = 0; index < deviceTypeMapsKeys.length; index++) {
var _m = deviceTypeMapsKeys[index];
if (_model.indexOf(_m) !== -1) {
deviceType = deviceTypeMaps[_m];
break;
}
}
}
return deviceType;
}
function getDeviceBrand(brand) {
var deviceBrand = brand;
if (deviceBrand) {
deviceBrand = brand.toLocaleLowerCase();
}
return deviceBrand;
}
function getAppLanguage(defaultLanguage) {
return getLocale$1 ? getLocale$1() : defaultLanguage;
}
function getHostName(result) {
var _platform = 'WeChat';
var _hostName = result.hostName || _platform; // mp-jd
{
if (result.environment) {
_hostName = result.environment;
} else if (result.host && result.host.env) {
_hostName = result.host.env;
}
}
return _hostName;
}
var getSystemInfo = {
returnValue: function returnValue(result) {
useDeviceId(result);
addSafeAreaInsets(result);
populateParameters(result);
}
};
var showActionSheet = {
args: function args(fromArgs) {
if ((0, _typeof2.default)(fromArgs) === 'object') {
fromArgs.alertText = fromArgs.title;
}
}
};
var getAppBaseInfo = {
returnValue: function returnValue(result) {
var _result = result,
version = _result.version,
language = _result.language,
SDKVersion = _result.SDKVersion,
theme = _result.theme;
var _hostName = getHostName(result);
var hostLanguage = language.replace('_', '-');
result = sortObject(Object.assign(result, {
appId: "__UNI__9BF1085",
appName: "daoyou",
appVersion: "1.0.0",
appVersionCode: "100",
appLanguage: getAppLanguage(hostLanguage),
hostVersion: version,
hostLanguage: hostLanguage,
hostName: _hostName,
hostSDKVersion: SDKVersion,
hostTheme: theme
}));
}
};
var getDeviceInfo = {
returnValue: function returnValue(result) {
var _result2 = result,
brand = _result2.brand,
model = _result2.model;
var deviceType = getGetDeviceType(result, model);
var deviceBrand = getDeviceBrand(brand);
useDeviceId(result);
result = sortObject(Object.assign(result, {
deviceType: deviceType,
deviceBrand: deviceBrand,
deviceModel: model
}));
}
};
var getWindowInfo = {
returnValue: function returnValue(result) {
addSafeAreaInsets(result);
result = sortObject(Object.assign(result, {
windowTop: 0,
windowBottom: 0
}));
}
};
var getAppAuthorizeSetting = {
returnValue: function returnValue(result) {
var locationReducedAccuracy = result.locationReducedAccuracy;
result.locationAccuracy = 'unsupported';
if (locationReducedAccuracy === true) {
result.locationAccuracy = 'reduced';
} else if (locationReducedAccuracy === false) {
result.locationAccuracy = 'full';
}
}
};
// import navigateTo from 'uni-helpers/navigate-to'
var compressImage = {
args: function args(fromArgs) {
// https://developers.weixin.qq.com/community/develop/doc/000c08940c865011298e0a43256800?highLine=compressHeight
if (fromArgs.compressedHeight && !fromArgs.compressHeight) {
fromArgs.compressHeight = fromArgs.compressedHeight;
}
if (fromArgs.compressedWidth && !fromArgs.compressWidth) {
fromArgs.compressWidth = fromArgs.compressedWidth;
}
}
};
var protocols = {
redirectTo: redirectTo,
// navigateTo, // 由于在微信开发者工具的页面参数,会显示__id__参数,因此暂时关闭mp-weixin对于navigateTo的AOP
previewImage: previewImage,
getSystemInfo: getSystemInfo,
getSystemInfoSync: getSystemInfo,
showActionSheet: showActionSheet,
getAppBaseInfo: getAppBaseInfo,
getDeviceInfo: getDeviceInfo,
getWindowInfo: getWindowInfo,
getAppAuthorizeSetting: getAppAuthorizeSetting,
compressImage: compressImage
};
var todos = ['vibrate', 'preloadPage', 'unPreloadPage', 'loadSubPackage'];
var canIUses = [];
var CALLBACKS = ['success', 'fail', 'cancel', 'complete'];
function processCallback(methodName, method, returnValue) {
return function (res) {
return method(processReturnValue(methodName, res, returnValue));
};
}
function processArgs(methodName, fromArgs) {
var argsOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var returnValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var keepFromArgs = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
if (isPlainObject(fromArgs)) {
// 一般 api 的参数解析
var toArgs = keepFromArgs === true ? fromArgs : {}; // returnValue 为 false 时,说明是格式化返回值,直接在返回值对象上修改赋值
if (isFn(argsOption)) {
argsOption = argsOption(fromArgs, toArgs) || {};
}
for (var key in fromArgs) {
if (hasOwn(argsOption, key)) {
var keyOption = argsOption[key];
if (isFn(keyOption)) {
keyOption = keyOption(fromArgs[key], fromArgs, toArgs);
}
if (!keyOption) {
// 不支持的参数
console.warn("The '".concat(methodName, "' method of platform '\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F' does not support option '").concat(key, "'"));
} else if (isStr(keyOption)) {
// 重写参数 key
toArgs[keyOption] = fromArgs[key];
} else if (isPlainObject(keyOption)) {
// {name:newName,value:value}可重新指定参数 key:value
toArgs[keyOption.name ? keyOption.name : key] = keyOption.value;
}
} else if (CALLBACKS.indexOf(key) !== -1) {
if (isFn(fromArgs[key])) {
toArgs[key] = processCallback(methodName, fromArgs[key], returnValue);
}
} else {
if (!keepFromArgs) {
toArgs[key] = fromArgs[key];
}
}
}
return toArgs;
} else if (isFn(fromArgs)) {
fromArgs = processCallback(methodName, fromArgs, returnValue);
}
return fromArgs;
}
function processReturnValue(methodName, res, returnValue) {
var keepReturnValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
if (isFn(protocols.returnValue)) {
// 处理通用 returnValue
res = protocols.returnValue(methodName, res);
}
return processArgs(methodName, res, returnValue, {}, keepReturnValue);
}
function wrapper(methodName, method) {
if (hasOwn(protocols, methodName)) {
var protocol = protocols[methodName];
if (!protocol) {
// 暂不支持的 api
return function () {
console.error("Platform '\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F' does not support '".concat(methodName, "'."));
};
}
return function (arg1, arg2) {
// 目前 api 最多两个参数
var options = protocol;
if (isFn(protocol)) {
options = protocol(arg1);
}
arg1 = processArgs(methodName, arg1, options.args, options.returnValue);
var args = [arg1];
if (typeof arg2 !== 'undefined') {
args.push(arg2);
}
if (isFn(options.name)) {
methodName = options.name(arg1);
} else if (isStr(options.name)) {
methodName = options.name;
}
var returnValue = wx[methodName].apply(wx, args);
if (isSyncApi(methodName)) {
// 同步 api
return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName));
}
return returnValue;
};
}
return method;
}
var todoApis = Object.create(null);
var TODOS = ['onTabBarMidButtonTap', 'subscribePush', 'unsubscribePush', 'onPush', 'offPush', 'share'];
function createTodoApi(name) {
return function todoApi(_ref) {
var fail = _ref.fail,
complete = _ref.complete;
var res = {
errMsg: "".concat(name, ":fail method '").concat(name, "' not supported")
};
isFn(fail) && fail(res);
isFn(complete) && complete(res);
};
}
TODOS.forEach(function (name) {
todoApis[name] = createTodoApi(name);
});
var providers = {
oauth: ['weixin'],
share: ['weixin'],
payment: ['wxpay'],
push: ['weixin']
};
function getProvider(_ref2) {
var service = _ref2.service,
success = _ref2.success,
fail = _ref2.fail,
complete = _ref2.complete;
var res = false;
if (providers[service]) {
res = {
errMsg: 'getProvider:ok',
service: service,
provider: providers[service]
};
isFn(success) && success(res);
} else {
res = {
errMsg: 'getProvider:fail service not found'
};
isFn(fail) && fail(res);
}
isFn(complete) && complete(res);
}
var extraApi = /*#__PURE__*/Object.freeze({
__proto__: null,
getProvider: getProvider
});
var getEmitter = function () {
var Emitter;
return function getUniEmitter() {
if (!Emitter) {
Emitter = new _vue.default();
}
return Emitter;
};
}();
function apply(ctx, method, args) {
return ctx[method].apply(ctx, args);
}
function $on() {
return apply(getEmitter(), '$on', Array.prototype.slice.call(arguments));
}
function $off() {
return apply(getEmitter(), '$off', Array.prototype.slice.call(arguments));
}
function $once() {
return apply(getEmitter(), '$once', Array.prototype.slice.call(arguments));
}
function $emit() {
return apply(getEmitter(), '$emit', Array.prototype.slice.call(arguments));
}
var eventApi = /*#__PURE__*/Object.freeze({
__proto__: null,
$on: $on,
$off: $off,
$once: $once,
$emit: $emit
});
/**
* 框架内 try-catch
*/
/**
* 开发者 try-catch
*/
function tryCatch(fn) {
return function () {
try {
return fn.apply(fn, arguments);
} catch (e) {
// TODO
console.error(e);
}
};
}
function getApiCallbacks(params) {
var apiCallbacks = {};
for (var name in params) {
var param = params[name];
if (isFn(param)) {
apiCallbacks[name] = tryCatch(param);
delete params[name];
}
}
return apiCallbacks;
}
var cid;
var cidErrMsg;
var enabled;
function normalizePushMessage(message) {
try {
return JSON.parse(message);
} catch (e) {}
return message;
}
function invokePushCallback(args) {
if (args.type === 'enabled') {
enabled = true;
} else if (args.type === 'clientId') {
cid = args.cid;
cidErrMsg = args.errMsg;
invokeGetPushCidCallbacks(cid, args.errMsg);
} else if (args.type === 'pushMsg') {
var message = {
type: 'receive',
data: normalizePushMessage(args.message)
};
for (var i = 0; i < onPushMessageCallbacks.length; i++) {
var callback = onPushMessageCallbacks[i];
callback(message);
// 该消息已被阻止
if (message.stopped) {
break;
}
}
} else if (args.type === 'click') {
onPushMessageCallbacks.forEach(function (callback) {
callback({
type: 'click',
data: normalizePushMessage(args.message)
});
});
}
}
var getPushCidCallbacks = [];
function invokeGetPushCidCallbacks(cid, errMsg) {
getPushCidCallbacks.forEach(function (callback) {
callback(cid, errMsg);
});
getPushCidCallbacks.length = 0;
}
function getPushClientId(args) {
if (!isPlainObject(args)) {
args = {};
}
var _getApiCallbacks = getApiCallbacks(args),
success = _getApiCallbacks.success,
fail = _getApiCallbacks.fail,
complete = _getApiCallbacks.complete;
var hasSuccess = isFn(success);
var hasFail = isFn(fail);
var hasComplete = isFn(complete);
Promise.resolve().then(function () {
if (typeof enabled === 'undefined') {
enabled = false;
cid = '';
cidErrMsg = 'uniPush is not enabled';
}
getPushCidCallbacks.push(function (cid, errMsg) {
var res;
if (cid) {
res = {
errMsg: 'getPushClientId:ok',
cid: cid
};
hasSuccess && success(res);
} else {
res = {
errMsg: 'getPushClientId:fail' + (errMsg ? ' ' + errMsg : '')
};
hasFail && fail(res);
}
hasComplete && complete(res);
});
if (typeof cid !== 'undefined') {
invokeGetPushCidCallbacks(cid, cidErrMsg);
}
});
}
var onPushMessageCallbacks = [];
// 不使用 defineOnApi 实现,是因为 defineOnApi 依赖 UniServiceJSBridge ,该对象目前在小程序上未提供,故简单实现
var onPushMessage = function onPushMessage(fn) {
if (onPushMessageCallbacks.indexOf(fn) === -1) {
onPushMessageCallbacks.push(fn);
}
};
var offPushMessage = function offPushMessage(fn) {
if (!fn) {
onPushMessageCallbacks.length = 0;
} else {
var index = onPushMessageCallbacks.indexOf(fn);
if (index > -1) {
onPushMessageCallbacks.splice(index, 1);
}
}
};
var baseInfo = wx.getAppBaseInfo && wx.getAppBaseInfo();
if (!baseInfo) {
baseInfo = wx.getSystemInfoSync();
}
var host = baseInfo ? baseInfo.host : null;
var shareVideoMessage = host && host.env === 'SAAASDK' ? wx.miniapp.shareVideoMessage : wx.shareVideoMessage;
var api = /*#__PURE__*/Object.freeze({
__proto__: null,
shareVideoMessage: shareVideoMessage,
getPushClientId: getPushClientId,
onPushMessage: onPushMessage,
offPushMessage: offPushMessage,
invokePushCallback: invokePushCallback
});
var mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__'];
function findVmByVueId(vm, vuePid) {
var $children = vm.$children;
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for (var i = $children.length - 1; i >= 0; i--) {
var childVm = $children[i];
if (childVm.$scope._$vueId === vuePid) {
return childVm;
}
}
// 反向递归查找
var parentVm;
for (var _i = $children.length - 1; _i >= 0; _i--) {
parentVm = findVmByVueId($children[_i], vuePid);
if (parentVm) {
return parentVm;
}
}
}
function initBehavior(options) {
return Behavior(options);
}
function isPage() {
return !!this.route;
}
function initRelation(detail) {
this.triggerEvent('__l', detail);
}
function selectAllComponents(mpInstance, selector, $refs) {
var components = mpInstance.selectAllComponents(selector) || [];
components.forEach(function (component) {
var ref = component.dataset.ref;
$refs[ref] = component.$vm || toSkip(component);
{
if (component.dataset.vueGeneric === 'scoped') {
component.selectAllComponents('.scoped-ref').forEach(function (scopedComponent) {
selectAllComponents(scopedComponent, selector, $refs);
});
}
}
});
}
function syncRefs(refs, newRefs) {
var oldKeys = (0, _construct2.default)(Set, (0, _toConsumableArray2.default)(Object.keys(refs)));
var newKeys = Object.keys(newRefs);
newKeys.forEach(function (key) {
var oldValue = refs[key];
var newValue = newRefs[key];
if (Array.isArray(oldValue) && Array.isArray(newValue) && oldValue.length === newValue.length && newValue.every(function (value) {
return oldValue.includes(value);
})) {
return;
}
refs[key] = newValue;
oldKeys.delete(key);
});
oldKeys.forEach(function (key) {
delete refs[key];
});
return refs;
}
function initRefs(vm) {
var mpInstance = vm.$scope;
var refs = {};
Object.defineProperty(vm, '$refs', {
get: function get() {
var $refs = {};
selectAllComponents(mpInstance, '.vue-ref', $refs);
// TODO 暂不考虑 for 中的 scoped
var forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') || [];
forComponents.forEach(function (component) {
var ref = component.dataset.ref;
if (!$refs[ref]) {
$refs[ref] = [];
}
$refs[ref].push(component.$vm || toSkip(component));
});
return syncRefs(refs, $refs);
}
});
}
function handleLink(event) {
var _ref3 = event.detail || event.value,
vuePid = _ref3.vuePid,
vueOptions = _ref3.vueOptions; // detail 是微信,value 是百度(dipatch)
var parentVm;
if (vuePid) {
parentVm = findVmByVueId(this.$vm, vuePid);
}
if (!parentVm) {
parentVm = this.$vm;
}
vueOptions.parent = parentVm;
}
function markMPComponent(component) {
// 在 Vue 中标记为小程序组件
var IS_MP = '__v_isMPComponent';
Object.defineProperty(component, IS_MP, {
configurable: true,
enumerable: false,
value: true
});
return component;
}
function toSkip(obj) {
var OB = '__ob__';
var SKIP = '__v_skip';
if (isObject(obj) && Object.isExtensible(obj)) {
// 避免被 @vue/composition-api 观测
Object.defineProperty(obj, OB, {
configurable: true,
enumerable: false,
value: (0, _defineProperty2.default)({}, SKIP, true)
});
}
return obj;
}
var WORKLET_RE = /_(.*)_worklet_factory_/;
function initWorkletMethods(mpMethods, vueMethods) {
if (vueMethods) {
Object.keys(vueMethods).forEach(function (name) {
var matches = name.match(WORKLET_RE);
if (matches) {
var workletName = matches[1];
mpMethods[name] = vueMethods[name];
mpMethods[workletName] = vueMethods[workletName];
}
});
}
}
var MPPage = Page;
var MPComponent = Component;
var customizeRE = /:/g;
var customize = cached(function (str) {
return camelize(str.replace(customizeRE, '-'));
});
function initTriggerEvent(mpInstance) {
var oldTriggerEvent = mpInstance.triggerEvent;
var newTriggerEvent = function newTriggerEvent(event) {
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
}
// 事件名统一转驼峰格式,仅处理:当前组件为 vue 组件、当前组件为 vue 组件子组件
if (this.$vm || this.dataset && this.dataset.comType) {
event = customize(event);
} else {
// 针对微信/QQ小程序单独补充驼峰格式事件,以兼容历史项目
var newEvent = customize(event);
if (newEvent !== event) {
oldTriggerEvent.apply(this, [newEvent].concat(args));
}
}
return oldTriggerEvent.apply(this, [event].concat(args));
};
try {
// 京东小程序 triggerEvent 为只读
mpInstance.triggerEvent = newTriggerEvent;
} catch (error) {
mpInstance._triggerEvent = newTriggerEvent;
}
}
function initHook(name, options, isComponent) {
var oldHook = options[name];
options[name] = function () {
markMPComponent(this);
initTriggerEvent(this);
if (oldHook) {
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
return oldHook.apply(this, args);
}
};
}
if (!MPPage.__$wrappered) {
MPPage.__$wrappered = true;
Page = function Page() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
initHook('onLoad', options);
return MPPage(options);
};
Page.after = MPPage.after;
Component = function Component() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
initHook('created', options);
return MPComponent(options);
};
}
var PAGE_EVENT_HOOKS = ['onPullDownRefresh', 'onReachBottom', 'onAddToFavorites', 'onShareTimeline', 'onShareAppMessage', 'onPageScroll', 'onResize', 'onTabItemTap'];
function initMocks(vm, mocks) {
var mpInstance = vm.$mp[vm.mpType];
mocks.forEach(function (mock) {
if (hasOwn(mpInstance, mock)) {
vm[mock] = mpInstance[mock];
}
});
}
function hasHook(hook, vueOptions) {
if (!vueOptions) {
return true;
}
if (_vue.default.options && Array.isArray(_vue.default.options[hook])) {
return true;
}
vueOptions = vueOptions.default || vueOptions;
if (isFn(vueOptions)) {
if (isFn(vueOptions.extendOptions[hook])) {
return true;
}
if (vueOptions.super && vueOptions.super.options && Array.isArray(vueOptions.super.options[hook])) {
return true;
}
return false;
}
if (isFn(vueOptions[hook]) || Array.isArray(vueOptions[hook])) {
return true;
}
var mixins = vueOptions.mixins;
if (Array.isArray(mixins)) {
return !!mixins.find(function (mixin) {
return hasHook(hook, mixin);
});
}
}
function initHooks(mpOptions, hooks, vueOptions) {
hooks.forEach(function (hook) {
if (hasHook(hook, vueOptions)) {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args);
};
}
});
}
function initUnknownHooks(mpOptions, vueOptions) {
var excludes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
findHooks(vueOptions).forEach(function (hook) {
return initHook$1(mpOptions, hook, excludes);
});
}
function findHooks(vueOptions) {
var hooks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
if (vueOptions) {
Object.keys(vueOptions).forEach(function (name) {
if (name.indexOf('on') === 0 && isFn(vueOptions[name])) {
hooks.push(name);
}
});
}
return hooks;
}
function initHook$1(mpOptions, hook, excludes) {
if (excludes.indexOf(hook) === -1 && !hasOwn(mpOptions, hook)) {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args);
};
}
}
function initVueComponent(Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
var VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
} else {
VueComponent = Vue.extend(vueOptions);
}
vueOptions = VueComponent.options;
return [VueComponent, vueOptions];
}
function initSlots(vm, vueSlots) {
if (Array.isArray(vueSlots) && vueSlots.length) {
var $slots = Object.create(null);
vueSlots.forEach(function (slotName) {
$slots[slotName] = true;
});
vm.$scopedSlots = vm.$slots = $slots;
}
}
function initVueIds(vueIds, mpInstance) {
vueIds = (vueIds || '').split(',');
var len = vueIds.length;
if (len === 1) {
mpInstance._$vueId = vueIds[0];
} else if (len === 2) {
mpInstance._$vueId = vueIds[0];
mpInstance._$vuePid = vueIds[1];
}
}
function initData(vueOptions, context) {
var data = vueOptions.data || {};
var methods = vueOptions.methods || {};
if (typeof data === 'function') {
try {
data = data.call(context); // 支持 Vue.prototype 上挂的数据
} catch (e) {
if (Object({"VUE_APP_DARK_MODE":"false","VUE_APP_NAME":"daoyou","VUE_APP_PLATFORM":"mp-weixin","NODE_ENV":"development","BASE_URL":"/"}).VUE_APP_DEBUG) {
console.warn('根据 Vue 的 data 函数初始化小程序 data 失败,请尽量确保 data 函数中不访问 vm 对象,否则可能影响首次数据渲染速度。', data);
}
}
} else {
try {
// 对 data 格式化
data = JSON.parse(JSON.stringify(data));
} catch (e) {}
}
if (!isPlainObject(data)) {
data = {};
}
Object.keys(methods).forEach(function (methodName) {
if (context.__lifecycle_hooks__.indexOf(methodName) === -1 && !hasOwn(data, methodName)) {
data[methodName] = methods[methodName];
}
});
return data;
}
var PROP_TYPES = [String, Number, Boolean, Object, Array, null];
function createObserver(name) {
return function observer(newVal, oldVal) {
if (this.$vm) {
this.$vm[name] = newVal; // 为了触发其他非 render watcher
}
};
}
function initBehaviors(vueOptions, initBehavior) {
var vueBehaviors = vueOptions.behaviors;
var vueExtends = vueOptions.extends;
var vueMixins = vueOptions.mixins;
var vueProps = vueOptions.props;
if (!vueProps) {
vueOptions.props = vueProps = [];
}
var behaviors = [];
if (Array.isArray(vueBehaviors)) {
vueBehaviors.forEach(function (behavior) {
behaviors.push(behavior.replace('uni://', "wx".concat("://")));
if (behavior === 'uni://form-field') {
if (Array.isArray(vueProps)) {
vueProps.push('name');
vueProps.push('value');
} else {
vueProps.name = {
type: String,
default: ''
};
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
};
}
}
});
}
if (isPlainObject(vueExtends) && vueExtends.props) {
behaviors.push(initBehavior({
properties: initProperties(vueExtends.props, true)
}));
}
if (Array.isArray(vueMixins)) {
vueMixins.forEach(function (vueMixin) {
if (isPlainObject(vueMixin) && vueMixin.props) {
behaviors.push(initBehavior({
properties: initProperties(vueMixin.props, true)
}));
}
});
}
return behaviors;
}
function parsePropType(key, type, defaultValue, file) {
// [String]=>String
if (Array.isArray(type) && type.length === 1) {
return type[0];
}
return type;
}
function initProperties(props) {
var isBehavior = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var file = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var options = arguments.length > 3 ? arguments[3] : undefined;
var properties = {};
if (!isBehavior) {
properties.vueId = {
type: String,
value: ''
};
{
if (options.virtualHost) {
properties.virtualHostStyle = {
type: null,
value: ''
};
properties.virtualHostClass = {
type: null,
value: ''
};
}
}
// scopedSlotsCompiler auto
properties.scopedSlotsCompiler = {
type: String,
value: ''
};
properties.vueSlots = {
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
type: null,
value: [],
observer: function observer(newVal, oldVal) {
var $slots = Object.create(null);
newVal.forEach(function (slotName) {
$slots[slotName] = true;
});
this.setData({
$slots: $slots
});
}
};
}
if (Array.isArray(props)) {
// ['title']
props.forEach(function (key) {
properties[key] = {
type: null,
observer: createObserver(key)
};
});
} else if (isPlainObject(props)) {
// {title:{type:String,default:''},content:String}
Object.keys(props).forEach(function (key) {
var opts = props[key];
if (isPlainObject(opts)) {
// title:{type:String,default:''}
var value = opts.default;
if (isFn(value)) {
value = value();
}
opts.type = parsePropType(key, opts.type);
properties[key] = {
type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null,
value: value,
observer: createObserver(key)
};
} else {
// content:String
var type = parsePropType(key, opts);
properties[key] = {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
observer: createObserver(key)
};
}
});
}
return properties;
}
function wrapper$1(event) {
// TODO 又得兼容 mpvue 的 mp 对象
try {
event.mp = JSON.parse(JSON.stringify(event));
} catch (e) {}
event.stopPropagation = noop;
event.preventDefault = noop;
event.target = event.target || {};
if (!hasOwn(event, 'detail')) {
event.detail = {};
}
if (hasOwn(event, 'markerId')) {
event.detail = (0, _typeof2.default)(event.detail) === 'object' ? event.detail : {};
event.detail.markerId = event.markerId;
}
if (isPlainObject(event.detail)) {
event.target = Object.assign({}, event.target, event.detail);
}
return event;
}
function getExtraValue(vm, dataPathsArray) {
var context = vm;
dataPathsArray.forEach(function (dataPathArray) {
var dataPath = dataPathArray[0];
var value = dataPathArray[2];
if (dataPath || typeof value !== 'undefined') {
// ['','',index,'disable']
var propPath = dataPathArray[1];
var valuePath = dataPathArray[3];
var vFor;
if (Number.isInteger(dataPath)) {
vFor = dataPath;
} else if (!dataPath) {
vFor = context;
} else if (typeof dataPath === 'string' && dataPath) {
if (dataPath.indexOf('#s#') === 0) {
vFor = dataPath.substr(3);
} else {
vFor = vm.__get_value(dataPath, context);
}
}
if (Number.isInteger(vFor)) {
context = value;
} else if (!propPath) {
context = vFor[value];
} else {
if (Array.isArray(vFor)) {
context = vFor.find(function (vForItem) {
return vm.__get_value(propPath, vForItem) === value;
});
} else if (isPlainObject(vFor)) {
context = Object.keys(vFor).find(function (vForKey) {
return vm.__get_value(propPath, vFor[vForKey]) === value;
});
} else {
console.error('v-for 暂不支持循环数据:', vFor);
}
}
if (valuePath) {
context = vm.__get_value(valuePath, context);
}
}
});
return context;
}
function processEventExtra(vm, extra, event, __args__) {
var extraObj = {};
if (Array.isArray(extra) && extra.length) {
/**
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*'test'
*/
extra.forEach(function (dataPath, index) {
if (typeof dataPath === 'string') {
if (!dataPath) {
// model,prop.sync
extraObj['$' + index] = vm;
} else {
if (dataPath === '$event') {
// $event
extraObj['$' + index] = event;
} else if (dataPath === 'arguments') {
extraObj['$' + index] = event.detail ? event.detail.__args__ || __args__ : __args__;
} else if (dataPath.indexOf('$event.') === 0) {
// $event.target.value
extraObj['$' + index] = vm.__get_value(dataPath.replace('$event.', ''), event);
} else {
extraObj['$' + index] = vm.__get_value(dataPath);
}
}
} else {
extraObj['$' + index] = getExtraValue(vm, dataPath);
}
});
}
return extraObj;
}
function getObjByArray(arr) {
var obj = {};
for (var i = 1; i < arr.length; i++) {
var element = arr[i];
obj[element[0]] = element[1];
}
return obj;
}
function processEventArgs(vm, event) {
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var extra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
var isCustom = arguments.length > 4 ? arguments[4] : undefined;
var methodName = arguments.length > 5 ? arguments[5] : undefined;
var isCustomMPEvent = false; // wxcomponent 组件,传递原始 event 对象
// fixed 用户直接触发 mpInstance.triggerEvent
var __args__ = isPlainObject(event.detail) ? event.detail.__args__ || [event.detail] : [event.detail];
if (isCustom) {
// 自定义事件
isCustomMPEvent = event.currentTarget && event.currentTarget.dataset && event.currentTarget.dataset.comType === 'wx';
if (!args.length) {
// 无参数,直接传入 event 或 detail 数组
if (isCustomMPEvent) {
return [event];
}
return __args__;
}
}
var extraObj = processEventExtra(vm, extra, event, __args__);
var ret = [];
args.forEach(function (arg) {
if (arg === '$event') {
if (methodName === '__set_model' && !isCustom) {
// input v-model value
ret.push(event.target.value);
} else {
if (isCustom && !isCustomMPEvent) {
ret.push(__args__[0]);
} else {
// wxcomponent 组件或内置组件
ret.push(event);
}
}
} else {
if (Array.isArray(arg) && arg[0] === 'o') {
ret.push(getObjByArray(arg));
} else if (typeof arg === 'string' && hasOwn(extraObj, arg)) {
ret.push(extraObj[arg]);
} else {
ret.push(arg);
}
}
});
return ret;
}
var ONCE = '~';
var CUSTOM = '^';
function isMatchEventType(eventType, optType) {
return eventType === optType || optType === 'regionchange' && (eventType === 'begin' || eventType === 'end');
}
function getContextVm(vm) {
var $parent = vm.$parent;
// 父组件是 scoped slots 或者其他自定义组件时继续查找
while ($parent && $parent.$parent && ($parent.$options.generic || $parent.$parent.$options.generic || $parent.$scope._$vuePid)) {
$parent = $parent.$parent;
}
return $parent && $parent.$parent;
}
function handleEvent(event) {
var _this2 = this;
event = wrapper$1(event);
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
var dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn('事件信息不存在');
}
var eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn('事件信息不存在');
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
var eventType = event.type;
var ret = [];
eventOpts.forEach(function (eventOpt) {
var type = eventOpt[0];
var eventsArray = eventOpt[1];
var isCustom = type.charAt(0) === CUSTOM;
type = isCustom ? type.slice(1) : type;
var isOnce = type.charAt(0) === ONCE;
type = isOnce ? type.slice(1) : type;
if (eventsArray && isMatchEventType(eventType, type)) {
eventsArray.forEach(function (eventArray) {
var methodName = eventArray[0];
if (methodName) {
var handlerCtx = _this2.$vm;
if (handlerCtx.$options.generic) {
// mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = getContextVm(handlerCtx) || handlerCtx;
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx, processEventArgs(_this2.$vm, event, eventArray[1], eventArray[2], isCustom, methodName));
return;
}
var handler = handlerCtx[methodName];
if (!isFn(handler)) {
var _type = _this2.$vm.mpType === 'page' ? 'Page' : 'Component';
var path = _this2.route || _this2.is;
throw new Error("".concat(_type, " \"").concat(path, "\" does not have a method \"").concat(methodName, "\""));
}
if (isOnce) {
if (handler.once) {
return;
}
handler.once = true;
}
var params = processEventArgs(_this2.$vm, event, eventArray[1], eventArray[2], isCustom, methodName);
params = Array.isArray(params) ? params : [];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
if (/=\s*\S+\.eventParams\s*\|\|\s*\S+\[['"]event-params['"]\]/.test(handler.toString())) {
// eslint-disable-next-line no-sparse-arrays
params = params.concat([,,,,,,,,,, event]);
}
ret.push(handler.apply(handlerCtx, params));
}
});
}
});
if (eventType === 'input' && ret.length === 1 && typeof ret[0] !== 'undefined') {
return ret[0];
}
}
var eventChannels = {};
function getEventChannel(id) {
var eventChannel = eventChannels[id];
delete eventChannels[id];
return eventChannel;
}
var hooks = ['onShow', 'onHide', 'onError', 'onPageNotFound', 'onThemeChange', 'onUnhandledRejection'];
function initEventChannel() {
_vue.default.prototype.getOpenerEventChannel = function () {
// 微信小程序使用自身getOpenerEventChannel
{
return this.$scope.getOpenerEventChannel();
}
};
var callHook = _vue.default.prototype.__call_hook;
_vue.default.prototype.__call_hook = function (hook, args) {
if (hook === 'onLoad' && args && args.__id__) {
this.__eventChannel__ = getEventChannel(args.__id__);
delete args.__id__;
}
return callHook.call(this, hook, args);
};
}
function initScopedSlotsParams() {
var center = {};
var parents = {};
function currentId(fn) {
var vueIds = this.$options.propsData.vueId;
if (vueIds) {
var vueId = vueIds.split(',')[0];
fn(vueId);
}
}
_vue.default.prototype.$hasSSP = function (vueId) {
var slot = center[vueId];
if (!slot) {
parents[vueId] = this;
this.$on('hook:destroyed', function () {
delete parents[vueId];
});
}
return slot;
};
_vue.default.prototype.$getSSP = function (vueId, name, needAll) {
var slot = center[vueId];
if (slot) {
var params = slot[name] || [];
if (needAll) {
return params;
}
return params[0];
}
};
_vue.default.prototype.$setSSP = function (name, value) {
var index = 0;
currentId.call(this, function (vueId) {
var slot = center[vueId];
var params = slot[name] = slot[name] || [];
params.push(value);
index = params.length - 1;
});
return index;
};
_vue.default.prototype.$initSSP = function () {
currentId.call(this, function (vueId) {
center[vueId] = {};
});
};
_vue.default.prototype.$callSSP = function () {
currentId.call(this, function (vueId) {
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
});
};
_vue.default.mixin({
destroyed: function destroyed() {
var propsData = this.$options.propsData;
var vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}
});
}
function parseBaseApp(vm, _ref4) {
var mocks = _ref4.mocks,
initRefs = _ref4.initRefs;
initEventChannel();
{
initScopedSlotsParams();
}
if (vm.$options.store) {
_vue.default.prototype.$store = vm.$options.store;
}
uniIdMixin(_vue.default);
_vue.default.prototype.mpHost = "mp-weixin";
_vue.default.mixin({
beforeCreate: function beforeCreate() {
if (!this.$options.mpType) {
return;
}
this.mpType = this.$options.mpType;
this.$mp = (0, _defineProperty2.default)({
data: {}
}, this.mpType, this.$options.mpInstance);
this.$scope = this.$options.mpInstance;
delete this.$options.mpType;
delete this.$options.mpInstance;
if (this.mpType === 'page' && typeof getApp === 'function') {
// hack vue-i18n
var app = getApp();
if (app.$vm && app.$vm.$i18n) {
this._i18n = app.$vm.$i18n;
}
}
if (this.mpType !== 'app') {
initRefs(this);
initMocks(this, mocks);
}
}
});
var appOptions = {
onLaunch: function onLaunch(args) {
if (this.$vm) {
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return;
}
{
if (wx.canIUse && !wx.canIUse('nextTick')) {
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上');
}
}
this.$vm = vm;
this.$vm.$mp = {
app: this
};
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted', args);
this.$vm.__call_hook('onLaunch', args);
}
};
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
var methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(function (name) {
appOptions[name] = methods[name];
});
}
initAppLocale(_vue.default, vm, normalizeLocale(wx.getSystemInfoSync().language) || LOCALE_EN);
initHooks(appOptions, hooks);
initUnknownHooks(appOptions, vm.$options);
return appOptions;
}
function parseApp(vm) {
return parseBaseApp(vm, {
mocks: mocks,
initRefs: initRefs
});
}
function createApp(vm) {
App(parseApp(vm));
return vm;
}
var encodeReserveRE = /[!'()*]/g;
var encodeReserveReplacer = function encodeReserveReplacer(c) {
return '%' + c.charCodeAt(0).toString(16);
};
var commaRE = /%2C/g;
// fixed encodeURIComponent which is more conformant to RFC3986:
// - escapes [!'()*]
// - preserve commas
var encode = function encode(str) {
return encodeURIComponent(str).replace(encodeReserveRE, encodeReserveReplacer).replace(commaRE, ',');
};
function stringifyQuery(obj) {
var encodeStr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : encode;
var res = obj ? Object.keys(obj).map(function (key) {
var val = obj[key];
if (val === undefined) {
return '';
}
if (val === null) {
return encodeStr(key);
}
if (Array.isArray(val)) {
var result = [];
val.forEach(function (val2) {
if (val2 === undefined) {
return;
}
if (val2 === null) {
result.push(encodeStr(key));
} else {
result.push(encodeStr(key) + '=' + encodeStr(val2));
}
});
return result.join('&');
}
return encodeStr(key) + '=' + encodeStr(val);
}).filter(function (x) {
return x.length > 0;
}).join('&') : null;
return res ? "?".concat(res) : '';
}
function parseBaseComponent(vueComponentOptions) {
var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
isPage = _ref5.isPage,
initRelation = _ref5.initRelation;
var needVueOptions = arguments.length > 2 ? arguments[2] : undefined;
var _initVueComponent = initVueComponent(_vue.default, vueComponentOptions),
_initVueComponent2 = (0, _slicedToArray2.default)(_initVueComponent, 2),
VueComponent = _initVueComponent2[0],
vueOptions = _initVueComponent2[1];
var options = _objectSpread({
multipleSlots: true,
// styleIsolation: 'apply-shared',
addGlobalClass: true
}, vueOptions.options || {});
{
// 微信 multipleSlots 部分情况有 bug,导致内容顺序错乱 如 u-list,提供覆盖选项
if (vueOptions['mp-weixin'] && vueOptions['mp-weixin'].options) {
Object.assign(options, vueOptions['mp-weixin'].options);
}
}
var componentOptions = {
options: options,
data: initData(vueOptions, _vue.default.prototype),
behaviors: initBehaviors(vueOptions, initBehavior),
properties: initProperties(vueOptions.props, false, vueOptions.__file, options),
lifetimes: {
attached: function attached() {
var properties = this.properties;
var options = {
mpType: isPage.call(this) ? 'page' : 'component',
mpInstance: this,
propsData: properties
};
initVueIds(properties.vueId, this);
// 处理父子关系
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options
});
// 初始化 vue 实例
this.$vm = new VueComponent(options);
// 处理$slots,$scopedSlots(暂不支持动态变化$slots)
initSlots(this.$vm, properties.vueSlots);
// 触发首次 setData
this.$vm.$mount();
},
ready: function ready() {
// 当组件 props 默认值为 true,初始化时传入 false 会导致 created,ready 触发, 但 attached 不触发
// https://developers.weixin.qq.com/community/develop/doc/00066ae2844cc0f8eb883e2a557800
if (this.$vm) {
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted');
this.$vm.__call_hook('onReady');
}
},
detached: function detached() {
this.$vm && this.$vm.$destroy();
}
},
pageLifetimes: {
show: function show(args) {
this.$vm && this.$vm.__call_hook('onPageShow', args);
},
hide: function hide() {
this.$vm && this.$vm.__call_hook('onPageHide');
},
resize: function resize(size) {
this.$vm && this.$vm.__call_hook('onPageResize', size);
}
},
methods: {
__l: handleLink,
__e: handleEvent
}
};
// externalClasses
if (vueOptions.externalClasses) {
componentOptions.externalClasses = vueOptions.externalClasses;
}
if (Array.isArray(vueOptions.wxsCallMethods)) {
vueOptions.wxsCallMethods.forEach(function (callMethod) {
componentOptions.methods[callMethod] = function (args) {
return this.$vm[callMethod](args);
};
});
}
if (needVueOptions) {
return [componentOptions, vueOptions, VueComponent];
}
if (isPage) {
return componentOptions;
}
return [componentOptions, VueComponent];
}
function parseComponent(vueComponentOptions, needVueOptions) {
return parseBaseComponent(vueComponentOptions, {
isPage: isPage,
initRelation: initRelation
}, needVueOptions);
}
var hooks$1 = ['onShow', 'onHide', 'onUnload'];
hooks$1.push.apply(hooks$1, PAGE_EVENT_HOOKS);
function parseBasePage(vuePageOptions) {
var _parseComponent = parseComponent(vuePageOptions, true),
_parseComponent2 = (0, _slicedToArray2.default)(_parseComponent, 2),
pageOptions = _parseComponent2[0],
vueOptions = _parseComponent2[1];
initHooks(pageOptions.methods, hooks$1, vueOptions);
pageOptions.methods.onLoad = function (query) {
this.options = query;
var copyQuery = Object.assign({}, query);
delete copyQuery.__id__;
this.$page = {
fullPath: '/' + (this.route || this.is) + stringifyQuery(copyQuery)
};
this.$vm.$mp.query = query; // 兼容 mpvue
this.$vm.__call_hook('onLoad', query);
};
{
initUnknownHooks(pageOptions.methods, vuePageOptions, ['onReady']);
}
{
initWorkletMethods(pageOptions.methods, vueOptions.methods);
}
return pageOptions;
}
function parsePage(vuePageOptions) {
return parseBasePage(vuePageOptions);
}
function createPage(vuePageOptions) {
{
return Component(parsePage(vuePageOptions));
}
}
function createComponent(vueOptions) {
{
return Component(parseComponent(vueOptions));
}
}
function createSubpackageApp(vm) {
var appOptions = parseApp(vm);
var app = getApp({
allowDefault: true
});
vm.$scope = app;
var globalData = app.globalData;
if (globalData) {
Object.keys(appOptions.globalData).forEach(function (name) {
if (!hasOwn(globalData, name)) {
globalData[name] = appOptions.globalData[name];
}
});
}
Object.keys(appOptions).forEach(function (name) {
if (!hasOwn(app, name)) {
app[name] = appOptions[name];
}
});
if (isFn(appOptions.onShow) && wx.onAppShow) {
wx.onAppShow(function () {
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && wx.onAppHide) {
wx.onAppHide(function () {
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
var args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync();
vm.__call_hook('onLaunch', args);
}
return vm;
}
function createPlugin(vm) {
var appOptions = parseApp(vm);
if (isFn(appOptions.onShow) && wx.onAppShow) {
wx.onAppShow(function () {
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
args[_key7] = arguments[_key7];
}
vm.__call_hook('onShow', args);
});
}
if (isFn(appOptions.onHide) && wx.onAppHide) {
wx.onAppHide(function () {
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
args[_key8] = arguments[_key8];
}
vm.__call_hook('onHide', args);
});
}
if (isFn(appOptions.onLaunch)) {
var args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync();
vm.__call_hook('onLaunch', args);
}
return vm;
}
todos.forEach(function (todoApi) {
protocols[todoApi] = false;
});
canIUses.forEach(function (canIUseApi) {
var apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
if (!wx.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
});
var uni = {};
if (typeof Proxy !== 'undefined' && "mp-weixin" !== 'app-plus') {
uni = new Proxy({}, {
get: function get(target, name) {
if (hasOwn(target, name)) {
return target[name];
}
if (baseApi[name]) {
return baseApi[name];
}
if (api[name]) {
return promisify(name, api[name]);
}
{
if (extraApi[name]) {
return promisify(name, extraApi[name]);
}
if (todoApis[name]) {
return promisify(name, todoApis[name]);
}
}
if (eventApi[name]) {
return eventApi[name];
}
return promisify(name, wrapper(name, wx[name]));
},
set: function set(target, name, value) {
target[name] = value;
return true;
}
});
} else {
Object.keys(baseApi).forEach(function (name) {
uni[name] = baseApi[name];
});
{
Object.keys(todoApis).forEach(function (name) {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(function (name) {
uni[name] = promisify(name, extraApi[name]);
});
}
Object.keys(eventApi).forEach(function (name) {
uni[name] = eventApi[name];
});
Object.keys(api).forEach(function (name) {
uni[name] = promisify(name, api[name]);
});
Object.keys(wx).forEach(function (name) {
if (hasOwn(wx, name) || hasOwn(protocols, name)) {
uni[name] = promisify(name, wrapper(name, wx[name]));
}
});
}
wx.createApp = createApp;
wx.createPage = createPage;
wx.createComponent = createComponent;
wx.createSubpackageApp = createSubpackageApp;
wx.createPlugin = createPlugin;
var uni$1 = uni;
var _default = uni$1;
exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/wx.js */ 1)["default"], __webpack_require__(/*! ./../../../webpack/buildin/global.js */ 3)))
/***/ }),
/* 3 */
/*!***********************************!*\
!*** (webpack)/buildin/global.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports) {
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || new Function("return this")();
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
/***/ }),
/* 4 */
/*!**********************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
\**********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
};
}
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 5 */
/*!**************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/slicedToArray.js ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ 6);
var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ 7);
var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ 8);
var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ 10);
function _slicedToArray(arr, i) {
return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
}
module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 6 */
/*!***************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 7 */
/*!*********************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
\*********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) {
;
}
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 8 */
/*!***************************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
\***************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ 9);
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
}
module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 9 */
/*!*****************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
\*****************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 10 */
/*!****************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
\****************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 11 */
/*!***************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ 12);
function _defineProperty(obj, key, value) {
key = toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 12 */
/*!**************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var _typeof = __webpack_require__(/*! ./typeof.js */ 13)["default"];
var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ 14);
function toPropertyKey(t) {
var i = toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 13 */
/*!*******************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/typeof.js ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _typeof(o) {
"@babel/helpers - typeof";
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
}
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 14 */
/*!************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var _typeof = __webpack_require__(/*! ./typeof.js */ 13)["default"];
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 15 */
/*!**********************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/construct.js ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ 16);
var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ 17);
function _construct(t, e, r) {
if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
var o = [null];
o.push.apply(o, e);
var p = new (t.bind.apply(t, o))();
return r && setPrototypeOf(p, r.prototype), p;
}
module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 16 */
/*!***************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _setPrototypeOf(o, p) {
module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
return _setPrototypeOf(o, p);
}
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 17 */
/*!*************************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
\*************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (t) {}
return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
return !!t;
}, module.exports.__esModule = true, module.exports["default"] = module.exports)();
}
module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 18 */
/*!******************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/toConsumableArray.js ***!
\******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var arrayWithoutHoles = __webpack_require__(/*! ./arrayWithoutHoles.js */ 19);
var iterableToArray = __webpack_require__(/*! ./iterableToArray.js */ 20);
var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ 8);
var nonIterableSpread = __webpack_require__(/*! ./nonIterableSpread.js */ 21);
function _toConsumableArray(arr) {
return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
}
module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 19 */
/*!******************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js ***!
\******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ 9);
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return arrayLikeToArray(arr);
}
module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 20 */
/*!****************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/iterableToArray.js ***!
\****************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 21 */
/*!******************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/nonIterableSpread.js ***!
\******************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 22 */
/*!*************************************************************!*\
!*** ./node_modules/@dcloudio/uni-i18n/dist/uni-i18n.es.js ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(uni, global) {
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LOCALE_ZH_HANT = exports.LOCALE_ZH_HANS = exports.LOCALE_FR = exports.LOCALE_ES = exports.LOCALE_EN = exports.I18n = exports.Formatter = void 0;
exports.compileI18nJsonStr = compileI18nJsonStr;
exports.hasI18nJson = hasI18nJson;
exports.initVueI18n = initVueI18n;
exports.isI18nStr = isI18nStr;
exports.isString = void 0;
exports.normalizeLocale = normalizeLocale;
exports.parseI18nJson = parseI18nJson;
exports.resolveLocale = resolveLocale;
var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ 5));
var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ 23));
var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ 24));
var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ 13));
var isObject = function isObject(val) {
return val !== null && (0, _typeof2.default)(val) === 'object';
};
var defaultDelimiters = ['{', '}'];
var BaseFormatter = /*#__PURE__*/function () {
function BaseFormatter() {
(0, _classCallCheck2.default)(this, BaseFormatter);
this._caches = Object.create(null);
}
(0, _createClass2.default)(BaseFormatter, [{
key: "interpolate",
value: function interpolate(message, values) {
var delimiters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultDelimiters;
if (!values) {
return [message];
}
var tokens = this._caches[message];
if (!tokens) {
tokens = parse(message, delimiters);
this._caches[message] = tokens;
}
return compile(tokens, values);
}
}]);
return BaseFormatter;
}();
exports.Formatter = BaseFormatter;
var RE_TOKEN_LIST_VALUE = /^(?:\d)+/;
var RE_TOKEN_NAMED_VALUE = /^(?:\w)+/;
function parse(format, _ref) {
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
startDelimiter = _ref2[0],
endDelimiter = _ref2[1];
var tokens = [];
var position = 0;
var text = '';
while (position < format.length) {
var char = format[position++];
if (char === startDelimiter) {
if (text) {
tokens.push({
type: 'text',
value: text
});
}
text = '';
var sub = '';
char = format[position++];
while (char !== undefined && char !== endDelimiter) {
sub += char;
char = format[position++];
}
var isClosed = char === endDelimiter;
var type = RE_TOKEN_LIST_VALUE.test(sub) ? 'list' : isClosed && RE_TOKEN_NAMED_VALUE.test(sub) ? 'named' : 'unknown';
tokens.push({
value: sub,
type: type
});
}
// else if (char === '%') {
// // when found rails i18n syntax, skip text capture
// if (format[position] !== '{') {
// text += char
// }
// }
else {
text += char;
}
}
text && tokens.push({
type: 'text',
value: text
});
return tokens;
}
function compile(tokens, values) {
var compiled = [];
var index = 0;
var mode = Array.isArray(values) ? 'list' : isObject(values) ? 'named' : 'unknown';
if (mode === 'unknown') {
return compiled;
}
while (index < tokens.length) {
var token = tokens[index];
switch (token.type) {
case 'text':
compiled.push(token.value);
break;
case 'list':
compiled.push(values[parseInt(token.value, 10)]);
break;
case 'named':
if (mode === 'named') {
compiled.push(values[token.value]);
} else {
if (true) {
console.warn("Type of token '".concat(token.type, "' and format of value '").concat(mode, "' don't match!"));
}
}
break;
case 'unknown':
if (true) {
console.warn("Detect 'unknown' type of token!");
}
break;
}
index++;
}
return compiled;
}
var LOCALE_ZH_HANS = 'zh-Hans';
exports.LOCALE_ZH_HANS = LOCALE_ZH_HANS;
var LOCALE_ZH_HANT = 'zh-Hant';
exports.LOCALE_ZH_HANT = LOCALE_ZH_HANT;
var LOCALE_EN = 'en';
exports.LOCALE_EN = LOCALE_EN;
var LOCALE_FR = 'fr';
exports.LOCALE_FR = LOCALE_FR;
var LOCALE_ES = 'es';
exports.LOCALE_ES = LOCALE_ES;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var hasOwn = function hasOwn(val, key) {
return hasOwnProperty.call(val, key);
};
var defaultFormatter = new BaseFormatter();
function include(str, parts) {
return !!parts.find(function (part) {
return str.indexOf(part) !== -1;
});
}
function startsWith(str, parts) {
return parts.find(function (part) {
return str.indexOf(part) === 0;
});
}
function normalizeLocale(locale, messages) {
if (!locale) {
return;
}
locale = locale.trim().replace(/_/g, '-');
if (messages && messages[locale]) {
return locale;
}
locale = locale.toLowerCase();
if (locale === 'chinese') {
// 支付宝
return LOCALE_ZH_HANS;
}
if (locale.indexOf('zh') === 0) {
if (locale.indexOf('-hans') > -1) {
return LOCALE_ZH_HANS;
}
if (locale.indexOf('-hant') > -1) {
return LOCALE_ZH_HANT;
}
if (include(locale, ['-tw', '-hk', '-mo', '-cht'])) {
return LOCALE_ZH_HANT;
}
return LOCALE_ZH_HANS;
}
var locales = [LOCALE_EN, LOCALE_FR, LOCALE_ES];
if (messages && Object.keys(messages).length > 0) {
locales = Object.keys(messages);
}
var lang = startsWith(locale, locales);
if (lang) {
return lang;
}
}
var I18n = /*#__PURE__*/function () {
function I18n(_ref3) {
var locale = _ref3.locale,
fallbackLocale = _ref3.fallbackLocale,
messages = _ref3.messages,
watcher = _ref3.watcher,
formater = _ref3.formater;
(0, _classCallCheck2.default)(this, I18n);
this.locale = LOCALE_EN;
this.fallbackLocale = LOCALE_EN;
this.message = {};
this.messages = {};
this.watchers = [];
if (fallbackLocale) {
this.fallbackLocale = fallbackLocale;
}
this.formater = formater || defaultFormatter;
this.messages = messages || {};
this.setLocale(locale || LOCALE_EN);
if (watcher) {
this.watchLocale(watcher);
}
}
(0, _createClass2.default)(I18n, [{
key: "setLocale",
value: function setLocale(locale) {
var _this = this;
var oldLocale = this.locale;
this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale;
if (!this.messages[this.locale]) {
// 可能初始化时不存在
this.messages[this.locale] = {};
}
this.message = this.messages[this.locale];
// 仅发生变化时,通知
if (oldLocale !== this.locale) {
this.watchers.forEach(function (watcher) {
watcher(_this.locale, oldLocale);
});
}
}
}, {
key: "getLocale",
value: function getLocale() {
return this.locale;
}
}, {
key: "watchLocale",
value: function watchLocale(fn) {
var _this2 = this;
var index = this.watchers.push(fn) - 1;
return function () {
_this2.watchers.splice(index, 1);
};
}
}, {
key: "add",
value: function add(locale, message) {
var override = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var curMessages = this.messages[locale];
if (curMessages) {
if (override) {
Object.assign(curMessages, message);
} else {
Object.keys(message).forEach(function (key) {
if (!hasOwn(curMessages, key)) {
curMessages[key] = message[key];
}
});
}
} else {
this.messages[locale] = message;
}
}
}, {
key: "f",
value: function f(message, values, delimiters) {
return this.formater.interpolate(message, values, delimiters).join('');
}
}, {
key: "t",
value: function t(key, locale, values) {
var message = this.message;
if (typeof locale === 'string') {
locale = normalizeLocale(locale, this.messages);
locale && (message = this.messages[locale]);
} else {
values = locale;
}
if (!hasOwn(message, key)) {
console.warn("Cannot translate the value of keypath ".concat(key, ". Use the value of keypath as default."));
return key;
}
return this.formater.interpolate(message[key], values).join('');
}
}]);
return I18n;
}();
exports.I18n = I18n;
function watchAppLocale(appVm, i18n) {
// 需要保证 watch 的触发在组件渲染之前
if (appVm.$watchLocale) {
// vue2
appVm.$watchLocale(function (newLocale) {
i18n.setLocale(newLocale);
});
} else {
appVm.$watch(function () {
return appVm.$locale;
}, function (newLocale) {
i18n.setLocale(newLocale);
});
}
}
function getDefaultLocale() {
if (typeof uni !== 'undefined' && uni.getLocale) {
return uni.getLocale();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if (typeof global !== 'undefined' && global.getLocale) {
return global.getLocale();
}
return LOCALE_EN;
}
function initVueI18n(locale) {
var messages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var fallbackLocale = arguments.length > 2 ? arguments[2] : undefined;
var watcher = arguments.length > 3 ? arguments[3] : undefined;
// 兼容旧版本入参
if (typeof locale !== 'string') {
var _ref4 = [messages, locale];
locale = _ref4[0];
messages = _ref4[1];
}
if (typeof locale !== 'string') {
// 因为小程序平台,uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale = getDefaultLocale();
}
if (typeof fallbackLocale !== 'string') {
fallbackLocale = typeof __uniConfig !== 'undefined' && __uniConfig.fallbackLocale || LOCALE_EN;
}
var i18n = new I18n({
locale: locale,
fallbackLocale: fallbackLocale,
messages: messages,
watcher: watcher
});
var _t = function t(key, values) {
if (typeof getApp !== 'function') {
// app view
/* eslint-disable no-func-assign */
_t = function t(key, values) {
return i18n.t(key, values);
};
} else {
var isWatchedAppLocale = false;
_t = function t(key, values) {
var appVm = getApp().$vm;
// 可能$vm还不存在,比如在支付宝小程序中,组件定义较早,在props的default里使用了t()函数(如uni-goods-nav),此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if (appVm) {
// 触发响应式
appVm.$locale;
if (!isWatchedAppLocale) {
isWatchedAppLocale = true;
watchAppLocale(appVm, i18n);
}
}
return i18n.t(key, values);
};
}
return _t(key, values);
};
return {
i18n: i18n,
f: function f(message, values, delimiters) {
return i18n.f(message, values, delimiters);
},
t: function t(key, values) {
return _t(key, values);
},
add: function add(locale, message) {
var override = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
return i18n.add(locale, message, override);
},
watch: function watch(fn) {
return i18n.watchLocale(fn);
},
getLocale: function getLocale() {
return i18n.getLocale();
},
setLocale: function setLocale(newLocale) {
return i18n.setLocale(newLocale);
}
};
}
var isString = function isString(val) {
return typeof val === 'string';
};
exports.isString = isString;
var formater;
function hasI18nJson(jsonObj, delimiters) {
if (!formater) {
formater = new BaseFormatter();
}
return walkJsonObj(jsonObj, function (jsonObj, key) {
var value = jsonObj[key];
if (isString(value)) {
if (isI18nStr(value, delimiters)) {
return true;
}
} else {
return hasI18nJson(value, delimiters);
}
});
}
function parseI18nJson(jsonObj, values, delimiters) {
if (!formater) {
formater = new BaseFormatter();
}
walkJsonObj(jsonObj, function (jsonObj, key) {
var value = jsonObj[key];
if (isString(value)) {
if (isI18nStr(value, delimiters)) {
jsonObj[key] = compileStr(value, values, delimiters);
}
} else {
parseI18nJson(value, values, delimiters);
}
});
return jsonObj;
}
function compileI18nJsonStr(jsonStr, _ref5) {
var locale = _ref5.locale,
locales = _ref5.locales,
delimiters = _ref5.delimiters;
if (!isI18nStr(jsonStr, delimiters)) {
return jsonStr;
}
if (!formater) {
formater = new BaseFormatter();
}
var localeValues = [];
Object.keys(locales).forEach(function (name) {
if (name !== locale) {
localeValues.push({
locale: name,
values: locales[name]
});
}
});
localeValues.unshift({
locale: locale,
values: locales[locale]
});
try {
return JSON.stringify(compileJsonObj(JSON.parse(jsonStr), localeValues, delimiters), null, 2);
} catch (e) {}
return jsonStr;
}
function isI18nStr(value, delimiters) {
return value.indexOf(delimiters[0]) > -1;
}
function compileStr(value, values, delimiters) {
return formater.interpolate(value, values, delimiters).join('');
}
function compileValue(jsonObj, key, localeValues, delimiters) {
var value = jsonObj[key];
if (isString(value)) {
// 存在国际化
if (isI18nStr(value, delimiters)) {
jsonObj[key] = compileStr(value, localeValues[0].values, delimiters);
if (localeValues.length > 1) {
// 格式化国际化语言
var valueLocales = jsonObj[key + 'Locales'] = {};
localeValues.forEach(function (localValue) {
valueLocales[localValue.locale] = compileStr(value, localValue.values, delimiters);
});
}
}
} else {
compileJsonObj(value, localeValues, delimiters);
}
}
function compileJsonObj(jsonObj, localeValues, delimiters) {
walkJsonObj(jsonObj, function (jsonObj, key) {
compileValue(jsonObj, key, localeValues, delimiters);
});
return jsonObj;
}
function walkJsonObj(jsonObj, walk) {
if (Array.isArray(jsonObj)) {
for (var i = 0; i < jsonObj.length; i++) {
if (walk(jsonObj, i)) {
return true;
}
}
} else if (isObject(jsonObj)) {
for (var key in jsonObj) {
if (walk(jsonObj, key)) {
return true;
}
}
}
return false;
}
function resolveLocale(locales) {
return function (locale) {
if (!locale) {
return locale;
}
locale = normalizeLocale(locale) || locale;
return resolveLocaleChain(locale).find(function (locale) {
return locales.indexOf(locale) > -1;
});
};
}
function resolveLocaleChain(locale) {
var chain = [];
var tokens = locale.split('-');
while (tokens.length) {
chain.push(tokens.join('-'));
tokens.pop();
}
return chain;
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"], __webpack_require__(/*! ./../../../webpack/buildin/global.js */ 3)))
/***/ }),
/* 23 */
/*!***************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/classCallCheck.js ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 24 */
/*!************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/createClass.js ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ 12);
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, toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 25 */
/*!******************************************************************************************!*\
!*** ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js ***!
\******************************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* WEBPACK VAR INJECTION */(function(global) {/*!
* Vue.js v2.6.11
* (c) 2014-2023 Evan You
* Released under the MIT License.
*/
/* */
var emptyObject = Object.freeze({});
// These helpers produce better VM code in JS engines due to their
// explicitness and function inlining.
function isUndef (v) {
return v === undefined || v === null
}
function isDef (v) {
return v !== undefined && v !== null
}
function isTrue (v) {
return v === true
}
function isFalse (v) {
return v === false
}
/**
* Check if value is primitive.
*/
function isPrimitive (value) {
return (
typeof value === 'string' ||
typeof value === 'number' ||
// $flow-disable-line
typeof value === 'symbol' ||
typeof value === 'boolean'
)
}
/**
* Quick object check - this is primarily used to tell
* Objects from primitive values when we know the value
* is a JSON-compliant type.
*/
function isObject (obj) {
return obj !== null && typeof obj === 'object'
}
/**
* Get the raw type string of a value, e.g., [object Object].
*/
var _toString = Object.prototype.toString;
function toRawType (value) {
return _toString.call(value).slice(8, -1)
}
/**
* Strict object type check. Only returns true
* for plain JavaScript objects.
*/
function isPlainObject (obj) {
return _toString.call(obj) === '[object Object]'
}
function isRegExp (v) {
return _toString.call(v) === '[object RegExp]'
}
/**
* Check if val is a valid array index.
*/
function isValidArrayIndex (val) {
var n = parseFloat(String(val));
return n >= 0 && Math.floor(n) === n && isFinite(val)
}
function isPromise (val) {
return (
isDef(val) &&
typeof val.then === 'function' &&
typeof val.catch === 'function'
)
}
/**
* Convert a value to a string that is actually rendered.
*/
function toString (val) {
return val == null
? ''
: Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
? JSON.stringify(val, null, 2)
: String(val)
}
/**
* Convert an input value to a number for persistence.
* If the conversion fails, return original string.
*/
function toNumber (val) {
var n = parseFloat(val);
return isNaN(n) ? val : n
}
/**
* Make a map and return a function for checking if a key
* is in that map.
*/
function makeMap (
str,
expectsLowerCase
) {
var map = Object.create(null);
var list = str.split(',');
for (var i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase
? function (val) { return map[val.toLowerCase()]; }
: function (val) { return map[val]; }
}
/**
* Check if a tag is a built-in tag.
*/
var isBuiltInTag = makeMap('slot,component', true);
/**
* Check if an attribute is a reserved attribute.
*/
var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
/**
* Remove an item from an array.
*/
function remove (arr, item) {
if (arr.length) {
var index = arr.indexOf(item);
if (index > -1) {
return arr.splice(index, 1)
}
}
}
/**
* Check whether an object has the property.
*/
var hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
/**
* Create a cached version of a pure function.
*/
function cached (fn) {
var cache = Object.create(null);
return (function cachedFn (str) {
var hit = cache[str];
return hit || (cache[str] = fn(str))
})
}
/**
* Camelize a hyphen-delimited string.
*/
var camelizeRE = /-(\w)/g;
var camelize = cached(function (str) {
return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
});
/**
* Capitalize a string.
*/
var capitalize = cached(function (str) {
return str.charAt(0).toUpperCase() + str.slice(1)
});
/**
* Hyphenate a camelCase string.
*/
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function (str) {
return str.replace(hyphenateRE, '-$1').toLowerCase()
});
/**
* Simple bind polyfill for environments that do not support it,
* e.g., PhantomJS 1.x. Technically, we don't need this anymore
* since native bind is now performant enough in most browsers.
* But removing it would mean breaking code that was able to run in
* PhantomJS 1.x, so this must be kept for backward compatibility.
*/
/* istanbul ignore next */
function polyfillBind (fn, ctx) {
function boundFn (a) {
var l = arguments.length;
return l
? l > 1
? fn.apply(ctx, arguments)
: fn.call(ctx, a)
: fn.call(ctx)
}
boundFn._length = fn.length;
return boundFn
}
function nativeBind (fn, ctx) {
return fn.bind(ctx)
}
var bind = Function.prototype.bind
? nativeBind
: polyfillBind;
/**
* Convert an Array-like object to a real Array.
*/
function toArray (list, start) {
start = start || 0;
var i = list.length - start;
var ret = new Array(i);
while (i--) {
ret[i] = list[i + start];
}
return ret
}
/**
* Mix properties into target object.
*/
function extend (to, _from) {
for (var key in _from) {
to[key] = _from[key];
}
return to
}
/**
* Merge an Array of Objects into a single Object.
*/
function toObject (arr) {
var res = {};
for (var i = 0; i < arr.length; i++) {
if (arr[i]) {
extend(res, arr[i]);
}
}
return res
}
/* eslint-disable no-unused-vars */
/**
* Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
* with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
*/
function noop (a, b, c) {}
/**
* Always return false.
*/
var no = function (a, b, c) { return false; };
/* eslint-enable no-unused-vars */
/**
* Return the same value.
*/
var identity = function (_) { return _; };
/**
* Check if two values are loosely equal - that is,
* if they are plain objects, do they have the same shape?
*/
function looseEqual (a, b) {
if (a === b) { return true }
var isObjectA = isObject(a);
var isObjectB = isObject(b);
if (isObjectA && isObjectB) {
try {
var isArrayA = Array.isArray(a);
var isArrayB = Array.isArray(b);
if (isArrayA && isArrayB) {
return a.length === b.length && a.every(function (e, i) {
return looseEqual(e, b[i])
})
} else if (a instanceof Date && b instanceof Date) {
return a.getTime() === b.getTime()
} else if (!isArrayA && !isArrayB) {
var keysA = Object.keys(a);
var keysB = Object.keys(b);
return keysA.length === keysB.length && keysA.every(function (key) {
return looseEqual(a[key], b[key])
})
} else {
/* istanbul ignore next */
return false
}
} catch (e) {
/* istanbul ignore next */
return false
}
} else if (!isObjectA && !isObjectB) {
return String(a) === String(b)
} else {
return false
}
}
/**
* Return the first index at which a loosely equal value can be
* found in the array (if value is a plain object, the array must
* contain an object of the same shape), or -1 if it is not present.
*/
function looseIndexOf (arr, val) {
for (var i = 0; i < arr.length; i++) {
if (looseEqual(arr[i], val)) { return i }
}
return -1
}
/**
* Ensure a function is called only once.
*/
function once (fn) {
var called = false;
return function () {
if (!called) {
called = true;
fn.apply(this, arguments);
}
}
}
var ASSET_TYPES = [
'component',
'directive',
'filter'
];
var LIFECYCLE_HOOKS = [
'beforeCreate',
'created',
'beforeMount',
'mounted',
'beforeUpdate',
'updated',
'beforeDestroy',
'destroyed',
'activated',
'deactivated',
'errorCaptured',
'serverPrefetch'
];
/* */
var config = ({
/**
* Option merge strategies (used in core/util/options)
*/
// $flow-disable-line
optionMergeStrategies: Object.create(null),
/**
* Whether to suppress warnings.
*/
silent: false,
/**
* Show production mode tip message on boot?
*/
productionTip: "development" !== 'production',
/**
* Whether to enable devtools
*/
devtools: "development" !== 'production',
/**
* Whether to record perf
*/
performance: false,
/**
* Error handler for watcher errors
*/
errorHandler: null,
/**
* Warn handler for watcher warns
*/
warnHandler: null,
/**
* Ignore certain custom elements
*/
ignoredElements: [],
/**
* Custom user key aliases for v-on
*/
// $flow-disable-line
keyCodes: Object.create(null),
/**
* Check if a tag is reserved so that it cannot be registered as a
* component. This is platform-dependent and may be overwritten.
*/
isReservedTag: no,
/**
* Check if an attribute is reserved so that it cannot be used as a component
* prop. This is platform-dependent and may be overwritten.
*/
isReservedAttr: no,
/**
* Check if a tag is an unknown element.
* Platform-dependent.
*/
isUnknownElement: no,
/**
* Get the namespace of an element
*/
getTagNamespace: noop,
/**
* Parse the real tag name for the specific platform.
*/
parsePlatformTagName: identity,
/**
* Check if an attribute must be bound using property, e.g. value
* Platform-dependent.
*/
mustUseProp: no,
/**
* Perform updates asynchronously. Intended to be used by Vue Test Utils
* This will significantly reduce performance if set to false.
*/
async: true,
/**
* Exposed for legacy reasons
*/
_lifecycleHooks: LIFECYCLE_HOOKS
});
/* */
/**
* unicode letters used for parsing html tags, component names and property paths.
* using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
* skipping \u10000-\uEFFFF due to it freezing up PhantomJS
*/
var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
/**
* Check if a string starts with $ or _
*/
function isReserved (str) {
var c = (str + '').charCodeAt(0);
return c === 0x24 || c === 0x5F
}
/**
* Define a property.
*/
function def (obj, key, val, enumerable) {
Object.defineProperty(obj, key, {
value: val,
enumerable: !!enumerable,
writable: true,
configurable: true
});
}
/**
* Parse simple path.
*/
var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
function parsePath (path) {
if (bailRE.test(path)) {
return
}
var segments = path.split('.');
return function (obj) {
for (var i = 0; i < segments.length; i++) {
if (!obj) { return }
obj = obj[segments[i]];
}
return obj
}
}
/* */
// can we use __proto__?
var hasProto = '__proto__' in {};
// Browser environment sniffing
var inBrowser = typeof window !== 'undefined';
var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
var UA = inBrowser && window.navigator.userAgent.toLowerCase();
var isIE = UA && /msie|trident/.test(UA);
var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
var isEdge = UA && UA.indexOf('edge/') > 0;
var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
var isPhantomJS = UA && /phantomjs/.test(UA);
var isFF = UA && UA.match(/firefox\/(\d+)/);
// Firefox has a "watch" function on Object.prototype...
var nativeWatch = ({}).watch;
if (inBrowser) {
try {
var opts = {};
Object.defineProperty(opts, 'passive', ({
get: function get () {
}
})); // https://github.com/facebook/flow/issues/285
window.addEventListener('test-passive', null, opts);
} catch (e) {}
}
// this needs to be lazy-evaled because vue may be required before
// vue-server-renderer can set VUE_ENV
var _isServer;
var isServerRendering = function () {
if (_isServer === undefined) {
/* istanbul ignore if */
if (!inBrowser && !inWeex && typeof global !== 'undefined') {
// detect presence of vue-server-renderer and avoid
// Webpack shimming the process
_isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
} else {
_isServer = false;
}
}
return _isServer
};
// detect devtools
var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
/* istanbul ignore next */
function isNative (Ctor) {
return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
}
var hasSymbol =
typeof Symbol !== 'undefined' && isNative(Symbol) &&
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
var _Set;
/* istanbul ignore if */ // $flow-disable-line
if (typeof Set !== 'undefined' && isNative(Set)) {
// use native Set when available.
_Set = Set;
} else {
// a non-standard Set polyfill that only works with primitive keys.
_Set = /*@__PURE__*/(function () {
function Set () {
this.set = Object.create(null);
}
Set.prototype.has = function has (key) {
return this.set[key] === true
};
Set.prototype.add = function add (key) {
this.set[key] = true;
};
Set.prototype.clear = function clear () {
this.set = Object.create(null);
};
return Set;
}());
}
/* */
var warn = noop;
var tip = noop;
var generateComponentTrace = (noop); // work around flow check
var formatComponentName = (noop);
if (true) {
var hasConsole = typeof console !== 'undefined';
var classifyRE = /(?:^|[-_])(\w)/g;
var classify = function (str) { return str
.replace(classifyRE, function (c) { return c.toUpperCase(); })
.replace(/[-_]/g, ''); };
warn = function (msg, vm) {
var trace = vm ? generateComponentTrace(vm) : '';
if (config.warnHandler) {
config.warnHandler.call(null, msg, vm, trace);
} else if (hasConsole && (!config.silent)) {
console.error(("[Vue warn]: " + msg + trace));
}
};
tip = function (msg, vm) {
if (hasConsole && (!config.silent)) {
console.warn("[Vue tip]: " + msg + (
vm ? generateComponentTrace(vm) : ''
));
}
};
formatComponentName = function (vm, includeFile) {
if (vm.$root === vm) {
if (vm.$options && vm.$options.__file) { // fixed by xxxxxx
return ('') + vm.$options.__file
}
return '
Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins * with a new int. This is done intentionally so that we can copy out a row into a BitArray very * efficiently.
* *The ordering of bits is row-major. Within each int, the least significant bits are used first, * meaning they represent lower x values. This is compatible with BitArray's implementation.
* * @author Sean Owen * @author dswitkin@google.com (Daniel Switkin) */var BitMatrix/*implements Cloneable*/=/*#__PURE__*/function(){/** * Creates an empty square {@link BitMatrix}. * * @param dimension height and width */ // public constructor(dimension: number /*int*/) { // this(dimension, dimension) // } /** * Creates an empty {@link BitMatrix}. * * @param width bit matrix width * @param height bit matrix height */ // public constructor(width: number /*int*/, height: number /*int*/) { // if (width < 1 || height < 1) { // throw new IllegalArgumentException("Both dimensions must be greater than 0") // } // this.width = width // this.height = height // this.rowSize = (width + 31) / 32 // bits = new int[rowSize * height]; // } function BitMatrix(width/*int*/,height/*int*/,rowSize/*int*/,bits){_classCallCheck(this,BitMatrix);this.width=width;this.height=height;this.rowSize=rowSize;this.bits=bits;if(undefined===height||null===height){height=width;}this.height=height;if(width<1||height<1){throw new IllegalArgumentException('Both dimensions must be greater than 0');}if(undefined===rowSize||null===rowSize){rowSize=Math.floor((width+31)/32);}this.rowSize=rowSize;if(undefined===bits||null===bits){this.bits=new Int32Array(this.rowSize*this.height);}}/** * Interprets a 2D array of booleans as a {@link BitMatrix}, where "true" means an "on" bit. * * @function parse * @param image bits of the image, as a row-major 2D array. Elements are arrays representing rows * @return {@link BitMatrix} representation of image */_createClass(BitMatrix,[{key:"get",value:/** *Gets the requested bit, where true means black.
* * @param x The horizontal component (i.e. which column) * @param y The vertical component (i.e. which row) * @return value of given bit in matrix */function get(x/*int*/,y/*int*/){var offset=y*this.rowSize+Math.floor(x/32);return(this.bits[offset]>>>(x&0x1f)&1)!==0;}/** *Sets the given bit to true.
* * @param x The horizontal component (i.e. which column) * @param y The vertical component (i.e. which row) */},{key:"set",value:function set(x/*int*/,y/*int*/){var offset=y*this.rowSize+Math.floor(x/32);this.bits[offset]|=1<<(x&0x1f)&0xFFFFFFFF;}},{key:"unset",value:function unset(x/*int*/,y/*int*/){var offset=y*this.rowSize+Math.floor(x/32);this.bits[offset]&=~(1<<(x&0x1f)&0xFFFFFFFF);}/** *Flips the given bit.
* * @param x The horizontal component (i.e. which column) * @param y The vertical component (i.e. which row) */},{key:"flip",value:function flip(x/*int*/,y/*int*/){var offset=y*this.rowSize+Math.floor(x/32);this.bits[offset]^=1<<(x&0x1f)&0xFFFFFFFF;}/** * Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the corresponding * mask bit is set. * * @param mask XOR mask */},{key:"xor",value:function xor(mask){if(this.width!==mask.getWidth()||this.height!==mask.getHeight()||this.rowSize!==mask.getRowSize()){throw new IllegalArgumentException('input matrix dimensions do not match');}var rowArray=new BitArray(Math.floor(this.width/32)+1);var rowSize=this.rowSize;var bits=this.bits;for(var y=0,height=this.height;yEncapsulates the result of decoding a barcode within an image.
* * @author Sean Owen */var Result=/*#__PURE__*/function(){// public constructor(private text: string, // Uint8Array rawBytes, // ResultPoconst resultPoints: Int32Array, // BarcodeFormat format) { // this(text, rawBytes, resultPoints, format, System.currentTimeMillis()) // } // public constructor(text: string, // Uint8Array rawBytes, // ResultPoconst resultPoints: Int32Array, // BarcodeFormat format, // long timestamp) { // this(text, rawBytes, rawBytes == null ? 0 : 8 * rawBytes.length, // resultPoints, format, timestamp) // } function Result(text,rawBytes){var numBits=arguments.length>2&&arguments[2]!==undefined?arguments[2]:rawBytes==null?0:8*rawBytes.length;var resultPoints=arguments.length>3?arguments[3]:undefined;var format=arguments.length>4?arguments[4]:undefined;var timestamp=arguments.length>5&&arguments[5]!==undefined?arguments[5]:System.currentTimeMillis();_classCallCheck(this,Result);this.text=text;this.rawBytes=rawBytes;this.numBits=numBits;this.resultPoints=resultPoints;this.format=format;this.timestamp=timestamp;this.text=text;this.rawBytes=rawBytes;if(undefined===numBits||null===numBits){this.numBits=rawBytes===null||rawBytes===undefined?0:8*rawBytes.length;}else{this.numBits=numBits;}this.resultPoints=resultPoints;this.format=format;this.resultMetadata=null;if(undefined===timestamp||null===timestamp){this.timestamp=System.currentTimeMillis();}else{this.timestamp=timestamp;}}/** * @return raw text encoded by the barcode */_createClass(Result,[{key:"getText",value:function getText(){return this.text;}/** * @return raw bytes encoded by the barcode, if applicable, otherwise {@code null} */},{key:"getRawBytes",value:function getRawBytes(){return this.rawBytes;}/** * @return how many bits of {@link #getRawBytes()} are valid; typically 8 times its length * @since 3.3.0 */},{key:"getNumBits",value:function getNumBits(){return this.numBits;}/** * @return points related to the barcode in the image. These are typically points * identifying finder patterns or the corners of the barcode. The exact meaning is * specific to the type of barcode that was decoded. */},{key:"getResultPoints",value:function getResultPoints(){return this.resultPoints;}/** * @return {@link BarcodeFormat} representing the format of the barcode that was decoded */},{key:"getBarcodeFormat",value:function getBarcodeFormat(){return this.format;}/** * @return {@link Map} mapping {@link ResultMetadataType} keys to values. May be * {@code null}. This contains optional metadata about what was detected about the barcode, * like orientation. */},{key:"getResultMetadata",value:function getResultMetadata(){return this.resultMetadata;}},{key:"putMetadata",value:function putMetadata(type,value){if(this.resultMetadata===null){this.resultMetadata=new Map();}this.resultMetadata.set(type,value);}},{key:"putAllMetadata",value:function putAllMetadata(metadata){if(metadata!==null){if(this.resultMetadata===null){this.resultMetadata=metadata;}else{this.resultMetadata=new Map(metadata);}}}},{key:"addResultPoints",value:function addResultPoints(newPoints){var oldPoints=this.resultPoints;if(oldPoints===null){this.resultPoints=newPoints;}else if(newPoints!==null&&newPoints.length>0){var allPoints=new Array(oldPoints.length+newPoints.length);System.arraycopy(oldPoints,0,allPoints,0,oldPoints.length);System.arraycopy(newPoints,0,allPoints,oldPoints.length,newPoints.length);this.resultPoints=allPoints;}}},{key:"getTimestamp",value:function getTimestamp(){return this.timestamp;}/*@Override*/},{key:"toString",value:function toString(){return this.text;}}]);return Result;}();/* * Direct port to TypeScript of ZXing by Adrian Toșcă */ /* * Copyright 2009 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /*namespace com.google.zxing {*/ /** * Enumerates barcode formats known to this package. Please keep alphabetized. * * @author Sean Owen */var BarcodeFormat;(function(BarcodeFormat){/** Aztec 2D barcode format. */BarcodeFormat[BarcodeFormat["AZTEC"]=0]="AZTEC";/** CODABAR 1D format. */BarcodeFormat[BarcodeFormat["CODABAR"]=1]="CODABAR";/** Code 39 1D format. */BarcodeFormat[BarcodeFormat["CODE_39"]=2]="CODE_39";/** Code 93 1D format. */BarcodeFormat[BarcodeFormat["CODE_93"]=3]="CODE_93";/** Code 128 1D format. */BarcodeFormat[BarcodeFormat["CODE_128"]=4]="CODE_128";/** Data Matrix 2D barcode format. */BarcodeFormat[BarcodeFormat["DATA_MATRIX"]=5]="DATA_MATRIX";/** EAN-8 1D format. */BarcodeFormat[BarcodeFormat["EAN_8"]=6]="EAN_8";/** EAN-13 1D format. */BarcodeFormat[BarcodeFormat["EAN_13"]=7]="EAN_13";/** ITF (Interleaved Two of Five) 1D format. */BarcodeFormat[BarcodeFormat["ITF"]=8]="ITF";/** MaxiCode 2D barcode format. */BarcodeFormat[BarcodeFormat["MAXICODE"]=9]="MAXICODE";/** PDF417 format. */BarcodeFormat[BarcodeFormat["PDF_417"]=10]="PDF_417";/** QR Code 2D barcode format. */BarcodeFormat[BarcodeFormat["QR_CODE"]=11]="QR_CODE";/** RSS 14 */BarcodeFormat[BarcodeFormat["RSS_14"]=12]="RSS_14";/** RSS EXPANDED */BarcodeFormat[BarcodeFormat["RSS_EXPANDED"]=13]="RSS_EXPANDED";/** UPC-A 1D format. */BarcodeFormat[BarcodeFormat["UPC_A"]=14]="UPC_A";/** UPC-E 1D format. */BarcodeFormat[BarcodeFormat["UPC_E"]=15]="UPC_E";/** UPC/EAN extension format. Not a stand-alone format. */BarcodeFormat[BarcodeFormat["UPC_EAN_EXTENSION"]=16]="UPC_EAN_EXTENSION";})(BarcodeFormat||(BarcodeFormat={}));var BarcodeFormat$1=BarcodeFormat;/*namespace com.google.zxing {*/ /** * Represents some type of metadata about the result of the decoding that the decoder * wishes to communicate back to the caller. * * @author Sean Owen */var ResultMetadataType;(function(ResultMetadataType){/** * Unspecified, application-specific metadata. Maps to an unspecified {@link Object}. */ResultMetadataType[ResultMetadataType["OTHER"]=0]="OTHER";/** * Denotes the likely approximate orientation of the barcode in the image. This value * is given as degrees rotated clockwise from the normal, upright orientation. * For example a 1D barcode which was found by reading top-to-bottom would be * said to have orientation "90". This key maps to an {@link Integer} whose * value is in the range [0,360). */ResultMetadataType[ResultMetadataType["ORIENTATION"]=1]="ORIENTATION";/** *2D barcode formats typically encode text, but allow for a sort of 'byte mode' * which is sometimes used to encode binary data. While {@link Result} makes available * the complete raw bytes in the barcode for these formats, it does not offer the bytes * from the byte segments alone.
* *This maps to a {@link java.util.List} of byte arrays corresponding to the * raw bytes in the byte segments in the barcode, in order.
*/ResultMetadataType[ResultMetadataType["BYTE_SEGMENTS"]=2]="BYTE_SEGMENTS";/** * Error correction level used, if applicable. The value type depends on the * format, but is typically a String. */ResultMetadataType[ResultMetadataType["ERROR_CORRECTION_LEVEL"]=3]="ERROR_CORRECTION_LEVEL";/** * For some periodicals, indicates the issue number as an {@link Integer}. */ResultMetadataType[ResultMetadataType["ISSUE_NUMBER"]=4]="ISSUE_NUMBER";/** * For some products, indicates the suggested retail price in the barcode as a * formatted {@link String}. */ResultMetadataType[ResultMetadataType["SUGGESTED_PRICE"]=5]="SUGGESTED_PRICE";/** * For some products, the possible country of manufacture as a {@link String} denoting the * ISO country code. Some map to multiple possible countries, like "US/CA". */ResultMetadataType[ResultMetadataType["POSSIBLE_COUNTRY"]=6]="POSSIBLE_COUNTRY";/** * For some products, the extension text */ResultMetadataType[ResultMetadataType["UPC_EAN_EXTENSION"]=7]="UPC_EAN_EXTENSION";/** * PDF417-specific metadata */ResultMetadataType[ResultMetadataType["PDF417_EXTRA_METADATA"]=8]="PDF417_EXTRA_METADATA";/** * If the code format supports structured append and the current scanned code is part of one then the * sequence number is given with it. */ResultMetadataType[ResultMetadataType["STRUCTURED_APPEND_SEQUENCE"]=9]="STRUCTURED_APPEND_SEQUENCE";/** * If the code format supports structured append and the current scanned code is part of one then the * parity is given with it. */ResultMetadataType[ResultMetadataType["STRUCTURED_APPEND_PARITY"]=10]="STRUCTURED_APPEND_PARITY";})(ResultMetadataType||(ResultMetadataType={}));var ResultMetadataType$1=ResultMetadataType;/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /*namespace com.google.zxing.common {*/ /*import java.util.List;*/ /** *Encapsulates the result of decoding a matrix of bits. This typically * applies to 2D barcode formats. For now it contains the raw bytes obtained, * as well as a String interpretation of those bytes, if applicable.
* * @author Sean Owen */var DecoderResult=/*#__PURE__*/function(){// public constructor(rawBytes: Uint8Array, // text: string, // ListThis class contains utility methods for performing mathematical operations over * the Galois Fields. Operations use a given primitive polynomial in calculations.
* *Throughout this package, elements of the GF are represented as an {@code int} * for convenience and speed (but at the cost of memory). *
* * @author Sean Owen * @author David Olivier */var AbstractGenericGF=/*#__PURE__*/function(){function AbstractGenericGF(){_classCallCheck(this,AbstractGenericGF);}_createClass(AbstractGenericGF,[{key:"exp",value:/** * @return 2 to the power of a in GF(size) */function exp(a){return this.expTable[a];}/** * @return base 2 log of a in GF(size) */},{key:"log",value:function log(a/*int*/){if(a===0){throw new IllegalArgumentException();}return this.logTable[a];}/** * Implements both addition and subtraction -- they are the same in GF(size). * * @return sum/difference of a and b */}],[{key:"addOrSubtract",value:function addOrSubtract(a/*int*/,b/*int*/){return a^b;}}]);return AbstractGenericGF;}();/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** *Represents a polynomial whose coefficients are elements of a GF. * Instances of this class are immutable.
* *Much credit is due to William Rucklidge since portions of this code are an indirect * port of his C++ Reed-Solomon implementation.
* * @author Sean Owen */var GenericGFPoly=/*#__PURE__*/function(){/** * @param field the {@link GenericGF} instance representing the field to use * to perform computations * @param coefficients coefficients as ints representing elements of GF(size), arranged * from most significant (highest-power term) coefficient to least significant * @throws IllegalArgumentException if argument is null or empty, * or if leading coefficient is 0 and this is not a * constant polynomial (that is, it is not the monomial "0") */function GenericGFPoly(field,coefficients){_classCallCheck(this,GenericGFPoly);if(coefficients.length===0){throw new IllegalArgumentException();}this.field=field;var coefficientsLength=coefficients.length;if(coefficientsLength>1&&coefficients[0]===0){// Leading term must be non-zero for anything except the constant polynomial "0" var firstNonZero=1;while(firstNonZeroThis class contains utility methods for performing mathematical operations over * the Galois Fields. Operations use a given primitive polynomial in calculations.
* *Throughout this package, elements of the GF are represented as an {@code int} * for convenience and speed (but at the cost of memory). *
* * @author Sean Owen * @author David Olivier */var GenericGF=/*#__PURE__*/function(_AbstractGenericGF){_inherits(GenericGF,_AbstractGenericGF);var _super16=_createSuper(GenericGF);/** * Create a representation of GF(size) using the given primitive polynomial. * * @param primitive irreducible polynomial whose coefficients are represented by * the bits of an int, where the least-significant bit represents the constant * coefficient * @param size the size of the field * @param b the factor b in the generator polynomial can be 0- or 1-based * (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))). * In most cases it should be 1, but for QR code it is 0. */function GenericGF(primitive/*int*/,size/*int*/,generatorBase/*int*/){var _this13;_classCallCheck(this,GenericGF);_this13=_super16.call(this);_this13.primitive=primitive;_this13.size=size;_this13.generatorBase=generatorBase;var expTable=new Int32Array(size);var x=1;for(var i=0;iThe algorithm will not be explained here, but the following references were helpful * in creating this implementation:
* *Much credit is due to William Rucklidge since portions of this code are an indirect * port of his C++ Reed-Solomon implementation.
* * @author Sean Owen * @author William Rucklidge * @author sanfordsquires */var ReedSolomonDecoder=/*#__PURE__*/function(){function ReedSolomonDecoder(field){_classCallCheck(this,ReedSolomonDecoder);this.field=field;}/** *Decodes given set of received codewords, which include both data and error-correction * codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place, * in the input.
* * @param received data and error-correction codewords * @param twoS number of error-correction codewords available * @throws ReedSolomonException if decoding fails for any reason */_createClass(ReedSolomonDecoder,[{key:"decode",value:function decode(received,twoS/*int*/){var field=this.field;var poly=new GenericGFPoly(field,received);var syndromeCoefficients=new Int32Array(twoS);var noError=true;for(var i=0;iPerforms RS error correction on an array of bits.
* * @return the corrected array * @throws FormatException if the input contains too many errors */function correctBits(rawbits){var gf;var codewordSize;if(this.ddata.getNbLayers()<=2){codewordSize=6;gf=GenericGF.AZTEC_DATA_6;}else if(this.ddata.getNbLayers()<=8){codewordSize=8;gf=GenericGF.AZTEC_DATA_8;}else if(this.ddata.getNbLayers()<=22){codewordSize=10;gf=GenericGF.AZTEC_DATA_10;}else{codewordSize=12;gf=GenericGF.AZTEC_DATA_12;}var numDataCodewords=this.ddata.getNbDatablocks();var numCodewords=rawbits.length/codewordSize;if(numCodewordsEncapsulates a point of interest in an image containing a barcode. Typically, this * would be the location of a finder pattern or the corner of the barcode, for example.
* * @author Sean Owen */var ResultPoint=/*#__PURE__*/function(){function ResultPoint(x,y){_classCallCheck(this,ResultPoint);this.x=x;this.y=y;}_createClass(ResultPoint,[{key:"getX",value:function getX(){return this.x;}},{key:"getY",value:function getY(){return this.y;}/*@Override*/},{key:"equals",value:function equals(other){if(other instanceof ResultPoint){var otherPoint=other;return this.x===otherPoint.x&&this.y===otherPoint.y;}return false;}/*@Override*/},{key:"hashCode",value:function hashCode(){return 31*Float.floatToIntBits(this.x)+Float.floatToIntBits(this.y);}/*@Override*/},{key:"toString",value:function toString(){return'('+this.x+','+this.y+')';}/** * Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC * and BC is less than AC, and the angle between BC and BA is less than 180 degrees. * * @param patterns array of three {@code ResultPoint} to order */}],[{key:"orderBestPatterns",value:function orderBestPatterns(patterns){// Find distances between pattern centers var zeroOneDistance=this.distance(patterns[0],patterns[1]);var oneTwoDistance=this.distance(patterns[1],patterns[2]);var zeroTwoDistance=this.distance(patterns[0],patterns[2]);var pointA;var pointB;var pointC;// Assume one closest to other two is B; A and C will just be guesses at first if(oneTwoDistance>=zeroOneDistance&&oneTwoDistance>=zeroTwoDistance){pointB=patterns[0];pointA=patterns[1];pointC=patterns[2];}else if(zeroTwoDistance>=oneTwoDistance&&zeroTwoDistance>=zeroOneDistance){pointB=patterns[1];pointA=patterns[0];pointC=patterns[2];}else{pointB=patterns[2];pointA=patterns[0];pointC=patterns[1];}// Use cross product to figure out whether A and C are correct or flipped. // This asks whether BC x BA has a positive z component, which is the arrangement // we want for A, B, C. If it's negative, then we've got it flipped around and // should swap A and C. if(this.crossProductZ(pointA,pointB,pointC)<0.0){var temp=pointA;pointA=pointC;pointC=temp;}patterns[0]=pointA;patterns[1]=pointB;patterns[2]=pointC;}/** * @param pattern1 first pattern * @param pattern2 second pattern * @return distance between two points */},{key:"distance",value:function distance(pattern1,pattern2){return MathUtils.distance(pattern1.x,pattern1.y,pattern2.x,pattern2.y);}/** * Returns the z component of the cross product between vectors BC and BA. */},{key:"crossProductZ",value:function crossProductZ(pointA,pointB,pointC){var bX=pointB.x;var bY=pointB.y;return(pointC.x-bX)*(pointA.y-bY)-(pointC.y-bY)*(pointA.x-bX);}}]);return ResultPoint;}();/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** *Encapsulates the result of detecting a barcode in an image. This includes the raw * matrix of black/white pixels corresponding to the barcode, and possibly points of interest * in the image, like the location of finder patterns or corners of the barcode in the image.
* * @author Sean Owen */var DetectorResult=/*#__PURE__*/function(){function DetectorResult(bits,points){_classCallCheck(this,DetectorResult);this.bits=bits;this.points=points;}_createClass(DetectorResult,[{key:"getBits",value:function getBits(){return this.bits;}},{key:"getPoints",value:function getPoints(){return this.points;}}]);return DetectorResult;}();/* * Copyright 2010 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** *Extends {@link DetectorResult} with more information specific to the Aztec format, * like the number of layers and whether it's compact.
* * @author Sean Owen */var AztecDetectorResult=/*#__PURE__*/function(_DetectorResult){_inherits(AztecDetectorResult,_DetectorResult);var _super19=_createSuper(AztecDetectorResult);function AztecDetectorResult(bits,points,compact,nbDatablocks,nbLayers){var _this14;_classCallCheck(this,AztecDetectorResult);_this14=_super19.call(this,bits,points);_this14.compact=compact;_this14.nbDatablocks=nbDatablocks;_this14.nbLayers=nbLayers;return _this14;}_createClass(AztecDetectorResult,[{key:"getNbLayers",value:function getNbLayers(){return this.nbLayers;}},{key:"getNbDatablocks",value:function getNbDatablocks(){return this.nbDatablocks;}},{key:"isCompact",value:function isCompact(){return this.compact;}}]);return AztecDetectorResult;}(DetectorResult);/* * Copyright 2010 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** ** Detects a candidate barcode-like rectangular region within an image. It * starts around the center of the image, increases the size of the candidate * region until it finds a white rectangular region. By keeping track of the * last black points it encountered, it determines the corners of the barcode. *
* * @author David Olivier */var WhiteRectangleDetector=/*#__PURE__*/function(){// public constructor(private image: BitMatrix) /*throws NotFoundException*/ { // this(image, INIT_SIZE, image.getWidth() / 2, image.getHeight() / 2) // } /** * @param image barcode image to find a rectangle in * @param initSize initial size of search area around center * @param x x position of search center * @param y y position of search center * @throws NotFoundException if image is too small to accommodate {@code initSize} */function WhiteRectangleDetector(image,initSize/*int*/,x/*int*/,y/*int*/){_classCallCheck(this,WhiteRectangleDetector);this.image=image;this.height=image.getHeight();this.width=image.getWidth();if(undefined===initSize||null===initSize){initSize=WhiteRectangleDetector.INIT_SIZE;}if(undefined===x||null===x){x=image.getWidth()/2|0;}if(undefined===y||null===y){y=image.getHeight()/2|0;}var halfsize=initSize/2|0;this.leftInit=x-halfsize;this.rightInit=x+halfsize;this.upInit=y-halfsize;this.downInit=y+halfsize;if(this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width){throw new NotFoundException();}}/** ** Detects a candidate barcode-like rectangular region within an image. It * starts around the center of the image, increases the size of the candidate * region until it finds a white rectangular region. *
* * @return {@link ResultPoint}[] describing the corners of the rectangular * region. The first and last points are opposed on the diagonal, as * are the second and third. The first point will be the topmost * point and the last, the bottommost. The second point will be * leftmost and the third, the rightmost * @throws NotFoundException if no Data Matrix Code can be found */_createClass(WhiteRectangleDetector,[{key:"detect",value:function detect(){var left=this.leftInit;var right=this.rightInit;var up=this.upInit;var down=this.downInit;var sizeExceeded=false;var aBlackPointFoundOnBorder=true;var atLeastOneBlackPointFoundOnBorder=false;var atLeastOneBlackPointFoundOnRight=false;var atLeastOneBlackPointFoundOnBottom=false;var atLeastOneBlackPointFoundOnLeft=false;var atLeastOneBlackPointFoundOnTop=false;var width=this.width;var height=this.height;while(aBlackPointFoundOnBorder){aBlackPointFoundOnBorder=false;// ..... // . | // ..... var rightBorderNotWhite=true;while((rightBorderNotWhite||!atLeastOneBlackPointFoundOnRight)&&rightThis method will actually "nudge" the endpoints back onto the image if they are found to be * barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder * patterns in an image where the QR Code runs all the way to the image border.
* *For efficiency, the method will check points from either end of the line until one is found * to be within the image. Because the set of points are assumed to be linear, this is valid.
* * @param image image into which the points should map * @param points actual points in x1,y1,...,xn,yn form * @throws NotFoundException if an endpoint is lies outside the image boundaries */function checkAndNudgePoints(image,points){var width=image.getWidth();var height=image.getHeight();// Check and nudge points from start until we see some that are OK: var nudged=true;for(var offset=0;offsetThis class implements a perspective transform in two dimensions. Given four source and four * destination points, it will compute the transformation implied between them. The code is based * directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.
* * @author Sean Owen */var PerspectiveTransform=/*#__PURE__*/function(){function PerspectiveTransform(a11/*float*/,a21/*float*/,a31/*float*/,a12/*float*/,a22/*float*/,a32/*float*/,a13/*float*/,a23/*float*/,a33/*float*/){_classCallCheck(this,PerspectiveTransform);this.a11=a11;this.a21=a21;this.a31=a31;this.a12=a12;this.a22=a22;this.a32=a32;this.a13=a13;this.a23=a23;this.a33=a33;}_createClass(PerspectiveTransform,[{key:"transformPoints",value:function transformPoints(points){var max=points.length;var a11=this.a11;var a12=this.a12;var a13=this.a13;var a21=this.a21;var a22=this.a22;var a23=this.a23;var a31=this.a31;var a32=this.a32;var a33=this.a33;for(var i=0;iDecodes Code 128 barcodes.
* * @author Sean Owen */var Code128Reader=/*#__PURE__*/function(_OneDReader){_inherits(Code128Reader,_OneDReader);var _super22=_createSuper(Code128Reader);function Code128Reader(){_classCallCheck(this,Code128Reader);return _super22.apply(this,arguments);}_createClass(Code128Reader,[{key:"decodeRow",value:function decodeRow(rowNumber,row,hints){var convertFNC1=hints&&hints.get(DecodeHintType$1.ASSUME_GS1)===true;var startPatternInfo=Code128Reader.findStartPattern(row);var startCode=startPatternInfo[2];var currentRawCodesIndex=0;var rawCodes=new Uint8Array(20);rawCodes[currentRawCodesIndex++]=startCode;var codeSet;switch(startCode){case Code128Reader.CODE_START_A:codeSet=Code128Reader.CODE_CODE_A;break;case Code128Reader.CODE_START_B:codeSet=Code128Reader.CODE_CODE_B;break;case Code128Reader.CODE_START_C:codeSet=Code128Reader.CODE_CODE_C;break;default:throw new FormatException();}var done=false;var isNextShifted=false;var result='';var lastStart=startPatternInfo[0];var nextStart=startPatternInfo[1];var counters=Int32Array.from([0,0,0,0,0,0]);var lastCode=0;var code=0;var checksumTotal=startCode;var multiplier=0;var lastCharacterWasPrintable=true;var upperMode=false;var shiftUpperMode=false;while(!done){var unshift=isNextShifted;isNextShifted=false;// Save off last code lastCode=code;// Decode another code from image code=Code128Reader.decodeCode(row,counters,nextStart);rawCodes[currentRawCodesIndex++]=code;// Remember whether the last code was printable or not (excluding CODE_STOP) if(code!==Code128Reader.CODE_STOP){lastCharacterWasPrintable=true;}// Add to checksum computation (if not CODE_STOP of course) if(code!==Code128Reader.CODE_STOP){multiplier++;checksumTotal+=multiplier*code;}// Advance to where the next code will to start lastStart=nextStart;nextStart+=counters.reduce(function(previous,current){return previous+current;},0);// Take care of illegal start codes switch(code){case Code128Reader.CODE_START_A:case Code128Reader.CODE_START_B:case Code128Reader.CODE_START_C:throw new FormatException();}switch(codeSet){case Code128Reader.CODE_CODE_A:if(code<64){if(shiftUpperMode===upperMode){result+=String.fromCharCode(' '.charCodeAt(0)+code);}else{result+=String.fromCharCode(' '.charCodeAt(0)+code+128);}shiftUpperMode=false;}else if(code<96){if(shiftUpperMode===upperMode){result+=String.fromCharCode(code-64);}else{result+=String.fromCharCode(code+64);}shiftUpperMode=false;}else{// Don't let CODE_STOP, which always appears, affect whether whether we think the last // code was printable or not. if(code!==Code128Reader.CODE_STOP){lastCharacterWasPrintable=false;}switch(code){case Code128Reader.CODE_FNC_1:if(convertFNC1){if(result.length===0){// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code // is FNC1 then this is GS1-128. We add the symbology identifier. result+=']C1';}else{// GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) result+=String.fromCharCode(29);}}break;case Code128Reader.CODE_FNC_2:case Code128Reader.CODE_FNC_3:// do nothing? break;case Code128Reader.CODE_FNC_4_A:if(!upperMode&&shiftUpperMode){upperMode=true;shiftUpperMode=false;}else if(upperMode&&shiftUpperMode){upperMode=false;shiftUpperMode=false;}else{shiftUpperMode=true;}break;case Code128Reader.CODE_SHIFT:isNextShifted=true;codeSet=Code128Reader.CODE_CODE_B;break;case Code128Reader.CODE_CODE_B:codeSet=Code128Reader.CODE_CODE_B;break;case Code128Reader.CODE_CODE_C:codeSet=Code128Reader.CODE_CODE_C;break;case Code128Reader.CODE_STOP:done=true;break;}}break;case Code128Reader.CODE_CODE_B:if(code<96){if(shiftUpperMode===upperMode){result+=String.fromCharCode(' '.charCodeAt(0)+code);}else{result+=String.fromCharCode(' '.charCodeAt(0)+code+128);}shiftUpperMode=false;}else{if(code!==Code128Reader.CODE_STOP){lastCharacterWasPrintable=false;}switch(code){case Code128Reader.CODE_FNC_1:if(convertFNC1){if(result.length===0){// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code // is FNC1 then this is GS1-128. We add the symbology identifier. result+=']C1';}else{// GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) result+=String.fromCharCode(29);}}break;case Code128Reader.CODE_FNC_2:case Code128Reader.CODE_FNC_3:// do nothing? break;case Code128Reader.CODE_FNC_4_B:if(!upperMode&&shiftUpperMode){upperMode=true;shiftUpperMode=false;}else if(upperMode&&shiftUpperMode){upperMode=false;shiftUpperMode=false;}else{shiftUpperMode=true;}break;case Code128Reader.CODE_SHIFT:isNextShifted=true;codeSet=Code128Reader.CODE_CODE_A;break;case Code128Reader.CODE_CODE_A:codeSet=Code128Reader.CODE_CODE_A;break;case Code128Reader.CODE_CODE_C:codeSet=Code128Reader.CODE_CODE_C;break;case Code128Reader.CODE_STOP:done=true;break;}}break;case Code128Reader.CODE_CODE_C:if(code<100){if(code<10){result+='0';}result+=code;}else{if(code!==Code128Reader.CODE_STOP){lastCharacterWasPrintable=false;}switch(code){case Code128Reader.CODE_FNC_1:if(convertFNC1){if(result.length===0){// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code // is FNC1 then this is GS1-128. We add the symbology identifier. result+=']C1';}else{// GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) result+=String.fromCharCode(29);}}break;case Code128Reader.CODE_CODE_A:codeSet=Code128Reader.CODE_CODE_A;break;case Code128Reader.CODE_CODE_B:codeSet=Code128Reader.CODE_CODE_B;break;case Code128Reader.CODE_STOP:done=true;break;}}break;}// Unshift back to another code set if we were shifted if(unshift){codeSet=codeSet===Code128Reader.CODE_CODE_A?Code128Reader.CODE_CODE_B:Code128Reader.CODE_CODE_A;}}var lastPatternSize=nextStart-lastStart;// Check for ample whitespace following pattern, but, to do this we first need to remember that // we fudged decoding CODE_STOP since it actually has 7 bars, not 6. There is a black bar left // to read off. Would be slightly better to properly read. Here we just skip it: nextStart=row.getNextUnset(nextStart);if(!row.isRange(nextStart,Math.min(row.getSize(),nextStart+(nextStart-lastStart)/2),false)){throw new NotFoundException();}// Pull out from sum the value of the penultimate check code checksumTotal-=multiplier*lastCode;// lastCode is the checksum then: if(checksumTotal%103!==lastCode){throw new ChecksumException();}// Need to pull out the check digits from string var resultLength=result.length;if(resultLength===0){// false positive throw new NotFoundException();}// Only bother if the result had at least one character, and if the checksum digit happened to // be a printable character. If it was just interpreted as a control code, nothing to remove. if(resultLength>0&&lastCharacterWasPrintable){if(codeSet===Code128Reader.CODE_CODE_C){result=result.substring(0,resultLength-2);}else{result=result.substring(0,resultLength-1);}}var left=(startPatternInfo[1]+startPatternInfo[0])/2.0;var right=lastStart+lastPatternSize/2.0;var rawCodesSize=rawCodes.length;var rawBytes=new Uint8Array(rawCodesSize);for(var i=0;iDecodes Code 39 barcodes. Supports "Full ASCII Code 39" if USE_CODE_39_EXTENDED_MODE is set.
* * @author Sean Owen * @see Code93Reader */var Code39Reader=/*#__PURE__*/function(_OneDReader2){_inherits(Code39Reader,_OneDReader2);var _super23=_createSuper(Code39Reader);/** * Creates a reader that assumes all encoded data is data, and does not treat the final * character as a check digit. It will not decoded "extended Code 39" sequences. */ // public Code39Reader() { // this(false); // } /** * Creates a reader that can be configured to check the last character as a check digit. * It will not decoded "extended Code 39" sequences. * * @param usingCheckDigit if true, treat the last data character as a check digit, not * data, and verify that the checksum passes. */ // public Code39Reader(boolean usingCheckDigit) { // this(usingCheckDigit, false); // } /** * Creates a reader that can be configured to check the last character as a check digit, * or optionally attempt to decode "extended Code 39" sequences that are used to encode * the full ASCII character set. * * @param usingCheckDigit if true, treat the last data character as a check digit, not * data, and verify that the checksum passes. * @param extendedMode if true, will attempt to decode extended Code 39 sequences in the * text. */function Code39Reader(){var _this15;var usingCheckDigit=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var extendedMode=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;_classCallCheck(this,Code39Reader);_this15=_super23.call(this);_this15.usingCheckDigit=usingCheckDigit;_this15.extendedMode=extendedMode;_this15.decodeRowResult='';_this15.counters=new Int32Array(9);return _this15;}_createClass(Code39Reader,[{key:"decodeRow",value:function decodeRow(rowNumber,row,hints){var theCounters=this.counters;theCounters.fill(0);this.decodeRowResult='';var start=Code39Reader.findAsteriskPattern(row,theCounters);// Read off white space var nextStart=row.getNextSet(start[1]);var end=row.getSize();var decodedChar;var lastStart;do{Code39Reader.recordPattern(row,nextStart,theCounters);var pattern=Code39Reader.toNarrowWidePattern(theCounters);if(pattern<0){throw new NotFoundException();}decodedChar=Code39Reader.patternToChar(pattern);this.decodeRowResult+=decodedChar;lastStart=nextStart;var _iterator3=_createForOfIteratorHelper(theCounters),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var counter=_step3.value;nextStart+=counter;}// Read off white space }catch(err){_iterator3.e(err);}finally{_iterator3.f();}nextStart=row.getNextSet(nextStart);}while(decodedChar!=='*');this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);// remove asterisk // Look for whitespace after pattern: var lastPatternSize=0;var _iterator4=_createForOfIteratorHelper(theCounters),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var _counter=_step4.value;lastPatternSize+=_counter;}}catch(err){_iterator4.e(err);}finally{_iterator4.f();}var whiteSpaceAfterEnd=nextStart-lastStart-lastPatternSize;// If 50% of last pattern size, following last pattern, is not whitespace, fail // (but if it's whitespace to the very end of the image, that's OK) if(nextStart!==end&&whiteSpaceAfterEnd*2Decodes ITF barcodes.
* * @author Tjieco */var ITFReader=/*#__PURE__*/function(_OneDReader3){_inherits(ITFReader,_OneDReader3);var _super24=_createSuper(ITFReader);function ITFReader(){var _this16;_classCallCheck(this,ITFReader);// private static W = 3; // Pixel width of a 3x wide line // private static w = 2; // Pixel width of a 2x wide line // private static N = 1; // Pixed width of a narrow line _this16=_super24.apply(this,arguments);// Stores the actual narrow line width of the image being decoded. _this16.narrowLineWidth=-1;return _this16;}// See ITFWriter.PATTERNS /* /!** * Patterns of Wide / Narrow lines to indicate each digit *!/ */_createClass(ITFReader,[{key:"decodeRow",value:function decodeRow(rowNumber,row,hints){// Find out where the Middle section (payload) starts & ends var startRange=this.decodeStart(row);var endRange=this.decodeEnd(row);var result=new StringBuilder();ITFReader.decodeMiddle(row,startRange[1],endRange[0],result);var resultString=result.toString();var allowedLengths=null;if(hints!=null){allowedLengths=hints.get(DecodeHintType$1.ALLOWED_LENGTHS);}if(allowedLengths==null){allowedLengths=ITFReader.DEFAULT_ALLOWED_LENGTHS;}// To avoid false positives with 2D barcodes (and other patterns), make // an assumption that the decoded string must be a 'standard' length if it's short var length=resultString.length;var lengthOK=false;var maxAllowedLength=0;var _iterator6=_createForOfIteratorHelper(allowedLengths),_step6;try{for(_iterator6.s();!(_step6=_iterator6.n()).done;){var value=_step6.value;if(length===value){lengthOK=true;break;}if(value>maxAllowedLength){maxAllowedLength=value;}}}catch(err){_iterator6.e(err);}finally{_iterator6.f();}if(!lengthOK&&length>maxAllowedLength){lengthOK=true;}if(!lengthOK){throw new FormatException();}var points=[new ResultPoint(startRange[1],rowNumber),new ResultPoint(endRange[0],rowNumber)];var resultReturn=new Result(resultString,null,// no natural byte representation for these barcodes 0,points,BarcodeFormat$1.ITF,new Date().getTime());return resultReturn;}/* /!** * @param row row of black/white values to search * @param payloadStart offset of start pattern * @param resultString {@link StringBuilder} to append decoded chars to * @throws NotFoundException if decoding could not complete successfully *!/*/},{key:"decodeStart",value:/*/!** * Identify where the start of the middle / payload section starts. * * @param row row of black/white values to search * @return Array, containing index of start of 'start block' and end of * 'start block' *!/*/function decodeStart(row){var endStart=ITFReader.skipWhiteSpace(row);var startPattern=ITFReader.findGuardPattern(row,endStart,ITFReader.START_PATTERN);// Determine the width of a narrow line in pixels. We can do this by // getting the width of the start pattern and dividing by 4 because its // made up of 4 narrow lines. this.narrowLineWidth=(startPattern[1]-startPattern[0])/4;this.validateQuietZone(row,startPattern[0]);return startPattern;}/*/!** * The start & end patterns must be pre/post fixed by a quiet zone. This * zone must be at least 10 times the width of a narrow line. Scan back until * we either get to the start of the barcode or match the necessary number of * quiet zone pixels. * * Note: Its assumed the row is reversed when using this method to find * quiet zone after the end pattern. * * ref: http://www.barcode-1.net/i25code.html * * @param row bit array representing the scanned barcode. * @param startPattern index into row of the start or end pattern. * @throws NotFoundException if the quiet zone cannot be found *!/*/},{key:"validateQuietZone",value:function validateQuietZone(row,startPattern){var quietCount=this.narrowLineWidth*10;// expect to find this many pixels of quiet zone // if there are not so many pixel at all let's try as many as possible quietCount=quietCountEncapsulates functionality and implementation that is common to UPC and EAN families * of one-dimensional barcodes.
* * @author dswitkin@google.com (Daniel Switkin) * @author Sean Owen * @author alasdair@google.com (Alasdair Mackintosh) */var AbstractUPCEANReader=/*#__PURE__*/function(_OneDReader4){_inherits(AbstractUPCEANReader,_OneDReader4);var _super25=_createSuper(AbstractUPCEANReader);function AbstractUPCEANReader(){var _this17;_classCallCheck(this,AbstractUPCEANReader);_this17=_super25.apply(this,arguments);_this17.decodeRowStringBuffer='';return _this17;}_createClass(AbstractUPCEANReader,null,[{key:"findStartGuardPattern",value:function findStartGuardPattern(row){var foundStart=false;var startRange;var nextStart=0;var counters=Int32Array.from([0,0,0]);while(!foundStart){counters=Int32Array.from([0,0,0]);startRange=AbstractUPCEANReader.findGuardPattern(row,nextStart,false,this.START_END_PATTERN,counters);var start=startRange[0];nextStart=startRange[1];var quietStart=start-(nextStart-start);if(quietStart>=0){foundStart=row.isRange(quietStart,start,false);}}return startRange;}},{key:"checkChecksum",value:function checkChecksum(s){return AbstractUPCEANReader.checkStandardUPCEANChecksum(s);}},{key:"checkStandardUPCEANChecksum",value:function checkStandardUPCEANChecksum(s){var length=s.length;if(length===0)return false;var check=parseInt(s.charAt(length-1),10);return AbstractUPCEANReader.getStandardUPCEANChecksum(s.substring(0,length-1))===check;}},{key:"getStandardUPCEANChecksum",value:function getStandardUPCEANChecksum(s){var length=s.length;var sum=0;for(var i=length-1;i>=0;i-=2){var digit=s.charAt(i).charCodeAt(0)-'0'.charCodeAt(0);if(digit<0||digit>9){throw new FormatException();}sum+=digit;}sum*=3;for(var _i15=length-2;_i15>=0;_i15-=2){var _digit=s.charAt(_i15).charCodeAt(0)-'0'.charCodeAt(0);if(_digit<0||_digit>9){throw new FormatException();}sum+=_digit;}return(1000-sum)%10;}},{key:"decodeEnd",value:function decodeEnd(row,endStart){return AbstractUPCEANReader.findGuardPattern(row,endStart,false,AbstractUPCEANReader.START_END_PATTERN,new Int32Array(AbstractUPCEANReader.START_END_PATTERN.length).fill(0));}/** * @throws NotFoundException */},{key:"findGuardPatternWithoutCounters",value:function findGuardPatternWithoutCounters(row,rowOffset,whiteFirst,pattern){return this.findGuardPattern(row,rowOffset,whiteFirst,pattern,new Int32Array(pattern.length));}/** * @param row row of black/white values to search * @param rowOffset position to start search * @param whiteFirst if true, indicates that the pattern specifies white/black/white/... * pixel counts, otherwise, it is interpreted as black/white/black/... * @param pattern pattern of counts of number of black and white pixels that are being * searched for as a pattern * @param counters array of counters, as long as pattern, to re-use * @return start/end horizontal offset of guard pattern, as an array of two ints * @throws NotFoundException if pattern is not found */},{key:"findGuardPattern",value:function findGuardPattern(row,rowOffset,whiteFirst,pattern,counters){var width=row.getSize();rowOffset=whiteFirst?row.getNextUnset(rowOffset):row.getNextSet(rowOffset);var counterPosition=0;var patternStart=rowOffset;var patternLength=pattern.length;var isWhite=whiteFirst;for(var x=rowOffset;xEncapsulates functionality and implementation that is common to UPC and EAN families * of one-dimensional barcodes.
* * @author dswitkin@google.com (Daniel Switkin) * @author Sean Owen * @author alasdair@google.com (Alasdair Mackintosh) */var UPCEANReader=/*#__PURE__*/function(_AbstractUPCEANReader){_inherits(UPCEANReader,_AbstractUPCEANReader);var _super26=_createSuper(UPCEANReader);function UPCEANReader(){var _this18;_classCallCheck(this,UPCEANReader);_this18=_super26.call(this);_this18.decodeRowStringBuffer='';UPCEANReader.L_AND_G_PATTERNS=UPCEANReader.L_PATTERNS.map(function(arr){return Int32Array.from(arr);});for(var i=10;i<20;i++){var widths=UPCEANReader.L_PATTERNS[i-10];var reversedWidths=new Int32Array(widths.length);for(var j=0;jImplements decoding of the EAN-13 format.
* * @author dswitkin@google.com (Daniel Switkin) * @author Sean Owen * @author alasdair@google.com (Alasdair Mackintosh) */var EAN13Reader=/*#__PURE__*/function(_UPCEANReader){_inherits(EAN13Reader,_UPCEANReader);var _super27=_createSuper(EAN13Reader);function EAN13Reader(){var _this19;_classCallCheck(this,EAN13Reader);_this19=_super27.call(this);_this19.decodeMiddleCounters=Int32Array.from([0,0,0,0]);return _this19;}_createClass(EAN13Reader,[{key:"decodeMiddle",value:function decodeMiddle(row,startRange,resultString){var counters=this.decodeMiddleCounters;counters[0]=0;counters[1]=0;counters[2]=0;counters[3]=0;var end=row.getSize();var rowOffset=startRange[1];var lgPatternFound=0;for(var x=0;x<6&&rowOffsetThis is a great reference for * UPC-E information.
* * @author Sean Owen * * @source https://github.com/zxing/zxing/blob/3c96923276dd5785d58eb970b6ba3f80d36a9505/core/src/main/java/com/google/zxing/oned/UPCEReader.java * * @experimental */ /* final */var UPCEReader=/*#__PURE__*/function(_UPCEANReader4){_inherits(UPCEReader,_UPCEANReader4);var _super30=_createSuper(UPCEReader);function UPCEReader(){var _this22;_classCallCheck(this,UPCEReader);_this22=_super30.call(this);_this22.decodeMiddleCounters=new Int32Array(4);return _this22;}/** * @throws NotFoundException */ // @Override _createClass(UPCEReader,[{key:"decodeMiddle",value:function decodeMiddle(row,startRange,result){var counters=this.decodeMiddleCounters.map(function(x){return x;});counters[0]=0;counters[1]=0;counters[2]=0;counters[3]=0;var end=row.getSize();var rowOffset=startRange[1];var lgPatternFound=0;for(var x=0;x<6&&rowOffsetA reader that can read all available UPC/EAN formats. If a caller wants to try to * read all such formats, it is most efficient to use this implementation rather than invoke * individual readers.
* * @author Sean Owen */var MultiFormatUPCEANReader=/*#__PURE__*/function(_OneDReader5){_inherits(MultiFormatUPCEANReader,_OneDReader5);var _super31=_createSuper(MultiFormatUPCEANReader);function MultiFormatUPCEANReader(hints){var _this23;_classCallCheck(this,MultiFormatUPCEANReader);_this23=_super31.call(this);var possibleFormats=hints==null?null:hints.get(DecodeHintType$1.POSSIBLE_FORMATS);var readers=[];if(!isNullOrUndefined(possibleFormats)){if(possibleFormats.indexOf(BarcodeFormat$1.EAN_13)>-1){readers.push(new EAN13Reader());}if(possibleFormats.indexOf(BarcodeFormat$1.UPC_A)>-1){readers.push(new UPCAReader());}if(possibleFormats.indexOf(BarcodeFormat$1.EAN_8)>-1){readers.push(new EAN8Reader());}if(possibleFormats.indexOf(BarcodeFormat$1.UPC_E)>-1){readers.push(new UPCEReader());}}else{// No hints provided. readers.push(new EAN13Reader());readers.push(new UPCAReader());readers.push(new EAN8Reader());readers.push(new UPCEReader());}_this23.readers=readers;return _this23;}_createClass(MultiFormatUPCEANReader,[{key:"decodeRow",value:function decodeRow(rowNumber,row,hints){var _iterator14=_createForOfIteratorHelper(this.readers),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var reader=_step14.value;try{// const result: Result = reader.decodeRow(rowNumber, row, startGuardPattern, hints); var result=reader.decodeRow(rowNumber,row,hints);// Special case: a 12-digit code encoded in UPC-A is identical to a "0" // followed by those 12 digits encoded as EAN-13. Each will recognize such a code, // UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0". // Individually these are correct and their readers will both read such a code // and correctly call it EAN-13, or UPC-A, respectively. // // In this case, if we've been looking for both types, we'd like to call it // a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read // UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A // result if appropriate. // // But, don't return UPC-A if UPC-A was not a requested format! var ean13MayBeUPCA=result.getBarcodeFormat()===BarcodeFormat$1.EAN_13&&result.getText().charAt(0)==='0';// @SuppressWarnings("unchecked") var possibleFormats=hints==null?null:hints.get(DecodeHintType$1.POSSIBLE_FORMATS);var canReturnUPCA=possibleFormats==null||possibleFormats.includes(BarcodeFormat$1.UPC_A);if(ean13MayBeUPCA&&canReturnUPCA){var _rawBytes=result.getRawBytes();// Transfer the metadata across var resultUPCA=new Result(result.getText().substring(1),_rawBytes,_rawBytes?_rawBytes.length:null,result.getResultPoints(),BarcodeFormat$1.UPC_A);resultUPCA.putAllMetadata(result.getResultMetadata());return resultUPCA;}return result;}catch(err){// continue; }}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}throw new NotFoundException();}},{key:"reset",value:function reset(){var _iterator15=_createForOfIteratorHelper(this.readers),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var reader=_step15.value;reader.reset();}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}}]);return MultiFormatUPCEANReader;}(OneDReader);// import Integer from '../../util/Integer'; // import Float from '../../util/Float'; var AbstractRSSReader=/*#__PURE__*/function(_OneDReader6){_inherits(AbstractRSSReader,_OneDReader6);var _super32=_createSuper(AbstractRSSReader);function AbstractRSSReader(){var _this24;_classCallCheck(this,AbstractRSSReader);_this24=_super32.call(this);_this24.decodeFinderCounters=new Int32Array(4);_this24.dataCharacterCounters=new Int32Array(8);_this24.oddRoundingErrors=new Array(4);_this24.evenRoundingErrors=new Array(4);_this24.oddCounts=new Array(_this24.dataCharacterCounters.length/2);_this24.evenCounts=new Array(_this24.dataCharacterCounters.length/2);return _this24;}_createClass(AbstractRSSReader,[{key:"getDecodeFinderCounters",value:function getDecodeFinderCounters(){return this.decodeFinderCounters;}},{key:"getDataCharacterCounters",value:function getDataCharacterCounters(){return this.dataCharacterCounters;}},{key:"getOddRoundingErrors",value:function getOddRoundingErrors(){return this.oddRoundingErrors;}},{key:"getEvenRoundingErrors",value:function getEvenRoundingErrors(){return this.evenRoundingErrors;}},{key:"getOddCounts",value:function getOddCounts(){return this.oddCounts;}},{key:"getEvenCounts",value:function getEvenCounts(){return this.evenCounts;}},{key:"parseFinderValue",value:function parseFinderValue(counters,finderPatterns){for(var value=0;valueEncapsulates a set of error-correction blocks in one symbol version. Most versions will * use blocks of differing sizes within one version, so, this encapsulates the parameters for * each set of blocks. It also holds the number of error-correction codewords per block since it * will be the same across all blocks within one version.
*/var ECBlocks=/*#__PURE__*/function(){function ECBlocks(ecCodewords,ecBlocks1,ecBlocks2){_classCallCheck(this,ECBlocks);this.ecCodewords=ecCodewords;this.ecBlocks=[ecBlocks1];ecBlocks2&&this.ecBlocks.push(ecBlocks2);}_createClass(ECBlocks,[{key:"getECCodewords",value:function getECCodewords(){return this.ecCodewords;}},{key:"getECBlocks",value:function getECBlocks(){return this.ecBlocks;}}]);return ECBlocks;}();/** *Encapsulates the parameters for one error-correction block in one symbol version. * This includes the number of data codewords, and the number of times a block with these * parameters is used consecutively in the Data Matrix code version's format.
*/var ECB=/*#__PURE__*/function(){function ECB(count,dataCodewords){_classCallCheck(this,ECB);this.count=count;this.dataCodewords=dataCodewords;}_createClass(ECB,[{key:"getCount",value:function getCount(){return this.count;}},{key:"getDataCodewords",value:function getDataCodewords(){return this.dataCodewords;}}]);return ECB;}();/** * The Version object encapsulates attributes about a particular * size Data Matrix Code. * * @author bbrown@google.com (Brian Brown) */var Version=/*#__PURE__*/function(){function Version(versionNumber,symbolSizeRows,symbolSizeColumns,dataRegionSizeRows,dataRegionSizeColumns,ecBlocks){_classCallCheck(this,Version);this.versionNumber=versionNumber;this.symbolSizeRows=symbolSizeRows;this.symbolSizeColumns=symbolSizeColumns;this.dataRegionSizeRows=dataRegionSizeRows;this.dataRegionSizeColumns=dataRegionSizeColumns;this.ecBlocks=ecBlocks;// Calculate the total number of codewords var total=0;var ecCodewords=ecBlocks.getECCodewords();var ecbArray=ecBlocks.getECBlocks();var _iterator33=_createForOfIteratorHelper(ecbArray),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var ecBlock=_step33.value;total+=ecBlock.getCount()*(ecBlock.getDataCodewords()+ecCodewords);}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}this.totalCodewords=total;}_createClass(Version,[{key:"getVersionNumber",value:function getVersionNumber(){return this.versionNumber;}},{key:"getSymbolSizeRows",value:function getSymbolSizeRows(){return this.symbolSizeRows;}},{key:"getSymbolSizeColumns",value:function getSymbolSizeColumns(){return this.symbolSizeColumns;}},{key:"getDataRegionSizeRows",value:function getDataRegionSizeRows(){return this.dataRegionSizeRows;}},{key:"getDataRegionSizeColumns",value:function getDataRegionSizeColumns(){return this.dataRegionSizeColumns;}},{key:"getTotalCodewords",value:function getTotalCodewords(){return this.totalCodewords;}},{key:"getECBlocks",value:function getECBlocks(){return this.ecBlocks;}/** *Deduces version information from Data Matrix dimensions.
* * @param numRows Number of rows in modules * @param numColumns Number of columns in modules * @return Version for a Data Matrix Code of those dimensions * @throws FormatException if dimensions do correspond to a valid Data Matrix size */},{key:"toString",value:// @Override function toString(){return''+this.versionNumber;}/** * See ISO 16022:2006 5.5.1 Table 7 */}],[{key:"getVersionForDimensions",value:function getVersionForDimensions(numRows,numColumns){if((numRows&0x01)!==0||(numColumns&0x01)!==0){throw new FormatException();}var _iterator34=_createForOfIteratorHelper(Version.VERSIONS),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var version=_step34.value;if(version.symbolSizeRows===numRows&&version.symbolSizeColumns===numColumns){return version;}}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}throw new FormatException();}},{key:"buildVersions",value:function buildVersions(){return[new Version(1,10,10,8,8,new ECBlocks(5,new ECB(1,3))),new Version(2,12,12,10,10,new ECBlocks(7,new ECB(1,5))),new Version(3,14,14,12,12,new ECBlocks(10,new ECB(1,8))),new Version(4,16,16,14,14,new ECBlocks(12,new ECB(1,12))),new Version(5,18,18,16,16,new ECBlocks(14,new ECB(1,18))),new Version(6,20,20,18,18,new ECBlocks(18,new ECB(1,22))),new Version(7,22,22,20,20,new ECBlocks(20,new ECB(1,30))),new Version(8,24,24,22,22,new ECBlocks(24,new ECB(1,36))),new Version(9,26,26,24,24,new ECBlocks(28,new ECB(1,44))),new Version(10,32,32,14,14,new ECBlocks(36,new ECB(1,62))),new Version(11,36,36,16,16,new ECBlocks(42,new ECB(1,86))),new Version(12,40,40,18,18,new ECBlocks(48,new ECB(1,114))),new Version(13,44,44,20,20,new ECBlocks(56,new ECB(1,144))),new Version(14,48,48,22,22,new ECBlocks(68,new ECB(1,174))),new Version(15,52,52,24,24,new ECBlocks(42,new ECB(2,102))),new Version(16,64,64,14,14,new ECBlocks(56,new ECB(2,140))),new Version(17,72,72,16,16,new ECBlocks(36,new ECB(4,92))),new Version(18,80,80,18,18,new ECBlocks(48,new ECB(4,114))),new Version(19,88,88,20,20,new ECBlocks(56,new ECB(4,144))),new Version(20,96,96,22,22,new ECBlocks(68,new ECB(4,174))),new Version(21,104,104,24,24,new ECBlocks(56,new ECB(6,136))),new Version(22,120,120,18,18,new ECBlocks(68,new ECB(6,175))),new Version(23,132,132,20,20,new ECBlocks(62,new ECB(8,163))),new Version(24,144,144,22,22,new ECBlocks(62,new ECB(8,156),new ECB(2,155))),new Version(25,8,18,6,16,new ECBlocks(7,new ECB(1,5))),new Version(26,8,32,6,14,new ECBlocks(11,new ECB(1,10))),new Version(27,12,26,10,24,new ECBlocks(14,new ECB(1,16))),new Version(28,12,36,10,16,new ECBlocks(18,new ECB(1,22))),new Version(29,16,36,14,16,new ECBlocks(24,new ECB(1,32))),new Version(30,16,48,14,22,new ECBlocks(28,new ECB(1,49)))];}}]);return Version;}();Version.VERSIONS=Version.buildVersions();/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @author bbrown@google.com (Brian Brown) */var BitMatrixParser=/*#__PURE__*/function(){/** * @param bitMatrix {@link BitMatrix} to parse * @throws FormatException if dimension is < 8 or > 144 or not 0 mod 2 */function BitMatrixParser(bitMatrix){_classCallCheck(this,BitMatrixParser);var dimension=bitMatrix.getHeight();if(dimension<8||dimension>144||(dimension&0x01)!==0){throw new FormatException();}this.version=BitMatrixParser.readVersion(bitMatrix);this.mappingBitMatrix=this.extractDataRegion(bitMatrix);this.readMappingMatrix=new BitMatrix(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight());}_createClass(BitMatrixParser,[{key:"getVersion",value:function getVersion(){return this.version;}/** *Creates the version object based on the dimension of the original bit matrix from * the datamatrix code.
* *See ISO 16022:2006 Table 7 - ECC 200 symbol attributes
* * @param bitMatrix Original {@link BitMatrix} including alignment patterns * @return {@link Version} encapsulating the Data Matrix Code's "version" * @throws FormatException if the dimensions of the mapping matrix are not valid * Data Matrix dimensions. */},{key:"readCodewords",value:/** *Reads the bits in the {@link BitMatrix} representing the mapping matrix (No alignment patterns) * in the correct order in order to reconstitute the codewords bytes contained within the * Data Matrix Code.
* * @return bytes encoded within the Data Matrix Code * @throws FormatException if the exact number of bytes expected is not read */function readCodewords(){var result=new Int8Array(this.version.getTotalCodewords());var resultOffset=0;var row=4;var column=0;var numRows=this.mappingBitMatrix.getHeight();var numColumns=this.mappingBitMatrix.getWidth();var corner1Read=false;var corner2Read=false;var corner3Read=false;var corner4Read=false;// Read all of the codewords do{// Check the four corner cases if(row===numRows&&column===0&&!corner1Read){result[resultOffset++]=this.readCorner1(numRows,numColumns)&0xff;row-=2;column+=2;corner1Read=true;}else if(row===numRows-2&&column===0&&(numColumns&0x03)!==0&&!corner2Read){result[resultOffset++]=this.readCorner2(numRows,numColumns)&0xff;row-=2;column+=2;corner2Read=true;}else if(row===numRows+4&&column===2&&(numColumns&0x07)===0&&!corner3Read){result[resultOffset++]=this.readCorner3(numRows,numColumns)&0xff;row-=2;column+=2;corner3Read=true;}else if(row===numRows-2&&column===0&&(numColumns&0x07)===4&&!corner4Read){result[resultOffset++]=this.readCorner4(numRows,numColumns)&0xff;row-=2;column+=2;corner4Read=true;}else{// Sweep upward diagonally to the right do{if(rowReads the 8 bits of the standard Utah-shaped pattern.
* *See ISO 16022:2006, 5.8.1 Figure 6
* * @param row Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern * @param column Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern * @param numRows Number of rows in the mapping matrix * @param numColumns Number of columns in the mapping matrix * @return byte from the utah shape */},{key:"readUtah",value:function readUtah(row,column,numRows,numColumns){var currentByte=0;if(this.readModule(row-2,column-2,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(row-2,column-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(row-1,column-2,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(row-1,column-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(row-1,column,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(row,column-2,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(row,column-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(row,column,numRows,numColumns)){currentByte|=1;}return currentByte;}/** *Reads the 8 bits of the special corner condition 1.
* *See ISO 16022:2006, Figure F.3
* * @param numRows Number of rows in the mapping matrix * @param numColumns Number of columns in the mapping matrix * @return byte from the Corner condition 1 */},{key:"readCorner1",value:function readCorner1(numRows,numColumns){var currentByte=0;if(this.readModule(numRows-1,0,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(numRows-1,1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(numRows-1,2,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-2,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(1,numColumns-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(2,numColumns-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(3,numColumns-1,numRows,numColumns)){currentByte|=1;}return currentByte;}/** *Reads the 8 bits of the special corner condition 2.
* *See ISO 16022:2006, Figure F.4
* * @param numRows Number of rows in the mapping matrix * @param numColumns Number of columns in the mapping matrix * @return byte from the Corner condition 2 */},{key:"readCorner2",value:function readCorner2(numRows,numColumns){var currentByte=0;if(this.readModule(numRows-3,0,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(numRows-2,0,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(numRows-1,0,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-4,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-3,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-2,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(1,numColumns-1,numRows,numColumns)){currentByte|=1;}return currentByte;}/** *Reads the 8 bits of the special corner condition 3.
* *See ISO 16022:2006, Figure F.5
* * @param numRows Number of rows in the mapping matrix * @param numColumns Number of columns in the mapping matrix * @return byte from the Corner condition 3 */},{key:"readCorner3",value:function readCorner3(numRows,numColumns){var currentByte=0;if(this.readModule(numRows-1,0,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(numRows-1,numColumns-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-3,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-2,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(1,numColumns-3,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(1,numColumns-2,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(1,numColumns-1,numRows,numColumns)){currentByte|=1;}return currentByte;}/** *Reads the 8 bits of the special corner condition 4.
* *See ISO 16022:2006, Figure F.6
* * @param numRows Number of rows in the mapping matrix * @param numColumns Number of columns in the mapping matrix * @return byte from the Corner condition 4 */},{key:"readCorner4",value:function readCorner4(numRows,numColumns){var currentByte=0;if(this.readModule(numRows-3,0,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(numRows-2,0,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(numRows-1,0,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-2,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(0,numColumns-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(1,numColumns-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(2,numColumns-1,numRows,numColumns)){currentByte|=1;}currentByte<<=1;if(this.readModule(3,numColumns-1,numRows,numColumns)){currentByte|=1;}return currentByte;}/** *Extracts the data region from a {@link BitMatrix} that contains * alignment patterns.
* * @param bitMatrix Original {@link BitMatrix} with alignment patterns * @return BitMatrix that has the alignment patterns removed */},{key:"extractDataRegion",value:function extractDataRegion(bitMatrix){var symbolSizeRows=this.version.getSymbolSizeRows();var symbolSizeColumns=this.version.getSymbolSizeColumns();if(bitMatrix.getHeight()!==symbolSizeRows){throw new IllegalArgumentException('Dimension of bitMatrix must match the version size');}var dataRegionSizeRows=this.version.getDataRegionSizeRows();var dataRegionSizeColumns=this.version.getDataRegionSizeColumns();var numDataRegionsRow=symbolSizeRows/dataRegionSizeRows|0;var numDataRegionsColumn=symbolSizeColumns/dataRegionSizeColumns|0;var sizeDataRegionRow=numDataRegionsRow*dataRegionSizeRows;var sizeDataRegionColumn=numDataRegionsColumn*dataRegionSizeColumns;var bitMatrixWithoutAlignment=new BitMatrix(sizeDataRegionColumn,sizeDataRegionRow);for(var dataRegionRow=0;dataRegionRowWhen Data Matrix Codes use multiple data blocks, they actually interleave the bytes of each of them. * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This * method will separate the data into original blocks.
* * @param rawCodewords bytes as read directly from the Data Matrix Code * @param version version of the Data Matrix Code * @return DataBlocks containing original bytes, "de-interleaved" from representation in the * Data Matrix Code */_createClass(DataBlock,[{key:"getNumDataCodewords",value:function getNumDataCodewords(){return this.numDataCodewords;}},{key:"getCodewords",value:function getCodewords(){return this.codewords;}}],[{key:"getDataBlocks",value:function getDataBlocks(rawCodewords,version){// Figure out the number and size of data blocks used by this version var ecBlocks=version.getECBlocks();// First count the total number of data blocks var totalBlocks=0;var ecBlockArray=ecBlocks.getECBlocks();var _iterator35=_createForOfIteratorHelper(ecBlockArray),_step35;try{for(_iterator35.s();!(_step35=_iterator35.n()).done;){var ecBlock=_step35.value;totalBlocks+=ecBlock.getCount();}// Now establish DataBlocks of the appropriate size and number of data codewords }catch(err){_iterator35.e(err);}finally{_iterator35.f();}var result=new Array(totalBlocks);var numResultBlocks=0;var _iterator36=_createForOfIteratorHelper(ecBlockArray),_step36;try{for(_iterator36.s();!(_step36=_iterator36.n()).done;){var _ecBlock=_step36.value;for(var _i27=0;_i27<_ecBlock.getCount();_i27++){var numDataCodewords=_ecBlock.getDataCodewords();var numBlockCodewords=ecBlocks.getECCodewords()+numDataCodewords;result[numResultBlocks++]=new DataBlock(numDataCodewords,new Uint8Array(numBlockCodewords));}}// All blocks have the same amount of data, except that the last n // (where n may be 0) have 1 less byte. Figure out where these start. // TODO(bbrown): There is only one case where there is a difference for Data Matrix for size 144 }catch(err){_iterator36.e(err);}finally{_iterator36.f();}var longerBlocksTotalCodewords=result[0].codewords.length;// int shorterBlocksTotalCodewords = longerBlocksTotalCodewords - 1; var longerBlocksNumDataCodewords=longerBlocksTotalCodewords-ecBlocks.getECCodewords();var shorterBlocksNumDataCodewords=longerBlocksNumDataCodewords-1;// The last elements of result may be 1 element shorter for 144 matrix // first fill out as many elements as all of them have minus 1 var rawCodewordsOffset=0;for(var i=0;iThis provides an easy abstraction to read bits at a time from a sequence of bytes, where the * number of bits read is not often a multiple of 8.
* *This class is thread-safe but not reentrant -- unless the caller modifies the bytes array * it passed in, in which case all bets are off.
* * @author Sean Owen */var BitSource=/*#__PURE__*/function(){/** * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. * Bits are read within a byte from most-significant to least-significant bit. */function BitSource(bytes){_classCallCheck(this,BitSource);this.bytes=bytes;this.byteOffset=0;this.bitOffset=0;}/** * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}. */_createClass(BitSource,[{key:"getBitOffset",value:function getBitOffset(){return this.bitOffset;}/** * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}. */},{key:"getByteOffset",value:function getByteOffset(){return this.byteOffset;}/** * @param numBits number of bits to read * @return int representing the bits read. The bits will appear as the least-significant * bits of the int * @throws IllegalArgumentException if numBits isn't in [1,32] or more than is available */},{key:"readBits",value:function readBits(numBits/*int*/){if(numBits<1||numBits>32||numBits>this.available()){throw new IllegalArgumentException(''+numBits);}var result=0;var bitOffset=this.bitOffset;var byteOffset=this.byteOffset;var bytes=this.bytes;// First, read remainder from current byte if(bitOffset>0){var bitsLeft=8-bitOffset;var toRead=numBitsData Matrix Codes can encode text as bits in one of several modes, and can use multiple modes * in one Data Matrix Code. This class decodes the bits back into text.
* *See ISO 16022:2006, 5.2.1 - 5.2.9.2
* * @author bbrown@google.com (Brian Brown) * @author Sean Owen */var DecodedBitStreamParser=/*#__PURE__*/function(){function DecodedBitStreamParser(){_classCallCheck(this,DecodedBitStreamParser);}_createClass(DecodedBitStreamParser,null,[{key:"decode",value:function decode(bytes){var bits=new BitSource(bytes);var result=new StringBuilder();var resultTrailer=new StringBuilder();var byteSegments=new Array();var mode=Mode.ASCII_ENCODE;do{if(mode===Mode.ASCII_ENCODE){mode=this.decodeAsciiSegment(bits,result,resultTrailer);}else{switch(mode){case Mode.C40_ENCODE:this.decodeC40Segment(bits,result);break;case Mode.TEXT_ENCODE:this.decodeTextSegment(bits,result);break;case Mode.ANSIX12_ENCODE:this.decodeAnsiX12Segment(bits,result);break;case Mode.EDIFACT_ENCODE:this.decodeEdifactSegment(bits,result);break;case Mode.BASE256_ENCODE:this.decodeBase256Segment(bits,result,byteSegments);break;default:throw new FormatException();}mode=Mode.ASCII_ENCODE;}}while(mode!==Mode.PAD_ENCODE&&bits.available()>0);if(resultTrailer.length()>0){result.append(resultTrailer.toString());}return new DecoderResult(bytes,result.toString(),byteSegments.length===0?null:byteSegments,null);}/** * See ISO 16022:2006, 5.2.3 and Annex C, Table C.2 */},{key:"decodeAsciiSegment",value:function decodeAsciiSegment(bits,result,resultTrailer){var upperShift=false;do{var oneByte=bits.readBits(8);if(oneByte===0){throw new FormatException();}else if(oneByte<=128){// ASCII data (ASCII value + 1) if(upperShift){oneByte+=128;// upperShift = false; }result.append(String.fromCharCode(oneByte-1));return Mode.ASCII_ENCODE;}else if(oneByte===129){// Pad return Mode.PAD_ENCODE;}else if(oneByte<=229){// 2-digit data 00-99 (Numeric Value + 130) var value=oneByte-130;if(value<10){// pad with '0' for single digit values result.append('0');}result.append(''+value);}else{switch(oneByte){case 230:// Latch to C40 encodation return Mode.C40_ENCODE;case 231:// Latch to Base 256 encodation return Mode.BASE256_ENCODE;case 232:// FNC1 result.append(String.fromCharCode(29));// translate as ASCII 29 break;case 233:// Structured Append case 234:// Reader Programming // Ignore these symbols for now // throw ReaderException.getInstance(); break;case 235:// Upper Shift (shift to Extended ASCII) upperShift=true;break;case 236:// 05 Macro result.append("[)>\x1E05\x1D");resultTrailer.insert(0,"\x1E\x04");break;case 237:// 06 Macro result.append("[)>\x1E06\x1D");resultTrailer.insert(0,"\x1E\x04");break;case 238:// Latch to ANSI X12 encodation return Mode.ANSIX12_ENCODE;case 239:// Latch to Text encodation return Mode.TEXT_ENCODE;case 240:// Latch to EDIFACT encodation return Mode.EDIFACT_ENCODE;case 241:// ECI Character // TODO(bbrown): I think we need to support ECI // throw ReaderException.getInstance(); // Ignore this symbol for now break;default:// Not to be used in ASCII encodation // but work around encoders that end with 254, latch back to ASCII if(oneByte!==254||bits.available()!==0){throw new FormatException();}break;}}}while(bits.available()>0);return Mode.ASCII_ENCODE;}/** * See ISO 16022:2006, 5.2.5 and Annex C, Table C.1 */},{key:"decodeC40Segment",value:function decodeC40Segment(bits,result){// Three C40 values are encoded in a 16-bit value as // (1600 * C1) + (40 * C2) + C3 + 1 // TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time var upperShift=false;var cValues=[];var shift=0;do{// If there is only one byte left then it will be encoded as ASCII if(bits.available()===8){return;}var firstByte=bits.readBits(8);if(firstByte===254){// Unlatch codeword return;}this.parseTwoBytes(firstByte,bits.readBits(8),cValues);for(var i=0;i<3;i++){var cValue=cValues[i];switch(shift){case 0:if(cValue<3){shift=cValue+1;}else if(cValueThe main class which implements Data Matrix Code decoding -- as opposed to locating and extracting * the Data Matrix Code from an image.
* * @author bbrown@google.com (Brian Brown) */var Decoder$1=/*#__PURE__*/function(){function Decoder$1(){_classCallCheck(this,Decoder$1);this.rsDecoder=new ReedSolomonDecoder(GenericGF.DATA_MATRIX_FIELD_256);}/** *Decodes a Data Matrix Code represented as a {@link BitMatrix}. A 1 or "true" is taken * to mean a black module.
* * @param bits booleans representing white/black Data Matrix Code modules * @return text and bytes encoded within the Data Matrix Code * @throws FormatException if the Data Matrix Code cannot be decoded * @throws ChecksumException if error correction fails */_createClass(Decoder$1,[{key:"decode",value:function decode(bits){// Construct a parser and read version, error-correction level var parser=new BitMatrixParser(bits);var version=parser.getVersion();// Read codewords var codewords=parser.readCodewords();// Separate into data blocks var dataBlocks=DataBlock.getDataBlocks(codewords,version);// Count total number of data bytes var totalBytes=0;var _iterator37=_createForOfIteratorHelper(dataBlocks),_step37;try{for(_iterator37.s();!(_step37=_iterator37.n()).done;){var db=_step37.value;totalBytes+=db.getNumDataCodewords();}}catch(err){_iterator37.e(err);}finally{_iterator37.f();}var resultBytes=new Uint8Array(totalBytes);var dataBlocksCount=dataBlocks.length;// Error-correct and copy data blocks together into a stream of bytes for(var j=0;jDetects a Data Matrix Code in an image.
* * @return {@link DetectorResult} encapsulating results of detecting a Data Matrix Code * @throws NotFoundException if no Data Matrix Code can be found */_createClass(Detector$1,[{key:"detect",value:function detect(){var cornerPoints=this.rectangleDetector.detect();var points=this.detectSolid1(cornerPoints);points=this.detectSolid2(points);points[3]=this.correctTopRight(points);if(!points[3]){throw new NotFoundException();}points=this.shiftToModuleCenter(points);var topLeft=points[0];var bottomLeft=points[1];var bottomRight=points[2];var topRight=points[3];var dimensionTop=this.transitionsBetween(topLeft,topRight)+1;var dimensionRight=this.transitionsBetween(bottomRight,topRight)+1;if((dimensionTop&0x01)===1){dimensionTop+=1;}if((dimensionRight&0x01)===1){dimensionRight+=1;}if(4*dimensionTop<7*dimensionRight&&4*dimensionRight<7*dimensionTop){// The matrix is square dimensionTop=dimensionRight=Math.max(dimensionTop,dimensionRight);}var bits=Detector$1.sampleGrid(this.image,topLeft,bottomLeft,bottomRight,topRight,dimensionTop,dimensionRight);return new DetectorResult(bits,[topLeft,bottomLeft,bottomRight,topRight]);}},{key:"detectSolid1",value:/** * Detect a solid side which has minimum transition. */function detectSolid1(cornerPoints){// 0 2 // 1 3 var pointA=cornerPoints[0];var pointB=cornerPoints[1];var pointC=cornerPoints[3];var pointD=cornerPoints[2];var trAB=this.transitionsBetween(pointA,pointB);var trBC=this.transitionsBetween(pointB,pointC);var trCD=this.transitionsBetween(pointC,pointD);var trDA=this.transitionsBetween(pointD,pointA);// 0..3 // : : // 1--2 var min=trAB;var points=[pointD,pointA,pointB,pointC];if(min>trBC){min=trBC;points[0]=pointA;points[1]=pointB;points[2]=pointC;points[3]=pointD;}if(min>trCD){min=trCD;points[0]=pointB;points[1]=pointC;points[2]=pointD;points[3]=pointA;}if(min>trDA){points[0]=pointC;points[1]=pointD;points[2]=pointA;points[3]=pointB;}return points;}/** * Detect a second solid side next to first solid side. */},{key:"detectSolid2",value:function detectSolid2(points){// A..D // : : // B--C var pointA=points[0];var pointB=points[1];var pointC=points[2];var pointD=points[3];// Transition detection on the edge is not stable. // To safely detect, shift the points to the module center. var tr=this.transitionsBetween(pointA,pointD);var pointBs=Detector$1.shiftPoint(pointB,pointC,(tr+1)*4);var pointCs=Detector$1.shiftPoint(pointC,pointB,(tr+1)*4);var trBA=this.transitionsBetween(pointBs,pointA);var trCD=this.transitionsBetween(pointCs,pointD);// 0..3 // | : // 1--2 if(trBASee ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels * defined by the QR code standard.
* * @author Sean Owen */var ErrorCorrectionLevel=/*#__PURE__*/function(){function ErrorCorrectionLevel(value,stringValue,bits/*int*/){_classCallCheck(this,ErrorCorrectionLevel);this.value=value;this.stringValue=stringValue;this.bits=bits;ErrorCorrectionLevel.FOR_BITS.set(bits,this);ErrorCorrectionLevel.FOR_VALUE.set(value,this);}_createClass(ErrorCorrectionLevel,[{key:"getValue",value:function getValue(){return this.value;}},{key:"getBits",value:function getBits(){return this.bits;}},{key:"toString",value:function toString(){return this.stringValue;}},{key:"equals",value:function equals(o){if(!(o instanceof ErrorCorrectionLevel)){return false;}var other=o;return this.value===other.value;}/** * @param bits int containing the two bits encoding a QR Code's error correction level * @return ErrorCorrectionLevel representing the encoded error correction level */}],[{key:"fromString",value:function fromString(s){switch(s){case'L':return ErrorCorrectionLevel.L;case'M':return ErrorCorrectionLevel.M;case'Q':return ErrorCorrectionLevel.Q;case'H':return ErrorCorrectionLevel.H;default:throw new ArgumentException(s+'not available');}}},{key:"forBits",value:function forBits(bits/*int*/){if(bits<0||bits>=ErrorCorrectionLevel.FOR_BITS.size){throw new IllegalArgumentException();}return ErrorCorrectionLevel.FOR_BITS.get(bits);}}]);return ErrorCorrectionLevel;}();ErrorCorrectionLevel.FOR_BITS=new Map();ErrorCorrectionLevel.FOR_VALUE=new Map();/** L = ~7% correction */ErrorCorrectionLevel.L=new ErrorCorrectionLevel(ErrorCorrectionLevelValues.L,'L',0x01);/** M = ~15% correction */ErrorCorrectionLevel.M=new ErrorCorrectionLevel(ErrorCorrectionLevelValues.M,'M',0x00);/** Q = ~25% correction */ErrorCorrectionLevel.Q=new ErrorCorrectionLevel(ErrorCorrectionLevelValues.Q,'Q',0x03);/** H = ~30% correction */ErrorCorrectionLevel.H=new ErrorCorrectionLevel(ErrorCorrectionLevelValues.H,'H',0x02);/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** *Encapsulates a QR Code's format information, including the data mask used and * error correction level.
* * @author Sean Owen * @see DataMask * @see ErrorCorrectionLevel */var FormatInformation=/*#__PURE__*/function(){function FormatInformation(formatInfo/*int*/){_classCallCheck(this,FormatInformation);// Bits 3,4 this.errorCorrectionLevel=ErrorCorrectionLevel.forBits(formatInfo>>3&0x03);// Bottom 3 bits this.dataMask=/*(byte) */formatInfo&0x07;}_createClass(FormatInformation,[{key:"getErrorCorrectionLevel",value:function getErrorCorrectionLevel(){return this.errorCorrectionLevel;}},{key:"getDataMask",value:function getDataMask(){return this.dataMask;}/*@Override*/},{key:"hashCode",value:function hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask;}/*@Override*/},{key:"equals",value:function equals(o){if(!(o instanceof FormatInformation)){return false;}var other=o;return this.errorCorrectionLevel===other.errorCorrectionLevel&&this.dataMask===other.dataMask;}}],[{key:"numBitsDiffering",value:function numBitsDiffering(a/*int*/,b/*int*/){return Integer.bitCount(a^b);}/** * @param maskedFormatInfo1 format info indicator, with mask still applied * @param maskedFormatInfo2 second copy of same info; both are checked at the same time * to establish best match * @return information about the format it specifies, or {@code null} * if doesn't seem to match any known pattern */},{key:"decodeFormatInformation",value:function decodeFormatInformation(maskedFormatInfo1/*int*/,maskedFormatInfo2/*int*/){var formatInfo=FormatInformation.doDecodeFormatInformation(maskedFormatInfo1,maskedFormatInfo2);if(formatInfo!==null){return formatInfo;}// Should return null, but, some QR codes apparently // do not mask this info. Try again by actually masking the pattern // first return FormatInformation.doDecodeFormatInformation(maskedFormatInfo1^FormatInformation.FORMAT_INFO_MASK_QR,maskedFormatInfo2^FormatInformation.FORMAT_INFO_MASK_QR);}},{key:"doDecodeFormatInformation",value:function doDecodeFormatInformation(maskedFormatInfo1/*int*/,maskedFormatInfo2/*int*/){// Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing var bestDifference=Number.MAX_SAFE_INTEGER;var bestFormatInfo=0;var _iterator38=_createForOfIteratorHelper(FormatInformation.FORMAT_INFO_DECODE_LOOKUP),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var decodeInfo=_step38.value;var targetInfo=decodeInfo[0];if(targetInfo===maskedFormatInfo1||targetInfo===maskedFormatInfo2){// Found an exact match return new FormatInformation(decodeInfo[1]);}var bitsDifference=FormatInformation.numBitsDiffering(maskedFormatInfo1,targetInfo);if(bitsDifferenceEncapsulates the parameters for one error-correction block in one symbol version. * This includes the number of data codewords, and the number of times a block with these * parameters is used consecutively in the QR code version's format.
*/var ECB$1=/*#__PURE__*/function(){function ECB$1(count/*int*/,dataCodewords/*int*/){_classCallCheck(this,ECB$1);this.count=count;this.dataCodewords=dataCodewords;}_createClass(ECB$1,[{key:"getCount",value:function getCount(){return this.count;}},{key:"getDataCodewords",value:function getDataCodewords(){return this.dataCodewords;}}]);return ECB$1;}();/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * See ISO 18004:2006 Annex D * * @author Sean Owen */var Version$1=/*#__PURE__*/function(){function Version$1(versionNumber/*int*/,alignmentPatternCenters){_classCallCheck(this,Version$1);this.versionNumber=versionNumber;this.alignmentPatternCenters=alignmentPatternCenters;for(var _len5=arguments.length,ecBlocks=new Array(_len5>2?_len5-2:0),_key5=2;_key5<_len5;_key5++){ecBlocks[_key5-2]=arguments[_key5];}this.ecBlocks=ecBlocks;var total=0;var ecCodewords=ecBlocks[0].getECCodewordsPerBlock();var ecbArray=ecBlocks[0].getECBlocks();var _iterator40=_createForOfIteratorHelper(ecbArray),_step40;try{for(_iterator40.s();!(_step40=_iterator40.n()).done;){var ecBlock=_step40.value;total+=ecBlock.getCount()*(ecBlock.getDataCodewords()+ecCodewords);}}catch(err){_iterator40.e(err);}finally{_iterator40.f();}this.totalCodewords=total;}_createClass(Version$1,[{key:"getVersionNumber",value:function getVersionNumber(){return this.versionNumber;}},{key:"getAlignmentPatternCenters",value:function getAlignmentPatternCenters(){return this.alignmentPatternCenters;}},{key:"getTotalCodewords",value:function getTotalCodewords(){return this.totalCodewords;}},{key:"getDimensionForVersion",value:function getDimensionForVersion(){return 17+4*this.versionNumber;}},{key:"getECBlocksForLevel",value:function getECBlocksForLevel(ecLevel){return this.ecBlocks[ecLevel.getValue()];// TYPESCRIPTPORT: original was using ordinal, and using the order of levels as defined in ErrorCorrectionLevel enum (LMQH) // I will use the direct value from ErrorCorrectionLevelValues enum which in typescript goes to a number }/** *Deduces version information purely from QR Code dimensions.
* * @param dimension dimension in modules * @return Version for a QR Code of that dimension * @throws FormatException if dimension is not 1 mod 4 */},{key:"buildFunctionPattern",value:/** * See ISO 18004:2006 Annex E */function buildFunctionPattern(){var dimension=this.getDimensionForVersion();var bitMatrix=new BitMatrix(dimension);// Top left finder pattern + separator + format bitMatrix.setRegion(0,0,9,9);// Top right finder pattern + separator + format bitMatrix.setRegion(dimension-8,0,8,9);// Bottom left finder pattern + separator + format bitMatrix.setRegion(0,dimension-8,9,8);// Alignment patterns var max=this.alignmentPatternCenters.length;for(var x=0;xNote that the diagram in section 6.8.1 is misleading since it indicates that i is column position * and j is row position. In fact, as the text says, i is row position and j is column position.
* * @author Sean Owen */var DataMask=/*#__PURE__*/function(){// See ISO 18004:2006 6.8.1 function DataMask(value,isMasked){_classCallCheck(this,DataMask);this.value=value;this.isMasked=isMasked;}// End of enum constants. /** *Implementations of this method reverse the data masking process applied to a QR Code and * make its bits ready to read.
* * @param bits representation of QR Code bits * @param dimension dimension of QR Code, represented by bits, being unmasked */_createClass(DataMask,[{key:"unmaskBitMatrix",value:function unmaskBitMatrix(bits,dimension/*int*/){for(var i=0;iReads format information from one of its two locations within the QR Code.
* * @return {@link FormatInformation} encapsulating the QR Code's format info * @throws FormatException if both format information locations cannot be parsed as * the valid encoding of format information */_createClass(BitMatrixParser$1,[{key:"readFormatInformation",value:function readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==undefined){return this.parsedFormatInfo;}// Read top-left format info bits var formatInfoBits1=0;for(var i=0;i<6;i++){formatInfoBits1=this.copyBit(i,8,formatInfoBits1);}// .. and skip a bit in the timing pattern ... formatInfoBits1=this.copyBit(7,8,formatInfoBits1);formatInfoBits1=this.copyBit(8,8,formatInfoBits1);formatInfoBits1=this.copyBit(8,7,formatInfoBits1);// .. and skip a bit in the timing pattern ... for(var j=5;j>=0;j--){formatInfoBits1=this.copyBit(8,j,formatInfoBits1);}// Read the top-right/bottom-left pattern too var dimension=this.bitMatrix.getHeight();var formatInfoBits2=0;var jMin=dimension-7;for(var _j4=dimension-1;_j4>=jMin;_j4--){formatInfoBits2=this.copyBit(8,_j4,formatInfoBits2);}for(var _i28=dimension-8;_i28Reads the bits in the {@link BitMatrix} representing the finder pattern in the * correct order in order to reconstruct the codewords bytes contained within the * QR Code.
* * @return bytes encoded within the QR Code * @throws FormatException if the exact number of bytes expected is not read */},{key:"readCodewords",value:function readCodewords(){var formatInfo=this.readFormatInformation();var version=this.readVersion();// Get the data mask for the format used in this QR Code. This will exclude // some bits from reading as we wind through the bit matrix. var dataMask=DataMask.values.get(formatInfo.getDataMask());var dimension=this.bitMatrix.getHeight();dataMask.unmaskBitMatrix(this.bitMatrix,dimension);var functionPattern=version.buildFunctionPattern();var readingUp=true;var result=new Uint8Array(version.getTotalCodewords());var resultOffset=0;var currentByte=0;var bitsRead=0;// Read columns in pairs, from right to left for(var j=dimension-1;j>0;j-=2){if(j===6){// Skip whole column with vertical alignment pattern // saves time and makes the other code proceed more cleanly j--;}// Read alternatingly from bottom to top then top to bottom for(var count=0;countWhen QR Codes use multiple data blocks, they are actually interleaved. * That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This * method will separate the data into original blocks.
* * @param rawCodewords bytes as read directly from the QR Code * @param version version of the QR Code * @param ecLevel error-correction level of the QR Code * @return DataBlocks containing original bytes, "de-interleaved" from representation in the * QR Code */_createClass(DataBlock$1,[{key:"getNumDataCodewords",value:function getNumDataCodewords(){return this.numDataCodewords;}},{key:"getCodewords",value:function getCodewords(){return this.codewords;}}],[{key:"getDataBlocks",value:function getDataBlocks(rawCodewords,version,ecLevel){if(rawCodewords.length!==version.getTotalCodewords()){throw new IllegalArgumentException();}// Figure out the number and size of data blocks used by this version and // error correction level var ecBlocks=version.getECBlocksForLevel(ecLevel);// First count the total number of data blocks var totalBlocks=0;var ecBlockArray=ecBlocks.getECBlocks();var _iterator41=_createForOfIteratorHelper(ecBlockArray),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var ecBlock=_step41.value;totalBlocks+=ecBlock.getCount();}// Now establish DataBlocks of the appropriate size and number of data codewords }catch(err){_iterator41.e(err);}finally{_iterator41.f();}var result=new Array(totalBlocks);var numResultBlocks=0;var _iterator42=_createForOfIteratorHelper(ecBlockArray),_step42;try{for(_iterator42.s();!(_step42=_iterator42.n()).done;){var _ecBlock2=_step42.value;for(var _i31=0;_i31<_ecBlock2.getCount();_i31++){var numDataCodewords=_ecBlock2.getDataCodewords();var numBlockCodewords=ecBlocks.getECCodewordsPerBlock()+numDataCodewords;result[numResultBlocks++]=new DataBlock$1(numDataCodewords,new Uint8Array(numBlockCodewords));}}// All blocks have the same amount of data, except that the last n // (where n may be 0) have 1 more byte. Figure out where these start. }catch(err){_iterator42.e(err);}finally{_iterator42.f();}var shorterBlocksTotalCodewords=result[0].codewords.length;var longerBlocksStartAt=result.length-1;// TYPESCRIPTPORT: check length is correct here while(longerBlocksStartAt>=0){var numCodewords=result[longerBlocksStartAt].codewords.length;if(numCodewords===shorterBlocksTotalCodewords){break;}longerBlocksStartAt--;}longerBlocksStartAt++;var shorterBlocksNumDataCodewords=shorterBlocksTotalCodewords-ecBlocks.getECCodewordsPerBlock();// The last elements of result may be 1 element longer // first fill out as many elements as all of them have var rawCodewordsOffset=0;for(var i=0;iQR Codes can encode text as bits in one of several modes, and can use multiple modes * in one QR Code. This class decodes the bits back into text.
* *See ISO 18004:2006, 6.4.3 - 6.4.7
* * @author Sean Owen */var DecodedBitStreamParser$1=/*#__PURE__*/function(){function DecodedBitStreamParser$1(){_classCallCheck(this,DecodedBitStreamParser$1);}_createClass(DecodedBitStreamParser$1,null,[{key:"decode",value:function decode(bytes,version,ecLevel,hints){var bits=new BitSource(bytes);var result=new StringBuilder();var byteSegments=new Array();// 1 // TYPESCRIPTPORT: I do not use constructor with size 1 as in original Java means capacity and the array length is checked below var symbolSequence=-1;var parityData=-1;try{var currentCharacterSetECI=null;var fc1InEffect=false;var mode;do{// While still another segment to read... if(bits.available()<4){// OK, assume we're done. Really, a TERMINATOR mode should have been recorded here mode=Mode$1.TERMINATOR;}else{var modeBits=bits.readBits(4);mode=Mode$1.forBits(modeBits);// mode is encoded by 4 bits }switch(mode){case Mode$1.TERMINATOR:break;case Mode$1.FNC1_FIRST_POSITION:case Mode$1.FNC1_SECOND_POSITION:// We do little with FNC1 except alter the parsed result a bit according to the spec fc1InEffect=true;break;case Mode$1.STRUCTURED_APPEND:if(bits.available()<16){throw new FormatException();}// sequence number and parity is added later to the result metadata // Read next 8 bits (symbol sequence #) and 8 bits (data: parity), then continue symbolSequence=bits.readBits(8);parityData=bits.readBits(8);break;case Mode$1.ECI:// Count doesn't apply to ECI var value=DecodedBitStreamParser$1.parseECIValue(bits);currentCharacterSetECI=CharacterSetECI.getCharacterSetECIByValue(value);if(currentCharacterSetECI===null){throw new FormatException();}break;case Mode$1.HANZI:// First handle Hanzi mode which does not start with character count // Chinese mode contains a sub set indicator right after mode indicator var subset=bits.readBits(4);var countHanzi=bits.readBits(mode.getCharacterCountBits(version));if(subset===DecodedBitStreamParser$1.GB2312_SUBSET){DecodedBitStreamParser$1.decodeHanziSegment(bits,result,countHanzi);}break;default:// "Normal" QR code modes: // How many characters will follow, encoded in this mode? var count=bits.readBits(mode.getCharacterCountBits(version));switch(mode){case Mode$1.NUMERIC:DecodedBitStreamParser$1.decodeNumericSegment(bits,result,count);break;case Mode$1.ALPHANUMERIC:DecodedBitStreamParser$1.decodeAlphanumericSegment(bits,result,count,fc1InEffect);break;case Mode$1.BYTE:DecodedBitStreamParser$1.decodeByteSegment(bits,result,count,currentCharacterSetECI,byteSegments,hints);break;case Mode$1.KANJI:DecodedBitStreamParser$1.decodeKanjiSegment(bits,result,count);break;default:throw new FormatException();}break;}}while(mode!==Mode$1.TERMINATOR);}catch(iae/*: IllegalArgumentException*/){// from readBits() calls throw new FormatException();}return new DecoderResult(bytes,result.toString(),byteSegments.length===0?null:byteSegments,ecLevel===null?null:ecLevel.toString(),symbolSequence,parityData);}/** * See specification GBT 18284-2000 */},{key:"decodeHanziSegment",value:function decodeHanziSegment(bits,result,count/*int*/){// Don't crash trying to read more bits than we have available. if(count*13>bits.available()){throw new FormatException();}// Each character will require 2 bytes. Read the characters as 2-byte pairs // and decode as GB2312 afterwards var buffer=new Uint8Array(2*count);var offset=0;while(count>0){// Each 13 bits encodes a 2-byte character var twoBytes=bits.readBits(13);var assembledTwoBytes=twoBytes/0x060<<8&0xFFFFFFFF|twoBytes%0x060;if(assembledTwoBytes<0x003BF){// In the 0xA1A1 to 0xAAFE range assembledTwoBytes+=0x0A1A1;}else{// In the 0xB0A1 to 0xFAFE range assembledTwoBytes+=0x0A6A1;}buffer[offset]=/*(byte) */assembledTwoBytes>>8&0xFF;buffer[offset+1]=/*(byte) */assembledTwoBytes&0xFF;offset+=2;count--;}try{result.append(StringEncoding.decode(buffer,StringUtils.GB2312));// TYPESCRIPTPORT: TODO: implement GB2312 decode. StringView from MDN could be a starting point }catch(ignored/*: UnsupportedEncodingException*/){throw new FormatException(ignored);}}},{key:"decodeKanjiSegment",value:function decodeKanjiSegment(bits,result,count/*int*/){// Don't crash trying to read more bits than we have available. if(count*13>bits.available()){throw new FormatException();}// Each character will require 2 bytes. Read the characters as 2-byte pairs // and decode as Shift_JIS afterwards var buffer=new Uint8Array(2*count);var offset=0;while(count>0){// Each 13 bits encodes a 2-byte character var twoBytes=bits.readBits(13);var assembledTwoBytes=twoBytes/0x0C0<<8&0xFFFFFFFF|twoBytes%0x0C0;if(assembledTwoBytes<0x01F00){// In the 0x8140 to 0x9FFC range assembledTwoBytes+=0x08140;}else{// In the 0xE040 to 0xEBBF range assembledTwoBytes+=0x0C140;}buffer[offset]=/*(byte) */assembledTwoBytes>>8;buffer[offset+1]=/*(byte) */assembledTwoBytes;offset+=2;count--;}// Shift_JIS may not be supported in some environments: try{result.append(StringEncoding.decode(buffer,StringUtils.SHIFT_JIS));// TYPESCRIPTPORT: TODO: implement SHIFT_JIS decode. StringView from MDN could be a starting point }catch(ignored/*: UnsupportedEncodingException*/){throw new FormatException(ignored);}}},{key:"decodeByteSegment",value:function decodeByteSegment(bits,result,count/*int*/,currentCharacterSetECI,byteSegments,hints){// Don't crash trying to read more bits than we have available. if(8*count>bits.available()){throw new FormatException();}var readBytes=new Uint8Array(count);for(var i=0;iThe main class which implements QR Code decoding -- as opposed to locating and extracting * the QR Code from an image.
* * @author Sean Owen */var Decoder$2=/*#__PURE__*/function(){function Decoder$2(){_classCallCheck(this,Decoder$2);this.rsDecoder=new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);}// public decode(image: boolean[][]): DecoderResult /*throws ChecksumException, FormatException*/ { // return decode(image, null) // } /** *Convenience method that can decode a QR Code represented as a 2D array of booleans. * "true" is taken to mean a black module.
* * @param image booleans representing white/black QR Code modules * @param hints decoding hints that should be used to influence decoding * @return text and bytes encoded within the QR Code * @throws FormatException if the QR Code cannot be decoded * @throws ChecksumException if error correction fails */_createClass(Decoder$2,[{key:"decodeBooleanArray",value:function decodeBooleanArray(image,hints){return this.decodeBitMatrix(BitMatrix.parseFromBooleanArray(image),hints);}// public decodeBitMatrix(bits: BitMatrix): DecoderResult /*throws ChecksumException, FormatException*/ { // return decode(bits, null) // } /** *Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.
* * @param bits booleans representing white/black QR Code modules * @param hints decoding hints that should be used to influence decoding * @return text and bytes encoded within the QR Code * @throws FormatException if the QR Code cannot be decoded * @throws ChecksumException if error correction fails */},{key:"decodeBitMatrix",value:function decodeBitMatrix(bits,hints){// Construct a parser and read version, error-correction level var parser=new BitMatrixParser$1(bits);var ex=null;try{return this.decodeBitMatrixParser(parser,hints);}catch(e/*: FormatException, ChecksumException*/){ex=e;}try{// Revert the bit matrix parser.remask();// Will be attempting a mirrored reading of the version and format info. parser.setMirror(true);// Preemptively read the version. parser.readVersion();// Preemptively read the format information. parser.readFormatInformation();/* * Since we're here, this means we have successfully detected some kind * of version and format information when mirrored. This is a good sign, * that the QR code may be mirrored, and we should try once more with a * mirrored content. */ // Prepare for a mirrored reading. parser.mirror();var result=this.decodeBitMatrixParser(parser,hints);// Success! Notify the caller that the code was mirrored. result.setOther(new QRCodeDecoderMetaData(true));return result;}catch(e/*FormatException | ChecksumException*/){// Throw the exception from the original reading if(ex!==null){throw ex;}throw e;}}},{key:"decodeBitMatrixParser",value:function decodeBitMatrixParser(parser,hints){var version=parser.readVersion();var ecLevel=parser.readFormatInformation().getErrorCorrectionLevel();// Read codewords var codewords=parser.readCodewords();// Separate into data blocks var dataBlocks=DataBlock$1.getDataBlocks(codewords,version,ecLevel);// Count total number of data bytes var totalBytes=0;var _iterator43=_createForOfIteratorHelper(dataBlocks),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var dataBlock=_step43.value;totalBytes+=dataBlock.getNumDataCodewords();}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}var resultBytes=new Uint8Array(totalBytes);var resultOffset=0;// Error-correct and copy data blocks together into a stream of bytes var _iterator44=_createForOfIteratorHelper(dataBlocks),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var _dataBlock=_step44.value;var codewordBytes=_dataBlock.getCodewords();var numDataCodewords=_dataBlock.getNumDataCodewords();this.correctErrors(codewordBytes,numDataCodewords);for(var i=0;iDetermines if this alignment pattern "about equals" an alignment pattern at the stated * position and size -- meaning, it is at nearly the same center with nearly the same size.
*/_createClass(AlignmentPattern,[{key:"aboutEquals",value:function aboutEquals(moduleSize/*float*/,i/*float*/,j/*float*/){if(Math.abs(i-this.getY())<=moduleSize&&Math.abs(j-this.getX())<=moduleSize){var moduleSizeDiff=Math.abs(moduleSize-this.estimatedModuleSize);return moduleSizeDiff<=1.0||moduleSizeDiff<=this.estimatedModuleSize;}return false;}/** * Combines this object's current estimate of a finder pattern position and module size * with a new estimate. It returns a new {@code FinderPattern} containing an average of the two. */},{key:"combineEstimate",value:function combineEstimate(i/*float*/,j/*float*/,newModuleSize/*float*/){var combinedX=(this.getX()+j)/2.0;var combinedY=(this.getY()+i)/2.0;var combinedModuleSize=(this.estimatedModuleSize+newModuleSize)/2.0;return new AlignmentPattern(combinedX,combinedY,combinedModuleSize);}}]);return AlignmentPattern;}(ResultPoint);/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /*import java.util.ArrayList;*/ /*import java.util.List;*/ /** *This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder * patterns but are smaller and appear at regular intervals throughout the image.
* *At the moment this only looks for the bottom-right alignment pattern.
* *This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied, * pasted and stripped down here for maximum performance but does unfortunately duplicate * some code.
* *This class is thread-safe but not reentrant. Each thread must allocate its own object.
* * @author Sean Owen */var AlignmentPatternFinder=/*#__PURE__*/function(){/** *Creates a finder that will look in a portion of the whole image.
* * @param image image to search * @param startX left column from which to start searching * @param startY top row from which to start searching * @param width width of region to search * @param height height of region to search * @param moduleSize estimated module size so far */function AlignmentPatternFinder(image,startX/*int*/,startY/*int*/,width/*int*/,height/*int*/,moduleSize/*float*/,resultPointCallback){_classCallCheck(this,AlignmentPatternFinder);this.image=image;this.startX=startX;this.startY=startY;this.width=width;this.height=height;this.moduleSize=moduleSize;this.resultPointCallback=resultPointCallback;this.possibleCenters=[];// new ArrayThis method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since * it's pretty performance-critical and so is written to be fast foremost.
* * @return {@link AlignmentPattern} if found * @throws NotFoundException if not found */_createClass(AlignmentPatternFinder,[{key:"find",value:function find(){var startX=this.startX;var height=this.height;var width=this.width;var maxJ=startX+width;var middleI=this.startY+height/2;// We are looking for black/white/black modules in 1:1:1 ratio // this tracks the number of black/white/black modules seen so far var stateCount=new Int32Array(3);var image=this.image;for(var iGen=0;iGenAfter a horizontal scan finds a potential alignment pattern, this method * "cross-checks" by scanning down vertically through the center of the possible * alignment pattern to see if the same proportion is detected.
* * @param startI row where an alignment pattern was detected * @param centerJ center of the section that appears to cross an alignment pattern * @param maxCount maximum reasonable number of modules that should be * observed in any reading state, based on the results of the horizontal scan * @return vertical center of alignment pattern, or {@link Float#NaN} if not found */},{key:"crossCheckVertical",value:function crossCheckVertical(startI/*int*/,centerJ/*int*/,maxCount/*int*/,originalStateCountTotal/*int*/){var image=this.image;var maxI=image.getHeight();var stateCount=this.crossCheckStateCount;stateCount[0]=0;stateCount[1]=0;stateCount[2]=0;// Start counting up from center var i=startI;while(i>=0&&image.get(centerJ,i)&&stateCount[1]<=maxCount){stateCount[1]++;i--;}// If already too many modules in this state or ran off the edge: if(i<0||stateCount[1]>maxCount){return NaN;}while(i>=0&&!image.get(centerJ,i)&&stateCount[0]<=maxCount){stateCount[0]++;i--;}if(stateCount[0]>maxCount){return NaN;}// Now also count down from center i=startI+1;while(iThis is called when a horizontal scan finds a possible alignment pattern. It will * cross check with a vertical scan, and if successful, will see if this pattern had been * found on a previous horizontal scan. If so, we consider it confirmed and conclude we have * found the alignment pattern.
* * @param stateCount reading state module counts from horizontal scan * @param i row where alignment pattern may be found * @param j end of possible alignment pattern in row * @return {@link AlignmentPattern} if we have found the same pattern twice, or null if not */},{key:"handlePossibleCenter",value:function handlePossibleCenter(stateCount,i/*int*/,j/*int*/){var stateCountTotal=stateCount[0]+stateCount[1]+stateCount[2];var centerJ=AlignmentPatternFinder.centerFromEnd(stateCount,j);var centerI=this.crossCheckVertical(i,/*(int) */centerJ,2*stateCount[1],stateCountTotal);if(!isNaN(centerI)){var estimatedModuleSize=(stateCount[0]+stateCount[1]+stateCount[2])/3.0;var _iterator45=_createForOfIteratorHelper(this.possibleCenters),_step45;try{for(_iterator45.s();!(_step45=_iterator45.n()).done;){var center=_step45.value;// Look for about the same center and module size: if(center.aboutEquals(estimatedModuleSize,centerI,centerJ)){return center.combineEstimate(centerI,centerJ,estimatedModuleSize);}}// Hadn't found this before; save it }catch(err){_iterator45.e(err);}finally{_iterator45.f();}var point=new AlignmentPattern(centerJ,centerI,estimatedModuleSize);this.possibleCenters.push(point);if(this.resultPointCallback!==null&&this.resultPointCallback!==undefined){this.resultPointCallback.foundPossibleResultPoint(point);}}return null;}}],[{key:"centerFromEnd",value:function centerFromEnd(stateCount,end/*int*/){return end-stateCount[2]-stateCount[1]/2.0;}}]);return AlignmentPatternFinder;}();/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** *Encapsulates a finder pattern, which are the three square patterns found in * the corners of QR Codes. It also encapsulates a count of similar finder patterns, * as a convenience to the finder's bookkeeping.
* * @author Sean Owen */var FinderPattern$1=/*#__PURE__*/function(_ResultPoint2){_inherits(FinderPattern$1,_ResultPoint2);var _super53=_createSuper(FinderPattern$1);// FinderPattern(posX: number/*float*/, posY: number/*float*/, estimatedModuleSize: number/*float*/) { // this(posX, posY, estimatedModuleSize, 1) // } function FinderPattern$1(posX/*float*/,posY/*float*/,estimatedModuleSize/*float*/,count/*int*/){var _this34;_classCallCheck(this,FinderPattern$1);_this34=_super53.call(this,posX,posY);_this34.estimatedModuleSize=estimatedModuleSize;_this34.count=count;if(undefined===count){_this34.count=1;}return _this34;}_createClass(FinderPattern$1,[{key:"getEstimatedModuleSize",value:function getEstimatedModuleSize(){return this.estimatedModuleSize;}},{key:"getCount",value:function getCount(){return this.count;}/* void incrementCount() { this.count++ } */ /** *Determines if this finder pattern "about equals" a finder pattern at the stated * position and size -- meaning, it is at nearly the same center with nearly the same size.
*/},{key:"aboutEquals",value:function aboutEquals(moduleSize/*float*/,i/*float*/,j/*float*/){if(Math.abs(i-this.getY())<=moduleSize&&Math.abs(j-this.getX())<=moduleSize){var moduleSizeDiff=Math.abs(moduleSize-this.estimatedModuleSize);return moduleSizeDiff<=1.0||moduleSizeDiff<=this.estimatedModuleSize;}return false;}/** * Combines this object's current estimate of a finder pattern position and module size * with a new estimate. It returns a new {@code FinderPattern} containing a weighted average * based on count. */},{key:"combineEstimate",value:function combineEstimate(i/*float*/,j/*float*/,newModuleSize/*float*/){var combinedCount=this.count+1;var combinedX=(this.count*this.getX()+j)/combinedCount;var combinedY=(this.count*this.getY()+i)/combinedCount;var combinedModuleSize=(this.count*this.estimatedModuleSize+newModuleSize)/combinedCount;return new FinderPattern$1(combinedX,combinedY,combinedModuleSize,combinedCount);}}]);return FinderPattern$1;}(ResultPoint);/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** *Encapsulates information about finder patterns in an image, including the location of * the three finder patterns, and their estimated module size.
* * @author Sean Owen */var FinderPatternInfo=/*#__PURE__*/function(){function FinderPatternInfo(patternCenters){_classCallCheck(this,FinderPatternInfo);this.bottomLeft=patternCenters[0];this.topLeft=patternCenters[1];this.topRight=patternCenters[2];}_createClass(FinderPatternInfo,[{key:"getBottomLeft",value:function getBottomLeft(){return this.bottomLeft;}},{key:"getTopLeft",value:function getTopLeft(){return this.topLeft;}},{key:"getTopRight",value:function getTopRight(){return this.topRight;}}]);return FinderPatternInfo;}();/* * Copyright 2007 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /*import java.io.Serializable;*/ /*import java.util.ArrayList;*/ /*import java.util.Collections;*/ /*import java.util.Comparator;*/ /*import java.util.List;*/ /*import java.util.Map;*/ /** *This class attempts to find finder patterns in a QR Code. Finder patterns are the square * markers at three corners of a QR Code.
* *This class is thread-safe but not reentrant. Each thread must allocate its own object. * * @author Sean Owen */var FinderPatternFinder=/*#__PURE__*/function(){/** *
Creates a finder that will search the image for three finder patterns.
* * @param image image to search */ // public constructor(image: BitMatrix) { // this(image, null) // } function FinderPatternFinder(image,resultPointCallback){_classCallCheck(this,FinderPatternFinder);this.image=image;this.resultPointCallback=resultPointCallback;this.possibleCenters=[];this.crossCheckStateCount=new Int32Array(5);this.resultPointCallback=resultPointCallback;}_createClass(FinderPatternFinder,[{key:"getImage",value:function getImage(){return this.image;}},{key:"getPossibleCenters",value:function getPossibleCenters(){return this.possibleCenters;}},{key:"find",value:function find(hints){var tryHarder=hints!==null&&hints!==undefined&&undefined!==hints.get(DecodeHintType$1.TRY_HARDER);var pureBarcode=hints!==null&&hints!==undefined&&undefined!==hints.get(DecodeHintType$1.PURE_BARCODE);var image=this.image;var maxI=image.getHeight();var maxJ=image.getWidth();// We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. var iSkip=Math.floor(3*maxI/(4*FinderPatternFinder.MAX_MODULES));if(iSkipAfter a horizontal scan finds a potential finder pattern, this method * "cross-checks" by scanning down vertically through the center of the possible * finder pattern to see if the same proportion is detected.
* * @param startI row where a finder pattern was detected * @param centerJ center of the section that appears to cross a finder pattern * @param maxCount maximum reasonable number of modules that should be * observed in any reading state, based on the results of the horizontal scan * @return vertical center of finder pattern, or {@link Float#NaN} if not found */},{key:"crossCheckVertical",value:function crossCheckVertical(startI/*int*/,centerJ/*int*/,maxCount/*int*/,originalStateCountTotal/*int*/){var image=this.image;var maxI=image.getHeight();var stateCount=this.getCrossCheckStateCount();// Start counting up from center var i=startI;while(i>=0&&image.get(centerJ,i)){stateCount[2]++;i--;}if(i<0){return NaN;}while(i>=0&&!image.get(centerJ,i)&&stateCount[1]<=maxCount){stateCount[1]++;i--;}// If already too many modules in this state or ran off the edge: if(i<0||stateCount[1]>maxCount){return NaN;}while(i>=0&&image.get(centerJ,i)&&stateCount[0]<=maxCount){stateCount[0]++;i--;}if(stateCount[0]>maxCount){return NaN;}// Now also count down from center i=startI+1;while(iLike {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, * except it reads horizontally instead of vertically. This is used to cross-cross * check a vertical cross check and locate the real center of the alignment pattern.
*/},{key:"crossCheckHorizontal",value:function crossCheckHorizontal(startJ/*int*/,centerI/*int*/,maxCount/*int*/,originalStateCountTotal/*int*/){var image=this.image;var maxJ=image.getWidth();var stateCount=this.getCrossCheckStateCount();var j=startJ;while(j>=0&&image.get(j,centerI)){stateCount[2]++;j--;}if(j<0){return NaN;}while(j>=0&&!image.get(j,centerI)&&stateCount[1]<=maxCount){stateCount[1]++;j--;}if(j<0||stateCount[1]>maxCount){return NaN;}while(j>=0&&image.get(j,centerI)&&stateCount[0]<=maxCount){stateCount[0]++;j--;}if(stateCount[0]>maxCount){return NaN;}j=startJ+1;while(jThis is called when a horizontal scan finds a possible alignment pattern. It will * cross check with a vertical scan, and if successful, will, ah, cross-cross-check * with another horizontal scan. This is needed primarily to locate the real horizontal * center of the pattern in cases of extreme skew. * And then we cross-cross-cross check with another diagonal scan.
* *If that succeeds the finder pattern location is added to a list that tracks
* the number of times each location has been nearly-matched as a finder pattern.
* Each additional find is more evidence that the location is in fact a finder
* pattern center
*
* @param stateCount reading state module counts from horizontal scan
* @param i row where finder pattern may be found
* @param j end of possible finder pattern in row
* @param pureBarcode true if in "pure barcode" mode
* @return true if a finder pattern candidate was found this time
*/},{key:"handlePossibleCenter",value:function handlePossibleCenter(stateCount,i/*int*/,j/*int*/,pureBarcode){var stateCountTotal=stateCount[0]+stateCount[1]+stateCount[2]+stateCount[3]+stateCount[4];var centerJ=FinderPatternFinder.centerFromEnd(stateCount,j);var centerI=this.crossCheckVertical(i,/*(int) */Math.floor(centerJ),stateCount[2],stateCountTotal);if(!isNaN(centerI)){// Re-cross check
centerJ=this.crossCheckHorizontal(/*(int) */Math.floor(centerJ),/*(int) */Math.floor(centerI),stateCount[2],stateCountTotal);if(!isNaN(centerJ)&&(!pureBarcode||this.crossCheckDiagonal(/*(int) */Math.floor(centerI),/*(int) */Math.floor(centerJ),stateCount[2],stateCountTotal))){var estimatedModuleSize=stateCountTotal/7.0;var found=false;var possibleCenters=this.possibleCenters;for(var index=0,length=possibleCenters.length;index Orders by furthest from average Orders by {@link FinderPattern#getCount()}, descending.
Detects a QR Code in an image.
* * @return {@link DetectorResult} encapsulating results of detecting a QR Code * @throws NotFoundException if QR Code cannot be found * @throws FormatException if a QR Code cannot be decoded */ // public detect(): DetectorResult /*throws NotFoundException, FormatException*/ { // return detect(null) // } /** *Detects a QR Code in an image.
* * @param hints optional hints to detector * @return {@link DetectorResult} encapsulating results of detecting a QR Code * @throws NotFoundException if QR Code cannot be found * @throws FormatException if a QR Code cannot be decoded */},{key:"detect",value:function detect(hints){this.resultPointCallback=hints===null||hints===undefined?null:/*(ResultPointCallback) */hints.get(DecodeHintType$1.NEED_RESULT_POINT_CALLBACK);var finder=new FinderPatternFinder(this.image,this.resultPointCallback);var info=finder.find(hints);return this.processFinderPatternInfo(info);}},{key:"processFinderPatternInfo",value:function processFinderPatternInfo(info){var topLeft=info.getTopLeft();var topRight=info.getTopRight();var bottomLeft=info.getBottomLeft();var moduleSize=this.calculateModuleSize(topLeft,topRight,bottomLeft);if(moduleSize<1.0){throw new NotFoundException('No pattern found in proccess finder.');}var dimension=Detector$2.computeDimension(topLeft,topRight,bottomLeft,moduleSize);var provisionalVersion=Version$1.getProvisionalVersionForDimension(dimension);var modulesBetweenFPCenters=provisionalVersion.getDimensionForVersion()-7;var alignmentPattern=null;// Anything above version 1 has an alignment pattern if(provisionalVersion.getAlignmentPatternCenters().length>0){// Guess where a "bottom right" finder pattern would have been var bottomRightX=topRight.getX()-topLeft.getX()+bottomLeft.getX();var bottomRightY=topRight.getY()-topLeft.getY()+bottomLeft.getY();// Estimate that alignment pattern is closer by 3 modules // from "bottom right" to known top left location var correctionToTopLeft=1.0-3.0/modulesBetweenFPCenters;var estAlignmentX=/*(int) */Math.floor(topLeft.getX()+correctionToTopLeft*(bottomRightX-topLeft.getX()));var estAlignmentY=/*(int) */Math.floor(topLeft.getY()+correctionToTopLeft*(bottomRightY-topLeft.getY()));// Kind of arbitrary -- expand search radius before giving up for(var i=4;i<=16;i<<=1){try{alignmentPattern=this.findAlignmentInRegion(moduleSize,estAlignmentX,estAlignmentY,i);break;}catch(re/*NotFoundException*/){if(!(re instanceof NotFoundException)){throw re;}// try next round }}// If we didn't find alignment pattern... well try anyway without it }var transform=Detector$2.createTransform(topLeft,topRight,bottomLeft,alignmentPattern,dimension);var bits=Detector$2.sampleGrid(this.image,transform,dimension);var points;if(alignmentPattern===null){points=[bottomLeft,topLeft,topRight];}else{points=[bottomLeft,topLeft,topRight,alignmentPattern];}return new DetectorResult(bits,points);}},{key:"calculateModuleSize",value:/** *Computes an average estimated module size based on estimated derived from the positions * of the three finder patterns.
* * @param topLeft detected top-left finder pattern center * @param topRight detected top-right finder pattern center * @param bottomLeft detected bottom-left finder pattern center * @return estimated module size */function calculateModuleSize(topLeft,topRight,bottomLeft){// Take the average return(this.calculateModuleSizeOneWay(topLeft,topRight)+this.calculateModuleSizeOneWay(topLeft,bottomLeft))/2.0;}/** *Estimates module size based on two finder patterns -- it uses * {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the * width of each, measuring along the axis between their centers.
*/},{key:"calculateModuleSizeOneWay",value:function calculateModuleSizeOneWay(pattern,otherPattern){var moduleSizeEst1=this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */Math.floor(pattern.getX()),/*(int) */Math.floor(pattern.getY()),/*(int) */Math.floor(otherPattern.getX()),/*(int) */Math.floor(otherPattern.getY()));var moduleSizeEst2=this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */Math.floor(otherPattern.getX()),/*(int) */Math.floor(otherPattern.getY()),/*(int) */Math.floor(pattern.getX()),/*(int) */Math.floor(pattern.getY()));if(isNaN(moduleSizeEst1)){return moduleSizeEst2/7.0;}if(isNaN(moduleSizeEst2)){return moduleSizeEst1/7.0;}// Average them, and divide by 7 since we've counted the width of 3 black modules, // and 1 white and 1 black module on either side. Ergo, divide sum by 14. return(moduleSizeEst1+moduleSizeEst2)/14.0;}/** * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of * a finder pattern by looking for a black-white-black run from the center in the direction * of another point (another finder pattern center), and in the opposite direction too. */},{key:"sizeOfBlackWhiteBlackRunBothWays",value:function sizeOfBlackWhiteBlackRunBothWays(fromX/*int*/,fromY/*int*/,toX/*int*/,toY/*int*/){var result=this.sizeOfBlackWhiteBlackRun(fromX,fromY,toX,toY);// Now count other way -- don't run off image though of course var scale=1.0;var otherToX=fromX-(toX-fromX);if(otherToX<0){scale=fromX/(/*(float) */fromX-otherToX);otherToX=0;}else if(otherToX>=this.image.getWidth()){scale=(this.image.getWidth()-1-fromX)/(/*(float) */otherToX-fromX);otherToX=this.image.getWidth()-1;}var otherToY=/*(int) */Math.floor(fromY-(toY-fromY)*scale);scale=1.0;if(otherToY<0){scale=fromY/(/*(float) */fromY-otherToY);otherToY=0;}else if(otherToY>=this.image.getHeight()){scale=(this.image.getHeight()-1-fromY)/(/*(float) */otherToY-fromY);otherToY=this.image.getHeight()-1;}otherToX=/*(int) */Math.floor(fromX+(otherToX-fromX)*scale);result+=this.sizeOfBlackWhiteBlackRun(fromX,fromY,otherToX,otherToY);// Middle pixel is double-counted this way; subtract 1 return result-1.0;}/** *This method traces a line from a point in the image, in the direction towards another point. * It begins in a black region, and keeps going until it finds white, then black, then white again. * It reports the distance from the start to this point.
* *This is used when figuring out how wide a finder pattern is, when the finder pattern * may be skewed or rotated.
*/},{key:"sizeOfBlackWhiteBlackRun",value:function sizeOfBlackWhiteBlackRun(fromX/*int*/,fromY/*int*/,toX/*int*/,toY/*int*/){// Mild variant of Bresenham's algorithm // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm var steep=Math.abs(toY-fromY)>Math.abs(toX-fromX);if(steep){var temp=fromX;fromX=fromY;fromY=temp;temp=toX;toX=toY;toY=temp;}var dx=Math.abs(toX-fromX);var dy=Math.abs(toY-fromY);var error=-dx/2;var xstep=fromXAttempts to locate an alignment pattern in a limited region of the image, which is * guessed to contain it. This method uses {@link AlignmentPattern}.
* * @param overallEstModuleSize estimated module size so far * @param estAlignmentX x coordinate of center of area probably containing alignment pattern * @param estAlignmentY y coordinate of above * @param allowanceFactor number of pixels in all directions to search from the center * @return {@link AlignmentPattern} if found, or null otherwise * @throws NotFoundException if an unexpected error occurs during detection */},{key:"findAlignmentInRegion",value:function findAlignmentInRegion(overallEstModuleSize/*float*/,estAlignmentX/*int*/,estAlignmentY/*int*/,allowanceFactor/*float*/){// Look for an alignment pattern (3 modules in size) around where it // should be var allowance=/*(int) */Math.floor(allowanceFactor*overallEstModuleSize);var alignmentAreaLeftX=Math.max(0,estAlignmentX-allowance);var alignmentAreaRightX=Math.min(this.image.getWidth()-1,estAlignmentX+allowance);if(alignmentAreaRightX-alignmentAreaLeftXDetects a PDF417 Code in an image. Only checks 0 and 180 degree rotations.
* * @param image barcode image to decode * @param hints optional hints to detector * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will * be found and returned * @return {@link PDF417DetectorResult} encapsulating results of detecting a PDF417 code * @throws NotFoundException if no PDF417 Code can be found */function detectMultiple(image,hints,multiple){// TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even // different binarizers // boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); var bitMatrix=image.getBlackMatrix();var barcodeCoordinates=Detector$3.detect(multiple,bitMatrix);if(!barcodeCoordinates.length){bitMatrix=bitMatrix.clone();bitMatrix.rotate180();barcodeCoordinates=Detector$3.detect(multiple,bitMatrix);}return new PDF417DetectorResult(bitMatrix,barcodeCoordinates);}/** * Detects PDF417 codes in an image. Only checks 0 degree rotation * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will * be found and returned * @param bitMatrix bit matrix to detect barcodes in * @return List of ResultPoint arrays containing the coordinates of found barcodes */},{key:"detect",value:function detect(multiple,bitMatrix){var barcodeCoordinates=new Array();var row=0;var column=0;var foundBarcodeInRow=false;while(rowA field based on powers of a generator integer, modulo some modulus.
* * @author Sean Owen * @see com.google.zxing.common.reedsolomon.GenericGF */ /*public final*/var ModulusGF=/*#__PURE__*/function(_ModulusBase){_inherits(ModulusGF,_ModulusBase);var _super54=_createSuper(ModulusGF);// private /*final*/ modulus: /*int*/ number; function ModulusGF(modulus,generator){var _this35;_classCallCheck(this,ModulusGF);_this35=_super54.call(this);_this35.modulus=modulus;_this35.expTable=new Int32Array(modulus);_this35.logTable=new Int32Array(modulus);var x=/*int*/1;for(var i/*int*/=0;iThis example * is quite useful in understanding the algorithm.
* * @author Sean Owen * @see com.google.zxing.common.reedsolomon.ReedSolomonDecoder */ /*public final*/var ErrorCorrection=/*#__PURE__*/function(){function ErrorCorrection(){_classCallCheck(this,ErrorCorrection);this.field=ModulusGF.PDF417_GF;}/** * @param received received codewords * @param numECCodewords number of those codewords used for EC * @param erasures location of erasures * @return number of errors * @throws ChecksumException if errors cannot be corrected, maybe because of too many errors */_createClass(ErrorCorrection,[{key:"decode",value:function decode(received,numECCodewords,erasures){var poly=new ModulusPoly(this.field,received);var S=new Int32Array(numECCodewords);var error=false;for(var i/*int*/=numECCodewords;i>0;i--){var evaluation=poly.evaluateAt(this.field.exp(i));S[numECCodewords-i]=evaluation;if(evaluation!==0){error=true;}}if(!error){return 0;}var knownErrors=this.field.getOne();if(erasures!=null){var _iterator54=_createForOfIteratorHelper(erasures),_step54;try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){var erasure=_step54.value;var b=this.field.exp(received.length-1-erasure);// Add (1 - bx) term: var term=new ModulusPoly(this.field,new Int32Array([this.field.subtract(0,b),1]));knownErrors=knownErrors.multiply(term);}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}}var syndrome=new ModulusPoly(this.field,S);// syndrome = syndrome.multiply(knownErrors); var sigmaOmega=this.runEuclideanAlgorithm(this.field.buildMonomial(numECCodewords,1),syndrome,numECCodewords);var sigma=sigmaOmega[0];var omega=sigmaOmega[1];// sigma = sigma.multiply(knownErrors); var errorLocations=this.findErrorLocations(sigma);var errorMagnitudes=this.findErrorMagnitudes(omega,sigma,errorLocations);for(var _i33/*int*/=0;_i33
* Applications that need to define a subclass of
* OutputStream
must always provide at least a method
* that writes one byte of output.
*
* @author Arthur van Hoff
* @see java.io.BufferedOutputStream
* @see java.io.ByteArrayOutputStream
* @see java.io.DataOutputStream
* @see java.io.FilterOutputStream
* @see java.io.InputStream
* @see java.io.OutputStream#write(int)
* @since JDK1.0
*/ /*public*/var OutputStream/*implements Closeable, Flushable*/=/*#__PURE__*/function(){function OutputStream(){_classCallCheck(this,OutputStream);}_createClass(OutputStream,[{key:"writeBytes",value:/**
* Writes b.length
bytes from the specified byte array
* to this output stream. The general contract for write(b)
* is that it should have exactly the same effect as the call
* write(b, 0, b.length)
.
*
* @param b the data.
* @exception IOException if an I/O error occurs.
* @see java.io.OutputStream#write(byte[], int, int)
*/function writeBytes(b){this.writeBytesOffset(b,0,b.length);}/**
* Writes len
bytes from the specified byte array
* starting at offset off
to this output stream.
* The general contract for write(b, off, len)
is that
* some of the bytes in the array b
are written to the
* output stream in order; element b[off]
is the first
* byte written and b[off+len-1]
is the last byte written
* by this operation.
*
* The write
method of OutputStream
calls
* the write method of one argument on each of the bytes to be
* written out. Subclasses are encouraged to override this method and
* provide a more efficient implementation.
*
* If b
is null
, a
* NullPointerException
is thrown.
*
* If
* If the intended destination of this stream is an abstraction provided by
* the underlying operating system, for example a file, then flushing the
* stream guarantees only that bytes previously written to the stream are
* passed to the operating system for writing; it does not guarantee that
* they are actually written to a physical device such as a disk drive.
*
* The
* The
* Closing a ByteArrayOutputStream has no effect. The methods in
* this class can be called after the stream has been closed without
* generating an IOException.
*
* @author Arthur van Hoff
* @since JDK1.0
*/ /*public*/var ByteArrayOutputStream=/*#__PURE__*/function(_OutputStream){_inherits(ByteArrayOutputStream,_OutputStream);var _super58=_createSuper(ByteArrayOutputStream);/**
* Creates a new byte array output stream. The buffer capacity is
* initially 32 bytes, though its size increases if necessary.
*/ // public constructor() {
// this(32);
// }
/**
* Creates a new byte array output stream, with a buffer capacity of
* the specified size, in bytes.
*
* @param size the initial size.
* @exception IllegalArgumentException if size is negative.
*/function ByteArrayOutputStream(){var _this37;var size=arguments.length>0&&arguments[0]!==undefined?arguments[0]:32;_classCallCheck(this,ByteArrayOutputStream);_this37=_super58.call(this);/**
* The number of valid bytes in the buffer.
*/_this37.count=0;if(size<0){throw new IllegalArgumentException('Negative initial size: '+size);}_this37.buf=new Uint8Array(size);return _this37;}/**
* Increases the capacity if necessary to ensure that it can hold
* at least the number of elements specified by the minimum
* capacity argument.
*
* @param minCapacity the desired minimum capacity
* @throws OutOfMemoryError if {@code minCapacity < 0}. This is
* interpreted as a request for the unsatisfiably large capacity
* {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}.
*/_createClass(ByteArrayOutputStream,[{key:"ensureCapacity",value:function ensureCapacity(minCapacity){// overflow-conscious code
if(minCapacity-this.buf.length>0)this.grow(minCapacity);}/**
* Increases the capacity to ensure that it can hold at least the
* number of elements specified by the minimum capacity argument.
*
* @param minCapacity the desired minimum capacity
*/},{key:"grow",value:function grow(minCapacity){// overflow-conscious code
var oldCapacity=this.buf.length;var newCapacity=oldCapacity<<1;if(newCapacity-minCapacity<0)newCapacity=minCapacity;if(newCapacity<0){if(minCapacity<0)// overflow
throw new OutOfMemoryError();newCapacity=Integer.MAX_VALUE;}this.buf=Arrays.copyOfUint8Array(this.buf,newCapacity);}/**
* Writes the specified byte to this byte array output stream.
*
* @param b the byte to be written.
*/},{key:"write",value:function write(b){this.ensureCapacity(this.count+1);this.buf[this.count]=/*(byte)*/b;this.count+=1;}/**
* Writes This method always replaces malformed-input and unmappable-character
* sequences with the default replacement string for the platform's
* default character set. The {@linkplain java.nio.charset.CharsetDecoder}
* class should be used when more control over the decoding process is
* required.
*
* @return String decoded from the buffer's contents.
* @since JDK1.1
*/},{key:"toString_void",value:function toString_void(){return new String(this.buf/*, 0, this.count*/).toString();}/**
* Converts the buffer's contents into a string by decoding the bytes using
* the specified {@link java.nio.charset.Charset charsetName}. The length of
* the new String is a function of the charset, and hence may not be
* equal to the length of the byte array.
*
* This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. The {@link
* java.nio.charset.CharsetDecoder} class should be used when more control
* over the decoding process is required.
*
* @param charsetName the name of a supported
* {@linkplain java.nio.charset.Charset charset
*
* @throws IOException
*/},{key:"close",value:function close(){}}]);return ByteArrayOutputStream;}(OutputStream);/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ /*private*/var Mode$2;(function(Mode){Mode[Mode["ALPHA"]=0]="ALPHA";Mode[Mode["LOWER"]=1]="LOWER";Mode[Mode["MIXED"]=2]="MIXED";Mode[Mode["PUNCT"]=3]="PUNCT";Mode[Mode["ALPHA_SHIFT"]=4]="ALPHA_SHIFT";Mode[Mode["PUNCT_SHIFT"]=5]="PUNCT_SHIFT";})(Mode$2||(Mode$2={}));/**
* Indirectly access the global BigInt constructor, it
* allows browsers that doesn't support BigInt to run
* the library without breaking due to "undefined BigInt"
* errors.
*/function getBigIntConstructor(){if(typeof window!=='undefined'){return window['BigInt']||null;}if(typeof global!=='undefined'){return global['BigInt']||null;}if(typeof self!=='undefined'){return self['BigInt']||null;}throw new Error('Can\'t search globals for BigInt!');}/**
* Used to store the BigInt constructor.
*/var BigInteger;/**
* This function creates a bigint value. It allows browsers
* that doesn't support BigInt to run the rest of the library
* by not directly accessing the BigInt constructor.
*/function createBigInt(num){if(typeof BigInteger==='undefined'){BigInteger=getBigIntConstructor();}if(BigInteger===null){throw new Error('BigInt is not supported!');}return BigInteger(num);}function getEXP900(){// in Java - array with length = 16
var EXP900=[];EXP900[0]=createBigInt(1);var nineHundred=createBigInt(900);EXP900[1]=nineHundred;// in Java - array with length = 16
for(var i/*int*/=2;i<16;i++){EXP900[i]=EXP900[i-1]*nineHundred;}return EXP900;}/**
* This class contains the methods for decoding the PDF417 codewords. Implements Reed-Solomon encoding, as the name implies. Encode a sequence of code words (symbols) using Reed-Solomon to allow decoders
* to detect and correct errors that may have been introduced when the resulting
* data is stored or transmitted.off
is negative, or len
is negative, or
* off+len
is greater than the length of the array
* b
, then an IndexOutOfBoundsException is thrown.
*
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @exception IOException if an I/O error occurs. In particular,
* an IOException
is thrown if the output
* stream is closed.
*/},{key:"writeBytesOffset",value:function writeBytesOffset(b,off,len){if(b==null){throw new NullPointerException();}else if(off<0||off>b.length||len<0||off+len>b.length||off+len<0){throw new IndexOutOfBoundsException();}else if(len===0){return;}for(var i=0;iflush
method of OutputStream
does nothing.
*
* @exception IOException if an I/O error occurs.
*/},{key:"flush",value:function flush(){}/**
* Closes this output stream and releases any system resources
* associated with this stream. The general contract of close
* is that it closes the output stream. A closed stream cannot perform
* output operations and cannot be reopened.
* close
method of OutputStream
does nothing.
*
* @exception IOException if an I/O error occurs.
*/},{key:"close",value:function close(){}}]);return OutputStream;}();/**
* Custom Error class of type Exception.
*/var OutOfMemoryError=/*#__PURE__*/function(_Exception12){_inherits(OutOfMemoryError,_Exception12);var _super57=_createSuper(OutOfMemoryError);function OutOfMemoryError(){_classCallCheck(this,OutOfMemoryError);return _super57.apply(this,arguments);}return _createClass(OutOfMemoryError);}(Exception);/*
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/ /**
* This class implements an output stream in which the data is
* written into a byte array. The buffer automatically grows as data
* is written to it.
* The data can be retrieved using toByteArray()
and
* toString()
.
* len
bytes from the specified byte array
* starting at offset off
to this byte array output stream.
*
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
*/},{key:"writeBytesOffset",value:function writeBytesOffset(b,off,len){if(off<0||off>b.length||len<0||off+len-b.length>0){throw new IndexOutOfBoundsException();}this.ensureCapacity(this.count+len);System.arraycopy(b,off,this.buf,this.count,len);this.count+=len;}/**
* Writes the complete contents of this byte array output stream to
* the specified output stream argument, as if by calling the output
* stream's write method using out.write(buf, 0, count)
.
*
* @param out the output stream to which to write the data.
* @exception IOException if an I/O error occurs.
*/},{key:"writeTo",value:function writeTo(out){out.writeBytesOffset(this.buf,0,this.count);}/**
* Resets the count
field of this byte array output
* stream to zero, so that all currently accumulated output in the
* output stream is discarded. The output stream can be used again,
* reusing the already allocated buffer space.
*
* @see java.io.ByteArrayInputStream#count
*/},{key:"reset",value:function reset(){this.count=0;}/**
* Creates a newly allocated byte array. Its size is the current
* size of this output stream and the valid contents of the buffer
* have been copied into it.
*
* @return the current contents of this output stream, as a byte array.
* @see java.io.ByteArrayOutputStream#size()
*/},{key:"toByteArray",value:function toByteArray(){return Arrays.copyOfUint8Array(this.buf,this.count);}/**
* Returns the current size of the buffer.
*
* @return the value of the count
field, which is the number
* of valid bytes in this output stream.
* @see java.io.ByteArrayOutputStream#count
*/},{key:"size",value:function size(){return this.count;}},{key:"toString",value:function toString(param){if(!param){return this.toString_void();}if(typeof param==='string'){return this.toString_string(param);}return this.toString_number(param);}/**
* Converts the buffer's contents into a string decoding bytes using the
* platform's default character set. The length of the new String
* is a function of the character set, and hence may not be equal to the
* size of the buffer.
*
* }
* @return String decoded from the buffer's contents.
* @exception UnsupportedEncodingException
* If the named charset is not supported
* @since JDK1.1
*/},{key:"toString_string",value:function toString_string(charsetName){return new String(this.buf/*, 0, this.count, charsetName*/).toString();}/**
* Creates a newly allocated string. Its size is the current size of
* the output stream and the valid contents of the buffer have been
* copied into it. Each character c in the resulting string is
* constructed from the corresponding element b in the byte
* array such that:
*
*
* @deprecated This method does not properly convert bytes into characters.
* As of JDK 1.1, the preferred way to do this is via the
*
* c == (char)(((hibyte & 0xff) << 8) | (b & 0xff))
*
toString(String enc)
method, which takes an encoding-name
* argument, or the toString()
method, which uses the
* platform's default character encoding.
*
* @param hibyte the high byte of each resulting Unicode character.
* @return the current contents of the output stream, as a string.
* @see java.io.ByteArrayOutputStream#size()
* @see java.io.ByteArrayOutputStream#toString(String)
* @see java.io.ByteArrayOutputStream#toString()
*/ // @Deprecated
},{key:"toString_number",value:function toString_number(hibyte){return new String(this.buf/*, hibyte, 0, this.count*/).toString();}/**
* Closing a ByteArrayOutputStream has no effect. The methods in
* this class can be called after the stream has been closed without
* generating an IOException.
*
";
qrCodeScanRegion.appendChild(this.cameraScanImage);
return;
}
this.cameraScanImage = new Image();
this.cameraScanImage.onload = function (_) {
qrCodeScanRegion.innerHTML = "
";
qrCodeScanRegion.appendChild($this.cameraScanImage);
};
this.cameraScanImage.width = 64;
this.cameraScanImage.style.opacity = "0.8";
this.cameraScanImage.src = _imageAssets.ASSET_CAMERA_SCAN;
this.cameraScanImage.alt = _strings.Html5QrcodeScannerStrings.cameraScanAltText();
};
Html5QrcodeScanner.prototype.insertFileScanImageToScanRegion = function () {
var $this = this;
var qrCodeScanRegion = document.getElementById(this.getScanRegionId());
if (this.fileScanImage) {
qrCodeScanRegion.innerHTML = "
";
qrCodeScanRegion.appendChild(this.fileScanImage);
return;
}
this.fileScanImage = new Image();
this.fileScanImage.onload = function (_) {
qrCodeScanRegion.innerHTML = "
";
qrCodeScanRegion.appendChild($this.fileScanImage);
};
this.fileScanImage.width = 64;
this.fileScanImage.style.opacity = "0.8";
this.fileScanImage.src = _imageAssets.ASSET_FILE_SCAN;
this.fileScanImage.alt = _strings.Html5QrcodeScannerStrings.fileScanAltText();
};
Html5QrcodeScanner.prototype.clearScanRegion = function () {
var qrCodeScanRegion = document.getElementById(this.getScanRegionId());
qrCodeScanRegion.innerHTML = "";
};
Html5QrcodeScanner.prototype.getDashboardSectionId = function () {
return "".concat(this.elementId, "__dashboard_section");
};
Html5QrcodeScanner.prototype.getDashboardSectionCameraScanRegionId = function () {
return "".concat(this.elementId, "__dashboard_section_csr");
};
Html5QrcodeScanner.prototype.getDashboardSectionSwapLinkId = function () {
return _base.PublicUiElementIdAndClasses.SCAN_TYPE_CHANGE_ANCHOR_ID;
};
Html5QrcodeScanner.prototype.getScanRegionId = function () {
return "".concat(this.elementId, "__scan_region");
};
Html5QrcodeScanner.prototype.getDashboardId = function () {
return "".concat(this.elementId, "__dashboard");
};
Html5QrcodeScanner.prototype.getHeaderMessageContainerId = function () {
return "".concat(this.elementId, "__header_message");
};
Html5QrcodeScanner.prototype.getCameraPermissionButtonId = function () {
return _base.PublicUiElementIdAndClasses.CAMERA_PERMISSION_BUTTON_ID;
};
Html5QrcodeScanner.prototype.getCameraScanRegion = function () {
return document.getElementById(this.getDashboardSectionCameraScanRegionId());
};
Html5QrcodeScanner.prototype.getDashboardSectionSwapLink = function () {
return document.getElementById(this.getDashboardSectionSwapLinkId());
};
Html5QrcodeScanner.prototype.getHeaderMessageDiv = function () {
return document.getElementById(this.getHeaderMessageContainerId());
};
return Html5QrcodeScanner;
}();
exports.Html5QrcodeScanner = Html5QrcodeScanner;
/***/ }),
/* 82 */
/*!****************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/image-assets.js ***!
\****************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ASSET_INFO_ICON_16PX = exports.ASSET_FILE_SCAN = exports.ASSET_CLOSE_ICON_16PX = exports.ASSET_CAMERA_SCAN = void 0;
var SVG_XML_PREFIX = "data:image/svg+xml;base64,";
var ASSET_CAMERA_SCAN = SVG_XML_PREFIX + "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzNzEuNjQzIDM3MS42NDMiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDM3MS42NDMgMzcxLjY0MyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZD0iTTEwNS4wODQgMzguMjcxaDE2My43Njh2MjBIMTA1LjA4NHoiLz48cGF0aCBkPSJNMzExLjU5NiAxOTAuMTg5Yy03LjQ0MS05LjM0Ny0xOC40MDMtMTYuMjA2LTMyLjc0My0yMC41MjJWMzBjMC0xNi41NDItMTMuNDU4LTMwLTMwLTMwSDEyNS4wODRjLTE2LjU0MiAwLTMwIDEzLjQ1OC0zMCAzMHYxMjAuMTQzaC04LjI5NmMtMTYuNTQyIDAtMzAgMTMuNDU4LTMwIDMwdjEuMzMzYTI5LjgwNCAyOS44MDQgMCAwIDAgNC42MDMgMTUuOTM5Yy03LjM0IDUuNDc0LTEyLjEwMyAxNC4yMjEtMTIuMTAzIDI0LjA2MXYxLjMzM2MwIDkuODQgNC43NjMgMTguNTg3IDEyLjEwMyAyNC4wNjJhMjkuODEgMjkuODEgMCAwIDAtNC42MDMgMTUuOTM4djEuMzMzYzAgMTYuNTQyIDEzLjQ1OCAzMCAzMCAzMGg4LjMyNGMuNDI3IDExLjYzMSA3LjUwMyAyMS41ODcgMTcuNTM0IDI2LjE3Ny45MzEgMTAuNTAzIDQuMDg0IDMwLjE4NyAxNC43NjggNDUuNTM3YTkuOTg4IDkuOTg4IDAgMCAwIDguMjE2IDQuMjg4IDkuOTU4IDkuOTU4IDAgMCAwIDUuNzA0LTEuNzkzYzQuNTMzLTMuMTU1IDUuNjUtOS4zODggMi40OTUtMTMuOTIxLTYuNzk4LTkuNzY3LTkuNjAyLTIyLjYwOC0xMC43Ni0zMS40aDgyLjY4NWMuMjcyLjQxNC41NDUuODE4LjgxNSAxLjIxIDMuMTQyIDQuNTQxIDkuMzcyIDUuNjc5IDEzLjkxMyAyLjUzNCA0LjU0Mi0zLjE0MiA1LjY3Ny05LjM3MSAyLjUzNS0xMy45MTMtMTEuOTE5LTE3LjIyOS04Ljc4Ny0zNS44ODQgOS41ODEtNTcuMDEyIDMuMDY3LTIuNjUyIDEyLjMwNy0xMS43MzIgMTEuMjE3LTI0LjAzMy0uODI4LTkuMzQzLTcuMTA5LTE3LjE5NC0xOC42NjktMjMuMzM3YTkuODU3IDkuODU3IDAgMCAwLTEuMDYxLS40ODZjLS40NjYtLjE4Mi0xMS40MDMtNC41NzktOS43NDEtMTUuNzA2IDEuMDA3LTYuNzM3IDE0Ljc2OC04LjI3MyAyMy43NjYtNy42NjYgMjMuMTU2IDEuNTY5IDM5LjY5OCA3LjgwMyA0Ny44MzYgMTguMDI2IDUuNzUyIDcuMjI1IDcuNjA3IDE2LjYyMyA1LjY3MyAyOC43MzMtLjQxMyAyLjU4NS0uODI0IDUuMjQxLTEuMjQ1IDcuOTU5LTUuNzU2IDM3LjE5NC0xMi45MTkgODMuNDgzLTQ5Ljg3IDExNC42NjEtNC4yMjEgMy41NjEtNC43NTYgOS44Ny0xLjE5NCAxNC4wOTJhOS45OCA5Ljk4IDAgMCAwIDcuNjQ4IDMuNTUxIDkuOTU1IDkuOTU1IDAgMCAwIDYuNDQ0LTIuMzU4YzQyLjY3Mi0zNi4wMDUgNTAuODAyLTg4LjUzMyA1Ni43MzctMTI2Ljg4OC40MTUtMi42ODQuODIxLTUuMzA5IDEuMjI5LTcuODYzIDIuODM0LTE3LjcyMS0uNDU1LTMyLjY0MS05Ljc3Mi00NC4zNDV6bS0yMzIuMzA4IDQyLjYyYy01LjUxNCAwLTEwLTQuNDg2LTEwLTEwdi0xLjMzM2MwLTUuNTE0IDQuNDg2LTEwIDEwLTEwaDE1djIxLjMzM2gtMTV6bS0yLjUtNTIuNjY2YzAtNS41MTQgNC40ODYtMTAgMTAtMTBoNy41djIxLjMzM2gtNy41Yy01LjUxNCAwLTEwLTQuNDg2LTEwLTEwdi0xLjMzM3ptMTcuNSA5My45OTloLTcuNWMtNS41MTQgMC0xMC00LjQ4Ni0xMC0xMHYtMS4zMzNjMC01LjUxNCA0LjQ4Ni0xMCAxMC0xMGg3LjV2MjEuMzMzem0zMC43OTYgMjguODg3Yy01LjUxNCAwLTEwLTQuNDg2LTEwLTEwdi04LjI3MWg5MS40NTdjLS44NTEgNi42NjgtLjQzNyAxMi43ODcuNzMxIDE4LjI3MWgtODIuMTg4em03OS40ODItMTEzLjY5OGMtMy4xMjQgMjAuOTA2IDEyLjQyNyAzMy4xODQgMjEuNjI1IDM3LjA0IDUuNDQxIDIuOTY4IDcuNTUxIDUuNjQ3IDcuNzAxIDcuMTg4LjIxIDIuMTUtMi41NTMgNS42ODQtNC40NzcgNy4yNTEtLjQ4Mi4zNzgtLjkyOS44LTEuMzM1IDEuMjYxLTYuOTg3IDcuOTM2LTExLjk4MiAxNS41Mi0xNS40MzIgMjIuNjg4aC05Ny41NjRWMzBjMC01LjUxNCA0LjQ4Ni0xMCAxMC0xMGgxMjMuNzY5YzUuNTE0IDAgMTAgNC40ODYgMTAgMTB2MTM1LjU3OWMtMy4wMzItLjM4MS02LjE1LS42OTQtOS4zODktLjkxNC0yNS4xNTktMS42OTQtNDIuMzcgNy43NDgtNDQuODk4IDI0LjY2NnoiLz48cGF0aCBkPSJNMTc5LjEyOSA4My4xNjdoLTI0LjA2YTUgNSAwIDAgMC01IDV2MjQuMDYxYTUgNSAwIDAgMCA1IDVoMjQuMDZhNSA1IDAgMCAwIDUtNVY4OC4xNjdhNSA1IDAgMCAwLTUtNXpNMTcyLjYyOSAxNDIuODZoLTEyLjU2VjEzMC44YTUgNSAwIDEgMC0xMCAwdjE3LjA2MWE1IDUgMCAwIDAgNSA1aDE3LjU2YTUgNSAwIDEgMCAwLTEwLjAwMXpNMjE2LjU2OCA4My4xNjdoLTI0LjA2YTUgNSAwIDAgMC01IDV2MjQuMDYxYTUgNSAwIDAgMCA1IDVoMjQuMDZhNSA1IDAgMCAwIDUtNVY4OC4xNjdhNSA1IDAgMCAwLTUtNXptLTUgMjQuMDYxaC0xNC4wNlY5My4xNjdoMTQuMDZ2MTQuMDYxek0yMTEuNjY5IDEyNS45MzZIMTk3LjQxYTUgNSAwIDAgMC01IDV2MTQuMjU3YTUgNSAwIDAgMCA1IDVoMTQuMjU5YTUgNSAwIDAgMCA1LTV2LTE0LjI1N2E1IDUgMCAwIDAtNS01eiIvPjwvc3ZnPg==";
exports.ASSET_CAMERA_SCAN = ASSET_CAMERA_SCAN;
var ASSET_FILE_SCAN = SVG_XML_PREFIX + "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1OS4wMTggNTkuMDE4IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OS4wMTggNTkuMDE4IiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBkPSJtNTguNzQxIDU0LjgwOS01Ljk2OS02LjI0NGExMC43NCAxMC43NCAwIDAgMCAyLjgyLTcuMjVjMC01Ljk1My00Ljg0My0xMC43OTYtMTAuNzk2LTEwLjc5NlMzNCAzNS4zNjEgMzQgNDEuMzE0IDM4Ljg0MyA1Mi4xMSA0NC43OTYgNTIuMTFjMi40NDEgMCA0LjY4OC0uODI0IDYuNDk5LTIuMTk2bDYuMDAxIDYuMjc3YS45OTguOTk4IDAgMCAwIDEuNDE0LjAzMiAxIDEgMCAwIDAgLjAzMS0xLjQxNHpNMzYgNDEuMzE0YzAtNC44NSAzLjk0Ni04Ljc5NiA4Ljc5Ni04Ljc5NnM4Ljc5NiAzLjk0NiA4Ljc5NiA4Ljc5Ni0zLjk0NiA4Ljc5Ni04Ljc5NiA4Ljc5NlMzNiA0Ni4xNjQgMzYgNDEuMzE0ek0xMC40MzEgMTYuMDg4YzAgMy4wNyAyLjQ5OCA1LjU2OCA1LjU2OSA1LjU2OHM1LjU2OS0yLjQ5OCA1LjU2OS01LjU2OGMwLTMuMDcxLTIuNDk4LTUuNTY5LTUuNTY5LTUuNTY5cy01LjU2OSAyLjQ5OC01LjU2OSA1LjU2OXptOS4xMzggMGMwIDEuOTY4LTEuNjAyIDMuNTY4LTMuNTY5IDMuNTY4cy0zLjU2OS0xLjYwMS0zLjU2OS0zLjU2OCAxLjYwMi0zLjU2OSAzLjU2OS0zLjU2OSAzLjU2OSAxLjYwMSAzLjU2OSAzLjU2OXoiLz48cGF0aCBkPSJtMzAuODgyIDI4Ljk4NyA5LjE4LTEwLjA1NCAxMS4yNjIgMTAuMzIzYTEgMSAwIDAgMCAxLjM1MS0xLjQ3NWwtMTItMTFhMSAxIDAgMCAwLTEuNDE0LjA2M2wtOS43OTQgMTAuNzI3LTQuNzQzLTQuNzQzYTEuMDAzIDEuMDAzIDAgMCAwLTEuMzY4LS4wNDRMNi4zMzkgMzcuNzY4YTEgMSAwIDEgMCAxLjMyMiAxLjUwMWwxNi4zMTMtMTQuMzYyIDcuMzE5IDcuMzE4YS45OTkuOTk5IDAgMSAwIDEuNDE0LTEuNDE0bC0xLjgyNS0xLjgyNHoiLz48cGF0aCBkPSJNMzAgNDYuNTE4SDJ2LTQyaDU0djI4YTEgMSAwIDEgMCAyIDB2LTI5YTEgMSAwIDAgMC0xLTFIMWExIDEgMCAwIDAtMSAxdjQ0YTEgMSAwIDAgMCAxIDFoMjlhMSAxIDAgMSAwIDAtMnoiLz48L3N2Zz4=";
exports.ASSET_FILE_SCAN = ASSET_FILE_SCAN;
var ASSET_INFO_ICON_16PX = SVG_XML_PREFIX + "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NjAgNDYwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA0NjAgNDYwIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBkPSJNMjMwIDBDMTAyLjk3NSAwIDAgMTAyLjk3NSAwIDIzMHMxMDIuOTc1IDIzMCAyMzAgMjMwIDIzMC0xMDIuOTc0IDIzMC0yMzBTMzU3LjAyNSAwIDIzMCAwem0zOC4zMzMgMzc3LjM2YzAgOC42NzYtNy4wMzQgMTUuNzEtMTUuNzEgMTUuNzFoLTQzLjEwMWMtOC42NzYgMC0xNS43MS03LjAzNC0xNS43MS0xNS43MVYyMDIuNDc3YzAtOC42NzYgNy4wMzMtMTUuNzEgMTUuNzEtMTUuNzFoNDMuMTAxYzguNjc2IDAgMTUuNzEgNy4wMzMgMTUuNzEgMTUuNzFWMzc3LjM2ek0yMzAgMTU3Yy0yMS41MzkgMC0zOS0xNy40NjEtMzktMzlzMTcuNDYxLTM5IDM5LTM5IDM5IDE3LjQ2MSAzOSAzOS0xNy40NjEgMzktMzkgMzl6Ii8+PC9zdmc+";
exports.ASSET_INFO_ICON_16PX = ASSET_INFO_ICON_16PX;
var ASSET_CLOSE_ICON_16PX = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAQgAAAEIBarqQRAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAE1SURBVDiNfdI7S0NBEAXgLya1otFgpbYSbISAgpXYi6CmiH9KCAiChaVga6OiWPgfRDQ+0itaGVNosXtluWwcuMzePfM4M3sq8lbHBubwg1dc4m1E/J/N4ghDPOIsfk/4xiEao5KX0McFljN4C9d4QTPXuY99jP3DsIoDPGM6BY5i5yI5R7O4q+ImFkJY2DCh3cAH2klyB+9J1xUMMAG7eCh1a+Mr+k48b5diXrFVwwLuS+BJ9MfR7+G0FHOHhTHhnXNWS87VDF4pcnfQK4Ep7XScNLmPTZgURNKKYENYWDpzW1BhscS1WHS8CDgURFJQrWcoF3c13KKbgg1BYQfy8xZWEzTTw1QZbAoKu8FqJnktdu5hcVSHmchiILzzuaDQvjBzV2m8yohCE1jHfPx/xhU+y4G/D75ELlRJsSYAAAAASUVORK5CYII=";
exports.ASSET_CLOSE_ICON_16PX = ASSET_CLOSE_ICON_16PX;
/***/ }),
/* 83 */
/*!***********************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/storage.js ***!
\***********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PersistedDataManager = void 0;
var PersistedDataFactory = function () {
function PersistedDataFactory() {}
PersistedDataFactory.createDefault = function () {
return {
hasPermission: false,
lastUsedCameraId: null
};
};
return PersistedDataFactory;
}();
var PersistedDataManager = function () {
function PersistedDataManager() {
this.data = PersistedDataFactory.createDefault();
var data = localStorage.getItem(PersistedDataManager.LOCAL_STORAGE_KEY);
if (!data) {
this.reset();
} else {
this.data = JSON.parse(data);
}
}
PersistedDataManager.prototype.hasCameraPermissions = function () {
return this.data.hasPermission;
};
PersistedDataManager.prototype.getLastUsedCameraId = function () {
return this.data.lastUsedCameraId;
};
PersistedDataManager.prototype.setHasPermission = function (hasPermission) {
this.data.hasPermission = hasPermission;
this.flush();
};
PersistedDataManager.prototype.setLastUsedCameraId = function (lastUsedCameraId) {
this.data.lastUsedCameraId = lastUsedCameraId;
this.flush();
};
PersistedDataManager.prototype.resetLastUsedCameraId = function () {
this.data.lastUsedCameraId = null;
this.flush();
};
PersistedDataManager.prototype.reset = function () {
this.data = PersistedDataFactory.createDefault();
this.flush();
};
PersistedDataManager.prototype.flush = function () {
localStorage.setItem(PersistedDataManager.LOCAL_STORAGE_KEY, JSON.stringify(this.data));
};
PersistedDataManager.LOCAL_STORAGE_KEY = "HTML5_QRCODE_DATA";
return PersistedDataManager;
}();
exports.PersistedDataManager = PersistedDataManager;
/***/ }),
/* 84 */
/*!******************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/ui.js ***!
\******************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LibraryInfoContainer = void 0;
var _imageAssets = __webpack_require__(/*! ./image-assets */ 82);
var _strings = __webpack_require__(/*! ./strings */ 63);
var LibraryInfoDiv = function () {
function LibraryInfoDiv() {
this.infoDiv = document.createElement("div");
}
LibraryInfoDiv.prototype.renderInto = function (parent) {
this.infoDiv.style.position = "absolute";
this.infoDiv.style.top = "10px";
this.infoDiv.style.right = "10px";
this.infoDiv.style.zIndex = "2";
this.infoDiv.style.display = "none";
this.infoDiv.style.padding = "5pt";
this.infoDiv.style.border = "1px solid #171717";
this.infoDiv.style.fontSize = "10pt";
this.infoDiv.style.background = "rgb(0 0 0 / 69%)";
this.infoDiv.style.borderRadius = "5px";
this.infoDiv.style.textAlign = "center";
this.infoDiv.style.fontWeight = "400";
this.infoDiv.style.color = "white";
this.infoDiv.innerText = _strings.LibraryInfoStrings.poweredBy();
var projectLink = document.createElement("a");
projectLink.innerText = "ScanApp";
projectLink.href = "https://scanapp.org";
projectLink.target = "new";
projectLink.style.color = "white";
this.infoDiv.appendChild(projectLink);
var breakElemFirst = document.createElement("br");
var breakElemSecond = document.createElement("br");
this.infoDiv.appendChild(breakElemFirst);
this.infoDiv.appendChild(breakElemSecond);
var reportIssueLink = document.createElement("a");
reportIssueLink.innerText = _strings.LibraryInfoStrings.reportIssues();
reportIssueLink.href = "https://github.com/mebjas/html5-qrcode/issues";
reportIssueLink.target = "new";
reportIssueLink.style.color = "white";
this.infoDiv.appendChild(reportIssueLink);
parent.appendChild(this.infoDiv);
};
LibraryInfoDiv.prototype.show = function () {
this.infoDiv.style.display = "block";
};
LibraryInfoDiv.prototype.hide = function () {
this.infoDiv.style.display = "none";
};
return LibraryInfoDiv;
}();
var LibraryInfoIcon = function () {
function LibraryInfoIcon(onTapIn, onTapOut) {
this.isShowingInfoIcon = true;
this.onTapIn = onTapIn;
this.onTapOut = onTapOut;
this.infoIcon = document.createElement("img");
}
LibraryInfoIcon.prototype.renderInto = function (parent) {
var _this = this;
this.infoIcon.alt = "Info icon";
this.infoIcon.src = _imageAssets.ASSET_INFO_ICON_16PX;
this.infoIcon.style.position = "absolute";
this.infoIcon.style.top = "4px";
this.infoIcon.style.right = "4px";
this.infoIcon.style.opacity = "0.6";
this.infoIcon.style.cursor = "pointer";
this.infoIcon.style.zIndex = "2";
this.infoIcon.style.width = "16px";
this.infoIcon.style.height = "16px";
this.infoIcon.onmouseover = function (_) {
return _this.onHoverIn();
};
this.infoIcon.onmouseout = function (_) {
return _this.onHoverOut();
};
this.infoIcon.onclick = function (_) {
return _this.onClick();
};
parent.appendChild(this.infoIcon);
};
LibraryInfoIcon.prototype.onHoverIn = function () {
if (this.isShowingInfoIcon) {
this.infoIcon.style.opacity = "1";
}
};
LibraryInfoIcon.prototype.onHoverOut = function () {
if (this.isShowingInfoIcon) {
this.infoIcon.style.opacity = "0.6";
}
};
LibraryInfoIcon.prototype.onClick = function () {
if (this.isShowingInfoIcon) {
this.isShowingInfoIcon = false;
this.onTapIn();
this.infoIcon.src = _imageAssets.ASSET_CLOSE_ICON_16PX;
this.infoIcon.style.opacity = "1";
} else {
this.isShowingInfoIcon = true;
this.onTapOut();
this.infoIcon.src = _imageAssets.ASSET_INFO_ICON_16PX;
this.infoIcon.style.opacity = "0.6";
}
};
return LibraryInfoIcon;
}();
var LibraryInfoContainer = function () {
function LibraryInfoContainer() {
var _this = this;
this.infoDiv = new LibraryInfoDiv();
this.infoIcon = new LibraryInfoIcon(function () {
_this.infoDiv.show();
}, function () {
_this.infoDiv.hide();
});
}
LibraryInfoContainer.prototype.renderInto = function (parent) {
this.infoDiv.renderInto(parent);
this.infoIcon.renderInto(parent);
};
return LibraryInfoContainer;
}();
exports.LibraryInfoContainer = LibraryInfoContainer;
/***/ }),
/* 85 */
/*!**********************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/camera/permissions.js ***!
\**********************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CameraPermissions = void 0;
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
var _ = {
label: 0,
sent: function sent() {
if (t[0] & 1) throw t[1];
return t[1];
},
trys: [],
ops: []
},
f,
y,
t,
g;
return g = {
next: verb(0),
"throw": verb(1),
"return": verb(2)
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
return this;
}), g;
function verb(n) {
return function (v) {
return step([n, v]);
};
}
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) {
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return {
value: op[1],
done: false
};
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2]) _.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
} catch (e) {
op = [6, e];
y = 0;
} finally {
f = t = 0;
}
}
if (op[0] & 5) throw op[1];
return {
value: op[0] ? op[1] : void 0,
done: true
};
}
};
var CameraPermissions = function () {
function CameraPermissions() {}
CameraPermissions.hasPermissions = function () {
return __awaiter(this, void 0, void 0, function () {
var devices, _i, devices_1, device;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
return [4, navigator.mediaDevices.enumerateDevices()];
case 1:
devices = _a.sent();
for (_i = 0, devices_1 = devices; _i < devices_1.length; _i++) {
device = devices_1[_i];
if (device.kind === "videoinput" && device.label) {
return [2, true];
}
}
return [2, false];
}
});
});
};
return CameraPermissions;
}();
exports.CameraPermissions = CameraPermissions;
/***/ }),
/* 86 */
/*!*********************************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/ui/scanner/scan-type-selector.js ***!
\*********************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ScanTypeSelector = void 0;
var _core = __webpack_require__(/*! ../../core */ 62);
var ScanTypeSelector = function () {
function ScanTypeSelector(supportedScanTypes) {
this.supportedScanTypes = this.validateAndReturnScanTypes(supportedScanTypes);
}
ScanTypeSelector.prototype.getDefaultScanType = function () {
return this.supportedScanTypes[0];
};
ScanTypeSelector.prototype.hasMoreThanOneScanType = function () {
return this.supportedScanTypes.length > 1;
};
ScanTypeSelector.prototype.isCameraScanRequired = function () {
for (var _i = 0, _a = this.supportedScanTypes; _i < _a.length; _i++) {
var scanType = _a[_i];
if (ScanTypeSelector.isCameraScanType(scanType)) {
return true;
}
}
return false;
};
ScanTypeSelector.isCameraScanType = function (scanType) {
return scanType === _core.Html5QrcodeScanType.SCAN_TYPE_CAMERA;
};
ScanTypeSelector.isFileScanType = function (scanType) {
return scanType === _core.Html5QrcodeScanType.SCAN_TYPE_FILE;
};
ScanTypeSelector.prototype.validateAndReturnScanTypes = function (supportedScanTypes) {
if (!supportedScanTypes || supportedScanTypes.length === 0) {
return _core.Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE;
}
var maxExpectedValues = _core.Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE.length;
if (supportedScanTypes.length > maxExpectedValues) {
throw "Max ".concat(maxExpectedValues, " values expected for ") + "supportedScanTypes";
}
for (var _i = 0, supportedScanTypes_1 = supportedScanTypes; _i < supportedScanTypes_1.length; _i++) {
var scanType = supportedScanTypes_1[_i];
if (!_core.Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE.includes(scanType)) {
throw "Unsupported scan type ".concat(scanType);
}
}
return supportedScanTypes;
};
return ScanTypeSelector;
}();
exports.ScanTypeSelector = ScanTypeSelector;
/***/ }),
/* 87 */
/*!***************************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/ui/scanner/torch-button.js ***!
\***************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TorchButton = void 0;
var _strings = __webpack_require__(/*! ../../strings */ 63);
var _base = __webpack_require__(/*! ./base */ 88);
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
var _ = {
label: 0,
sent: function sent() {
if (t[0] & 1) throw t[1];
return t[1];
},
trys: [],
ops: []
},
f,
y,
t,
g;
return g = {
next: verb(0),
"throw": verb(1),
"return": verb(2)
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
return this;
}), g;
function verb(n) {
return function (v) {
return step([n, v]);
};
}
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) {
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return {
value: op[1],
done: false
};
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2]) _.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
} catch (e) {
op = [6, e];
y = 0;
} finally {
f = t = 0;
}
}
if (op[0] & 5) throw op[1];
return {
value: op[0] ? op[1] : void 0,
done: true
};
}
};
var TorchController = function () {
function TorchController(torchCapability, buttonController, onTorchActionFailureCallback) {
this.isTorchOn = false;
this.torchCapability = torchCapability;
this.buttonController = buttonController;
this.onTorchActionFailureCallback = onTorchActionFailureCallback;
}
TorchController.prototype.isTorchEnabled = function () {
return this.isTorchOn;
};
TorchController.prototype.flipState = function () {
return __awaiter(this, void 0, void 0, function () {
var isTorchOnExpected, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.buttonController.disable();
isTorchOnExpected = !this.isTorchOn;
_a.label = 1;
case 1:
_a.trys.push([1, 3,, 4]);
return [4, this.torchCapability.apply(isTorchOnExpected)];
case 2:
_a.sent();
this.updateUiBasedOnLatestSettings(this.torchCapability.value(), isTorchOnExpected);
return [3, 4];
case 3:
error_1 = _a.sent();
this.propagateFailure(isTorchOnExpected, error_1);
this.buttonController.enable();
return [3, 4];
case 4:
return [2];
}
});
});
};
TorchController.prototype.updateUiBasedOnLatestSettings = function (isTorchOn, isTorchOnExpected) {
if (isTorchOn === isTorchOnExpected) {
this.buttonController.setText(isTorchOnExpected ? _strings.Html5QrcodeScannerStrings.torchOffButton() : _strings.Html5QrcodeScannerStrings.torchOnButton());
this.isTorchOn = isTorchOnExpected;
} else {
this.propagateFailure(isTorchOnExpected);
}
this.buttonController.enable();
};
TorchController.prototype.propagateFailure = function (isTorchOnExpected, error) {
var errorMessage = isTorchOnExpected ? _strings.Html5QrcodeScannerStrings.torchOnFailedMessage() : _strings.Html5QrcodeScannerStrings.torchOffFailedMessage();
if (error) {
errorMessage += "; Error = " + error;
}
this.onTorchActionFailureCallback(errorMessage);
};
TorchController.prototype.reset = function () {
this.isTorchOn = false;
};
return TorchController;
}();
var TorchButton = function () {
function TorchButton(torchCapability, onTorchActionFailureCallback) {
this.onTorchActionFailureCallback = onTorchActionFailureCallback;
this.torchButton = _base.BaseUiElementFactory.createElement("button", _base.PublicUiElementIdAndClasses.TORCH_BUTTON_ID);
this.torchController = new TorchController(torchCapability, this, onTorchActionFailureCallback);
}
TorchButton.prototype.render = function (parentElement, torchButtonOptions) {
var _this = this;
this.torchButton.innerText = _strings.Html5QrcodeScannerStrings.torchOnButton();
this.torchButton.style.display = torchButtonOptions.display;
this.torchButton.style.marginLeft = torchButtonOptions.marginLeft;
var $this = this;
this.torchButton.addEventListener("click", function (_) {
return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
return [4, $this.torchController.flipState()];
case 1:
_a.sent();
if ($this.torchController.isTorchEnabled()) {
$this.torchButton.classList.remove(_base.PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF);
$this.torchButton.classList.add(_base.PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON);
} else {
$this.torchButton.classList.remove(_base.PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON);
$this.torchButton.classList.add(_base.PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF);
}
return [2];
}
});
});
});
parentElement.appendChild(this.torchButton);
};
TorchButton.prototype.updateTorchCapability = function (torchCapability) {
this.torchController = new TorchController(torchCapability, this, this.onTorchActionFailureCallback);
};
TorchButton.prototype.getTorchButton = function () {
return this.torchButton;
};
TorchButton.prototype.hide = function () {
this.torchButton.style.display = "none";
};
TorchButton.prototype.show = function () {
this.torchButton.style.display = "inline-block";
};
TorchButton.prototype.disable = function () {
this.torchButton.disabled = true;
};
TorchButton.prototype.enable = function () {
this.torchButton.disabled = false;
};
TorchButton.prototype.setText = function (text) {
this.torchButton.innerText = text;
};
TorchButton.prototype.reset = function () {
this.torchButton.innerText = _strings.Html5QrcodeScannerStrings.torchOnButton();
this.torchController.reset();
};
TorchButton.create = function (parentElement, torchCapability, torchButtonOptions, onTorchActionFailureCallback) {
var button = new TorchButton(torchCapability, onTorchActionFailureCallback);
button.render(parentElement, torchButtonOptions);
return button;
};
return TorchButton;
}();
exports.TorchButton = TorchButton;
/***/ }),
/* 88 */
/*!*******************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/ui/scanner/base.js ***!
\*******************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PublicUiElementIdAndClasses = exports.BaseUiElementFactory = void 0;
var PublicUiElementIdAndClasses = function () {
function PublicUiElementIdAndClasses() {}
PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS = "html5-qrcode-element";
PublicUiElementIdAndClasses.CAMERA_PERMISSION_BUTTON_ID = "html5-qrcode-button-camera-permission";
PublicUiElementIdAndClasses.CAMERA_START_BUTTON_ID = "html5-qrcode-button-camera-start";
PublicUiElementIdAndClasses.CAMERA_STOP_BUTTON_ID = "html5-qrcode-button-camera-stop";
PublicUiElementIdAndClasses.TORCH_BUTTON_ID = "html5-qrcode-button-torch";
PublicUiElementIdAndClasses.CAMERA_SELECTION_SELECT_ID = "html5-qrcode-select-camera";
PublicUiElementIdAndClasses.FILE_SELECTION_BUTTON_ID = "html5-qrcode-button-file-selection";
PublicUiElementIdAndClasses.ZOOM_SLIDER_ID = "html5-qrcode-input-range-zoom";
PublicUiElementIdAndClasses.SCAN_TYPE_CHANGE_ANCHOR_ID = "html5-qrcode-anchor-scan-type-change";
PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_ON = "html5-qrcode-button-torch-on";
PublicUiElementIdAndClasses.TORCH_BUTTON_CLASS_TORCH_OFF = "html5-qrcode-button-torch-off";
return PublicUiElementIdAndClasses;
}();
exports.PublicUiElementIdAndClasses = PublicUiElementIdAndClasses;
var BaseUiElementFactory = function () {
function BaseUiElementFactory() {}
BaseUiElementFactory.createElement = function (elementType, elementId) {
var element = document.createElement(elementType);
element.id = elementId;
element.classList.add(PublicUiElementIdAndClasses.ALL_ELEMENT_CLASS);
if (elementType === "button") {
element.setAttribute("type", "button");
}
return element;
};
return BaseUiElementFactory;
}();
exports.BaseUiElementFactory = BaseUiElementFactory;
/***/ }),
/* 89 */
/*!********************************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/ui/scanner/file-selection-ui.js ***!
\********************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FileSelectionUi = void 0;
var _strings = __webpack_require__(/*! ../../strings */ 63);
var _base = __webpack_require__(/*! ./base */ 88);
var FileSelectionUi = function () {
function FileSelectionUi(parentElement, showOnRender, onFileSelected) {
this.fileBasedScanRegion = this.createFileBasedScanRegion();
this.fileBasedScanRegion.style.display = showOnRender ? "block" : "none";
parentElement.appendChild(this.fileBasedScanRegion);
var fileScanLabel = document.createElement("label");
fileScanLabel.setAttribute("for", this.getFileScanInputId());
fileScanLabel.style.display = "inline-block";
this.fileBasedScanRegion.appendChild(fileScanLabel);
this.fileSelectionButton = _base.BaseUiElementFactory.createElement("button", _base.PublicUiElementIdAndClasses.FILE_SELECTION_BUTTON_ID);
this.setInitialValueToButton();
this.fileSelectionButton.addEventListener("click", function (_) {
fileScanLabel.click();
});
fileScanLabel.append(this.fileSelectionButton);
this.fileScanInput = _base.BaseUiElementFactory.createElement("input", this.getFileScanInputId());
this.fileScanInput.type = "file";
this.fileScanInput.accept = "image/*";
this.fileScanInput.style.display = "none";
fileScanLabel.appendChild(this.fileScanInput);
var $this = this;
this.fileScanInput.addEventListener("change", function (e) {
if (e == null || e.target == null) {
return;
}
var target = e.target;
if (target.files && target.files.length === 0) {
return;
}
var fileList = target.files;
var file = fileList[0];
var fileName = file.name;
$this.setImageNameToButton(fileName);
onFileSelected(file);
});
var dragAndDropMessage = this.createDragAndDropMessage();
this.fileBasedScanRegion.appendChild(dragAndDropMessage);
this.fileBasedScanRegion.addEventListener("dragenter", function (event) {
$this.fileBasedScanRegion.style.border = $this.fileBasedScanRegionActiveBorder();
event.stopPropagation();
event.preventDefault();
});
this.fileBasedScanRegion.addEventListener("dragleave", function (event) {
$this.fileBasedScanRegion.style.border = $this.fileBasedScanRegionDefaultBorder();
event.stopPropagation();
event.preventDefault();
});
this.fileBasedScanRegion.addEventListener("dragover", function (event) {
$this.fileBasedScanRegion.style.border = $this.fileBasedScanRegionActiveBorder();
event.stopPropagation();
event.preventDefault();
});
this.fileBasedScanRegion.addEventListener("drop", function (event) {
event.stopPropagation();
event.preventDefault();
$this.fileBasedScanRegion.style.border = $this.fileBasedScanRegionDefaultBorder();
var dataTransfer = event.dataTransfer;
if (dataTransfer) {
var files = dataTransfer.files;
if (!files || files.length === 0) {
return;
}
var isAnyFileImage = false;
for (var i = 0; i < files.length; ++i) {
var file = files.item(i);
if (!file) {
continue;
}
var imageType = /image.*/;
if (!file.type.match(imageType)) {
continue;
}
isAnyFileImage = true;
var fileName = file.name;
$this.setImageNameToButton(fileName);
onFileSelected(file);
dragAndDropMessage.innerText = _strings.Html5QrcodeScannerStrings.dragAndDropMessage();
break;
}
if (!isAnyFileImage) {
dragAndDropMessage.innerText = _strings.Html5QrcodeScannerStrings.dragAndDropMessageOnlyImages();
}
}
});
}
FileSelectionUi.prototype.hide = function () {
this.fileBasedScanRegion.style.display = "none";
this.fileScanInput.disabled = true;
};
FileSelectionUi.prototype.show = function () {
this.fileBasedScanRegion.style.display = "block";
this.fileScanInput.disabled = false;
};
FileSelectionUi.prototype.isShowing = function () {
return this.fileBasedScanRegion.style.display === "block";
};
FileSelectionUi.prototype.resetValue = function () {
this.fileScanInput.value = "";
this.setInitialValueToButton();
};
FileSelectionUi.prototype.createFileBasedScanRegion = function () {
var fileBasedScanRegion = document.createElement("div");
fileBasedScanRegion.style.textAlign = "center";
fileBasedScanRegion.style.margin = "auto";
fileBasedScanRegion.style.width = "80%";
fileBasedScanRegion.style.maxWidth = "600px";
fileBasedScanRegion.style.border = this.fileBasedScanRegionDefaultBorder();
fileBasedScanRegion.style.padding = "10px";
fileBasedScanRegion.style.marginBottom = "10px";
return fileBasedScanRegion;
};
FileSelectionUi.prototype.fileBasedScanRegionDefaultBorder = function () {
return "6px dashed #ebebeb";
};
FileSelectionUi.prototype.fileBasedScanRegionActiveBorder = function () {
return "6px dashed rgb(153 151 151)";
};
FileSelectionUi.prototype.createDragAndDropMessage = function () {
var dragAndDropMessage = document.createElement("div");
dragAndDropMessage.innerText = _strings.Html5QrcodeScannerStrings.dragAndDropMessage();
dragAndDropMessage.style.fontWeight = "400";
return dragAndDropMessage;
};
FileSelectionUi.prototype.setImageNameToButton = function (imageFileName) {
var MAX_CHARS = 20;
if (imageFileName.length > MAX_CHARS) {
var start8Chars = imageFileName.substring(0, 8);
var length_1 = imageFileName.length;
var last8Chars = imageFileName.substring(length_1 - 8, length_1);
imageFileName = "".concat(start8Chars, "....").concat(last8Chars);
}
var newText = _strings.Html5QrcodeScannerStrings.fileSelectionChooseAnother() + " - " + imageFileName;
this.fileSelectionButton.innerText = newText;
};
FileSelectionUi.prototype.setInitialValueToButton = function () {
var initialText = _strings.Html5QrcodeScannerStrings.fileSelectionChooseImage() + " - " + _strings.Html5QrcodeScannerStrings.fileSelectionNoImageSelected();
this.fileSelectionButton.innerText = initialText;
};
FileSelectionUi.prototype.getFileScanInputId = function () {
return "html5-qrcode-private-filescan-input";
};
FileSelectionUi.create = function (parentElement, showOnRender, onFileSelected) {
var button = new FileSelectionUi(parentElement, showOnRender, onFileSelected);
return button;
};
return FileSelectionUi;
}();
exports.FileSelectionUi = FileSelectionUi;
/***/ }),
/* 90 */
/*!**********************************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/ui/scanner/camera-selection-ui.js ***!
\**********************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CameraSelectionUi = void 0;
var _base = __webpack_require__(/*! ./base */ 88);
var _strings = __webpack_require__(/*! ../../strings */ 63);
var CameraSelectionUi = function () {
function CameraSelectionUi(cameras) {
this.selectElement = _base.BaseUiElementFactory.createElement("select", _base.PublicUiElementIdAndClasses.CAMERA_SELECTION_SELECT_ID);
this.cameras = cameras;
this.options = [];
}
CameraSelectionUi.prototype.render = function (parentElement) {
var cameraSelectionContainer = document.createElement("span");
cameraSelectionContainer.style.marginRight = "10px";
var numCameras = this.cameras.length;
if (numCameras === 0) {
throw new Error("No cameras found");
}
if (numCameras === 1) {
cameraSelectionContainer.style.display = "none";
} else {
var selectCameraString = _strings.Html5QrcodeScannerStrings.selectCamera();
cameraSelectionContainer.innerText = "".concat(selectCameraString, " (").concat(this.cameras.length, ") ");
}
var anonymousCameraId = 1;
for (var _i = 0, _a = this.cameras; _i < _a.length; _i++) {
var camera = _a[_i];
var value = camera.id;
var name_1 = camera.label == null ? value : camera.label;
if (!name_1 || name_1 === "") {
name_1 = [_strings.Html5QrcodeScannerStrings.anonymousCameraPrefix(), anonymousCameraId++].join(" ");
}
var option = document.createElement("option");
option.value = value;
option.innerText = name_1;
this.options.push(option);
this.selectElement.appendChild(option);
}
cameraSelectionContainer.appendChild(this.selectElement);
parentElement.appendChild(cameraSelectionContainer);
};
CameraSelectionUi.prototype.disable = function () {
this.selectElement.disabled = true;
};
CameraSelectionUi.prototype.isDisabled = function () {
return this.selectElement.disabled === true;
};
CameraSelectionUi.prototype.enable = function () {
this.selectElement.disabled = false;
};
CameraSelectionUi.prototype.getValue = function () {
return this.selectElement.value;
};
CameraSelectionUi.prototype.hasValue = function (value) {
for (var _i = 0, _a = this.options; _i < _a.length; _i++) {
var option = _a[_i];
if (option.value === value) {
return true;
}
}
return false;
};
CameraSelectionUi.prototype.setValue = function (value) {
if (!this.hasValue(value)) {
throw new Error("".concat(value, " is not present in the camera list."));
}
this.selectElement.value = value;
};
CameraSelectionUi.prototype.hasSingleItem = function () {
return this.cameras.length === 1;
};
CameraSelectionUi.prototype.numCameras = function () {
return this.cameras.length;
};
CameraSelectionUi.create = function (parentElement, cameras) {
var cameraSelectUi = new CameraSelectionUi(cameras);
cameraSelectUi.render(parentElement);
return cameraSelectUi;
};
return CameraSelectionUi;
}();
exports.CameraSelectionUi = CameraSelectionUi;
/***/ }),
/* 91 */
/*!*****************************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/node_modules/html5-qrcode/esm/ui/scanner/camera-zoom-ui.js ***!
\*****************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CameraZoomUi = void 0;
var _base = __webpack_require__(/*! ./base */ 88);
var _strings = __webpack_require__(/*! ../../strings */ 63);
var CameraZoomUi = function () {
function CameraZoomUi() {
this.onChangeCallback = null;
this.zoomElementContainer = document.createElement("div");
this.rangeInput = _base.BaseUiElementFactory.createElement("input", _base.PublicUiElementIdAndClasses.ZOOM_SLIDER_ID);
this.rangeInput.type = "range";
this.rangeText = document.createElement("span");
this.rangeInput.min = "1";
this.rangeInput.max = "5";
this.rangeInput.value = "1";
this.rangeInput.step = "0.1";
}
CameraZoomUi.prototype.render = function (parentElement, renderOnCreate) {
this.zoomElementContainer.style.display = renderOnCreate ? "block" : "none";
this.zoomElementContainer.style.padding = "5px 10px";
this.zoomElementContainer.style.textAlign = "center";
parentElement.appendChild(this.zoomElementContainer);
this.rangeInput.style.display = "inline-block";
this.rangeInput.style.width = "50%";
this.rangeInput.style.height = "5px";
this.rangeInput.style.background = "#d3d3d3";
this.rangeInput.style.outline = "none";
this.rangeInput.style.opacity = "0.7";
var zoomString = _strings.Html5QrcodeScannerStrings.zoom();
this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString);
this.rangeText.style.marginRight = "10px";
var $this = this;
this.rangeInput.addEventListener("input", function () {
return $this.onValueChange();
});
this.rangeInput.addEventListener("change", function () {
return $this.onValueChange();
});
this.zoomElementContainer.appendChild(this.rangeInput);
this.zoomElementContainer.appendChild(this.rangeText);
};
CameraZoomUi.prototype.onValueChange = function () {
var zoomString = _strings.Html5QrcodeScannerStrings.zoom();
this.rangeText.innerText = "".concat(this.rangeInput.value, "x ").concat(zoomString);
if (this.onChangeCallback) {
this.onChangeCallback(parseFloat(this.rangeInput.value));
}
};
CameraZoomUi.prototype.setValues = function (minValue, maxValue, defaultValue, step) {
this.rangeInput.min = minValue.toString();
this.rangeInput.max = maxValue.toString();
this.rangeInput.step = step.toString();
this.rangeInput.value = defaultValue.toString();
this.onValueChange();
};
CameraZoomUi.prototype.show = function () {
this.zoomElementContainer.style.display = "block";
};
CameraZoomUi.prototype.hide = function () {
this.zoomElementContainer.style.display = "none";
};
CameraZoomUi.prototype.setOnCameraZoomValueChangeCallback = function (onChangeCallback) {
this.onChangeCallback = onChangeCallback;
};
CameraZoomUi.prototype.removeOnCameraZoomValueChangeCallback = function () {
this.onChangeCallback = null;
};
CameraZoomUi.create = function (parentElement, renderOnCreate) {
var cameraZoomUi = new CameraZoomUi();
cameraZoomUi.render(parentElement, renderOnCreate);
return cameraZoomUi;
};
return CameraZoomUi;
}();
exports.CameraZoomUi = CameraZoomUi;
/***/ }),
/* 92 */,
/* 93 */,
/* 94 */,
/* 95 */,
/* 96 */,
/* 97 */,
/* 98 */,
/* 99 */,
/* 100 */,
/* 101 */,
/* 102 */,
/* 103 */,
/* 104 */,
/* 105 */,
/* 106 */,
/* 107 */,
/* 108 */,
/* 109 */,
/* 110 */,
/* 111 */,
/* 112 */,
/* 113 */,
/* 114 */,
/* 115 */,
/* 116 */,
/* 117 */,
/* 118 */,
/* 119 */,
/* 120 */,
/* 121 */,
/* 122 */,
/* 123 */,
/* 124 */,
/* 125 */,
/* 126 */,
/* 127 */,
/* 128 */,
/* 129 */,
/* 130 */,
/* 131 */,
/* 132 */,
/* 133 */,
/* 134 */,
/* 135 */,
/* 136 */,
/* 137 */,
/* 138 */
/*!******************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/static/js/mmmm-image-tools/index.js ***!
\******************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(wx) {
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.base64ToPath = base64ToPath;
exports.pathToBase64 = pathToBase64;
var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ 13));
function getLocalFilePath(path) {
if (path.indexOf('_www') === 0 || path.indexOf('_doc') === 0 || path.indexOf('_documents') === 0 || path.indexOf('_downloads') === 0) {
return path;
}
if (path.indexOf('file://') === 0) {
return path;
}
if (path.indexOf('/storage/emulated/0/') === 0) {
return path;
}
if (path.indexOf('/') === 0) {
var localFilePath = plus.io.convertAbsoluteFileSystem(path);
if (localFilePath !== path) {
return localFilePath;
} else {
path = path.substr(1);
}
}
return '_www/' + path;
}
function dataUrlToBase64(str) {
var array = str.split(',');
return array[array.length - 1];
}
var index = 0;
function getNewFileId() {
return Date.now() + String(index++);
}
function biggerThan(v1, v2) {
var v1Array = v1.split('.');
var v2Array = v2.split('.');
var update = false;
for (var index = 0; index < v2Array.length; index++) {
var diff = v1Array[index] - v2Array[index];
if (diff !== 0) {
update = diff > 0;
break;
}
}
return update;
}
function pathToBase64(path) {
return new Promise(function (resolve, reject) {
if ((typeof window === "undefined" ? "undefined" : (0, _typeof2.default)(window)) === 'object' && 'document' in window) {
if (typeof FileReader === 'function') {
var xhr = new XMLHttpRequest();
xhr.open('GET', path, true);
xhr.responseType = 'blob';
xhr.onload = function () {
if (this.status === 200) {
var fileReader = new FileReader();
fileReader.onload = function (e) {
resolve(e.target.result);
};
fileReader.onerror = reject;
fileReader.readAsDataURL(this.response);
}
};
xhr.onerror = reject;
xhr.send();
return;
}
var canvas = document.createElement('canvas');
var c2x = canvas.getContext('2d');
var img = new Image();
img.onload = function () {
canvas.width = img.width;
canvas.height = img.height;
c2x.drawImage(img, 0, 0);
resolve(canvas.toDataURL());
canvas.height = canvas.width = 0;
};
img.onerror = reject;
img.src = path;
return;
}
if ((typeof plus === "undefined" ? "undefined" : (0, _typeof2.default)(plus)) === 'object') {
plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), function (entry) {
entry.file(function (file) {
var fileReader = new plus.io.FileReader();
fileReader.onload = function (data) {
resolve(data.target.result);
};
fileReader.onerror = function (error) {
reject(error);
};
fileReader.readAsDataURL(file);
}, function (error) {
reject(error);
});
}, function (error) {
reject(error);
});
return;
}
if ((typeof wx === "undefined" ? "undefined" : (0, _typeof2.default)(wx)) === 'object' && wx.canIUse('getFileSystemManager')) {
wx.getFileSystemManager().readFile({
filePath: path,
encoding: 'base64',
success: function success(res) {
resolve('data:image/png;base64,' + res.data);
},
fail: function fail(error) {
reject(error);
}
});
return;
}
reject(new Error('not support'));
});
}
function base64ToPath(base64) {
return new Promise(function (resolve, reject) {
if ((typeof window === "undefined" ? "undefined" : (0, _typeof2.default)(window)) === 'object' && 'document' in window) {
base64 = base64.split(',');
var type = base64[0].match(/:(.*?);/)[1];
var str = atob(base64[1]);
var n = str.length;
var array = new Uint8Array(n);
while (n--) {
array[n] = str.charCodeAt(n);
}
return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([array], {
type: type
})));
}
var extName = base64.split(',')[0].match(/data\:\S+\/(\S+);/);
if (extName) {
extName = extName[1];
} else {
reject(new Error('base64 error'));
}
var fileName = getNewFileId() + '.' + extName;
if ((typeof plus === "undefined" ? "undefined" : (0, _typeof2.default)(plus)) === 'object') {
var basePath = '_doc';
var dirPath = 'uniapp_temp';
var filePath = basePath + '/' + dirPath + '/' + fileName;
if (!biggerThan(plus.os.name === 'Android' ? '1.9.9.80627' : '1.9.9.80472', plus.runtime.innerVersion)) {
plus.io.resolveLocalFileSystemURL(basePath, function (entry) {
entry.getDirectory(dirPath, {
create: true,
exclusive: false
}, function (entry) {
entry.getFile(fileName, {
create: true,
exclusive: false
}, function (entry) {
entry.createWriter(function (writer) {
writer.onwrite = function () {
resolve(filePath);
};
writer.onerror = reject;
writer.seek(0);
writer.writeAsBinary(dataUrlToBase64(base64));
}, reject);
}, reject);
}, reject);
}, reject);
return;
}
var bitmap = new plus.nativeObj.Bitmap(fileName);
bitmap.loadBase64Data(base64, function () {
bitmap.save(filePath, {}, function () {
bitmap.clear();
resolve(filePath);
}, function (error) {
bitmap.clear();
reject(error);
});
}, function (error) {
bitmap.clear();
reject(error);
});
return;
}
if ((typeof wx === "undefined" ? "undefined" : (0, _typeof2.default)(wx)) === 'object' && wx.canIUse('getFileSystemManager')) {
var filePath = wx.env.USER_DATA_PATH + '/' + fileName;
wx.getFileSystemManager().writeFile({
filePath: filePath,
data: dataUrlToBase64(base64),
encoding: 'base64',
success: function success() {
resolve(filePath);
},
fail: function fail(error) {
reject(error);
}
});
return;
}
reject(new Error('not support'));
});
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/wx.js */ 1)["default"]))
/***/ }),
/* 139 */,
/* 140 */,
/* 141 */,
/* 142 */,
/* 143 */,
/* 144 */,
/* 145 */,
/* 146 */,
/* 147 */,
/* 148 */,
/* 149 */,
/* 150 */,
/* 151 */,
/* 152 */,
/* 153 */,
/* 154 */,
/* 155 */,
/* 156 */,
/* 157 */,
/* 158 */,
/* 159 */,
/* 160 */,
/* 161 */,
/* 162 */,
/* 163 */,
/* 164 */,
/* 165 */,
/* 166 */,
/* 167 */,
/* 168 */,
/* 169 */,
/* 170 */,
/* 171 */,
/* 172 */,
/* 173 */,
/* 174 */,
/* 175 */,
/* 176 */,
/* 177 */,
/* 178 */,
/* 179 */
/*!*****************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
\*****************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/* 180 */,
/* 181 */,
/* 182 */,
/* 183 */,
/* 184 */,
/* 185 */,
/* 186 */,
/* 187 */
/*!*************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/static/js/lunar.js ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.lunar = void 0;
var lunar = {
/**
* 农历1900-2100的润大小信息表
* @Array Of Property
* @return Hex
*/
lunarInfo: [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,
//1900-1909
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,
//1910-1919
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,
//1920-1929
0x06566, 0x0d4a0, 0x0ea50, 0x16a95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,
//1930-1939
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,
//1940-1949
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0,
//1950-1959
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,
//1960-1969
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6,
//1970-1979
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,
//1980-1989
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x05ac0, 0x0ab60, 0x096d5, 0x092e0,
//1990-1999
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,
//2000-2009
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,
//2010-2019
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,
//2020-2029
0x05aa0, 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45,
//2030-2039
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0,
//2040-2049
/**Add By JJonline@JJonline.Cn**/
0x14b63, 0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, 0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0,
//2050-2059
0x092e0, 0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, 0x05d55, 0x056a0, 0x0a6d0, 0x055d4,
//2060-2069
0x052d0, 0x0a9b8, 0x0a950, 0x0b4a0, 0x0b6a6, 0x0ad50, 0x055a0, 0x0aba4, 0x0a5b0, 0x052b0,
//2070-2079
0x0b273, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160,
//2080-2089
0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252,
//2090-2099
0x0d520],
//2100
/**
* 公历每个月份的天数普通表
* @Array Of Property
* @return Number
*/
solarMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
/**
* 天干地支之天干速查表
* @Array Of Property trans["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"]
* @return Cn string
*/
Gan: ["\u7532", "\u4E59", "\u4E19", "\u4E01", "\u620A", "\u5DF1", "\u5E9A", "\u8F9B", "\u58EC", "\u7678"],
/**
* 天干地支之地支速查表
* @Array Of Property
* @trans["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"]
* @return Cn string
*/
Zhi: ["\u5B50", "\u4E11", "\u5BC5", "\u536F", "\u8FB0", "\u5DF3", "\u5348", "\u672A", "\u7533", "\u9149", "\u620C", "\u4EA5"],
/**
* 天干地支之地支速查表<=>生肖
* @Array Of Property
* @trans["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"]
* @return Cn string
*/
Animals: ["\u9F20", "\u725B", "\u864E", "\u5154", "\u9F99", "\u86C7", "\u9A6C", "\u7F8A", "\u7334", "\u9E21", "\u72D7", "\u732A"],
/**
* 阳历节日
*/
festival: {
"1-1": {
title: "元旦"
},
"2-14": {
title: "情人节"
},
"5-1": {
title: "劳动节"
},
"5-4": {
title: "青年节"
},
"6-1": {
title: "儿童节"
},
"9-10": {
title: "教师节"
},
"10-1": {
title: "国庆节"
},
"12-25": {
title: "圣诞节"
},
"3-8": {
title: "妇女节"
},
"3-12": {
title: "植树节"
},
"4-1": {
title: "愚人节"
},
"4-4": {
title: "清明节"
},
"5-12": {
title: "护士节"
},
"7-1": {
title: "建党节"
},
"8-1": {
title: "建军节"
},
"12-24": {
title: "平安夜"
}
},
/**
* 农历节日
*/
lFestival: {
"12-30": {
title: "除夕"
},
"1-1": {
title: "春节"
},
"1-15": {
title: "元宵节"
},
"2-2": {
title: "龙抬头"
},
"5-5": {
title: "端午节"
},
"7-7": {
title: "七夕节"
},
"7-15": {
title: "中元节"
},
"8-15": {
title: "中秋节"
},
"9-9": {
title: "重阳节"
},
"10-1": {
title: "寒衣节"
},
"10-15": {
title: "下元节"
},
"12-8": {
title: "腊八节"
},
"12-23": {
title: "北方小年"
},
"12-24": {
title: "南方小年"
}
},
/**
* 返回默认定义的阳历节日
*/
getFestival: function getFestival() {
return this.festival;
},
/**
* 返回默认定义的内容里节日
*/
getLunarFestival: function getLunarFestival() {
return this.lFestival;
},
/**
*
* @param param {Object} 按照festival的格式输入数据,设置阳历节日
*/
setFestival: function setFestival() {
var param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this.festival = param;
},
/**
*
* @param param {Object} 按照lFestival的格式输入数据,设置农历节日
*/
setLunarFestival: function setLunarFestival() {
var param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this.lFestival = param;
},
/**
* 24节气速查表
* @Array Of Property
* @trans["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"]
* @return Cn string
*/
solarTerm: ["\u5C0F\u5BD2", "\u5927\u5BD2", "\u7ACB\u6625", "\u96E8\u6C34", "\u60CA\u86F0", "\u6625\u5206", "\u6E05\u660E", "\u8C37\u96E8", "\u7ACB\u590F", "\u5C0F\u6EE1", "\u8292\u79CD", "\u590F\u81F3", "\u5C0F\u6691", "\u5927\u6691", "\u7ACB\u79CB", "\u5904\u6691", "\u767D\u9732", "\u79CB\u5206", "\u5BD2\u9732", "\u971C\u964D", "\u7ACB\u51AC", "\u5C0F\u96EA", "\u5927\u96EA", "\u51AC\u81F3"],
/**
* 1900-2100各年的24节气日期速查表
* @Array Of Property
* @return 0x string For splice
*/
sTermInfo: ["9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c3598082c95f8c965cc920f", "97bd0b06bdb0722c965ce1cfcc920f", "b027097bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd0b06bdb0722c965ce1cfcc920f", "b027097bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd0b06bdb0722c965ce1cfcc920f", "b027097bd097c36b0b6fc9274c91aa", "9778397bd19801ec9210c965cc920e", "97b6b97bd19801ec95f8c965cc920f", "97bd09801d98082c95f8e1cfcc920f", "97bd097bd097c36b0b6fc9210c8dc2", "9778397bd197c36c9210c9274c91aa", "97b6b97bd19801ec95f8c965cc920e", "97bd09801d98082c95f8e1cfcc920f", "97bd097bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c91aa", "97b6b97bd19801ec95f8c965cc920e", "97bcf97c3598082c95f8e1cfcc920f", "97bd097bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c3598082c95f8c965cc920f", "97bd097bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c3598082c95f8c965cc920f", "97bd097bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd097bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd097bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd097bd07f595b0b6fc920fb0722", "9778397bd097c36b0b6fc9210c8dc2", "9778397bd19801ec9210c9274c920e", "97b6b97bd19801ec95f8c965cc920f", "97bd07f5307f595b0b0bc920fb0722", "7f0e397bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c920e", "97b6b97bd19801ec95f8c965cc920f", "97bd07f5307f595b0b0bc920fb0722", "7f0e397bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bd07f1487f595b0b0bc920fb0722", "7f0e397bd097c36b0b6fc9210c8dc2", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf7f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf7f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf7f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf7f1487f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c9274c920e", "97bcf7f0e47f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9210c91aa", "97b6b97bd197c36c9210c9274c920e", "97bcf7f0e47f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c920e", "97b6b7f0e47f531b0723b0b6fb0722", "7f0e37f5307f595b0b0bc920fb0722", "7f0e397bd097c36b0b6fc9210c8dc2", "9778397bd097c36b0b70c9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e37f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc9210c8dc2", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e27f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0787b0721", "7f0e27f0e47f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9210c91aa", "97b6b7f0e47f149b0723b0787b0721", "7f0e27f0e47f531b0723b0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9210c8dc2", "977837f0e37f149b0723b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e37f5307f595b0b0bc920fb0722", "7f0e397bd097c35b0b6fc9210c8dc2", "977837f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e37f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc9210c8dc2", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f149b0723b0787b0721", "7f0e27f0e47f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "977837f0e37f14998082b0723b06bd", "7f07e7f0e37f149b0723b0787b0721", "7f0e27f0e47f531b0723b0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "977837f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e37f1487f595b0b0bb0b6fb0722", "7f0e37f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e37f1487f531b0b0bb0b6fb0722", "7f0e37f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e37f1487f531b0b0bb0b6fb0722", "7f0e37f0e37f14898082b072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e37f0e37f14898082b072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e37f0e366aa89801eb072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f149b0723b0787b0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e37f0e366aa89801eb072297c35", "7ec967f0e37f14998082b0723b06bd", "7f07e7f0e47f149b0723b0787b0721", "7f0e27f0e47f531b0723b0b6fb0722", "7f0e37f0e366aa89801eb072297c35", "7ec967f0e37f14998082b0723b06bd", "7f07e7f0e37f14998083b0787b0721", "7f0e27f0e47f531b0723b0b6fb0722", "7f0e37f0e366aa89801eb072297c35", "7ec967f0e37f14898082b0723b02d5", "7f07e7f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e36665b66aa89801e9808297c35", "665f67f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e36665b66a449801e9808297c35", "665f67f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e36665b66a449801e9808297c35", "665f67f0e37f14898082b072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e26665b66a449801e9808297c35", "665f67f0e37f1489801eb072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722"],
/**
* 数字转中文速查表
* @Array Of Property
* @trans ['日','一','二','三','四','五','六','七','八','九','十']
* @return Cn string
*/
nStr1: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u4E03", "\u516B", "\u4E5D", "\u5341"],
/**
* 日期转农历称呼速查表
* @Array Of Property
* @trans ['初','十','廿','卅']
* @return Cn string
*/
nStr2: ["\u521D", "\u5341", "\u5EFF", "\u5345"],
/**
* 月份转农历称呼速查表
* @Array Of Property
* @trans ['正','一','二','三','四','五','六','七','八','九','十','冬','腊']
* @return Cn string
*/
nStr3: ["\u6B63", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u4E03", "\u516B", "\u4E5D", "\u5341", "\u51AC", "\u814A"],
/**
* 返回农历y年一整年的总天数
* @param y lunar Year
* @return Number
* @eg:var count = calendar.lYearDays(1987) ;//count=387
*/
lYearDays: function lYearDays(y) {
var i,
sum = 348;
for (i = 0x8000; i > 0x8; i >>= 1) {
sum += this.lunarInfo[y - 1900] & i ? 1 : 0;
}
return sum + this.leapDays(y);
},
/**
* 返回农历y年闰月是哪个月;若y年没有闰月 则返回0
* @param y lunar Year
* @return Number (0-12)
* @eg:var leapMonth = calendar.leapMonth(1987) ;//leapMonth=6
*/
leapMonth: function leapMonth(y) {
//闰字编码 \u95f0
return this.lunarInfo[y - 1900] & 0xf;
},
/**
* 返回农历y年闰月的天数 若该年没有闰月则返回0
* @param y lunar Year
* @return Number (0、29、30)
* @eg:var leapMonthDay = calendar.leapDays(1987) ;//leapMonthDay=29
*/
leapDays: function leapDays(y) {
if (this.leapMonth(y)) {
return this.lunarInfo[y - 1900] & 0x10000 ? 30 : 29;
}
return 0;
},
/**
* 返回农历y年m月(非闰月)的总天数,计算m为闰月时的天数请使用leapDays方法
* @param y lunar Year
* @param m lunar Month
* @return Number (-1、29、30)
* @eg:var MonthDay = calendar.monthDays(1987,9) ;//MonthDay=29
*/
monthDays: function monthDays(y, m) {
if (m > 12 || m < 1) {
return -1;
} //月份参数从1至12,参数错误返回-1
return this.lunarInfo[y - 1900] & 0x10000 >> m ? 30 : 29;
},
/**
* 返回公历(!)y年m月的天数
* @param y solar Year
* @param m solar Month
* @return Number (-1、28、29、30、31)
* @eg:var solarMonthDay = calendar.leapDays(1987) ;//solarMonthDay=30
*/
solarDays: function solarDays(y, m) {
if (m > 12 || m < 1) {
return -1;
} //若参数错误 返回-1
var ms = m - 1;
if (ms === 1) {
//2月份的闰平规律测算后确认返回28或29
return y % 4 === 0 && y % 100 !== 0 || y % 400 === 0 ? 29 : 28;
} else {
return this.solarMonth[ms];
}
},
/**
* 农历年份转换为干支纪年
* @param lYear 农历年的年份数
* @return Cn string
*/
toGanZhiYear: function toGanZhiYear(lYear) {
var ganKey = (lYear - 3) % 10;
var zhiKey = (lYear - 3) % 12;
if (ganKey === 0) ganKey = 10; //如果余数为0则为最后一个天干
if (zhiKey === 0) zhiKey = 12; //如果余数为0则为最后一个地支
return this.Gan[ganKey - 1] + this.Zhi[zhiKey - 1];
},
/**
* 公历月、日判断所属星座
* @param cMonth [description]
* @param cDay [description]
* @return Cn string
*/
toAstro: function toAstro(cMonth, cDay) {
var s = "\u9B54\u7FAF\u6C34\u74F6\u53CC\u9C7C\u767D\u7F8A\u91D1\u725B\u53CC\u5B50\u5DE8\u87F9\u72EE\u5B50\u5904\u5973\u5929\u79E4\u5929\u874E\u5C04\u624B\u9B54\u7FAF";
var arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22];
return s.substr(cMonth * 2 - (cDay < arr[cMonth - 1] ? 2 : 0), 2) + "\u5EA7"; //座
},
/**
* 传入offset偏移量返回干支
* @param offset 相对甲子的偏移量
* @return Cn string
*/
toGanZhi: function toGanZhi(offset) {
return this.Gan[offset % 10] + this.Zhi[offset % 12];
},
/**
* 传入公历(!)y年获得该年第n个节气的公历日期
* @param y y公历年(1900-2100)
* @param n n二十四节气中的第几个节气(1~24);从n=1(小寒)算起
* @return day Number
* @eg:var _24 = calendar.getTerm(1987,3) ;//_24=4;意即1987年2月4日立春
*/
getTerm: function getTerm(y, n) {
if (y < 1900 || y > 2100 || n < 1 || n > 24) {
return -1;
}
var _table = this.sTermInfo[y - 1900];
var _calcDay = [];
for (var index = 0; index < _table.length; index += 5) {
var chunk = parseInt("0x" + _table.substr(index, 5)).toString();
_calcDay.push(chunk[0], chunk.substr(1, 2), chunk[3], chunk.substr(4, 2));
}
return parseInt(_calcDay[n - 1]);
},
/**
* 传入农历数字月份返回汉语通俗表示法
* @param m lunar month
* @return Cn string
* @eg:var cnMonth = calendar.toChinaMonth(12) ;//cnMonth='腊月'
*/
toChinaMonth: function toChinaMonth(m) {
// 月 => \u6708
if (m > 12 || m < 1) {
return -1;
} //若参数错误 返回-1
var s = this.nStr3[m - 1];
s += "\u6708"; //加上月字
return s;
},
/**
* 传入农历日期数字返回汉字表示法
* @param d lunar day
* @return Cn string
* @eg:var cnDay = calendar.toChinaDay(21) ;//cnMonth='廿一'
*/
toChinaDay: function toChinaDay(d) {
//日 => \u65e5
var s;
switch (d) {
case 10:
s = "\u521D\u5341";
break;
case 20:
s = "\u4E8C\u5341";
break;
case 30:
s = "\u4E09\u5341";
break;
default:
s = this.nStr2[Math.floor(d / 10)];
s += this.nStr1[d % 10];
}
return s;
},
/**
* 年份转生肖[!仅能大致转换] => 精确划分生肖分界线是“立春”
* @param y year
* @return Cn string
* @eg:var animal = calendar.getAnimal(1987) ;//animal='兔'
*/
getAnimal: function getAnimal(y) {
return this.Animals[(y - 4) % 12];
},
/**
* 传入阳历年月日获得详细的公历、农历object信息 <=>JSON
* !important! 公历参数区间1900.1.31~2100.12.31
* @param yPara solar year
* @param mPara solar month
* @param dPara solar day
* @return JSON object
* @eg:console.log(calendar.solar2lunar(1987,11,01));
*/
solar2lunar: function solar2lunar(yPara, mPara, dPara) {
var y = parseInt(yPara);
var m = parseInt(mPara);
var d = parseInt(dPara);
//年份限定、上限
if (y < 1900 || y > 2100) {
return -1; // undefined转换为数字变为NaN
}
//公历传参最下限
if (y === 1900 && m === 1 && d < 31) {
return -1;
}
//未传参 获得当天
var objDate;
if (!y) {
objDate = new Date();
} else {
objDate = new Date(y, parseInt(m) - 1, d);
}
var i,
leap = 0,
temp = 0;
//修正ymd参数
y = objDate.getFullYear();
m = objDate.getMonth() + 1;
d = objDate.getDate();
var offset = (Date.UTC(objDate.getFullYear(), objDate.getMonth(), objDate.getDate()) - Date.UTC(1900, 0, 31)) / 86400000;
for (i = 1900; i < 2101 && offset > 0; i++) {
temp = this.lYearDays(i);
offset -= temp;
}
if (offset < 0) {
offset += temp;
i--;
}
//是否今天
var isTodayObj = new Date(),
isToday = false;
if (isTodayObj.getFullYear() === y && isTodayObj.getMonth() + 1 === m && isTodayObj.getDate() === d) {
isToday = true;
}
//星期几
var nWeek = objDate.getDay(),
cWeek = this.nStr1[nWeek];
//数字表示周几顺应天朝周一开始的惯例
if (nWeek === 0) {
nWeek = 7;
}
//农历年
var year = i;
leap = this.leapMonth(i); //闰哪个月
var isLeap = false;
//效验闰月
for (i = 1; i < 13 && offset > 0; i++) {
//闰月
if (leap > 0 && i === leap + 1 && isLeap === false) {
--i;
isLeap = true;
temp = this.leapDays(year); //计算农历闰月天数
} else {
temp = this.monthDays(year, i); //计算农历普通月天数
}
//解除闰月
if (isLeap === true && i === leap + 1) {
isLeap = false;
}
offset -= temp;
}
// 闰月导致数组下标重叠取反
if (offset === 0 && leap > 0 && i === leap + 1) {
if (isLeap) {
isLeap = false;
} else {
isLeap = true;
--i;
}
}
if (offset < 0) {
offset += temp;
--i;
}
//农历月
var month = i;
//农历日
var day = offset + 1;
//天干地支处理
var sm = m - 1;
var gzY = this.toGanZhiYear(year);
// 当月的两个节气
// bugfix-2017-7-24 11:03:38 use lunar Year Param `y` Not `year`
var firstNode = this.getTerm(y, m * 2 - 1); //返回当月「节」为几日开始
var secondNode = this.getTerm(y, m * 2); //返回当月「节」为几日开始
// 依据12节气修正干支月
var gzM = this.toGanZhi((y - 1900) * 12 + m + 11);
if (d >= firstNode) {
gzM = this.toGanZhi((y - 1900) * 12 + m + 12);
}
//传入的日期的节气与否
var isTerm = false;
var Term = null;
if (firstNode === d) {
isTerm = true;
Term = this.solarTerm[m * 2 - 2];
}
if (secondNode === d) {
isTerm = true;
Term = this.solarTerm[m * 2 - 1];
}
//日柱 当月一日与 1900/1/1 相差天数
var dayCyclical = Date.UTC(y, sm, 1, 0, 0, 0, 0) / 86400000 + 25567 + 10;
var gzD = this.toGanZhi(dayCyclical + d - 1);
//该日期所属的星座
var astro = this.toAstro(m, d);
var solarDate = y + "-" + m + "-" + d;
var lunarDate = year + "-" + month + "-" + day;
var festival = this.festival;
var lFestival = this.lFestival;
var festivalDate = m + "-" + d;
var lunarFestivalDate = month + "-" + day;
// bugfix https://github.com/jjonline/calendar.js/issues/29
// 农历节日修正:农历12月小月则29号除夕,大月则30号除夕
// 此处取巧修正:当前为农历12月29号时增加一次判断并且把lunarFestivalDate设置为12-30以正确取得除夕
// 天朝农历节日遇闰月过前不过后的原则,此处取农历12月天数不考虑闰月
// 农历润12月在本工具支持的200年区间内仅1574年出现
if (month === 12 && day === 29 && this.monthDays(year, month) === 29) {
lunarFestivalDate = "12-30";
}
return {
date: solarDate,
lunarDate: lunarDate,
festival: festival[festivalDate] ? festival[festivalDate].title : null,
lunarFestival: lFestival[lunarFestivalDate] ? lFestival[lunarFestivalDate].title : null,
lYear: year,
lMonth: month,
lDay: day,
Animal: this.getAnimal(year),
IMonthCn: (isLeap ? "\u95F0" : "") + this.toChinaMonth(month),
IDayCn: this.toChinaDay(day),
cYear: y,
cMonth: m,
cDay: d,
gzYear: gzY,
gzMonth: gzM,
gzDay: gzD,
isToday: isToday,
isLeap: isLeap,
nWeek: nWeek,
ncWeek: "\u661F\u671F" + cWeek,
isTerm: isTerm,
Term: Term,
astro: astro
};
},
/**
* 传入农历年月日以及传入的月份是否闰月获得详细的公历、农历object信息 <=>JSON
* !important! 参数区间1900.1.31~2100.12.1
* @param y lunar year
* @param m lunar month
* @param d lunar day
* @param isLeapMonth lunar month is leap or not.[如果是农历闰月第四个参数赋值true即可]
* @return JSON object
* @eg:console.log(calendar.lunar2solar(1987,9,10));
*/
lunar2solar: function lunar2solar(y, m, d, isLeapMonth) {
y = parseInt(y);
m = parseInt(m);
d = parseInt(d);
isLeapMonth = !!isLeapMonth;
var leapOffset = 0;
var leapMonth = this.leapMonth(y);
var leapDay = this.leapDays(y);
if (isLeapMonth && leapMonth !== m) {
return -1;
} //传参要求计算该闰月公历 但该年得出的闰月与传参的月份并不同
if (y === 2100 && m === 12 && d > 1 || y === 1900 && m === 1 && d < 31) {
return -1;
} //超出了最大极限值
var day = this.monthDays(y, m);
var _day = day;
//bugFix 2016-9-25
//if month is leap, _day use leapDays method
if (isLeapMonth) {
_day = this.leapDays(y, m);
}
if (y < 1900 || y > 2100 || d > _day) {
return -1;
} //参数合法性效验
//计算农历的时间差
var offset = 0;
var i;
for (i = 1900; i < y; i++) {
offset += this.lYearDays(i);
}
var leap = 0,
isAdd = false;
for (i = 1; i < m; i++) {
leap = this.leapMonth(y);
if (!isAdd) {
//处理闰月
if (leap <= i && leap > 0) {
offset += this.leapDays(y);
isAdd = true;
}
}
offset += this.monthDays(y, i);
}
//转换闰月农历 需补充该年闰月的前一个月的时差
if (isLeapMonth) {
offset += day;
}
//1900年农历正月一日的公历时间为1900年1月30日0时0分0秒(该时间也是本农历的最开始起始点)
var strap = Date.UTC(1900, 1, 30, 0, 0, 0);
var calObj = new Date((offset + d - 31) * 86400000 + strap);
var cY = calObj.getUTCFullYear();
var cM = calObj.getUTCMonth() + 1;
var cD = calObj.getUTCDate();
return this.solar2lunar(cY, cM, cD);
}
};
exports.lunar = lunar;
/***/ }),
/* 188 */,
/* 189 */,
/* 190 */,
/* 191 */,
/* 192 */,
/* 193 */,
/* 194 */,
/* 195 */,
/* 196 */,
/* 197 */,
/* 198 */,
/* 199 */,
/* 200 */,
/* 201 */,
/* 202 */
/*!**********************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/uni_modules/uni-icons/components/uni-icons/icons.js ***!
\**********************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {
"id": "2852637",
"name": "uniui图标库",
"font_family": "uniicons",
"css_prefix_text": "uniui-",
"description": "",
"glyphs": [{
"icon_id": "25027049",
"name": "yanse",
"font_class": "color",
"unicode": "e6cf",
"unicode_decimal": 59087
}, {
"icon_id": "25027048",
"name": "wallet",
"font_class": "wallet",
"unicode": "e6b1",
"unicode_decimal": 59057
}, {
"icon_id": "25015720",
"name": "settings-filled",
"font_class": "settings-filled",
"unicode": "e6ce",
"unicode_decimal": 59086
}, {
"icon_id": "25015434",
"name": "shimingrenzheng-filled",
"font_class": "auth-filled",
"unicode": "e6cc",
"unicode_decimal": 59084
}, {
"icon_id": "24934246",
"name": "shop-filled",
"font_class": "shop-filled",
"unicode": "e6cd",
"unicode_decimal": 59085
}, {
"icon_id": "24934159",
"name": "staff-filled-01",
"font_class": "staff-filled",
"unicode": "e6cb",
"unicode_decimal": 59083
}, {
"icon_id": "24932461",
"name": "VIP-filled",
"font_class": "vip-filled",
"unicode": "e6c6",
"unicode_decimal": 59078
}, {
"icon_id": "24932462",
"name": "plus_circle_fill",
"font_class": "plus-filled",
"unicode": "e6c7",
"unicode_decimal": 59079
}, {
"icon_id": "24932463",
"name": "folder_add-filled",
"font_class": "folder-add-filled",
"unicode": "e6c8",
"unicode_decimal": 59080
}, {
"icon_id": "24932464",
"name": "yanse-filled",
"font_class": "color-filled",
"unicode": "e6c9",
"unicode_decimal": 59081
}, {
"icon_id": "24932465",
"name": "tune-filled",
"font_class": "tune-filled",
"unicode": "e6ca",
"unicode_decimal": 59082
}, {
"icon_id": "24932455",
"name": "a-rilidaka-filled",
"font_class": "calendar-filled",
"unicode": "e6c0",
"unicode_decimal": 59072
}, {
"icon_id": "24932456",
"name": "notification-filled",
"font_class": "notification-filled",
"unicode": "e6c1",
"unicode_decimal": 59073
}, {
"icon_id": "24932457",
"name": "wallet-filled",
"font_class": "wallet-filled",
"unicode": "e6c2",
"unicode_decimal": 59074
}, {
"icon_id": "24932458",
"name": "paihangbang-filled",
"font_class": "medal-filled",
"unicode": "e6c3",
"unicode_decimal": 59075
}, {
"icon_id": "24932459",
"name": "gift-filled",
"font_class": "gift-filled",
"unicode": "e6c4",
"unicode_decimal": 59076
}, {
"icon_id": "24932460",
"name": "fire-filled",
"font_class": "fire-filled",
"unicode": "e6c5",
"unicode_decimal": 59077
}, {
"icon_id": "24928001",
"name": "refreshempty",
"font_class": "refreshempty",
"unicode": "e6bf",
"unicode_decimal": 59071
}, {
"icon_id": "24926853",
"name": "location-ellipse",
"font_class": "location-filled",
"unicode": "e6af",
"unicode_decimal": 59055
}, {
"icon_id": "24926735",
"name": "person-filled",
"font_class": "person-filled",
"unicode": "e69d",
"unicode_decimal": 59037
}, {
"icon_id": "24926703",
"name": "personadd-filled",
"font_class": "personadd-filled",
"unicode": "e698",
"unicode_decimal": 59032
}, {
"icon_id": "24923351",
"name": "back",
"font_class": "back",
"unicode": "e6b9",
"unicode_decimal": 59065
}, {
"icon_id": "24923352",
"name": "forward",
"font_class": "forward",
"unicode": "e6ba",
"unicode_decimal": 59066
}, {
"icon_id": "24923353",
"name": "arrowthinright",
"font_class": "arrow-right",
"unicode": "e6bb",
"unicode_decimal": 59067
}, {
"icon_id": "24923353",
"name": "arrowthinright",
"font_class": "arrowthinright",
"unicode": "e6bb",
"unicode_decimal": 59067
}, {
"icon_id": "24923354",
"name": "arrowthinleft",
"font_class": "arrow-left",
"unicode": "e6bc",
"unicode_decimal": 59068
}, {
"icon_id": "24923354",
"name": "arrowthinleft",
"font_class": "arrowthinleft",
"unicode": "e6bc",
"unicode_decimal": 59068
}, {
"icon_id": "24923355",
"name": "arrowthinup",
"font_class": "arrow-up",
"unicode": "e6bd",
"unicode_decimal": 59069
}, {
"icon_id": "24923355",
"name": "arrowthinup",
"font_class": "arrowthinup",
"unicode": "e6bd",
"unicode_decimal": 59069
}, {
"icon_id": "24923356",
"name": "arrowthindown",
"font_class": "arrow-down",
"unicode": "e6be",
"unicode_decimal": 59070
}, {
"icon_id": "24923356",
"name": "arrowthindown",
"font_class": "arrowthindown",
"unicode": "e6be",
"unicode_decimal": 59070
}, {
"icon_id": "24923349",
"name": "arrowdown",
"font_class": "bottom",
"unicode": "e6b8",
"unicode_decimal": 59064
}, {
"icon_id": "24923349",
"name": "arrowdown",
"font_class": "arrowdown",
"unicode": "e6b8",
"unicode_decimal": 59064
}, {
"icon_id": "24923346",
"name": "arrowright",
"font_class": "right",
"unicode": "e6b5",
"unicode_decimal": 59061
}, {
"icon_id": "24923346",
"name": "arrowright",
"font_class": "arrowright",
"unicode": "e6b5",
"unicode_decimal": 59061
}, {
"icon_id": "24923347",
"name": "arrowup",
"font_class": "top",
"unicode": "e6b6",
"unicode_decimal": 59062
}, {
"icon_id": "24923347",
"name": "arrowup",
"font_class": "arrowup",
"unicode": "e6b6",
"unicode_decimal": 59062
}, {
"icon_id": "24923348",
"name": "arrowleft",
"font_class": "left",
"unicode": "e6b7",
"unicode_decimal": 59063
}, {
"icon_id": "24923348",
"name": "arrowleft",
"font_class": "arrowleft",
"unicode": "e6b7",
"unicode_decimal": 59063
}, {
"icon_id": "24923334",
"name": "eye",
"font_class": "eye",
"unicode": "e651",
"unicode_decimal": 58961
}, {
"icon_id": "24923335",
"name": "eye-filled",
"font_class": "eye-filled",
"unicode": "e66a",
"unicode_decimal": 58986
}, {
"icon_id": "24923336",
"name": "eye-slash",
"font_class": "eye-slash",
"unicode": "e6b3",
"unicode_decimal": 59059
}, {
"icon_id": "24923337",
"name": "eye-slash-filled",
"font_class": "eye-slash-filled",
"unicode": "e6b4",
"unicode_decimal": 59060
}, {
"icon_id": "24923305",
"name": "info-filled",
"font_class": "info-filled",
"unicode": "e649",
"unicode_decimal": 58953
}, {
"icon_id": "24923299",
"name": "reload-01",
"font_class": "reload",
"unicode": "e6b2",
"unicode_decimal": 59058
}, {
"icon_id": "24923195",
"name": "mic_slash_fill",
"font_class": "micoff-filled",
"unicode": "e6b0",
"unicode_decimal": 59056
}, {
"icon_id": "24923165",
"name": "map-pin-ellipse",
"font_class": "map-pin-ellipse",
"unicode": "e6ac",
"unicode_decimal": 59052
}, {
"icon_id": "24923166",
"name": "map-pin",
"font_class": "map-pin",
"unicode": "e6ad",
"unicode_decimal": 59053
}, {
"icon_id": "24923167",
"name": "location",
"font_class": "location",
"unicode": "e6ae",
"unicode_decimal": 59054
}, {
"icon_id": "24923064",
"name": "starhalf",
"font_class": "starhalf",
"unicode": "e683",
"unicode_decimal": 59011
}, {
"icon_id": "24923065",
"name": "star",
"font_class": "star",
"unicode": "e688",
"unicode_decimal": 59016
}, {
"icon_id": "24923066",
"name": "star-filled",
"font_class": "star-filled",
"unicode": "e68f",
"unicode_decimal": 59023
}, {
"icon_id": "24899646",
"name": "a-rilidaka",
"font_class": "calendar",
"unicode": "e6a0",
"unicode_decimal": 59040
}, {
"icon_id": "24899647",
"name": "fire",
"font_class": "fire",
"unicode": "e6a1",
"unicode_decimal": 59041
}, {
"icon_id": "24899648",
"name": "paihangbang",
"font_class": "medal",
"unicode": "e6a2",
"unicode_decimal": 59042
}, {
"icon_id": "24899649",
"name": "font",
"font_class": "font",
"unicode": "e6a3",
"unicode_decimal": 59043
}, {
"icon_id": "24899650",
"name": "gift",
"font_class": "gift",
"unicode": "e6a4",
"unicode_decimal": 59044
}, {
"icon_id": "24899651",
"name": "link",
"font_class": "link",
"unicode": "e6a5",
"unicode_decimal": 59045
}, {
"icon_id": "24899652",
"name": "notification",
"font_class": "notification",
"unicode": "e6a6",
"unicode_decimal": 59046
}, {
"icon_id": "24899653",
"name": "staff",
"font_class": "staff",
"unicode": "e6a7",
"unicode_decimal": 59047
}, {
"icon_id": "24899654",
"name": "VIP",
"font_class": "vip",
"unicode": "e6a8",
"unicode_decimal": 59048
}, {
"icon_id": "24899655",
"name": "folder_add",
"font_class": "folder-add",
"unicode": "e6a9",
"unicode_decimal": 59049
}, {
"icon_id": "24899656",
"name": "tune",
"font_class": "tune",
"unicode": "e6aa",
"unicode_decimal": 59050
}, {
"icon_id": "24899657",
"name": "shimingrenzheng",
"font_class": "auth",
"unicode": "e6ab",
"unicode_decimal": 59051
}, {
"icon_id": "24899565",
"name": "person",
"font_class": "person",
"unicode": "e699",
"unicode_decimal": 59033
}, {
"icon_id": "24899566",
"name": "email-filled",
"font_class": "email-filled",
"unicode": "e69a",
"unicode_decimal": 59034
}, {
"icon_id": "24899567",
"name": "phone-filled",
"font_class": "phone-filled",
"unicode": "e69b",
"unicode_decimal": 59035
}, {
"icon_id": "24899568",
"name": "phone",
"font_class": "phone",
"unicode": "e69c",
"unicode_decimal": 59036
}, {
"icon_id": "24899570",
"name": "email",
"font_class": "email",
"unicode": "e69e",
"unicode_decimal": 59038
}, {
"icon_id": "24899571",
"name": "personadd",
"font_class": "personadd",
"unicode": "e69f",
"unicode_decimal": 59039
}, {
"icon_id": "24899558",
"name": "chatboxes-filled",
"font_class": "chatboxes-filled",
"unicode": "e692",
"unicode_decimal": 59026
}, {
"icon_id": "24899559",
"name": "contact",
"font_class": "contact",
"unicode": "e693",
"unicode_decimal": 59027
}, {
"icon_id": "24899560",
"name": "chatbubble-filled",
"font_class": "chatbubble-filled",
"unicode": "e694",
"unicode_decimal": 59028
}, {
"icon_id": "24899561",
"name": "contact-filled",
"font_class": "contact-filled",
"unicode": "e695",
"unicode_decimal": 59029
}, {
"icon_id": "24899562",
"name": "chatboxes",
"font_class": "chatboxes",
"unicode": "e696",
"unicode_decimal": 59030
}, {
"icon_id": "24899563",
"name": "chatbubble",
"font_class": "chatbubble",
"unicode": "e697",
"unicode_decimal": 59031
}, {
"icon_id": "24881290",
"name": "upload-filled",
"font_class": "upload-filled",
"unicode": "e68e",
"unicode_decimal": 59022
}, {
"icon_id": "24881292",
"name": "upload",
"font_class": "upload",
"unicode": "e690",
"unicode_decimal": 59024
}, {
"icon_id": "24881293",
"name": "weixin",
"font_class": "weixin",
"unicode": "e691",
"unicode_decimal": 59025
}, {
"icon_id": "24881274",
"name": "compose",
"font_class": "compose",
"unicode": "e67f",
"unicode_decimal": 59007
}, {
"icon_id": "24881275",
"name": "qq",
"font_class": "qq",
"unicode": "e680",
"unicode_decimal": 59008
}, {
"icon_id": "24881276",
"name": "download-filled",
"font_class": "download-filled",
"unicode": "e681",
"unicode_decimal": 59009
}, {
"icon_id": "24881277",
"name": "pengyouquan",
"font_class": "pyq",
"unicode": "e682",
"unicode_decimal": 59010
}, {
"icon_id": "24881279",
"name": "sound",
"font_class": "sound",
"unicode": "e684",
"unicode_decimal": 59012
}, {
"icon_id": "24881280",
"name": "trash-filled",
"font_class": "trash-filled",
"unicode": "e685",
"unicode_decimal": 59013
}, {
"icon_id": "24881281",
"name": "sound-filled",
"font_class": "sound-filled",
"unicode": "e686",
"unicode_decimal": 59014
}, {
"icon_id": "24881282",
"name": "trash",
"font_class": "trash",
"unicode": "e687",
"unicode_decimal": 59015
}, {
"icon_id": "24881284",
"name": "videocam-filled",
"font_class": "videocam-filled",
"unicode": "e689",
"unicode_decimal": 59017
}, {
"icon_id": "24881285",
"name": "spinner-cycle",
"font_class": "spinner-cycle",
"unicode": "e68a",
"unicode_decimal": 59018
}, {
"icon_id": "24881286",
"name": "weibo",
"font_class": "weibo",
"unicode": "e68b",
"unicode_decimal": 59019
}, {
"icon_id": "24881288",
"name": "videocam",
"font_class": "videocam",
"unicode": "e68c",
"unicode_decimal": 59020
}, {
"icon_id": "24881289",
"name": "download",
"font_class": "download",
"unicode": "e68d",
"unicode_decimal": 59021
}, {
"icon_id": "24879601",
"name": "help",
"font_class": "help",
"unicode": "e679",
"unicode_decimal": 59001
}, {
"icon_id": "24879602",
"name": "navigate-filled",
"font_class": "navigate-filled",
"unicode": "e67a",
"unicode_decimal": 59002
}, {
"icon_id": "24879603",
"name": "plusempty",
"font_class": "plusempty",
"unicode": "e67b",
"unicode_decimal": 59003
}, {
"icon_id": "24879604",
"name": "smallcircle",
"font_class": "smallcircle",
"unicode": "e67c",
"unicode_decimal": 59004
}, {
"icon_id": "24879605",
"name": "minus-filled",
"font_class": "minus-filled",
"unicode": "e67d",
"unicode_decimal": 59005
}, {
"icon_id": "24879606",
"name": "micoff",
"font_class": "micoff",
"unicode": "e67e",
"unicode_decimal": 59006
}, {
"icon_id": "24879588",
"name": "closeempty",
"font_class": "closeempty",
"unicode": "e66c",
"unicode_decimal": 58988
}, {
"icon_id": "24879589",
"name": "clear",
"font_class": "clear",
"unicode": "e66d",
"unicode_decimal": 58989
}, {
"icon_id": "24879590",
"name": "navigate",
"font_class": "navigate",
"unicode": "e66e",
"unicode_decimal": 58990
}, {
"icon_id": "24879591",
"name": "minus",
"font_class": "minus",
"unicode": "e66f",
"unicode_decimal": 58991
}, {
"icon_id": "24879592",
"name": "image",
"font_class": "image",
"unicode": "e670",
"unicode_decimal": 58992
}, {
"icon_id": "24879593",
"name": "mic",
"font_class": "mic",
"unicode": "e671",
"unicode_decimal": 58993
}, {
"icon_id": "24879594",
"name": "paperplane",
"font_class": "paperplane",
"unicode": "e672",
"unicode_decimal": 58994
}, {
"icon_id": "24879595",
"name": "close",
"font_class": "close",
"unicode": "e673",
"unicode_decimal": 58995
}, {
"icon_id": "24879596",
"name": "help-filled",
"font_class": "help-filled",
"unicode": "e674",
"unicode_decimal": 58996
}, {
"icon_id": "24879597",
"name": "plus-filled",
"font_class": "paperplane-filled",
"unicode": "e675",
"unicode_decimal": 58997
}, {
"icon_id": "24879598",
"name": "plus",
"font_class": "plus",
"unicode": "e676",
"unicode_decimal": 58998
}, {
"icon_id": "24879599",
"name": "mic-filled",
"font_class": "mic-filled",
"unicode": "e677",
"unicode_decimal": 58999
}, {
"icon_id": "24879600",
"name": "image-filled",
"font_class": "image-filled",
"unicode": "e678",
"unicode_decimal": 59000
}, {
"icon_id": "24855900",
"name": "locked-filled",
"font_class": "locked-filled",
"unicode": "e668",
"unicode_decimal": 58984
}, {
"icon_id": "24855901",
"name": "info",
"font_class": "info",
"unicode": "e669",
"unicode_decimal": 58985
}, {
"icon_id": "24855903",
"name": "locked",
"font_class": "locked",
"unicode": "e66b",
"unicode_decimal": 58987
}, {
"icon_id": "24855884",
"name": "camera-filled",
"font_class": "camera-filled",
"unicode": "e658",
"unicode_decimal": 58968
}, {
"icon_id": "24855885",
"name": "chat-filled",
"font_class": "chat-filled",
"unicode": "e659",
"unicode_decimal": 58969
}, {
"icon_id": "24855886",
"name": "camera",
"font_class": "camera",
"unicode": "e65a",
"unicode_decimal": 58970
}, {
"icon_id": "24855887",
"name": "circle",
"font_class": "circle",
"unicode": "e65b",
"unicode_decimal": 58971
}, {
"icon_id": "24855888",
"name": "checkmarkempty",
"font_class": "checkmarkempty",
"unicode": "e65c",
"unicode_decimal": 58972
}, {
"icon_id": "24855889",
"name": "chat",
"font_class": "chat",
"unicode": "e65d",
"unicode_decimal": 58973
}, {
"icon_id": "24855890",
"name": "circle-filled",
"font_class": "circle-filled",
"unicode": "e65e",
"unicode_decimal": 58974
}, {
"icon_id": "24855891",
"name": "flag",
"font_class": "flag",
"unicode": "e65f",
"unicode_decimal": 58975
}, {
"icon_id": "24855892",
"name": "flag-filled",
"font_class": "flag-filled",
"unicode": "e660",
"unicode_decimal": 58976
}, {
"icon_id": "24855893",
"name": "gear-filled",
"font_class": "gear-filled",
"unicode": "e661",
"unicode_decimal": 58977
}, {
"icon_id": "24855894",
"name": "home",
"font_class": "home",
"unicode": "e662",
"unicode_decimal": 58978
}, {
"icon_id": "24855895",
"name": "home-filled",
"font_class": "home-filled",
"unicode": "e663",
"unicode_decimal": 58979
}, {
"icon_id": "24855896",
"name": "gear",
"font_class": "gear",
"unicode": "e664",
"unicode_decimal": 58980
}, {
"icon_id": "24855897",
"name": "smallcircle-filled",
"font_class": "smallcircle-filled",
"unicode": "e665",
"unicode_decimal": 58981
}, {
"icon_id": "24855898",
"name": "map-filled",
"font_class": "map-filled",
"unicode": "e666",
"unicode_decimal": 58982
}, {
"icon_id": "24855899",
"name": "map",
"font_class": "map",
"unicode": "e667",
"unicode_decimal": 58983
}, {
"icon_id": "24855825",
"name": "refresh-filled",
"font_class": "refresh-filled",
"unicode": "e656",
"unicode_decimal": 58966
}, {
"icon_id": "24855826",
"name": "refresh",
"font_class": "refresh",
"unicode": "e657",
"unicode_decimal": 58967
}, {
"icon_id": "24855808",
"name": "cloud-upload",
"font_class": "cloud-upload",
"unicode": "e645",
"unicode_decimal": 58949
}, {
"icon_id": "24855809",
"name": "cloud-download-filled",
"font_class": "cloud-download-filled",
"unicode": "e646",
"unicode_decimal": 58950
}, {
"icon_id": "24855810",
"name": "cloud-download",
"font_class": "cloud-download",
"unicode": "e647",
"unicode_decimal": 58951
}, {
"icon_id": "24855811",
"name": "cloud-upload-filled",
"font_class": "cloud-upload-filled",
"unicode": "e648",
"unicode_decimal": 58952
}, {
"icon_id": "24855813",
"name": "redo",
"font_class": "redo",
"unicode": "e64a",
"unicode_decimal": 58954
}, {
"icon_id": "24855814",
"name": "images-filled",
"font_class": "images-filled",
"unicode": "e64b",
"unicode_decimal": 58955
}, {
"icon_id": "24855815",
"name": "undo-filled",
"font_class": "undo-filled",
"unicode": "e64c",
"unicode_decimal": 58956
}, {
"icon_id": "24855816",
"name": "more",
"font_class": "more",
"unicode": "e64d",
"unicode_decimal": 58957
}, {
"icon_id": "24855817",
"name": "more-filled",
"font_class": "more-filled",
"unicode": "e64e",
"unicode_decimal": 58958
}, {
"icon_id": "24855818",
"name": "undo",
"font_class": "undo",
"unicode": "e64f",
"unicode_decimal": 58959
}, {
"icon_id": "24855819",
"name": "images",
"font_class": "images",
"unicode": "e650",
"unicode_decimal": 58960
}, {
"icon_id": "24855821",
"name": "paperclip",
"font_class": "paperclip",
"unicode": "e652",
"unicode_decimal": 58962
}, {
"icon_id": "24855822",
"name": "settings",
"font_class": "settings",
"unicode": "e653",
"unicode_decimal": 58963
}, {
"icon_id": "24855823",
"name": "search",
"font_class": "search",
"unicode": "e654",
"unicode_decimal": 58964
}, {
"icon_id": "24855824",
"name": "redo-filled",
"font_class": "redo-filled",
"unicode": "e655",
"unicode_decimal": 58965
}, {
"icon_id": "24841702",
"name": "list",
"font_class": "list",
"unicode": "e644",
"unicode_decimal": 58948
}, {
"icon_id": "24841489",
"name": "mail-open-filled",
"font_class": "mail-open-filled",
"unicode": "e63a",
"unicode_decimal": 58938
}, {
"icon_id": "24841491",
"name": "hand-thumbsdown-filled",
"font_class": "hand-down-filled",
"unicode": "e63c",
"unicode_decimal": 58940
}, {
"icon_id": "24841492",
"name": "hand-thumbsdown",
"font_class": "hand-down",
"unicode": "e63d",
"unicode_decimal": 58941
}, {
"icon_id": "24841493",
"name": "hand-thumbsup-filled",
"font_class": "hand-up-filled",
"unicode": "e63e",
"unicode_decimal": 58942
}, {
"icon_id": "24841494",
"name": "hand-thumbsup",
"font_class": "hand-up",
"unicode": "e63f",
"unicode_decimal": 58943
}, {
"icon_id": "24841496",
"name": "heart-filled",
"font_class": "heart-filled",
"unicode": "e641",
"unicode_decimal": 58945
}, {
"icon_id": "24841498",
"name": "mail-open",
"font_class": "mail-open",
"unicode": "e643",
"unicode_decimal": 58947
}, {
"icon_id": "24841488",
"name": "heart",
"font_class": "heart",
"unicode": "e639",
"unicode_decimal": 58937
}, {
"icon_id": "24839963",
"name": "loop",
"font_class": "loop",
"unicode": "e633",
"unicode_decimal": 58931
}, {
"icon_id": "24839866",
"name": "pulldown",
"font_class": "pulldown",
"unicode": "e632",
"unicode_decimal": 58930
}, {
"icon_id": "24813798",
"name": "scan",
"font_class": "scan",
"unicode": "e62a",
"unicode_decimal": 58922
}, {
"icon_id": "24813786",
"name": "bars",
"font_class": "bars",
"unicode": "e627",
"unicode_decimal": 58919
}, {
"icon_id": "24813788",
"name": "cart-filled",
"font_class": "cart-filled",
"unicode": "e629",
"unicode_decimal": 58921
}, {
"icon_id": "24813790",
"name": "checkbox",
"font_class": "checkbox",
"unicode": "e62b",
"unicode_decimal": 58923
}, {
"icon_id": "24813791",
"name": "checkbox-filled",
"font_class": "checkbox-filled",
"unicode": "e62c",
"unicode_decimal": 58924
}, {
"icon_id": "24813794",
"name": "shop",
"font_class": "shop",
"unicode": "e62f",
"unicode_decimal": 58927
}, {
"icon_id": "24813795",
"name": "headphones",
"font_class": "headphones",
"unicode": "e630",
"unicode_decimal": 58928
}, {
"icon_id": "24813796",
"name": "cart",
"font_class": "cart",
"unicode": "e631",
"unicode_decimal": 58929
}]
};
exports.default = _default;
/***/ }),
/* 203 */,
/* 204 */,
/* 205 */,
/* 206 */,
/* 207 */,
/* 208 */,
/* 209 */,
/* 210 */,
/* 211 */,
/* 212 */,
/* 213 */,
/* 214 */,
/* 215 */,
/* 216 */,
/* 217 */
/*!******************************************************************************************************************!*\
!*** D:/Project/project_wenlv/tourGuide/uni_modules/uni-transition/components/uni-transition/createAnimation.js ***!
\******************************************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(uni) {
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ 4);
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createAnimation = createAnimation;
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ 23));
var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ 24));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
// const defaultOption = {
// duration: 300,
// timingFunction: 'linear',
// delay: 0,
// transformOrigin: '50% 50% 0'
// }
var MPAnimation = /*#__PURE__*/function () {
function MPAnimation(options, _this) {
(0, _classCallCheck2.default)(this, MPAnimation);
this.options = options;
this.animation = uni.createAnimation(options);
this.currentStepAnimates = {};
this.next = 0;
this.$ = _this;
}
(0, _createClass2.default)(MPAnimation, [{
key: "_nvuePushAnimates",
value: function _nvuePushAnimates(type, args) {
var aniObj = this.currentStepAnimates[this.next];
var styles = {};
if (!aniObj) {
styles = {
styles: {},
config: {}
};
} else {
styles = aniObj;
}
if (animateTypes1.includes(type)) {
if (!styles.styles.transform) {
styles.styles.transform = '';
}
var unit = '';
if (type === 'rotate') {
unit = 'deg';
}
styles.styles.transform += "".concat(type, "(").concat(args + unit, ") ");
} else {
styles.styles[type] = "".concat(args);
}
this.currentStepAnimates[this.next] = styles;
}
}, {
key: "_animateRun",
value: function _animateRun() {
var styles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var ref = this.$.$refs['ani'].ref;
if (!ref) return;
return new Promise(function (resolve, reject) {
nvueAnimation.transition(ref, _objectSpread({
styles: styles
}, config), function (res) {
resolve();
});
});
}
}, {
key: "_nvueNextAnimate",
value: function _nvueNextAnimate(animates) {
var _this2 = this;
var step = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var fn = arguments.length > 2 ? arguments[2] : undefined;
var obj = animates[step];
if (obj) {
var styles = obj.styles,
config = obj.config;
this._animateRun(styles, config).then(function () {
step += 1;
_this2._nvueNextAnimate(animates, step, fn);
});
} else {
this.currentStepAnimates = {};
typeof fn === 'function' && fn();
this.isEnd = true;
}
}
}, {
key: "step",
value: function step() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this.animation.step(config);
return this;
}
}, {
key: "run",
value: function run(fn) {
this.$.animationData = this.animation.export();
this.$.timer = setTimeout(function () {
typeof fn === 'function' && fn();
}, this.$.durationTime);
}
}]);
return MPAnimation;
}();
var animateTypes1 = ['matrix', 'matrix3d', 'rotate', 'rotate3d', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scale3d', 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'translate', 'translate3d', 'translateX', 'translateY', 'translateZ'];
var animateTypes2 = ['opacity', 'backgroundColor'];
var animateTypes3 = ['width', 'height', 'left', 'right', 'top', 'bottom'];
animateTypes1.concat(animateTypes2, animateTypes3).forEach(function (type) {
MPAnimation.prototype[type] = function () {
var _this$animation;
(_this$animation = this.animation)[type].apply(_this$animation, arguments);
return this;
};
});
function createAnimation(option, _this) {
if (!_this) return;
clearTimeout(_this.timer);
return new MPAnimation(option, _this);
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
/***/ })
]]);
//# sourceMappingURL=../../.sourcemap/mp-weixin/common/vendor.js.map