@ox-content/vite-plugin-svelte 1.0.0-alpha.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,5 @@
1
- //#region rolldown:runtime
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -6,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
9
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
19
16
  }
20
17
  return to;
21
18
  };
@@ -23,15 +20,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
20
  value: mod,
24
21
  enumerable: true
25
22
  }) : target, mod));
26
-
27
23
  //#endregion
28
24
  let fs = require("fs");
29
25
  fs = __toESM(fs);
30
- let path$1 = require("path");
31
- path$1 = __toESM(path$1);
26
+ let path = require("path");
27
+ path = __toESM(path);
32
28
  let _ox_content_vite_plugin = require("@ox-content/vite-plugin");
33
29
  let svelte_compiler = require("svelte/compiler");
34
-
35
30
  //#region src/transform.ts
36
31
  const COMPONENT_REGEX = /<([A-Z][a-zA-Z0-9]*)\s*([^>]*?)\s*(?:\/>|>([\s\S]*?)<\/\1>)/g;
37
32
  const PROP_REGEX = /([a-zA-Z0-9-]+)(?:=(?:"([^"]*)"|'([^']*)'|{([^}]*)}|\[([^\]]*)\]))?/g;
@@ -72,50 +67,52 @@ async function transformMarkdownWithSvelte(code, id, options) {
72
67
  lastIndex = matchEnd;
73
68
  }
74
69
  processedContent += markdownContent.slice(lastIndex);
