@likec4/core 0.28.3 → 0.29.0

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.
@@ -1,5 +1,5 @@
1
1
  import { anyPass, filter, uniq, isNil } from 'rambdax';
2
- import { DefaultThemeColor, DefaultElementShape, } from '../types';
2
+ import { DefaultThemeColor, DefaultElementShape } from '../types';
3
3
  import * as Expr from '../types/expression';
4
4
  import { isViewRuleAutoLayout, isViewRuleExpression, isViewRuleStyle } from '../types/view';
5
5
  import { compareByFqnHierarchically, failExpectedNever, ignoreNeverInRuntime, isAncestor, isSameHierarchy, parentFqn, Relations } from '../utils';
@@ -8,7 +8,7 @@ import { EdgeBuilder } from './EdgeBuilder';
8
8
  import { sortNodes } from './utils/sortNodes';
9
9
  import { ComputeCtx } from './compute-ctx';
10
10
  import { anyPossibleRelations } from './utils/anyPossibleRelations';
11
- import invariant from 'tiny-invariant';
11
+ import { invariant } from '../errors';
12
12
  function transformToNodes(elementsIterator) {
13
13
  return Array.from(elementsIterator)
14
14
  .sort(compareByFqnHierarchically)
@@ -33,7 +33,7 @@ function transformToNodes(elementsIterator) {
33
33
  color: color ?? DefaultThemeColor,
34
34
  shape: shape ?? DefaultElementShape,
35
35
  children: [],
36
- ...(description ? { description } : {}),
36
+ ...(description ? { description } : {})
37
37
  };
38
38
  map.set(id, node);
39
39
  return map;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Base class for all errors in the LikeC4 library.
3
+ */
4
+ export declare const BaseError: import("modern-errors").ErrorSubclassCore<[], {}, import("modern-errors").CustomClass>;
5
+ /**
6
+ * Unknown error, mosly probably a bug, unhandled case or coming from a third-party library.
7
+ */
8
+ export declare const UnknownError: import("modern-errors").ErrorSubclassCore<[], {}, import("modern-errors").CustomClass>;
9
+ export declare const RelationRefError: import("modern-errors").ErrorSubclassCore<[], {}, import("modern-errors").CustomClass>;
10
+ //# sourceMappingURL=_base.d.ts.map
@@ -0,0 +1,11 @@
1
+ import ModernError from 'modern-errors';
2
+ /**
3
+ * Base class for all errors in the LikeC4 library.
4
+ */
5
+ export const BaseError = ModernError.subclass('BaseError');
6
+ /**
7
+ * Unknown error, mosly probably a bug, unhandled case or coming from a third-party library.
8
+ */
9
+ export const UnknownError = BaseError.subclass('UnknownError');
10
+ export const RelationRefError = BaseError.subclass('RelationRefError');
11
+ //# sourceMappingURL=_base.js.map
@@ -0,0 +1,3 @@
1
+ export * from './_base';
2
+ export * from './invariant';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './_base';
2
+ export * from './invariant';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ export declare const InvariantError: import("modern-errors").ErrorSubclassCore<[], {}, import("modern-errors").CustomClass>;
2
+ export declare function invariant(condition: any, message?: string): asserts condition;
3
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { BaseError } from './_base';
2
+ export const InvariantError = BaseError.subclass('InvariantError');
3
+ // Throw an error if the condition fails
4
+ // > Not providing an inline default argument for message as the result is smaller
5
+ export function invariant(
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ condition,
8
+ // Can provide a string, or a function that returns a string for cases where
9
+ // the message takes a fair amount of effort to compute
10
+ message) {
11
+ if (condition) {
12
+ return;
13
+ }
14
+ throw new InvariantError(message ?? 'Invariant failed');
15
+ }
16
+ //# sourceMappingURL=invariant.js.map
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * from './compute-view';
3
3
  export * from './utils';
4
4
  export * from './model-index';
5
5
  export * from './colors';
6
+ export * from './errors';
6
7
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@ export * from './compute-view';
2
2
  export * from './utils';
3
3
  export * from './model-index';
4
4
  export * from './colors';
5
+ export * from './errors';
5
6
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { values } from 'remeda';
2
- import invariant from 'tiny-invariant';
2
+ import { invariant } from '../errors';
3
3
  import { parentFqn } from '../utils/fqn';
4
4
  function childrenOf(trie) {
5
5
  const children = [];
@@ -1,4 +1,4 @@
1
- import invariant from 'tiny-invariant';
1
+ import { invariant } from '../errors';
2
2
  export const computeNodeLevels = ({ nodes }) => {
3
3
  const nodeLevels = {};
4
4
  const compute = (node, level) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/core",
3
- "version": "0.28.3",
3
+ "version": "0.29.0",
4
4
  "license": "MIT",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
@@ -91,9 +91,9 @@
91
91
  },
92
92
  "dependencies": {
93
93
  "@dagrejs/graphlib": "^2.1.13",
94
+ "modern-errors": "^6.0.0",
94
95
  "rambdax": "^9.1.1",
95
- "remeda": "^1.23.0",
96
- "tiny-invariant": "^1.3.1"
96
+ "remeda": "^1.23.0"
97
97
  },
98
98
  "devDependencies": {
99
99
  "typescript": "^5.1.6"