@powerlines/plugin-unenv 0.1.105 → 0.1.107

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/index.cjs CHANGED
@@ -1 +1,49 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});let e=require(`unenv`);const t=(t={})=>({name:`unenv`,async config(){return{unenv:t}},configResolved(){this.unenv=(0,e.defineEnv)(this.config.unenv||{}),this.config.build.alias??={},Array.isArray(this.config.build.alias)?this.config.build.alias=Object.entries(this.unenv.env.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),this.config.build.alias):this.config.build.alias={...this.unenv.env.alias,...this.config.build.alias},this.config.build.external??=[],this.config.build.external.push(...this.unenv.env.external),this.config.build.inject??={},this.config.build.inject={...this.unenv.env.inject,...this.config.build.inject},this.config.build.polyfill??=[],this.config.build.polyfill.push(...this.unenv.env.polyfill)}});var n=t;exports.default=n,exports.plugin=t;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ let unenv = require("unenv");
3
+
4
+ //#region src/index.ts
5
+ /**
6
+ * The unenv plugin for Powerlines.
7
+ *
8
+ * @see https://unjs.dev/packages/unenv
9
+ *
10
+ * @param options - The unenv plugin user configuration options.
11
+ * @returns A Powerlines plugin to transform source code to be platform agnostic using unenv.
12
+ */
13
+ const plugin = (options = {}) => {
14
+ return {
15
+ name: "unenv",
16
+ async config() {
17
+ return { unenv: options };
18
+ },
19
+ configResolved() {
20
+ this.unenv = (0, unenv.defineEnv)(this.config.unenv || {});
21
+ this.config.build.alias ??= {};
22
+ if (Array.isArray(this.config.build.alias)) this.config.build.alias = Object.entries(this.unenv.env.alias).reduce((aliases, [key, value]) => {
23
+ if (!aliases.find((alias) => alias.find === key)) aliases.push({
24
+ find: key,
25
+ replacement: value
26
+ });
27
+ return aliases;
28
+ }, this.config.build.alias);
29
+ else this.config.build.alias = {
30
+ ...this.unenv.env.alias,
31
+ ...this.config.build.alias
32
+ };
33
+ this.config.build.external ??= [];
34
+ this.config.build.external.push(...this.unenv.env.external);
35
+ this.config.build.inject ??= {};
36
+ this.config.build.inject = {
37
+ ...this.unenv.env.inject,
38
+ ...this.config.build.inject
39
+ };
40
+ this.config.build.polyfill ??= [];
41
+ this.config.build.polyfill.push(...this.unenv.env.polyfill);
42
+ }
43
+ };
44
+ };
45
+ var src_default = plugin;
46
+
47
+ //#endregion
48
+ exports.default = src_default;
49
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1 +1,47 @@
1
- import{defineEnv as e}from"unenv";const t=(t={})=>({name:`unenv`,async config(){return{unenv:t}},configResolved(){this.unenv=e(this.config.unenv||{}),this.config.build.alias??={},Array.isArray(this.config.build.alias)?this.config.build.alias=Object.entries(this.unenv.env.alias).reduce((e,[t,n])=>(e.find(e=>e.find===t)||e.push({find:t,replacement:n}),e),this.config.build.alias):this.config.build.alias={...this.unenv.env.alias,...this.config.build.alias},this.config.build.external??=[],this.config.build.external.push(...this.unenv.env.external),this.config.build.inject??={},this.config.build.inject={...this.unenv.env.inject,...this.config.build.inject},this.config.build.polyfill??=[],this.config.build.polyfill.push(...this.unenv.env.polyfill)}});var n=t;export{n as default,t as plugin};
1
+ import { defineEnv } from "unenv";
2
+
3
+ //#region src/index.ts
4
+ /**
5
+ * The unenv plugin for Powerlines.
6
+ *
7
+ * @see https://unjs.dev/packages/unenv
8
+ *
9
+ * @param options - The unenv plugin user configuration options.
10
+ * @returns A Powerlines plugin to transform source code to be platform agnostic using unenv.
11
+ */
12
+ const plugin = (options = {}) => {
13
+ return {
14
+ name: "unenv",
15
+ async config() {
16
+ return { unenv: options };
17
+ },
18
+ configResolved() {
19
+ this.unenv = defineEnv(this.config.unenv || {});
20
+ this.config.build.alias ??= {};
21
+ if (Array.isArray(this.config.build.alias)) this.config.build.alias = Object.entries(this.unenv.env.alias).reduce((aliases, [key, value]) => {
22
+ if (!aliases.find((alias) => alias.find === key)) aliases.push({
23
+ find: key,
24
+ replacement: value
25
+ });
26
+ return aliases;
27
+ }, this.config.build.alias);
28
+ else this.config.build.alias = {
29
+ ...this.unenv.env.alias,
30
+ ...this.config.build.alias
31
+ };
32
+ this.config.build.external ??= [];
33
+ this.config.build.external.push(...this.unenv.env.external);
34
+ this.config.build.inject ??= {};
35
+ this.config.build.inject = {
36
+ ...this.unenv.env.inject,
37
+ ...this.config.build.inject
38
+ };
39
+ this.config.build.polyfill ??= [];
40
+ this.config.build.polyfill.push(...this.unenv.env.polyfill);
41
+ }
42
+ };
43
+ };
44
+ var src_default = plugin;
45
+
46
+ //#endregion
47
+ export { src_default as default, plugin };
@@ -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,16 @@ 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>;
328
+ /**
329
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
330
+ *
331
+ * @param code - The source code of the builtin file
332
+ * @param id - The unique identifier of the builtin file
333
+ * @param path - An optional path to write the builtin file to
334
+ * @param options - Additional options for writing the builtin file
335
+ */
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
304
337
  /**
305
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
306
339
  *
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
342
  * @param options - Additional options for writing the entry file
310
343
  */
