@kosdev-code/kos-ui-sdk 0.1.0-next.967 → 0.1.0-next.970

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-ui-sdk",
3
- "version": "0.1.0-next.967",
3
+ "version": "0.1.0-next.970",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -50,7 +50,7 @@
50
50
  "react-router-dom": "^6.11.2"
51
51
  },
52
52
  "dependencies": {
53
- "@kosdev-code/kos-api-levels": "0.1.0-next.967",
53
+ "@kosdev-code/kos-api-levels": "0.1.0-next.970",
54
54
  "mobx": "^6.9.0",
55
55
  "mobx-react-lite": "^3.4.3",
56
56
  "date-fns": "^2.30.0",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "kos": {
61
61
  "build": {
62
- "gitHash": "3f91cfc3d4f7b61eda12afa9925a4062bec85788"
62
+ "gitHash": "d5940a35064adbc3194fd9eca2be1831bb8614c2"
63
63
  }
64
64
  }
65
65
  }
@@ -587,6 +587,7 @@ const OptionsRequired = /* @__PURE__ */ Symbol(`OptionsRequired`);
587
587
  const KosViewModelSymbol = /* @__PURE__ */ Symbol(`KosViewModelSymbol`);
588
588
  const ViewModelConfig = /* @__PURE__ */ Symbol(`ViewModelConfig`);
589
589
  const ReloadAwareSetup = /* @__PURE__ */ Symbol(`ReloadAwareSetup`);
590
+ const MixinModels = /* @__PURE__ */ Symbol(`MixinModels`);
590
591
  const log$L = KosLog.createLogger({ group: "decorators", name: "fsm-injection" });
591
592
  function injectStateMachineSupport(modelInstance) {
592
593
  const fsmSetup = modelInstance[StateMachineSetup];
@@ -2732,6 +2733,10 @@ class KosBaseModelRegistration {
2732
2733
  this.loader = `kos.extension.model.loader.${props.type}`;
2733
2734
  this.factory = props.factory;
2734
2735
  this.class = props.class;
2736
+ const mixins = props.class.prototype[MixinModels] || {};
2737
+ Object.values(mixins).forEach(
2738
+ ({ registration }) => this.addRelatedModel(registration)
2739
+ );
2735
2740
  }
2736
2741
  addRelatedModel(model) {
2737
2742
  this.relatedModels.push(model);
@@ -3286,6 +3291,15 @@ function injectReloadAwareSupport(modelInstance) {
3286
3291
  configurable: true
3287
3292
  });
3288
3293
  }
3294
+ function injectMixinSupport(modelInstance) {
3295
+ const mixins = modelInstance[MixinModels];
3296
+ if (!mixins) return;
3297
+ Object.keys(mixins).forEach((property) => {
3298
+ if (!Object.prototype.hasOwnProperty.call(modelInstance, property)) {
3299
+ modelInstance[property] = void 0;
3300
+ }
3301
+ });
3302
+ }
3289
3303
  function makeSafeObservable(instance) {
3290
3304
  try {
3291
3305
  return mobx.makeAutoObservable(instance);
@@ -3316,6 +3330,7 @@ const modelConstructorProxy = {
3316
3330
  injectContainerAwareSupport(modelInstance, modelId);
3317
3331
  injectStateMachineSupport(modelInstance);
3318
3332
  injectReloadAwareSupport(modelInstance);
3333
+ injectMixinSupport(modelInstance);
3319
3334
  injectDependencies(modelInstance, modelId);
3320
3335
  return makeSafeObservable(modelInstance);
3321
3336
  }
@@ -3888,6 +3903,47 @@ class KosCompanionInstantiator {
3888
3903
  if (!this.shouldCreateCompanion(resolved.lifecycle, lifecycle)) continue;
3889
3904
  this.instantiateCompanion(resolved.type, model, options, lifecycle);
3890
3905
  }
3906
+ if (lifecycle === void 0) {
3907
+ this.createMixins(model);
3908
+ }
3909
+ }
3910
+ /**
3911
+ * Create the mixins the parent's class declares with @kosMixin and assign each to
3912
+ * the parent property that holds it.
3913
+ */
3914
+ createMixins(model) {
3915
+ const mixins = this.registry.models[model.modelTypeName]?.class?.prototype[MixinModels] || {};
3916
+ Object.entries(mixins).forEach(([property, { registration, options }]) => {
3917
+ const mixinId = this.generateCompanionId(
3918
+ registration.type,
3919
+ model.modelId
3920
+ );
3921
+ if (this.companionAlreadyExists(
3922
+ mixinId,
3923
+ registration.type,
3924
+ model.modelTypeName
3925
+ )) {
3926
+ return;
3927
+ }
3928
+ const mixin = this.createCompanionInstance(
3929
+ registration.type,
3930
+ mixinId,
3931
+ model,
3932
+ resolveParameters({
3933
+ value: options || {},
3934
+ modelData: model.modelData,
3935
+ modelId: model.modelId
3936
+ })
3937
+ );
3938
+ if (!mixin) return;
3939
+ this.attachCompanionToParent(mixin, model);
3940
+ mobx.runInAction(() => {
3941
+ model.modelData[property] = mixin.modelData;
3942
+ });
3943
+ log$C.debug(
3944
+ `Created mixin ${registration.type} for ${model.modelTypeName} [${model.modelId}]`
3945
+ );
3946
+ });
3891
3947
  }
3892
3948
  /**
3893
3949
  * Get companion definitions for a parent model type
@@ -24486,6 +24542,7 @@ exports.LogStream = LogStream;
24486
24542
  exports.LogStreamContainer = LogStreamContainer;
24487
24543
  exports.LoggerSetup = LoggerSetup;
24488
24544
  exports.MODEL_DELETION_DELAY = MODEL_DELETION_DELAY;
24545
+ exports.MixinModels = MixinModels;
24489
24546
  exports.ModelEffects = ModelEffects;
24490
24547
  exports.ModelError = ModelError;
24491
24548
  exports.MultipleFutureContainerSetup = MultipleFutureContainerSetup;
@@ -24745,4 +24802,4 @@ exports.waitForAppToStart = waitForAppToStart;
24745
24802
  exports.waitForAppsToStart = waitForAppsToStart;
24746
24803
  exports.whenReady = whenReady;
24747
24804
  exports.wrapWithFutureLifecycle = wrapWithFutureLifecycle;
24748
- //# sourceMappingURL=software-info-registration-BAk6JWkz.cjs.map
24805
+ //# sourceMappingURL=software-info-registration-Le3V0a6v.cjs.map