@powerlines/plugin-alloy 0.26.238 → 0.26.240
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/helpers/capnp.cjs +27 -27
- package/dist/helpers/capnp.d.cts +1 -1
- package/dist/helpers/capnp.d.cts.map +1 -1
- package/dist/helpers/capnp.d.mts +1 -1
- package/dist/helpers/capnp.mjs +1 -1
- package/dist/render.cjs +5 -7
- package/dist/render.d.cts +4 -6
- package/dist/render.d.cts.map +1 -1
- package/dist/render.d.mts +4 -6
- package/dist/render.mjs +5 -7
- package/package.json +9 -9
package/dist/helpers/capnp.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
let defu = require("defu");
|
|
4
4
|
defu = require_runtime.__toESM(defu, 1);
|
|
5
|
-
let
|
|
5
|
+
let _power_plant_schema = require("@power-plant/schema");
|
|
6
6
|
let _stryke_capnp_compile = require("@stryke/capnp/compile");
|
|
7
7
|
let _stryke_capnp_helpers = require("@stryke/capnp/helpers");
|
|
8
8
|
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
@@ -61,7 +61,7 @@ function stringifyCapnpDefaultValue(property, value) {
|
|
|
61
61
|
* @returns A string representation of the value.
|
|
62
62
|
*/
|
|
63
63
|
function stringifyCapnpValue(schema, value) {
|
|
64
|
-
return (0,
|
|
64
|
+
return (0, _power_plant_schema.isJsonSchemaString)(schema) || (0, _power_plant_schema.isJsonSchemaLiteral)(schema) && (0, _stryke_type_checks_is_string.isString)(schema.const) ? `"${String(value)}"` : (0, _power_plant_schema.isJsonSchemaEnum)(schema) || (0, _power_plant_schema.isJsonSchemaNativeEnum)(schema) ? `${(0, _stryke_string_format_camel_case.camelCase)(String(value))}` : (0, _power_plant_schema.isJsonSchemaArray)(schema) && !(0, _power_plant_schema.isJsonSchemaMap)(schema) ? _stryke_json.StormJSON.stringify(value) : (0, _power_plant_schema.isJsonSchemaObject)(schema) || (0, _power_plant_schema.isJsonSchemaRecord)(schema) ? _stryke_json.StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
@@ -84,7 +84,7 @@ function getCapnpEnumTypes(schema) {
|
|
|
84
84
|
* @returns True if the Type is a `Void` type, false otherwise.
|
|
85
85
|
*/
|
|
86
86
|
function isVoidType(schema) {
|
|
87
|
-
return (0,
|
|
87
|
+
return (0, _power_plant_schema.isJsonSchemaNever)(schema) || (0, _power_plant_schema.isJsonSchemaNull)(schema) || (0, _power_plant_schema.isJsonSchemaUndefined)(schema);
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
@@ -106,7 +106,7 @@ function getCapnpUnionTypes(schema) {
|
|
|
106
106
|
* @returns An array of Cap'n Proto primitive types.
|
|
107
107
|
*/
|
|
108
108
|
function isCapnpStringUnion(schema) {
|
|
109
|
-
return getCapnpUnionTypes(schema).some((member) => (0,
|
|
109
|
+
return getCapnpUnionTypes(schema).some((member) => (0, _power_plant_schema.isJsonSchemaString)(member) || (0, _power_plant_schema.isJsonSchemaLiteral)(member) && (0, _stryke_type_checks_is_string.isString)(member.const));
|
|
110
110
|
}
|
|
111
111
|
const LARGE_BUFFER = 1024 * 1e6;
|
|
112
112
|
const execAsync = (0, node_util.promisify)(node_child_process.exec);
|
|
@@ -146,7 +146,7 @@ function formatEnumName(name) {
|
|
|
146
146
|
return (0, _stryke_string_format_pascal_case.pascalCase)(`${name}_Type`);
|
|
147
147
|
}
|
|
148
148
|
function generateCapnpEnums(schema) {
|
|
149
|
-
const enums = (0,
|
|
149
|
+
const enums = (0, _power_plant_schema.getPropertiesList)(schema).filter((prop) => !prop.ignore && ((0, _power_plant_schema.isJsonSchemaEnum)(prop) || (0, _power_plant_schema.isJsonSchemaNativeEnum)(prop) || ((0, _power_plant_schema.isJsonSchemaUnion)(prop) || (0, _power_plant_schema.isJsonSchemaAnyOf)(prop)) && getCapnpUnionTypes(prop).filter((t) => (0, _power_plant_schema.isJsonSchemaLiteral)(t) && ((0, _stryke_type_checks_is_string.isString)(t.const) || (0, _stryke_type_checks_is_number.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);
|
|
150
150
|
if (enums.length === 0) return "";
|
|
151
151
|
return `${enums.map((prop) => generateCapnpEnumSchema(prop, formatEnumName(prop.name))).join("\n\n")}
|
|
152
152
|
|
|
@@ -155,10 +155,10 @@ function generateCapnpEnums(schema) {
|
|
|
155
155
|
function generateCapnpSchema(schema, options = {}) {
|
|
156
156
|
let index = 0;
|
|
157
157
|
const indexCounter = options?.indexCounter ?? (() => index++);
|
|
158
|
-
const props = (0,
|
|
158
|
+
const props = (0, _power_plant_schema.getPropertiesList)(schema);
|
|
159
159
|
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);
|
|
160
|
-
const hasMap = props.some((prop) => (0,
|
|
161
|
-
const hasDate = props.some((prop) => (0,
|
|
160
|
+
const hasMap = props.some((prop) => (0, _power_plant_schema.isJsonSchemaMap)(prop));
|
|
161
|
+
const hasDate = props.some((prop) => (0, _power_plant_schema.isJsonSchemaDate)(prop));
|
|
162
162
|
return `${filteredProps.map((prop) => generateCapnpPropertySchema(prop, indexCounter)).join(" \n\n ")}${hasMap ? `
|
|
163
163
|
struct Map(Key, Value) {
|
|
164
164
|
entries @0 :List(Entry);
|
|
@@ -203,11 +203,11 @@ function generateCapnpPropertyComment(prop) {
|
|
|
203
203
|
function generateCapnpPropertySchema(prop, indexCounter) {
|
|
204
204
|
const propName = prop.name;
|
|
205
205
|
const defaultStr = prop.default !== void 0 ? ` = ${stringifyCapnpDefaultValue(prop)}` : "";
|
|
206
|
-
if ((0,
|
|
206
|
+
if ((0, _power_plant_schema.isJsonSchemaUnion)(prop) || (0, _power_plant_schema.isJsonSchemaAnyOf)(prop)) {
|
|
207
207
|
const unionTypes = getCapnpUnionTypes(prop);
|
|
208
208
|
if (unionTypes.length === 0) return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :Void;
|
|
209
209
|
${generateCapnpPropertyComment(prop)}`;
|
|
210
|
-
else if (unionTypes.filter((t) => (0,
|
|
210
|
+
else if (unionTypes.filter((t) => (0, _power_plant_schema.isJsonSchemaLiteral)(t) && ((0, _stryke_type_checks_is_string.isString)(t.const) || (0, _stryke_type_checks_is_number.isNumber)(t.const))).length === 1) return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${formatEnumName(propName)}${defaultStr};
|
|
211
211
|
${generateCapnpPropertyComment(prop)}`;
|
|
212
212
|
else return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} :union {
|
|
213
213
|
${unionTypes.map((t) => {
|
|
@@ -215,37 +215,37 @@ ${unionTypes.map((t) => {
|
|
|
215
215
|
}).join("\n")}
|
|
216
216
|
}
|
|
217
217
|
${generateCapnpPropertyComment(prop)}`;
|
|
218
|
-
} else if ((0,
|
|
218
|
+
} else if ((0, _power_plant_schema.isJsonSchemaMap)(prop)) {
|
|
219
219
|
const keySchema = prop.items?.prefixItems?.[0];
|
|
220
220
|
const valueSchema = prop.items?.prefixItems?.[1];
|
|
221
221
|
return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :Map(${keySchema ? generateCapnpPrimitive(keySchema) : "Data"}, ${valueSchema ? generateCapnpPrimitive(valueSchema) : "Data"})${defaultStr};
|
|
222
222
|
${generateCapnpPropertyComment(prop)}`;
|
|
223
|
-
} else if ((0,
|
|
223
|
+
} else if ((0, _power_plant_schema.isJsonSchemaDate)(prop)) return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :Data${defaultStr};
|
|
224
224
|
${generateCapnpPropertyComment(prop)}`;
|
|
225
|
-
else if ((0,
|
|
225
|
+
else if ((0, _power_plant_schema.isJsonSchemaSet)(prop) || (0, _power_plant_schema.isJsonSchemaTuple)(prop)) {
|
|
226
226
|
const itemSchema = prop.items;
|
|
227
227
|
return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :List(${itemSchema ? generateCapnpPrimitive(itemSchema) : "Data"})${defaultStr};
|
|
228
228
|
${generateCapnpPropertyComment(prop)}`;
|
|
229
|
-
} else if ((0,
|
|
229
|
+
} else if ((0, _power_plant_schema.isJsonSchemaArray)(prop)) {
|
|
230
230
|
const itemSchema = prop.items;
|
|
231
231
|
return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :List(${itemSchema ? generateCapnpPrimitive(itemSchema) : "Data"})${defaultStr};
|
|
232
232
|
${generateCapnpPropertyComment(prop)}`;
|
|
233
|
-
} else if ((0,
|
|
233
|
+
} else if ((0, _power_plant_schema.isJsonSchemaRef)(prop)) {
|
|
234
234
|
const refName = prop.$ref.split("/").pop() || prop.$ref;
|
|
235
235
|
return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(refName)}${defaultStr};
|
|
236
236
|
${generateCapnpPropertyComment(prop)}`;
|
|
237
|
-
} else if ((0,
|
|
237
|
+
} else if ((0, _power_plant_schema.isJsonSchemaObject)(prop) || (0, _power_plant_schema.isJsonSchemaRecord)(prop)) {
|
|
238
238
|
const typeName = prop.title || propName;
|
|
239
239
|
return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(typeName)}${generateCapnpStruct(prop, { name: (0, _stryke_string_format_pascal_case.pascalCase)(typeName) })}${defaultStr};
|
|
240
240
|
${generateCapnpPropertyComment(prop)}`;
|
|
241
|
-
} else if ((0,
|
|
241
|
+
} else if ((0, _power_plant_schema.isJsonSchemaEnum)(prop) || (0, _power_plant_schema.isJsonSchemaNativeEnum)(prop)) return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(propName)}${defaultStr};
|
|
242
242
|
${generateCapnpPropertyComment(prop)}`;
|
|
243
243
|
return `${(0, _stryke_string_format_camel_case.camelCase)(propName)} @${indexCounter()} :${generateCapnpPrimitive(prop)}${defaultStr};
|
|
244
244
|
${generateCapnpPropertyComment(prop)}`;
|
|
245
245
|
}
|
|
246
246
|
function generateCapnpEnumSchema(schema, name) {
|
|
247
|
-
if ((0,
|
|
248
|
-
const enumValues = (schema.anyOf || []).filter((t) => (0,
|
|
247
|
+
if ((0, _power_plant_schema.isJsonSchemaAnyOf)(schema)) {
|
|
248
|
+
const enumValues = (schema.anyOf || []).filter((t) => (0, _power_plant_schema.isJsonSchemaLiteral)(t) && ((0, _stryke_type_checks_is_string.isString)(t.const) || (0, _stryke_type_checks_is_number.isNumber)(t.const))).map((t) => t.const);
|
|
249
249
|
return generateCapnpEnumSchema({
|
|
250
250
|
type: enumValues.some((v) => (0, _stryke_type_checks_is_string.isString)(v)) ? "string" : "number",
|
|
251
251
|
enum: enumValues
|
|
@@ -274,17 +274,17 @@ ${values.map((value) => ` ${enumType === "Text" && value ? (0, _stryke_string
|
|
|
274
274
|
* @returns A string representation of the Cap'n Proto primitive type.
|
|
275
275
|
*/
|
|
276
276
|
function generateCapnpPrimitive(schema) {
|
|
277
|
-
if ((0,
|
|
278
|
-
if ((0,
|
|
279
|
-
if ((0,
|
|
277
|
+
if ((0, _power_plant_schema.isJsonSchemaNever)(schema) || (0, _power_plant_schema.isJsonSchemaNull)(schema) || (0, _power_plant_schema.isJsonSchemaUndefined)(schema)) return "Void";
|
|
278
|
+
if ((0, _power_plant_schema.isJsonSchemaDate)(schema)) return "Date";
|
|
279
|
+
if ((0, _power_plant_schema.isJsonSchemaSet)(schema)) {
|
|
280
280
|
const itemSchema = schema.items;
|
|
281
281
|
return `List(${itemSchema ? generateCapnpPrimitive(itemSchema) : "Data"})`;
|
|
282
282
|
}
|
|
283
|
-
if ((0,
|
|
284
|
-
if ((0,
|
|
285
|
-
if ((0,
|
|
286
|
-
if ((0,
|
|
287
|
-
if ((0,
|
|
283
|
+
if ((0, _power_plant_schema.isJsonSchemaBigint)(schema)) return "UInt64";
|
|
284
|
+
if ((0, _power_plant_schema.isJsonSchemaNumber)(schema) || (0, _power_plant_schema.isJsonSchemaInteger)(schema)) return "Float64";
|
|
285
|
+
if ((0, _power_plant_schema.isJsonSchemaString)(schema)) return "Text";
|
|
286
|
+
if ((0, _power_plant_schema.isJsonSchemaBoolean)(schema)) return "Bool";
|
|
287
|
+
if ((0, _power_plant_schema.isJsonSchemaLiteral)(schema)) {
|
|
288
288
|
const constVal = schema.const;
|
|
289
289
|
if ((0, _stryke_type_checks_is_number.isNumber)(constVal)) return "Float64";
|
|
290
290
|
if ((0, _stryke_type_checks_is_bigint.isBigInt)(constVal)) return "UInt64";
|
package/dist/helpers/capnp.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, PluginContext } from "powerlines";
|
|
2
|
-
import { GetPropertyResult, JsonSchema, JsonSchemaAnyOf, JsonSchemaEnum, JsonSchemaNativeEnum, JsonSchemaObject } from "@
|
|
2
|
+
import { GetPropertyResult, JsonSchema, JsonSchemaAnyOf, JsonSchemaEnum, JsonSchemaNativeEnum, JsonSchemaObject } from "@power-plant/schema";
|
|
3
3
|
import { CapnpcOptions, CapnpcResult } from "@stryke/capnp/types";
|
|
4
4
|
//#region src/helpers/capnp.d.ts
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capnp.d.cts","names":[],"sources":["../../src/helpers/capnp.ts"],"mappings":";;;;;;;;;;;iBA8EsB,QACpB,SAAS,SACT,UAAS,QAAQ,iBAChB,QAAQ;;;;;;;;iBA+BK,2BACd,UAAU,mBACV;;;;;;;;iBAYc,oBAAoB,QAAQ,YAAY;;;;;;;iBAmBxC,kBACd,QAAQ;;;;;;;iBAuBM,WAAW,QAAQ;;;;;;;iBAcnB,mBAAmB,QAAQ,aAAa;;;;;;;iBAoBxC,mBAAmB,QAAQ;cAS9B;KACD;KACA,
|
|
1
|
+
{"version":3,"file":"capnp.d.cts","names":[],"sources":["../../src/helpers/capnp.ts"],"mappings":";;;;;;;;;;;iBA8EsB,QACpB,SAAS,SACT,UAAS,QAAQ,iBAChB,QAAQ;;;;;;;;iBA+BK,2BACd,UAAU,mBACV;;;;;;;;iBAYc,oBAAoB,QAAQ,YAAY;;;;;;;iBAmBxC,kBACd,QAAQ;;;;;;;iBAuBM,WAAW,QAAQ;;;;;;;iBAcnB,mBAAmB,QAAQ,aAAa;;;;;;;iBAoBxC,mBAAmB,QAAQ;cAS9B;KACD;KACA,eACV,SAAS,MAAM;iBAIK,mBAAe;UAUpB;EACf;;iBAGoB,cACpB,SAAS,eACT,QAAQ,kBACR,SAAS,uBAAoB;UAYd,mCAAmC;EAClD;;iBAGc,oBACd,QAAQ,kBACR,UAAS;iBAYK,uBACd,QAAQ,kBACR,UAAS;iBAyDK,oBACd,QAAQ,kBACR,UAAS;iBA+KK,wBACd,QAAQ,iBAAiB,uBAAuB,iBAChD;;;;;;;;;;;;;iBA4Dc,uBAAuB,QAAQ"}
|
package/dist/helpers/capnp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetPropertyResult, JsonSchema, JsonSchemaAnyOf, JsonSchemaEnum, JsonSchemaNativeEnum, JsonSchemaObject } from "@
|
|
1
|
+
import { GetPropertyResult, JsonSchema, JsonSchemaAnyOf, JsonSchemaEnum, JsonSchemaNativeEnum, JsonSchemaObject } from "@power-plant/schema";
|
|
2
2
|
import { Context, PluginContext } from "powerlines";
|
|
3
3
|
import { CapnpcOptions, CapnpcResult } from "@stryke/capnp/types";
|
|
4
4
|
//#region src/helpers/capnp.d.ts
|
package/dist/helpers/capnp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import defu from "defu";
|
|
2
|
-
import { getPropertiesList, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaUndefined, isJsonSchemaUnion } from "@
|
|
2
|
+
import { getPropertiesList, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaUndefined, isJsonSchemaUnion } from "@power-plant/schema";
|
|
3
3
|
import { capnpc } from "@stryke/capnp/compile";
|
|
4
4
|
import { resolveOptions } from "@stryke/capnp/helpers";
|
|
5
5
|
import { toArray } from "@stryke/convert/to-array";
|
package/dist/render.cjs
CHANGED
|
@@ -15,12 +15,10 @@ function getDocumentContents(document) {
|
|
|
15
15
|
return (document.chunks ?? []).map((chunk) => chunk.content ?? "").join("");
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* A function to render
|
|
18
|
+
* A function to render Alloy-js template components within the [Alloy-js](https://alloy-framework.github.io) context, and write any saved content to the file system.
|
|
19
19
|
*
|
|
20
20
|
* @remarks
|
|
21
|
-
* Uses Power Plant's {@link generate | `generate`} entry point to create an
|
|
22
|
-
* execution context and render Alloy-js templates, then emits the resulting
|
|
23
|
-
* documents through the Powerlines plugin context.
|
|
21
|
+
* Uses Power Plant's {@link generate | `generate`} entry point to create an execution context and render Alloy-js templates, then emits the resulting documents through the Powerlines plugin context.
|
|
24
22
|
*
|
|
25
23
|
* @example
|
|
26
24
|
* ```tsx
|
|
@@ -32,13 +30,13 @@ function getDocumentContents(document) {
|
|
|
32
30
|
* @see https://github.com/storm-software/power-plant/blob/main/packages/generators/alloy-js/src/generate.ts
|
|
33
31
|
*
|
|
34
32
|
* @param context - The Powerlines plugin context.
|
|
35
|
-
* @param
|
|
33
|
+
* @param template - The children components to render.
|
|
36
34
|
* @returns A promise that resolves when rendering is complete.
|
|
37
35
|
*/
|
|
38
|
-
async function render(context,
|
|
36
|
+
async function render(context, template) {
|
|
39
37
|
const documents = await (0, _power_plant_alloy_js_generate.generate)((0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_context.PowerlinesContext.Provider, {
|
|
40
38
|
value: context,
|
|
41
|
-
children
|
|
39
|
+
children: template
|
|
42
40
|
}), {}, {
|
|
43
41
|
cwd: context.config.cwd,
|
|
44
42
|
logger: {
|
package/dist/render.d.cts
CHANGED
|
@@ -26,12 +26,10 @@ interface MetaItem extends MetaConfig {
|
|
|
26
26
|
[key: string]: any;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* A function to render
|
|
29
|
+
* A function to render Alloy-js template components within the [Alloy-js](https://alloy-framework.github.io) context, and write any saved content to the file system.
|
|
30
30
|
*
|
|
31
31
|
* @remarks
|
|
32
|
-
* Uses Power Plant's {@link generate | `generate`} entry point to create an
|
|
33
|
-
* execution context and render Alloy-js templates, then emits the resulting
|
|
34
|
-
* documents through the Powerlines plugin context.
|
|
32
|
+
* Uses Power Plant's {@link generate | `generate`} entry point to create an execution context and render Alloy-js templates, then emits the resulting documents through the Powerlines plugin context.
|
|
35
33
|
*
|
|
36
34
|
* @example
|
|
37
35
|
* ```tsx
|
|
@@ -43,10 +41,10 @@ interface MetaItem extends MetaConfig {
|
|
|
43
41
|
* @see https://github.com/storm-software/power-plant/blob/main/packages/generators/alloy-js/src/generate.ts
|
|
44
42
|
*
|
|
45
43
|
* @param context - The Powerlines plugin context.
|
|
46
|
-
* @param
|
|
44
|
+
* @param template - The children components to render.
|
|
47
45
|
* @returns A promise that resolves when rendering is complete.
|
|
48
46
|
*/
|
|
49
|
-
declare function render<TContext extends PluginContext>(context: TContext,
|
|
47
|
+
declare function render<TContext extends PluginContext>(context: TContext, template: Children): Promise<void>;
|
|
50
48
|
/**
|
|
51
49
|
* A function to render children components within the [Alloy](https://alloy-framework.github.io) context and return the rendered output as a string.
|
|
52
50
|
*
|
package/dist/render.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.cts","names":[],"sources":["../src/render.tsx"],"mappings":";;;;UA4BiB,iBAAiB;;;;EAIhC;;;;EAKA;;;;EAKA,UAAU;;;;EAKV;;;;EAKA,iBAAiB;GAEhB
|
|
1
|
+
{"version":3,"file":"render.d.cts","names":[],"sources":["../src/render.tsx"],"mappings":";;;;UA4BiB,iBAAiB;;;;EAIhC;;;;EAKA;;;;EAKA,UAAU;;;;EAKV;;;;EAKA,iBAAiB;GAEhB;;;;;;;;;;;;;;;;;;;;;iBA8BmB,OAAO,iBAAiB,eAC5C,SAAS,UACT,UAAU,WAAQ;;;;;;;;;;;;;;;;iBAqGJ,aAAa,iBAAiB,eAC5C,SAAS,UACT,UAAU,UACV,UAAU"}
|
package/dist/render.d.mts
CHANGED
|
@@ -26,12 +26,10 @@ interface MetaItem extends MetaConfig {
|
|
|
26
26
|
[key: string]: any;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* A function to render
|
|
29
|
+
* A function to render Alloy-js template components within the [Alloy-js](https://alloy-framework.github.io) context, and write any saved content to the file system.
|
|
30
30
|
*
|
|
31
31
|
* @remarks
|
|
32
|
-
* Uses Power Plant's {@link generate | `generate`} entry point to create an
|
|
33
|
-
* execution context and render Alloy-js templates, then emits the resulting
|
|
34
|
-
* documents through the Powerlines plugin context.
|
|
32
|
+
* Uses Power Plant's {@link generate | `generate`} entry point to create an execution context and render Alloy-js templates, then emits the resulting documents through the Powerlines plugin context.
|
|
35
33
|
*
|
|
36
34
|
* @example
|
|
37
35
|
* ```tsx
|
|
@@ -43,10 +41,10 @@ interface MetaItem extends MetaConfig {
|
|
|
43
41
|
* @see https://github.com/storm-software/power-plant/blob/main/packages/generators/alloy-js/src/generate.ts
|
|
44
42
|
*
|
|
45
43
|
* @param context - The Powerlines plugin context.
|
|
46
|
-
* @param
|
|
44
|
+
* @param template - The children components to render.
|
|
47
45
|
* @returns A promise that resolves when rendering is complete.
|
|
48
46
|
*/
|
|
49
|
-
declare function render<TContext extends PluginContext>(context: TContext,
|
|
47
|
+
declare function render<TContext extends PluginContext>(context: TContext, template: Children): Promise<void>;
|
|
50
48
|
/**
|
|
51
49
|
* A function to render children components within the [Alloy](https://alloy-framework.github.io) context and return the rendered output as a string.
|
|
52
50
|
*
|
package/dist/render.mjs
CHANGED
|
@@ -14,12 +14,10 @@ function getDocumentContents(document) {
|
|
|
14
14
|
return (document.chunks ?? []).map((chunk) => chunk.content ?? "").join("");
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* A function to render
|
|
17
|
+
* A function to render Alloy-js template components within the [Alloy-js](https://alloy-framework.github.io) context, and write any saved content to the file system.
|
|
18
18
|
*
|
|
19
19
|
* @remarks
|
|
20
|
-
* Uses Power Plant's {@link generate | `generate`} entry point to create an
|
|
21
|
-
* execution context and render Alloy-js templates, then emits the resulting
|
|
22
|
-
* documents through the Powerlines plugin context.
|
|
20
|
+
* Uses Power Plant's {@link generate | `generate`} entry point to create an execution context and render Alloy-js templates, then emits the resulting documents through the Powerlines plugin context.
|
|
23
21
|
*
|
|
24
22
|
* @example
|
|
25
23
|
* ```tsx
|
|
@@ -31,13 +29,13 @@ function getDocumentContents(document) {
|
|
|
31
29
|
* @see https://github.com/storm-software/power-plant/blob/main/packages/generators/alloy-js/src/generate.ts
|
|
32
30
|
*
|
|
33
31
|
* @param context - The Powerlines plugin context.
|
|
34
|
-
* @param
|
|
32
|
+
* @param template - The children components to render.
|
|
35
33
|
* @returns A promise that resolves when rendering is complete.
|
|
36
34
|
*/
|
|
37
|
-
async function render(context,
|
|
35
|
+
async function render(context, template) {
|
|
38
36
|
const documents = await generate(createComponent(PowerlinesContext.Provider, {
|
|
39
37
|
value: context,
|
|
40
|
-
children
|
|
38
|
+
children: template
|
|
41
39
|
}), {}, {
|
|
42
40
|
cwd: context.config.cwd,
|
|
43
41
|
logger: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-alloy",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.240",
|
|
4
4
|
"description": "A Powerlines plugin to generate project code using Alloy JS via Power Plant.",
|
|
5
5
|
"keywords": ["alloy-js", "powerlines", "powerlines-plugin"],
|
|
6
6
|
"homepage": "https://stormsoftware.com",
|
|
@@ -285,14 +285,14 @@
|
|
|
285
285
|
"typings": "./dist/index.d.mts",
|
|
286
286
|
"files": ["dist"],
|
|
287
287
|
"dependencies": {
|
|
288
|
-
"@alloy-js/core": "^0.
|
|
289
|
-
"@alloy-js/typescript": "^0.
|
|
288
|
+
"@alloy-js/core": "^0.24.1",
|
|
289
|
+
"@alloy-js/typescript": "^0.24.0",
|
|
290
290
|
"@babel/preset-typescript": "^8.0.1",
|
|
291
291
|
"@power-plant/alloy-js": "^0.0.20",
|
|
292
292
|
"@power-plant/core": "^0.0.23",
|
|
293
|
-
"@powerlines/plugin-babel": "^0.13.
|
|
294
|
-
"@powerlines/plugin-power-plant": "^0.1.
|
|
295
|
-
"@
|
|
293
|
+
"@powerlines/plugin-babel": "^0.13.143",
|
|
294
|
+
"@powerlines/plugin-power-plant": "^0.1.3",
|
|
295
|
+
"@power-plant/schema": "^0.0.22",
|
|
296
296
|
"@storm-software/config-tools": "^1.190.109",
|
|
297
297
|
"@stryke/capnp": "^0.12.123",
|
|
298
298
|
"@stryke/convert": "^0.7.27",
|
|
@@ -302,15 +302,15 @@
|
|
|
302
302
|
"@stryke/string-format": "^0.17.38",
|
|
303
303
|
"@stryke/type-checks": "^0.6.29",
|
|
304
304
|
"defu": "^6.1.7",
|
|
305
|
-
"powerlines": "^0.47.
|
|
305
|
+
"powerlines": "^0.47.147"
|
|
306
306
|
},
|
|
307
307
|
"devDependencies": {
|
|
308
308
|
"@alloy-js/babel-preset": "^0.3.0",
|
|
309
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
309
|
+
"@powerlines/plugin-plugin": "^0.12.559",
|
|
310
310
|
"@types/node": "^25.9.5"
|
|
311
311
|
},
|
|
312
312
|
"peerDependencies": { "@alloy-js/babel-preset": ">=0.3.0" },
|
|
313
313
|
"peerDependenciesMeta": { "@alloy-js/babel-preset": { "optional": false } },
|
|
314
314
|
"publishConfig": { "access": "public" },
|
|
315
|
-
"gitHead": "
|
|
315
|
+
"gitHead": "af891c3e728ec71f441887e7f1bb92272c6823fe"
|
|
316
316
|
}
|