@powerlines/plugin-asyncapi 0.1.121 → 0.1.122

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 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
package/dist/index.cjs CHANGED
@@ -1 +1,58 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./powerlines/src/plugin-utils/paths.cjs`);let n=require(`@asyncapi/generator`),r=require(`@asyncapi/parser/esm/document`),i=require(`@stryke/fs/exists`),a=require(`@stryke/fs/package-fns`),o=require(`@stryke/path/join`),s=require(`defu`);s=e.__toESM(s);const c=e=>({name:`asyncapi`,config(){return{asyncapi:(0,s.default)(e,{schema:(0,o.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`schema.yaml`),output:`string`,install:!1,compile:!1,debug:this.config.mode===`development`||this.config.logLevel===`debug`||this.config.logLevel===`trace`,targetDir:(0,o.joinPaths)(this.builtinsPath,`asyncapi`)})}},async configResolved(){if(!this.config.asyncapi.schema)throw Error(`AsyncAPI schema is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.schema".`);if(!this.config.asyncapi.document||!(0,r.isAsyncAPIDocument)(this.config.asyncapi.document))if((0,r.isAsyncAPIDocument)(this.config.asyncapi.schema))this.config.asyncapi.document=this.config.asyncapi.schema;else if((0,i.existsSync)(this.config.asyncapi.schema.toString())){let e=await this.fs.read(this.config.asyncapi.schema.toString());if(!e)throw Error(`Failed to read AsyncAPI schema from file: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=e}else{let e=await this.fetch(this.config.asyncapi.schema.toString());if(!e)throw Error(`Failed to fetch AsyncAPI schema from endpoint: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=await e.text()}if(!this.config.asyncapi.templateName)throw Error(`AsyncAPI template name is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.templateName".`);if(!this.config.asyncapi.outputPath)throw Error(`AsyncAPI output path is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.outputPath".`);!(0,i.existsSync)(this.config.asyncapi.templateName)&&!(0,a.isPackageExists)(this.config.asyncapi.templateName)&&(this.devDependencies[this.config.asyncapi.templateName]=`latest`),this.config.asyncapi.outputPath=t.replacePathTokens(this,this.config.asyncapi.outputPath)},async prepare(){await new n.Generator(this.config.asyncapi.templateName,this.config.asyncapi.outputPath,this.config.asyncapi).generate(this.config.asyncapi.document)}});var l=c;exports.default=l,exports.plugin=c;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_paths = require('./powerlines/src/plugin-utils/paths.cjs');
4
+ let __asyncapi_generator = require("@asyncapi/generator");
5
+ let __asyncapi_parser_esm_document = require("@asyncapi/parser/esm/document");
6
+ let __stryke_fs_exists = require("@stryke/fs/exists");
7
+ let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
8
+ let __stryke_path_join = require("@stryke/path/join");
9
+ let defu = require("defu");
10
+ defu = require_rolldown_runtime.__toESM(defu);
11
+
12
+ //#region src/index.ts
13
+ /**
14
+ * A Powerlines plugin to integrate AsyncAPI for code generation.
15
+ *
16
+ * @param options - The plugin options.
17
+ * @returns A Powerlines plugin instance.
18
+ */
19
+ const plugin = (options) => {
20
+ return {
21
+ name: "asyncapi",
22
+ config() {
23
+ return { asyncapi: (0, defu.default)(options, {
24
+ schema: (0, __stryke_path_join.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "schema.yaml"),
25
+ output: "string",
26
+ install: false,
27
+ compile: false,
28
+ debug: this.config.mode === "development" || this.config.logLevel === "debug" || this.config.logLevel === "trace",
29
+ targetDir: (0, __stryke_path_join.joinPaths)(this.builtinsPath, "asyncapi")
30
+ }) };
31
+ },
32
+ async configResolved() {
33
+ if (!this.config.asyncapi.schema) throw new Error("AsyncAPI schema is required. Please specify it in the plugin options or your Powerlines configuration under \"asyncapi.schema\".");
34
+ if (!this.config.asyncapi.document || !(0, __asyncapi_parser_esm_document.isAsyncAPIDocument)(this.config.asyncapi.document)) if ((0, __asyncapi_parser_esm_document.isAsyncAPIDocument)(this.config.asyncapi.schema)) this.config.asyncapi.document = this.config.asyncapi.schema;
35
+ else if ((0, __stryke_fs_exists.existsSync)(this.config.asyncapi.schema.toString())) {
36
+ const document = await this.fs.read(this.config.asyncapi.schema.toString());
37
+ if (!document) throw new Error(`Failed to read AsyncAPI schema from file: ${this.config.asyncapi.schema.toString()}`);
38
+ this.config.asyncapi.document = document;
39
+ } else {
40
+ const document = await this.fetch(this.config.asyncapi.schema.toString());
41
+ if (!document) throw new Error(`Failed to fetch AsyncAPI schema from endpoint: ${this.config.asyncapi.schema.toString()}`);
42
+ this.config.asyncapi.document = await document.text();
43
+ }
44
+ if (!this.config.asyncapi.templateName) throw new Error("AsyncAPI template name is required. Please specify it in the plugin options or your Powerlines configuration under \"asyncapi.templateName\".");
45
+ if (!this.config.asyncapi.outputPath) throw new Error("AsyncAPI output path is required. Please specify it in the plugin options or your Powerlines configuration under \"asyncapi.outputPath\".");
46
+ if (!(0, __stryke_fs_exists.existsSync)(this.config.asyncapi.templateName) && !(0, __stryke_fs_package_fns.isPackageExists)(this.config.asyncapi.templateName)) this.devDependencies[this.config.asyncapi.templateName] = "latest";
47
+ this.config.asyncapi.outputPath = require_paths.replacePathTokens(this, this.config.asyncapi.outputPath);
48
+ },
49
+ async prepare() {
50
+ await new __asyncapi_generator.Generator(this.config.asyncapi.templateName, this.config.asyncapi.outputPath, this.config.asyncapi).generate(this.config.asyncapi.document);
51
+ }
52
+ };
53
+ };
54
+ var src_default = plugin;
55
+
56
+ //#endregion
57
+ exports.default = src_default;
58
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1 +1,54 @@
1
- import{replacePathTokens as e}from"./powerlines/src/plugin-utils/paths.mjs";import{Generator as t}from"@asyncapi/generator";import{isAsyncAPIDocument as n}from"@asyncapi/parser/esm/document";import{existsSync as r}from"@stryke/fs/exists";import{isPackageExists as i}from"@stryke/fs/package-fns";import{joinPaths as a}from"@stryke/path/join";import o from"defu";const s=s=>({name:`asyncapi`,config(){return{asyncapi:o(s,{schema:a(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`schema.yaml`),output:`string`,install:!1,compile:!1,debug:this.config.mode===`development`||this.config.logLevel===`debug`||this.config.logLevel===`trace`,targetDir:a(this.builtinsPath,`asyncapi`)})}},async configResolved(){if(!this.config.asyncapi.schema)throw Error(`AsyncAPI schema is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.schema".`);if(!this.config.asyncapi.document||!n(this.config.asyncapi.document))if(n(this.config.asyncapi.schema))this.config.asyncapi.document=this.config.asyncapi.schema;else if(r(this.config.asyncapi.schema.toString())){let e=await this.fs.read(this.config.asyncapi.schema.toString());if(!e)throw Error(`Failed to read AsyncAPI schema from file: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=e}else{let e=await this.fetch(this.config.asyncapi.schema.toString());if(!e)throw Error(`Failed to fetch AsyncAPI schema from endpoint: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=await e.text()}if(!this.config.asyncapi.templateName)throw Error(`AsyncAPI template name is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.templateName".`);if(!this.config.asyncapi.outputPath)throw Error(`AsyncAPI output path is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.outputPath".`);!r(this.config.asyncapi.templateName)&&!i(this.config.asyncapi.templateName)&&(this.devDependencies[this.config.asyncapi.templateName]=`latest`),this.config.asyncapi.outputPath=e(this,this.config.asyncapi.outputPath)},async prepare(){await new t(this.config.asyncapi.templateName,this.config.asyncapi.outputPath,this.config.asyncapi).generate(this.config.asyncapi.document)}});var c=s;export{c as default,s as plugin};
1
+ import { replacePathTokens } from "./powerlines/src/plugin-utils/paths.mjs";
2
+ import { Generator } from "@asyncapi/generator";
3
+ import { isAsyncAPIDocument } from "@asyncapi/parser/esm/document";
4
+ import { existsSync } from "@stryke/fs/exists";
5
+ import { isPackageExists } from "@stryke/fs/package-fns";
6
+ import { joinPaths } from "@stryke/path/join";
7
+ import defu from "defu";
8
+
9
+ //#region src/index.ts
10
+ /**
11
+ * A Powerlines plugin to integrate AsyncAPI for code generation.
12
+ *
13
+ * @param options - The plugin options.
14
+ * @returns A Powerlines plugin instance.
15
+ */
16
+ const plugin = (options) => {
17
+ return {
18
+ name: "asyncapi",
19
+ config() {
20
+ return { asyncapi: defu(options, {
21
+ schema: joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "schema.yaml"),
22
+ output: "string",
23
+ install: false,
24
+ compile: false,
25
+ debug: this.config.mode === "development" || this.config.logLevel === "debug" || this.config.logLevel === "trace",
26
+ targetDir: joinPaths(this.builtinsPath, "asyncapi")
27
+ }) };
28
+ },
29
+ async configResolved() {
30
+ if (!this.config.asyncapi.schema) throw new Error("AsyncAPI schema is required. Please specify it in the plugin options or your Powerlines configuration under \"asyncapi.schema\".");
31
+ if (!this.config.asyncapi.document || !isAsyncAPIDocument(this.config.asyncapi.document)) if (isAsyncAPIDocument(this.config.asyncapi.schema)) this.config.asyncapi.document = this.config.asyncapi.schema;
32
+ else if (existsSync(this.config.asyncapi.schema.toString())) {
33
+ const document = await this.fs.read(this.config.asyncapi.schema.toString());
34
+ if (!document) throw new Error(`Failed to read AsyncAPI schema from file: ${this.config.asyncapi.schema.toString()}`);
35
+ this.config.asyncapi.document = document;
36
+ } else {
37
+ const document = await this.fetch(this.config.asyncapi.schema.toString());
38
+ if (!document) throw new Error(`Failed to fetch AsyncAPI schema from endpoint: ${this.config.asyncapi.schema.toString()}`);
39
+ this.config.asyncapi.document = await document.text();
40
+ }
41
+ if (!this.config.asyncapi.templateName) throw new Error("AsyncAPI template name is required. Please specify it in the plugin options or your Powerlines configuration under \"asyncapi.templateName\".");
42
+ if (!this.config.asyncapi.outputPath) throw new Error("AsyncAPI output path is required. Please specify it in the plugin options or your Powerlines configuration under \"asyncapi.outputPath\".");
43
+ if (!existsSync(this.config.asyncapi.templateName) && !isPackageExists(this.config.asyncapi.templateName)) this.devDependencies[this.config.asyncapi.templateName] = "latest";
44
+ this.config.asyncapi.outputPath = replacePathTokens(this, this.config.asyncapi.outputPath);
45
+ },
46
+ async prepare() {
47
+ await new Generator(this.config.asyncapi.templateName, this.config.asyncapi.outputPath, this.config.asyncapi).generate(this.config.asyncapi.document);
48
+ }
49
+ };
50
+ };
51
+ var src_default = plugin;
52
+
53
+ //#endregion
54
+ export { src_default as default, plugin };
@@ -1 +1,36 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/replace`);function n(e,n){return n&&n.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,(0,t.replacePath)(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,(0,t.replacePath)(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,(0,t.replacePath)(e.entryPath,e.workspaceConfig.workspaceRoot))}exports.replacePathTokens=n;
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_path_replace = require("@stryke/path/replace");
3
+
4
+ //#region ../powerlines/src/plugin-utils/paths.ts
5
+ /**
6
+ * Replaces tokens in the given path string with their corresponding values from the context.
7
+ *
8
+ * @remarks
9
+ * The following tokens are supported:
10
+ * - `{workspaceRoot}` - The root directory of the workspace.
11
+ * - `{root}` - The root directory of the project (same as `{projectRoot}`).
12
+ * - `{projectRoot}` - The root directory of the project (same as `{root}`).
13
+ * - `{sourceRoot}` - The source root directory of the project (usually `./src`).
14
+ * - `{powerlinesPath}` - The directory where Powerlines is installed.
15
+ * - `{cachePath}` - The environment's directory for cached files.
16
+ * - `{dataPath}` - The environment's directory for data files.
17
+ * - `{logPath}` - The environment's directory for log files.
18
+ * - `{tempPath}` - The environment's directory for temporary files.
19
+ * - `{configPath}` - The environment's directory for configuration files.
20
+ * - `{outputPath}` - The configured output directory for the project.
21
+ * - `{buildPath}` - The configured distribution directory for the project.
22
+ * - `{artifactsPath}` - The configured directory for build artifacts.
23
+ * - `{builtinPath}` - The configured directory for generated built-in plugins.
24
+ * - `{entryPath}` - The configured directory for generated entry files.
25
+ *
26
+ * @param context - The context containing the values for the path tokens.
27
+ * @param path - The path string with tokens to replace.
28
+ * @returns The path string with tokens replaced by their corresponding values from the context.
29
+ */
30
+ function replacePathTokens(context, path) {
31
+ if (!path) return path;
32
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", (0, __stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, __stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
33
+ }
34
+
35
+ //#endregion
36
+ exports.replacePathTokens = replacePathTokens;
@@ -1 +1,35 @@
1
- import{replacePath as e}from"@stryke/path/replace";function t(t,n){return n&&n.replaceAll(`{workspaceRoot}`,t.workspaceConfig.workspaceRoot).replaceAll(`{root}`,t.config.projectRoot).replaceAll(`{projectRoot}`,t.config.projectRoot).replaceAll(`{sourceRoot}`,t.config.sourceRoot).replaceAll(`{powerlinesPath}`,t.powerlinesPath).replaceAll(`{cachePath}`,t.cachePath).replaceAll(`{dataPath}`,t.dataPath).replaceAll(`{logPath}`,t.envPaths.log).replaceAll(`{tempPath}`,t.envPaths.temp).replaceAll(`{configPath}`,t.envPaths.config).replaceAll(`{outputPath}`,t.config.output.outputPath).replaceAll(`{buildPath}`,t.config.output.buildPath).replaceAll(`{artifactsPath}`,e(t.artifactsPath,t.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,e(t.builtinsPath,t.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,e(t.entryPath,t.workspaceConfig.workspaceRoot))}export{t as replacePathTokens};
1
+ import { replacePath } from "@stryke/path/replace";
2
+
3
+ //#region ../powerlines/src/plugin-utils/paths.ts
4
+ /**
5
+ * Replaces tokens in the given path string with their corresponding values from the context.
6
+ *
7
+ * @remarks
8
+ * The following tokens are supported:
9
+ * - `{workspaceRoot}` - The root directory of the workspace.
10
+ * - `{root}` - The root directory of the project (same as `{projectRoot}`).
11
+ * - `{projectRoot}` - The root directory of the project (same as `{root}`).
12
+ * - `{sourceRoot}` - The source root directory of the project (usually `./src`).
13
+ * - `{powerlinesPath}` - The directory where Powerlines is installed.
14
+ * - `{cachePath}` - The environment's directory for cached files.
15
+ * - `{dataPath}` - The environment's directory for data files.
16
+ * - `{logPath}` - The environment's directory for log files.
17
+ * - `{tempPath}` - The environment's directory for temporary files.
18
+ * - `{configPath}` - The environment's directory for configuration files.
19
+ * - `{outputPath}` - The configured output directory for the project.
20
+ * - `{buildPath}` - The configured distribution directory for the project.
21
+ * - `{artifactsPath}` - The configured directory for build artifacts.
22
+ * - `{builtinPath}` - The configured directory for generated built-in plugins.
23
+ * - `{entryPath}` - The configured directory for generated entry files.
24
+ *
25
+ * @param context - The context containing the values for the path tokens.
26
+ * @param path - The path string with tokens to replace.
27
+ * @returns The path string with tokens replaced by their corresponding values from the context.
28
+ */
29
+ function replacePathTokens(context, path) {
30
+ if (!path) return path;
31
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
32
+ }
33
+
34
+ //#endregion
35
+ export { replacePathTokens };
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
78
78
  */
79
79
  allowReturnOutsideFunction?: boolean;
80
80
  }
81
+ interface EmitOptions extends WriteOptions {
82
+ /**
83
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
84
+ */
85
+ emitWithBundler?: boolean;
86
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
87
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
88
+ }
81
89
  /**
82
90
  * Options for emitting entry virtual files
83
91
  */
84
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
92
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
85
93
  /**
86
94
  * The unresolved Powerlines context.
87
95
  *
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
292
300
  * The Powerlines builtin virtual files
293
301
  */
294
302
  getBuiltins: () => Promise<VirtualFile[]>;
303
+ /**
304
+ * Resolves a file and writes it to the VFS if it does not already exist
305
+ *
306
+ * @param code - The source code of the file
307
+ * @param path - The path to write the file to
308
+ * @param options - Additional options for writing the file
309
+ */
310
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
311
+ /**
312
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
313
+ *
314
+ * @param code - The source code of the file
315
+ * @param path - The path to write the file to
316
+ * @param options - Additional options for writing the file
317
+ */
318
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
295
319
  /**
296
320
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
297
321
  *
@@ -300,7 +324,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
300
324
  * @param path - An optional path to write the builtin file to
301
325
  * @param options - Additional options for writing the builtin file
302
326
  */
303
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
327
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
304
328
  /**
305
329
  * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
306
330
  *
@@ -309,7 +333,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
333
  * @param path - An optional path to write the builtin file to
310
334
  * @param options - Additional options for writing the builtin file
311
335
  */
312
- emitBuiltinSync: (code: string, id: string, path?: string, options?: WriteOptions) => void;
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
313
337
  /**
314
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
315
339
  *
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
78
78
  */
79
79
  allowReturnOutsideFunction?: boolean;
80
80
  }
81
+ interface EmitOptions extends WriteOptions {
82
+ /**
83
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
84
+ */
85
+ emitWithBundler?: boolean;
86
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
87
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
88
+ }
81
89
  /**
82
90
  * Options for emitting entry virtual files
83
91
  */
84
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
92
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
85
93
  /**
86
94
  * The unresolved Powerlines context.
87
95
  *
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
292
300
  * The Powerlines builtin virtual files
293
301
  */
294
302
  getBuiltins: () => Promise<VirtualFile[]>;
303
+ /**
304
+ * Resolves a file and writes it to the VFS if it does not already exist
305
+ *
306
+ * @param code - The source code of the file
307
+ * @param path - The path to write the file to
308
+ * @param options - Additional options for writing the file
309
+ */
310
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
311
+ /**
312
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
313
+ *
314
+ * @param code - The source code of the file
315
+ * @param path - The path to write the file to
316
+ * @param options - Additional options for writing the file
317
+ */
318
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
295
319
  /**
296
320
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
297
321
  *
@@ -300,7 +324,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
300
324
  * @param path - An optional path to write the builtin file to
301
325
  * @param options - Additional options for writing the builtin file
302
326
  */
303
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
327
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
304
328
  /**
305
329
  * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
306
330
  *
@@ -309,7 +333,7 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
333
  * @param path - An optional path to write the builtin file to
310
334
  * @param options - Additional options for writing the builtin file
311
335
  */
312
- emitBuiltinSync: (code: string, id: string, path?: string, options?: WriteOptions) => void;
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
313
337
  /**
314
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
315
339
  *
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1 @@
1
- export{};
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-asyncapi",
3
- "version": "0.1.121",
3
+ "version": "0.1.122",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to generate project code from AsyncAPI specifications.",
6
6
  "repository": {
@@ -119,18 +119,18 @@
119
119
  "dependencies": {
120
120
  "@asyncapi/generator": "^2.11.0",
121
121
  "@asyncapi/parser": "^3.4.0",
122
- "@stryke/convert": "^0.6.29",
123
- "@stryke/fs": "^0.33.26",
124
- "@stryke/http": "^0.12.20",
125
- "@stryke/path": "^0.24.0",
122
+ "@stryke/convert": "^0.6.30",
123
+ "@stryke/fs": "^0.33.27",
124
+ "@stryke/http": "^0.12.21",
125
+ "@stryke/path": "^0.24.1",
126
126
  "defu": "^6.1.4",
127
- "powerlines": "^0.36.22"
127
+ "powerlines": "^0.36.23"
128
128
  },
129
129
  "devDependencies": {
130
- "@powerlines/nx": "^0.11.48",
131
- "@powerlines/plugin-plugin": "^0.12.69",
130
+ "@powerlines/nx": "^0.11.49",
131
+ "@powerlines/plugin-plugin": "^0.12.70",
132
132
  "@types/node": "^24.10.4"
133
133
  },
134
134
  "publishConfig": { "access": "public" },
135
- "gitHead": "f88fe8eb30f96536b83fc9af884972d48e31e63a"
135
+ "gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
136
136
  }