@nine-lab/nine-util 0.8.0 β†’ 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/nine-util.js CHANGED
@@ -81,9 +81,13 @@ class TaskDebouncer {
81
81
  exec(func, ...args) {
82
82
  __privateGet(this, _queue).push({ func, args });
83
83
  if (__privateGet(this, _timer)) clearTimeout(__privateGet(this, _timer));
84
- __privateSet(this, _timer, setTimeout(() => {
85
- __privateMethod(this, _TaskDebouncer_instances, flush_fn).call(this);
86
- }, __privateGet(this, _delay)));
84
+ __privateSet(this, _timer, setTimeout(() => __privateMethod(this, _TaskDebouncer_instances, flush_fn).call(this), __privateGet(this, _delay)));
85
+ }
86
+ execWithKey(key, func, ...args) {
87
+ __privateSet(this, _queue, __privateGet(this, _queue).filter((task) => task.key !== key));
88
+ __privateGet(this, _queue).push({ key, func, args });
89
+ if (__privateGet(this, _timer)) clearTimeout(__privateGet(this, _timer));
90
+ __privateSet(this, _timer, setTimeout(() => __privateMethod(this, _TaskDebouncer_instances, flush_fn).call(this), __privateGet(this, _delay)));
87
91
  }
88
92
  }
89
93
  _timer = new WeakMap();
