laymur 0.16.0 → 0.17.1
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 +84 -208
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +41 -0
- package/dist/{constraints → core/constraints}/UIConstraint.d.ts +2 -2
- package/dist/core/constraints/UIConstraint.js +11 -0
- package/dist/core/constraints/UICustomConstraint.js +37 -0
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +34 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +136 -0
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +40 -0
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +71 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +136 -0
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +40 -0
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +34 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.js +19 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.js +138 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.js +63 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.js +63 -0
- package/dist/{elements → core/elements}/UIAnchor/UIAnchor.Internal.d.ts +3 -0
- package/dist/core/elements/UIAnchor/UIAnchor.Internal.js +5 -0
- package/dist/{elements → core/elements}/UIAnchor/UIAnchor.d.ts +3 -3
- package/dist/core/elements/UIAnchor/UIAnchor.js +49 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.js +15 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +259 -0
- package/dist/core/elements/UIDummy/UIDummy.Internal.js +8 -0
- package/dist/{elements → core/elements}/UIDummy/UIDummy.d.ts +2 -2
- package/dist/core/elements/UIDummy/UIDummy.js +173 -0
- package/dist/core/elements/UIElement/UIElement.Internal.js +5 -0
- package/dist/{elements → core/elements}/UIElement/UIElement.d.ts +2 -2
- package/dist/core/elements/UIElement/UIElement.js +74 -0
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +7 -0
- package/dist/core/elements/UIGraphics/UIGraphics.js +126 -0
- package/dist/core/elements/UIImage/UIImage.js +85 -0
- package/dist/core/elements/UINineSlice/UINineSlice.Internal.js +12 -0
- package/dist/core/elements/UINineSlice/UINineSlice.js +188 -0
- package/dist/core/elements/UIProgress/UIProgress.Internal.js +3 -0
- package/dist/core/elements/UIProgress/UIProgress.js +165 -0
- package/dist/core/elements/UIScene/UIScene.Internal.js +27 -0
- package/dist/core/elements/UIScene/UIScene.js +157 -0
- package/dist/core/elements/UIText/UIText.Internal.js +12 -0
- package/dist/core/elements/UIText/UIText.Measuring.js +153 -0
- package/dist/core/elements/UIText/UIText.Rendering.js +61 -0
- package/dist/core/elements/UIText/UIText.js +265 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.js +5 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +147 -0
- package/dist/core/layers/UILayer/UILayer.Internal.js +7 -0
- package/dist/core/layers/UILayer/UILayer.js +113 -0
- package/dist/core/miscellaneous/UIExpression.js +128 -0
- package/dist/core/miscellaneous/UIMode.js +30 -0
- package/dist/core/miscellaneous/UIOrientation.js +20 -0
- package/dist/core/miscellaneous/UIPriority.js +63 -0
- package/dist/core/miscellaneous/UIRelation.js +40 -0
- package/dist/core/miscellaneous/UITransparencyMode.js +12 -0
- package/dist/core/miscellaneous/area/UIArea.js +5 -0
- package/dist/core/miscellaneous/area/UIAreaCircle.js +32 -0
- package/dist/core/miscellaneous/area/UIAreaPolygon.js +40 -0
- package/dist/core/miscellaneous/area/UIAreaRectangle.js +36 -0
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +72 -0
- package/dist/core/miscellaneous/asserts.js +163 -0
- package/dist/core/miscellaneous/canvas.js +37 -0
- package/dist/core/miscellaneous/color/UIColor.Internal.js +42 -0
- package/dist/core/miscellaneous/color/UIColor.js +636 -0
- package/dist/core/miscellaneous/computeTransform.js +82 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +168 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +349 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +357 -0
- package/dist/core/miscellaneous/generic-plane/shared.js +228 -0
- package/dist/core/miscellaneous/insets/UIInsets.Internal.js +3 -0
- package/dist/core/miscellaneous/insets/UIInsets.js +224 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +19 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +51 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +48 -0
- package/dist/{miscellaneous → core/miscellaneous}/math.d.ts +2 -0
- package/dist/core/miscellaneous/math.js +11 -0
- package/dist/core/miscellaneous/micro/UIMicro.Internal.js +15 -0
- package/dist/core/miscellaneous/micro/UIMicro.js +181 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +9 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.js +13 -0
- package/dist/core/miscellaneous/shared.js +37 -0
- package/dist/core/miscellaneous/text-span/UITextSpan.js +36 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +17 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.js +372 -0
- package/dist/core/miscellaneous/texture/UITextureView.Internal.js +6 -0
- package/dist/core/miscellaneous/texture/UITextureView.js +234 -0
- package/dist/core/miscellaneous/webglCapabilities.js +103 -0
- package/dist/core/shaders/UIImage.glsl.js +3 -0
- package/dist/core/shaders/UINineSlice.glsl.js +3 -0
- package/dist/core/shaders/UIProgress.glsl.js +3 -0
- package/dist/core/shaders/UIProgressMaskFunctionCircular.glsl.js +3 -0
- package/dist/core/shaders/UIProgressMaskFunctionDirectional.glsl.js +3 -0
- package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.d.ts +2 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +108 -0
- package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.d.ts +2 -2
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +75 -0
- package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.d.ts +2 -2
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +505 -0
- package/dist/index.js +51 -9246
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +21 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +47 -0
- package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +14 -0
- package/dist/particles/behaviorModules/UIBehaviorModule.js +9 -0
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +39 -0
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +110 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +22 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +66 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +20 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +48 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +26 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +66 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +20 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +49 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +26 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +70 -0
- package/dist/particles/elements/UIEmitter.Internal.d.ts +15 -0
- package/dist/particles/elements/UIEmitter.Internal.js +11 -0
- package/dist/particles/elements/UIEmitter.d.ts +68 -0
- package/dist/particles/elements/UIEmitter.js +203 -0
- package/dist/particles/index.d.ts +18 -0
- package/dist/particles/index.js +18 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +13 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +211 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +17 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.js +93 -0
- package/dist/particles/miscellaneous/miscellaneous.d.ts +32 -0
- package/dist/particles/miscellaneous/miscellaneous.js +67 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +14 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.js +32 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +15 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +37 -0
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +8 -0
- package/dist/particles/renderingModules/UIRenderingModule.js +9 -0
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +14 -0
- package/dist/particles/renderingModules/UIRenderingTexture.js +26 -0
- package/dist/particles/shaders/UIRenderingColorOverLife.glsl.js +3 -0
- package/dist/particles/shaders/UIRenderingColorOverVelocity.glsl.js +3 -0
- package/dist/particles/shaders/UIRenderingTexture.glsl.js +3 -0
- package/dist/particles/spawnModules/UISpawnModule.d.ts +9 -0
- package/dist/particles/spawnModules/UISpawnModule.js +9 -0
- package/dist/particles/spawnModules/UISpawnOffset.d.ts +21 -0
- package/dist/particles/spawnModules/UISpawnOffset.js +46 -0
- package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomLifetime.js +47 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.js +45 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +26 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.js +60 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.js +45 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +26 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.js +64 -0
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +27 -0
- package/dist/particles/spawnModules/UISpawnRectangle.js +62 -0
- package/package.json +27 -36
- package/dist/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UICustomConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIDummy/UIDummy.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIElement/UIElement.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIImage/UIImage.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIImage/UIImage.d.ts +0 -0
- /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIProgress/UIProgress.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIProgress/UIProgress.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIScene/UIScene.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIScene/UIScene.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Interfaces.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Measuring.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Rendering.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.d.ts +0 -0
- /package/dist/{index.d.ts → core/index.d.ts} +0 -0
- /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +0 -0
- /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -0
- /package/dist/{layers → core/layers}/UILayer/UILayer.Internal.d.ts +0 -0
- /package/dist/{layers → core/layers}/UILayer/UILayer.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIExpression.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIMode.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIOrientation.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIPriority.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIRelation.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UITransparencyMode.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIArea.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaCircle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaPolygon.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRectangle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRoundedRectangle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/asserts.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/canvas.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/computeTransform.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/shared.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunction.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionCircular.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionDirectional.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicy.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCover.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCross.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCrossInverted.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFit.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedHeight.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedWidth.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyNone.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/shared.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/webglCapabilities.d.ts +0 -0
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import { Solver, Variable, Constraint, Expression } from '@lume/kiwi';
|
|
2
|
+
import { UIExpression } from '../../miscellaneous/UIExpression.js';
|
|
3
|
+
import { UIPriority, convertPriority } from '../../miscellaneous/UIPriority.js';
|
|
4
|
+
import { UIRelation, convertRelation } from '../../miscellaneous/UIRelation.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Wrapper around the Kiwi constraint solver providing enhanced UI-specific functionality.
|
|
8
|
+
*
|
|
9
|
+
* UISolverWrapper abstracts the Kiwi (Cassowary) constraint solver to provide a more
|
|
10
|
+
* UI-friendly interface with additional features like dynamic constraint modification,
|
|
11
|
+
* required variables (P0 priority), partial constraint updates, and automatic solver
|
|
12
|
+
* recovery. It manages variables and constraints through index-based references,
|
|
13
|
+
* allowing for easy tracking and modification of layout constraints.
|
|
14
|
+
*
|
|
15
|
+
* Key features:
|
|
16
|
+
* - Index-based variable and constraint management
|
|
17
|
+
* - Required variables with P0 priority (always satisfied)
|
|
18
|
+
* - Dynamic constraint modification without full rebuilds
|
|
19
|
+
* - Automatic solver recovery on constraint conflicts
|
|
20
|
+
* - Lazy evaluation with recalculation flags
|
|
21
|
+
*
|
|
22
|
+
* @see {@link UIExpression} - Expression system for constraint definitions
|
|
23
|
+
* @see {@link UIPriority} - Priority levels for variables and constraints
|
|
24
|
+
* @see {@link UIRelation} - Relational operators for constraints
|
|
25
|
+
*/
|
|
26
|
+
class UISolverWrapper {
|
|
27
|
+
constructor() {
|
|
28
|
+
/** @internal */
|
|
29
|
+
this.dirty = false;
|
|
30
|
+
/** The underlying Kiwi solver instance, undefined when solver needs rebuilding. */
|
|
31
|
+
this._private_solver = new Solver();
|
|
32
|
+
/** Flag indicating whether variable values need recalculation. */
|
|
33
|
+
this._private_recalculationRequired = false;
|
|
34
|
+
/** Map of variable indices to their descriptions. */
|
|
35
|
+
this._private_variables = new Map();
|
|
36
|
+
/** Counter for generating unique variable indices. */
|
|
37
|
+
this._private_lastVariableIndex = 0;
|
|
38
|
+
/** Map of constraint indices to their descriptions. */
|
|
39
|
+
this._private_constraints = new Map();
|
|
40
|
+
/** Counter for generating unique constraint indices. */
|
|
41
|
+
this._private_lastConstraintIndex = 0;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new solver variable with the specified value and priority.
|
|
45
|
+
*
|
|
46
|
+
* Variables with P0 priority are treated as required (must be satisfied exactly)
|
|
47
|
+
* and are implemented using equality constraints. Other priorities use edit
|
|
48
|
+
* variables that can be adjusted by the solver.
|
|
49
|
+
*
|
|
50
|
+
* @param value - Initial value for the variable
|
|
51
|
+
* @param priority - Priority level for constraint solving
|
|
52
|
+
* @returns Unique index identifier for the created variable
|
|
53
|
+
*/
|
|
54
|
+
createVariable(value, priority) {
|
|
55
|
+
const index = this._private_lastVariableIndex++;
|
|
56
|
+
const variable = new Variable();
|
|
57
|
+
if (priority === UIPriority.P0) {
|
|
58
|
+
const description = { variable, priority, value };
|
|
59
|
+
this._private_variables.set(index, description);
|
|
60
|
+
description.constraint = this._private_buildConstraint(new UIExpression(0, [[index, 1]]), new UIExpression(value), UIRelation.EQUAL, priority);
|
|
61
|
+
try {
|
|
62
|
+
this._private_solver?.addConstraint(description.constraint);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
this._private_solver = undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this._private_variables.set(index, { variable, priority, value });
|
|
70
|
+
try {
|
|
71
|
+
this._private_solver?.addEditVariable(variable, convertPriority(priority));
|
|
72
|
+
this._private_solver?.suggestValue(variable, value);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
this._private_solver = undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this._private_recalculationRequired = true;
|
|
79
|
+
this.dirty = true;
|
|
80
|
+
return index;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Removes a variable from the solver system.
|
|
84
|
+
*
|
|
85
|
+
* The variable must not be referenced by any existing constraints.
|
|
86
|
+
* Cleans up both the variable itself and any associated required constraint.
|
|
87
|
+
*
|
|
88
|
+
* @param index - Index of the variable to remove
|
|
89
|
+
* @throws Will throw an error if the variable doesn't exist or is still in use
|
|
90
|
+
*/
|
|
91
|
+
removeVariable(index) {
|
|
92
|
+
const description = this._private_variables.get(index);
|
|
93
|
+
if (description === undefined) {
|
|
94
|
+
throw new Error(`UISolverWrapper.removeVariable.index: variable does not exist`);
|
|
95
|
+
}
|
|
96
|
+
for (const cDescription of this._private_constraints.values()) {
|
|
97
|
+
if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {
|
|
98
|
+
throw new Error(`UISolverWrapper.removeVariable.index: variable is used in constraint`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
description.constraint
|
|
103
|
+
? this._private_solver?.removeConstraint(description.constraint)
|
|
104
|
+
: this._private_solver?.removeEditVariable(description.variable);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
this._private_solver = undefined;
|
|
108
|
+
}
|
|
109
|
+
this._private_variables.delete(index);
|
|
110
|
+
this._private_recalculationRequired = true;
|
|
111
|
+
this.dirty = true;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Suggests a new value for an existing variable.
|
|
115
|
+
*
|
|
116
|
+
* For P0 priority variables, rebuilds the associated constraint.
|
|
117
|
+
* For other priorities, suggests the value to the solver's edit system.
|
|
118
|
+
* Only triggers updates if the value actually changes.
|
|
119
|
+
*
|
|
120
|
+
* @param index - Index of the variable to update
|
|
121
|
+
* @param value - New suggested value
|
|
122
|
+
* @throws Will throw an error if the variable doesn't exist
|
|
123
|
+
*/
|
|
124
|
+
suggestVariableValue(index, value) {
|
|
125
|
+
const description = this._private_variables.get(index);
|
|
126
|
+
if (description === undefined) {
|
|
127
|
+
throw new Error(`UISolverWrapper.suggestVariableValue.index: variable does not exist`);
|
|
128
|
+
}
|
|
129
|
+
if (description.value !== value) {
|
|
130
|
+
description.value = value;
|
|
131
|
+
if (description.constraint) {
|
|
132
|
+
description.constraint = this._private_rebuildConstraint(description.constraint, new UIExpression().plus(index, 1), new UIExpression(description.value), UIRelation.EQUAL, description.priority);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this._private_solver?.suggestValue(description.variable, value);
|
|
136
|
+
}
|
|
137
|
+
this._private_recalculationRequired = true;
|
|
138
|
+
this.dirty = true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Changes the priority of an existing variable.
|
|
143
|
+
*
|
|
144
|
+
* Switching to/from P0 priority changes how the variable is handled:
|
|
145
|
+
* - P0: Creates required constraint (must be satisfied exactly)
|
|
146
|
+
* - Other: Uses edit variable system (can be adjusted by solver)
|
|
147
|
+
*
|
|
148
|
+
* @param index - Index of the variable to modify
|
|
149
|
+
* @param priority - New priority level
|
|
150
|
+
* @throws Will throw an error if the variable doesn't exist
|
|
151
|
+
*/
|
|
152
|
+
setVariablePriority(index, priority) {
|
|
153
|
+
const description = this._private_variables.get(index);
|
|
154
|
+
if (description === undefined) {
|
|
155
|
+
throw new Error(`UISolverWrapper.setVariablePriority.index: variable does not exist`);
|
|
156
|
+
}
|
|
157
|
+
if (priority !== description.priority) {
|
|
158
|
+
description.priority = priority;
|
|
159
|
+
if (description.priority === UIPriority.P0) {
|
|
160
|
+
const lhs = new UIExpression().plus(index, 1);
|
|
161
|
+
const rhs = new UIExpression(description.value);
|
|
162
|
+
description.constraint = this._private_buildConstraint(lhs, rhs, UIRelation.EQUAL, description.priority);
|
|
163
|
+
try {
|
|
164
|
+
this._private_solver?.addConstraint(description.constraint);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
this._private_solver = undefined;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
if (description.constraint) {
|
|
172
|
+
try {
|
|
173
|
+
this._private_solver?.removeConstraint(description.constraint);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
this._private_solver = undefined;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
description.constraint = undefined;
|
|
180
|
+
this._private_rebuildVariable(index, description);
|
|
181
|
+
}
|
|
182
|
+
this._private_recalculationRequired = true;
|
|
183
|
+
this.dirty = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Reads the current solved value of a variable.
|
|
188
|
+
*
|
|
189
|
+
* Triggers solver recalculation if needed and rebuilds the solver
|
|
190
|
+
* if it was invalidated due to constraint conflicts.
|
|
191
|
+
*
|
|
192
|
+
* @param index - Index of the variable to read
|
|
193
|
+
* @returns Current solved value of the variable
|
|
194
|
+
* @throws Will throw an error if the variable doesn't exist
|
|
195
|
+
*/
|
|
196
|
+
readVariableValue(index) {
|
|
197
|
+
const description = this._private_variables.get(index);
|
|
198
|
+
if (description === undefined) {
|
|
199
|
+
throw new Error(`UISolverWrapper.readVariableValue.index: variable does not exist`);
|
|
200
|
+
}
|
|
201
|
+
if (this._private_solver === undefined) {
|
|
202
|
+
this._private_rebuildSolver();
|
|
203
|
+
}
|
|
204
|
+
if (this._private_recalculationRequired) {
|
|
205
|
+
this._private_solver?.updateVariables();
|
|
206
|
+
this._private_recalculationRequired = false;
|
|
207
|
+
}
|
|
208
|
+
return description.variable.value();
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Creates a new constraint between two expressions.
|
|
212
|
+
*
|
|
213
|
+
* Constraints can be enabled or disabled, and all properties can be
|
|
214
|
+
* modified later without recreating the constraint.
|
|
215
|
+
*
|
|
216
|
+
* @param lhs - Left-hand side expression
|
|
217
|
+
* @param rhs - Right-hand side expression
|
|
218
|
+
* @param relation - Relational operator (equal, less than, greater than)
|
|
219
|
+
* @param priority - Priority level for constraint solving
|
|
220
|
+
* @param enabled - Whether the constraint is initially active
|
|
221
|
+
* @returns Unique index identifier for the created constraint
|
|
222
|
+
*/
|
|
223
|
+
createConstraint(lhs, rhs, relation, priority, enabled) {
|
|
224
|
+
const index = this._private_lastConstraintIndex++;
|
|
225
|
+
const constraint = this._private_buildConstraint(lhs, rhs, relation, priority);
|
|
226
|
+
this._private_constraints.set(index, {
|
|
227
|
+
constraint,
|
|
228
|
+
lhs: lhs.clone(),
|
|
229
|
+
rhs: rhs.clone(),
|
|
230
|
+
priority,
|
|
231
|
+
relation,
|
|
232
|
+
enabled,
|
|
233
|
+
});
|
|
234
|
+
if (enabled) {
|
|
235
|
+
try {
|
|
236
|
+
this._private_solver?.addConstraint(constraint);
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
this._private_solver = undefined;
|
|
240
|
+
}
|
|
241
|
+
this._private_recalculationRequired = true;
|
|
242
|
+
this.dirty = true;
|
|
243
|
+
}
|
|
244
|
+
return index;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Removes a constraint from the solver system.
|
|
248
|
+
*
|
|
249
|
+
* If the constraint is currently enabled, it will be removed from
|
|
250
|
+
* the active solver before deletion.
|
|
251
|
+
*
|
|
252
|
+
* @param index - Index of the constraint to remove
|
|
253
|
+
* @throws Will throw an error if the constraint doesn't exist
|
|
254
|
+
*/
|
|
255
|
+
removeConstraint(index) {
|
|
256
|
+
const description = this._private_constraints.get(index);
|
|
257
|
+
if (description === undefined) {
|
|
258
|
+
throw new Error(`UISolverWrapper.removeConstraint.index: constraint does not exist`);
|
|
259
|
+
}
|
|
260
|
+
if (description.enabled) {
|
|
261
|
+
try {
|
|
262
|
+
this._private_solver?.removeConstraint(description.constraint);
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
this._private_solver = undefined;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
this._private_constraints.delete(index);
|
|
269
|
+
this._private_recalculationRequired = true;
|
|
270
|
+
this.dirty = true;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Updates the left-hand side expression of an existing constraint.
|
|
274
|
+
*
|
|
275
|
+
* Rebuilds the underlying constraint with the new expression while
|
|
276
|
+
* preserving all other properties.
|
|
277
|
+
*
|
|
278
|
+
* @param index - Index of the constraint to modify
|
|
279
|
+
* @param lhs - New left-hand side expression
|
|
280
|
+
* @throws Will throw an error if the constraint doesn't exist
|
|
281
|
+
*/
|
|
282
|
+
setConstraintLHS(index, lhs) {
|
|
283
|
+
const description = this._private_constraints.get(index);
|
|
284
|
+
if (description === undefined) {
|
|
285
|
+
throw new Error(`UISolverWrapper.setConstraintLHS.index: constraint does not exist`);
|
|
286
|
+
}
|
|
287
|
+
description.lhs.copy(lhs);
|
|
288
|
+
this._private_rebuildConstraintByDescription(description);
|
|
289
|
+
this._private_recalculationRequired = true;
|
|
290
|
+
this.dirty = true;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Updates the right-hand side expression of an existing constraint.
|
|
294
|
+
*
|
|
295
|
+
* Rebuilds the underlying constraint with the new expression while
|
|
296
|
+
* preserving all other properties.
|
|
297
|
+
*
|
|
298
|
+
* @param index - Index of the constraint to modify
|
|
299
|
+
* @param rhs - New right-hand side expression
|
|
300
|
+
* @throws Will throw an error if the constraint doesn't exist
|
|
301
|
+
*/
|
|
302
|
+
setConstraintRHS(index, rhs) {
|
|
303
|
+
const description = this._private_constraints.get(index);
|
|
304
|
+
if (description === undefined) {
|
|
305
|
+
throw new Error(`UISolverWrapper.setConstraintRHS.index: constraint does not exist`);
|
|
306
|
+
}
|
|
307
|
+
description.rhs.copy(rhs);
|
|
308
|
+
this._private_rebuildConstraintByDescription(description);
|
|
309
|
+
this._private_recalculationRequired = true;
|
|
310
|
+
this.dirty = true;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Updates the relational operator of an existing constraint.
|
|
314
|
+
*
|
|
315
|
+
* Changes how the left and right expressions are compared
|
|
316
|
+
* (equal, less than, greater than).
|
|
317
|
+
*
|
|
318
|
+
* @param index - Index of the constraint to modify
|
|
319
|
+
* @param relation - New relational operator
|
|
320
|
+
* @throws Will throw an error if the constraint doesn't exist
|
|
321
|
+
*/
|
|
322
|
+
setConstraintRelation(index, relation) {
|
|
323
|
+
const description = this._private_constraints.get(index);
|
|
324
|
+
if (description === undefined) {
|
|
325
|
+
throw new Error(`UISolverWrapper.setConstraintRelation.index: constraint does not exist`);
|
|
326
|
+
}
|
|
327
|
+
if (description.relation !== relation) {
|
|
328
|
+
description.relation = relation;
|
|
329
|
+
this._private_rebuildConstraintByDescription(description);
|
|
330
|
+
this._private_recalculationRequired = true;
|
|
331
|
+
this.dirty = true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Updates the priority level of an existing constraint.
|
|
336
|
+
*
|
|
337
|
+
* Higher priority constraints are more likely to be satisfied
|
|
338
|
+
* when conflicts arise.
|
|
339
|
+
*
|
|
340
|
+
* @param index - Index of the constraint to modify
|
|
341
|
+
* @param priority - New priority level
|
|
342
|
+
* @throws Will throw an error if the constraint doesn't exist
|
|
343
|
+
*/
|
|
344
|
+
setConstraintPriority(index, priority) {
|
|
345
|
+
const description = this._private_constraints.get(index);
|
|
346
|
+
if (description === undefined) {
|
|
347
|
+
throw new Error(`UISolverWrapper.setConstraintPriority.index: constraint does not exist`);
|
|
348
|
+
}
|
|
349
|
+
if (description.priority !== priority) {
|
|
350
|
+
description.priority = priority;
|
|
351
|
+
this._private_rebuildConstraintByDescription(description);
|
|
352
|
+
this._private_recalculationRequired = true;
|
|
353
|
+
this.dirty = true;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Enables or disables an existing constraint.
|
|
358
|
+
*
|
|
359
|
+
* Disabled constraints are not considered during solving but
|
|
360
|
+
* remain in the system for potential re-enabling.
|
|
361
|
+
*
|
|
362
|
+
* @param index - Index of the constraint to modify
|
|
363
|
+
* @param enabled - Whether the constraint should be active
|
|
364
|
+
* @throws Will throw an error if the constraint doesn't exist
|
|
365
|
+
*/
|
|
366
|
+
setConstraintEnabled(index, enabled) {
|
|
367
|
+
const description = this._private_constraints.get(index);
|
|
368
|
+
if (description === undefined) {
|
|
369
|
+
throw new Error(`UISolverWrapper.setConstraintEnabled.index: constraint does not exist`);
|
|
370
|
+
}
|
|
371
|
+
if (enabled !== description.enabled) {
|
|
372
|
+
description.enabled = enabled;
|
|
373
|
+
try {
|
|
374
|
+
description.enabled
|
|
375
|
+
? this._private_solver?.addConstraint(description.constraint)
|
|
376
|
+
: this._private_solver?.removeConstraint(description.constraint);
|
|
377
|
+
}
|
|
378
|
+
catch {
|
|
379
|
+
this._private_solver = undefined;
|
|
380
|
+
}
|
|
381
|
+
this._private_recalculationRequired = true;
|
|
382
|
+
this.dirty = true;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Rebuilds a variable in the solver system with new properties.
|
|
387
|
+
*
|
|
388
|
+
* Temporarily removes all constraints that reference the variable,
|
|
389
|
+
* updates the variable configuration, then rebuilds and re-adds
|
|
390
|
+
* the dependent constraints.
|
|
391
|
+
*/
|
|
392
|
+
_private_rebuildVariable(index, description) {
|
|
393
|
+
const dependConstraints = [];
|
|
394
|
+
for (const cDescription of this._private_constraints.values()) {
|
|
395
|
+
if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {
|
|
396
|
+
try {
|
|
397
|
+
this._private_solver?.removeConstraint(cDescription.constraint);
|
|
398
|
+
}
|
|
399
|
+
catch {
|
|
400
|
+
this._private_solver = undefined;
|
|
401
|
+
}
|
|
402
|
+
dependConstraints.push(cDescription);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
this._private_solver?.removeEditVariable(description.variable);
|
|
406
|
+
this._private_solver?.addEditVariable(description.variable, convertPriority(description.priority));
|
|
407
|
+
for (const cDescription of dependConstraints) {
|
|
408
|
+
cDescription.constraint = this._private_buildConstraint(cDescription.lhs, cDescription.rhs, cDescription.relation, cDescription.priority);
|
|
409
|
+
}
|
|
410
|
+
for (const cDescription of dependConstraints) {
|
|
411
|
+
try {
|
|
412
|
+
this._private_solver?.addConstraint(cDescription.constraint);
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
this._private_solver = undefined;
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Rebuilds a constraint based on its current description.
|
|
422
|
+
*
|
|
423
|
+
* Uses different rebuild strategies depending on whether the
|
|
424
|
+
* constraint is currently enabled.
|
|
425
|
+
*/
|
|
426
|
+
_private_rebuildConstraintByDescription(description) {
|
|
427
|
+
description.constraint = description.enabled
|
|
428
|
+
? this._private_rebuildConstraint(description.constraint, description.lhs, description.rhs, description.relation, description.priority)
|
|
429
|
+
: this._private_buildConstraint(description.lhs, description.rhs, description.relation, description.priority);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Rebuilds a constraint by removing the old one and creating a new one.
|
|
433
|
+
*
|
|
434
|
+
* Safely handles solver state transitions and constraint replacement.
|
|
435
|
+
*/
|
|
436
|
+
_private_rebuildConstraint(oldConstraint, lhs, rhs, relation, priority) {
|
|
437
|
+
try {
|
|
438
|
+
this._private_solver?.removeConstraint(oldConstraint);
|
|
439
|
+
}
|
|
440
|
+
catch {
|
|
441
|
+
this._private_solver = undefined;
|
|
442
|
+
}
|
|
443
|
+
const constraint = this._private_buildConstraint(lhs, rhs, relation, priority);
|
|
444
|
+
try {
|
|
445
|
+
this._private_solver?.addConstraint(constraint);
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
this._private_solver = undefined;
|
|
449
|
+
}
|
|
450
|
+
return constraint;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Creates a new Kiwi constraint from UI expressions and parameters.
|
|
454
|
+
*
|
|
455
|
+
* Converts UI-level expressions and enums to Kiwi-compatible formats.
|
|
456
|
+
*/
|
|
457
|
+
_private_buildConstraint(lhs, rhs, relation, priority) {
|
|
458
|
+
return new Constraint(this._private_convertExpression(lhs), convertRelation(relation), this._private_convertExpression(rhs), convertPriority(priority));
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Converts a UIExpression to a Kiwi Expression.
|
|
462
|
+
*
|
|
463
|
+
* Maps variable indices to their corresponding Kiwi Variable instances
|
|
464
|
+
* and preserves coefficients and constants.
|
|
465
|
+
*/
|
|
466
|
+
_private_convertExpression(expression) {
|
|
467
|
+
return new Expression(...expression.prepareTerms().map(([variableIndex, coefficient]) => {
|
|
468
|
+
const description = this._private_variables.get(variableIndex);
|
|
469
|
+
if (description === undefined) {
|
|
470
|
+
throw new Error(`UISolverWrapper.convertExpression.expression: variable does not exist`);
|
|
471
|
+
}
|
|
472
|
+
return [coefficient, description.variable];
|
|
473
|
+
}), expression.constant);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Completely rebuilds the solver from scratch.
|
|
477
|
+
*
|
|
478
|
+
* Re-adds all variables and constraints to a fresh solver instance.
|
|
479
|
+
* Used for recovery when the solver enters an invalid state.
|
|
480
|
+
*/
|
|
481
|
+
_private_rebuildSolver() {
|
|
482
|
+
if (this._private_solver) {
|
|
483
|
+
throw new Error("UISolverWrapper.rebuildSolver: solver already exists");
|
|
484
|
+
}
|
|
485
|
+
this._private_solver = new Solver();
|
|
486
|
+
for (const description of this._private_variables.values()) {
|
|
487
|
+
if (description.constraint) {
|
|
488
|
+
this._private_solver.addConstraint(description.constraint);
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
this._private_solver.addEditVariable(description.variable, convertPriority(description.priority));
|
|
492
|
+
this._private_solver.suggestValue(description.variable, description.value);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
for (const description of this._private_constraints.values()) {
|
|
496
|
+
if (description.enabled) {
|
|
497
|
+
this._private_solver.addConstraint(description.constraint);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
this._private_recalculationRequired = true;
|
|
501
|
+
this.dirty = true;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export { UISolverWrapper };
|