@cldmv/slothlet 3.3.0 → 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.
Files changed (127) hide show
  1. package/README.md +6 -8
  2. package/REFERENCE.md +23 -0
  3. package/dist/lib/builders/api-assignment.mjs +1 -589
  4. package/dist/lib/builders/api_builder.mjs +1 -1385
  5. package/dist/lib/builders/builder.mjs +1 -78
  6. package/dist/lib/builders/modes-processor.mjs +1 -1800
  7. package/dist/lib/errors.mjs +9 -211
  8. package/dist/lib/factories/component-base.mjs +1 -80
  9. package/dist/lib/factories/context.mjs +1 -22
  10. package/dist/lib/handlers/api-cache-manager.mjs +1 -200
  11. package/dist/lib/handlers/api-manager.mjs +1 -2536
  12. package/dist/lib/handlers/context-async.mjs +1 -172
  13. package/dist/lib/handlers/context-live.mjs +1 -173
  14. package/dist/lib/handlers/hook-manager.mjs +1 -667
  15. package/dist/lib/handlers/lifecycle-token.mjs +1 -28
  16. package/dist/lib/handlers/lifecycle.mjs +1 -115
  17. package/dist/lib/handlers/materialize-manager.mjs +1 -48
  18. package/dist/lib/handlers/metadata.mjs +1 -501
  19. package/dist/lib/handlers/ownership.mjs +1 -322
  20. package/dist/lib/handlers/permission-manager.mjs +1 -392
  21. package/dist/lib/handlers/unified-wrapper.mjs +1 -3110
  22. package/dist/lib/handlers/version-manager.mjs +1 -885
  23. package/dist/lib/helpers/class-instance-wrapper.mjs +1 -109
  24. package/dist/lib/helpers/config.mjs +1 -439
  25. package/dist/lib/helpers/eventemitter-context.mjs +1 -349
  26. package/dist/lib/helpers/hint-detector.mjs +1 -47
  27. package/dist/lib/helpers/modes-utils.mjs +1 -37
  28. package/dist/lib/helpers/pattern-matcher.mjs +1 -125
  29. package/dist/lib/helpers/resolve-from-caller.mjs +1 -169
  30. package/dist/lib/helpers/sanitize.mjs +1 -340
  31. package/dist/lib/helpers/utilities.mjs +1 -70
  32. package/dist/lib/i18n/translations.mjs +1 -126
  33. package/dist/lib/modes/eager.mjs +1 -59
  34. package/dist/lib/modes/lazy.mjs +1 -81
  35. package/dist/lib/processors/flatten.mjs +1 -437
  36. package/dist/lib/processors/loader.mjs +1 -339
  37. package/dist/lib/processors/type-generator.mjs +1 -275
  38. package/dist/lib/processors/typescript.mjs +1 -172
  39. package/dist/lib/runtime/runtime-asynclocalstorage.mjs +1 -113
  40. package/dist/lib/runtime/runtime-livebindings.mjs +1 -78
  41. package/dist/lib/runtime/runtime.mjs +1 -102
  42. package/dist/slothlet.mjs +1 -817
  43. package/package.json +34 -31
  44. package/types/dist/lib/builders/api-assignment.d.mts +3 -92
  45. package/types/dist/lib/builders/api-assignment.d.mts.map +1 -1
  46. package/types/dist/lib/builders/api_builder.d.mts +102 -91
  47. package/types/dist/lib/builders/api_builder.d.mts.map +1 -1
  48. package/types/dist/lib/builders/builder.d.mts +1 -55
  49. package/types/dist/lib/builders/builder.d.mts.map +1 -1
  50. package/types/dist/lib/builders/modes-processor.d.mts +3 -27
  51. package/types/dist/lib/builders/modes-processor.d.mts.map +1 -1
  52. package/types/dist/lib/errors.d.mts +19 -109
  53. package/types/dist/lib/errors.d.mts.map +1 -1
  54. package/types/dist/lib/factories/component-base.d.mts +7 -177
  55. package/types/dist/lib/factories/component-base.d.mts.map +1 -1
  56. package/types/dist/lib/factories/context.d.mts +4 -22
  57. package/types/dist/lib/factories/context.d.mts.map +1 -1
  58. package/types/dist/lib/handlers/api-cache-manager.d.mts +20 -203
  59. package/types/dist/lib/handlers/api-cache-manager.d.mts.map +1 -1
  60. package/types/dist/lib/handlers/api-manager.d.mts +33 -408
  61. package/types/dist/lib/handlers/api-manager.d.mts.map +1 -1
  62. package/types/dist/lib/handlers/context-async.d.mts +23 -61
  63. package/types/dist/lib/handlers/context-async.d.mts.map +1 -1
  64. package/types/dist/lib/handlers/context-live.d.mts +22 -59
  65. package/types/dist/lib/handlers/context-live.d.mts.map +1 -1
  66. package/types/dist/lib/handlers/hook-manager.d.mts +46 -185
  67. package/types/dist/lib/handlers/hook-manager.d.mts.map +1 -1
  68. package/types/dist/lib/handlers/lifecycle-token.d.mts +3 -48
  69. package/types/dist/lib/handlers/lifecycle-token.d.mts.map +1 -1
  70. package/types/dist/lib/handlers/lifecycle.d.mts +5 -82
  71. package/types/dist/lib/handlers/lifecycle.d.mts.map +1 -1
  72. package/types/dist/lib/handlers/materialize-manager.d.mts +8 -70
  73. package/types/dist/lib/handlers/materialize-manager.d.mts.map +1 -1
  74. package/types/dist/lib/handlers/metadata.d.mts +17 -221
  75. package/types/dist/lib/handlers/metadata.d.mts.map +1 -1
  76. package/types/dist/lib/handlers/ownership.d.mts +44 -160
  77. package/types/dist/lib/handlers/ownership.d.mts.map +1 -1
  78. package/types/dist/lib/handlers/permission-manager.d.mts +37 -141
  79. package/types/dist/lib/handlers/permission-manager.d.mts.map +1 -1
  80. package/types/dist/lib/handlers/unified-wrapper.d.mts +26 -239
  81. package/types/dist/lib/handlers/unified-wrapper.d.mts.map +1 -1
  82. package/types/dist/lib/handlers/version-manager.d.mts +28 -225
  83. package/types/dist/lib/handlers/version-manager.d.mts.map +1 -1
  84. package/types/dist/lib/helpers/class-instance-wrapper.d.mts +2 -52
  85. package/types/dist/lib/helpers/class-instance-wrapper.d.mts.map +1 -1
  86. package/types/dist/lib/helpers/config.d.mts +125 -139
  87. package/types/dist/lib/helpers/config.d.mts.map +1 -1
  88. package/types/dist/lib/helpers/eventemitter-context.d.mts +3 -29
  89. package/types/dist/lib/helpers/eventemitter-context.d.mts.map +1 -1
  90. package/types/dist/lib/helpers/hint-detector.d.mts +2 -15
  91. package/types/dist/lib/helpers/hint-detector.d.mts.map +1 -1
  92. package/types/dist/lib/helpers/modes-utils.d.mts +3 -30
  93. package/types/dist/lib/helpers/modes-utils.d.mts.map +1 -1
  94. package/types/dist/lib/helpers/pattern-matcher.d.mts +3 -43
  95. package/types/dist/lib/helpers/pattern-matcher.d.mts.map +1 -1
  96. package/types/dist/lib/helpers/resolve-from-caller.d.mts +3 -27
  97. package/types/dist/lib/helpers/resolve-from-caller.d.mts.map +1 -1
  98. package/types/dist/lib/helpers/sanitize.d.mts +4 -92
  99. package/types/dist/lib/helpers/sanitize.d.mts.map +1 -1
  100. package/types/dist/lib/helpers/utilities.d.mts +4 -52
  101. package/types/dist/lib/helpers/utilities.d.mts.map +1 -1
  102. package/types/dist/lib/i18n/translations.d.mts +4 -37
  103. package/types/dist/lib/i18n/translations.d.mts.map +1 -1
  104. package/types/dist/lib/modes/eager.d.mts +8 -30
  105. package/types/dist/lib/modes/eager.d.mts.map +1 -1
  106. package/types/dist/lib/modes/lazy.d.mts +10 -43
  107. package/types/dist/lib/modes/lazy.d.mts.map +1 -1
  108. package/types/dist/lib/processors/flatten.d.mts +56 -107
  109. package/types/dist/lib/processors/flatten.d.mts.map +1 -1
  110. package/types/dist/lib/processors/loader.d.mts +6 -41
  111. package/types/dist/lib/processors/loader.d.mts.map +1 -1
  112. package/types/dist/lib/processors/type-generator.d.mts +2 -16
  113. package/types/dist/lib/processors/type-generator.d.mts.map +1 -1
  114. package/types/dist/lib/processors/typescript.d.mts +6 -53
  115. package/types/dist/lib/processors/typescript.d.mts.map +1 -1
  116. package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts +3 -71
  117. package/types/dist/lib/runtime/runtime-asynclocalstorage.d.mts.map +1 -1
  118. package/types/dist/lib/runtime/runtime-livebindings.d.mts +2 -37
  119. package/types/dist/lib/runtime/runtime-livebindings.d.mts.map +1 -1
  120. package/types/dist/lib/runtime/runtime.d.mts +3 -39
  121. package/types/dist/lib/runtime/runtime.d.mts.map +1 -1
  122. package/types/dist/slothlet.d.mts +3 -249
  123. package/types/dist/slothlet.d.mts.map +1 -1
  124. package/types/index.d.mts +36 -16
  125. package/types/index.d.mts.map +1 -0
  126. package/AGENT-USAGE.md +0 -736
  127. package/docs/API-RULES.md +0 -712
