@void/md 0.21.1 → 0.21.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.
Files changed (2) hide show
  1. package/dist/plugin.mjs +12 -11
  2. package/package.json +3 -3
package/dist/plugin.mjs CHANGED
@@ -4,6 +4,7 @@ import { dirname, join, relative, resolve } from "pathslash";
4
4
  import { glob } from "tinyglobby";
5
5
  import { normalizePath } from "vite";
6
6
  import { resolvePagesDir } from "void/pages";
7
+ import { editIslandSource, findIslandImports } from "void/pages-islands-plugin";
7
8
  import matter from "gray-matter";
8
9
  import MarkdownExit from "markdown-exit";
9
10
  import anchor from "markdown-it-anchor";
@@ -397,8 +398,6 @@ export default defineComponent({
397
398
  //#endregion
398
399
  //#region src/extract-script.ts
399
400
  const SCRIPT_RE = /^<script\b[^>]*>([\s\S]*?)<\/script>\s*\n?/;
400
- const ISLAND_IMPORT_RE = /import\s+([$_A-Za-z][$_\w]*)\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*,?\s*\}/g;
401
- const ISLAND_IMPORT_LINE_RE = /^[ \t]*import\s+[$_A-Za-z][$_\w]*\s+from\s+(?:"[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*(?:"[^"]+"|'[^']+')\s*,?\s*\}\s*;?\s*$/gm;
402
401
  function extractScript(source) {
403
402
  const match = source.match(SCRIPT_RE);
404
403
  if (!match) return {
@@ -409,18 +408,20 @@ function extractScript(source) {
409
408
  };
410
409
  const script = match[1].trim();
411
410
  const body = source.slice(match[0].length);
412
- const islandImports = [];
413
- let importMatch;
414
- while ((importMatch = ISLAND_IMPORT_RE.exec(script)) !== null) islandImports.push({
415
- name: importMatch[1],
416
- specifier: importMatch[2].slice(1, -1),
417
- strategy: importMatch[3].slice(1, -1)
418
- });
411
+ const imports = findIslandImports(script, "page.md-script.ts");
419
412
  return {
420
413
  script,
421
414
  body,
422
- islandImports,
423
- clientCode: script.replace(ISLAND_IMPORT_LINE_RE, "").trim() || null
415
+ islandImports: imports.map((entry) => ({
416
+ name: entry.importName,
417
+ specifier: entry.specifier,
418
+ strategy: entry.hydrate
419
+ })),
420
+ clientCode: (imports.length > 0 ? editIslandSource(script, imports.map((entry) => ({
421
+ start: entry.start,
422
+ end: entry.end,
423
+ text: ""
424
+ }))).code.trim() : script) || null
424
425
  };
425
426
  }
426
427
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@void/md",
3
- "version": "0.21.1",
3
+ "version": "0.21.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/voidzero-dev/void.git",
@@ -47,12 +47,12 @@
47
47
  "@types/node": "^26.5.1",
48
48
  "vite": "npm:@voidzero-dev/vite-plus-core@0.3.1",
49
49
  "vite-plus": "0.3.1",
50
- "void": "0.21.1",
50
+ "void": "0.21.3",
51
51
  "vue": "^3.5.42"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "vite": "^8.0.0",
55
- "void": "0.21.1"
55
+ "void": "0.21.3"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "vp pack",