UNPKG

logic-bind-model

Version:
1,226 lines (1,094 loc) 653 kB
/*! Logic Core v1.1.13 Copyright (c) 2025 logicfeel and contributors */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); /**** load-json.cjs loadJSON() CJS module ****/ var loadJson; var hasRequiredLoadJson; function requireLoadJson () { if (hasRequiredLoadJson) return loadJson; hasRequiredLoadJson = 1; //============================================================== const isNode = typeof globalThis.isDOM === 'boolean' ? !globalThis.isDOM : typeof process !== 'undefined' && process.versions !== null && process.versions.node !== null; async function loadJSON(filePath) { try { if (isNode) { const path = require('path'); const fs = require('fs'); var absolutePath = path.resolve(__dirname, filePath); const data = fs.readFileSync(absolutePath, 'utf8'); const parsed = JSON.parse(data); return parsed; } else { var absolutePath = await getLocalePath(filePath); const response = await fetch(absolutePath); return await response.json(); } } catch (error) { return undefined; } } async function getLocalePath(filename) { try { if (isNode) { const path = require('path'); return path.resolve(__dirname, filename); } if (typeof window !== 'undefined') { let baseURL = ''; if (typeof document !== 'undefined' && document.currentScript) { baseURL = document.currentScript.src; } else { baseURL = new URL('./', window.location.href).href; } return new URL(filename, baseURL).href; } throw new Error('Unsupported environment'); } catch (error) { throw new Error('Unsupported environment'); } } // exports.loadJSON = loadJSON; // exports.__esModule = true; loadJson = { loadJSON, default: { loadJSON } // ESM default import 대응 }; return loadJson; } var loadJsonExports = requireLoadJson(); /**** message.js | 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() { let locale = ''; if (typeof window !== 'undefined' && typeof navigator !== 'undefined') { // 브라우저 환경 const lang = navigator.languages?.[0] || navigator.language || Intl.DateTimeFormat().resolvedOptions().locale; locale = lang.split(/[_-]/)[0]; // "ko-KR" -> "ko" } else if (typeof process !== 'undefined') { // Node.js 환경 const 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) { let 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. */ class Message { /** * Namespace path. ('Common') */ static _NS = 'Common'; /** * Internal repository that stores message code. */ static $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'. */ static defaultLang = 'default'; /** * Sets the current language. Default is 'default'. */ static currentLang = this.defaultLang; /** * Returns a message that corresponds to the message code. * * @param {string} p_code Message code * @returns {string} Message String */ static getMessageByCode (p_code) { var value = this.$storage.lang[this.currentLang]?.[p_code] || this.$storage.lang[this.defaultLang]?.[p_code]; return typeof value === 'number' ? String(value) : value; }; /** * Add the message code to the storage. * * @param {object} p_msg Message Object * @param {string} p_path Message file path */ static 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); }; /** * Change the language. * * @param {string} p_lang language code */ static async changeLanguage (p_lang) { var msg; this.currentLang = p_lang; if (p_lang === 'default') return; for (var i = 0; i < this.$storage.path.length; i++) { const 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] || []; const _history = this.$storage._history[p_lang]; if (_history.indexOf(localPath) >= 0) continue; msg = await loadJsonExports.loadJSON(`${localPath}/${p_lang}.json`); if (typeof msg === 'object') { _deepMerge(this.$storage.lang[p_lang], msg); _history.push(localPath); } else console.warn(`Path '${localPath}/${p_lang}.json' does not have a file.`); } } /** * 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} 메시지 */ static get (p_code, p_values) { var msg = Message.getMessageByCode(p_code); var result; if (typeof msg === 'undefined') { return `There is no message for code. '${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 +'] '; } }; /** * Initialize the language. */ static resetLang () { this.currentLang = this.defaultLang; } /** * Set the current language by automatically detecting the language. */ static async autoDetect () { let locale = _getLocale(); // internal function if (locale === 'en') locale = 'default'; await Message.changeLanguage(locale); } } /* 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._type = '$1', oGuid._guid = '$2'", "EL03256": "findSetObject(oGuid, origin); [ oGuid._guid | oGuid ]는 'string' 타입만 가능합니다.(length > 0) guid = '$1'", "EL03257": "findSetObject(oGuid, origin); origin can only be of type 'object'. typeof origin = '$1'", "EL03300": "----- namespace-manager.js -----", "EL03310": "----- private function, proterty -----", "EL03311": "NamespaceManager.allowOverlap 은 'boolean' 타입만 가능합니다. typeof allowOverlap = $1", "EL03312": "_getArray(ns); ns is not a valid namespace name rule. ns = $1", "EL03313": "_getArray(ns); ns type is 'string', 'array<string>' only typeofns = $1", "EL03314": "_getArray(ns); ns[$1] is not type 'string'. typeofns[$1] = $2", "EL03315": "_getArray(ns); ns[$1] is not a valid name rule. ns[$1] = $1", "EL03320": "----- addNamespace, delNamespace, path -----", "EL0321": "addNamespace(ns); addition of namespace failed", "EL03322": "delNamespace(ns); Namespace deletion failed", "EL0323": "path(ns); failed to get the namespace path", "EL03330": "----- add, del -----", "EL03331": "add(fullName,lem); [$1] is not a valid name rule", "EL03332": "add(fullName,lem);lem is already registered. Allow duplicate [this.allowOverlap = 'true']", "EL03333": "add(fullName,lem); failed to register elements in the namespace", "EL03334": "del(fullName); Failed to delete element in Namespace", "EL03340": "----- getPath, output, load -----", "EL03341": "getPath(elem); no element value. typeoflem = $1", "EL03342": "output (stringify, space); Namespace export failed. $1", "EL03343": "load(str, path); str is not type 'string'. typeofstr = $1", "EL03344": "load(str, path); Namespace loading failed. $1", "EL04100": "----- Collection.* -----", "EL04110": "----- base-collection.js -----", "EL04111": "_remove(idx): boolean is an abstract method. Must be implemented", "EL04112": "setObject(oGuid, origin); _owner connection of oGuid failed. guid = $1", "EL04113": "removeAt(idx); idx is not type 'number'. typeof idx = $1", "EL04114": "add(any): number is an abstract method. must be implemented", "EL04115": "clear() is an abstract method. must be implemented", "EL04116": "map(callback); callback is not function type. type of callback = $1", "EL04117": "filter(callback); callback is not function type. type of callback = $1", "EL04118": "reduce(callback); callback is not function type. type of callback = $1", "EL04119": "find(callback); callback is not function type. type of callback = $1", "EL041110": "forEach(callback); callback is not function type. type of callback = $1", "EL041111": "Some(callback); callback is not function type. type of callback = $1", "EL041112": "Every(callback); callback is not function type. type of callback = $1", "EL041113": "findIndex(callback); callback 이 function 타입이 아닙니다. typeof callback = $1", "EL04200": "", "EL04210": "----- collection-array.js -----", "EL04211": "_elements connection failed for setObject(oGuid, origin); oGuid['_elem'][$1]: guid = $2", "EL04212": "insertAt(pos, value, desc); pos is not type 'number'. typeof pos = $1", "EL04213": "insertAt(pos, value, desc); pos cannot be greater than this.count.pos = $1, count = $2", "EL04214": "insertAt(pos, value, desc); pos cannot be less than 0. pos = $1", "EL04215": "insertAt(pos, value, desc); registration failed. pos = $1, value = $2", "EL04220": "----- collection-property.js -----", "EL04221": "setObject(oGuid, origin); oGuid['_lem'].length = $1 length and oGuid['_key'].length = $2 length are different", "EL04222": "setObject(oGuid, origin); oGuid['_elem'].length = $1 length and oGuid['_desc'].length = $2 length are different", "EL04223": "setObject(oGuid, origin); oGuid._elem[$1] guid not found. guid = $2", "EL04224": "indexOf(obj, isKey); if the index value is found by key, obj must be of type 'string'. typeof obj = $1", "EL04225": "add(name, value, desc); name is not of type 'string'. type of name = $1", "EL04226": "add(name, value, desc); name = '$1' is not valid for name rule. Rule = '$2'", "EL04227": "add(name, value, desc); name = '$1' is the reserved word", "EL04228": "add(name, value, desc); name = '$1' is duplicated with existing name", "EL04229": "add(name, value, desc); addition failed. name = '$1', value = '$2'", "EL0422A": "indexToKey(idx); idx is not of type 'number'. typeof idx = $1", "EL0422B": "exists(key); key is not of type 'string' (length > 0) type of key = $1", "EL04300": "", "EL04310": "----- collection-transaction.js -----", "EL04311": "$1.autoChanges 는 'boolean' 타입입니다. typeof aucoChanges = '$2'", "EL04320": "----- trans-queue.js -----", "EL04321": "collection value is not an instance that inherited [MetaObject]", "EL04322": "collection is not an instance of [ArrayCollection]", "EL04323": "rollback(); '$1' is an unprocessable cmd", "WS011": "[$1] Destination [$2] cannot be deleted", "EN": "OK" }; /**** message-wrap-bundle.js | Message ****/ //============================================================== const localesPath$2 = './locales'; // 상대 경로 Message.importMessage(defaultCode$2, localesPath$2); (async () => { await Message.autoDetect(); })(); /**** extend-error.js | ExtendError ****/ //============================================================== // inner function function _buildMessageProp(obj) { var msg = ''; for (var prop in obj) { if (typeof obj[prop] === 'string') msg += prop + ' : '+ obj[prop] + '\n'; else continue; } return msg; } function _buildMsgQueue(queue) { var msg = ''; var queue_cnt = queue.length; for (var i = 0; i < queue_cnt; i++) { var mark = ''; for (var j = 0; j < i; j++) { mark += '#'; } msg += '' + mark +' '+ queue[i] + '\n'; } // for (var i = queue_cnt; i > 0; i--) { // var mark = ''; // for (var j = i; j <= queue_cnt; j++) { mark += '#'; } // msg += '' + mark + ' '+ queue[i - 1] + '\n'; // } return msg.trim(); } class ExtendError extends Error { static _NS = 'Common'; // namespace /** * Save previously generated messages. * * @member {string[]} ExtendError#queue */ queue = []; /** * Error message related to property type. * * @member {object} ExtendError#prop */ prop = {}; /** * Use user messages to create an ExtendError instance. * * @param {string} msg Error message string * @param {ExtendError | object | null} causeOrProp Error message by existing ExtendError, Error object or property * * @example * throw new ExtendError("Custom error message"); * throw new ExtendError("Custom error message", error); * throw new ExtendError("Custom error message", { style: "required" }); */ /** * Create an instance of 'ExtendError' using the message code and substitution value. * * @param {RegExp} msgPattern Code value of regular expression type * @param {ExtendError | object | null} causeOrProp Error message by existing ExtendError, Error object or property * @param {string[]} placeholders Array of strings containing substitution values such as '$1' and '$2' in the * * @example * // For messages that do not have a substitution value * throw new ExtendError(/EL01504/); * throw new ExtendError(/EL01504/, error); * throw new ExtendError(/EL01504/, { style: "required" }); * // For messages with substitution values * throw new ExtendError(/EL01504/, undefined, ['value1', 'value2']); * throw new ExtendError(/EL01504/, error, ['value1', 'value2']);); * throw new ExtendError(/EL01504/, { style: "required" }, ['value1', 'value2']); */ constructor(p_msg, p_prop, p_codeVal) { super(); var _build = ''; var _prop; var _queue = []; var _msg; if (p_prop instanceof ExtendError) { _queue = p_prop.queue; _prop = p_prop.prop; } else if (p_prop instanceof Error) { _queue.push(p_prop.message); } else if (typeof p_prop === 'object' && p_prop !== null) { _prop = p_prop; } if (typeof p_msg === 'string') { _msg = p_msg; } else if (p_msg instanceof RegExp) { _msg = Message.get(p_msg.source, p_codeVal); } else _msg = 'An unknown error occurred.'; // _build = _msg + '\n'; _queue.push(_msg); if (_prop) _build += _buildMessageProp(_prop); if (_queue.length > 0) _build += _buildMsgQueue(_queue); this.message = _build; this.queue = _queue; // this.queue.push(_msg); } /** * Converts error messages into strings. * * @return error message string */ toString() { return 'ExtendError : ' + this.message; } } /**** util-type.js Type ****/ //============================================================== var _global$2 = globalThis; var OLD_ENV$1 = _global$2.OLD_ENV ? _global$2.OLD_ENV : false; // 커버리지 테스트 역활 /** * This is a type module. */ var Type = {}; /** * object 와 new 생성한 사용자 함수를 제외한 객쳐 여부 * * @param {*} obj * @returns {boolean} */ function _isPrimitiveObj(obj) { // REVIEW: 정리 필요, 의미적으로 명료하게.. if(typeof obj === 'object' && obj !== null && (obj instanceof RegExp || obj instanceof Date )) { return true; } return false; } /** * 최상위 object 이거나 사용자 함수에서 생성한 객체 여부 * * @param {*} obj * @returns {boolean} */ function _isObject$1(obj) { // REVIEW: 정리 필요, 의미적으로 명료하게 if(typeof obj === 'object' && obj !== null && !_isPrimitiveObj(obj)) { return true; } return false; } /** * 공백객체 인지 확인 * * @param {*} obj 검사대상 * @returns {boolean} */ function _isEmptyObj(obj) { if(_isObject$1(obj) && Object.keys(obj).length === 0 && getAllProperties(obj).length === 0) return true; return false; } /** * 공백이 아닌 객체 (prototype 및 속성 있는것) * * @param {*} obj 대상 * @returns {boolean} */ function _isFillObj(obj) { if(_isObject$1(obj) && getAllProperties(obj).length > 0) return true; return false; } /** * 내장함수 유무 * * @param {*} obj * @returns {boolean} */ function _isBuiltFunction(obj) { if (typeof obj === 'function' && (obj === Number || obj === String || obj === Boolean || obj === Object || obj === Array || obj === Function || obj === RegExp || obj === Date || obj === Symbol || obj === BigInt )) return true; return false; } /** * 첫문자 대문자 여부 * * @param {string} strValue * @returns {boolean} */ function _isUpper(strValue) { var firstStr = strValue.charAt(0); if (firstStr === '') return false; if(firstStr === firstStr.toUpperCase()) return true; return false; } /** * 리터럴 여부 * number, string, boolean, bigint, RexExp instance * * @param {*} obj * @returns {boolean} */ function _isLiteral(obj) { if (typeof obj === 'number') return true; if (typeof obj === 'string') return true; if (typeof obj === 'boolean') return true; if (typeof obj === 'bigint') return true; if (obj instanceof RegExp) return true; return false; } /** * 리터럴값 비교 * number, string, boolean, bigint, RexExp instance * * @param {*} obj1 * @param {*} obj2 * @returns {boolean} */ function _equalLiternal(obj1, obj2) { if (obj1 === obj2) return true; if (obj1 instanceof RegExp && obj2 instanceof RegExp && obj1.source === obj2.source) return true; return false; } /** * function 생성하는 생성자 * @param {*} type * @returns {object} */ var _creator = function(type) { return new type; }; /** * 타임명 얻기 * * @param {*} obj * @returns {string} */ function _typeName(obj) { return obj['name']; } /** * kind 코드, 대문자로 얻기 '_any_'... * * @param {*} val * @returns {string} */ function _getKeyCode(val) { var reg = /^_[a-zA-Z]+_/; var result; if (typeof val !== 'string') return ''; result = reg.exec(val); if (result !== null) return result[0].toUpperCase(); return ''; } // 배열 구조 분해 할당을 해제 function restoreArrowFunction(transformedCode) { // 1. 화살표 함수의 매개변수와 본문 전체를 추출 const regex = /\((.*?)\)\s*=>\s*\{([\s\S]*)\}/; const match = transformedCode.match(regex); // 특별히 `_ref => { ... }` 형태도 대응할 수 있도록 추가 처리 // -> _ref => { let [String] = _ref; return Number; } // -> 실제로는 ( _ref ) => { ... } 형태로 통일 if (!match) { // 혹시 _ref => { ... } 형태라면, 강제로 괄호를 넣어 재시도 const altRegex = /^(.*?)\s*=>\s*\{([\s\S]*)\}/; const altMatch = transformedCode.match(altRegex); if (!altMatch) { throw new Error('Invalid arrow function format.'); } // altMatch[1] = "_ref" // altMatch[2] = "let [String] = _ref; return Number;" let altParams = altMatch[1].trim(); let altBody = altMatch[2].trim(); // 화살표 함수 형태 통일: ( _ref ) => { ... } return restoreArrowFunction(`(${altParams}) => {${altBody}}`); } // 2. 매개변수와 함수 본문 부분 분리 let params = match[1].trim(); // 함수의 매개변수 부분 let body = match[2].trim(); // 함수 본문 // 3. 구조 분해 할당 패턴 (객체/배열 모두 대응) - 여러 줄(줄바꿈)도 허용 // 예: let { aa: String } = _ref5; 또는 let [[{ bb: Number }]] = _ref6; const paramAssignments = body.match(/let\s+(\{[\s\S]*?\}|\[[\s\S]*?\])\s*=\s*(\w+);/g) || []; // 4. 찾아낸 구조 분해 할당들을 순회하며 매개변수( _ref5, _ref6 등 )를 원래 형태로 치환 paramAssignments.forEach(assign => { // - parts[1]: { aa: String } 또는 [String] 등 (줄바꿈 포함 가능) // - parts[2]: _ref5, _ref6 등 const parts = assign.match(/let\s+(\{[\s\S]*?\}|\[[\s\S]*?\])\s*=\s*(\w+);/); if (parts) { const extractedParam = parts[1].trim(); // 원래 구조 const originalParam = parts[2].trim(); // 변환된 변수명 (_ref5 등) // 매개변수 목록에 있던 _ref5 등을 { aa: String } 등으로 치환 const re = new RegExp(`\\b${originalParam}\\b`, 'g'); params = params.replace(re, extractedParam); } }); // 5. return 문이 있다면 반환값을 추출 // 예: return Number; -> "Number" const returnStatementMatch = body.match(/return\s+(.*?);/); let returnType = returnStatementMatch ? returnStatementMatch[1].trim() : ''; // 6. 최종 복원 – return 문이 있다면 { return ... } 형태로, 없으면 { } 로 if (returnType) { // 불필요한 공백 없애기 위해 파라메터 부분도 스페이스 정리 params = params.replace(/\s+/g, ''); return `(${params})=>{return ${returnType}}`; } else { params = params.replace(/\s+/g, ''); return `(${params})=>{}`; } } /** * 함수 규칙 * - (params 내부에는 '()' 입력 금지) * - 참조형 타입 금지 : new Function() 시점에 자동 해석됨 * * @param {*} funBody * @returns {object} */ function _parseFunc(funBody) { var syntax1 = /\([,_\[\]{:}\w\s]*\)\s*(?:=>)?\s*{\s*.*\s*.*\s*}/; // 제한 규칙 var syntax2 = /(\(.*\)|\w+)\s*(?:=>).*/; var regFunc1 = /(?:function\s)?\(([\[\]{:}\s\w,]*)\)\s*(?:=>)?\s*{(?:\s*return\s+|\s*)?([\[\]{:}\s\w,]*);?\s*}/; var regFunc2 = /\(?([\[\]{:}\s\w,]*)\)?\s*(?:=>)\s*{?(?:\s*return\s+|\s*)?([\[\]\s\w,]*);?\s*}?/; var arrFunc; var result = { params: [], return: undefined }; var arrParam = []; var arrRetrun; // 배열 구조 분해 할당을 해제 if (/\blet\b/.test(funBody)) funBody = restoreArrowFunction(funBody); funBody = $skipComment(funBody); try { if (syntax1.test(funBody)) arrFunc = regFunc1.exec(funBody); else if (syntax2.test(funBody)) arrFunc = regFunc2.exec(funBody); else throw new ExtendError(/EL01301/, null, [funBody]); if (arrFunc === null) throw new ExtendError(/EL01302/, null, [funBody]); arrParam = (new Function('return ['+ arrFunc[1] +']'))(); result['params'] = arrParam; if (arrFunc[2] !== '') arrRetrun = (new Function('return '+ arrFunc[2]))(); result['return'] = arrRetrun; } catch (error) { throw new ExtendError(/EL01303/, error, ['']); } return result; // inner function function $skipComment(body) { // 주석 제거 comment var rBody = body; var bloackComment = /\/\*[^](.*?)\*\//g; var lineComment = /\/\/[^](.*?)(\n|$)/g; rBody = rBody.replace(bloackComment, ''); rBody = rBody.replace(lineComment, ''); return rBody; } } /** * 타입 여부 * * @param {string} name * @returns {boolean} */ function _hasType(name) { var arr = []; if (typeof name !== 'string') return false; arr = arr.concat(['null', 'undefined', 'number', 'string', 'boolean']); arr = arr.concat(['array', 'function', 'object']); arr = arr.concat(['choice', 'union', 'class']); arr = arr.concat(['symbol', 'bigint', 'regexp']); arr = arr.concat(['etc']); // 예외 오류 코드 검출 return arr.indexOf(name) > -1; } /** * 타입 여부 * * @param {string} name * @returns {boolean} */ function _isLeafType(name) { var arr = []; arr = arr.concat(['null', 'undefined', 'number', 'string', 'boolean']); arr = arr.concat(['symbol', 'bigint', 'regexp', 'object']); return arr.indexOf(name) > -1; } /** * choice type kind 여부 * * @param {string} name * @returns {boolean} */ function _hasKindChoice(name) { var arr = []; if (typeof name !== 'string') return false; arr = arr.concat(['_ALL_', '_ANY_', '_NON_', '_ERR_']); arr = arr.concat(['_REQ_', '_OPT_', '_DEF_', '_EUM_']); arr = arr.concat(['_ETC_']); // 예외 오류 코드 검출 return arr.indexOf(name) > -1; } /** * choice type kind 여부 * * @param {string} name * @returns {boolean} */ function _hasKindArray(name) { var arr = []; if (typeof name !== 'string') return false; arr = arr.concat(['_ALL_', '_ANY_']); arr = arr.concat(['_REQ_', '_OPT_', '_SEQ_']); arr = arr.concat(['_ETC_']); // 예외 오류 코드 검출 return arr.indexOf(name) > -1; } /** * Query all properties of the object. * * @param {object} obj Object to look up properties (except Object) * @param {boolean?} hasObj Whether to include properties of 'Object' * @returns {array<string>} Property Name Arrangement */ function getAllProperties(obj, hasObj) { var allProps = [], cur = obj; var is = hasObj || false; do { var props = Object.getOwnPropertyNames(cur); for (var i = 0; i < props.length; i++) { var prop = props[i]; if (allProps.indexOf(prop) === -1 && (is || !Object.prototype.hasOwnProperty(prop))) allProps.push(prop); } } while (cur = Object.getPrototypeOf(cur)); return allProps; } Type.getAllProperties = getAllProperties; /** * Compare the two objects to see if they are the same (except Prototype) * * @param {any} obj1 Source object * @param {any} obj2 Object to compare * @returns {boolean} Whether the two objects are the same ('true' or 'false') */ function deepEqual(obj1, obj2) { // 두 객체가 동일한 참조를 가지면 true를 반환 if (obj1 === obj2) return true; // 두 객체 중 하나가 null이거나 타입이 다르면 false를 반환 if (obj1 === null || obj2 === null || typeof obj1 !== typeof obj2) return false; // 함수 비교 if (typeof obj1 === 'function' && typeof obj2 === 'function') { return obj1.toString() === obj2.toString(); } // 원시 값 비교 if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false; // 배열 비교 if (Array.isArray(obj1) && Array.isArray(obj2)) { if (obj1.length !== obj2.length) return false; for (var i = 0; i < obj1.length; i++) { if (!deepEqual(obj1[i], obj2[i])) return false; } return true; } // 객체 비교 // var keys1 = Object.keys(obj1); // var keys2 = Object.keys(obj2); var keys1 = Object.getOwnPropertyNames(obj1); var keys2 = Object.getOwnPropertyNames(obj2); if (keys1.length !== keys2.length) return false; for (var j = 0; j < keys1.length; j++) { var key = keys1[j]; if (keys2.indexOf(key) === -1 || !deepEqual(obj1[key], obj2[key])) return false; } return true; } Type.deepEqual = deepEqual; /** * Gets the type of the given function (generator). (Can include '_UNION') * The returned arrays are included in order from the specified function. * * @param {function} ctor Generator function or class * @param {boolean} [hasUnion= true] whether '_UNION' is included (default: 'true') * @returns {array<function>} Array function type */ function getTypes(ctor, hasUnion) { var arr = []; var tempArr = []; var union; var proto; hasUnion = hasUnion === false ? false : true; if (typeof ctor !== 'function') throw new ExtendError(/EL0130C/, null, [typeof ctor]); arr.push(ctor); proto = $getPrototype(ctor); if (proto !== Function.prototype) { arr = arr.concat(getTypes(proto, hasUnion)); } if (hasUnion) { union = ctor['_UNION'] || []; for (var i = 0; i < union.length; i++) { arr = arr.concat(getTypes(union[i], hasUnion)); } } for (var j = 0; j < arr.length; j++) { var idx = tempArr.indexOf(arr[j]); if (idx < 0) tempArr.push(arr[j]); } return tempArr; // innner function function $getPrototype(ctor) { // if (ctor.hasOwnProperty('super')) return ctor.super; if (Object.prototype.hasOwnProperty.call(ctor, 'super')) return ctor.super; return !OLD_ENV$1 && typeof Object.getPrototypeOf === 'function' ? Object.getPrototypeOf(ctor) : ctor.__proto__; } } Type.getTypes = getTypes; /** * Verify that the prototype (inheritance) chain of the function type contains the specified target. * * @param {function} ctor Generator function or class * @param {function | string} target To be examined (generator function or class name) * @returns {boolean} whether to be included in the prototype chain ('true' or 'false') */ function isProtoChain(ctor, target) { var arr; if (typeof ctor !== 'function') return false; if (!(typeof target === 'function' || typeof target === 'string')) return false; arr = getTypes(ctor, false); for (var i = 0; i < arr.length; i++) { if (typeof target === 'string') { if (target === arr[i].name) return true; } else { if (target === arr[i]) return true; } } return false; } Type.isProtoChain = isProtoChain; /** * Verify that the given function type is included in the prototype (inheritance) chain or is of type '_UNION'. * * @param {function} ctor Generator function or class * @param {function | string} target To be examined (generator function or class name) * @returns {boolean} Prototype chain or type '_UNION' ('true' or 'false') */ function hasType(ctor, target) { var arr; if (typeof ctor !== 'function') return false; if (!(typeof target === 'function' || typeof target === 'string')) return false; arr = getTypes(ctor); for (var i = 0; i < arr.length; i++) { if (typeof target === 'string') { if (target === arr[i].name) return true; } else { if (target === arr[i]) return true; } } return false; } Type.hasType = hasType; /** * Returns extension information of the target type in JSON format. * Analyze the internal properties of the object to transform all properties into the format 'typeObject()'. * * @param {*} target Target type * @returns {object} converted extension type object * @example * var obj = { * $ype: '', * default: null, // string, number, boolean, regexp * kind: '', // array, choice * creator: null, _instance: {}, // class * _prop: {}, // union * params: [], return: null, // function * name: name, func: null, * } */ function typeObject(target) { var obj = {}; var typeObj = _isObject$1(target) && target['$type'] ? target : extendType(target); var leafType = ['null', 'undefined', 'number', 'string', 'boolean', 'symbol', 'bigi¡nt', 'object', 'regexp']; obj['$type'] = typeObj['$type']; if (typeObj['default'] !== null && typeof typeObj['default'] !== 'undefined') obj['default'] = typeObj['default']; if (typeObj['kind'] !== null && typeof typeObj['kind'] !== 'undefined') obj['kind'] = typeObj['kind']; if (typeObj['params']) obj['params'] = typeObj['params']; if (typeObj['return']) obj['return'] = typeObj['return']; if (typeObj['creator']) obj['creator'] = typeObj['creator']; if (typeObj['_instance']) obj['_instance'] = typeObj['_instance']; if (leafType.indexOf(obj['$type']) > -