@powerlines/plugin-alloy 0.26.227 → 0.26.228

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/core/components/infrastructure-file.cjs +1 -1
  2. package/dist/core/components/source-file.cjs +1 -1
  3. package/dist/helpers/capnp.cjs +141 -87
  4. package/dist/helpers/capnp.d.cts +20 -15
  5. package/dist/helpers/capnp.d.cts.map +1 -1
  6. package/dist/helpers/capnp.d.mts +20 -15
  7. package/dist/helpers/capnp.mjs +142 -87
  8. package/dist/helpers/index.cjs +0 -3
  9. package/dist/helpers/index.d.cts +2 -3
  10. package/dist/helpers/index.d.mts +2 -3
  11. package/dist/helpers/index.mjs +2 -3
  12. package/dist/index.cjs +1 -1
  13. package/dist/markdown/components/alert.cjs +74 -0
  14. package/dist/markdown/components/alert.d.cts +53 -0
  15. package/dist/markdown/components/alert.d.cts.map +1 -0
  16. package/dist/markdown/components/alert.d.mts +53 -0
  17. package/dist/markdown/components/alert.d.mts.map +1 -0
  18. package/dist/markdown/components/alert.mjs +69 -0
  19. package/dist/markdown/components/alert.mjs.map +1 -0
  20. package/dist/markdown/components/index.cjs +8 -1
  21. package/dist/markdown/components/index.d.cts +2 -1
  22. package/dist/markdown/components/index.d.mts +2 -1
  23. package/dist/markdown/components/index.mjs +2 -1
  24. package/dist/markdown/index.cjs +7 -0
  25. package/dist/markdown/index.d.cts +2 -1
  26. package/dist/markdown/index.d.mts +2 -1
  27. package/dist/markdown/index.mjs +2 -1
  28. package/dist/typescript/components/builtin-file.cjs +5 -3
  29. package/dist/typescript/components/builtin-file.d.cts +6 -0
  30. package/dist/typescript/components/builtin-file.d.cts.map +1 -1
  31. package/dist/typescript/components/builtin-file.d.mts +6 -0
  32. package/dist/typescript/components/builtin-file.mjs +5 -3
  33. package/dist/typescript/components/entry-file.cjs +1 -1
  34. package/dist/typescript/components/interface-declaration.cjs +1 -1
  35. package/dist/typescript/components/interface-declaration.d.mts +1 -1
  36. package/dist/typescript/components/interface-declaration.mjs +1 -1
  37. package/dist/typescript/components/object-declaration.cjs +2 -2
  38. package/dist/typescript/components/object-declaration.d.mts +1 -1
  39. package/dist/typescript/components/object-declaration.mjs +2 -2
  40. package/dist/typescript/components/tsdoc-schema.cjs +2 -2
  41. package/dist/typescript/components/tsdoc-schema.mjs +2 -2
  42. package/dist/typescript/components/tsdoc.cjs +1 -1
  43. package/dist/typescript/components/tsdoc.d.mts +1 -1
  44. package/dist/typescript/components/tsdoc.mjs +1 -1
  45. package/package.json +23 -22
  46. package/dist/helpers/typescript.cjs +0 -47
  47. package/dist/helpers/typescript.d.cts +0 -24
  48. package/dist/helpers/typescript.d.cts.map +0 -1
  49. package/dist/helpers/typescript.d.mts +0 -24
  50. package/dist/helpers/typescript.d.mts.map +0 -1
  51. package/dist/helpers/typescript.mjs +0 -47
  52. package/dist/helpers/typescript.mjs.map +0 -1
@@ -1,24 +1,19 @@
1
1
  import defu from "defu";
2
2
  import { titleCase } from "@stryke/string-format/title-case";
3
3
  import { getFileHeader } from "powerlines/utils";
4
- import { getUnionTypes, kindToName } from "@powerlines/deepkit/utilities";
5
- import { camelCase } from "@stryke/string-format/camel-case";
6
- import { isUndefined } from "@stryke/type-checks/is-undefined";
7
- import { getClassName } from "@powerlines/deepkit/vendor/core";
8
- import { ReflectionKind, memberNameToString } from "@powerlines/deepkit/vendor/type";
4
+ import { getPropertiesList, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaUndefined, isJsonSchemaUnion } from "@powerlines/schema";
9
5
  import { capnpc } from "@stryke/capnp/compile";
10
6
  import { resolveOptions } from "@stryke/capnp/helpers";
11
7
  import { toArray } from "@stryke/convert/to-array";
12
8
  import { getUniqueBy } from "@stryke/helpers/get-unique";
13
9
  import { StormJSON } from "@stryke/json";
14
10
  import { joinPaths } from "@stryke/path/join";
11
+ import { camelCase } from "@stryke/string-format/camel-case";
15
12
  import { getWords } from "@stryke/string-format/get-words";
16
13
  import { pascalCase } from "@stryke/string-format/pascal-case";
