@absolutejs/absolute 0.20.0-beta.178 → 0.20.0-beta.179

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.
@@ -1,11 +1,39 @@
1
1
  import type { FrameworkKey } from '../generate/frameworkKey';
2
- type FrameworkDependencies = {
3
- dependencies: Record<string, string>;
4
- devDependencies: Record<string, string>;
2
+ export declare const SCAFFOLD_VERSIONS: {
3
+ readonly '@absolutejs/scoped-state': "0.3.1";
4
+ readonly '@angular/common': "21.2.24";
5
+ readonly '@angular/compiler': "21.2.24";
6
+ readonly '@angular/compiler-cli': "21.2.24";
7
+ readonly '@angular/core': "21.2.24";
8
+ readonly '@angular/platform-browser': "21.2.24";
9
+ readonly '@angular/platform-server': "21.2.24";
10
+ readonly '@angular/router': "21.2.24";
11
+ readonly '@angular/ssr': "21.2.24";
12
+ readonly '@types/react': "19.3.0";
13
+ readonly react: "19.3.0";
14
+ readonly 'react-dom': "19.3.0";
15
+ readonly 'react-refresh': "0.19.0";
16
+ readonly svelte: "5.57.1";
17
+ readonly 'svelte-check': "4.7.8";
18
+ readonly svelte2tsx: "0.7.63";
19
+ readonly vue: "3.5.43";
20
+ readonly 'vue-router': "4.6.4";
21
+ readonly 'vue-tsc': "3.3.14";
5
22
  };
6
- export declare const FRAMEWORK_DEPENDENCIES: Record<FrameworkKey, FrameworkDependencies>;
7
- export declare const frameworkDependencyNames: (framework: FrameworkKey) => string[];
8
- export declare const installFrameworkDependencies: (cwd: string, framework: FrameworkKey) => {
23
+ type ScaffoldPackage = keyof typeof SCAFFOLD_VERSIONS;
24
+ type FrameworkPackages = {
25
+ dependencies: readonly ScaffoldPackage[];
26
+ devDependencies: readonly ScaffoldPackage[];
27
+ };
28
+ export declare const FRAMEWORK_PACKAGES: Record<FrameworkKey, FrameworkPackages>;
29
+ /** The `bun add` specs `absolute add <framework>` installs, split by section. */
30
+ export declare const plannedFrameworkInstall: (framework: FrameworkKey) => {
31
+ dependencies: string[];
32
+ devDependencies: string[];
33
+ };
34
+ type BunAddRunner = (cwd: string, specs: string[], dev: boolean) => boolean;
35
+ export declare const frameworkDependencyNames: (framework: FrameworkKey) => ("react" | "svelte" | "vue" | "@angular/core" | "@angular/platform-server" | "@angular/platform-browser" | "@angular/common" | "@angular/compiler" | "react-dom" | "@angular/router" | "@angular/ssr" | "@angular/compiler-cli" | "svelte2tsx" | "@absolutejs/scoped-state" | "vue-router" | "@types/react" | "react-refresh" | "svelte-check" | "vue-tsc")[];
36
+ export declare const installFrameworkDependencies: (cwd: string, framework: FrameworkKey, run?: BunAddRunner) => {
9
37
  ok: boolean;
10
38
  specs: string[];
11
39
  };
@@ -1007,7 +1007,7 @@ import { basename, dirname as dirname2, extname as extname2, join as join3, rela
1007
1007
  var serverCacheRoot, compiledModuleCache, originalSourcePathCache, syncIslandGeneration, transpiler, ensureRelativeImportPath = (from, target) => {
1008
1008
  const importPath = relative2(dirname2(from), target).replace(/\\/g, "/");
1009
1009
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
1010
- }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
1010
+ }, escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), replaceQuotedSpecifier = (code, spec, target) => code.replace(new RegExp(`(['"])${escapeRegExp(spec)}\\1`, "g"), (_match, quote) => `${quote}${target}${quote}`), processDirectoryEntries = (entries, dir, targetFileName, stack) => {
1011
1011
  for (const entry of entries) {
1012
1012
  const entryPath = join3(dir, entry.name);
1013
1013
  if (entry.isDirectory())
@@ -1052,18 +1052,21 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, syncIslandGen
1052
1052
  return null;
1053
1053
  }
1054
1054
  const basePath = resolve3(dirname2(from), spec);
1055
+ const extensions = [
1056
+ ".ts",
1057
+ ".tsx",
1058
+ ".mts",
1059
+ ".cts",
1060
+ ".js",
1061
+ ".jsx",
1062
+ ".mjs",
1063
+ ".cjs",
1064
+ ".json"
1065
+ ];
1055
1066
  const candidates = [
1056
1067
  basePath,
1057
- `${basePath}.ts`,
1058
- `${basePath}.js`,
1059
- `${basePath}.mjs`,
1060
- `${basePath}.cjs`,
1061
- `${basePath}.json`,
1062
- join3(basePath, "index.ts"),
1063
- join3(basePath, "index.js"),
1064
- join3(basePath, "index.mjs"),
1065
- join3(basePath, "index.cjs"),
1066
- join3(basePath, "index.json")
1068
+ ...extensions.map((extension) => `${basePath}${extension}`),
1069
+ ...extensions.map((extension) => join3(basePath, `index${extension}`))
1067
1070
  ];
1068
1071
  const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
1069
1072
  const foundIndex = existResults.indexOf(true);
@@ -1148,7 +1151,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, syncIslandGen
1148
1151
  rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), resolvedModuleImport));
