@powerlines/plugin-alloy 0.25.68 → 0.25.70

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 (38) hide show
  1. package/README.md +1 -1
  2. package/dist/core/contexts/index.cjs +2 -1
  3. package/dist/core/contexts/index.d.cts +2 -2
  4. package/dist/core/contexts/index.d.mts +2 -2
  5. package/dist/core/contexts/index.mjs +2 -2
  6. package/dist/core/contexts/reflection.cjs +13 -2
  7. package/dist/core/contexts/reflection.d.cts +14 -3
  8. package/dist/core/contexts/reflection.d.cts.map +1 -1
  9. package/dist/core/contexts/reflection.d.mts +14 -3
  10. package/dist/core/contexts/reflection.d.mts.map +1 -1
  11. package/dist/core/contexts/reflection.mjs +12 -2
  12. package/dist/core/contexts/reflection.mjs.map +1 -1
  13. package/dist/core/index.cjs +2 -1
  14. package/dist/core/index.d.cts +2 -2
  15. package/dist/core/index.d.mts +2 -2
  16. package/dist/core/index.mjs +2 -2
  17. package/dist/typescript/components/interface-declaration.cjs +16 -6
  18. package/dist/typescript/components/interface-declaration.d.cts +3 -2
  19. package/dist/typescript/components/interface-declaration.d.cts.map +1 -1
  20. package/dist/typescript/components/interface-declaration.d.mts +3 -2
  21. package/dist/typescript/components/interface-declaration.d.mts.map +1 -1
  22. package/dist/typescript/components/interface-declaration.mjs +16 -6
  23. package/dist/typescript/components/interface-declaration.mjs.map +1 -1
  24. package/dist/typescript/components/object-declaration.cjs +16 -5
  25. package/dist/typescript/components/object-declaration.d.cts +4 -3
  26. package/dist/typescript/components/object-declaration.d.cts.map +1 -1
  27. package/dist/typescript/components/object-declaration.d.mts +4 -3
  28. package/dist/typescript/components/object-declaration.d.mts.map +1 -1
  29. package/dist/typescript/components/object-declaration.mjs +16 -5
  30. package/dist/typescript/components/object-declaration.mjs.map +1 -1
  31. package/dist/typescript/components/tsdoc-reflection.cjs +15 -4
  32. package/dist/typescript/components/tsdoc-reflection.d.cts +1 -0
  33. package/dist/typescript/components/tsdoc-reflection.d.cts.map +1 -1
  34. package/dist/typescript/components/tsdoc-reflection.d.mts +1 -0
  35. package/dist/typescript/components/tsdoc-reflection.d.mts.map +1 -1
  36. package/dist/typescript/components/tsdoc-reflection.mjs +16 -5
  37. package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
  38. package/package.json +7 -7
package/README.md CHANGED
@@ -27,7 +27,7 @@ This package is part of the <b>🔌 Powerlines</b> monorepo. Powerlines is the "
27
27
 
28
28
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
29
29
 
