@likec4/core 1.10.0 → 1.10.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/dist/index.cjs +204 -103
- package/dist/index.d.cts +175 -154
- package/dist/index.d.mts +175 -154
- package/dist/index.d.ts +175 -154
- package/dist/index.mjs +204 -103
- package/dist/shared/{core.CpR2fq5B.d.cts → core.Czd51Dd8.d.cts} +2 -1
- package/dist/shared/{core.CpR2fq5B.d.mts → core.Czd51Dd8.d.mts} +2 -1
- package/dist/shared/{core.CpR2fq5B.d.ts → core.Czd51Dd8.d.ts} +2 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +8 -8
- package/src/types/_common.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,157 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection, bl as BBox, aU as BasicElementView, aT as BasicView, o as BorderStyle, B as BorderStyles, aE as ColorLiteral, bi as ComputedDynamicView, bh as ComputedElementView,
|
|
3
|
-
|
|
4
|
-
type Numeric = number | bigint;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
Returns a boolean for whether the given type is `never`.
|
|
8
|
-
|
|
9
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
10
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
11
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
12
|
-
|
|
13
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
14
|
-
|
|
15
|
-
@example
|
|
16
|
-
```
|
|
17
|
-
import type {IsNever, And} from 'type-fest';
|
|
18
|
-
|
|
19
|
-
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
20
|
-
type AreStringsEqual<A extends string, B extends string> =
|
|
21
|
-
And<
|
|
22
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
23
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
24
|
-
>;
|
|
25
|
-
|
|
26
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
27
|
-
AreStringsEqual<I, O> extends true
|
|
28
|
-
? never
|
|
29
|
-
: void;
|
|
30
|
-
|
|
31
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
32
|
-
if (input === output) {
|
|
33
|
-
process.exit(0);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
endIfEqual('abc', 'abc');
|
|
38
|
-
//=> never
|
|
39
|
-
|
|
40
|
-
endIfEqual('abc', '123');
|
|
41
|
-
//=> void
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
@category Type Guard
|
|
45
|
-
@category Utilities
|
|
46
|
-
*/
|
|
47
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
Returns a boolean for whether the given type `T` is the specified `LiteralType`.
|
|
51
|
-
|
|
52
|
-
@link https://stackoverflow.com/a/52806744/10292952
|
|
53
|
-
|
|
54
|
-
@example
|
|
55
|
-
```
|
|
56
|
-
LiteralCheck<1, number>
|
|
57
|
-
//=> true
|
|
58
|
-
|
|
59
|
-
LiteralCheck<number, number>
|
|
60
|
-
//=> false
|
|
61
|
-
|
|
62
|
-
LiteralCheck<1, string>
|
|
63
|
-
//=> false
|
|
64
|
-
```
|
|
65
|
-
*/
|
|
66
|
-
type LiteralCheck<T, LiteralType extends Primitive> = (
|
|
67
|
-
IsNever<T> extends false // Must be wider than `never`
|
|
68
|
-
? [T] extends [LiteralType & infer U] // Remove any branding
|
|
69
|
-
? [U] extends [LiteralType] // Must be narrower than `LiteralType`
|
|
70
|
-
? [LiteralType] extends [U] // Cannot be wider than `LiteralType`
|
|
71
|
-
? false
|
|
72
|
-
: true
|
|
73
|
-
: false
|
|
74
|
-
: false
|
|
75
|
-
: false
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
Returns a boolean for whether the given type `T` is one of the specified literal types in `LiteralUnionType`.
|
|
80
|
-
|
|
81
|
-
@example
|
|
82
|
-
```
|
|
83
|
-
LiteralChecks<1, Numeric>
|
|
84
|
-
//=> true
|
|
85
|
-
|
|
86
|
-
LiteralChecks<1n, Numeric>
|
|
87
|
-
//=> true
|
|
88
|
-
|
|
89
|
-
LiteralChecks<bigint, Numeric>
|
|
90
|
-
//=> false
|
|
91
|
-
```
|
|
92
|
-
*/
|
|
93
|
-
type LiteralChecks<T, LiteralUnionType> = (
|
|
94
|
-
// Conditional type to force union distribution.
|
|
95
|
-
// If `T` is none of the literal types in the union `LiteralUnionType`, then `LiteralCheck<T, LiteralType>` will evaluate to `false` for the whole union.
|
|
96
|
-
// If `T` is one of the literal types in the union, it will evaluate to `boolean` (i.e. `true | false`)
|
|
97
|
-
IsNotFalse<LiteralUnionType extends Primitive
|
|
98
|
-
? LiteralCheck<T, LiteralUnionType>
|
|
99
|
-
: never
|
|
100
|
-
>
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
Returns a boolean for whether the given type is a `number` or `bigint` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
105
|
-
|
|
106
|
-
Useful for:
|
|
107
|
-
- providing strongly-typed functions when given literal arguments
|
|
108
|
-
- type utilities, such as when constructing parsers and ASTs
|
|
109
|
-
|
|
110
|
-
@example
|
|
111
|
-
```
|
|
112
|
-
import type {IsNumericLiteral} from 'type-fest';
|
|
113
|
-
|
|
114
|
-
// https://github.com/inocan-group/inferred-types/blob/master/src/types/boolean-logic/EndsWith.ts
|
|
115
|
-
type EndsWith<TValue, TEndsWith extends string> =
|
|
116
|
-
TValue extends string
|
|
117
|
-
? IsStringLiteral<TEndsWith> extends true
|
|
118
|
-
? IsStringLiteral<TValue> extends true
|
|
119
|
-
? TValue extends `${string}${TEndsWith}`
|
|
120
|
-
? true
|
|
121
|
-
: false
|
|
122
|
-
: boolean
|
|
123
|
-
: boolean
|
|
124
|
-
: TValue extends number
|
|
125
|
-
? IsNumericLiteral<TValue> extends true
|
|
126
|
-
? EndsWith<`${TValue}`, TEndsWith>
|
|
127
|
-
: false
|
|
128
|
-
: false;
|
|
129
|
-
|
|
130
|
-
function endsWith<Input extends string | number, End extends string>(input: Input, end: End) {
|
|
131
|
-
return `${input}`.endsWith(end) as EndsWith<Input, End>;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
endsWith('abc', 'c');
|
|
135
|
-
//=> true
|
|
136
|
-
|
|
137
|
-
endsWith(123456, '456');
|
|
138
|
-
//=> true
|
|
139
|
-
|
|
140
|
-
const end = '123' as string;
|
|
141
|
-
|
|
142
|
-
endsWith('abc123', end);
|
|
143
|
-
//=> boolean
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
@category Type Guard
|
|
147
|
-
@category Utilities
|
|
148
|
-
*/
|
|
149
|
-
type IsNumericLiteral<T> = LiteralChecks<T, Numeric>;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
Returns a boolean for whether the given `boolean` is not `false`.
|
|
153
|
-
*/
|
|
154
|
-
type IsNotFalse<T extends boolean> = [T] extends [false] ? false : true;
|
|
1
|
+
import { H as HexColorLiteral, T as ThemeColorValues, L as LiteralUnion, F as Fqn$1, R as RelationID$1, V as ViewID$1, E as EdgeId$1, C as ComputedView, a as Tag, b as ComputedNode, N as NodeId, c as ElementKind, d as ElementShape, e as Color, f as ComputedEdge, g as ComputedLikeC4Model, h as Element, i as Relation, j as RelationshipKind, k as NonEmptyArray } from './shared/core.Czd51Dd8.js';
|
|
2
|
+
export { aq as AndOperator, A as AsFqn, aP as AutoLayoutDirection, bl as BBox, aU as BasicElementView, aT as BasicView, o as BorderStyle, B as BorderStyles, aE as ColorLiteral, bi as ComputedDynamicView, bh as ComputedElementView, n as CustomColor, b4 as CustomColorDefinitions, G as CustomElementExpr, ad as CustomRelationExpr, aA as DefaultArrowType, q as DefaultElementShape, az as DefaultLineStyle, aB as DefaultRelationshipColor, D as DefaultThemeColor, bo as DiagramEdge, bn as DiagramNode, bp as DiagramView, b2 as DynamicView, a$ as DynamicViewIncludeRule, aZ as DynamicViewParallelSteps, b1 as DynamicViewRule, aY as DynamicViewStep, a_ as DynamicViewStepOrParallel, U as ElementExpression, M as ElementKindExpr, v as ElementKindSpecification, u as ElementKindSpecificationStyle, bs as ElementNotation, $ as ElementPredicateExpression, w as ElementRefExpr, p as ElementShapes, r as ElementStyle, Q as ElementTagExpr, aG as ElementThemeColorValues, aH as ElementThemeColors, aX as ElementView, Z as ElementWhereExpr, aj as EqualOperator, y as ExpandedElementExpr, l as Expr, ah as Expression, aW as ExtendsElementView, I as IconUrl, a3 as InOutExpr, a5 as IncomingExpr, am as KindEqual, aK as LikeC4Theme, b5 as LikeC4View, t as Link, m as NonEmptyReadonlyArray, ao as NotOperator, as as OrOperator, a7 as OutgoingExpr, aw as OverviewGraph, ai as ParsedLikeC4Model, P as Point, a1 as RelationExpr, a9 as RelationExpression, af as RelationPredicateExpression, ab as RelationWhereExpr, ay as RelationshipArrowType, aC as RelationshipKindSpecification, ax as RelationshipLineType, aI as RelationshipThemeColorValues, aJ as RelationshipThemeColors, aV as ScopedElementView, bb as StepEdgeId, ba as StepEdgeIdLiteral, ak as TagEqual, s as TagSpec, aD as ThemeColor, br as ViewChange, bq as ViewManualLayout, aS as ViewRule, aQ as ViewRuleAutoLayout, aL as ViewRulePredicate, aN as ViewRuleStyle, bf as ViewWithHash, bg as ViewWithNotation, au as WhereOperator, W as WildcardExpr, X as XYPoint, bd as extractStep, bm as getBBoxCenter, be as getParallelStepsPrefix, ar as isAndOperator, bj as isComputedDynamicView, bk as isComputedElementView, J as isCustomElement, ae as isCustomRelationExpr, b6 as isDynamicView, b0 as isDynamicViewIncludeRule, b3 as isDynamicViewParallelSteps, Y as isElement, O as isElementKindExpr, a0 as isElementPredicateExpr, x as isElementRef, S as isElementTagExpr, b7 as isElementView, _ as isElementWhere, z as isExpandedElementExpr, b8 as isExtendsElementView, a4 as isInOut, a6 as isIncoming, an as isKindEqual, ap as isNotOperator, at as isOrOperator, a8 as isOutgoing, a2 as isRelation, aa as isRelationExpression, ag as isRelationPredicateExpr, ac as isRelationWhere, b9 as isScopedElementView, bc as isStepEdgeId, al as isTagEqual, aF as isThemeColor, aR as isViewRuleAutoLayout, aM as isViewRulePredicate, aO as isViewRuleStyle, K as isWildcard, av as whereOperatorAsPredicate } from './shared/core.Czd51Dd8.js';
|
|
155
3
|
|
|
156
4
|
declare const ElementColors: {
|
|
157
5
|
readonly primary: {
|
|
@@ -699,6 +547,179 @@ declare function sortNaturalByFqn<T extends {
|
|
|
699
547
|
id: string;
|
|
700
548
|
}, A extends IterableContainer$1<T>>(array: A): ReorderedArray<A>;
|
|
701
549
|
|
|
550
|
+
/**
|
|
551
|
+
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
552
|
+
|
|
553
|
+
@category Type
|
|
554
|
+
*/
|
|
555
|
+
type Primitive =
|
|
556
|
+
| null
|
|
557
|
+
| undefined
|
|
558
|
+
| string
|
|
559
|
+
| number
|
|
560
|
+
| boolean
|
|
561
|
+
| symbol
|
|
562
|
+
| bigint;
|
|
563
|
+
|
|
564
|
+
declare global {
|
|
565
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
566
|
+
interface SymbolConstructor {
|
|
567
|
+
readonly observable: symbol;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
type Numeric = number | bigint;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
Returns a boolean for whether the given type is `never`.
|
|
575
|
+
|
|
576
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
577
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
578
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
579
|
+
|
|
580
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
581
|
+
|
|
582
|
+
@example
|
|
583
|
+
```
|
|
584
|
+
import type {IsNever, And} from 'type-fest';
|
|
585
|
+
|
|
586
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
587
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
588
|
+
And<
|
|
589
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
590
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
591
|
+
>;
|
|
592
|
+
|
|
593
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
594
|
+
AreStringsEqual<I, O> extends true
|
|
595
|
+
? never
|
|
596
|
+
: void;
|
|
597
|
+
|
|
598
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
599
|
+
if (input === output) {
|
|
600
|
+
process.exit(0);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
endIfEqual('abc', 'abc');
|
|
605
|
+
//=> never
|
|
606
|
+
|
|
607
|
+
endIfEqual('abc', '123');
|
|
608
|
+
//=> void
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
@category Type Guard
|
|
612
|
+
@category Utilities
|
|
613
|
+
*/
|
|
614
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
Returns a boolean for whether the given type `T` is the specified `LiteralType`.
|
|
618
|
+
|
|
619
|
+
@link https://stackoverflow.com/a/52806744/10292952
|
|
620
|
+
|
|
621
|
+
@example
|
|
622
|
+
```
|
|
623
|
+
LiteralCheck<1, number>
|
|
624
|
+
//=> true
|
|
625
|
+
|
|
626
|
+
LiteralCheck<number, number>
|
|
627
|
+
//=> false
|
|
628
|
+
|
|
629
|
+
LiteralCheck<1, string>
|
|
630
|
+
//=> false
|
|
631
|
+
```
|
|
632
|
+
*/
|
|
633
|
+
type LiteralCheck<T, LiteralType extends Primitive> = (
|
|
634
|
+
IsNever<T> extends false // Must be wider than `never`
|
|
635
|
+
? [T] extends [LiteralType & infer U] // Remove any branding
|
|
636
|
+
? [U] extends [LiteralType] // Must be narrower than `LiteralType`
|
|
637
|
+
? [LiteralType] extends [U] // Cannot be wider than `LiteralType`
|
|
638
|
+
? false
|
|
639
|
+
: true
|
|
640
|
+
: false
|
|
641
|
+
: false
|
|
642
|
+
: false
|
|
643
|
+
);
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
Returns a boolean for whether the given type `T` is one of the specified literal types in `LiteralUnionType`.
|
|
647
|
+
|
|
648
|
+
@example
|
|
649
|
+
```
|
|
650
|
+
LiteralChecks<1, Numeric>
|
|
651
|
+
//=> true
|
|
652
|
+
|
|
653
|
+
LiteralChecks<1n, Numeric>
|
|
654
|
+
//=> true
|
|
655
|
+
|
|
656
|
+
LiteralChecks<bigint, Numeric>
|
|
657
|
+
//=> false
|
|
658
|
+
```
|
|
659
|
+
*/
|
|
660
|
+
type LiteralChecks<T, LiteralUnionType> = (
|
|
661
|
+
// Conditional type to force union distribution.
|
|
662
|
+
// If `T` is none of the literal types in the union `LiteralUnionType`, then `LiteralCheck<T, LiteralType>` will evaluate to `false` for the whole union.
|
|
663
|
+
// If `T` is one of the literal types in the union, it will evaluate to `boolean` (i.e. `true | false`)
|
|
664
|
+
IsNotFalse<LiteralUnionType extends Primitive
|
|
665
|
+
? LiteralCheck<T, LiteralUnionType>
|
|
666
|
+
: never
|
|
667
|
+
>
|
|
668
|
+
);
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
Returns a boolean for whether the given type is a `number` or `bigint` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
672
|
+
|
|
673
|
+
Useful for:
|
|
674
|
+
- providing strongly-typed functions when given literal arguments
|
|
675
|
+
- type utilities, such as when constructing parsers and ASTs
|
|
676
|
+
|
|
677
|
+
@example
|
|
678
|
+
```
|
|
679
|
+
import type {IsNumericLiteral} from 'type-fest';
|
|
680
|
+
|
|
681
|
+
// https://github.com/inocan-group/inferred-types/blob/master/src/types/boolean-logic/EndsWith.ts
|
|
682
|
+
type EndsWith<TValue, TEndsWith extends string> =
|
|
683
|
+
TValue extends string
|
|
684
|
+
? IsStringLiteral<TEndsWith> extends true
|
|
685
|
+
? IsStringLiteral<TValue> extends true
|
|
686
|
+
? TValue extends `${string}${TEndsWith}`
|
|
687
|
+
? true
|
|
688
|
+
: false
|
|
689
|
+
: boolean
|
|
690
|
+
: boolean
|
|
691
|
+
: TValue extends number
|
|
692
|
+
? IsNumericLiteral<TValue> extends true
|
|
693
|
+
? EndsWith<`${TValue}`, TEndsWith>
|
|
694
|
+
: false
|
|
695
|
+
: false;
|
|
696
|
+
|
|
697
|
+
function endsWith<Input extends string | number, End extends string>(input: Input, end: End) {
|
|
698
|
+
return `${input}`.endsWith(end) as EndsWith<Input, End>;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
endsWith('abc', 'c');
|
|
702
|
+
//=> true
|
|
703
|
+
|
|
704
|
+
endsWith(123456, '456');
|
|
705
|
+
//=> true
|
|
706
|
+
|
|
707
|
+
const end = '123' as string;
|
|
708
|
+
|
|
709
|
+
endsWith('abc123', end);
|
|
710
|
+
//=> boolean
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
@category Type Guard
|
|
714
|
+
@category Utilities
|
|
715
|
+
*/
|
|
716
|
+
type IsNumericLiteral<T> = LiteralChecks<T, Numeric>;
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
Returns a boolean for whether the given `boolean` is not `false`.
|
|
720
|
+
*/
|
|
721
|
+
type IsNotFalse<T extends boolean> = [T] extends [false] ? false : true;
|
|
722
|
+
|
|
702
723
|
/**
|
|
703
724
|
* This should only be used for defining generics which extend any kind of JS
|
|
704
725
|
* array under the hood, this includes arrays *AND* tuples (of the form [x, y],
|