Skip to content

Commit

Permalink
Fixed re exports (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugos68 authored Jan 2, 2025
1 parent 6b3adc0 commit a367fa4
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-beers-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skeletonlabs/floating-ui-svelte": patch
---

Restructure `@floating-ui/dom` re-exports.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { createPubSub } from "../internal/create-pub-sub.js";
import { getDPR, roundByDPR } from "../internal/dpr.js";
import { noop } from "../internal/noop.js";
import { styleObjectToString } from "../internal/style-object-to-string.js";
import type { OpenChangeReason } from "../internal/types.js";
import type { OpenChangeReason } from "../types.js";
import { useId } from "./use-id.js";

interface FloatingElements {
Expand Down
2 changes: 1 addition & 1 deletion packages/floating-ui-svelte/src/hooks/use-focus.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "../internal/dom.js";
import { isMac, isSafari } from "../internal/environment.js";
import { isTypeableElement } from "../internal/is-typable-element.js";
import type { OpenChangeReason } from "../internal/types.js";
import type { OpenChangeReason } from "../types.js";
import type { FloatingContext } from "./use-floating.svelte.js";

interface UseFocusOptions {
Expand Down
33 changes: 32 additions & 1 deletion packages/floating-ui-svelte/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
export * from "@floating-ui/dom";
/**
* Components
*/
export * from "./components/floating-arrow.svelte";
export { default as FloatingArrow } from "./components/floating-arrow.svelte";

/**
* Hooks
*/
export * from "./hooks/use-click.svelte.js";
export * from "./hooks/use-dismiss.svelte.js";
export * from "./hooks/use-floating.svelte.js";
Expand All @@ -9,3 +15,28 @@ export * from "./hooks/use-hover.svelte.js";
export * from "./hooks/use-id.js";
export * from "./hooks/use-interactions.svelte.js";
export * from "./hooks/use-role.svelte.js";

/**
* Types
*/
export * from "./types.js";

/**
* Re-exports
*/
export {
autoPlacement,
autoUpdate,
arrow,
computePosition,
detectOverflow,
flip,
getOverflowAncestors,
hide,
inline,
limitShift,
offset,
platform,
shift,
size,
} from "@floating-ui/dom";
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
<script lang="ts">
import { page } from "$app/state";
<script lang="ts" module>
import MoonlightDark from "$lib/themes/moonlight-dark.json";
import type { BuiltinLanguage, SpecialLanguage } from "shiki";
import type {
BuiltinLanguage,
SpecialLanguage,
ThemeRegistration,
} from "shiki";
import { createHighlighterCoreSync } from "shiki/core";
import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
import bash from "shiki/langs/bash.mjs";
import css from "shiki/langs/css.mjs";
import html from "shiki/langs/html.mjs";
import svelte from "shiki/langs/svelte.mjs";
import ts from "shiki/langs/ts.mjs";
const highlighter = createHighlighterCoreSync({
engine: createJavaScriptRegexEngine(),
langs: [svelte, html, css, ts, bash],
themes: [MoonlightDark as ThemeRegistration],
});
</script>

<script lang="ts">
interface Props {
code: string;
lang: BuiltinLanguage | SpecialLanguage;
mark?: Array<number | [number, number]>;
}
// Props
let { code, lang = "text", mark = [] }: Props = $props();
const highlightedLineNumbers = $derived(
Expand All @@ -22,16 +39,10 @@ const highlightedLineNumbers = $derived(
}),
);
// Process Language
const renderedCode = $derived(
page.data.highlighter.codeToHtml(code.trim(), {
highlighter.codeToHtml(code.trim(), {
lang,
themes: {
// @ts-expect-error - Shiki theme type is annoyingly strict
dark: MoonlightDark,
// @ts-expect-error - Shiki theme type is annoyingly strict
light: MoonlightDark,
},
theme: MoonlightDark as ThemeRegistration,
transformers: [
/**
* This transformer adds the `highlighted` class to lines that are to be highlighted.
Expand Down
13 changes: 0 additions & 13 deletions sites/floating-ui-svelte.vercel.app/src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
import { browser } from "$app/environment";
import MoonlightDark from "$lib/themes/moonlight-dark.json";
import { getHighlighter } from "shiki";
import type { Pagefind } from "vite-plugin-pagefind/types";

export async function load() {
const highlighter = await getHighlighter({
langs: ["svelte", "html", "css", "javascript", "typescript", "bash"],
// @ts-expect-error - Shiki theme type is annoyingly strict
themes: [MoonlightDark],
});

if (browser) {
// @ts-expect-error - Dynamic import
const pagefind: Pagefind = await import("/pagefind/pagefind.js");
await pagefind.init();
return {
highlighter,
pagefind,
};
}

return {
highlighter,
};
}

export const prerender = true;

0 comments on commit a367fa4

Please sign in to comment.