@publish.os/nextjs 0.0.1-alpha.90 → 0.0.1-alpha.91
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/compiler-assets/nextjs/defaults/group/layout.tsx +1 -5
- package/compiler-assets/nextjs/defaults/group/page.tsx +31 -22
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +19 -10
- package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +10 -0
- package/compiler-assets/nextjs/defaults/root/css/components/code-block.css +18 -0
- package/compiler-assets/nextjs/shims/document.tsx +38 -0
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +2 -0
- package/compiler-assets/nextjs/shims/global-layout.tsx +8 -42
- package/compiler-assets/nextjs/shims/global-not-found.tsx +69 -0
- package/compiler-assets/nextjs/shims/markdown-route.ts +2 -0
- package/compiler-assets/nextjs/shims/metadata-icons.tsx +39 -0
- package/compiler-assets/nextjs/shims/not-found-content.tsx +53 -0
- package/compiler-assets/nextjs/shims/not-found-navigation.tsx +60 -0
- package/compiler-assets/nextjs/shims/proxy.ts +126 -60
- package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +2 -6
- package/compiler-assets/nextjs/shims/site-mdx-components.tsx +28 -16
- package/compiler-assets/nextjs/shims/site-mdx.tsx +6 -1
- package/dist/{build-operation-2JAYBSKF.js → build-operation-5QMLXF7N.js} +29 -23
- package/dist/{button-c3WGnxIj.d.ts → button-BdCScEKi.d.ts} +3 -3
- package/dist/capture-local-source-WGGDIUU2.js +258 -0
- package/dist/chunk-22RSSUNV.js +13 -0
- package/dist/{chunk-WKTEO6RS.js → chunk-4BC2L2KA.js} +46 -12
- package/dist/{chunk-WDY4IK6Z.js → chunk-5J3YUNRY.js} +3 -10
- package/dist/chunk-5KAD7W53.js +248 -0
- package/dist/{chunk-DWA3ZRGW.js → chunk-6C65KV7O.js} +2 -2
- package/dist/{chunk-GGKFQ3MA.js → chunk-6D2E6UMD.js} +144 -70
- package/dist/{chunk-7OGTPSKI.js → chunk-7NY22B5U.js} +8 -3
- package/dist/chunk-EFO6AWXN.js +19 -0
- package/dist/{chunk-726GV2NF.js → chunk-F3AGNDF4.js} +100 -67
- package/dist/chunk-GBPLER5H.js +426 -0
- package/dist/chunk-IL4RJOKI.js +186 -0
- package/dist/{chunk-DLDFHU7Y.js → chunk-NNBJZPFM.js} +4 -2
- package/dist/{chunk-VO2I7MTM.js → chunk-ORIUWJBQ.js} +8 -6
- package/dist/{chunk-H6XILMZX.js → chunk-OXOFRXEI.js} +1806 -831
- package/dist/chunk-UYGCOWRF.js +1709 -0
- package/dist/{chunk-YLTOLYWM.js → chunk-WL75GQ5M.js} +6 -18
- package/dist/compiler.d.ts +15 -2
- package/dist/compiler.js +90 -21
- package/dist/components/blocks/agent-actions.d.ts +81 -0
- package/dist/components/blocks/agent-actions.js +594 -0
- package/dist/components/blocks/toc.d.ts +43 -0
- package/dist/components/blocks/toc.js +136 -0
- package/dist/components/ui/button.d.ts +5 -0
- package/dist/components/ui/button.js +94 -0
- package/dist/compose-CVBJRAF6.js +16 -0
- package/dist/config/createNextConfig.js +17 -3
- package/dist/{dev-operation-TZDVJCN7.js → dev-operation-OSHHWRWK.js} +121 -81
- package/dist/{framework-selection-X4U6Y6QC.js → framework-selection-ZVO323PK.js} +3 -2
- package/dist/ide-support-CU6Z5PVR.js +16 -0
- package/dist/index.d.ts +40 -1
- package/dist/jsx-dev-runtime.d.ts +6 -0
- package/dist/jsx-dev-runtime.js +100 -0
- package/dist/jsx-runtime.d.ts +7 -0
- package/dist/jsx-runtime.js +97 -0
- package/dist/kernel/components/blocks/AgentActions.d.ts +35 -6
- package/dist/kernel/components/blocks/AgentActions.js +383 -142
- package/dist/kernel/components/blocks/agent-actions.d.ts +5 -0
- package/dist/kernel/components/blocks/agent-actions.js +594 -0
- package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
- package/dist/kernel/components/blocks/color-palette.js +4 -4
- package/dist/kernel/components/blocks/logo-block.js +1 -1
- package/dist/kernel/components/blocks/nav-breadcrumb.js +2 -2
- package/dist/kernel/components/blocks/navbar.js +17 -17
- package/dist/kernel/components/blocks/navigation-progress.js +2 -2
- package/dist/kernel/components/blocks/next-prev.js +1 -1
- package/dist/kernel/components/blocks/page-list.js +2 -2
- package/dist/kernel/components/blocks/search.d.ts +1 -1
- package/dist/kernel/components/blocks/search.js +16 -17
- package/dist/kernel/components/blocks/sidebar-node.js +1 -1
- package/dist/kernel/components/blocks/sidebar.js +7 -4
- package/dist/kernel/components/blocks/theme-toggle.d.ts +1 -1
- package/dist/kernel/components/blocks/theme-toggle.js +5 -5
- package/dist/kernel/components/blocks/toc-client.d.ts +40 -0
- package/dist/kernel/components/blocks/toc-client.js +495 -0
- package/dist/kernel/components/blocks/toc.d.ts +19 -1
- package/dist/kernel/components/blocks/toc.js +121 -179
- package/dist/kernel/components/mdx/components/blockquote.js +1 -1
- package/dist/kernel/components/mdx/components/callout.js +1 -1
- package/dist/kernel/components/mdx/components/code-block.js +2 -2
- package/dist/kernel/components/mdx/components/copy-code-button.js +5 -4
- package/dist/kernel/components/mdx/components/figure-caption.d.ts +1 -1
- package/dist/kernel/components/mdx/components/figure-caption.js +3 -2
- package/dist/kernel/components/mdx/components/figure.d.ts +6 -2
- package/dist/kernel/components/mdx/components/figure.js +23 -13
- package/dist/kernel/components/mdx/components/footnotes.js +1 -1
- package/dist/kernel/components/mdx/components/heading-copy-link.js +1 -1
- package/dist/kernel/components/mdx/components/heading.js +6 -3
- package/dist/kernel/components/mdx/components/hr.js +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.js +1 -1
- package/dist/kernel/components/mdx/components/image.d.ts +1 -1
- package/dist/kernel/components/mdx/components/image.js +21 -16
- package/dist/kernel/components/mdx/components/inline-code.js +1 -1
- package/dist/kernel/components/mdx/components/kbd.js +2 -2
- package/dist/kernel/components/mdx/components/link.d.ts +3 -3
- package/dist/kernel/components/mdx/components/link.js +2 -2
- package/dist/kernel/components/mdx/components/paragraph.js +1 -1
- package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
- package/dist/kernel/components/mdx/components/table.js +2 -2
- package/dist/kernel/components/mdx/components/task-list.js +1 -1
- package/dist/kernel/components/mdx/components/video-player.d.ts +6 -2
- package/dist/kernel/components/mdx/components/video-player.js +6 -2
- package/dist/kernel/components/mdx/components/video.d.ts +5 -3
- package/dist/kernel/components/mdx/components/video.js +7 -5
- package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
- package/dist/kernel/components/mdx/error-boundary.js +2 -2
- package/dist/kernel/components/mdx/error-fallback.js +1 -1
- package/dist/kernel/components/mdx/mdx.d.ts +20 -10
- package/dist/kernel/components/mdx/mdx.js +231 -34
- package/dist/kernel/components/mdx/rehype-heading-ids.d.ts +1 -0
- package/dist/kernel/components/mdx/rehype-heading-ids.js +5 -3
- package/dist/kernel/components/mdx/types.d.ts +1 -1
- package/dist/kernel/components/next-image.d.ts +12 -0
- package/dist/kernel/components/next-image.js +61 -0
- package/dist/kernel/components/ui/accordion.js +1 -1
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +2 -2
- package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
- package/dist/kernel/components/ui/breadcrumb.d.ts +1 -1
- package/dist/kernel/components/ui/breadcrumb.js +4 -4
- package/dist/kernel/components/ui/button-group.d.ts +1 -1
- package/dist/kernel/components/ui/button-group.js +3 -3
- package/dist/kernel/components/ui/button.d.ts +56 -4
- package/dist/kernel/components/ui/button.js +43 -39
- package/dist/kernel/components/ui/card.js +1 -1
- package/dist/kernel/components/ui/dialog.js +1 -1
- package/dist/kernel/components/ui/drawer.js +1 -1
- package/dist/kernel/components/ui/input.d.ts +2 -2
- package/dist/kernel/components/ui/input.js +1 -1
- package/dist/kernel/components/ui/kbd.d.ts +1 -1
- package/dist/kernel/components/ui/kbd.js +1 -1
- package/dist/kernel/components/ui/link.d.ts +8 -2
- package/dist/kernel/components/ui/link.js +2 -2
- package/dist/kernel/components/ui/menu.js +1 -1
- package/dist/kernel/components/ui/mod-key.js +2 -2
- package/dist/kernel/components/ui/navigation-menu.js +1 -1
- package/dist/kernel/components/ui/popover.js +1 -1
- package/dist/kernel/components/ui/progress.js +1 -1
- package/dist/kernel/components/ui/scroll-area.d.ts +8 -8
- package/dist/kernel/components/ui/scroll-area.js +1 -1
- package/dist/kernel/components/ui/select.js +1 -1
- package/dist/kernel/components/ui/separator.js +1 -1
- package/dist/kernel/components/ui/table.js +1 -1
- package/dist/kernel/components/ui/tabs.js +1 -1
- package/dist/kernel/components/ui/tag.js +1 -1
- package/dist/kernel/components/ui/text.d.ts +1 -1
- package/dist/kernel/components/ui/text.js +1 -1
- package/dist/kernel/components/ui/toast.js +1 -1
- package/dist/kernel/components/ui/tooltip.js +1 -1
- package/dist/kernel/defaults.registry.d.ts +2 -15
- package/dist/kernel/defaults.registry.js +2 -17
- package/dist/kernel/routes/agent/markdown.d.ts +3 -0
- package/dist/kernel/routes/agent/markdown.js +219 -48
- package/dist/kernel/routes/layouts/group.d.ts +1 -1
- package/dist/kernel/routes/layouts/group.js +5 -7
- package/dist/kernel/routes/metadata/feed.d.ts +1 -1
- package/dist/kernel/routes/metadata/feed.js +109 -83
- package/dist/kernel/routes/metadata/llms.d.ts +11 -3
- package/dist/kernel/routes/metadata/llms.js +154 -57
- package/dist/kernel/routes/metadata/og-image.js +1 -1
- package/dist/kernel/routes/metadata/robots.d.ts +1 -1
- package/dist/kernel/routes/metadata/sitemap.d.ts +22 -3
- package/dist/kernel/routes/metadata/sitemap.js +183 -43
- package/dist/kernel/routes/not-found.d.ts +34 -0
- package/dist/kernel/routes/not-found.js +213 -0
- package/dist/kernel/routes/pages/group.d.ts +2 -2
- package/dist/kernel/routes/pages/group.js +1 -1
- package/dist/kernel/routes/pages/leaf.d.ts +30 -3
- package/dist/kernel/routes/pages/leaf.js +5 -4
- package/dist/kernel/routes/pages/root.d.ts +2 -2
- package/dist/kernel/routes/pages/root.js +1 -1
- package/dist/keyboard-shortcuts.js +1 -1
- package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
- package/dist/search.js +7 -9
- package/dist/theme-scope.js +1 -1
- package/dist/{types-BzkZty3r.d.ts → types-J2w_puPF.d.ts} +1 -20
- package/dist/types-sM2g9nW0.d.ts +12 -0
- package/dist/types.d.ts +1 -0
- package/dist/utils/heading-ids.js +30 -11
- package/dist/utils/toc-selection.d.ts +7 -0
- package/dist/utils/toc-selection.js +14 -0
- package/dist/validate-local-source-SV44DBQT.js +16 -0
- package/dist/validate-publish-os-source-NZJF3TB2.js +14 -0
- package/init/seed/minimal/publish.os/assets/blog/hello-world.svg +13 -0
- package/init/seed/minimal/publish.os/assets/favicon.dark.svg +13 -0
- package/init/seed/minimal/publish.os/assets/favicon.svg +13 -0
- package/init/seed/minimal/publish.os/blog/content/hello-world.mdx +48 -0
- package/init/seed/minimal/publish.os/blog/content/series-a.mdx +11 -0
- package/init/seed/minimal/publish.os/blog/index.tsx +82 -0
- package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
- package/init/seed/minimal/publish.os/blog/page.tsx +76 -0
- package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -0
- package/init/seed/minimal/publish.os/docs/content/get-started.mdx +2 -3
- package/init/seed/minimal/publish.os/docs/content/groups.mdx +5 -6
- package/init/seed/minimal/publish.os/publish.os.config.json +6 -2
- package/init/seed/minimal/publish.os/theme.css +3 -3
- package/init/seed/minimal/seed.json +11 -4
- package/init/seed/scratch/publish.os/docs/content/get-started.mdx +1 -1
- package/init/seed/scratch/publish.os/publish.os.config.json +1 -1
- package/package.json +45 -20
- package/release/app/phosphor/package.json +3 -3
- package/release/app/phosphor/pnpm-lock.yaml.template +88 -75
- package/release/compiler/package.json +5 -3
- package/release/compiler/pnpm-lock.yaml.template +118 -74
- package/release/release.json +6 -6
- package/dist/button-CtzUJB8u.d.ts +0 -11
- package/dist/chunk-535TM4A5.js +0 -1455
- package/dist/chunk-B2V22WRT.js +0 -297
- package/dist/chunk-NECL5IBJ.js +0 -318
- package/dist/chunk-SVYGXXYR.js +0 -36
- package/dist/chunk-UF6ATARM.js +0 -1100
- package/dist/compose-NN23UJGC.js +0 -13
- package/dist/ide-support-ZNW7ODFY.js +0 -15
- package/dist/kernel/components/blocks/design-system-preview.d.ts +0 -61
- package/dist/kernel/components/blocks/design-system-preview.js +0 -667
- package/dist/kernel/components/blocks/link-playground.d.ts +0 -5
- package/dist/kernel/components/blocks/link-playground.js +0 -744
- package/dist/kernel/components/blocks/navigation-progress-playground.d.ts +0 -5
- package/dist/kernel/components/blocks/navigation-progress-playground.js +0 -629
- package/dist/kernel/components/ui/theme-toggle.d.ts +0 -24
- package/dist/kernel/components/ui/theme-toggle.js +0 -53
- package/dist/validate-local-source-XRL2Y7XE.js +0 -14
- package/dist/validate-publish-os-source-DAPZ4QGE.js +0 -12
- package/init/seed/minimal/publish.os/assets/favicon/favicon.dark.png +0 -0
- package/init/seed/minimal/publish.os/assets/favicon/favicon.png +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/components/mdx/inline-code.tsx
|
|
2
2
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
3
|
-
import { jsx } from "
|
|
3
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
4
4
|
function InlineCode({ className, ...props }) {
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
6
6
|
"code",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/components/mdx/kbd.tsx
|
|
2
|
-
import { Kbd as UiKbd } from "@
|
|
2
|
+
import { Kbd as UiKbd } from "@components/ui/kbd";
|
|
3
3
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
4
|
-
import { jsx } from "
|
|
4
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
5
5
|
function Kbd({ className, ...props }) {
|
|
6
6
|
return /* @__PURE__ */ jsx(UiKbd, { ...props, size: null, className: cn("text-[0.75em]", className) });
|
|
7
7
|
}
|
|
@@ -5,9 +5,9 @@ import { LinkProps as LinkProps$1 } from 'next/link';
|
|
|
5
5
|
import { ReactNode, AnchorHTMLAttributes } from 'react';
|
|
6
6
|
|
|
7
7
|
declare const buttonVariants: (props?: ({
|
|
8
|
-
variant?: "solid" | "soft" | "outline" | "ghost" | null | undefined;
|
|
9
|
-
size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
10
|
-
iconOnly?: boolean | null | undefined;
|
|
8
|
+
readonly variant?: "solid" | "soft" | "outline" | "ghost" | null | undefined;
|
|
9
|
+
readonly size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
10
|
+
readonly iconOnly?: boolean | null | undefined;
|
|
11
11
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
12
12
|
type ButtonVariantProps = VariantProps<typeof buttonVariants>;
|
|
13
13
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/components/mdx/link.tsx
|
|
2
2
|
import {
|
|
3
3
|
Link as UiLink
|
|
4
|
-
} from "@
|
|
5
|
-
import { jsx } from "
|
|
4
|
+
} from "@components/ui/link";
|
|
5
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
6
6
|
function Link({
|
|
7
7
|
color = "accent",
|
|
8
8
|
href = "#",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/components/mdx/paragraph.tsx
|
|
2
2
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
3
3
|
import { Children, isValidElement } from "react";
|
|
4
|
-
import { Fragment, jsx } from "
|
|
4
|
+
import { Fragment, jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
5
5
|
function isBlockMediaChild(child) {
|
|
6
6
|
if (!isValidElement(child)) return !1;
|
|
7
7
|
let props = child.props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/components/mdx/strikethrough.tsx
|
|
2
2
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
3
|
-
import { jsx } from "
|
|
3
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
4
4
|
function Strikethrough({ className, ...props }) {
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
6
6
|
"del",
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
TableHeader,
|
|
7
7
|
TableRow,
|
|
8
8
|
Table as UiTable
|
|
9
|
-
} from "@
|
|
10
|
-
import { jsx } from "
|
|
9
|
+
} from "@components/ui/table";
|
|
10
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
11
11
|
function Table(props) {
|
|
12
12
|
return /* @__PURE__ */ jsx(UiTable, { ...props });
|
|
13
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/components/mdx/task-list.tsx
|
|
2
2
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
3
|
-
import { jsx } from "
|
|
3
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
4
4
|
function TaskList({ className, ...props }) {
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
6
6
|
"ul",
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
3
|
|
|
3
4
|
type VideoEmbed = {
|
|
4
5
|
allow: string;
|
|
5
6
|
src: string;
|
|
6
7
|
title: string;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
/** Native playback options and media events applied after the Play button. */
|
|
10
|
+
type NativeVideoProps = Pick<ComponentPropsWithoutRef<"video">, "autoPlay" | "controls" | "controlsList" | "crossOrigin" | "disablePictureInPicture" | "disableRemotePlayback" | "loop" | "muted" | "playsInline" | "preload" | "onAbort" | "onCanPlay" | "onCanPlayThrough" | "onDurationChange" | "onEmptied" | "onEncrypted" | "onEnded" | "onError" | "onLoadedData" | "onLoadedMetadata" | "onLoadStart" | "onPause" | "onPlay" | "onPlaying" | "onProgress" | "onRateChange" | "onResize" | "onSeeked" | "onSeeking" | "onStalled" | "onSuspend" | "onTimeUpdate" | "onVolumeChange" | "onWaiting">;
|
|
11
|
+
declare function VideoPlayer({ className, embed, height, nativeProps, poster, src, title, width, }: {
|
|
9
12
|
className?: string;
|
|
10
13
|
embed?: VideoEmbed;
|
|
11
14
|
height?: number;
|
|
15
|
+
nativeProps?: NativeVideoProps;
|
|
12
16
|
poster?: string;
|
|
13
17
|
src: string;
|
|
14
18
|
title: string;
|
|
15
19
|
width?: number;
|
|
16
20
|
}): react_jsx_runtime.JSX.Element;
|
|
17
21
|
|
|
18
|
-
export { type VideoEmbed, VideoPlayer };
|
|
22
|
+
export { type NativeVideoProps, type VideoEmbed, VideoPlayer };
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
5
5
|
import { usePathname } from "next/navigation";
|
|
6
6
|
import { useCallback, useEffect, useId, useState } from "react";
|
|
7
|
-
import { jsx, jsxs } from "
|
|
7
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
8
8
|
var VIDEO_PLAY_EVENT = "publishos:video-play";
|
|
9
9
|
function VideoPlayer({
|
|
10
10
|
className,
|
|
11
11
|
embed,
|
|
12
12
|
height,
|
|
13
|
+
nativeProps,
|
|
13
14
|
poster,
|
|
14
15
|
src,
|
|
15
16
|
title,
|
|
@@ -65,10 +66,13 @@ function VideoPlayer({
|
|
|
65
66
|
),
|
|
66
67
|
controls: !0,
|
|
67
68
|
playsInline: !0,
|
|
68
|
-
poster,
|
|
69
69
|
preload: "metadata",
|
|
70
|
+
...nativeProps,
|
|
71
|
+
height,
|
|
72
|
+
poster,
|
|
70
73
|
src,
|
|
71
74
|
title,
|
|
75
|
+
width,
|
|
72
76
|
children: /* @__PURE__ */ jsx("track", { kind: "captions" })
|
|
73
77
|
},
|
|
74
78
|
src
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { NativeVideoProps } from './video-player.js';
|
|
3
|
+
import 'react';
|
|
2
4
|
|
|
3
|
-
type VideoProps =
|
|
5
|
+
type VideoProps = NativeVideoProps & {
|
|
4
6
|
caption?: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
5
8
|
frame?: boolean | "default" | "none";
|
|
6
9
|
height?: number | string;
|
|
7
10
|
poster?: string;
|
|
8
|
-
provider?: "self-hosted" | "youtube" | "vimeo" | "loom" | "wistia" | "cloudflare-stream";
|
|
9
11
|
src?: string;
|
|
10
12
|
title?: string;
|
|
11
13
|
width?: number | string;
|
|
12
14
|
};
|
|
13
|
-
declare function Video({ caption, className, frame, height, poster, src, title, width, }: VideoProps): react_jsx_runtime.JSX.Element | null;
|
|
15
|
+
declare function Video({ caption, className, frame, height, poster, src, title, width, ...nativeProps }: VideoProps): react_jsx_runtime.JSX.Element | null;
|
|
14
16
|
|
|
15
17
|
export { Video, type VideoProps };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/components/mdx/video/video.tsx
|
|
2
|
-
import { FigureCaption } from "@
|
|
2
|
+
import { FigureCaption } from "@components/mdx/components/figure-caption";
|
|
3
3
|
import {
|
|
4
4
|
VideoPlayer
|
|
5
|
-
} from "@
|
|
5
|
+
} from "@components/mdx/components/video-player";
|
|
6
6
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
7
|
-
import { jsx, jsxs } from "
|
|
7
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
8
8
|
function toNumber(value) {
|
|
9
9
|
if (typeof value == "number" && Number.isFinite(value)) return value;
|
|
10
10
|
if (typeof value == "string" && value.trim() !== "") {
|
|
@@ -76,7 +76,8 @@ function Video({
|
|
|
76
76
|
poster,
|
|
77
77
|
src,
|
|
78
78
|
title,
|
|
79
|
-
width
|
|
79
|
+
width,
|
|
80
|
+
...nativeProps
|
|
80
81
|
}) {
|
|
81
82
|
if (!src) return null;
|
|
82
83
|
let videoTitle = title?.trim() || "Video", numericWidth = toNumber(width), numericHeight = toNumber(height), framed = frame !== !1 && frame !== "none", embed = resolveEmbed(src, videoTitle), frameStyle = {
|
|
@@ -96,6 +97,7 @@ function Video({
|
|
|
96
97
|
{
|
|
97
98
|
embed,
|
|
98
99
|
height: numericHeight,
|
|
100
|
+
nativeProps,
|
|
99
101
|
poster,
|
|
100
102
|
src,
|
|
101
103
|
title: videoTitle,
|
|
@@ -106,7 +108,7 @@ function Video({
|
|
|
106
108
|
);
|
|
107
109
|
return caption ? /* @__PURE__ */ jsxs("figure", { className: "not-markdown-prose my-8", children: [
|
|
108
110
|
player,
|
|
109
|
-
/* @__PURE__ */ jsx(FigureCaption, {
|
|
111
|
+
/* @__PURE__ */ jsx(FigureCaption, { children: caption })
|
|
110
112
|
] }) : /* @__PURE__ */ jsx("div", { className: "not-markdown-prose my-6", children: player });
|
|
111
113
|
}
|
|
112
114
|
export {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/components/mdx/error-boundary.tsx
|
|
4
|
-
import { MDXErrorFallback } from "@
|
|
4
|
+
import { MDXErrorFallback } from "@components/mdx/error-fallback";
|
|
5
5
|
import { catchError } from "next/error";
|
|
6
|
-
import { jsx } from "
|
|
6
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
7
7
|
function MDXRenderErrorFallback(props, { error }) {
|
|
8
8
|
return /* @__PURE__ */ jsx(
|
|
9
9
|
MDXErrorFallback,
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { MDXComponents } from '
|
|
2
|
+
import { a as MDXComponents } from '../../../types-sM2g9nW0.js';
|
|
3
3
|
import { P as PageData } from '../../../types-CJWRG05y.js';
|
|
4
|
-
import { ReactNode, AnchorHTMLAttributes } from 'react';
|
|
4
|
+
import { ReactNode, AnchorHTMLAttributes, ComponentPropsWithoutRef } from 'react';
|
|
5
5
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
-
import { a as ButtonVariantProps } from '../../../button-
|
|
6
|
+
import { a as ButtonVariantProps } from '../../../button-BdCScEKi.js';
|
|
7
7
|
import { VariantProps } from 'class-variance-authority';
|
|
8
8
|
import { LinkProps as LinkProps$1 } from 'next/link';
|
|
9
9
|
import 'mdx/types.js';
|
|
10
10
|
|
|
11
|
-
type
|
|
11
|
+
type FigureCaptionProps = React.ComponentProps<"figcaption">;
|
|
12
|
+
declare function FigureCaption({ className, ...props }: FigureCaptionProps): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
type FigureProps = React.ComponentProps<"figure"> & {
|
|
15
|
+
/** A fallback caption after the children. An authored caption takes precedence. */
|
|
12
16
|
caption?: ReactNode;
|
|
13
|
-
frame?: boolean | "default" | "none";
|
|
14
17
|
};
|
|
15
18
|
declare function Figure({ caption, children, className, ...props }: FigureProps): react_jsx_runtime.JSX.Element;
|
|
19
|
+
declare namespace Figure {
|
|
20
|
+
var Caption: typeof FigureCaption;
|
|
21
|
+
}
|
|
16
22
|
|
|
17
23
|
type ImageProps = Omit<React.ComponentPropsWithoutRef<"img">, "height" | "sizes" | "width"> & {
|
|
18
24
|
aspect?: number | `${number}/${number}`;
|
|
@@ -30,7 +36,7 @@ type ImageProps = Omit<React.ComponentPropsWithoutRef<"img">, "height" | "sizes"
|
|
|
30
36
|
width?: number;
|
|
31
37
|
zoom?: boolean;
|
|
32
38
|
};
|
|
33
|
-
declare function Image({ alt, aspect, caption, className, decorative, fill, frame, height, intrinsicHeight, intrinsicWidth, optimized, priority, quality, sizes, src, width, zoom, ...props }: ImageProps): react_jsx_runtime.JSX.Element | null;
|
|
39
|
+
declare function Image({ alt, aspect, caption, className, decorative: authoredDecorative, fill: authoredFill, frame, height, intrinsicHeight, intrinsicWidth, optimized: authoredOptimized, priority: authoredPriority, quality, sizes, src, width, zoom: authoredZoom, ...props }: ImageProps): react_jsx_runtime.JSX.Element | null;
|
|
34
40
|
|
|
35
41
|
declare const linkVariants: (props?: ({
|
|
36
42
|
color?: "default" | "accent" | null | undefined;
|
|
@@ -59,24 +65,28 @@ type LinkProps = {
|
|
|
59
65
|
type MdxLinkProps = LinkProps;
|
|
60
66
|
declare function Link({ color, href, size, variant, ...props }: MdxLinkProps): react_jsx_runtime.JSX.Element;
|
|
61
67
|
|
|
62
|
-
|
|
68
|
+
/** Native playback options and media events applied after the Play button. */
|
|
69
|
+
type NativeVideoProps = Pick<ComponentPropsWithoutRef<"video">, "autoPlay" | "controls" | "controlsList" | "crossOrigin" | "disablePictureInPicture" | "disableRemotePlayback" | "loop" | "muted" | "playsInline" | "preload" | "onAbort" | "onCanPlay" | "onCanPlayThrough" | "onDurationChange" | "onEmptied" | "onEncrypted" | "onEnded" | "onError" | "onLoadedData" | "onLoadedMetadata" | "onLoadStart" | "onPause" | "onPlay" | "onPlaying" | "onProgress" | "onRateChange" | "onResize" | "onSeeked" | "onSeeking" | "onStalled" | "onSuspend" | "onTimeUpdate" | "onVolumeChange" | "onWaiting">;
|
|
70
|
+
|
|
71
|
+
type VideoProps = NativeVideoProps & {
|
|
63
72
|
caption?: React.ReactNode;
|
|
73
|
+
className?: string;
|
|
64
74
|
frame?: boolean | "default" | "none";
|
|
65
75
|
height?: number | string;
|
|
66
76
|
poster?: string;
|
|
67
|
-
provider?: "self-hosted" | "youtube" | "vimeo" | "loom" | "wistia" | "cloudflare-stream";
|
|
68
77
|
src?: string;
|
|
69
78
|
title?: string;
|
|
70
79
|
width?: number | string;
|
|
71
80
|
};
|
|
72
|
-
declare function Video({ caption, className, frame, height, poster, src, title, width, }: VideoProps): react_jsx_runtime.JSX.Element | null;
|
|
81
|
+
declare function Video({ caption, className, frame, height, poster, src, title, width, ...nativeProps }: VideoProps): react_jsx_runtime.JSX.Element | null;
|
|
73
82
|
|
|
74
83
|
type MDXProps = {
|
|
75
84
|
components?: MDXComponents;
|
|
76
85
|
page: PageData;
|
|
77
86
|
};
|
|
78
|
-
declare function renderMdx({ components, page, siteComponents, }: MDXProps & {
|
|
87
|
+
declare function renderMdx({ components, page, siteComponents, importedComponents, }: MDXProps & {
|
|
79
88
|
siteComponents?: MDXComponents;
|
|
89
|
+
importedComponents?: MDXComponents;
|
|
80
90
|
}): Promise<react_jsx_runtime.JSX.Element>;
|
|
81
91
|
declare function MDX(props: MDXProps): Promise<react_jsx_runtime.JSX.Element>;
|
|
82
92
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// src/components/mdx/mdx.tsx
|
|
2
|
-
import { Blockquote } from "@
|
|
3
|
-
import { Callout } from "@
|
|
4
|
-
import { CodeBlock } from "@
|
|
5
|
-
import { Figure } from "@
|
|
6
|
-
import { FigureCaption } from "@
|
|
7
|
-
import { Footnotes } from "@
|
|
8
|
-
import { Heading } from "@
|
|
9
|
-
import { Hr } from "@
|
|
10
|
-
import { Image } from "@
|
|
11
|
-
import { InlineCode } from "@
|
|
12
|
-
import { Kbd } from "@
|
|
13
|
-
import { Link } from "@
|
|
14
|
-
import { Paragraph } from "@
|
|
15
|
-
import { Strikethrough } from "@
|
|
2
|
+
import { Blockquote } from "@components/mdx/components/blockquote";
|
|
3
|
+
import { Callout } from "@components/mdx/components/callout";
|
|
4
|
+
import { CodeBlock } from "@components/mdx/components/code-block";
|
|
5
|
+
import { Figure } from "@components/mdx/components/figure";
|
|
6
|
+
import { FigureCaption } from "@components/mdx/components/figure-caption";
|
|
7
|
+
import { Footnotes } from "@components/mdx/components/footnotes";
|
|
8
|
+
import { Heading } from "@components/mdx/components/heading";
|
|
9
|
+
import { Hr } from "@components/mdx/components/hr";
|
|
10
|
+
import { Image } from "@components/mdx/components/image";
|
|
11
|
+
import { InlineCode } from "@components/mdx/components/inline-code";
|
|
12
|
+
import { Kbd } from "@components/mdx/components/kbd";
|
|
13
|
+
import { Link } from "@components/mdx/components/link";
|
|
14
|
+
import { Paragraph } from "@components/mdx/components/paragraph";
|
|
15
|
+
import { Strikethrough } from "@components/mdx/components/strikethrough";
|
|
16
16
|
import {
|
|
17
17
|
Table,
|
|
18
18
|
TableBodyGroup,
|
|
@@ -20,20 +20,20 @@ import {
|
|
|
20
20
|
TableHeaderCell,
|
|
21
21
|
TableHeadGroup,
|
|
22
22
|
TableRowGroup
|
|
23
|
-
} from "@
|
|
24
|
-
import { TaskList, TaskListInput } from "@
|
|
25
|
-
import { Video } from "@
|
|
26
|
-
import { MDXErrorBoundary } from "@
|
|
27
|
-
import { rehypeHeadingIds } from "@
|
|
23
|
+
} from "@components/mdx/components/table";
|
|
24
|
+
import { TaskList, TaskListInput } from "@components/mdx/components/task-list";
|
|
25
|
+
import { Video } from "@components/mdx/components/video";
|
|
26
|
+
import { MDXErrorBoundary } from "@components/mdx/error-boundary";
|
|
27
|
+
import { rehypeHeadingIds } from "@components/mdx/rehype-heading-ids";
|
|
28
28
|
import { compileMDX } from "next-mdx-remote/rsc";
|
|
29
29
|
import remarkGfm from "remark-gfm";
|
|
30
30
|
|
|
31
31
|
// src/components/mdx/mod-key.tsx
|
|
32
32
|
import {
|
|
33
33
|
ModKey as UiModKey
|
|
34
|
-
} from "@
|
|
34
|
+
} from "@components/ui/mod-key";
|
|
35
35
|
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
36
|
-
import { jsx } from "
|
|
36
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
37
37
|
function ModKey({ className, ...props }) {
|
|
38
38
|
return /* @__PURE__ */ jsx(
|
|
39
39
|
UiModKey,
|
|
@@ -45,6 +45,19 @@ function ModKey({ className, ...props }) {
|
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// src/components/mdx/plugins/remark-code-elements.ts
|
|
49
|
+
function remarkCodeElements() {
|
|
50
|
+
return (tree) => {
|
|
51
|
+
function visit(node, insidePre = !1) {
|
|
52
|
+
if ((node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name === "code" && !insidePre && node.data && Reflect.deleteProperty(node.data, "_mdxExplicitJsx"), "children" in node) {
|
|
53
|
+
let childInsidePre = insidePre || (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name === "pre";
|
|
54
|
+
for (let child of node.children) visit(child, childInsidePre);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
visit(tree);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
48
61
|
// src/components/mdx/plugins/remark-code-title.ts
|
|
49
62
|
function remarkCodeTitle() {
|
|
50
63
|
return (tree) => {
|
|
@@ -63,6 +76,29 @@ function remarkCodeTitle() {
|
|
|
63
76
|
};
|
|
64
77
|
}
|
|
65
78
|
|
|
79
|
+
// src/components/mdx/plugins/remark-component-references.ts
|
|
80
|
+
function remarkComponentReferences({
|
|
81
|
+
components,
|
|
82
|
+
pagePath
|
|
83
|
+
}) {
|
|
84
|
+
return () => (tree) => {
|
|
85
|
+
function visit(node) {
|
|
86
|
+
if ((node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name && /^[A-Z]/.test(node.name)) {
|
|
87
|
+
let rootName = node.name.split(".")[0];
|
|
88
|
+
if (rootName && !components[rootName]) {
|
|
89
|
+
let file = rootName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), position = node.position?.start;
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Undefined MDX component "${rootName}" on page "${pagePath}"` + (position ? ` (body line ${position.line}, column ${position.column})` : "") + (rootName.endsWith("Icon") ? `. For a Phosphor icon, use import { ${rootName} } from "@phosphor-icons/react/ssr".` : `. Add publish.os/components/mdx/${file}.tsx with a named ${rootName} export, or supply it through the MDX components prop.`)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if ("children" in node)
|
|
96
|
+
for (let child of node.children) visit(child);
|
|
97
|
+
}
|
|
98
|
+
visit(tree);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
66
102
|
// src/components/mdx/plugins/remark-keyboard-input.ts
|
|
67
103
|
function remarkKeyboardInput() {
|
|
68
104
|
return (tree) => {
|
|
@@ -74,12 +110,160 @@ function remarkKeyboardInput() {
|
|
|
74
110
|
};
|
|
75
111
|
}
|
|
76
112
|
|
|
113
|
+
// src/components/mdx/plugins/remark-media-elements.ts
|
|
114
|
+
var mediaElements = /* @__PURE__ */ new Set(["img", "figure", "figcaption"]);
|
|
115
|
+
function remarkMediaElements() {
|
|
116
|
+
return (tree) => {
|
|
117
|
+
function visit(node) {
|
|
118
|
+
if ((node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") && node.name && mediaElements.has(node.name) && node.data && Reflect.deleteProperty(node.data, "_mdxExplicitJsx"), "children" in node)
|
|
119
|
+
for (let child of node.children) visit(child);
|
|
120
|
+
}
|
|
121
|
+
visit(tree);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/lib/hosting/framework-paths.ts
|
|
126
|
+
var FRAMEWORK_PREFIX = "/publishos", SOURCE_ASSET_PREFIX = `${FRAMEWORK_PREFIX}/assets`, INTERNAL_PREFIX = `${FRAMEWORK_PREFIX}/internal`, SITE_API_PREFIX = `${FRAMEWORK_PREFIX}/api`, SEARCH_PREFIX = `${INTERNAL_PREFIX}/search`, PAGEFIND_MODULE_URL = `${SEARCH_PREFIX}/pagefind.js`, PAGEFIND_ENTRY_URL = `${SEARCH_PREFIX}/pagefind-entry.json`, IMAGE_OPTIMIZER_PATH = `${SITE_API_PREFIX}/image`;
|
|
127
|
+
var OG_SERVICE_PREFIX = `${SITE_API_PREFIX}/og`, PUBLIC_INTERNAL_DIRECTORY = INTERNAL_PREFIX.slice(1), PUBLIC_FONT_DIRECTORY = `${PUBLIC_INTERNAL_DIRECTORY}/fonts`, PUBLIC_SEARCH_DIRECTORY = `public/${PUBLIC_INTERNAL_DIRECTORY}/search`, FRAMEWORK_PROXY_MATCHER = `/((?!${FRAMEWORK_PREFIX.slice(1)}(?:/|$)|_next/static|_next/image|_next/webpack-hmr).*)`;
|
|
128
|
+
|
|
129
|
+
// src/lib/assets/map-source-asset-url.ts
|
|
130
|
+
var SOURCE_ASSET_PATH = "/assets/", URL_PROPS = [
|
|
131
|
+
"action",
|
|
132
|
+
"cite",
|
|
133
|
+
"data",
|
|
134
|
+
"formAction",
|
|
135
|
+
"href",
|
|
136
|
+
"poster",
|
|
137
|
+
"src",
|
|
138
|
+
"xlinkHref"
|
|
139
|
+
];
|
|
140
|
+
function hasUnsafeControlCharacters(value) {
|
|
141
|
+
for (let character of value) {
|
|
142
|
+
let code = character.codePointAt(0) ?? 0;
|
|
143
|
+
if (code <= 31 || code >= 127 && code <= 159) return !0;
|
|
144
|
+
}
|
|
145
|
+
return !1;
|
|
146
|
+
}
|
|
147
|
+
function assertSafeAssetPath(path) {
|
|
148
|
+
if (path.includes("\\") || hasUnsafeControlCharacters(path))
|
|
149
|
+
throw new TypeError("Local asset URLs must use safe path segments.");
|
|
150
|
+
for (let segment of path.split("/")) {
|
|
151
|
+
if (!segment)
|
|
152
|
+
throw new TypeError("Local asset URLs must use safe path segments.");
|
|
153
|
+
let decoded;
|
|
154
|
+
try {
|
|
155
|
+
decoded = decodeURIComponent(segment);
|
|
156
|
+
} catch {
|
|
157
|
+
throw new TypeError("Local asset URLs must use valid URL encoding.");
|
|
158
|
+
}
|
|
159
|
+
if (decoded === "." || decoded === ".." || decoded.includes("/") || decoded.includes("\\") || hasUnsafeControlCharacters(decoded))
|
|
160
|
+
throw new TypeError("Local asset URLs must use safe path segments.");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function mapSourceAssetUrl(value) {
|
|
164
|
+
if (typeof value != "string" || !value.startsWith(SOURCE_ASSET_PATH))
|
|
165
|
+
return value;
|
|
166
|
+
let suffixIndex = value.search(/[?#]/u), pathname = suffixIndex < 0 ? value : value.slice(0, suffixIndex), suffix = suffixIndex < 0 ? "" : value.slice(suffixIndex), path = pathname.slice(SOURCE_ASSET_PATH.length);
|
|
167
|
+
return assertSafeAssetPath(path), `${SOURCE_ASSET_PREFIX}/${path}${suffix}`;
|
|
168
|
+
}
|
|
169
|
+
function mapSourceSet(value) {
|
|
170
|
+
let candidates = [], cursor = 0;
|
|
171
|
+
for (; cursor < value.length; ) {
|
|
172
|
+
for (; cursor < value.length && /[\s,]/u.test(value[cursor] ?? ""); )
|
|
173
|
+
cursor += 1;
|
|
174
|
+
if (cursor >= value.length) break;
|
|
175
|
+
let start = cursor;
|
|
176
|
+
for (; cursor < value.length && !/\s/u.test(value[cursor] ?? ""); )
|
|
177
|
+
cursor += 1;
|
|
178
|
+
let url = value.slice(start, cursor), endsCandidate = url.endsWith(",");
|
|
179
|
+
endsCandidate && (url = url.replace(/,+$/u, ""));
|
|
180
|
+
let mapped = String(mapSourceAssetUrl(url));
|
|
181
|
+
if (endsCandidate) {
|
|
182
|
+
candidates.push(mapped);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
for (; cursor < value.length && /\s/u.test(value[cursor] ?? ""); )
|
|
186
|
+
cursor += 1;
|
|
187
|
+
let descriptorStart = cursor;
|
|
188
|
+
for (; cursor < value.length && value[cursor] !== ","; ) cursor += 1;
|
|
189
|
+
let descriptor = value.slice(descriptorStart, cursor).trim();
|
|
190
|
+
candidates.push(descriptor ? `${mapped} ${descriptor}` : mapped), value[cursor] === "," && (cursor += 1);
|
|
191
|
+
}
|
|
192
|
+
return candidates.join(", ");
|
|
193
|
+
}
|
|
194
|
+
function mapSourceAssetProps(props) {
|
|
195
|
+
if (!props || typeof props != "object") return props;
|
|
196
|
+
let source = props, mapped;
|
|
197
|
+
for (let name of URL_PROPS) {
|
|
198
|
+
let value = source[name], next = mapSourceAssetUrl(value);
|
|
199
|
+
next !== value && (mapped ??= { ...source }, mapped[name] = next);
|
|
200
|
+
}
|
|
201
|
+
if (typeof source.srcSet == "string") {
|
|
202
|
+
let next = mapSourceSet(source.srcSet);
|
|
203
|
+
next !== source.srcSet && (mapped ??= { ...source }, mapped.srcSet = next);
|
|
204
|
+
}
|
|
205
|
+
return mapped ?? props;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// src/lib/assets/remark-map-source-assets.ts
|
|
209
|
+
var imageBooleanAttributes = /* @__PURE__ */ new Set([
|
|
210
|
+
"decorative",
|
|
211
|
+
"fill",
|
|
212
|
+
"frame",
|
|
213
|
+
"optimized",
|
|
214
|
+
"priority",
|
|
215
|
+
"zoom"
|
|
216
|
+
]);
|
|
217
|
+
function preserveImageControlLiteral(node) {
|
|
218
|
+
if (!(node.name !== "Image" && node.name !== "img" || !node.attributes))
|
|
219
|
+
for (let attribute of node.attributes) {
|
|
220
|
+
if (attribute.type !== "mdxJsxAttribute" || !attribute.value || typeof attribute.value != "object")
|
|
221
|
+
continue;
|
|
222
|
+
let expression = attribute.value.value;
|
|
223
|
+
if (typeof expression != "string") continue;
|
|
224
|
+
let value = expression.trim();
|
|
225
|
+
if (imageBooleanAttributes.has(attribute.name ?? "") && (value === "true" || value === "false")) {
|
|
226
|
+
attribute.value = value;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
let isPositiveNumber = (candidate) => {
|
|
230
|
+
let number = Number(candidate);
|
|
231
|
+
return candidate !== "" && Number.isFinite(number) && number > 0;
|
|
232
|
+
}, unquotedValue = value.replace(/^(?:"(.*)"|'(.*)')$/u, "$1$2"), ratio = unquotedValue.match(
|
|
233
|
+
/^(\d+(?:\.\d+)?)\s*\/\s*(\d+(?:\.\d+)?)$/u
|
|
234
|
+
), isPositiveAspect = isPositiveNumber(unquotedValue) || ratio !== null && Number(ratio[1]) > 0 && Number(ratio[2]) > 0;
|
|
235
|
+
(attribute.name === "width" || attribute.name === "height") && /^\d+$/u.test(value) && isPositiveNumber(value) && Number.isSafeInteger(Number(value)) ? attribute.value = value : attribute.name === "aspect" && isPositiveAspect && (attribute.value = unquotedValue);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function mapAttribute(node) {
|
|
239
|
+
if (preserveImageControlLiteral(node), (node.type === "image" || node.type === "link" || node.type === "definition") && typeof node.url == "string") {
|
|
240
|
+
let prop = node.type === "image" ? "src" : "href", props = mapSourceAssetProps({ [prop]: node.url });
|
|
241
|
+
typeof props[prop] == "string" && (node.url = props[prop]);
|
|
242
|
+
}
|
|
243
|
+
for (let attribute of node.attributes ?? []) {
|
|
244
|
+
if (attribute.type !== "mdxJsxAttribute" || typeof attribute.value != "string")
|
|
245
|
+
continue;
|
|
246
|
+
let mapped = mapSourceAssetProps({
|
|
247
|
+
[attribute.name ?? ""]: attribute.value
|
|
248
|
+
});
|
|
249
|
+
attribute.name && typeof mapped[attribute.name] == "string" && (attribute.value = mapped[attribute.name]);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function remarkMapSourceAssets() {
|
|
253
|
+
return (tree) => {
|
|
254
|
+
let visit = (node) => {
|
|
255
|
+
mapAttribute(node), node.children?.forEach(visit);
|
|
256
|
+
};
|
|
257
|
+
visit(tree);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
77
261
|
// src/components/mdx/mdx.tsx
|
|
78
|
-
import { Figure as Figure2 } from "@
|
|
79
|
-
import { Image as Image2 } from "@
|
|
80
|
-
import { Link as Link2 } from "@
|
|
81
|
-
import { Video as Video2 } from "@
|
|
82
|
-
import { jsx as jsx2 } from "
|
|
262
|
+
import { Figure as Figure2 } from "@components/mdx/components/figure";
|
|
263
|
+
import { Image as Image2 } from "@components/mdx/components/image";
|
|
264
|
+
import { Link as Link2 } from "@components/mdx/components/link";
|
|
265
|
+
import { Video as Video2 } from "@components/mdx/components/video";
|
|
266
|
+
import { jsx as jsx2 } from "@publish.os/nextjs/jsx-runtime";
|
|
83
267
|
var defaultMdxComponents = {
|
|
84
268
|
h1: (props) => /* @__PURE__ */ jsx2(Heading, { as: "h1", ...props }),
|
|
85
269
|
h2: (props) => /* @__PURE__ */ jsx2(Heading, { as: "h2", ...props }),
|
|
@@ -138,20 +322,33 @@ function getErrorMessage(error) {
|
|
|
138
322
|
async function renderMdx({
|
|
139
323
|
components,
|
|
140
324
|
page,
|
|
141
|
-
siteComponents
|
|
325
|
+
siteComponents,
|
|
326
|
+
importedComponents
|
|
142
327
|
}) {
|
|
143
|
-
let
|
|
328
|
+
let selectedComponents = {
|
|
329
|
+
...defaultMdxComponents,
|
|
330
|
+
...siteComponents ?? {},
|
|
331
|
+
...components ?? {},
|
|
332
|
+
...importedComponents ?? {}
|
|
333
|
+
}, mdx = await compileMDX({
|
|
144
334
|
source: page.body,
|
|
145
|
-
components:
|
|
146
|
-
...defaultMdxComponents,
|
|
147
|
-
...siteComponents ?? {},
|
|
148
|
-
...components ?? {}
|
|
149
|
-
},
|
|
335
|
+
components: selectedComponents,
|
|
150
336
|
options: {
|
|
151
337
|
parseFrontmatter: !1,
|
|
152
338
|
mdxOptions: {
|
|
153
339
|
rehypePlugins: [rehypeHeadingIds],
|
|
154
|
-
remarkPlugins: [
|
|
340
|
+
remarkPlugins: [
|
|
341
|
+
remarkGfm,
|
|
342
|
+
remarkCodeTitle,
|
|
343
|
+
remarkKeyboardInput,
|
|
344
|
+
remarkCodeElements,
|
|
345
|
+
remarkMediaElements,
|
|
346
|
+
remarkMapSourceAssets,
|
|
347
|
+
remarkComponentReferences({
|
|
348
|
+
components: selectedComponents,
|
|
349
|
+
pagePath: page.path
|
|
350
|
+
})
|
|
351
|
+
]
|
|
155
352
|
}
|
|
156
353
|
}
|
|
157
354
|
}).then(({ content: compiledContent }) => ({
|