@@ -1 +1 @@
1
- {"version":3,"file":"nine-util.js","sources":["../src/Trace.js","../src/TaskDebouncer.js"],"sourcesContent":["export class Trace {\r\n\t#name;\r\n\t#color;\r\n\t#enabled = true; // πŸ‘ˆ 이 μƒνƒœκ°’μ΄ 기쀀이 λ©λ‹ˆλ‹€.\r\n\r\n\tconstructor(name = null, color = \"green\") {\r\n\t\tthis.#name = name;\r\n\t\tthis.#color = color;\r\n\r\n\t\t// μΈμŠ€ν„΄μŠ€κ°€ 생성될 λ•Œ μžλ™μœΌλ‘œ ν™˜κ²½μ„ μ²΄ν¬ν•΄μ„œ λ„κ±°λ‚˜ μΌ­λ‹ˆλ‹€.\r\n\t\tthis.#autoConfig();\r\n\t}\r\n\r\n\t#autoConfig() {\r\n\t\tif (typeof window === 'undefined') return;\r\n\r\n\t\tconst isLocal = window.location.hostname === 'localhost' ||\r\n\t\t\twindow.location.hostname === '127.0.0.1' ||\r\n\t\t\twindow.location.hostname.startsWith('192.168.'); // 둜컬 IP μΆ”κ°€\r\n\r\n\t\tif (isLocal) {\r\n\t\t\tthis.enable();\r\n\t\t\t// 둜컬일 λ•ŒλŠ” ν™˜μ˜ λ©”μ‹œμ§€ (λ”± ν•œ 번만 λ‚˜μ˜€κ²Œ ν•˜λ €λ©΄ 클래슀 λ³€μˆ˜ ν™œμš© κ°€λŠ₯)\r\n\t\t} else {\r\n\t\t\tthis.disable();\r\n\t\t\t// 운영 ν™˜κ²½ μ•ˆλ‚΄ λ©”μ‹œμ§€λŠ” console.log둜 직접 좜λ ₯\r\n\t\t\tconsole.log(\r\n\t\t\t\t`%c[${this.#name}]%c 운영 λͺ¨λ“œ: λ‘œκ·Έκ°€ λΉ„ν™œμ„±ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€. %ctrace.enable()%c 둜 μΌ€ 수 μžˆμŠ΅λ‹ˆλ‹€.`,\r\n\t\t\t\t\"color: #4CAF50; font-weight: bold;\", \"\",\r\n\t\t\t\t\"background: #333; color: yellow; padding: 2px 5px;\", \"\"\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tinit(name, color = \"green\") {\r\n\t\tthis.#name = name;\r\n\t\tthis.#color = color;\r\n\t}\r\n\r\n\t// πŸ”΄ 핡심: ν•¨μˆ˜λ₯Ό κ°ˆμ•„λΌμš°μ§€ μ•Šκ³ , 호좜될 λ•Œλ§ˆλ‹€ μƒνƒœλ₯Ό μ²΄ν¬ν•©λ‹ˆλ‹€.\r\n\tlog(...args) {\r\n\t\tif (!this.#enabled) return;\r\n\t\tconst style = `color: ${this.#color}; font-weight: bold;`;\r\n\t\t(this.#name) ? console.log(`%c[${this.#name}]`, style, ...args) : console.log(...args);\r\n\t}\r\n\r\n\twarn(...args) {\r\n\t\tif (!this.#enabled) return;\r\n\t\t(this.#name) ? console.warn(`%c[${this.#name}]`, \"color: cyan; font-weight: bold;\", ...args) : console.warn(...args);\r\n\t}\r\n\r\n\terror(...args) {\r\n\t\t//if (!this.#enabled) return;\r\n\t\t(this.#name) ? console.error(`%c[${this.#name}]`, \"color: red; font-weight: bold;\", ...args) : console.error(...args);\r\n\t}\r\n\r\n\tenable() { this.#enabled = true; }\r\n\tdisable() { this.#enabled = false; }\r\n}\r\n\r\nexport const trace = new Trace();\r\n\r\n// λΈŒλΌμš°μ € μ½˜μ†”μ—μ„œ μ¦‰μ‹œ μ œμ–΄ν•  수 μžˆλ„λ‘ window에 μ—°κ²°\r\nif (typeof window !== 'undefined') {\r\n\twindow.trace = trace;\r\n}","export class TaskDebouncer {\r\n\t#timer = null;\r\n\t#queue = [];\r\n\t#delay;\r\n\r\n\tconstructor(delay = 50) {\r\n\t\tthis.#delay = delay;\r\n\t}\r\n\r\n\t/**\r\n\t * @param {Function} func - μ‹€ν–‰ν•  ν•¨μˆ˜\r\n\t * @param {...any} args - ν•¨μˆ˜μ— 전달할 μž„μ˜μ˜ νŒŒλΌλ―Έν„°λ“€\r\n\t */\r\n\texec(func, ...args) {\r\n\t\t// 1. μ–΄λ–€ ν•¨μˆ˜μ™€ μ–΄λ–€ μΈμžλ“€μ΄ λ“€μ–΄μ™”λŠ”μ§€ 큐에 μ €μž₯\r\n\t\tthis.#queue.push({ func, args });\r\n\r\n\t\t// 2. λ””λ°”μš΄μŠ€ 타이머 μ„€μ •\r\n\t\tif (this.#timer) clearTimeout(this.#timer);\r\n\r\n\t\tthis.#timer = setTimeout(() => {\r\n\t\t\tthis.#flush();\r\n\t\t}, this.#delay);\r\n\t}\r\n\r\n\t#flush() {\r\n\t\tif (this.#queue.length === 0) return;\r\n\r\n\t\t// 3. ν˜„μž¬κΉŒμ§€ μŒ“μΈ 큐λ₯Ό 쏙 빼옴\r\n\t\tconst tasks = this.#queue.splice(0, this.#queue.length);\r\n\t\tconst seen = new Set();\r\n\r\n\t\ttasks.forEach(task => {\r\n\t\t\t// 4. 핡심: ν•¨μˆ˜ 이름과 μΈμžλ“€μ„ λ¬Έμžμ—΄λ‘œ ν•©μ³μ„œ μœ λ‹ˆν¬ ν‚€ 생성\r\n\t\t\t// JSON.stringifyλ₯Ό 톡해 [1, {a:1}] 같은 νŒŒλΌλ―Έν„°λ„ λ¬Έμžμ—΄λ‘œ 비ꡐ κ°€λŠ₯\r\n\t\t\tconst identifier = `${task.func.name}_${JSON.stringify(task.args)}`;\r\n\r\n\t\t\tif (!seen.has(identifier)) {\r\n\t\t\t\t// 5. 쀑볡이 아닐 λ•Œλ§Œ μ›λž˜ μΈμžλ“€(...args) κ·ΈλŒ€λ‘œ μ‹€ν–‰\r\n\t\t\t\ttask.func(...task.args);\r\n\t\t\t\tseen.add(identifier);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis.#timer = null;\r\n\t}\r\n}"],"names":[],"mappings":";;;;;;;;AAAO;AAAA,MAAM,MAAM;AAAA;AAAA,EAKlB,YAAY,OAAO,MAAM,QAAQ,SAAS;AALpC;AACN;AACA;AACA,iCAAW;AAGV,uBAAK,OAAQ;AACb,uBAAK,QAAS;AAGd,0BAAK,iCAAL;AAAA,EACD;AAAA,EAuBA,KAAK,MAAM,QAAQ,SAAS;AAC3B,uBAAK,OAAQ;AACb,uBAAK,QAAS;AAAA,EACf;AAAA;AAAA,EAGA,OAAO,MAAM;AACZ,QAAI,CAAC,mBAAK,UAAU;AACpB,UAAM,QAAQ,UAAU,mBAAK,OAAM;AACnC,IAAC,mBAAK,SAAS,QAAQ,IAAI,MAAM,mBAAK,MAAK,KAAK,OAAO,GAAG,IAAI,IAAI,QAAQ,IAAI,GAAG,IAAI;AAAA,EACtF;AAAA,EAEA,QAAQ,MAAM;AACb,QAAI,CAAC,mBAAK,UAAU;AACpB,IAAC,mBAAK,SAAS,QAAQ,KAAK,MAAM,mBAAK,MAAK,KAAK,mCAAmC,GAAG,IAAI,IAAI,QAAQ,KAAK,GAAG,IAAI;AAAA,EACp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AM;AACtD,QAAM,OAAO,oBAAI;AAEjB,QAAM,QAAQ,UAAQ;AAGrB,UAAM,aAAa,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,UAAU,KAAK,IAAI,CAAC;AAEjE,QAAI,CAAC,KAAK,IAAI,UAAU,GAAG;AAE1B,WAAK,KAAK,GAAG,KAAK,IAAI;AACtB,WAAK,IAAI,UAAU;AAAA,IACpB;AAAA,EACD,CAAC;AAED,qBAAK,QAAS;AACf;"}
1
+ {"version":3,"file":"nine-util.js","sources":["../src/Trace.js","../src/TaskDebouncer.js"],"sourcesContent":["export class Trace {\r\n\t#name;\r\n\t#color;\r\n\t#enabled = true; // πŸ‘ˆ 이 μƒνƒœκ°’μ΄ 기쀀이 λ©λ‹ˆλ‹€.\r\n\r\n\tconstructor(name = null, color = \"green\") {\r\n\t\tthis.#name = name;\r\n\t\tthis.#color = color;\r\n\r\n\t\t// μΈμŠ€ν„΄μŠ€κ°€ 생성될 λ•Œ μžλ™μœΌλ‘œ ν™˜κ²½μ„ μ²΄ν¬ν•΄μ„œ λ„κ±°λ‚˜ μΌ­λ‹ˆλ‹€.\r\n\t\tthis.#autoConfig();\r\n\t}\r\n\r\n\t#autoConfig() {\r\n\t\tif (typeof window === 'undefined') return;\r\n\r\n\t\tconst isLocal = window.location.hostname === 'localhost' ||\r\n\t\t\twindow.location.hostname === '127.0.0.1' ||\r\n\t\t\twindow.location.hostname.startsWith('192.168.'); // 둜컬 IP μΆ”κ°€\r\n\r\n\t\tif (isLocal) {\r\n\t\t\tthis.enable();\r\n\t\t\t// 둜컬일 λ•ŒλŠ” ν™˜μ˜ λ©”μ‹œμ§€ (λ”± ν•œ 번만 λ‚˜μ˜€κ²Œ ν•˜λ €λ©΄ 클래슀 λ³€μˆ˜ ν™œμš© κ°€λŠ₯)\r\n\t\t} else {\r\n\t\t\tthis.disable();\r\n\t\t\t// 운영 ν™˜κ²½ μ•ˆλ‚΄ λ©”μ‹œμ§€λŠ” console.log둜 직접 좜λ ₯\r\n\t\t\tconsole.log(\r\n\t\t\t\t`%c[${this.#name}]%c 운영 λͺ¨λ“œ: λ‘œκ·Έκ°€ λΉ„ν™œμ„±ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€. %ctrace.enable()%c 둜 μΌ€ 수 μžˆμŠ΅λ‹ˆλ‹€.`,\r\n\t\t\t\t\"color: #4CAF50; font-weight: bold;\", \"\",\r\n\t\t\t\t\"background: #333; color: yellow; padding: 2px 5px;\", \"\"\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tinit(name, color = \"green\") {\r\n\t\tthis.#name = name;\r\n\t\tthis.#color = color;\r\n\t}\r\n\r\n\t// πŸ”΄ 핡심: ν•¨μˆ˜λ₯Ό κ°ˆμ•„λΌμš°μ§€ μ•Šκ³ , 호좜될 λ•Œλ§ˆλ‹€ μƒνƒœλ₯Ό μ²΄ν¬ν•©λ‹ˆλ‹€.\r\n\tlog(...args) {\r\n\t\tif (!this.#enabled) return;\r\n\t\tconst style = `color: ${this.#color}; font-weight: bold;`;\r\n\t\t(this.#name) ? console.log(`%c[${this.#name}]`, style, ...args) : console.log(...args);\r\n\t}\r\n\r\n\twarn(...args) {\r\n\t\tif (!this.#enabled) return;\r\n\t\t(this.#name) ? console.warn(`%c[${this.#name}]`, \"color: cyan; font-weight: bold;\", ...args) : console.warn(...args);\r\n\t}\r\n\r\n\terror(...args) {\r\n\t\t//if (!this.#enabled) return;\r\n\t\t(this.#name) ? console.error(`%c[${this.#name}]`, \"color: red; font-weight: bold;\", ...args) : console.error(...args);\r\n\t}\r\n\r\n\tenable() { this.#enabled = true; }\r\n\tdisable() { this.#enabled = false; }\r\n}\r\n\r\nexport const trace = new Trace();\r\n\r\n// λΈŒλΌμš°μ € μ½˜μ†”μ—μ„œ μ¦‰μ‹œ μ œμ–΄ν•  수 μžˆλ„λ‘ window에 μ—°κ²°\r\nif (typeof window !== 'undefined') {\r\n\twindow.trace = trace;\r\n}","export class TaskDebouncer {\r\n\t#timer = null;\r\n\t#queue = [];\r\n\t#delay;\r\n\r\n\tconstructor(delay = 50) {\r\n\t\tthis.#delay = delay;\r\n\t}\r\n\r\n\t/**\r\n\t * @param {Function} func - μ‹€ν–‰ν•  ν•¨μˆ˜\r\n\t * @param {...any} args - ν•¨μˆ˜μ— 전달할 μž„μ˜μ˜ νŒŒλΌλ―Έν„°λ“€\r\n\t */\r\n\texec(func, ...args) {\r\n\t\t// 1. μ–΄λ–€ ν•¨μˆ˜μ™€ μ–΄λ–€ μΈμžλ“€μ΄ λ“€μ–΄μ™”λŠ”μ§€ 큐에 μ €μž₯\r\n\t\tthis.#queue.push({ func, args });\r\n\r\n\t\t// 2. λ””λ°”μš΄μŠ€ 타이머 μ„€μ •\r\n\t\tif (this.#timer) clearTimeout(this.#timer);\r\n\r\n\t\tthis.#timer = setTimeout(() => this.#flush(), this.#delay);\r\n\t}\r\n\r\n\texecWithKey(key, func, ...args) {\r\n\t\t// 1. 같은 ν‚€(예: 'resize')κ°€ λ“€μ–΄μ˜€λ©΄ 이전 νμ—μ„œ ν•΄λ‹Ή ν‚€ μ‚­μ œ (쀑볡 제거)\r\n\t\tthis.#queue = this.#queue.filter(task => task.key !== key);\r\n\r\n\t\t// 2. μƒˆλ‘œμš΄ νƒœμŠ€ν¬ μΆ”κ°€\r\n\t\tthis.#queue.push({ key, func, args });\r\n\r\n\t\tif (this.#timer) clearTimeout(this.#timer);\r\n\t\tthis.#timer = setTimeout(() => this.#flush(), this.#delay);\r\n\t}\r\n\r\n\t#flush() {\r\n\t\tif (this.#queue.length === 0) return;\r\n\r\n\t\t// 3. ν˜„μž¬κΉŒμ§€ μŒ“μΈ 큐λ₯Ό 쏙 빼옴\r\n\t\tconst tasks = this.#queue.splice(0, this.#queue.length);\r\n\t\tconst seen = new Set();\r\n\r\n\t\ttasks.forEach(task => {\r\n\t\t\t// 4. 핡심: ν•¨μˆ˜ 이름과 μΈμžλ“€μ„ λ¬Έμžμ—΄λ‘œ ν•©μ³μ„œ μœ λ‹ˆν¬ ν‚€ 생성\r\n\t\t\t// JSON.stringifyλ₯Ό 톡해 [1, {a:1}] 같은 νŒŒλΌλ―Έν„°λ„ λ¬Έμžμ—΄λ‘œ 비ꡐ κ°€λŠ₯\r\n\t\t\tconst identifier = `${task.func.name}_${JSON.stringify(task.args)}`;\r\n\r\n\t\t\tif (!seen.has(identifier)) {\r\n\t\t\t\t// 5. 쀑볡이 아닐 λ•Œλ§Œ μ›λž˜ μΈμžλ“€(...args) κ·ΈλŒ€λ‘œ μ‹€ν–‰\r\n\t\t\t\ttask.func(...task.args);\r\n\t\t\t\tseen.add(identifier);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis.#timer = null;\r\n\t}\r\n}"],"names":[],"mappings":";;;;;;;;AAAO;AAAA,MAAM,MAAM;AAAA;AAAA,EAKlB,YAAY,OAAO,MAAM,QAAQ,SAAS;AALpC;AACN;AACA;AACA,iCAAW;AAGV,uBAAK,OAAQ;AACb,uBAAK,QAAS;AAGd,0BAAK,iCAAL;AAAA,EACD;AAAA,EAuBA,KAAK,MAAM,QAAQ,SAAS;AAC3B,uBAAK,OAAQ;AACb,uBAAK,QAAS;AAAA,EACf;AAAA;AAAA,EAGA,OAAO,MAAM;AACZ,QAAI,CAAC,mBAAK,UAAU;AACpB,UAAM,QAAQ,UAAU,mBAAK,OAAM;AACnC,IAAC,mBAAK,SAAS,QAAQ,IAAI,MAAM,mBAAK,MAAK,KAAK,OAAO,GAAG,IAAI,IAAI,QAAQ,IAAI,GAAG,IAAI;AAAA,EACtF;AAAA,EAEA,QAAQ,MAAM;AACb,QAAI,CAAC,mBAAK,UAAU;AACpB,IAAC,mBAAK,SAAS,QAAQ,KAAK,MAAM,mBAAK,MAAK,KAAK,mCAAmC,GAAG,IAAI,IAAI,QAAQ,KAAK,GAAG,IAAI;AAAA,EACpH;AAAA,EAEA,SAAS,MAAM;AAEd,IAAC,mBAAK,SAAS,QAAQ,MAAM,MAAM,mBAAK,MAAK,KAAK,kC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e,mBAAK,OAAM;AAAA,EAC1D;AAuBD;AAtDC;AACA;AACA;AAHM;AAkCN,WAAM,WAAG;AACR,MAAI,mBAAK,QAAO,WAAW,EAAG;AAG9B,QAAM,QAAQ,mBAAK,QAAO,OAAO,GAAG,mBAAK,QAAO,MAAM;AACtD,QAAM,OAAO,oBAAI;AAEjB,QAAM,QAAQ,UAAQ;AAGrB,UAAM,aAAa,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,UAAU,KAAK,IAAI,CAAC;AAEjE,QAAI,CAAC,KAAK,IAAI,UAAU,GAAG;AAE1B,WAAK,KAAK,GAAG,KAAK,IAAI;AACtB,WAAK,IAAI,UAAU;AAAA,IACpB;AAAA,EACD,CAAC;AAED,qBAAK,QAAS;AACf;"}
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).NineUtil={})}(this,function(e){"use strict";var t,o,n,i,s,a,l,r,c,h,d=e=>{throw TypeError(e)},f=(e,t,o)=>t.has(e)||d("Cannot "+o),w=(e,t,o)=>(f(e,t,"read from private field"),o?o.call(e):t.get(e)),u=(e,t,o)=>t.has(e)?d("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,o),p=(e,t,o,n)=>(f(e,t,"write to private field"),n?n.call(e,o):t.set(e,o),o),g=(e,t,o)=>(f(e,t,"access private method"),o);class b{constructor(e=null,a="green"){u(this,i),u(this,t),u(this,o),u(this,n,!0),p(this,t,e),p(this,o,a),g(this,i,s).call(this)}init(e,n="green"){p(this,t,e),p(this,o,n)}log(...e){if(!w(this,n))return;const i=`color: ${w(this,o)}; font-weight: bold;`;w(this,t)?console.log(`%c[${w(this,t)}]`,i,...e):console.log(...e)}warn(...e){w(this,n)&&(w(this,t)?console.warn(`%c[${w(this,t)}]`,"color: cyan; font-weight: bold;",...e):console.warn(...e))}error(...e){w(this,t)?console.error(`%c[${w(this,t)}]`,"color: red; font-weight: bold;",...e):console.error(...e)}enable(){p(this,n,!0)}disable(){p(this,n,!1)}}t=new WeakMap,o=new WeakMap,n=new WeakMap,i=new WeakSet,s=function(){if("undefined"==typeof window)return;"localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||window.location.hostname.startsWith("192.168.")?this.enable():(this.disable(),console.log(`%c[${w(this,t)}]%c 운영 λͺ¨λ“œ: λ‘œκ·Έκ°€ λΉ„ν™œμ„±ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€. %ctrace.enable()%c 둜 μΌ€ 수 μžˆμŠ΅λ‹ˆλ‹€.`,"color: #4CAF50; font-weight: bold;","","background: #333; color: yellow; padding: 2px 5px;",""))};const m=new b;"undefined"!=typeof window&&(window.trace=m);a=new WeakMap,l=new WeakMap,r=new WeakMap,c=new WeakSet,h=function(){if(0===w(this,l).length)return;const e=w(this,l).splice(0,w(this,l).length),t=new Set;e.forEach(e=>{const o=`${e.func.name}_${JSON.stringify(e.args)}`;t.has(o)||(e.func(...e.args),t.add(o))}),p(this,a,null)},e.TaskDebouncer=class{constructor(e=50){u(this,c),u(this,a,null),u(this,l,[]),u(this,r),p(this,r,e)}exec(e,...t){w(this,l).push({func:e,args:t}),w(this,a)&&clearTimeout(w(this,a)),p(this,a,setTimeout(()=>{g(this,c,h).call(this)},w(this,r)))}},e.Trace=b,e.trace=m,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).NineUtil={})}(this,function(e){"use strict";var t,i,o,s,n,a,h,l,c,r,d=e=>{throw TypeError(e)},f=(e,t,i)=>t.has(e)||d("Cannot "+i),u=(e,t,i)=>(f(e,t,"read from private field"),i?i.call(e):t.get(e)),w=(e,t,i)=>t.has(e)?d("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),p=(e,t,i,o)=>(f(e,t,"write to private field"),o?o.call(e,i):t.set(e,i),i),g=(e,t,i)=>(f(e,t,"access private method"),i);class b{constructor(e=null,a="green"){w(this,s),w(this,t),w(this,i),w(this,o,!0),p(this,t,e),p(this,i,a),g(this,s,n).call(this)}init(e,o="green"){p(this,t,e),p(this,i,o)}log(...e){if(!u(this,o))return;const s=`color: ${u(this,i)}; font-weight: bold;`;u(this,t)?console.log(`%c[${u(this,t)}]`,s,...e):console.log(...e)}warn(...e){u(this,o)&&(u(this,t)?console.warn(`%c[${u(this,t)}]`,"color: cyan; font-weight: bold;",...e):console.warn(...e))}error(...e){u(this,t)?console.error(`%c[${u(this,t)}]`,"color: red; font-weight: bold;",...e):console.error(...e)}enable(){p(this,o,!0)}disable(){p(this,o,!1)}}t=new WeakMap,i=new WeakMap,o=new WeakMap,s=new WeakSet,n=function(){if("undefined"==typeof window)return;"localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||window.location.hostname.startsWith("192.168.")?this.enable():(this.disable(),console.log(`%c[${u(this,t)}]%c 운영 λͺ¨λ“œ: λ‘œκ·Έκ°€ λΉ„ν™œμ„±ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€. %ctrace.enable()%c 둜 μΌ€ 수 μžˆμŠ΅λ‹ˆλ‹€.`,"color: #4CAF50; font-weight: bold;","","background: #333; color: yellow; padding: 2px 5px;",""))};const m=new b;"undefined"!=typeof window&&(window.trace=m);a=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakSet,r=function(){if(0===u(this,h).length)return;const e=u(this,h).splice(0,u(this,h).length),t=new Set;e.forEach(e=>{const i=`${e.func.name}_${JSON.stringify(e.args)}`;t.has(i)||(e.func(...e.args),t.add(i))}),p(this,a,null)},e.TaskDebouncer=class{constructor(e=50){w(this,c),w(this,a,null),w(this,h,[]),w(this,l),p(this,l,e)}exec(e,...t){u(this,h).push({func:e,args:t}),u(this,a)&&clearTimeout(u(this,a)),p(this,a,setTimeout(()=>g(this,c,r).call(this),u(this,l)))}execWithKey(e,t,...i){p(this,h,u(this,h).filter(t=>t.key!==e)),u(this,h).push({key:e,func:t,args:i}),u(this,a)&&clearTimeout(u(this,a)),p(this,a,setTimeout(()=>g(this,c,r).call(this),u(this,l)))}},e.Trace=b,e.trace=m,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=nine-util.umd.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nine-util.umd.cjs","sources":["../src/Trace.js","../src/TaskDebouncer.js"],"sourcesContent":["export class Trace {\r\n\t#name;\r\n\t#color;\r\n\t#enabled = true; // πŸ‘ˆ 이 μƒνƒœκ°’μ΄ 기쀀이 λ©λ‹ˆλ‹€.\r\n\r\n\tconstructor(name = null, color = \"green\") {\r\n\t\tthis.#name = name;\r\n\t\tthis.#color = color;\r\n\r\n\t\t// μΈμŠ€ν„΄μŠ€κ°€ 생성될 λ•Œ μžλ™μœΌλ‘œ ν™˜κ²½μ„ μ²΄ν¬ν•΄μ„œ λ„κ±°λ‚˜ μΌ­λ‹ˆλ‹€.\r\n\t\tthis.#autoConfig();\r\n\t}\r\n\r\n\t#autoConfig() {\r\n\t\tif (typeof window === 'undefined') return;\r\n\r\n\t\tconst isLocal = window.location.hostname === 'localhost' ||\r\n\t\t\twindow.location.hostname === '127.0.0.1' ||\r\n\t\t\twindow.location.hostname.startsWith('192.168.'); // 둜컬 IP μΆ”κ°€\r\n\r\n\t\tif (isLocal) {\r\n\t\t\tthis.enable();\r\n\t\t\t// 둜컬일 λ•ŒλŠ” ν™˜μ˜ λ©”μ‹œμ§€ (λ”± ν•œ 번만 λ‚˜μ˜€κ²Œ ν•˜λ €λ©΄ 클래슀 λ³€μˆ˜ ν™œμš© κ°€λŠ₯)\r\n\t\t} else {\r\n\t\t\tthis.disable();\r\n\t\t\t// 운영 ν™˜κ²½ μ•ˆλ‚΄ λ©”μ‹œμ§€λŠ” console.log둜 직접 좜λ ₯\r\n\t\t\tconsole.log(\r\n\t\t\t\t`%c[${this.#name}]%c 운영 λͺ¨λ“œ: λ‘œκ·Έκ°€ λΉ„ν™œμ„±ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€. %ctrace.enable()%c 둜 μΌ€ 수 μžˆμŠ΅λ‹ˆλ‹€.`,\r\n\t\t\t\t\"color: #4CAF50; font-weight: bold;\", \"\",\r\n\t\t\t\t\"background: #333; color: yellow; padding: 2px 5px;\", \"\"\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tinit(name, color = \"green\") {\r\n\t\tthis.#name = name;\r\n\t\tthis.#color = color;\r\n\t}\r\n\r\n\t// πŸ”΄ 핡심: ν•¨μˆ˜λ₯Ό κ°ˆμ•„λΌμš°μ§€ μ•Šκ³ , 호좜될 λ•Œλ§ˆλ‹€ μƒνƒœλ₯Ό μ²΄ν¬ν•©λ‹ˆλ‹€.\r\n\tlog(...args) {\r\n\t\tif (!this.#enabled) return;\r\n\t\tconst style = `color: ${this.#color}; font-weight: bold;`;\r\n\t\t(this.#name) ? console.log(`%c[${this.#name}]`, style, ...args) : console.log(...args);\r\n\t}\r\n\r\n\twarn(...args) {\r\n\t\tif (!this.#enabled) return;\r\n\t\t(this.#name) ? console.warn(`%c[${this.#name}]`, \"color: cyan; font-weight: bold;\", ...args) : console.warn(...args);\r\n\t}\r\n\r\n\terror(...args) {\r\n\t\t//if (!this.#enabled) return;\r\n\t\t(this.#name) ? console.error(`%c[${this.#name}]`, \"color: red; font-weight: bold;\", ...args) : console.error(...args);\r\n\t}\r\n\r\n\tenable() { this.#enabled = true; }\r\n\tdisable() { this.#enabled = false; }\r\n}\r\n\r\nexport const trace = new Trace();\r\n\r\n// λΈŒλΌμš°μ € μ½˜μ†”μ—μ„œ μ¦‰μ‹œ μ œμ–΄ν•  수 μžˆλ„λ‘ window에 μ—°κ²°\r\nif (typeof window !== 'undefined') {\r\n\twindow.trace = trace;\r\n}","export class TaskDebouncer {\r\n\t#timer = null;\r\n\t#queue = [];\r\n\t#delay;\r\n\r\n\tconstructor(delay = 50) {\r\n\t\tthis.#delay = delay;\r\n\t}\r\n\r\n\t/**\r\n\t * @param {Function} func - μ‹€ν–‰ν•  ν•¨μˆ˜\r\n\t * @param {...any} args - ν•¨μˆ˜μ— 전달할 μž„μ˜μ˜ νŒŒλΌλ―Έν„°λ“€\r\n\t */\r\n\texec(func, ...args) {\r\n\t\t// 1. μ–΄λ–€ ν•¨μˆ˜μ™€ μ–΄λ–€ μΈμžλ“€μ΄ λ“€μ–΄μ™”λŠ”μ§€ 큐에 μ €μž₯\r\n\t\tthis.#queue.push({ func, args });\r\n\r\n\t\t// 2. λ””λ°”μš΄μŠ€ 타이머 μ„€μ •\r\n\t\tif (this.#timer) clearTimeout(this.#timer);\r\n\r\n\t\tthis.#timer = setTimeout(() => {\r\n\t\t\tthis.#flush();\r\n\t\t}, this.#delay);\r\n\t}\r\n\r\n\t#flush() {\r\n\t\tif (this.#queue.length === 0) return;\r\n\r\n\t\t// 3. ν˜„μž¬κΉŒμ§€ μŒ“μΈ 큐λ₯Ό 쏙 빼옴\r\n\t\tconst tasks = this.#queue.splice(0, this.#queue.length);\r\n\t\tconst seen = new Set();\r\n\r\n\t\ttasks.forEach(task => {\r\n\t\t\t// 4. 핡심: ν•¨μˆ˜ 이름과 μΈμžλ“€μ„ λ¬Έμžμ—΄λ‘œ ν•©μ³μ„œ μœ λ‹ˆν¬ ν‚€ 생성\r\n\t\t\t// JSON.stringifyλ₯Ό 톡해 [1, {a:1}] 같은 νŒŒλΌλ―Έν„°λ„ λ¬Έμžμ—΄λ‘œ 비ꡐ κ°€λŠ₯\r\n\t\t\tconst identifier = `${task.func.name}_${JSON.stringify(task.args)}`;\r\n\r\n\t\t\tif (!seen.has(identifier)) {\r\n\t\t\t\t// 5. 쀑볡이 아닐 λ•Œλ§Œ μ›λž˜ μΈμžλ“€(...args) κ·ΈλŒ€λ‘œ μ‹€ν–‰\r\n\t\t\t\ttask.func(...task.args);\r\n\t\t\t\tseen.add(identifier);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis.#timer = null;\r\n\t}\r\n}"],"names":["Trace","constructor","name","color","__privateAdd","this","_Trace_instances","_name","_color","_enabled","__privateSet","__privateMethod","autoConfig_fn","call","init","log","args","__privateGet","style","console","warn","error","enable","disable","WeakMap","WeakSet","window","location","hostname","startsWith","trace","_timer","_queue","_delay","_TaskDebouncer_instances","flush_fn","length","tasks","splice","seen","Set","forEach","task","identifier","func","JSON","stringify","has","add","delay","exec","push","clearTimeout","setTimeout"],"mappings":"onBAAO,MAAMA,EAKZ,WAAAC,CAAYC,EAAO,KAAMC,EAAQ,SAL3BC,EAAAC,KAAAC,GACNF,EAAAC,KAAAE,GACAH,EAAAC,KAAAG,GACAJ,EAAAC,KAAAI,GAAW,GAGVC,EAAAL,KAAKE,EAAQL,GACbQ,EAAAL,KAAKG,EAASL,GAGdQ,EAAAN,KAAKC,EAAAM,GAALC,KAAAR,KACD,CAuBA,IAAAS,CAAKZ,EAAMC,EAAQ,SAClBO,EAAAL,KAAKE,EAAQL,GACbQ,EAAAL,KAAKG,EAASL,EACf,CAGA,GAAAY,IAAOC,GACN,IAAKC,OAAKR,GAAU,OACpB,MAAMS,EAAQ,UAAUD,EAAAZ,KAAKG,yBAC5BS,EAAAZ,KAAKE,GAASY,QAAQJ,IAAI,MAAME,EAAAZ,KAAKE,MAAUW,KAAUF,GAAQG,QAAQJ,OAAOC,EAClF,CAEA,IAAAI,IAAQJ,GACFC,OAAKR,KACTQ,EAAAZ,KAAKE,GAASY,QAAQC,KAAK,MAAMH,EAAAZ,KAAKE,MAAU,qCAAsCS,GAAQG,QAAQC,QAAQJ,GAChH,CAEA,KAAAK,IAASL,GAEPC,EAAAZ,KAAKE,GAASY,QAAQE,MAAM,MAAMJ,EAAAZ,KAAKE,MAAU,oCAAqCS,GAAQG,QAAQE,SAASL,EACjH,CAEA,MAAAM,GAAWZ,EAAAL,KAAKI,GAAW,EAAM,CACjC,OAAAc,GAAYb,EAAAL,KA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AAAN,KAAK6B,EAAAC,GAALtB,KAAAR,OACEY,OAAKgB,IACT"}
1
+ {"version":3,"file":"nine-util.umd.cjs","sources":["../src/Trace.js","../src/TaskDebouncer.js"],"sourcesContent":["export class Trace {\r\n\t#name;\r\n\t#color;\r\n\t#enabled = true; // πŸ‘ˆ 이 μƒνƒœκ°’μ΄ 기쀀이 λ©λ‹ˆλ‹€.\r\n\r\n\tconstructor(name = null, color = \"green\") {\r\n\t\tthis.#name = name;\r\n\t\tthis.#color = color;\r\n\r\n\t\t// μΈμŠ€ν„΄μŠ€κ°€ 생성될 λ•Œ μžλ™μœΌλ‘œ ν™˜κ²½μ„ μ²΄ν¬ν•΄μ„œ λ„κ±°λ‚˜ μΌ­λ‹ˆλ‹€.\r\n\t\tthis.#autoConfig();\r\n\t}\r\n\r\n\t#autoConfig() {\r\n\t\tif (typeof window === 'undefined') return;\r\n\r\n\t\tconst isLocal = window.location.hostname === 'localhost' ||\r\n\t\t\twindow.location.hostname === '127.0.0.1' ||\r\n\t\t\twindow.location.hostname.startsWith('192.168.'); // 둜컬 IP μΆ”κ°€\r\n\r\n\t\tif (isLocal) {\r\n\t\t\tthis.enable();\r\n\t\t\t// 둜컬일 λ•ŒλŠ” ν™˜μ˜ λ©”μ‹œμ§€ (λ”± ν•œ 번만 λ‚˜μ˜€κ²Œ ν•˜λ €λ©΄ 클래슀 λ³€μˆ˜ ν™œμš© κ°€λŠ₯)\r\n\t\t} else {\r\n\t\t\tthis.disable();\r\n\t\t\t// 운영 ν™˜κ²½ μ•ˆλ‚΄ λ©”μ‹œμ§€λŠ” console.log둜 직접 좜λ ₯\r\n\t\t\tconsole.log(\r\n\t\t\t\t`%c[${this.#name}]%c 운영 λͺ¨λ“œ: λ‘œκ·Έκ°€ λΉ„ν™œμ„±ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€. %ctrace.enable()%c 둜 μΌ€ 수 μžˆμŠ΅λ‹ˆλ‹€.`,\r\n\t\t\t\t\"color: #4CAF50; font-weight: bold;\", \"\",\r\n\t\t\t\t\"background: #333; color: yellow; padding: 2px 5px;\", \"\"\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tinit(name, color = \"green\") {\r\n\t\tthis.#name = name;\r\n\t\tthis.#color = color;\r\n\t}\r\n\r\n\t// πŸ”΄ 핡심: ν•¨μˆ˜λ₯Ό κ°ˆμ•„λΌμš°μ§€ μ•Šκ³ , 호좜될 λ•Œλ§ˆλ‹€ μƒνƒœλ₯Ό μ²΄ν¬ν•©λ‹ˆλ‹€.\r\n\tlog(...args) {\r\n\t\tif (!this.#enabled) return;\r\n\t\tconst style = `color: ${this.#color}; font-weight: bold;`;\r\n\t\t(this.#name) ? console.log(`%c[${this.#name}]`, style, ...args) : console.log(...args);\r\n\t}\r\n\r\n\twarn(...args) {\r\n\t\tif (!this.#enabled) return;\r\n\t\t(this.#name) ? console.warn(`%c[${this.#name}]`, \"color: cyan; font-weight: bold;\", ...args) : console.warn(...args);\r\n\t}\r\n\r\n\terror(...args) {\r\n\t\t//if (!this.#enabled) return;\r\n\t\t(this.#name) ? console.error(`%c[${this.#name}]`, \"color: red; font-weight: bold;\", ...args) : console.error(...args);\r\n\t}\r\n\r\n\tenable() { this.#enabled = true; }\r\n\tdisable() { this.#enabled = false; }\r\n}\r\n\r\nexport const trace = new Trace();\r\n\r\n// λΈŒλΌμš°μ € μ½˜μ†”μ—μ„œ μ¦‰μ‹œ μ œμ–΄ν•  수 μžˆλ„λ‘ window에 μ—°κ²°\r\nif (typeof window !== 'undefined') {\r\n\twindow.trace = trace;\r\n}","export class TaskDebouncer {\r\n\t#timer = null;\r\n\t#queue = [];\r\n\t#delay;\r\n\r\n\tconstructor(delay = 50) {\r\n\t\tthis.#delay = delay;\r\n\t}\r\n\r\n\t/**\r\n\t * @param {Function} func - μ‹€ν–‰ν•  ν•¨μˆ˜\r\n\t * @param {...any} args - ν•¨μˆ˜μ— 전달할 μž„μ˜μ˜ νŒŒλΌλ―Έν„°λ“€\r\n\t */\r\n\texec(func, ...args) {\r\n\t\t// 1. μ–΄λ–€ ν•¨μˆ˜μ™€ μ–΄λ–€ μΈμžλ“€μ΄ λ“€μ–΄μ™”λŠ”μ§€ 큐에 μ €μž₯\r\n\t\tthis.#queue.push({ func, args });\r\n\r\n\t\t// 2. λ””λ°”μš΄μŠ€ 타이머 μ„€μ •\r\n\t\tif (this.#timer) clearTimeout(this.#timer);\r\n\r\n\t\tthis.#timer = setTimeout(() => this.#flush(), this.#delay);\r\n\t}\r\n\r\n\texecWithKey(key, func, ...args) {\r\n\t\t// 1. 같은 ν‚€(예: 'resize')κ°€ λ“€μ–΄μ˜€λ©΄ 이전 νμ—μ„œ ν•΄λ‹Ή ν‚€ μ‚­μ œ (쀑볡 제거)\r\n\t\tthis.#queue = this.#queue.filter(task => task.key !== key);\r\n\r\n\t\t// 2. μƒˆλ‘œμš΄ νƒœμŠ€ν¬ μΆ”κ°€\r\n\t\tthis.#queue.push({ key, func, args });\r\n\r\n\t\tif (this.#timer) clearTimeout(this.#timer);\r\n\t\tthis.#timer = setTimeout(() => this.#flush(), this.#delay);\r\n\t}\r\n\r\n\t#flush() {\r\n\t\tif (this.#queue.length === 0) return;\r\n\r\n\t\t// 3. ν˜„μž¬κΉŒμ§€ μŒ“μΈ 큐λ₯Ό 쏙 빼옴\r\n\t\tconst tasks = this.#queue.splice(0, this.#queue.length);\r\n\t\tconst seen = new Set();\r\n\r\n\t\ttasks.forEach(task => {\r\n\t\t\t// 4. 핡심: ν•¨μˆ˜ 이름과 μΈμžλ“€μ„ λ¬Έμžμ—΄λ‘œ ν•©μ³μ„œ μœ λ‹ˆν¬ ν‚€ 생성\r\n\t\t\t// JSON.stringifyλ₯Ό 톡해 [1, {a:1}] 같은 νŒŒλΌλ―Έν„°λ„ λ¬Έμžμ—΄λ‘œ 비ꡐ κ°€λŠ₯\r\n\t\t\tconst identifier = `${task.func.name}_${JSON.stringify(task.args)}`;\r\n\r\n\t\t\tif (!seen.has(identifier)) {\r\n\t\t\t\t// 5. 쀑볡이 아닐 λ•Œλ§Œ μ›λž˜ μΈμžλ“€(...args) κ·ΈλŒ€λ‘œ μ‹€ν–‰\r\n\t\t\t\ttask.func(...task.args);\r\n\t\t\t\tseen.add(identifier);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis.#timer = null;\r\n\t}\r\n}"],"names":["Trace","constructor","name","color","__privateAdd","this","_Trace_instances","_name","_color","_enabled","__privateSet","__privateMethod","autoConfig_fn","call","init","log","args","__privateGet","style","console","warn","error","enable","disable","WeakMap","WeakSet","window","location","hostname","startsWith","trace","_timer","_queue","_delay","_TaskDebouncer_instances","flush_fn","length","tasks","splice","seen","Set","forEach","task","identifier","func","JSON","stringify","has","add","delay","exec","push","clearTimeout","setTimeout","execWithKey","key","filter"],"mappings":"onBAAO,MAAMA,EAKZ,WAAAC,CAAYC,EAAO,KAAMC,EAAQ,SAL3BC,EAAAC,KAAAC,GACNF,EAAAC,KAAAE,GACAH,EAAAC,KAAAG,GACAJ,EAAAC,KAAAI,GAAW,GAGVC,EAAAL,KAAKE,EAAQL,GACbQ,EAAAL,KAAKG,EAASL,GAGdQ,EAAAN,KAAKC,EAAAM,GAALC,KAAAR,KACD,CAuBA,IAAAS,CAAKZ,EAAMC,EAAQ,SAClBO,EAAAL,KAAKE,EAAQL,GACbQ,EAAAL,KAAKG,EAASL,EACf,CAGA,GAAAY,IAAOC,GACN,IAAKC,OAAKR,GAAU,OACpB,MAAMS,EAAQ,UAAUD,EAAAZ,KAAKG,yBAC5BS,EAAAZ,KAAKE,GAASY,QAAQJ,IAAI,MAAME,EAAAZ,KAAKE,MAAUW,KAAUF,GAAQG,QAAQJ,OAAOC,EAClF,CAEA,IAAAI,IAAQJ,GACFC,OAAKR,KACTQ,EAAAZ,KAAKE,GAASY,QAAQC,KAAK,MAAMH,EAAAZ,KAAKE,MAAU,qCAAsCS,GAAQG,QAAQC,QAAQJ,GAChH,CAEA,KAAAK,IAASL,GAEPC,EAAAZ,KAA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AAS5B,GAEbC,EAAAZ,KAAK2B,GAAOmB,KAAK,CAAEP,OAAM5B,SAGrBC,EAAAZ,KAAK0B,IAAQqB,aAAanC,EAAAZ,KAAK0B,IAEnCrB,EAAAL,KAAK0B,EAASsB,WAAW,IAAM1C,OAAKuB,EAAAC,GAALtB,KAAAR,MAAeY,OAAKgB,IACpD,CAEA,WAAAqB,CAAYC,EAAKX,KAAS5B,GAEzBN,EAAAL,KAAK2B,EAASf,EAAAZ,KAAK2B,GAAOwB,OAAOd,GAAQA,EAAKa,MAAQA,IAGtDtC,EAAAZ,KAAK2B,GAAOmB,KAAK,CAAEI,MAAKX,OAAM5B,SAE1BC,EAAAZ,KAAK0B,IAAQqB,aAAanC,EAAAZ,KAAK0B,IACnCrB,EAAAL,KAAK0B,EAASsB,WAAW,IAAM1C,OAAKuB,EAAAC,GAALtB,KAAAR,MAAeY,OAAKgB,IACpD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nine-lab/nine-util",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Custom Element based Util Component for Real-time Collaboration",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-util.umd.cjs",