@alloy-js/core 0.21.0-dev.0 → 0.21.0-dev.10

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.
Files changed (92) hide show
  1. package/dist/src/binder.d.ts +3 -3
  2. package/dist/src/binder.d.ts.map +1 -1
  3. package/dist/src/binder.js +18 -4
  4. package/dist/src/binder.js.map +1 -1
  5. package/dist/src/components/Declaration.js +1 -1
  6. package/dist/src/components/Declaration.js.map +1 -1
  7. package/dist/src/components/MemberDeclaration.js +1 -1
  8. package/dist/src/components/MemberDeclaration.js.map +1 -1
  9. package/dist/src/components/ReferenceOrContent.d.ts +1 -1
  10. package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
  11. package/dist/src/index.d.ts +1 -0
  12. package/dist/src/index.d.ts.map +1 -1
  13. package/dist/src/index.js +1 -0
  14. package/dist/src/index.js.map +1 -1
  15. package/dist/src/library-symbol-reference.d.ts +8 -0
  16. package/dist/src/library-symbol-reference.d.ts.map +1 -0
  17. package/dist/src/library-symbol-reference.js +5 -0
  18. package/dist/src/library-symbol-reference.js.map +1 -0
  19. package/dist/src/name-policy.d.ts +2 -2
  20. package/dist/src/name-policy.d.ts.map +1 -1
  21. package/dist/src/name-policy.js +14 -1
  22. package/dist/src/name-policy.js.map +1 -1
  23. package/dist/src/pretty-string/pretty-string.d.ts +47 -0
  24. package/dist/src/pretty-string/pretty-string.d.ts.map +1 -0
  25. package/dist/src/pretty-string/pretty-string.js +100 -0
  26. package/dist/src/pretty-string/pretty-string.js.map +1 -0
  27. package/dist/src/pretty-string/pretty-string.test.d.ts +2 -0
  28. package/dist/src/pretty-string/pretty-string.test.d.ts.map +1 -0
  29. package/dist/src/pretty-string/pretty-string.test.js +38 -0
  30. package/dist/src/pretty-string/pretty-string.test.js.map +1 -0
  31. package/dist/src/refkey.d.ts +12 -8
  32. package/dist/src/refkey.d.ts.map +1 -1
  33. package/dist/src/refkey.js +40 -12
  34. package/dist/src/refkey.js.map +1 -1
  35. package/dist/src/render.d.ts.map +1 -1
  36. package/dist/src/render.js +10 -4
  37. package/dist/src/render.js.map +1 -1
  38. package/dist/src/runtime/component.d.ts +22 -2
  39. package/dist/src/runtime/component.d.ts.map +1 -1
  40. package/dist/src/runtime/component.js +18 -0
  41. package/dist/src/runtime/component.js.map +1 -1
  42. package/dist/src/symbols/output-scope.d.ts +1 -0
  43. package/dist/src/symbols/output-scope.d.ts.map +1 -1
  44. package/dist/src/symbols/output-scope.js +4 -0
  45. package/dist/src/symbols/output-scope.js.map +1 -1
  46. package/dist/src/symbols/output-symbol.d.ts +10 -0
  47. package/dist/src/symbols/output-symbol.d.ts.map +1 -1
  48. package/dist/src/symbols/output-symbol.js +33 -0
  49. package/dist/src/symbols/output-symbol.js.map +1 -1
  50. package/dist/src/tracer.d.ts.map +1 -1
  51. package/dist/src/tracer.js +2 -2
  52. package/dist/src/tracer.js.map +1 -1
  53. package/dist/test/refkey.test.js +11 -1
  54. package/dist/test/refkey.test.js.map +1 -1
  55. package/dist/test/rendering/basic.test.js +22 -0
  56. package/dist/test/rendering/basic.test.js.map +1 -1
  57. package/dist/test/symbols/output-scope.test.js +4 -3
  58. package/dist/test/symbols/output-scope.test.js.map +1 -1
  59. package/dist/test/symbols/resolution.test.js +29 -1
  60. package/dist/test/symbols/resolution.test.js.map +1 -1
  61. package/dist/testing/create-test-wrapper.d.ts +22 -0
  62. package/dist/testing/create-test-wrapper.d.ts.map +1 -0
  63. package/dist/testing/create-test-wrapper.js +60 -0
  64. package/dist/testing/create-test-wrapper.js.map +1 -0
  65. package/dist/testing/index.d.ts +1 -0
  66. package/dist/testing/index.d.ts.map +1 -1
  67. package/dist/testing/index.js +1 -0
  68. package/dist/testing/index.js.map +1 -1
  69. package/dist/tsconfig.tsbuildinfo +1 -1
  70. package/package.json +1 -1
  71. package/src/binder.ts +34 -6
  72. package/src/components/Declaration.tsx +1 -1
  73. package/src/components/MemberDeclaration.tsx +1 -1
  74. package/src/index.ts +1 -0
  75. package/src/library-symbol-reference.ts +20 -0
  76. package/src/name-policy.ts +22 -3
  77. package/src/pretty-string/pretty-string.test.ts +47 -0
  78. package/src/pretty-string/pretty-string.ts +130 -0
  79. package/src/refkey.ts +67 -26
  80. package/src/render.ts +11 -3
  81. package/src/runtime/component.ts +33 -1
  82. package/src/symbols/output-scope.ts +7 -0
  83. package/src/symbols/output-symbol.ts +44 -0
  84. package/src/tracer.ts +2 -5
  85. package/temp/api.json +792 -88
  86. package/test/refkey.test.ts +12 -1
  87. package/test/rendering/basic.test.tsx +35 -1
  88. package/test/symbols/output-scope.test.ts +4 -4
  89. package/test/symbols/resolution.test.ts +42 -1
  90. package/testing/create-test-wrapper.tsx +70 -0
  91. package/testing/index.ts +1 -0
  92. package/tsconfig.json +1 -0