@@ -14,175 +14,4 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
-
18
-
19
-
20
-
21
-
22
- import fs from "fs";
23
- import path from "path";
24
- import { SlothletError } from "@cldmv/slothlet/errors";
25
-
26
- let esbuildInstance = null;
27
- let typescriptInstance = null;
28
-
29
-
30
- async function getEsbuild() {
31
- if (!esbuildInstance) {
32
- try {
33
- esbuildInstance = await import("esbuild");
34
-
35
-
36
-
37
- } catch (error) {
38
- throw new SlothletError("TYPESCRIPT_ESBUILD_NOT_INSTALLED", { mode: "fast" }, error);
39
- }
40
-
41
- }
42
- return esbuildInstance;
43
- }
44
-
45
-
46
- async function getTypeScript() {
47
- if (!typescriptInstance) {
48
- try {
49
- typescriptInstance = await import("typescript");
50
-
51
-
52
-
53
- } catch (error) {
54
- throw new SlothletError("TYPESCRIPT_TSC_NOT_INSTALLED", { mode: "strict" }, error);
55
- }
56
-
57
- }
58
- return typescriptInstance;
59
- }
60
-
61
-
62
- export async function transformTypeScript(filePath, options = {}) {
63
- const esbuild = await getEsbuild();
64
- const code = fs.readFileSync(filePath, "utf8");
65
-
66
- const result = await esbuild.transform(code, {
67
- loader: "ts",
68
- format: options.format || "esm",
69
- target: options.target || "es2020",
70
- sourcemap: options.sourcemap || false,
71
- ...options
72
- });
73
-
74
- return result.code;
75
- }
76
-
77
-
78
- export function createDataUrl(code) {
79
-
80
- const encoded = encodeURIComponent(code);
81
- const timestamp = Date.now();
82
- return `data:text/javascript;charset=utf-8,${encoded}#t=${timestamp}`;
83
- }
84
-
85
-
86
- export async function transformTypeScriptStrict(filePath, options = {}) {
87
- const ts = await getTypeScript();
88
- const code = fs.readFileSync(filePath, "utf8");
89
-
90
-
91
- const targetMap = {
92
- es3: ts.ScriptTarget.ES3,
93
- es5: ts.ScriptTarget.ES5,
94
- es6: ts.ScriptTarget.ES2015,
95
- es2015: ts.ScriptTarget.ES2015,
96
- es2016: ts.ScriptTarget.ES2016,
97
- es2017: ts.ScriptTarget.ES2017,
98
- es2018: ts.ScriptTarget.ES2018,
99
- es2019: ts.ScriptTarget.ES2019,
100
- es2020: ts.ScriptTarget.ES2020,
101
- es2021: ts.ScriptTarget.ES2021,
102
- es2022: ts.ScriptTarget.ES2022,
103
- esnext: ts.ScriptTarget.ESNext,
104
- latest: ts.ScriptTarget.Latest
105
- };
106
-
107
-
108
- const moduleMap = {
109
- none: ts.ModuleKind.None,
110
- commonjs: ts.ModuleKind.CommonJS,
111
- amd: ts.ModuleKind.AMD,
112
- system: ts.ModuleKind.System,
113
- umd: ts.ModuleKind.UMD,
114
- es6: ts.ModuleKind.ES2015,
115
- es2015: ts.ModuleKind.ES2015,
116
- es2020: ts.ModuleKind.ES2020,
117
- es2022: ts.ModuleKind.ES2022,
118
- esnext: ts.ModuleKind.ESNext,
119
- node16: ts.ModuleKind.Node16,
120
- nodenext: ts.ModuleKind.NodeNext
121
- };
122
-
123
- const targetKey = (options.target || "es2020").toLowerCase();
124
- const moduleKey = (options.module || "esnext").toLowerCase();
125
-
126
- const compilerOptions = {
127
- target: targetMap[targetKey] || ts.ScriptTarget.ES2020,
128
- module: moduleMap[moduleKey] || ts.ModuleKind.ESNext,
129
- strict: options.strict !== false,
130
- esModuleInterop: true,
131
- skipLibCheck: true,
132
- noEmit: false,
133
- ...(options.typeDefinitionPath && {
134
- typeRoots: [path.dirname(options.typeDefinitionPath)],
135
- types: [path.basename(options.typeDefinitionPath, ".d.ts")]
136
- }),
137
- ...options.compilerOptions
138
- };
139
-
140
-
141
- let diagnostics = [];
142
- if (!options.skipTypeCheck) {
143
-
144
- const host = ts.createCompilerHost(compilerOptions);
145
-
146
-
147
- const originalReadFile = host.readFile;
148
- host.readFile = (fileName) => {
149
- if (fileName === filePath) {
150
- return code;
151
- }
152
- return originalReadFile.call(host, fileName);
153
- };
154
-
155
-
156
- const program = ts.createProgram([filePath], compilerOptions, host);
157
-
158
-
159
- const allDiagnostics = [...program.getSemanticDiagnostics(), ...program.getSyntacticDiagnostics()];
160
-
161
-
162
- diagnostics = allDiagnostics.filter((d) => d.file && d.file.fileName === filePath);
163
- }
164
-
165
-
166
- const result = ts.transpileModule(code, {
167
- compilerOptions,
168
- fileName: filePath
169
- });
170
-
171
- return {
172
- code: result.outputText,
173
- diagnostics
174
- };
175
- }
176
-
177
-
178
- export function formatDiagnostics(diagnostics, ts) {
179
- return diagnostics.map((diagnostic) => {
180
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
181
- if (diagnostic.file && diagnostic.start !== undefined) {
182
- const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
183
- const fileName = diagnostic.file.fileName;
184
- return `${fileName}:${line + 1}:${character + 1} - ${message}`;
185
- }
186
- return message;
187
- });
188
- }
17
+ import fs from"fs";import path from"path";import{SlothletError}from"@cldmv/slothlet/errors";let esbuildInstance=null;let typescriptInstance=null;async function getEsbuild(){if(!esbuildInstance){try{esbuildInstance=await import("esbuild")}catch(error){throw new SlothletError("TYPESCRIPT_ESBUILD_NOT_INSTALLED",{mode:"fast"},error)}}return esbuildInstance}async function getTypeScript(){if(!typescriptInstance){try{typescriptInstance=await import("typescript")}catch(error){throw new SlothletError("TYPESCRIPT_TSC_NOT_INSTALLED",{mode:"strict"},error)}}return typescriptInstance}async function transformTypeScript(filePath,options={}){const esbuild=await getEsbuild();const code=fs.readFileSync(filePath,"utf8");const result=await esbuild.transform(code,{loader:"ts",format:options.format||"esm",target:options.target||"es2020",sourcemap:options.sourcemap||false,...options});return result.code}function createDataUrl(code){const encoded=encodeURIComponent(code);const timestamp=Date.now();return`data:text/javascript;charset=utf-8,${encoded}#t=${timestamp}`}async function transformTypeScriptStrict(filePath,options={}){const ts=await getTypeScript();const code=fs.readFileSync(filePath,"utf8");const targetMap={es3:ts.ScriptTarget.ES3,es5:ts.ScriptTarget.ES5,es6:ts.ScriptTarget.ES2015,es2015:ts.ScriptTarget.ES2015,es2016:ts.ScriptTarget.ES2016,es2017:ts.ScriptTarget.ES2017,es2018:ts.ScriptTarget.ES2018,es2019:ts.ScriptTarget.ES2019,es2020:ts.ScriptTarget.ES2020,es2021:ts.ScriptTarget.ES2021,es2022:ts.ScriptTarget.ES2022,esnext:ts.ScriptTarget.ESNext,latest:ts.ScriptTarget.Latest};const moduleMap={none:ts.ModuleKind.None,commonjs:ts.ModuleKind.CommonJS,amd:ts.ModuleKind.AMD,system:ts.ModuleKind.System,umd:ts.ModuleKind.UMD,es6:ts.ModuleKind.ES2015,es2015:ts.ModuleKind.ES2015,es2020:ts.ModuleKind.ES2020,es2022:ts.ModuleKind.ES2022,esnext:ts.ModuleKind.ESNext,node16:ts.ModuleKind.Node16,nodenext:ts.ModuleKind.NodeNext};const targetKey=(options.target||"es2020").toLowerCase();const moduleKey=(options.module||"esnext").toLowerCase();const compilerOptions={target:targetMap[targetKey]||ts.ScriptTarget.ES2020,module:moduleMap[moduleKey]||ts.ModuleKind.ESNext,strict:options.strict!==false,esModuleInterop:true,skipLibCheck:true,noEmit:false,...options.typeDefinitionPath&&{typeRoots:[path.dirname(options.typeDefinitionPath)],types:[path.basename(options.typeDefinitionPath,".d.ts")]},...options.compilerOptions};let diagnostics=[];if(!options.skipTypeCheck){const host=ts.createCompilerHost(compilerOptions);const originalReadFile=host.readFile;host.readFile=fileName=>{if(fileName===filePath){return code}return originalReadFile.call(host,fileName)};const program=ts.createProgram([filePath],compilerOptions,host);const allDiagnostics=[...program.getSemanticDiagnostics(),...program.getSyntacticDiagnostics()];diagnostics=allDiagnostics.filter(d=>d.file&&d.file.fileName===filePath)}const result=ts.transpileModule(code,{compilerOptions,fileName:filePath});return{code:result.outputText,diagnostics}}function formatDiagnostics(diagnostics,ts){return diagnostics.map(diagnostic=>{const message=ts.flattenDiagnosticMessageText(diagnostic.messageText,"\n");if(diagnostic.file&&diagnostic.start!==void 0){const{line,character}=diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);const fileName=diagnostic.file.fileName;return`${fileName}:${line+1}:${character+1} - ${message}`}return message})}export{createDataUrl,formatDiagnostics,transformTypeScript,transformTypeScriptStrict};
@@ -14,116 +14,4 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
-
18
-
19
-
20
-
21
- import { asyncRuntime } from "@cldmv/slothlet/factories/context";
22
- import { SlothletError } from "@cldmv/slothlet/errors";
23
-
24
-
25
- function safeGetContext() {
26
- try {
27
- return asyncRuntime.getContext();
28
- } catch {
29
- return null;
30
- }
31
- }
32
-
33
-
34
- export const self = new Proxy(
35
- {},
36
- {
37
- get(_, prop) {
38
- const ctx = safeGetContext();
39
- if (!ctx || !ctx.self) {
40
- throw new SlothletError("RUNTIME_NO_ACTIVE_CONTEXT_SELF", {}, null, { validationError: true });
41
- }
42
- return ctx.self[prop];
43
- },
44
- ownKeys() {
45
- const ctx = safeGetContext();
46
- if (!ctx || !ctx.self) return [];
47
- return Reflect.ownKeys(ctx.self);
48
- },
49
- has(_, prop) {
50
- const ctx = safeGetContext();
51
- if (!ctx || !ctx.self) return false;
52
- return prop in ctx.self;
53
- },
54
- getOwnPropertyDescriptor(_, prop) {
55
- const ctx = safeGetContext();
56
- if (!ctx || !ctx.self) return undefined;
57
- const desc = Reflect.getOwnPropertyDescriptor(ctx.self, prop);
58
-
59
-
60
- if (desc) {
61
- return { ...desc, configurable: true };
62
- }
63
- return undefined;
64
- }
65
- }
66
- );
67
-
68
-
69
- export const context = new Proxy(
70
- {},
71
- {
72
- get(_, prop) {
73
- const ctx = safeGetContext();
74
- if (!ctx || !ctx.context) {
75
- return undefined;
76
- }
77
- return ctx.context[prop];
78
- },
79
- set(_, prop, value) {
80
- const ctx = safeGetContext();
81
- if (!ctx || !ctx.context) {
82
- throw new SlothletError("RUNTIME_NO_ACTIVE_CONTEXT_CONTEXT", {}, null, { validationError: true });
83
- }
84
- ctx.context[prop] = value;
85
- return true;
86
- },
87
- ownKeys() {
88
- const ctx = safeGetContext();
89
- if (!ctx || !ctx.context) return [];
90
- return Reflect.ownKeys(ctx.context);
91
- },
92
- has(_, prop) {
93
- const ctx = safeGetContext();
94
- if (!ctx || !ctx.context) return false;
95
- return prop in ctx.context;
96
- },
97
- getOwnPropertyDescriptor(_, prop) {
98
- const ctx = safeGetContext();
99
- if (!ctx || !ctx.context) return undefined;
100
- return Reflect.getOwnPropertyDescriptor(ctx.context, prop);
101
- }
102
- }
103
- );
104
-
105
-
106
-
107
-
108
- export const instanceID = new Proxy(
109
- {},
110
- {
111
- get(_, prop) {
112
- const ctx = safeGetContext();
113
- if (!ctx || !ctx.instanceID) {
114
- return undefined;
115
- }
116
-
117
- if (prop === Symbol.toPrimitive || prop === "toString" || prop === "valueOf") {
118
- return () => ctx.instanceID;
119
- }
120
- return ctx.instanceID[prop];
121
- },
122
- has(_, prop) {
123
- const ctx = safeGetContext();
124
- if (!ctx || !ctx.instanceID) return false;
125
-
126
- return prop in Object(ctx.instanceID);
127
- }
128
- }
129
- );
17
+ import{asyncRuntime}from"@cldmv/slothlet/factories/context";import{SlothletError}from"@cldmv/slothlet/errors";function safeGetContext(){try{return asyncRuntime.getContext()}catch{return null}}const self=new Proxy({},{get(_,prop){const ctx=safeGetContext();if(!ctx||!ctx.self){throw new SlothletError("RUNTIME_NO_ACTIVE_CONTEXT_SELF",{},null,{validationError:true})}return ctx.self[prop]},ownKeys(){const ctx=safeGetContext();if(!ctx||!ctx.self)return[];return Reflect.ownKeys(ctx.self)},has(_,prop){const ctx=safeGetContext();if(!ctx||!ctx.self)return false;return prop in ctx.self},getOwnPropertyDescriptor(_,prop){const ctx=safeGetContext();if(!ctx||!ctx.self)return void 0;const desc=Reflect.getOwnPropertyDescriptor(ctx.self,prop);if(desc){return{...desc,configurable:true}}return void 0}});const context=new Proxy({},{get(_,prop){const ctx=safeGetContext();if(!ctx||!ctx.context){return void 0}return ctx.context[prop]},set(_,prop,value){const ctx=safeGetContext();if(!ctx||!ctx.context){throw new SlothletError("RUNTIME_NO_ACTIVE_CONTEXT_CONTEXT",{},null,{validationError:true})}ctx.context[prop]=value;return true},ownKeys(){const ctx=safeGetContext();if(!ctx||!ctx.context)return[];return Reflect.ownKeys(ctx.context)},has(_,prop){const ctx=safeGetContext();if(!ctx||!ctx.context)return false;return prop in ctx.context},getOwnPropertyDescriptor(_,prop){const ctx=safeGetContext();if(!ctx||!ctx.context)return void 0;return Reflect.getOwnPropertyDescriptor(ctx.context,prop)}});const instanceID=new Proxy({},{get(_,prop){const ctx=safeGetContext();if(!ctx||!ctx.instanceID){return void 0}if(prop===Symbol.toPrimitive||prop==="toString"||prop==="valueOf"){return()=>ctx.instanceID}return ctx.instanceID[prop]},has(_,prop){const ctx=safeGetContext();if(!ctx||!ctx.instanceID)return false;return prop in Object(ctx.instanceID)}});export{context,instanceID,self};
@@ -14,81 +14,4 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
-
18
-
19
-
20
-
21
- import { liveRuntime } from "@cldmv/slothlet/factories/context";
22
- import { SlothletError } from "@cldmv/slothlet/errors";
23
-
24
-
25
- export const self = new Proxy(
26
- {},
27
- {
28
- get(_, prop) {
29
- const ctx = liveRuntime.getContext();
30
- if (!ctx || !ctx.self) {
31
- throw new SlothletError("RUNTIME_NO_ACTIVE_CONTEXT_SELF", {}, null, { validationError: true });
32
- }
33
- return ctx.self[prop];
34
- },
35
- ownKeys() {
36
- const ctx = liveRuntime.getContext();
37
- if (!ctx || !ctx.self) return [];
38
- return Reflect.ownKeys(ctx.self);
39
- },
40
- has(_, prop) {
41
- const ctx = liveRuntime.getContext();
42
- if (!ctx || !ctx.self) return false;
43
- return prop in ctx.self;
44
- },
45
- getOwnPropertyDescriptor(_, prop) {
46
- const ctx = liveRuntime.getContext();
47
- if (!ctx || !ctx.self) return undefined;
48
- const desc = Reflect.getOwnPropertyDescriptor(ctx.self, prop);
49
-
50
-
51
- if (desc) {
52
- return { ...desc, configurable: true };
53
- }
54
- return undefined;
55
- }
56
- }
57
- );
58
-
59
-
60
- export const context = new Proxy(
61
- {},
62
- {
63
- get(_, prop) {
64
- const ctx = liveRuntime.getContext();
65
- if (!ctx || !ctx.context) {
66
- return undefined;
67
- }
68
- return ctx.context[prop];
69
- },
70
- set(_, prop, value) {
71
- const ctx = liveRuntime.getContext();
72
- if (!ctx || !ctx.context) {
73
- throw new SlothletError("RUNTIME_NO_ACTIVE_CONTEXT_CONTEXT", {}, null, { validationError: true });
74
- }
75
- ctx.context[prop] = value;
76
- return true;
77
- },
78
- ownKeys() {
79
- const ctx = liveRuntime.getContext();
80
- if (!ctx || !ctx.context) return [];
81
- return Reflect.ownKeys(ctx.context);
82
- },
83
- has(_, prop) {
84
- const ctx = liveRuntime.getContext();
85
- if (!ctx || !ctx.context) return false;
86
- return prop in ctx.context;
87
- },
88
- getOwnPropertyDescriptor(_, prop) {
89
- const ctx = liveRuntime.getContext();
90
- if (!ctx || !ctx.context) return undefined;
91
- return Reflect.getOwnPropertyDescriptor(ctx.context, prop);
92
- }
93
- }
94
- );
17
+ import{liveRuntime}from"@cldmv/slothlet/factories/context";import{SlothletError}from"@cldmv/slothlet/errors";const self=new Proxy({},{get(_,prop){const ctx=liveRuntime.getContext();if(!ctx||!ctx.self){throw new SlothletError("RUNTIME_NO_ACTIVE_CONTEXT_SELF",{},null,{validationError:true})}return ctx.self[prop]},ownKeys(){const ctx=liveRuntime.getContext();if(!ctx||!ctx.self)return[];return Reflect.ownKeys(ctx.self)},has(_,prop){const ctx=liveRuntime.getContext();if(!ctx||!ctx.self)return false;return prop in ctx.self},getOwnPropertyDescriptor(_,prop){const ctx=liveRuntime.getContext();if(!ctx||!ctx.self)return void 0;const desc=Reflect.getOwnPropertyDescriptor(ctx.self,prop);if(desc){return{...desc,configurable:true}}return void 0}});const context=new Proxy({},{get(_,prop){const ctx=liveRuntime.getContext();if(!ctx||!ctx.context){return void 0}return ctx.context[prop]},set(_,prop,value){const ctx=liveRuntime.getContext();if(!ctx||!ctx.context){throw new SlothletError("RUNTIME_NO_ACTIVE_CONTEXT_CONTEXT",{},null,{validationError:true})}ctx.context[prop]=value;return true},ownKeys(){const ctx=liveRuntime.getContext();if(!ctx||!ctx.context)return[];return Reflect.ownKeys(ctx.context)},has(_,prop){const ctx=liveRuntime.getContext();if(!ctx||!ctx.context)return false;return prop in ctx.context},getOwnPropertyDescriptor(_,prop){const ctx=liveRuntime.getContext();if(!ctx||!ctx.context)return void 0;return Reflect.getOwnPropertyDescriptor(ctx.context,prop)}});export{context,self};
@@ -14,105 +14,4 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
-
18
-
19
-
20
-
21
-
22
- import { asyncRuntime, liveRuntime } from "@cldmv/slothlet/factories/context";
23
-
24
-
25
- const asyncRuntimeModule = await import("@cldmv/slothlet/runtime/async");
26
- const liveRuntimeModule = await import("@cldmv/slothlet/runtime/live");
27
-
28
-
29
- function getCurrentRuntime() {
30
-
31
-
32
-
33
- const asyncCtx = asyncRuntime.tryGetContext();
34
- if (asyncCtx) {
35
- return asyncRuntimeModule;
36
- }
37
-
38
-
39
- const liveCtx = liveRuntime.tryGetContext();
40
- if (liveCtx) {
41
- return liveRuntimeModule;
42
- }
43
-
44
-
45
- return asyncRuntimeModule;
46
- }
47
-
48
-
49
- export const self = new Proxy(
50
- {},
51
- {
52
- get(_, prop) {
53
- const runtime = getCurrentRuntime();
54
- return runtime.self[prop];
55
- },
56
- ownKeys() {
57
- const runtime = getCurrentRuntime();
58
- return Reflect.ownKeys(runtime.self);
59
- },
60
- has(_, prop) {
61
- const runtime = getCurrentRuntime();
62
- return prop in runtime.self;
63
- },
64
- getOwnPropertyDescriptor(_, prop) {
65
- const runtime = getCurrentRuntime();
66
- const desc = Reflect.getOwnPropertyDescriptor(runtime.self, prop);
67
-
68
-
69
- if (desc) {
70
- return { ...desc, configurable: true };
71
- }
72
- return undefined;
73
- }
74
- }
75
- );
76
-
77
-
78
- export const context = new Proxy(
79
- {},
80
- {
81
- get(_, prop) {
82
- const runtime = getCurrentRuntime();
83
- return runtime.context[prop];
84
- },
85
- ownKeys() {
86
- const runtime = getCurrentRuntime();
87
- return Reflect.ownKeys(runtime.context);
88
- },
89
- has(_, prop) {
90
- const runtime = getCurrentRuntime();
91
- return prop in runtime.context;
92
- },
93
- getOwnPropertyDescriptor(_, prop) {
94
- const runtime = getCurrentRuntime();
95
- return Reflect.getOwnPropertyDescriptor(runtime.context, prop);
96
- },
97
- set(_, prop, value) {
98
- const runtime = getCurrentRuntime();
99
- runtime.context[prop] = value;
100
- return true;
101
- }
102
- }
103
- );
104
-
105
-
106
- export const instanceID = new Proxy(
107
- {},
108
- {
109
- get(_, prop) {
110
- const runtime = getCurrentRuntime();
111
- return runtime.instanceID ? runtime.instanceID[prop] : undefined;
112
- },
113
- has(_, prop) {
114
- const runtime = getCurrentRuntime();
115
- return runtime.instanceID ? prop in runtime.instanceID : false;
116
- }
117
- }
118
- );
17
+ import{asyncRuntime,liveRuntime}from"@cldmv/slothlet/factories/context";const asyncRuntimeModule=await import("@cldmv/slothlet/runtime/async");const liveRuntimeModule=await import("@cldmv/slothlet/runtime/live");function getCurrentRuntime(){const asyncCtx=asyncRuntime.tryGetContext();if(asyncCtx){return asyncRuntimeModule}const liveCtx=liveRuntime.tryGetContext();if(liveCtx){return liveRuntimeModule}return asyncRuntimeModule}const self=new Proxy({},{get(_,prop){const runtime=getCurrentRuntime();return runtime.self[prop]},ownKeys(){const runtime=getCurrentRuntime();return Reflect.ownKeys(runtime.self)},has(_,prop){const runtime=getCurrentRuntime();return prop in runtime.self},getOwnPropertyDescriptor(_,prop){const runtime=getCurrentRuntime();const desc=Reflect.getOwnPropertyDescriptor(runtime.self,prop);if(desc){return{...desc,configurable:true}}return void 0}});const context=new Proxy({},{get(_,prop){const runtime=getCurrentRuntime();return runtime.context[prop]},ownKeys(){const runtime=getCurrentRuntime();return Reflect.ownKeys(runtime.context)},has(_,prop){const runtime=getCurrentRuntime();return prop in runtime.context},getOwnPropertyDescriptor(_,prop){const runtime=getCurrentRuntime();return Reflect.getOwnPropertyDescriptor(runtime.context,prop)},set(_,prop,value){const runtime=getCurrentRuntime();runtime.context[prop]=value;return true}});const instanceID=new Proxy({},{get(_,prop){const runtime=getCurrentRuntime();return runtime.instanceID?runtime.instanceID[prop]:void 0},has(_,prop){const runtime=getCurrentRuntime();return runtime.instanceID?prop in runtime.instanceID:false}});export{context,instanceID,self};