@power-plant/alloy-js 0.0.17 → 0.0.19

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.
@@ -1,2 +1,2 @@
1
- import { n as useExecution, r as useExecutionSafe, t as ExecutionContext } from "../../execution-BGY24cO8.mjs";
1
+ import { n as useExecution, r as useExecutionSafe, t as ExecutionContext } from "../../execution-zVRllrpa.mjs";
2
2
  export { ExecutionContext, useExecution, useExecutionSafe };
@@ -1,4 +1,4 @@
1
- import { n as useExecution, r as useExecutionSafe, t as ExecutionContext } from "../../execution-BGY24cO8.mjs";
1
+ import { n as useExecution, r as useExecutionSafe, t as ExecutionContext } from "../../execution-zVRllrpa.mjs";
2
2
  import { n as useMeta, r as useMetaSafe, t as MetaContext } from "../../meta-DtIlHZG5.mjs";
3
3
  import { a as useSchemaPropertySafe, i as useSchemaProperty, n as SchemaPropertyContext, o as useSchemaSafe, r as useSchema, t as SchemaContext } from "../../schema-CkCXkDzU.mjs";
4
4
  import { n as useSession, r as useSessionSafe, t as SessionContext } from "../../session-C2p15ap9.mjs";
@@ -3,7 +3,7 @@ import { n as SingleLineCommentProps, r as SingleLineCommentVariant, t as Single
3
3
  import { n as SourceFileProps, t as SourceFile } from "../source-file-DEGtBMgH.mjs";
4
4
  import { n as SpacingProps, t as Spacing } from "../spacing-HIHoQdxS.mjs";
5
5
  import "./components/index.mjs";
6
- import { n as useExecution, r as useExecutionSafe, t as ExecutionContext } from "../execution-BGY24cO8.mjs";
6
+ import { n as useExecution, r as useExecutionSafe, t as ExecutionContext } from "../execution-zVRllrpa.mjs";
7
7
  import { n as useMeta, r as useMetaSafe, t as MetaContext } from "../meta-DtIlHZG5.mjs";
8
8
  import { a as useSchemaPropertySafe, i as useSchemaProperty, n as SchemaPropertyContext, o as useSchemaSafe, r as useSchema, t as SchemaContext } from "../schema-CkCXkDzU.mjs";
9
9
  import { n as useSession, r as useSessionSafe, t as SessionContext } from "../session-C2p15ap9.mjs";
@@ -11,7 +11,7 @@ declare const ExecutionContext$1: ComponentContext<ExecutionContext<any, any, an
11
11
  * @returns The Execution context.
12
12
  * @throws An error if the execution context is not set.
13
13
  */
14
- declare function useExecution(): ExecutionContext<any, any, any>;
14
+ declare function useExecution$1(): ExecutionContext<any, any, any>;
15
15
  /**
16
16
  * Hook to safely access the {@link ExecutionContext | Execution context}.
17
17
  *
@@ -19,5 +19,5 @@ declare function useExecution(): ExecutionContext<any, any, any>;
19
19
  */
20
20
  declare function useExecutionSafe(): ExecutionContext<any, any, any> | undefined;
21
21
  //#endregion
22
- export { useExecution as n, useExecutionSafe as r, ExecutionContext$1 as t };
23
- //# sourceMappingURL=execution-BGY24cO8.d.mts.map
22
+ export { useExecution$1 as n, useExecutionSafe as r, ExecutionContext$1 as t };
23
+ //# sourceMappingURL=execution-zVRllrpa.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-zVRllrpa.d.mts","names":[],"sources":["../src/core/contexts/execution.ts"],"mappings":""}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- const e=require("./render.cjs");let t=require("@power-plant/core");var n=(0,t.defineGenerator)({meta:{name:`alloy-js`,description:`A generator that uses Alloy-js to generate source code from a specification.`,version:`1.0`,tags:[`alloy-js`],links:[{description:`Alloy-js Repository`,href:`https://github.com/alloy-framework/alloy`},{description:`Alloy-js Documentation`,href:`https://alloy-framework.github.io/alloy/guides/getting-started/`}]},generator:async(n,r)=>e.render((0,t.useExecutionContext)(),n,r.template)});module.exports=n;
1
+ const e=require("./render.cjs");var t=(0,require("@power-plant/core").defineGenerator)({meta:{name:`alloy-js`,description:`A generator that uses Alloy-js to generate source code from a specification.`,version:`1.0`,tags:[`alloy-js`],links:[{description:`Alloy-js Repository`,href:`https://github.com/alloy-framework/alloy`},{description:`Alloy-js Documentation`,href:`https://alloy-framework.github.io/alloy/guides/getting-started/`}]},generator:async(t,n)=>e.render(n.template)});module.exports=t;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{render as e}from"./render.mjs";import{defineGenerator as t,useExecutionContext as n}from"@power-plant/core";var r=t({meta:{name:`alloy-js`,description:`A generator that uses Alloy-js to generate source code from a specification.`,version:`1.0`,tags:[`alloy-js`],links:[{description:`Alloy-js Repository`,href:`https://github.com/alloy-framework/alloy`},{description:`Alloy-js Documentation`,href:`https://alloy-framework.github.io/alloy/guides/getting-started/`}]},generator:async(t,r)=>e(n(),t,r.template)});export{r as default};
1
+ import{render as e}from"./render.mjs";import{defineGenerator as t}from"@power-plant/core";var n=t({meta:{name:`alloy-js`,description:`A generator that uses Alloy-js to generate source code from a specification.`,version:`1.0`,tags:[`alloy-js`],links:[{description:`Alloy-js Repository`,href:`https://github.com/alloy-framework/alloy`},{description:`Alloy-js Documentation`,href:`https://alloy-framework.github.io/alloy/guides/getting-started/`}]},generator:async(t,n)=>e(n.template)});export{n as default};
2
2
  //# sourceMappingURL=index.mjs.map
package/dist/render.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-CMqjfN_6.cjs"),t=require("./core/components/output.cjs");require("./core/index.cjs");let n=require("@alloy-js/core/jsx-runtime"),r=require("@alloy-js/core"),i=require("@stryke/helpers/noop"),a=require("@stryke/path/replace"),o=require("@stryke/string-format/list"),s=require("defu");s=e.t(s,1);async function c(e,c,l){let u={},{cwd:d,logger:f}=e,p=await(0,r.renderAsync)((0,n.createComponent)(t.Output,{context:e,spec:c,meta:u,children:l})),m=[];if(await(0,r.traverseOutput)(p,{visitDirectory:i.noop,visitFile:e=>m.push(e)}),!m.length)return f.debug(`No output files were rendered by the Alloy-js components.`),{};f.debug(`Rendering ${m.length} output files from Alloy-js components: ${(0,o.list)(m.map(e=>(0,a.replacePath)(e.path,d)))}.`);let h={},g={};await(0,r.traverseOutput)(p,{visitDirectory:i.noop,visitFile:e=>{if(`contents`in e){let t=u[e.path]??{};h[e.path]={path:e.path,chunks:[{content:e.contents,meta:t}]}}else e.sourcePath&&(g[e.sourcePath]=e.path)}});for(let[e,t]of Object.entries(g))if(h[e])h[t]={...h[e],path:t,chunks:h[e].chunks?.map(e=>(0,s.default)(e,{meta:u[t]??{}}))};else throw Error(`Source path ${e} not found in documents.`);return h}exports.render=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-CMqjfN_6.cjs"),t=require("./core/components/output.cjs");require("./core/index.cjs");let n=require("@alloy-js/core/jsx-runtime"),r=require("@alloy-js/core"),i=require("@power-plant/core"),a=require("@stryke/helpers/noop"),o=require("@stryke/path/replace"),s=require("@stryke/string-format/list"),c=require("defu");c=e.t(c,1);async function l(e,i){let l={},{cwd:u,logger:d}=e,f=await(0,r.renderAsync)((0,n.createComponent)(t.Output,{context:e,meta:l,children:i})),p=[];if(await(0,r.traverseOutput)(f,{visitDirectory:a.noop,visitFile:e=>p.push(e)}),!p.length)return d.debug(`No output files were rendered by the Alloy-js components.`),{};d.debug(`Rendering ${p.length} output files from Alloy-js components: ${(0,s.list)(p.map(e=>(0,o.replacePath)(e.path,u)))}.`);let m={},h={};await(0,r.traverseOutput)(f,{visitDirectory:a.noop,visitFile:e=>{if(`contents`in e){let t=l[e.path]??{};m[e.path]={path:e.path,chunks:[{content:e.contents,meta:t}]}}else e.sourcePath&&(h[e.sourcePath]=e.path)}});for(let[e,t]of Object.entries(h))if(m[e])m[t]={...m[e],path:t,chunks:m[e].chunks?.map(e=>(0,c.default)(e,{meta:l[t]??{}}))};else throw Error(`Source path ${e} not found in documents.`);return m}async function u(e){return l((0,i.useExecution)(),e)}exports.render=u,exports.renderBase=l;
package/dist/render.d.cts CHANGED
@@ -8,14 +8,28 @@ import { ExecutionContext, GeneratorFunctionResult } from "@power-plant/core";
8
8
  * ```tsx
9
9
  * import { render } from "@power-plant/alloy-js/render";
10
10
  *
11
- * await render(context, spec, <> ... </>);
11
+ * await renderBase(context, <> ... </>);
12
12
  * ```
