@absolutejs/absolute 0.19.0-beta.887 → 0.19.0-beta.888

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.js CHANGED
@@ -9829,7 +9829,8 @@ var init_angularLinkerPlugin = __esm(() => {
9829
9829
  // src/dev/angular/hmrInjectionPlugin.ts
9830
9830
  var exports_hmrInjectionPlugin = {};
9831
9831
  __export(exports_hmrInjectionPlugin, {
9832
- createAngularHmrInjectionPlugin: () => createAngularHmrInjectionPlugin
9832
+ createAngularHmrInjectionPlugin: () => createAngularHmrInjectionPlugin,
9833
+ applyAngularHmrInjection: () => applyAngularHmrInjection
9833
9834
  });
9834
9835
  import { readFile as readFile5 } from "fs/promises";
9835
9836
  import { relative as relative6, resolve as resolve15 } from "path";
@@ -9993,50 +9994,53 @@ var ENTITY_DECORATOR_RE, IMPORT_RE, TOP_LEVEL_DECL_RE, extractAllTopLevelNames =
9993
9994
  });
9994
9995
  }
9995
9996
  }
9996
- `, createAngularHmrInjectionPlugin = (params) => {
9997
+ `, applyAngularHmrInjection = (jsSource, componentJsAbsPath, params) => {
9997
9998
  const { generatedAngularRoot, userAngularRoot, projectRoot } = params;
9998
9999
  const normalizedGenRoot = resolve15(generatedAngularRoot).replace(/\\/g, "/");
9999
- return {
10000
- name: "absolute-angular-hmr-injection",
10001
- setup(build2) {
10002
- build2.onLoad({ filter: /\.component\.js$/ }, async (args) => {
10003
- const normalizedPath = args.path.replace(/\\/g, "/");
10004
- if (!normalizedPath.startsWith(normalizedGenRoot + "/"))
10005
- return;
10006
- const text = await readFile5(args.path, "utf8");
10007
- const seen = new Set;
10008
- const classNames = [];
10009
- let match;
10010
- const re2 = new RegExp(ENTITY_DECORATOR_RE.source, ENTITY_DECORATOR_RE.flags);
10011
- while ((match = re2.exec(text)) !== null) {
10012
- const className = match[1];
10013
- if (className && !seen.has(className)) {
10014
- seen.add(className);
10015
- classNames.push(className);
10016
- }
10017
- }
10018
- if (classNames.length === 0)
10019
- return;
10020
- const relFromGenRoot = relative6(generatedAngularRoot, args.path).replace(/\\/g, "/");
10021
- const userTsPath = resolve15(userAngularRoot, relFromGenRoot.replace(/\.js$/, ".ts"));
10022
- const projectRel = relative6(projectRoot, userTsPath).replace(/\\/g, "/");
10023
- const tail = classNames.map((className) => {
10024
- const id = `${projectRel}@${className}`;
10025
- return buildHmrTail(className, JSON.stringify(id));
10026
- }).join("");
10027
- const topLevelNames = extractAllTopLevelNames(text);
10028
- const depsKeys = topLevelNames.filter((n) => !classNames.includes(n)).join(", ");
10029
- const depsBlock = classNames.length > 0 && depsKeys ? `
10000
+ const normalizedPath = componentJsAbsPath.replace(/\\/g, "/");
10001
+ if (!normalizedPath.startsWith(normalizedGenRoot + "/"))
10002
+ return;
10003
+ const seen = new Set;
10004
+ const classNames = [];
10005
+ let match;
10006
+ const re2 = new RegExp(ENTITY_DECORATOR_RE.source, ENTITY_DECORATOR_RE.flags);
10007
+ while ((match = re2.exec(jsSource)) !== null) {
10008
+ const className = match[1];
10009
+ if (className && !seen.has(className)) {
10010
+ seen.add(className);
10011
+ classNames.push(className);
10012
+ }
10013
+ }
10014
+ if (classNames.length === 0)
10015
+ return;
10016
+ const relFromGenRoot = relative6(generatedAngularRoot, componentJsAbsPath).replace(/\\/g, "/");
10017
+ const userTsPath = resolve15(userAngularRoot, relFromGenRoot.replace(/\.js$/, ".ts"));
10018
+ const projectRel = relative6(projectRoot, userTsPath).replace(/\\/g, "/");
10019
+ const tail = classNames.map((className) => {
10020
+ const id = `${projectRel}@${className}`;
10021
+ return buildHmrTail(className, JSON.stringify(id));
10022
+ }).join("");
10023
+ const topLevelNames = extractAllTopLevelNames(jsSource);
10024
+ const depsKeys = topLevelNames.filter((n) => !classNames.includes(n)).join(", ");
10025
+ const depsBlock = classNames.length > 0 && depsKeys ? `
10030
10026
 
10031
10027
  // absolutejs HMR \u2014 Tier 1a class-deps registry
10032
10028
  ` + classNames.map((c) => `try { ${c}.__abs_deps = { ${depsKeys} }; } catch {}`).join(`
10033
10029
  `) + `
10034
10030
  ` : "";
10035
- return { contents: text + tail + depsBlock, loader: "js" };
10036
- });
10037
- }
10038
- };
10039
- };
10031
+ return jsSource + tail + depsBlock;
10032
+ }, createAngularHmrInjectionPlugin = (params) => ({
10033
+ name: "absolute-angular-hmr-injection",
10034
+ setup(build2) {
10035
+ build2.onLoad({ filter: /\.component\.js$/ }, async (args) => {
10036
+ const text = await readFile5(args.path, "utf8");
10037
+ const transformed = applyAngularHmrInjection(text, args.path, params);
10038
+ if (transformed === undefined)
10039
+ return;
10040
+ return { contents: transformed, loader: "js" };
10041
+ });
10042
+ }
10043
+ });
10040
10044
  var init_hmrInjectionPlugin = __esm(() => {
10041
10045
  ENTITY_DECORATOR_RE = /([A-Z][A-Za-z0-9_$]*)\s*=\s*__legacyDecorateClassTS[A-Za-z0-9_$]*\s*\(\s*\[[\s\S]*?\b(?:Component|Directive|Pipe|Injectable)[A-Za-z0-9_$]*\s*\(/g;
10042
10046
  IMPORT_RE = /^\s*import\s+(?:(?:(\*)\s+as\s+([A-Za-z_$][\w$]*)\s+from)|(?:([A-Za-z_$][\w$]*)(?:\s*,\s*\{([^}]*)\})?\s+from)|(?:\{([^}]*)\}\s+from))\s*['"][^'"]+['"]/gm;
@@ -15040,13 +15044,14 @@ ${content.slice(firstUseIdx)}`;
15040
15044
  ];
15041
15045
  const reactClientEntryPoints = [...reactEntries];
15042
15046
  const urlReferencedFiles = await urlReferencedFilesPromise;
15047
+ const skipAngularClientBundle = hmr && angularClientPaths.length > 0;
15043
15048
  const nonReactClientEntryPoints = [
15044
15049
  ...svelteIndexPaths,
15045
15050
  ...svelteClientPaths,
15046
15051
  ...htmlEntries,
15047
15052
  ...vueIndexPaths,
15048
15053
  ...vueClientPaths,
15049
- ...angularClientPaths,
15054
+ ...skipAngularClientBundle ? [] : angularClientPaths,
15050
15055
  ...islandBootstrapPath ? [islandBootstrapPath] : [],
15051
15056
  ...urlReferencedFiles
15052
15057
  ];
@@ -15432,6 +15437,13 @@ ${content.slice(firstUseIdx)}`;
15432
15437
  const fileBase = basename9(serverPath, ".js");
15433
15438
  manifest[toPascal(fileBase)] = serverPath;
15434
15439
  }
15440
+ if (skipAngularClientBundle) {
15441
+ for (const clientPath of angularClientPaths) {
15442
+ const fileBase = basename9(clientPath, ".js");
15443
+ const relFromCwd = relative11(projectRoot, clientPath).replace(/\\/g, "/");
15444
+ manifest[`${toPascal(fileBase)}Index`] = `/@src/${relFromCwd}`;
15445
+ }
15446
+ }
15435
15447
  const shouldCopyHtmx = !isIncremental || normalizedIncrementalFiles?.some((f2) => f2.includes("/htmx/") && f2.endsWith(".html"));
15436
15448
  const shouldUpdateHtmlAssetPaths = !isIncremental || normalizedIncrementalFiles?.some((f2) => f2.includes("/html/") && (f2.endsWith(".html") || isStylePath(f2)));
15437
15449
  const shouldUpdateHtmxAssetPaths = !isIncremental || normalizedIncrementalFiles?.some((f2) => f2.includes("/htmx/") && (f2.endsWith(".html") || isStylePath(f2)));
@@ -17469,10 +17481,31 @@ export default {};
17469
17481
  return;
17470
17482
  const stat3 = statSync2(filePath);
17471
17483
  const resolvedVueDir = vueDir ? resolve31(vueDir) : undefined;
17472
- const content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, resolvedVueDir);
17484
+ let content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, resolvedVueDir);
17485
+ const isComponentJs = ext === ".js" && filePath.endsWith(".component.js") && filePath.replace(/\\/g, "/").includes("/.absolutejs/generated/angular/");
17486
+ if (isComponentJs) {
17487
+ const userAngularRoot = await getAngularUserRoot(projectRoot);
17488
+ if (userAngularRoot) {
17489
+ const { applyAngularHmrInjection: applyAngularHmrInjection2 } = await Promise.resolve().then(() => (init_hmrInjectionPlugin(), exports_hmrInjectionPlugin));
17490
+ const { getFrameworkGeneratedDir: getFrameworkGeneratedDir2 } = await Promise.resolve().then(() => (init_generatedDir(), exports_generatedDir));
17491
+ const generatedAngularRoot = getFrameworkGeneratedDir2("angular");
17492
+ const transformed = applyAngularHmrInjection2(content, filePath, {
17493
+ generatedAngularRoot,
17494
+ projectRoot,
17495
+ userAngularRoot
17496
+ });
17497
+ if (transformed !== undefined)
17498
+ content = transformed;
17499
+ }
17500
+ }
17473
17501
  setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
17474
17502
  return jsResponse(content);
17475
- }, transformAndCacheSvelte = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
17503
+ }, cachedAngularUserRoot, getAngularUserRoot = async (_projectRoot) => {
17504
+ if (cachedAngularUserRoot !== undefined)
17505
+ return cachedAngularUserRoot;
17506
+ cachedAngularUserRoot = configuredAngularUserRoot ?? null;
17507
+ return cachedAngularUserRoot;
17508
+ }, configuredAngularUserRoot, transformAndCacheSvelte = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
17476
17509
  const stat3 = statSync2(filePath);
17477
17510
  const content = await transformSvelteFile(filePath, projectRoot, rewriter, stylePreprocessors);
17478
17511
  setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
@@ -17491,6 +17524,10 @@ export default {};
17491
17524
  }, createModuleServer = (config) => {
17492
17525
  const { projectRoot, vendorPaths, frameworkDirs, stylePreprocessors } = config;
17493
17526
  const rewriter = buildImportRewriter(vendorPaths);
17527
+ if (frameworkDirs?.angular) {
17528
+ configuredAngularUserRoot = frameworkDirs.angular;
17529
+ cachedAngularUserRoot = undefined;
17530
+ }
17494
17531
  return async (pathname) => {
17495
17532
  if (pathname.startsWith("/@stub/"))
17496
17533
  return handleStubRequest(pathname);
@@ -30673,5 +30710,5 @@ export {
30673
30710
  ANGULAR_INIT_TIMEOUT_MS
30674
30711
  };
30675
30712
 
30676
- //# debugId=F971A5A35190242364756E2164756E21
30713
+ //# debugId=4D0BEC65366DBDA064756E2164756E21
30677
30714
  //# sourceMappingURL=index.js.map