@mlightcad/common 1.0.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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/dist/common.js +1226 -0
  3. package/dist/common.umd.cjs +1 -0
  4. package/lib/AcCmColor.d.ts +42 -0
  5. package/lib/AcCmColor.d.ts.map +1 -0
  6. package/lib/AcCmColor.js +456 -0
  7. package/lib/AcCmColor.js.map +1 -0
  8. package/lib/AcCmColorUtil.d.ts +9 -0
  9. package/lib/AcCmColorUtil.d.ts.map +1 -0
  10. package/lib/AcCmColorUtil.js +54 -0
  11. package/lib/AcCmColorUtil.js.map +1 -0
  12. package/lib/AcCmErrors.d.ts +23 -0
  13. package/lib/AcCmErrors.d.ts.map +1 -0
  14. package/lib/AcCmErrors.js +37 -0
  15. package/lib/AcCmErrors.js.map +1 -0
  16. package/lib/AcCmEventDispatcher.d.ts +48 -0
  17. package/lib/AcCmEventDispatcher.d.ts.map +1 -0
  18. package/lib/AcCmEventDispatcher.js +60 -0
  19. package/lib/AcCmEventDispatcher.js.map +1 -0
  20. package/lib/AcCmEventManager.d.ts +27 -0
  21. package/lib/AcCmEventManager.d.ts.map +1 -0
  22. package/lib/AcCmEventManager.js +94 -0
  23. package/lib/AcCmEventManager.js.map +1 -0
  24. package/lib/AcCmLogUtil.d.ts +31 -0
  25. package/lib/AcCmLogUtil.d.ts.map +1 -0
  26. package/lib/AcCmLogUtil.js +23 -0
  27. package/lib/AcCmLogUtil.js.map +1 -0
  28. package/lib/AcCmObject.d.ts +96 -0
  29. package/lib/AcCmObject.d.ts.map +1 -0
  30. package/lib/AcCmObject.js +175 -0
  31. package/lib/AcCmObject.js.map +1 -0
  32. package/lib/AcCmPerformanceCollector.d.ts +68 -0
  33. package/lib/AcCmPerformanceCollector.d.ts.map +1 -0
  34. package/lib/AcCmPerformanceCollector.js +110 -0
  35. package/lib/AcCmPerformanceCollector.js.map +1 -0
  36. package/lib/AcCmStringUtil.d.ts +11 -0
  37. package/lib/AcCmStringUtil.d.ts.map +1 -0
  38. package/lib/AcCmStringUtil.js +25 -0
  39. package/lib/AcCmStringUtil.js.map +1 -0
  40. package/lib/AcCmTaskScheduler.d.ts +70 -0
  41. package/lib/AcCmTaskScheduler.d.ts.map +1 -0
  42. package/lib/AcCmTaskScheduler.js +173 -0
  43. package/lib/AcCmTaskScheduler.js.map +1 -0
  44. package/lib/index.d.ts +11 -0
  45. package/lib/index.d.ts.map +1 -0
  46. package/lib/index.js +11 -0
  47. package/lib/index.js.map +1 -0
  48. package/lib/loader/AcCmFileLoader.d.ts +58 -0
  49. package/lib/loader/AcCmFileLoader.d.ts.map +1 -0
  50. package/lib/loader/AcCmFileLoader.js +225 -0
  51. package/lib/loader/AcCmFileLoader.js.map +1 -0
  52. package/lib/loader/AcCmLoader.d.ts +92 -0
  53. package/lib/loader/AcCmLoader.d.ts.map +1 -0
  54. package/lib/loader/AcCmLoader.js +88 -0
  55. package/lib/loader/AcCmLoader.js.map +1 -0
  56. package/lib/loader/AcCmLoadingManager.d.ts +119 -0
  57. package/lib/loader/AcCmLoadingManager.d.ts.map +1 -0
  58. package/lib/loader/AcCmLoadingManager.js +133 -0
  59. package/lib/loader/AcCmLoadingManager.js.map +1 -0
  60. package/lib/loader/index.d.ts +3 -0
  61. package/lib/loader/index.d.ts.map +1 -0
  62. package/lib/loader/index.js +3 -0
  63. package/lib/loader/index.js.map +1 -0
  64. package/package.json +44 -0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * A performance entry containing a unique name, associated data,