311
344
  emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
345
+ /**
346
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
347
+ *
348
+ * @param code - The source code of the entry file
349
+ * @param path - An optional path to write the entry file to
350
+ * @param options - Additional options for writing the entry file
351
+ */
352
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
312
353
  /**
313
354
  * A function to update the context fields using a new user configuration options
314
355
  */
@@ -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,16 @@ 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>;
328
+ /**
329
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
330
+ *
331
+ * @param code - The source code of the builtin file
332
+ * @param id - The unique identifier of the builtin file
333
+ * @param path - An optional path to write the builtin file to
334
+ * @param options - Additional options for writing the builtin file
335
+ */
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
304
337
  /**
305
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
306
339
  *
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
342
  * @param options - Additional options for writing the entry file
310
343
  */
311
344
  emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
345
+ /**
346
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
347
+ *
348
+ * @param code - The source code of the entry file
349
+ * @param path - An optional path to write the entry file to
350
+ * @param options - Additional options for writing the entry file
351
+ */
352
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
312
353
  /**
313
354
  * A function to update the context fields using a new user configuration options
314
355
  */
@@ -13,6 +13,13 @@ interface StorageAdapter {
13
13
  * A name identifying the storage adapter type.
14
14
  */
15
15
  name: string;
16
+ /**
17
+ * The storage preset for the adapter.
18
+ *
19
+ * @remarks
20
+ * This can be used as an alternate way to identify the type of storage being used.
21
+ */
22
+ preset?: StoragePreset | null;
16
23
  /**
17
24
  * Checks if a key exists in the storage.
18
25
  *
@@ -207,6 +214,13 @@ interface WriteOptions {
207
214
  * @defaultValue false
208
215
  */
209
216
  skipFormat?: boolean;
217
+ /**
218
+ * The storage preset or adapter name for the output file.
219
+ *
220
+ * @remarks
221
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
222
+ */
223
+ storage?: StoragePreset | string;
210
224
  /**
211
225
  * Additional metadata for the file.
212
226
  */
@@ -13,6 +13,13 @@ interface StorageAdapter {
13
13
  * A name identifying the storage adapter type.
14
14
  */
15
15
  name: string;
16
+ /**
17
+ * The storage preset for the adapter.
18
+ *
19
+ * @remarks
20
+ * This can be used as an alternate way to identify the type of storage being used.
21
+ */
22
+ preset?: StoragePreset | null;
16
23
  /**
17
24
  * Checks if a key exists in the storage.
18
25
  *
@@ -207,6 +214,13 @@ interface WriteOptions {
207
214
  * @defaultValue false
208
215
  */
209
216
  skipFormat?: boolean;
217
+ /**
218
+ * The storage preset or adapter name for the output file.
219
+ *
220
+ * @remarks
221
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
222
+ */
223
+ storage?: StoragePreset | string;
210
224
  /**
211
225
  * Additional metadata for the file.
212
226
  */
@@ -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-unenv",
3
- "version": "0.1.105",
3
+ "version": "0.1.107",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to transform source code to be platform agnostic using unenv.",
6
6
  "repository": {
@@ -117,19 +117,19 @@
117
117
  "files": ["dist/**/*"],
118
118
  "keywords": ["unenv", "powerlines", "storm-software", "powerlines-plugin"],
119
119
  "dependencies": {
120
- "@stryke/path": "^0.24.0",
121
- "@stryke/fs": "^0.33.26",
122
- "@stryke/hash": "^0.12.32",
120
+ "@stryke/path": "^0.24.1",
121
+ "@stryke/fs": "^0.33.27",
122
+ "@stryke/hash": "^0.12.33",
123
123
  "unenv": "npm:unenv-nightly@2.0.0-rc.24",
124
124
  "defu": "^6.1.4",
125
- "powerlines": "^0.36.21",
125
+ "powerlines": "^0.36.23",
126
126
  "typescript": "^5.9.3",
127
127
  "vite": "8.0.0-beta.2"
128
128
  },
129
129
  "devDependencies": {
130
- "@powerlines/nx": "^0.11.47",
130
+ "@powerlines/nx": "^0.11.49",
131
131
  "@types/node": "^24.10.4"
132
132
  },
133
133
  "publishConfig": { "access": "public" },
134
- "gitHead": "b16324cf857ea5743fd7ad06e18607b1ba32abe0"
134
+ "gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
135
135
  }