17
14
  import { isBigInt } from "@stryke/type-checks/is-bigint";
18
- import { isNull } from "@stryke/type-checks/is-null";
19
15
  import { isNumber } from "@stryke/type-checks/is-number";
20
16
  import { isString } from "@stryke/type-checks/is-string";
21
- import { Buffer } from "node:buffer";
22
17
  import { exec } from "node:child_process";
23
18
  import { promisify } from "node:util";
24
19
 
@@ -53,7 +48,7 @@ async function compile(context, options = {}) {
53
48
  * @returns A string representation of the value.
54
49
  */
55
50
  function stringifyCapnpDefaultValue(property, value) {
56
- return stringifyCapnpValue(property.type, value ?? property.getDefaultValue());
51
+ return stringifyCapnpValue(property, value ?? property.default);
57
52
  }
58
53
  /**
59
54
  * Converts any {@link Type}'s actual value to string representation.
@@ -62,8 +57,8 @@ function stringifyCapnpDefaultValue(property, value) {
62
57
  * @param value - The value to stringify.
63
58
  * @returns A string representation of the value.
64
59
  */
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);
60
+ function stringifyCapnpValue(schema, value) {
61
+ return isJsonSchemaString(schema) || isJsonSchemaLiteral(schema) && isString(schema.const) ? `"${String(value)}"` : isJsonSchemaEnum(schema) || isJsonSchemaNativeEnum(schema) ? `${camelCase(String(value))}` : isJsonSchemaArray(schema) && !isJsonSchemaMap(schema) ? StormJSON.stringify(value) : isJsonSchemaObject(schema) || isJsonSchemaRecord(schema) ? StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
67
62
  }
68
63
  /**
69
64
  * Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
@@ -71,11 +66,13 @@ function stringifyCapnpValue(type, value) {
71
66
  * @param type - The TypeEnum to evaluate.
72
67
  * @returns A string representation of the property.
73
68
  */
