@absolutejs/absolute 0.19.0-beta.872 → 0.19.0-beta.873

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,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-VGlvkC/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-D74EKb/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-VGlvkC/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-D74EKb/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -48,7 +48,7 @@ var warnMissingStreamingSlotCollector = (primitiveName) => {
48
48
  getWarningController()?.maybeWarn(primitiveName);
49
49
  };
50
50
 
51
- // .angular-partial-tmp-VGlvkC/src/core/streamingSlotRegistry.ts
51
+ // .angular-partial-tmp-D74EKb/src/core/streamingSlotRegistry.ts
52
52
  var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
53
53
  var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
54
54
  var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
package/dist/build.js CHANGED
@@ -9561,7 +9561,31 @@ __export(exports_hmrInjectionPlugin, {
9561
9561
  });
9562
9562
  import { readFile as readFile5 } from "fs/promises";
9563
9563
  import { relative as relative6, resolve as resolve12 } from "path";
9564
- var ENTITY_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9564
+ var ENTITY_DECORATOR_RE, IMPORT_RE, extractImportedLocalNames = (jsSource) => {
9565
+ const names = new Set;
9566
+ IMPORT_RE.lastIndex = 0;
9567
+ let match;
9568
+ while ((match = IMPORT_RE.exec(jsSource)) !== null) {
9569
+ const [, , nsName, defaultName, namedAfterDefault, named] = match;
9570
+ if (nsName)
9571
+ names.add(nsName);
9572
+ if (defaultName)
9573
+ names.add(defaultName);
9574
+ const namedClause = namedAfterDefault ?? named;
9575
+ if (namedClause) {
9576
+ for (const part of namedClause.split(",")) {
9577
+ const trimmed = part.trim();
9578
+ if (!trimmed)
9579
+ continue;
9580
+ const asIdx = trimmed.search(/\s+as\s+/);
9581
+ const local = asIdx >= 0 ? trimmed.slice(asIdx).replace(/^\s+as\s+/, "").trim() : trimmed;
9582
+ if (/^[A-Za-z_$][\w$]*$/.test(local))
9583
+ names.add(local);
9584
+ }
9585
+ }
9586
+ }
9587
+ return [...names];
9588
+ }, buildHmrTail = (className, encodedIdLiteral) => `
9565
9589
 
9566
9590
  // absolutejs HMR \u2014 auto-generated; mirrors compileHmrInitializer from
9567
9591
  // @angular/compiler with import.meta.hot adapted to globalThis.__angularHmr.
@@ -9682,13 +9706,22 @@ var ENTITY_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9682
9706
  const id = `${projectRel}@${className}`;
9683
9707
  return buildHmrTail(className, JSON.stringify(id));
9684
9708
  }).join("");
9685
- return { contents: text + tail, loader: "js" };
9709
+ const importedLocalNames = extractImportedLocalNames(text);
9710
+ const depsKeys = importedLocalNames.filter((n) => !classNames.includes(n)).join(", ");
9711
+ const depsBlock = classNames.length > 0 && depsKeys ? `
9712
+
9713
+ // absolutejs HMR \u2014 Tier 1a class-deps registry
9714
+ ` + classNames.map((c) => `try { ${c}.__abs_deps = { ${depsKeys} }; } catch {}`).join(`
9715
+ `) + `
9716
+ ` : "";
9717
+ return { contents: text + tail + depsBlock, loader: "js" };
9686
9718
  });
9687
9719
  }
9688
9720
  };
9689
9721
  };
9690
9722
  var init_hmrInjectionPlugin = __esm(() => {
9691
9723
  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;
9724
+ 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;
9692
9725
  });
9693
9726
 
9694
9727
  // src/utils/cleanStaleOutputs.ts
@@ -18757,10 +18790,22 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18757
18790
  standalone: decoratorMeta.standalone
18758
18791
  };
18759
18792
  }, buildFreshClassMethodsBlock = (classNode, className) => {
18760
- const methodSources = [];
18793
+ const memberSources = [];
18761
18794
  let hasStatic = false;
18762
18795
  const printer = ts7.createPrinter({ removeComments: true });
18763
18796
  for (const member of classNode.members) {
18797
+ if (ts7.isPropertyDeclaration(member)) {
18798
+ const modifiers = (ts7.getModifiers(member) ?? []).filter((m) => m.kind !== ts7.SyntaxKind.Decorator && m.kind !== ts7.SyntaxKind.PrivateKeyword && m.kind !== ts7.SyntaxKind.PublicKeyword && m.kind !== ts7.SyntaxKind.ProtectedKeyword && m.kind !== ts7.SyntaxKind.ReadonlyKeyword && m.kind !== ts7.SyntaxKind.OverrideKeyword);
18799
+ const cleaned = ts7.factory.createPropertyDeclaration(modifiers, member.name, undefined, undefined, member.initializer);
18800
+ memberSources.push(printer.printNode(ts7.EmitHint.Unspecified, cleaned, classNode.getSourceFile()));
18801
+ continue;
18802
+ }
18803
+ if (ts7.isConstructorDeclaration(member)) {
18804
+ const cleanedParams = member.parameters.map((param) => ts7.factory.updateParameterDeclaration(param, (ts7.getModifiers(param) ?? []).filter((m) => m.kind !== ts7.SyntaxKind.Decorator && m.kind !== ts7.SyntaxKind.PrivateKeyword && m.kind !== ts7.SyntaxKind.PublicKeyword && m.kind !== ts7.SyntaxKind.ProtectedKeyword && m.kind !== ts7.SyntaxKind.ReadonlyKeyword && m.kind !== ts7.SyntaxKind.OverrideKeyword), param.dotDotDotToken, param.name, param.questionToken, param.type, param.initializer));
18805
+ const cleaned = ts7.factory.createConstructorDeclaration([], cleanedParams, member.body);
18806
+ memberSources.push(printer.printNode(ts7.EmitHint.Unspecified, cleaned, classNode.getSourceFile()));
18807
+ continue;
18808
+ }
18764
18809
  if (ts7.isMethodDeclaration(member) || ts7.isGetAccessorDeclaration(member) || ts7.isSetAccessorDeclaration(member)) {
18765
18810
  const modifiers = ts7.getModifiers(member) ?? [];
18766
18811
  const isStatic = modifiers.some((m) => m.kind === ts7.SyntaxKind.StaticKeyword);
@@ -18776,13 +18821,13 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18776
18821
  cleaned = ts7.factory.createSetAccessorDeclaration(modifiers.filter((m) => m.kind !== ts7.SyntaxKind.Decorator), member.name, cleanedParams, member.body);
18777
18822
  }
18778
18823
  const printed = printer.printNode(ts7.EmitHint.Unspecified, cleaned, classNode.getSourceFile());
18779
- methodSources.push(printed);
18824
+ memberSources.push(printed);
18780
18825
  }
18781
18826
  }
18782
- if (methodSources.length === 0)
18827
+ if (memberSources.length === 0)
18783
18828
  return null;
18784
18829
  const wrappedSource = `class _Fresh {
18785
- ${methodSources.join(`
18830
+ ${memberSources.join(`
18786
18831
  `)}
18787
18832
  }`;
18788
18833
  let transpiled;
@@ -19021,55 +19066,59 @@ ${block}
19021
19066
  while ((idMatch = identRe.exec(provisionalMethodsBlock)) !== null) {
19022
19067
  referencedNames.add(idMatch[0]);
19023
19068
  }
19024
- const importDecls = [];
19069
+ const sourceImportedNames = new Set;
19025
19070
  for (const stmt of sourceFile.statements) {
19026
19071
  if (!ts7.isImportDeclaration(stmt))
19027
19072
  continue;
19028
19073
  if (!ts7.isStringLiteral(stmt.moduleSpecifier))
19029
19074
  continue;
19030
- const spec = stmt.moduleSpecifier.text;
19031
- if (spec.startsWith(".") || spec.startsWith("/"))
19032
- continue;
19033
- const importedNames = [];
19034
19075
  const clause = stmt.importClause;
19035
19076
  if (clause?.name)
19036
- importedNames.push(clause.name.text);
19077
+ sourceImportedNames.add(clause.name.text);
19037
19078
  if (clause?.namedBindings && ts7.isNamedImports(clause.namedBindings)) {
19038
19079
  for (const el of clause.namedBindings.elements) {
19039
19080
  if (el.isTypeOnly)
19040
19081
  continue;
19041
- importedNames.push(el.name.text);
19082
+ sourceImportedNames.add(el.name.text);
19042
19083
  }
19043
19084
  } else if (clause?.namedBindings && ts7.isNamespaceImport(clause.namedBindings)) {
19044
- importedNames.push(clause.namedBindings.name.text);
19085
+ sourceImportedNames.add(clause.namedBindings.name.text);
19045
19086
  }
19046
- if (!importedNames.some((n) => referencedNames.has(n)))
19047
- continue;
19048
- importDecls.push(printer.printNode(ts7.EmitHint.Unspecified, stmt, sourceFile));
19049
19087
  }
19050
- const tsSourceText = (importDecls.length > 0 ? importDecls.join(`
19051
- `) + `
19052
-
19053
- ` : "") + fnText;
19088
+ const depsToDestructure = [...sourceImportedNames].filter((n) => referencedNames.has(n));
19089
+ const tsSourceText = fnText;
19054
19090
  const transpiled = ts7.transpileModule(tsSourceText, {
19055
19091
  compilerOptions: {
19056
19092
  module: ts7.ModuleKind.ES2022,
19057
- target: ts7.ScriptTarget.ES2022,
19058
- verbatimModuleSyntax: true
19093
+ target: ts7.ScriptTarget.ES2022
19059
19094
  },
19060
19095
  fileName: componentFilePath,
19061
19096
  reportDiagnostics: false
19062
19097
  }).outputText;
19063
19098
  const methodsBlock = buildFreshClassMethodsBlock(classNode, className);
19064
19099
  let moduleText = transpiled;
19065
- if (methodsBlock) {
19066
- const fnOpening = `function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) {`;
19067
- const idx = moduleText.indexOf(fnOpening);
19068
- if (idx >= 0) {
19069
- const insertAt = idx + fnOpening.length;
19070
- moduleText = moduleText.slice(0, insertAt) + `
19100
+ const fnOpening = `function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) {`;
19101
+ const fnOpeningIdx = moduleText.indexOf(fnOpening);
19102
+ const depsDestructure = depsToDestructure.length > 0 ? `
19103
+ const { ${depsToDestructure.join(", ")} } = ${className}.__abs_deps || {};
19104
+ ` : "";
19105
+ if (fnOpeningIdx >= 0 && (methodsBlock || depsDestructure)) {
19106
+ const insertAt = fnOpeningIdx + fnOpening.length;
19107
+ moduleText = moduleText.slice(0, insertAt) + depsDestructure + (methodsBlock ? `
19071
19108
  ` + methodsBlock + `
19072
- ` + moduleText.slice(insertAt);
19109
+ ` : "") + moduleText.slice(insertAt);
19110
+ }
19111
+ if (methodsBlock) {
19112
+ const tail = `
19113
+ if (typeof _Fresh !== 'undefined') {
19114
+ _Fresh.\u0275cmp = ${className}.\u0275cmp;
19115
+ _Fresh.\u0275fac = function() { return new _Fresh(); };
19116
+ return _Fresh;
19117
+ }
19118
+ `;
19119
+ const lastBrace = moduleText.lastIndexOf("}");
19120
+ if (lastBrace >= 0) {
19121
+ moduleText = moduleText.slice(0, lastBrace) + tail + moduleText.slice(lastBrace);
19073
19122
  }
19074
19123
  }
19075
19124
  fingerprintCache.set(fingerprintId, currentFingerprint);
@@ -21728,5 +21777,5 @@ export {
21728
21777
  build
21729
21778
  };
21730
21779
 
21731
- //# debugId=7188E6E5DCCA465064756E2164756E21
21780
+ //# debugId=52057CAB22A6B36464756E2164756E21
21732
21781
  //# sourceMappingURL=build.js.map