13
13
  *
14
14
  * @param context - The Power Plant execution context.
15
15
  * @param children - The children components to render.
16
16
  * @returns A promise that resolves when rendering is complete.
17
17
  */
18
- declare function render<TSpec, TOptions extends object, TReturns = void>(context: ExecutionContext<TSpec, TOptions, TReturns>, spec: TSpec, children: Children): Promise<GeneratorFunctionResult<TSpec, TOptions>>;
18
+ declare function renderBase<TSpec, TOptions extends object, TReturns = void>(context: ExecutionContext<TSpec, TOptions, TReturns>, children: Children): Promise<GeneratorFunctionResult<TSpec, TOptions>>;
19
+ /**
20
+ * A function to render children components within the [Alloy](https://alloy-framework.github.io) context, and register any generated documents on the execution context.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * import { render } from "@power-plant/alloy-js/render";
25
+ *
26
+ * await render(<> ... </>);
27
+ * ```
28
+ *
29
+ * @param children - The children components to render.
30
+ * @returns A promise that resolves when rendering is complete.
31
+ */
32
+ declare function render<TSpec, TOptions extends object, TReturns = void>(children: Children): Promise<GeneratorFunctionResult<TSpec, TOptions>>;
19
33
  //#endregion
20
- export { render };
34
+ export { render, renderBase };
21
35
  //# sourceMappingURL=render.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.cts","names":[],"sources":["../src/render.tsx"],"mappings":";;;;;;;;;;;;;;;;;iBA6CsB,OAAO,OAAO,yBAAyB,iBAC3D,SAAS,iBAAiB,OAAO,UAAU,WAC3C,MAAM,OACN,UAAU,WACT,QAAQ,wBAAwB,OAAO"}
