@objectstack/core 2.0.5 → 2.0.6
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +8 -0
- package/dist/index.cjs +38 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/kernel-base.ts +15 -0
- package/src/kernel.test.ts +87 -0
- package/src/kernel.ts +9 -0
- package/src/lite-kernel.test.ts +48 -0
- package/src/plugin-loader.ts +12 -0
- package/src/security/plugin-permission-enforcer.ts +6 -0
- package/src/types.ts +11 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @objectstack/core@2.0.
|
|
2
|
+
> @objectstack/core@2.0.6 build /home/runner/work/spec/spec/packages/core
|
|
3
3
|
> tsup --config ../../tsup.config.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m136.06 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m281.06 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 108ms
|
|
16
|
+
[32mESM[39m [1mdist/index.js [22m[32m133.29 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m279.69 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 108ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m52.
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m52.
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 3199ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m52.98 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m52.98 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -117,6 +117,20 @@ var ObjectKernelBase = class {
|
|
|
117
117
|
return this.services.get(name);
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
|
+
replaceService: (name, implementation) => {
|
|
121
|
+
if (this.services instanceof Map) {
|
|
122
|
+
if (!this.services.has(name)) {
|
|
123
|
+
throw new Error(`[Kernel] Service '${name}' not found. Use registerService() to add new services.`);
|
|
124
|
+
}
|
|
125
|
+
this.services.set(name, implementation);
|
|
126
|
+
} else {
|
|
127
|
+
if (!this.services.has(name)) {
|
|
128
|
+
throw new Error(`[Kernel] Service '${name}' not found. Use registerService() to add new services.`);
|
|
129
|
+
}
|
|
130
|
+
this.services.register(name, implementation);
|
|
131
|
+
}
|
|
132
|
+
this.logger.info(`Service '${name}' replaced`, { service: name });
|
|
133
|
+
},
|
|
120
134
|
hook: (name, handler) => {
|
|
121
135
|
if (!this.hooks.has(name)) {
|
|
122
136
|
this.hooks.set(name, []);
|
|
@@ -792,6 +806,17 @@ var PluginLoader = class {
|
|
|
792
806
|
}
|
|
793
807
|
this.serviceInstances.set(name, service);
|
|
794
808
|
}
|
|
809
|
+
/**
|
|
810
|
+
* Replace an existing service instance.
|
|
811
|
+
* Used by optimization plugins to swap kernel internals.
|
|
812
|
+
* @throws Error if service does not exist
|
|
813
|
+
*/
|
|
814
|
+
replaceService(name, service) {
|
|
815
|
+
if (!this.hasService(name)) {
|
|
816
|
+
throw new Error(`Service '${name}' not found`);
|
|
817
|
+
}
|
|
818
|
+
this.serviceInstances.set(name, service);
|
|
819
|
+
}
|
|
795
820
|
/**
|
|
796
821
|
* Check if a service is registered (either as instance or factory)
|
|
797
822
|
*/
|
|
@@ -1027,6 +1052,15 @@ var ObjectKernel = class {
|
|
|
1027
1052
|
throw new Error(`[Kernel] Service '${name}' not found`);
|
|
1028
1053
|
}
|
|
1029
1054
|
},
|
|
1055
|
+
replaceService: (name, implementation) => {
|
|
1056
|
+
const hasService = this.services.has(name) || this.pluginLoader.hasService(name);
|
|
1057
|
+
if (!hasService) {
|
|
1058
|
+
throw new Error(`[Kernel] Service '${name}' not found. Use registerService() to add new services.`);
|
|
1059
|
+
}
|
|
1060
|
+
this.services.set(name, implementation);
|
|
1061
|
+
this.pluginLoader.replaceService(name, implementation);
|
|
1062
|
+
this.logger.info(`Service '${name}' replaced`, { service: name });
|
|
1063
|
+
},
|
|
1030
1064
|
hook: (name, handler) => {
|
|
1031
1065
|
if (!this.hooks.has(name)) {
|
|
1032
1066
|
this.hooks.set(name, []);
|
|
@@ -2795,6 +2829,10 @@ var SecurePluginContext = class {
|
|
|
2795
2829
|
this.permissionEnforcer.enforceServiceAccess(this.pluginName, name);
|
|
2796
2830
|
return this.baseContext.getService(name);
|
|
2797
2831
|
}
|
|
2832
|
+
replaceService(name, implementation) {
|
|
2833
|
+
this.permissionEnforcer.enforceServiceAccess(this.pluginName, name);
|
|
2834
|
+
this.baseContext.replaceService(name, implementation);
|
|
2835
|
+
}
|
|
2798
2836
|
getServices() {
|
|
2799
2837
|
return this.baseContext.getServices();
|
|
2800
2838
|
}
|