@@ -94,6 +94,11 @@ export interface OutputSymbolOptions {
94
94
  * also ignoring name conflict resolution.
95
95
  */
96
96
  ignoreNameConflict?: boolean;
97
+
98
+ /**
99
+ * Provide a function which lazy-initializes members when an enumeration of members are needed.
100
+ */
101
+ lazyMemberInitializer?: () => void;
97
102
  }
98
103
 
99
104
  let symbolCount = 0;
@@ -459,6 +464,40 @@ export abstract class OutputSymbol {
459
464
  return this.#namePolicy;
460
465
  }
461
466
 
467
+ #lazyMemberInitializer: (() => void) | undefined;
468
+ #lazyMembersInitialized: boolean = false;
469
+
470
+ #initializeMembers() {
471
+ if (this.#lazyMemberInitializer && !this.#lazyMembersInitialized) {
472
+ this.#lazyMemberInitializer();
473
+ }
474
+ this.#lazyMembersInitialized = true;
475
+ }
476
+
477
+ /**
478
+ * Get a member symbol by name from this symbol's member spaces. Checks member
479
+ * spaces in order until it finds a member with that name.
480
+ */
481
+ resolveMemberByName(name: string): OutputSymbol | undefined {
482
+ this.#initializeMembers();
483
+
484
+ if (this.isTyped) {
485
+ if (!this.hasTypeSymbol) {
486
+ return undefined;
487
+ }
488
+
489
+ return this.type!.resolveMemberByName(name);
490
+ }
491
+ for (const space of this.memberSpaces) {
492
+ const member = space.symbolNames.get(name);
493
+ if (member) {
494
+ return member;
495
+ }
496
+ }
497
+
498
+ return undefined;
499
+ }
500
+
462
501
  // Tell \@vue/reactivity that this symbol should never be wrapped in a reactive
463
502
  // proxy.
464
503
  [ReactiveFlags.SKIP] = true;
@@ -502,6 +541,7 @@ export abstract class OutputSymbol {
502
541
  this.#isTransient = !!options.transient;
503
542
  this.#isTyped = !!options.type;
504
543
  this.type = options.type;
544
+ this.#lazyMemberInitializer = options.lazyMemberInitializer;
505
545
 
506
546
  this.#handleNewSpaces(this.#spaces);
507
547
  const constructor = this.constructor as typeof OutputSymbol;
@@ -630,6 +670,10 @@ export abstract class OutputSymbol {
630
670
  }
631
671
 
632
672
  [inspect.custom]() {
673
+ return this.toString();
674
+ }
675
+
676
+ toString() {
633
677
  return untrack(() => `${this.constructor.name} "${this.name}"[${this.id}]`);
634
678
  }
635
679
  }
package/src/tracer.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { effect, ReactiveEffectRunner } from "@vue/reactivity";
2
2
  import { untrack } from "./reactivity.js";
3
- import { isMemberRefkey, type Refkey } from "./refkey.js";
3
+ import { inspectRefkey, type Refkey } from "./refkey.js";
4
4
  import { scheduler } from "./scheduler.js";
5
5
  import { type OutputScope } from "./symbols/output-scope.js";
6
6
  import type {
@@ -429,10 +429,7 @@ export function formatRefkeys(refkeys: Refkey[] | Refkey | undefined) {
429
429
  }
430
430
 
431
431
  function formatRefkey(refkey: Refkey): string {
432
- const text =
433
- isMemberRefkey(refkey) ?
434
- `memberRefkey[${formatRefkey(refkey.base)} -> ${formatRefkey(refkey.member)}]`
435
- : `refkey[${refkey.key}]`;
432
+ const text = inspectRefkey(refkey);
436
433
 
437
434
  return colorText(text, {
438
435
  fg: {