74
- function getCapnpEnumTypes(type) {
75
- if (type.kind !== ReflectionKind.enum) return null;
76
- const unique = getUniqueBy(type.values.filter((value) => !isUndefined(value) && !isNull(value)), (enumMember) => isString(enumMember) ? "Text" : "Float32");
77
- if (unique.length === 0) return null;
78
- return unique[0] && isString(unique[0]) ? "Text" : "Float32";
69
+ function getCapnpEnumTypes(schema) {
70
+ const s = schema;
71
+ if (!s.enum || !Array.isArray(s.enum)) return null;
72
+ const values = s.enum.filter((v) => v !== null && v !== void 0);
73
+ if (values.length === 0) return null;
74
+ const unique = getUniqueBy(values, (v) => isString(v) ? "Text" : "Float32");
75
+ return unique.length > 0 && isString(unique[0]) ? "Text" : "Float32";
79
76
  }
80
77
  /**
81
78
  * Determines if a Type is a `Void` type in a Cap'n Proto schema.
@@ -83,8 +80,8 @@ function getCapnpEnumTypes(type) {
83
80
  * @param type - The Type to check.
84
81
  * @returns True if the Type is a `Void` type, false otherwise.
85
82
  */
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;
83
+ function isVoidType(schema) {
84
+ return isJsonSchemaNever(schema) || isJsonSchemaNull(schema) || isJsonSchemaUndefined(schema);
88
85
  }
89
86
  /**
90
87
  * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
@@ -92,8 +89,12 @@ function isVoidType(type) {
92
89
  * @param type - The {@link TypeUnion} to convert.
93
90
  * @returns A string representation of the Cap'n Proto primitive type.
94
91
  */
95
- function getCapnpUnionTypes(type) {
96
- return getUnionTypes(type);
92
+ function getCapnpUnionTypes(schema) {
93
+ const s = schema;
94
+ if (Array.isArray(s.anyOf)) return s.anyOf;
95
+ if (Array.isArray(s.oneOf)) return s.oneOf;
96
+ if (Array.isArray(s.type)) return s.type.map((t) => ({ type: t }));
97
+ return [];
97
98
  }
98
99
  /**
99
100
  * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
@@ -101,8 +102,8 @@ function getCapnpUnionTypes(type) {
101
102
  * @param type - The {@link TypeUnion} to convert.
102
103
  * @returns An array of Cap'n Proto primitive types.
103
104
  */
104
- function isCapnpStringUnion(type) {
105
- return getCapnpUnionTypes(type).some((member) => member.kind === ReflectionKind.string);
105
+ function isCapnpStringUnion(schema) {
106
+ return getCapnpUnionTypes(schema).some((member) => isJsonSchemaString(member) || isJsonSchemaLiteral(member) && isString(member.const));
106
107
  }
107
108
  const LARGE_BUFFER = 1024 * 1e6;
108
109
  const execAsync = promisify(exec);
@@ -114,44 +115,48 @@ async function generateCapnpId() {
114
115
  });
115
116
  return stdout;
116
117
  }
117
- async function generateCapnp(context, reflection, options) {
118
+ async function generateCapnp(context, schema, options) {
118
119
  return `${(await generateCapnpId()).trim()};
119
120
  ${getFileHeader(context).replace(/^\r*\n*/g, "").replaceAll("//", "#")}
120
- ${reflection.getMethods().length === 0 ? generateCapnpStruct(reflection, options) : generateCapnpInterface(reflection, options)}
121
+ ${generateCapnpStruct(schema, options)}
121
122
  `.trim();
122
123
  }
123
- function generateCapnpStruct(reflection, options = {}) {
124
- const structName = options?.name || reflection.getTitle() || reflection.getClassName() || reflection.getName();
125
- return `${generateCapnpEnums(reflection)}struct ${pascalCase(structName)} {
124
+ function generateCapnpStruct(schema, options = {}) {
125
+ const structName = options?.name || schema.title || schema.name || "Schema";
126
+ return `${generateCapnpEnums(schema)}struct ${pascalCase(structName)} {
126
127
  # Struct definition for ${titleCase(structName)}.
127
128
 
128
- ${generateCapnpSchema(reflection, options)}
129
+ ${generateCapnpSchema(schema, options)}
129
130
  }
130
131
  `;
131
132
  }
132
- function generateCapnpInterface(reflection, options = {}) {
133
- const interfaceName = options?.name || reflection.getTitle() || reflection.getClassName() || reflection.getName();
134
- return `${generateCapnpEnums(reflection)}interface ${pascalCase(interfaceName)} {
133
+ function generateCapnpInterface(schema, options = {}) {
134
+ const interfaceName = options?.name || schema.title || schema.name || "Schema";
135
+ return `${generateCapnpEnums(schema)}interface ${pascalCase(interfaceName)} {
135
136
  # Interface definition for ${titleCase(interfaceName)}.
136
137
 
137
- ${generateCapnpSchema(reflection, options)}
138
+ ${generateCapnpSchema(schema, options)}
138
139
  }
139
140
  `;
140
141
  }
141
142
  function formatEnumName(name) {
142
143
  return pascalCase(`${name}_Type`);
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
+ function generateCapnpEnums(schema) {
146
+ const enums = getPropertiesList(schema).filter((prop) => !prop.ignore && (isJsonSchemaEnum(prop) || isJsonSchemaNativeEnum(prop) || (isJsonSchemaUnion(prop) || isJsonSchemaAnyOf(prop)) && getCapnpUnionTypes(prop).filter((t) => isJsonSchemaLiteral(t) && (isString(t.const) || isNumber(t.const))).length === 1)).sort((a, b) => a.readOnly && b.readOnly || !a.readOnly && !b.readOnly ? b.name.localeCompare(a.name) : a.readOnly ? 1 : -1);
146
147
  if (enums.length === 0) return "";
147
- return `${enums.map((enumeration) => generateCapnpEnumSchema(enumeration.type, formatEnumName(enumeration.getNameAsString()))).join("\n\n")}
148
+ return `${enums.map((prop) => generateCapnpEnumSchema(prop, formatEnumName(prop.name))).join("\n\n")}
148
149
 
149
150
  `;
150
151
  }
151
- function generateCapnpSchema(reflection, options = {}) {
152
+ function generateCapnpSchema(schema, options = {}) {
152
153
  let index = 0;
153
154
  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) ? `
155
+ const props = getPropertiesList(schema);
156
+ const filteredProps = props.filter((prop) => !prop.ignore).sort((a, b) => a.readOnly && b.readOnly || !a.readOnly && !b.readOnly ? b.name.localeCompare(a.name) : a.readOnly ? 1 : -1);
157
+ const hasMap = props.some((prop) => isJsonSchemaMap(prop));
158
+ const hasDate = props.some((prop) => isJsonSchemaDate(prop));
159
+ return `${filteredProps.map((prop) => generateCapnpPropertySchema(prop, indexCounter)).join(" \n\n ")}${hasMap ? `
155
160
  struct Map(Key, Value) {
156
161
  entries @0 :List(Entry);
157
162
 
@@ -159,7 +164,7 @@ function generateCapnpSchema(reflection, options = {}) {
159
164
  key @0 :Key;
160
165
  value @1 :Value;
161
166
  }
162
- }` : ""}${reflection.getProperties().some((prop) => prop.type.kind === ReflectionKind.class && prop.type.classType === Date) ? `
167
+ }` : ""}${hasDate ? `
163
168
  struct Date {
164
169
  # A standard Gregorian calendar date.
165
170
 
@@ -180,15 +185,8 @@ function generateCapnpSchema(reflection, options = {}) {
180
185
  millisecond @6 :UInt16; # Milliseconds of the second, 0-999
181
186
  }` : ""}`;
182
187
  }
183
- function generateCapnpMethodSchema(reflection, indexCounter) {
184
- const methodName = reflection.getTitle() || typeof reflection.getName() === "string" ? String(reflection.getName()) : "";
185
- if (!methodName) throw new Error(`Cannot generate Cap'n Proto schema for method without a name - Parent interface: ${reflection.reflectionClass.getName()}`);
186
- return `${camelCase(methodName)} @${indexCounter()} (${reflection.getParameters().map((param) => {
187
- return `${camelCase(param.getName())} :${generateCapnpPrimitive(param.getType())}${param.hasDefault() ? ` = ${stringifyCapnpDefaultValue(param)}` : ""}`;
188
- }).join(", ")})${isVoidType(reflection.getReturnType()) ? "" : ` -> (${kindToName(reflection.getReturnType().kind)}: ${generateCapnpPrimitive(reflection.getReturnType())})`}; # ${(reflection.getDescription() || `The ${titleCase(reflection.reflectionClass.getTitle() || reflection.reflectionClass.getName())} interface ${titleCase(methodName)} method.`).replaceAll("\n", ". ")}`;
189
- }
190
- function generateCapnpPropertyComment(reflection) {
191
- const result = getWords(reflection.getDescription() || `A schema property for ${titleCase(reflection.getTitle() || reflection.getNameAsString())} field.`, { relaxed: true }).reduce((ret, word) => {
188
+ function generateCapnpPropertyComment(prop) {
189
+ const result = getWords(prop.description || `A schema property for ${titleCase(prop.title || prop.name)} field.`, { relaxed: true }).reduce((ret, word) => {
192
190
  let length = ret.length;
193
191
  if (ret.includes("\n")) length = ret.substring(ret.lastIndexOf("\n") + 1).length;
194
192
  const current = word.trim();
@@ -199,50 +197,65 @@ function generateCapnpPropertyComment(reflection) {
199
197
  if (result.length > 0) return `\t# ${result}`;
200
198
  return "";
201
199
  }
202
- function generateCapnpPropertySchema(reflection, indexCounter) {
203
- if (reflection.type.kind === ReflectionKind.union) if (getCapnpUnionTypes(reflection.type).length === 0) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Void;
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)}` : ""};
206
- ${generateCapnpPropertyComment(reflection)}`;
207
- else return `${camelCase(reflection.getNameAsString())} :union {
208
- ${getCapnpUnionTypes(reflection.type).map((type) => ` ${kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(type)};`).join("\n")}
200
+ function generateCapnpPropertySchema(prop, indexCounter) {
201
+ const propName = prop.name;
202
+ const defaultStr = prop.default !== void 0 ? ` = ${stringifyCapnpDefaultValue(prop)}` : "";
203
+ if (isJsonSchemaUnion(prop) || isJsonSchemaAnyOf(prop)) {
204
+ const unionTypes = getCapnpUnionTypes(prop);
205
+ if (unionTypes.length === 0) return `${camelCase(propName)} @${indexCounter()} :Void;
206
+ ${generateCapnpPropertyComment(prop)}`;
207
+ else if (unionTypes.filter((t) => isJsonSchemaLiteral(t) && (isString(t.const) || isNumber(t.const))).length === 1) return `${camelCase(propName)} @${indexCounter()} :${formatEnumName(propName)}${defaultStr};
208
+ ${generateCapnpPropertyComment(prop)}`;
209
+ else return `${camelCase(propName)} :union {
210
+ ${unionTypes.map((t) => {
211
+ return ` ${getJsonSchemaCapnpTypeName(t)} @${indexCounter()} :${generateCapnpPrimitive(t)};`;
212
+ }).join("\n")}
209
213
  }
210
- ${generateCapnpPropertyComment(reflection)}`;
211
- else if (reflection.type.kind === ReflectionKind.array) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
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)}` : ""};
214
- ${generateCapnpPropertyComment(reflection)}`;
215
- else if (reflection.type.classType === Date) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
216
- ${generateCapnpPropertyComment(reflection)}`;
217
- else if (reflection.type.classType === Buffer) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
218
- ${generateCapnpPropertyComment(reflection)}`;
219
- else if (reflection.type.classType === ArrayBuffer) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
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)}` : ""};
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)}` : ""};
224
- ${generateCapnpPropertyComment(reflection)}`;
225
- else if (reflection.type.kind === ReflectionKind.enum) return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
226
- ${generateCapnpPropertyComment(reflection)}`;
227
- return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(reflection.getType())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
228
- ${generateCapnpPropertyComment(reflection)}`;
214
+ ${generateCapnpPropertyComment(prop)}`;
215
+ } else if (isJsonSchemaMap(prop)) {
216
+ const keySchema = prop.items?.prefixItems?.[0];
217
+ const valueSchema = prop.items?.prefixItems?.[1];
218
+ return `${camelCase(propName)} @${indexCounter()} :Map(${keySchema ? generateCapnpPrimitive(keySchema) : "Data"}, ${valueSchema ? generateCapnpPrimitive(valueSchema) : "Data"})${defaultStr};
219
+ ${generateCapnpPropertyComment(prop)}`;
220
+ } else if (isJsonSchemaDate(prop)) return `${camelCase(propName)} @${indexCounter()} :Data${defaultStr};
221
+ ${generateCapnpPropertyComment(prop)}`;
222
+ else if (isJsonSchemaSet(prop) || isJsonSchemaTuple(prop)) {
223
+ const itemSchema = prop.items;
224
+ return `${camelCase(propName)} @${indexCounter()} :List(${itemSchema ? generateCapnpPrimitive(itemSchema) : "Data"})${defaultStr};
225
+ ${generateCapnpPropertyComment(prop)}`;
226
+ } else if (isJsonSchemaArray(prop)) {
227
+ const itemSchema = prop.items;
228
+ return `${camelCase(propName)} @${indexCounter()} :List(${itemSchema ? generateCapnpPrimitive(itemSchema) : "Data"})${defaultStr};
229
+ ${generateCapnpPropertyComment(prop)}`;
230
+ } else if (isJsonSchemaRef(prop)) {
231
+ const refName = prop.$ref.split("/").pop() || prop.$ref;
232
+ return `${camelCase(propName)} @${indexCounter()} :${pascalCase(refName)}${defaultStr};
233
+ ${generateCapnpPropertyComment(prop)}`;
234
+ } else if (isJsonSchemaObject(prop) || isJsonSchemaRecord(prop)) {
235
+ const typeName = prop.title || propName;
236
+ return `${camelCase(propName)} @${indexCounter()} :${pascalCase(typeName)}${generateCapnpStruct(prop, { name: pascalCase(typeName) })}${defaultStr};
237
+ ${generateCapnpPropertyComment(prop)}`;
238
+ } else if (isJsonSchemaEnum(prop) || isJsonSchemaNativeEnum(prop)) return `${camelCase(propName)} @${indexCounter()} :${pascalCase(propName)}${defaultStr};
239
+ ${generateCapnpPropertyComment(prop)}`;
240
+ return `${camelCase(propName)} @${indexCounter()} :${generateCapnpPrimitive(prop)}${defaultStr};
241
+ ${generateCapnpPropertyComment(prop)}`;
229
242
  }
230
- function generateCapnpEnumSchema(type, name) {
231
- if (type.kind === ReflectionKind.union) return generateCapnpEnumSchema({
232
- kind: ReflectionKind.enum,
233
- indexType: type,
234
- enum: type.types.reduce((ret, type) => {
235
- if (isString(type.literal) || isNumber(type.literal)) ret[camelCase(String(type.literal))] = type.literal;
236
- return ret;
237
- }, {}),
238
- values: getCapnpUnionTypes(type).filter((type) => type.kind === ReflectionKind.literal && (isString(type.literal) || isNumber(type.literal))).map((type) => type.literal)
239
- }, name);
243
+ function generateCapnpEnumSchema(schema, name) {
244
+ if (isJsonSchemaAnyOf(schema)) {
245
+ const enumValues = (schema.anyOf || []).filter((t) => isJsonSchemaLiteral(t) && (isString(t.const) || isNumber(t.const))).map((t) => t.const);
246
+ return generateCapnpEnumSchema({
247
+ type: enumValues.some((v) => isString(v)) ? "string" : "number",
248
+ enum: enumValues
249
+ }, name);
250
+ }
240
251
  let index = 0;
241
252
  const indexCounter = () => index++;
242
- const enumType = getCapnpEnumTypes(type);
253
+ const enumType = getCapnpEnumTypes(schema);
243
254
  if (!enumType) return "";
255
+ const values = (schema.enum || []).filter((v) => v !== null && v !== void 0);
256
+ const schemaTitle = schema.title;
244
257
  return `enum ${pascalCase(name)} {
245
- ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).filter(([, value]) => value !== null && value !== void 0).map(([key]) => ` ${camelCase(key)} @${indexCounter()};`).join("\n") : type.values.filter((value) => value !== null && value !== void 0).map((value) => `${enumType === "Text" && value ? camelCase(String(value)) : `${type.typeName ? `${camelCase(type.typeName)}_` : ""}${value || ""}`} @${indexCounter()};`).join("\n")}
258
+ ${values.map((value) => ` ${enumType === "Text" && value ? camelCase(String(value)) : `${schemaTitle ? `${camelCase(schemaTitle)}_` : ""}${value || ""}`} @${indexCounter()};`).join("\n")}
246
259
  }`;
247
260
  }
248
261
  /**
@@ -251,10 +264,52 @@ ${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).
251
264
  * @param type - The Deepkit Type to convert.
252
265
  * @returns A string representation of the Cap'n Proto primitive type.
253
266
  */
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";
267
+ /**
268
+ * Generates a string representation of Cap'n Proto primitive types from a JSON Schema.
269
+ *
270
+ * @param schema - The JSON Schema to convert.
271
+ * @returns A string representation of the Cap'n Proto primitive type.
272
+ */
273
+ function generateCapnpPrimitive(schema) {
274
+ if (isJsonSchemaNever(schema) || isJsonSchemaNull(schema) || isJsonSchemaUndefined(schema)) return "Void";
275
+ if (isJsonSchemaDate(schema)) return "Date";
276
+ if (isJsonSchemaSet(schema)) {
277
+ const itemSchema = schema.items;
278
+ return `List(${itemSchema ? generateCapnpPrimitive(itemSchema) : "Data"})`;
279
+ }
280
+ if (isJsonSchemaBigint(schema)) return "UInt64";
281
+ if (isJsonSchemaNumber(schema) || isJsonSchemaInteger(schema)) return "Float64";
282
+ if (isJsonSchemaString(schema)) return "Text";
283
+ if (isJsonSchemaBoolean(schema)) return "Bool";
284
+ if (isJsonSchemaLiteral(schema)) {
285
+ const constVal = schema.const;
286
+ if (isNumber(constVal)) return "Float64";
287
+ if (isBigInt(constVal)) return "UInt64";
288
+ if (isString(constVal)) return "Text";
289
+ if (typeof constVal === "boolean") return "Bool";
290
+ }
291
+ return "Data";
292
+ }
293
+ /**
294
+ * Returns a descriptive Cap'n Proto field name for a JSON Schema member in a union.
295
+ *
296
+ * @param schema - The JSON Schema union member.
297
+ * @returns A camelCase name suitable for use as a Cap'n Proto union field label.
298
+ */
299
+ function getJsonSchemaCapnpTypeName(schema) {
300
+ const s = schema;
301
+ if (s.title || s.name) return camelCase(String(s.title || s.name));
302
+ if (s.type) return camelCase(Array.isArray(s.type) ? String(s.type[0]) : String(s.type));
303
+ if ("const" in s) {
304
+ if (isString(s.const)) return "string";
305
+ if (isNumber(s.const)) return "number";
306
+ if (typeof s.const === "boolean") return "bool";
307
+ if (isBigInt(s.const)) return "bigInt";
308
+ }
309
+ if (s.anyOf) return "union";
310
+ return "data";
256
311
  }
257
312
 
258
313
  //#endregion
259
- export { LARGE_BUFFER, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue };
314
+ export { LARGE_BUFFER, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue };
260
315
  //# sourceMappingURL=capnp.mjs.map
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_helpers_typescript = require('./typescript.cjs');
3
2
  const require_helpers_refkey = require('./refkey.cjs');
4
3
  const require_helpers_capnp = require('./capnp.cjs');
5
4
  const require_helpers_create_builtin = require('./create-builtin.cjs');
@@ -11,11 +10,9 @@ exports.generateCapnp = require_helpers_capnp.generateCapnp;
11
10
  exports.generateCapnpEnumSchema = require_helpers_capnp.generateCapnpEnumSchema;
12
11
  exports.generateCapnpId = require_helpers_capnp.generateCapnpId;
13
12
  exports.generateCapnpInterface = require_helpers_capnp.generateCapnpInterface;
14
- exports.generateCapnpMethodSchema = require_helpers_capnp.generateCapnpMethodSchema;
15
13
  exports.generateCapnpPrimitive = require_helpers_capnp.generateCapnpPrimitive;
16
14
  exports.generateCapnpSchema = require_helpers_capnp.generateCapnpSchema;
17
15
  exports.generateCapnpStruct = require_helpers_capnp.generateCapnpStruct;
18
- exports.generateObjectDeclaration = require_helpers_typescript.generateObjectDeclaration;
19
16
  exports.getCapnpEnumTypes = require_helpers_capnp.getCapnpEnumTypes;
20
17
  exports.getCapnpUnionTypes = require_helpers_capnp.getCapnpUnionTypes;
21
18
  exports.isCapnpStringUnion = require_helpers_capnp.isCapnpStringUnion;
@@ -1,5 +1,4 @@
1
- import { GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue } from "./capnp.cjs";
1
+ import { GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue } from "./capnp.cjs";
2
2
  import { CreateBuiltinOptions, createBuiltin } from "./create-builtin.cjs";
3
3
  import { refkey } from "./refkey.cjs";
4
- import { GenerateInterfaceDeclarationOptions, GenerateObjectDeclarationOptions, generateObjectDeclaration } from "./typescript.cjs";
5
- export { CreateBuiltinOptions, GenerateCapnpOptions, GenerateCapnpStructOptions, GenerateInterfaceDeclarationOptions, GenerateObjectDeclarationOptions, IOType, LARGE_BUFFER, StdioOptions, compile, createBuiltin, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, generateObjectDeclaration, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, refkey, stringifyCapnpDefaultValue, stringifyCapnpValue };
4
+ export { CreateBuiltinOptions, GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, createBuiltin, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, refkey, stringifyCapnpDefaultValue, stringifyCapnpValue };
@@ -1,5 +1,4 @@
1
- import { GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue } from "./capnp.mjs";
1
+ import { GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue } from "./capnp.mjs";
2
2
  import { CreateBuiltinOptions, createBuiltin } from "./create-builtin.mjs";
3
3
  import { refkey } from "./refkey.mjs";
4
- import { GenerateInterfaceDeclarationOptions, GenerateObjectDeclarationOptions, generateObjectDeclaration } from "./typescript.mjs";
5
- export { CreateBuiltinOptions, GenerateCapnpOptions, GenerateCapnpStructOptions, GenerateInterfaceDeclarationOptions, GenerateObjectDeclarationOptions, IOType, LARGE_BUFFER, StdioOptions, compile, createBuiltin, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, generateObjectDeclaration, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, refkey, stringifyCapnpDefaultValue, stringifyCapnpValue };
4
+ export { CreateBuiltinOptions, GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, compile, createBuiltin, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, refkey, stringifyCapnpDefaultValue, stringifyCapnpValue };
@@ -1,6 +1,5 @@
1
- import { generateObjectDeclaration } from "./typescript.mjs";
2
1
  import { refkey } from "./refkey.mjs";
3
- import { LARGE_BUFFER, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue } from "./capnp.mjs";
2
+ import { LARGE_BUFFER, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue } from "./capnp.mjs";
4
3
  import { createBuiltin } from "./create-builtin.mjs";
5
4
 
6
- export { LARGE_BUFFER, compile, createBuiltin, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, generateObjectDeclaration, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, refkey, stringifyCapnpDefaultValue, stringifyCapnpValue };
5
+ export { LARGE_BUFFER, compile, createBuiltin, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, refkey, stringifyCapnpDefaultValue, stringifyCapnpValue };
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  let _powerlines_plugin_babel = require("@powerlines/plugin-babel");
4
- _powerlines_plugin_babel = require_runtime.__toESM(_powerlines_plugin_babel);
4
+ _powerlines_plugin_babel = require_runtime.__toESM(_powerlines_plugin_babel, 1);
5
5
  let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
6
6
 
7
7
  //#region src/index.tsx
@@ -0,0 +1,74 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_core_components_spacing = require('../../core/components/spacing.cjs');
3
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
+ let _alloy_js_core = require("@alloy-js/core");
5
+
6
+ //#region src/markdown/components/alert.tsx
7
+ /**
8
+ * Renders an alert component for a markdown file.
9
+ *
10
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
11
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
12
+ */
13
+ function Alert(props) {
14
+ return [
15
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`> [!${props.variant.toUpperCase()}]`),
16
+ (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
17
+ _alloy_js_core.code`> `,
18
+ (0, _alloy_js_core_jsx_runtime.memo)(() => props.children),
19
+ (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_components_spacing.Spacing, {})
20
+ ];
21
+ }
22
+ /**
23
+ * Renders a Note alert component for a markdown file.
24
+ *
25
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
26
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
27
+ */
28
+ function NoteAlert(props) {
29
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(Alert, (0, _alloy_js_core_jsx_runtime.mergeProps)({ variant: "note" }, props));
30
+ }
31
+ /**
32
+ * Renders a Tip alert component for a markdown file.
33
+ *
34
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
35
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
36
+ */
37
+ function TipAlert(props) {
38
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(Alert, (0, _alloy_js_core_jsx_runtime.mergeProps)({ variant: "tip" }, props));
39
+ }
40
+ /**
41
+ * Renders an Important alert component for a markdown file.
42
+ *
43
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
44
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
45
+ */
46
+ function ImportantAlert(props) {
47
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(Alert, (0, _alloy_js_core_jsx_runtime.mergeProps)({ variant: "important" }, props));
48
+ }
49
+ /**
50
+ * Renders a Warning alert component for a markdown file.
51
+ *
52
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
53
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
54
+ */
55
+ function WarningAlert(props) {
56
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(Alert, (0, _alloy_js_core_jsx_runtime.mergeProps)({ variant: "warning" }, props));
57
+ }
58
+ /**
59
+ * Renders a Caution alert component for a markdown file.
60
+ *
61
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
62
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
63
+ */
64
+ function CautionAlert(props) {
65
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(Alert, (0, _alloy_js_core_jsx_runtime.mergeProps)({ variant: "caution" }, props));
66
+ }
67
+
68
+ //#endregion
69
+ exports.Alert = Alert;
70
+ exports.CautionAlert = CautionAlert;
71
+ exports.ImportantAlert = ImportantAlert;
72
+ exports.NoteAlert = NoteAlert;
73
+ exports.TipAlert = TipAlert;
74
+ exports.WarningAlert = WarningAlert;
@@ -0,0 +1,53 @@
1
+ import { Children } from "@alloy-js/core";
2
+
3
+ //#region src/markdown/components/alert.d.ts
4
+ interface AlertProps {
5
+ variant: "note" | "tip" | "important" | "warning" | "caution";
6
+ children: Children;
7
+ }
8
+ /**
9
+ * Renders an alert component for a markdown file.
10
+ *
11
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
12
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
13
+ */
14
+ declare function Alert(props: AlertProps): Children;
15
+ type AlertVariantProps = Omit<AlertProps, "variant">;
16
+ /**
17
+ * Renders a Note alert component for a markdown file.
18
+ *
19
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
20
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
21
+ */
22
+ declare function NoteAlert(props: AlertVariantProps): Children;
23
+ /**
24
+ * Renders a Tip alert component for a markdown file.
25
+ *
26
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
27
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
28
+ */
29
+ declare function TipAlert(props: AlertVariantProps): Children;
30
+ /**
31
+ * Renders an Important alert component for a markdown file.
32
+ *
33
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
34
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
35
+ */
36
+ declare function ImportantAlert(props: AlertVariantProps): Children;
37
+ /**
38
+ * Renders a Warning alert component for a markdown file.
39
+ *
40
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
41
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
42
+ */
43
+ declare function WarningAlert(props: AlertVariantProps): Children;
44
+ /**
45
+ * Renders a Caution alert component for a markdown file.
46
+ *
47
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
48
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
49
+ */
50
+ declare function CautionAlert(props: AlertVariantProps): Children;
51
+ //#endregion
52
+ export { Alert, AlertProps, AlertVariantProps, CautionAlert, ImportantAlert, NoteAlert, TipAlert, WarningAlert };
53
+ //# sourceMappingURL=alert.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.d.cts","names":[],"sources":["../../../src/markdown/components/alert.tsx"],"mappings":";;;UAqBiB,UAAA;EACf,OAAA;EACA,QAAA,EAAU,QAAQ;AAAA;;;;;;;iBASJ,KAAA,CAAM,KAAA,EAAO,UAAA,GAAU,QAAA;AAAA,KAY3B,iBAAA,GAAoB,IAAI,CAAC,UAAA;;;;;;;iBAQrB,SAAA,CAAU,KAAA,EAAO,iBAAA,GAAiB,QAAA;AApBX;AAYvC;;;;AAA+C;AAZR,iBA8BvB,QAAA,CAAS,KAAA,EAAO,iBAAA,GAAiB,QAAA;;;;;;;iBAUjC,cAAA,CAAe,KAAA,EAAO,iBAAA,GAAiB,QAAA;AApBL;AAUlD;;;;;AAVkD,iBA8BlC,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAiB,QAAA;;;AApBJ;AAUjD;;;iBAoBgB,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAiB,QAAA"}
@@ -0,0 +1,53 @@
1
+ import { Children } from "@alloy-js/core";
2
+
3
+ //#region src/markdown/components/alert.d.ts
4
+ interface AlertProps {
5
+ variant: "note" | "tip" | "important" | "warning" | "caution";
6
+ children: Children;
7
+ }
8
+ /**
9
+ * Renders an alert component for a markdown file.
10
+ *
11
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
12
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
13
+ */
14
+ declare function Alert(props: AlertProps): Children;
15
+ type AlertVariantProps = Omit<AlertProps, "variant">;
16
+ /**
17
+ * Renders a Note alert component for a markdown file.
18
+ *
19
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
20
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
21
+ */
22
+ declare function NoteAlert(props: AlertVariantProps): Children;
23
+ /**
24
+ * Renders a Tip alert component for a markdown file.
25
+ *
26
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
27
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
28
+ */
29
+ declare function TipAlert(props: AlertVariantProps): Children;
30
+ /**
31
+ * Renders an Important alert component for a markdown file.
32
+ *
33
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
34
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
35
+ */
36
+ declare function ImportantAlert(props: AlertVariantProps): Children;
37
+ /**
38
+ * Renders a Warning alert component for a markdown file.
39
+ *
40
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
41
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
42
+ */
43
+ declare function WarningAlert(props: AlertVariantProps): Children;
44
+ /**
45
+ * Renders a Caution alert component for a markdown file.
46
+ *
47
+ * @see https://github.blog/changelog/2023-12-14-new-markdown-extension-alerts-provide-distinctive-styling-for-significant-content/
48
+ * @see https://github.com/KeJunMao/vscode-markdown-alert
49
+ */
50
+ declare function CautionAlert(props: AlertVariantProps): Children;
51
+ //#endregion
52
+ export { Alert, AlertProps, AlertVariantProps, CautionAlert, ImportantAlert, NoteAlert, TipAlert, WarningAlert };
53
+ //# sourceMappingURL=alert.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.d.mts","names":[],"sources":["../../../src/markdown/components/alert.tsx"],"mappings":""}