@likec4/core 1.31.0 → 1.32.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 +407 -5
- package/dist/builder/index.d.mts +221 -42
- package/dist/builder/index.mjs +118 -65
- package/dist/compute-view/index.d.mts +23 -7
- package/dist/compute-view/index.mjs +11 -6
- package/dist/compute-view/relationships-view/index.d.mts +9 -7
- package/dist/compute-view/relationships-view/index.mjs +3 -2
- package/dist/index.d.mts +10 -14
- package/dist/index.mjs +9 -6
- package/dist/model/index.d.mts +173 -19
- package/dist/model/index.mjs +6 -1
- package/dist/shared/core.BaYE_r29.d.mts +258 -0
- package/dist/shared/core.Bk7wEZFG.mjs +276 -0
- package/dist/shared/core.BrCnZFTn.mjs +32 -0
- package/dist/shared/core.BuO4ncfY.d.mts +146 -0
- package/dist/shared/{core.Bq753SYD.mjs → core.CBpKAlhj.mjs} +2012 -4422
- package/dist/shared/core.CUYDgv2-.mjs +214 -0
- package/dist/shared/{core.Cu-UdkSl.mjs → core.CpXlRyE5.mjs} +7 -494
- package/dist/shared/{core.C-YXI-43.mjs → core.Cy9smucx.mjs} +3 -1
- package/dist/shared/core.CywrQs86.d.mts +31 -0
- package/dist/shared/core.DXzRBkuI.d.mts +1264 -0
- package/dist/shared/core.DoK86JEe.mjs +518 -0
- package/dist/shared/{core.D2830qgg.d.mts → core.Pf5I9o0e.d.mts} +1 -1
- package/dist/shared/core.cbA9VZ02.mjs +2681 -0
- package/dist/shared/{core.CQXU9DF7.mjs → core.rmvsy0n3.mjs} +23 -32
- package/dist/shared/core.znRaUX_A.d.mts +920 -0
- package/dist/types/aux.d.mts +3 -0
- package/dist/types/aux.mjs +1 -0
- package/dist/types/index.d.mts +7 -45
- package/dist/types/index.mjs +130 -3
- package/dist/utils/index.d.mts +221 -53
- package/dist/utils/index.mjs +14 -10
- package/package.json +16 -8
- package/src/builder/Builder.deploymentModel.ts +82 -18
- package/src/builder/Builder.element.ts +40 -20
- package/src/builder/Builder.model.ts +66 -17
- package/src/builder/Builder.ts +168 -76
- package/src/builder/Builder.view-common.ts +35 -17
- package/src/builder/Builder.view-deployment.ts +25 -25
- package/src/builder/Builder.view-element.ts +13 -12
- package/src/builder/Builder.views.ts +12 -7
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +62 -34
- package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +319 -0
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +45 -24
- package/src/builder/_types.ts +34 -27
- package/src/compute-view/compute-view.ts +31 -34
- package/src/compute-view/deployment-view/__test__/TestHelper.ts +27 -14
- package/src/compute-view/deployment-view/__test__/fixture.ts +15 -13
- package/src/compute-view/deployment-view/_types.ts +10 -10
- package/src/compute-view/deployment-view/clean-connections.ts +5 -7
- package/src/compute-view/deployment-view/compute.ts +16 -13
- package/src/compute-view/deployment-view/memory/memory.ts +5 -6
- package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +4 -5
- package/src/compute-view/deployment-view/predicates/relation-direct.ts +25 -50
- package/src/compute-view/deployment-view/predicates/relation-in-out.ts +5 -7
- package/src/compute-view/deployment-view/predicates/relation-incoming.ts +7 -11
- package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +7 -10
- package/src/compute-view/deployment-view/predicates/utils.ts +37 -31
- package/src/compute-view/deployment-view/predicates/wildcard.ts +3 -2
- package/src/compute-view/deployment-view/stages/stage-final.ts +2 -2
- package/src/compute-view/deployment-view/stages/stage-include.ts +1 -1
- package/src/compute-view/deployment-view/utils.ts +79 -72
- package/src/compute-view/dynamic-view/__test__/fixture.ts +20 -11
- package/src/compute-view/dynamic-view/compute.ts +60 -53
- package/src/compute-view/element-view/__test__/TestHelper.ts +53 -29
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +26 -26
- package/src/compute-view/element-view/__test__/fixture.ts +134 -83
- package/src/compute-view/element-view/_types.ts +14 -19
- package/src/compute-view/element-view/clean-connections.ts +12 -8
- package/src/compute-view/element-view/compute.ts +61 -51
- package/src/compute-view/element-view/memory/NodeGroup.ts +8 -9
- package/src/compute-view/element-view/memory/memory.ts +22 -22
- package/src/compute-view/element-view/memory/stage-include.ts +5 -3
- package/src/compute-view/element-view/predicates/_utils.ts +18 -14
- package/src/compute-view/element-view/predicates/element-expand.ts +4 -5
- package/src/compute-view/element-view/predicates/element-kind-tag.ts +3 -4
- package/src/compute-view/element-view/predicates/element-ref.ts +3 -4
- package/src/compute-view/element-view/predicates/relation-direct.ts +16 -12
- package/src/compute-view/element-view/predicates/relation-in-out.ts +7 -8
- package/src/compute-view/element-view/predicates/relation-in.ts +19 -26
- package/src/compute-view/element-view/predicates/relation-out.ts +20 -21
- package/src/compute-view/element-view/predicates/wildcard.ts +3 -3
- package/src/compute-view/element-view/utils.ts +25 -23
- package/src/compute-view/index.ts +1 -1
- package/src/compute-view/memory/AbstractStageExclude.ts +3 -4
- package/src/compute-view/memory/AbstractStageInclude.ts +1 -1
- package/src/compute-view/memory/_types.ts +3 -2
- package/src/compute-view/relationships-view/_types.ts +3 -4
- package/src/compute-view/relationships-view/compute.ts +8 -11
- package/src/compute-view/relationships-view/layout.ts +6 -6
- package/src/compute-view/relationships-view/utils.ts +4 -4
- package/src/compute-view/utils/ancestorsOfNode.ts +7 -7
- package/src/compute-view/utils/applyCustomElementProperties.ts +16 -8
- package/src/compute-view/utils/applyCustomRelationProperties.ts +19 -9
- package/src/compute-view/utils/applyViewRuleStyles.ts +18 -10
- package/src/compute-view/utils/buildComputedNodes.ts +40 -40
- package/src/compute-view/utils/buildElementNotations.ts +14 -14
- package/src/compute-view/utils/elementExpressionToPredicate.ts +14 -15
- package/src/compute-view/utils/link-nodes-with-edges.ts +6 -4
- package/src/compute-view/utils/merge-props-from-relationships.ts +52 -20
- package/src/compute-view/utils/relationExpressionToPredicates.ts +19 -19
- package/src/compute-view/utils/resolve-extended-views.ts +8 -7
- package/src/compute-view/utils/resolve-global-rules.ts +31 -26
- package/src/compute-view/utils/topological-sort.ts +14 -14
- package/src/compute-view/utils/view-hash.ts +2 -2
- package/src/compute-view/utils/with-readable-edges.ts +9 -5
- package/src/index.ts +0 -32
- package/src/model/DeploymentElementModel.ts +171 -144
- package/src/model/DeploymentModel.ts +88 -65
- package/src/model/ElementModel.ts +85 -74
- package/src/model/LikeC4Model.ts +430 -241
- package/src/model/RelationModel.ts +63 -29
- package/src/model/__test__/fixture.ts +50 -36
- package/src/model/connection/Connection.ts +2 -2
- package/src/model/connection/deployment/DeploymentConnectionModel.ts +21 -24
- package/src/model/connection/deployment/find.ts +1 -1
- package/src/model/connection/model/ConnectionModel.ts +21 -20
- package/src/model/connection/model/find.ts +7 -7
- package/src/model/connection/ops.ts +6 -6
- package/src/model/guards.ts +66 -14
- package/src/model/index.ts +20 -7
- package/src/model/types.ts +41 -97
- package/src/model/view/EdgeModel.ts +47 -41
- package/src/model/view/LikeC4ViewModel.ts +130 -80
- package/src/model/view/NodeModel.ts +102 -96
- package/src/theme/element.ts +1 -1
- package/src/theme/index.ts +9 -9
- package/src/theme/relationships.ts +1 -1
- package/src/types/_common.ts +21 -15
- package/src/types/aux.ts +285 -0
- package/src/types/const.ts +34 -0
- package/src/types/expression-model.ts +292 -0
- package/src/types/expression.ts +311 -0
- package/src/types/fqnRef.ts +88 -0
- package/src/types/geometry.ts +131 -0
- package/src/types/global.ts +10 -8
- package/src/types/index.ts +39 -201
- package/src/types/model-data.ts +52 -84
- package/src/types/model-deployment.ts +87 -0
- package/src/types/model-dump.ts +72 -0
- package/src/types/model-logical.ts +111 -0
- package/src/types/model-spec.ts +81 -0
- package/src/types/operators.ts +51 -52
- package/src/types/scalar.ts +114 -0
- package/src/types/{theme.ts → styles.ts} +55 -15
- package/src/types/view-changes.ts +4 -5
- package/src/types/view-common.ts +157 -0
- package/src/types/view-computed.ts +113 -0
- package/src/types/view-layouted.ts +82 -0
- package/src/types/view-parsed.deployment.ts +40 -0
- package/src/types/view-parsed.dynamic.ts +78 -0
- package/src/types/view-parsed.element.ts +65 -0
- package/src/types/view.ts +122 -542
- package/src/utils/compare-natural.ts +43 -1
- package/src/utils/getOrCreate.ts +0 -34
- package/src/utils/index.ts +7 -12
- package/src/utils/iterable/filter.ts +1 -1
- package/src/utils/iterable/find.ts +3 -1
- package/src/utils/iterable/head.ts +22 -0
- package/src/utils/iterable/index.ts +1 -0
- package/src/utils/iterable/map.ts +1 -1
- package/src/utils/iterable/reduce.ts +1 -1
- package/src/utils/iterable/some.ts +1 -1
- package/src/utils/memoize-prop.ts +30 -0
- package/src/utils/object-hash.ts +1 -1
- package/src/utils/relations.ts +14 -11
- package/src/utils/string-hash.ts +1 -1
- package/dist/shared/core.CQDU11hR.d.mts +0 -753
- package/dist/shared/core.DJvmfnEi.d.mts +0 -1153
- package/dist/shared/core.DgfwjBtu.mjs +0 -495
- package/dist/shared/core.Dx7siloV.d.mts +0 -146
- package/dist/shared/core.SjLhMA7a.d.mts +0 -62
- package/src/builder/__snapshots__/Builder.spec.ts.snap +0 -374
- package/src/compute-view/element-view/predicates.ts +0 -520
- package/src/compute-view/utils/uniqueTags.ts +0 -21
- package/src/types/deployments.ts +0 -170
- package/src/types/element.ts +0 -109
- package/src/types/expression-v2-model.ts +0 -314
- package/src/types/expression-v2.ts +0 -392
- package/src/types/overview-graph.ts +0 -43
- package/src/types/relation.ts +0 -61
- package/src/types/scalars.ts +0 -39
- package/src/types/view-notation.ts +0 -9
- package/src/utils/graphlib.ts +0 -10
- /package/src/{errors/index.ts → utils/invariant.ts} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import 'type-fest';
|
|
2
|
+
import '../shared/core.BuO4ncfY.mjs';
|
|
3
|
+
export { y as AllKinds, A as Any, A as AnyAux, C as AnySpec, b as Aux, q as DeploymentFqn, u as DeploymentId, D as DeploymentKind, h as EdgeId, g as ElementId, l as ElementKind, F as Fqn, p as LooseDeploymentId, a3 as LooseDeploymentKind, o as LooseElementId, a2 as LooseElementKind, a4 as LooseRelationKind, L as LooseTag, a1 as LooseTags, x as LooseViewId, j as Metadata, k as MetadataKey, N as Never, I as NodeId, a0 as OrString, G as PickByStage, P as ProjectId, m as RelationId, R as RelationKind, J as Spec, S as SpecAux, s as Stage, q as StrictDeploymentFqn, X as StrictDeploymentKind, Q as StrictElementKind, F as StrictFqn, K as StrictProjectId, Y as StrictRelationKind, O as StrictTag, n as StrictViewId, v as Tag, T as Tags, U as Unknown, c as UnknownComputed, d as UnknownLayouted, e as UnknownParsed, V as ViewId, $ as WithLinks, B as WithMetadata, z as WithOptionalLinks, W as WithOptionalTags, Z as WithTags, H as setStage, t as toComputed, r as toLayouted, w as toParsed } from '../shared/core.BaYE_r29.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,48 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { d as NonEmptyArray, F as Fqn, D as DeploymentFqn } from '../shared/core.BuO4ncfY.mjs';
|
|
2
|
+
export { A as AnyFqn, B as BuiltInIcon, C as Coalesce, b as DeploymentKind, E as EdgeId, a as ElementKind, f as ExclusiveUnion, m as GlobalFqn, G as GroupElementKind, i as Icon, j as IconUrl, I as IteratorLike, K as KeysOf, L as Link, g as NTuple, N as NodeId, e as NonEmptyReadonlyArray, h as Predicate, P as ProjectId, R as RelationId, l as RelationKind, c as RelationshipKind, p as StepEdgeId, S as StepEdgeIdLiteral, r as StepEdgeKind, T as Tag, V as ViewId, u as extractStep, n as isGlobalFqn, k as isGroupElementKind, t as isStepEdgeId, s as scalar, o as splitGlobalFqn, q as stepEdgeId } from '../shared/core.BuO4ncfY.mjs';
|
|
3
|
+
export { A as Any, A as AnyAux, b as Aux, E as ExtractOnStage, M as ModelStage, S as SpecAux, U as Unknown, c as UnknownComputed, d as UnknownLayouted, e as UnknownParsed, _ as _stage, f as _type, a as aux, i as isOnStage } from '../shared/core.BaYE_r29.mjs';
|
|
4
|
+
import { ap as BorderStyle, ar as ElementShape, ay as ThemeColor, b7 as ViewManualLayout, b2 as AutoLayoutDirection } from '../shared/core.DXzRBkuI.mjs';
|
|
5
|
+
export { W as AbstractRelationship, ad as AndOperator, aY as AnyExcludePredicate, aX as AnyIncludePredicate, aK as AnyView, aZ as AnyViewRuleStyle, y as AuxFromDump, A as AuxFromLikeC4ModelData, B as BBox, ba as BaseParsedViewProperties, b9 as BaseViewProperties, ao as BorderStyles, az as Color, C as ColorLiteral, bh as ComputedDeploymentView, bi as ComputedDynamicView, bf as ComputedEdge, bg as ComputedElementView, l as ComputedLikeC4ModelData, be as ComputedNode, aI as ComputedView, at as CustomColor, au as CustomColorDefinitions, U as DefaultArrowType, H as DefaultElementShape, Q as DefaultLineStyle, J as DefaultPaddingSize, V as DefaultRelationshipColor, I as DefaultShapeSize, K as DefaultTextSize, z as DefaultThemeColor, p as DeployedInstance, q as DeploymentElement, r as DeploymentElementRef, D as DeploymentElementStyle, o as DeploymentNode, v as DeploymentRelation, u as DeploymentRelationship, bp as DeploymentViewExcludePredicate, bo as DeploymentViewIncludePredicate, bq as DeploymentViewPredicate, bs as DeploymentViewRule, br as DeploymentViewRuleStyle, bk as DiagramEdge, bj as DiagramNode, aG as DiagramView, by as DynamicViewIncludeRule, bv as DynamicViewParallelSteps, bz as DynamicViewRule, bu as DynamicViewStep, bx as DynamicViewStepOrParallel, O as Element, aq as ElementShapes, _ as ElementSpecification, N as ElementStyle, aB as ElementThemeColorValues, aC as ElementThemeColors, bD as ElementViewExcludePredicate, bC as ElementViewIncludePredicate, bE as ElementViewPredicate, bI as ElementViewRule, bF as ElementViewRuleGroup, bH as ElementViewRuleStyle, a3 as EqualOperator, E as Expression, ai as Filterable, F as FqnExpr, c as FqnRef, g as GlobalDynamicPredicates, G as GlobalPredicateId, f as GlobalPredicates, h as GlobalStyleID, i as GlobalStyles, as as HexColor, a6 as KindEqual, bm as LayoutedDeploymentView, bn as LayoutedDynamicView, bl as LayoutedElementView, m as LayoutedLikeC4ModelData, aG as LayoutedView, n as LikeC4ModelData, x as LikeC4ModelDump, L as LikeC4Theme, aF as LikeC4View, b as ModelExpression, M as ModelFqnExpr, j as ModelGlobals, Z as ModelRelation, a as ModelRelationExpr, bb as NodeNotation, ab as NotOperator, aj as OperatorPredicate, af as OrOperator, bt as ParsedDeploymentView, bA as ParsedDynamicView, bJ as ParsedElementView, k as ParsedLikeC4ModelData, aF as ParsedView, a8 as Participant, a9 as ParticipantOperator, d as Point, P as PredicateSelector, aJ as ProcessedView, e as RectBox, R as RelationExpr, Y as Relationship, aw as RelationshipArrowType, av as RelationshipLineType, a1 as RelationshipSpecification, aD as RelationshipThemeColorValues, aE as RelationshipThemeColors, an as ShapeSize, al as SpacingSize, w as SpecTypesFromDump, a2 as Specification, S as SpecificationDump, a4 as TagEqual, $ as TagSpecification, am as TextSize, T as ThemeColorValues, ax as ThemeColors, b6 as ViewAutoLayout, aL as ViewOnStage, aN as ViewRule, b4 as ViewRuleAutoLayout, b0 as ViewRuleGlobalPredicateRef, a_ as ViewRuleGlobalStyle, aO as ViewRulePredicate, b8 as ViewType, bd as ViewWithHash, bc as ViewWithNotation, aM as ViewWithType, ah as WhereOperator, X as XYPoint, bw as getParallelStepsPrefix, ae as isAndOperator, b3 as isAutoLayoutDirection, aR as isComputedView, t as isDeployedInstance, s as isDeploymentNode, aV as isDeploymentView, aH as isDiagramView, aW as isDynamicView, bB as isDynamicViewParallelSteps, aS as isElementView, aU as isExtendsElementView, a7 as isKindEqual, aH as isLayoutedView, ac as isNotOperator, ag as isOrOperator, aa as isParticipantOperator, aT as isScopedElementView, a0 as isTagColorSpecified, a5 as isTagEqual, aA as isThemeColor, b5 as isViewRuleAutoLayout, b1 as isViewRuleGlobalPredicateRef, a$ as isViewRuleGlobalStyle, bG as isViewRuleGroup, aP as isViewRulePredicate, aQ as isViewRuleStyle, ak as whereOperatorAsPredicate } from '../shared/core.DXzRBkuI.mjs';
|
|
5
6
|
import 'type-fest';
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
-
* OverviewGraph is a graph representation of all views in a model
|
|
9
|
-
*/
|
|
10
|
-
declare namespace OverviewGraph {
|
|
11
|
-
type Node = {
|
|
12
|
-
id: string;
|
|
13
|
-
type: 'folder' | 'file';
|
|
14
|
-
path: string;
|
|
15
|
-
label: string;
|
|
16
|
-
parentId: string | null;
|
|
17
|
-
position: XYPoint;
|
|
18
|
-
width: number;
|
|
19
|
-
height: number;
|
|
20
|
-
} | {
|
|
21
|
-
id: string;
|
|
22
|
-
type: 'view';
|
|
23
|
-
viewId: ViewId;
|
|
24
|
-
label: string;
|
|
25
|
-
parentId: string | null;
|
|
26
|
-
position: XYPoint;
|
|
27
|
-
width: number;
|
|
28
|
-
height: number;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Edge represents a navigational link from one view to another
|
|
32
|
-
*/
|
|
33
|
-
type Edge = {
|
|
34
|
-
id: string;
|
|
35
|
-
source: string;
|
|
36
|
-
target: string;
|
|
37
|
-
points: NonEmptyArray<Point>;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
interface OverviewGraph {
|
|
41
|
-
nodes: OverviewGraph.Node[];
|
|
42
|
-
edges: OverviewGraph.Edge[];
|
|
43
|
-
bounds: BBox;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
8
|
declare namespace ViewChange {
|
|
47
9
|
interface ChangeElementStyle {
|
|
48
10
|
op: 'change-element-style';
|
|
@@ -52,7 +14,7 @@ declare namespace ViewChange {
|
|
|
52
14
|
shape?: ElementShape;
|
|
53
15
|
color?: ThemeColor;
|
|
54
16
|
};
|
|
55
|
-
targets: NonEmptyArray<Fqn>;
|
|
17
|
+
targets: NonEmptyArray<Fqn | DeploymentFqn>;
|
|
56
18
|
}
|
|
57
19
|
interface SaveManualLayout {
|
|
58
20
|
op: 'save-manual-layout';
|
|
@@ -69,4 +31,4 @@ declare namespace ViewChange {
|
|
|
69
31
|
}
|
|
70
32
|
type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
|
|
71
33
|
|
|
72
|
-
export { AutoLayoutDirection,
|
|
34
|
+
export { AutoLayoutDirection, BorderStyle, DeploymentFqn, ElementShape, Fqn, NonEmptyArray, ThemeColor, ViewChange, ViewManualLayout };
|
package/dist/types/index.mjs
CHANGED
|
@@ -1,5 +1,132 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { f as DefaultArrowType, D as DefaultElementShape, g as DefaultLineStyle, m as DefaultPaddingSize, h as DefaultRelationshipColor, l as DefaultShapeSize, p as DefaultTextSize, a as DefaultThemeColor, A as DeploymentFqn, H as EdgeId, z as Fqn, F as FqnRef, B as GlobalFqn, G as GroupElementKind, N as NodeId, R as RelationId, S as StepEdgeKind, V as ViewId, b as _stage, _ as _type, I as extractStep, v as isAndOperator, i as isDeployedInstance, k as isDeploymentNode, C as isGlobalFqn, e as isGroupElementKind, r as isKindEqual, u as isNotOperator, j as isOnStage, x as isOrOperator, t as isParticipantOperator, d as isStepEdgeId, q as isTagEqual, E as splitGlobalFqn, s as stepEdgeId, w as whereOperatorAsPredicate } from '../shared/core.CUYDgv2-.mjs';
|
|
2
|
+
export { E as Expression, F as FqnExpr, k as ModelExpression, M as ModelFqnExpr, j as ModelRelationExpr, R as RelationExpr, s as getParallelStepsPrefix, r as isAutoLayoutDirection, n as isComputedView, m as isDeploymentView, p as isDiagramView, l as isDynamicView, h as isDynamicViewParallelSteps, a as isElementView, i as isExtendsElementView, p as isLayoutedView, q as isScopedElementView, d as isViewRuleAutoLayout, f as isViewRuleGlobalPredicateRef, g as isViewRuleGlobalStyle, e as isViewRuleGroup, c as isViewRulePredicate, b as isViewRuleStyle } from '../shared/core.Bk7wEZFG.mjs';
|
|
3
|
+
import { i as invariant } from '../shared/core.Cy9smucx.mjs';
|
|
4
|
+
import '../shared/core.DbRvwARP.mjs';
|
|
2
5
|
|
|
6
|
+
var BBox;
|
|
7
|
+
((BBox2) => {
|
|
8
|
+
function center({ x, y, width, height }) {
|
|
9
|
+
return {
|
|
10
|
+
x: x + width / 2,
|
|
11
|
+
y: y + height / 2
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
BBox2.center = center;
|
|
15
|
+
function fromPoints(points) {
|
|
16
|
+
const { x1, y1, x2, y2 } = RectBox.fromPoints(points);
|
|
17
|
+
return {
|
|
18
|
+
x: x1,
|
|
19
|
+
y: y1,
|
|
20
|
+
width: x2 - x1,
|
|
21
|
+
height: y2 - y1
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
BBox2.fromPoints = fromPoints;
|
|
25
|
+
function merge(...boxes) {
|
|
26
|
+
invariant(boxes.length > 0, "No boxes provided");
|
|
27
|
+
let minX = Infinity;
|
|
28
|
+
let minY = Infinity;
|
|
29
|
+
let maxX = -Infinity;
|
|
30
|
+
let maxY = -Infinity;
|
|
31
|
+
for (const box of boxes) {
|
|
32
|
+
minX = Math.min(minX, box.x);
|
|
33
|
+
minY = Math.min(minY, box.y);
|
|
34
|
+
maxX = Math.max(maxX, box.x + box.width);
|
|
35
|
+
maxY = Math.max(maxY, box.y + box.height);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
x: minX,
|
|
39
|
+
y: minY,
|
|
40
|
+
width: maxX - minX,
|
|
41
|
+
height: maxY - minY
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
BBox2.merge = merge;
|
|
45
|
+
function toRectBox(box) {
|
|
46
|
+
return {
|
|
47
|
+
x1: box.x,
|
|
48
|
+
y1: box.y,
|
|
49
|
+
x2: box.x + box.width,
|
|
50
|
+
y2: box.y + box.height
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
BBox2.toRectBox = toRectBox;
|
|
54
|
+
})(BBox || (BBox = {}));
|
|
55
|
+
var RectBox;
|
|
56
|
+
((RectBox2) => {
|
|
57
|
+
function center({ x1, y1, x2, y2 }) {
|
|
58
|
+
return {
|
|
59
|
+
x: (x1 + x2) / 2,
|
|
60
|
+
y: (y1 + y2) / 2
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
RectBox2.center = center;
|
|
64
|
+
function fromPoints(points) {
|
|
65
|
+
invariant(points.length > 0, "At least one point is required");
|
|
66
|
+
let minX = Infinity;
|
|
67
|
+
let minY = Infinity;
|
|
68
|
+
let maxX = -Infinity;
|
|
69
|
+
let maxY = -Infinity;
|
|
70
|
+
for (const [x, y] of points) {
|
|
71
|
+
minX = Math.min(minX, x);
|
|
72
|
+
minY = Math.min(minY, y);
|
|
73
|
+
maxX = Math.max(maxX, x);
|
|
74
|
+
maxY = Math.max(maxY, y);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
x1: minX,
|
|
78
|
+
y1: minY,
|
|
79
|
+
x2: maxX,
|
|
80
|
+
y2: maxY
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
RectBox2.fromPoints = fromPoints;
|
|
84
|
+
function merge(...boxes) {
|
|
85
|
+
invariant(boxes.length > 0, "No boxes provided");
|
|
86
|
+
let minX = Infinity;
|
|
87
|
+
let minY = Infinity;
|
|
88
|
+
let maxX = -Infinity;
|
|
89
|
+
let maxY = -Infinity;
|
|
90
|
+
for (const box of boxes) {
|
|
91
|
+
minX = Math.min(minX, box.x1);
|
|
92
|
+
minY = Math.min(minY, box.y1);
|
|
93
|
+
maxX = Math.max(maxX, box.x2);
|
|
94
|
+
maxY = Math.max(maxY, box.y2);
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
x1: minX,
|
|
98
|
+
y1: minY,
|
|
99
|
+
x2: maxX,
|
|
100
|
+
y2: maxY
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
RectBox2.merge = merge;
|
|
104
|
+
function toBBox(box) {
|
|
105
|
+
return {
|
|
106
|
+
x: box.x1,
|
|
107
|
+
y: box.y1,
|
|
108
|
+
width: box.x2 - box.x1,
|
|
109
|
+
height: box.y2 - box.y1
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
RectBox2.toBBox = toBBox;
|
|
113
|
+
})(RectBox || (RectBox = {}));
|
|
114
|
+
|
|
115
|
+
function isTagColorSpecified(spec) {
|
|
116
|
+
const color = typeof spec === "string" ? spec : spec.color;
|
|
117
|
+
return color.startsWith("#") || color.startsWith("rgb");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const BorderStyles = ["solid", "dashed", "dotted", "none"];
|
|
121
|
+
const ElementShapes = [
|
|
122
|
+
"rectangle",
|
|
123
|
+
"person",
|
|
124
|
+
"browser",
|
|
125
|
+
"mobile",
|
|
126
|
+
"cylinder",
|
|
127
|
+
"storage",
|
|
128
|
+
"queue"
|
|
129
|
+
];
|
|
3
130
|
const ThemeColors = [
|
|
4
131
|
"amber",
|
|
5
132
|
"blue",
|
|
@@ -14,7 +141,7 @@ const ThemeColors = [
|
|
|
14
141
|
"sky"
|
|
15
142
|
];
|
|
16
143
|
function isThemeColor(color) {
|
|
17
|
-
return color
|
|
144
|
+
return ThemeColors.includes(color);
|
|
18
145
|
}
|
|
19
146
|
|
|
20
|
-
export { ThemeColors, isThemeColor };
|
|
147
|
+
export { BBox, BorderStyles, ElementShapes, RectBox, ThemeColors, isTagColorSpecified, isThemeColor };
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Mnemonist DefaultMap Typings
|
|
7
|
-
* =============================
|
|
8
|
-
*/
|
|
9
|
-
declare class DefaultMap<K, V> implements Iterable<[K, V]> {
|
|
10
|
-
|
|
11
|
-
// Members
|
|
12
|
-
size: number;
|
|
13
|
-
|
|
14
|
-
// Constructor
|
|
15
|
-
constructor(factory: (key: K, index: number) => V);
|
|
16
|
-
|
|
17
|
-
// Methods
|
|
18
|
-
clear(): void;
|
|
19
|
-
set(key: K, value: V): this;
|
|
20
|
-
delete(key: K): boolean;
|
|
21
|
-
has(key: K): boolean;
|
|
22
|
-
get(key: K): V;
|
|
23
|
-
peek(key: K): V | undefined;
|
|
24
|
-
forEach(callback: (value: V, key: K, map: this) => void, scope?: any): void;
|
|
25
|
-
keys(): IterableIterator<K>;
|
|
26
|
-
values(): IterableIterator<V>;
|
|
27
|
-
entries(): IterableIterator<[K, V]>;
|
|
28
|
-
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
29
|
-
inspect(): any;
|
|
30
|
-
|
|
31
|
-
// Statics
|
|
32
|
-
static autoIncrement(): number;
|
|
33
|
-
}
|
|
1
|
+
export { D as DefaultMap } from '../shared/core.CywrQs86.mjs';
|
|
2
|
+
export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from '../shared/core.Pf5I9o0e.mjs';
|
|
3
|
+
import { d as NonEmptyArray, I as IteratorLike } from '../shared/core.BuO4ncfY.mjs';
|
|
4
|
+
import { Tagged, Simplify, Or, IfNever, IsLiteral, And, GreaterThan, IsNever, IsEqual, ReadonlyTuple, IsNumericLiteral } from 'type-fest';
|
|
34
5
|
|
|
35
6
|
/**
|
|
36
7
|
* Mnemonist DefaultWeakMap Typings
|
|
@@ -245,6 +216,10 @@ declare class BiMap<K, V> implements Iterable<[K, V]> {
|
|
|
245
216
|
static from<I, J>(iterable: Iterable<[I, J]> | {[key: string]: J}): BiMap<I, J>;
|
|
246
217
|
}
|
|
247
218
|
|
|
219
|
+
declare function nonNullable<T>(value: T, message?: string | (() => string)): NonNullable<T>;
|
|
220
|
+
declare function invariant(condition: any, message?: string): asserts condition;
|
|
221
|
+
declare function nonexhaustive(value: never): never;
|
|
222
|
+
|
|
248
223
|
/**
|
|
249
224
|
* Common head of two arrays
|
|
250
225
|
*
|
|
@@ -253,6 +228,26 @@ declare class BiMap<K, V> implements Iterable<[K, V]> {
|
|
|
253
228
|
declare function commonHead<T>(sources: ReadonlyArray<T>, targets: ReadonlyArray<T>, equals?: (a: T, b: T) => boolean): T[];
|
|
254
229
|
|
|
255
230
|
declare function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1;
|
|
231
|
+
/**
|
|
232
|
+
* Compares two strings hierarchically based on their depth.
|
|
233
|
+
* From parent nodes to leaves
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* const lines = [
|
|
237
|
+
* 'a.b.c',
|
|
238
|
+
* 'a',
|
|
239
|
+
* 'a.b',
|
|
240
|
+
* 'a.c.c',
|
|
241
|
+
* ]
|
|
242
|
+
* lines.sort(compareNaturalHierarchically('.'))
|
|
243
|
+
* // [
|
|
244
|
+
* // 'a',
|
|
245
|
+
* // 'a.b',
|
|
246
|
+
* // 'a.b.c',
|
|
247
|
+
* // 'a.c.c',
|
|
248
|
+
* // ]
|
|
249
|
+
*/
|
|
250
|
+
declare function compareNaturalHierarchically(separator?: string): (a: string | undefined, b: string | undefined) => number;
|
|
256
251
|
|
|
257
252
|
declare function getOrCreate<K, V>(map: Map<K, V>, key: K, create: (key: K) => V): V;
|
|
258
253
|
|
|
@@ -270,19 +265,155 @@ declare function getOrCreate<K, V>(map: Map<K, V>, key: K, create: (key: K) => V
|
|
|
270
265
|
*/
|
|
271
266
|
type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly [];
|
|
272
267
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
268
|
+
declare const RemedaErrorSymbol: unique symbol;
|
|
269
|
+
type RemedaTypeErrorOptions = {
|
|
270
|
+
type?: unknown;
|
|
271
|
+
metadata?: unknown;
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Used for reporting type errors in a more useful way than `never`.
|
|
275
|
+
*/
|
|
276
|
+
type RemedaTypeError<Name extends string, Message extends string, Options extends RemedaTypeErrorOptions = {}> = Tagged<Options extends {
|
|
277
|
+
type: infer T;
|
|
278
|
+
} ? T : typeof RemedaErrorSymbol, `RemedaTypeError(${Name}): ${Message}.`, Options extends {
|
|
279
|
+
metadata: infer Metadata;
|
|
280
|
+
} ? Metadata : never>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Takes a tuple and returns the types that make up its parts. These parts
|
|
284
|
+
* follow TypeScript's only supported format for arrays/tuples:
|
|
285
|
+
* [<required>, <optional>, ...<rest>[], <suffix>].
|
|
286
|
+
*
|
|
287
|
+
* There are some limitations to what shapes TypeScript supports:
|
|
288
|
+
* tuples can only have a suffix if they also have a non-never rest element,
|
|
289
|
+
* **and** tuples cannot have both an optional part and a suffix; this means
|
|
290
|
+
* there are only 10 possible shapes for tuples:
|
|
291
|
+
* 1. Empty Tuples: `[]`.
|
|
292
|
+
* 2. Fixed Tuples: `[string, number]`.
|
|
293
|
+
* 3. Optional Tuples: `[string?, number?]`.
|
|
294
|
+
* 4. Mixed Tuples: `[string, number?]`.
|
|
295
|
+
* 5. Arrays: `Array<string>`.
|
|
296
|
+
* 6. Fixed-Prefix Arrays: `[string, ...Array<string>]`.
|
|
297
|
+
* 7. Optional-Prefix Arrays: `[number?, ...Array<boolean>]`.
|
|
298
|
+
* 8. Mixed-Prefix Arrays: `[string, number?, ...Array<boolean>]`.
|
|
299
|
+
* 9. Fixed-Suffix Arrays: `[...Array<string>, string]`.
|
|
300
|
+
* 10. Fixed-Elements Arrays: `[string, ...Array<string>, string]`.
|
|
301
|
+
*
|
|
302
|
+
* @example [
|
|
303
|
+
* ...TupleParts<T>["required"],
|
|
304
|
+
* ...Partial<TupleParts<T>["optional"]>,
|
|
305
|
+
* ...CoercedArray<TupleParts<T>["item"]>,
|
|
306
|
+
* ...TupleParts<T>["suffix"],
|
|
307
|
+
* ].
|
|
308
|
+
*/
|
|
309
|
+
type TupleParts<T extends IterableContainer, Prefix extends Array<unknown> = []> = T extends readonly [infer Head, ...infer Tail] ? TupleParts<Tail, [...Prefix, Head]> : Simplify<{
|
|
310
|
+
/**
|
|
311
|
+
* A fixed tuple that defines the part of the tuple where all its
|
|
312
|
+
* elements are required. This will always be the first part of the
|
|
313
|
+
* tuple and will never contain any optional or rest elements. When the
|
|
314
|
+
* array doesn't have a required part this will be an empty tuple
|
|
315
|
+
* (`[]`).
|
|
316
|
+
*/
|
|
317
|
+
required: Prefix;
|
|
318
|
+
} & TuplePartsWithoutRequired<T>>;
|
|
319
|
+
type TuplePartsWithoutRequired<T extends IterableContainer, Suffix extends Array<unknown> = []> = T extends readonly [...infer Head, infer Tail] ? TuplePartsWithoutRequired<Head, [Tail, ...Suffix]> : (Suffix extends readonly [] ? TuplePartsWithoutFixed<T> : // When the suffix is not empty we can skip the optional part and go
|
|
320
|
+
{
|
|
321
|
+
optional: [];
|
|
322
|
+
} & TuplePartsRest<T>) & {
|
|
323
|
+
/**
|
|
324
|
+
* A *fixed* tuple that defines the part of a tuple **after** a non-never
|
|
325
|
+
* rest parameter. These could never be optional elements, and could
|
|
326
|
+
* never contain another rest element. When the array doesn't have a
|
|
327
|
+
* required part this will be an empty tuple (`[]`).
|
|
328
|
+
*/
|
|
329
|
+
suffix: Suffix;
|
|
330
|
+
};
|
|
331
|
+
type TuplePartsWithoutFixed<T extends IterableContainer, Optional extends Array<unknown> = []> = T extends readonly [(infer Head)?, ...infer Tail] ? Or<T extends readonly [] ? true : false, Array<T[number]> extends Tail ? true : false> extends true ? {
|
|
332
|
+
/**
|
|
333
|
+
* A *fixed* tuple that defines the part of a tuple where all its
|
|
334
|
+
* elements are suffixed with the optional operator (`?`); but with
|
|
335
|
+
* the optional operator removed (e.g. `[string?]` would be
|
|
336
|
+
* represented as `[string]`). These elements can only follow the
|
|
337
|
+
* `required` part (which could be empty).
|
|
338
|
+
* To add optional operator back wrap the result with the built-in
|
|
339
|
+
* `Partial` type.
|
|
340
|
+
* When the array doesn't have a required part this will be an empty
|
|
341
|
+
* tuple (`[]`).
|
|
342
|
+
*
|
|
343
|
+
* @example Partial<TupleParts<T>["optional"]>
|
|
344
|
+
*/
|
|
345
|
+
optional: Optional;
|
|
346
|
+
} & TuplePartsRest<T> : TuplePartsWithoutFixed<Tail, [...Optional, Head | undefined]> : RemedaTypeError<"TupleParts", "Unexpected tuple shape", {
|
|
347
|
+
type: never;
|
|
348
|
+
metadata: T;
|
|
349
|
+
}>;
|
|
350
|
+
type TuplePartsRest<T extends IterableContainer> = {
|
|
351
|
+
/**
|
|
352
|
+
* The type for the rest parameter of the tuple, if any. Unlike the
|
|
353
|
+
* other parts of the tuple, this is a single type and not
|
|
354
|
+
* represented as an array/tuple. When a tuple doesn't have a rest
|
|
355
|
+
* element, this will be `never`. To convert this to a matching array
|
|
356
|
+
* type that could be spread into a new type use the `CoercedArray`
|
|
357
|
+
* type which handles the `never` case correctly.
|
|
358
|
+
*
|
|
359
|
+
* @example CoercedArray<TupleParts<T>["item"]>
|
|
360
|
+
*/
|
|
361
|
+
item: T extends readonly [] ? never : T[number];
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* We built our own version of Subtract instead of using type-fest's one
|
|
366
|
+
* because we needed a simpler implementation that isn't as prone to excessive
|
|
367
|
+
* recursion issues and that is clamped at 0 so that we don't need to handle
|
|
368
|
+
* negative values using even more utilities.
|
|
369
|
+
*/
|
|
370
|
+
type ClampedIntegerSubtract<Minuend, Subtrahend, SubtrahendBag extends Array<unknown> = [], ResultBag extends Array<unknown> = []> = [...SubtrahendBag, ...ResultBag]["length"] extends Minuend ? ResultBag["length"] : SubtrahendBag["length"] extends Subtrahend ? ClampedIntegerSubtract<Minuend, Subtrahend, SubtrahendBag, [
|
|
371
|
+
...ResultBag,
|
|
372
|
+
unknown
|
|
373
|
+
]> : ClampedIntegerSubtract<Minuend, Subtrahend, [
|
|
374
|
+
...SubtrahendBag,
|
|
375
|
+
unknown
|
|
376
|
+
], ResultBag>;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* `never[]` and `[]` are not the same type, and in some cases they aren't
|
|
380
|
+
* interchangeable.
|
|
381
|
+
*
|
|
382
|
+
* This type makes it easier to use the result of TupleParts when the input is a
|
|
383
|
+
* fixed-length tuple but we still want to spread the rest of the array. e.g.
|
|
384
|
+
* `[...CoercedArray<TupleParts<T>["item"]>, ...TupleParts<T>["suffix"]]`.
|
|
385
|
+
*
|
|
386
|
+
*/
|
|
387
|
+
type CoercedArray<T> = IfNever<T, [], Array<T>>;
|
|
388
|
+
|
|
389
|
+
type ArrayRequiredPrefix<T extends IterableContainer, N extends number> = IsLiteral<N> extends true ? T extends unknown ? ClampedIntegerSubtract<N, [
|
|
390
|
+
...TupleParts<T>["required"],
|
|
391
|
+
...TupleParts<T>["suffix"]
|
|
392
|
+
]["length"]> extends infer Remainder extends number ? Remainder extends 0 ? T : And<GreaterThan<Remainder, TupleParts<T>["optional"]["length"]>, IsNever<TupleParts<T>["item"]>> extends true ? RemedaTypeError<"ArrayRequiredPrefix", "The input tuple cannot satisfy the minimum", {
|
|
393
|
+
type: never;
|
|
394
|
+
metadata: [T, N];
|
|
395
|
+
}> : WithSameReadonly<T, [
|
|
396
|
+
...TupleParts<T>["required"],
|
|
397
|
+
...OptionalTupleRequiredPrefix<TupleParts<T>["optional"], Remainder>,
|
|
398
|
+
...ReadonlyTuple<TupleParts<T>["item"], ClampedIntegerSubtract<Remainder, TupleParts<T>["optional"]["length"]>>,
|
|
399
|
+
...CoercedArray<TupleParts<T>["item"]>,
|
|
400
|
+
...TupleParts<T>["suffix"]
|
|
401
|
+
]> : RemedaTypeError<"ArrayRequiredPrefix", "Remainder didn't compute to a number?!", {
|
|
402
|
+
type: never;
|
|
403
|
+
metadata: [T, N];
|
|
404
|
+
}> : RemedaTypeError<"ArrayRequiredPrefix", "Failed to distribute union?!", {
|
|
405
|
+
type: never;
|
|
406
|
+
metadata: T;
|
|
407
|
+
}> : RemedaTypeError<"ArrayRequiredPrefix", "Only literal minimums are supported!", {
|
|
408
|
+
type: never;
|
|
409
|
+
metadata: N;
|
|
410
|
+
}>;
|
|
411
|
+
type WithSameReadonly<Source, Destination> = IsEqual<Source, Readonly<Source>> extends true ? Readonly<Destination> : Destination;
|
|
412
|
+
type OptionalTupleRequiredPrefix<T extends Array<unknown>, N, Prefix extends Array<unknown> = []> = Prefix["length"] extends N ? [
|
|
413
|
+
...Prefix,
|
|
414
|
+
...Partial<T>
|
|
415
|
+
] : T extends readonly [infer Head, ...infer Rest] ? OptionalTupleRequiredPrefix<Rest, N, [...Prefix, Head]> : Prefix;
|
|
416
|
+
|
|
286
417
|
/**
|
|
287
418
|
* Checks if the given array has at least the defined number of elements. When
|
|
288
419
|
* the minimum used is a literal (e.g. `3`) the output is refined accordingly so
|
|
@@ -305,7 +436,7 @@ type ArraySetRequired<T extends IterableContainer, Min extends number, Iteration
|
|
|
305
436
|
* @dataFirst
|
|
306
437
|
* @category Array
|
|
307
438
|
*/
|
|
308
|
-
declare function hasAtLeast<T extends IterableContainer, N extends number>(data: IterableContainer | T, minimum: IsNumericLiteral<N> extends true ? N : never): data is
|
|
439
|
+
declare function hasAtLeast<T extends IterableContainer, N extends number>(data: IterableContainer | T, minimum: IsNumericLiteral<N> extends true ? N : never): data is ArrayRequiredPrefix<T, N>;
|
|
309
440
|
declare function hasAtLeast(data: IterableContainer, minimum: number): boolean;
|
|
310
441
|
/**
|
|
311
442
|
* Checks if the given array has at least the defined number of elements. When
|
|
@@ -331,7 +462,7 @@ declare function hasAtLeast(data: IterableContainer, minimum: number): boolean;
|
|
|
331
462
|
* @dataLast
|
|
332
463
|
* @category Array
|
|
333
464
|
*/
|
|
334
|
-
declare function hasAtLeast<N extends number>(minimum: IsNumericLiteral<N> extends true ? N : never): <T extends IterableContainer>(data: IterableContainer | T) => data is
|
|
465
|
+
declare function hasAtLeast<N extends number>(minimum: IsNumericLiteral<N> extends true ? N : never): <T extends IterableContainer>(data: IterableContainer | T) => data is ArrayRequiredPrefix<T, N>;
|
|
335
466
|
declare function hasAtLeast(minimum: number): (data: IterableContainer) => boolean;
|
|
336
467
|
|
|
337
468
|
declare function isString(value: unknown): value is string;
|
|
@@ -364,6 +495,7 @@ declare function ifilter<T>(iterable: Iterable<T>, predicate: (v: T) => boolean)
|
|
|
364
495
|
* @signature
|
|
365
496
|
* ifind(predicate)(data)
|
|
366
497
|
*/
|
|
498
|
+
declare function ifind<T, S extends T>(predicate: (item: T) => item is S): (iterable: Iterable<T>) => S | undefined;
|
|
367
499
|
declare function ifind<T>(predicate: (item: T) => boolean): (iterable: Iterable<T>) => T | undefined;
|
|
368
500
|
/**
|
|
369
501
|
* Finds the first element in the iterable that satisfies the predicate.
|
|
@@ -371,11 +503,21 @@ declare function ifind<T>(predicate: (item: T) => boolean): (iterable: Iterable<
|
|
|
371
503
|
* @signature
|
|
372
504
|
* ifind(data, predicate)
|
|
373
505
|
*/
|
|
506
|
+
declare function ifind<T, S extends T>(iterable: Iterable<T>, predicate: (item: T) => item is S): S | undefined;
|
|
374
507
|
declare function ifind<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): T | undefined;
|
|
375
508
|
|
|
376
509
|
declare function iflat(): <T>(iterable: Iterable<IteratorLike<T>>) => IteratorLike<T>;
|
|
377
510
|
declare function iflat<T>(iterable: Iterable<IteratorLike<T>>): IteratorLike<T>;
|
|
378
511
|
|
|
512
|
+
declare function ihead<T>(): (iterable: Iterable<T>) => T | undefined;
|
|
513
|
+
/**
|
|
514
|
+
* Finds the first element in the iterable that satisfies the predicate.
|
|
515
|
+
* Data first version of `find`.
|
|
516
|
+
* @signature
|
|
517
|
+
* ifind(data, predicate)
|
|
518
|
+
*/
|
|
519
|
+
declare function ihead<T>(iterable: Iterable<T>): T | undefined;
|
|
520
|
+
|
|
379
521
|
type MapFunction<T, S> = (item: T) => S;
|
|
380
522
|
/**
|
|
381
523
|
* Maps an iterable using a mapper function.
|
|
@@ -422,18 +564,44 @@ declare function toSet<T>(iterable: Iterable<T>): Set<T>;
|
|
|
422
564
|
declare function iunique(): <T>(iterable: Iterable<T>) => IteratorLike<T>;
|
|
423
565
|
declare function iunique<T>(iterable: Iterable<T>): IteratorLike<T>;
|
|
424
566
|
|
|
567
|
+
/**
|
|
568
|
+
* Saves the value returned by fn() in a hidden property tag of obj object, so next time memoizeProp() is called,
|
|
569
|
+
* that value will be returned, and fn won't be called.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```ts
|
|
573
|
+
* class Model {
|
|
574
|
+
* // using same Symbol
|
|
575
|
+
* get computed1() {
|
|
576
|
+
* return memoizeProp(this, Symbol.for('computed1'), () => doOnce())
|
|
577
|
+
* }
|
|
578
|
+
* // using string
|
|
579
|
+
* get computed2() {
|
|
580
|
+
* return memoizeProp(this, 'computed2', () => doOnce())
|
|
581
|
+
* }
|
|
582
|
+
*
|
|
583
|
+
* }
|
|
584
|
+
* ```
|
|
585
|
+
*/
|
|
586
|
+
declare function memoizeProp<Tag extends symbol | string, Res>(obj: object, tag: Tag, fn: () => Res): Res;
|
|
587
|
+
|
|
425
588
|
declare function delay(): Promise<string>;
|
|
426
589
|
declare function delay(ms: number): Promise<string>;
|
|
427
590
|
declare function delay(randomFrom: number, randomTo: number): Promise<string>;
|
|
428
591
|
|
|
592
|
+
type RelationshipLike = {
|
|
593
|
+
source: {
|
|
594
|
+
model: string;
|
|
595
|
+
};
|
|
596
|
+
target: {
|
|
597
|
+
model: string;
|
|
598
|
+
};
|
|
599
|
+
};
|
|
429
600
|
/**
|
|
430
601
|
* Compares two relations hierarchically.
|
|
431
602
|
* From the most general (implicit) to the most specific.
|
|
432
603
|
*/
|
|
433
|
-
declare const compareRelations: <T extends
|
|
434
|
-
source: string;
|
|
435
|
-
target: string;
|
|
436
|
-
}>(a: T, b: T) => number;
|
|
604
|
+
declare const compareRelations: <T extends RelationshipLike>(a: T, b: T) => number;
|
|
437
605
|
|
|
438
606
|
/**
|
|
439
607
|
* Returns new set as a union of given sets
|
|
@@ -456,4 +624,4 @@ declare function stringHash(str: string): string;
|
|
|
456
624
|
|
|
457
625
|
declare function objectHash(value: any): string;
|
|
458
626
|
|
|
459
|
-
export { BiMap,
|
|
627
|
+
export { BiMap, DefaultWeakMap, LinkedList, MultiMap, Queue, Stack, commonHead, compareNatural, compareNaturalHierarchically, compareRelations, delay, difference, equals as equalsSet, getOrCreate, hasAtLeast, ifilter, ifind, iflat, ihead, imap, intersection, invariant, ireduce, isIterable, isNonEmptyArray, isString, isome, iunique, memoizeProp, nonNullable, nonexhaustive, objectHash, stringHash, symmetricDifference, toArray, toSet, union };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
import {
|
|
1
|
+
import { i as invariant } from '../shared/core.Cy9smucx.mjs';
|
|
2
|
+
export { n as nonNullable, a as nonexhaustive } from '../shared/core.Cy9smucx.mjs';
|
|
3
|
+
import { r as requireForeach, a as requireIterator, n } from '../shared/core.CpXlRyE5.mjs';
|
|
4
|
+
export { S as Stack, c as commonHead, e as iflat, i as isIterable, b as iunique, o as objectHash } from '../shared/core.CpXlRyE5.mjs';
|
|
5
|
+
import { g as getDefaultExportFromCjs, t, k as commonAncestor, q as compareFqnHierarchically } from '../shared/core.rmvsy0n3.mjs';
|
|
6
|
+
export { D as DefaultMap, l as ancestorsFqn, h as compareByFqnHierarchically, m as compareNatural, o as compareNaturalHierarchically, r as hierarchyDistance, u as hierarchyLevel, b as ifilter, a as isAncestor, i as isDescendantOf, c as isNonEmptyArray, d as isSameHierarchy, w as isString, n as nameFromFqn, p as parentFqn, j as sortByFqnHierarchically, v as sortNaturalByFqn, s as sortParentsFirst } from '../shared/core.rmvsy0n3.mjs';
|
|
7
|
+
export { d as difference, j as equalsSet, g as getOrCreate, i as hasAtLeast, c as ifind, e as ihead, a as intersection, b as isome, f as memoizeProp, k as stringHash, s as symmetricDifference, u as union } from '../shared/core.DoK86JEe.mjs';
|
|
8
|
+
export { i as imap, a as toArray, t as toSet } from '../shared/core.BrCnZFTn.mjs';
|
|
9
|
+
import '../shared/core.DbRvwARP.mjs';
|
|
6
10
|
|
|
7
11
|
function o(r,n){let e=Math.ceil(r),t=Math.floor(n);if(t<e)throw new RangeError(`randomInteger: The range [${r.toString()},${n.toString()}] contains no integer`);return Math.floor(Math.random()*(t-e+1)+e)}
|
|
8
12
|
|
|
@@ -1287,8 +1291,8 @@ function delay(...args) {
|
|
|
1287
1291
|
}
|
|
1288
1292
|
|
|
1289
1293
|
const compareRelations = (a, b) => {
|
|
1290
|
-
const parentA = commonAncestor(a.source, a.target);
|
|
1291
|
-
const parentB = commonAncestor(b.source, b.target);
|
|
1294
|
+
const parentA = commonAncestor(a.source.model, a.target.model);
|
|
1295
|
+
const parentB = commonAncestor(b.source.model, b.target.model);
|
|
1292
1296
|
if (parentA && !parentB) {
|
|
1293
1297
|
return 1;
|
|
1294
1298
|
}
|
|
@@ -1299,11 +1303,11 @@ const compareRelations = (a, b) => {
|
|
|
1299
1303
|
if (compareParents !== 0) {
|
|
1300
1304
|
return compareParents;
|
|
1301
1305
|
}
|
|
1302
|
-
const compareSource = compareFqnHierarchically(a.source, b.source);
|
|
1306
|
+
const compareSource = compareFqnHierarchically(a.source.model, b.source.model);
|
|
1303
1307
|
if (compareSource !== 0) {
|
|
1304
1308
|
return compareSource;
|
|
1305
1309
|
}
|
|
1306
|
-
return compareFqnHierarchically(a.target, b.target);
|
|
1310
|
+
return compareFqnHierarchically(a.target.model, b.target.model);
|
|
1307
1311
|
};
|
|
1308
1312
|
|
|
1309
|
-
export { biMap as BiMap, defaultWeakMap as DefaultWeakMap, linkedList as LinkedList, multiMap as MultiMap, queue as Queue, commonAncestor, compareFqnHierarchically, compareRelations, delay, ireduce };
|
|
1313
|
+
export { biMap as BiMap, defaultWeakMap as DefaultWeakMap, linkedList as LinkedList, multiMap as MultiMap, queue as Queue, commonAncestor, compareFqnHierarchically, compareRelations, delay, invariant, ireduce };
|