70
+ const baseOptions = {
71
+ srcDir: options.srcDir,
72
+ outDir: options.outDir,
73
+ base: options.base,
74
+ ssg: {
75
+ enabled: false,
76
+ extension: ".html",
77
+ clean: false,
78
+ bare: false,
79
+ generateOgImage: false
80
+ },
81
+ gfm: options.gfm,
82
+ frontmatter: false,
83
+ toc: options.toc,
84
+ tocMaxDepth: options.tocMaxDepth,
85
+ codeAnnotations: options.codeAnnotations,
86
+ footnotes: true,
87
+ tables: true,
88
+ taskLists: true,
89
+ strikethrough: true,
90
+ highlight: false,
91
+ highlightTheme: "github-dark",
92
+ highlightLangs: [],
93
+ mermaid: false,
94
+ ogImage: false,
95
+ ogImageOptions: {
96
+ vuePlugin: "vitejs",
97
+ width: 1200,
98
+ height: 630,
99
+ cache: true,
100
+ concurrency: 1
101
+ },
102
+ transformers: [],
103
+ docs: false,
104
+ ogViewer: false,
105
+ search: {
106
+ enabled: false,
107
+ limit: 10,
108
+ prefix: true,
109
+ placeholder: "Search...",
110
+ hotkey: "k"
111
+ },
112
+ i18n: false
113
+ };
75
114
  return {
76
- code: `${(0, svelte_compiler.compile)(generateSvelteModule(injectIslandMarkers((await (0, _ox_content_vite_plugin.transformMarkdown)(processedContent, id, {
77
- srcDir: options.srcDir,
78
- outDir: options.outDir,
79
- base: options.base,
80
- ssg: {
81
- enabled: false,
82
- extension: ".html",
83
- clean: false,
84
- bare: false,
85
- generateOgImage: false
86
- },
87
- gfm: options.gfm,
88
- frontmatter: false,
89
- toc: options.toc,
90
- tocMaxDepth: options.tocMaxDepth,
91
- footnotes: true,
92
- tables: true,
93
- taskLists: true,
94
- strikethrough: true,
95
- highlight: false,
96
- highlightTheme: "github-dark",
97
- highlightLangs: [],
98
- mermaid: false,
99
- ogImage: false,
100
- ogImageOptions: {
101
- vuePlugin: "vitejs",
102
- width: 1200,
103
- height: 630,
104
- cache: true,
105
- concurrency: 1
106
- },
107
- transformers: [],
108
- docs: false,
109
- ogViewer: false,
110
- search: {
111
- enabled: false,
112
- limit: 10,
113
- prefix: true,
114
- placeholder: "Search...",
115
- hotkey: "k"
116
- },
117
- i18n: false
118
- })).html, islands), usedComponents, islands, frontmatter, options, id), {
115
+ code: `${(0, svelte_compiler.compile)(generateSvelteModule(injectIslandMarkers((await (0, _ox_content_vite_plugin.transformMarkdown)(processedContent, id, baseOptions)).html, islands), usedComponents, islands, frontmatter, options, id), {
119
116
  filename: id,
120
117
  generate: "client",
121
118
  runes: true
@@ -230,13 +227,13 @@ function parseProps(propsString) {
230
227
  return props;
231
228
  }
232
229
  function generateSvelteModule(content, usedComponents, islands, frontmatter, options, id) {
233
- const mdDir = path$1.dirname(id);
230
+ const mdDir = path.dirname(id);
234
231
  const root = options.root || process.cwd();
235
232
  const imports = usedComponents.map((name) => {
236
233
  const componentPath = options.components[name];
237
234
  if (!componentPath) return "";
238
- const absolutePath = path$1.resolve(root, componentPath.replace(/^\.\//, ""));
239
- const relativePath = path$1.relative(mdDir, absolutePath).replace(/\\/g, "/");
235
+ const absolutePath = path.resolve(root, componentPath.replace(/^\.\//, ""));
236
+ const relativePath = path.relative(mdDir, absolutePath).replace(/\\/g, "/");
240
237
  return `import ${name} from '${relativePath.startsWith(".") ? relativePath : "./" + relativePath}';`;
241
238
  }).filter(Boolean).join("\n");
242
239
  if (islands.length === 0) return `
@@ -317,7 +314,6 @@ ${componentMap}
317
314
  </style>
318
315
  `;
319
316
  }
320
-
321
317
  //#endregion
322
318
  //#region src/environment.ts
323
319
  function createSvelteMarkdownEnvironment(mode, options) {
@@ -342,7 +338,6 @@ function createSvelteMarkdownEnvironment(mode, options) {
342
338
  }
343
339
  };
344
340
  }
345
-
346
341
  //#endregion
347
342
  //#region src/index.ts
348
343
  /**
@@ -433,7 +428,7 @@ function oxContentSvelte(options = {}) {
433
428
  name: "ox-content:svelte-hmr",
434
429
  apply: "serve",
435
430
  handleHotUpdate({ file, server, modules }) {
436
- if (Array.from(componentMap.values()).some((path) => file.endsWith(path.replace(/^\.\//, "")))) {
431
+ if (Array.from(componentMap.values()).some((path$1) => file.endsWith(path$1.replace(/^\.\//, "")))) {
437
432
  const mdModules = Array.from(server.moduleGraph.idToModuleMap.values()).filter((mod) => mod.file?.endsWith(".md"));
438
433
  if (mdModules.length > 0) {
439
434
  server.ws.send({
@@ -447,13 +442,14 @@ function oxContentSvelte(options = {}) {
447
442
  return modules;
448
443
  }
449
444
  };
450
- const environmentPlugin = (0, _ox_content_vite_plugin.oxContent)(options).find((p) => p.name === "ox-content:environment");
451
- return [
445
+ const environmentPlugin = (0, _ox_content_vite_plugin.oxContent)(options).flatMap((plugin) => Array.isArray(plugin) ? plugin : [plugin]).find((plugin) => plugin.name === "ox-content:environment");
446
+ const plugins = [
452
447
  svelteTransformPlugin,
453
448
  svelteEnvironmentPlugin,
454
- svelteHmrPlugin,
455
- ...environmentPlugin ? [environmentPlugin] : []
449
+ svelteHmrPlugin
456
450
  ];
451
+ if (environmentPlugin) plugins.push(environmentPlugin);
452
+ return plugins;
457
453
  }
458
454
  function resolveSvelteOptions(options) {
459
455
  return {
@@ -464,9 +460,24 @@ function resolveSvelteOptions(options) {
464
460
  frontmatter: options.frontmatter ?? true,
465
461
  toc: options.toc ?? true,
466
462
  tocMaxDepth: options.tocMaxDepth ?? 3,
463
+ codeAnnotations: resolveCodeAnnotationsOptions(options.codeAnnotations),
467
464
  runes: options.runes ?? true
468
465
  };
469
466
  }
467
+ function resolveCodeAnnotationsOptions(options) {
468
+ if (!options) return {
469
+ enabled: false,
470
+ metaKey: "annotate"
471
+ };
472
+ if (options === true) return {
473
+ enabled: true,
474
+ metaKey: "annotate"
475
+ };
476
+ return {
477
+ enabled: true,
478
+ metaKey: options.metaKey ?? "annotate"
479
+ };
480
+ }
470
481
  function generateRuntimeModule() {
471
482
  return `
472
483
  // Svelte 5 runtime for ox-content
@@ -476,8 +487,8 @@ export { mount, unmount } from 'svelte';
476
487
  function generateComponentsModule(componentMap) {
477
488
  const imports = [];
478
489
  const exports = [];
479
- componentMap.forEach((path, name) => {
480
- imports.push(`import ${name} from '${path}';`);
490
+ componentMap.forEach((path$2, name) => {
491
+ imports.push(`import ${name} from '${path$2}';`);
481
492
  exports.push(` ${name},`);
482
493
  });
483
494
  return `
@@ -497,8 +508,8 @@ async function resolveComponentsGlob(componentsOption, root) {
497
508
  for (const pattern of patterns) {
498
509
  const files = await globFiles(pattern, root);
499
510
  for (const file of files) {
500
- const componentName = toPascalCase(path$1.basename(file, path$1.extname(file)));
501
- result[componentName] = "./" + path$1.relative(root, file).replace(/\\/g, "/");
511
+ const componentName = toPascalCase(path.basename(file, path.extname(file)));
512
+ result[componentName] = "./" + path.relative(root, file).replace(/\\/g, "/");
502
513
  }
503
514
  }
504
515
  return result;
@@ -506,25 +517,25 @@ async function resolveComponentsGlob(componentsOption, root) {
506
517
  async function globFiles(pattern, root) {
507
518
  const files = [];
508
519
  if (!pattern.includes("*")) {
509
- const fullPath = path$1.resolve(root, pattern);
520
+ const fullPath = path.resolve(root, pattern);
510
521
  if (fs.existsSync(fullPath)) files.push(fullPath);
511
522
  return files;
512
523
  }
513
524
  const parts = pattern.split("*");
514
- const baseDir = path$1.resolve(root, parts[0]);
525
+ const baseDir = path.resolve(root, parts[0]);
515
526
  const ext = parts[1] || "";
516
527
  if (!fs.existsSync(baseDir)) return files;
517
528
  if (pattern.includes("**")) await walkDir(baseDir, files, ext);
518
529
  else {
519
530
  const entries = await fs.promises.readdir(baseDir, { withFileTypes: true });
520
- for (const entry of entries) if (entry.isFile() && entry.name.endsWith(ext)) files.push(path$1.join(baseDir, entry.name));
531
+ for (const entry of entries) if (entry.isFile() && entry.name.endsWith(ext)) files.push(path.join(baseDir, entry.name));
521
532
  }
522
533
  return files;
523
534
  }
524
535
  async function walkDir(dir, files, ext) {
525
536
  const entries = await fs.promises.readdir(dir, { withFileTypes: true });
526
537
  for (const entry of entries) {
527
- const fullPath = path$1.join(dir, entry.name);
538
+ const fullPath = path.join(dir, entry.name);
528
539
  if (entry.isDirectory()) await walkDir(fullPath, files, ext);
529
540
  else if (entry.isFile() && entry.name.endsWith(ext)) files.push(fullPath);
530
541
  }
@@ -532,12 +543,11 @@ async function walkDir(dir, files, ext) {
532
543
  function toPascalCase(str) {
533
544
  return str.replace(/[-_](\w)/g, (_, c) => c.toUpperCase()).replace(/^\w/, (c) => c.toUpperCase());
534
545
  }
535
-
536
546
  //#endregion
537
- Object.defineProperty(exports, 'oxContent', {
538
- enumerable: true,
539
- get: function () {
540
- return _ox_content_vite_plugin.oxContent;
541
- }
547
+ Object.defineProperty(exports, "oxContent", {
548
+ enumerable: true,
549
+ get: function() {
550
+ return _ox_content_vite_plugin.oxContent;
551
+ }
542
552
  });
543
- exports.oxContentSvelte = oxContentSvelte;
553
+ exports.oxContentSvelte = oxContentSvelte;
package/dist/index.d.cts CHANGED
@@ -2,6 +2,13 @@ import { PluginOption } from "vite";
2
2
  import { OxContentOptions, oxContent } from "@ox-content/vite-plugin";
3
3
 
4
4
  //#region src/types.d.ts
5
+ interface CodeAnnotationsOptions {
6
+ metaKey?: string;
7
+ }
8
+ interface ResolvedCodeAnnotationsOptions {
9
+ enabled: boolean;
10
+ metaKey: string;
11
+ }
5
12
  type ComponentsMap = Record<string, string>;
6
13
  /**
7
14
  * Component registration options.
@@ -24,6 +31,7 @@ interface SvelteIntegrationOptions extends OxContentOptions {
24
31
  * ```
25
32
  */
26
33
  components?: ComponentsOption;
34
+ codeAnnotations?: boolean | CodeAnnotationsOptions;
27
35
  runes?: boolean;
28
36
  }
29
37
  interface ResolvedSvelteOptions {
@@ -34,6 +42,7 @@ interface ResolvedSvelteOptions {
34
42
  frontmatter: boolean;
35
43
  toc: boolean;
36
44
  tocMaxDepth: number;
45
+ codeAnnotations: ResolvedCodeAnnotationsOptions;
37
46
  components: ComponentsMap;
38
47
  runes: boolean;
39
48
  root?: string;
@@ -51,7 +60,6 @@ interface ComponentIsland {
51
60
  id: string;
52
61
  content?: string;
53
62
  }
54
- //# sourceMappingURL=types.d.ts.map
55
63
  //#endregion
56
64
  //#region src/index.d.ts
57
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;KAEY,aAAA,GAAgB;;;AAA5B;AAMA;AAEiB,KAFL,gBAAA,GAAmB,aAEW,GAAA,MAAA,GAAA,MAAA,EAAA;AAAA,UAAzB,wBAAA,SAAiC,gBAAR,CAAA;;;;AAmB1C;AAaA;AAOA;;;;ACEA;;;;;eD1Be;;;UAIE,qBAAA;;;;;;;;cAQH;;;;UAKG,qBAAA;;;;eAIF;;UAGE,eAAA;;SAER;;;;;;;;;;;AAtBT;AAaA;AAOA;;;;ACEA;;;;;;;;;;;;;;iBAAgB,eAAA,WAAyB,2BAAgC"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/index.ts"],"mappings":";;;;UAEiB,sBAAA;EACf,OAAA;AAAA;AAAA,UAGe,8BAAA;EACf,OAAA;EACA,OAAA;AAAA;AAAA,KAGU,aAAA,GAAgB,MAAA;AAL5B;;;;AAAA,KAWY,gBAAA,GAAmB,aAAA;AAAA,UAEd,wBAAA,SAAiC,gBAAA;EARzB;;;;AAMzB;;;;;AAEA;;;;;EAeE,UAAA,GAAa,gBAAA;EACb,eAAA,aAA4B,sBAAA;EAC5B,KAAA;AAAA;AAAA,UAGe,qBAAA;EACf,MAAA;EACA,MAAA;EACA,IAAA;EACA,GAAA;EACA,WAAA;EACA,GAAA;EACA,WAAA;EACA,eAAA,EAAiB,8BAAA;EACjB,UAAA,EAAY,aAAA;EACZ,KAAA;EACA,IAAA;AAAA;AAAA,UAGe,qBAAA;EACf,IAAA;EACA,GAAA;EACA,cAAA;EACA,WAAA,EAAa,MAAA;AAAA;AAAA,UAGE,eAAA;EACf,IAAA;EACA,KAAA,EAAO,MAAA;EACP,QAAA;EACA,EAAA;EACA,OAAA;AAAA;;;;AA3DF;;;;;AAKA;;;;;AAMA;;;;;AAEA;;;;;;;iBCgCgB,eAAA,CAAgB,OAAA,GAAS,wBAAA,GAAgC,YAAA"}
@@ -2,6 +2,13 @@ import { OxContentOptions, oxContent } from "@ox-content/vite-plugin";
2
2
  import { PluginOption } from "vite";
3
3
 
4
4
  //#region src/types.d.ts
5
+ interface CodeAnnotationsOptions {
6
+ metaKey?: string;
7
+ }
8
+ interface ResolvedCodeAnnotationsOptions {
9
+ enabled: boolean;
10
+ metaKey: string;
11
+ }
5
12
  type ComponentsMap = Record<string, string>;
6
13
  /**
7
14
  * Component registration options.
@@ -24,6 +31,7 @@ interface SvelteIntegrationOptions extends OxContentOptions {
24
31
  * ```
25
32
  */
26
33
  components?: ComponentsOption;
34
+ codeAnnotations?: boolean | CodeAnnotationsOptions;
27
35
  runes?: boolean;
28
36
  }
29
37
  interface ResolvedSvelteOptions {
@@ -34,6 +42,7 @@ interface ResolvedSvelteOptions {
34
42
  frontmatter: boolean;
35
43
  toc: boolean;
36
44
  tocMaxDepth: number;
45
+ codeAnnotations: ResolvedCodeAnnotationsOptions;
37
46
  components: ComponentsMap;
38
47
  runes: boolean;
39
48
  root?: string;
@@ -51,7 +60,6 @@ interface ComponentIsland {
51
60
  id: string;
52
61
  content?: string;
53
62
  }
54
- //# sourceMappingURL=types.d.ts.map
55
63
  //#endregion
56
64
  //#region src/index.d.ts
57
65
  /**
@@ -80,4 +88,4 @@ interface ComponentIsland {
80
88
  declare function oxContentSvelte(options?: SvelteIntegrationOptions): PluginOption[];
81
89
  //#endregion
82
90
  export { type ComponentIsland, type ComponentsMap, type ComponentsOption, type ResolvedSvelteOptions, type SvelteIntegrationOptions, type SvelteTransformResult, oxContent, oxContentSvelte };
83
- //# sourceMappingURL=index.d.ts.map
91
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/index.ts"],"mappings":";;;;UAEiB,sBAAA;EACf,OAAA;AAAA;AAAA,UAGe,8BAAA;EACf,OAAA;EACA,OAAA;AAAA;AAAA,KAGU,aAAA,GAAgB,MAAA;AAL5B;;;;AAAA,KAWY,gBAAA,GAAmB,aAAA;AAAA,UAEd,wBAAA,SAAiC,gBAAA;EARzB;;;;AAMzB;;;;;AAEA;;;;;EAeE,UAAA,GAAa,gBAAA;EACb,eAAA,aAA4B,sBAAA;EAC5B,KAAA;AAAA;AAAA,UAGe,qBAAA;EACf,MAAA;EACA,MAAA;EACA,IAAA;EACA,GAAA;EACA,WAAA;EACA,GAAA;EACA,WAAA;EACA,eAAA,EAAiB,8BAAA;EACjB,UAAA,EAAY,aAAA;EACZ,KAAA;EACA,IAAA;AAAA;AAAA,UAGe,qBAAA;EACf,IAAA;EACA,GAAA;EACA,cAAA;EACA,WAAA,EAAa,MAAA;AAAA;AAAA,UAGE,eAAA;EACf,IAAA;EACA,KAAA,EAAO,MAAA;EACP,QAAA;EACA,EAAA;EACA,OAAA;AAAA;;;;AA3DF;;;;;AAKA;;;;;AAMA;;;;;AAEA;;;;;;;iBCgCgB,eAAA,CAAgB,OAAA,GAAS,wBAAA,GAAgC,YAAA"}
@@ -2,7 +2,6 @@ import * as fs from "fs";
2
2
  import * as path from "path";
3
3
  import { oxContent, oxContent as oxContent$1, transformMarkdown } from "@ox-content/vite-plugin";
4
4
  import { compile } from "svelte/compiler";
5
-
6
5
  //#region src/transform.ts
7
6
  const COMPONENT_REGEX = /<([A-Z][a-zA-Z0-9]*)\s*([^>]*?)\s*(?:\/>|>([\s\S]*?)<\/\1>)/g;
8
7
  const PROP_REGEX = /([a-zA-Z0-9-]+)(?:=(?:"([^"]*)"|'([^']*)'|{([^}]*)}|\[([^\]]*)\]))?/g;
@@ -43,50 +42,52 @@ async function transformMarkdownWithSvelte(code, id, options) {
43
42
  lastIndex = matchEnd;
44
43
  }
45
44
  processedContent += markdownContent.slice(lastIndex);
45
+ const baseOptions = {
46
+ srcDir: options.srcDir,
47
+ outDir: options.outDir,
48
+ base: options.base,
49
+ ssg: {
50
+ enabled: false,
51
+ extension: ".html",
52
+ clean: false,
53
+ bare: false,
54
+ generateOgImage: false
55
+ },
56
+ gfm: options.gfm,
57
+ frontmatter: false,
58
+ toc: options.toc,
59
+ tocMaxDepth: options.tocMaxDepth,
60
+ codeAnnotations: options.codeAnnotations,
61
+ footnotes: true,
62
+ tables: true,
63
+ taskLists: true,
64
+ strikethrough: true,
65
+ highlight: false,
66
+ highlightTheme: "github-dark",
67
+ highlightLangs: [],
68
+ mermaid: false,
69
+ ogImage: false,
70
+ ogImageOptions: {
71
+ vuePlugin: "vitejs",
72
+ width: 1200,
73
+ height: 630,
74
+ cache: true,
75
+ concurrency: 1
76
+ },
77
+ transformers: [],
78
+ docs: false,
79
+ ogViewer: false,
80
+ search: {
81
+ enabled: false,
82
+ limit: 10,
83
+ prefix: true,
84
+ placeholder: "Search...",
85
+ hotkey: "k"
86
+ },
87
+ i18n: false
88
+ };
46
89
  return {
47
- code: `${compile(generateSvelteModule(injectIslandMarkers((await transformMarkdown(processedContent, id, {
48
- srcDir: options.srcDir,
49
- outDir: options.outDir,
50
- base: options.base,
51
- ssg: {
52
- enabled: false,
53
- extension: ".html",
54
- clean: false,
55
- bare: false,
56
- generateOgImage: false
57
- },
58
- gfm: options.gfm,
59
- frontmatter: false,
60
- toc: options.toc,
61
- tocMaxDepth: options.tocMaxDepth,
62
- footnotes: true,
63
- tables: true,
64
- taskLists: true,
65
- strikethrough: true,
66
- highlight: false,
67
- highlightTheme: "github-dark",
68
- highlightLangs: [],
69
- mermaid: false,
70
- ogImage: false,
71
- ogImageOptions: {
72
- vuePlugin: "vitejs",
73
- width: 1200,
74
- height: 630,
75
- cache: true,
76
- concurrency: 1
77
- },
78
- transformers: [],
79
- docs: false,
80
- ogViewer: false,
81
- search: {
82
- enabled: false,
83
- limit: 10,
84
- prefix: true,
85
- placeholder: "Search...",
86
- hotkey: "k"
87
- },
88
- i18n: false
89
- })).html, islands), usedComponents, islands, frontmatter, options, id), {
90
+ code: `${compile(generateSvelteModule(injectIslandMarkers((await transformMarkdown(processedContent, id, baseOptions)).html, islands), usedComponents, islands, frontmatter, options, id), {
90
91
  filename: id,
91
92
  generate: "client",
92
93
  runes: true
@@ -288,7 +289,6 @@ ${componentMap}
288
289
  </style>
289
290
  `;
290
291
  }
291
-
292
292
  //#endregion
293
293
  //#region src/environment.ts
294
294
  function createSvelteMarkdownEnvironment(mode, options) {
@@ -313,7 +313,6 @@ function createSvelteMarkdownEnvironment(mode, options) {
313
313
  }
314
314
  };
315
315
  }
316
-
317
316
  //#endregion
318
317
  //#region src/index.ts
319
318
  /**
@@ -418,13 +417,14 @@ function oxContentSvelte(options = {}) {
418
417
  return modules;
419
418
  }
420
419
  };
421
- const environmentPlugin = oxContent$1(options).find((p) => p.name === "ox-content:environment");
422
- return [
420
+ const environmentPlugin = oxContent$1(options).flatMap((plugin) => Array.isArray(plugin) ? plugin : [plugin]).find((plugin) => plugin.name === "ox-content:environment");
421
+ const plugins = [
423
422
  svelteTransformPlugin,
424
423
  svelteEnvironmentPlugin,
425
- svelteHmrPlugin,
426
- ...environmentPlugin ? [environmentPlugin] : []
424
+ svelteHmrPlugin
427
425
  ];
426
+ if (environmentPlugin) plugins.push(environmentPlugin);
427
+ return plugins;
428
428
  }
429
429
  function resolveSvelteOptions(options) {
430
430
  return {
@@ -435,9 +435,24 @@ function resolveSvelteOptions(options) {
435
435
  frontmatter: options.frontmatter ?? true,
436
436
  toc: options.toc ?? true,
437
437
  tocMaxDepth: options.tocMaxDepth ?? 3,
438
+ codeAnnotations: resolveCodeAnnotationsOptions(options.codeAnnotations),
438
439
  runes: options.runes ?? true
439
440
  };
440
441
  }
442
+ function resolveCodeAnnotationsOptions(options) {
443
+ if (!options) return {
444
+ enabled: false,
445
+ metaKey: "annotate"
446
+ };
447
+ if (options === true) return {
448
+ enabled: true,
449
+ metaKey: "annotate"
450
+ };
451
+ return {
452
+ enabled: true,
453
+ metaKey: options.metaKey ?? "annotate"
454
+ };
455
+ }
441
456
  function generateRuntimeModule() {
442
457
  return `
443
458
  // Svelte 5 runtime for ox-content
@@ -503,7 +518,7 @@ async function walkDir(dir, files, ext) {
503
518
  function toPascalCase(str) {
504
519
  return str.replace(/[-_](\w)/g, (_, c) => c.toUpperCase()).replace(/^\w/, (c) => c.toUpperCase());
505
520
  }
506
-
507
521
  //#endregion
508
522
  export { oxContent, oxContentSvelte };
509
- //# sourceMappingURL=index.js.map
523
+
524
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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 ssg: {\n enabled: false,\n extension: \".html\",\n clean: false,\n bare: false,\n generateOgImage: 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 highlight: false,\n highlightTheme: \"github-dark\",\n highlightLangs: [],\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 i18n: false,\n } 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, \"&#39;\")}'`\n : \"\";\n const contentAttr = island.content\n ? ` data-ox-content='${island.content.replace(/'/g, \"&#39;\")}'`\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} from \"./types\";\n\nexport type {\n SvelteIntegrationOptions,\n ResolvedSvelteOptions,\n ComponentsOption,\n ComponentsMap,\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 (!id.endsWith(\".md\")) {\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((mod) =>\n mod.file?.endsWith(\".md\"),\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 gfm: 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 };\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,EAAE;CACnC,MAAM,UAA6B,EAAE;CACrC,IAAI,cAAc;CAElB,MAAM,EAAE,SAAS,iBAAiB,gBAAgB,mBAAmB,KAAK;CAC1E,MAAM,cAAc,mBAAmB,gBAAgB;CACvD,IAAI,mBAAmB;CACvB,IAAI,YAAY;CAChB,IAAI;AAEJ,iBAAgB,YAAY;AAC5B,SAAQ,QAAQ,gBAAgB,KAAK,gBAAgB,MAAM,MAAM;EAC/D,MAAM,CAAC,WAAW,eAAe,aAAa,oBAAoB;EAClE,MAAM,aAAa,MAAM;EACzB,MAAM,WAAW,aAAa,UAAU;AAExC,MACE,CAAC,OAAO,UAAU,eAAe,KAAK,YAAY,cAAc,IAChE,WAAW,YAAY,UAAU,YAAY,EAC7C;AACA,uBAAoB,gBAAgB,MAAM,WAAW,SAAS;AAC9D,eAAY;AACZ;;AAGF,MAAI,CAAC,eAAe,SAAS,cAAc,CACzC,gBAAe,KAAK,cAAc;EAGpC,MAAM,QAAQ,WAAW,YAAY;EACrC,MAAM,WAAW,aAAa;EAC9B,MAAM,gBACJ,OAAO,qBA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,MAAM,MAAM,MAAM,MAAM;AAExB,KAAI,CAAC,GAAG,WAAW,QAAQ,CACzB,QAAO;AAGT,KAAI,QAAQ,SAAS,KAAK,CACxB,OAAM,QAAQ,SAAS,OAAO,IAAI;MAC7B;EACL,MAAM,UAAU,MAAM,GAAG,SAAS,QAAQ,SAAS,EAAE,eAAe,MAAM,CAAC;AAC3E,OAAK,MAAM,SAAS,QAClB,KAAI,MAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,IAAI,CAC5C,OAAM,KAAK,KAAK,KAAK,SAAS,MAAM,KAAK,CAAC;;AAKhD,QAAO;;AAGT,eAAe,QAAQ,KAAa,OAAiB,KAA4B;CAC/E,MAAM,UAAU,MAAM,GAAG,SAAS,QAAQ,KAAK,EAAE,eAAe,MAAM,CAAC;AAEvE,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,WAAW,KAAK,KAAK,KAAK,MAAM,KAAK;AAE3C,MAAI,MAAM,aAAa,CACrB,OAAM,QAAQ,UAAU,OAAO,IAAI;WAC1B,MAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,IAAI,CACnD,OAAM,KAAK,SAAS;;;AAK1B,SAAS,aAAa,KAAqB;AACzC,QAAO,IAAI,QAAQ,cAAc,GAAG,MAAM,EAAE,aAAa,CAAC,CAAC,QAAQ,QAAQ,MAAM,EAAE,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,57 +1,58 @@
1
1
  {
2
2
  "name": "@ox-content/vite-plugin-svelte",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.1.0",
4
4
  "description": "Svelte integration for Ox Content - Embed Svelte components in Markdown",
5
+ "keywords": [
6
+ "markdown",
7
+ "ox-content",
8
+ "svelte",
9
+ "vite",
10
+ "vite-plugin"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "ubugeeei",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/ubugeeei/ox-content.git",
17
+ "directory": "npm/vite-plugin-ox-content-svelte"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
5
22
  "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
23
+ "main": "./dist/index.cjs",
24
+ "types": "./dist/index.d.mts",
8
25
  "exports": {
9
26
  ".": {
10
- "import": "./dist/index.js",
11
- "types": "./dist/index.d.ts"
27
+ "import": "./dist/index.mjs",
28
+ "require": "./dist/index.cjs",
29
+ "types": "./dist/index.d.mts"
12
30
  }
13
31
  },
14
- "files": [
15
- "dist"
16
- ],
17
- "peerDependencies": {
18
- "svelte": "^5.46.4",
19
- "vite": "^8.0.0"
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "provenance": true
20
35
  },
21
36
  "dependencies": {
22
- "@ox-content/vite-plugin": "1.0.0-alpha.0",
23
- "@ox-content/islands": "1.0.0-alpha.0"
37
+ "@ox-content/islands": "1.1.0",
38
+ "@ox-content/vite-plugin": "1.1.0"
24
39
  },
25
40
  "devDependencies": {
26
41
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
27
42
  "@types/node": "^22.0.0",
28
- "svelte": "^5.46.4",
29
- "tsdown": "^0.12.0",
30
43
  "@typescript/native-preview": "^7.0.0-dev.20250601",
44
+ "svelte": "^5.46.4",
31
45
  "typescript": "^5.7.0",
32
- "vite": "^8.0.0"
46
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.1.11",
47
+ "vite-plus": "0.1.11"
33
48
  },
34
- "keywords": [
35
- "vite",
36
- "vite-plugin",
37
- "svelte",
38
- "markdown",
39
- "ox-content"
40
- ],
41
- "license": "MIT",
42
- "author": "ubugeeei",
43
- "repository": {
44
- "type": "git",
45
- "url": "https://github.com/ubugeeei/ox-content.git",
46
- "directory": "npm/vite-plugin-ox-content-svelte"
47
- },
48
- "publishConfig": {
49
- "provenance": true,
50
- "access": "public"
49
+ "peerDependencies": {
50
+ "svelte": "^5.46.4",
51
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.1.11"
51
52
  },
52
53
  "scripts": {
53
- "build": "tsdown",
54
- "dev": "tsdown --watch",
54
+ "build": "vp pack",
55
+ "dev": "vp pack --watch",
55
56
  "typecheck": "tsgo --noEmit"
56
57
  }
57
58
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;KAEY,aAAA,GAAgB;;;AAA5B;AAMA;AAEiB,KAFL,gBAAA,GAAmB,aAEW,GAAA,MAAA,GAAA,MAAA,EAAA;AAAA,UAAzB,wBAAA,SAAiC,gBAAR,CAAA;;;;AAmB1C;AAaA;AAOA;;;;ACEA;;;;;eD1Be;;;UAIE,qBAAA;;;;;;;;cAQH;;;;UAKG,qBAAA;;;;eAIF;;UAGE,eAAA;;SAER;;;;;;;;;;;AAtBT;AAaA;AAOA;;;;ACEA;;;;;;;;;;;;;;iBAAgB,eAAA,WAAyB,2BAAgC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","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 transformed = await baseTransformMarkdown(processedContent, id, {\n srcDir: options.srcDir,\n outDir: options.outDir,\n base: options.base,\n ssg: {\n enabled: false,\n extension: \".html\",\n clean: false,\n bare: false,\n generateOgImage: false,\n },\n gfm: options.gfm,\n frontmatter: false,\n toc: options.toc,\n tocMaxDepth: options.tocMaxDepth,\n footnotes: true,\n tables: true,\n taskLists: true,\n strikethrough: true,\n highlight: false,\n highlightTheme: \"github-dark\",\n highlightLangs: [],\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 i18n: false,\n });\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, \"&#39;\")}'`\n : \"\";\n const contentAttr = island.content\n ? ` data-ox-content='${island.content.replace(/'/g, \"&#39;\")}'`\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} from \"./types\";\n\nexport type {\n SvelteIntegrationOptions,\n ResolvedSvelteOptions,\n ComponentsOption,\n ComponentsMap,\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 (!id.endsWith(\".md\")) {\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((mod) =>\n mod.file?.endsWith(\".md\"),\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);\n const environmentPlugin = basePlugins.find((p) => p.name === \"ox-content:environment\");\n\n return [\n svelteTransformPlugin,\n svelteEnvironmentPlugin,\n svelteHmrPlugin,\n ...(environmentPlugin ? [environmentPlugin] : []),\n ];\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 gfm: options.gfm ?? true,\n frontmatter: options.frontmatter ?? true,\n toc: options.toc ?? true,\n tocMaxDepth: options.tocMaxDepth ?? 3,\n runes: options.runes ?? true,\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,iBAA2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