@powerlines/plugin-alloy 0.25.25 → 0.25.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -16
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/core/components/index.cjs +1 -0
- package/dist/core/components/output.cjs +9 -8
- package/dist/core/components/output.d.cts +2 -3
- package/dist/core/components/output.d.cts.map +1 -1
- package/dist/core/components/output.d.mts +2 -3
- package/dist/core/components/output.d.mts.map +1 -1
- package/dist/core/components/single-line-comment.cjs +6 -5
- package/dist/core/components/single-line-comment.d.cts +2 -2
- package/dist/core/components/single-line-comment.d.cts.map +1 -1
- package/dist/core/components/single-line-comment.d.mts.map +1 -1
- package/dist/core/components/source-file.cjs +14 -13
- package/dist/core/components/source-file.d.cts +2 -2
- package/dist/core/components/source-file.d.cts.map +1 -1
- package/dist/core/components/source-file.d.mts +2 -2
- package/dist/core/components/source-file.d.mts.map +1 -1
- package/dist/core/components/spacing.cjs +6 -5
- package/dist/core/components/spacing.d.cts +2 -2
- package/dist/core/components/spacing.d.cts.map +1 -1
- package/dist/core/components/spacing.d.mts.map +1 -1
- package/dist/core/contexts/context.cjs +5 -4
- package/dist/core/contexts/context.d.cts +0 -1
- package/dist/core/contexts/context.d.cts.map +1 -1
- package/dist/core/contexts/context.d.mts +0 -1
- package/dist/core/contexts/context.d.mts.map +1 -1
- package/dist/core/contexts/index.cjs +1 -0
- package/dist/core/contexts/meta.cjs +5 -4
- package/dist/core/contexts/meta.d.cts.map +1 -1
- package/dist/core/contexts/meta.d.mts.map +1 -1
- package/dist/core/contexts/reflection.cjs +11 -10
- package/dist/core/contexts/reflection.d.cts.map +1 -1
- package/dist/core/contexts/reflection.d.mts.map +1 -1
- package/dist/core/helpers/code.cjs +4 -3
- package/dist/core/helpers/code.d.cts +0 -1
- package/dist/core/helpers/code.d.cts.map +1 -1
- package/dist/core/helpers/code.d.mts +0 -1
- package/dist/core/helpers/code.d.mts.map +1 -1
- package/dist/core/helpers/index.cjs +1 -0
- package/dist/core/index.cjs +1 -0
- package/dist/core/index.d.cts +0 -3
- package/dist/core/index.d.mts +0 -3
- package/dist/helpers/capnp.cjs +65 -64
- package/dist/helpers/capnp.d.cts +0 -1
- package/dist/helpers/capnp.d.cts.map +1 -1
- package/dist/helpers/capnp.d.mts +0 -1
- package/dist/helpers/capnp.d.mts.map +1 -1
- package/dist/helpers/capnp.mjs +3 -3
- package/dist/helpers/create-builtin.cjs +4 -3
- package/dist/helpers/create-builtin.d.cts.map +1 -1
- package/dist/helpers/create-builtin.d.mts.map +1 -1
- package/dist/helpers/index.cjs +1 -0
- package/dist/helpers/refkey.cjs +4 -3
- package/dist/helpers/refkey.d.cts +0 -1
- package/dist/helpers/refkey.d.cts.map +1 -1
- package/dist/helpers/refkey.d.mts +0 -1
- package/dist/helpers/refkey.d.mts.map +1 -1
- package/dist/helpers/typescript.cjs +14 -13
- package/dist/helpers/typescript.d.cts.map +1 -1
- package/dist/helpers/typescript.d.mts.map +1 -1
- package/dist/index.cjs +8 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/markdown/components/front-matter.cjs +8 -7
- package/dist/markdown/components/front-matter.d.cts +2 -2
- package/dist/markdown/components/front-matter.d.cts.map +1 -1
- package/dist/markdown/components/front-matter.d.mts +2 -2
- package/dist/markdown/components/front-matter.d.mts.map +1 -1
- package/dist/markdown/components/index.cjs +1 -0
- package/dist/markdown/components/markdown-file.cjs +34 -33
- package/dist/markdown/components/markdown-file.d.cts +3 -3
- package/dist/markdown/components/markdown-file.d.cts.map +1 -1
- package/dist/markdown/components/markdown-file.d.mts +3 -3
- package/dist/markdown/components/markdown-file.d.mts.map +1 -1
- package/dist/markdown/components/markdown-table.cjs +26 -25
- package/dist/markdown/components/markdown-table.d.cts +4 -4
- package/dist/markdown/components/markdown-table.d.cts.map +1 -1
- package/dist/markdown/components/markdown-table.d.mts +4 -4
- package/dist/markdown/components/markdown-table.d.mts.map +1 -1
- package/dist/markdown/contexts/index.cjs +1 -0
- package/dist/markdown/contexts/markdown-table.cjs +7 -6
- package/dist/markdown/contexts/markdown-table.d.cts.map +1 -1
- package/dist/markdown/contexts/markdown-table.d.mts.map +1 -1
- package/dist/markdown/index.cjs +1 -0
- package/dist/markdown/index.d.cts +0 -2
- package/dist/markdown/index.d.mts +0 -2
- package/dist/render.cjs +10 -9
- package/dist/render.d.cts +0 -1
- package/dist/render.d.cts.map +1 -1
- package/dist/render.d.mts +0 -1
- package/dist/render.d.mts.map +1 -1
- package/dist/types/components.d.cts.map +1 -1
- package/dist/types/components.d.mts.map +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/typescript/components/builtin-file.cjs +14 -13
- package/dist/typescript/components/builtin-file.d.cts +2 -2
- package/dist/typescript/components/builtin-file.d.cts.map +1 -1
- package/dist/typescript/components/builtin-file.d.mts +2 -2
- package/dist/typescript/components/builtin-file.d.mts.map +1 -1
- package/dist/typescript/components/class-declaration.cjs +57 -56
- package/dist/typescript/components/class-declaration.d.cts.map +1 -1
- package/dist/typescript/components/class-declaration.d.mts.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +6 -5
- package/dist/typescript/components/dynamic-import-statement.d.cts +2 -2
- package/dist/typescript/components/dynamic-import-statement.d.cts.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.d.mts +2 -2
- package/dist/typescript/components/dynamic-import-statement.d.mts.map +1 -1
- package/dist/typescript/components/entry-file.cjs +12 -11
- package/dist/typescript/components/entry-file.d.cts +2 -2
- package/dist/typescript/components/entry-file.d.cts.map +1 -1
- package/dist/typescript/components/entry-file.d.mts +2 -2
- package/dist/typescript/components/entry-file.d.mts.map +1 -1
- package/dist/typescript/components/index.cjs +1 -0
- package/dist/typescript/components/infrastructure-file.cjs +11 -10
- package/dist/typescript/components/infrastructure-file.d.cts +2 -2
- package/dist/typescript/components/infrastructure-file.d.cts.map +1 -1
- package/dist/typescript/components/infrastructure-file.d.mts +2 -2
- package/dist/typescript/components/infrastructure-file.d.mts.map +1 -1
- package/dist/typescript/components/interface-declaration.cjs +59 -58
- package/dist/typescript/components/interface-declaration.d.cts +2 -2
- package/dist/typescript/components/interface-declaration.d.cts.map +1 -1
- package/dist/typescript/components/interface-declaration.d.mts +2 -2
- package/dist/typescript/components/interface-declaration.d.mts.map +1 -1
- package/dist/typescript/components/interface-declaration.mjs +2 -2
- package/dist/typescript/components/object-declaration.cjs +40 -39
- package/dist/typescript/components/object-declaration.d.cts +3 -3
- package/dist/typescript/components/object-declaration.d.cts.map +1 -1
- package/dist/typescript/components/object-declaration.d.mts +3 -3
- package/dist/typescript/components/object-declaration.d.mts.map +1 -1
- package/dist/typescript/components/property-name.cjs +8 -7
- package/dist/typescript/components/property-name.d.cts +2 -2
- package/dist/typescript/components/property-name.d.cts.map +1 -1
- package/dist/typescript/components/property-name.d.mts +2 -2
- package/dist/typescript/components/property-name.d.mts.map +1 -1
- package/dist/typescript/components/record-expression.cjs +4 -3
- package/dist/typescript/components/record-expression.d.cts.map +1 -1
- package/dist/typescript/components/record-expression.d.mts.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +74 -73
- package/dist/typescript/components/tsdoc-reflection.d.cts +7 -7
- package/dist/typescript/components/tsdoc-reflection.d.cts.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.d.mts +7 -7
- package/dist/typescript/components/tsdoc-reflection.d.mts.map +1 -1
- package/dist/typescript/components/tsdoc.cjs +107 -106
- package/dist/typescript/components/tsdoc.d.cts.map +1 -1
- package/dist/typescript/components/tsdoc.d.mts.map +1 -1
- package/dist/typescript/components/tsdoc.mjs +2 -2
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/components/type-declaration.cjs +11 -10
- package/dist/typescript/components/type-declaration.d.cts.map +1 -1
- package/dist/typescript/components/type-declaration.d.mts +2 -2
- package/dist/typescript/components/type-declaration.d.mts.map +1 -1
- package/dist/typescript/components/type-declaration.mjs +1 -1
- package/dist/typescript/components/type-parameters.cjs +17 -16
- package/dist/typescript/components/type-parameters.d.cts.map +1 -1
- package/dist/typescript/components/type-parameters.d.mts.map +1 -1
- package/dist/typescript/components/typescript-file.cjs +63 -62
- package/dist/typescript/components/typescript-file.d.cts.map +1 -1
- package/dist/typescript/components/typescript-file.d.mts.map +1 -1
- package/dist/typescript/contexts/index.cjs +1 -0
- package/dist/typescript/contexts/lexical-scope.cjs +8 -7
- package/dist/typescript/contexts/lexical-scope.d.cts.map +1 -1
- package/dist/typescript/contexts/lexical-scope.d.mts +2 -2
- package/dist/typescript/contexts/lexical-scope.d.mts.map +1 -1
- package/dist/typescript/contexts/member-scope.cjs +8 -7
- package/dist/typescript/contexts/member-scope.d.cts.map +1 -1
- package/dist/typescript/contexts/member-scope.d.mts.map +1 -1
- package/dist/typescript/helpers/get-call-signature-props.cjs +5 -4
- package/dist/typescript/helpers/get-call-signature-props.d.cts +0 -1
- package/dist/typescript/helpers/get-call-signature-props.d.cts.map +1 -1
- package/dist/typescript/helpers/get-call-signature-props.d.mts +0 -1
- package/dist/typescript/helpers/get-call-signature-props.d.mts.map +1 -1
- package/dist/typescript/helpers/index.cjs +1 -0
- package/dist/typescript/helpers/utilities.cjs +1 -0
- package/dist/typescript/helpers/utilities.d.cts.map +1 -1
- package/dist/typescript/helpers/utilities.d.mts.map +1 -1
- package/dist/typescript/index.cjs +1 -0
- package/dist/typescript/index.d.cts +0 -3
- package/dist/typescript/index.d.mts +0 -3
- package/dist/yaml/components/index.cjs +1 -0
- package/dist/yaml/components/yaml-file.cjs +34 -33
- package/dist/yaml/components/yaml-file.d.cts.map +1 -1
- package/dist/yaml/components/yaml-file.d.mts.map +1 -1
- package/dist/yaml/index.cjs +1 -0
- package/dist/yaml/index.d.cts +0 -1
- package/dist/yaml/index.d.mts +0 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.mts","names":[],"sources":["../../../src/core/helpers/code.ts"],"
|
|
1
|
+
{"version":3,"file":"code.d.mts","names":[],"sources":["../../../src/core/helpers/code.ts"],"mappings":";;;;;AA0CA;;;;;;;;;;;;;;;;;;;;iBAAgB,IAAA,CACd,QAAA,EAAU,oBAAA,KACP,aAAA,EAAe,QAAA,KACjB,QAAA"}
|
package/dist/core/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
const require_core_contexts_context = require('./contexts/context.cjs');
|
|
2
3
|
const require_core_contexts_meta = require('./contexts/meta.cjs');
|
|
3
4
|
const require_core_contexts_reflection = require('./contexts/reflection.cjs');
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,12 +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
3
|
import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.cjs";
|
|
4
|
-
import "./contexts/index.cjs";
|
|
5
4
|
import { Output, OutputProps, __ΩOutputProps } from "./components/output.cjs";
|
|
6
5
|
import { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant } from "./components/single-line-comment.cjs";
|
|
7
6
|
import { SourceFile, SourceFileProps, __ΩSourceFileProps } from "./components/source-file.cjs";
|
|
8
7
|
import { Spacing, SpacingProps, __ΩSpacingProps } from "./components/spacing.cjs";
|
|
9
|
-
import "./components/index.cjs";
|
|
10
8
|
import { code } from "./helpers/code.cjs";
|
|
11
|
-
import "./helpers/index.cjs";
|
|
12
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 };
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,12 +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
3
|
import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.mjs";
|
|
4
|
-
import "./contexts/index.mjs";
|
|
5
4
|
import { Output, OutputProps, __ΩOutputProps } from "./components/output.mjs";
|
|
6
5
|
import { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant } from "./components/single-line-comment.mjs";
|
|
7
6
|
import { SourceFile, SourceFileProps, __ΩSourceFileProps } from "./components/source-file.mjs";
|
|
8
7
|
import { Spacing, SpacingProps, __ΩSpacingProps } from "./components/spacing.mjs";
|
|
9
|
-
import "./components/index.mjs";
|
|
10
8
|
import { code } from "./helpers/code.mjs";
|
|
11
|
-
import "./helpers/index.mjs";
|
|
12
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 };
|
package/dist/helpers/capnp.cjs
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
let defu = require("defu");
|
|
3
|
-
defu =
|
|
4
|
-
let
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
let
|
|
13
|
-
let
|
|
14
|
-
let
|
|
15
|
-
let
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
let
|
|
19
|
-
let
|
|
20
|
-
let
|
|
21
|
-
let
|
|
4
|
+
defu = require_runtime.__toESM(defu);
|
|
5
|
+
let _powerlines_deepkit_utilities = require("@powerlines/deepkit/utilities");
|
|
6
|
+
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
7
|
+
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
8
|
+
let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
9
|
+
let _powerlines_deepkit_vendor_core = require("@powerlines/deepkit/vendor/core");
|
|
10
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
11
|
+
let _stryke_capnp_compile = require("@stryke/capnp/compile");
|
|
12
|
+
let _stryke_capnp_helpers = require("@stryke/capnp/helpers");
|
|
13
|
+
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
14
|
+
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
15
|
+
let _stryke_json = require("@stryke/json");
|
|
16
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
17
|
+
let _stryke_string_format_get_words = require("@stryke/string-format/get-words");
|
|
18
|
+
let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
19
|
+
let _stryke_type_checks_is_bigint = require("@stryke/type-checks/is-bigint");
|
|
20
|
+
let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
21
|
+
let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
22
|
+
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
22
23
|
let node_buffer = require("node:buffer");
|
|
23
24
|
let node_child_process = require("node:child_process");
|
|
24
25
|
let node_util = require("node:util");
|
|
@@ -37,15 +38,15 @@ async function compile(context, options = {}) {
|
|
|
37
38
|
ts: true,
|
|
38
39
|
js: false,
|
|
39
40
|
dts: false,
|
|
40
|
-
schemas: (0,
|
|
41
|
+
schemas: (0, _stryke_path_join.joinPaths)(context.artifactsPath, "schemas"),
|
|
41
42
|
tsconfig: context.tsconfig,
|
|
42
43
|
projectRoot: context.config.root,
|
|
43
44
|
workspaceRoot: context.workspaceConfig.workspaceRoot,
|
|
44
45
|
tty: true
|
|
45
46
|
});
|
|
46
|
-
const resolvedOptions = await (0,
|
|
47
|
-
if (!resolvedOptions) throw new Error(`✖ No Cap'n Proto schema files found in the specified source paths: ${(0,
|
|
48
|
-
return (0,
|
|
47
|
+
const resolvedOptions = await (0, _stryke_capnp_helpers.resolveOptions)(opts);
|
|
48
|
+
if (!resolvedOptions) throw new Error(`✖ No Cap'n Proto schema files found in the specified source paths: ${(0, _stryke_convert_to_array.toArray)(opts.schemas).join(", ")}.`);
|
|
49
|
+
return (0, _stryke_capnp_compile.capnpc)(resolvedOptions);
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.
|
|
@@ -65,7 +66,7 @@ function stringifyCapnpDefaultValue(property, value) {
|
|
|
65
66
|
* @returns A string representation of the value.
|
|
66
67
|
*/
|
|
67
68
|
function stringifyCapnpValue(type, value) {
|
|
68
|
-
return type.kind ===
|
|
69
|
+
return type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && (0, _stryke_type_checks_is_string.isString)(type.literal) ? `"${String(value)}"` : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.enum ? `${(0, _stryke_string_format_camel_case.camelCase)(String(value))}` : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.array ? _stryke_json.StormJSON.stringify(value) : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.object || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral ? _stryke_json.StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
@@ -74,10 +75,10 @@ function stringifyCapnpValue(type, value) {
|
|
|
74
75
|
* @returns A string representation of the property.
|
|
75
76
|
*/
|
|
76
77
|
function getCapnpEnumTypes(type) {
|
|
77
|
-
if (type.kind !==
|
|
78
|
-
const unique = (0,
|
|
78
|
+
if (type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.enum) return null;
|
|
79
|
+
const unique = (0, _stryke_helpers_get_unique.getUniqueBy)(type.values.filter((value) => !(0, _stryke_type_checks_is_undefined.isUndefined)(value) && !(0, _stryke_type_checks_is_null.isNull)(value)), (enumMember) => (0, _stryke_type_checks_is_string.isString)(enumMember) ? "Text" : "Float32");
|
|
79
80
|
if (unique.length === 0) return null;
|
|
80
|
-
return unique[0] && (0,
|
|
81
|
+
return unique[0] && (0, _stryke_type_checks_is_string.isString)(unique[0]) ? "Text" : "Float32";
|
|
81
82
|
}
|
|
82
83
|
/**
|
|
83
84
|
* Determines if a Type is a `Void` type in a Cap'n Proto schema.
|
|
@@ -86,7 +87,7 @@ function getCapnpEnumTypes(type) {
|
|
|
86
87
|
* @returns True if the Type is a `Void` type, false otherwise.
|
|
87
88
|
*/
|
|
88
89
|
function isVoidType(type) {
|
|
89
|
-
return type.kind ===
|
|
90
|
+
return type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.void || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.never || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.null || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.undefined || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.symbol;
|
|
90
91
|
}
|
|
91
92
|
/**
|
|
92
93
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
@@ -95,7 +96,7 @@ function isVoidType(type) {
|
|
|
95
96
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
96
97
|
*/
|
|
97
98
|
function getCapnpUnionTypes(type) {
|
|
98
|
-
return (0,
|
|
99
|
+
return (0, _powerlines_deepkit_utilities.getUnionTypes)(type);
|
|
99
100
|
}
|
|
100
101
|
/**
|
|
101
102
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
@@ -104,7 +105,7 @@ function getCapnpUnionTypes(type) {
|
|
|
104
105
|
* @returns An array of Cap'n Proto primitive types.
|
|
105
106
|
*/
|
|
106
107
|
function isCapnpStringUnion(type) {
|
|
107
|
-
return getCapnpUnionTypes(type).some((member) => member.kind ===
|
|
108
|
+
return getCapnpUnionTypes(type).some((member) => member.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string);
|
|
108
109
|
}
|
|
109
110
|
const LARGE_BUFFER = 1024 * 1e6;
|
|
110
111
|
const execAsync = (0, node_util.promisify)(node_child_process.exec);
|
|
@@ -124,8 +125,8 @@ ${reflection.getMethods().length === 0 ? generateCapnpStruct(reflection, options
|
|
|
124
125
|
}
|
|
125
126
|
function generateCapnpStruct(reflection, options = {}) {
|
|
126
127
|
const structName = options?.name || reflection.getTitle() || reflection.getClassName() || reflection.getName();
|
|
127
|
-
return `${generateCapnpEnums(reflection)}struct ${(0,
|
|
128
|
-
# Struct definition for ${(0,
|
|
128
|
+
return `${generateCapnpEnums(reflection)}struct ${(0, _stryke_string_format_pascal_case.pascalCase)(structName)} {
|
|
129
|
+
# Struct definition for ${(0, _stryke_string_format_title_case.titleCase)(structName)}.
|
|
129
130
|
|
|
130
131
|
${generateCapnpSchema(reflection, options)}
|
|
131
132
|
}
|
|
@@ -133,18 +134,18 @@ function generateCapnpStruct(reflection, options = {}) {
|
|
|
133
134
|
}
|
|
134
135
|
function generateCapnpInterface(reflection, options = {}) {
|
|
135
136
|
const interfaceName = options?.name || reflection.getTitle() || reflection.getClassName() || reflection.getName();
|
|
136
|
-
return `${generateCapnpEnums(reflection)}interface ${(0,
|
|
137
|
-
# Interface definition for ${(0,
|
|
137
|
+
return `${generateCapnpEnums(reflection)}interface ${(0, _stryke_string_format_pascal_case.pascalCase)(interfaceName)} {
|
|
138
|
+
# Interface definition for ${(0, _stryke_string_format_title_case.titleCase)(interfaceName)}.
|
|
138
139
|
|
|
139
140
|
${generateCapnpSchema(reflection, options)}
|
|
140
141
|
}
|
|
141
142
|
`;
|
|
142
143
|
}
|
|
143
144
|
function formatEnumName(name) {
|
|
144
|
-
return (0,
|
|
145
|
+
return (0, _stryke_string_format_pascal_case.pascalCase)(`${name}_Type`);
|
|
145
146
|
}
|
|
146
147
|
function generateCapnpEnums(reflection) {
|
|
147
|
-
const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind ===
|
|
148
|
+
const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.enum || prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union && getCapnpUnionTypes(prop.type).filter((type) => type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal))).length === 1)).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1);
|
|
148
149
|
if (enums.length === 0) return "";
|
|
149
150
|
return `${enums.map((enumeration) => generateCapnpEnumSchema(enumeration.type, formatEnumName(enumeration.getNameAsString()))).join("\n\n")}
|
|
150
151
|
|
|
@@ -153,7 +154,7 @@ function generateCapnpEnums(reflection) {
|
|
|
153
154
|
function generateCapnpSchema(reflection, options = {}) {
|
|
154
155
|
let index = 0;
|
|
155
156
|
const indexCounter = options?.indexCounter ?? (() => index++);
|
|
156
|
-
return `${reflection.getProperties().filter((prop) => !prop.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1).map((prop) => generateCapnpPropertySchema(prop, indexCounter)).join(" \n\n ")}${reflection.getMethods().filter((methods) => !methods.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? String(b.getName()).localeCompare(String(a.getName())) : a.isReadonly() ? 1 : -1).map((methods) => generateCapnpMethodSchema(methods, indexCounter)).join(" \n\n ")}${reflection.getProperties().some((prop) => prop.type.kind ===
|
|
157
|
+
return `${reflection.getProperties().filter((prop) => !prop.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1).map((prop) => generateCapnpPropertySchema(prop, indexCounter)).join(" \n\n ")}${reflection.getMethods().filter((methods) => !methods.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? String(b.getName()).localeCompare(String(a.getName())) : a.isReadonly() ? 1 : -1).map((methods) => generateCapnpMethodSchema(methods, indexCounter)).join(" \n\n ")}${reflection.getProperties().some((prop) => prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && prop.type.classType === Map) ? `
|
|
157
158
|
struct Map(Key, Value) {
|
|
158
159
|
entries @0 :List(Entry);
|
|
159
160
|
|
|
@@ -161,7 +162,7 @@ function generateCapnpSchema(reflection, options = {}) {
|
|
|
161
162
|
key @0 :Key;
|
|
162
163
|
value @1 :Value;
|
|
163
164
|
}
|
|
164
|
-
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind ===
|
|
165
|
+
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && prop.type.classType === Date) ? `
|
|
165
166
|
struct Date {
|
|
166
167
|
# A standard Gregorian calendar date.
|
|
167
168
|
|
|
@@ -185,12 +186,12 @@ function generateCapnpSchema(reflection, options = {}) {
|
|
|
185
186
|
function generateCapnpMethodSchema(reflection, indexCounter) {
|
|
186
187
|
const methodName = reflection.getTitle() || typeof reflection.getName() === "string" ? String(reflection.getName()) : "";
|
|
187
188
|
if (!methodName) throw new Error(`Cannot generate Cap'n Proto schema for method without a name - Parent interface: ${reflection.reflectionClass.getName()}`);
|
|
188
|
-
return `${(0,
|
|
189
|
-
return `${(0,
|
|
190
|
-
}).join(", ")})${isVoidType(reflection.getReturnType()) ? "" : ` -> (${(0,
|
|
189
|
+
return `${(0, _stryke_string_format_camel_case.camelCase)(methodName)} @${indexCounter()} (${reflection.getParameters().map((param) => {
|
|
190
|
+
return `${(0, _stryke_string_format_camel_case.camelCase)(param.getName())} :${generateCapnpPrimitive(param.getType())}${param.hasDefault() ? ` = ${stringifyCapnpDefaultValue(param)}` : ""}`;
|
|
191
|
+
}).join(", ")})${isVoidType(reflection.getReturnType()) ? "" : ` -> (${(0, _powerlines_deepkit_utilities.kindToName)(reflection.getReturnType().kind)}: ${generateCapnpPrimitive(reflection.getReturnType())})`}; # ${(reflection.getDescription() || `The ${(0, _stryke_string_format_title_case.titleCase)(reflection.reflectionClass.getTitle() || reflection.reflectionClass.getName())} interface ${(0, _stryke_string_format_title_case.titleCase)(methodName)} method.`).replaceAll("\n", ". ")}`;
|
|
191
192
|
}
|
|
192
193
|
function generateCapnpPropertyComment(reflection) {
|
|
193
|
-
const result = (0,
|
|
194
|
+
const result = (0, _stryke_string_format_get_words.getWords)(reflection.getDescription() || `A schema property for ${(0, _stryke_string_format_title_case.titleCase)(reflection.getTitle() || reflection.getNameAsString())} field.`, { relaxed: true }).reduce((ret, word) => {
|
|
194
195
|
let length = ret.length;
|
|
195
196
|
if (ret.includes("\n")) length = ret.substring(ret.lastIndexOf("\n") + 1).length;
|
|
196
197
|
const current = word.trim();
|
|
@@ -202,49 +203,49 @@ function generateCapnpPropertyComment(reflection) {
|
|
|
202
203
|
return "";
|
|
203
204
|
}
|
|
204
205
|
function generateCapnpPropertySchema(reflection, indexCounter) {
|
|
205
|
-
if (reflection.type.kind ===
|
|
206
|
+
if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) if (getCapnpUnionTypes(reflection.type).length === 0) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Void;
|
|
206
207
|
${generateCapnpPropertyComment(reflection)}`;
|
|
207
|
-
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind ===
|
|
208
|
+
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal))).length === 1) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
208
209
|
${generateCapnpPropertyComment(reflection)}`;
|
|
209
|
-
else return `${(0,
|
|
210
|
-
${getCapnpUnionTypes(reflection.type).map((type) => ` ${(0,
|
|
210
|
+
else return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} :union {
|
|
211
|
+
${getCapnpUnionTypes(reflection.type).map((type) => ` ${(0, _powerlines_deepkit_utilities.kindToName)(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(type)};`).join("\n")}
|
|
211
212
|
}
|
|
212
213
|
${generateCapnpPropertyComment(reflection)}`;
|
|
213
|
-
else if (reflection.type.kind ===
|
|
214
|
+
else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.array) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
214
215
|
${generateCapnpPropertyComment(reflection)}`;
|
|
215
|
-
else if (reflection.type.kind ===
|
|
216
|
+
else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class) if (reflection.type.classType === Map) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Map(${!reflection.type.typeArguments || reflection.type.typeArguments.length === 0 || !reflection.type.typeArguments[0] ? "Data" : generateCapnpPrimitive(reflection.type.typeArguments[0])}, ${!reflection.type.typeArguments || reflection.type.typeArguments.length < 2 || !reflection.type.typeArguments[1] ? "Data" : generateCapnpPrimitive(reflection.type.typeArguments[1])})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
216
217
|
${generateCapnpPropertyComment(reflection)}`;
|
|
217
|
-
else if (reflection.type.classType === Date) return `${(0,
|
|
218
|
+
else if (reflection.type.classType === Date) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
218
219
|
${generateCapnpPropertyComment(reflection)}`;
|
|
219
|
-
else if (reflection.type.classType === node_buffer.Buffer) return `${(0,
|
|
220
|
+
else if (reflection.type.classType === node_buffer.Buffer) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
220
221
|
${generateCapnpPropertyComment(reflection)}`;
|
|
221
|
-
else if (reflection.type.classType === ArrayBuffer) return `${(0,
|
|
222
|
+
else if (reflection.type.classType === ArrayBuffer) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
222
223
|
${generateCapnpPropertyComment(reflection)}`;
|
|
223
|
-
else return `${(0,
|
|
224
|
+
else return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_core.getClassName)(reflection.type.classType))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_core.getClassName)(reflection.type.classType)) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
224
225
|
${generateCapnpPropertyComment(reflection)}`;
|
|
225
|
-
else if (reflection.type.kind ===
|
|
226
|
+
else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_type.memberNameToString)(reflection.getNameAsString()))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_type.memberNameToString)(reflection.getNameAsString())) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
226
227
|
${generateCapnpPropertyComment(reflection)}`;
|
|
227
|
-
else if (reflection.type.kind ===
|
|
228
|
+
else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.enum) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
228
229
|
${generateCapnpPropertyComment(reflection)}`;
|
|
229
|
-
return `${(0,
|
|
230
|
+
return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(reflection.getType())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
230
231
|
${generateCapnpPropertyComment(reflection)}`;
|
|
231
232
|
}
|
|
232
233
|
function generateCapnpEnumSchema(type, name) {
|
|
233
|
-
if (type.kind ===
|
|
234
|
-
kind:
|
|
234
|
+
if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) return generateCapnpEnumSchema({
|
|
235
|
+
kind: _powerlines_deepkit_vendor_type.ReflectionKind.enum,
|
|
235
236
|
indexType: type,
|
|
236
|
-
enum: type.types.reduce((ret, type
|
|
237
|
-
if ((0,
|
|
237
|
+
enum: type.types.reduce((ret, type) => {
|
|
238
|
+
if ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal)) ret[(0, _stryke_string_format_camel_case.camelCase)(String(type.literal))] = type.literal;
|
|
238
239
|
return ret;
|
|
239
240
|
}, {}),
|
|
240
|
-
values: getCapnpUnionTypes(type).filter((type
|
|
241
|
+
values: getCapnpUnionTypes(type).filter((type) => type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal))).map((type) => type.literal)
|
|
241
242
|
}, name);
|
|
242
243
|
let index = 0;
|
|
243
244
|
const indexCounter = () => index++;
|
|
244
245
|
const enumType = getCapnpEnumTypes(type);
|
|
245
246
|
if (!enumType) return "";
|
|
246
|
-
return `enum ${(0,
|
|
247
|
-
${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).filter(([, value]) => value !== null && value !== void 0).map(([key]) => ` ${(0,
|
|
247
|
+
return `enum ${(0, _stryke_string_format_pascal_case.pascalCase)(name)} {
|
|
248
|
+
${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).filter(([, value]) => value !== null && value !== void 0).map(([key]) => ` ${(0, _stryke_string_format_camel_case.camelCase)(key)} @${indexCounter()};`).join("\n") : type.values.filter((value) => value !== null && value !== void 0).map((value) => `${enumType === "Text" && value ? (0, _stryke_string_format_camel_case.camelCase)(String(value)) : `${type.typeName ? `${(0, _stryke_string_format_camel_case.camelCase)(type.typeName)}_` : ""}${value || ""}`} @${indexCounter()};`).join("\n")}
|
|
248
249
|
}`;
|
|
249
250
|
}
|
|
250
251
|
/**
|
|
@@ -254,7 +255,7 @@ ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).
|
|
|
254
255
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
255
256
|
*/
|
|
256
257
|
function generateCapnpPrimitive(type) {
|
|
257
|
-
return type.kind ===
|
|
258
|
+
return type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.never || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.void || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.null || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.undefined || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.symbol ? "Void" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && type.classType === Date ? "Date" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && type.classType === Set ? `List(${type.typeArguments && type.typeArguments[0] ? generateCapnpPrimitive(type.typeArguments[0]) : "Data"})` : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.bigint ? "UInt64" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number ? "Float64" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.regexp ? "Text" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "Bool" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal ? (0, _stryke_type_checks_is_number.isNumber)(type.literal) ? "Float64" : (0, _stryke_type_checks_is_bigint.isBigInt)(type.literal) ? "UInt64" : (0, _stryke_type_checks_is_string.isString)(type.literal) ? "Text" : typeof type.literal === "boolean" ? "Bool" : "Data" : "Data";
|
|
258
259
|
}
|
|
259
260
|
|
|
260
261
|
//#endregion
|
package/dist/helpers/capnp.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capnp.d.cts","names":[],"sources":["../../src/helpers/capnp.ts"],"
|
|
1
|
+
{"version":3,"file":"capnp.d.cts","names":[],"sources":["../../src/helpers/capnp.ts"],"mappings":";;;;;;;AA8DA;;;;;iBAAsB,OAAA,CACpB,OAAA,EAAS,OAAA,EACT,OAAA,GAAS,OAAA,CAAQ,aAAA,IAChB,OAAA,CAAQ,YAAA;;;;;;;;iBA+BK,0BAAA,CACd,QAAA,EAAU,kBAAA,GAAqB,mBAAA,EAC/B,KAAA;;;;;;AAFF;;iBAiBgB,mBAAA,CAAoB,IAAA,EAAM,IAAA,EAAM,KAAA;;;;;;;iBAoBhC,iBAAA,CAAkB,IAAA,EAAM,IAAA;AApBxC;;;;;;AAAA,iBA0CgB,UAAA,CAAW,IAAA,EAAM,IAAA;;;AAtBjC;;;;iBAsCgB,kBAAA,CAAmB,IAAA,EAAM,IAAA,GAAO,IAAA;AAhBhD;;;;;AAgBA;AAhBA,iBA0BgB,kBAAA,CAAmB,IAAA,EAAM,IAAA;AAAA,cAM5B,YAAA;AAAA,KACD,MAAA;AAAA,KACA,YAAA,GACR,MAAA,GACA,KAAA,CAAM,MAAA;AAAA,iBAIY,eAAA,CAAA,GAAe,OAAA;AAAA,UAUpB,oBAAA;EACf,IAAA;AAAA;AAAA,iBAGoB,aAAA,CACpB,OAAA,EAAS,aAAA,EACT,UAAA,EAAY,eAAA,OACZ,OAAA,EAAS,oBAAA,GAAoB,OAAA;AAAA,UAgBd,0BAAA,SAAmC,oBAAA;EAClD,YAAA;AAAA;AAAA,iBAGc,mBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAAA;AAAA,iBAgBK,sBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAAA;AAAA,iBAyDK,mBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAAA;AAAA,iBA4EK,yBAAA,CACd,UAAA,EAAY,gBAAA,EACZ,YAAA;AAAA,iBA0Mc,uBAAA,CACd,IAAA,EAAM,QAAA,GAAW,SAAA,EACjB,IAAA;;AArZF;;;;;iBAudgB,sBAAA,CAAuB,IAAA,EAAM,IAAA;AAAA"}
|
package/dist/helpers/capnp.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capnp.d.mts","names":[],"sources":["../../src/helpers/capnp.ts"],"
|
|
1
|
+
{"version":3,"file":"capnp.d.mts","names":[],"sources":["../../src/helpers/capnp.ts"],"mappings":";;;;;;;AA8DA;;;;;iBAAsB,OAAA,CACpB,OAAA,EAAS,OAAA,EACT,OAAA,GAAS,OAAA,CAAQ,aAAA,IAChB,OAAA,CAAQ,YAAA;;;;;;;;iBA+BK,0BAAA,CACd,QAAA,EAAU,kBAAA,GAAqB,mBAAA,EAC/B,KAAA;;;;;;AAFF;;iBAiBgB,mBAAA,CAAoB,IAAA,EAAM,IAAA,EAAM,KAAA;;;;;;;iBAoBhC,iBAAA,CAAkB,IAAA,EAAM,IAAA;AApBxC;;;;;;AAAA,iBA0CgB,UAAA,CAAW,IAAA,EAAM,IAAA;;;AAtBjC;;;;iBAsCgB,kBAAA,CAAmB,IAAA,EAAM,IAAA,GAAO,IAAA;AAhBhD;;;;;AAgBA;AAhBA,iBA0BgB,kBAAA,CAAmB,IAAA,EAAM,IAAA;AAAA,cAM5B,YAAA;AAAA,KACD,MAAA;AAAA,KACA,YAAA,GACR,MAAA,GACA,KAAA,CAAM,MAAA;AAAA,iBAIY,eAAA,CAAA,GAAe,OAAA;AAAA,UAUpB,oBAAA;EACf,IAAA;AAAA;AAAA,iBAGoB,aAAA,CACpB,OAAA,EAAS,aAAA,EACT,UAAA,EAAY,eAAA,OACZ,OAAA,EAAS,oBAAA,GAAoB,OAAA;AAAA,UAgBd,0BAAA,SAAmC,oBAAA;EAClD,YAAA;AAAA;AAAA,iBAGc,mBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAAA;AAAA,iBAgBK,sBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAAA;AAAA,iBAyDK,mBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAAA;AAAA,iBA4EK,yBAAA,CACd,UAAA,EAAY,gBAAA,EACZ,YAAA;AAAA,iBA0Mc,uBAAA,CACd,IAAA,EAAM,QAAA,GAAW,SAAA,EACjB,IAAA;;AArZF;;;;;iBAudgB,sBAAA,CAAuB,IAAA,EAAM,IAAA;AAAA"}
|
package/dist/helpers/capnp.mjs
CHANGED
|
@@ -231,11 +231,11 @@ function generateCapnpEnumSchema(type, name) {
|
|
|
231
231
|
if (type.kind === ReflectionKind.union) return generateCapnpEnumSchema({
|
|
232
232
|
kind: ReflectionKind.enum,
|
|
233
233
|
indexType: type,
|
|
234
|
-
enum: type.types.reduce((ret, type
|
|
235
|
-
if (isString(type
|
|
234
|
+
enum: type.types.reduce((ret, type) => {
|
|
235
|
+
if (isString(type.literal) || isNumber(type.literal)) ret[camelCase(String(type.literal))] = type.literal;
|
|
236
236
|
return ret;
|
|
237
237
|
}, {}),
|
|
238
|
-
values: getCapnpUnionTypes(type).filter((type
|
|
238
|
+
values: getCapnpUnionTypes(type).filter((type) => type.kind === ReflectionKind.literal && (isString(type.literal) || isNumber(type.literal))).map((type) => type.literal)
|
|
239
239
|
}, name);
|
|
240
240
|
let index = 0;
|
|
241
241
|
const indexCounter = () => index++;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
3
4
|
|
|
4
5
|
//#region src/helpers/create-builtin.ts
|
|
5
6
|
/**
|
|
@@ -9,7 +10,7 @@ let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
|
9
10
|
* @returns An object containing reference keys for the package and a symbol creator function.
|
|
10
11
|
*/
|
|
11
12
|
function createBuiltin(options) {
|
|
12
|
-
return (0,
|
|
13
|
+
return (0, _alloy_js_typescript.createPackage)({
|
|
13
14
|
...options,
|
|
14
15
|
builtin: true
|
|
15
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-builtin.d.cts","names":[],"sources":["../../src/helpers/create-builtin.ts"],"
|
|
1
|
+
{"version":3,"file":"create-builtin.d.cts","names":[],"sources":["../../src/helpers/create-builtin.ts"],"mappings":";;;;KA0BY,oBAAA,WAA+B,iBAAA,IAAqB,IAAA,CAC9D,kBAAA,CAAmB,CAAA;;AADrB;;;;;iBAWgB,aAAA,iBAA8B,iBAAA,CAAA,CAC5C,OAAA,EAAS,oBAAA,CAAqB,CAAA,IAC7B,cAAA,CAAe,CAAA,IAAK,aAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-builtin.d.mts","names":[],"sources":["../../src/helpers/create-builtin.ts"],"
|
|
1
|
+
{"version":3,"file":"create-builtin.d.mts","names":[],"sources":["../../src/helpers/create-builtin.ts"],"mappings":";;;;KA0BY,oBAAA,WAA+B,iBAAA,IAAqB,IAAA,CAC9D,kBAAA,CAAmB,CAAA;;AADrB;;;;;iBAWgB,aAAA,iBAA8B,iBAAA,CAAA,CAC5C,OAAA,EAAS,oBAAA,CAAqB,CAAA,IAC7B,cAAA,CAAe,CAAA,IAAK,aAAA;AAAA"}
|
package/dist/helpers/index.cjs
CHANGED
package/dist/helpers/refkey.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
3
4
|
|
|
4
5
|
//#region src/helpers/refkey.ts
|
|
5
6
|
/**
|
|
@@ -9,7 +10,7 @@ let __alloy_js_core = require("@alloy-js/core");
|
|
|
9
10
|
* Values are compared using the SameValueZero algorithm, which considers objects the same if they are reference identical, and primitives the same if they are the same value, with the exception of `NaN`, which is always considered equal to other `NaN` values, and `-0`, which is considered identical to `+0`
|
|
10
11
|
*/
|
|
11
12
|
function refkey(...args) {
|
|
12
|
-
return (0,
|
|
13
|
+
return (0, _alloy_js_core.refkey)("powerlines", ...args);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Refkey } from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/helpers/refkey.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Create a refkey for the provided arguments. Passing no arguments returns a fresh refkey that is guaranteed to be unique. Otherwise, the arguments passed will be used to create a refkey for those values. Providing the same arguments will always return the same refkey.
|
|
7
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refkey.d.cts","names":[],"sources":["../../src/helpers/refkey.ts"],"
|
|
1
|
+
{"version":3,"file":"refkey.d.cts","names":[],"sources":["../../src/helpers/refkey.ts"],"mappings":";;;;;AA0BA;;;;iBAAgB,MAAA,CAAA,GAAU,IAAA,cAAkB,MAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Refkey } from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/helpers/refkey.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Create a refkey for the provided arguments. Passing no arguments returns a fresh refkey that is guaranteed to be unique. Otherwise, the arguments passed will be used to create a refkey for those values. Providing the same arguments will always return the same refkey.
|
|
7
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refkey.d.mts","names":[],"sources":["../../src/helpers/refkey.ts"],"
|
|
1
|
+
{"version":3,"file":"refkey.d.mts","names":[],"sources":["../../src/helpers/refkey.ts"],"mappings":";;;;;AA0BA;;;;iBAAgB,MAAA,CAAA,GAAU,IAAA,cAAkB,MAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
let
|
|
5
|
-
let
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _powerlines_deepkit_utilities = require("@powerlines/deepkit/utilities");
|
|
4
|
+
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
5
|
+
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
6
|
+
let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
6
7
|
|
|
7
8
|
//#region src/helpers/typescript.ts
|
|
8
9
|
/**
|
|
@@ -16,16 +17,16 @@ function generateObjectDeclaration(reflection, options = {}) {
|
|
|
16
17
|
if (!reflection) return "";
|
|
17
18
|
return `
|
|
18
19
|
/**
|
|
19
|
-
* ${reflection.getDescription() || `${(0,
|
|
20
|
+
* ${reflection.getDescription() || `${(0, _stryke_string_format_title_case.titleCase)(options.overrideName || reflection.getClassName() || reflection.getName())} object instance`}.
|
|
20
21
|
*/
|
|
21
|
-
export const ${(0,
|
|
22
|
-
${reflection.getProperties().filter((item) => !item.isIgnored() && !(0,
|
|
23
|
-
if ((0,
|
|
22
|
+
export const ${(0, _stryke_string_format_camel_case.camelCase)(options.overrideName || reflection.getName())}${options.overrideExtends !== false && (options.overrideExtends || reflection.getSuperReflectionClass()?.getName()) ? `: ${options.overrideExtends || reflection.getSuperReflectionClass()?.getName()}` : ""} = {
|
|
23
|
+
${reflection.getProperties().filter((item) => !item.isIgnored() && !(0, _stryke_type_checks_is_undefined.isUndefined)(options.defaultValues?.[item.getNameAsString()] ?? item.getAlias().reduce((ret, alias) => {
|
|
24
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(ret) && !(0, _stryke_type_checks_is_undefined.isUndefined)(options.defaultValues?.[alias])) return options.defaultValues?.[alias];
|
|
24
25
|
return ret;
|
|
25
26
|
}, void 0) ?? item.getDefaultValue())).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1).map((item) => ` /**
|
|
26
|
-
* ${item.getDescription() || item.getTitle() || (0,
|
|
27
|
+
* ${item.getDescription() || item.getTitle() || (0, _stryke_string_format_title_case.titleCase)(item.getNameAsString())}
|
|
27
28
|
*
|
|
28
|
-
* @title ${item.getTitle() || (0,
|
|
29
|
+
* @title ${item.getTitle() || (0, _stryke_string_format_title_case.titleCase)(item.getNameAsString())}${item.getAlias().length ? `
|
|
29
30
|
${item.getAlias().map((alias) => ` * @alias ${alias}`).join("\n")}` : ""}${item.getDomain() ? `
|
|
30
31
|
* @domain ${item.getDomain()}` : ""}${item.getPermission().length ? `
|
|
31
32
|
${item.getPermission().map((permission) => ` * @permission ${permission}`).join("\n")}` : ""}${item.isInternal() ? `
|
|
@@ -34,8 +35,8 @@ export const ${(0, __stryke_string_format_camel_case.camelCase)(options.override
|
|
|
34
35
|
* @ignored` : ""}${item.isHidden() ? `
|
|
35
36
|
* @hidden` : ""}
|
|
36
37
|
*/
|
|
37
|
-
${item.getNameAsString()}: ${(0,
|
|
38
|
-
if ((0,
|
|
38
|
+
${item.getNameAsString()}: ${(0, _powerlines_deepkit_utilities.stringifyValue)(item.getType(), options.defaultValues?.[item.getNameAsString()] ?? item.getAlias().reduce((ret, alias) => {
|
|
39
|
+
if ((0, _stryke_type_checks_is_undefined.isUndefined)(ret) && !(0, _stryke_type_checks_is_undefined.isUndefined)(options.defaultValues?.[alias])) return options.defaultValues?.[alias];
|
|
39
40
|
return ret;
|
|
40
41
|
}, void 0) ?? item.getDefaultValue())}`).join(", \n")}
|
|
41
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.d.cts","names":[],"sources":["../../src/helpers/typescript.ts"],"
|
|
1
|
+
{"version":3,"file":"typescript.d.cts","names":[],"sources":["../../src/helpers/typescript.ts"],"mappings":";;;UAwBiB,mCAAA;EACf,YAAA;EACA,eAAA;EACA,aAAA,GAAgB,OAAA,CAAQ,CAAA;AAAA;AAAA,UAqJT,gCAAA;EACf,YAAA;EACA,eAAA;EACA,aAAA,GAAgB,OAAA,CAAQ,CAAA;AAAA;;;;;AAH1B;;;iBAagB,yBAAA,WAAoC,MAAA,cAAA,CAClD,UAAA,EAAY,eAAA,CAAgB,CAAA,GAC5B,OAAA,GAAS,gCAAA,CAAiC,CAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.d.mts","names":[],"sources":["../../src/helpers/typescript.ts"],"
|
|
1
|
+
{"version":3,"file":"typescript.d.mts","names":[],"sources":["../../src/helpers/typescript.ts"],"mappings":";;;UAwBiB,mCAAA;EACf,YAAA;EACA,eAAA;EACA,aAAA,GAAgB,OAAA,CAAQ,CAAA;AAAA;AAAA,UAqJT,gCAAA;EACf,YAAA;EACA,eAAA;EACA,aAAA,GAAgB,OAAA,CAAQ,CAAA;AAAA;;;;;AAH1B;;;iBAagB,yBAAA,WAAoC,MAAA,cAAA,CAClD,UAAA,EAAY,eAAA,CAAgB,CAAA,GAC5B,OAAA,GAAS,gCAAA,CAAiC,CAAA;AAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
let
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_rollup_plugin = require("@alloy-js/rollup-plugin");
|
|
4
|
+
_alloy_js_rollup_plugin = require_runtime.__toESM(_alloy_js_rollup_plugin);
|
|
5
|
+
let _stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
6
6
|
|
|
7
7
|
//#region src/index.tsx
|
|
8
8
|
/**
|
|
@@ -24,7 +24,7 @@ const plugin = (options = {}) => {
|
|
|
24
24
|
resolve: { external: [/^@alloy-js\//] },
|
|
25
25
|
tsdown: {
|
|
26
26
|
inputOptions: { transform: { jsx: "preserve" } },
|
|
27
|
-
plugins: [(0,
|
|
27
|
+
plugins: [(0, _alloy_js_rollup_plugin.default)()]
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
},
|
|
@@ -34,13 +34,12 @@ const plugin = (options = {}) => {
|
|
|
34
34
|
this.tsconfig.tsconfigJson.compilerOptions ??= {};
|
|
35
35
|
if (this.tsconfig.tsconfigJson.compilerOptions.jsx !== "preserve") this.tsconfig.tsconfigJson.compilerOptions.jsx = "preserve";
|
|
36
36
|
if (this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource !== "@alloy-js/core") this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = "@alloy-js/core";
|
|
37
|
-
await this.fs.write(this.tsconfig.tsconfigFilePath,
|
|
37
|
+
await this.fs.write(this.tsconfig.tsconfigFilePath, _stryke_json_storm_json.StormJSON.stringify(this.tsconfig.tsconfigJson));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}];
|
|
41
41
|
};
|
|
42
|
-
var src_default = plugin;
|
|
43
42
|
|
|
44
43
|
//#endregion
|
|
45
|
-
exports.default =
|
|
44
|
+
exports.default = plugin;
|
|
46
45
|
exports.plugin = plugin;
|