@wexample/js-helpers 0.0.23 → 0.0.24

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.
Files changed (104) hide show
  1. package/README.md +1 -1
  2. package/dist/Common/AsyncConstructor.js +39 -44
  3. package/dist/Common/AsyncConstructor.js.map +1 -1
  4. package/dist/Helper/Array.js +18 -19
  5. package/dist/Helper/Array.js.map +1 -1
  6. package/dist/Helper/Bytes.js +9 -13
  7. package/dist/Helper/Bytes.js.map +1 -1
  8. package/dist/Helper/Dom.js +61 -58
  9. package/dist/Helper/Dom.js.map +1 -1
  10. package/dist/Helper/Event.js +27 -31
  11. package/dist/Helper/Event.js.map +1 -1
  12. package/dist/Helper/Function.js +2 -6
  13. package/dist/Helper/Function.js.map +1 -1
  14. package/dist/Helper/KeyCode.js +2 -6
  15. package/dist/Helper/KeyCode.js.map +1 -1
  16. package/dist/Helper/Location.js +41 -43
  17. package/dist/Helper/Location.js.map +1 -1
  18. package/dist/Helper/Log.js +21 -25
  19. package/dist/Helper/Log.js.map +1 -1
  20. package/dist/Helper/Mixin.js +26 -24
  21. package/dist/Helper/Mixin.js.map +1 -1
  22. package/dist/Helper/Object.js +81 -86
  23. package/dist/Helper/Object.js.map +1 -1
  24. package/dist/Helper/Pointer.js +2 -6
  25. package/dist/Helper/Pointer.js.map +1 -1
  26. package/dist/Helper/Queue.js +72 -74
  27. package/dist/Helper/Queue.js.map +1 -1
  28. package/dist/Helper/String.js +250 -200
  29. package/dist/Helper/String.js.map +1 -1
  30. package/dist/Helper/Time.js +4 -8
  31. package/dist/Helper/Time.js.map +1 -1
  32. package/dist/Helper/Url.js +14 -18
  33. package/dist/Helper/Url.js.map +1 -1
  34. package/dist/Helper/Variables.js +9 -13
  35. package/dist/Helper/Variables.js.map +1 -1
  36. package/package.json +4 -11
  37. package/dist/Common/AsyncConstructor.cjs +0 -49
  38. package/dist/Common/AsyncConstructor.cjs.map +0 -1
  39. package/dist/Common/AsyncConstructor.d.cts +0 -13
  40. package/dist/Common/AsyncConstructor.d.ts +0 -13
  41. package/dist/Helper/Array.cjs +0 -33
  42. package/dist/Helper/Array.cjs.map +0 -1
  43. package/dist/Helper/Array.d.cts +0 -11
  44. package/dist/Helper/Array.d.ts +0 -11
  45. package/dist/Helper/Bytes.cjs +0 -17
  46. package/dist/Helper/Bytes.cjs.map +0 -1
  47. package/dist/Helper/Bytes.d.cts +0 -3
  48. package/dist/Helper/Bytes.d.ts +0 -3
  49. package/dist/Helper/Dom.cjs +0 -83
  50. package/dist/Helper/Dom.cjs.map +0 -1
  51. package/dist/Helper/Dom.d.cts +0 -32
  52. package/dist/Helper/Dom.d.ts +0 -32
  53. package/dist/Helper/Event.cjs +0 -35
  54. package/dist/Helper/Event.cjs.map +0 -1
  55. package/dist/Helper/Event.d.cts +0 -31
  56. package/dist/Helper/Event.d.ts +0 -31
  57. package/dist/Helper/Function.cjs +0 -10
  58. package/dist/Helper/Function.cjs.map +0 -1
  59. package/dist/Helper/Function.d.cts +0 -3
  60. package/dist/Helper/Function.d.ts +0 -3
  61. package/dist/Helper/KeyCode.cjs +0 -10
  62. package/dist/Helper/KeyCode.cjs.map +0 -1
  63. package/dist/Helper/KeyCode.d.cts +0 -6
  64. package/dist/Helper/KeyCode.d.ts +0 -6
  65. package/dist/Helper/Location.cjs +0 -57
  66. package/dist/Helper/Location.cjs.map +0 -1
  67. package/dist/Helper/Location.d.cts +0 -9
  68. package/dist/Helper/Location.d.ts +0 -9
  69. package/dist/Helper/Log.cjs +0 -37
  70. package/dist/Helper/Log.cjs.map +0 -1
  71. package/dist/Helper/Log.d.cts +0 -19
  72. package/dist/Helper/Log.d.ts +0 -19
  73. package/dist/Helper/Mixin.cjs +0 -29
  74. package/dist/Helper/Mixin.cjs.map +0 -1
  75. package/dist/Helper/Mixin.d.cts +0 -8
  76. package/dist/Helper/Mixin.d.ts +0 -8
  77. package/dist/Helper/Object.cjs +0 -103
  78. package/dist/Helper/Object.cjs.map +0 -1
  79. package/dist/Helper/Object.d.cts +0 -14
  80. package/dist/Helper/Object.d.ts +0 -14
  81. package/dist/Helper/Pointer.cjs +0 -10
  82. package/dist/Helper/Pointer.cjs.map +0 -1
  83. package/dist/Helper/Pointer.d.cts +0 -5
  84. package/dist/Helper/Pointer.d.ts +0 -5
  85. package/dist/Helper/Queue.cjs +0 -84
  86. package/dist/Helper/Queue.cjs.map +0 -1
  87. package/dist/Helper/Queue.d.cts +0 -35
  88. package/dist/Helper/Queue.d.ts +0 -35
  89. package/dist/Helper/String.cjs +0 -253
  90. package/dist/Helper/String.cjs.map +0 -1
  91. package/dist/Helper/String.d.cts +0 -50
  92. package/dist/Helper/String.d.ts +0 -50
  93. package/dist/Helper/Time.cjs +0 -12
  94. package/dist/Helper/Time.cjs.map +0 -1
  95. package/dist/Helper/Time.d.cts +0 -3
  96. package/dist/Helper/Time.d.ts +0 -3
  97. package/dist/Helper/Url.cjs +0 -24
  98. package/dist/Helper/Url.cjs.map +0 -1
  99. package/dist/Helper/Url.d.cts +0 -4
  100. package/dist/Helper/Url.d.ts +0 -4
  101. package/dist/Helper/Variables.cjs +0 -20
  102. package/dist/Helper/Variables.cjs.map +0 -1
  103. package/dist/Helper/Variables.d.cts +0 -12
  104. package/dist/Helper/Variables.d.ts +0 -12
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Helper/Location.ts"],"names":[],"mappings":";AAAA,IAAI,kBAAA,GAA6C,IAAA;AAE1C,SAAS,mBAAA,GAAuC;AACrD,EAAA,kBAAA,GAAqB,IAAI,eAAA,CAAgB,MAAA,CAAO,SAAS,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA;AACtE,EAAA,OAAO,kBAAA;AACT;AAEO,SAAS,oBAAA,CAAqB,IAAA,EAAc,YAAA,GAAe,EAAA,EAAY;AAC5E,EAAA,MAAM,SAAS,mBAAA,EAAoB;AACnC,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,GAAA,CAAI,IAAI,CAAA;AAC7B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AM,eAAA,GAAkB,IAAI,MAAA,CAAO,CAAA,EAAA,EAAK,QAAQ,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAG,CAAA;AAE5D,EAAA,IAAI,eAAA,CAAgB,IAAA,CAAK,WAAW,CAAA,EAAG;AACrC,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,cAAc,MAAA,CAAO,QAAA;AAEzB,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,GAAG,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AAChD,IAAA,IAAI,SAAS,UAAA,EAAY;AACvB,MAAA;AAAA,IACF;AACA,IAAA,IAAI,YAAA,CAAa,UAAA,CAAW,IAAA,CAAK,WAAA,EAAa,CAAA,EAAG;AAC/C,MAAA,WAAA,GAAc,GAAA;AACd,MAAA;AAAA,IACF;AAAA,EACF;AAEA,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAChD,EAAA,MAAA,CAAO,QAAA,CAAS,IAAA,GAAO,CAAA,EAAG,WAAW,GAAG,UAAU,CAAA,CAAA;AACpD","file":"Location.js","sourcesContent":["let locationParamsHash: URLSearchParams | null = null;\n\nexport function locationParamReload(): URLSearchParams {\n locationParamsHash = new URLSearchParams(window.location.hash.slice(1));\n return locationParamsHash;\n}\n\nexport function locationHashParamGet(name: string, defaultValue = ''): string {\n const params = locationParamReload();\n const value = params.get(name);\n return value !== null ? value : defaultValue;\n}\n\nexport function locationHashParamSet(name: string, value: string, ignoreHistory = false): void {\n const params = locationParamReload();\n params.set(name, value);\n\n const { pathname, search } = window.location;\n locationUpdate(`${pathname}${search}#${params.toString()}`, ignoreHistory);\n}\n\nexport function locationUpdate(href: string, ignoreHistory = false): void {\n let nextHref = href;\n\n if (nextHref.endsWith('#')) {\n nextHref = nextHref.slice(0, -1);\n }\n\n const method: 'pushState' | 'replaceState' = ignoreHistory ? 'replaceState' : 'pushState';\n window.history[method]({ manualState: true }, document.title, nextHref);\n}\n\nexport function locationDetectLanguageAndRedirect(\n config: Record<string, string> & { _default: string }\n): void {\n const userLanguage = (\n navigator.language ||\n (navigator as unknown as { userLanguage?: string })?.userLanguage ||\n ''\n ).toLowerCase();\n const currentPath = window.location.pathname;\n\n const redirectUrls = Object.values(config);\n const escaped = redirectUrls.map((url) => url.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'));\n const redirectPattern = new RegExp(`^(${escaped.join('|')})`);\n\n if (redirectPattern.test(currentPath)) {\n return;\n }\n\n let redirectUrl = config._default;\n\n for (const [lang, url] of Object.entries(config)) {\n if (lang === '_default') {\n continue;\n }\n if (userLanguage.startsWith(lang.toLowerCase())) {\n redirectUrl = url;\n break;\n }\n }\n\n const restOfPath = currentPath.replace(/^\\//, '');\n window.location.href = `${redirectUrl}${restOfPath}`;\n}\n"]}
1
+ {"version":3,"file":"Location.js","sourceRoot":"","sources":["../../src/Helper/Location.ts"],"names":[],"mappings":"AAAA,IAAI,kBAAkB,GAA2B,IAAI,CAAC;AAEtD,MAAM,UAAU,mBAAmB;IACjC,kBAAkB,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,YAAY,GAAG,EAAE;IAClE,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;IACrC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,KAAa,EAAE,aAAa,GAAG,KAAK;IACrF,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;IACrC,MAAM,CAAC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AG,CAAC,CAAC;IAE9D,IAAI,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QACtC,OAAO;IACT,CAAC;IAED,IAAI,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC;IAElC,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QACD,IAAI,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YAChD,WAAW,GAAG,GAAG,CAAC;YAClB,MAAM;QACR,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAClD,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,WAAW,GAAG,UAAU,EAAE,CAAC;AACvD,CAAC"}
@@ -1,31 +1,27 @@
1
- // src/Helper/Log.ts
2
- var COLORS = {
3
- blue: "34",
4
- cyan: "36",
5
- gray: "90",
6
- green: "32",
7
- magenta: "35",
8
- yellow: "33",
9
- red: "31"
1
+ export const COLORS = {
2
+ blue: '34',
3
+ cyan: '36',
4
+ gray: '90',
5
+ green: '32',
6
+ magenta: '35',
7
+ yellow: '33',
8
+ red: '31',
10
9
  };
11
- function logColor(text, colorCode = COLORS.gray) {
12
- const resolved = typeof colorCode === "string" && colorCode in COLORS ? COLORS[colorCode] : colorCode || COLORS.gray;
13
- return `\x1B[${resolved}m${text}\x1B[0m`;
10
+ export function logColor(text, colorCode = COLORS.gray) {
11
+ const resolved = typeof colorCode === 'string' && colorCode in COLORS
12
+ ? COLORS[colorCode]
13
+ : colorCode || COLORS.gray;
14
+ return `\x1b[${resolved}m${text}\x1b[0m`;
14
15
  }
15
- function logTitle(title, colorCode = COLORS.cyan) {
16
- console.log("");
17
- console.log(logColor(`# ${String(title).toUpperCase()}`, colorCode));
16
+ export function logTitle(title, colorCode = COLORS.cyan) {
17
+ console.log('');
18
+ console.log(logColor(`# ${String(title).toUpperCase()}`, colorCode));
18
19
  }
19
- function logPath(label, value, labelColor = COLORS.gray, valueColor = COLORS.yellow) {
20
- console.log(`${logColor(label, labelColor)} ${logColor(value, valueColor)}`);
20
+ export function logPath(label, value, labelColor = COLORS.gray, valueColor = COLORS.yellow) {
21
+ console.log(`${logColor(label, labelColor)} ${logColor(value, valueColor)}`);
21
22
  }
22
- function logEntry(action, entry) {
23
- console.log(
24
- `${logColor("\u2022", COLORS.green)} ${logColor(action, COLORS.blue)} ${logColor(entry.output, COLORS.yellow)}`
25
- );
26
- console.log(` ${logColor("from", COLORS.gray)} ${logColor(entry.source, COLORS.gray)}`);
23
+ export function logEntry(action, entry) {
24
+ console.log(`${logColor('•', COLORS.green)} ${logColor(action, COLORS.blue)} ${logColor(entry.output, COLORS.yellow)}`);
25
+ console.log(` ${logColor('from', COLORS.gray)} ${logColor(entry.source, COLORS.gray)}`);
27
26
  }
28
-
29
- export { COLORS, logColor, logEntry, logPath, logTitle };
30
- //# sourceMappingURL=Log.js.map
31
27
  //# sourceMappingURL=Log.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Helper/Log.ts"],"names":[],"mappings":";AAAO,IAAM,MAAA,GAAS;AAAA,EACpB,IAAA,EAAM,IAAA;AAAA,EACN,IAAA,EAAM,IAAA;AAAA,EACN,IAAA,EAAM,IAAA;AAAA,EACN,KAAA,EAAO,IAAA;AAAA,EACP,OAAA,EAAS,IAAA;AAAA,EACT,MAAA,EAAQ,IAAA;AAAA,EACR,GAAA,EAAK;AACP;AAIO,SAAS,QAAA,CAAS,IAAA,EAAc,SAAA,GAAwB,MAAA,CAAO,IAAA,EAAc;AAClF,EAAA,MAAM,QAAA,GACJ,OAAO,SAAA,KAAc,QAAA,IAAY,SAAA,IAAa,SAC1C,MAAA,CAAO,SAAgC,CAAA,GACvC,SAA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} as const;\n\ntype ColorValue = keyof typeof COLORS | string;\n\nexport function logColor(text: string, colorCode: ColorValue = COLORS.gray): string {\n const resolved =\n typeof colorCode === 'string' && colorCode in COLORS\n ? COLORS[colorCode as keyof typeof COLORS]\n : colorCode || COLORS.gray;\n\n return `\\x1b[${resolved}m${text}\\x1b[0m`;\n}\n\nexport function logTitle(title: string, colorCode: ColorValue = COLORS.cyan): void {\n console.log('');\n console.log(logColor(`# ${String(title).toUpperCase()}`, colorCode));\n}\n\nexport function logPath(\n label: string,\n value: string,\n labelColor: ColorValue = COLORS.gray,\n valueColor: ColorValue = COLORS.yellow\n): void {\n console.log(`${logColor(label, labelColor)} ${logColor(value, valueColor)}`);\n}\n\nexport function logEntry(action: string, entry: { output: string; source: string }): void {\n console.log(\n `${logColor('•', COLORS.green)} ${logColor(action, COLORS.blue)} ${logColor(entry.output, COLORS.yellow)}`\n );\n console.log(` ${logColor('from', COLORS.gray)} ${logColor(entry.source, COLORS.gray)}`);\n}\n"]}
1
+ {"version":3,"file":"Log.js","sourceRoot":"","sources":["../../src/Helper/Log.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,IAAI;IACZ,GAAG,EAAE,IAAI;CACD,CAAC;AAIX,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,YAAwB,MAAM,CAAC,IAAI;IACxE,MAAM,QAAQ,GACZ,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,IAAI,MAAM;QAClD,CAAC,CAAC,MAAM,CAAC,SAAgC,CAAC;QAC1C,CAAC,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC;IAE/B,OAAO,QAAQ,QAAQ,IAAI,IAAI,SAAS,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,YAAwB,MAAM,CAAC,IAAI;IACzE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,KAAa,EACb,KAAa,EACb,aAAyB,MAAM,CAAC,IAAI,EACpC,aAAyB,MAAM,CAAC,MAAM;IAEtC,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,KAAyC;IAChF,OAAO,CAAC,GAAG,CACT,GAAG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAC3G,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,OAAO,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7F,CAAC"}
@@ -1,27 +1,29 @@
1
- // src/Helper/Mixin.ts
2
- function mixinApply(targetCtor, mixins) {
3
- mixins.forEach((mixinCtor) => {
4
- Object.getOwnPropertyNames(mixinCtor.prototype).forEach((name) => {
5
- if (name === "constructor") {
6
- return;
7
- }
8
- const descriptor = Object.getOwnPropertyDescriptor(mixinCtor.prototype, name);
9
- if (descriptor) {
10
- Object.defineProperty(targetCtor.prototype, name, descriptor);
11
- }
1
+ /**
2
+ * Apply mixin classes to a target class (TypeScript-compatible).
3
+ * Copy prototype properties (except constructor) and static props.
4
+ */
5
+ export function mixinApply(targetCtor, mixins) {
6
+ mixins.forEach((mixinCtor) => {
7
+ // Copy instance members (prototype).
8
+ Object.getOwnPropertyNames(mixinCtor.prototype).forEach((name) => {
9
+ if (name === 'constructor') {
10
+ return;
11
+ }
12
+ const descriptor = Object.getOwnPropertyDescriptor(mixinCtor.prototype, name);
13
+ if (descriptor) {
14
+ Object.defineProperty(targetCtor.prototype, name, descriptor);
15
+ }
16
+ });
17
+ // Copy static members if any (excluding length/name/prototype).
18
+ Object.getOwnPropertyNames(mixinCtor).forEach((name) => {
19
+ if (['length', 'name', 'prototype'].includes(name)) {
20
+ return;
21
+ }
22
+ const descriptor = Object.getOwnPropertyDescriptor(mixinCtor, name);
23
+ if (descriptor) {
24
+ Object.defineProperty(targetCtor, name, descriptor);
25
+ }
26
+ });
12
27
  });
13
- Object.getOwnPropertyNames(mixinCtor).forEach((name) => {
14
- if (["length", "name", "prototype"].includes(name)) {
15
- return;
16
- }
17
- const descriptor = Object.getOwnPropertyDescriptor(mixinCtor, name);
18
- if (descriptor) {
19
- Object.defineProperty(targetCtor, name, descriptor);
20
- }
21
- });
22
- });
23
28
  }
24
-
25
- export { mixinApply };
26
- //# sourceMappingURL=Mixin.js.map
27
29
  //# sourceMappingURL=Mixin.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Helper/Mixin.ts"],"names":[],"mappings":";AAMO,SAAS,UAAA,CAAW,YAAyB,MAAA,EAA6B;AAC/E,EAAA,MAAA,CAAO,OAAA,CAAQ,CAAC,SAAA,KAAc;AAE5B,IAAA,MAAA,CAAO,oBAAoB,SAAA,CAAU,SAAS,CAAA,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS;AAChE,MAAA,IAAI,SAAS,aAAA,EAAe;AAC1B,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,UAAA,GAAa,MAAA,CAAO,wBAAA,CAAyB,SAAA,CAAU,WAAW,IAAI,CAAA;AAC5E,MAAA,IAAI,UAAA,EAAY;AACd,QAAA,MAAA,CAAO,cAAA,CAAe,UAAA,CAAW,SAAA,EAAW,IAAA,EAAM,UAAU,CAAA;AAAA,MAC9D;AAAA,IACF,CAAC,CAAA;AAGD,IAAA,MAAA,CAAO,mBAAA,CAAoB,SAAS,CAAA,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS;AACtD,MAAA,IAAI,CAAC,QAAA,EAAU,MAAA,EAAQ,WAAW,CAAA,CAAE,QAAA,CAAS,IAAI,CAAA,EAAG;AAClD,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,UAAA,GAAa,MAAA,CAAO,wBAAA,CAAyB,SAAA,EAAW,IAAI,CAAA;AAClE,MAAA,IAAI,UAAA,EAAY;AACd,QAAA,MAAA,CAAO,cAAA,CAAe,UAAA,EAAY,IAAA,EAAM,UAAU,CAAA;AAAA,MACpD;AAAA,IACF,CAAC,CAAA;AAAA,EACH,CAAC,CAAA;AACH","file":"Mixin.js","sourcesContent":["type Constructor<T = any> = abstract new (...args: any[]) => T;\n\n/**\n * Apply mixin classes to a target class (TypeScript-compatible).\n * Copy prototype properties (except constructor) and static props.\n */\nexport function mixinApply(targetCtor: Constructor, mixins: Constructor[]): void {\n mixins.forEach((mixinCtor) => {\n // Copy instance members (prototype).\n Object.getOwnPropertyNames(mixinCtor.prototype).forEach((name) => {\n if (name === 'constructor') {\n return;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(mixinCtor.prototype, name);\n if (descriptor) {\n Object.defineProperty(targetCtor.prototype, name, descriptor);\n }\n });\n\n // Copy static members if any (excluding length/name/prototype).\n Object.getOwnPropertyNames(mixinCtor).forEach((name) => {\n if (['length', 'name', 'prototype'].includes(name)) {\n return;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(mixinCtor, name);\n if (descriptor) {\n Object.defineProperty(targetCtor, name, descriptor);\n }\n });\n });\n}\n"]}
1
+ {"version":3,"file":"Mixin.js","sourceRoot":"","sources":["../../src/Helper/Mixin.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,UAAuB,EAAE,MAAqB;IACvE,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3B,qCAAqC;QACrC,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC/D,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;gBAC3B,OAAO;YACT,CAAC;YAED,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC9E,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;YAChE,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,gEAAgE;QAChE,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrD,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnD,OAAO;YACT,CAAC;YAED,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACpE,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,95 +1,90 @@
1
- // src/Helper/Object.ts
2
- function objectMergeDeep(target = {}, source = {}) {
3
- const output = { ...target };
4
- Object.entries(source || {}).forEach(([key, value]) => {
5
- if (value && typeof value === "object" && !Array.isArray(value)) {
6
- output[key] = objectMergeDeep(
7
- typeof output[key] === "object" && output[key] !== null ? output[key] : {},
8
- value
9
- );
10
- } else {
11
- output[key] = value;
12
- }
13
- });
14
- return output;
15
- }
16
- function objectToType(value) {
17
- return {}.toString.call(value).match(/([a-z]+)(:?\])/i)?.[1] ?? typeof value;
18
- }
19
- function objectIsPlainObject(value) {
20
- return objectToType(value) === "Object";
21
- }
22
- function objectDeepAssignWithOptions(options) {
23
- const mergedOptions = {
24
- nonEnum: true,
25
- symbols: true,
26
- descriptors: true,
27
- proto: true,
28
- ...options
29
- };
30
- return (target, ...sources) => {
31
- sources.forEach((source) => {
32
- if (!objectIsPlainObject(source) || !objectIsPlainObject(target)) return;
33
- const copyProperty = (property) => {
34
- const descriptor = Object.getOwnPropertyDescriptor(source, property);
35
- if (!descriptor) return;
36
- if (descriptor.enumerable || mergedOptions.nonEnum) {
37
- if (objectIsPlainObject(source[property]) && objectIsPlainObject(target[property])) {
38
- descriptor.value = objectDeepAssignWithOptions(mergedOptions)(
39
- target[property],
40
- source[property]
41
- );
42
- }
43
- if (mergedOptions.descriptors) {
44
- Object.defineProperty(target, property, descriptor);
45
- } else {
46
- target[property] = descriptor.value;
47
- }
1
+ export function objectMergeDeep(target = {}, source = {}) {
2
+ const output = { ...target };
3
+ Object.entries(source || {}).forEach(([key, value]) => {
4
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
5
+ output[key] = objectMergeDeep(typeof output[key] === 'object' && output[key] !== null ? output[key] : {}, value);
48
6
  }
49
- };
50
- Object.getOwnPropertyNames(source).forEach(copyProperty);
51
- if (mergedOptions.symbols) {
52
- Object.getOwnPropertySymbols(source).forEach(copyProperty);
53
- }
54
- if (mergedOptions.proto) {
55
- const targetProto = Object.getPrototypeOf(target);
56
- const sourceProto = Object.getPrototypeOf(source);
57
- if (targetProto && sourceProto) {
58
- objectDeepAssignWithOptions({ ...mergedOptions, proto: false })(targetProto, sourceProto);
7
+ else {
8
+ output[key] = value;
59
9
  }
60
- }
61
10
  });
62
- return target;
63
- };
11
+ return output;
12
+ }
13
+ export function objectToType(value) {
14
+ return {}.toString.call(value).match(/([a-z]+)(:?\])/i)?.[1] ?? typeof value;
64
15
  }
65
- function objectDeepAssign(...args) {
66
- return objectDeepAssignWithOptions({
67
- nonEnum: true,
68
- symbols: true,
69
- descriptors: true,
70
- proto: true
71
- }).apply(void 0, args);
16
+ export function objectIsPlainObject(value) {
17
+ return objectToType(value) === 'Object';
72
18
  }
73
- function objectCallPrototypeMethodIfExists(self, methodName, args = []) {
74
- const method = Object.getPrototypeOf(self)?.[methodName];
75
- if (typeof method === "function") {
76
- return method.apply(self, args);
77
- }
78
- return void 0;
19
+ export function objectDeepAssignWithOptions(options) {
20
+ const mergedOptions = {
21
+ nonEnum: true,
22
+ symbols: true,
23
+ descriptors: true,
24
+ proto: true,
25
+ ...options,
26
+ };
27
+ return (target, ...sources) => {
28
+ sources.forEach((source) => {
29
+ if (!objectIsPlainObject(source) || !objectIsPlainObject(target))
30
+ return;
31
+ const copyProperty = (property) => {
32
+ const descriptor = Object.getOwnPropertyDescriptor(source, property);
33
+ if (!descriptor)
34
+ return;
35
+ if (descriptor.enumerable || mergedOptions.nonEnum) {
36
+ if (objectIsPlainObject(source[property]) && objectIsPlainObject(target[property])) {
37
+ descriptor.value = objectDeepAssignWithOptions(mergedOptions)(target[property], source[property]);
38
+ }
39
+ if (mergedOptions.descriptors) {
40
+ Object.defineProperty(target, property, descriptor);
41
+ }
42
+ else {
43
+ target[property] = descriptor.value;
44
+ }
45
+ }
46
+ };
47
+ Object.getOwnPropertyNames(source).forEach(copyProperty);
48
+ if (mergedOptions.symbols) {
49
+ Object.getOwnPropertySymbols(source).forEach(copyProperty);
50
+ }
51
+ if (mergedOptions.proto) {
52
+ const targetProto = Object.getPrototypeOf(target);
53
+ const sourceProto = Object.getPrototypeOf(source);
54
+ if (targetProto && sourceProto) {
55
+ objectDeepAssignWithOptions({ ...mergedOptions, proto: false })(targetProto, sourceProto);
56
+ }
57
+ }
58
+ });
59
+ return target;
60
+ };
79
61
  }
80
- function objectGetItemByPath(data, key, defaultValue = null, separator = ".") {
81
- const keys = Array.isArray(key) ? key : key.split(separator);
82
- let cursor = data;
83
- for (const k of keys) {
84
- if (cursor !== null && typeof cursor === "object" && k in cursor) {
85
- cursor = cursor[k];
86
- } else {
87
- return defaultValue;
62
+ export function objectDeepAssign(...args) {
63
+ return objectDeepAssignWithOptions({
64
+ nonEnum: true,
65
+ symbols: true,
66
+ descriptors: true,
67
+ proto: true,
68
+ }).apply(undefined, args);
69
+ }
70
+ export function objectCallPrototypeMethodIfExists(self, methodName, args = []) {
71
+ const method = Object.getPrototypeOf(self)?.[methodName];
72
+ if (typeof method === 'function') {
73
+ return method.apply(self, args);
74
+ }
75
+ return undefined;
76
+ }
77
+ export function objectGetItemByPath(data, key, defaultValue = null, separator = '.') {
78
+ const keys = Array.isArray(key) ? key : key.split(separator);
79
+ let cursor = data;
80
+ for (const k of keys) {
81
+ if (cursor !== null && typeof cursor === 'object' && k in cursor) {
82
+ cursor = cursor[k];
83
+ }
84
+ else {
85
+ return defaultValue;
86
+ }
88
87
  }
89
- }
90
- return cursor;
88
+ return cursor;
91
89
  }
92
-
93
- export { objectCallPrototypeMethodIfExists, objectDeepAssign, objectDeepAssignWithOptions, objectGetItemByPath, objectIsPlainObject, objectMergeDeep, objectToType };
94
- //# sourceMappingURL=Object.js.map
95
90
  //# sourceMappingURL=Object.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Helper/Object.ts"],"names":[],"mappings":";AAAO,SAAS,gBACd,MAAA,GAAY,EAAC,EACb,MAAA,GAAY,EAAC,EACN;AACP,EAAA,MAAM,MAAA,GAA8B,EAAE,GAAG,MAAA,EAAO;AAEhD,EAAA,MAAA,CAAO,OAAA,CAAQ,MAAA,IAAU,EAAE,CAAA,CAAE,QAAQ,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AACrD,IAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,I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AA,EAAS,IAAA;AAAA,IACT,OAAA,EAAS,IAAA;AAAA,IACT,WAAA,EAAa,IAAA;AAAA,IACb,KAAA,EAAO;AAAA,GACR,CAAA,CAAE,KAAA,CAAM,MAAA,EAAW,IAAuB,CAAA;AAC7C;AAEO,SAAS,iCAAA,CACd,IAAA,EACA,UAAA,EACA,IAAA,GAAkB,EAAC,EACJ;AACf,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,cAAA,CAAe,IAAI,IAAI,UAAU,CAAA;AACvD,EAAA,IAAI,OAAO,WAAW,UAAA,EAAY;AAChC,IAAA,OAAO,MAAA,CAAO,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAAA,EAChC;AACA,EAAA,OAAO,MAAA;AACT;AAEO,SAAS,oBACd,IAAA,EACA,GAAA,EACA,YAAA,GAAoB,IAAA,EACpB,YAAY,GAAA,EACP;AACL,EAAA,MAAM,IAAA,GAAO,MAAM,OAAA,CAAQ,GAAG,IAAI,GAAA,GAAM,GAAA,CAAI,MAAM,SAAS,CAAA;AAC3D,EAAA,IAAI,MAAA,GAAc,IAAA;AAElB,EAAA,KAAA,MAAW,KAAK,IAAA,EAAM;AACpB,IAAA,IAAI,WAAW,IAAA,IAAQ,OAAO,MAAA,KAAW,QAAA,IAAY,KAAK,MAAA,EAAQ;AAChE,MAAA,MAAA,GAAS,OAAO,CAAC,CAAA;AAAA,IACnB,CAAA,MAAO;AACL,MAAA,OAAO,YAAA;AAAA,IACT;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"Object.js","sourcesContent":["export function objectMergeDeep<T extends Record<string, any>, U extends Record<string, any>>(\n target: T = {} as T,\n source: U = {} as U\n): T & U {\n const output: Record<string, any> = { ...target };\n\n Object.entries(source || {}).forEach(([key, value]) => {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n output[key] = objectMergeDeep(\n typeof output[key] === 'object' && output[key] !== null ? output[key] : {},\n value as Record<string, any>\n );\n } else {\n output[key] = value;\n }\n });\n\n return output as T & U;\n}\n\nexport function objectToType(value: unknown): string {\n return {}.toString.call(value).match(/([a-z]+)(:?\\])/i)?.[1] ?? typeof value;\n}\n\nexport function objectIsPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\n return objectToType(value) === 'Object';\n}\n\nexport function objectDeepAssignWithOptions(options: {\n nonEnum?: boolean;\n symbols?: boolean;\n descriptors?: boolean;\n proto?: boolean;\n}) {\n const mergedOptions = {\n nonEnum: true,\n symbols: true,\n descriptors: true,\n proto: true,\n ...options,\n };\n\n return (target: any, ...sources: any[]) => {\n sources.forEach((source) => {\n if (!objectIsPlainObject(source) || !objectIsPlainObject(target)) return;\n\n const copyProperty = (property: string | symbol) => {\n const descriptor = Object.getOwnPropertyDescriptor(source, property);\n if (!descriptor) return;\n\n if (descriptor.enumerable || mergedOptions.nonEnum) {\n if (objectIsPlainObject(source[property]) && objectIsPlainObject(target[property])) {\n descriptor.value = objectDeepAssignWithOptions(mergedOptions)(\n target[property],\n source[property]\n );\n }\n\n if (mergedOptions.descriptors) {\n Object.defineProperty(target, property, descriptor);\n } else {\n target[property] = descriptor.value;\n }\n }\n };\n\n Object.getOwnPropertyNames(source).forEach(copyProperty);\n\n if (mergedOptions.symbols) {\n Object.getOwnPropertySymbols(source).forEach(copyProperty);\n }\n\n if (mergedOptions.proto) {\n const targetProto = Object.getPrototypeOf(target);\n const sourceProto = Object.getPrototypeOf(source);\n if (targetProto && sourceProto) {\n objectDeepAssignWithOptions({ ...mergedOptions, proto: false })(targetProto, sourceProto);\n }\n }\n });\n return target;\n };\n}\n\nexport function objectDeepAssign(...args: any[]): any {\n return objectDeepAssignWithOptions({\n nonEnum: true,\n symbols: true,\n descriptors: true,\n proto: true,\n }).apply(undefined, args as [any, ...any[]]);\n}\n\nexport function objectCallPrototypeMethodIfExists<T extends object, R>(\n self: T,\n methodName: string,\n args: unknown[] = []\n): R | undefined {\n const method = Object.getPrototypeOf(self)?.[methodName];\n if (typeof method === 'function') {\n return method.apply(self, args);\n }\n return undefined;\n}\n\nexport function objectGetItemByPath(\n data: any,\n key: string | string[],\n defaultValue: any = null,\n separator = '.'\n): any {\n const keys = Array.isArray(key) ? key : key.split(separator);\n let cursor: any = data;\n\n for (const k of keys) {\n if (cursor !== null && typeof cursor === 'object' && k in cursor) {\n cursor = cursor[k];\n } else {\n return defaultValue;\n }\n }\n\n return cursor;\n}\n"]}
1
+ {"version":3,"file":"Object.js","sourceRoot":"","sources":["../../src/Helper/Object.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAC7B,SAAY,EAAO,EACnB,SAAY,EAAO;IAEnB,MAAM,MAAM,GAAwB,EAAE,GAAG,MAAM,EAAE,CAAC;IAElD,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACpD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChE,MAAM,CAAC,GAAG,CAAC,GAAG,eAAe,CAC3B,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAC1E,KAA4B,CAC7B,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAe,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,KAAK,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,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,mBAAmB,CACjC,IAAS,EACT,GAAsB,EACtB,eAAoB,IAAI,EACxB,SAAS,GAAG,GAAG;IAEf,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7D,IAAI,MAAM,GAAQ,IAAI,CAAC;IAEvB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC;YACjE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,OAAO,YAAY,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,8 +1,4 @@
1
- // src/Helper/Pointer.ts
2
- var POINTER = {
3
- CLICK_DURATION: 500
1
+ export const POINTER = {
2
+ CLICK_DURATION: 500,
4
3
  };
5
-
6
- export { POINTER };
7
- //# sourceMappingURL=Pointer.js.map
8
4
  //# sourceMappingURL=Pointer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Helper/Pointer.ts"],"names":[],"mappings":";AAAO,IAAM,OAAA,GAAU;AAAA,EACrB,cAAA,EAAgB;AAClB","file":"Pointer.js","sourcesContent":["export const POINTER = {\n CLICK_DURATION: 500,\n} as const;\n"]}
1
+ {"version":3,"file":"Pointer.js","sourceRoot":"","sources":["../../src/Helper/Pointer.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,cAAc,EAAE,GAAG;CACX,CAAC"}
@@ -1,82 +1,80 @@
1
- // src/Helper/Queue.ts
2
- var Queue = class {
3
- constructor(options) {
4
- this.queue = [];
5
- this.activeCount = 0;
6
- this.paused = false;
7
- this.worker = options.worker;
8
- this.concurrency = Math.max(1, options.concurrency ?? 1);
9
- this.autoStart = options.autoStart ?? true;
10
- this.callbacks = {
11
- onItemStart: options.onItemStart,
12
- onItemSuccess: options.onItemSuccess,
13
- onItemError: options.onItemError,
14
- onItemDone: options.onItemDone,
15
- onDrain: options.onDrain
16
- };
17
- }
18
- enqueue(item) {
19
- this.queue.push(item);
20
- if (this.autoStart) {
21
- this.pump();
1
+ export default class Queue {
2
+ constructor(options) {
3
+ this.queue = [];
4
+ this.activeCount = 0;
5
+ this.paused = false;
6
+ this.worker = options.worker;
7
+ this.concurrency = Math.max(1, options.concurrency ?? 1);
8
+ this.autoStart = options.autoStart ?? true;
9
+ this.callbacks = {
10
+ onItemStart: options.onItemStart,
11
+ onItemSuccess: options.onItemSuccess,
12
+ onItemError: options.onItemError,
13
+ onItemDone: options.onItemDone,
14
+ onDrain: options.onDrain,
15
+ };
22
16
  }
23
- }
24
- enqueueMany(items) {
25
- this.queue.push(...items);
26
- if (this.autoStart) {
27
- this.pump();
17
+ enqueue(item) {
18
+ this.queue.push(item);
19
+ if (this.autoStart) {
20
+ this.pump();
21
+ }
28
22
  }
29
- }
30
- pause() {
31
- this.paused = true;
32
- }
33
- resume() {
34
- if (!this.paused) {
35
- return;
23
+ enqueueMany(items) {
24
+ this.queue.push(...items);
25
+ if (this.autoStart) {
26
+ this.pump();
27
+ }
36
28
  }
37
- this.paused = false;
38
- this.pump();
39
- }
40
- clear() {
41
- this.queue = [];
42
- }
43
- size() {
44
- return this.queue.length;
45
- }
46
- active() {
47
- return this.activeCount;
48
- }
49
- isIdle() {
50
- return this.queue.length === 0 && this.activeCount === 0;
51
- }
52
- pump() {
53
- if (this.paused) {
54
- return;
29
+ pause() {
30
+ this.paused = true;
55
31
  }
56
- while (this.activeCount < this.concurrency && this.queue.length > 0) {
57
- const item = this.queue.shift();
58
- this.runItem(item);
32
+ resume() {
33
+ if (!this.paused) {
34
+ return;
35
+ }
36
+ this.paused = false;
37
+ this.pump();
59
38
  }
60
- if (this.isIdle()) {
61
- this.callbacks.onDrain?.();
39
+ clear() {
40
+ this.queue = [];
62
41
  }
63
- }
64
- async runItem(item) {
65
- this.activeCount += 1;
66
- this.callbacks.onItemStart?.(item);
67
- try {
68
- const result = await this.worker(item);
69
- this.callbacks.onItemSuccess?.(item, result);
70
- } catch (error) {
71
- this.callbacks.onItemError?.(item, error);
72
- } finally {
73
- this.callbacks.onItemDone?.(item);
74
- this.activeCount -= 1;
75
- this.pump();
42
+ size() {
43
+ return this.queue.length;
76
44
  }
77
- }
78
- };
79
-
80
- export { Queue as default };
81
- //# sourceMappingURL=Queue.js.map
45
+ active() {
46
+ return this.activeCount;
47
+ }
48
+ isIdle() {
49
+ return this.queue.length === 0 && this.activeCount === 0;
50
+ }
51
+ pump() {
52
+ if (this.paused) {
53
+ return;
54
+ }
55
+ while (this.activeCount < this.concurrency && this.queue.length > 0) {
56
+ const item = this.queue.shift();
57
+ this.runItem(item);
58
+ }
59
+ if (this.isIdle()) {
60
+ this.callbacks.onDrain?.();
61
+ }
62
+ }
63
+ async runItem(item) {
64
+ this.activeCount += 1;
65
+ this.callbacks.onItemStart?.(item);
66
+ try {
67
+ const result = await this.worker(item);
68
+ this.callbacks.onItemSuccess?.(item, result);
69
+ }
70
+ catch (error) {
71
+ this.callbacks.onItemError?.(item, error);
72
+ }
73
+ finally {
74
+ this.callbacks.onItemDone?.(item);
75
+ this.activeCount -= 1;
76
+ this.pump();
77
+ }
78
+ }
79
+ }
82
80
  //# sourceMappingURL=Queue.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Helper/Queue.ts"],"names":[],"mappings":";AAgBA,IAAqB,QAArB,MAAqD;AAAA,EASnD,YAAY,OAAA,EAAuC;AARnD,IAAA,IAAA,CAAQ,QAAiB,EAAC;AAC1B,IAAA,IAAA,CAAQ,WAAA,GAAc,CAAA;AACtB,IAAA,IAAA,CAAQ,MAAA,GAAS,KAAA;AAOf,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AACtB,I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AAA,EACd;AAAA,EAEA,MAAA,GAAkB;AAChB,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,MAAA,KAAW,CAAA,IAAK,KAAK,WAAA,KAAgB,CAAA;AAAA,EACzD;AAAA,EAEQ,IAAA,GAAa;AACnB,IAAA,IAAI,KAAK,MAAA,EAAQ;AACf,MAAA;AAAA,IACF;AAEA,IAAA,OAAO,KAAK,WAAA,GAAc,IAAA,CAAK,eAAe,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA,EAAG;AACnE,MAAA,MAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,KAAA,EAAM;AAC9B,MAAA,IAAA,CAAK,QAAQ,IAAI,CAAA;AAAA,IACnB;AAEA,IAAA,IAAI,IAAA,CAAK,QAAO,EAAG;AACjB,MAAA,IAAA,CAAK,UAAU,OAAA,IAAU;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,MAAc,QAAQ,IAAA,EAA4B;AAChD,IAAA,IAAA,CAAK,WAAA,IAAe,CAAA;AACpB,IAAA,IAAA,CAAK,SAAA,CAAU,cAAc,IAAI,CAAA;AAEjC,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,MAAA,CAAO,IAAI,CAAA;AACrC,MAAA,IAAA,CAAK,SAAA,CAAU,aAAA,GAAgB,IAAA,EAAM,MAAM,CAAA;AAAA,IAC7C,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,SAAA,CAAU,WAAA,GAAc,IAAA,EAAM,KAAK,CAAA;AAAA,IAC1C,CAAA,SAAE;AACA,MAAA,IAAA,CAAK,SAAA,CAAU,aAAa,IAAI,CAAA;AAChC,MAAA,IAAA,CAAK,WAAA,IAAe,CAAA;AACpB,MAAA,IAAA,CAAK,IAAA,EAAK;AAAA,IACZ;AAAA,EACF;AACF","file":"Queue.js","sourcesContent":["export type QueueWorker<TItem, TResult = unknown> = (item: TItem) => Promise<TResult> | TResult;\n\nexport type QueueCallbacks<TItem, TResult = unknown> = {\n onItemStart?: (item: TItem) => void;\n onItemSuccess?: (item: TItem, result: TResult) => void;\n onItemError?: (item: TItem, error: unknown) => void;\n onItemDone?: (item: TItem) => void;\n onDrain?: () => void;\n};\n\nexport type QueueOptions<TItem, TResult = unknown> = QueueCallbacks<TItem, TResult> & {\n worker: QueueWorker<TItem, TResult>;\n concurrency?: number;\n autoStart?: boolean;\n};\n\nexport default class Queue<TItem, TResult = unknown> {\n private queue: TItem[] = [];\n private activeCount = 0;\n private paused = false;\n private readonly worker: QueueWorker<TItem, TResult>;\n private readonly concurrency: number;\n private readonly autoStart: boolean;\n private readonly callbacks: QueueCallbacks<TItem, TResult>;\n\n constructor(options: QueueOptions<TItem, TResult>) {\n this.worker = options.worker;\n this.concurrency = Math.max(1, options.concurrency ?? 1);\n this.autoStart = options.autoStart ?? true;\n this.callbacks = {\n onItemStart: options.onItemStart,\n onItemSuccess: options.onItemSuccess,\n onItemError: options.onItemError,\n onItemDone: options.onItemDone,\n onDrain: options.onDrain,\n };\n }\n\n enqueue(item: TItem): void {\n this.queue.push(item);\n if (this.autoStart) {\n this.pump();\n }\n }\n\n enqueueMany(items: TItem[]): void {\n this.queue.push(...items);\n if (this.autoStart) {\n this.pump();\n }\n }\n\n pause(): void {\n this.paused = true;\n }\n\n resume(): void {\n if (!this.paused) {\n return;\n }\n\n this.paused = false;\n this.pump();\n }\n\n clear(): void {\n this.queue = [];\n }\n\n size(): number {\n return this.queue.length;\n }\n\n active(): number {\n return this.activeCount;\n }\n\n isIdle(): boolean {\n return this.queue.length === 0 && this.activeCount === 0;\n }\n\n private pump(): void {\n if (this.paused) {\n return;\n }\n\n while (this.activeCount < this.concurrency && this.queue.length > 0) {\n const item = this.queue.shift() as TItem;\n this.runItem(item);\n }\n\n if (this.isIdle()) {\n this.callbacks.onDrain?.();\n }\n }\n\n private async runItem(item: TItem): Promise<void> {\n this.activeCount += 1;\n this.callbacks.onItemStart?.(item);\n\n try {\n const result = await this.worker(item);\n this.callbacks.onItemSuccess?.(item, result);\n } catch (error) {\n this.callbacks.onItemError?.(item, error);\n } finally {\n this.callbacks.onItemDone?.(item);\n this.activeCount -= 1;\n this.pump();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Queue.js","sourceRoot":"","sources":["../../src/Helper/Queue.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,OAAO,OAAO,KAAK;IASxB,YAAY,OAAqC;QARzC,UAAK,GAAY,EAAE,CAAC;QACpB,gBAAW,GAAG,CAAC,CAAC;QAChB,WAAM,GAAG,KAAK,CAAC;QAOrB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG;YACf,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAW;QACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IAED,WAAW,CAAC,KAAc;QACxB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,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