1149
1152
  }
1150
1153
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
1151
- transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
1154
+ transpiled = replaceQuotedSpecifier(transpiled, spec, resolvedModuleImport);
1152
1155
  }
1153
1156
  let compiledCode = compile(transpiled, {
1154
1157
  css: "injected",
@@ -1160,10 +1163,10 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, syncIslandGen
1160
1163
  hmr: isDevelopmentRuntime()
1161
1164
  }).js.code;
1162
1165
  for (const [spec, compiledChildPath] of childModulePaths) {
1163
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
1166
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
1164
1167
  }
1165
1168
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
1166
- compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
1169
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, resolvedModuleImport);
1167
1170
  }
1168
1171
  const sourceId = JSON.stringify(relative2(process.cwd(), resolutionSourcePath).replace(/\\/g, "/"));
1169
1172
  const componentName = /export default function ([\w$]+)\s*\(/.exec(compiledCode)?.[1];
@@ -4840,7 +4843,13 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
4840
4843
  ].join(`
4841
4844
  `) : nonVueLines.join(`
4842
4845
  `);
4843
- }, 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) => {
4846
+ }, RELATIVE_SPECIFIER_PATTERN, extractRelativeImports = (code) => Array.from(new Set(Array.from(code.matchAll(RELATIVE_SPECIFIER_PATTERN), (match) => match.groups?.spec).filter((spec) => spec !== undefined))), resolveFromSource = (spec, sourcePath) => {
4847
+ try {
4848
+ return Bun.resolveSync(spec, dirname4(sourcePath));
4849
+ } catch {
4850
+ return null;
4851
+ }
4852
+ }, compileVueServerModule = async (sourcePath) => {
4844
4853
  syncIslandGeneration2();
4845
4854
  const cachedModulePath = compiledModuleCache3.get(sourcePath);
4846
4855
  if (cachedModulePath)
@@ -4873,10 +4882,10 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
4873
4882
  ssr: true,
4874
4883
  ssrCssVars: descriptor.cssVars
4875
4884
  }).code : "const ssrRender = () => {};";
4876
- const childImportPaths = extractRelativeVueImports(compiledScript.content);
4877
- const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
4878
- compiledPath: await compileVueServerModule(resolve5(dirname4(sourcePath), relativeImport)),
4879
- spec: relativeImport
4885
+ const relativeImports = extractRelativeImports(compiledScript.content);
4886
+ const compiledChildren = await Promise.all(relativeImports.filter((spec) => spec.endsWith(".vue")).map(async (spec) => ({
4887
+ compiledPath: await compileVueServerModule(resolve5(dirname4(sourcePath), spec)),
4888
+ spec
4880
4889
  })));
4881
4890
  const strippedScript = stripExports(compiledScript.content);
4882
4891
  const transpiledScript = transpiler2.transformSync(strippedScript);
@@ -4888,10 +4897,22 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
4888
4897
  ].join(`
4889
4898
  `));
4890
4899
  const compiledModulePath = getCachedModulePath3(sourcePath);
4891
- let rewritten = assembled;
4900
+ const rewrittenSpecifiers = new Map;
4892
4901
  for (const child of compiledChildren) {
4893
- rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
4902
+ rewrittenSpecifiers.set(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
4894
4903
  }
4904
+ for (const spec of extractRelativeImports(assembled)) {
4905
+ if (rewrittenSpecifiers.has(spec))
4906
+ continue;
4907
+ const resolvedImport = resolveFromSource(spec, sourcePath);
4908
+ if (!resolvedImport)
4909
+ continue;
4910
+ rewrittenSpecifiers.set(spec, ensureRelativeImportPath2(compiledModulePath, resolvedImport));
4911
+ }
4912
+ const rewritten = assembled.replace(RELATIVE_SPECIFIER_PATTERN, (match, prefix, quote, spec) => {
4913
+ const target = rewrittenSpecifiers.get(spec);
4914
+ return target ? `${prefix}${quote}${target}${quote}` : match;
4915
+ });
4895
4916
  await mkdir3(dirname4(compiledModulePath), { recursive: true });
4896
4917
  await writeIfChanged2(compiledModulePath, rewritten);
4897
4918
  compiledModuleCache3.set(sourcePath, compiledModulePath);
@@ -4905,6 +4926,7 @@ var init_vueServerModule = __esm(() => {
4905
4926
  compiledModuleCache3.clear();
4906
4927
  });
4907
4928
  transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
4929
+ RELATIVE_SPECIFIER_PATTERN = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(?<spec>\.{1,2}\/[^'"]*)\2/g;
4908
4930
  });
4909
4931
 
4910
4932
  // src/core/islands.ts
@@ -6163,5 +6185,5 @@ export {
6163
6185
  useIslandStore
6164
6186
  };
6165
6187
 
6166
- //# debugId=1234E6F5317F9A0564756E2164756E21
6188
+ //# debugId=E6EA4B1420FAE74C64756E2164756E21
6167
6189
  //# sourceMappingURL=index.js.map