@cldmv/slothlet 3.2.3 → 3.3.2
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/README.md +22 -9
- package/REFERENCE.md +23 -0
- package/dist/lib/builders/api-assignment.mjs +1 -589
- package/dist/lib/builders/api_builder.mjs +1 -1155
- package/dist/lib/builders/builder.mjs +1 -78
- package/dist/lib/builders/modes-processor.mjs +1 -1800
- package/dist/lib/errors.mjs +9 -211
- package/dist/lib/factories/component-base.mjs +1 -80
- package/dist/lib/factories/context.mjs +1 -22
- package/dist/lib/handlers/api-cache-manager.mjs +1 -200
- package/dist/lib/handlers/api-manager.mjs +1 -2513
- package/dist/lib/handlers/context-async.mjs +1 -168
- package/dist/lib/handlers/context-live.mjs +1 -168
- package/dist/lib/handlers/hook-manager.mjs +1 -773
- package/dist/lib/handlers/lifecycle-token.mjs +1 -28
- package/dist/lib/handlers/lifecycle.mjs +1 -115
- package/dist/lib/handlers/materialize-manager.mjs +1 -48
- package/dist/lib/handlers/metadata.mjs +1 -501
- package/dist/lib/handlers/ownership.mjs +1 -322
- package/dist/lib/handlers/permission-manager.mjs +17 -0
- package/dist/lib/handlers/unified-wrapper.mjs +1 -3042
- package/dist/lib/handlers/version-manager.mjs +1 -885
- package/dist/lib/helpers/class-instance-wrapper.mjs +1 -109
- package/dist/lib/helpers/config.mjs +1 -355
- package/dist/lib/helpers/eventemitter-context.mjs +1 -349
- package/dist/lib/helpers/hint-detector.mjs +1 -47
- package/dist/lib/helpers/modes-utils.mjs +1 -37
- package/dist/lib/helpers/pattern-matcher.mjs +17 -0
- package/dist/lib/helpers/resolve-from-caller.mjs +1 -169
- package/dist/lib/helpers/sanitize.mjs +1 -340
- package/dist/lib/helpers/utilities.mjs +1 -70
- package/dist/lib/i18n/languages/de-de.json +21 -1
- package/dist/lib/i18n/languages/en-gb.json +21 -1
- package/dist/lib/i18n/languages/en-us.json +21 -1
- package/dist/lib/i18n/languages/es-mx.json +21 -1
- package/dist/lib/i18n/languages/fr-fr.json +21 -1
- package/dist/lib/i18n/languages/hi-in.json +21 -1
- package/dist/lib/i18n/languages/ja-jp.json +21 -1
- package/dist/lib/i18n/languages/ko-kr.json +21 -1
- package/dist/lib/i18n/languages/pt-br.json +21 -1
- package/dist/lib/i18n/languages/ru-ru.json +21 -1
- package/dist/lib/i18n/languages/zh-cn.json +21 -1
- package/dist/lib/i18n/translations.mjs +1 -126
- package/dist/lib/modes/eager.mjs +1 -59
- package/dist/lib/modes/lazy.mjs +1 -81
- package/dist/lib/processors/flatten.mjs +1 -437
- package/dist/lib/processors/loader.mjs +1 -339
- package/dist/lib/processors/type-generator.mjs +1 -275
- package/dist/lib/processors/typescript.mjs +1 -172
- package/dist/lib/runtime/runtime-asynclocalstorage.mjs +1 -113
- package/dist/lib/runtime/runtime-livebindings.mjs +1 -78
- package/dist/lib/runtime/runtime.mjs +1 -102
- package/dist/slothlet.mjs +1 -808
- package/package.json +37 -31
- package/types/dist/lib/builders/api-assignment.d.mts +3 -92
- package/types/dist/lib/builders/api-assignment.d.mts.map +1 -1
- package/types/dist/lib/builders/api_builder.d.mts +102 -91
- package/types/dist/lib/builders/api_builder.d.mts.map +1 -1
- package/types/dist/lib/builders/builder.d.mts +1 -55
- package/types/dist/lib/builders/builder.d.mts.map +1 -1
- package/types/dist/lib/builders/modes-processor.d.mts +3 -27
- package/types/dist/lib/builders/modes-processor.d.mts.map +1 -1
- package/types/dist/lib/errors.d.mts +19 -109
- package/types/dist/lib/errors.d.mts.map +1 -1
- package/types/dist/lib/factories/component-base.d.mts +7 -177
- package/types/dist/lib/factories/component-base.d.mts.map +1 -1
- package/types/dist/lib/factories/context.d.mts +4 -22
- package/types/dist/lib/factories/context.d.mts.map +1 -1
- package/types/dist/lib/handlers/api-cache-manager.d.mts +20 -203
- package/types/dist/lib/handlers/api-cache-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/api-manager.d.mts +33 -408
- package/types/dist/lib/handlers/api-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/context-async.d.mts +23 -61
- package/types/dist/lib/handlers/context-async.d.mts.map +1 -1
- package/types/dist/lib/handlers/context-live.d.mts +22 -59
- package/types/dist/lib/handlers/context-live.d.mts.map +1 -1
- package/types/dist/lib/handlers/hook-manager.d.mts +46 -185
- package/types/dist/lib/handlers/hook-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/lifecycle-token.d.mts +3 -48
- package/types/dist/lib/handlers/lifecycle-token.d.mts.map +1 -1
- package/types/dist/lib/handlers/lifecycle.d.mts +5 -82
- package/types/dist/lib/handlers/lifecycle.d.mts.map +1 -1
- package/types/dist/lib/handlers/materialize-manager.d.mts +8 -70
- package/types/dist/lib/handlers/materialize-manager.d.mts.map +1 -1
- package/types/dist/lib/handlers/metadata.d.mts +17 -221
- package/types/dist/lib/handlers/metadata.d.mts.map +1 -1
- package/types/dist/lib/handlers/ownership.d.mts +44 -160
- package/types/dist/lib/handlers/ownership.d.mts.map +1 -1
- package/types/dist/lib/handlers/permission-manager.d.mts +47 -0
- package/types/dist/lib/handlers/permission-manager.d.mts.map +1 -0
- package/types/dist/lib/handlers/unified-wrapper.d.mts +26 -239
- package/types/dist/lib/handlers/unified-wrapper.d.mts.map +1 -1
- package/types/dist/lib/handlers/version-manager.d.mts +28 -225
- package/types/dist/lib/handlers/version-manager.d.mts.map +1 -1
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts +2 -52
- package/types/dist/lib/helpers/class-instance-wrapper.d.mts.map +1 -1
- package/types/dist/lib/helpers/config.d.mts +125 -123
- package/types/dist/lib/helpers/config.d.mts.map +1 -1
- package/types/dist/lib/helpers/eventemitter-context.d.mts +3 -29
- package/types/dist/lib/helpers/eventemitter-context.d.mts.map +1 -1
- package/types/dist/lib/helpers/hint-detector.d.mts +2 -15
- package/types/dist/lib/helpers/hint-detector.d.mts.map +1 -1
- package/types/dist/lib/helpers/modes-utils.d.mts +3 -30
- package/types/dist/lib/helpers/modes-utils.d.mts.map +1 -1
- package/types/dist/lib/helpers/pattern-matcher.d.mts +4 -0
- package/types/dist/lib/helpers/pattern-matcher.d.mts.map +1 -0
- package/types/dist/lib/helpers/resolve-from-caller.d.mts +3 -27
- package/types/dist/lib/helpers/resolve-from-caller.d.mts.map +1 -1
- package/types/dist/lib/helpers/sanitize.d.mts +4 -92
- package/types/dist/lib/helpers/sanitize.d.mts.map +1 -1
- package/types/dist/lib/helpers/utilities.d.mts +4 -52
- package/types/dist/lib/helpers/utilities.d.mts.map +1 -1
- package/types/dist/lib/i18n/translations.d.mts +4 -37
- package/types/dist/lib/i18n/translations.d.mts.map +1 -1
- package/types/dist/lib/modes/eager.d.mts +8 -30
- package/types/dist/lib/modes/eager.d.mts.map +1 -1
- package/types/dist/lib/modes/lazy.d.mts +10 -43
- package/types/dist/lib/modes/lazy.d.mts.map +1 -1
- package/types/dist/lib/processors/flatten.d.mts +56 -107
- package/types/dist/lib/processors/flatten.d.mts.map +1 -1
- package/types/dist/lib/processors/loader.d.mts +6 -41
- package/types/dist/lib/processors/loader.d.mts.map +1 -1
- package/types/dist/lib/processors/type-generator.d.mts +2 -16
- package/types/dist/lib/processors/type-generator.d.mts.map +1 -1
- package/types/dist/lib/processors/typescript.d.mts +6 -53
- package/types/dist/lib/processors/typescript.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts +3 -71
- package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime-livebindings.d.mts +2 -37
- package/types/dist/lib/runtime/runtime-livebindings.d.mts.map +1 -1
- package/types/dist/lib/runtime/runtime.d.mts +3 -39
- package/types/dist/lib/runtime/runtime.d.mts.map +1 -1
- package/types/dist/slothlet.d.mts +3 -249
- package/types/dist/slothlet.d.mts.map +1 -1
- package/types/index.d.mts +36 -16
- package/types/index.d.mts.map +1 -0
- package/AGENT-USAGE.md +0 -736
- package/docs/API-RULES.md +0 -712
|
@@ -14,31 +14,4 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const instanceTokens = new WeakMap();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function registerInstance(slothlet) {
|
|
26
|
-
if (instanceTokens.has(slothlet)) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
instanceTokens.set(slothlet, Symbol("@cldmv/slothlet/lifecycle.tagToken"));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function getInstanceToken(slothlet) {
|
|
36
|
-
return instanceTokens.get(slothlet);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
function verifyToken(slothlet, token) {
|
|
41
|
-
return token === instanceTokens.get(slothlet);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { registerInstance, getInstanceToken, verifyToken };
|
|
17
|
+
const instanceTokens=new WeakMap;function registerInstance(slothlet){if(instanceTokens.has(slothlet)){return}instanceTokens.set(slothlet,Symbol("@cldmv/slothlet/lifecycle.tagToken"))}function getInstanceToken(slothlet){return instanceTokens.get(slothlet)}function verifyToken(slothlet,token){return token===instanceTokens.get(slothlet)}export{getInstanceToken,registerInstance,verifyToken};
|
|
@@ -14,118 +14,4 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
|
|
22
|
-
import { getInstanceToken } from "@cldmv/slothlet/handlers/lifecycle-token";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export class Lifecycle extends ComponentBase {
|
|
26
|
-
|
|
27
|
-
static slothletProperty = "lifecycle";
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
constructor(slothlet) {
|
|
31
|
-
super(slothlet);
|
|
32
|
-
this.subscribers = new Map();
|
|
33
|
-
this.eventLog = [];
|
|
34
|
-
this.maxLogSize = 1000;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
subscribe(event, handler) {
|
|
39
|
-
if (!this.subscribers.has(event)) {
|
|
40
|
-
this.subscribers.set(event, new Set());
|
|
41
|
-
}
|
|
42
|
-
this.subscribers.get(event).add(handler);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return () => {
|
|
46
|
-
const handlers = this.subscribers.get(event);
|
|
47
|
-
if (handlers) {
|
|
48
|
-
handlers.delete(handler);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
on(event, handler) {
|
|
55
|
-
return this.subscribe(event, handler);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
off(event, handler) {
|
|
60
|
-
const handlers = this.subscribers.get(event);
|
|
61
|
-
if (handlers) {
|
|
62
|
-
handlers.delete(handler);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
unsubscribe(event, handler) {
|
|
68
|
-
this.off(event, handler);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
async emit(event, data) {
|
|
73
|
-
|
|
74
|
-
if (this.____config?.debug?.lifecycle) {
|
|
75
|
-
this.eventLog.push({
|
|
76
|
-
event,
|
|
77
|
-
data: { ...data },
|
|
78
|
-
timestamp: Date.now()
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (this.eventLog.length > this.maxLogSize) {
|
|
83
|
-
this.eventLog.shift();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
this.slothlet.debug("lifecycle", {
|
|
87
|
-
key: "DEBUG_MODE_LIFECYCLE_EVENT",
|
|
88
|
-
event,
|
|
89
|
-
apiPath: data.apiPath,
|
|
90
|
-
source: data.source,
|
|
91
|
-
moduleID: data.moduleID
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const handlers = this.subscribers.get(event);
|
|
97
|
-
if (handlers) {
|
|
98
|
-
|
|
99
|
-
const handlerPromises = [];
|
|
100
|
-
|
|
101
|
-
const token = getInstanceToken(this.slothlet);
|
|
102
|
-
for (const handler of handlers) {
|
|
103
|
-
try {
|
|
104
|
-
const result = handler(data, token);
|
|
105
|
-
|
|
106
|
-
if (result && typeof result.then === "function") {
|
|
107
|
-
handlerPromises.push(
|
|
108
|
-
result.catch((error) => {
|
|
109
|
-
|
|
110
|
-
if (!this.____config?.silent) {
|
|
111
|
-
new this.SlothletWarning("WARNING_LIFECYCLE_HANDLER_ERROR", { event }, error);
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
} catch (error) {
|
|
117
|
-
|
|
118
|
-
if (!this.____config?.silent) {
|
|
119
|
-
new this.SlothletWarning("WARNING_LIFECYCLE_HANDLER_ERROR", { event }, error);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (handlerPromises.length > 0) {
|
|
126
|
-
await Promise.all(handlerPromises);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
}
|
|
17
|
+
import{ComponentBase}from"@cldmv/slothlet/factories/component-base";import{getInstanceToken}from"@cldmv/slothlet/handlers/lifecycle-token";class Lifecycle extends ComponentBase{static slothletProperty="lifecycle";constructor(slothlet){super(slothlet);this.subscribers=new Map;this.eventLog=[];this.maxLogSize=1e3}subscribe(event,handler){if(!this.subscribers.has(event)){this.subscribers.set(event,new Set)}this.subscribers.get(event).add(handler);return()=>{const handlers=this.subscribers.get(event);if(handlers){handlers.delete(handler)}}}on(event,handler){return this.subscribe(event,handler)}off(event,handler){const handlers=this.subscribers.get(event);if(handlers){handlers.delete(handler)}}unsubscribe(event,handler){this.off(event,handler)}async emit(event,data){if(this.____config?.debug?.lifecycle){this.eventLog.push({event,data:{...data},timestamp:Date.now()});if(this.eventLog.length>this.maxLogSize){this.eventLog.shift()}this.slothlet.debug("lifecycle",{key:"DEBUG_MODE_LIFECYCLE_EVENT",event,apiPath:data.apiPath,source:data.source,moduleID:data.moduleID})}const handlers=this.subscribers.get(event);if(handlers){const handlerPromises=[];const token=getInstanceToken(this.slothlet);for(const handler of handlers){try{const result=handler(data,token);if(result&&typeof result.then==="function"){handlerPromises.push(result.catch(error=>{if(!this.____config?.silent){new this.SlothletWarning("WARNING_LIFECYCLE_HANDLER_ERROR",{event},error)}}))}}catch(error){if(!this.____config?.silent){new this.SlothletWarning("WARNING_LIFECYCLE_HANDLER_ERROR",{event},error)}}}if(handlerPromises.length>0){await Promise.all(handlerPromises)}}}}export{Lifecycle};
|
|
@@ -14,51 +14,4 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import { ComponentBase } from "@cldmv/slothlet/factories/component-base";
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export class MaterializeManager extends ComponentBase {
|
|
25
|
-
static slothletProperty = "materialize";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
constructor(slothlet) {
|
|
29
|
-
super(slothlet);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
get materialized() {
|
|
34
|
-
return this.slothlet._unmaterializedLazyCount === 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
get() {
|
|
39
|
-
const total = this.slothlet._totalLazyCount;
|
|
40
|
-
const remaining = this.slothlet._unmaterializedLazyCount;
|
|
41
|
-
const materialized = total - remaining;
|
|
42
|
-
const percentage = total > 0 ? Math.round((materialized / total) * 100) : 100;
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
total,
|
|
46
|
-
materialized,
|
|
47
|
-
remaining,
|
|
48
|
-
percentage
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
async wait() {
|
|
54
|
-
|
|
55
|
-
if (this.slothlet._unmaterializedLazyCount === 0) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return new Promise((resolve) => {
|
|
61
|
-
this.slothlet._materializationWaiters.push(resolve);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
17
|
+
import{ComponentBase}from"@cldmv/slothlet/factories/component-base";class MaterializeManager extends ComponentBase{static slothletProperty="materialize";constructor(slothlet){super(slothlet)}get materialized(){return this.slothlet._unmaterializedLazyCount===0}get(){const total=this.slothlet._totalLazyCount;const remaining=this.slothlet._unmaterializedLazyCount;const materialized=total-remaining;const percentage=total>0?Math.round(materialized/total*100):100;return{total,materialized,remaining,percentage}}async wait(){if(this.slothlet._unmaterializedLazyCount===0){return}return new Promise(resolve=>{this.slothlet._materializationWaiters.push(resolve)})}}export{MaterializeManager};
|