1
+ {"version":3,"file":"render.d.cts","names":[],"sources":["../src/render.tsx"],"mappings":";;;;;;;;;;;;;;;;;iBA8CsB,WACpB,OACA,yBACA,iBAEA,SAAS,iBAAiB,OAAO,UAAU,WAC3C,UAAU,WACT,QAAQ,wBAAwB,OAAO;;;;;;;;;;;;;;iBAkFpB,OAAO,OAAO,yBAAyB,iBAC3D,UAAU,WACT,QAAQ,wBAAwB,OAAO"}
package/dist/render.d.mts CHANGED
@@ -8,14 +8,28 @@ import { ExecutionContext, GeneratorFunctionResult } from "@power-plant/core";
8
8
  * ```tsx
9
9
  * import { render } from "@power-plant/alloy-js/render";
10
10
  *
11
- * await render(context, spec, <> ... </>);
11
+ * await renderBase(context, <> ... </>);
12
12
  * ```
13
13
  *
14
14
  * @param context - The Power Plant execution context.
15
15
  * @param children - The children components to render.
16
16
  * @returns A promise that resolves when rendering is complete.
17
17
  */
18
- declare function render<TSpec, TOptions extends object, TReturns = void>(context: ExecutionContext<TSpec, TOptions, TReturns>, spec: TSpec, children: Children): Promise<GeneratorFunctionResult<TSpec, TOptions>>;
18
+ declare function renderBase<TSpec, TOptions extends object, TReturns = void>(context: ExecutionContext<TSpec, TOptions, TReturns>, children: Children): Promise<GeneratorFunctionResult<TSpec, TOptions>>;
19
+ /**
20
+ * A function to render children components within the [Alloy](https://alloy-framework.github.io) context, and register any generated documents on the execution context.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * import { render } from "@power-plant/alloy-js/render";
25
+ *
26
+ * await render(<> ... </>);
27
+ * ```
28
+ *
29
+ * @param children - The children components to render.
30
+ * @returns A promise that resolves when rendering is complete.
31
+ */
32
+ declare function render<TSpec, TOptions extends object, TReturns = void>(children: Children): Promise<GeneratorFunctionResult<TSpec, TOptions>>;
19
33
  //#endregion
