@powerlines/plugin-alloy 0.15.4 → 0.15.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/rolldown_runtime.cjs +8 -0
- package/dist/_virtual/rolldown_runtime.mjs +0 -2
- package/dist/core/components/index.cjs +1 -1
- package/dist/core/components/index.mjs +1 -1
- package/dist/core/components/output.d.cts +2 -2
- package/dist/core/components/output.d.mts +2 -2
- package/dist/core/components/single-line-comment.d.cts +2 -2
- package/dist/core/components/single-line-comment.d.mts +2 -2
- package/dist/core/components/source-file.d.cts +2 -2
- package/dist/core/components/source-file.d.mts +2 -2
- package/dist/core/index.cjs +2 -2
- package/dist/core/index.mjs +2 -2
- package/dist/deepkit/src/utilities.cjs +113 -0
- package/dist/deepkit/src/utilities.mjs +109 -0
- package/dist/deepkit/src/vendor/core.cjs +20 -0
- package/dist/deepkit/src/vendor/core.mjs +11 -0
- package/dist/deepkit/src/vendor/type.cjs +20 -0
- package/dist/deepkit/src/vendor/type.mjs +11 -0
- package/dist/helpers/capnp.cjs +33 -33
- package/dist/helpers/capnp.mjs +29 -29
- package/dist/helpers/index.cjs +2 -2
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/typescript.cjs +3 -3
- package/dist/helpers/typescript.mjs +2 -2
- package/dist/index.cjs +22 -16
- package/dist/index.mjs +22 -16
- package/dist/markdown/components/markdown-file.d.cts +3 -3
- package/dist/markdown/components/markdown-file.d.mts +3 -3
- package/dist/markdown/components/markdown-table.d.cts +4 -4
- package/dist/markdown/components/markdown-table.d.mts +4 -4
- package/dist/powerlines/src/lib/utilities/file-header.cjs +13 -0
- package/dist/powerlines/src/lib/utilities/file-header.mjs +12 -0
- package/dist/powerlines/src/types/config.d.cts +12 -0
- package/dist/powerlines/src/types/config.d.mts +12 -0
- package/dist/powerlines/src/types/resolved.d.cts +1 -1
- package/dist/powerlines/src/types/resolved.d.mts +1 -1
- package/dist/typescript/components/builtin-file.d.cts +2 -2
- package/dist/typescript/components/builtin-file.d.mts +2 -2
- package/dist/typescript/components/dynamic-import-statement.d.cts +2 -2
- package/dist/typescript/components/dynamic-import-statement.d.mts +2 -2
- package/dist/typescript/components/entry-file.d.cts +2 -2
- package/dist/typescript/components/entry-file.d.mts +2 -2
- package/dist/typescript/components/tsdoc-reflection.cjs +2 -2
- package/dist/typescript/components/tsdoc-reflection.d.cts +4 -4
- package/dist/typescript/components/tsdoc-reflection.d.mts +4 -4
- package/dist/typescript/components/tsdoc-reflection.mjs +2 -2
- package/dist/typescript/components/tsdoc.cjs +2 -2
- package/dist/typescript/components/tsdoc.mjs +1 -1
- package/dist/typescript/components/typescript-file.cjs +2 -2
- package/dist/typescript/components/typescript-file.mjs +2 -2
- package/dist/typescript/components/typescript-interface.cjs +3 -3
- package/dist/typescript/components/typescript-interface.d.cts +3 -3
- package/dist/typescript/components/typescript-interface.d.mts +3 -3
- package/dist/typescript/components/typescript-interface.mjs +3 -3
- package/dist/typescript/components/typescript-object.cjs +5 -5
- package/dist/typescript/components/typescript-object.d.cts +3 -3
- package/dist/typescript/components/typescript-object.d.mts +3 -3
- package/dist/typescript/components/typescript-object.mjs +4 -4
- package/dist/vendor.cjs +12594 -0
- package/dist/vendor.d.cts +1 -0
- package/dist/vendor.d.ts +1 -0
- package/dist/vendor.js +12424 -0
- package/package.json +23 -7
package/dist/helpers/capnp.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const require_type = require('../deepkit/src/vendor/type.cjs');
|
|
3
|
+
const require_utilities = require('../deepkit/src/utilities.cjs');
|
|
4
|
+
const require_core = require('../deepkit/src/vendor/core.cjs');
|
|
5
|
+
const require_file_header = require('../powerlines/src/lib/utilities/file-header.cjs');
|
|
6
6
|
let defu = require("defu");
|
|
7
7
|
defu = require_rolldown_runtime.__toESM(defu);
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
11
|
-
let
|
|
8
|
+
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
9
|
+
let __stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
10
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
11
|
+
let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
12
12
|
let __stryke_capnp_compile = require("@stryke/capnp/compile");
|
|
13
13
|
let __stryke_capnp_helpers = require("@stryke/capnp/helpers");
|
|
14
14
|
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
15
|
-
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
16
15
|
let __stryke_json = require("@stryke/json");
|
|
17
16
|
let __stryke_path_join = require("@stryke/path/join");
|
|
17
|
+
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
18
18
|
let __stryke_string_format_get_words = require("@stryke/string-format/get-words");
|
|
19
|
+
let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
20
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
19
21
|
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
22
|
let __stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
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");
|
|
25
|
-
let powerlines_lib_utilities_file_header = require("powerlines/lib/utilities/file-header");
|
|
26
26
|
|
|
27
27
|
//#region src/helpers/capnp.ts
|
|
28
28
|
/**
|
|
@@ -65,7 +65,7 @@ function stringifyCapnpDefaultValue(property, value) {
|
|
|
65
65
|
* @returns A string representation of the value.
|
|
66
66
|
*/
|
|
67
67
|
function stringifyCapnpValue(type, value) {
|
|
68
|
-
return type.kind ===
|
|
68
|
+
return type.kind === require_type.type_exports.ReflectionKind.string || type.kind === require_type.type_exports.ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(type.literal) ? `"${String(value)}"` : type.kind === require_type.type_exports.ReflectionKind.enum ? `${(0, __stryke_string_format_camel_case.camelCase)(String(value))}` : type.kind === require_type.type_exports.ReflectionKind.array ? __stryke_json.StormJSON.stringify(value) : type.kind === require_type.type_exports.ReflectionKind.object || type.kind === require_type.type_exports.ReflectionKind.objectLiteral ? __stryke_json.StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
@@ -74,7 +74,7 @@ function stringifyCapnpValue(type, value) {
|
|
|
74
74
|
* @returns A string representation of the property.
|
|
75
75
|
*/
|
|
76
76
|
function getCapnpEnumTypes(type) {
|
|
77
|
-
if (type.kind !==
|
|
77
|
+
if (type.kind !== require_type.type_exports.ReflectionKind.enum) return null;
|
|
78
78
|
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
79
|
if (unique.length === 0) return null;
|
|
80
80
|
return unique[0] && (0, __stryke_type_checks_is_string.isString)(unique[0]) ? "Text" : "Float32";
|
|
@@ -86,7 +86,7 @@ function getCapnpEnumTypes(type) {
|
|
|
86
86
|
* @returns True if the Type is a `Void` type, false otherwise.
|
|
87
87
|
*/
|
|
88
88
|
function isVoidType(type) {
|
|
89
|
-
return type.kind ===
|
|
89
|
+
return type.kind === require_type.type_exports.ReflectionKind.void || type.kind === require_type.type_exports.ReflectionKind.never || type.kind === require_type.type_exports.ReflectionKind.null || type.kind === require_type.type_exports.ReflectionKind.undefined || type.kind === require_type.type_exports.ReflectionKind.symbol;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
@@ -95,7 +95,7 @@ function isVoidType(type) {
|
|
|
95
95
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
96
96
|
*/
|
|
97
97
|
function getCapnpUnionTypes(type) {
|
|
98
|
-
return
|
|
98
|
+
return require_utilities.getUnionTypes(type);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
@@ -104,7 +104,7 @@ function getCapnpUnionTypes(type) {
|
|
|
104
104
|
* @returns An array of Cap'n Proto primitive types.
|
|
105
105
|
*/
|
|
106
106
|
function isCapnpStringUnion(type) {
|
|
107
|
-
return getCapnpUnionTypes(type).some((member) => member.kind ===
|
|
107
|
+
return getCapnpUnionTypes(type).some((member) => member.kind === require_type.type_exports.ReflectionKind.string);
|
|
108
108
|
}
|
|
109
109
|
const LARGE_BUFFER = 1024 * 1e6;
|
|
110
110
|
const execAsync = (0, node_util.promisify)(node_child_process.exec);
|
|
@@ -118,7 +118,7 @@ async function generateCapnpId() {
|
|
|
118
118
|
}
|
|
119
119
|
async function generateCapnp(context, reflection, options) {
|
|
120
120
|
return `${(await generateCapnpId()).trim()};
|
|
121
|
-
${
|
|
121
|
+
${require_file_header.getBaseFileHeader(context).replace(/^\r*\n*/g, "").replaceAll("//", "#")}
|
|
122
122
|
${reflection.getMethods().length === 0 ? generateCapnpStruct(reflection, options) : generateCapnpInterface(reflection, options)}
|
|
123
123
|
`.trim();
|
|
124
124
|
}
|
|
@@ -144,7 +144,7 @@ function formatEnumName(name) {
|
|
|
144
144
|
return (0, __stryke_string_format_pascal_case.pascalCase)(`${name}_Type`);
|
|
145
145
|
}
|
|
146
146
|
function generateCapnpEnums(reflection) {
|
|
147
|
-
const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind ===
|
|
147
|
+
const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind === require_type.type_exports.ReflectionKind.enum || prop.type.kind === require_type.type_exports.ReflectionKind.union && getCapnpUnionTypes(prop.type).filter((type) => type.kind === require_type.type_exports.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
148
|
if (enums.length === 0) return "";
|
|
149
149
|
return `${enums.map((enumeration) => generateCapnpEnumSchema(enumeration.type, formatEnumName(enumeration.getNameAsString()))).join("\n\n")}
|
|
150
150
|
|
|
@@ -153,7 +153,7 @@ function generateCapnpEnums(reflection) {
|
|
|
153
153
|
function generateCapnpSchema(reflection, options = {}) {
|
|
154
154
|
let index = 0;
|
|
155
155
|
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 ===
|
|
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 === require_type.type_exports.ReflectionKind.class && prop.type.classType === Map) ? `
|
|
157
157
|
struct Map(Key, Value) {
|
|
158
158
|
entries @0 :List(Entry);
|
|
159
159
|
|
|
@@ -161,7 +161,7 @@ function generateCapnpSchema(reflection, options = {}) {
|
|
|
161
161
|
key @0 :Key;
|
|
162
162
|
value @1 :Value;
|
|
163
163
|
}
|
|
164
|
-
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind ===
|
|
164
|
+
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind === require_type.type_exports.ReflectionKind.class && prop.type.classType === Date) ? `
|
|
165
165
|
struct Date {
|
|
166
166
|
# A standard Gregorian calendar date.
|
|
167
167
|
|
|
@@ -187,7 +187,7 @@ function generateCapnpMethodSchema(reflection, indexCounter) {
|
|
|
187
187
|
if (!methodName) throw new Error(`Cannot generate Cap'n Proto schema for method without a name - Parent interface: ${reflection.reflectionClass.getName()}`);
|
|
188
188
|
return `${(0, __stryke_string_format_camel_case.camelCase)(methodName)} @${indexCounter()} (${reflection.getParameters().map((param) => {
|
|
189
189
|
return `${(0, __stryke_string_format_camel_case.camelCase)(param.getName())} :${generateCapnpPrimitive(param.getType())}${param.hasDefault() ? ` = ${stringifyCapnpDefaultValue(param)}` : ""}`;
|
|
190
|
-
}).join(", ")})${isVoidType(reflection.getReturnType()) ? "" : ` -> (${
|
|
190
|
+
}).join(", ")})${isVoidType(reflection.getReturnType()) ? "" : ` -> (${require_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
191
|
}
|
|
192
192
|
function generateCapnpPropertyComment(reflection) {
|
|
193
193
|
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) => {
|
|
@@ -202,17 +202,17 @@ function generateCapnpPropertyComment(reflection) {
|
|
|
202
202
|
return "";
|
|
203
203
|
}
|
|
204
204
|
function generateCapnpPropertySchema(reflection, indexCounter) {
|
|
205
|
-
if (reflection.type.kind ===
|
|
205
|
+
if (reflection.type.kind === require_type.type_exports.ReflectionKind.union) if (getCapnpUnionTypes(reflection.type).length === 0) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Void;
|
|
206
206
|
${generateCapnpPropertyComment(reflection)}`;
|
|
207
|
-
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind ===
|
|
207
|
+
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind === require_type.type_exports.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
208
|
${generateCapnpPropertyComment(reflection)}`;
|
|
209
209
|
else return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} :union {
|
|
210
|
-
${getCapnpUnionTypes(reflection.type).map((type) => ` ${
|
|
210
|
+
${getCapnpUnionTypes(reflection.type).map((type) => ` ${require_utilities.kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(type)};`).join("\n")}
|
|
211
211
|
}
|
|
212
212
|
${generateCapnpPropertyComment(reflection)}`;
|
|
213
|
-
else if (reflection.type.kind ===
|
|
213
|
+
else if (reflection.type.kind === require_type.type_exports.ReflectionKind.array) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
214
214
|
${generateCapnpPropertyComment(reflection)}`;
|
|
215
|
-
else if (reflection.type.kind ===
|
|
215
|
+
else if (reflection.type.kind === require_type.type_exports.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
216
|
${generateCapnpPropertyComment(reflection)}`;
|
|
217
217
|
else if (reflection.type.classType === Date) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
218
218
|
${generateCapnpPropertyComment(reflection)}`;
|
|
@@ -220,24 +220,24 @@ ${generateCapnpPropertyComment(reflection)}`;
|
|
|
220
220
|
${generateCapnpPropertyComment(reflection)}`;
|
|
221
221
|
else if (reflection.type.classType === ArrayBuffer) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
222
222
|
${generateCapnpPropertyComment(reflection)}`;
|
|
223
|
-
else return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0,
|
|
223
|
+
else return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, require_core.core_exports.getClassName)(reflection.type.classType))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, require_core.core_exports.getClassName)(reflection.type.classType)) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
224
224
|
${generateCapnpPropertyComment(reflection)}`;
|
|
225
|
-
else if (reflection.type.kind ===
|
|
225
|
+
else if (reflection.type.kind === require_type.type_exports.ReflectionKind.objectLiteral) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, require_type.type_exports.memberNameToString)(reflection.getNameAsString()))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, require_type.type_exports.memberNameToString)(reflection.getNameAsString())) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
226
226
|
${generateCapnpPropertyComment(reflection)}`;
|
|
227
|
-
else if (reflection.type.kind ===
|
|
227
|
+
else if (reflection.type.kind === require_type.type_exports.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
228
|
${generateCapnpPropertyComment(reflection)}`;
|
|
229
229
|
return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(reflection.getType())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
230
230
|
${generateCapnpPropertyComment(reflection)}`;
|
|
231
231
|
}
|
|
232
232
|
function generateCapnpEnumSchema(type, name) {
|
|
233
|
-
if (type.kind ===
|
|
234
|
-
kind:
|
|
233
|
+
if (type.kind === require_type.type_exports.ReflectionKind.union) return generateCapnpEnumSchema({
|
|
234
|
+
kind: require_type.type_exports.ReflectionKind.enum,
|
|
235
235
|
indexType: type,
|
|
236
236
|
enum: type.types.reduce((ret, type$1) => {
|
|
237
237
|
if ((0, __stryke_type_checks_is_string.isString)(type$1.literal) || (0, __stryke_type_checks_is_number.isNumber)(type$1.literal)) ret[(0, __stryke_string_format_camel_case.camelCase)(String(type$1.literal))] = type$1.literal;
|
|
238
238
|
return ret;
|
|
239
239
|
}, {}),
|
|
240
|
-
values: getCapnpUnionTypes(type).filter((type$1) => type$1.kind ===
|
|
240
|
+
values: getCapnpUnionTypes(type).filter((type$1) => type$1.kind === require_type.type_exports.ReflectionKind.literal && ((0, __stryke_type_checks_is_string.isString)(type$1.literal) || (0, __stryke_type_checks_is_number.isNumber)(type$1.literal))).map((type$1) => type$1.literal)
|
|
241
241
|
}, name);
|
|
242
242
|
let index = 0;
|
|
243
243
|
const indexCounter = () => index++;
|
|
@@ -254,7 +254,7 @@ ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).
|
|
|
254
254
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
255
255
|
*/
|
|
256
256
|
function generateCapnpPrimitive(type) {
|
|
257
|
-
return type.kind ===
|
|
257
|
+
return type.kind === require_type.type_exports.ReflectionKind.never || type.kind === require_type.type_exports.ReflectionKind.void || type.kind === require_type.type_exports.ReflectionKind.null || type.kind === require_type.type_exports.ReflectionKind.undefined || type.kind === require_type.type_exports.ReflectionKind.symbol ? "Void" : type.kind === require_type.type_exports.ReflectionKind.class && type.classType === Date ? "Date" : type.kind === require_type.type_exports.ReflectionKind.class && type.classType === Set ? `List(${type.typeArguments && type.typeArguments[0] ? generateCapnpPrimitive(type.typeArguments[0]) : "Data"})` : type.kind === require_type.type_exports.ReflectionKind.bigint ? "UInt64" : type.kind === require_type.type_exports.ReflectionKind.number ? "Float64" : type.kind === require_type.type_exports.ReflectionKind.string || type.kind === require_type.type_exports.ReflectionKind.regexp ? "Text" : type.kind === require_type.type_exports.ReflectionKind.boolean ? "Bool" : type.kind === require_type.type_exports.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
258
|
}
|
|
259
259
|
|
|
260
260
|
//#endregion
|
package/dist/helpers/capnp.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { type_exports } from "../deepkit/src/vendor/type.mjs";
|
|
2
|
+
import { getUnionTypes, kindToName } from "../deepkit/src/utilities.mjs";
|
|
3
|
+
import { core_exports } from "../deepkit/src/vendor/core.mjs";
|
|
4
|
+
import { getBaseFileHeader } from "../powerlines/src/lib/utilities/file-header.mjs";
|
|
5
5
|
import defu from "defu";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
7
|
+
import { isNull } from "@stryke/type-checks/is-null";
|
|
8
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
9
|
+
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
10
10
|
import { capnpc } from "@stryke/capnp/compile";
|
|
11
11
|
import { resolveOptions } from "@stryke/capnp/helpers";
|
|
12
12
|
import { toArray } from "@stryke/convert/to-array";
|
|
13
|
-
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
14
13
|
import { StormJSON } from "@stryke/json";
|
|
15
14
|
import { joinPaths } from "@stryke/path/join";
|
|
15
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
16
16
|
import { getWords } from "@stryke/string-format/get-words";
|
|
17
|
+
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
18
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
17
19
|
import { isBigInt } from "@stryke/type-checks/is-bigint";
|
|
18
|
-
import { isNull } from "@stryke/type-checks/is-null";
|
|
19
20
|
import { isNumber } from "@stryke/type-checks/is-number";
|
|
20
21
|
import { Buffer } from "node:buffer";
|
|
21
22
|
import { exec } from "node:child_process";
|
|
22
23
|
import { promisify } from "node:util";
|
|
23
|
-
import { getBaseFileHeader } from "powerlines/lib/utilities/file-header";
|
|
24
24
|
|
|
25
25
|
//#region src/helpers/capnp.ts
|
|
26
26
|
/**
|
|
@@ -63,7 +63,7 @@ function stringifyCapnpDefaultValue(property, value) {
|
|
|
63
63
|
* @returns A string representation of the value.
|
|
64
64
|
*/
|
|
65
65
|
function stringifyCapnpValue(type, value) {
|
|
66
|
-
return type.kind === ReflectionKind.string || type.kind === ReflectionKind.literal && isString(type.literal) ? `"${String(value)}"` : type.kind === ReflectionKind.enum ? `${camelCase(String(value))}` : type.kind === ReflectionKind.array ? StormJSON.stringify(value) : type.kind === ReflectionKind.object || type.kind === ReflectionKind.objectLiteral ? StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
|
|
66
|
+
return type.kind === type_exports.ReflectionKind.string || type.kind === type_exports.ReflectionKind.literal && isString(type.literal) ? `"${String(value)}"` : type.kind === type_exports.ReflectionKind.enum ? `${camelCase(String(value))}` : type.kind === type_exports.ReflectionKind.array ? StormJSON.stringify(value) : type.kind === type_exports.ReflectionKind.object || type.kind === type_exports.ReflectionKind.objectLiteral ? StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
@@ -72,7 +72,7 @@ function stringifyCapnpValue(type, value) {
|
|
|
72
72
|
* @returns A string representation of the property.
|
|
73
73
|
*/
|
|
74
74
|
function getCapnpEnumTypes(type) {
|
|
75
|
-
if (type.kind !== ReflectionKind.enum) return null;
|
|
75
|
+
if (type.kind !== type_exports.ReflectionKind.enum) return null;
|
|
76
76
|
const unique = getUniqueBy(type.values.filter((value) => !isUndefined(value) && !isNull(value)), (enumMember) => isString(enumMember) ? "Text" : "Float32");
|
|
77
77
|
if (unique.length === 0) return null;
|
|
78
78
|
return unique[0] && isString(unique[0]) ? "Text" : "Float32";
|
|
@@ -84,7 +84,7 @@ function getCapnpEnumTypes(type) {
|
|
|
84
84
|
* @returns True if the Type is a `Void` type, false otherwise.
|
|
85
85
|
*/
|
|
86
86
|
function isVoidType(type) {
|
|
87
|
-
return type.kind === ReflectionKind.void || type.kind === ReflectionKind.never || type.kind === ReflectionKind.null || type.kind === ReflectionKind.undefined || type.kind === ReflectionKind.symbol;
|
|
87
|
+
return type.kind === type_exports.ReflectionKind.void || type.kind === type_exports.ReflectionKind.never || type.kind === type_exports.ReflectionKind.null || type.kind === type_exports.ReflectionKind.undefined || type.kind === type_exports.ReflectionKind.symbol;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
@@ -102,7 +102,7 @@ function getCapnpUnionTypes(type) {
|
|
|
102
102
|
* @returns An array of Cap'n Proto primitive types.
|
|
103
103
|
*/
|
|
104
104
|
function isCapnpStringUnion(type) {
|
|
105
|
-
return getCapnpUnionTypes(type).some((member) => member.kind === ReflectionKind.string);
|
|
105
|
+
return getCapnpUnionTypes(type).some((member) => member.kind === type_exports.ReflectionKind.string);
|
|
106
106
|
}
|
|
107
107
|
const LARGE_BUFFER = 1024 * 1e6;
|
|
108
108
|
const execAsync = promisify(exec);
|
|
@@ -142,7 +142,7 @@ function formatEnumName(name) {
|
|
|
142
142
|
return pascalCase(`${name}_Type`);
|
|
143
143
|
}
|
|
144
144
|
function generateCapnpEnums(reflection) {
|
|
145
|
-
const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind === ReflectionKind.enum || prop.type.kind === ReflectionKind.union && getCapnpUnionTypes(prop.type).filter((type) => type.kind === ReflectionKind.literal && (isString(type.literal) || 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);
|
|
145
|
+
const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind === type_exports.ReflectionKind.enum || prop.type.kind === type_exports.ReflectionKind.union && getCapnpUnionTypes(prop.type).filter((type) => type.kind === type_exports.ReflectionKind.literal && (isString(type.literal) || 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);
|
|
146
146
|
if (enums.length === 0) return "";
|
|
147
147
|
return `${enums.map((enumeration) => generateCapnpEnumSchema(enumeration.type, formatEnumName(enumeration.getNameAsString()))).join("\n\n")}
|
|
148
148
|
|
|
@@ -151,7 +151,7 @@ function generateCapnpEnums(reflection) {
|
|
|
151
151
|
function generateCapnpSchema(reflection, options = {}) {
|
|
152
152
|
let index = 0;
|
|
153
153
|
const indexCounter = options?.indexCounter ?? (() => index++);
|
|
154
|
-
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 === ReflectionKind.class && prop.type.classType === Map) ? `
|
|
154
|
+
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 === type_exports.ReflectionKind.class && prop.type.classType === Map) ? `
|
|
155
155
|
struct Map(Key, Value) {
|
|
156
156
|
entries @0 :List(Entry);
|
|
157
157
|
|
|
@@ -159,7 +159,7 @@ function generateCapnpSchema(reflection, options = {}) {
|
|
|
159
159
|
key @0 :Key;
|
|
160
160
|
value @1 :Value;
|
|
161
161
|
}
|
|
162
|
-
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind === ReflectionKind.class && prop.type.classType === Date) ? `
|
|
162
|
+
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind === type_exports.ReflectionKind.class && prop.type.classType === Date) ? `
|
|
163
163
|
struct Date {
|
|
164
164
|
# A standard Gregorian calendar date.
|
|
165
165
|
|
|
@@ -200,17 +200,17 @@ function generateCapnpPropertyComment(reflection) {
|
|
|
200
200
|
return "";
|
|
201
201
|
}
|
|
202
202
|
function generateCapnpPropertySchema(reflection, indexCounter) {
|
|
203
|
-
if (reflection.type.kind === ReflectionKind.union) if (getCapnpUnionTypes(reflection.type).length === 0) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Void;
|
|
203
|
+
if (reflection.type.kind === type_exports.ReflectionKind.union) if (getCapnpUnionTypes(reflection.type).length === 0) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Void;
|
|
204
204
|
${generateCapnpPropertyComment(reflection)}`;
|
|
205
|
-
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind === ReflectionKind.literal && (isString(type.literal) || isNumber(type.literal))).length === 1) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
205
|
+
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind === type_exports.ReflectionKind.literal && (isString(type.literal) || isNumber(type.literal))).length === 1) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
206
206
|
${generateCapnpPropertyComment(reflection)}`;
|
|
207
207
|
else return `${camelCase(reflection.getNameAsString())} :union {
|
|
208
208
|
${getCapnpUnionTypes(reflection.type).map((type) => ` ${kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(type)};`).join("\n")}
|
|
209
209
|
}
|
|
210
210
|
${generateCapnpPropertyComment(reflection)}`;
|
|
211
|
-
else if (reflection.type.kind === ReflectionKind.array) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
211
|
+
else if (reflection.type.kind === type_exports.ReflectionKind.array) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
212
212
|
${generateCapnpPropertyComment(reflection)}`;
|
|
213
|
-
else if (reflection.type.kind === ReflectionKind.class) if (reflection.type.classType === Map) return `${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)}` : ""};
|
|
213
|
+
else if (reflection.type.kind === type_exports.ReflectionKind.class) if (reflection.type.classType === Map) return `${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)}` : ""};
|
|
214
214
|
${generateCapnpPropertyComment(reflection)}`;
|
|
215
215
|
else if (reflection.type.classType === Date) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
216
216
|
${generateCapnpPropertyComment(reflection)}`;
|
|
@@ -218,24 +218,24 @@ ${generateCapnpPropertyComment(reflection)}`;
|
|
|
218
218
|
${generateCapnpPropertyComment(reflection)}`;
|
|
219
219
|
else if (reflection.type.classType === ArrayBuffer) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
220
220
|
${generateCapnpPropertyComment(reflection)}`;
|
|
221
|
-
else return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(reflection.type.typeName || getClassName(reflection.type.classType))}${generateCapnpStruct(reflection.reflectionClass, { name: pascalCase(reflection.type.typeName || getClassName(reflection.type.classType)) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
221
|
+
else return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(reflection.type.typeName || (0, core_exports.getClassName)(reflection.type.classType))}${generateCapnpStruct(reflection.reflectionClass, { name: pascalCase(reflection.type.typeName || (0, core_exports.getClassName)(reflection.type.classType)) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
222
222
|
${generateCapnpPropertyComment(reflection)}`;
|
|
223
|
-
else if (reflection.type.kind === ReflectionKind.objectLiteral) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(reflection.type.typeName || memberNameToString(reflection.getNameAsString()))}${generateCapnpStruct(reflection.reflectionClass, { name: pascalCase(reflection.type.typeName || memberNameToString(reflection.getNameAsString())) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
223
|
+
else if (reflection.type.kind === type_exports.ReflectionKind.objectLiteral) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(reflection.type.typeName || (0, type_exports.memberNameToString)(reflection.getNameAsString()))}${generateCapnpStruct(reflection.reflectionClass, { name: pascalCase(reflection.type.typeName || (0, type_exports.memberNameToString)(reflection.getNameAsString())) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
224
224
|
${generateCapnpPropertyComment(reflection)}`;
|
|
225
|
-
else if (reflection.type.kind === ReflectionKind.enum) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
225
|
+
else if (reflection.type.kind === type_exports.ReflectionKind.enum) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
226
226
|
${generateCapnpPropertyComment(reflection)}`;
|
|
227
227
|
return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(reflection.getType())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
228
228
|
${generateCapnpPropertyComment(reflection)}`;
|
|
229
229
|
}
|
|
230
230
|
function generateCapnpEnumSchema(type, name) {
|
|
231
|
-
if (type.kind === ReflectionKind.union) return generateCapnpEnumSchema({
|
|
232
|
-
kind: ReflectionKind.enum,
|
|
231
|
+
if (type.kind === type_exports.ReflectionKind.union) return generateCapnpEnumSchema({
|
|
232
|
+
kind: type_exports.ReflectionKind.enum,
|
|
233
233
|
indexType: type,
|
|
234
234
|
enum: type.types.reduce((ret, type$1) => {
|
|
235
235
|
if (isString(type$1.literal) || isNumber(type$1.literal)) ret[camelCase(String(type$1.literal))] = type$1.literal;
|
|
236
236
|
return ret;
|
|
237
237
|
}, {}),
|
|
238
|
-
values: getCapnpUnionTypes(type).filter((type$1) => type$1.kind === ReflectionKind.literal && (isString(type$1.literal) || isNumber(type$1.literal))).map((type$1) => type$1.literal)
|
|
238
|
+
values: getCapnpUnionTypes(type).filter((type$1) => type$1.kind === type_exports.ReflectionKind.literal && (isString(type$1.literal) || isNumber(type$1.literal))).map((type$1) => type$1.literal)
|
|
239
239
|
}, name);
|
|
240
240
|
let index = 0;
|
|
241
241
|
const indexCounter = () => index++;
|
|
@@ -252,7 +252,7 @@ ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).
|
|
|
252
252
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
253
253
|
*/
|
|
254
254
|
function generateCapnpPrimitive(type) {
|
|
255
|
-
return type.kind === ReflectionKind.never || type.kind === ReflectionKind.void || type.kind === ReflectionKind.null || type.kind === ReflectionKind.undefined || type.kind === ReflectionKind.symbol ? "Void" : type.kind === ReflectionKind.class && type.classType === Date ? "Date" : type.kind === ReflectionKind.class && type.classType === Set ? `List(${type.typeArguments && type.typeArguments[0] ? generateCapnpPrimitive(type.typeArguments[0]) : "Data"})` : type.kind === ReflectionKind.bigint ? "UInt64" : type.kind === ReflectionKind.number ? "Float64" : type.kind === ReflectionKind.string || type.kind === ReflectionKind.regexp ? "Text" : type.kind === ReflectionKind.boolean ? "Bool" : type.kind === ReflectionKind.literal ? isNumber(type.literal) ? "Float64" : isBigInt(type.literal) ? "UInt64" : isString(type.literal) ? "Text" : typeof type.literal === "boolean" ? "Bool" : "Data" : "Data";
|
|
255
|
+
return type.kind === type_exports.ReflectionKind.never || type.kind === type_exports.ReflectionKind.void || type.kind === type_exports.ReflectionKind.null || type.kind === type_exports.ReflectionKind.undefined || type.kind === type_exports.ReflectionKind.symbol ? "Void" : type.kind === type_exports.ReflectionKind.class && type.classType === Date ? "Date" : type.kind === type_exports.ReflectionKind.class && type.classType === Set ? `List(${type.typeArguments && type.typeArguments[0] ? generateCapnpPrimitive(type.typeArguments[0]) : "Data"})` : type.kind === type_exports.ReflectionKind.bigint ? "UInt64" : type.kind === type_exports.ReflectionKind.number ? "Float64" : type.kind === type_exports.ReflectionKind.string || type.kind === type_exports.ReflectionKind.regexp ? "Text" : type.kind === type_exports.ReflectionKind.boolean ? "Bool" : type.kind === type_exports.ReflectionKind.literal ? isNumber(type.literal) ? "Float64" : isBigInt(type.literal) ? "UInt64" : isString(type.literal) ? "Text" : typeof type.literal === "boolean" ? "Bool" : "Data" : "Data";
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
//#endregion
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_helpers_typescript = require('./typescript.cjs');
|
|
2
|
-
const require_helpers_refkey = require('./refkey.cjs');
|
|
3
1
|
const require_helpers_capnp = require('./capnp.cjs');
|
|
4
2
|
const require_helpers_create_builtin = require('./create-builtin.cjs');
|
|
3
|
+
const require_helpers_refkey = require('./refkey.cjs');
|
|
4
|
+
const require_helpers_typescript = require('./typescript.cjs');
|
|
5
5
|
|
|
6
6
|
exports.LARGE_BUFFER = require_helpers_capnp.LARGE_BUFFER;
|
|
7
7
|
exports.compile = require_helpers_capnp.compile;
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { generateTypeScriptObject } from "./typescript.mjs";
|
|
2
|
-
import { refkey } from "./refkey.mjs";
|
|
3
1
|
import { LARGE_BUFFER, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue } from "./capnp.mjs";
|
|
4
2
|
import { createBuiltin } from "./create-builtin.mjs";
|
|
3
|
+
import { refkey } from "./refkey.mjs";
|
|
4
|
+
import { generateTypeScriptObject } from "./typescript.mjs";
|
|
5
5
|
|
|
6
6
|
export { LARGE_BUFFER, compile, createBuiltin, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, generateTypeScriptObject, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, refkey, stringifyCapnpDefaultValue, stringifyCapnpValue };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
|
|
2
|
+
const require_utilities = require('../deepkit/src/utilities.cjs');
|
|
3
3
|
let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
4
|
-
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
5
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
6
|
|
|
7
7
|
//#region src/helpers/typescript.ts
|
|
8
8
|
/**
|
|
@@ -34,7 +34,7 @@ export const ${(0, __stryke_string_format_camel_case.camelCase)(options.override
|
|
|
34
34
|
* @ignored` : ""}${item.isHidden() ? `
|
|
35
35
|
* @hidden` : ""}
|
|
36
36
|
*/
|
|
37
|
-
${item.getNameAsString()}: ${
|
|
37
|
+
${item.getNameAsString()}: ${require_utilities.stringifyValue(item.getType(), options.defaultValues?.[item.getNameAsString()] ?? item.getAlias().reduce((ret, alias) => {
|
|
38
38
|
if ((0, __stryke_type_checks_is_undefined.isUndefined)(ret) && !(0, __stryke_type_checks_is_undefined.isUndefined)(options.defaultValues?.[alias])) return options.defaultValues?.[alias];
|
|
39
39
|
return ret;
|
|
40
40
|
}, void 0) ?? item.getDefaultValue())}`).join(", \n")}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { stringifyValue } from "
|
|
1
|
+
import { stringifyValue } from "../deepkit/src/utilities.mjs";
|
|
2
2
|
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
3
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
4
3
|
import { camelCase } from "@stryke/string-format/camel-case";
|
|
4
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
5
5
|
|
|
6
6
|
//#region src/helpers/typescript.ts
|
|
7
7
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
3
|
const require_core_contexts_context = require('./core/contexts/context.cjs');
|
|
4
|
-
const
|
|
4
|
+
const require_core_components_output = require('./core/components/output.cjs');
|
|
5
5
|
const require_core_components_single_line_comment = require('./core/components/single-line-comment.cjs');
|
|
6
6
|
const require_core_components_source_file = require('./core/components/source-file.cjs');
|
|
7
|
+
const require_core_contexts_reflection = require('./core/contexts/reflection.cjs');
|
|
8
|
+
require('./core/index.cjs');
|
|
9
|
+
const require_helpers_capnp = require('./helpers/capnp.cjs');
|
|
10
|
+
const require_helpers_create_builtin = require('./helpers/create-builtin.cjs');
|
|
11
|
+
const require_helpers_refkey = require('./helpers/refkey.cjs');
|
|
12
|
+
const require_helpers_typescript = require('./helpers/typescript.cjs');
|
|
13
|
+
require('./helpers/index.cjs');
|
|
14
|
+
const require_markdown_components_markdown_file = require('./markdown/components/markdown-file.cjs');
|
|
15
|
+
const require_markdown_contexts_markdown_table = require('./markdown/contexts/markdown-table.cjs');
|
|
16
|
+
const require_markdown_components_markdown_table = require('./markdown/components/markdown-table.cjs');
|
|
17
|
+
require('./markdown/index.cjs');
|
|
18
|
+
const require_typescript_components_tsdoc = require('./typescript/components/tsdoc.cjs');
|
|
7
19
|
const require_typescript_components_typescript_file = require('./typescript/components/typescript-file.cjs');
|
|
8
20
|
const require_typescript_components_builtin_file = require('./typescript/components/builtin-file.cjs');
|
|
9
21
|
const require_typescript_components_dynamic_import_statement = require('./typescript/components/dynamic-import-statement.cjs');
|
|
10
22
|
const require_typescript_components_entry_file = require('./typescript/components/entry-file.cjs');
|
|
11
23
|
const require_typescript_components_record_expression = require('./typescript/components/record-expression.cjs');
|
|
12
|
-
const require_core_contexts_reflection = require('./core/contexts/reflection.cjs');
|
|
13
24
|
const require_typescript_components_tsdoc_reflection = require('./typescript/components/tsdoc-reflection.cjs');
|
|
14
25
|
const require_typescript_components_typescript_interface = require('./typescript/components/typescript-interface.cjs');
|
|
15
26
|
const require_typescript_components_typescript_object = require('./typescript/components/typescript-object.cjs');
|
|
16
27
|
require('./typescript/index.cjs');
|
|
17
|
-
const require_markdown_components_markdown_file = require('./markdown/components/markdown-file.cjs');
|
|
18
|
-
const require_markdown_contexts_markdown_table = require('./markdown/contexts/markdown-table.cjs');
|
|
19
|
-
const require_markdown_components_markdown_table = require('./markdown/components/markdown-table.cjs');
|
|
20
|
-
require('./markdown/index.cjs');
|
|
21
|
-
const require_helpers_typescript = require('./helpers/typescript.cjs');
|
|
22
|
-
const require_helpers_refkey = require('./helpers/refkey.cjs');
|
|
23
|
-
const require_helpers_capnp = require('./helpers/capnp.cjs');
|
|
24
|
-
const require_helpers_create_builtin = require('./helpers/create-builtin.cjs');
|
|
25
|
-
require('./helpers/index.cjs');
|
|
26
|
-
const require_core_components_output = require('./core/components/output.cjs');
|
|
27
|
-
require('./core/index.cjs');
|
|
28
28
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
29
29
|
let __alloy_js_core = require("@alloy-js/core");
|
|
30
|
-
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
31
|
-
let __stryke_path_replace = require("@stryke/path/replace");
|
|
32
30
|
let __alloy_js_rollup_plugin = require("@alloy-js/rollup-plugin");
|
|
33
31
|
__alloy_js_rollup_plugin = require_rolldown_runtime.__toESM(__alloy_js_rollup_plugin);
|
|
34
32
|
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
35
33
|
let __stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
36
34
|
let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
35
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
36
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
37
37
|
let prettier_doc_js = require("prettier/doc.js");
|
|
38
38
|
|
|
39
39
|
//#region src/index.tsx
|
|
@@ -58,7 +58,13 @@ const plugin = (options = {}) => {
|
|
|
58
58
|
pragma: "Alloy.createElement",
|
|
59
59
|
importSource: "@alloy-js/core"
|
|
60
60
|
} } },
|
|
61
|
-
plugins: [(0, __alloy_js_rollup_plugin.default)()]
|
|
61
|
+
plugins: [(0, __alloy_js_rollup_plugin.default)()],
|
|
62
|
+
alias: { "@alloy-js/core": "@powerlines/plugin-alloy/vendor" },
|
|
63
|
+
external: [
|
|
64
|
+
"@alloy-js/core",
|
|
65
|
+
"@vue/reactivity",
|
|
66
|
+
"@vue/shared"
|
|
67
|
+
]
|
|
62
68
|
}
|
|
63
69
|
};
|
|
64
70
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { PowerlinesContext, usePowerlines, usePowerlinesContext } from "./core/contexts/context.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Output } from "./core/components/output.mjs";
|
|
3
3
|
import { SingleLineComment } from "./core/components/single-line-comment.mjs";
|
|
4
4
|
import { SourceFile } from "./core/components/source-file.mjs";
|
|
5
|
+
import { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./core/contexts/reflection.mjs";
|
|
6
|
+
import "./core/index.mjs";
|
|
7
|
+
import { LARGE_BUFFER, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue } from "./helpers/capnp.mjs";
|
|
8
|
+
import { createBuiltin } from "./helpers/create-builtin.mjs";
|
|
9
|
+
import { refkey } from "./helpers/refkey.mjs";
|
|
10
|
+
import { generateTypeScriptObject } from "./helpers/typescript.mjs";
|
|
11
|
+
import "./helpers/index.mjs";
|
|
12
|
+
import { MarkdownFile, MarkdownFileHeader } from "./markdown/components/markdown-file.mjs";
|
|
13
|
+
import { MarkdownTableColumnContext, MarkdownTableContext, useMarkdownTable, useMarkdownTableColumn } from "./markdown/contexts/markdown-table.mjs";
|
|
14
|
+
import { MarkdownTable, MarkdownTableColumn, MarkdownTableColumnHeader } from "./markdown/components/markdown-table.mjs";
|
|
15
|
+
import "./markdown/index.mjs";
|
|
16
|
+
import { TSDoc, TSDocAlias, TSDocAttributesTags, TSDocDefaultValue, TSDocDomain, TSDocExample, TSDocHidden, TSDocIgnore, TSDocInternal, TSDocLink, TSDocModule, TSDocParam, TSDocParams, TSDocPermission, TSDocReadonly, TSDocRemarks, TSDocReturns, TSDocTag, TSDocThrows, TSDocTitle } from "./typescript/components/tsdoc.mjs";
|
|
5
17
|
import { TypescriptFile, TypescriptFileHeader, TypescriptFileHeaderImports } from "./typescript/components/typescript-file.mjs";
|
|
6
18
|
import { BuiltinFile } from "./typescript/components/builtin-file.mjs";
|
|
7
19
|
import { DynamicImportStatement } from "./typescript/components/dynamic-import-statement.mjs";
|
|
8
20
|
import { EntryFile } from "./typescript/components/entry-file.mjs";
|
|
9
21
|
import { RecordExpression } from "./typescript/components/record-expression.mjs";
|
|
10
|
-
import { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./core/contexts/reflection.mjs";
|
|
11
22
|
import { TSDocReflectionClass, TSDocReflectionMethod, TSDocReflectionProperty } from "./typescript/components/tsdoc-reflection.mjs";
|
|
12
23
|
import { TypeScriptInterface, TypescriptInterfaceProperty } from "./typescript/components/typescript-interface.mjs";
|
|
13
24
|
import { TypescriptObject, TypescriptObjectProperty } from "./typescript/components/typescript-object.mjs";
|
|
14
25
|
import "./typescript/index.mjs";
|
|
15
|
-
import { MarkdownFile, MarkdownFileHeader } from "./markdown/components/markdown-file.mjs";
|
|
16
|
-
import { MarkdownTableColumnContext, MarkdownTableContext, useMarkdownTable, useMarkdownTableColumn } from "./markdown/contexts/markdown-table.mjs";
|
|
17
|
-
import { MarkdownTable, MarkdownTableColumn, MarkdownTableColumnHeader } from "./markdown/components/markdown-table.mjs";
|
|
18
|
-
import "./markdown/index.mjs";
|
|
19
|
-
import { generateTypeScriptObject } from "./helpers/typescript.mjs";
|
|
20
|
-
import { refkey } from "./helpers/refkey.mjs";
|
|
21
|
-
import { LARGE_BUFFER, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue } from "./helpers/capnp.mjs";
|
|
22
|
-
import { createBuiltin } from "./helpers/create-builtin.mjs";
|
|
23
|
-
import "./helpers/index.mjs";
|
|
24
|
-
import { Output } from "./core/components/output.mjs";
|
|
25
|
-
import "./core/index.mjs";
|
|
26
26
|
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
27
27
|
import { flushJobsAsync, getContextForRenderNode, isPrintHook, renderTree } from "@alloy-js/core";
|
|
28
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
29
|
-
import { replacePath } from "@stryke/path/replace";
|
|
30
28
|
import alloy from "@alloy-js/rollup-plugin";
|
|
31
29
|
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
32
30
|
import { StormJSON } from "@stryke/json/storm-json";
|
|
33
31
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
32
|
+
import { replacePath } from "@stryke/path/replace";
|
|
33
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
34
34
|
import { printer } from "prettier/doc.js";
|
|
35
35
|
|
|
36
36
|
//#region src/index.tsx
|
|
@@ -55,7 +55,13 @@ const plugin = (options = {}) => {
|
|
|
55
55
|
pragma: "Alloy.createElement",
|
|
56
56
|
importSource: "@alloy-js/core"
|
|
57
57
|
} } },
|
|
58
|
-
plugins: [alloy()]
|
|
58
|
+
plugins: [alloy()],
|
|
59
|
+
alias: { "@alloy-js/core": "@powerlines/plugin-alloy/vendor" },
|
|
60
|
+
external: [
|
|
61
|
+
"@alloy-js/core",
|
|
62
|
+
"@vue/reactivity",
|
|
63
|
+
"@vue/shared"
|
|
64
|
+
]
|
|
59
65
|
}
|
|
60
66
|
};
|
|
61
67
|
},
|