@likec4/core 1.48.0 → 1.50.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.
- package/dist/THIRD-PARTY-LICENSES.md +1034 -0
- package/dist/_chunks/Builder.view-element.mjs +2 -3284
- package/dist/_chunks/LikeC4Model.d.mts +21 -25
- package/dist/_chunks/_types.d.mts +1 -5
- package/dist/_chunks/_types2.d.mts +2 -4
- package/dist/_chunks/assignTagColors.mjs +1 -24
- package/dist/_chunks/geometry.mjs +1 -335
- package/dist/_chunks/index.d.mts +1995 -131
- package/dist/_chunks/index2.d.mts +153 -892
- package/dist/_chunks/index3.d.mts +15 -13
- package/dist/_chunks/index4.d.mts +229 -3
- package/dist/_chunks/index5.d.mts +392 -30
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
- package/dist/_chunks/libs/bail.mjs +1 -14
- package/dist/_chunks/libs/ccount.mjs +1 -25
- package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
- package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
- package/dist/_chunks/libs/character-entities.mjs +2 -2136
- package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
- package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
- package/dist/_chunks/libs/defu.mjs +1 -42
- package/dist/_chunks/libs/devlop.mjs +1 -5
- package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
- package/dist/_chunks/libs/extend.mjs +1 -77
- package/dist/_chunks/libs/graphology-dag.mjs +1 -703
- package/dist/_chunks/libs/graphology.mjs +1 -4565
- package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
- package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
- package/dist/_chunks/libs/longest-streak.mjs +1 -30
- package/dist/_chunks/libs/markdown-table.mjs +2 -290
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
- package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
- package/dist/_chunks/libs/mnemonist.d.mts +1 -91
- package/dist/_chunks/libs/mnemonist.mjs +1 -1978
- package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
- package/dist/_chunks/libs/ohash.mjs +1 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
- package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
- package/dist/_chunks/libs/remark-gfm.mjs +1 -36
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
- package/dist/_chunks/libs/remark-parse.mjs +1 -39
- package/dist/_chunks/libs/remark-rehype.mjs +1 -171
- package/dist/_chunks/libs/remeda.mjs +2 -702
- package/dist/_chunks/libs/trough.mjs +1 -158
- package/dist/_chunks/libs/unified.mjs +1 -2212
- package/dist/_chunks/manual-layout.mjs +1 -0
- package/dist/_chunks/model.mjs +4 -1898
- package/dist/_chunks/rolldown-runtime.mjs +1 -42
- package/dist/_chunks/types.mjs +1 -0
- package/dist/_chunks/utils.mjs +1 -483
- package/dist/builder/index.d.mts +3 -6
- package/dist/builder/index.mjs +1 -662
- package/dist/compute-view/index.d.mts +85 -13
- package/dist/compute-view/index.mjs +2 -262
- package/dist/geometry/index.d.mts +2 -2
- package/dist/geometry/index.mjs +1 -3
- package/dist/index.d.mts +7 -13
- package/dist/index.mjs +1 -27
- package/dist/model/index.d.mts +4 -11
- package/dist/model/index.mjs +1 -11
- package/dist/styles/index.d.mts +2 -7
- package/dist/styles/index.mjs +1 -30
- package/dist/types/index.d.mts +3 -9
- package/dist/types/index.mjs +1 -15
- package/dist/utils/graphology/index.d.mts +1 -1
- package/dist/utils/graphology/index.mjs +1 -3
- package/dist/utils/index.d.mts +5 -10
- package/dist/utils/index.mjs +1 -17
- package/package.json +14 -13
- package/dist/_chunks/LikeC4Styles.mjs +0 -691
- package/dist/_chunks/RichText.d.mts +0 -84
- package/dist/_chunks/RichText.mjs +0 -148
- package/dist/_chunks/_aux.d.mts +0 -289
- package/dist/_chunks/_aux.mjs +0 -18
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +0 -379
- package/dist/_chunks/connection.mjs +0 -0
- package/dist/_chunks/const.d.mts +0 -43
- package/dist/_chunks/const.mjs +0 -33
- package/dist/_chunks/expression-model.d.mts +0 -192
- package/dist/_chunks/expression-model.mjs +0 -103
- package/dist/_chunks/expression.d.mts +0 -347
- package/dist/_chunks/expression.mjs +0 -107
- package/dist/_chunks/find.d.mts +0 -82
- package/dist/_chunks/find.mjs +0 -646
- package/dist/_chunks/find2.d.mts +0 -78
- package/dist/_chunks/find2.mjs +0 -287
- package/dist/_chunks/fqnRef.d.mts +0 -58
- package/dist/_chunks/fqnRef.mjs +0 -41
- package/dist/_chunks/index6.d.mts +0 -43
- package/dist/_chunks/index7.d.mts +0 -268
- package/dist/_chunks/index8.d.mts +0 -144
- package/dist/_chunks/invariant.mjs +0 -18
- package/dist/_chunks/iterable.mjs +0 -146
- package/dist/_chunks/libs/graphology-types.d.mts +0 -601
- package/dist/_chunks/libs/graphology.d.mts +0 -6
- package/dist/_chunks/mnemonist.mjs +0 -0
- package/dist/_chunks/model2.mjs +0 -0
- package/dist/_chunks/relationships-view.mjs +0 -132
- package/dist/_chunks/scalar.d.mts +0 -109
- package/dist/_chunks/scalar.mjs +0 -84
- package/dist/compute-view/relationships-view/index.d.mts +0 -16
- package/dist/compute-view/relationships-view/index.mjs +0 -7
- package/dist/model/connection/deployment/index.d.mts +0 -12
- package/dist/model/connection/deployment/index.mjs +0 -9
- package/dist/model/connection/index.d.mts +0 -14
- package/dist/model/connection/index.mjs +0 -10
- package/dist/model/connection/model/index.d.mts +0 -12
- package/dist/model/connection/model/index.mjs +0 -8
- package/dist/types/RichText.d.mts +0 -3
- package/dist/types/RichText.mjs +0 -7
- package/dist/types/_aux.d.mts +0 -3
- package/dist/types/_aux.mjs +0 -3
- package/dist/types/expression-model.d.mts +0 -6
- package/dist/types/expression-model.mjs +0 -7
- package/dist/types/expression.d.mts +0 -5
- package/dist/types/expression.mjs +0 -7
- package/dist/types/fqnRef.d.mts +0 -4
- package/dist/types/fqnRef.mjs +0 -7
- package/dist/types/scalar.d.mts +0 -2
- package/dist/types/scalar.mjs +0 -7
- package/dist/utils/iterable/index.d.mts +0 -9
- package/dist/utils/iterable/index.mjs +0 -3
- package/dist/utils/mnemonist.d.mts +0 -2
- package/dist/utils/mnemonist.mjs +0 -12
|
@@ -1,42 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
-
var __exportAll = (all, symbols) => {
|
|
10
|
-
let target = {};
|
|
11
|
-
for (var name in all) {
|
|
12
|
-
__defProp(target, name, {
|
|
13
|
-
get: all[name],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
if (symbols) {
|
|
18
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
19
|
-
}
|
|
20
|
-
return target;
|
|
21
|
-
};
|
|
22
|
-
var __copyProps = (to, from, except, desc) => {
|
|
23
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
-
key = keys[i];
|
|
26
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
27
|
-
__defProp(to, key, {
|
|
28
|
-
get: ((k) => from[k]).bind(null, key),
|
|
29
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return to;
|
|
35
|
-
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
37
|
-
value: mod,
|
|
38
|
-
enumerable: true
|
|
39
|
-
}) : target, mod));
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { __exportAll as n, __toESM as r, __commonJSMin as t };
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{s as n,l as r,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime.mjs";import{t}from"./libs/defu.mjs";import{B as n,I as r,M as i,N as a,O as o,T as s,V as c,et as l,it as ee,k as u,rt as te,t as ne,x as re}from"./libs/remeda.mjs";import{Q as d,et as f,h as p,n as ie,t as ae}from"./utils.mjs";import{i as m,n as oe,t as se}from"./libs/mnemonist.mjs";import{a as ce,c as le,d as ue,f as de,h as fe,i as pe,l as me,m as he,n as ge,o as _e,p as ve,r as ye,s as be,t as xe,u as Se}from"./libs/@radix-ui/colors.mjs";import{n as h,t as Ce}from"./libs/@mantine/colors-generator.mjs";function we(e){return re(e,e=>e===void 0)}function Te(e){return e.summary??e.description}function Ee(e){return e.description??e.summary}function De(e,t){return e[g]===t}const g=`_stage`,Oe=`_type`,ke=`_layout`;var Ae=e({DeploymentFqn:()=>w,EdgeId:()=>j,Fqn:()=>x,GlobalFqn:()=>D,GroupElementKind:()=>S,MarkdownOrString:()=>v,NodeId:()=>A,NoneIcon:()=>b,ProjectId:()=>_,RelationId:()=>E,StepEdgeKind:()=>je,ViewId:()=>T,extractStep:()=>P,flattenMarkdownOrString:()=>y,isGlobalFqn:()=>O,isGroupElementKind:()=>C,isStepEdgeId:()=>N,splitGlobalFqn:()=>k,stepEdgeId:()=>M});function _(e){return e}function v(e){return typeof e==`string`?{txt:e}:e}function y(e){if(r(e))return null;let t=u(e)?e:e.txt??e.md;return o(t?.trim())?t:null}const b=`none`;function x(e,t){return t?t+`.`+e:e}const S=`@group`;function C(e){return e.kind===S}function w(e,t){return t?t+`.`+e:e}function T(e){return e}function E(e){return e}function D(e,t){return d(typeof e==`string`&&e!=``),`@`+e+`.`+t}function O(e){return e.startsWith(`@`)}function k(e){if(!e.startsWith(`@`))return[null,e];let t=e.indexOf(`.`);if(t<2)throw Error(`Invalid global FQN`);return[e.slice(1,t),e.slice(t+1)]}function A(e){return e}function j(e){return e}function M(e,t){let n=`step-${String(e).padStart(2,`0`)}`;return t?`${n}.${t}`:n}const je=`@step`;function N(e){return e.startsWith(`step-`)}function P(e){if(!N(e))throw Error(`Invalid step edge id: ${e}`);return parseFloat(e.slice(5))}let F;(function(e){function t(e){return`model`in e&&!(`project`in e)}e.isElementRef=t;function n(e){return`project`in e&&`model`in e}e.isImportRef=n;function r(e){if(u(e))throw Error(`Expected FqnRef, got: "${e}"`);if(n(e))return D(e.project,e.model);if(t(e))return e.model;throw Error(`Expected FqnRef.ModelRef or FqnRef.ImportRef`)}e.flatten=r;function i(e){return t(e)||n(e)}e.isModelRef=i;function a(e){return`deployment`in e&&`element`in e}e.isInsideInstanceRef=a;function o(e){return`deployment`in e&&!(`element`in e)}e.isDeploymentElementRef=o;function s(e){return o(e)||a(e)}e.isDeploymentRef=s})(F||={});let I;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`ref`in e&&F.isDeploymentRef(e.ref)}e.isDeploymentRef=r;function i(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=i;function a(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=a;function o(e){return`where`in e&&c(e.where.expr)}e.isWhere=o;function s(e){return`custom`in e&&(c(e.custom.expr)||o(e.custom.expr))}e.isCustom=s;function c(e){return t(e)||n(e)||r(e)||i(e)||a(e)}e.is=c;function l(e){return s(e)&&(e=e.custom.expr),o(e)&&(e=e.where.expr),e}e.unwrap=l})(I||={});let L;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(L||={});let R;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return L.isWhere(e)}e.isRelationWhere=n;function r(e){return I.isWhere(e)}e.isFqnExprWhere=r;function i(e){return I.is(e)||I.isWhere(e)||I.isCustom(e)}e.isFqnExpr=i;function a(e){return L.is(e)||L.isWhere(e)||L.isCustom(e)}e.isRelation=a})(R||={});let z;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=r;function i(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=i;function a(e){return`where`in e&&s(e.where.expr)}e.isWhere=a;function o(e){return`custom`in e&&(s(e.custom.expr)||a(e.custom.expr))}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.custom.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(z||={});let B;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(B||={});let V;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return B.isWhere(e)}e.isRelationWhere=n;function r(e){return z.isWhere(e)}e.isFqnExprWhere=r;function i(e){return z.is(e)||z.isWhere(e)||z.isCustom(e)}e.isFqnExpr=i;function a(e){return B.is(e)||B.isWhere(e)||B.isCustom(e)}e.isRelationExpr=a})(V||={});function Me(e){return o(e.kind)&&!o(e.element)}function Ne(e){return o(e.element)&&!o(e.kind)}const H={fill:`#3b82f6`,stroke:`#2563eb`,hiContrast:`#eff6ff`,loContrast:`#bfdbfe`},U={fill:`#0284c7`,stroke:`#0369a1`,hiContrast:`#f0f9ff`,loContrast:`#B6ECF7`},W={fill:`#64748b`,stroke:`#475569`,hiContrast:`#f8fafc`,loContrast:`#cbd5e1`},Pe={primary:H,blue:H,secondary:U,sky:U,muted:W,slate:W,gray:{fill:`#737373`,stroke:`#525252`,hiContrast:`#fafafa`,loContrast:`#d4d4d4`},red:{fill:`#AC4D39`,stroke:`#853A2D`,hiContrast:`#FBD3CB`,loContrast:`#f5b2a3`},green:{fill:`#428a4f`,stroke:`#2d5d39`,hiContrast:`#f8fafc`,loContrast:`#c2f0c2`},amber:{fill:`#A35829`,stroke:`#7E451D`,hiContrast:`#FFE0C2`,loContrast:`#f9b27c`},indigo:{fill:`#6366f1`,stroke:`#4f46e5`,hiContrast:`#eef2ff`,loContrast:`#c7d2fe`}},Fe={line:`#8D8D8D`,labelBg:`#18191B`,label:`#C9C9C9`},G={line:`#64748b`,labelBg:`#0f172a`,label:`#cbd5e1`},K={line:`#3b82f6`,labelBg:`#172554`,label:`#60a5fa`},q={line:`#0ea5e9`,labelBg:`#082f49`,label:`#38bdf8`},Ie={amber:{line:`#b45309`,labelBg:`#78350f`,label:`#FFE0C2`},blue:K,gray:Fe,green:{line:`#15803d`,labelBg:`#052e16`,label:`#22c55e`},indigo:{line:`#6366f1`,labelBg:`#1e1b4b`,label:`#818cf8`},muted:G,primary:K,red:{line:`#AC4D39`,labelBg:`#b91c1c`,label:`#f5b2a3`},secondary:q,sky:q,slate:G},Le={sizes:{xs:{width:180,height:100},sm:{width:240,height:135},md:{width:320,height:180},lg:{width:420,height:234},xl:{width:520,height:290}},spacing:{xs:8,sm:10,md:16,lg:24,xl:32},textSizes:{xs:13.33,sm:16,md:19.2,lg:23.04,xl:27.65},iconSizes:{xs:24,sm:36,md:60,lg:82,xl:90}},Re=[`xs`,`sm`,`md`,`lg`,`xl`],ze=[`left`,`right`,`top`,`bottom`],Be=[`solid`,`dashed`,`dotted`,`none`],Ve=[`rectangle`,`person`,`browser`,`mobile`,`cylinder`,`storage`,`queue`,`bucket`,`document`,`component`],J=[`amber`,`blue`,`gray`,`slate`,`green`,`indigo`,`muted`,`primary`,`red`,`secondary`,`sky`],He=[`tomato`,`grass`,`blue`,`ruby`,`orange`,`indigo`,`pink`,`teal`,`purple`,`amber`,`crimson`,`red`,`lime`,`yellow`,`violet`],Y={tomato:ve.tomato9,grass:pe.grass9,blue:ge.blue9,ruby:ue.ruby9,orange:be.orange9,indigo:ce.indigo9,pink:le.pink9,teal:de.teal9,purple:me.purple9,amber:xe.amber9,crimson:ye.crimson9,red:Se.red9,lime:_e.lime9,yellow:fe.yellow9,violet:he.violet9};function Ue(e){return e in Y}const We={colors:J.reduce((e,t)=>(e[t]={elements:Pe[t],relationships:Ie[t]},e),{}),...Le};function Ge(e){d(h.valid(e),`Invalid color: ${e}`);let t=Ce(e),n=t[6],r=Ke(n);return{elements:{fill:n,stroke:t[7],...r},relationships:{line:t[4],label:t[3],labelBg:t[9]}}}function Ke(e){let t=h(e),n=t.brighten(2),r=t.darken(2),i,a,o,s;do i=n,a=r,n=n.brighten(1),r=r.darken(1),o=h.contrastAPCA(t,n),s=h.contrastAPCA(t,r);while(Math.abs(o)<60&&Math.abs(s)<60&&(!c(n,i)||!c(r,a)));return Math.abs(o)>Math.abs(s)?{hiContrast:n.brighten(.4).hex(),loContrast:n.hex()}:{hiContrast:r.darken(.4).hex(),loContrast:r.hex()}}function qe(e,t){let n=t??6,r=h(e.fill),i=h(e.stroke),a=r.luminance()>.8,o=l(ne(h.scale(a?[r.darken(.02).desaturate(.05),r.darken(.1).desaturate(.1)]:[r.shade(.12,`lch`).desaturate(.05),r.shade(.35,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null),h.scale(a?[i.darken(.04).desaturate(.05),i.darken(.12).desaturate(.1)]:[i.shade(.15,`lch`).desaturate(.08),i.shade(.4,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null)),s(([t,n])=>({...e,fill:t.hex(),stroke:n.hex()})));return d(o.length===n,`Expected ${n} colors, got ${o.length}`),o}const Je={color:`primary`,size:`md`,opacity:15,shape:`rectangle`,group:{opacity:15,border:`dashed`},relationship:{color:`gray`,line:`dashed`,arrow:`normal`}},Ye=We,X={theme:Ye,defaults:Je};var Xe=class e{theme;defaults;static DEFAULT=new e(X);static from(n,i){if(!n&&!i)return this.DEFAULT;let{customCss:a,theme:o,defaults:s}={...n},l=t({theme:o},{defaults:{...s}},{theme:{colors:{...i}}},X);return r(a?.content)&&c(l,X)?this.DEFAULT:new e(l,a)}constructor(e,t){this.config=e,this.customCss=t,this.theme=e.theme,this.defaults=e.defaults}get elementColors(){return this.theme.colors[this.defaults.color].elements}get relationshipColors(){return this.theme.colors[this.defaults.relationship.color].relationships}get groupColors(){let e=this.defaults.group?.color;if(!e)return this.elementColors;if(!this.isThemeColor(e))throw Error(`Default group color not found in theme: ${e}`);return p(this,`defaultGroup`,()=>({...this.elementColors,...this.theme.colors[e].elements}))}isDefaultColor(e){return e===this.defaults.color}colors(e){return this.computeFrom(e??=this.defaults.color)}compoundColorsCache=new oe.default(e=>new se.default(t=>qe(e,t)));colorsForCompounds(e,t){return this.compoundColorsCache.get(e).get(t??6)}fontSize(e){return e??=this.defaults.text??this.defaults.size,this.theme.textSizes[e]}padding(e){return e??=this.defaults.padding??this.defaults.size,this.theme.spacing[e]}iconSize(e){return e??=this.defaults.size,this.theme.iconSizes[e]}isThemeColor(e){return e in this.theme.colors}nodeSizes(e){let t=Ze(e,this.defaults.size);return{sizes:t,values:{sizes:this.theme.sizes[t.size],padding:this.padding(t.padding),textSize:this.fontSize(t.textSize),iconSize:this.iconSize(t.iconSize)}}}computeFrom(e){if(this.isThemeColor(e))return this.theme.colors[e];if(!h.valid(e))throw Error(`Invalid color value: "${e}" (not a theme color and not a valid CSS color)`);return Ge(e)}equals(e){return e===this?!0:this.constructor===e.constructor?c(this.config,e.config)&&c(this.customCss??null,e.customCss??null):!1}tagColor(e){return this.isThemeColor(e)?this.theme.colors[e].elements:Ue(e)?this.computeFrom(Y[e]).elements:this.computeFrom(e).elements}};function Ze({size:e,padding:t,textSize:n,iconSize:r,...i},a=X.defaults.size){return e??=a,n??=e,t??=e,r??=e,{...i,size:e,padding:t,textSize:n,iconSize:r}}function Qe(e){let t=typeof e==`string`?e:e.color;return t.startsWith(`#`)||t.startsWith(`rgb`)}function $e(e){return`tag`in e}function et(e){return`kind`in e}function tt(e){return`participant`in e}function nt(e){return`not`in e}function rt(e){return`and`in e}function Z(e){return`or`in e}function Q(e){switch(!0){case tt(e):{let t=e.participant;return it(t,Q(e.operator))}case $e(e):{if(u(e.tag)||`eq`in e.tag){let t=u(e.tag)?e.tag:e.tag.eq;return e=>Array.isArray(e.tags)&&e.tags.includes(t)}let t=e.tag.neq;return e=>!Array.isArray(e.tags)||!e.tags.includes(t)}case et(e):{if(u(e.kind)||`eq`in e.kind){let t=u(e.kind)?e.kind:e.kind.eq;return e=>e.kind===t}let t=e.kind.neq;return e=>i(e.kind)||e.kind!==t}case nt(e):return a(Q(e.not));case rt(e):return ee(e.and.map(Q));case Z(e):return te(e.or.map(Q));default:f(e)}}function it(e,t){return n=>{if(!n.source||!n.target)return!1;switch(e){case`source`:return t(n.source);case`target`:return t(n.target)}}}function at(e){return`include`in e||`exclude`in e}function ot(e){return`targets`in e&&`style`in e}function st(e){return e._stage===`computed`}function ct(e){return e._stage===`layouted`}function $(e){return e._type===`element`}function lt(e){return $(e)&&o(e.viewOf)}function ut(e){return $(e)&&o(e.extends)}function dt(e){return e._type===`deployment`}function ft(e){return e._type===`dynamic`}function pt(e){return`styleId`in e}function mt(e){return`predicateId`in e}function ht(e){return e===`TB`||e===`BT`||e===`LR`||e===`RL`}function gt(e){return`direction`in e}function _t(e){return N(e)&&e.includes(`.`)?e.slice(0,e.indexOf(`.`)+1):null}function vt(e){return!!e&&!(`__series`in e||`__parallel`in e)}function yt(e){return!!e&&`__parallel`in e&&n(e.__parallel)}function bt(e){return!!e&&`__series`in e&&n(e.__series)}function xt(e){return`title`in e&&`groupRules`in e&&Array.isArray(e.groupRules)}function St(e){return`rank`in e&&Array.isArray(e.targets)}const Ct=Symbol.for(`text`),wt=Symbol.for(`html`);var Tt=class e{static mdcache=new m.default(500);static txtcache=new m.default(500);static getOrCreateFromText(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.txtcache.get(t);return n||(n=new e({txt:t}),e.txtcache.set(t,n),n)}static getOrCreateFromMarkdown(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.mdcache.get(t);return n||(n=new e({md:t}),e.mdcache.set(t,n),n)}static memoize(t,n,r){return p(t,n,()=>e.from(r))}static from(t){return t==null||t===e.EMPTY?e.EMPTY:t instanceof e?t:typeof t==`string`?this.getOrCreateFromText(t):`isEmpty`in t&&t.isEmpty?e.EMPTY:`md`in t?this.getOrCreateFromMarkdown(t.md):this.getOrCreateFromText(t.txt)}static EMPTY=new class extends e{isEmpty=!0;nonEmpty=!1;isMarkdown=!1;$source=null;constructor(){super({txt:``})}get text(){return null}get md(){return null}get html(){return null}};$source;isEmpty;nonEmpty;isMarkdown;constructor(e){this.isMarkdown=!1,typeof e==`string`?(this.$source={txt:e},this.isEmpty=e.trim()===``):(this.$source=e,this.isEmpty=!0,`md`in e?(this.isEmpty=e.md===``,this.isMarkdown=!0):this.isEmpty=e.txt===``),this.nonEmpty=!this.isEmpty}get text(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,Ct,()=>ae(e.md))}get md(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;if(`md`in e)return e.md;if(`txt`in e)return e.txt;f(e)}get html(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,wt,()=>ie(e.md))}equals(t){return this===t?!0:t instanceof e?this.isEmpty&&t.isEmpty?!0:this.isEmpty!==t.isEmpty||this.isMarkdown!==t.isMarkdown?!1:this.isMarkdown?this.$source?.md===t.$source?.md:this.$source?.txt===t.$source?.txt:!1}};export{S as $,Xe as A,Ne as B,nt as C,Q as D,$e as E,He as F,R as G,V as H,Ve as I,F as J,I as K,ze as L,Je as M,Ge as N,Qe as O,Be as P,D as Q,Re as R,et as S,tt as T,z as U,Me as V,B as W,j as X,w as Y,x as Z,ut as _,Oe as _t,vt as a,je as at,ot as b,Te as bt,ht as c,y as ct,pt as d,N as dt,v as et,st as f,Ae as ft,$ as g,g as gt,ft as h,ke as ht,_t as i,E as it,Ye as j,Ze as k,gt as l,O as lt,ct as m,M as mt,xt as n,b as nt,yt as o,T as ot,dt as p,k as pt,L as q,St as r,_ as rt,bt as s,P as st,Tt as t,A as tt,mt as u,C as ut,lt as v,De as vt,Z as w,rt as x,we as xt,at as y,Ee as yt,J as z};
|
package/dist/_chunks/utils.mjs
CHANGED
|
@@ -1,483 +1 @@
|
|
|
1
|
-
import { r as
|
|
2
|
-
import { N as e$2, O as e, Q as t, Z as t$4, a as t$2, f as e$1, t as t$1, w as t$3 } from "./libs/remeda.mjs";
|
|
3
|
-
import { t as require_natural_compare_lite } from "./libs/natural-compare-lite.mjs";
|
|
4
|
-
import { t as invariant } from "./invariant.mjs";
|
|
5
|
-
import { c as import_set } from "./libs/mnemonist.mjs";
|
|
6
|
-
import { t as defu } from "./libs/defu.mjs";
|
|
7
|
-
import { n as defaultSchema } from "./libs/hast-util-sanitize.mjs";
|
|
8
|
-
import { t as rehypeSanitize } from "./libs/rehype-sanitize.mjs";
|
|
9
|
-
import { t as rehypeStringify } from "./libs/rehype-stringify.mjs";
|
|
10
|
-
import { c as toString, t as fromMarkdown } from "./libs/mdast-util-from-markdown.mjs";
|
|
11
|
-
import { t as remarkGfm } from "./libs/remark-gfm.mjs";
|
|
12
|
-
import { t as remarkAlert } from "./libs/remark-github-blockquote-alert.mjs";
|
|
13
|
-
import { t as remarkParse } from "./libs/remark-parse.mjs";
|
|
14
|
-
import { t as remarkRehype } from "./libs/remark-rehype.mjs";
|
|
15
|
-
import { t as unified } from "./libs/unified.mjs";
|
|
16
|
-
import { hash } from "ohash";
|
|
17
|
-
|
|
18
|
-
//#region src/utils/compare-natural.ts
|
|
19
|
-
var import_natural_compare_lite = /* @__PURE__ */ __toESM(require_natural_compare_lite(), 1);
|
|
20
|
-
function compareNatural(a, b) {
|
|
21
|
-
if (a === b) return 0;
|
|
22
|
-
if (e(a)) {
|
|
23
|
-
if (e(b)) return (0, import_natural_compare_lite.default)(a, b);
|
|
24
|
-
return 1;
|
|
25
|
-
}
|
|
26
|
-
return e(b) ? -1 : 0;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Compares two strings lexicographically first, then hierarchically based on their depth.\
|
|
30
|
-
* From parent nodes to leaves
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* const lines = [
|
|
34
|
-
* 'b.c',
|
|
35
|
-
* 'b',
|
|
36
|
-
* 'a.b.c',
|
|
37
|
-
* ]
|
|
38
|
-
* lines.sort(compareNaturalHierarchically('.'))
|
|
39
|
-
* // [
|
|
40
|
-
* // 'a.b.c',
|
|
41
|
-
* // 'b',
|
|
42
|
-
* // 'b.c',
|
|
43
|
-
* // ]
|
|
44
|
-
*/
|
|
45
|
-
function compareNaturalHierarchically(separator = ".", deepestFirst = false) {
|
|
46
|
-
return (a, b) => {
|
|
47
|
-
if (a === b) return 0;
|
|
48
|
-
if (!a) return -1;
|
|
49
|
-
if (!b) return 1;
|
|
50
|
-
const aParts = a.split(separator);
|
|
51
|
-
const bParts = b.split(separator);
|
|
52
|
-
const minLength = Math.min(aParts.length, bParts.length);
|
|
53
|
-
for (let i = 0; i < minLength; i++) {
|
|
54
|
-
const aPart = aParts[i];
|
|
55
|
-
const bPart = bParts[i];
|
|
56
|
-
const comparison = (0, import_natural_compare_lite.default)(aPart, bPart);
|
|
57
|
-
if (comparison !== 0) return comparison;
|
|
58
|
-
}
|
|
59
|
-
const diff = aParts.length - bParts.length;
|
|
60
|
-
return deepestFirst ? -1 * diff : diff;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/utils/common-head.ts
|
|
66
|
-
/**
|
|
67
|
-
* Common head of two arrays
|
|
68
|
-
*
|
|
69
|
-
* @param equals - Equality function, defaults to `Object.is`
|
|
70
|
-
*/
|
|
71
|
-
function commonHead(sources, targets, equals) {
|
|
72
|
-
if (sources.length === 0 || targets.length === 0) return [];
|
|
73
|
-
equals ??= Object.is;
|
|
74
|
-
return t(t$1(sources, targets), t$2(([source, target]) => equals(source, target)), t$3(([source, _]) => source));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/utils/guards.ts
|
|
79
|
-
function isString(value) {
|
|
80
|
-
return value != null && typeof value === "string";
|
|
81
|
-
}
|
|
82
|
-
function isNonEmptyArray(arr) {
|
|
83
|
-
return !!arr && Array.isArray(arr) && arr.length > 0;
|
|
84
|
-
}
|
|
85
|
-
function hasProp(value, path) {
|
|
86
|
-
return value[path] != null;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Creates a type guard that checks if a value matches any of the provided predicates.
|
|
90
|
-
*
|
|
91
|
-
* @template Predicates - A non-empty array of guard functions
|
|
92
|
-
* @param predicates - The guard functions to test against
|
|
93
|
-
* @returns A type guard function that returns true if the value matches any of the predicates
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* const isStringOrNumber = isAnyOf(isString, isNumber);
|
|
98
|
-
*
|
|
99
|
-
* if (isStringOrNumber(value)) {
|
|
100
|
-
* // value is now typed as string | number
|
|
101
|
-
* console.log(value);
|
|
102
|
-
* }
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
function isAnyOf(...predicates) {
|
|
106
|
-
return (value) => {
|
|
107
|
-
return predicates.some((predicate) => predicate(value));
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/utils/fqn.ts
|
|
113
|
-
function parentFqn(fqn) {
|
|
114
|
-
const lastDot = fqn.lastIndexOf(".");
|
|
115
|
-
if (lastDot > 0) return fqn.slice(0, lastDot);
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
function nameFromFqn(fqn) {
|
|
119
|
-
const lastDot = fqn.lastIndexOf(".");
|
|
120
|
-
if (lastDot > 0) return fqn.slice(lastDot + 1);
|
|
121
|
-
else return fqn;
|
|
122
|
-
}
|
|
123
|
-
const asString = (e) => isString(e) ? e : e.id;
|
|
124
|
-
function isAncestor(arg1, arg2) {
|
|
125
|
-
const arg1Id = asString(arg1);
|
|
126
|
-
if (arg2) return asString(arg2).startsWith(arg1Id + ".");
|
|
127
|
-
return (ancestor) => {
|
|
128
|
-
const ancestorId = asString(ancestor);
|
|
129
|
-
return arg1Id.startsWith(ancestorId + ".");
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function isSameHierarchy(one, another) {
|
|
133
|
-
if (!another) return (b) => isSameHierarchy(one, b);
|
|
134
|
-
const first = asString(one);
|
|
135
|
-
const second = asString(another);
|
|
136
|
-
return first === second || second.startsWith(first + ".") || first.startsWith(second + ".");
|
|
137
|
-
}
|
|
138
|
-
function isDescendantOf(descedant, ancestor) {
|
|
139
|
-
if (!ancestor) return (d) => isAncestor(descedant, d);
|
|
140
|
-
return isAncestor(ancestor, descedant);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* How deep in the hierarchy the element is.
|
|
144
|
-
* Root element has depth 1
|
|
145
|
-
*/
|
|
146
|
-
function hierarchyLevel(elementOfFqn) {
|
|
147
|
-
return (isString(elementOfFqn) ? elementOfFqn : elementOfFqn.id).split(".").length;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Calculate the distance as number of steps from one element to another, i.e.
|
|
151
|
-
* going up to the common ancestor, then going down to the other element.
|
|
152
|
-
* Sibling distance is always 1
|
|
153
|
-
*
|
|
154
|
-
* Can be used for hierarchical clustering
|
|
155
|
-
*/
|
|
156
|
-
function hierarchyDistance(one, another) {
|
|
157
|
-
const first = isString(one) ? one : one.id;
|
|
158
|
-
const second = isString(another) ? another : another.id;
|
|
159
|
-
if (first === second) return 0;
|
|
160
|
-
const firstDepth = hierarchyLevel(first);
|
|
161
|
-
const secondDepth = hierarchyLevel(second);
|
|
162
|
-
if (isSameHierarchy(first, second)) return Math.abs(firstDepth - secondDepth);
|
|
163
|
-
const ancestor = commonAncestor(first, second);
|
|
164
|
-
const ancestorDepth = ancestor ? hierarchyLevel(ancestor) : 0;
|
|
165
|
-
return firstDepth + secondDepth - (2 * ancestorDepth + 1);
|
|
166
|
-
}
|
|
167
|
-
function commonAncestor(first, second) {
|
|
168
|
-
const a = first.split(".");
|
|
169
|
-
if (a.length < 2) return null;
|
|
170
|
-
const b = second.split(".");
|
|
171
|
-
if (b.length < 2) return null;
|
|
172
|
-
let ancestor = [];
|
|
173
|
-
for (let i = 0; i < Math.min(a.length, b.length) - 1 && a[i] === b[i]; i++) ancestor.push(a[i]);
|
|
174
|
-
if (ancestor.length === 0) return null;
|
|
175
|
-
return ancestor.join(".");
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Get all ancestor elements (i.e. parent, parent’s parent, etc.)
|
|
179
|
-
* going up from parent to the root
|
|
180
|
-
*/
|
|
181
|
-
function ancestorsFqn(fqn) {
|
|
182
|
-
const path = fqn.split(".");
|
|
183
|
-
path.pop();
|
|
184
|
-
if (path.length === 0) return [];
|
|
185
|
-
return path.reduce((acc, part, idx) => {
|
|
186
|
-
if (idx === 0) {
|
|
187
|
-
acc.push(part);
|
|
188
|
-
return acc;
|
|
189
|
-
}
|
|
190
|
-
acc.unshift(`${acc[0]}.${part}`);
|
|
191
|
-
return acc;
|
|
192
|
-
}, []);
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Compares two fully qualified names (fqns) hierarchically based on their depth.
|
|
196
|
-
* From parent nodes to leaves
|
|
197
|
-
*
|
|
198
|
-
* @param {string} a - The first fqn to compare.
|
|
199
|
-
* @param {string} b - The second fqn to compare.
|
|
200
|
-
* @returns {number} - 0 if the fqns have the same depth.
|
|
201
|
-
* - Positive number if a is deeper than b.
|
|
202
|
-
* - Negative number if b is deeper than a.
|
|
203
|
-
*/
|
|
204
|
-
function compareFqnHierarchically(a, b) {
|
|
205
|
-
const depthA = a.split(".").length;
|
|
206
|
-
const depthB = b.split(".").length;
|
|
207
|
-
switch (true) {
|
|
208
|
-
case depthA > depthB: return 1;
|
|
209
|
-
case depthA < depthB: return -1;
|
|
210
|
-
default: return 0;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function compareByFqnHierarchically(a, b) {
|
|
214
|
-
return compareFqnHierarchically(a.id, b.id);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Sorts an array of objects hierarchically based on their fully qualified names (FQN).
|
|
218
|
-
* Objects are sorted by the number of segments in their FQN (defined by dot-separated ID).
|
|
219
|
-
*
|
|
220
|
-
* @typeParam T - Object type that contains an 'id' string property
|
|
221
|
-
* @typeParam A - Type extending IterableContainer of T
|
|
222
|
-
*
|
|
223
|
-
* @param array - Array of objects to be sorted
|
|
224
|
-
* @returns A new array with items sorted by their FQN hierarchy depth (number of segments)
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* ```ts
|
|
228
|
-
* const items = [
|
|
229
|
-
* { id: "a.b.c" },
|
|
230
|
-
* { id: "a" },
|
|
231
|
-
* { id: "a.b" }
|
|
232
|
-
* ];
|
|
233
|
-
* sortByFqnHierarchically(items);
|
|
234
|
-
* // Result: [
|
|
235
|
-
* // { id: "a" },
|
|
236
|
-
* // { id: "a.b" },
|
|
237
|
-
* // { id: "a.b.c" }
|
|
238
|
-
* // ]
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
function sortByFqnHierarchically(array) {
|
|
242
|
-
return array.map((item) => ({
|
|
243
|
-
item,
|
|
244
|
-
fqn: item.id.split(".")
|
|
245
|
-
})).sort((a, b) => {
|
|
246
|
-
return a.fqn.length - b.fqn.length;
|
|
247
|
-
}).map(({ item }) => item);
|
|
248
|
-
}
|
|
249
|
-
function findTopAncestor(items, item) {
|
|
250
|
-
let parent = item;
|
|
251
|
-
for (const e of items) if (isAncestor(e, parent)) parent = e;
|
|
252
|
-
return parent !== item ? parent : null;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Keeps initial order of the elements, but ensures that parents are before children
|
|
256
|
-
*/
|
|
257
|
-
function sortParentsFirst(array) {
|
|
258
|
-
const result = [];
|
|
259
|
-
const items = [...array];
|
|
260
|
-
let item;
|
|
261
|
-
while (item = items.shift()) {
|
|
262
|
-
let parent;
|
|
263
|
-
while (parent = findTopAncestor(items, item)) result.push(items.splice(items.indexOf(parent), 1)[0]);
|
|
264
|
-
result.push(item);
|
|
265
|
-
}
|
|
266
|
-
return result;
|
|
267
|
-
}
|
|
268
|
-
function sortNaturalByFqn(array, sort) {
|
|
269
|
-
if (!array || isString(array)) {
|
|
270
|
-
const dir = array ?? "asc";
|
|
271
|
-
return (arr) => sortNaturalByFqn(arr, dir);
|
|
272
|
-
}
|
|
273
|
-
const dir = sort === "desc" ? -1 : 1;
|
|
274
|
-
return array.map((item) => ({
|
|
275
|
-
item,
|
|
276
|
-
fqn: item.id.split(".")
|
|
277
|
-
})).sort((a, b) => {
|
|
278
|
-
if (a.fqn.length !== b.fqn.length) return (a.fqn.length - b.fqn.length) * dir;
|
|
279
|
-
for (let i = 0; i < a.fqn.length; i++) {
|
|
280
|
-
const compare = compareNatural(a.fqn[i], b.fqn[i]);
|
|
281
|
-
if (compare !== 0) return compare;
|
|
282
|
-
}
|
|
283
|
-
return 0;
|
|
284
|
-
}).map(({ item }) => item);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region src/utils/getOrCreate.ts
|
|
289
|
-
function getOrCreate(map, key, create) {
|
|
290
|
-
let entry = map.get(key);
|
|
291
|
-
if (!entry) {
|
|
292
|
-
entry = create(key);
|
|
293
|
-
map.set(key, entry);
|
|
294
|
-
}
|
|
295
|
-
return entry;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/utils/memoize-prop.ts
|
|
300
|
-
/**
|
|
301
|
-
* Saves the value returned by fn() in a hidden property tag of obj object, so next time memoizeProp() is called,
|
|
302
|
-
* that value will be returned, and fn won't be called.
|
|
303
|
-
*
|
|
304
|
-
* @example
|
|
305
|
-
* ```ts
|
|
306
|
-
* class Model {
|
|
307
|
-
* // using same Symbol
|
|
308
|
-
* get computed1() {
|
|
309
|
-
* return memoizeProp(this, Symbol.for('computed1'), () => doOnce())
|
|
310
|
-
* }
|
|
311
|
-
* // using string
|
|
312
|
-
* get computed2() {
|
|
313
|
-
* return memoizeProp(this, 'computed2', () => doOnce())
|
|
314
|
-
* }
|
|
315
|
-
*
|
|
316
|
-
* }
|
|
317
|
-
* ```
|
|
318
|
-
*/
|
|
319
|
-
function memoizeProp(obj, tag, fn) {
|
|
320
|
-
const tagSymbol = typeof tag === "symbol" ? tag : Symbol.for(tag);
|
|
321
|
-
if (!obj.hasOwnProperty(tagSymbol)) Object.defineProperty(obj, tagSymbol, {
|
|
322
|
-
enumerable: false,
|
|
323
|
-
writable: false,
|
|
324
|
-
value: fn()
|
|
325
|
-
});
|
|
326
|
-
return obj[tagSymbol];
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
//#endregion
|
|
330
|
-
//#region src/utils/promises.ts
|
|
331
|
-
const DELAY = "LIKEC4_DELAY";
|
|
332
|
-
function delay(...args) {
|
|
333
|
-
let ms = 100;
|
|
334
|
-
if (args.length === 2) ms = e$1(args[0], args[1]);
|
|
335
|
-
else if (args.length === 1) ms = args[0];
|
|
336
|
-
return new Promise((resolve) => {
|
|
337
|
-
setTimeout(() => {
|
|
338
|
-
resolve(DELAY);
|
|
339
|
-
}, ms ?? 100);
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
function promiseNextTick() {
|
|
343
|
-
return Promise.resolve().then(() => void 0);
|
|
344
|
-
}
|
|
345
|
-
function onNextTick(fn) {
|
|
346
|
-
Promise.resolve().then(fn);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/utils/relations.ts
|
|
351
|
-
/**
|
|
352
|
-
* Compares two relations hierarchically.
|
|
353
|
-
* From the most general (implicit) to the most specific (deepest in the tree)
|
|
354
|
-
*/
|
|
355
|
-
const compareRelations = (a, b) => {
|
|
356
|
-
const parentA = commonAncestor(a.source.id, a.target.id);
|
|
357
|
-
const parentB = commonAncestor(b.source.id, b.target.id);
|
|
358
|
-
if (parentA && !parentB) return 1;
|
|
359
|
-
if (!parentA && parentB) return -1;
|
|
360
|
-
const compareParents = parentA && parentB ? compareFqnHierarchically(parentA, parentB) : 0;
|
|
361
|
-
if (compareParents !== 0) return compareParents;
|
|
362
|
-
const compareSource = compareFqnHierarchically(a.source.id, b.source.id);
|
|
363
|
-
if (compareSource !== 0) return compareSource;
|
|
364
|
-
return compareFqnHierarchically(a.target.id, b.target.id);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
//#endregion
|
|
368
|
-
//#region src/utils/set.ts
|
|
369
|
-
/**
|
|
370
|
-
* Returns new set as a union of given sets
|
|
371
|
-
* Keeps order of elements
|
|
372
|
-
*/
|
|
373
|
-
function union(...sets) {
|
|
374
|
-
let result = /* @__PURE__ */ new Set();
|
|
375
|
-
for (const set of sets) for (const value of set) result.add(value);
|
|
376
|
-
return result;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Returns new set as an intersection of all sets
|
|
380
|
-
* Keeps order from the first set
|
|
381
|
-
*/
|
|
382
|
-
function intersection(first, ...sets) {
|
|
383
|
-
let result = /* @__PURE__ */ new Set();
|
|
384
|
-
if (first.size === 0) return result;
|
|
385
|
-
let other = t$4(sets, 2) ? (0, import_set.intersection)(...sets) : sets[0];
|
|
386
|
-
if (other.size === 0) return result;
|
|
387
|
-
for (const value of first) if (other.has(value)) result.add(value);
|
|
388
|
-
return result;
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Returns new set as a difference of two sets (A-B)
|
|
392
|
-
* Keeps order from the first set
|
|
393
|
-
*/
|
|
394
|
-
function difference(a, b) {
|
|
395
|
-
if (a.size === 0) return /* @__PURE__ */ new Set();
|
|
396
|
-
if (b.size === 0) return new Set(a);
|
|
397
|
-
let result = /* @__PURE__ */ new Set();
|
|
398
|
-
for (const value of a) if (!b.has(value)) result.add(value);
|
|
399
|
-
return result;
|
|
400
|
-
}
|
|
401
|
-
function equals(a, b) {
|
|
402
|
-
return a.size === b.size && [...a].every((value) => b.has(value));
|
|
403
|
-
}
|
|
404
|
-
function symmetricDifference(a, b) {
|
|
405
|
-
return (0, import_set.symmetricDifference)(a, b);
|
|
406
|
-
}
|
|
407
|
-
function hasIntersection(a, b) {
|
|
408
|
-
if (a.size === 0 || b.size === 0) return false;
|
|
409
|
-
if (b.size < a.size) [a, b] = [b, a];
|
|
410
|
-
for (const value of a) if (b.has(value)) return true;
|
|
411
|
-
return false;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
//#endregion
|
|
415
|
-
//#region src/utils/object-hash.ts
|
|
416
|
-
function objectHash(value) {
|
|
417
|
-
invariant(typeof value === "object" && e$2(value), "objectHash: value must be an object");
|
|
418
|
-
return hash(value);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
//#endregion
|
|
422
|
-
//#region src/utils/string-hash.ts
|
|
423
|
-
/**
|
|
424
|
-
* @see https://gist.github.com/victor-homyakov/bcb7d7911e4a388b1c810f8c3ce17bcf
|
|
425
|
-
*/
|
|
426
|
-
function stringHash(str) {
|
|
427
|
-
let hash = 5381;
|
|
428
|
-
const len = str.length;
|
|
429
|
-
invariant(len > 0, "stringHash: empty string");
|
|
430
|
-
for (let i = 0; i < len; i++) hash = hash * 33 ^ str.charCodeAt(i);
|
|
431
|
-
return (hash >>> 0).toString(36);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
//#endregion
|
|
435
|
-
//#region src/utils/markdown/to-html.ts
|
|
436
|
-
function parser() {
|
|
437
|
-
return unified().use(remarkParse).use(remarkGfm).use(remarkAlert).use(remarkRehype, { allowDangerousHtml: true }).use(rehypeSanitize, defu({
|
|
438
|
-
attributes: {
|
|
439
|
-
"*": ["className"],
|
|
440
|
-
"svg": [
|
|
441
|
-
"width",
|
|
442
|
-
"height",
|
|
443
|
-
"viewBox",
|
|
444
|
-
"fill",
|
|
445
|
-
"ariaHidden"
|
|
446
|
-
],
|
|
447
|
-
"path": [
|
|
448
|
-
"d",
|
|
449
|
-
"fill",
|
|
450
|
-
"stroke",
|
|
451
|
-
"strokeWidth",
|
|
452
|
-
"strokeLinecap",
|
|
453
|
-
"strokeLinejoin"
|
|
454
|
-
]
|
|
455
|
-
},
|
|
456
|
-
tagNames: [
|
|
457
|
-
"svg",
|
|
458
|
-
"g",
|
|
459
|
-
"path",
|
|
460
|
-
"div"
|
|
461
|
-
]
|
|
462
|
-
}, defaultSchema)).use(rehypeStringify, { allowDangerousHtml: true });
|
|
463
|
-
}
|
|
464
|
-
function markdownToHtml(markdown) {
|
|
465
|
-
return ("" + parser().processSync(markdown)).trim();
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
//#endregion
|
|
469
|
-
//#region src/utils/markdown/to-text.ts
|
|
470
|
-
/**
|
|
471
|
-
* Converts markdown to plain text, removing any markdown formatting.
|
|
472
|
-
* @param markdown - The markdown to convert.
|
|
473
|
-
* @returns The plain text.
|
|
474
|
-
*/
|
|
475
|
-
function markdownToText(markdown) {
|
|
476
|
-
return toString(fromMarkdown(markdown), {
|
|
477
|
-
includeHtml: false,
|
|
478
|
-
includeImageAlt: false
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
//#endregion
|
|
483
|
-
export { sortParentsFirst as A, isAncestor as C, parentFqn as D, nameFromFqn as E, commonHead as F, compareNatural as I, compareNaturalHierarchically as L, isAnyOf as M, isNonEmptyArray as N, sortByFqnHierarchically as O, isString as P, hierarchyLevel as S, isSameHierarchy as T, ancestorsFqn as _, difference as a, compareFqnHierarchically as b, intersection as c, compareRelations as d, delay as f, getOrCreate as g, memoizeProp as h, objectHash as i, hasProp as j, sortNaturalByFqn as k, symmetricDifference as l, promiseNextTick as m, markdownToHtml as n, equals as o, onNextTick as p, stringHash as r, hasIntersection as s, markdownToText as t, union as u, commonAncestor as v, isDescendantOf as w, hierarchyDistance as x, compareByFqnHierarchically as y };
|
|
1
|
+
import{r as e}from"./rolldown-runtime.mjs";import{t}from"./libs/defu.mjs";import{F as n,P as r,Q as i,R as a,T as o,a as s,et as c,f as l,k as u,l as d,t as f}from"./libs/remeda.mjs";import{s as p}from"./libs/mnemonist.mjs";import{t as m}from"./libs/natural-compare-lite.mjs";import{t as h}from"./libs/ohash.mjs";import{n as g}from"./libs/hast-util-sanitize.mjs";import{t as _}from"./libs/rehype-sanitize.mjs";import{t as v}from"./libs/rehype-stringify.mjs";import{l as y,t as b}from"./libs/mdast-util-from-markdown.mjs";import{t as ee}from"./libs/remark-gfm.mjs";import{t as te}from"./libs/remark-github-blockquote-alert.mjs";import{t as ne}from"./libs/remark-parse.mjs";import{t as re}from"./libs/remark-rehype.mjs";import{t as ie}from"./libs/unified.mjs";function x(e,t){if(e===void 0||e==null){let n=typeof t==`function`?t():t;throw Error(n??`Expected defined value, but received ${e}`)}return e}function S(e,t){if(!e)throw Error(t??`Invariant failed`)}function C(e){throw Error(`NonExhaustive value: ${e}`)}function w(e,t,n){return e.length===0||t.length===0?[]:(n??=Object.is,c(f(e,t),s(([e,t])=>n(e,t)),o(([e,t])=>e)))}var T=e(m(),1);function E(e,t){return e===t?0:u(e)?u(t)?(0,T.default)(e,t):1:u(t)?-1:0}function D(e){return d(e,E)}function O(...e){return e.length===0?D:D(e[0])}function k(e=`.`,t=!1){return(n,r)=>{if(n===r)return 0;if(!n)return-1;if(!r)return 1;let i=n.split(e),a=r.split(e),o=Math.min(i.length,a.length);for(let e=0;e<o;e++){let t=i[e],n=a[e],r=(0,T.default)(t,n);if(r!==0)return r}let s=i.length-a.length;return t?-1*s:s}}function A(e){return e!=null&&typeof e==`string`}function j(e){return!!e&&Array.isArray(e)&&e.length>0}function M(e,t){return e[t]!=null}function N(...e){return(t=>e.some(e=>e(t)))}function P(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(0,t):null}function F(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t+1):e}const I=e=>A(e)?e:e.id;function L(e,t){let n=I(e);return t?I(t).startsWith(n+`.`):e=>{let t=I(e);return n.startsWith(t+`.`)}}function R(e,t){if(!t)return t=>R(e,t);let n=I(e),r=I(t);return n===r||r.startsWith(n+`.`)||n.startsWith(r+`.`)}function z(e,t){return t?L(t,e):t=>L(e,t)}function B(e){return(A(e)?e:e.id).split(`.`).length}function V(e,t){let n=A(e)?e:e.id,r=A(t)?t:t.id;if(n===r)return 0;let i=B(n),a=B(r);if(R(n,r))return Math.abs(i-a);let o=H(n,r),s=o?B(o):0;return i+a-(2*s+1)}function H(e,t){let n=e.split(`.`);if(n.length<2)return null;let r=t.split(`.`);if(r.length<2)return null;let i=[];for(let e=0;e<Math.min(n.length,r.length)-1&&n[e]===r[e];e++)i.push(n[e]);return i.length===0?null:i.join(`.`)}function U(e){let t=e.split(`.`);if(t.pop(),!i(t,2))return t;for(let e=1;e<t.length;e++)t[e]=t[e-1]+`.`+t[e];return t.reverse()}function W(e,t){let n=e.split(`.`).length,r=t.split(`.`).length;switch(!0){case n>r:return 1;case n<r:return-1;default:return 0}}function G(e,t){return W(e.id,t.id)}function K(e){return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>e.fqn.length-t.fqn.length).map(({item:e})=>e)}function q(e,t){let n=t;for(let t of e)t!==n&&L(t,n)&&(n=t);return n===t?null:n}function J(e){let t=[],n=[...e],r;for(;r=n.shift();){let e;for(;e=q(n,r);)t.push(...n.splice(n.indexOf(e),1));t.push(r)}return t}function Y(e,t){if(!e||A(e)){let t=e??`asc`;return e=>Y(e,t)}let n=t===`desc`?-1:1;return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>{if(e.fqn.length!==t.fqn.length)return(e.fqn.length-t.fqn.length)*n;for(let n=0;n<e.fqn.length;n++){let r=E(e.fqn[n],t.fqn[n]);if(r!==0)return r}return 0}).map(({item:e})=>e)}function ae(e,t,n){let r=e.get(t);return r||(r=n(t),e.set(t,r)),r}function oe(e){return typeof e==`object`&&!!e&&Symbol.iterator in e}function se(e,t){let r=t??e;S(n(r));function*i(e){for(let t of e)r(t)&&(yield t)}return t?i(e):i}function ce(e,t){let r=t??e;S(n(r));function i(e){for(let t of e)if(r(t))return t}return t?i(e):i}function le(e,t){let n=t??e;S(typeof n==`number`&&n>=0,`Count must be a non-negative number`);function*r(e){let t=0;for(let r of e){if(t>=n)break;yield r,t++}}return t===void 0?e=>r(e):r(e)}function ue(e){return e?X(e):X}function*X(e){for(let t of e)yield*t}function de(e,t){let r=t??e;S(n(r));function*i(e){for(let t of e)yield*r(t)}return t?i(e):i}function fe(e){return e?Z(e):Z}function Z(e){let{value:t}=e[Symbol.iterator]().next();return t}function pe(e,t){let r=t??e;S(n(r));function*i(e){for(let t of e)yield r(t)}return t?i(e):i}function me(e,t,r){let i=a(r)?t:e,o=r??t;S(n(i));function s(e){let t=o;for(let n of e)t=i(t,n);return t}return a(r)?s(e):s}function he(e,t){let r=t??e;S(n(r));function i(e){for(let t of e)if(r(t))return!0;return!1}return t?i(e):i}function ge(e){return e?Array.from(e):e=>Array.from(e)}function _e(e){return e?new Set(e):e=>new Set(e)}function ve(e){return e?Q(e):Q}function*Q(e){let t=new Set;for(let n of e)t.has(n)||(t.add(n),yield n)}function ye(e,t,n){let r=typeof t==`symbol`?t:Symbol.for(t);return e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!1,writable:!1,value:n()}),e[r]}function be(...e){let t=100;return e.length===2?t=l(e[0],e[1]):e.length===1&&(t=e[0]),new Promise(e=>{setTimeout(()=>{e(`LIKEC4_DELAY`)},t??100)})}function xe(){return Promise.resolve().then(()=>void 0)}function Se(e){Promise.resolve().then(e)}const Ce=(e,t)=>{let n=H(e.source.id,e.target.id),r=H(t.source.id,t.target.id);if(n&&!r)return 1;if(!n&&r)return-1;let i=n&&r?W(n,r):0;if(i!==0)return i;let a=W(e.source.id,t.source.id);return a===0?W(e.target.id,t.target.id):a};function we(...e){let t=new Set;for(let n of e)for(let e of n)t.add(e);return t}function Te(e,...t){let n=new Set;if(e.size===0)return n;let r=i(t,2)?(0,p.intersection)(...t):t[0];if(r.size===0)return n;for(let t of e)r.has(t)&&n.add(t);return n}function Ee(e,t){if(e.size===0)return new Set;if(t.size===0)return new Set(e);let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function De(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function $(e,t){return(0,p.symmetricDifference)(e,t)}function Oe(e,t){if(e.size===0||t.size===0)return!1;t.size<e.size&&([e,t]=[t,e]);for(let n of e)if(t.has(n))return!0;return!1}function ke(e){return S(typeof e==`object`&&r(e),`objectHash: value must be an object`),h(e)}function Ae(e){let t=5381,n=e.length;S(n>0,`stringHash: empty string`);for(let r=0;r<n;r++)t=t*33^e.charCodeAt(r);return(t>>>0).toString(36)}function je(){return ie().use(ne).use(ee).use(te).use(re,{allowDangerousHtml:!0}).use(_,t({attributes:{"*":[`className`],svg:[`width`,`height`,`viewBox`,`fill`,`ariaHidden`],path:[`d`,`fill`,`stroke`,`strokeWidth`,`strokeLinecap`,`strokeLinejoin`]},tagNames:[`svg`,`g`,`path`,`div`]},g)).use(v,{allowDangerousHtml:!0})}function Me(e){return(``+je().processSync(e)).trim()}function Ne(e){return y(b(e),{includeHtml:!1,includeImageAlt:!1})}export{x as $,U as A,P as B,de as C,se as D,ce as E,B as F,N as G,Y as H,L as I,E as J,j as K,z as L,G as M,W as N,oe as O,V as P,S as Q,R,fe as S,le as T,J as U,K as V,M as W,O as X,k as Y,w as Z,ge as _,Ee as a,me as b,Te as c,Ce as d,C as et,be as f,ve as g,ye as h,ke as i,H as j,ae as k,$ as l,xe as m,Me as n,De as o,Se as p,A as q,Ae as r,Oe as s,Ne as t,we as u,_e as v,ue as w,pe as x,he as y,F as z};
|
package/dist/builder/index.d.mts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import "../_chunks/
|
|
2
|
-
import "../_chunks/scalar.mjs";
|
|
3
|
-
import "../_chunks/expression.mjs";
|
|
4
|
-
import "../_chunks/fqnRef.mjs";
|
|
5
|
-
import "../_chunks/expression-model.mjs";
|
|
1
|
+
import "../_chunks/index.mjs";
|
|
6
2
|
import "../_chunks/index2.mjs";
|
|
7
|
-
import "../_chunks/RichText.mjs";
|
|
8
3
|
import "../_chunks/index3.mjs";
|
|
4
|
+
import "../_chunks/libs/mnemonist.mjs";
|
|
5
|
+
import "../_chunks/mnemonist.mjs";
|
|
9
6
|
import "../_chunks/LikeC4Model.mjs";
|
|
10
7
|
import { $ as DeloymentModelHelpers, A as AddDeploymentViewHelper, B as ViewPredicate, C as AddViewHelper, D as ElementViewRulesBuilder, E as ElementViewBuilder, F as $exclude, G as NestedRelationshipHelper, H as ModelBuilder, I as $include, J as AddElement, K as RelationshipHelper, L as $rules, M as DeploymentRulesBuilderOp, N as DeploymentViewBuilder, O as TypedAddViewOfHelper, P as $autoLayout, Q as DeloymentModelBuildFunction, R as $style, S as $expr, T as AddViewRules, U as ModelBuilderFunction, V as AddElementHelpers, W as ModelHelpers, X as AddDeploymentNodeHelpers, Y as AddDeployedInstance, Z as AddDeploymentRelation, _ as ViewsBuilder, a as Invalid, b as mkViewBuilder, c as NewElementProps, d as Types, et as DeploymentModelBuilder, f as TypesNested, g as BuilderMethods, h as Builder, i as BuilderSpecification, j as AddDeploymentViewRules, k as $deploymentExpr, l as NewRelationProps, m as Warn, n as AnyTypesNested, nt as AddDeploymentNode, o as Metadata, p as ValidId, q as model, r as BuilderProjectSpecification, s as NewDeploymentNodeProps, t as AnyTypes, tt as deployment, u as NewViewProps, v as ViewsBuilderFunction, w as AddViewOfHelper, x as views, y as ViewsHelpers, z as LikeC4ViewBuilder } from "../_chunks/_types.mjs";
|
|
11
8
|
export { $autoLayout, $deploymentExpr, $exclude, $expr, $include, $rules, $style, AddDeployedInstance, AddDeploymentNode, AddDeploymentNodeHelpers, AddDeploymentRelation, AddDeploymentViewHelper, AddDeploymentViewRules, AddElement, AddElementHelpers, AddViewHelper, AddViewOfHelper, AddViewRules, AnyTypes, AnyTypesNested, Builder, BuilderMethods, BuilderProjectSpecification, BuilderSpecification, DeloymentModelBuildFunction, DeloymentModelHelpers, DeploymentModelBuilder, DeploymentRulesBuilderOp, DeploymentViewBuilder, ElementViewBuilder, ElementViewRulesBuilder, Invalid, LikeC4ViewBuilder, Metadata, ModelBuilder, ModelBuilderFunction, ModelHelpers, NestedRelationshipHelper, NewDeploymentNodeProps, NewElementProps, NewRelationProps, NewViewProps, RelationshipHelper, TypedAddViewOfHelper, Types, TypesNested, ValidId, ViewPredicate, ViewsBuilder, ViewsBuilderFunction, ViewsHelpers, Warn, deployment, mkViewBuilder, model, views };
|