20
- export { render };
34
+ export { render, renderBase };
21
35
  //# sourceMappingURL=render.d.mts.map
package/dist/render.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{Output as e}from"./core/components/output.mjs";import"./core/index.mjs";import{createComponent as t}from"@alloy-js/core/jsx-runtime";import{renderAsync as n,traverseOutput as r}from"@alloy-js/core";import{noop as i}from"@stryke/helpers/noop";import{replacePath as a}from"@stryke/path/replace";import{list as o}from"@stryke/string-format/list";import s from"defu";async function c(c,l,u){let d={},{cwd:f,logger:p}=c,m=await n(t(e,{context:c,spec:l,meta:d,children:u})),h=[];if(await r(m,{visitDirectory:i,visitFile:e=>h.push(e)}),!h.length)return p.debug(`No output files were rendered by the Alloy-js components.`),{};p.debug(`Rendering ${h.length} output files from Alloy-js components: ${o(h.map(e=>a(e.path,f)))}.`);let g={},_={};await r(m,{visitDirectory:i,visitFile:e=>{if(`contents`in e){let t=d[e.path]??{};g[e.path]={path:e.path,chunks:[{content:e.contents,meta:t}]}}else e.sourcePath&&(_[e.sourcePath]=e.path)}});for(let[e,t]of Object.entries(_))if(g[e])g[t]={...g[e],path:t,chunks:g[e].chunks?.map(e=>s(e,{meta:d[t]??{}}))};else throw Error(`Source path ${e} not found in documents.`);return g}export{c as render};
1
+ import{Output as e}from"./core/components/output.mjs";import"./core/index.mjs";import{createComponent as t}from"@alloy-js/core/jsx-runtime";import{renderAsync as n,traverseOutput as r}from"@alloy-js/core";import{useExecution as i}from"@power-plant/core";import{noop as a}from"@stryke/helpers/noop";import{replacePath as o}from"@stryke/path/replace";import{list as s}from"@stryke/string-format/list";import c from"defu";async function l(i,l){let u={},{cwd:d,logger:f}=i,p=await n(t(e,{context:i,meta:u,children:l})),m=[];if(await r(p,{visitDirectory:a,visitFile:e=>m.push(e)}),!m.length)return f.debug(`No output files were rendered by the Alloy-js components.`),{};f.debug(`Rendering ${m.length} output files from Alloy-js components: ${s(m.map(e=>o(e.path,d)))}.`);let h={},g={};await r(p,{visitDirectory:a,visitFile:e=>{if(`contents`in e){let t=u[e.path]??{};h[e.path]={path:e.path,chunks:[{content:e.contents,meta:t}]}}else e.sourcePath&&(g[e.sourcePath]=e.path)}});for(let[e,t]of Object.entries(g))if(h[e])h[t]={...h[e],path:t,chunks:h[e].chunks?.map(e=>c(e,{meta:u[t]??{}}))};else throw Error(`Source path ${e} not found in documents.`);return h}async function u(e){return l(i(),e)}export{u as render,l as renderBase};
2
2
  //# sourceMappingURL=render.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@power-plant/alloy-js",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "private": false,
5
5
  "description": "A Power Plant generator for using Alloy JS to generate source code.",
6
6
  "keywords": [
@@ -869,8 +869,8 @@
869
869
  "@alloy-js/json": "^0.24.0",
870
870
  "@alloy-js/markdown": "^0.24.0",
871
871
  "@alloy-js/typescript": "^0.24.0",
872
- "@power-plant/core": "^0.0.21",
873
- "@power-plant/schema": "^0.0.20",
872
+ "@power-plant/core": "^0.0.22",
873
+ "@power-plant/schema": "^0.0.21",
874
874
  "@stryke/convert": "^0.7.27",
875
875
  "@stryke/helpers": "^0.10.36",
876
876
  "@stryke/path": "^0.29.23",
@@ -892,5 +892,5 @@
892
892
  "peerDependencies": { "@alloy-js/babel-preset": ">=0.3.0" },
893
893
  "peerDependenciesMeta": { "@alloy-js/babel-preset": { "optional": false } },
894
894
  "publishConfig": { "access": "public" },
895
- "gitHead": "463bd5515bf8deb2aca08f5222add9cf58bd4149"
895
+ "gitHead": "79c19a661afc8b7f551988af50af27b372996e28"
896
896
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"execution-BGY24cO8.d.mts","names":[],"sources":["../src/core/contexts/execution.ts"],"mappings":""}