3
+ * and a method to format the data into a human-readable string.
4
+ *
5
+ * @template T The type of the performance data.
6
+ */
7
+ export interface AcCmPerformanceEntry<T> {
8
+ /** Unique name of this performance entry. */
9
+ name: string;
10
+ /** Performance data to be recorded. */
11
+ data: T;
12
+ /**
13
+ * Converts the performance data into a formatted string.
14
+ * @returns A string representing the performance data.
15
+ */
16
+ format(): string;
17
+ }
18
+ /**
19
+ * A singleton class for collecting and managing performance data.
20
+ * All entries must have a unique name. Entries are stored in a Map.
21
+ */
22
+ export declare class AcCmPerformanceCollector {
23
+ /** The singleton instance. */
24
+ private static instance;
25
+ /** Map of performance entries keyed by their unique name. */
26
+ private entries;
27
+ /**
28
+ * Private constructor to enforce singleton pattern.
29
+ */
30
+ private constructor();
31
+ /**
32
+ * Retrieves the singleton instance of the AcCmPerformanceCollector.
33
+ * @returns The shared AcCmPerformanceCollector instance.
34
+ */
35
+ static getInstance(): AcCmPerformanceCollector;
36
+ /**
37
+ * Adds or replaces a performance entry by name.
38
+ * @template T The type of the performance data.
39
+ * @param entry A performance entry object with name, data, and format method.
40
+ */
41
+ collect<T>(entry: AcCmPerformanceEntry<T>): void;
42
+ /**
43
+ * Logs all performance entries to the console using their format method.
44
+ */
45
+ printAll(): void;
46
+ /**
47
+ * Clears all collected performance entries.
48
+ */
49
+ clear(): void;
50
+ /**
51
+ * Retrieves all entries as an array.
52
+ * @returns A copy of all performance entries.
53
+ */
54
+ getAll(): AcCmPerformanceEntry<unknown>[];
55
+ /**
56
+ * Gets a single entry by name.
57
+ * @param name The unique name of the entry.
58
+ * @returns The matching entry or undefined.
59
+ */
60
+ getEntry(name: string): AcCmPerformanceEntry<unknown> | undefined;
61
+ /**
62
+ * Removes an entry by name.
63
+ * @param name The name of the entry to remove.
64
+ * @returns True if the entry was removed; false if not found.
65
+ */
66
+ remove(name: string): boolean;
67
+ }
68
+ //# sourceMappingURL=AcCmPerformanceCollector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcCmPerformanceCollector.d.ts","sourceRoot":"","sources":["../src/AcCmPerformanceCollector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAA;IAEZ,uCAAuC;IACvC,IAAI,EAAE,CAAC,CAAA;IAEP;;;OAGG;IACH,MAAM,IAAI,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,qBAAa,wBAAwB;IACnC,8BAA8B;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0B;IAEjD,6DAA6D;IAC7D,OAAO,CAAC,OAAO,CAAwD;IAEvE;;OAEG;IACH,OAAO;IAEP;;;OAGG;WACW,WAAW,IAAI,wBAAwB;IAOrD;;;;OAIG;IACI,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAIvD;;OAEG;IACI,QAAQ,IAAI,IAAI;IAOvB;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;;OAGG;IACI,MAAM,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE;IAIhD;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,SAAS;IAIxE;;;;OAIG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGrC"}
@@ -0,0 +1,110 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ /**
29
+ * A singleton class for collecting and managing performance data.
30
+ * All entries must have a unique name. Entries are stored in a Map.
31
+ */
32
+ var AcCmPerformanceCollector = /** @class */ (function () {
33
+ /**
34
+ * Private constructor to enforce singleton pattern.
35
+ */
36
+ function AcCmPerformanceCollector() {
37
+ /** Map of performance entries keyed by their unique name. */
38
+ this.entries = new Map();
39
+ }
40
+ /**
41
+ * Retrieves the singleton instance of the AcCmPerformanceCollector.
42
+ * @returns The shared AcCmPerformanceCollector instance.
43
+ */
44
+ AcCmPerformanceCollector.getInstance = function () {
45
+ if (!AcCmPerformanceCollector.instance) {
46
+ AcCmPerformanceCollector.instance = new AcCmPerformanceCollector();
47
+ }
48
+ return AcCmPerformanceCollector.instance;
49
+ };
50
+ /**
51
+ * Adds or replaces a performance entry by name.
52
+ * @template T The type of the performance data.
53
+ * @param entry A performance entry object with name, data, and format method.
54
+ */
55
+ AcCmPerformanceCollector.prototype.collect = function (entry) {
56
+ this.entries.set(entry.name, entry);
57
+ };
58
+ /**
59
+ * Logs all performance entries to the console using their format method.
60
+ */
61
+ AcCmPerformanceCollector.prototype.printAll = function () {
62
+ var e_1, _a;
63
+ try {
64
+ for (var _b = __values(this.entries), _c = _b.next(); !_c.done; _c = _b.next()) {
65
+ var _d = __read(_c.value, 2), name_1 = _d[0], entry = _d[1];
66
+ console.log("".concat(name_1, ":"));
67
+ console.log(entry.format());
68
+ }
69
+ }
70
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
71
+ finally {
72
+ try {
73
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
74
+ }
75
+ finally { if (e_1) throw e_1.error; }
76
+ }
77
+ };
78
+ /**
79
+ * Clears all collected performance entries.
80
+ */
81
+ AcCmPerformanceCollector.prototype.clear = function () {
82
+ this.entries.clear();
83
+ };
84
+ /**
85
+ * Retrieves all entries as an array.
86
+ * @returns A copy of all performance entries.
87
+ */
88
+ AcCmPerformanceCollector.prototype.getAll = function () {
89
+ return Array.from(this.entries.values());
90
+ };
91
+ /**
92
+ * Gets a single entry by name.
93
+ * @param name The unique name of the entry.
94
+ * @returns The matching entry or undefined.
95
+ */
96
+ AcCmPerformanceCollector.prototype.getEntry = function (name) {
97
+ return this.entries.get(name);
98
+ };
99
+ /**
100
+ * Removes an entry by name.
101
+ * @param name The name of the entry to remove.
102
+ * @returns True if the entry was removed; false if not found.
103
+ */
104
+ AcCmPerformanceCollector.prototype.remove = function (name) {
105
+ return this.entries.delete(name);
106
+ };
107
+ return AcCmPerformanceCollector;
108
+ }());
109
+ export { AcCmPerformanceCollector };
110
+ //# sourceMappingURL=AcCmPerformanceCollector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcCmPerformanceCollector.js","sourceRoot":"","sources":["../src/AcCmPerformanceCollector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA;;;GAGG;AACH;IAOE;;OAEG;IACH;QANA,6DAA6D;QACrD,YAAO,GAA+C,IAAI,GAAG,EAAE,CAAA;IAKhD,CAAC;IAExB;;;OAGG;IACW,oCAAW,GAAzB;QACE,IAAI,CAAC,wBAAwB,CAAC,QAAQ,EAAE,CAAC;YACvC,wBAAwB,CAAC,QAAQ,GAAG,IAAI,wBAAwB,EAAE,CAAA;QACpE,CAAC;QACD,OAAO,wBAAwB,CAAC,QAAQ,CAAA;IAC1C,CAAC;IAED;;;;OAIG;IACI,0CAAO,GAAd,UAAkB,KAA8B;QAC9C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACrC,CAAC;IAED;;OAEG;IACI,2CAAQ,GAAf;;;YACE,KAA4B,IAAA,KAAA,SAAA,IAAI,CAAC,OAAO,CAAA,gBAAA,4BAAE,CAAC;gBAAhC,IAAA,KAAA,mBAAa,EAAZ,MAAI,QAAA,EAAE,KAAK,QAAA;gBACrB,OAAO,CAAC,GAAG,CAAC,UAAG,MAAI,MAAG,CAAC,CAAA;gBACvB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;YAC7B,CAAC;;;;;;;;;IACH,CAAC;IAED;;OAEG;IACI,wCAAK,GAAZ;QACE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;IACtB,CAAC;IAED;;;OAGG;IACI,yCAAM,GAAb;QACE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED;;;;OAIG;IACI,2CAAQ,GAAf,UAAgB,IAAY;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IAED;;;;OAIG;IACI,yCAAM,GAAb,UAAc,IAAY;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IACH,+BAAC;AAAD,CAAC,AA1ED,IA0EC"}
@@ -0,0 +1,11 @@
1
+ export declare class AcTrStringUtil {
2
+ /**
3
+ * Converts a byte count to a human-readable string using KB, MB, or GB.
4
+ *
5
+ * @param bytes - The number of bytes.
6
+ * @param decimals - Number of decimal places to include (default is 2).
7
+ * @returns A formatted string with the appropriate unit.
8
+ */
9
+ static formatBytes(bytes: number, decimals?: number): string;
10
+ }
11
+ //# sourceMappingURL=AcCmStringUtil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcCmStringUtil.d.ts","sourceRoot":"","sources":["../src/AcCmStringUtil.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;IACzB;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM;CAYxD"}
@@ -0,0 +1,25 @@
1
+ var AcTrStringUtil = /** @class */ (function () {
2
+ function AcTrStringUtil() {
3
+ }
4
+ /**
5
+ * Converts a byte count to a human-readable string using KB, MB, or GB.
6
+ *
7
+ * @param bytes - The number of bytes.
8
+ * @param decimals - Number of decimal places to include (default is 2).
9
+ * @returns A formatted string with the appropriate unit.
10
+ */
11
+ AcTrStringUtil.formatBytes = function (bytes, decimals) {
12
+ if (decimals === void 0) { decimals = 2; }
13
+ if (bytes === 0)
14
+ return '0 B';
15
+ var k = 1024;
16
+ var dm = Math.max(0, decimals);
17
+ var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
18
+ var i = Math.floor(Math.log(bytes) / Math.log(k));
19
+ var value = bytes / Math.pow(k, i);
20
+ return "".concat(parseFloat(value.toFixed(dm)), " ").concat(sizes[i]);
21
+ };
22
+ return AcTrStringUtil;
23
+ }());
24
+ export { AcTrStringUtil };
25
+ //# sourceMappingURL=AcCmStringUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcCmStringUtil.js","sourceRoot":"","sources":["../src/AcCmStringUtil.ts"],"names":[],"mappings":"AAAA;IAAA;IAoBA,CAAC;IAnBC;;;;;;OAMG;IACI,0BAAW,GAAlB,UAAmB,KAAa,EAAE,QAAY;QAAZ,yBAAA,EAAA,YAAY;QAC5C,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,KAAK,CAAA;QAE7B,IAAM,CAAC,GAAG,IAAI,CAAA;QACd,IAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;QAChC,IAAM,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAE3C,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACnD,IAAM,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAEpC,OAAO,UAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,cAAI,KAAK,CAAC,CAAC,CAAC,CAAE,CAAA;IACvD,CAAC;IACH,qBAAC;AAAD,CAAC,AApBD,IAoBC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Represents a named unit of work with an asynchronous or synchronous execution function.
3
+ * @template TIn Input type
4
+ * @template TOut Output type
5
+ */
6
+ export declare class AcCmTask<TIn, TOut> {
7
+ /**
8
+ * Name of the task (for logging/debugging purposes)
9
+ */
10
+ readonly name: string;
11
+ constructor(name: string);
12
+ /**
13
+ * Executes the task.
14
+ */
15
+ run(_input: TIn): TOut | Promise<TOut>;
16
+ }
17
+ /**
18
+ * Reports progress after a task completes.
19
+ * @param progress A number between 0 and 1 indicating task completion
20
+ * @param task The task that was just completed
21
+ */
22
+ type AcCmProgressCallback = (progress: number, task: AcCmTask<unknown, unknown>) => void;
23
+ /**
24
+ * Callback function to handle final output.
25
+ */
26
+ export type AcCmCompleteCallback<T> = (finalResult: T) => void;
27
+ /**
28
+ * Handles errors during task execution.
29
+ * @param error The error thrown
30
+ * @param taskIndex Index of the failed task
31
+ * @param task The task that failed
32
+ */
33
+ type AcCmErrorCallback = (error: unknown, taskIndex: number, task: AcCmTask<unknown, unknown>) => void;
34
+ /**
35
+ * Type-safe task scheduler that executes a chain of named tasks in order,
36
+ * passing results between them and stopping on the first failure.
37
+ *
38
+ * @template TInitial Initial input type
39
+ * @template TFinal Final output type
40
+ */
41
+ export declare class AcCmTaskScheduler<TInitial, TFinal = TInitial> {
42
+ private tasks;
43
+ private onProgress;
44
+ private onComplete;
45
+ private onError;
46
+ /**
47
+ * Adds a task to the execution queue.
48
+ *
49
+ * @param task Task instance with name and run function
50
+ */
51
+ addTask<TIn, TOut>(task: AcCmTask<TIn, TOut>): void;
52
+ /**
53
+ * Sets a callback to receive progress updates.
54
+ */
55
+ setProgressCallback(callback: AcCmProgressCallback): void;
56
+ /**
57
+ * Sets a callback to be called after successful completion of all tasks.
58
+ */
59
+ setCompleteCallback(callback: AcCmCompleteCallback<TFinal>): void;
60
+ /**
61
+ * Sets a callback to be called if any task throws an error.
62
+ */
63
+ setErrorCallback(callback: AcCmErrorCallback): void;
64
+ /**
65
+ * Starts execution of the task queue with the given initial input.
66
+ */
67
+ run(initialData: TInitial): Promise<void>;
68
+ }
69
+ export {};
70
+ //# sourceMappingURL=AcCmTaskScheduler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcCmTaskScheduler.d.ts","sourceRoot":"","sources":["../src/AcCmTaskScheduler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,QAAQ,CAAC,GAAG,EAAE,IAAI;IAC7B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;gBAET,IAAI,EAAE,MAAM;IAIxB;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvC;AAED;;;;GAIG;AACH,KAAK,oBAAoB,GAAG,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,KAC7B,IAAI,CAAA;AAET;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,IAAI,CAAA;AAE9D;;;;;GAKG;AACH,KAAK,iBAAiB,GAAG,CACvB,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,KAC7B,IAAI,CAAA;AAET;;;;;;GAMG;AACH,qBAAa,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ;IACxD,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,UAAU,CAAyC;IAC3D,OAAO,CAAC,OAAO,CAA8B;IAE7C;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI;IAInD;;OAEG;IACH,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI;IAIzD;;OAEG;IACH,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,MAAM,CAAC,GAAG,IAAI;IAIjE;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAInD;;OAEG;IACG,GAAG,CAAC,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BhD"}
@@ -0,0 +1,173 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ /**
38
+ * Represents a named unit of work with an asynchronous or synchronous execution function.
39
+ * @template TIn Input type
40
+ * @template TOut Output type
41
+ */
42
+ var AcCmTask = /** @class */ (function () {
43
+ function AcCmTask(name) {
44
+ this.name = name;
45
+ }
46
+ /**
47
+ * Executes the task.
48
+ */
49
+ AcCmTask.prototype.run = function (_input) {
50
+ throw new Error('run() must be implemented by subclass');
51
+ };
52
+ return AcCmTask;
53
+ }());
54
+ export { AcCmTask };
55
+ /**
56
+ * Type-safe task scheduler that executes a chain of named tasks in order,
57
+ * passing results between them and stopping on the first failure.
58
+ *
59
+ * @template TInitial Initial input type
60
+ * @template TFinal Final output type
61
+ */
62
+ var AcCmTaskScheduler = /** @class */ (function () {
63
+ function AcCmTaskScheduler() {
64
+ this.tasks = [];
65
+ this.onProgress = function () { };
66
+ this.onComplete = function () { };
67
+ this.onError = function () { };
68
+ }
69
+ /**
70
+ * Adds a task to the execution queue.
71
+ *
72
+ * @param task Task instance with name and run function
73
+ */
74
+ AcCmTaskScheduler.prototype.addTask = function (task) {
75
+ this.tasks.push(task);
76
+ };
77
+ /**
78
+ * Sets a callback to receive progress updates.
79
+ */
80
+ AcCmTaskScheduler.prototype.setProgressCallback = function (callback) {
81
+ this.onProgress = callback;
82
+ };
83
+ /**
84
+ * Sets a callback to be called after successful completion of all tasks.
85
+ */
86
+ AcCmTaskScheduler.prototype.setCompleteCallback = function (callback) {
87
+ this.onComplete = callback;
88
+ };
89
+ /**
90
+ * Sets a callback to be called if any task throws an error.
91
+ */
92
+ AcCmTaskScheduler.prototype.setErrorCallback = function (callback) {
93
+ this.onError = callback;
94
+ };
95
+ /**
96
+ * Starts execution of the task queue with the given initial input.
97
+ */
98
+ AcCmTaskScheduler.prototype.run = function (initialData) {
99
+ return __awaiter(this, void 0, void 0, function () {
100
+ var total, result, _loop_1, this_1, i, state_1;
101
+ var _this = this;
102
+ return __generator(this, function (_a) {
103
+ switch (_a.label) {
104
+ case 0:
105
+ total = this.tasks.length;
106
+ result = initialData;
107
+ _loop_1 = function (i) {
108
+ var task, error_1;
109
+ return __generator(this, function (_b) {
110
+ switch (_b.label) {
111
+ case 0:
112
+ task = this_1.tasks[i];
113
+ _b.label = 1;
114
+ case 1:
115
+ _b.trys.push([1, 3, , 4]);
116
+ return [4 /*yield*/, new Promise(function (resolve, reject) {
117
+ setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
118
+ var output, err_1;
119
+ return __generator(this, function (_a) {
120
+ switch (_a.label) {
121
+ case 0:
122
+ _a.trys.push([0, 2, , 3]);
123
+ return [4 /*yield*/, task.run(result)];
124
+ case 1:
125
+ output = _a.sent();
126
+ this.onProgress((i + 1) / total, task);
127
+ resolve(output);
128
+ return [3 /*break*/, 3];
129
+ case 2:
130
+ err_1 = _a.sent();
131
+ reject(err_1);
132
+ return [3 /*break*/, 3];
133
+ case 3: return [2 /*return*/];
134
+ }
135
+ });
136
+ }); }, 0);
137
+ })];
138
+ case 2:
139
+ result = _b.sent();
140
+ return [3 /*break*/, 4];
141
+ case 3:
142
+ error_1 = _b.sent();
143
+ this_1.onError(error_1, i, task);
144
+ return [2 /*return*/, { value: void 0 }];
145
+ case 4: return [2 /*return*/];
146
+ }
147
+ });
148
+ };
149
+ this_1 = this;
150
+ i = 0;
151
+ _a.label = 1;
152
+ case 1:
153
+ if (!(i < total)) return [3 /*break*/, 4];
154
+ return [5 /*yield**/, _loop_1(i)];
155
+ case 2:
156
+ state_1 = _a.sent();
157
+ if (typeof state_1 === "object")
158
+ return [2 /*return*/, state_1.value];
159
+ _a.label = 3;
160
+ case 3:
161
+ i++;
162
+ return [3 /*break*/, 1];
163
+ case 4:
164
+ this.onComplete(result);
165
+ return [2 /*return*/];
166
+ }
167
+ });
168
+ });
169
+ };
170
+ return AcCmTaskScheduler;
171
+ }());
172
+ export { AcCmTaskScheduler };
173
+ //# sourceMappingURL=AcCmTaskScheduler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcCmTaskScheduler.js","sourceRoot":"","sources":["../src/AcCmTaskScheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH;IAME,kBAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;OAEG;IACH,sBAAG,GAAH,UAAI,MAAW;QACb,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IAC1D,CAAC;IACH,eAAC;AAAD,CAAC,AAhBD,IAgBC;;AA6BD;;;;;;GAMG;AACH;IAAA;QACU,UAAK,GAAiC,EAAE,CAAA;QACxC,eAAU,GAAyB,cAAO,CAAC,CAAA;QAC3C,eAAU,GAAiC,cAAO,CAAC,CAAA;QACnD,YAAO,GAAsB,cAAO,CAAC,CAAA;IA8D/C,CAAC;IA5DC;;;;OAIG;IACH,mCAAO,GAAP,UAAmB,IAAyB;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAkC,CAAC,CAAA;IACrD,CAAC;IAED;;OAEG;IACH,+CAAmB,GAAnB,UAAoB,QAA8B;QAChD,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,+CAAmB,GAAnB,UAAoB,QAAsC;QACxD,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,4CAAgB,GAAhB,UAAiB,QAA2B;QAC1C,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAA;IACzB,CAAC;IAED;;OAEG;IACG,+BAAG,GAAT,UAAU,WAAqB;;;;;;;wBACvB,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAA;wBAC3B,MAAM,GAAY,WAAW,CAAA;4CAExB,CAAC;;;;;wCACF,IAAI,GAAG,OAAK,KAAK,CAAC,CAAC,CAAC,CAAA;;;;wCAGf,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;gDACzC,UAAU,CAAC;;;;;;gEAEQ,qBAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAA;;gEAA/B,MAAM,GAAG,SAAsB;gEACrC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,CAAA;gEACtC,OAAO,CAAC,MAAM,CAAC,CAAA;;;;gEAEf,MAAM,CAAC,KAAG,CAAC,CAAA;;;;;qDAEd,EAAE,CAAC,CAAC,CAAA;4CACP,CAAC,CAAC,EAAA;;wCAVF,MAAM,GAAG,SAUP,CAAA;;;;wCAEF,OAAK,OAAO,CAAC,OAAK,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;;;;;;;wBAhBvB,CAAC,GAAG,CAAC;;;6BAAE,CAAA,CAAC,GAAG,KAAK,CAAA;sDAAhB,CAAC;;;;;;;wBAAiB,CAAC,EAAE,CAAA;;;wBAqB9B,IAAI,CAAC,UAAU,CAAC,MAAgB,CAAC,CAAA;;;;;KAClC;IACH,wBAAC;AAAD,CAAC,AAlED,IAkEC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export * from './AcCmColor';
2
+ export * from './AcCmErrors';
3
+ export * from './AcCmEventDispatcher';
4
+ export * from './AcCmEventManager';
5
+ export * from './AcCmLogUtil';
6
+ export * from './AcCmObject';
7
+ export * from './AcCmPerformanceCollector';
8
+ export * from './AcCmStringUtil';
9
+ export * from './AcCmTaskScheduler';
10
+ export * from './loader';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,UAAU,CAAA"}
package/lib/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from './AcCmColor';
2
+ export * from './AcCmErrors';
3
+ export * from './AcCmEventDispatcher';
4
+ export * from './AcCmEventManager';
5
+ export * from './AcCmLogUtil';
6
+ export * from './AcCmObject';
7
+ export * from './AcCmPerformanceCollector';
8
+ export * from './AcCmStringUtil';
9
+ export * from './AcCmTaskScheduler';
10
+ export * from './loader';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,UAAU,CAAA"}
@@ -0,0 +1,58 @@
1
+ import { AcCmLoader, AcCmLoaderProgressCallback } from './AcCmLoader';
2
+ import { AcCmLoadingManager, AcCmOnErrorCallback, AcCmOnLoadCallback } from './AcCmLoadingManager';
3
+ /**
4
+ * The response type. Valid values are:
5
+ * - text or empty string (default) - returns the data as String.
6
+ * - arraybuffer - loads the data into a ArrayBuffer and returns that.
7
+ * - blob - returns the data as a Blob.
8
+ * - document - parses the file using the DOMParser.
9
+ * - json - parses the file using JSON.parse.
10
+ */
11
+ type AcCmResponseType = '' | 'text' | 'arraybuffer' | 'blob' | 'document' | 'json';
12
+ /**
13
+ * A low level class for loading resources with 'Fetch', used internally by most loaders. It can also
14
+ * be used directly to load any file type that does not have a loader.
15
+ */
16
+ export declare class AcCmFileLoader extends AcCmLoader {
17
+ /**
18
+ * The expected mimeType. Default is undefined.
19
+ */
20
+ mimeType?: DOMParserSupportedType;
21
+ /**
22
+ * The expected response type. Default is undefined.
23
+ */
24
+ responseType?: AcCmResponseType;
25
+ /**
26
+ * Create a new AcCmFileLoader instance.
27
+ * @param manager The loadingManager for the loader to use. Default is DefaultLoadingManager.
28
+ */
29
+ constructor(manager?: AcCmLoadingManager);
30
+ /**
31
+ * Load the URL and pass the response to the onLoad function.
32
+ * @param url The path or URL to the file. This can also be a Data URI.
33
+ * @param onLoad (optional) — Will be called when loading completes.
34
+ * @param onProgress (optional) — Will be called while load progresses.
35
+ * @param onError (optional) — Will be called if an error occurs.
36
+ */
37
+ load(url: string, onLoad: AcCmOnLoadCallback, onProgress: AcCmLoaderProgressCallback, onError: AcCmOnErrorCallback): void;
38
+ /**
39
+ * Change the response type. Valid values are:
40
+ * - text or empty string (default) - returns the data as String.
41
+ * - arraybuffer - loads the data into a ArrayBuffer and returns that.
42
+ * - blob - returns the data as a Blob.
43
+ * - document - parses the file using the DOMParser.
44
+ * - json - parses the file using JSON.parse.
45
+ * @param value
46
+ * @returns Return this object
47
+ */
48
+ setResponseType(value: AcCmResponseType): this;
49
+ /**
50
+ * Set the expected mimeType of the file being loaded. Note that in many cases this will be determined
51
+ * automatically, so by default it is undefined.
52
+ * @param value The expected mimeType of the file being loaded.
53
+ * @returns Return this object.
54
+ */
55
+ setMimeType(value: DOMParserSupportedType): this;
56
+ }
57
+ export {};
58
+ //# sourceMappingURL=AcCmFileLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcCmFileLoader.d.ts","sourceRoot":"","sources":["../../src/loader/AcCmFileLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,sBAAsB,CAAA;AAmB7B;;;;;;;GAOG;AACH,KAAK,gBAAgB,GACjB,EAAE,GACF,MAAM,GACN,aAAa,GACb,MAAM,GACN,UAAU,GACV,MAAM,CAAA;AAEV;;;GAGG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C;;OAEG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAA;IACjC;;OAEG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAA;IAE/B;;;OAGG;gBACS,OAAO,CAAC,EAAE,kBAAkB;IAIxC;;;;;;OAMG;IACH,IAAI,CACF,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,kBAAkB,EAC1B,UAAU,EAAE,0BAA0B,EACtC,OAAO,EAAE,mBAAmB;IAmL9B;;;;;;;;;OASG;IACH,eAAe,CAAC,KAAK,EAAE,gBAAgB;IAKvC;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,sBAAsB;CAI1C"}