likec4 1.4.0 → 1.5.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,17 +1,20 @@
1
1
  import { LikeC4Browser, type LikeC4ViewBaseProps, LikeC4ViewElement } from 'likec4/react'
2
- import { useCallback, useState } from 'react'
2
+ import { memo, useCallback, useState } from 'react'
3
3
  import { isLikeC4ViewId, type LikeC4ViewId, LikeC4Views } from 'virtual:likec4/views'
4
4
 
5
5
  export { isLikeC4ViewId }
6
+
6
7
  export type LikeC4ViewProps = LikeC4ViewBaseProps<LikeC4ViewId>
7
8
 
8
- export function LikeC4View({
9
+ export const LikeC4View = memo<LikeC4ViewProps>(function LikeC4ViewComponent({
9
10
  viewId,
10
11
  interactive = true,
11
12
  colorScheme,
12
13
  injectFontCss = true,
14
+ background = 'transparent',
15
+ browserBackground = 'dots',
13
16
  ...props
14
- }: LikeC4ViewProps) {
17
+ }) {
15
18
  const view = LikeC4Views[viewId]
16
19
 
17
20
  const [browserViewId, onNavigateTo] = useState(null as LikeC4ViewId | null)
@@ -37,6 +40,7 @@ export function LikeC4View({
37
40
  colorScheme={colorScheme}
38
41
  injectFontCss={injectFontCss}
39
42
  onNavigateTo={interactive ? onNavigateTo : undefined}
43
+ background={background}
40
44
  {...props}
41
45
  />
42
46
  {browserView && (
@@ -45,10 +49,10 @@ export function LikeC4View({
45
49
  injectFontCss={false}
46
50
  colorScheme={colorScheme}
47
51
  onNavigateTo={onNavigateTo}
48
- background="dots"
52
+ background={browserBackground}
49
53
  onClose={closeBrowser}
50
54
  />
51
55
  )}
52
56
  </>
53
57
  )
54
- }
58
+ })
@@ -0,0 +1,9 @@
1
+ import { d2Source } from "virtual:likec4/d2-sources";
2
+ import { dotSource, svgSource } from "virtual:likec4/dot-sources";
3
+ import { mmdSource } from "virtual:likec4/mmd-sources";
4
+ export {
5
+ d2Source,
6
+ dotSource,
7
+ mmdSource,
8
+ svgSource
9
+ };
@@ -263,12 +263,7 @@ async function embed(cssText, resourceURL, baseURL, options, getContentFromUrl)
263
263
  try {
264
264
  const resolvedURL = baseURL ? resolveUrl(resourceURL, baseURL) : resourceURL, contentType = getMimeType(resourceURL);
265
265
  let dataURL;
266
- if (getContentFromUrl) {
267
- const content = await getContentFromUrl(resolvedURL);
268
- dataURL = makeDataUrl(content, contentType);
269
- } else
270
- dataURL = await resourceToDataURL(resolvedURL, contentType, options);
271
- return cssText.replace(toRegex(resourceURL), `$1${dataURL}$3`);
266
+ return getContentFromUrl || (dataURL = await resourceToDataURL(resolvedURL, contentType, options)), cssText.replace(toRegex(resourceURL), `$1${dataURL}$3`);
272
267
  } catch {
273
268
  }
274
269
  return cssText;