@absolutejs/absolute 0.19.0-beta.930 → 0.19.0-beta.931

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.
@@ -1713,100 +1713,6 @@ var init_svelteServerModule = __esm(() => {
1713
1713
  });
1714
1714
  });
1715
1715
 
1716
- // src/core/vueServerModule.ts
1717
- import { mkdir as mkdir2 } from "fs/promises";
1718
- import { dirname as dirname3, join as join5, relative as relative3, resolve as resolve5 } from "path";
1719
- var {Transpiler } = globalThis.Bun;
1720
- var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, transpiler2, ensureRelativeImportPath2 = (from, target) => {
1721
- const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
1722
- return importPath.startsWith(".") ? importPath : `./${importPath}`;
1723
- }, getCachedModulePath2 = (sourcePath) => {
1724
- const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
1725
- const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
1726
- return join5(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
1727
- }, writeIfChanged2 = async (path, content) => {
1728
- const targetFile = Bun.file(path);
1729
- if (await targetFile.exists()) {
1730
- const currentContent = await targetFile.text();
1731
- if (currentContent === content)
1732
- return;
1733
- }
1734
- await Bun.write(path, content);
1735
- }, stripExports = (code) => code.replace(/export\s+default/, "const script ="), mergeVueImports = (code) => {
1736
- const lines = code.split(`
1737
- `);
1738
- const specifierSet = new Set;
1739
- const vueImportRegex = /^import\s+{([^}]+)}\s+from\s+['"]vue['"];?$/;
1740
- lines.forEach((line) => {
1741
- const match = line.match(vueImportRegex);
1742
- if (match?.[1])
1743
- match[1].split(",").forEach((importSpecifier) => specifierSet.add(importSpecifier.trim()));
1744
- });
1745
- const nonVueLines = lines.filter((line) => !vueImportRegex.test(line));
1746
- return specifierSet.size ? [
1747
- `import { ${[...specifierSet].join(", ")} } from "vue";`,
1748
- ...nonVueLines
1749
- ].join(`
1750
- `) : nonVueLines.join(`
1751
- `);
1752
- }, extractRelativeVueImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => typeof importPath === "string" && importPath.startsWith(".") && importPath.endsWith(".vue")), compileVueServerModule = async (sourcePath) => {
1753
- const cachedModulePath = compiledModuleCache2.get(sourcePath);
1754
- if (cachedModulePath)
1755
- return cachedModulePath;
1756
- const compiler = await import("@vue/compiler-sfc");
1757
- const source = await Bun.file(sourcePath).text();
1758
- const { descriptor } = compiler.parse(source, { filename: sourcePath });
1759
- const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
1760
- const hasScript = descriptor.script || descriptor.scriptSetup;
1761
- const compiledScript = hasScript ? compiler.compileScript(descriptor, {
1762
- id: componentId,
1763
- inlineTemplate: false
1764
- }) : { bindings: {}, content: "export default {};" };
1765
- const renderCode = descriptor.template ? compiler.compileTemplate({
1766
- compilerOptions: {
1767
- bindingMetadata: compiledScript.bindings,
1768
- expressionPlugins: ["typescript"],
1769
- prefixIdentifiers: true,
1770
- isCustomElement: (tag) => tag === "absolute-island"
1771
- },
1772
- filename: sourcePath,
1773
- id: componentId,
1774
- scoped: descriptor.styles.some((styleBlock) => styleBlock.scoped),
1775
- source: descriptor.template.content,
1776
- ssr: true,
1777
- ssrCssVars: descriptor.cssVars
1778
- }).code : "const ssrRender = () => {};";
1779
- const childImportPaths = extractRelativeVueImports(compiledScript.content);
1780
- const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
1781
- compiledPath: await compileVueServerModule(resolve5(dirname3(sourcePath), relativeImport)),
1782
- spec: relativeImport
1783
- })));
1784
- const strippedScript = stripExports(compiledScript.content);
1785
- const transpiledScript = transpiler2.transformSync(strippedScript);
1786
- const assembled = mergeVueImports([
1787
- transpiledScript,
1788
- renderCode,
1789
- "script.ssrRender = ssrRender;",
1790
- "export default script;"
1791
- ].join(`
1792
- `));
1793
- const compiledModulePath = getCachedModulePath2(sourcePath);
1794
- let rewritten = assembled;
1795
- for (const child of compiledChildren) {
1796
- rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
1797
- }
1798
- await mkdir2(dirname3(compiledModulePath), { recursive: true });
1799
- await writeIfChanged2(compiledModulePath, rewritten);
1800
- compiledModuleCache2.set(sourcePath, compiledModulePath);
1801
- return compiledModulePath;
1802
- };
1803
- var init_vueServerModule = __esm(() => {
1804
- init_constants();
1805
- serverCacheRoot2 = join5(process.cwd(), ".absolutejs", "islands", "vue");
1806
- compiledModuleCache2 = new Map;
1807
- transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
1808
- });
1809
-
1810
1716
  // src/core/islandMarkupAttributes.ts
1811
1717
  var getIslandMarkerAttributes = (props, islandId) => ({
1812
1718
  "data-component": props.component,
@@ -1842,17 +1748,9 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
1842
1748
  const loadPromise = loadAndCompileServerBuildComponent(buildReferencePath);
1843
1749
  resolvedServerBuildComponentCache.set(buildReferencePath, loadPromise);
1844
1750
  return loadPromise;
1845
- }, resolveRuntimeImportTarget = async (resolvedModulePath) => {
1846
- if (resolvedModulePath.endsWith(".svelte")) {
1847
- return compileSvelteServerModule(resolvedModulePath);
1848
- }
1849
- if (resolvedModulePath.endsWith(".vue")) {
1850
- return compileVueServerModule(resolvedModulePath);
1851
- }
1852
- return resolvedModulePath;
1853
1751
  }, loadServerImportComponent = async (resolvedComponent, exportName) => {
1854
1752
  const resolvedModulePath = resolvedComponent.startsWith(".") ? new URL(resolvedComponent, import.meta.url).pathname : resolvedComponent;
1855
- const importTarget = await resolveRuntimeImportTarget(resolvedModulePath);
1753
+ const importTarget = resolvedModulePath.endsWith(".svelte") ? await compileSvelteServerModule(resolvedModulePath) : resolvedModulePath;
1856
1754
  const loadedModule = await import(importTarget);
1857
1755
  if (exportName && exportName !== "default" && exportName in loadedModule) {
1858
1756
  return loadedModule[exportName];
@@ -1956,7 +1854,6 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
1956
1854
  var init_renderIslandMarkup = __esm(() => {
1957
1855
  init_islandSsr();
1958
1856
  init_svelteServerModule();
1959
- init_vueServerModule();
1960
1857
  init_islandMarkupAttributes();
1961
1858
  init_islands();
1962
1859
  resolvedServerComponentCache = new Map;
@@ -2085,5 +1982,5 @@ export {
2085
1982
  createIslandStore
2086
1983
  };
2087
1984
 
2088
- //# debugId=50CD3E7F3547894F64756E2164756E21
1985
+ //# debugId=F7EEE59A12B7B0C464756E2164756E21
2089
1986
  //# sourceMappingURL=index.js.map