@ox-content/vite-plugin-svelte 3.0.0-alpha.1 → 3.0.0-alpha.3
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/dist/index.cjs +71 -50
- package/dist/index.d.cts +9 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +72 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -34,44 +34,14 @@ const ISLAND_MARKER_PREFIX = "OXCONTENT-ISLAND-";
|
|
|
34
34
|
const ISLAND_MARKER_SUFFIX = "-PLACEHOLDER";
|
|
35
35
|
async function transformMarkdownWithSvelte(code, id, options) {
|
|
36
36
|
const components = options.components;
|
|
37
|
-
const usedComponents = [];
|
|
38
|
-
const islands = [];
|
|
39
|
-
let islandIndex = 0;
|
|
40
37
|
const { content: markdownContent, frontmatter } = extractFrontmatter(code);
|
|
41
|
-
const
|
|
42
|
-
let processedContent = "";
|
|
43
|
-
let lastIndex = 0;
|
|
44
|
-
let match;
|
|
45
|
-
COMPONENT_REGEX.lastIndex = 0;
|
|
46
|
-
while ((match = COMPONENT_REGEX.exec(markdownContent)) !== null) {
|
|
47
|
-
const [fullMatch, componentName, propsString, rawIslandContent] = match;
|
|
48
|
-
const matchStart = match.index;
|
|
49
|
-
const matchEnd = matchStart + fullMatch.length;
|
|
50
|
-
if (!Object.prototype.hasOwnProperty.call(components, componentName) || isInRanges(matchStart, matchEnd, fenceRanges)) {
|
|
51
|
-
processedContent += markdownContent.slice(lastIndex, matchEnd);
|
|
52
|
-
lastIndex = matchEnd;
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (!usedComponents.includes(componentName)) usedComponents.push(componentName);
|
|
56
|
-
const props = parseProps(propsString);
|
|
57
|
-
const islandId = `ox-island-${islandIndex++}`;
|
|
58
|
-
const islandContent = typeof rawIslandContent === "string" ? rawIslandContent.trim() : void 0;
|
|
59
|
-
islands.push({
|
|
60
|
-
name: componentName,
|
|
61
|
-
props,
|
|
62
|
-
position: matchStart,
|
|
63
|
-
id: islandId,
|
|
64
|
-
content: islandContent
|
|
65
|
-
});
|
|
66
|
-
processedContent += markdownContent.slice(lastIndex, matchStart) + createIslandMarker(islandId);
|
|
67
|
-
lastIndex = matchEnd;
|
|
68
|
-
}
|
|
69
|
-
processedContent += markdownContent.slice(lastIndex);
|
|
38
|
+
const mdx = (0, _ox_content_vite_plugin.resolveMdxForFilePath)(id, options.mdx);
|
|
70
39
|
const baseOptions = {
|
|
71
40
|
srcDir: options.srcDir,
|
|
72
41
|
outDir: options.outDir,
|
|
73
42
|
base: options.base,
|
|
74
43
|
extensions: options.extensions,
|
|
44
|
+
mdx,
|
|
75
45
|
ssg: {
|
|
76
46
|
enabled: false,
|
|
77
47
|
extension: ".html",
|
|
@@ -81,6 +51,7 @@ async function transformMarkdownWithSvelte(code, id, options) {
|
|
|
81
51
|
lastUpdated: false,
|
|
82
52
|
pagination: false,
|
|
83
53
|
breadcrumbs: false,
|
|
54
|
+
jsonLd: false,
|
|
84
55
|
readerChrome: false,
|
|
85
56
|
localeSwitcher: false,
|
|
86
57
|
a11y: false,
|
|
@@ -119,7 +90,57 @@ async function transformMarkdownWithSvelte(code, id, options) {
|
|
|
119
90
|
embeds: options.embeds,
|
|
120
91
|
i18n: false
|
|
121
92
|
};
|
|
122
|
-
|
|
93
|
+
if (mdx) {
|
|
94
|
+
const transformed = await (0, _ox_content_vite_plugin.transformMarkdown)(markdownContent, id, baseOptions);
|
|
95
|
+
const discovered = await (0, _ox_content_vite_plugin.discoverDocumentMdxIslands)({
|
|
96
|
+
source: markdownContent,
|
|
97
|
+
html: transformed.html,
|
|
98
|
+
components,
|
|
99
|
+
imports: transformed.imports,
|
|
100
|
+
documentPath: id,
|
|
101
|
+
contentRoot: (0, _ox_content_vite_plugin.resolveContentRootPath)({
|
|
102
|
+
srcDir: options.srcDir,
|
|
103
|
+
root: options.root
|
|
104
|
+
}),
|
|
105
|
+
srcDir: options.srcDir
|
|
106
|
+
});
|
|
107
|
+
return compileSvelteResult(generateSvelteModule(options.renderIsland ? await (0, _ox_content_vite_plugin.applyIslandSsrHtml)(transformed.html, options.renderIsland, id, discovered.usedComponents) : transformed.html, discovered.usedComponents, discovered.usedComponents, frontmatter, options, id, discovered.localBindings), id, discovered.usedComponents, frontmatter);
|
|
108
|
+
}
|
|
109
|
+
const usedComponents = [];
|
|
110
|
+
const islands = [];
|
|
111
|
+
let islandIndex = 0;
|
|
112
|
+
const fenceRanges = collectFenceRanges(markdownContent);
|
|
113
|
+
let processedContent = "";
|
|
114
|
+
let lastIndex = 0;
|
|
115
|
+
let match;
|
|
116
|
+
COMPONENT_REGEX.lastIndex = 0;
|
|
117
|
+
while ((match = COMPONENT_REGEX.exec(markdownContent)) !== null) {
|
|
118
|
+
const [fullMatch, componentName, propsString, rawIslandContent] = match;
|
|
119
|
+
const matchStart = match.index;
|
|
120
|
+
const matchEnd = matchStart + fullMatch.length;
|
|
121
|
+
if (!Object.prototype.hasOwnProperty.call(components, componentName) || isInRanges(matchStart, matchEnd, fenceRanges)) {
|
|
122
|
+
processedContent += markdownContent.slice(lastIndex, matchEnd);
|
|
123
|
+
lastIndex = matchEnd;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (!usedComponents.includes(componentName)) usedComponents.push(componentName);
|
|
127
|
+
const props = parseProps(propsString);
|
|
128
|
+
const islandId = `ox-island-${islandIndex++}`;
|
|
129
|
+
const islandContent = typeof rawIslandContent === "string" ? rawIslandContent.trim() : void 0;
|
|
130
|
+
islands.push({
|
|
131
|
+
name: componentName,
|
|
132
|
+
props,
|
|
133
|
+
position: matchStart,
|
|
134
|
+
id: islandId,
|
|
135
|
+
content: islandContent
|
|
136
|
+
});
|
|
137
|
+
processedContent += markdownContent.slice(lastIndex, matchStart) + createIslandMarker(islandId);
|
|
138
|
+
lastIndex = matchEnd;
|
|
139
|
+
}
|
|
140
|
+
processedContent += markdownContent.slice(lastIndex);
|
|
141
|
+
return compileSvelteResult(generateSvelteModule(injectIslandMarkers((await (0, _ox_content_vite_plugin.transformMarkdown)(processedContent, id, baseOptions)).html, islands), usedComponents, islands, frontmatter, options, id), id, usedComponents, frontmatter);
|
|
142
|
+
}
|
|
143
|
+
function compileSvelteResult(svelteCode, id, usedComponents, frontmatter) {
|
|
123
144
|
return {
|
|
124
145
|
code: `${(0, svelte_compiler.compile)(svelteCode, {
|
|
125
146
|
filename: id,
|
|
@@ -237,20 +258,18 @@ function parseProps(propsString) {
|
|
|
237
258
|
}
|
|
238
259
|
return props;
|
|
239
260
|
}
|
|
240
|
-
function generateSvelteModule(content, usedComponents,
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}).filter(Boolean).join("\n");
|
|
250
|
-
if (islands.length === 0) return `
|
|
261
|
+
function generateSvelteModule(content, usedComponents, _islands, frontmatter, options, id, localBindings) {
|
|
262
|
+
const rawHtmlLiteral = JSON.stringify(content).replaceAll("<\/script", "<\\/script");
|
|
263
|
+
const imports = (0, _ox_content_vite_plugin.renderIslandComponentImports)(usedComponents, {
|
|
264
|
+
globalComponents: options.components,
|
|
265
|
+
localBindings,
|
|
266
|
+
documentPath: id,
|
|
267
|
+
root: options.root
|
|
268
|
+
});
|
|
269
|
+
if (usedComponents.length === 0) return `
|
|
251
270
|
<script>
|
|
252
271
|
const frontmatter = ${JSON.stringify(frontmatter)};
|
|
253
|
-
const rawHtml = ${
|
|
272
|
+
const rawHtml = ${rawHtmlLiteral};
|
|
254
273
|
|
|
255
274
|
export { frontmatter };
|
|
256
275
|
<\/script>
|
|
@@ -269,11 +288,11 @@ function generateSvelteModule(content, usedComponents, islands, frontmatter, opt
|
|
|
269
288
|
return `
|
|
270
289
|
<script>
|
|
271
290
|
import { createRawSnippet, onMount, mount, unmount } from 'svelte';
|
|
272
|
-
import { initIslands } from '@ox-content/islands';
|
|
291
|
+
import { initIslands, readIslandSlotHtml } from '@ox-content/islands';
|
|
273
292
|
${imports}
|
|
274
293
|
|
|
275
294
|
const frontmatter = ${JSON.stringify(frontmatter)};
|
|
276
|
-
const rawHtml = ${
|
|
295
|
+
const rawHtml = ${rawHtmlLiteral};
|
|
277
296
|
const components = {
|
|
278
297
|
${componentMap}
|
|
279
298
|
};
|
|
@@ -290,7 +309,7 @@ ${componentMap}
|
|
|
290
309
|
const Component = components[componentName];
|
|
291
310
|
if (!Component) return;
|
|
292
311
|
|
|
293
|
-
const islandContent = element
|
|
312
|
+
const islandContent = readIslandSlotHtml(element);
|
|
294
313
|
const componentProps = { ...props };
|
|
295
314
|
if (islandContent) {
|
|
296
315
|
componentProps.children = createRawSnippet(() => ({
|
|
@@ -431,7 +450,8 @@ function oxContentSvelte(options = {}) {
|
|
|
431
450
|
const result = await transformMarkdownWithSvelte(code, id, {
|
|
432
451
|
...resolved,
|
|
433
452
|
components: Object.fromEntries(componentMap),
|
|
434
|
-
root: config.root
|
|
453
|
+
root: config.root,
|
|
454
|
+
renderIsland: options.renderIsland
|
|
435
455
|
});
|
|
436
456
|
return {
|
|
437
457
|
code: result.code,
|
|
@@ -506,7 +526,8 @@ function resolveSvelteOptions(options) {
|
|
|
506
526
|
tocMaxDepth: options.tocMaxDepth ?? 3,
|
|
507
527
|
codeAnnotations: resolveCodeAnnotationsOptions(options.codeAnnotations),
|
|
508
528
|
runes: options.runes ?? true,
|
|
509
|
-
embeds: resolveBuiltinEmbedOptions(options.embeds)
|
|
529
|
+
embeds: resolveBuiltinEmbedOptions(options.embeds),
|
|
530
|
+
mdx: options.mdx
|
|
510
531
|
};
|
|
511
532
|
}
|
|
512
533
|
function resolveCodeAnnotationsOptions(options) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginOption } from "vite";
|
|
2
|
-
import { OxContentOptions, oxContent } from "@ox-content/vite-plugin";
|
|
2
|
+
import { OxContentOptions, RenderIslandFn, oxContent } from "@ox-content/vite-plugin";
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Code annotation options for the Svelte integration.
|
|
@@ -91,6 +91,12 @@ interface SvelteIntegrationOptions extends OxContentOptions {
|
|
|
91
91
|
* @default { github: true, openGraph: true }
|
|
92
92
|
*/
|
|
93
93
|
embeds?: BuiltinEmbedOptions | false;
|
|
94
|
+
/**
|
|
95
|
+
* Optional adapter hook that replaces island inner HTML at transform time.
|
|
96
|
+
* The core renderer stays framework-neutral; do not import a framework SSR
|
|
97
|
+
* runtime from `@ox-content/vite-plugin`.
|
|
98
|
+
*/
|
|
99
|
+
renderIsland?: RenderIslandFn;
|
|
94
100
|
}
|
|
95
101
|
/**
|
|
96
102
|
* Fetch options for Svelte GitHub embeds.
|
|
@@ -180,7 +186,9 @@ interface ResolvedSvelteOptions {
|
|
|
180
186
|
components: ComponentsMap;
|
|
181
187
|
runes: boolean;
|
|
182
188
|
embeds: ResolvedBuiltinEmbedOptions;
|
|
189
|
+
mdx?: boolean;
|
|
183
190
|
root?: string;
|
|
191
|
+
renderIsland?: RenderIslandFn;
|
|
184
192
|
}
|
|
185
193
|
interface SvelteTransformResult {
|
|
186
194
|
code: string;
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/index.ts"],"mappings":";;;;;;;;;UAQiB;;;;;;EAMf;;UAGe;EACf;EACA;;;;;KAMU,gBAAgB;;;;;;;;KAShB,mBAAmB;;;;;;;;UASd,iCAAiC;;;;;;;;EAQhD;;;;;;;;;;;;;;;;;;EAmBA,aAAa;;;;;;;;EASb,4BAA4B;;;;;;;;;EAU5B;;;;;;;;;EAUA,SAAS;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/index.ts"],"mappings":";;;;;;;;;UAQiB;;;;;;EAMf;;UAGe;EACf;EACA;;;;;KAMU,gBAAgB;;;;;;;;KAShB,mBAAmB;;;;;;;;UASd,iCAAiC;;;;;;;;EAQhD;;;;;;;;;;;;;;;;;;EAmBA,aAAa;;;;;;;;EASb,4BAA4B;;;;;;;;;EAU5B;;;;;;;;;EAUA,SAAS;;;;;;EAOT,eAAe;;;;;UAMA;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;;EAMA;;;;;EAMA;;;;;UAMe;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;;EAMA;;;;;UAMe;;;;;EAKf,mBAAmB;;;;;EAMnB,sBAAsB;;UAGP;EACf,QAAQ;EACR,WAAW;;UAGI;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB,YAAY;EACZ;EACA,QAAQ;EACR;EACA;EACA,eAAe;;UAGA;EACf;EACA;EACA;EACA,aAAa;;UAGE;EACf;EACA,OAAO;EACP;EACA;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCvIc,gBAAgB,UAAS,2BAAgC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OxContentOptions, oxContent } from "@ox-content/vite-plugin";
|
|
1
|
+
import { OxContentOptions, RenderIslandFn, oxContent } from "@ox-content/vite-plugin";
|
|
2
2
|
import { PluginOption } from "vite";
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
/**
|
|
@@ -91,6 +91,12 @@ interface SvelteIntegrationOptions extends OxContentOptions {
|
|
|
91
91
|
* @default { github: true, openGraph: true }
|
|
92
92
|
*/
|
|
93
93
|
embeds?: BuiltinEmbedOptions | false;
|
|
94
|
+
/**
|
|
95
|
+
* Optional adapter hook that replaces island inner HTML at transform time.
|
|
96
|
+
* The core renderer stays framework-neutral; do not import a framework SSR
|
|
97
|
+
* runtime from `@ox-content/vite-plugin`.
|
|
98
|
+
*/
|
|
99
|
+
renderIsland?: RenderIslandFn;
|
|
94
100
|
}
|
|
95
101
|
/**
|
|
96
102
|
* Fetch options for Svelte GitHub embeds.
|
|
@@ -180,7 +186,9 @@ interface ResolvedSvelteOptions {
|
|
|
180
186
|
components: ComponentsMap;
|
|
181
187
|
runes: boolean;
|
|
182
188
|
embeds: ResolvedBuiltinEmbedOptions;
|
|
189
|
+
mdx?: boolean;
|
|
183
190
|
root?: string;
|
|
191
|
+
renderIsland?: RenderIslandFn;
|
|
184
192
|
}
|
|
185
193
|
interface SvelteTransformResult {
|
|
186
194
|
code: string;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/index.ts"],"mappings":";;;;;;;;;UAQiB;;;;;;EAMf;;UAGe;EACf;EACA;;;;;KAMU,gBAAgB;;;;;;;;KAShB,mBAAmB;;;;;;;;UASd,iCAAiC;;;;;;;;EAQhD;;;;;;;;;;;;;;;;;;EAmBA,aAAa;;;;;;;;EASb,4BAA4B;;;;;;;;;EAU5B;;;;;;;;;EAUA,SAAS;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/index.ts"],"mappings":";;;;;;;;;UAQiB;;;;;;EAMf;;UAGe;EACf;EACA;;;;;KAMU,gBAAgB;;;;;;;;KAShB,mBAAmB;;;;;;;;UASd,iCAAiC;;;;;;;;EAQhD;;;;;;;;;;;;;;;;;;EAmBA,aAAa;;;;;;;;EASb,4BAA4B;;;;;;;;;EAU5B;;;;;;;;;EAUA,SAAS;;;;;;EAOT,eAAe;;;;;UAMA;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;;EAMA;;;;;EAMA;;;;;UAMe;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;;EAMA;;;;;UAMe;;;;;EAKf,mBAAmB;;;;;EAMnB,sBAAsB;;UAGP;EACf,QAAQ;EACR,WAAW;;UAGI;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB,YAAY;EACZ;EACA,QAAQ;EACR;EACA;EACA,eAAe;;UAGA;EACf;EACA;EACA;EACA,aAAa;;UAGE;EACf;EACA,OAAO;EACP;EACA;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCvIc,gBAAgB,UAAS,2BAAgC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { oxContent, oxContent as oxContent$1, transformMarkdown } from "@ox-content/vite-plugin";
|
|
3
|
+
import { applyIslandSsrHtml, discoverDocumentMdxIslands, oxContent, oxContent as oxContent$1, renderIslandComponentImports, resolveContentRootPath, resolveMdxForFilePath, transformMarkdown } from "@ox-content/vite-plugin";
|
|
4
4
|
import { compile } from "svelte/compiler";
|
|
5
5
|
//#region src/transform.ts
|
|
6
6
|
const COMPONENT_REGEX = /<([A-Z][a-zA-Z0-9]*)\s*([^>]*?)\s*(?:\/>|>([\s\S]*?)<\/\1>)/g;
|
|
@@ -9,44 +9,14 @@ const ISLAND_MARKER_PREFIX = "OXCONTENT-ISLAND-";
|
|
|
9
9
|
const ISLAND_MARKER_SUFFIX = "-PLACEHOLDER";
|
|
10
10
|
async function transformMarkdownWithSvelte(code, id, options) {
|
|
11
11
|
const components = options.components;
|
|
12
|
-
const usedComponents = [];
|
|
13
|
-
const islands = [];
|
|
14
|
-
let islandIndex = 0;
|
|
15
12
|
const { content: markdownContent, frontmatter } = extractFrontmatter(code);
|
|
16
|
-
const
|
|
17
|
-
let processedContent = "";
|
|
18
|
-
let lastIndex = 0;
|
|
19
|
-
let match;
|
|
20
|
-
COMPONENT_REGEX.lastIndex = 0;
|
|
21
|
-
while ((match = COMPONENT_REGEX.exec(markdownContent)) !== null) {
|
|
22
|
-
const [fullMatch, componentName, propsString, rawIslandContent] = match;
|
|
23
|
-
const matchStart = match.index;
|
|
24
|
-
const matchEnd = matchStart + fullMatch.length;
|
|
25
|
-
if (!Object.prototype.hasOwnProperty.call(components, componentName) || isInRanges(matchStart, matchEnd, fenceRanges)) {
|
|
26
|
-
processedContent += markdownContent.slice(lastIndex, matchEnd);
|
|
27
|
-
lastIndex = matchEnd;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (!usedComponents.includes(componentName)) usedComponents.push(componentName);
|
|
31
|
-
const props = parseProps(propsString);
|
|
32
|
-
const islandId = `ox-island-${islandIndex++}`;
|
|
33
|
-
const islandContent = typeof rawIslandContent === "string" ? rawIslandContent.trim() : void 0;
|
|
34
|
-
islands.push({
|
|
35
|
-
name: componentName,
|
|
36
|
-
props,
|
|
37
|
-
position: matchStart,
|
|
38
|
-
id: islandId,
|
|
39
|
-
content: islandContent
|
|
40
|
-
});
|
|
41
|
-
processedContent += markdownContent.slice(lastIndex, matchStart) + createIslandMarker(islandId);
|
|
42
|
-
lastIndex = matchEnd;
|
|
43
|
-
}
|
|
44
|
-
processedContent += markdownContent.slice(lastIndex);
|
|
13
|
+
const mdx = resolveMdxForFilePath(id, options.mdx);
|
|
45
14
|
const baseOptions = {
|
|
46
15
|
srcDir: options.srcDir,
|
|
47
16
|
outDir: options.outDir,
|
|
48
17
|
base: options.base,
|
|
49
18
|
extensions: options.extensions,
|
|
19
|
+
mdx,
|
|
50
20
|
ssg: {
|
|
51
21
|
enabled: false,
|
|
52
22
|
extension: ".html",
|
|
@@ -56,6 +26,7 @@ async function transformMarkdownWithSvelte(code, id, options) {
|
|
|
56
26
|
lastUpdated: false,
|
|
57
27
|
pagination: false,
|
|
58
28
|
breadcrumbs: false,
|
|
29
|
+
jsonLd: false,
|
|
59
30
|
readerChrome: false,
|
|
60
31
|
localeSwitcher: false,
|
|
61
32
|
a11y: false,
|
|
@@ -94,7 +65,57 @@ async function transformMarkdownWithSvelte(code, id, options) {
|
|
|
94
65
|
embeds: options.embeds,
|
|
95
66
|
i18n: false
|
|
96
67
|
};
|
|
97
|
-
|
|
68
|
+
if (mdx) {
|
|
69
|
+
const transformed = await transformMarkdown(markdownContent, id, baseOptions);
|
|
70
|
+
const discovered = await discoverDocumentMdxIslands({
|
|
71
|
+
source: markdownContent,
|
|
72
|
+
html: transformed.html,
|
|
73
|
+
components,
|
|
74
|
+
imports: transformed.imports,
|
|
75
|
+
documentPath: id,
|
|
76
|
+
contentRoot: resolveContentRootPath({
|
|
77
|
+
srcDir: options.srcDir,
|
|
78
|
+
root: options.root
|
|
79
|
+
}),
|
|
80
|
+
srcDir: options.srcDir
|
|
81
|
+
});
|
|
82
|
+
return compileSvelteResult(generateSvelteModule(options.renderIsland ? await applyIslandSsrHtml(transformed.html, options.renderIsland, id, discovered.usedComponents) : transformed.html, discovered.usedComponents, discovered.usedComponents, frontmatter, options, id, discovered.localBindings), id, discovered.usedComponents, frontmatter);
|
|
83
|
+
}
|
|
84
|
+
const usedComponents = [];
|
|
85
|
+
const islands = [];
|
|
86
|
+
let islandIndex = 0;
|
|
87
|
+
const fenceRanges = collectFenceRanges(markdownContent);
|
|
88
|
+
let processedContent = "";
|
|
89
|
+
let lastIndex = 0;
|
|
90
|
+
let match;
|
|
91
|
+
COMPONENT_REGEX.lastIndex = 0;
|
|
92
|
+
while ((match = COMPONENT_REGEX.exec(markdownContent)) !== null) {
|
|
93
|
+
const [fullMatch, componentName, propsString, rawIslandContent] = match;
|
|
94
|
+
const matchStart = match.index;
|
|
95
|
+
const matchEnd = matchStart + fullMatch.length;
|
|
96
|
+
if (!Object.prototype.hasOwnProperty.call(components, componentName) || isInRanges(matchStart, matchEnd, fenceRanges)) {
|
|
97
|
+
processedContent += markdownContent.slice(lastIndex, matchEnd);
|
|
98
|
+
lastIndex = matchEnd;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (!usedComponents.includes(componentName)) usedComponents.push(componentName);
|
|
102
|
+
const props = parseProps(propsString);
|
|
103
|
+
const islandId = `ox-island-${islandIndex++}`;
|
|
104
|
+
const islandContent = typeof rawIslandContent === "string" ? rawIslandContent.trim() : void 0;
|
|
105
|
+
islands.push({
|
|
106
|
+
name: componentName,
|
|
107
|
+
props,
|
|
108
|
+
position: matchStart,
|
|
109
|
+
id: islandId,
|
|
110
|
+
content: islandContent
|
|
111
|
+
});
|
|
112
|
+
processedContent += markdownContent.slice(lastIndex, matchStart) + createIslandMarker(islandId);
|
|
113
|
+
lastIndex = matchEnd;
|
|
114
|
+
}
|
|
115
|
+
processedContent += markdownContent.slice(lastIndex);
|
|
116
|
+
return compileSvelteResult(generateSvelteModule(injectIslandMarkers((await transformMarkdown(processedContent, id, baseOptions)).html, islands), usedComponents, islands, frontmatter, options, id), id, usedComponents, frontmatter);
|
|
117
|
+
}
|
|
118
|
+
function compileSvelteResult(svelteCode, id, usedComponents, frontmatter) {
|
|
98
119
|
return {
|
|
99
120
|
code: `${compile(svelteCode, {
|
|
100
121
|
filename: id,
|
|
@@ -212,20 +233,18 @@ function parseProps(propsString) {
|
|
|
212
233
|
}
|
|
213
234
|
return props;
|
|
214
235
|
}
|
|
215
|
-
function generateSvelteModule(content, usedComponents,
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}).filter(Boolean).join("\n");
|
|
225
|
-
if (islands.length === 0) return `
|
|
236
|
+
function generateSvelteModule(content, usedComponents, _islands, frontmatter, options, id, localBindings) {
|
|
237
|
+
const rawHtmlLiteral = JSON.stringify(content).replaceAll("<\/script", "<\\/script");
|
|
238
|
+
const imports = renderIslandComponentImports(usedComponents, {
|
|
239
|
+
globalComponents: options.components,
|
|
240
|
+
localBindings,
|
|
241
|
+
documentPath: id,
|
|
242
|
+
root: options.root
|
|
243
|
+
});
|
|
244
|
+
if (usedComponents.length === 0) return `
|
|
226
245
|
<script>
|
|
227
246
|
const frontmatter = ${JSON.stringify(frontmatter)};
|
|
228
|
-
const rawHtml = ${
|
|
247
|
+
const rawHtml = ${rawHtmlLiteral};
|
|
229
248
|
|
|
230
249
|
export { frontmatter };
|
|
231
250
|
<\/script>
|
|
@@ -244,11 +263,11 @@ function generateSvelteModule(content, usedComponents, islands, frontmatter, opt
|
|
|
244
263
|
return `
|
|
245
264
|
<script>
|
|
246
265
|
import { createRawSnippet, onMount, mount, unmount } from 'svelte';
|
|
247
|
-
import { initIslands } from '@ox-content/islands';
|
|
266
|
+
import { initIslands, readIslandSlotHtml } from '@ox-content/islands';
|
|
248
267
|
${imports}
|
|
249
268
|
|
|
250
269
|
const frontmatter = ${JSON.stringify(frontmatter)};
|
|
251
|
-
const rawHtml = ${
|
|
270
|
+
const rawHtml = ${rawHtmlLiteral};
|
|
252
271
|
const components = {
|
|
253
272
|
${componentMap}
|
|
254
273
|
};
|
|
@@ -265,7 +284,7 @@ ${componentMap}
|
|
|
265
284
|
const Component = components[componentName];
|
|
266
285
|
if (!Component) return;
|
|
267
286
|
|
|
268
|
-
const islandContent = element
|
|
287
|
+
const islandContent = readIslandSlotHtml(element);
|
|
269
288
|
const componentProps = { ...props };
|
|
270
289
|
if (islandContent) {
|
|
271
290
|
componentProps.children = createRawSnippet(() => ({
|
|
@@ -406,7 +425,8 @@ function oxContentSvelte(options = {}) {
|
|
|
406
425
|
const result = await transformMarkdownWithSvelte(code, id, {
|
|
407
426
|
...resolved,
|
|
408
427
|
components: Object.fromEntries(componentMap),
|
|
409
|
-
root: config.root
|
|
428
|
+
root: config.root,
|
|
429
|
+
renderIsland: options.renderIsland
|
|
410
430
|
});
|
|
411
431
|
return {
|
|
412
432
|
code: result.code,
|
|
@@ -481,7 +501,8 @@ function resolveSvelteOptions(options) {
|
|
|
481
501
|
tocMaxDepth: options.tocMaxDepth ?? 3,
|
|
482
502
|
codeAnnotations: resolveCodeAnnotationsOptions(options.codeAnnotations),
|
|
483
503
|
runes: options.runes ?? true,
|
|
484
|
-
embeds: resolveBuiltinEmbedOptions(options.embeds)
|
|
504
|
+
embeds: resolveBuiltinEmbedOptions(options.embeds),
|
|
505
|
+
mdx: options.mdx
|
|
485
506
|
};
|
|
486
507
|
}
|
|
487
508
|
function resolveCodeAnnotationsOptions(options) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["baseTransformMarkdown","oxContent"],"sources":["../src/transform.ts","../src/environment.ts","../src/index.ts"],"sourcesContent":["import * as path from \"path\";\nimport { transformMarkdown as baseTransformMarkdown } from \"@ox-content/vite-plugin\";\nimport { compile } from \"svelte/compiler\";\nimport type {\n ResolvedSvelteOptions,\n SvelteTransformResult,\n ComponentIsland,\n ComponentsMap,\n} from \"./types\";\n\nconst COMPONENT_REGEX = /<([A-Z][a-zA-Z0-9]*)\\s*([^>]*?)\\s*(?:\\/>|>([\\s\\S]*?)<\\/\\1>)/g;\nconst PROP_REGEX = /([a-zA-Z0-9-]+)(?:=(?:\"([^\"]*)\"|'([^']*)'|{([^}]*)}|\\[([^\\]]*)\\]))?/g;\n\nconst ISLAND_MARKER_PREFIX = \"OXCONTENT-ISLAND-\";\nconst ISLAND_MARKER_SUFFIX = \"-PLACEHOLDER\";\n\ninterface Range {\n start: number;\n end: number;\n}\n\nexport async function transformMarkdownWithSvelte(\n code: string,\n id: string,\n options: ResolvedSvelteOptions,\n): Promise<SvelteTransformResult> {\n const components: ComponentsMap = options.components;\n const usedComponents: string[] = [];\n const islands: ComponentIsland[] = [];\n let islandIndex = 0;\n\n const { content: markdownContent, frontmatter } = extractFrontmatter(code);\n const fenceRanges = collectFenceRanges(markdownContent);\n let processedContent = \"\";\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n\n COMPONENT_REGEX.lastIndex = 0;\n while ((match = COMPONENT_REGEX.exec(markdownContent)) !== null) {\n const [fullMatch, componentName, propsString, rawIslandContent] = match;\n const matchStart = match.index;\n const matchEnd = matchStart + fullMatch.length;\n\n if (\n !Object.prototype.hasOwnProperty.call(components, componentName) ||\n isInRanges(matchStart, matchEnd, fenceRanges)\n ) {\n processedContent += markdownContent.slice(lastIndex, matchEnd);\n lastIndex = matchEnd;\n continue;\n }\n\n if (!usedComponents.includes(componentName)) {\n usedComponents.push(componentName);\n }\n\n const props = parseProps(propsString);\n const islandId = `ox-island-${islandIndex++}`;\n const islandContent =\n typeof rawIslandContent === \"string\" ? rawIslandContent.trim() : undefined;\n\n islands.push({\n name: componentName,\n props,\n position: matchStart,\n id: islandId,\n content: islandContent,\n });\n\n processedContent += markdownContent.slice(lastIndex, matchStart) + createIslandMarker(islandId);\n lastIndex = matchEnd;\n }\n processedContent += markdownContent.slice(lastIndex);\n\n const baseOptions = {\n srcDir: options.srcDir,\n outDir: options.outDir,\n base: options.base,\n extensions: options.extensions,\n ssg: {\n enabled: false,\n extension: \".html\",\n clean: false,\n bare: false,\n generateOgImage: false,\n lastUpdated: false,\n pagination: false,\n breadcrumbs: false,\n readerChrome: false,\n localeSwitcher: false,\n a11y: false,\n pageChrome: false,\n },\n gfm: options.gfm,\n frontmatter: false,\n toc: options.toc,\n tocMaxDepth: options.tocMaxDepth,\n codeAnnotations: options.codeAnnotations,\n footnotes: true,\n tables: true,\n taskLists: true,\n strikethrough: true,\n autolinks: options.autolinks,\n highlight: false,\n mermaid: false,\n ogImage: false,\n ogImageOptions: {\n vuePlugin: \"vitejs\",\n width: 1200,\n height: 630,\n cache: true,\n concurrency: 1,\n },\n transformers: [],\n docs: false,\n ogViewer: false,\n search: {\n enabled: false,\n limit: 10,\n prefix: true,\n placeholder: \"Search...\",\n hotkey: \"k\",\n },\n embeds: options.embeds,\n i18n: false,\n } as unknown as Parameters<typeof baseTransformMarkdown>[2] & {\n codeAnnotations?: ResolvedSvelteOptions[\"codeAnnotations\"];\n };\n\n const transformed = await baseTransformMarkdown(processedContent, id, baseOptions);\n\n const htmlWithIslands = injectIslandMarkers(transformed.html, islands);\n const svelteCode = generateSvelteModule(\n htmlWithIslands,\n usedComponents,\n islands,\n frontmatter,\n options,\n id,\n );\n\n const compiled = compile(svelteCode, {\n filename: id,\n generate: \"client\",\n runes: true,\n });\n\n const finalCode = `${compiled.js.code}\\nexport const frontmatter = ${JSON.stringify(frontmatter)};`;\n\n return {\n code: finalCode,\n map: null,\n usedComponents,\n frontmatter,\n };\n}\n\nfunction createIslandMarker(islandId: string): string {\n return `${ISLAND_MARKER_PREFIX}${islandId}${ISLAND_MARKER_SUFFIX}`;\n}\n\nfunction collectFenceRanges(content: string): Range[] {\n const ranges: Range[] = [];\n let inFence = false;\n let fenceChar = \"\";\n let fenceLength = 0;\n let fenceStart = 0;\n let pos = 0;\n\n while (pos < content.length) {\n const lineEnd = content.indexOf(\"\\n\", pos);\n const next = lineEnd === -1 ? content.length : lineEnd + 1;\n const line = content.slice(pos, lineEnd === -1 ? content.length : lineEnd);\n const fenceMatch = line.match(/^\\s{0,3}([`~]{3,})/);\n\n if (fenceMatch) {\n const marker = fenceMatch[1];\n if (!inFence) {\n inFence = true;\n fenceChar = marker[0];\n fenceLength = marker.length;\n fenceStart = pos;\n } else if (marker[0] === fenceChar && marker.length >= fenceLength) {\n inFence = false;\n ranges.push({ start: fenceStart, end: next });\n fenceChar = \"\";\n fenceLength = 0;\n }\n }\n\n pos = next;\n }\n\n if (inFence) {\n ranges.push({ start: fenceStart, end: content.length });\n }\n\n return ranges;\n}\n\nfunction isInRanges(start: number, end: number, ranges: Range[]): boolean {\n for (const range of ranges) {\n if (start < range.end && end > range.start) {\n return true;\n }\n }\n return false;\n}\n\nfunction injectIslandMarkers(html: string, islands: ComponentIsland[]): string {\n let output = html;\n\n for (const island of islands) {\n const marker = createIslandMarker(island.id);\n const propsAttr =\n Object.keys(island.props).length > 0\n ? ` data-ox-props='${JSON.stringify(island.props).replace(/'/g, \"'\")}'`\n : \"\";\n const contentAttr = island.content\n ? ` data-ox-content='${island.content.replace(/'/g, \"'\")}'`\n : \"\";\n const attrs = `data-ox-island=\"${island.name}\"${propsAttr}${contentAttr}`;\n output = output.replaceAll(`<p>${marker}</p>`, `<div ${attrs}></div>`);\n output = output.replaceAll(marker, `<span ${attrs}></span>`);\n }\n\n return output;\n}\n\nfunction extractFrontmatter(content: string): {\n content: string;\n frontmatter: Record<string, unknown>;\n} {\n const frontmatterRegex = /^---\\n([\\s\\S]*?)\\n---\\n/;\n const match = frontmatterRegex.exec(content);\n\n if (!match) {\n return { content, frontmatter: {} };\n }\n\n const frontmatterStr = match[1];\n const frontmatter: Record<string, unknown> = {};\n\n for (const line of frontmatterStr.split(\"\\n\")) {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex > 0) {\n const key = line.slice(0, colonIndex).trim();\n let value: unknown = line.slice(colonIndex + 1).trim();\n try {\n value = JSON.parse(value as string);\n } catch {\n if (\n typeof value === \"string\" &&\n ((value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\")))\n ) {\n value = value.slice(1, -1);\n }\n }\n frontmatter[key] = value;\n }\n }\n\n return { content: content.slice(match[0].length), frontmatter };\n}\n\nfunction parseProps(propsString: string): Record<string, unknown> {\n const props: Record<string, unknown> = {};\n if (!propsString) return props;\n\n PROP_REGEX.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = PROP_REGEX.exec(propsString)) !== null) {\n const [, name, doubleQuoted, singleQuoted, braceValue, bracketValue] = match;\n if (name) {\n if (doubleQuoted !== undefined) props[name] = doubleQuoted;\n else if (singleQuoted !== undefined) props[name] = singleQuoted;\n else if (braceValue !== undefined) {\n try {\n props[name] = JSON.parse(braceValue);\n } catch {\n props[name] = braceValue;\n }\n } else if (bracketValue !== undefined) {\n try {\n props[name] = JSON.parse(`[${bracketValue}]`);\n } catch {\n props[name] = bracketValue;\n }\n } else props[name] = true;\n }\n }\n return props;\n}\n\nfunction generateSvelteModule(\n content: string,\n usedComponents: string[],\n islands: ComponentIsland[],\n frontmatter: Record<string, unknown>,\n options: ResolvedSvelteOptions & { root?: string },\n id: string,\n): string {\n const mdDir = path.dirname(id);\n const root = options.root || process.cwd();\n\n const imports = usedComponents\n .map((name) => {\n const componentPath = options.components[name];\n if (!componentPath) return \"\";\n const absolutePath = path.resolve(root, componentPath.replace(/^\\.\\//, \"\"));\n const relativePath = path.relative(mdDir, absolutePath).replace(/\\\\/g, \"/\");\n const importPath = relativePath.startsWith(\".\") ? relativePath : \"./\" + relativePath;\n return `import ${name} from '${importPath}';`;\n })\n .filter(Boolean)\n .join(\"\\n\");\n\n // If no islands, generate simpler code without island runtime\n if (islands.length === 0) {\n return `\n<script>\n const frontmatter = ${JSON.stringify(frontmatter)};\n const rawHtml = ${JSON.stringify(content)};\n\n export { frontmatter };\n</script>\n\n<div class=\"ox-content\">\n {@html rawHtml}\n</div>\n\n<style>\n .ox-content {\n line-height: 1.6;\n }\n</style>\n`;\n }\n\n const componentMap = usedComponents.map((name) => ` ${name},`).join(\"\\n\");\n\n return `\n<script>\n import { createRawSnippet, onMount, mount, unmount } from 'svelte';\n import { initIslands } from '@ox-content/islands';\n ${imports}\n\n const frontmatter = ${JSON.stringify(frontmatter)};\n const rawHtml = ${JSON.stringify(content)};\n const components = {\n${componentMap}\n };\n\n export { frontmatter };\n\n let container;\n\n function createSvelteHydrate() {\n const mounted = [];\n\n return (element, props) => {\n const componentName = element.dataset.oxIsland;\n const Component = components[componentName];\n if (!Component) return;\n\n const islandContent = element.dataset.oxContent || element.innerHTML;\n const componentProps = { ...props };\n if (islandContent) {\n componentProps.children = createRawSnippet(() => ({\n render: () => \\`<div>\\${islandContent}</div>\\`,\n }));\n }\n\n const instance = mount(Component, { target: element, props: componentProps });\n mounted.push(instance);\n\n return () => unmount(instance);\n };\n }\n\n onMount(() => {\n if (!container) return;\n const controller = initIslands(createSvelteHydrate(), {\n selector: '.ox-content [data-ox-island]',\n });\n return () => controller.destroy();\n });\n</script>\n\n<div class=\"ox-content\" bind:this={container}>\n {@html rawHtml}\n</div>\n\n<style>\n .ox-content {\n line-height: 1.6;\n }\n</style>\n`;\n}\n","import type { EnvironmentOptions } from \"vite\";\n\nexport function createSvelteMarkdownEnvironment(\n mode: \"ssr\" | \"client\",\n options: { outDir: string },\n): EnvironmentOptions {\n const isSSR = mode === \"ssr\";\n\n return {\n build: {\n outDir: isSSR ? `${options.outDir}/.ox-content/ssr` : `${options.outDir}/.ox-content/client`,\n ssr: isSSR,\n rollupOptions: {\n output: {\n format: \"esm\",\n entryFileNames: isSSR ? \"[name].js\" : \"[name].[hash].js\",\n },\n },\n ...(isSSR && { target: \"node18\", minify: false }),\n },\n resolve: {\n conditions: isSSR ? [\"node\", \"import\"] : [\"browser\", \"import\"],\n },\n optimizeDeps: {\n include: isSSR ? [] : [\"svelte\"],\n exclude: [\"@ox-content/vite-plugin\", \"@ox-content/vite-plugin-svelte\"],\n },\n };\n}\n","/**\n * Vite Plugin for Ox Content Svelte Integration\n *\n * Uses Vite's Environment API to enable embedding Svelte components in Markdown.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport type { Plugin, PluginOption, ResolvedConfig } from \"vite\";\nimport { oxContent } from \"@ox-content/vite-plugin\";\nimport { transformMarkdownWithSvelte } from \"./transform\";\nimport { createSvelteMarkdownEnvironment } from \"./environment\";\nimport type {\n SvelteIntegrationOptions,\n ResolvedSvelteOptions,\n ComponentsMap,\n ComponentsOption,\n BuiltinEmbedOptions,\n} from \"./types\";\n\nconst DEFAULT_MARKDOWN_EXTENSIONS = [\".md\", \".markdown\", \".mdx\"] as const;\n\nfunction normalizeMarkdownExtensions(extensions?: readonly string[]): string[] {\n const values = extensions?.length ? extensions : DEFAULT_MARKDOWN_EXTENSIONS;\n return Array.from(\n new Map(\n values.map((extension) => {\n const value = extension.startsWith(\".\") ? extension : `.${extension}`;\n return [value.toLowerCase(), value] as const;\n }),\n ).values(),\n );\n}\n\nfunction isMarkdownFilePath(filePath: string, extensions: readonly string[]): boolean {\n const pathname = filePath.split(\"?\")[0].split(\"#\")[0].toLowerCase();\n return extensions.some((extension) => pathname.endsWith(extension.toLowerCase()));\n}\n\nfunction resolveBuiltinEmbedOptions(\n options: BuiltinEmbedOptions | false | undefined,\n): ResolvedSvelteOptions[\"embeds\"] {\n if (options === false) return { github: false, openGraph: false };\n return {\n github: resolveSingleEmbedOptions(options?.github),\n openGraph: resolveSingleEmbedOptions(options?.openGraph),\n };\n}\n\nfunction resolveSingleEmbedOptions<T extends object>(options: boolean | T | undefined): T | false {\n if (options === false) return false;\n if (options === true || options === undefined) return {} as T;\n return options;\n}\n\nexport type {\n SvelteIntegrationOptions,\n ResolvedSvelteOptions,\n ComponentsOption,\n ComponentsMap,\n BuiltinEmbedOptions,\n GitHubEmbedOptions,\n OpenGraphEmbedOptions,\n ResolvedBuiltinEmbedOptions,\n SvelteTransformResult,\n ComponentIsland,\n} from \"./types\";\n\n/**\n * Creates the Ox Content Svelte integration plugin.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { svelte } from '@sveltejs/vite-plugin-svelte';\n * import { oxContentSvelte } from 'vite-plugin-ox-content-svelte';\n *\n * export default defineConfig({\n * plugins: [\n * svelte(),\n * oxContentSvelte({\n * srcDir: 'docs',\n * components: {\n * Counter: './src/components/Counter.svelte',\n * },\n * }),\n * ],\n * });\n * ```\n */\nexport function oxContentSvelte(options: SvelteIntegrationOptions = {}): PluginOption[] {\n const resolved = resolveSvelteOptions(options);\n let componentMap = new Map<string, string>();\n let config: ResolvedConfig;\n\n if (typeof options.components === \"object\" && !Array.isArray(options.components)) {\n componentMap = new Map(Object.entries(options.components));\n }\n\n const svelteTransformPlugin: Plugin = {\n name: \"ox-content:svelte-transform\",\n enforce: \"pre\",\n\n async configResolved(resolvedConfig) {\n config = resolvedConfig;\n\n const componentsOption = options.components;\n if (componentsOption) {\n const resolvedComponents = await resolveComponentsGlob(componentsOption, config.root);\n componentMap = new Map(Object.entries(resolvedComponents));\n }\n },\n\n async transform(code, id) {\n if (!isMarkdownFilePath(id, resolved.extensions)) {\n return null;\n }\n\n const result = await transformMarkdownWithSvelte(code, id, {\n ...resolved,\n components: Object.fromEntries(componentMap),\n root: config.root,\n });\n\n return {\n code: result.code,\n map: result.map,\n };\n },\n };\n\n const svelteEnvironmentPlugin: Plugin = {\n name: \"ox-content:svelte-environment\",\n\n config() {\n return {\n environments: {\n oxcontent_ssr: createSvelteMarkdownEnvironment(\"ssr\", resolved),\n oxcontent_client: createSvelteMarkdownEnvironment(\"client\", resolved),\n },\n };\n },\n\n resolveId(id) {\n if (id === \"virtual:ox-content-svelte/runtime\") {\n return \"\\0virtual:ox-content-svelte/runtime\";\n }\n if (id === \"virtual:ox-content-svelte/components\") {\n return \"\\0virtual:ox-content-svelte/components\";\n }\n return null;\n },\n\n load(id) {\n if (id === \"\\0virtual:ox-content-svelte/runtime\") {\n return generateRuntimeModule();\n }\n if (id === \"\\0virtual:ox-content-svelte/components\") {\n return generateComponentsModule(componentMap);\n }\n return null;\n },\n\n applyToEnvironment(environment) {\n return [\"oxcontent_ssr\", \"oxcontent_client\", \"client\", \"ssr\"].includes(environment.name);\n },\n };\n\n const svelteHmrPlugin: Plugin = {\n name: \"ox-content:svelte-hmr\",\n apply: \"serve\",\n\n handleHotUpdate({ file, server, modules }) {\n const isComponent = Array.from(componentMap.values()).some((path) =>\n file.endsWith(path.replace(/^\\.\\//, \"\")),\n );\n\n if (isComponent) {\n const mdModules = Array.from(server.moduleGraph.idToModuleMap.values()).filter(\n (mod) => mod.file && isMarkdownFilePath(mod.file, resolved.extensions),\n );\n\n if (mdModules.length > 0) {\n server.ws.send({\n type: \"custom\",\n event: \"ox-content:svelte-update\",\n data: { file },\n });\n return [...modules, ...mdModules];\n }\n }\n\n return modules;\n },\n };\n\n const basePlugins = oxContent(options).flatMap((plugin) =>\n Array.isArray(plugin) ? plugin : [plugin],\n ) as Plugin[];\n const environmentPlugin = basePlugins.find((plugin) => plugin.name === \"ox-content:environment\");\n const plugins: Plugin[] = [svelteTransformPlugin, svelteEnvironmentPlugin, svelteHmrPlugin];\n\n if (environmentPlugin) {\n plugins.push(environmentPlugin);\n }\n\n return plugins;\n}\n\nfunction resolveSvelteOptions(\n options: SvelteIntegrationOptions,\n): Omit<ResolvedSvelteOptions, \"components\"> {\n return {\n srcDir: options.srcDir ?? \"docs\",\n outDir: options.outDir ?? \"dist\",\n base: options.base ?? \"/\",\n extensions: normalizeMarkdownExtensions(options.extensions),\n gfm: options.gfm ?? true,\n autolinks: options.autolinks ?? options.gfm ?? true,\n frontmatter: options.frontmatter ?? true,\n toc: options.toc ?? true,\n tocMaxDepth: options.tocMaxDepth ?? 3,\n codeAnnotations: resolveCodeAnnotationsOptions(options.codeAnnotations),\n runes: options.runes ?? true,\n embeds: resolveBuiltinEmbedOptions(options.embeds),\n };\n}\n\nfunction resolveCodeAnnotationsOptions(\n options: SvelteIntegrationOptions[\"codeAnnotations\"],\n): ResolvedSvelteOptions[\"codeAnnotations\"] {\n if (!options) {\n return {\n enabled: false,\n metaKey: \"annotate\",\n };\n }\n\n if (options === true) {\n return {\n enabled: true,\n metaKey: \"annotate\",\n };\n }\n\n return {\n enabled: true,\n metaKey: options.metaKey ?? \"annotate\",\n };\n}\n\nfunction generateRuntimeModule(): string {\n return `\n// Svelte 5 runtime for ox-content\nexport { mount, unmount } from 'svelte';\n`;\n}\n\nfunction generateComponentsModule(componentMap: Map<string, string>): string {\n const imports: string[] = [];\n const exports: string[] = [];\n\n componentMap.forEach((path, name) => {\n imports.push(`import ${name} from '${path}';`);\n exports.push(` ${name},`);\n });\n\n return `\n${imports.join(\"\\n\")}\n\nexport const components = {\n${exports.join(\"\\n\")}\n};\n\nexport default components;\n`;\n}\n\nasync function resolveComponentsGlob(\n componentsOption: ComponentsOption,\n root: string,\n): Promise<ComponentsMap> {\n if (typeof componentsOption === \"object\" && !Array.isArray(componentsOption)) {\n return componentsOption;\n }\n\n const patterns = Array.isArray(componentsOption) ? componentsOption : [componentsOption];\n\n const result: ComponentsMap = {};\n\n for (const pattern of patterns) {\n const files = await globFiles(pattern, root);\n\n for (const file of files) {\n const baseName = path.basename(file, path.extname(file));\n const componentName = toPascalCase(baseName);\n const relativePath = \"./\" + path.relative(root, file).replace(/\\\\/g, \"/\");\n\n result[componentName] = relativePath;\n }\n }\n\n return result;\n}\n\nasync function globFiles(pattern: string, root: string): Promise<string[]> {\n const files: string[] = [];\n const isGlob = pattern.includes(\"*\");\n\n if (!isGlob) {\n const fullPath = path.resolve(root, pattern);\n if (fs.existsSync(fullPath)) {\n files.push(fullPath);\n }\n return files;\n }\n\n const parts = pattern.split(\"*\");\n const baseDir = path.resolve(root, parts[0]);\n const ext = parts[1] || \"\";\n\n if (!fs.existsSync(baseDir)) {\n return files;\n }\n\n if (pattern.includes(\"**\")) {\n await walkDir(baseDir, files, ext);\n } else {\n const entries = await fs.promises.readdir(baseDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isFile() && entry.name.endsWith(ext)) {\n files.push(path.join(baseDir, entry.name));\n }\n }\n }\n\n return files;\n}\n\nasync function walkDir(dir: string, files: string[], ext: string): Promise<void> {\n const entries = await fs.promises.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n if (entry.isDirectory()) {\n await walkDir(fullPath, files, ext);\n } else if (entry.isFile() && entry.name.endsWith(ext)) {\n files.push(fullPath);\n }\n }\n}\n\nfunction toPascalCase(str: string): string {\n return str.replace(/[-_](\\w)/g, (_, c) => c.toUpperCase()).replace(/^\\w/, (c) => c.toUpperCase());\n}\n\nexport { oxContent } from \"@ox-content/vite-plugin\";\n"],"mappings":";;;;;AAUA,MAAM,kBAAkB;AACxB,MAAM,aAAa;AAEnB,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAO7B,eAAsB,4BACpB,MACA,IACA,SACgC;CAChC,MAAM,aAA4B,QAAQ;CAC1C,MAAM,iBAA2B,CAAC;CAClC,MAAM,UAA6B,CAAC;CACpC,IAAI,cAAc;CAElB,MAAM,EAAE,SAAS,iBAAiB,gBAAgB,mBAAmB,IAAI;CACzE,MAAM,cAAc,mBAAmB,eAAe;CACtD,IAAI,mBAAmB;CACvB,IAAI,YAAY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I,MAAM,YAAY,GACpB,MAAM,QAAQ,UAAU,OAAO,GAAG;OAC7B,IAAI,MAAM,OAAO,KAAK,MAAM,KAAK,SAAS,GAAG,GAClD,MAAM,KAAK,QAAQ;CAEvB;AACF;AAEA,SAAS,aAAa,KAAqB;CACzC,OAAO,IAAI,QAAQ,cAAc,GAAG,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ,QAAQ,MAAM,EAAE,YAAY,CAAC;AAClG"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["baseTransformMarkdown","oxContent"],"sources":["../src/transform.ts","../src/environment.ts","../src/index.ts"],"sourcesContent":["import {\n applyIslandSsrHtml,\n discoverDocumentMdxIslands,\n renderIslandComponentImports,\n resolveContentRootPath,\n resolveMdxForFilePath,\n transformMarkdown as baseTransformMarkdown,\n type ResolvedDocumentComponentImport,\n} from \"@ox-content/vite-plugin\";\nimport { compile } from \"svelte/compiler\";\nimport type {\n ResolvedSvelteOptions,\n SvelteTransformResult,\n ComponentIsland,\n ComponentsMap,\n} from \"./types\";\n\nconst COMPONENT_REGEX = /<([A-Z][a-zA-Z0-9]*)\\s*([^>]*?)\\s*(?:\\/>|>([\\s\\S]*?)<\\/\\1>)/g;\nconst PROP_REGEX = /([a-zA-Z0-9-]+)(?:=(?:\"([^\"]*)\"|'([^']*)'|{([^}]*)}|\\[([^\\]]*)\\]))?/g;\n\nconst ISLAND_MARKER_PREFIX = \"OXCONTENT-ISLAND-\";\nconst ISLAND_MARKER_SUFFIX = \"-PLACEHOLDER\";\n\ninterface Range {\n start: number;\n end: number;\n}\n\nexport async function transformMarkdownWithSvelte(\n code: string,\n id: string,\n options: ResolvedSvelteOptions,\n): Promise<SvelteTransformResult> {\n const components: ComponentsMap = options.components;\n const { content: markdownContent, frontmatter } = extractFrontmatter(code);\n const mdx = resolveMdxForFilePath(id, options.mdx);\n\n const baseOptions = {\n srcDir: options.srcDir,\n outDir: options.outDir,\n base: options.base,\n extensions: options.extensions,\n mdx,\n ssg: {\n enabled: false,\n extension: \".html\",\n clean: false,\n bare: false,\n generateOgImage: false,\n lastUpdated: false,\n pagination: false,\n breadcrumbs: false,\n jsonLd: false,\n readerChrome: false,\n localeSwitcher: false,\n a11y: false,\n pageChrome: false,\n },\n gfm: options.gfm,\n frontmatter: false,\n toc: options.toc,\n tocMaxDepth: options.tocMaxDepth,\n codeAnnotations: options.codeAnnotations,\n footnotes: true,\n tables: true,\n taskLists: true,\n strikethrough: true,\n autolinks: options.autolinks,\n highlight: false,\n mermaid: false,\n ogImage: false,\n ogImageOptions: {\n vuePlugin: \"vitejs\",\n width: 1200,\n height: 630,\n cache: true,\n concurrency: 1,\n },\n transformers: [],\n docs: false,\n ogViewer: false,\n search: {\n enabled: false,\n limit: 10,\n prefix: true,\n placeholder: \"Search...\",\n hotkey: \"k\",\n },\n embeds: options.embeds,\n i18n: false,\n } as unknown as Parameters<typeof baseTransformMarkdown>[2] & {\n codeAnnotations?: ResolvedSvelteOptions[\"codeAnnotations\"];\n };\n\n if (mdx) {\n const transformed = await baseTransformMarkdown(markdownContent, id, baseOptions);\n const discovered = await discoverDocumentMdxIslands({\n source: markdownContent,\n html: transformed.html,\n components,\n imports: transformed.imports,\n documentPath: id,\n contentRoot: resolveContentRootPath({ srcDir: options.srcDir, root: options.root }),\n srcDir: options.srcDir,\n });\n const html = options.renderIsland\n ? await applyIslandSsrHtml(\n transformed.html,\n options.renderIsland,\n id,\n discovered.usedComponents,\n )\n : transformed.html;\n return compileSvelteResult(\n generateSvelteModule(\n html,\n discovered.usedComponents,\n discovered.usedComponents,\n frontmatter,\n options,\n id,\n discovered.localBindings,\n ),\n id,\n discovered.usedComponents,\n frontmatter,\n );\n }\n\n const usedComponents: string[] = [];\n const islands: ComponentIsland[] = [];\n let islandIndex = 0;\n\n const fenceRanges = collectFenceRanges(markdownContent);\n let processedContent = \"\";\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n\n COMPONENT_REGEX.lastIndex = 0;\n while ((match = COMPONENT_REGEX.exec(markdownContent)) !== null) {\n const [fullMatch, componentName, propsString, rawIslandContent] = match;\n const matchStart = match.index;\n const matchEnd = matchStart + fullMatch.length;\n\n if (\n !Object.prototype.hasOwnProperty.call(components, componentName) ||\n isInRanges(matchStart, matchEnd, fenceRanges)\n ) {\n processedContent += markdownContent.slice(lastIndex, matchEnd);\n lastIndex = matchEnd;\n continue;\n }\n\n if (!usedComponents.includes(componentName)) {\n usedComponents.push(componentName);\n }\n\n const props = parseProps(propsString);\n const islandId = `ox-island-${islandIndex++}`;\n const islandContent =\n typeof rawIslandContent === \"string\" ? rawIslandContent.trim() : undefined;\n\n islands.push({\n name: componentName,\n props,\n position: matchStart,\n id: islandId,\n content: islandContent,\n });\n\n processedContent += markdownContent.slice(lastIndex, matchStart) + createIslandMarker(islandId);\n lastIndex = matchEnd;\n }\n processedContent += markdownContent.slice(lastIndex);\n\n const transformed = await baseTransformMarkdown(processedContent, id, baseOptions);\n const htmlWithIslands = injectIslandMarkers(transformed.html, islands);\n return compileSvelteResult(\n generateSvelteModule(htmlWithIslands, usedComponents, islands, frontmatter, options, id),\n id,\n usedComponents,\n frontmatter,\n );\n}\n\nfunction compileSvelteResult(\n svelteCode: string,\n id: string,\n usedComponents: string[],\n frontmatter: Record<string, unknown>,\n): SvelteTransformResult {\n const compiled = compile(svelteCode, {\n filename: id,\n generate: \"client\",\n runes: true,\n });\n\n return {\n code: `${compiled.js.code}\\nexport const frontmatter = ${JSON.stringify(frontmatter)};`,\n map: null,\n usedComponents,\n frontmatter,\n };\n}\n\nfunction createIslandMarker(islandId: string): string {\n return `${ISLAND_MARKER_PREFIX}${islandId}${ISLAND_MARKER_SUFFIX}`;\n}\n\nfunction collectFenceRanges(content: string): Range[] {\n const ranges: Range[] = [];\n let inFence = false;\n let fenceChar = \"\";\n let fenceLength = 0;\n let fenceStart = 0;\n let pos = 0;\n\n while (pos < content.length) {\n const lineEnd = content.indexOf(\"\\n\", pos);\n const next = lineEnd === -1 ? content.length : lineEnd + 1;\n const line = content.slice(pos, lineEnd === -1 ? content.length : lineEnd);\n const fenceMatch = line.match(/^\\s{0,3}([`~]{3,})/);\n\n if (fenceMatch) {\n const marker = fenceMatch[1];\n if (!inFence) {\n inFence = true;\n fenceChar = marker[0];\n fenceLength = marker.length;\n fenceStart = pos;\n } else if (marker[0] === fenceChar && marker.length >= fenceLength) {\n inFence = false;\n ranges.push({ start: fenceStart, end: next });\n fenceChar = \"\";\n fenceLength = 0;\n }\n }\n\n pos = next;\n }\n\n if (inFence) {\n ranges.push({ start: fenceStart, end: content.length });\n }\n\n return ranges;\n}\n\nfunction isInRanges(start: number, end: number, ranges: Range[]): boolean {\n for (const range of ranges) {\n if (start < range.end && end > range.start) {\n return true;\n }\n }\n return false;\n}\n\nfunction injectIslandMarkers(html: string, islands: ComponentIsland[]): string {\n let output = html;\n\n for (const island of islands) {\n const marker = createIslandMarker(island.id);\n const propsAttr =\n Object.keys(island.props).length > 0\n ? ` data-ox-props='${JSON.stringify(island.props).replace(/'/g, \"'\")}'`\n : \"\";\n const contentAttr = island.content\n ? ` data-ox-content='${island.content.replace(/'/g, \"'\")}'`\n : \"\";\n const attrs = `data-ox-island=\"${island.name}\"${propsAttr}${contentAttr}`;\n output = output.replaceAll(`<p>${marker}</p>`, `<div ${attrs}></div>`);\n output = output.replaceAll(marker, `<span ${attrs}></span>`);\n }\n\n return output;\n}\n\nfunction extractFrontmatter(content: string): {\n content: string;\n frontmatter: Record<string, unknown>;\n} {\n const frontmatterRegex = /^---\\n([\\s\\S]*?)\\n---\\n/;\n const match = frontmatterRegex.exec(content);\n\n if (!match) {\n return { content, frontmatter: {} };\n }\n\n const frontmatterStr = match[1];\n const frontmatter: Record<string, unknown> = {};\n\n for (const line of frontmatterStr.split(\"\\n\")) {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex > 0) {\n const key = line.slice(0, colonIndex).trim();\n let value: unknown = line.slice(colonIndex + 1).trim();\n try {\n value = JSON.parse(value as string);\n } catch {\n if (\n typeof value === \"string\" &&\n ((value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\")))\n ) {\n value = value.slice(1, -1);\n }\n }\n frontmatter[key] = value;\n }\n }\n\n return { content: content.slice(match[0].length), frontmatter };\n}\n\nfunction parseProps(propsString: string): Record<string, unknown> {\n const props: Record<string, unknown> = {};\n if (!propsString) return props;\n\n PROP_REGEX.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = PROP_REGEX.exec(propsString)) !== null) {\n const [, name, doubleQuoted, singleQuoted, braceValue, bracketValue] = match;\n if (name) {\n if (doubleQuoted !== undefined) props[name] = doubleQuoted;\n else if (singleQuoted !== undefined) props[name] = singleQuoted;\n else if (braceValue !== undefined) {\n try {\n props[name] = JSON.parse(braceValue);\n } catch {\n props[name] = braceValue;\n }\n } else if (bracketValue !== undefined) {\n try {\n props[name] = JSON.parse(`[${bracketValue}]`);\n } catch {\n props[name] = bracketValue;\n }\n } else props[name] = true;\n }\n }\n return props;\n}\n\nfunction generateSvelteModule(\n content: string,\n usedComponents: string[],\n _islands: ComponentIsland[] | string[],\n frontmatter: Record<string, unknown>,\n options: ResolvedSvelteOptions & { root?: string },\n id: string,\n localBindings?: ReadonlyMap<string, ResolvedDocumentComponentImport>,\n): string {\n // Rust island payloads include `</script>`; that must not close this SFC block.\n const rawHtmlLiteral = JSON.stringify(content).replaceAll(\"</script\", \"<\\\\/script\");\n\n const imports = renderIslandComponentImports(usedComponents, {\n globalComponents: options.components,\n localBindings,\n documentPath: id,\n root: options.root,\n });\n\n // If no registered islands, generate simpler code without island runtime\n if (usedComponents.length === 0) {\n return `\n<script>\n const frontmatter = ${JSON.stringify(frontmatter)};\n const rawHtml = ${rawHtmlLiteral};\n\n export { frontmatter };\n</script>\n\n<div class=\"ox-content\">\n {@html rawHtml}\n</div>\n\n<style>\n .ox-content {\n line-height: 1.6;\n }\n</style>\n`;\n }\n\n const componentMap = usedComponents.map((name) => ` ${name},`).join(\"\\n\");\n\n return `\n<script>\n import { createRawSnippet, onMount, mount, unmount } from 'svelte';\n import { initIslands, readIslandSlotHtml } from '@ox-content/islands';\n ${imports}\n\n const frontmatter = ${JSON.stringify(frontmatter)};\n const rawHtml = ${rawHtmlLiteral};\n const components = {\n${componentMap}\n };\n\n export { frontmatter };\n\n let container;\n\n function createSvelteHydrate() {\n const mounted = [];\n\n return (element, props) => {\n const componentName = element.dataset.oxIsland;\n const Component = components[componentName];\n if (!Component) return;\n\n const islandContent = readIslandSlotHtml(element);\n const componentProps = { ...props };\n if (islandContent) {\n componentProps.children = createRawSnippet(() => ({\n render: () => \\`<div>\\${islandContent}</div>\\`,\n }));\n }\n\n const instance = mount(Component, { target: element, props: componentProps });\n mounted.push(instance);\n\n return () => unmount(instance);\n };\n }\n\n onMount(() => {\n if (!container) return;\n const controller = initIslands(createSvelteHydrate(), {\n selector: '.ox-content [data-ox-island]',\n });\n return () => controller.destroy();\n });\n</script>\n\n<div class=\"ox-content\" bind:this={container}>\n {@html rawHtml}\n</div>\n\n<style>\n .ox-content {\n line-height: 1.6;\n }\n</style>\n`;\n}\n","import type { EnvironmentOptions } from \"vite\";\n\nexport function createSvelteMarkdownEnvironment(\n mode: \"ssr\" | \"client\",\n options: { outDir: string },\n): EnvironmentOptions {\n const isSSR = mode === \"ssr\";\n\n return {\n build: {\n outDir: isSSR ? `${options.outDir}/.ox-content/ssr` : `${options.outDir}/.ox-content/client`,\n ssr: isSSR,\n rollupOptions: {\n output: {\n format: \"esm\",\n entryFileNames: isSSR ? \"[name].js\" : \"[name].[hash].js\",\n },\n },\n ...(isSSR && { target: \"node18\", minify: false }),\n },\n resolve: {\n conditions: isSSR ? [\"node\", \"import\"] : [\"browser\", \"import\"],\n },\n optimizeDeps: {\n include: isSSR ? [] : [\"svelte\"],\n exclude: [\"@ox-content/vite-plugin\", \"@ox-content/vite-plugin-svelte\"],\n },\n };\n}\n","/**\n * Vite Plugin for Ox Content Svelte Integration\n *\n * Uses Vite's Environment API to enable embedding Svelte components in Markdown.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport type { Plugin, PluginOption, ResolvedConfig } from \"vite\";\nimport { oxContent } from \"@ox-content/vite-plugin\";\nimport { transformMarkdownWithSvelte } from \"./transform\";\nimport { createSvelteMarkdownEnvironment } from \"./environment\";\nimport type {\n SvelteIntegrationOptions,\n ResolvedSvelteOptions,\n ComponentsMap,\n ComponentsOption,\n BuiltinEmbedOptions,\n} from \"./types\";\n\nconst DEFAULT_MARKDOWN_EXTENSIONS = [\".md\", \".markdown\", \".mdx\"] as const;\n\nfunction normalizeMarkdownExtensions(extensions?: readonly string[]): string[] {\n const values = extensions?.length ? extensions : DEFAULT_MARKDOWN_EXTENSIONS;\n return Array.from(\n new Map(\n values.map((extension) => {\n const value = extension.startsWith(\".\") ? extension : `.${extension}`;\n return [value.toLowerCase(), value] as const;\n }),\n ).values(),\n );\n}\n\nfunction isMarkdownFilePath(filePath: string, extensions: readonly string[]): boolean {\n const pathname = filePath.split(\"?\")[0].split(\"#\")[0].toLowerCase();\n return extensions.some((extension) => pathname.endsWith(extension.toLowerCase()));\n}\n\nfunction resolveBuiltinEmbedOptions(\n options: BuiltinEmbedOptions | false | undefined,\n): ResolvedSvelteOptions[\"embeds\"] {\n if (options === false) return { github: false, openGraph: false };\n return {\n github: resolveSingleEmbedOptions(options?.github),\n openGraph: resolveSingleEmbedOptions(options?.openGraph),\n };\n}\n\nfunction resolveSingleEmbedOptions<T extends object>(options: boolean | T | undefined): T | false {\n if (options === false) return false;\n if (options === true || options === undefined) return {} as T;\n return options;\n}\n\nexport type {\n SvelteIntegrationOptions,\n ResolvedSvelteOptions,\n ComponentsOption,\n ComponentsMap,\n BuiltinEmbedOptions,\n GitHubEmbedOptions,\n OpenGraphEmbedOptions,\n ResolvedBuiltinEmbedOptions,\n SvelteTransformResult,\n ComponentIsland,\n} from \"./types\";\n\n/**\n * Creates the Ox Content Svelte integration plugin.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { svelte } from '@sveltejs/vite-plugin-svelte';\n * import { oxContentSvelte } from 'vite-plugin-ox-content-svelte';\n *\n * export default defineConfig({\n * plugins: [\n * svelte(),\n * oxContentSvelte({\n * srcDir: 'docs',\n * components: {\n * Counter: './src/components/Counter.svelte',\n * },\n * }),\n * ],\n * });\n * ```\n */\nexport function oxContentSvelte(options: SvelteIntegrationOptions = {}): PluginOption[] {\n const resolved = resolveSvelteOptions(options);\n let componentMap = new Map<string, string>();\n let config: ResolvedConfig;\n\n if (typeof options.components === \"object\" && !Array.isArray(options.components)) {\n componentMap = new Map(Object.entries(options.components));\n }\n\n const svelteTransformPlugin: Plugin = {\n name: \"ox-content:svelte-transform\",\n enforce: \"pre\",\n\n async configResolved(resolvedConfig) {\n config = resolvedConfig;\n\n const componentsOption = options.components;\n if (componentsOption) {\n const resolvedComponents = await resolveComponentsGlob(componentsOption, config.root);\n componentMap = new Map(Object.entries(resolvedComponents));\n }\n },\n\n async transform(code, id) {\n if (!isMarkdownFilePath(id, resolved.extensions)) {\n return null;\n }\n\n const result = await transformMarkdownWithSvelte(code, id, {\n ...resolved,\n components: Object.fromEntries(componentMap),\n root: config.root,\n renderIsland: options.renderIsland,\n });\n\n return {\n code: result.code,\n map: result.map,\n };\n },\n };\n\n const svelteEnvironmentPlugin: Plugin = {\n name: \"ox-content:svelte-environment\",\n\n config() {\n return {\n environments: {\n oxcontent_ssr: createSvelteMarkdownEnvironment(\"ssr\", resolved),\n oxcontent_client: createSvelteMarkdownEnvironment(\"client\", resolved),\n },\n };\n },\n\n resolveId(id) {\n if (id === \"virtual:ox-content-svelte/runtime\") {\n return \"\\0virtual:ox-content-svelte/runtime\";\n }\n if (id === \"virtual:ox-content-svelte/components\") {\n return \"\\0virtual:ox-content-svelte/components\";\n }\n return null;\n },\n\n load(id) {\n if (id === \"\\0virtual:ox-content-svelte/runtime\") {\n return generateRuntimeModule();\n }\n if (id === \"\\0virtual:ox-content-svelte/components\") {\n return generateComponentsModule(componentMap);\n }\n return null;\n },\n\n applyToEnvironment(environment) {\n return [\"oxcontent_ssr\", \"oxcontent_client\", \"client\", \"ssr\"].includes(environment.name);\n },\n };\n\n const svelteHmrPlugin: Plugin = {\n name: \"ox-content:svelte-hmr\",\n apply: \"serve\",\n\n handleHotUpdate({ file, server, modules }) {\n const isComponent = Array.from(componentMap.values()).some((path) =>\n file.endsWith(path.replace(/^\\.\\//, \"\")),\n );\n\n if (isComponent) {\n const mdModules = Array.from(server.moduleGraph.idToModuleMap.values()).filter(\n (mod) => mod.file && isMarkdownFilePath(mod.file, resolved.extensions),\n );\n\n if (mdModules.length > 0) {\n server.ws.send({\n type: \"custom\",\n event: \"ox-content:svelte-update\",\n data: { file },\n });\n return [...modules, ...mdModules];\n }\n }\n\n return modules;\n },\n };\n\n const basePlugins = oxContent(options).flatMap((plugin) =>\n Array.isArray(plugin) ? plugin : [plugin],\n ) as Plugin[];\n const environmentPlugin = basePlugins.find((plugin) => plugin.name === \"ox-content:environment\");\n const plugins: Plugin[] = [svelteTransformPlugin, svelteEnvironmentPlugin, svelteHmrPlugin];\n\n if (environmentPlugin) {\n plugins.push(environmentPlugin);\n }\n\n return plugins;\n}\n\nfunction resolveSvelteOptions(\n options: SvelteIntegrationOptions,\n): Omit<ResolvedSvelteOptions, \"components\"> {\n return {\n srcDir: options.srcDir ?? \"docs\",\n outDir: options.outDir ?? \"dist\",\n base: options.base ?? \"/\",\n extensions: normalizeMarkdownExtensions(options.extensions),\n gfm: options.gfm ?? true,\n autolinks: options.autolinks ?? options.gfm ?? true,\n frontmatter: options.frontmatter ?? true,\n toc: options.toc ?? true,\n tocMaxDepth: options.tocMaxDepth ?? 3,\n codeAnnotations: resolveCodeAnnotationsOptions(options.codeAnnotations),\n runes: options.runes ?? true,\n embeds: resolveBuiltinEmbedOptions(options.embeds),\n mdx: options.mdx,\n };\n}\n\nfunction resolveCodeAnnotationsOptions(\n options: SvelteIntegrationOptions[\"codeAnnotations\"],\n): ResolvedSvelteOptions[\"codeAnnotations\"] {\n if (!options) {\n return {\n enabled: false,\n metaKey: \"annotate\",\n };\n }\n\n if (options === true) {\n return {\n enabled: true,\n metaKey: \"annotate\",\n };\n }\n\n return {\n enabled: true,\n metaKey: options.metaKey ?? \"annotate\",\n };\n}\n\nfunction generateRuntimeModule(): string {\n return `\n// Svelte 5 runtime for ox-content\nexport { mount, unmount } from 'svelte';\n`;\n}\n\nfunction generateComponentsModule(componentMap: Map<string, string>): string {\n const imports: string[] = [];\n const exports: string[] = [];\n\n componentMap.forEach((path, name) => {\n imports.push(`import ${name} from '${path}';`);\n exports.push(` ${name},`);\n });\n\n return `\n${imports.join(\"\\n\")}\n\nexport const components = {\n${exports.join(\"\\n\")}\n};\n\nexport default components;\n`;\n}\n\nasync function resolveComponentsGlob(\n componentsOption: ComponentsOption,\n root: string,\n): Promise<ComponentsMap> {\n if (typeof componentsOption === \"object\" && !Array.isArray(componentsOption)) {\n return componentsOption;\n }\n\n const patterns = Array.isArray(componentsOption) ? componentsOption : [componentsOption];\n\n const result: ComponentsMap = {};\n\n for (const pattern of patterns) {\n const files = await globFiles(pattern, root);\n\n for (const file of files) {\n const baseName = path.basename(file, path.extname(file));\n const componentName = toPascalCase(baseName);\n const relativePath = \"./\" + path.relative(root, file).replace(/\\\\/g, \"/\");\n\n result[componentName] = relativePath;\n }\n }\n\n return result;\n}\n\nasync function globFiles(pattern: string, root: string): Promise<string[]> {\n const files: string[] = [];\n const isGlob = pattern.includes(\"*\");\n\n if (!isGlob) {\n const fullPath = path.resolve(root, pattern);\n if (fs.existsSync(fullPath)) {\n files.push(fullPath);\n }\n return files;\n }\n\n const parts = pattern.split(\"*\");\n const baseDir = path.resolve(root, parts[0]);\n const ext = parts[1] || \"\";\n\n if (!fs.existsSync(baseDir)) {\n return files;\n }\n\n if (pattern.includes(\"**\")) {\n await walkDir(baseDir, files, ext);\n } else {\n const entries = await fs.promises.readdir(baseDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isFile() && entry.name.endsWith(ext)) {\n files.push(path.join(baseDir, entry.name));\n }\n }\n }\n\n return files;\n}\n\nasync function walkDir(dir: string, files: string[], ext: string): Promise<void> {\n const entries = await fs.promises.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n if (entry.isDirectory()) {\n await walkDir(fullPath, files, ext);\n } else if (entry.isFile() && entry.name.endsWith(ext)) {\n files.push(fullPath);\n }\n }\n}\n\nfunction toPascalCase(str: string): string {\n return str.replace(/[-_](\\w)/g, (_, c) => c.toUpperCase()).replace(/^\\w/, (c) => c.toUpperCase());\n}\n\nexport { oxContent } from \"@ox-content/vite-plugin\";\n"],"mappings":";;;;;AAiBA,MAAM,kBAAkB;AACxB,MAAM,aAAa;AAEnB,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAO7B,eAAsB,4BACpB,MACA,IACA,SACgC;CAChC,MAAM,aAA4B,QAAQ;CAC1C,MAAM,EAAE,SAAS,iBAAiB,gBAAgB,mBAAmB,IAAI;CACzE,MAAM,MAAM,sBAAsB,IAAI,QAAQ,GAAG;CAEjD,MAAM,cAAc;EAClB,QAAQ,QAAQ;EAChB,QAAQ,QAAQ;EAChB,MAAM,QAAQ;EACd,YAAY,QAAQ;EACpB;EACA,KAAK;GACH,SAAS;GACT,WAAW;GACX,OAAO;GACP,MAAM;GACN,iBAAiB;GACjB,aAAa;GACb,YAAY;GACZ,aAAa;GACb,QAAQ;GACR,cAAc;GACd,gBAAgB;GAChB,MAAM;GACN,YAAY;EACd;EACA,KAAK,QAAQ;EACb,aAAa;EACb,KAAK,QAAQ;EACb,aAAa,QAAQ;EACrB,iBAAiB,QAAQ;EACzB,WAAW;EACX,QAAQ;EACR,WAAW;EACX,eAAe;EACf,WAAW,QAAQ;EACnB,WAAW;EACX,SAAS;EACT,SAAS;EACT,gBAAgB;GACd,WAAW;GACX,OAAO;GACP,QAAQ;GACR,OAAO;GACP,aAAa;EACf;EACA,cAAc,CAAC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;CAEvB;AACF;AAEA,SAAS,aAAa,KAAqB;CACzC,OAAO,IAAI,QAAQ,cAAc,GAAG,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ,QAAQ,MAAM,EAAE,YAAY,CAAC;AAClG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ox-content/vite-plugin-svelte",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
4
|
"description": "Svelte integration for Ox Content - Embed Svelte components in Markdown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"provenance": true
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@ox-content/islands": "3.0.0-alpha.
|
|
38
|
-
"@ox-content/vite-plugin": "3.0.0-alpha.
|
|
37
|
+
"@ox-content/islands": "3.0.0-alpha.3",
|
|
38
|
+
"@ox-content/vite-plugin": "3.0.0-alpha.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|