30
- [![Version](https://img.shields.io/badge/version-0.25.65-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/powerlines)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/powerlines/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
30
+ [![Version](https://img.shields.io/badge/version-0.25.68-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/powerlines)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/powerlines/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
31
 
32
32
  <!-- prettier-ignore-start -->
33
33
  <!-- markdownlint-disable -->
@@ -18,4 +18,5 @@ exports.usePowerlinesSafe = require_core_contexts_context.usePowerlinesSafe;
18
18
  exports.useReflectionClass = require_core_contexts_reflection.useReflectionClass;
19
19
  exports.useReflectionMethod = require_core_contexts_reflection.useReflectionMethod;
20
20
  exports.useReflectionParameter = require_core_contexts_reflection.useReflectionParameter;
21
- exports.useReflectionProperty = require_core_contexts_reflection.useReflectionProperty;
21
+ exports.useReflectionProperty = require_core_contexts_reflection.useReflectionProperty;
22
+ exports.useReflectionPropertyContext = require_core_contexts_reflection.useReflectionPropertyContext;
@@ -1,4 +1,4 @@
1
1
  import { PowerlinesContext, usePowerlines, usePowerlinesContext, usePowerlinesSafe } from "./context.cjs";
2
2
  import { MetaContext, MetaItem, __ΩMetaItem, useMeta, useMetaContext, useMetaSafe } from "./meta.cjs";
3
- import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./reflection.cjs";
4
- export { MetaContext, MetaItem, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩMetaItem, __ΩReflectionClassContextInterface, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
3
+ import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext } from "./reflection.cjs";
4
+ export { MetaContext, MetaItem, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, __ΩMetaItem, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext };
@@ -1,4 +1,4 @@
1
1
  import { PowerlinesContext, usePowerlines, usePowerlinesContext, usePowerlinesSafe } from "./context.mjs";
2
2
  import { MetaContext, MetaItem, __ΩMetaItem, useMeta, useMetaContext, useMetaSafe } from "./meta.mjs";
3
- import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./reflection.mjs";
4
- export { MetaContext, MetaItem, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩMetaItem, __ΩReflectionClassContextInterface, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
3
+ import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext } from "./reflection.mjs";
4
+ export { MetaContext, MetaItem, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, __ΩMetaItem, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext };
@@ -1,5 +1,5 @@
1
1
  import { PowerlinesContext, usePowerlines, usePowerlinesContext, usePowerlinesSafe } from "./context.mjs";
2
2
  import { MetaContext, useMeta, useMetaContext, useMetaSafe } from "./meta.mjs";
3
- import { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./reflection.mjs";
3
+ import { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext } from "./reflection.mjs";
4
4
 
5
- export { MetaContext, PowerlinesContext, ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
5
+ export { MetaContext, PowerlinesContext, ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext };
@@ -26,12 +26,22 @@ const ReflectionPropertyContext = (0, _alloy_js_core.createNamedContext)("Reflec
26
26
  *
27
27
  * @returns A reactive version of the current reflection.
28
28
  */
29
- function useReflectionProperty() {
29
+ function useReflectionPropertyContext() {
30
30
  const context = (0, _alloy_js_core.useContext)(ReflectionPropertyContext);
31
31
  if (!context) throw new Error("Powerlines - Reflection Property Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
32
32
  return context;
33
33
  }
34
34
  /**
35
+ * Hook to access the Reflection Property context.
36
+ *
37
+ * @returns A reactive version of the current reflection.
38
+ */
39
+ function useReflectionProperty() {
40
+ const context = useReflectionPropertyContext();
41
+ if (!context) throw new Error("Powerlines - Reflection Property Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
42
+ return context;
43
+ }
44
+ /**
35
45
  * The reflection method context used in template rendering.
36
46
  */
37
47
  const ReflectionMethodContext = (0, _alloy_js_core.createNamedContext)("ReflectionMethod");
@@ -66,4 +76,5 @@ exports.ReflectionPropertyContext = ReflectionPropertyContext;
66
76
  exports.useReflectionClass = useReflectionClass;
67
77
  exports.useReflectionMethod = useReflectionMethod;
68
78
  exports.useReflectionParameter = useReflectionParameter;
69
- exports.useReflectionProperty = useReflectionProperty;
79
+ exports.useReflectionProperty = useReflectionProperty;
80
+ exports.useReflectionPropertyContext = useReflectionPropertyContext;
@@ -17,16 +17,26 @@ declare const ReflectionClassContext: ComponentContext<ReflectionClassContextInt
17
17
  * @returns A reactive version of the current reflection.
18
18
  */
19
19
  declare function useReflectionClass<T extends Record<string, any> = Record<string, any>>(): ReflectionClassContextInterface<T>;
20
+ interface ReflectionPropertyContextInterface {
21
+ property: ReflectionProperty;
22
+ defaultValue?: any;
23
+ }
20
24
  /**
21
25
  * The reflection property context used in template rendering.
22
26
  */
23
- declare const ReflectionPropertyContext: ComponentContext<ReflectionProperty>;
27
+ declare const ReflectionPropertyContext: ComponentContext<ReflectionPropertyContextInterface>;
28
+ /**
29
+ * Hook to access the Reflection Property context.
30
+ *
31
+ * @returns A reactive version of the current reflection.
32
+ */
33
+ declare function useReflectionPropertyContext(): ReflectionPropertyContextInterface;
24
34
  /**
25
35
  * Hook to access the Reflection Property context.
26
36
  *
27
37
  * @returns A reactive version of the current reflection.
28
38
  */
29
- declare function useReflectionProperty(): ReflectionProperty;
39
+ declare function useReflectionProperty(): ReflectionPropertyContextInterface;
30
40
  /**
31
41
  * The reflection method context used in template rendering.
32
42
  */
@@ -48,6 +58,7 @@ declare const ReflectionParameterContext: ComponentContext<ReflectionParameter>;
48
58
  */
49
59
  declare function useReflectionParameter(): ReflectionParameter;
50
60
  declare type __ΩReflectionClassContextInterface = any[];
61
+ declare type __ΩReflectionPropertyContextInterface = any[];
51
62
  //#endregion
52
- export { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
63
+ export { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext };
53
64
  //# sourceMappingURL=reflection.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reflection.d.cts","names":[],"sources":["../../../src/core/contexts/reflection.ts"],"mappings":";;;;;UA4BiB,+BAAA,WACL,MAAA,gBAAsB,MAAA;EAEhC,UAAA,EAAY,eAAA,CAAgB,CAAA;EAC5B,QAAA,GAAW,2BAAA,CAA4B,CAAA;AAAA;;;;cAM5B,sBAAA,EAAwB,gBAAA,CACnC,+BAAA;;;;;;iBAQc,kBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAAA,GAAmB,+BAAA,CAAA,CAAA;;;;cAkBxC,yBAAA,EAA2B,gBAAA,CAAiB,kBAAA;;;;;;iBAQzC,qBAAA,CAAA,GAAqB,kBAAA;AApCrC;;;AAAA,cAmDa,uBAAA,EAAyB,gBAAA,CAAiB,gBAAA;;AA1CvD;;;;iBAkDgB,mBAAA,CAAA,GAAmB,gBAAA;;;;cAetB,0BAAA,EAA4B,gBAAA,CAAiB,mBAAA;;;;;;iBAQ1C,sBAAA,CAAA,GAAsB,mBAAA;AAAA"}
1
+ {"version":3,"file":"reflection.d.cts","names":[],"sources":["../../../src/core/contexts/reflection.ts"],"mappings":";;;;;UA4BiB,+BAAA,WACL,MAAA,gBAAsB,MAAA;EAEhC,UAAA,EAAY,eAAA,CAAgB,CAAA;EAC5B,QAAA,GAAW,2BAAA,CAA4B,CAAA;AAAA;;;;cAM5B,sBAAA,EAAwB,gBAAA,CACnC,+BAAA;;;;;;iBAQc,kBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAAA,GAAmB,+BAAA,CAAA,CAAA;AAAA,UAepC,kCAAA;EACf,QAAA,EAAU,kBAAA;EACV,YAAA;AAAA;;;;cAMW,yBAAA,EAA2B,gBAAA,CAAiB,kCAAA;;;AAjCzD;;;iBAyCgB,4BAAA,CAAA,GAA4B,kCAAA;;AAhC5C;;;;iBAmDgB,qBAAA,CAAA,GAAqB,kCAAA;;;;cAexB,uBAAA,EAAyB,gBAAA,CAAiB,gBAAA;;;;;;iBAQvC,mBAAA,CAAA,GAAmB,gBAAA;;AA1DnC;;cAyEa,0BAAA,EAA4B,gBAAA,CAAiB,mBAAA;;;;;;iBAQ1C,sBAAA,CAAA,GAAsB,mBAAA;AAAA"}
@@ -17,16 +17,26 @@ declare const ReflectionClassContext: ComponentContext<ReflectionClassContextInt
17
17
  * @returns A reactive version of the current reflection.
18
18
  */
19
19
  declare function useReflectionClass<T extends Record<string, any> = Record<string, any>>(): ReflectionClassContextInterface<T>;
20
+ interface ReflectionPropertyContextInterface {
21
+ property: ReflectionProperty;
22
+ defaultValue?: any;
23
+ }
20
24
  /**
21
25
  * The reflection property context used in template rendering.
22
26
  */
23
- declare const ReflectionPropertyContext: ComponentContext<ReflectionProperty>;
27
+ declare const ReflectionPropertyContext: ComponentContext<ReflectionPropertyContextInterface>;
28
+ /**
29
+ * Hook to access the Reflection Property context.
30
+ *
31
+ * @returns A reactive version of the current reflection.
32
+ */
33
+ declare function useReflectionPropertyContext(): ReflectionPropertyContextInterface;
24
34
  /**
25
35
  * Hook to access the Reflection Property context.
26
36
  *
27
37
  * @returns A reactive version of the current reflection.
28
38
  */
29
- declare function useReflectionProperty(): ReflectionProperty;
39
+ declare function useReflectionProperty(): ReflectionPropertyContextInterface;
30
40
  /**
31
41
  * The reflection method context used in template rendering.
32
42
  */
@@ -48,6 +58,7 @@ declare const ReflectionParameterContext: ComponentContext<ReflectionParameter>;
48
58
  */
49
59
  declare function useReflectionParameter(): ReflectionParameter;
50
60
  declare type __ΩReflectionClassContextInterface = any[];
61
+ declare type __ΩReflectionPropertyContextInterface = any[];
51
62
  //#endregion
52
- export { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
63
+ export { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext };
53
64
  //# sourceMappingURL=reflection.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reflection.d.mts","names":[],"sources":["../../../src/core/contexts/reflection.ts"],"mappings":";;;;;UA4BiB,+BAAA,WACL,MAAA,gBAAsB,MAAA;EAEhC,UAAA,EAAY,eAAA,CAAgB,CAAA;EAC5B,QAAA,GAAW,2BAAA,CAA4B,CAAA;AAAA;;;;cAM5B,sBAAA,EAAwB,gBAAA,CACnC,+BAAA;;;;;;iBAQc,kBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAAA,GAAmB,+BAAA,CAAA,CAAA;;;;cAkBxC,yBAAA,EAA2B,gBAAA,CAAiB,kBAAA;;;;;;iBAQzC,qBAAA,CAAA,GAAqB,kBAAA;AApCrC;;;AAAA,cAmDa,uBAAA,EAAyB,gBAAA,CAAiB,gBAAA;;AA1CvD;;;;iBAkDgB,mBAAA,CAAA,GAAmB,gBAAA;;;;cAetB,0BAAA,EAA4B,gBAAA,CAAiB,mBAAA;;;;;;iBAQ1C,sBAAA,CAAA,GAAsB,mBAAA;AAAA"}
1
+ {"version":3,"file":"reflection.d.mts","names":[],"sources":["../../../src/core/contexts/reflection.ts"],"mappings":";;;;;UA4BiB,+BAAA,WACL,MAAA,gBAAsB,MAAA;EAEhC,UAAA,EAAY,eAAA,CAAgB,CAAA;EAC5B,QAAA,GAAW,2BAAA,CAA4B,CAAA;AAAA;;;;cAM5B,sBAAA,EAAwB,gBAAA,CACnC,+BAAA;;;;;;iBAQc,kBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAAA,GAAmB,+BAAA,CAAA,CAAA;AAAA,UAepC,kCAAA;EACf,QAAA,EAAU,kBAAA;EACV,YAAA;AAAA;;;;cAMW,yBAAA,EAA2B,gBAAA,CAAiB,kCAAA;;;AAjCzD;;;iBAyCgB,4BAAA,CAAA,GAA4B,kCAAA;;AAhC5C;;;;iBAmDgB,qBAAA,CAAA,GAAqB,kCAAA;;;;cAexB,uBAAA,EAAyB,gBAAA,CAAiB,gBAAA;;;;;;iBAQvC,mBAAA,CAAA,GAAmB,gBAAA;;AA1DnC;;cAyEa,0BAAA,EAA4B,gBAAA,CAAiB,mBAAA;;;;;;iBAQ1C,sBAAA,CAAA,GAAsB,mBAAA;AAAA"}
@@ -24,12 +24,22 @@ const ReflectionPropertyContext = createNamedContext("ReflectionProperty");
24
24
  *
25
25
  * @returns A reactive version of the current reflection.
26
26
  */
27
- function useReflectionProperty() {
27
+ function useReflectionPropertyContext() {
28
28
  const context = useContext(ReflectionPropertyContext);
29
29
  if (!context) throw new Error("Powerlines - Reflection Property Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
30
30
  return context;
31
31
  }
32
32
  /**
33
+ * Hook to access the Reflection Property context.
34
+ *
35
+ * @returns A reactive version of the current reflection.
36
+ */
37
+ function useReflectionProperty() {
38
+ const context = useReflectionPropertyContext();
39
+ if (!context) throw new Error("Powerlines - Reflection Property Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
40
+ return context;
41
+ }
42
+ /**
33
43
  * The reflection method context used in template rendering.
34
44
  */
35
45
  const ReflectionMethodContext = createNamedContext("ReflectionMethod");
@@ -57,5 +67,5 @@ function useReflectionParameter() {
57
67
  }
58
68
 
59
69
  //#endregion
60
- export { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
70
+ export { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext };
61
71
  //# sourceMappingURL=reflection.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"reflection.mjs","names":[],"sources":["../../../src/core/contexts/reflection.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ComponentContext } from \"@alloy-js/core\";\nimport { createContext, createNamedContext, useContext } from \"@alloy-js/core\";\nimport type {\n ReflectionClass,\n ReflectionMethod,\n ReflectionParameter,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { ReflectionOverrideInterface } from \"../../types/components\";\n\nexport interface ReflectionClassContextInterface<\n T extends Record<string, any> = Record<string, any>\n> {\n reflection: ReflectionClass<T>;\n override?: ReflectionOverrideInterface<T>;\n}\n\n/**\n * The reflection class context used in template rendering.\n */\nexport const ReflectionClassContext: ComponentContext<\n ReflectionClassContextInterface<any>\n> = createContext<ReflectionClassContextInterface<any>>();\n\n/**\n * Hook to access the Reflection context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionClass<\n T extends Record<string, any> = Record<string, any>\n>() {\n const context = useContext<ReflectionClassContextInterface<T>>(\n ReflectionClassContext\n )!;\n\n if (!context) {\n throw new Error(\n \"Powerlines - ReflectionClass Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.\"\n );\n }\n\n return context;\n}\n\n/**\n * The reflection property context used in template rendering.\n */\nexport const ReflectionPropertyContext: ComponentContext<ReflectionProperty> =\n createNamedContext<ReflectionProperty>(\"ReflectionProperty\");\n\n/**\n * Hook to access the Reflection Property context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionProperty() {\n const context = useContext<ReflectionProperty>(ReflectionPropertyContext)!;\n\n if (!context) {\n throw new Error(\n \"Powerlines - Reflection Property Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.\"\n );\n }\n\n return context;\n}\n\n/**\n * The reflection method context used in template rendering.\n */\nexport const ReflectionMethodContext: ComponentContext<ReflectionMethod> =\n createNamedContext<ReflectionMethod>(\"ReflectionMethod\");\n\n/**\n * Hook to access the Reflection Method context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionMethod() {\n const context = useContext<ReflectionMethod>(ReflectionMethodContext)!;\n\n if (!context) {\n throw new Error(\n \"Powerlines - Reflection Method Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.\"\n );\n }\n\n return context;\n}\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const ReflectionParameterContext: ComponentContext<ReflectionParameter> =\n createNamedContext<ReflectionParameter>(\"ReflectionParameter\");\n\n/**\n * Hook to access the Reflection Parameter context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionParameter() {\n return useContext<ReflectionParameter>(ReflectionParameterContext)!;\n}\n"],"mappings":";;;;;;AAsCA,MAAa,yBAET,eAAqD;;;;;;AAOzD,SAAgB,qBAEZ;CACF,MAAM,UAAU,WACd,uBACD;AAED,KAAI,CAAC,QACH,OAAM,IAAI,MACR,sMACD;AAGH,QAAO;;;;;AAMT,MAAa,4BACX,mBAAuC,qBAAqB;;;;;;AAO9D,SAAgB,wBAAwB;CACtC,MAAM,UAAU,WAA+B,0BAA0B;AAEzE,KAAI,CAAC,QACH,OAAM,IAAI,MACR,0MACD;AAGH,QAAO;;;;;AAMT,MAAa,0BACX,mBAAqC,mBAAmB;;;;;;AAO1D,SAAgB,sBAAsB;CACpC,MAAM,UAAU,WAA6B,wBAAwB;AAErE,KAAI,CAAC,QACH,OAAM,IAAI,MACR,wMACD;AAGH,QAAO;;;;;AAMT,MAAa,6BACX,mBAAwC,sBAAsB;;;;;;AAOhE,SAAgB,yBAAyB;AACvC,QAAO,WAAgC,2BAA2B"}
1
+ {"version":3,"file":"reflection.mjs","names":[],"sources":["../../../src/core/contexts/reflection.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ComponentContext } from \"@alloy-js/core\";\nimport { createContext, createNamedContext, useContext } from \"@alloy-js/core\";\nimport type {\n ReflectionClass,\n ReflectionMethod,\n ReflectionParameter,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { ReflectionOverrideInterface } from \"../../types/components\";\n\nexport interface ReflectionClassContextInterface<\n T extends Record<string, any> = Record<string, any>\n> {\n reflection: ReflectionClass<T>;\n override?: ReflectionOverrideInterface<T>;\n}\n\n/**\n * The reflection class context used in template rendering.\n */\nexport const ReflectionClassContext: ComponentContext<\n ReflectionClassContextInterface<any>\n> = createContext<ReflectionClassContextInterface<any>>();\n\n/**\n * Hook to access the Reflection context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionClass<\n T extends Record<string, any> = Record<string, any>\n>() {\n const context = useContext<ReflectionClassContextInterface<T>>(\n ReflectionClassContext\n )!;\n\n if (!context) {\n throw new Error(\n \"Powerlines - ReflectionClass Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.\"\n );\n }\n\n return context;\n}\n\nexport interface ReflectionPropertyContextInterface {\n property: ReflectionProperty;\n defaultValue?: any;\n}\n\n/**\n * The reflection property context used in template rendering.\n */\nexport const ReflectionPropertyContext: ComponentContext<ReflectionPropertyContextInterface> =\n createNamedContext<ReflectionPropertyContextInterface>(\"ReflectionProperty\");\n\n/**\n * Hook to access the Reflection Property context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionPropertyContext() {\n const context = useContext<ReflectionPropertyContextInterface>(\n ReflectionPropertyContext\n )!;\n\n if (!context) {\n throw new Error(\n \"Powerlines - Reflection Property Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.\"\n );\n }\n\n return context;\n}\n\n/**\n * Hook to access the Reflection Property context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionProperty() {\n const context = useReflectionPropertyContext();\n\n if (!context) {\n throw new Error(\n \"Powerlines - Reflection Property Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.\"\n );\n }\n\n return context;\n}\n\n/**\n * The reflection method context used in template rendering.\n */\nexport const ReflectionMethodContext: ComponentContext<ReflectionMethod> =\n createNamedContext<ReflectionMethod>(\"ReflectionMethod\");\n\n/**\n * Hook to access the Reflection Method context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionMethod() {\n const context = useContext<ReflectionMethod>(ReflectionMethodContext)!;\n\n if (!context) {\n throw new Error(\n \"Powerlines - Reflection Method Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.\"\n );\n }\n\n return context;\n}\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const ReflectionParameterContext: ComponentContext<ReflectionParameter> =\n createNamedContext<ReflectionParameter>(\"ReflectionParameter\");\n\n/**\n * Hook to access the Reflection Parameter context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionParameter() {\n return useContext<ReflectionParameter>(ReflectionParameterContext)!;\n}\n"],"mappings":";;;;;;AAsCA,MAAa,yBAET,eAAqD;;;;;;AAOzD,SAAgB,qBAEZ;CACF,MAAM,UAAU,WACd,uBACD;AAED,KAAI,CAAC,QACH,OAAM,IAAI,MACR,sMACD;AAGH,QAAO;;;;;AAWT,MAAa,4BACX,mBAAuD,qBAAqB;;;;;;AAO9E,SAAgB,+BAA+B;CAC7C,MAAM,UAAU,WACd,0BACD;AAED,KAAI,CAAC,QACH,OAAM,IAAI,MACR,0MACD;AAGH,QAAO;;;;;;;AAQT,SAAgB,wBAAwB;CACtC,MAAM,UAAU,8BAA8B;AAE9C,KAAI,CAAC,QACH,OAAM,IAAI,MACR,0MACD;AAGH,QAAO;;;;;AAMT,MAAa,0BACX,mBAAqC,mBAAmB;;;;;;AAO1D,SAAgB,sBAAsB;CACpC,MAAM,UAAU,WAA6B,wBAAwB;AAErE,KAAI,CAAC,QACH,OAAM,IAAI,MACR,wMACD;AAGH,QAAO;;;;;AAMT,MAAa,6BACX,mBAAwC,sBAAsB;;;;;;AAOhE,SAAgB,yBAAyB;AACvC,QAAO,WAAgC,2BAA2B"}
@@ -31,4 +31,5 @@ exports.usePowerlinesSafe = require_core_contexts_context.usePowerlinesSafe;
31
31
  exports.useReflectionClass = require_core_contexts_reflection.useReflectionClass;
32
32
  exports.useReflectionMethod = require_core_contexts_reflection.useReflectionMethod;
33
33
  exports.useReflectionParameter = require_core_contexts_reflection.useReflectionParameter;
34
- exports.useReflectionProperty = require_core_contexts_reflection.useReflectionProperty;
34
+ exports.useReflectionProperty = require_core_contexts_reflection.useReflectionProperty;
35
+ exports.useReflectionPropertyContext = require_core_contexts_reflection.useReflectionPropertyContext;
@@ -1,9 +1,9 @@
1
1
  import { PowerlinesContext, usePowerlines, usePowerlinesContext, usePowerlinesSafe } from "./contexts/context.cjs";
2
2
  import { MetaContext, MetaItem, __ΩMetaItem, useMeta, useMetaContext, useMetaSafe } from "./contexts/meta.cjs";
3
- import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.cjs";
3
+ import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext } from "./contexts/reflection.cjs";
4
4
  import { Output, OutputProps, __ΩOutputProps } from "./components/output.cjs";
5
5
  import { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant } from "./components/single-line-comment.cjs";
6
6
  import { SourceFile, SourceFileProps, __ΩSourceFileProps } from "./components/source-file.cjs";
7
7
  import { Spacing, SpacingProps, __ΩSpacingProps } from "./components/spacing.cjs";
8
8
  import { code } from "./helpers/code.cjs";
9
- export { MetaContext, MetaItem, Output, OutputProps, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, SourceFile, SourceFileProps, Spacing, SpacingProps, __ΩMetaItem, __ΩOutputProps, __ΩReflectionClassContextInterface, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant, __ΩSourceFileProps, __ΩSpacingProps, code, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
9
+ export { MetaContext, MetaItem, Output, OutputProps, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, SourceFile, SourceFileProps, Spacing, SpacingProps, __ΩMetaItem, __ΩOutputProps, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant, __ΩSourceFileProps, __ΩSpacingProps, code, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext };
@@ -1,9 +1,9 @@
1
1
  import { PowerlinesContext, usePowerlines, usePowerlinesContext, usePowerlinesSafe } from "./contexts/context.mjs";
2
2
  import { MetaContext, MetaItem, __ΩMetaItem, useMeta, useMetaContext, useMetaSafe } from "./contexts/meta.mjs";
3
- import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.mjs";
3
+ import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext } from "./contexts/reflection.mjs";
4
4
  import { Output, OutputProps, __ΩOutputProps } from "./components/output.mjs";
5
5
  import { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant } from "./components/single-line-comment.mjs";
6
6
  import { SourceFile, SourceFileProps, __ΩSourceFileProps } from "./components/source-file.mjs";
7
7
  import { Spacing, SpacingProps, __ΩSpacingProps } from "./components/spacing.mjs";
8
8
  import { code } from "./helpers/code.mjs";
9
- export { MetaContext, MetaItem, Output, OutputProps, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, SourceFile, SourceFileProps, Spacing, SpacingProps, __ΩMetaItem, __ΩOutputProps, __ΩReflectionClassContextInterface, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant, __ΩSourceFileProps, __ΩSpacingProps, code, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
9
+ export { MetaContext, MetaItem, Output, OutputProps, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, ReflectionPropertyContextInterface, SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, SourceFile, SourceFileProps, Spacing, SpacingProps, __ΩMetaItem, __ΩOutputProps, __ΩReflectionClassContextInterface, __ΩReflectionPropertyContextInterface, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant, __ΩSourceFileProps, __ΩSpacingProps, code, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext };
@@ -1,6 +1,6 @@
1
1
  import { PowerlinesContext, usePowerlines, usePowerlinesContext, usePowerlinesSafe } from "./contexts/context.mjs";
2
2
  import { MetaContext, useMeta, useMetaContext, useMetaSafe } from "./contexts/meta.mjs";
3
- import { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.mjs";
3
+ import { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext } from "./contexts/reflection.mjs";
4
4
  import "./contexts/index.mjs";
5
5
  import { Output } from "./components/output.mjs";
6
6
  import { SingleLineComment } from "./components/single-line-comment.mjs";
@@ -10,4 +10,4 @@ import "./components/index.mjs";
10
10
  import { code } from "./helpers/code.mjs";
11
11
  import "./helpers/index.mjs";
12
12
 
13
- export { MetaContext, Output, PowerlinesContext, ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, SingleLineComment, SourceFile, Spacing, code, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
13
+ export { MetaContext, Output, PowerlinesContext, ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, SingleLineComment, SourceFile, Spacing, code, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty, useReflectionPropertyContext };
@@ -152,10 +152,11 @@ const BaseInterfaceDeclaration = (0, _alloy_js_typescript.ensureTypeRefContext)(
152
152
  * Generates a TypeScript interface for the given reflection class.
153
153
  */
154
154
  function InterfaceDeclaration(props) {
155
- const [{ name, reflection, doc }, rest] = (0, _alloy_js_core.splitProps)(props, [
155
+ const [{ name, reflection, doc, defaultValue }, rest] = (0, _alloy_js_core.splitProps)(props, [
156
156
  "name",
157
157
  "reflection",
158
- "doc"
158
+ "doc",
159
+ "defaultValue"
159
160
  ]);
160
161
  const interfaceName = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_pascal_case.pascalCase)(((0, _stryke_type_checks_is_string.isString)(name) ? name : name.toString()) || reflection?.getName()));
161
162
  const properties = (0, _alloy_js_core.computed)(() => reflection ? reflection.getProperties().filter((item) => !item.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1) : []);
@@ -179,13 +180,19 @@ function InterfaceDeclaration(props) {
179
180
  "export": true,
180
181
  get name() {
181
182
  return interfaceName.value;
182
- }
183
+ },
184
+ defaultValue
183
185
  }, rest, { get children() {
184
186
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
185
187
  each: properties,
186
188
  doubleHardline: true,
187
189
  semicolon: true,
188
- children: (prop) => (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceDeclarationProperty, { property: prop })
190
+ children: (prop) => (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceDeclarationProperty, {
191
+ property: prop,
192
+ get defaultValue() {
193
+ return defaultValue?.value?.[prop.getNameAsString()];
194
+ }
195
+ })
189
196
  });
190
197
  } }))];
191
198
  }
@@ -197,9 +204,12 @@ function InterfaceDeclaration(props) {
197
204
  * Generates a TypeScript interface property for the given reflection class.
198
205
  */
199
206
  function InterfaceDeclarationProperty(props) {
200
- const [{ property }, rest] = (0, _alloy_js_core.splitProps)(props, ["property"]);
207
+ const [{ property, defaultValue }, rest] = (0, _alloy_js_core.splitProps)(props, ["property", "defaultValue"]);
201
208
  return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_reflection.ReflectionPropertyContext.Provider, {
202
- value: property,
209
+ value: {
210
+ property,
211
+ defaultValue
212
+ },
203
213
  get children() {
204
214
  return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_reflection.TSDocContextProperty, {}), (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceMember, (0, _alloy_js_core_jsx_runtime.mergeProps)({
205
215
  get name() {
@@ -1,6 +1,6 @@
1
1
  import { ComponentProps } from "../../types/components.cjs";
2
2
  import * as _alloy_js_core0 from "@alloy-js/core";
3
- import { Children, Namekey, Refkey } from "@alloy-js/core";
3
+ import { Children, Namekey, Ref, Refkey } from "@alloy-js/core";
4
4
  import { ReflectionClass, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
5
5
  import { CommonDeclarationProps, TypeParameterDescriptor } from "@alloy-js/typescript";
6
6
 
@@ -27,7 +27,7 @@ interface InterfaceDeclarationProps<T extends Record<string, any> = Record<strin
27
27
  * @remarks
28
28
  * This is used when the interface is used as a type for a variable declaration, to provide an initial value for the variable.
29
29
  */
30
- defaultValue?: Partial<T>;
30
+ defaultValue?: Ref<Partial<T>>;
31
31
  /**
32
32
  * Documentation for the interface. This can be a string or any Alloy component that renders documentation content (such as `TSDoc`).
33
33
  */
@@ -35,6 +35,7 @@ interface InterfaceDeclarationProps<T extends Record<string, any> = Record<strin
35
35
  }
36
36
  interface InterfaceDeclarationPropertyProps extends Omit<InterfaceMemberProps, "name">, ComponentProps {
37
37
  property: ReflectionProperty;
38
+ defaultValue?: any;
38
39
  }
39
40
  interface InterfaceExpressionProps {
40
41
  children?: Children;
@@ -1 +1 @@
1
- {"version":3,"file":"interface-declaration.d.cts","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"mappings":";;;;;;;UAkEiB,yBAAA,WACL,MAAA,gBAAsB,MAAA,uBAExB,sBAAA,EAAwB,cAAA;;;AAHlC;EAOE,OAAA,GAAU,QAAA;EAP8B;;;EAYxC,cAAA,GAAiB,uBAAA;EAAA;;;;;;EAQjB,UAAA,GAAa,eAAA,CAAgB,CAAA;EAjBG;;;;;;EAyBhC,YAAA,GAAe,OAAA,CAAQ,CAAA;EAzBS;;;EA8BhC,GAAA,GAAM,QAAA;AAAA;AAAA,UAGS,iCAAA,SACP,IAAA,CAAK,oBAAA,WAA+B,cAAA;EAC5C,QAAA,EAAU,kBAAA;AAAA;AAAA,UAGK,wBAAA;EACf,QAAA,GAAW,QAAA;AAAA;AAAA,cAGA,mBAAA,EAAmB,eAAA,CAAA,SAAA,CAAA,wBAAA;AAAA,UAoBf,wBAAA;EACf,IAAA,GAAO,QAAA;EACP,QAAA,GAAW,QAAA;EACX,QAAA;EACA,GAAA,GAAM,QAAA;EACN,MAAA,GAAS,MAAA,GAAS,MAAA;AAAA;AAAA,UAEH,4BAAA,SAAqC,wBAAA;EACpD,IAAA,WAAe,OAAA;EACf,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,2BAAA,SAAoC,wBAAA;EACnD,OAAA,EAAS,QAAA;AAAA;AAAA,KAGC,oBAAA,GACR,4BAAA,GACA,2BAAA;;;;AA3CJ;;;;;AAIA;iBAkDgB,eAAA,CAAgB,KAAA,EAAO,oBAAA,GAAoB,QAAA;;;;iBA+G3C,oBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,yBAAA,CAA0B,CAAA,IAAE,QAAA;;;;iBAwDrB,4BAAA,CACd,KAAA,EAAO,iCAAA,GAAiC,QAAA;AAAA"}
1
+ {"version":3,"file":"interface-declaration.d.cts","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"mappings":";;;;;;;UAmEiB,yBAAA,WACL,MAAA,gBAAsB,MAAA,uBAExB,sBAAA,EAAwB,cAAA;;;AAHlC;EAOE,OAAA,GAAU,QAAA;EAP8B;;;EAYxC,cAAA,GAAiB,uBAAA;EAAA;;;;;;EAQjB,UAAA,GAAa,eAAA,CAAgB,CAAA;EAjBrB;;;;;;EAyBR,YAAA,GAAe,GAAA,CAAI,OAAA,CAAQ,CAAA;EAzBnB;;;EA8BR,GAAA,GAAM,QAAA;AAAA;AAAA,UAGS,iCAAA,SACP,IAAA,CAAK,oBAAA,WAA+B,cAAA;EAC5C,QAAA,EAAU,kBAAA;EACV,YAAA;AAAA;AAAA,UAGe,wBAAA;EACf,QAAA,GAAW,QAAA;AAAA;AAAA,cAGA,mBAAA,EAAmB,eAAA,CAAA,SAAA,CAAA,wBAAA;AAAA,UAoBf,wBAAA;EACf,IAAA,GAAO,QAAA;EACP,QAAA,GAAW,QAAA;EACX,QAAA;EACA,GAAA,GAAM,QAAA;EACN,MAAA,GAAS,MAAA,GAAS,MAAA;AAAA;AAAA,UAEH,4BAAA,SAAqC,wBAAA;EACpD,IAAA,WAAe,OAAA;EACf,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,2BAAA,SAAoC,wBAAA;EACnD,OAAA,EAAS,QAAA;AAAA;AAAA,KAGC,oBAAA,GACR,4BAAA,GACA,2BAAA;;;;;;AA3CJ;;;;iBAsDgB,eAAA,CAAgB,KAAA,EAAO,oBAAA,GAAoB,QAAA;AAlD3D;;;AAAA,iBAiKgB,oBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,yBAAA,CAA0B,CAAA,IAAE,QAAA;;AA/IrC;;iBA8MgB,4BAAA,CACd,KAAA,EAAO,iCAAA,GAAiC,QAAA;AAAA"}
@@ -1,6 +1,6 @@
1
1
  import { ComponentProps } from "../../types/components.mjs";
2
2
  import * as _alloy_js_core0 from "@alloy-js/core";
3
- import { Children, Namekey, Refkey } from "@alloy-js/core";
3
+ import { Children, Namekey, Ref, Refkey } from "@alloy-js/core";
4
4
  import { ReflectionClass, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
5
5
  import { CommonDeclarationProps, TypeParameterDescriptor } from "@alloy-js/typescript";
6
6
 
@@ -27,7 +27,7 @@ interface InterfaceDeclarationProps<T extends Record<string, any> = Record<strin
27
27
  * @remarks
28
28
  * This is used when the interface is used as a type for a variable declaration, to provide an initial value for the variable.
29
29
  */
30
- defaultValue?: Partial<T>;
30
+ defaultValue?: Ref<Partial<T>>;
31
31
  /**
32
32
  * Documentation for the interface. This can be a string or any Alloy component that renders documentation content (such as `TSDoc`).
33
33
  */
@@ -35,6 +35,7 @@ interface InterfaceDeclarationProps<T extends Record<string, any> = Record<strin
35
35
  }
36
36
  interface InterfaceDeclarationPropertyProps extends Omit<InterfaceMemberProps, "name">, ComponentProps {
37
37
  property: ReflectionProperty;
38
+ defaultValue?: any;
38
39
  }
39
40
  interface InterfaceExpressionProps {
40
41
  children?: Children;
@@ -1 +1 @@
1
- {"version":3,"file":"interface-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"mappings":";;;;;;;UAkEiB,yBAAA,WACL,MAAA,gBAAsB,MAAA,uBAExB,sBAAA,EAAwB,cAAA;;;AAHlC;EAOE,OAAA,GAAU,QAAA;EAP8B;;;EAYxC,cAAA,GAAiB,uBAAA;EAAA;;;;;;EAQjB,UAAA,GAAa,eAAA,CAAgB,CAAA;EAjBG;;;;;;EAyBhC,YAAA,GAAe,OAAA,CAAQ,CAAA;EAzBS;;;EA8BhC,GAAA,GAAM,QAAA;AAAA;AAAA,UAGS,iCAAA,SACP,IAAA,CAAK,oBAAA,WAA+B,cAAA;EAC5C,QAAA,EAAU,kBAAA;AAAA;AAAA,UAGK,wBAAA;EACf,QAAA,GAAW,QAAA;AAAA;AAAA,cAGA,mBAAA,EAAmB,eAAA,CAAA,SAAA,CAAA,wBAAA;AAAA,UAoBf,wBAAA;EACf,IAAA,GAAO,QAAA;EACP,QAAA,GAAW,QAAA;EACX,QAAA;EACA,GAAA,GAAM,QAAA;EACN,MAAA,GAAS,MAAA,GAAS,MAAA;AAAA;AAAA,UAEH,4BAAA,SAAqC,wBAAA;EACpD,IAAA,WAAe,OAAA;EACf,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,2BAAA,SAAoC,wBAAA;EACnD,OAAA,EAAS,QAAA;AAAA;AAAA,KAGC,oBAAA,GACR,4BAAA,GACA,2BAAA;;;;AA3CJ;;;;;AAIA;iBAkDgB,eAAA,CAAgB,KAAA,EAAO,oBAAA,GAAoB,QAAA;;;;iBA+G3C,oBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,yBAAA,CAA0B,CAAA,IAAE,QAAA;;;;iBAwDrB,4BAAA,CACd,KAAA,EAAO,iCAAA,GAAiC,QAAA;AAAA"}
1
+ {"version":3,"file":"interface-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"mappings":";;;;;;;UAmEiB,yBAAA,WACL,MAAA,gBAAsB,MAAA,uBAExB,sBAAA,EAAwB,cAAA;;;AAHlC;EAOE,OAAA,GAAU,QAAA;EAP8B;;;EAYxC,cAAA,GAAiB,uBAAA;EAAA;;;;;;EAQjB,UAAA,GAAa,eAAA,CAAgB,CAAA;EAjBrB;;;;;;EAyBR,YAAA,GAAe,GAAA,CAAI,OAAA,CAAQ,CAAA;EAzBnB;;;EA8BR,GAAA,GAAM,QAAA;AAAA;AAAA,UAGS,iCAAA,SACP,IAAA,CAAK,oBAAA,WAA+B,cAAA;EAC5C,QAAA,EAAU,kBAAA;EACV,YAAA;AAAA;AAAA,UAGe,wBAAA;EACf,QAAA,GAAW,QAAA;AAAA;AAAA,cAGA,mBAAA,EAAmB,eAAA,CAAA,SAAA,CAAA,wBAAA;AAAA,UAoBf,wBAAA;EACf,IAAA,GAAO,QAAA;EACP,QAAA,GAAW,QAAA;EACX,QAAA;EACA,GAAA,GAAM,QAAA;EACN,MAAA,GAAS,MAAA,GAAS,MAAA;AAAA;AAAA,UAEH,4BAAA,SAAqC,wBAAA;EACpD,IAAA,WAAe,OAAA;EACf,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,2BAAA,SAAoC,wBAAA;EACnD,OAAA,EAAS,QAAA;AAAA;AAAA,KAGC,oBAAA,GACR,4BAAA,GACA,2BAAA;;;;;;AA3CJ;;;;iBAsDgB,eAAA,CAAgB,KAAA,EAAO,oBAAA,GAAoB,QAAA;AAlD3D;;;AAAA,iBAiKgB,oBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,yBAAA,CAA0B,CAAA,IAAE,QAAA;;AA/IrC;;iBA8MgB,4BAAA,CACd,KAAA,EAAO,iCAAA,GAAiC,QAAA;AAAA"}
@@ -150,10 +150,11 @@ const BaseInterfaceDeclaration = ensureTypeRefContext(function InterfaceDeclarat
150
150
  * Generates a TypeScript interface for the given reflection class.
151
151
  */
152
152
  function InterfaceDeclaration(props) {
153
- const [{ name, reflection, doc }, rest] = splitProps(props, [
153
+ const [{ name, reflection, doc, defaultValue }, rest] = splitProps(props, [
154
154
  "name",
155
155
  "reflection",
156
- "doc"
156
+ "doc",
157
+ "defaultValue"
157
158
  ]);
158
159
  const interfaceName = computed(() => pascalCase((isString(name) ? name : name.toString()) || reflection?.getName()));
159
160
  const properties = computed(() => reflection ? reflection.getProperties().filter((item) => !item.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1) : []);
@@ -177,13 +178,19 @@ function InterfaceDeclaration(props) {
177
178
  "export": true,
178
179
  get name() {
179
180
  return interfaceName.value;
180
- }
181
+ },
182
+ defaultValue
181
183
  }, rest, { get children() {
182
184
  return createComponent(For, {
183
185
  each: properties,
184
186
  doubleHardline: true,
185
187
  semicolon: true,
186
- children: (prop) => createComponent(InterfaceDeclarationProperty, { property: prop })
188
+ children: (prop) => createComponent(InterfaceDeclarationProperty, {
189
+ property: prop,
190
+ get defaultValue() {
191
+ return defaultValue?.value?.[prop.getNameAsString()];
192
+ }
193
+ })
187
194
  });
188
195
  } }))];
189
196
  }
@@ -195,9 +202,12 @@ function InterfaceDeclaration(props) {
195
202
  * Generates a TypeScript interface property for the given reflection class.
196
203
  */
197
204
  function InterfaceDeclarationProperty(props) {
198
- const [{ property }, rest] = splitProps(props, ["property"]);
205
+ const [{ property, defaultValue }, rest] = splitProps(props, ["property", "defaultValue"]);
199
206
  return createComponent(ReflectionPropertyContext.Provider, {
200
- value: property,
207
+ value: {
208
+ property,
209
+ defaultValue
210
+ },
201
211
  get children() {
202
212
  return [createComponent(TSDocContextProperty, {}), createComponent(InterfaceMember, mergeProps({
203
213
  get name() {
@@ -1 +1 @@
1
- {"version":3,"file":"interface-declaration.mjs","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Block,\n Children,\n childrenArray,\n computed,\n createSymbol,\n createSymbolSlot,\n effect,\n emitSymbol,\n findUnkeyedChildren,\n For,\n MemberDeclaration,\n Name,\n Namekey,\n Refkey,\n Show,\n splitProps,\n takeSymbols\n} from \"@alloy-js/core\";\nimport {\n CommonDeclarationProps,\n Declaration,\n ensureTypeRefContext,\n TSOutputSymbol,\n TSSymbolFlags,\n TypeParameterDescriptor,\n useTSLexicalScope,\n useTSMemberScope,\n useTSNamePolicy\n} from \"@alloy-js/typescript\";\nimport {\n ReflectionClass,\n ReflectionProperty,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport {\n ReflectionClassContext,\n ReflectionPropertyContext\n} from \"../../core/contexts/reflection\";\nimport { ComponentProps } from \"../../types/components\";\nimport { MemberScope } from \"../contexts/member-scope\";\nimport { PropertyName } from \"./property-name\";\nimport { TSDoc } from \"./tsdoc\";\nimport { TSDocContextProperty, TSDocReflectionClass } from \"./tsdoc-reflection\";\nimport { TypeParameters } from \"./type-parameters\";\n\nexport interface InterfaceDeclarationProps<\n T extends Record<string, any> = Record<string, any>\n>\n extends CommonDeclarationProps, ComponentProps {\n /**\n * A base type that this interface extends. This can be used to represent inheritance\n */\n extends?: Children;\n\n /**\n * The generic type parameters of the interface.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n\n /**\n * The reflection class that describes the properties of this interface.\n *\n * @remarks\n * This is used to generate the members of the interface based on the properties of the reflection class.\n */\n reflection?: ReflectionClass<T>;\n\n /**\n * A default value for this interface.\n *\n * @remarks\n * This is used when the interface is used as a type for a variable declaration, to provide an initial value for the variable.\n */\n defaultValue?: Partial<T>;\n\n /**\n * Documentation for the interface. This can be a string or any Alloy component that renders documentation content (such as `TSDoc`).\n */\n doc?: Children;\n}\n\nexport interface InterfaceDeclarationPropertyProps\n extends Omit<InterfaceMemberProps, \"name\">, ComponentProps {\n property: ReflectionProperty;\n}\n\nexport interface InterfaceExpressionProps {\n children?: Children;\n}\n\nexport const InterfaceExpression = ensureTypeRefContext(\n function InterfaceExpression(props: InterfaceExpressionProps) {\n const scope = useTSLexicalScope();\n const symbol = createSymbol(TSOutputSymbol, \"\", undefined, {\n transient: true,\n binder: scope?.binder\n });\n\n emitSymbol(symbol);\n\n return (\n <group>\n <MemberScope ownerSymbol={symbol}>\n <Block>{props.children}</Block>\n </MemberScope>\n </group>\n );\n }\n);\n\nexport interface InterfaceMemberPropsBase {\n type?: Children;\n children?: Children;\n readonly?: boolean;\n doc?: Children;\n refkey?: Refkey | Refkey[];\n}\nexport interface InterfacePropertyMemberProps extends InterfaceMemberPropsBase {\n name: string | Namekey;\n optional?: boolean;\n nullish?: boolean;\n}\n\nexport interface InterfaceIndexerMemberProps extends InterfaceMemberPropsBase {\n indexer: Children;\n}\n\nexport type InterfaceMemberProps =\n | InterfacePropertyMemberProps\n | InterfaceIndexerMemberProps;\n\n/**\n * Create a TypeScript interface member.\n *\n * An interface member can either provide a `name` prop to create a named\n * property, or an `indexer` prop to define an indexer for the interface.\n *\n * The type of the member can be provided either as the `type` prop or as the\n * children of the component.\n */\nexport function InterfaceMember(props: InterfaceMemberProps) {\n const type = props.type ?? props.children;\n const readonly = props.readonly ? \"readonly \" : \"\";\n\n if (\"indexer\" in props) {\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n {readonly}[{props.indexer}]: {type}\n </>\n );\n }\n\n const optionality = props.optional ? \"?\" : \"\";\n const scope = useTSMemberScope();\n const sym = createSymbol(\n TSOutputSymbol,\n props.name,\n scope.ownerSymbol.staticMembers,\n {\n refkeys: props.refkey,\n tsFlags:\n TSSymbolFlags.TypeSymbol |\n ((props.nullish ?? props.optional)\n ? TSSymbolFlags.Nullish\n : TSSymbolFlags.None),\n namePolicy: useTSNamePolicy().for(\"interface-member\"),\n binder: scope.binder\n }\n );\n\n const taken = takeSymbols();\n\n effect(() => {\n if (taken.size > 1) return;\n const symbol = Array.from(taken)[0];\n if (symbol?.isTransient) {\n symbol.moveMembersTo(sym);\n }\n });\n\n return (\n <MemberDeclaration symbol={sym}>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n {readonly}\n <PropertyName />\n {optionality}: {type}\n </MemberDeclaration>\n );\n}\n\nconst BaseInterfaceDeclaration = ensureTypeRefContext(\n function InterfaceDeclaration(props: InterfaceDeclarationProps) {\n const ExprSlot = createSymbolSlot();\n\n const children = childrenArray(() => props.children);\n\n const extendsPart = props.extends ? <> extends {props.extends}</> : \"\";\n const filteredChildren = findUnkeyedChildren(children);\n const currentScope = useTSLexicalScope();\n\n const binder = currentScope?.binder;\n const sym = createSymbol(TSOutputSymbol, props.name, currentScope.types, {\n refkeys: props.refkey,\n default: props.default,\n export: props.export,\n metadata: props.metadata,\n tsFlags: TSSymbolFlags.TypeSymbol,\n namePolicy: useTSNamePolicy().for(\"interface\"),\n binder\n });\n\n effect(() => {\n if (ExprSlot.ref.value) {\n const takenSymbols = ExprSlot.ref.value;\n for (const symbol of takenSymbols) {\n // ignore non-transient symbols (likely not the result of an expression).\n if (symbol.isTransient) {\n symbol.moveMembersTo(sym);\n }\n }\n }\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <Declaration {...props} nameKind=\"interface\" kind=\"type\" symbol={sym}>\n interface <Name />\n {props.typeParameters && (\n <TypeParameters parameters={props.typeParameters} />\n )}\n {extendsPart}{\" \"}\n <ExprSlot>\n <InterfaceExpression>{filteredChildren}</InterfaceExpression>\n </ExprSlot>\n </Declaration>\n </>\n );\n }\n);\n\n/**\n * Generates a TypeScript interface for the given reflection class.\n */\nexport function InterfaceDeclaration<\n T extends Record<string, any> = Record<string, any>\n>(props: InterfaceDeclarationProps<T>) {\n const [{ name, reflection, doc }, rest] = splitProps(props, [\n \"name\",\n \"reflection\",\n \"doc\"\n ]);\n\n const interfaceName = computed(() =>\n pascalCase(\n (isString(name) ? name : name.toString()) || reflection?.getName()\n )\n );\n\n const properties = computed(() =>\n reflection\n ? reflection\n .getProperties()\n .filter(item => !item.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) ||\n (!a.isReadonly() && !b.isReadonly())\n ? a.getNameAsString().localeCompare(b.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n )\n : []\n );\n\n return (\n <Show\n when={reflection && properties.value.length > 0}\n fallback={\n <BaseInterfaceDeclaration {...props} name={interfaceName.value} />\n }>\n <ReflectionClassContext.Provider\n value={{\n reflection: reflection!\n }}>\n <TSDocReflectionClass<T> heading={doc} reflection={reflection!} />\n <BaseInterfaceDeclaration\n export={true}\n name={interfaceName.value}\n {...rest}>\n <For each={properties} doubleHardline={true} semicolon={true}>\n {prop => <InterfaceDeclarationProperty property={prop} />}\n </For>\n </BaseInterfaceDeclaration>\n </ReflectionClassContext.Provider>\n </Show>\n );\n}\n\n/**\n * Generates a TypeScript interface property for the given reflection class.\n */\nexport function InterfaceDeclarationProperty(\n props: InterfaceDeclarationPropertyProps\n) {\n const [{ property }, rest] = splitProps(props, [\"property\"]);\n\n return (\n <ReflectionPropertyContext.Provider value={property}>\n <TSDocContextProperty />\n <InterfaceMember\n name={property.getNameAsString()}\n readonly={property.isReadonly()}\n optional={property.isOptional()}\n nullish={property.isNullable()}\n type={stringifyType(property.getType())}\n {...rest}\n />\n </ReflectionPropertyContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAqEA,MAAU,sBAAwB,qBAAe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,OAAA,KAAA,UAAA,KAAA,YAAA,SAAA,CAAA,CAAA;;AAEJ,QAAE,gBAAa,MAAA;EACb,IAAI,OAAE;AACJ,UAAO,cAAc,WAAW,MAAI,SAAK;;EAE3C,IAAI,WAAW;AACb,UAAO,gBAAQ,0BAAa,WAAA,OAAA,EAC1B,IAAI,OAAO;AACT,WAAA,cAAA;MAEJ,CAAA,CAAA;;;AAGF,UAAO,gBAAA,uBAAA,UAAA;IACJ,OAAA,EACa,YACX;IACD,IAAE,WAAI;AACL,YAAA,CAAA,gBAAuB,sBAA0B;MAChD,SAAW;MACJ;MACN,CAAC,EAAC,gBAAe,0BAAkB,WAAiB;MACpD,UAAA;MACA,IAAA,OAAY;AACZ,cAAQ,cAAA;;MAER,EAAC,MAAA,EACF,IAAA,WAAW;AACb,aAAA,gBAAA,KAAA;OACH,MAAA;OACH,gBAAA;OACD,WAAA;2EAEC,UAAA,MACa,CAAA;OACb,CAAA;QAES,CAAC,CAAA,CAAA;;IAEL,CAAC;;EAEL,CAAC;;;;;AAMJ,SAAgB,6BAA6B,OAA0B;CACrE,MAAE,CAAA,EACD;AAED,QAAM,gBAAa,0BAAa,UAAA;EAC9B,OAAA;EACA,IAAI,WAAA;AACF,UAAK,CAAA,gBAAc,sBAAA,EAAA,CAAA,EAAA,gBAAA,iBAAA,WAAA;IACjB,IAAG,OAAO;AACR,YAAO,SAAO,iBAAA;;IAEhB,IAAI,WAAI;AACN,YAAO,SAAC,YAAkB;;IAE5B,IAAI,WAAM;AACR,YAAO,SAAE,YAAA;;IAEX,IAAC,UAAA;AACN,YAAA,SAAA,YAAA;;IAEK,IAAC,OAAA;AACJ,YAAA,cAAA,SAAA,SAAA,CAAA;;IAEC,EAAA,KAAQ,CAAC,CAAA;;EAEZ,CAAC"}
1
+ {"version":3,"file":"interface-declaration.mjs","names":[],"sources":["../../../src/typescript/components/interface-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Block,\n Children,\n childrenArray,\n computed,\n createSymbol,\n createSymbolSlot,\n effect,\n emitSymbol,\n findUnkeyedChildren,\n For,\n MemberDeclaration,\n Name,\n Namekey,\n Ref,\n Refkey,\n Show,\n splitProps,\n takeSymbols\n} from \"@alloy-js/core\";\nimport {\n CommonDeclarationProps,\n Declaration,\n ensureTypeRefContext,\n TSOutputSymbol,\n TSSymbolFlags,\n TypeParameterDescriptor,\n useTSLexicalScope,\n useTSMemberScope,\n useTSNamePolicy\n} from \"@alloy-js/typescript\";\nimport {\n ReflectionClass,\n ReflectionProperty,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport {\n ReflectionClassContext,\n ReflectionPropertyContext\n} from \"../../core/contexts/reflection\";\nimport { ComponentProps } from \"../../types/components\";\nimport { MemberScope } from \"../contexts/member-scope\";\nimport { PropertyName } from \"./property-name\";\nimport { TSDoc } from \"./tsdoc\";\nimport { TSDocContextProperty, TSDocReflectionClass } from \"./tsdoc-reflection\";\nimport { TypeParameters } from \"./type-parameters\";\n\nexport interface InterfaceDeclarationProps<\n T extends Record<string, any> = Record<string, any>\n>\n extends CommonDeclarationProps, ComponentProps {\n /**\n * A base type that this interface extends. This can be used to represent inheritance\n */\n extends?: Children;\n\n /**\n * The generic type parameters of the interface.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n\n /**\n * The reflection class that describes the properties of this interface.\n *\n * @remarks\n * This is used to generate the members of the interface based on the properties of the reflection class.\n */\n reflection?: ReflectionClass<T>;\n\n /**\n * A default value for this interface.\n *\n * @remarks\n * This is used when the interface is used as a type for a variable declaration, to provide an initial value for the variable.\n */\n defaultValue?: Ref<Partial<T>>;\n\n /**\n * Documentation for the interface. This can be a string or any Alloy component that renders documentation content (such as `TSDoc`).\n */\n doc?: Children;\n}\n\nexport interface InterfaceDeclarationPropertyProps\n extends Omit<InterfaceMemberProps, \"name\">, ComponentProps {\n property: ReflectionProperty;\n defaultValue?: any;\n}\n\nexport interface InterfaceExpressionProps {\n children?: Children;\n}\n\nexport const InterfaceExpression = ensureTypeRefContext(\n function InterfaceExpression(props: InterfaceExpressionProps) {\n const scope = useTSLexicalScope();\n const symbol = createSymbol(TSOutputSymbol, \"\", undefined, {\n transient: true,\n binder: scope?.binder\n });\n\n emitSymbol(symbol);\n\n return (\n <group>\n <MemberScope ownerSymbol={symbol}>\n <Block>{props.children}</Block>\n </MemberScope>\n </group>\n );\n }\n);\n\nexport interface InterfaceMemberPropsBase {\n type?: Children;\n children?: Children;\n readonly?: boolean;\n doc?: Children;\n refkey?: Refkey | Refkey[];\n}\nexport interface InterfacePropertyMemberProps extends InterfaceMemberPropsBase {\n name: string | Namekey;\n optional?: boolean;\n nullish?: boolean;\n}\n\nexport interface InterfaceIndexerMemberProps extends InterfaceMemberPropsBase {\n indexer: Children;\n}\n\nexport type InterfaceMemberProps =\n | InterfacePropertyMemberProps\n | InterfaceIndexerMemberProps;\n\n/**\n * Create a TypeScript interface member.\n *\n * An interface member can either provide a `name` prop to create a named\n * property, or an `indexer` prop to define an indexer for the interface.\n *\n * The type of the member can be provided either as the `type` prop or as the\n * children of the component.\n */\nexport function InterfaceMember(props: InterfaceMemberProps) {\n const type = props.type ?? props.children;\n const readonly = props.readonly ? \"readonly \" : \"\";\n\n if (\"indexer\" in props) {\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n {readonly}[{props.indexer}]: {type}\n </>\n );\n }\n\n const optionality = props.optional ? \"?\" : \"\";\n const scope = useTSMemberScope();\n const sym = createSymbol(\n TSOutputSymbol,\n props.name,\n scope.ownerSymbol.staticMembers,\n {\n refkeys: props.refkey,\n tsFlags:\n TSSymbolFlags.TypeSymbol |\n ((props.nullish ?? props.optional)\n ? TSSymbolFlags.Nullish\n : TSSymbolFlags.None),\n namePolicy: useTSNamePolicy().for(\"interface-member\"),\n binder: scope.binder\n }\n );\n\n const taken = takeSymbols();\n\n effect(() => {\n if (taken.size > 1) return;\n const symbol = Array.from(taken)[0];\n if (symbol?.isTransient) {\n symbol.moveMembersTo(sym);\n }\n });\n\n return (\n <MemberDeclaration symbol={sym}>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n {readonly}\n <PropertyName />\n {optionality}: {type}\n </MemberDeclaration>\n );\n}\n\nconst BaseInterfaceDeclaration = ensureTypeRefContext(\n function InterfaceDeclaration(props: InterfaceDeclarationProps) {\n const ExprSlot = createSymbolSlot();\n\n const children = childrenArray(() => props.children);\n\n const extendsPart = props.extends ? <> extends {props.extends}</> : \"\";\n const filteredChildren = findUnkeyedChildren(children);\n const currentScope = useTSLexicalScope();\n\n const binder = currentScope?.binder;\n const sym = createSymbol(TSOutputSymbol, props.name, currentScope.types, {\n refkeys: props.refkey,\n default: props.default,\n export: props.export,\n metadata: props.metadata,\n tsFlags: TSSymbolFlags.TypeSymbol,\n namePolicy: useTSNamePolicy().for(\"interface\"),\n binder\n });\n\n effect(() => {\n if (ExprSlot.ref.value) {\n const takenSymbols = ExprSlot.ref.value;\n for (const symbol of takenSymbols) {\n // ignore non-transient symbols (likely not the result of an expression).\n if (symbol.isTransient) {\n symbol.moveMembersTo(sym);\n }\n }\n }\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <Declaration {...props} nameKind=\"interface\" kind=\"type\" symbol={sym}>\n interface <Name />\n {props.typeParameters && (\n <TypeParameters parameters={props.typeParameters} />\n )}\n {extendsPart}{\" \"}\n <ExprSlot>\n <InterfaceExpression>{filteredChildren}</InterfaceExpression>\n </ExprSlot>\n </Declaration>\n </>\n );\n }\n);\n\n/**\n * Generates a TypeScript interface for the given reflection class.\n */\nexport function InterfaceDeclaration<\n T extends Record<string, any> = Record<string, any>\n>(props: InterfaceDeclarationProps<T>) {\n const [{ name, reflection, doc, defaultValue }, rest] = splitProps(props, [\n \"name\",\n \"reflection\",\n \"doc\",\n \"defaultValue\"\n ]);\n\n const interfaceName = computed(() =>\n pascalCase(\n (isString(name) ? name : name.toString()) || reflection?.getName()\n )\n );\n\n const properties = computed(() =>\n reflection\n ? reflection\n .getProperties()\n .filter(item => !item.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) ||\n (!a.isReadonly() && !b.isReadonly())\n ? a.getNameAsString().localeCompare(b.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n )\n : []\n );\n\n return (\n <Show\n when={reflection && properties.value.length > 0}\n fallback={\n <BaseInterfaceDeclaration {...props} name={interfaceName.value} />\n }>\n <ReflectionClassContext.Provider\n value={{\n reflection: reflection!\n }}>\n <TSDocReflectionClass<T> heading={doc} reflection={reflection!} />\n <BaseInterfaceDeclaration\n export={true}\n name={interfaceName.value}\n defaultValue={defaultValue}\n {...rest}>\n <For each={properties} doubleHardline={true} semicolon={true}>\n {prop => (\n <InterfaceDeclarationProperty\n property={prop}\n defaultValue={defaultValue?.value?.[prop.getNameAsString()]}\n />\n )}\n </For>\n </BaseInterfaceDeclaration>\n </ReflectionClassContext.Provider>\n </Show>\n );\n}\n\n/**\n * Generates a TypeScript interface property for the given reflection class.\n */\nexport function InterfaceDeclarationProperty(\n props: InterfaceDeclarationPropertyProps\n) {\n const [{ property, defaultValue }, rest] = splitProps(props, [\n \"property\",\n \"defaultValue\"\n ]);\n\n return (\n <ReflectionPropertyContext.Provider value={{ property, defaultValue }}>\n <TSDocContextProperty />\n <InterfaceMember\n name={property.getNameAsString()}\n readonly={property.isReadonly()}\n optional={property.isOptional()}\n nullish={property.isNullable()}\n type={stringifyType(property.getType())}\n {...rest}\n />\n </ReflectionPropertyContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAsEA,MAAU,sBAAwB,qBAAe,SAAA,oBAAA,OAAA;CAE/C,MAAK,SAAU,aAAU,gBAAmB,IAAI,QAAQ;EACtD,WAAA;EACF,QAHE,mBAAA,EAGQ;;AAEV,YAAE,OAAA;AACF,QAAO,gBAAa,SAAc,EAChC,IAAA,WAAA;AACF,SAAA,gBAAiB,eAAyB;;GAExC,IAAA,WAAA;AACK,WAAA,gBAAsB,OAAU,EACtC,IAAA,WAAA;AACG,YAAA,MAAA;OAEF,CAAA;;;IAID,CAAC;EACF;;;;;;;;;;AA2BF,SAAc,gBAAO,OAAA;CACnB,MAAI,OAAA,MAAA,QAAA,MAAA;;AAEJ,KAAE,aAAW;;GAEX,IAAM,OAAC;AACJ,WAAK,QAAA,MAAA,IAAA;;GAEN,IAAI,WAAQ;AACV,WAAE,gBAAW,OAAA,EACb,IAAK,UAAA;AACR,YAAA,MAAA;OAEJ,CAAA;;GAED,CAAM;EAAC;EAAU;EAAA,WAAA,MAAyB,QAAA;EAAA;EAAA;EAAA;CAExC,MAAA,cAAmB,MAAA,WAAA,MAAA;CACnB,MAAA,QAAW,kBAAO;CAClB,MAAM,MAAA,aAAQ,gBAAA,MAAA,MAAA,MAAA,YAAA,eAAA;EACd,SAAS,MAAQ;EACnB,SAAA,cAAA,cAAA,MAAA,WAAA,MAAA,WAAA,cAAA,UAAA,cAAA;EACA,YAAgB,iBAAC,CAAA,IAAA,mBAAqC;EACpD,QAAM,MAAS;EACf,CAAA;CACA,MAAA,QAAU,aAAO;AACnB,cAAA;;EAEA,MAAO,SAAU,MAAA,KAAA,MAAA,CAAA;AACf,MAAA,QAAS,YACX,QAAA,cAAA,IAAA;GAEA;AACE,QAAE,gBAAA,mBAAA;EACA,QAAA;;AAEF,UAAA;IAAA,gBAAA,MAAA;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AAA,iBAAA,WAAA;IACV,IAAI,OAAO;AACT,YAAA,SAAA,iBAAA;;IAEP,IAAA,WAAA;;;IAGE,IAAA,WAAA;AACK,YAAE,SAAc,YAAW;;IAE7B,IAAC,UAAA;AACF,YAAA,SAAA,YAAA;;IAEC,IAAA,OAAO;AACL,YAAA,cAAY,SAAU,SAAA,CAAA;;IAEzB,EAAE,KAAA,CAAA,CAAA;;EAEN,CAAC"}
@@ -85,7 +85,12 @@ function ObjectDeclaration(props) {
85
85
  },
86
86
  comma: true,
87
87
  doubleHardline: true,
88
- children: (prop) => (0, _alloy_js_core_jsx_runtime.createComponent)(ObjectDeclarationProperty, { property: prop })
88
+ children: (prop) => (0, _alloy_js_core_jsx_runtime.createComponent)(ObjectDeclarationProperty, {
89
+ property: prop,
90
+ get defaultValue() {
91
+ return props.defaultValue?.value?.[prop.getNameAsString()];
92
+ }
93
+ })
89
94
  });
90
95
  } });
91
96
  } })
@@ -103,18 +108,24 @@ function ObjectDeclaration(props) {
103
108
  * Generates a TypeScript object property for the given reflection class.
104
109
  */
105
110
  function ObjectDeclarationProperty(props) {
106
- const [{ property }] = (0, _alloy_js_core.splitProps)(props, ["property"]);
111
+ const [{ property, defaultValue }] = (0, _alloy_js_core.splitProps)(props, ["property", "defaultValue"]);
107
112
  return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_reflection.ReflectionPropertyContext.Provider, {
108
- value: property,
113
+ value: {
114
+ property,
115
+ defaultValue
116
+ },
109
117
  get children() {
110
118
  return [
111
- (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_reflection.TSDocReflectionProperty, { reflection: property }),
119
+ (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_reflection.TSDocReflectionProperty, {
120
+ reflection: property,
121
+ defaultValue
122
+ }),
112
123
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ObjectProperty, {
113
124
  get name() {
114
125
  return property.getNameAsString();
115
126
  },
116
127
  get value() {
117
- return (0, _powerlines_deepkit_utilities.stringifyDefaultValue)(property);
128
+ return (0, _powerlines_deepkit_utilities.stringifyDefaultValue)(property, defaultValue);
118
129
  }
119
130
  }),
120
131
  (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
@@ -11,13 +11,14 @@ interface ObjectDeclarationProps<T extends Record<string, any> = Record<string,
11
11
  reflection?: ComputedRef<ReflectionClass<T>>;
12
12
  defaultValue?: ComputedRef<Partial<T> | undefined>;
13
13
  }
14
- interface ObjectDeclarationPropertyProps extends ComponentProps {
15
- property: ReflectionProperty;
16
- }
17
14
  /**
18
15
  * Generates a TypeScript object for the given reflection class.
19
16
  */
20
17
  declare function ObjectDeclaration<T extends Record<string, any> = Record<string, any>>(props: ObjectDeclarationProps<T>): _alloy_js_core0.Children;
18
+ interface ObjectDeclarationPropertyProps extends ComponentProps {
19
+ property: ReflectionProperty;
20
+ defaultValue?: any;
21
+ }
21
22
  /**
22
23
  * Generates a TypeScript object property for the given reflection class.
23
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"object-declaration.d.cts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":";;;;;;UAuDiB,WAAA;EAAA,SACN,KAAA,EAAO,CAAA;AAAA;AAAA,UAGD,sBAAA,WACL,MAAA,gBAAsB,MAAA,uBACxB,mBAAA;EACR,UAAA,GAAa,WAAA,CAAY,eAAA,CAAgB,CAAA;EACzC,YAAA,GAAe,WAAA,CAAY,OAAA,CAAQ,CAAA;AAAA;AAAA,UAGpB,8BAAA,SAAuC,cAAA;EACtD,QAAA,EAAU,kBAAA;AAAA;;;AARZ;iBAcgB,iBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,sBAAA,CAAuB,CAAA,IAAD,eAAA,CAAG,QAAA;;;;iBAiHlB,yBAAA,CACd,KAAA,EAAO,8BAAA,GAA8B,eAAA,CAAA,QAAA;AAAA"}
1
+ {"version":3,"file":"object-declaration.d.cts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":";;;;;;UAuDiB,WAAA;EAAA,SACN,KAAA,EAAO,CAAA;AAAA;AAAA,UAGD,sBAAA,WACL,MAAA,gBAAsB,MAAA,uBACxB,mBAAA;EACR,UAAA,GAAa,WAAA,CAAY,eAAA,CAAgB,CAAA;EACzC,YAAA,GAAe,WAAA,CAAY,OAAA,CAAQ,CAAA;AAAA;;;;iBAMrB,iBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,sBAAA,CAAuB,CAAA,IAAD,eAAA,CAAG,QAAA;AAAA,UAqHjB,8BAAA,SAAuC,cAAA;EACtD,QAAA,EAAU,kBAAA;EACV,YAAA;AAAA;;;;iBAMc,yBAAA,CACd,KAAA,EAAO,8BAAA,GAA8B,eAAA,CAAA,QAAA;AAAA"}
@@ -11,13 +11,14 @@ interface ObjectDeclarationProps<T extends Record<string, any> = Record<string,
11
11
  reflection?: ComputedRef<ReflectionClass<T>>;
12
12
  defaultValue?: ComputedRef<Partial<T> | undefined>;
13
13
  }
14
- interface ObjectDeclarationPropertyProps extends ComponentProps {
15
- property: ReflectionProperty;
16
- }
17
14
  /**
18
15
  * Generates a TypeScript object for the given reflection class.
19
16
  */
20
17
  declare function ObjectDeclaration<T extends Record<string, any> = Record<string, any>>(props: ObjectDeclarationProps<T>): _alloy_js_core0.Children;
18
+ interface ObjectDeclarationPropertyProps extends ComponentProps {
19
+ property: ReflectionProperty;
20
+ defaultValue?: any;
21
+ }
21
22
  /**
22
23
  * Generates a TypeScript object property for the given reflection class.
23
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"object-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":";;;;;;UAuDiB,WAAA;EAAA,SACN,KAAA,EAAO,CAAA;AAAA;AAAA,UAGD,sBAAA,WACL,MAAA,gBAAsB,MAAA,uBACxB,mBAAA;EACR,UAAA,GAAa,WAAA,CAAY,eAAA,CAAgB,CAAA;EACzC,YAAA,GAAe,WAAA,CAAY,OAAA,CAAQ,CAAA;AAAA;AAAA,UAGpB,8BAAA,SAAuC,cAAA;EACtD,QAAA,EAAU,kBAAA;AAAA;;;AARZ;iBAcgB,iBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,sBAAA,CAAuB,CAAA,IAAD,eAAA,CAAG,QAAA;;;;iBAiHlB,yBAAA,CACd,KAAA,EAAO,8BAAA,GAA8B,eAAA,CAAA,QAAA;AAAA"}
1
+ {"version":3,"file":"object-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":";;;;;;UAuDiB,WAAA;EAAA,SACN,KAAA,EAAO,CAAA;AAAA;AAAA,UAGD,sBAAA,WACL,MAAA,gBAAsB,MAAA,uBACxB,mBAAA;EACR,UAAA,GAAa,WAAA,CAAY,eAAA,CAAgB,CAAA;EACzC,YAAA,GAAe,WAAA,CAAY,OAAA,CAAQ,CAAA;AAAA;;;;iBAMrB,iBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,sBAAA,CAAuB,CAAA,IAAD,eAAA,CAAG,QAAA;AAAA,UAqHjB,8BAAA,SAAuC,cAAA;EACtD,QAAA,EAAU,kBAAA;EACV,YAAA;AAAA;;;;iBAMc,yBAAA,CACd,KAAA,EAAO,8BAAA,GAA8B,eAAA,CAAA,QAAA;AAAA"}
@@ -83,7 +83,12 @@ function ObjectDeclaration(props) {
83
83
  },
84
84
  comma: true,
85
85
  doubleHardline: true,
86
- children: (prop) => createComponent(ObjectDeclarationProperty, { property: prop })
86
+ children: (prop) => createComponent(ObjectDeclarationProperty, {
87
+ property: prop,
88
+ get defaultValue() {
89
+ return props.defaultValue?.value?.[prop.getNameAsString()];
90
+ }
91
+ })
87
92
  });
88
93
  } });
89
94
  } })
@@ -101,18 +106,24 @@ function ObjectDeclaration(props) {
101
106
  * Generates a TypeScript object property for the given reflection class.
102
107
  */
103
108
  function ObjectDeclarationProperty(props) {
104
- const [{ property }] = splitProps(props, ["property"]);
109
+ const [{ property, defaultValue }] = splitProps(props, ["property", "defaultValue"]);
105
110
  return createComponent(ReflectionPropertyContext.Provider, {
106
- value: property,
111
+ value: {
112
+ property,
113
+ defaultValue
114
+ },
107
115
  get children() {
108
116
  return [
109
- createComponent(TSDocReflectionProperty, { reflection: property }),
117
+ createComponent(TSDocReflectionProperty, {
118
+ reflection: property,
119
+ defaultValue
120
+ }),
110
121
  createComponent(ObjectProperty, {
111
122
  get name() {
112
123
  return property.getNameAsString();
113
124
  },
114
125
  get value() {
115
- return stringifyDefaultValue(property);
126
+ return stringifyDefaultValue(property, defaultValue);
116
127
  }
117
128
  }),
118
129
  createIntrinsic("hbr", {})
@@ -1 +1 @@
1
- {"version":3,"file":"object-declaration.mjs","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n computed,\n Declaration as CoreDeclaration,\n createSymbolSlot,\n For,\n Name,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n createValueSymbol,\n ObjectExpression,\n ObjectProperty,\n TSSymbolFlags,\n TypeRefContext,\n useTSNamePolicy,\n VarDeclarationProps\n} from \"@alloy-js/typescript\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\nimport type {\n ReflectionClass,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport {\n ReflectionClassContext,\n ReflectionPropertyContext\n} from \"../../core/contexts/reflection\";\nimport { ComponentProps } from \"../../types/components\";\nimport {\n TSDocReflectionClass,\n TSDocReflectionProperty\n} from \"./tsdoc-reflection\";\n\nexport interface ComputedRef<T = any> {\n readonly value: T;\n}\n\nexport interface ObjectDeclarationProps<\n T extends Record<string, any> = Record<string, any>\n> extends VarDeclarationProps {\n reflection?: ComputedRef<ReflectionClass<T>>;\n defaultValue?: ComputedRef<Partial<T> | undefined>;\n}\n\nexport interface ObjectDeclarationPropertyProps extends ComponentProps {\n property: ReflectionProperty;\n}\n\n/**\n * Generates a TypeScript object for the given reflection class.\n */\nexport function ObjectDeclaration<\n T extends Record<string, any> = Record<string, any>\n>(props: ObjectDeclarationProps<T>) {\n if (!props.reflection?.value) {\n return null;\n }\n\n const objectName = computed(() =>\n camelCase(\n (isString(props.name) ? props.name : props.name.toString()) ||\n props.reflection!.value.getName()\n )\n );\n const objectType = computed(\n () => props.type || pascalCase(props.reflection!.value.getName())\n );\n const properties = computed(() =>\n props\n .reflection!.value.getProperties()\n .filter(\n item =>\n !item.isIgnored() &&\n !isUndefined(\n props.defaultValue?.value?.[item.getNameAsString()] ??\n item.getAlias().reduce((ret, alias) => {\n if (\n isUndefined(ret) &&\n !isUndefined(\n (props.defaultValue as Record<string, any>)?.value?.[alias]\n )\n ) {\n return (props.defaultValue as Record<string, any>)?.value?.[\n alias\n ];\n }\n\n return ret;\n }, undefined) ??\n item.getDefaultValue()\n )\n )\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) ||\n (!a.isReadonly() && !b.isReadonly())\n ? a.getNameAsString().localeCompare(b.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n )\n );\n\n const TypeSymbolSlot = createSymbolSlot();\n const ValueTypeSymbolSlot = createSymbolSlot();\n const sym = createValueSymbol(props.name, {\n refkeys: props.refkey,\n default: props.default,\n export: props.export,\n metadata: props.metadata,\n tsFlags: props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None,\n type: props.type ? TypeSymbolSlot.firstSymbol : undefined,\n namePolicy: useTSNamePolicy().for(\"variable\")\n });\n\n if (!props.type) {\n ValueTypeSymbolSlot.moveMembersTo(sym);\n }\n\n const keyword = props.var ? \"var\" : props.let ? \"let\" : \"const\";\n const type = props.type ? (\n <TypeRefContext>\n : <TypeSymbolSlot>{props.type}</TypeSymbolSlot>\n </TypeRefContext>\n ) : undefined;\n\n return (\n <Show when={!!props.reflection.value}>\n <ReflectionClassContext.Provider\n value={{\n reflection: props.reflection.value as ReflectionClass<any>,\n override: {\n name: objectName.value,\n type: objectType.value,\n defaultValue: props.defaultValue?.value\n }\n }}>\n <Show when={!!objectName.value && !!objectType.value}>\n <TSDocReflectionClass reflection={props.reflection.value} />\n <CoreDeclaration symbol={sym}>\n {props.export ? \"export \" : \"\"}\n {props.default ? \"default \" : \"\"}\n {keyword} <Name />\n {type} ={\" \"}\n <ValueTypeSymbolSlot>\n {props.initializer ?? props.children ?? (\n <ObjectExpression>\n <For\n each={properties.value ?? []}\n comma={true}\n doubleHardline={true}>\n {prop => <ObjectDeclarationProperty property={prop} />}\n </For>\n </ObjectExpression>\n )}\n </ValueTypeSymbolSlot>\n </CoreDeclaration>\n </Show>\n <hbr />\n </ReflectionClassContext.Provider>\n </Show>\n );\n}\n\n/**\n * Generates a TypeScript object property for the given reflection class.\n */\nexport function ObjectDeclarationProperty(\n props: ObjectDeclarationPropertyProps\n) {\n const [{ property }] = splitProps(props, [\"property\"]);\n\n return (\n <ReflectionPropertyContext.Provider value={property}>\n <TSDocReflectionProperty reflection={property} />\n <ObjectProperty\n name={property.getNameAsString()}\n value={stringifyDefaultValue(property)}\n />\n <hbr />\n </ReflectionPropertyContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4CA,SAAS,kBAAqD,OAAA;AAC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BAAA,yBAAA,EACJ,YAAa,UACX,CAAA;IAAA,gBAAA,gBAAuB;KACtB,IAAA,OAAO;AACL,aAAA,SAAY,iBAAiB;;KAE/B,IAAI,QAAM;AACR,aAAO,sBAAiB,SAAA;;KAE3B,CAAC;IAAE,gBAAA,OAAA,EAAA,CAAA;IAAA;;EAEP,CAAC"}
1
+ {"version":3,"file":"object-declaration.mjs","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n computed,\n Declaration as CoreDeclaration,\n createSymbolSlot,\n For,\n Name,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n createValueSymbol,\n ObjectExpression,\n ObjectProperty,\n TSSymbolFlags,\n TypeRefContext,\n useTSNamePolicy,\n VarDeclarationProps\n} from \"@alloy-js/typescript\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\nimport type {\n ReflectionClass,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport {\n ReflectionClassContext,\n ReflectionPropertyContext\n} from \"../../core/contexts/reflection\";\nimport { ComponentProps } from \"../../types/components\";\nimport {\n TSDocReflectionClass,\n TSDocReflectionProperty\n} from \"./tsdoc-reflection\";\n\nexport interface ComputedRef<T = any> {\n readonly value: T;\n}\n\nexport interface ObjectDeclarationProps<\n T extends Record<string, any> = Record<string, any>\n> extends VarDeclarationProps {\n reflection?: ComputedRef<ReflectionClass<T>>;\n defaultValue?: ComputedRef<Partial<T> | undefined>;\n}\n\n/**\n * Generates a TypeScript object for the given reflection class.\n */\nexport function ObjectDeclaration<\n T extends Record<string, any> = Record<string, any>\n>(props: ObjectDeclarationProps<T>) {\n if (!props.reflection?.value) {\n return null;\n }\n\n const objectName = computed(() =>\n camelCase(\n (isString(props.name) ? props.name : props.name.toString()) ||\n props.reflection!.value.getName()\n )\n );\n const objectType = computed(\n () => props.type || pascalCase(props.reflection!.value.getName())\n );\n const properties = computed(() =>\n props\n .reflection!.value.getProperties()\n .filter(\n item =>\n !item.isIgnored() &&\n !isUndefined(\n props.defaultValue?.value?.[item.getNameAsString()] ??\n item.getAlias().reduce((ret, alias) => {\n if (\n isUndefined(ret) &&\n !isUndefined(\n (props.defaultValue as Record<string, any>)?.value?.[alias]\n )\n ) {\n return (props.defaultValue as Record<string, any>)?.value?.[\n alias\n ];\n }\n\n return ret;\n }, undefined) ??\n item.getDefaultValue()\n )\n )\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) ||\n (!a.isReadonly() && !b.isReadonly())\n ? a.getNameAsString().localeCompare(b.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n )\n );\n\n const TypeSymbolSlot = createSymbolSlot();\n const ValueTypeSymbolSlot = createSymbolSlot();\n const sym = createValueSymbol(props.name, {\n refkeys: props.refkey,\n default: props.default,\n export: props.export,\n metadata: props.metadata,\n tsFlags: props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None,\n type: props.type ? TypeSymbolSlot.firstSymbol : undefined,\n namePolicy: useTSNamePolicy().for(\"variable\")\n });\n\n if (!props.type) {\n ValueTypeSymbolSlot.moveMembersTo(sym);\n }\n\n const keyword = props.var ? \"var\" : props.let ? \"let\" : \"const\";\n const type = props.type ? (\n <TypeRefContext>\n : <TypeSymbolSlot>{props.type}</TypeSymbolSlot>\n </TypeRefContext>\n ) : undefined;\n\n return (\n <Show when={!!props.reflection.value}>\n <ReflectionClassContext.Provider\n value={{\n reflection: props.reflection.value as ReflectionClass<any>,\n override: {\n name: objectName.value,\n type: objectType.value,\n defaultValue: props.defaultValue?.value\n }\n }}>\n <Show when={!!objectName.value && !!objectType.value}>\n <TSDocReflectionClass reflection={props.reflection.value} />\n <CoreDeclaration symbol={sym}>\n {props.export ? \"export \" : \"\"}\n {props.default ? \"default \" : \"\"}\n {keyword} <Name />\n {type} ={\" \"}\n <ValueTypeSymbolSlot>\n {props.initializer ?? props.children ?? (\n <ObjectExpression>\n <For\n each={properties.value ?? []}\n comma={true}\n doubleHardline={true}>\n {prop => (\n <ObjectDeclarationProperty\n property={prop}\n defaultValue={\n props.defaultValue?.value?.[prop.getNameAsString()]\n }\n />\n )}\n </For>\n </ObjectExpression>\n )}\n </ValueTypeSymbolSlot>\n </CoreDeclaration>\n </Show>\n <hbr />\n </ReflectionClassContext.Provider>\n </Show>\n );\n}\n\nexport interface ObjectDeclarationPropertyProps extends ComponentProps {\n property: ReflectionProperty;\n defaultValue?: any;\n}\n\n/**\n * Generates a TypeScript object property for the given reflection class.\n */\nexport function ObjectDeclarationProperty(\n props: ObjectDeclarationPropertyProps\n) {\n const [{ property, defaultValue }] = splitProps(props, [\n \"property\",\n \"defaultValue\"\n ]);\n\n return (\n <ReflectionPropertyContext.Provider value={{ property, defaultValue }}>\n <TSDocReflectionProperty\n reflection={property}\n defaultValue={defaultValue}\n />\n <ObjectProperty\n name={property.getNameAsString()}\n value={stringifyDefaultValue(property, defaultValue)}\n />\n <hbr />\n </ReflectionPropertyContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyCA,SAAS,kBAAmD,OAAA;AAC5D,KAAM,CAAC,MAAE,YAAa,MACtB,QAAS;CAET,MAAO,aAAA,eAAA,WAAA,SAAA,MAAA,KAAA,GAAA,MAAA,OAAA,MAAA,KAAA,UAAA,KAAA,M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;KACQ;KACZ,CAAC;IAAE,gBAAkB,gBAAgB;KACpC,IAAI,OAAC;AACH,aAAO,SAAO,iBAAA;;KAEhB,IAAI,QAAQ;AACV,aAAO,sBAAgB,UAAA,aAAA;;KAE1B,CAAC;IAAE,gBAAgB,OAAA,EAAW,CAAA;IAAA;;EAElC,CAAC"}
@@ -111,7 +111,11 @@ function TSDocContextClass(props) {
111
111
  * Generates a TSDoc documentation block for the given reflection property. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. This is useful for rendering additional details about the reflection that may not be included in the description, such as information about parameters of a method or properties of a class.
112
112
  */
113
113
  function TSDocReflectionProperty(props) {
114
- const [{ children, reflection }, rest] = (0, _alloy_js_core.splitProps)(props, ["children", "reflection"]);
114
+ const [{ children, reflection, defaultValue }, rest] = (0, _alloy_js_core.splitProps)(props, [
115
+ "children",
116
+ "reflection",
117
+ "defaultValue"
118
+ ]);
115
119
  if (!(0, _stryke_type_checks.isSetObject)(reflection)) return null;
116
120
  const hasAttributes = (0, _alloy_js_core.computed)(() => (0, _stryke_type_checks_is_set_string.isSetString)(reflection.getTitle()) || !(0, _stryke_type_checks_is_undefined.isUndefined)(reflection.getAlias()) && reflection.getAlias().length > 0 || !(0, _stryke_type_checks_is_undefined.isUndefined)(reflection.getPermission()) && reflection.getPermission().length > 0 || (0, _stryke_type_checks_is_set_string.isSetString)(reflection.getDomain()) || !(0, _stryke_type_checks_is_undefined.isUndefined)(reflection.isReadonly()) || !(0, _stryke_type_checks_is_undefined.isUndefined)(reflection.isInternal()) || !(0, _stryke_type_checks_is_undefined.isUndefined)(reflection.isIgnored()) || !(0, _stryke_type_checks_is_undefined.isUndefined)(reflection.isHidden()) || reflection.hasDefault() && !(0, _stryke_type_checks_is_undefined.isUndefined)(reflection.getDefaultValue()));
117
121
  return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc.TSDoc, (0, _alloy_js_core_jsx_runtime.mergeProps)({ get heading() {
@@ -149,7 +153,7 @@ function TSDocReflectionProperty(props) {
149
153
  return reflection.isHidden();
150
154
  },
151
155
  get defaultValue() {
152
- return reflection.getDefaultValue();
156
+ return defaultValue ?? reflection.getDefaultValue();
153
157
  }
154
158
  });
155
159
  }
@@ -176,13 +180,20 @@ function TSDocReflectionProperty(props) {
176
180
  * Uses the `useReflectionProperty` hook to retrieve the reflection property from the context, and then renders a `TSDocReflectionProperty` component with the retrieved reflection property. This is a convenience component that allows you to easily render a TSDoc documentation block for the current reflection property without having to manually retrieve the reflection property from the context.
177
181
  */
178
182
  function TSDocContextProperty(props) {
179
- const reflection = require_core_contexts_reflection.useReflectionProperty();
183
+ const reflection = require_core_contexts_reflection.useReflectionPropertyContext();
180
184
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
181
185
  get when() {
182
186
  return (0, _stryke_type_checks.isSetObject)(reflection);
183
187
  },
184
188
  get children() {
185
- return (0, _alloy_js_core_jsx_runtime.createComponent)(TSDocReflectionProperty, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, { reflection }));
189
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(TSDocReflectionProperty, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, {
190
+ get reflection() {
191
+ return reflection.property;
192
+ },
193
+ get defaultValue() {
194
+ return reflection.defaultValue;
195
+ }
196
+ }));
186
197
  }
187
198
  });
188
199
  }
@@ -16,6 +16,7 @@ declare function TSDocReflectionClass<T extends Record<string, any> = Record<str
16
16
  declare function TSDocContextClass<T extends Record<string, any> = Record<string, any>>(props: TSDocProps): _alloy_js_core0.Children;
17
17
  interface TSDocReflectionPropertyProps extends TSDocProps {
18
18
  reflection: ReflectionProperty;
19
+ defaultValue?: any;
19
20
  }
20
21
  /**
21
22
  * Generates a TSDoc documentation block for the given reflection property. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. This is useful for rendering additional details about the reflection that may not be included in the description, such as information about parameters of a method or properties of a class.
@@ -1 +1 @@
1
- {"version":3,"file":"tsdoc-reflection.d.cts","names":[],"sources":["../../../src/typescript/components/tsdoc-reflection.tsx"],"mappings":";;;;;UAqDiB,yBAAA,WACL,MAAA,gBAAsB,MAAA,uBACxB,UAAA;EACR,UAAA,EAAY,eAAA,CAAgB,CAAA;AAAA;AAH9B;;;AAAA,iBASgB,oBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,yBAAA,CAA0B,CAAA,IAAD,eAAA,CAAG,QAAA;;;;iBAkFrB,iBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,UAAA,GAAU,eAAA,CAAA,QAAA;AAAA,UAaF,4BAAA,SAAqC,UAAA;EACpD,UAAA,EAAY,kBAAA;AAAA;;;;iBAME,uBAAA,CAAwB,KAAA,EAAO,4BAAA,GAA4B,eAAA,CAAA,QAAA;;;;iBA0D3D,oBAAA,CAAqB,KAAA,EAAO,UAAA,GAAU,eAAA,CAAA,QAAA;AAAA,UAUrC,0BAAA,SAAmC,UAAA;EAClD,UAAA,EAAY,gBAAA;AAAA;;;;iBAME,qBAAA,CAAsB,KAAA,EAAO,0BAAA,GAA0B,eAAA,CAAA,QAAA;;;;iBAoEvD,kBAAA,CAAmB,KAAA,EAAO,UAAA,GAAU,eAAA,CAAA,QAAA;AAAA"}
1
+ {"version":3,"file":"tsdoc-reflection.d.cts","names":[],"sources":["../../../src/typescript/components/tsdoc-reflection.tsx"],"mappings":";;;;;UAqDiB,yBAAA,WACL,MAAA,gBAAsB,MAAA,uBACxB,UAAA;EACR,UAAA,EAAY,eAAA,CAAgB,CAAA;AAAA;AAH9B;;;AAAA,iBASgB,oBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,yBAAA,CAA0B,CAAA,IAAD,eAAA,CAAG,QAAA;;;;iBAkFrB,iBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,UAAA,GAAU,eAAA,CAAA,QAAA;AAAA,UAaF,4BAAA,SAAqC,UAAA;EACpD,UAAA,EAAY,kBAAA;EACZ,YAAA;AAAA;;;;iBAMc,uBAAA,CAAwB,KAAA,EAAO,4BAAA,GAA4B,eAAA,CAAA,QAAA;;;;iBA2D3D,oBAAA,CAAqB,KAAA,EAAO,UAAA,GAAU,eAAA,CAAA,QAAA;AAAA,UAcrC,0BAAA,SAAmC,UAAA;EAClD,UAAA,EAAY,gBAAA;AAAA;;;;iBAME,qBAAA,CAAsB,KAAA,EAAO,0BAAA,GAA0B,eAAA,CAAA,QAAA;;;;iBAoEvD,kBAAA,CAAmB,KAAA,EAAO,UAAA,GAAU,eAAA,CAAA,QAAA;AAAA"}
@@ -16,6 +16,7 @@ declare function TSDocReflectionClass<T extends Record<string, any> = Record<str
16
16
  declare function TSDocContextClass<T extends Record<string, any> = Record<string, any>>(props: TSDocProps): _alloy_js_core0.Children;
17
17
  interface TSDocReflectionPropertyProps extends TSDocProps {
18
18
  reflection: ReflectionProperty;
19
+ defaultValue?: any;
19
20
  }
20
21
  /**
21
22
  * Generates a TSDoc documentation block for the given reflection property. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. This is useful for rendering additional details about the reflection that may not be included in the description, such as information about parameters of a method or properties of a class.
@@ -1 +1 @@
1
- {"version":3,"file":"tsdoc-reflection.d.mts","names":[],"sources":["../../../src/typescript/components/tsdoc-reflection.tsx"],"mappings":";;;;;UAqDiB,yBAAA,WACL,MAAA,gBAAsB,MAAA,uBACxB,UAAA;EACR,UAAA,EAAY,eAAA,CAAgB,CAAA;AAAA;AAH9B;;;AAAA,iBASgB,oBAAA,WACJ,MAAA,gBAAsB,MAAA,cAAA,CAChC,KAAA,EAAO,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EAAY,gBAAA;AAAA;;;;iBAME,qBAAA,CAAsB,KAAA,EAAO,0BAAA,GAA0B,eAAA,CAAA,QAAA;;;;iBAoEvD,kBAAA,CAAmB,KAAA,EAAO,UAAA,GAAU,eAAA,CAAA,QAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- import { useReflectionClass, useReflectionMethod, useReflectionProperty } from "../../core/contexts/reflection.mjs";
1
+ import { useReflectionClass, useReflectionMethod, useReflectionPropertyContext } from "../../core/contexts/reflection.mjs";
2
2
  import { Spacing } from "../../core/components/spacing.mjs";
3
3
  import { TSDoc, TSDocAttributesTags, TSDocParam, TSDocReturns } from "./tsdoc.mjs";
4
4
  import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
@@ -109,7 +109,11 @@ function TSDocContextClass(props) {
109
109
  * Generates a TSDoc documentation block for the given reflection property. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. This is useful for rendering additional details about the reflection that may not be included in the description, such as information about parameters of a method or properties of a class.
110
110
  */
111
111
  function TSDocReflectionProperty(props) {
112
- const [{ children, reflection }, rest] = splitProps(props, ["children", "reflection"]);
112
+ const [{ children, reflection, defaultValue }, rest] = splitProps(props, [
113
+ "children",
114
+ "reflection",
115
+ "defaultValue"
116
+ ]);
113
117
  if (!isSetObject(reflection)) return null;
114
118
  const hasAttributes = computed(() => isSetString(reflection.getTitle()) || !isUndefined(reflection.getAlias()) && reflection.getAlias().length > 0 || !isUndefined(reflection.getPermission()) && reflection.getPermission().length > 0 || isSetString(reflection.getDomain()) || !isUndefined(reflection.isReadonly()) || !isUndefined(reflection.isInternal()) || !isUndefined(reflection.isIgnored()) || !isUndefined(reflection.isHidden()) || reflection.hasDefault() && !isUndefined(reflection.getDefaultValue()));
115
119
  return createComponent(TSDoc, mergeProps({ get heading() {
@@ -147,7 +151,7 @@ function TSDocReflectionProperty(props) {
147
151
  return reflection.isHidden();
148
152
  },
149
153
  get defaultValue() {
150
- return reflection.getDefaultValue();
154
+ return defaultValue ?? reflection.getDefaultValue();
151
155
  }
152
156
  });
153
157
  }
@@ -174,13 +178,20 @@ function TSDocReflectionProperty(props) {
174
178
  * Uses the `useReflectionProperty` hook to retrieve the reflection property from the context, and then renders a `TSDocReflectionProperty` component with the retrieved reflection property. This is a convenience component that allows you to easily render a TSDoc documentation block for the current reflection property without having to manually retrieve the reflection property from the context.
175
179
  */
176
180
  function TSDocContextProperty(props) {
177
- const reflection = useReflectionProperty();
181
+ const reflection = useReflectionPropertyContext();
178
182
  return createComponent(Show, {
179
183
  get when() {
180
184
  return isSetObject(reflection);
181
185
  },
182
186
  get children() {
183
- return createComponent(TSDocReflectionProperty, mergeProps(props, { reflection }));
187
+ return createComponent(TSDocReflectionProperty, mergeProps(props, {
188
+ get reflection() {
189
+ return reflection.property;
190
+ },
191
+ get defaultValue() {
192
+ return reflection.defaultValue;
193
+ }
194
+ }));
184
195
  }
185
196
  });
186
197
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tsdoc-reflection.mjs","names":[],"sources":["../../../src/typescript/components/tsdoc-reflection.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n childrenArray,\n code,\n computed,\n For,\n List,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n ReflectionClass,\n ReflectionKind,\n ReflectionMethod,\n ReflectionProperty,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { Spacing } from \"../../core/components/spacing\";\nimport {\n useReflectionClass,\n useReflectionMethod,\n useReflectionProperty\n} from \"../../core/contexts/reflection\";\nimport {\n TSDoc,\n TSDocAttributesTags,\n TSDocParam,\n TSDocProps,\n TSDocReturns\n} from \"./tsdoc\";\n\nexport interface TSDocReflectionClassProps<\n T extends Record<string, any> = Record<string, any>\n> extends TSDocProps {\n reflection: ReflectionClass<T>;\n}\n\n/**\n * Generates a TSDoc documentation block for the given reflection class. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. This is useful for rendering additional details about the reflection that may not be included in the description, such as information about properties or methods of a class.\n */\nexport function TSDocReflectionClass<\n T extends Record<string, any> = Record<string, any>\n>(props: TSDocReflectionClassProps<T>) {\n const [{ children, heading, reflection }, rest] = splitProps(props, [\n \"heading\",\n \"children\",\n \"reflection\"\n ]);\n\n if (!isSetObject(reflection)) {\n return null;\n }\n\n const title = computed(\n () => reflection.getTitle() || titleCase(reflection.getName())\n );\n const computedHeading = computed(\n () => heading || reflection.getDescription() || title.value\n );\n\n const alias = computed(() => reflection.getAlias());\n const domain = computed(() => reflection.getDomain());\n const permission = computed(() => reflection.getPermission());\n const readonly = computed(() => reflection.isReadonly());\n const internal = computed(() => reflection.isInternal());\n const ignore = computed(() => reflection.isIgnored());\n const hidden = computed(() => reflection.isHidden());\n\n if (\n !computedHeading.value ||\n (isSetString(computedHeading.value) && computedHeading.value.trim() === \"\")\n ) {\n return null;\n }\n\n const hasAttributes = computed(\n () =>\n isSetString(title.value) ||\n (!isUndefined(alias.value) && alias.value.length > 0) ||\n (!isUndefined(permission.value) && permission.value.length > 0) ||\n isSetString(domain.value) ||\n !isUndefined(readonly.value) ||\n !isUndefined(internal.value) ||\n !isUndefined(ignore.value) ||\n !isUndefined(hidden.value)\n );\n\n return (\n <TSDoc\n {...rest}\n heading={\n isSetString(computedHeading.value)\n ? computedHeading.value.trim()\n : computedHeading.value\n }>\n <Show when={hasAttributes.value}>\n <TSDocAttributesTags\n title={title.value}\n alias={alias.value}\n domain={domain.value}\n permission={permission.value}\n readonly={readonly.value}\n internal={internal.value}\n ignore={ignore.value}\n hidden={hidden.value}\n />\n </Show>\n <Show\n when={\n !isUndefined(children) &&\n childrenArray(() => children).filter(Boolean).length > 0\n }>\n <Show when={hasAttributes.value}>\n <Spacing />\n </Show>\n <List>{childrenArray(() => children)}</List>\n </Show>\n </TSDoc>\n );\n}\n\n/**\n * Uses the `useReflectionClass` hook to retrieve the reflection class from the context, and then renders a `TSDocReflectionClass` component with the retrieved reflection class. This is a convenience component that allows you to easily render a TSDoc documentation block for the current reflection class without having to manually retrieve the reflection class from the context.\n */\nexport function TSDocContextClass<\n T extends Record<string, any> = Record<string, any>\n>(props: TSDocProps) {\n const reflectionClass = useReflectionClass<T>();\n\n return (\n <Show when={isSetObject(reflectionClass.reflection)}>\n <TSDocReflectionClass\n {...props}\n reflection={reflectionClass.reflection}\n />\n </Show>\n );\n}\n\nexport interface TSDocReflectionPropertyProps extends TSDocProps {\n reflection: ReflectionProperty;\n}\n\n/**\n * Generates a TSDoc documentation block for the given reflection property. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. This is useful for rendering additional details about the reflection that may not be included in the description, such as information about parameters of a method or properties of a class.\n */\nexport function TSDocReflectionProperty(props: TSDocReflectionPropertyProps) {\n const [{ children, reflection }, rest] = splitProps(props, [\n \"children\",\n \"reflection\"\n ]);\n\n if (!isSetObject(reflection)) {\n return null;\n }\n\n const hasAttributes = computed(\n () =>\n isSetString(reflection.getTitle()) ||\n (!isUndefined(reflection.getAlias()) &&\n reflection.getAlias().length > 0) ||\n (!isUndefined(reflection.getPermission()) &&\n reflection.getPermission().length > 0) ||\n isSetString(reflection.getDomain()) ||\n !isUndefined(reflection.isReadonly()) ||\n !isUndefined(reflection.isInternal()) ||\n !isUndefined(reflection.isIgnored()) ||\n !isUndefined(reflection.isHidden()) ||\n (reflection.hasDefault() && !isUndefined(reflection.getDefaultValue()))\n );\n\n return (\n <TSDoc heading={reflection.getDescription()} {...rest}>\n <Show when={hasAttributes.value}>\n <TSDocAttributesTags\n type={reflection}\n title={reflection.getTitle()}\n alias={reflection.getAlias()}\n domain={reflection.getDomain()}\n permission={reflection.getPermission()}\n readonly={reflection.isReadonly()}\n internal={reflection.isInternal()}\n ignore={reflection.isIgnored()}\n hidden={reflection.isHidden()}\n defaultValue={reflection.getDefaultValue()}\n />\n </Show>\n <Show\n when={\n !isUndefined(children) &&\n childrenArray(() => children).filter(Boolean).length > 0\n }>\n <Show when={hasAttributes.value}>\n <Spacing />\n </Show>\n <List>{childrenArray(() => children)}</List>\n </Show>\n </TSDoc>\n );\n}\n\n/**\n * Uses the `useReflectionProperty` hook to retrieve the reflection property from the context, and then renders a `TSDocReflectionProperty` component with the retrieved reflection property. This is a convenience component that allows you to easily render a TSDoc documentation block for the current reflection property without having to manually retrieve the reflection property from the context.\n */\nexport function TSDocContextProperty(props: TSDocProps) {\n const reflection = useReflectionProperty();\n\n return (\n <Show when={isSetObject(reflection)}>\n <TSDocReflectionProperty {...props} reflection={reflection} />\n </Show>\n );\n}\n\nexport interface TSDocReflectionMethodProps extends TSDocProps {\n reflection: ReflectionMethod;\n}\n\n/**\n * Generates a TSDoc documentation block for the given reflection method. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. Additionally, this component will render information about the parameters and return type of the method, if available.\n */\nexport function TSDocReflectionMethod(props: TSDocReflectionMethodProps) {\n const [{ children, reflection }, rest] = splitProps(props, [\n \"children\",\n \"reflection\"\n ]);\n\n if (!isSetObject(reflection)) {\n return null;\n }\n\n const heading = computed(\n () =>\n reflection.getDescription() ||\n (isString(reflection.getName())\n ? code`${String(reflection.getName())} method definition`\n : undefined)\n );\n\n return (\n <TSDoc heading={heading.value} {...rest}>\n <TSDocAttributesTags\n title={reflection.getTitle()}\n alias={reflection.getAlias()}\n domain={reflection.getDomain()}\n permission={reflection.getPermission()}\n readonly={reflection.isReadonly()}\n internal={reflection.isInternal()}\n ignore={reflection.isIgnored()}\n hidden={reflection.isHidden()}\n />\n <Show\n when={Boolean(children) && childrenArray(() => children).length > 0}>\n <List>{childrenArray(() => children)}</List>\n </Show>\n <Show when={reflection.getParameters().length > 0}>\n <Spacing />\n <For each={reflection.getParameters()} hardline ender={<hbr />}>\n {param => (\n <TSDocParam\n name={param.getName()}\n optional={param.isOptional()}\n defaultValue={\n param.hasDefault() ? param.getDefaultValue() : undefined\n }>\n <Show\n when={Boolean(param.parameter.description)}\n fallback={code`A parameter to provide a ${param.getName()} value to the function.`}>\n {param.parameter.description}\n </Show>\n </TSDocParam>\n )}\n </For>\n </Show>\n <Show when={reflection.getReturnType().kind !== ReflectionKind.void}>\n <Spacing />\n <TSDocReturns>\n {code`The return value of the function, which is of type ${stringifyType(\n reflection.getReturnType()\n )}.`}\n </TSDocReturns>\n </Show>\n </TSDoc>\n );\n}\n\n/**\n * Uses the `useReflectionMethod` hook to retrieve the reflection method from the context, and then renders a `TSDocReflectionMethod` component with the retrieved reflection method. This is a convenience component that allows you to easily render a TSDoc documentation block for the current reflection method without having to manually retrieve the reflection method from the context.\n */\nexport function TSDocContextMethod(props: TSDocProps) {\n const reflection = useReflectionMethod();\n\n return (\n <Show when={isSetObject(reflection)}>\n <TSDocReflectionMethod {...props} reflection={reflection} />\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,SAAS,qBAAsD,OAAA;CAC/D,MAAQ,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,eAAA;;MAET,UAAU;MACV,IAAE,QAAA;AACJ,cAAA,gBAAY,OAAA,EAAA,CAAA;;MAEX,WAAA,UAAA,gBAAA,YAAA;OACR,IAAA,OAAA;AACH,eAAA,MAAA,SAAA;;OAEE,IAAA,WAAA;AACW,eAAA,MAAA,YAA4B;;OAElC,IAAS,eAAA;AACR,eAAa,WAAA,CAAA,CAAA,MAAqB,YAAA,CAAA,EAAA,GAAA,MAAA,iBAAA,GAAA;;OAEjC,IAAA,WAAA;AACO,eAAA,gBAAwB,MAAA;SACjC,IAAA,OAAsB;AACnB,iBAAA,QAAA,MAAA,UAAA,YAAA;;SAEV,IAAA,WAAA"}
1
+ {"version":3,"file":"tsdoc-reflection.mjs","names":[],"sources":["../../../src/typescript/components/tsdoc-reflection.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n childrenArray,\n code,\n computed,\n For,\n List,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n ReflectionClass,\n ReflectionKind,\n ReflectionMethod,\n ReflectionProperty,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { Spacing } from \"../../core/components/spacing\";\nimport {\n useReflectionClass,\n useReflectionMethod,\n useReflectionPropertyContext\n} from \"../../core/contexts/reflection\";\nimport {\n TSDoc,\n TSDocAttributesTags,\n TSDocParam,\n TSDocProps,\n TSDocReturns\n} from \"./tsdoc\";\n\nexport interface TSDocReflectionClassProps<\n T extends Record<string, any> = Record<string, any>\n> extends TSDocProps {\n reflection: ReflectionClass<T>;\n}\n\n/**\n * Generates a TSDoc documentation block for the given reflection class. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. This is useful for rendering additional details about the reflection that may not be included in the description, such as information about properties or methods of a class.\n */\nexport function TSDocReflectionClass<\n T extends Record<string, any> = Record<string, any>\n>(props: TSDocReflectionClassProps<T>) {\n const [{ children, heading, reflection }, rest] = splitProps(props, [\n \"heading\",\n \"children\",\n \"reflection\"\n ]);\n\n if (!isSetObject(reflection)) {\n return null;\n }\n\n const title = computed(\n () => reflection.getTitle() || titleCase(reflection.getName())\n );\n const computedHeading = computed(\n () => heading || reflection.getDescription() || title.value\n );\n\n const alias = computed(() => reflection.getAlias());\n const domain = computed(() => reflection.getDomain());\n const permission = computed(() => reflection.getPermission());\n const readonly = computed(() => reflection.isReadonly());\n const internal = computed(() => reflection.isInternal());\n const ignore = computed(() => reflection.isIgnored());\n const hidden = computed(() => reflection.isHidden());\n\n if (\n !computedHeading.value ||\n (isSetString(computedHeading.value) && computedHeading.value.trim() === \"\")\n ) {\n return null;\n }\n\n const hasAttributes = computed(\n () =>\n isSetString(title.value) ||\n (!isUndefined(alias.value) && alias.value.length > 0) ||\n (!isUndefined(permission.value) && permission.value.length > 0) ||\n isSetString(domain.value) ||\n !isUndefined(readonly.value) ||\n !isUndefined(internal.value) ||\n !isUndefined(ignore.value) ||\n !isUndefined(hidden.value)\n );\n\n return (\n <TSDoc\n {...rest}\n heading={\n isSetString(computedHeading.value)\n ? computedHeading.value.trim()\n : computedHeading.value\n }>\n <Show when={hasAttributes.value}>\n <TSDocAttributesTags\n title={title.value}\n alias={alias.value}\n domain={domain.value}\n permission={permission.value}\n readonly={readonly.value}\n internal={internal.value}\n ignore={ignore.value}\n hidden={hidden.value}\n />\n </Show>\n <Show\n when={\n !isUndefined(children) &&\n childrenArray(() => children).filter(Boolean).length > 0\n }>\n <Show when={hasAttributes.value}>\n <Spacing />\n </Show>\n <List>{childrenArray(() => children)}</List>\n </Show>\n </TSDoc>\n );\n}\n\n/**\n * Uses the `useReflectionClass` hook to retrieve the reflection class from the context, and then renders a `TSDocReflectionClass` component with the retrieved reflection class. This is a convenience component that allows you to easily render a TSDoc documentation block for the current reflection class without having to manually retrieve the reflection class from the context.\n */\nexport function TSDocContextClass<\n T extends Record<string, any> = Record<string, any>\n>(props: TSDocProps) {\n const reflectionClass = useReflectionClass<T>();\n\n return (\n <Show when={isSetObject(reflectionClass.reflection)}>\n <TSDocReflectionClass\n {...props}\n reflection={reflectionClass.reflection}\n />\n </Show>\n );\n}\n\nexport interface TSDocReflectionPropertyProps extends TSDocProps {\n reflection: ReflectionProperty;\n defaultValue?: any;\n}\n\n/**\n * Generates a TSDoc documentation block for the given reflection property. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. This is useful for rendering additional details about the reflection that may not be included in the description, such as information about parameters of a method or properties of a class.\n */\nexport function TSDocReflectionProperty(props: TSDocReflectionPropertyProps) {\n const [{ children, reflection, defaultValue }, rest] = splitProps(props, [\n \"children\",\n \"reflection\",\n \"defaultValue\"\n ]);\n\n if (!isSetObject(reflection)) {\n return null;\n }\n\n const hasAttributes = computed(\n () =>\n isSetString(reflection.getTitle()) ||\n (!isUndefined(reflection.getAlias()) &&\n reflection.getAlias().length > 0) ||\n (!isUndefined(reflection.getPermission()) &&\n reflection.getPermission().length > 0) ||\n isSetString(reflection.getDomain()) ||\n !isUndefined(reflection.isReadonly()) ||\n !isUndefined(reflection.isInternal()) ||\n !isUndefined(reflection.isIgnored()) ||\n !isUndefined(reflection.isHidden()) ||\n (reflection.hasDefault() && !isUndefined(reflection.getDefaultValue()))\n );\n\n return (\n <TSDoc heading={reflection.getDescription()} {...rest}>\n <Show when={hasAttributes.value}>\n <TSDocAttributesTags\n type={reflection}\n title={reflection.getTitle()}\n alias={reflection.getAlias()}\n domain={reflection.getDomain()}\n permission={reflection.getPermission()}\n readonly={reflection.isReadonly()}\n internal={reflection.isInternal()}\n ignore={reflection.isIgnored()}\n hidden={reflection.isHidden()}\n defaultValue={defaultValue ?? reflection.getDefaultValue()}\n />\n </Show>\n <Show\n when={\n !isUndefined(children) &&\n childrenArray(() => children).filter(Boolean).length > 0\n }>\n <Show when={hasAttributes.value}>\n <Spacing />\n </Show>\n <List>{childrenArray(() => children)}</List>\n </Show>\n </TSDoc>\n );\n}\n\n/**\n * Uses the `useReflectionProperty` hook to retrieve the reflection property from the context, and then renders a `TSDocReflectionProperty` component with the retrieved reflection property. This is a convenience component that allows you to easily render a TSDoc documentation block for the current reflection property without having to manually retrieve the reflection property from the context.\n */\nexport function TSDocContextProperty(props: TSDocProps) {\n const reflection = useReflectionPropertyContext();\n\n return (\n <Show when={isSetObject(reflection)}>\n <TSDocReflectionProperty\n {...props}\n reflection={reflection.property}\n defaultValue={reflection.defaultValue}\n />\n </Show>\n );\n}\n\nexport interface TSDocReflectionMethodProps extends TSDocProps {\n reflection: ReflectionMethod;\n}\n\n/**\n * Generates a TSDoc documentation block for the given reflection method. This component will render the description of the reflection as the main content of the documentation block, and will render any additional attributes (such as title, alias, domain, permission, etc.) as tags in the documentation block. If there are child elements provided, they will be rendered as a list below the main content of the documentation block. Additionally, this component will render information about the parameters and return type of the method, if available.\n */\nexport function TSDocReflectionMethod(props: TSDocReflectionMethodProps) {\n const [{ children, reflection }, rest] = splitProps(props, [\n \"children\",\n \"reflection\"\n ]);\n\n if (!isSetObject(reflection)) {\n return null;\n }\n\n const heading = computed(\n () =>\n reflection.getDescription() ||\n (isString(reflection.getName())\n ? code`${String(reflection.getName())} method definition`\n : undefined)\n );\n\n return (\n <TSDoc heading={heading.value} {...rest}>\n <TSDocAttributesTags\n title={reflection.getTitle()}\n alias={reflection.getAlias()}\n domain={reflection.getDomain()}\n permission={reflection.getPermission()}\n readonly={reflection.isReadonly()}\n internal={reflection.isInternal()}\n ignore={reflection.isIgnored()}\n hidden={reflection.isHidden()}\n />\n <Show\n when={Boolean(children) && childrenArray(() => children).length > 0}>\n <List>{childrenArray(() => children)}</List>\n </Show>\n <Show when={reflection.getParameters().length > 0}>\n <Spacing />\n <For each={reflection.getParameters()} hardline ender={<hbr />}>\n {param => (\n <TSDocParam\n name={param.getName()}\n optional={param.isOptional()}\n defaultValue={\n param.hasDefault() ? param.getDefaultValue() : undefined\n }>\n <Show\n when={Boolean(param.parameter.description)}\n fallback={code`A parameter to provide a ${param.getName()} value to the function.`}>\n {param.parameter.description}\n </Show>\n </TSDocParam>\n )}\n </For>\n </Show>\n <Show when={reflection.getReturnType().kind !== ReflectionKind.void}>\n <Spacing />\n <TSDocReturns>\n {code`The return value of the function, which is of type ${stringifyType(\n reflection.getReturnType()\n )}.`}\n </TSDocReturns>\n </Show>\n </TSDoc>\n );\n}\n\n/**\n * Uses the `useReflectionMethod` hook to retrieve the reflection method from the context, and then renders a `TSDocReflectionMethod` component with the retrieved reflection method. This is a convenience component that allows you to easily render a TSDoc documentation block for the current reflection method without having to manually retrieve the reflection method from the context.\n */\nexport function TSDocContextMethod(props: TSDocProps) {\n const reflection = useReflectionMethod();\n\n return (\n <Show when={isSetObject(reflection)}>\n <TSDocReflectionMethod {...props} reflection={reflection} />\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,SAAS,qBAAsD,OAAA;CAC/D,MAAQ,CAAC,EACT,UACA,SACA,cACE,QAAA,WAAkB,OAAA;EAAA;EAAA;EAAA;EAAA,CAAA;AAClB,KAAA,CAAA,YAAA,WAAmB,CACnB,QAAA;CAEF,MAAO,QAAA,eAAA,WAAA,UAAA,IAAA,UAAA,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,IAAA,QAAY;AACV,cAAA,gBAAA,OAAA,EAAA,CAAA;;MAET,WAAA,UAAA,gBAAA,YAAA;OACH,IAAA,OAAA;;;OAGa,IAAA,WAAA;AACX,eAAA,MAAA,YAAA;;OAEM,IAAU,eAAG;;;OAGP,IAAE,WAAY;AACrB,eAAA,gBAAiC,MAAA;SAC9B,IAAA,OAAA;AACP,iBAAA,QAAA,MAAA,UAAA,YAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-alloy",
3
- "version": "0.25.68",
3
+ "version": "0.25.70",
4
4
  "type": "module",
5
5
  "description": "A package containing various Alloy framework components and helper utilities.",
6
6
  "repository": {
@@ -809,9 +809,9 @@
809
809
  "@alloy-js/json": "0.23.0-dev.2",
810
810
  "@alloy-js/markdown": "0.23.0-dev.1",
811
811
  "@alloy-js/typescript": "0.23.0-dev.4",
812
- "@powerlines/deepkit": "^0.6.160",
813
- "@powerlines/plugin-babel": "^0.12.377",
814
- "@storm-software/config-tools": "^1.189.57",
812
+ "@powerlines/deepkit": "^0.6.162",
813
+ "@powerlines/plugin-babel": "^0.12.379",
814
+ "@storm-software/config-tools": "^1.189.60",
815
815
  "@stryke/capnp": "^0.12.90",
816
816
  "@stryke/convert": "^0.6.57",
817
817
  "@stryke/fs": "^0.33.64",
@@ -823,14 +823,14 @@
823
823
  "@stryke/types": "^0.11.2",
824
824
  "@stryke/unique-id": "^0.3.75",
825
825
  "defu": "^6.1.4",
826
- "powerlines": "^0.42.22",
826
+ "powerlines": "^0.42.24",
827
827
  "prettier": "^3.8.1",
828
828
  "unctx": "^2.5.0"
829
829
  },
830
830
  "devDependencies": {
831
- "@powerlines/plugin-plugin": "^0.12.332",
831
+ "@powerlines/plugin-plugin": "^0.12.334",
832
832
  "@types/node": "^25.5.0"
833
833
  },
834
834
  "publishConfig": { "access": "public" },
835
- "gitHead": "c3781ffadfbf52a06d7684294cbcdca702689ad6"
835
+ "gitHead": "7230bc7bb8f070d2188b0cade2e512c042f50783"
836
836
  }