@powerlines/plugin-alloy 0.17.5 → 0.18.0
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 +29 -0
- 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/contexts/reflection.d.cts +8 -7
- package/dist/core/contexts/reflection.d.mts +8 -7
- package/dist/deepkit/src/utilities.cjs +42 -41
- package/dist/deepkit/src/utilities.mjs +42 -41
- 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.d.cts +7 -0
- package/dist/deepkit/src/vendor/type.d.mts +7 -0
- package/dist/deepkit/src/vendor/type.mjs +11 -0
- package/dist/helpers/capnp.cjs +20 -18
- package/dist/helpers/capnp.d.cts +14 -13
- package/dist/helpers/capnp.d.mts +14 -13
- package/dist/helpers/capnp.mjs +20 -18
- package/dist/helpers/typescript.d.cts +3 -1
- package/dist/helpers/typescript.d.mts +3 -1
- 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/types/components.d.cts +6 -2
- package/dist/types/components.d.mts +6 -2
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +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.d.cts +4 -4
- package/dist/typescript/components/tsdoc-reflection.d.mts +4 -4
- package/dist/typescript/components/typescript-file.cjs +2 -1
- package/dist/typescript/components/typescript-file.mjs +2 -1
- package/dist/typescript/components/typescript-interface.cjs +2 -1
- package/dist/typescript/components/typescript-interface.d.cts +6 -5
- package/dist/typescript/components/typescript-interface.d.mts +6 -5
- package/dist/typescript/components/typescript-interface.mjs +2 -1
- package/dist/typescript/components/typescript-object.d.cts +6 -5
- package/dist/typescript/components/typescript-object.d.mts +6 -5
- package/package.json +5 -5
package/dist/helpers/capnp.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_type = require('../deepkit/src/vendor/type.cjs');
|
|
2
3
|
const require_utilities = require('../deepkit/src/utilities.cjs');
|
|
4
|
+
const require_core = require('../deepkit/src/vendor/core.cjs');
|
|
3
5
|
const require_file_header = require('../powerlines/src/lib/utilities/file-header.cjs');
|
|
4
6
|
let defu = require("defu");
|
|
5
7
|
defu = require_rolldown_runtime.__toESM(defu);
|
|
@@ -63,7 +65,7 @@ function stringifyCapnpDefaultValue(property, value) {
|
|
|
63
65
|
* @returns A string representation of the value.
|
|
64
66
|
*/
|
|
65
67
|
function stringifyCapnpValue(type, value) {
|
|
66
|
-
return type.kind === ReflectionKind.string || type.kind === ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(type.literal) ? `"${String(value)}"` : type.kind === ReflectionKind.enum ? `${(0, __stryke_string_format_camel_case.camelCase)(String(value))}` : type.kind === ReflectionKind.array ? __stryke_json.StormJSON.stringify(value) : type.kind === ReflectionKind.object || type.kind === ReflectionKind.objectLiteral ? __stryke_json.StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
|
|
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);
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
@@ -72,7 +74,7 @@ function stringifyCapnpValue(type, value) {
|
|
|
72
74
|
* @returns A string representation of the property.
|
|
73
75
|
*/
|
|
74
76
|
function getCapnpEnumTypes(type) {
|
|
75
|
-
if (type.kind !== ReflectionKind.enum) return null;
|
|
77
|
+
if (type.kind !== require_type.type_exports.ReflectionKind.enum) return null;
|
|
76
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");
|
|
77
79
|
if (unique.length === 0) return null;
|
|
78
80
|
return unique[0] && (0, __stryke_type_checks_is_string.isString)(unique[0]) ? "Text" : "Float32";
|
|
@@ -84,7 +86,7 @@ function getCapnpEnumTypes(type) {
|
|
|
84
86
|
* @returns True if the Type is a `Void` type, false otherwise.
|
|
85
87
|
*/
|
|
86
88
|
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;
|
|
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;
|
|
88
90
|
}
|
|
89
91
|
/**
|
|
90
92
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
@@ -102,7 +104,7 @@ function getCapnpUnionTypes(type) {
|
|
|
102
104
|
* @returns An array of Cap'n Proto primitive types.
|
|
103
105
|
*/
|
|
104
106
|
function isCapnpStringUnion(type) {
|
|
105
|
-
return getCapnpUnionTypes(type).some((member) => member.kind === ReflectionKind.string);
|
|
107
|
+
return getCapnpUnionTypes(type).some((member) => member.kind === require_type.type_exports.ReflectionKind.string);
|
|
106
108
|
}
|
|
107
109
|
const LARGE_BUFFER = 1024 * 1e6;
|
|
108
110
|
const execAsync = (0, node_util.promisify)(node_child_process.exec);
|
|
@@ -142,7 +144,7 @@ function formatEnumName(name) {
|
|
|
142
144
|
return (0, __stryke_string_format_pascal_case.pascalCase)(`${name}_Type`);
|
|
143
145
|
}
|
|
144
146
|
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 && ((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);
|
|
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);
|
|
146
148
|
if (enums.length === 0) return "";
|
|
147
149
|
return `${enums.map((enumeration) => generateCapnpEnumSchema(enumeration.type, formatEnumName(enumeration.getNameAsString()))).join("\n\n")}
|
|
148
150
|
|
|
@@ -151,7 +153,7 @@ function generateCapnpEnums(reflection) {
|
|
|
151
153
|
function generateCapnpSchema(reflection, options = {}) {
|
|
152
154
|
let index = 0;
|
|
153
155
|
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) ? `
|
|
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) ? `
|
|
155
157
|
struct Map(Key, Value) {
|
|
156
158
|
entries @0 :List(Entry);
|
|
157
159
|
|
|
@@ -159,7 +161,7 @@ function generateCapnpSchema(reflection, options = {}) {
|
|
|
159
161
|
key @0 :Key;
|
|
160
162
|
value @1 :Value;
|
|
161
163
|
}
|
|
162
|
-
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind === ReflectionKind.class && prop.type.classType === Date) ? `
|
|
164
|
+
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind === require_type.type_exports.ReflectionKind.class && prop.type.classType === Date) ? `
|
|
163
165
|
struct Date {
|
|
164
166
|
# A standard Gregorian calendar date.
|
|
165
167
|
|
|
@@ -200,17 +202,17 @@ function generateCapnpPropertyComment(reflection) {
|
|
|
200
202
|
return "";
|
|
201
203
|
}
|
|
202
204
|
function generateCapnpPropertySchema(reflection, indexCounter) {
|
|
203
|
-
if (reflection.type.kind === ReflectionKind.union) if (getCapnpUnionTypes(reflection.type).length === 0) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Void;
|
|
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;
|
|
204
206
|
${generateCapnpPropertyComment(reflection)}`;
|
|
205
|
-
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind === 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)}` : ""};
|
|
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)}` : ""};
|
|
206
208
|
${generateCapnpPropertyComment(reflection)}`;
|
|
207
209
|
else return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} :union {
|
|
208
210
|
${getCapnpUnionTypes(reflection.type).map((type) => ` ${require_utilities.kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(type)};`).join("\n")}
|
|
209
211
|
}
|
|
210
212
|
${generateCapnpPropertyComment(reflection)}`;
|
|
211
|
-
else if (reflection.type.kind === ReflectionKind.array) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
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)}` : ""};
|
|
212
214
|
${generateCapnpPropertyComment(reflection)}`;
|
|
213
|
-
else if (reflection.type.kind === 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)}` : ""};
|
|
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)}` : ""};
|
|
214
216
|
${generateCapnpPropertyComment(reflection)}`;
|
|
215
217
|
else if (reflection.type.classType === Date) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
216
218
|
${generateCapnpPropertyComment(reflection)}`;
|
|
@@ -218,24 +220,24 @@ ${generateCapnpPropertyComment(reflection)}`;
|
|
|
218
220
|
${generateCapnpPropertyComment(reflection)}`;
|
|
219
221
|
else if (reflection.type.classType === ArrayBuffer) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
220
222
|
${generateCapnpPropertyComment(reflection)}`;
|
|
221
|
-
else return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || getClassName(reflection.type.classType))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || getClassName(reflection.type.classType)) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(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, 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)}` : ""};
|
|
222
224
|
${generateCapnpPropertyComment(reflection)}`;
|
|
223
|
-
else if (reflection.type.kind === ReflectionKind.objectLiteral) return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || memberNameToString(reflection.getNameAsString()))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, __stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || memberNameToString(reflection.getNameAsString())) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
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)}` : ""};
|
|
224
226
|
${generateCapnpPropertyComment(reflection)}`;
|
|
225
|
-
else if (reflection.type.kind === 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)}` : ""};
|
|
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)}` : ""};
|
|
226
228
|
${generateCapnpPropertyComment(reflection)}`;
|
|
227
229
|
return `${(0, __stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(reflection.getType())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
228
230
|
${generateCapnpPropertyComment(reflection)}`;
|
|
229
231
|
}
|
|
230
232
|
function generateCapnpEnumSchema(type, name) {
|
|
231
|
-
if (type.kind === ReflectionKind.union) return generateCapnpEnumSchema({
|
|
232
|
-
kind: ReflectionKind.enum,
|
|
233
|
+
if (type.kind === require_type.type_exports.ReflectionKind.union) return generateCapnpEnumSchema({
|
|
234
|
+
kind: require_type.type_exports.ReflectionKind.enum,
|
|
233
235
|
indexType: type,
|
|
234
236
|
enum: type.types.reduce((ret, type$1) => {
|
|
235
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;
|
|
236
238
|
return ret;
|
|
237
239
|
}, {}),
|
|
238
|
-
values: getCapnpUnionTypes(type).filter((type$1) => type$1.kind === 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)
|
|
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)
|
|
239
241
|
}, name);
|
|
240
242
|
let index = 0;
|
|
241
243
|
const indexCounter = () => index++;
|
|
@@ -252,7 +254,7 @@ ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).
|
|
|
252
254
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
253
255
|
*/
|
|
254
256
|
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 ? (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";
|
|
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";
|
|
256
258
|
}
|
|
257
259
|
|
|
258
260
|
//#endregion
|
package/dist/helpers/capnp.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Context, PluginContext } from "../powerlines/src/types/context.cjs";
|
|
2
|
+
import { type_d_exports } from "../deepkit/src/vendor/type.cjs";
|
|
2
3
|
import { CapnpcOptions, CapnpcResult } from "@stryke/capnp/types";
|
|
3
4
|
|
|
4
5
|
//#region src/helpers/capnp.d.ts
|
|
@@ -18,7 +19,7 @@ declare function compile(context: Context, options?: Partial<CapnpcOptions>): Pr
|
|
|
18
19
|
* @param value - The value to stringify.
|
|
19
20
|
* @returns A string representation of the value.
|
|
20
21
|
*/
|
|
21
|
-
declare function stringifyCapnpDefaultValue(property: ReflectionProperty | ReflectionParameter, value?: any): string;
|
|
22
|
+
declare function stringifyCapnpDefaultValue(property: type_d_exports.ReflectionProperty | type_d_exports.ReflectionParameter, value?: any): string;
|
|
22
23
|
/**
|
|
23
24
|
* Converts any {@link Type}'s actual value to string representation.
|
|
24
25
|
*
|
|
@@ -26,35 +27,35 @@ declare function stringifyCapnpDefaultValue(property: ReflectionProperty | Refle
|
|
|
26
27
|
* @param value - The value to stringify.
|
|
27
28
|
* @returns A string representation of the value.
|
|
28
29
|
*/
|
|
29
|
-
declare function stringifyCapnpValue(type: Type, value: any): string;
|
|
30
|
+
declare function stringifyCapnpValue(type: type_d_exports.Type, value: any): string;
|
|
30
31
|
/**
|
|
31
32
|
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
32
33
|
*
|
|
33
34
|
* @param type - The TypeEnum to evaluate.
|
|
34
35
|
* @returns A string representation of the property.
|
|
35
36
|
*/
|
|
36
|
-
declare function getCapnpEnumTypes(type: Type): "Text" | "Float32" | null;
|
|
37
|
+
declare function getCapnpEnumTypes(type: type_d_exports.Type): "Text" | "Float32" | null;
|
|
37
38
|
/**
|
|
38
39
|
* Determines if a Type is a `Void` type in a Cap'n Proto schema.
|
|
39
40
|
*
|
|
40
41
|
* @param type - The Type to check.
|
|
41
42
|
* @returns True if the Type is a `Void` type, false otherwise.
|
|
42
43
|
*/
|
|
43
|
-
declare function isVoidType(type: Type): boolean;
|
|
44
|
+
declare function isVoidType(type: type_d_exports.Type): boolean;
|
|
44
45
|
/**
|
|
45
46
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
46
47
|
*
|
|
47
48
|
* @param type - The {@link TypeUnion} to convert.
|
|
48
49
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
49
50
|
*/
|
|
50
|
-
declare function getCapnpUnionTypes(type: Type): Type[];
|
|
51
|
+
declare function getCapnpUnionTypes(type: type_d_exports.Type): type_d_exports.Type[];
|
|
51
52
|
/**
|
|
52
53
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
53
54
|
*
|
|
54
55
|
* @param type - The {@link TypeUnion} to convert.
|
|
55
56
|
* @returns An array of Cap'n Proto primitive types.
|
|
56
57
|
*/
|
|
57
|
-
declare function isCapnpStringUnion(type: Type): boolean;
|
|
58
|
+
declare function isCapnpStringUnion(type: type_d_exports.Type): boolean;
|
|
58
59
|
declare const LARGE_BUFFER: number;
|
|
59
60
|
type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
|
|
60
61
|
type StdioOptions = IOType | Array<IOType | "ipc" | number | null | undefined>;
|
|
@@ -62,22 +63,22 @@ declare function generateCapnpId(): Promise<string>;
|
|
|
62
63
|
interface GenerateCapnpOptions {
|
|
63
64
|
name?: string;
|
|
64
65
|
}
|
|
65
|
-
declare function generateCapnp(context: PluginContext, reflection: ReflectionClass<any>, options: GenerateCapnpOptions): Promise<string>;
|
|
66
|
+
declare function generateCapnp(context: PluginContext, reflection: type_d_exports.ReflectionClass<any>, options: GenerateCapnpOptions): Promise<string>;
|
|
66
67
|
interface GenerateCapnpStructOptions extends GenerateCapnpOptions {
|
|
67
68
|
indexCounter?: () => number;
|
|
68
69
|
}
|
|
69
|
-
declare function generateCapnpStruct(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
70
|
-
declare function generateCapnpInterface(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
71
|
-
declare function generateCapnpSchema(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
72
|
-
declare function generateCapnpMethodSchema(reflection: ReflectionMethod, indexCounter: () => number): string;
|
|
73
|
-
declare function generateCapnpEnumSchema(type: TypeEnum | TypeUnion, name: string): string;
|
|
70
|
+
declare function generateCapnpStruct(reflection: type_d_exports.ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
71
|
+
declare function generateCapnpInterface(reflection: type_d_exports.ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
72
|
+
declare function generateCapnpSchema(reflection: type_d_exports.ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
73
|
+
declare function generateCapnpMethodSchema(reflection: type_d_exports.ReflectionMethod, indexCounter: () => number): string;
|
|
74
|
+
declare function generateCapnpEnumSchema(type: type_d_exports.TypeEnum | type_d_exports.TypeUnion, name: string): string;
|
|
74
75
|
/**
|
|
75
76
|
* Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.
|
|
76
77
|
*
|
|
77
78
|
* @param type - The Deepkit Type to convert.
|
|
78
79
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
79
80
|
*/
|
|
80
|
-
declare function generateCapnpPrimitive(type: Type): string;
|
|
81
|
+
declare function generateCapnpPrimitive(type: type_d_exports.Type): string;
|
|
81
82
|
declare type __ΩIOType = any[];
|
|
82
83
|
declare type __ΩStdioOptions = any[];
|
|
83
84
|
declare type __ΩGenerateCapnpOptions = any[];
|
package/dist/helpers/capnp.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Context, PluginContext } from "../powerlines/src/types/context.mjs";
|
|
2
|
+
import { type_d_exports } from "../deepkit/src/vendor/type.mjs";
|
|
2
3
|
import { CapnpcOptions, CapnpcResult } from "@stryke/capnp/types";
|
|
3
4
|
|
|
4
5
|
//#region src/helpers/capnp.d.ts
|
|
@@ -18,7 +19,7 @@ declare function compile(context: Context, options?: Partial<CapnpcOptions>): Pr
|
|
|
18
19
|
* @param value - The value to stringify.
|
|
19
20
|
* @returns A string representation of the value.
|
|
20
21
|
*/
|
|
21
|
-
declare function stringifyCapnpDefaultValue(property: ReflectionProperty | ReflectionParameter, value?: any): string;
|
|
22
|
+
declare function stringifyCapnpDefaultValue(property: type_d_exports.ReflectionProperty | type_d_exports.ReflectionParameter, value?: any): string;
|
|
22
23
|
/**
|
|
23
24
|
* Converts any {@link Type}'s actual value to string representation.
|
|
24
25
|
*
|
|
@@ -26,35 +27,35 @@ declare function stringifyCapnpDefaultValue(property: ReflectionProperty | Refle
|
|
|
26
27
|
* @param value - The value to stringify.
|
|
27
28
|
* @returns A string representation of the value.
|
|
28
29
|
*/
|
|
29
|
-
declare function stringifyCapnpValue(type: Type, value: any): string;
|
|
30
|
+
declare function stringifyCapnpValue(type: type_d_exports.Type, value: any): string;
|
|
30
31
|
/**
|
|
31
32
|
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
32
33
|
*
|
|
33
34
|
* @param type - The TypeEnum to evaluate.
|
|
34
35
|
* @returns A string representation of the property.
|
|
35
36
|
*/
|
|
36
|
-
declare function getCapnpEnumTypes(type: Type): "Text" | "Float32" | null;
|
|
37
|
+
declare function getCapnpEnumTypes(type: type_d_exports.Type): "Text" | "Float32" | null;
|
|
37
38
|
/**
|
|
38
39
|
* Determines if a Type is a `Void` type in a Cap'n Proto schema.
|
|
39
40
|
*
|
|
40
41
|
* @param type - The Type to check.
|
|
41
42
|
* @returns True if the Type is a `Void` type, false otherwise.
|
|
42
43
|
*/
|
|
43
|
-
declare function isVoidType(type: Type): boolean;
|
|
44
|
+
declare function isVoidType(type: type_d_exports.Type): boolean;
|
|
44
45
|
/**
|
|
45
46
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
46
47
|
*
|
|
47
48
|
* @param type - The {@link TypeUnion} to convert.
|
|
48
49
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
49
50
|
*/
|
|
50
|
-
declare function getCapnpUnionTypes(type: Type): Type[];
|
|
51
|
+
declare function getCapnpUnionTypes(type: type_d_exports.Type): type_d_exports.Type[];
|
|
51
52
|
/**
|
|
52
53
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
53
54
|
*
|
|
54
55
|
* @param type - The {@link TypeUnion} to convert.
|
|
55
56
|
* @returns An array of Cap'n Proto primitive types.
|
|
56
57
|
*/
|
|
57
|
-
declare function isCapnpStringUnion(type: Type): boolean;
|
|
58
|
+
declare function isCapnpStringUnion(type: type_d_exports.Type): boolean;
|
|
58
59
|
declare const LARGE_BUFFER: number;
|
|
59
60
|
type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
|
|
60
61
|
type StdioOptions = IOType | Array<IOType | "ipc" | number | null | undefined>;
|
|
@@ -62,22 +63,22 @@ declare function generateCapnpId(): Promise<string>;
|
|
|
62
63
|
interface GenerateCapnpOptions {
|
|
63
64
|
name?: string;
|
|
64
65
|
}
|
|
65
|
-
declare function generateCapnp(context: PluginContext, reflection: ReflectionClass<any>, options: GenerateCapnpOptions): Promise<string>;
|
|
66
|
+
declare function generateCapnp(context: PluginContext, reflection: type_d_exports.ReflectionClass<any>, options: GenerateCapnpOptions): Promise<string>;
|
|
66
67
|
interface GenerateCapnpStructOptions extends GenerateCapnpOptions {
|
|
67
68
|
indexCounter?: () => number;
|
|
68
69
|
}
|
|
69
|
-
declare function generateCapnpStruct(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
70
|
-
declare function generateCapnpInterface(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
71
|
-
declare function generateCapnpSchema(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
72
|
-
declare function generateCapnpMethodSchema(reflection: ReflectionMethod, indexCounter: () => number): string;
|
|
73
|
-
declare function generateCapnpEnumSchema(type: TypeEnum | TypeUnion, name: string): string;
|
|
70
|
+
declare function generateCapnpStruct(reflection: type_d_exports.ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
71
|
+
declare function generateCapnpInterface(reflection: type_d_exports.ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
72
|
+
declare function generateCapnpSchema(reflection: type_d_exports.ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
73
|
+
declare function generateCapnpMethodSchema(reflection: type_d_exports.ReflectionMethod, indexCounter: () => number): string;
|
|
74
|
+
declare function generateCapnpEnumSchema(type: type_d_exports.TypeEnum | type_d_exports.TypeUnion, name: string): string;
|
|
74
75
|
/**
|
|
75
76
|
* Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.
|
|
76
77
|
*
|
|
77
78
|
* @param type - The Deepkit Type to convert.
|
|
78
79
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
79
80
|
*/
|
|
80
|
-
declare function generateCapnpPrimitive(type: Type): string;
|
|
81
|
+
declare function generateCapnpPrimitive(type: type_d_exports.Type): string;
|
|
81
82
|
declare type __ΩIOType = any[];
|
|
82
83
|
declare type __ΩStdioOptions = any[];
|
|
83
84
|
declare type __ΩGenerateCapnpOptions = any[];
|
package/dist/helpers/capnp.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type_exports } from "../deepkit/src/vendor/type.mjs";
|
|
1
2
|
import { getUnionTypes, kindToName } from "../deepkit/src/utilities.mjs";
|
|
3
|
+
import { core_exports } from "../deepkit/src/vendor/core.mjs";
|
|
2
4
|
import { getBaseFileHeader } from "../powerlines/src/lib/utilities/file-header.mjs";
|
|
3
5
|
import defu from "defu";
|
|
4
6
|
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
@@ -61,7 +63,7 @@ function stringifyCapnpDefaultValue(property, value) {
|
|
|
61
63
|
* @returns A string representation of the value.
|
|
62
64
|
*/
|
|
63
65
|
function stringifyCapnpValue(type, value) {
|
|
64
|
-
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);
|
|
65
67
|
}
|
|
66
68
|
/**
|
|
67
69
|
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
@@ -70,7 +72,7 @@ function stringifyCapnpValue(type, value) {
|
|
|
70
72
|
* @returns A string representation of the property.
|
|
71
73
|
*/
|
|
72
74
|
function getCapnpEnumTypes(type) {
|
|
73
|
-
if (type.kind !== ReflectionKind.enum) return null;
|
|
75
|
+
if (type.kind !== type_exports.ReflectionKind.enum) return null;
|
|
74
76
|
const unique = getUniqueBy(type.values.filter((value) => !isUndefined(value) && !isNull(value)), (enumMember) => isString(enumMember) ? "Text" : "Float32");
|
|
75
77
|
if (unique.length === 0) return null;
|
|
76
78
|
return unique[0] && isString(unique[0]) ? "Text" : "Float32";
|
|
@@ -82,7 +84,7 @@ function getCapnpEnumTypes(type) {
|
|
|
82
84
|
* @returns True if the Type is a `Void` type, false otherwise.
|
|
83
85
|
*/
|
|
84
86
|
function isVoidType(type) {
|
|
85
|
-
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;
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
88
90
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
@@ -100,7 +102,7 @@ function getCapnpUnionTypes(type) {
|
|
|
100
102
|
* @returns An array of Cap'n Proto primitive types.
|
|
101
103
|
*/
|
|
102
104
|
function isCapnpStringUnion(type) {
|
|
103
|
-
return getCapnpUnionTypes(type).some((member) => member.kind === ReflectionKind.string);
|
|
105
|
+
return getCapnpUnionTypes(type).some((member) => member.kind === type_exports.ReflectionKind.string);
|
|
104
106
|
}
|
|
105
107
|
const LARGE_BUFFER = 1024 * 1e6;
|
|
106
108
|
const execAsync = promisify(exec);
|
|
@@ -140,7 +142,7 @@ function formatEnumName(name) {
|
|
|
140
142
|
return pascalCase(`${name}_Type`);
|
|
141
143
|
}
|
|
142
144
|
function generateCapnpEnums(reflection) {
|
|
143
|
-
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);
|
|
144
146
|
if (enums.length === 0) return "";
|
|
145
147
|
return `${enums.map((enumeration) => generateCapnpEnumSchema(enumeration.type, formatEnumName(enumeration.getNameAsString()))).join("\n\n")}
|
|
146
148
|
|
|
@@ -149,7 +151,7 @@ function generateCapnpEnums(reflection) {
|
|
|
149
151
|
function generateCapnpSchema(reflection, options = {}) {
|
|
150
152
|
let index = 0;
|
|
151
153
|
const indexCounter = options?.indexCounter ?? (() => index++);
|
|
152
|
-
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) ? `
|
|
153
155
|
struct Map(Key, Value) {
|
|
154
156
|
entries @0 :List(Entry);
|
|
155
157
|
|
|
@@ -157,7 +159,7 @@ function generateCapnpSchema(reflection, options = {}) {
|
|
|
157
159
|
key @0 :Key;
|
|
158
160
|
value @1 :Value;
|
|
159
161
|
}
|
|
160
|
-
}` : ""}${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) ? `
|
|
161
163
|
struct Date {
|
|
162
164
|
# A standard Gregorian calendar date.
|
|
163
165
|
|
|
@@ -198,17 +200,17 @@ function generateCapnpPropertyComment(reflection) {
|
|
|
198
200
|
return "";
|
|
199
201
|
}
|
|
200
202
|
function generateCapnpPropertySchema(reflection, indexCounter) {
|
|
201
|
-
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;
|
|
202
204
|
${generateCapnpPropertyComment(reflection)}`;
|
|
203
|
-
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)}` : ""};
|
|
204
206
|
${generateCapnpPropertyComment(reflection)}`;
|
|
205
207
|
else return `${camelCase(reflection.getNameAsString())} :union {
|
|
206
208
|
${getCapnpUnionTypes(reflection.type).map((type) => ` ${kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(type)};`).join("\n")}
|
|
207
209
|
}
|
|
208
210
|
${generateCapnpPropertyComment(reflection)}`;
|
|
209
|
-
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)}` : ""};
|
|
210
212
|
${generateCapnpPropertyComment(reflection)}`;
|
|
211
|
-
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)}` : ""};
|
|
212
214
|
${generateCapnpPropertyComment(reflection)}`;
|
|
213
215
|
else if (reflection.type.classType === Date) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
214
216
|
${generateCapnpPropertyComment(reflection)}`;
|
|
@@ -216,24 +218,24 @@ ${generateCapnpPropertyComment(reflection)}`;
|
|
|
216
218
|
${generateCapnpPropertyComment(reflection)}`;
|
|
217
219
|
else if (reflection.type.classType === ArrayBuffer) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
218
220
|
${generateCapnpPropertyComment(reflection)}`;
|
|
219
|
-
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)}` : ""};
|
|
220
222
|
${generateCapnpPropertyComment(reflection)}`;
|
|
221
|
-
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)}` : ""};
|
|
222
224
|
${generateCapnpPropertyComment(reflection)}`;
|
|
223
|
-
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)}` : ""};
|
|
224
226
|
${generateCapnpPropertyComment(reflection)}`;
|
|
225
227
|
return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(reflection.getType())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
226
228
|
${generateCapnpPropertyComment(reflection)}`;
|
|
227
229
|
}
|
|
228
230
|
function generateCapnpEnumSchema(type, name) {
|
|
229
|
-
if (type.kind === ReflectionKind.union) return generateCapnpEnumSchema({
|
|
230
|
-
kind: ReflectionKind.enum,
|
|
231
|
+
if (type.kind === type_exports.ReflectionKind.union) return generateCapnpEnumSchema({
|
|
232
|
+
kind: type_exports.ReflectionKind.enum,
|
|
231
233
|
indexType: type,
|
|
232
234
|
enum: type.types.reduce((ret, type$1) => {
|
|
233
235
|
if (isString(type$1.literal) || isNumber(type$1.literal)) ret[camelCase(String(type$1.literal))] = type$1.literal;
|
|
234
236
|
return ret;
|
|
235
237
|
}, {}),
|
|
236
|
-
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)
|
|
237
239
|
}, name);
|
|
238
240
|
let index = 0;
|
|
239
241
|
const indexCounter = () => index++;
|
|
@@ -250,7 +252,7 @@ ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).
|
|
|
250
252
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
251
253
|
*/
|
|
252
254
|
function generateCapnpPrimitive(type) {
|
|
253
|
-
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";
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
//#endregion
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type_d_exports } from "../deepkit/src/vendor/type.cjs";
|
|
2
|
+
|
|
1
3
|
//#region src/helpers/typescript.d.ts
|
|
2
4
|
interface GenerateTypeScriptInterfaceOptions<T> {
|
|
3
5
|
overrideName?: string;
|
|
@@ -16,7 +18,7 @@ interface GenerateTypeScriptObjectOptions<T> {
|
|
|
16
18
|
* @param options - Options for generating the object.
|
|
17
19
|
* @returns A string containing the TypeScript object definition.
|
|
18
20
|
*/
|
|
19
|
-
declare function generateTypeScriptObject<T extends Record<string, any>>(reflection: ReflectionClass<T>, options?: GenerateTypeScriptObjectOptions<T>): string;
|
|
21
|
+
declare function generateTypeScriptObject<T extends Record<string, any>>(reflection: type_d_exports.ReflectionClass<T>, options?: GenerateTypeScriptObjectOptions<T>): string;
|
|
20
22
|
declare type __ΩGenerateTypeScriptInterfaceOptions = any[];
|
|
21
23
|
declare type __ΩGenerateTypeScriptObjectOptions = any[];
|
|
22
24
|
//#endregion
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type_d_exports } from "../deepkit/src/vendor/type.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/helpers/typescript.d.ts
|
|
2
4
|
interface GenerateTypeScriptInterfaceOptions<T> {
|
|
3
5
|
overrideName?: string;
|
|
@@ -16,7 +18,7 @@ interface GenerateTypeScriptObjectOptions<T> {
|
|
|
16
18
|
* @param options - Options for generating the object.
|
|
17
19
|
* @returns A string containing the TypeScript object definition.
|
|
18
20
|
*/
|
|
19
|
-
declare function generateTypeScriptObject<T extends Record<string, any>>(reflection: ReflectionClass<T>, options?: GenerateTypeScriptObjectOptions<T>): string;
|
|
21
|
+
declare function generateTypeScriptObject<T extends Record<string, any>>(reflection: type_d_exports.ReflectionClass<T>, options?: GenerateTypeScriptObjectOptions<T>): string;
|
|
20
22
|
declare type __ΩGenerateTypeScriptInterfaceOptions = any[];
|
|
21
23
|
declare type __ΩGenerateTypeScriptObjectOptions = any[];
|
|
22
24
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentProps, SourceFileHeaderProps } from "../../types/components.cjs";
|
|
2
2
|
import { SourceFileProps as SourceFileProps$1 } from "../../core/components/source-file.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core12 from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/markdown/components/markdown-file.d.ts
|
|
6
6
|
type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps;
|
|
@@ -10,14 +10,14 @@ type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps;
|
|
|
10
10
|
* @param props - The properties for the source file.
|
|
11
11
|
* @returns The rendered source file component.
|
|
12
12
|
*/
|
|
13
|
-
declare function MarkdownFile(props: MarkdownFileProps):
|
|
13
|
+
declare function MarkdownFile(props: MarkdownFileProps): _alloy_js_core12.Children;
|
|
14
14
|
/**
|
|
15
15
|
* Renders the header for a Powerlines Typescript source file.
|
|
16
16
|
*
|
|
17
17
|
* @param props - The properties for the source file header.
|
|
18
18
|
* @returns The rendered source file header.
|
|
19
19
|
*/
|
|
20
|
-
declare function MarkdownFileHeader(props: SourceFileHeaderProps):
|
|
20
|
+
declare function MarkdownFileHeader(props: SourceFileHeaderProps): _alloy_js_core12.Children;
|
|
21
21
|
declare type __ΩMarkdownFileProps = any[];
|
|
22
22
|
//#endregion
|
|
23
23
|
export { MarkdownFile, MarkdownFileHeader, MarkdownFileProps, __ΩMarkdownFileProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentProps, SourceFileHeaderProps } from "../../types/components.mjs";
|
|
2
2
|
import { SourceFileProps as SourceFileProps$1 } from "../../core/components/source-file.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/markdown/components/markdown-file.d.ts
|
|
6
6
|
type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps;
|
|
@@ -10,14 +10,14 @@ type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps;
|
|
|
10
10
|
* @param props - The properties for the source file.
|
|
11
11
|
* @returns The rendered source file component.
|
|
12
12
|
*/
|
|
13
|
-
declare function MarkdownFile(props: MarkdownFileProps):
|
|
13
|
+
declare function MarkdownFile(props: MarkdownFileProps): _alloy_js_core0.Children;
|
|
14
14
|
/**
|
|
15
15
|
* Renders the header for a Powerlines Typescript source file.
|
|
16
16
|
*
|
|
17
17
|
* @param props - The properties for the source file header.
|
|
18
18
|
* @returns The rendered source file header.
|
|
19
19
|
*/
|
|
20
|
-
declare function MarkdownFileHeader(props: SourceFileHeaderProps):
|
|
20
|
+
declare function MarkdownFileHeader(props: SourceFileHeaderProps): _alloy_js_core0.Children;
|
|
21
21
|
declare type __ΩMarkdownFileProps = any[];
|
|
22
22
|
//#endregion
|
|
23
23
|
export { MarkdownFile, MarkdownFileHeader, MarkdownFileProps, __ΩMarkdownFileProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.cjs";
|
|
2
2
|
import { MarkdownTableColumnContextInterface } from "../contexts/markdown-table.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core9 from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/markdown/components/markdown-table.d.ts
|
|
6
6
|
interface MarkdownTableProps<T extends Record<string, any> = Record<string, any>> extends ComponentProps {
|
|
@@ -9,18 +9,18 @@ interface MarkdownTableProps<T extends Record<string, any> = Record<string, any>
|
|
|
9
9
|
/**
|
|
10
10
|
* Component that provides a context for rendering markdown tables.
|
|
11
11
|
*/
|
|
12
|
-
declare function MarkdownTable<T extends Record<string, any> = Record<string, any>>(props: MarkdownTableProps<T>):
|
|
12
|
+
declare function MarkdownTable<T extends Record<string, any> = Record<string, any>>(props: MarkdownTableProps<T>): _alloy_js_core9.Children;
|
|
13
13
|
type MarkdownTableColumnProps = ComponentProps & Partial<Pick<MarkdownTableColumnContextInterface, "align">> & Required<Pick<MarkdownTableColumnContextInterface, "name">> & {
|
|
14
14
|
width?: number;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Component that provides a context for rendering markdown tables.
|
|
18
18
|
*/
|
|
19
|
-
declare function MarkdownTableColumn(props: MarkdownTableColumnProps):
|
|
19
|
+
declare function MarkdownTableColumn(props: MarkdownTableColumnProps): _alloy_js_core9.Children;
|
|
20
20
|
/**
|
|
21
21
|
* Component that provides a context for rendering markdown tables.
|
|
22
22
|
*/
|
|
23
|
-
declare function MarkdownTableColumnHeader(props: MarkdownTableColumnProps):
|
|
23
|
+
declare function MarkdownTableColumnHeader(props: MarkdownTableColumnProps): _alloy_js_core9.Children;
|
|
24
24
|
declare type __ΩMarkdownTableProps = any[];
|
|
25
25
|
declare type __ΩMarkdownTableColumnProps = any[];
|
|
26
26
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.mjs";
|
|
2
2
|
import { MarkdownTableColumnContextInterface } from "../contexts/markdown-table.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core9 from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/markdown/components/markdown-table.d.ts
|
|
6
6
|
interface MarkdownTableProps<T extends Record<string, any> = Record<string, any>> extends ComponentProps {
|
|
@@ -9,18 +9,18 @@ interface MarkdownTableProps<T extends Record<string, any> = Record<string, any>
|
|
|
9
9
|
/**
|
|
10
10
|
* Component that provides a context for rendering markdown tables.
|
|
11
11
|
*/
|
|
12
|
-
declare function MarkdownTable<T extends Record<string, any> = Record<string, any>>(props: MarkdownTableProps<T>):
|
|
12
|
+
declare function MarkdownTable<T extends Record<string, any> = Record<string, any>>(props: MarkdownTableProps<T>): _alloy_js_core9.Children;
|
|
13
13
|
type MarkdownTableColumnProps = ComponentProps & Partial<Pick<MarkdownTableColumnContextInterface, "align">> & Required<Pick<MarkdownTableColumnContextInterface, "name">> & {
|
|
14
14
|
width?: number;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Component that provides a context for rendering markdown tables.
|
|
18
18
|
*/
|
|
19
|
-
declare function MarkdownTableColumn(props: MarkdownTableColumnProps):
|
|
19
|
+
declare function MarkdownTableColumn(props: MarkdownTableColumnProps): _alloy_js_core9.Children;
|
|
20
20
|
/**
|
|
21
21
|
* Component that provides a context for rendering markdown tables.
|
|
22
22
|
*/
|
|
23
|
-
declare function MarkdownTableColumnHeader(props: MarkdownTableColumnProps):
|
|
23
|
+
declare function MarkdownTableColumnHeader(props: MarkdownTableColumnProps): _alloy_js_core9.Children;
|
|
24
24
|
declare type __ΩMarkdownTableProps = any[];
|
|
25
25
|
declare type __ΩMarkdownTableColumnProps = any[];
|
|
26
26
|
//#endregion
|