UNPKG

logic-bind-model

Version:
1,149 lines (1,138 loc) 678 kB
/*! Logic Core v1.1.13 Copyright (c) 2025 logicfeel and contributors */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global._L = {})); })(this, (function (exports) { 'use strict'; var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; function _OverloadYield(e, d) { this.v = e, this.k = d; } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } function _asyncGeneratorDelegate(t) { var e = {}, n = false; function pump(e, r) { return n = true, r = new Promise(function (n) { n(t[e](r)); }), { done: false, value: new _OverloadYield(r, 1) }; } return e["undefined" != typeof Symbol && Symbol.iterator || "@@iterator"] = function () { return this; }, e.next = function (t) { return n ? (n = false, t) : pump("next", t); }, "function" == typeof t.throw && (e.throw = function (t) { if (n) throw n = false, t; return pump("throw", t); }), "function" == typeof t.return && (e.return = function (t) { return n ? (n = false, t) : pump("return", t); }), e; } function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); } function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function (r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function () { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function (r) { var n = this.s.return; return void 0 === n ? Promise.resolve({ value: r, done: true }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, throw: function (r) { var n = this.s.return; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); } function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } function _awaitAsyncGenerator(e) { return new _OverloadYield(e, 0); } function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } 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; } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: false }), e; } function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var n = 0, F = function () {}; return { s: F, n: function () { return n >= r.length ? { done: true } : { done: false, value: r[n++] }; }, e: function (r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function () { t = t.call(r); }, n: function () { var r = t.next(); return a = r.done, r; }, e: function (r) { u = true, o = r; }, f: function () { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; } function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: true, configurable: true } }), Object.defineProperty(t, "prototype", { writable: false }), e && _setPrototypeOf(t, e); } function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); } function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } 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 = true, o = false; 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 = true, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } 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."); } 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."); } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } function _readOnlyError(r) { throw new TypeError('"' + r + '" is read-only'); } function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function (t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = true, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), true), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () { return this; }), _regeneratorDefine(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function () { return { w: i, m: f }; })(); } function _regeneratorDefine(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine = function (e, r, n, t) { function o(r, n) { _regeneratorDefine(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine(e, r, n, t); } function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function () { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(typeof e + " is not iterable"); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); } function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } 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); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _typeof(o) { "@babel/helpers - typeof"; return _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; }, _typeof(o); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _wrapAsyncGenerator(e) { return function () { return new AsyncGenerator(e.apply(this, arguments)); }; } function AsyncGenerator(e) { var r, t; function resume(r, t) { try { var n = e[r](t), o = n.value, u = o instanceof _OverloadYield; Promise.resolve(u ? o.v : o).then(function (t) { if (u) { var i = "return" === r ? "return" : "next"; if (!o.k || t.done) return resume(i, t); t = e[i](t).value; } settle(n.done ? "return" : "normal", t); }, function (e) { resume("throw", e); }); } catch (e) { settle("throw", e); } } function settle(e, n) { switch (e) { case "return": r.resolve({ value: n, done: true }); break; case "throw": r.reject(n); break; default: r.resolve({ value: n, done: false }); } (r = r.next) ? resume(r.key, r.arg) : t = null; } this._invoke = function (e, n) { return new Promise(function (o, u) { var i = { key: e, arg: n, resolve: o, reject: u, next: null }; t ? t = t.next = i : (r = t = i, resume(e, n)); }); }, "function" != typeof e.return && (this.return = void 0); } AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function () { return this; }, AsyncGenerator.prototype.next = function (e) { return this._invoke("next", e); }, AsyncGenerator.prototype.throw = function (e) { return this._invoke("throw", e); }, AsyncGenerator.prototype.return = function (e) { return this._invoke("return", e); }; function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function (t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); } /**** load-json.cjs loadJSON() ESM module ****/ //============================================================== var isNode$2 = typeof globalThis.isDOM === 'boolean' ? !globalThis.isDOM : typeof process !== 'undefined' && process.versions !== null && process.versions.node !== null; function loadJSON(_x) { return _loadJSON.apply(this, arguments); } function _loadJSON() { _loadJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(filePath) { var _yield$import, readFile, absolutePath, jsonText, _absolutePath, response; return _regenerator().w(function (_context) { while (1) switch (_context.p = _context.n) { case 0: _context.p = 0; if (!isNode$2) { _context.n = 4; break; } _context.n = 1; return import('fs/promises'); case 1: _yield$import = _context.v; readFile = _yield$import.readFile; _context.n = 2; return getLocalePath(filePath); case 2: absolutePath = _context.v; _context.n = 3; return readFile(absolutePath, 'utf8'); case 3: jsonText = _context.v; return _context.a(2, JSON.parse(jsonText)); case 4: _context.n = 5; return getLocalePath(filePath); case 5: _absolutePath = _context.v; _context.n = 6; return fetch(_absolutePath); case 6: response = _context.v; _context.n = 7; return response.json(); case 7: return _context.a(2, _context.v); case 8: _context.n = 10; break; case 9: _context.p = 9; _context.v; return _context.a(2, undefined); case 10: return _context.a(2); } }, _callee, null, [[0, 9]]); })); return _loadJSON.apply(this, arguments); } function getLocalePath(_x2) { return _getLocalePath.apply(this, arguments); } function _getLocalePath() { _getLocalePath = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(filename) { var _yield$import2, fileURLToPath, path, __filename, __dirname, baseURL; return _regenerator().w(function (_context2) { while (1) switch (_context2.n) { case 0: if (!isNode$2) { _context2.n = 3; break; } _context2.n = 1; return import('url'); case 1: _yield$import2 = _context2.v; fileURLToPath = _yield$import2.fileURLToPath; _context2.n = 2; return import('path'); case 2: path = _context2.v; __filename = fileURLToPath((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bind-model.js', document.baseURI).href))); __dirname = path.dirname(__filename); return _context2.a(2, path.resolve(__dirname, filename)); case 3: if (!(typeof window !== 'undefined')) { _context2.n = 7; break; } baseURL = ''; if (!(typeof document !== 'undefined' && document.currentScript)) { _context2.n = 4; break; } baseURL = document.currentScript.src; _context2.n = 6; break; case 4: if (!(typeof ({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bind-model.js', document.baseURI).href)) }) !== 'undefined' && (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bind-model.js', document.baseURI).href)))) { _context2.n = 5; break; } baseURL = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bind-model.js', document.baseURI).href)); _context2.n = 6; break; case 5: throw new Error('Unable to determine base URL in browser.'); case 6: return _context2.a(2, new URL(filename, baseURL).href); case 7: throw new Error('Unsupported environment'); case 8: return _context2.a(2); } }, _callee2); })); return _getLocalePath.apply(this, arguments); } var _Message; // inner function function _isObject$2(obj) { return obj && _typeof(obj) === 'object' && !Array.isArray(obj); } function _isString$2(obj) { // 공백아닌 문자 여부 if (typeof obj === 'string' && obj.length > 0) return true; return false; } function _deepMerge(target, source) { for (var key in source) { if (source.hasOwnProperty(key)) { var targetValue = target[key]; var sourceValue = source[key]; if (_isObject$2(sourceValue)) { if (!_isObject$2(targetValue)) { target[key] = {}; } target[key] = _deepMerge(target[key], sourceValue); } else { target[key] = sourceValue; } } } return target; } function _getLocale() { var locale = ''; if (typeof window !== 'undefined' && typeof navigator !== 'undefined') { var _navigator$languages; // 브라우저 환경 var lang = ((_navigator$languages = navigator.languages) === null || _navigator$languages === void 0 ? void 0 : _navigator$languages[0]) || navigator.language || Intl.DateTimeFormat().resolvedOptions().locale; locale = lang.split(/[_-]/)[0]; // "ko-KR" -> "ko" } else if (typeof process !== 'undefined') { // Node.js 환경 var rawLocale = process.env.LANG || process.env.LC_ALL || process.env.LANGUAGE; if (rawLocale) { locale = rawLocale.split(/[:_.]/)[0].replace('_', '-'); // "ko_KR.UTF-8" -> "ko" } } return locale || 'en'; } function _replacePlaceholders(p_template, p_values) { var namedValues = {}, indexedValues = []; if (Array.isArray(p_values)) indexedValues = p_values;else if (_typeof(p_values) === 'object') namedValues = p_values; // `${변수명}` 치환 p_template = p_template.replace(/\$\{(\w+)\}/g, function (match, key) { return namedValues.hasOwnProperty(key) ? namedValues[key] : match; }); // `$1, $2` 치환 p_template = p_template.replace(/\$(\d+)/g, function (match, index) { var i = parseInt(index, 10) - 1; return indexedValues[i] !== undefined ? indexedValues[i] : match; }); return p_template; } /** * 'Message' is a class that manages messages and codes. */ var Message = /*#__PURE__*/function () { function Message() { _classCallCheck(this, Message); } return _createClass(Message, null, [{ key: "getMessageByCode", value: /** * Returns a message that corresponds to the message code. * * @param {string} p_code Message code * @returns {string} Message String */ function getMessageByCode(p_code) { var _this$$storage$lang$t, _this$$storage$lang$t2; var value = ((_this$$storage$lang$t = this.$storage.lang[this.currentLang]) === null || _this$$storage$lang$t === void 0 ? void 0 : _this$$storage$lang$t[p_code]) || ((_this$$storage$lang$t2 = this.$storage.lang[this.defaultLang]) === null || _this$$storage$lang$t2 === void 0 ? void 0 : _this$$storage$lang$t2[p_code]); return typeof value === 'number' ? String(value) : value; } }, { key: "importMessage", value: /** * Add the message code to the storage. * * @param {object} p_msg Message Object * @param {string} p_path Message file path */ function importMessage(p_msg, p_path) { if (_isObject$2(p_msg)) { _deepMerge(this.$storage.lang["default"], p_msg); if (_isString$2(p_path)) { // if (isNode && isESM) { // REVIEW: esm module & node // const { fileURLToPath } = await import('url'); // const { dirname, resolve } = await import('path'); // const __filename = fileURLToPath(import.meta.url); // const __dirname = dirname(__filename); // p_path = resolve(__dirname, p_path); // } if (this.$storage.path.indexOf(p_path) < 0) this.$storage.path.push(p_path); } } // locale = _getLocale(); // if (locale === 'en') locale = 'default'; // else await Message.changeLanguage(locale); } }, { key: "changeLanguage", value: ( /** * Change the language. * * @param {string} p_lang language code */ function () { var _changeLanguage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(p_lang) { var msg, i, localPath, _history; return _regenerator().w(function (_context) { while (1) switch (_context.n) { case 0: this.currentLang = p_lang; if (!(p_lang === 'default')) { _context.n = 1; break; } return _context.a(2); case 1: i = 0; case 2: if (!(i < this.$storage.path.length)) { _context.n = 6; break; } localPath = this.$storage.path[i]; // var msg = await loadJSON(`${localPath}/${p_lang}.json`); // initialize the language this.$storage.lang[p_lang] = this.$storage.lang[p_lang] || {}; this.$storage._history[p_lang] = this.$storage._history[p_lang] || []; _history = this.$storage._history[p_lang]; if (!(_history.indexOf(localPath) >= 0)) { _context.n = 3; break; } return _context.a(3, 5); case 3: _context.n = 4; return loadJSON("".concat(localPath, "/").concat(p_lang, ".json")); case 4: msg = _context.v; if (_typeof(msg) === 'object') { _deepMerge(this.$storage.lang[p_lang], msg); _history.push(localPath); } else console.warn("Path '".concat(localPath, "/").concat(p_lang, ".json' does not have a file.")); case 5: i++; _context.n = 2; break; case 6: return _context.a(2); } }, _callee, this); })); function changeLanguage(_x) { return _changeLanguage.apply(this, arguments); } return changeLanguage; }() /** * Returns a string corresponding to the given message code. * * @param {string} p_code Message code * @param {object | string[]} p_values Value to replace in message * @returns {string} 메시지 */ ) }, { key: "get", value: function get(p_code, p_values) { var msg = Message.getMessageByCode(p_code); var result; if (typeof msg === 'undefined') { return "There is no message for code. '".concat(p_code, "'"); } result = _replacePlaceholders(msg, p_values); return $intro(p_code) + result; // inner funciton function $intro(code) { var intro = ''; var firstChar = code.substring(0, 1); if (firstChar === 'E') intro = 'Error';else if (firstChar === 'W') intro = 'Warn'; return intro + ' [' + code + '] '; } } }, { key: "resetLang", value: /** * Initialize the language. */ function resetLang() { this.currentLang = this.defaultLang; } /** * Set the current language by automatically detecting the language. */ }, { key: "autoDetect", value: (function () { var _autoDetect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() { var locale; return _regenerator().w(function (_context2) { while (1) switch (_context2.n) { case 0: locale = _getLocale(); // internal function if (locale === 'en') locale = 'default'; _context2.n = 1; return Message.changeLanguage(locale); case 1: return _context2.a(2); } }, _callee2); })); function autoDetect() { return _autoDetect.apply(this, arguments); } return autoDetect; }()) }]); }(); _Message = Message; /** * Namespace path. ('Common') */ _defineProperty(Message, "_NS", 'Common'); /** * Internal repository that stores message code. */ _defineProperty(Message, "$storage", { lang: { "default": {} }, path: [], _history: {} }); /** * Sets whether automatic language detection is enabled. Default is true. */ // static autoDetect = true; /** * Set the default language. Default is 'default'. */ _defineProperty(Message, "defaultLang", 'default'); /** * Sets the current language. Default is 'default'. */ _defineProperty(Message, "currentLang", _Message.defaultLang); /* eslint-disable */ var defaultCode$2 = { "ES010": "Other errors", "ES011": "Failed to get module ['$1']", "ES012": "Failed to get function ['$1'()", "ES013": "[$1] failed to process [$2]", "ES021": "[$1] can only be of type [$2]", "ES022": "[$1] is an unprocessable typo", "ES023": "[$1] is not type [$2]", "ES031": "[$1] is not an object", "ES032": "[$1] is not an instance of [$2]", "ES033": "The object in [$1] is different from [$2]", "ES041": "[$1] is duplicated with [$2]", "ES042": "[$2] exists in [$1] and cannot measure [$3]", "ES043": "[$1] cannot be added because [$1] exists in [$1] ", "ES044": "[$1] is a reserved word ", "ES051": "Required value [$1] not found", "ES052": "[$1] requires [$2]", "ES053": "[$2] does not exist in [$1]", "ES054": "[$1] cannot be blanked", "ES061": "Exceeded the range [$2] of [$1]", "ES062": "[$1] cannot be less than [$2]", "ES063": "[$1] and [$2] have different lengths", "ES064": "and(&) condition check failed. $1", "ES065": "Or(|) condition check failed. $1", "ES066": "[$1] ranges from [$2] to [$3]", "EL01100": "----- util-type.js match -----", "EL01101": "Type match: You must specify a detailed type of $1.$1: $2", "EL01102": "Type match : target is not type '$1'. tarType : $2", "EL01103": "Type match: cannot handle type", "EL01110": "----- match array -----", "EL01111": "Array match: target is not array type. tarType: $1", "EL01112": "Array match : array(_ANY_) type must have at least one element of target array. target.length = $1", "EL01113": "Array match: target array is less than array(_SEQ_) type length. extType.length = $1, target.length = $2", "EL01114": "Array match: array(_SEQ_) [$1]th literal type is different from target value. extType[$1] = $2, target[$1] = $3", "EL01115": "Array match: array(_SEQ_) [$1]th type check failed. extType[$1] = $2", "EL01116": "Array match : array(_REQ_) type must have at least one element of target array. target.length = $1", "EL01117": "Array match : array($1) is the type of array that cannot be handled", "EL01118": "Array match: array element check failed. extType: $1, tarType: $2", "EL01120": "----- match choice -----", "EL01121": "Choice match: 'undefined' is not available for choice(_ANY_) type", "EL01122": "Choice match: 'undefined' only for choice(_NON_) type", "EL01123": "Choice match: Error instance only for choice(_ERR_) type", "EL01124": "Choice match: choice(_EUM_) type details can only be literal. extType[$1]: $2", "EL01125": "Choice match: the first subtype of choice(_DEF_) type is literal only. extType[0]: $1", "EL01126": "Choice match : choice($1) is a type of choice that cannot be handled", "EL01127": "Choice match: choice detailed type check failed. extType: $1, tarType: $2", "EL01130": "----- match class -----", "EL01131": "Class match: Inspection failed after creating class type as union type (opt = 1)", "EL01132": "Class match: target is not an instance of [$1]", "EL01133": "Class match: target is not class, object, or union type. tarType: $1", "EL01140": "----- match union -----", "EL01141": "Union match: target is not union type. tarType: $1", "EL01142": "Union match: target['$1'] key does not exist. extType['$1'] = $2", "EL01143": "Union match: '$1' type check failed", "EL01150": "----- match function -----", "EL01151": "Function match: target is not function type. tarType: $1", "EL01152": "Function match: declared extType.name = '$1' and target name do not match: function.name = '$2'", "EL01153": "Function match : declared extType.func, target.func is not function type", "EL01154": "Function match: extType.func and target.func are different (proto check)", "EL01155": "Function match: You must set the params or return object of the target. extType.param = $1, extType.return = $2", "EL01156": "Function match: params acceptance test denied. <array(_SEQ_) conversion>", "EL01157": "Function Match: Return Acceptance Test Denied", "EL01200": "----- allow -----", "EL01201": "Type allowed: You must specify a subtype of $1.$1: $2", "EL01202": "Type allowed: different from type 1 literal value. extType = $2, tarType = $3", "EL01203": "Type allowed: not type $1. tarType = $2", "EL01204": "Type allowed: type not processable", "EL01210": "----- allow array -----", "EL01211": "Array permit: Not array type. tarType: $1", "EL01212": "Type allowed: array(_ALL_, _OPT_) type is not allowed for array(_ANY_) type. tarType: $1", "EL01213": "Allow array: Only array(_SEQ_) type is allowed for array(_SEQ_) type. tarType: $1", "EL01214": "Array permit: tarType must be equal to or greater than the length of array(_SEQ_) type of extType.length = $1, target.length = $2", "EL01215": "Array Allowance: array(_SEQ_) [$1]th type check failed", "EL01216": "Allow array : Do not allow array(_ALL_, _ANY_, _OPT_) type for array(_REQ_). tarType: $2", "EL01217": "Allow array: Do not allow array(_ALL_, _ANY_) type for array(_OPT_). tarType: $2", "EL01218": "Allow array : array($1) is the type of array that cannot be handled", "EL01219": "Array element check failed. extType: $1, tarType: $2", "EL01220": "----- allow choice -----", "EL01221": "Choice allowed: do not allow choice(_ERR_) type for choice(_ALL_). tarType: $1", "EL01222": "Choice allowed: 'undefined' type is not allowed for choice(_ANY_) type", "EL01223": "Choice allowed: choice(_NON_, _ERR_) type is not allowed for choice(_ANY_) type. tarType: $1", "EL01224": "Choice allowed: only choice(_NON_) type and choice(_NON_) type. tarType: $1", "EL01225": "Choice allowed: choice(_ERR_) type and choice(_ERR_) type only. tarType: $1", "EL01226": "Choice allowed: do not allow choice(_ALL_, _ANY_, _OPT_, _NON_, _ERR_) type for choice(_REQ_). tarType: $1", "EL01227": "Choice allowed: do not allow choice(_ALL_, _ANY_, _NON_, _ERR_) type for choice(_OPT_). tarType: $1", "EL01228": "Choice allowed: choice(_EUM_) type and choice(_EUM_) type only", "EL01229": "Choice allowed: choice(_EUM_) subtype can only be literal. extType[$1]: $2", "EL0122A": "Choice allowed: the subtype of tarType choice(_EUM_) can only be literal. tarType[$1]: $2", "EL0122B": "Choice allowed: choice(_DEF_) type and choice(_DEF_) type only", "EL0122C": "Choice allowed: the first subtype of extType choice(_DEF_) is literal only. extType[0]: $1", "EL0122D": "Choice allowed: the first subtype of tarType choice(_DEF_) is literal only. tarType[0]: $1", "EL0122E": "Choice allowed: choice($1) is a type of choice that cannot be handled", "EL0122F": "Choice allowed: tarType[$1] = $3, no extType allowed. extType = $2", "EL01230": "----- allow class -----", "EL01231": "Class allowed: ExtType, tarType class failed after creating a union type. (opt = 1)", "EL01232": "Class allowed: class to class denied. (opt = $1)", "EL01233": "Class allowed: Inspection failed after creating tarType class type as union type (opt = 1)", "EL01234": "Class allowed: class to union denied. (opt = $1)", "EL01235": "Class allowed: tarType is not class, union type. tarType: $1", "EL01240": "----- allow union -----", "EL01241": "Union allowed: tarType is not a union type. tarType: $1", "EL01242": "Union allowed: tarType['$1'] key does not exist. extType['$1'] = $2", "EL01243": "Union allowed: Type '$1' check failed", "EL01250": "----- allow function -----", "EL01251": "Allow function : tarType is not function type. tarType : $1", "EL01252": "Function allowed: declared extType.name = '$1' and target name do not match: function.name = '$2'", "EL01253": "Function allowed: declared extType.func, target.func is not of function type", "EL01254": "Function allowed: extType.func and target.func are different (proto check)", "EL01255": "Function permit: params or return object of tarType must be set. extType.param = $1, extType.return = $2", "EL01256": "Function permit: params permit test denied. <array(_SEQ_) conversion>", "EL01257": "Function Permitted: Return Permitted Test Denied", "EL01300": "----- util-type.js -----", "EL01301": "Parcing check: function is not a rule: '$1'", "EL01302": "Parcing inspection: function has no argument, body content. '$1'", "EL01303": "Parcing inspection: function parsing failed $1", "EL01304": "Type check: [$1] is a special type to handle", "EL01305": "Type check: array($1) type is a specular type that cannot be handled", "EL01306": "Type check: choice($1) type is a special type that cannot be handled", "EL01307": "Type check: array($1) type is a type that cannot be handled", "EL01308": "Type check: choice($1) type is a type that cannot be handled", "EL01309": "REVIEW:", "EL0130A": "Type allowed: allowType (extType, tarType) scan failed", "EL0130B": "Type match: matchtype (extType, target) check failed", "EL0130C": "ctor is not function type. type aperture = $1", "EL01400": "----- util.js -----", "EL01401": "implements(ctor, obj, args..); ctor is not of type <function> == '$1'", "EL01402": "implements(ctor, obj, args..); obj is not of type <object> type of obj == '$1'", "EL01403": "implements(ctor, obj, args..); args[$1] is not type <function>. type of args[$1] == '$2'", "EL01404": "[$1] must implement type [$2]. $1._KIND = '$3'", "EL01405": "isImplementOf(target); target is of type <function, string> only. type of target = '$1'", "EL01500": "----- etc -----", "EL01501": "$1.$events is obejct type. type of $events $2", "EL01502": "$1.isLog is boolean type. type isLog $2", "EL01503": "on(event, listener); event is not of type <string> type of event == '$1'", "EL01504": "on(event, listener); listener is not of type <function> type of listener == '$1'", "EL01505": "once(event, listener); event is not of string type. typeof event == '$1'", "EL01506": "once(event, listener); listener 는 <function> 타입이 아닙니다. typeof listener == '$1'", "EL01507": "off(event, listener); event is not of type <string> type of event == '$1'", "EL01508": "off(event, listener); listener 는 <function> 타입이 아닙니다. typeof listener == '$1'", "EL01509": "emit(event); event is not of type <string> type of event == '$1'", "EL01510": "", "EL02100": "----- Interface.* -----", "EL02110": "----- i-object.js -----", "EL02111": "getType(): array<function> is an abstract method. [$1] must be implemented", "EL02112": "instanceOf(any): boolean is an abstract method. [$1] must be implemented", "EL02113": "equal(any): boolena is an abstract method. [$1] must be implemented", "EL02120": "----- i-marshal.js -----", "EL02121": "getObject(opt?, origin?) : object is abstract method. [$1] must be implemented", "EL02122": "setObject(mObj) is an abstract method. [$1] must be implemented", "EL02130": "----- i-element.js -----", "EL02131": "clone(): object is an abstract method. [$1] must be implemented", "EL02140": "----- i-list.js -----", "EL02150": "----- i-control-list.js -----", "EL02151": "add(key) is an abstract method. [$1] must be implemented", "EL02152": "del(key) is an abstract method. [$1] must be implemented", "EL02153": "has(key): boolean is an abstract method. [$1] must be implemented", "EL02154": "find(any): any is an abstract method. [$1] must be implemented", "EL02160": "----- i-collection.js -----", "EL02161": "add(any): boolean is an abstract method. [$1] must be implemented", "EL02162": "remove(elem): boolean is an abstract method. [$1] must be implemented", "EL02163": "cantains(any): boolean is an abstract method. [$1] must be implemented", "EL02164": "indexOf(any): number is an abstract method. [$1] must be implemented", "EL02170": "----- i-collection-array.js -----", "EL02171": "insertAt(pos, val, ..): boolean is an abstract method. [$1] must be implemented", "EL02180": "----- i-collection-property.js -----", "EL02181": "indexToKey(idx): string is an abstract method. [$1] must be implemented", "EL02190": "----- i-serialize.js -----", "EL02191": "output(opt, ...): string is an abstract method. [$1] must be implemented", "EL02192": "load(any, ...) is an abstract method. [$1] must be implemented", "EL02300": "----- Meta.Entity.* -----", "EL03100": "----- Meta.* -----", "EL03110": "----- meta-object.js -----", "EL03111": "You cannot create abstract, interface, enum type. $1['_KIND'] = '$2'", "EL03112": "setObject(oGuid, origin); oGuid 는 'object' 타입입니다. typeof oGuid = '$1'", "EL03113": "setObject(oGuid, origin); different namespaces. this._type = $1, oGuid._type = $2", "EL03114": "setObject(oGuid, origin); origin 은 Guid 객체가 아닙니다. origin._type = '$1', origin._guid = '$2'", "EL03120": "----- meta-element.js -----", "EL03121": "$name;val is of type 'string'. type of valve = '$1'", "EL03122": "$name; val.length must be greater than 0", "EL03200": "----- meta-registry.js -----", "EL03211": "register(meta); the meta to register is not a Guide object. meta._type = '$1', meta._guid = '$2'", "EL03212": "register(meta); meta._guid to register is already registered. meta._guid = '$1'", "EL03213": "release(meta); the meta to release is string(guid) | object(guid) type only. type of meta = '$1'", "EL03220": "----- create -----", "EL03221": "createMetaObject(oGuid, origin); oGuid can only be of type 'object'. typeof oGuid = '$1'", "EL03222": "createMetaObject(oGuid, origin); oGuid._type 은 'string' 타입만 가능합니다.(length > 0) typeof oGuid._type = '$1'", "EL03223": "createMetaObject(oGuid, origin); origin can only be of type 'object'. typeof origin = '$1'", "EL03224": "createMetaObject(oGuid, origin);[$1] Namespace is not of type 'function'. type of coClass = '$2'", "EL03225": "createReferObject(meta); meta can only be of type 'object'. type of meta = '$1'", "EL03226": "createReferObject(meta); meta._guid 은 'string' 타입만 가능합니다.(length > 0) typeof meta._guid = '$1'", "EL03227": "createNsReferObject(fun); fun is not type 'function'. type of fun = '$1'", "EL03230": "----- ns Class -----", "EL03231": "register Class(fun, ns, key); fun is not of type 'function'. type of fun = '$1'", "EL03232": "registerClass(fun, ns, key); ns is not of type 'string'. typeofns = '$1'", "EL03233": "register Class(fun, ns, key); key is not of type 'string'. type of key = '$1'", "EL03234": "releaseClass(fullName); fullName 은 'string' 타입만 가능합니다.(length > 0) typeof fullName = '$1'", "EL03235": "findClass(fun); fun is not type 'function'. type of fun = '$1'", "EL03236": "getClass(fullName); fullName can only be of type 'string' (length > 0) type of fullName = '$1'", "EL03240": "----- set, transform, load -----", "EL03241": "setMetaObject(oGuid, meta); oGuid can only be of type 'object'. typeof oGuid = '$1'", "EL0324": "setMetaObject(oGuid, meta); meta can only be of type 'object'. type of meta = '$1'", "EL03243": "setMetaObject(meta); meta._guid can only be of type 'string' (length > 0) type of meta._guid = '$1'", "EL03244": "transformRefer(oGuid); oGuid can only be of type 'object'. type oGuid = '$1'", "EL03245": "transformRefer(oGuid); $1['$2']['$ns'] is not of type 'function'", "EL03246": "loadMetaObject(str, path?); str is only of type 'string'. typeof str = '$1'", "EL03247": "loadMetaObject(str, path?); The object parsed str is not a Guide object. obj._type = '$1', obj._guid = '$2'", "EL03250": "----- has, valid, find -----", "EL03251": "validObject(oGuid); oGuid is only of type 'object'. typeof oGuid = '$1'", "EL03252": "hasGuidObject(oGuid, origin); guid can only be of type 'string' (length > 0) type of guid = '$1'", "EL03253": "hasGuidObject(oGuid, origin); origin[$1]는 'object' 타입이 아닙니다. typeof origin[$1] = '$2'", "EL03254": "hasRefer(oGuid); oGuid can only be of type 'object'. typeof oGuid = '$1'", "EL03255": "hasRefer(oGuid); oGuid is not a Guide object. oGuid._