likec4 1.29.0 → 1.30.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/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # LikeC4
2
2
 
3
- ![NPM Version](https://img.shields.io/npm/v/likec4)
3
+ <a href="https://www.npmjs.com/package/likec4" target="_blank">![NPM Version](https://img.shields.io/npm/v/likec4)</a>
4
+ <a href="https://www.npmjs.com/package/likec4" target="_blank">![NPM Downloads](https://img.shields.io/npm/dw/likec4)</a>
4
5
 
5
6
  `likec4` package is a composition of language services, react components, vite plugin and CLI.
6
7
 
@@ -828,6 +828,11 @@ function useDebouncedValue(value, wait, options = { leading: !1 }) {
828
828
  }, [value, options.leading, wait]), useEffect(() => (mountedRef.current = !0, cancel), []), [_value, cancel];
829
829
  }
830
830
  const useIsomorphicEffect = typeof document < "u" ? useLayoutEffect$1 : useEffect;
831
+ function useDocumentTitle(title2) {
832
+ useIsomorphicEffect(() => {
833
+ typeof title2 == "string" && title2.trim().length > 0 && (document.title = title2.trim());
834
+ }, [title2]);
835
+ }
831
836
  function useDidUpdate(fn, dependencies) {
832
837
  const mounted = useRef(!1);
833
838
  useEffect(
@@ -16523,9 +16528,11 @@ var memo$1 = (fn) => {
16523
16528
  const result = fn(...args);
16524
16529
  return cache.set(key2, result), result;
16525
16530
  };
16526
- };
16531
+ }, MERGE_OMIT = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
16527
16532
  function mergeProps(...sources) {
16528
16533
  return sources.reduce((prev, obj) => (obj && Object.keys(obj).forEach((key2) => {
16534
+ if (MERGE_OMIT.has(key2))
16535
+ return;
16529
16536
  const prevValue = prev[key2], value = obj[key2];
16530
16537
  isObject(prevValue) && isObject(value) ? prev[key2] = mergeProps(prevValue, value) : prev[key2] = value;
16531
16538
  }), prev), {});
@@ -16855,7 +16862,7 @@ const asTheme = (v) => {
16855
16862
  component: RouteComponent$3
16856
16863
  });
16857
16864
  function RouteComponent$3() {
16858
- return /* @__PURE__ */ jsx(Container, { size: "xs", py: "lg", children: /* @__PURE__ */ jsxs(Stack, { children: [
16865
+ return useDocumentTitle("LikeC4 Projects"), /* @__PURE__ */ jsx(Container, { size: "xs", py: "lg", children: /* @__PURE__ */ jsxs(Stack, { children: [
16859
16866
  /* @__PURE__ */ jsx(Text, { fz: "lg", children: "Select a project" }),
16860
16867
  projects.map((v) => /* @__PURE__ */ jsx(
16861
16868
  Button,
@@ -16932,29 +16939,22 @@ function PopChild({ children: children2, isPresent, anchorX }) {
16932
16939
  }, [isPresent]), jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size2, children: React.cloneElement(children2, { ref }) });
16933
16940
  }
16934
16941
  const PresenceChild = ({ children: children2, initial, isPresent, onExitComplete, custom: custom5, presenceAffectsLayout, mode, anchorX }) => {
16935
- const presenceChildren = useConstant(newChildrenMap), id2 = useId$2(), memoizedOnExitComplete = useCallback((childId) => {
16936
- presenceChildren.set(childId, !0);
16937
- for (const isComplete of presenceChildren.values())
16938
- if (!isComplete)
16939
- return;
16940
- onExitComplete && onExitComplete();
16941
- }, [presenceChildren, onExitComplete]), context2 = useMemo(
16942
- () => ({
16943
- id: id2,
16944
- initial,
16945
- isPresent,
16946
- custom: custom5,
16947
- onExitComplete: memoizedOnExitComplete,
16948
- register: (childId) => (presenceChildren.set(childId, !1), () => presenceChildren.delete(childId))
16949
- }),
16950
- /**
16951
- * If the presence of a child affects the layout of the components around it,
16952
- * we want to make a new context value to ensure they get re-rendered
16953
- * so they can detect that layout change.
16954
- */
16955
- presenceAffectsLayout ? [Math.random(), memoizedOnExitComplete] : [isPresent, memoizedOnExitComplete]
16956
- );
16957
- return useMemo(() => {
16942
+ const presenceChildren = useConstant(newChildrenMap), id2 = useId$2();
16943
+ let isReusedContext = !0, context2 = useMemo(() => (isReusedContext = !1, {
16944
+ id: id2,
16945
+ initial,
16946
+ isPresent,
16947
+ custom: custom5,
16948
+ onExitComplete: (childId) => {
16949
+ presenceChildren.set(childId, !0);
16950
+ for (const isComplete of presenceChildren.values())
16951
+ if (!isComplete)
16952
+ return;
16953
+ onExitComplete && onExitComplete();
16954
+ },
16955
+ register: (childId) => (presenceChildren.set(childId, !1), () => presenceChildren.delete(childId))
16956
+ }), [isPresent, presenceChildren, onExitComplete]);
16957
+ return presenceAffectsLayout && isReusedContext && (context2 = { ...context2 }), useMemo(() => {
16958
16958
  presenceChildren.forEach((_, key2) => presenceChildren.set(key2, !1));
16959
16959
  }, [isPresent]), React.useEffect(() => {
16960
16960
  !isPresent && !presenceChildren.size && onExitComplete && onExitComplete();
@@ -17935,7 +17935,7 @@ class MotionValue {
17935
17935
  * - `transformer`: A function to transform incoming values with.
17936
17936
  */
17937
17937
  constructor(init2, options = {}) {
17938
- this.version = "12.7.3", this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (v, render = !0) => {
17938
+ this.version = "12.7.4", this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (v, render = !0) => {
17939
17939
  const currentTime = time.now();
17940
17940
  this.updatedAt !== currentTime && this.setPrevFrameValue(), this.prev = this.current, this.setCurrent(v), this.current !== this.prev && this.events.change && this.events.change.notify(this.current), render && this.events.renderRequest && this.events.renderRequest.notify(this.current);
17941
17941
  }, this.hasAnimated = !1, this.setCurrent(init2), this.owner = options.owner;
@@ -44626,9 +44626,15 @@ const root$1 = css({
44626
44626
  fontSize: "sm",
44627
44627
  // mantine.fontSizes.sm,
44628
44628
  fontWeight: 500,
44629
- paddingRight: "50px",
44629
+ paddingRight: "10px",
44630
44630
  color: "mantine.colors.placeholder",
44631
- flex: "1"
44631
+ flex: "1",
44632
+ sm: {
44633
+ paddingRight: "30px"
44634
+ },
44635
+ md: {
44636
+ paddingRight: "50px"
44637
+ }
44632
44638
  }), shortcut = css({
44633
44639
  fontSize: "11px",
44634
44640
  fontWeight: 600,
@@ -49260,6 +49266,7 @@ const previewBg = css({
49260
49266
  component: RouteComponent$1
49261
49267
  });
49262
49268
  function RouteComponent$1() {
49269
+ useDocumentTitle("LikeC4");
49263
49270
  const views = t$4(useLikeC4Model$1(!0).$model.views);
49264
49271
  return /* @__PURE__ */ jsx(
49265
49272
  SimpleGrid,
@@ -49913,7 +49920,15 @@ function Header({ diagram }) {
49913
49920
  /* @__PURE__ */ jsxs(Group, { gap: isTablet ? 6 : 4, wrap: "nowrap", children: [
49914
49921
  isReactDiagramRoute ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
49915
49922
  /* @__PURE__ */ jsx(SelectProject, {}),
49916
- /* @__PURE__ */ jsx(Button, { size: isTablet ? "sm" : "xs", leftSection: /* @__PURE__ */ jsx(IconShare, { size: 14 }), onClick: open, children: "Share" }),
49923
+ projects.length <= 1 && /* @__PURE__ */ jsx(
49924
+ Button,
49925
+ {
49926
+ size: isTablet ? "sm" : "xs",
49927
+ leftSection: /* @__PURE__ */ jsx(IconShare, { size: 14 }),
49928
+ onClick: open,
49929
+ children: "Share"
49930
+ }
49931
+ ),
49917
49932
  /* @__PURE__ */ jsx(ExportButton, { diagram })
49918
49933
  ] }) : /* @__PURE__ */ jsx(
49919
49934
  Button,
@@ -50475,7 +50490,7 @@ function ExportPage() {
50475
50490
  500
50476
50491
  ), !diagram)
50477
50492
  throw notFound();
50478
- const width = diagram.bounds.width + padding * 2, height = diagram.bounds.height + padding * 2;
50493
+ const extraPadding = 16, width = diagram.bounds.width + padding * 2 + extraPadding, height = diagram.bounds.height + padding * 2 + extraPadding;
50479
50494
  return /* @__PURE__ */ jsxs(
50480
50495
  Box,
50481
50496
  {
@@ -50558,18 +50573,21 @@ const Route$a = createFileRoute("/_single/embed/$viewId")({
50558
50573
  component: EmbedPage
50559
50574
  });
50560
50575
  function ViewReact() {
50561
- const router = useRouter(), view = useCurrentDiagram(), onNavigateTo = useCallbackRef((viewId) => {
50576
+ const viewId = useParams({
50577
+ select: (params) => params.viewId ?? "index",
50578
+ strict: !1
50579
+ }), router = useRouter(), view = useCurrentDiagram(), onNavigateTo = useCallbackRef((viewId2) => {
50562
50580
  const loc = router.buildLocation({
50563
50581
  to: ".",
50564
50582
  params: (current) => ({
50565
50583
  ...current,
50566
- viewId
50584
+ viewId: viewId2
50567
50585
  }),
50568
50586
  search: !0
50569
50587
  });
50570
50588
  router.commitLocation(loc);
50571
- });
50572
- if (!view)
50589
+ }), title2 = view ? view.title ?? view.id : `${viewId} not found`;
50590
+ if (useDocumentTitle(title2 + " - LikeC4"), !view)
50573
50591
  return /* @__PURE__ */ jsx(NotFound, {});
50574
50592
  const hasNotations = (view.notation?.elements ?? []).length > 0;
50575
50593
  return /* @__PURE__ */ jsx(