Skip to content

Commit a367fa4

Browse files
authored
Fixed re exports (#150)
1 parent 6b3adc0 commit a367fa4

File tree

7 files changed

+62
-28
lines changed

7 files changed

+62
-28
lines changed

.changeset/nine-beers-collect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@skeletonlabs/floating-ui-svelte": patch
3+
---
4+
5+
Restructure `@floating-ui/dom` re-exports.

packages/floating-ui-svelte/src/hooks/use-floating.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { createPubSub } from "../internal/create-pub-sub.js";
1212
import { getDPR, roundByDPR } from "../internal/dpr.js";
1313
import { noop } from "../internal/noop.js";
1414
import { styleObjectToString } from "../internal/style-object-to-string.js";
15-
import type { OpenChangeReason } from "../internal/types.js";
15+
import type { OpenChangeReason } from "../types.js";
1616
import { useId } from "./use-id.js";
1717

1818
interface FloatingElements {

packages/floating-ui-svelte/src/hooks/use-focus.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "../internal/dom.js";
1010
import { isMac, isSafari } from "../internal/environment.js";
1111
import { isTypeableElement } from "../internal/is-typable-element.js";
12-
import type { OpenChangeReason } from "../internal/types.js";
12+
import type { OpenChangeReason } from "../types.js";
1313
import type { FloatingContext } from "./use-floating.svelte.js";
1414

1515
interface UseFocusOptions {
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
export * from "@floating-ui/dom";
1+
/**
2+
* Components
3+
*/
24
export * from "./components/floating-arrow.svelte";
35
export { default as FloatingArrow } from "./components/floating-arrow.svelte";
6+
7+
/**
8+
* Hooks
9+
*/
410
export * from "./hooks/use-click.svelte.js";
511
export * from "./hooks/use-dismiss.svelte.js";
612
export * from "./hooks/use-floating.svelte.js";
@@ -9,3 +15,28 @@ export * from "./hooks/use-hover.svelte.js";
915
export * from "./hooks/use-id.js";
1016
export * from "./hooks/use-interactions.svelte.js";
1117
export * from "./hooks/use-role.svelte.js";
18+
19+
/**
20+
* Types
21+
*/
22+
export * from "./types.js";
23+
24+
/**
25+
* Re-exports
26+
*/
27+
export {
28+
autoPlacement,
29+
autoUpdate,
30+
arrow,
31+
computePosition,
32+
detectOverflow,
33+
flip,
34+
getOverflowAncestors,
35+
hide,
36+
inline,
37+
limitShift,
38+
offset,
39+
platform,
40+
shift,
41+
size,
42+
} from "@floating-ui/dom";

sites/floating-ui-svelte.vercel.app/src/lib/components/CodeBlock/CodeBlock.svelte

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1-
<script lang="ts">
2-
import { page } from "$app/state";
1+
<script lang="ts" module>
32
import MoonlightDark from "$lib/themes/moonlight-dark.json";
4-
import type { BuiltinLanguage, SpecialLanguage } from "shiki";
3+
import type {
4+
BuiltinLanguage,
5+
SpecialLanguage,
6+
ThemeRegistration,
7+
} from "shiki";
8+
import { createHighlighterCoreSync } from "shiki/core";
9+
import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
10+
import bash from "shiki/langs/bash.mjs";
11+
import css from "shiki/langs/css.mjs";
12+
import html from "shiki/langs/html.mjs";
13+
import svelte from "shiki/langs/svelte.mjs";
14+
import ts from "shiki/langs/ts.mjs";
15+
16+
const highlighter = createHighlighterCoreSync({
17+
engine: createJavaScriptRegexEngine(),
18+
langs: [svelte, html, css, ts, bash],
19+
themes: [MoonlightDark as ThemeRegistration],
20+
});
21+
</script>
522

23+
<script lang="ts">
624
interface Props {
725
code: string;
826
lang: BuiltinLanguage | SpecialLanguage;
927
mark?: Array<number | [number, number]>;
1028
}
1129
12-
// Props
1330
let { code, lang = "text", mark = [] }: Props = $props();
1431
1532
const highlightedLineNumbers = $derived(
@@ -22,16 +39,10 @@ const highlightedLineNumbers = $derived(
2239
}),
2340
);
2441
25-
// Process Language
2642
const renderedCode = $derived(
27-
page.data.highlighter.codeToHtml(code.trim(), {
43+
highlighter.codeToHtml(code.trim(), {
2844
lang,
29-
themes: {
30-
// @ts-expect-error - Shiki theme type is annoyingly strict
31-
dark: MoonlightDark,
32-
// @ts-expect-error - Shiki theme type is annoyingly strict
33-
light: MoonlightDark,
34-
},
45+
theme: MoonlightDark as ThemeRegistration,
3546
transformers: [
3647
/**
3748
* This transformer adds the `highlighted` class to lines that are to be highlighted.
Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
import { browser } from "$app/environment";
2-
import MoonlightDark from "$lib/themes/moonlight-dark.json";
3-
import { getHighlighter } from "shiki";
42
import type { Pagefind } from "vite-plugin-pagefind/types";
53

64
export async function load() {
7-
const highlighter = await getHighlighter({
8-
langs: ["svelte", "html", "css", "javascript", "typescript", "bash"],
9-
// @ts-expect-error - Shiki theme type is annoyingly strict
10-
themes: [MoonlightDark],
11-
});
12-
135
if (browser) {
146
// @ts-expect-error - Dynamic import
157
const pagefind: Pagefind = await import("/pagefind/pagefind.js");
168
await pagefind.init();
179
return {
18-
highlighter,
1910
pagefind,
2011
};
2112
}
22-
23-
return {
24-
highlighter,
25-
};
2613
}
2714

2815
export const prerender = true;

0 commit comments

Comments
 (0)