@absolutejs/absolute 0.19.0-beta.854 → 0.19.0-beta.855

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
@@ -18594,6 +18594,47 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18594
18594
  selector: decoratorMeta.selector,
18595
18595
  standalone: decoratorMeta.standalone
18596
18596
  };
18597
+ }, buildFreshClassMethodsBlock = (classNode, className) => {
18598
+ const methodSources = [];
18599
+ for (const member of classNode.members) {
18600
+ if (ts7.isMethodDeclaration(member) || ts7.isGetAccessorDeclaration(member) || ts7.isSetAccessorDeclaration(member)) {
18601
+ const modifiers = ts7.getModifiers(member) ?? [];
18602
+ const isStatic = modifiers.some((m) => m.kind === ts7.SyntaxKind.StaticKeyword);
18603
+ if (isStatic)
18604
+ continue;
18605
+ methodSources.push(member.getText());
18606
+ }
18607
+ }
18608
+ if (methodSources.length === 0)
18609
+ return null;
18610
+ const wrappedSource = `class _Fresh {
18611
+ ${methodSources.join(`
18612
+ `)}
18613
+ }`;
18614
+ let transpiled;
18615
+ try {
18616
+ transpiled = ts7.transpileModule(wrappedSource, {
18617
+ compilerOptions: {
18618
+ module: ts7.ModuleKind.ES2022,
18619
+ target: ts7.ScriptTarget.ES2022
18620
+ },
18621
+ reportDiagnostics: false
18622
+ }).outputText;
18623
+ } catch {
18624
+ return null;
18625
+ }
18626
+ return `// SURGICAL_HMR \u2014 patch prototype methods so existing instances
18627
+ // pick up new method bodies (\`compileComponentFromMetadata\` only
18628
+ // updates \`\u0275cmp\`, never the prototype).
18629
+ ${transpiled}
18630
+ {
18631
+ const __fresh_proto = _Fresh.prototype;
18632
+ for (const __name of Object.getOwnPropertyNames(__fresh_proto)) {
18633
+ if (__name === 'constructor') continue;
18634
+ const __desc = Object.getOwnPropertyDescriptor(__fresh_proto, __name);
18635
+ if (__desc) Object.defineProperty(${className}.prototype, __name, __desc);
18636
+ }
18637
+ }`;
18597
18638
  }, resolveAndReadResource = (componentDir, url) => {
18598
18639
  const abs = resolve33(componentDir, url);
18599
18640
  if (!existsSync26(abs))
@@ -18783,7 +18824,7 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18783
18824
  removeComments: false
18784
18825
  });
18785
18826
  const tsSourceText = printer.printNode(ts7.EmitHint.Unspecified, exportedDecl, sourceFile);
18786
- const moduleText = ts7.transpileModule(tsSourceText, {
18827
+ const transpiled = ts7.transpileModule(tsSourceText, {
18787
18828
  compilerOptions: {
18788
18829
  module: ts7.ModuleKind.ES2022,
18789
18830
  target: ts7.ScriptTarget.ES2022
@@ -18791,6 +18832,18 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18791
18832
  fileName: componentFilePath,
18792
18833
  reportDiagnostics: false
18793
18834
  }).outputText;
18835
+ const methodsBlock = buildFreshClassMethodsBlock(classNode, className);
18836
+ let moduleText = transpiled;
18837
+ if (methodsBlock) {
18838
+ const fnOpening = `function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) {`;
18839
+ const idx = moduleText.indexOf(fnOpening);
18840
+ if (idx >= 0) {
18841
+ const insertAt = idx + fnOpening.length;
18842
+ moduleText = moduleText.slice(0, insertAt) + `
18843
+ ` + methodsBlock + `
18844
+ ` + moduleText.slice(insertAt);
18845
+ }
18846
+ }
18794
18847
  fingerprintCache.set(fingerprintId, currentFingerprint);
18795
18848
  return { ok: true, moduleText, componentSource: sourceFile };
18796
18849
  } catch (err) {
@@ -29950,5 +30003,5 @@ export {
29950
30003
  ANGULAR_INIT_TIMEOUT_MS
29951
30004
  };
29952
30005
 
29953
- //# debugId=1AAD42B006C96FC764756E2164756E21
30006
+ //# debugId=A3C5EF48AC33740564756E2164756E21
29954
30007
  //# sourceMappingURL=index.js.map