powerlines 0.37.77 → 0.37.78

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 (91) hide show
  1. package/dist/lib/{chunk-ZOUD5WPQ.cjs → chunk-3I6LVWDP.cjs} +4 -4
  2. package/dist/lib/{chunk-ZOUD5WPQ.cjs.map → chunk-3I6LVWDP.cjs.map} +1 -1
  3. package/dist/lib/{chunk-NHYQ45UY.cjs → chunk-5EQ4CPQF.cjs} +19 -19
  4. package/dist/lib/{chunk-NHYQ45UY.cjs.map → chunk-5EQ4CPQF.cjs.map} +1 -1
  5. package/dist/lib/{chunk-PRAJIORG.js → chunk-5P644NSA.js} +3 -3
  6. package/dist/lib/{chunk-PRAJIORG.js.map → chunk-5P644NSA.js.map} +1 -1
  7. package/dist/lib/{chunk-3SMW7KVT.cjs → chunk-5ZPTAQEL.cjs} +3 -3
  8. package/dist/lib/{chunk-3SMW7KVT.cjs.map → chunk-5ZPTAQEL.cjs.map} +1 -1
  9. package/dist/lib/{chunk-6TXWOIA7.js → chunk-FLGXMGPQ.js} +3 -3
  10. package/dist/lib/{chunk-6TXWOIA7.js.map → chunk-FLGXMGPQ.js.map} +1 -1
  11. package/dist/lib/{chunk-O5OZ2UZO.cjs → chunk-GV526TGC.cjs} +4 -4
  12. package/dist/lib/chunk-GV526TGC.cjs.map +1 -0
  13. package/dist/lib/{chunk-WUZN5S4O.cjs → chunk-LI5EMC63.cjs} +16 -16
  14. package/dist/lib/{chunk-WUZN5S4O.cjs.map → chunk-LI5EMC63.cjs.map} +1 -1
  15. package/dist/lib/chunk-M2YUBCOO.cjs +4 -0
  16. package/dist/lib/{chunk-3GMJQ5G3.cjs.map → chunk-M2YUBCOO.cjs.map} +1 -1
  17. package/dist/lib/{chunk-VLUZ5CII.js → chunk-MQGE627Y.js} +3 -3
  18. package/dist/lib/{chunk-VLUZ5CII.js.map → chunk-MQGE627Y.js.map} +1 -1
  19. package/dist/lib/{chunk-NC45P7WJ.cjs → chunk-PG4GO2CR.cjs} +44 -60
  20. package/dist/lib/chunk-PG4GO2CR.cjs.map +1 -0
  21. package/dist/lib/{chunk-RXBIMIC6.js → chunk-PMXZ2XNX.js} +3 -3
  22. package/dist/lib/{chunk-RXBIMIC6.js.map → chunk-PMXZ2XNX.js.map} +1 -1
  23. package/dist/lib/chunk-R5BT5UQJ.cjs +75 -0
  24. package/dist/lib/chunk-R5BT5UQJ.cjs.map +1 -0
  25. package/dist/lib/chunk-RBL4NKT3.js +73 -0
  26. package/dist/lib/chunk-RBL4NKT3.js.map +1 -0
  27. package/dist/lib/{chunk-R36EMMJN.js → chunk-S5ZVX4JC.js} +44 -61
  28. package/dist/lib/chunk-S5ZVX4JC.js.map +1 -0
  29. package/dist/lib/{chunk-NQRBC322.cjs → chunk-SCWBDB6B.cjs} +6 -6
  30. package/dist/lib/{chunk-NQRBC322.cjs.map → chunk-SCWBDB6B.cjs.map} +1 -1
  31. package/dist/lib/chunk-XJFMPZ5P.js +3 -0
  32. package/dist/lib/{chunk-4BPHC6QQ.js.map → chunk-XJFMPZ5P.js.map} +1 -1
  33. package/dist/lib/{chunk-LCCQFULF.js → chunk-XXBJRC3X.js} +4 -4
  34. package/dist/lib/{chunk-LCCQFULF.js.map → chunk-XXBJRC3X.js.map} +1 -1
  35. package/dist/lib/{chunk-VWV5EWZM.js → chunk-YHPUSCWS.js} +4 -4
  36. package/dist/lib/chunk-YHPUSCWS.js.map +1 -0
  37. package/dist/lib/{chunk-KSKVDYXI.cjs → chunk-Z7AFA7O6.cjs} +5 -5
  38. package/dist/lib/{chunk-KSKVDYXI.cjs.map → chunk-Z7AFA7O6.cjs.map} +1 -1
  39. package/dist/lib/{chunk-PGSOL5W5.js → chunk-ZKIG3DC2.js} +4 -4
  40. package/dist/lib/{chunk-PGSOL5W5.js.map → chunk-ZKIG3DC2.js.map} +1 -1
  41. package/dist/lib/contexts/api-context.cjs +6 -6
  42. package/dist/lib/contexts/api-context.js +5 -5
  43. package/dist/lib/contexts/context.cjs +4 -4
  44. package/dist/lib/contexts/context.js +3 -3
  45. package/dist/lib/contexts/environment-context.cjs +5 -5
  46. package/dist/lib/contexts/environment-context.js +4 -4
  47. package/dist/lib/contexts/index.cjs +8 -8
  48. package/dist/lib/contexts/index.js +5 -5
  49. package/dist/lib/fs/index.cjs +3 -3
  50. package/dist/lib/fs/index.js +2 -2
  51. package/dist/lib/fs/storage/index.cjs +5 -5
  52. package/dist/lib/fs/storage/index.js +1 -1
  53. package/dist/lib/fs/vfs.cjs +3 -3
  54. package/dist/lib/fs/vfs.js +2 -2
  55. package/dist/lib/index.cjs +33 -24
  56. package/dist/lib/index.d.cts +2 -1
  57. package/dist/lib/index.d.ts +2 -1
  58. package/dist/lib/index.js +11 -10
  59. package/dist/lib/unplugin/factory.cjs +7 -7
  60. package/dist/lib/unplugin/factory.js +6 -6
  61. package/dist/lib/unplugin/index.cjs +19 -10
  62. package/dist/lib/unplugin/index.d.cts +2 -1
  63. package/dist/lib/unplugin/index.d.ts +2 -1
  64. package/dist/lib/unplugin/index.js +9 -8
  65. package/dist/lib/unplugin/module-resolution.cjs +13 -0
  66. package/dist/lib/unplugin/module-resolution.cjs.map +1 -0
  67. package/dist/lib/unplugin/module-resolution.d.cts +52 -0
  68. package/dist/lib/unplugin/module-resolution.d.ts +52 -0
  69. package/dist/lib/unplugin/module-resolution.js +4 -0
  70. package/dist/lib/unplugin/module-resolution.js.map +1 -0
  71. package/dist/lib/unplugin/plugin.cjs +7 -2
  72. package/dist/lib/unplugin/plugin.d.cts +8 -1
  73. package/dist/lib/unplugin/plugin.d.ts +8 -1
  74. package/dist/lib/unplugin/plugin.js +2 -1
  75. package/dist/lib/utilities/bundle.cjs +4 -3
  76. package/dist/lib/utilities/bundle.js +3 -2
  77. package/dist/lib/utilities/index.cjs +12 -11
  78. package/dist/lib/utilities/index.js +4 -3
  79. package/dist/lib/utilities/resolve.cjs +5 -4
  80. package/dist/lib/utilities/resolve.js +4 -3
  81. package/dist/unplugin.cjs +109 -58
  82. package/dist/unplugin.d.cts +23 -2
  83. package/dist/unplugin.d.ts +23 -2
  84. package/dist/unplugin.js +108 -59
  85. package/package.json +2 -2
  86. package/dist/lib/chunk-3GMJQ5G3.cjs +0 -4
  87. package/dist/lib/chunk-4BPHC6QQ.js +0 -3
  88. package/dist/lib/chunk-NC45P7WJ.cjs.map +0 -1
  89. package/dist/lib/chunk-O5OZ2UZO.cjs.map +0 -1
  90. package/dist/lib/chunk-R36EMMJN.js.map +0 -1
  91. package/dist/lib/chunk-VWV5EWZM.js.map +0 -1
package/dist/unplugin.cjs CHANGED
@@ -9,6 +9,112 @@ var chunkPK6SKIKE_cjs = require('./chunk-PK6SKIKE.cjs');
9
9
  var types = require('@storm-software/config-tools/types');
10
10
  var unplugin = require('unplugin');
11
11
 
12
+ // src/lib/unplugin/module-resolution.ts
13
+ function createUnpluginModuleResolutionFunctions(context) {
14
+ const ctx = context;
15
+ async function resolveId(id, importer, opts = {
16
+ isEntry: false
17
+ }) {
18
+ let result = await ctx.$$internal.callHook("resolveId", {
19
+ sequential: true,
20
+ result: "first",
21
+ order: "pre"
22
+ }, id, importer, opts);
23
+ if (result) {
24
+ return result;
25
+ }
26
+ result = await ctx.$$internal.callHook("resolveId", {
27
+ sequential: true,
28
+ result: "first",
29
+ order: "normal"
30
+ }, id, importer, opts);
31
+ if (result) {
32
+ return result;
33
+ }
34
+ result = await ctx.resolve(id, importer, opts);
35
+ if (result) {
36
+ return result;
37
+ }
38
+ return ctx.$$internal.callHook("resolveId", {
39
+ sequential: true,
40
+ result: "first",
41
+ order: "post"
42
+ }, id, importer, opts);
43
+ }
44
+ chunkPK6SKIKE_cjs.__name(resolveId, "resolveId");
45
+ async function load(id) {
46
+ let result = await ctx.$$internal.callHook("load", {
47
+ sequential: true,
48
+ result: "first",
49
+ order: "pre"
50
+ }, id);
51
+ if (result) {
52
+ return result;
53
+ }
54
+ result = await ctx.$$internal.callHook("load", {
55
+ sequential: true,
56
+ result: "first",
57
+ order: "normal"
58
+ }, id);
59
+ if (result) {
60
+ return result;
61
+ }
62
+ result = await ctx.load(id);
63
+ if (result) {
64
+ return result;
65
+ }
66
+ return ctx.$$internal.callHook("load", {
67
+ sequential: true,
68
+ result: "first",
69
+ order: "post"
70
+ }, id);
71
+ }
72
+ chunkPK6SKIKE_cjs.__name(load, "load");
73
+ return {
74
+ resolveId,
75
+ load
76
+ };
77
+ }
78
+ chunkPK6SKIKE_cjs.__name(createUnpluginModuleResolutionFunctions, "createUnpluginModuleResolutionFunctions");
79
+ function createUnpluginResolver(context) {
80
+ const ctx = context;
81
+ unplugin.setParseImpl(ctx.parse);
82
+ return () => {
83
+ const log = chunkQW4VON3V_cjs.extendLog(ctx.log, "unplugin");
84
+ log(types.LogLevelLabel.DEBUG, "Initializing Unplugin");
85
+ try {
86
+ const { resolveId, load } = createUnpluginModuleResolutionFunctions(context);
87
+ return {
88
+ name: "powerlines",
89
+ api: ctx.$$internal.api,
90
+ resolveId: {
91
+ filter: {
92
+ id: {
93
+ include: [
94
+ /.*/
95
+ ]
96
+ }
97
+ },
98
+ handler: resolveId
99
+ },
100
+ load: {
101
+ filter: {
102
+ id: {
103
+ include: [
104
+ /.*/
105
+ ]
106
+ }
107
+ },
108
+ handler: load
109
+ }
110
+ };
111
+ } catch (error) {
112
+ log(types.LogLevelLabel.FATAL, error?.message);
113
+ throw error;
114
+ }
115
+ };
116
+ }
117
+ chunkPK6SKIKE_cjs.__name(createUnpluginResolver, "createUnpluginResolver");
12
118
  function createUnplugin(context) {
13
119
  const ctx = context;
14
120
  unplugin.setParseImpl(ctx.parse);
@@ -16,6 +122,7 @@ function createUnplugin(context) {
16
122
  const log = chunkQW4VON3V_cjs.extendLog(ctx.log, "unplugin");
17
123
  log(types.LogLevelLabel.DEBUG, "Initializing Unplugin");
18
124
  try {
125
+ const { resolveId, load } = createUnpluginModuleResolutionFunctions(context);
19
126
  async function buildStart() {
20
127
  log(types.LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
21
128
  await ctx.$$internal.callHook("buildStart", {
@@ -23,64 +130,6 @@ function createUnplugin(context) {
23
130
  });
24
131
  }
25
132
  chunkPK6SKIKE_cjs.__name(buildStart, "buildStart");
26
- async function resolveId(id, importer, opts = {
27
- isEntry: false
28
- }) {
29
- let result = await ctx.$$internal.callHook("resolveId", {
30
- sequential: true,
31
- result: "first",
32
- order: "pre"
33
- }, id, importer, opts);
34
- if (result) {
35
- return result;
36
- }
37
- result = await ctx.$$internal.callHook("resolveId", {
38
- sequential: true,
39
- result: "first",
40
- order: "normal"
41
- }, id, importer, opts);
42
- if (result) {
43
- return result;
44
- }
45
- result = await ctx.resolve(id, importer, opts);
46
- if (result) {
47
- return result;
48
- }
49
- return ctx.$$internal.callHook("resolveId", {
50
- sequential: true,
51
- result: "first",
52
- order: "post"
53
- }, id, importer, opts);
54
- }
55
- chunkPK6SKIKE_cjs.__name(resolveId, "resolveId");
56
- async function load(id) {
57
- let result = await ctx.$$internal.callHook("load", {
58
- sequential: true,
59
- result: "first",
60
- order: "pre"
61
- }, id);
62
- if (result) {
63
- return result;
64
- }
65
- result = await ctx.$$internal.callHook("load", {
66
- sequential: true,
67
- result: "first",
68
- order: "normal"
69
- }, id);
70
- if (result) {
71
- return result;
72
- }
73
- result = await ctx.load(id);
74
- if (result) {
75
- return result;
76
- }
77
- return ctx.$$internal.callHook("load", {
78
- sequential: true,
79
- result: "first",
80
- order: "post"
81
- }, id);
82
- }
83
- chunkPK6SKIKE_cjs.__name(load, "load");
84
133
  async function transform(code, id) {
85
134
  let transformed = code;
86
135
  for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
@@ -161,5 +210,7 @@ Object.defineProperty(exports, "isUnpluginBuilderVariant", {
161
210
  get: function () { return chunkQW4VON3V_cjs.isUnpluginBuilderVariant; }
162
211
  });
163
212
  exports.createUnplugin = createUnplugin;
213
+ exports.createUnpluginModuleResolutionFunctions = createUnpluginModuleResolutionFunctions;
214
+ exports.createUnpluginResolver = createUnpluginResolver;
164
215
  //# sourceMappingURL=unplugin.cjs.map
165
216
  //# sourceMappingURL=unplugin.cjs.map
@@ -1,4 +1,4 @@
1
- import { UnpluginOptions as UnpluginOptions$1, UnpluginBuildContext, UnpluginContext } from 'unplugin';
1
+ import { UnpluginOptions as UnpluginOptions$1, UnpluginBuildContext, UnpluginContext, HookFnMap } from 'unplugin';
2
2
  import { r as Context, A as API, b0 as UnpluginOptions, aW as UnpluginFactory, aj as PluginContext } from './api-r5K-Tp5J.cjs';
3
3
  import { UnpluginBuilderVariant } from './types/build.cjs';
4
4
  import '@stryke/types/base';
@@ -153,6 +153,27 @@ declare function combineContexts<TContext extends PluginContext = PluginContext>
153
153
  */
154
154
  declare function isUnpluginBuilderVariant(str: unknown): str is UnpluginBuilderVariant;
155
155
 
156
+ /**
157
+ * Creates the module resolution hook functions for a Powerlines unplugin plugin instance.
158
+ *
159
+ * @remarks
160
+ * This includes the `resolveId` and `load` hooks.
161
+ *
162
+ * @see https://rollupjs.org/plugin-development/#resolveid
163
+ * @see https://rollupjs.org/plugin-development/#load
164
+ *
165
+ * @param context - The plugin context.
166
+ * @returns The module resolution hooks (`resolveId` and `load`).
167
+ */
168
+ declare function createUnpluginModuleResolutionFunctions<TContext extends PluginContext = PluginContext>(context: TContext): Pick<HookFnMap, "resolveId" | "load">;
169
+
170
+ /**
171
+ * Creates a Powerlines unplugin instance.
172
+ *
173
+ * @param context - The plugin context.
174
+ * @returns The unplugin instance.
175
+ */
176
+ declare function createUnpluginResolver<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant>(context: TContext): UnpluginFactory<TBuildVariant>;
156
177
  /**
157
178
  * Creates a Powerlines unplugin instance.
158
179
  *
@@ -161,4 +182,4 @@ declare function isUnpluginBuilderVariant(str: unknown): str is UnpluginBuilderV
161
182
  */
162
183
  declare function createUnplugin<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant>(context: TContext): UnpluginFactory<TBuildVariant>;
163
184
 
164
- export { combineContexts, createUnplugin, createUnpluginFactory, isUnpluginBuilderVariant };
185
+ export { combineContexts, createUnplugin, createUnpluginFactory, createUnpluginModuleResolutionFunctions, createUnpluginResolver, isUnpluginBuilderVariant };
@@ -1,4 +1,4 @@
1
- import { UnpluginOptions as UnpluginOptions$1, UnpluginBuildContext, UnpluginContext } from 'unplugin';
1
+ import { UnpluginOptions as UnpluginOptions$1, UnpluginBuildContext, UnpluginContext, HookFnMap } from 'unplugin';
2
2
  import { r as Context, A as API, b0 as UnpluginOptions, aW as UnpluginFactory, aj as PluginContext } from './api-_4a_8i2y.js';
3
3
  import { UnpluginBuilderVariant } from './types/build.js';
4
4
  import '@stryke/types/base';
@@ -153,6 +153,27 @@ declare function combineContexts<TContext extends PluginContext = PluginContext>
153
153
  */
154
154
  declare function isUnpluginBuilderVariant(str: unknown): str is UnpluginBuilderVariant;
155
155
 
156
+ /**
157
+ * Creates the module resolution hook functions for a Powerlines unplugin plugin instance.
158
+ *
159
+ * @remarks
160
+ * This includes the `resolveId` and `load` hooks.
161
+ *
162
+ * @see https://rollupjs.org/plugin-development/#resolveid
163
+ * @see https://rollupjs.org/plugin-development/#load
164
+ *
165
+ * @param context - The plugin context.
166
+ * @returns The module resolution hooks (`resolveId` and `load`).
167
+ */
168
+ declare function createUnpluginModuleResolutionFunctions<TContext extends PluginContext = PluginContext>(context: TContext): Pick<HookFnMap, "resolveId" | "load">;
169
+
170
+ /**
171
+ * Creates a Powerlines unplugin instance.
172
+ *
173
+ * @param context - The plugin context.
174
+ * @returns The unplugin instance.
175
+ */
176
+ declare function createUnpluginResolver<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant>(context: TContext): UnpluginFactory<TBuildVariant>;
156
177
  /**
157
178
  * Creates a Powerlines unplugin instance.
158
179
  *
@@ -161,4 +182,4 @@ declare function isUnpluginBuilderVariant(str: unknown): str is UnpluginBuilderV
161
182
  */
162
183
  declare function createUnplugin<TContext extends PluginContext = PluginContext, TBuildVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant>(context: TContext): UnpluginFactory<TBuildVariant>;
163
184
 
164
- export { combineContexts, createUnplugin, createUnpluginFactory, isUnpluginBuilderVariant };
185
+ export { combineContexts, createUnplugin, createUnpluginFactory, createUnpluginModuleResolutionFunctions, createUnpluginResolver, isUnpluginBuilderVariant };
package/dist/unplugin.js CHANGED
@@ -9,6 +9,112 @@ import { __name } from './chunk-7QVYU63E.js';
9
9
  import { LogLevelLabel } from '@storm-software/config-tools/types';
10
10
  import { setParseImpl } from 'unplugin';
11
11
 
12
+ // src/lib/unplugin/module-resolution.ts
13
+ function createUnpluginModuleResolutionFunctions(context) {
14
+ const ctx = context;
15
+ async function resolveId(id, importer, opts = {
16
+ isEntry: false
17
+ }) {
18
+ let result = await ctx.$$internal.callHook("resolveId", {
19
+ sequential: true,
20
+ result: "first",
21
+ order: "pre"
22
+ }, id, importer, opts);
23
+ if (result) {
24
+ return result;
25
+ }
26
+ result = await ctx.$$internal.callHook("resolveId", {
27
+ sequential: true,
28
+ result: "first",
29
+ order: "normal"
30
+ }, id, importer, opts);
31
+ if (result) {
32
+ return result;
33
+ }
34
+ result = await ctx.resolve(id, importer, opts);
35
+ if (result) {
36
+ return result;
37
+ }
38
+ return ctx.$$internal.callHook("resolveId", {
39
+ sequential: true,
40
+ result: "first",
41
+ order: "post"
42
+ }, id, importer, opts);
43
+ }
44
+ __name(resolveId, "resolveId");
45
+ async function load(id) {
46
+ let result = await ctx.$$internal.callHook("load", {
47
+ sequential: true,
48
+ result: "first",
49
+ order: "pre"
50
+ }, id);
51
+ if (result) {
52
+ return result;
53
+ }
54
+ result = await ctx.$$internal.callHook("load", {
55
+ sequential: true,
56
+ result: "first",
57
+ order: "normal"
58
+ }, id);
59
+ if (result) {
60
+ return result;
61
+ }
62
+ result = await ctx.load(id);
63
+ if (result) {
64
+ return result;
65
+ }
66
+ return ctx.$$internal.callHook("load", {
67
+ sequential: true,
68
+ result: "first",
69
+ order: "post"
70
+ }, id);
71
+ }
72
+ __name(load, "load");
73
+ return {
74
+ resolveId,
75
+ load
76
+ };
77
+ }
78
+ __name(createUnpluginModuleResolutionFunctions, "createUnpluginModuleResolutionFunctions");
79
+ function createUnpluginResolver(context) {
80
+ const ctx = context;
81
+ setParseImpl(ctx.parse);
82
+ return () => {
83
+ const log = extendLog(ctx.log, "unplugin");
84
+ log(LogLevelLabel.DEBUG, "Initializing Unplugin");
85
+ try {
86
+ const { resolveId, load } = createUnpluginModuleResolutionFunctions(context);
87
+ return {
88
+ name: "powerlines",
89
+ api: ctx.$$internal.api,
90
+ resolveId: {
91
+ filter: {
92
+ id: {
93
+ include: [
94
+ /.*/
95
+ ]
96
+ }
97
+ },
98
+ handler: resolveId
99
+ },
100
+ load: {
101
+ filter: {
102
+ id: {
103
+ include: [
104
+ /.*/
105
+ ]
106
+ }
107
+ },
108
+ handler: load
109
+ }
110
+ };
111
+ } catch (error) {
112
+ log(LogLevelLabel.FATAL, error?.message);
113
+ throw error;
114
+ }
115
+ };
116
+ }
117
+ __name(createUnpluginResolver, "createUnpluginResolver");
12
118
  function createUnplugin(context) {
13
119
  const ctx = context;
14
120
  setParseImpl(ctx.parse);
@@ -16,6 +122,7 @@ function createUnplugin(context) {
16
122
  const log = extendLog(ctx.log, "unplugin");
17
123
  log(LogLevelLabel.DEBUG, "Initializing Unplugin");
18
124
  try {
125
+ const { resolveId, load } = createUnpluginModuleResolutionFunctions(context);
19
126
  async function buildStart() {
20
127
  log(LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
21
128
  await ctx.$$internal.callHook("buildStart", {
@@ -23,64 +130,6 @@ function createUnplugin(context) {
23
130
  });
24
131
  }
25
132
  __name(buildStart, "buildStart");
26
- async function resolveId(id, importer, opts = {
27
- isEntry: false
28
- }) {
29
- let result = await ctx.$$internal.callHook("resolveId", {
30
- sequential: true,
31
- result: "first",
32
- order: "pre"
33
- }, id, importer, opts);
34
- if (result) {
35
- return result;
36
- }
37
- result = await ctx.$$internal.callHook("resolveId", {
38
- sequential: true,
39
- result: "first",
40
- order: "normal"
41
- }, id, importer, opts);
42
- if (result) {
43
- return result;
44
- }
45
- result = await ctx.resolve(id, importer, opts);
46
- if (result) {
47
- return result;
48
- }
49
- return ctx.$$internal.callHook("resolveId", {
50
- sequential: true,
51
- result: "first",
52
- order: "post"
53
- }, id, importer, opts);
54
- }
55
- __name(resolveId, "resolveId");
56
- async function load(id) {
57
- let result = await ctx.$$internal.callHook("load", {
58
- sequential: true,
59
- result: "first",
60
- order: "pre"
61
- }, id);
62
- if (result) {
63
- return result;
64
- }
65
- result = await ctx.$$internal.callHook("load", {
66
- sequential: true,
67
- result: "first",
68
- order: "normal"
69
- }, id);
70
- if (result) {
71
- return result;
72
- }
73
- result = await ctx.load(id);
74
- if (result) {
75
- return result;
76
- }
77
- return ctx.$$internal.callHook("load", {
78
- sequential: true,
79
- result: "first",
80
- order: "post"
81
- }, id);
82
- }
83
- __name(load, "load");
84
133
  async function transform(code, id) {
85
134
  let transformed = code;
86
135
  for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
@@ -148,6 +197,6 @@ function createUnplugin(context) {
148
197
  }
149
198
  __name(createUnplugin, "createUnplugin");
150
199
 
151
- export { createUnplugin };
200
+ export { createUnplugin, createUnpluginModuleResolutionFunctions, createUnpluginResolver };
152
201
  //# sourceMappingURL=unplugin.js.map
153
202
  //# sourceMappingURL=unplugin.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powerlines",
3
- "version": "0.37.77",
3
+ "version": "0.37.78",
4
4
  "type": "module",
5
5
  "description": "The \"any framework\" framework that simplifies modern dev tool usage, generates virtual (or actual) code modules, and improves DX across the board.",
6
6
  "repository": {
@@ -662,5 +662,5 @@
662
662
  "undici-types": "^7.19.0"
663
663
  },
664
664
  "publishConfig": { "access": "public" },
665
- "gitHead": "77a3e8d37f6eff165c11192daf8da35ff294ff5f"
665
+ "gitHead": "b9c9c76658b8cd7f3491ff9212b40ffc5b0d0e02"
666
666
  }
@@ -1,4 +0,0 @@
1
- 'use strict';
2
-
3
- //# sourceMappingURL=chunk-3GMJQ5G3.cjs.map
4
- //# sourceMappingURL=chunk-3GMJQ5G3.cjs.map
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-4BPHC6QQ.js.map
3
- //# sourceMappingURL=chunk-4BPHC6QQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/unplugin/plugin.ts"],"names":["createUnplugin","context","ctx","setParseImpl","parse","log","extendLog","LogLevelLabel","DEBUG","buildStart","$$internal","callHook","sequential","resolveId","id","importer","opts","isEntry","result","order","resolve","load","transform","code","transformed","hook","environment","selectHooks","handler","apply","combineContexts","getString","buildEnd","writeBundle","name","api","filter","include","vite","sharedDuringBuild","error","FATAL","message"],"mappings":";;;;;;;;;AAwCO,SAASA,eAGdC,OAAAA,EAAiB;AACjB,EAAA,MAAMC,GAAAA,GAAMD,OAAAA;AACZE,EAAAA,qBAAAA,CAAaD,IAAIE,KAAK,CAAA;AAEtB,EAAA,OAAO,MAAA;AACL,IAAA,MAAMC,GAAAA,GAAMC,2BAAAA,CAAUJ,GAAAA,CAAIG,GAAAA,EAAK,UAAA,CAAA;AAC/BA,IAAAA,GAAAA,CAAIE,mBAAAA,CAAcC,OAAO,uBAAA,CAAA;AAEzB,IAAA,IAAI;AACF,MAAA,eAAeC,UAAAA,GAAAA;AACbJ,QAAAA,GAAAA,CAAIE,mBAAAA,CAAcC,OAAO,qCAAA,CAAA;AAEzB,QAAA,MAAMN,GAAAA,CAAIQ,UAAAA,CAAWC,QAAAA,CAAS,YAAA,EAAc;UAC1CC,UAAAA,EAAY;SACd,CAAA;AACF,MAAA;AANeH,MAAAA,wBAAAA,CAAAA,UAAAA,EAAAA,YAAAA,CAAAA;AAQf,MAAA,eAAeI,SAAAA,CAEbC,EAAAA,EACAC,QAAAA,EACAC,IAAAA,GA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AAO;AACdnC,MAAAA,GAAAA,CAAIE,mBAAAA,CAAckC,KAAAA,EAAQD,KAAAA,EAAiBE,OAAAA,CAAAA;AAE3C,MAAA,MAAMF,KAAAA;AACR,IAAA;AACF,EAAA,CAAA;AACF;AAlMgBxC,wBAAAA,CAAAA,cAAAA,EAAAA,gBAAAA,CAAAA","file":"chunk-NC45P7WJ.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport type {\n ExternalIdResult,\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { UnpluginBuilderVariant } from \"../../types/build\";\nimport { PluginContext } from \"../../types/context\";\nimport { UNSAFE_PluginContext } from \"../../types/internal\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<\n TContext extends PluginContext = PluginContext,\n TBuildVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant\n>(context: TContext): UnpluginFactory<TBuildVariant> {\n const ctx = context as unknown as UNSAFE_PluginContext;\n setParseImpl(ctx.parse);\n\n return () => {\n const log = extendLog(ctx.log, \"unplugin\");\n log(LogLevelLabel.DEBUG, \"Initializing Unplugin\");\n\n try {\n async function buildStart(this: UnpluginBuildContext) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n\n await ctx.$$internal.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n opts: {\n isEntry: boolean;\n } = { isEntry: false }\n ): Promise<string | ExternalIdResult | null | undefined> {\n let result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n id,\n importer,\n opts\n );\n if (result) {\n return result;\n }\n\n result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n id,\n importer,\n opts\n );\n if (result) {\n return result;\n }\n\n result = await ctx.resolve(id, importer, opts);\n if (result) {\n return result;\n }\n\n return ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n id,\n importer,\n opts\n );\n }\n\n async function load(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n id\n );\n if (result) {\n return result;\n }\n\n result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n id\n );\n if (result) {\n return result;\n }\n\n result = await ctx.load(id);\n if (result) {\n return result;\n }\n\n return ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n id\n );\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of ctx.$$internal.environment.selectHooks(\n \"transform\"\n )) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(ctx, this), [\n getString(transformed),\n id\n ]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin finishing...\");\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name: \"powerlines\",\n api: ctx.$$internal.api,\n resolveId: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: resolveId\n },\n load: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: load\n },\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/utilities/bundle.ts"],"names":["bundle","context","file","overrides","path","fs","resolve","existsSync","Error","result","build","defu","extractESBuildConfig","entryPoints","write","sourcemap","splitting","treeShaking","packages","platform","logLevel","plugins","createEsbuildPlugin","createUnplugin","errors","length","map","error","text","join","warnings","warn","warning","outputFiles","filter","Boolean"],"mappings":";;;;;;;;;;;;;AAoGA,eAAsBA,MAAAA,CACpBC,OAAAA,EACAC,IAAAA,EACAC,SAAAA,GAAiD,EAAC,EAAC;AAEnD,EAAA,MAAMC,IAAAA,GAAO,MAAMH,OAAAA,CAAQI,EAAAA,CAAGC,QAAQJ,IAAAA,CAAAA;AACtC,EAAA,IAAI,CAACE,IAAAA,IAAQ,CAACH,QAAQI,EAAAA,CAAGE,UAAAA,CAAWH,IAAAA,CAAAA,EAAO;AACzC,IAAA,MAAM,IAAII,KAAAA,CACR,CAAA,mBAAA,EAAsBN,IAAAA,CAAAA,uCAAAA,CAA6C,CAAA;AAEvE,EAAA;AAGA,EAAA,MAAMO,MAAAA,GAAS,MAAMC,aAAAA,CACnBC,qBAAAA,CACE;AACE,IAAA,G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AA,CAAAA,+CAAAA,CAC+C,CAAA;AAErD,EAAA;AAEA,EAAA,OAAOO,MAAAA,CAAOwB,WAAAA,CAAYC,MAAAA,CAAOC,OAAAA,EAAS,CAAA,CAAA;AAC5C;AAxDsBnC,wBAAAA,CAAAA,MAAAA,EAAAA,QAAAA,CAAAA","file":"chunk-O5OZ2UZO.cjs","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport defu from \"defu\";\nimport { build, BuildOptions, OutputFile } from \"esbuild\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport { ESBuildResolvedBuildConfig } from \"../../types/build\";\nimport { PluginContext } from \"../../types/context\";\nimport { extractESBuildConfig } from \"../build/esbuild\";\nimport { createUnplugin } from \"../unplugin/plugin\";\n\n// const externalBuiltinsPlugin = async (context: Context): Promise<Plugin> => {\n// const builtins = await context.getBuiltins();\n\n// return {\n// name: `powerlines:external-builtins`,\n// setup(build) {\n// build.onResolve(\n// {\n// filter: new RegExp(`^${context.config.framework || \"powerlines\"}:.*`)\n// },\n// async (args: OnResolveArgs) => {\n// const found = builtins.find(\n// builtin =>\n// builtin.id === args.path ||\n// builtin.id ===\n// args.path.replace(\n// new RegExp(`^${context.config.framework || \"powerlines\"}:`),\n// \"\"\n// ) ||\n// builtin.path === args.path\n// );\n// if (found) {\n// return {\n// path: found.id,\n// external: false,\n// namespace: \"powerlines\"\n// };\n// }\n\n// return { external: true };\n// }\n// );\n// build.onLoad(\n// {\n// filter: /.*/,\n// namespace: \"powerlines\"\n// },\n// async (args: OnLoadArgs) => {\n// const found = builtins.find(\n// builtin =>\n// builtin.id === args.path ||\n// builtin.id ===\n// args.path.replace(\n// new RegExp(`^${context.config.framework || \"powerlines\"}:`),\n// \"\"\n// ) ||\n// builtin.path === args.path\n// );\n// if (!found) {\n// context.warn(\n// `Failed to load builtin module: \"${\n// args.path\n// }\" during bundling - this should not happen since the \\`onResolve\\` hook resolves all existing built-in modules. Please ensure the built-in module \"${\n// args.path\n// }\" was generated.`\n// );\n// return { contents: \"\", loader: \"ts\" };\n// }\n\n// return { contents: found?.code || \"\", loader: \"ts\" };\n// }\n// );\n// }\n// };\n// };\n\n/**\n * Bundle a type definition to a module.\n *\n * @param context - The context object containing the environment paths.\n * @param file - The file path to bundle.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the bundled module.\n */\nexport async function bundle(\n context: PluginContext,\n file: string,\n overrides: Partial<ESBuildResolvedBuildConfig> = {}\n): Promise<OutputFile> {\n const path = await context.fs.resolve(file);\n if (!path || !context.fs.existsSync(path)) {\n throw new Error(\n `Module not found: \"${file}\". Please check the path and try again.`\n );\n }\n\n // const plugin = await externalBuiltinsPlugin(context);\n const result = await build(\n defu(\n {\n ...extractESBuildConfig(context),\n entryPoints: [path],\n write: false,\n sourcemap: false,\n splitting: false,\n treeShaking: false,\n bundle: true,\n packages: \"bundle\",\n platform: \"node\",\n logLevel: \"silent\",\n ...overrides\n } as BuildOptions,\n {\n plugins: [createEsbuildPlugin(createUnplugin(context))({})]\n }\n )\n );\n if (result.errors.length > 0) {\n throw new Error(\n `Failed to bundle ${file}: ${result.errors\n .map(error => error.text)\n .join(\", \")}`\n );\n }\n if (result.warnings.length > 0) {\n context.warn(\n `Warnings while bundling ${file}: ${result.warnings\n .map(warning => warning.text)\n .join(\", \")}`\n );\n }\n if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) {\n throw new Error(\n `No output files generated for ${\n file\n }. Please check the configuration and try again.`\n );\n }\n\n return result.outputFiles.filter(Boolean)[0]!;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/unplugin/plugin.ts"],"names":["createUnplugin","context","ctx","setParseImpl","parse","log","extendLog","LogLevelLabel","DEBUG","buildStart","$$internal","callHook","sequential","resolveId","id","importer","opts","isEntry","result","order","resolve","load","transform","code","transformed","hook","environment","selectHooks","handler","apply","combineContexts","getString","buildEnd","writeBundle","name","api","filter","include","vite","sharedDuringBuild","error","FATAL","message"],"mappings":";;;;;;;AAwCO,SAASA,eAGdC,OAAAA,EAAiB;AACjB,EAAA,MAAMC,GAAAA,GAAMD,OAAAA;AACZE,EAAAA,YAAAA,CAAaD,IAAIE,KAAK,CAAA;AAEtB,EAAA,OAAO,MAAA;AACL,IAAA,MAAMC,GAAAA,GAAMC,SAAAA,CAAUJ,GAAAA,CAAIG,GAAAA,EAAK,UAAA,CAAA;AAC/BA,IAAAA,GAAAA,CAAIE,aAAAA,CAAcC,OAAO,uBAAA,CAAA;AAEzB,IAAA,IAAI;AACF,MAAA,eAAeC,UAAAA,GAAAA;AACbJ,QAAAA,GAAAA,CAAIE,aAAAA,CAAcC,OAAO,qCAAA,CAAA;AAEzB,QAAA,MAAMN,GAAAA,CAAIQ,UAAAA,CAAWC,QAAAA,CAAS,YAAA,EAAc;UAC1CC,UAAAA,EAAY;SACd,CAAA;AACF,MAAA;AANeH,MAAAA,MAAAA,CAAAA,UAAAA,EAAAA,YAAAA,CAAAA;AAQf,MAAA,eAAeI,SAAAA,CAEbC,EAAAA,EACAC,QAAAA,EACAC,IAAAA,GAEI;QAAEC,OAAAA,EAAS;OAAM,EAAC;AAEtB,QAAA,IAAIC,MAAAA,GAAS,MAAMhB,GAAAA,CAAIQ,UAAAA,CAAWC,SAChC,WAAA,EACA;UACEC,UAAAA,EAAY,IAAA;UACZM,MAAAA,EAAQ,OAAA;UACRC,KAAAA,EAAO;SACT,EACAL,EAAAA,EACAC,UACAC,IAAAA,CAAAA;AAEF,QAAA,IAAIE,MAAAA,EAAQ;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AAY;UACzCC,UAAAA,EAAY;SACd,CAAA;AACF,MAAA;AANeoB,MAAAA,MAAAA,CAAAA,QAAAA,EAAAA,UAAAA,CAAAA;AAQf,MAAA,eAAeC,WAAAA,GAAAA;AACb5B,QAAAA,GAAAA,CAAIE,aAAAA,CAAcC,OAAO,yCAAA,CAAA;AAEzB,QAAA,OAAON,GAAAA,CAAIQ,UAAAA,CAAWC,QAAAA,CAAS,aAAA,EAAe;UAC5CC,UAAAA,EAAY;SACd,CAAA;AACF,MAAA;AANeqB,MAAAA,MAAAA,CAAAA,WAAAA,EAAAA,aAAAA,CAAAA;AAQf,MAAA,OAAO;QACLC,IAAAA,EAAM,YAAA;AACNC,QAAAA,GAAAA,EAAKjC,IAAIQ,UAAAA,CAAWyB,GAAAA;QACpBtB,SAAAA,EAAW;UACTuB,MAAAA,EAAQ;YACNtB,EAAAA,EAAI;cACFuB,OAAAA,EAAS;AAAC,gBAAA;;AACZ;AACF,WAAA;UACAT,OAAAA,EAASf;AACX,SAAA;QACAQ,IAAAA,EAAM;UACJe,MAAAA,EAAQ;YACNtB,EAAAA,EAAI;cACFuB,OAAAA,EAAS;AAAC,gBAAA;;AACZ;AACF,WAAA;UACAT,OAAAA,EAASP;AACX,SAAA;AACAC,QAAAA,SAAAA;AACAb,QAAAA,UAAAA;AACAuB,QAAAA,QAAAA;AACAC,QAAAA,WAAAA;QACAK,IAAAA,EAAM;UACJC,iBAAAA,EAAmB;AACrB;AACF,OAAA;AACF,IAAA,CAAA,CAAA,OAASC,KAAAA,EAAO;AACdnC,MAAAA,GAAAA,CAAIE,aAAAA,CAAckC,KAAAA,EAAQD,KAAAA,EAAiBE,OAAAA,CAAAA;AAE3C,MAAA,MAAMF,KAAAA;AACR,IAAA;AACF,EAAA,CAAA;AACF;AAlMgBxC,MAAAA,CAAAA,cAAAA,EAAAA,gBAAAA,CAAAA","file":"chunk-R36EMMJN.js","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport type {\n ExternalIdResult,\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { UnpluginBuilderVariant } from \"../../types/build\";\nimport { PluginContext } from \"../../types/context\";\nimport { UNSAFE_PluginContext } from \"../../types/internal\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<\n TContext extends PluginContext = PluginContext,\n TBuildVariant extends UnpluginBuilderVariant = UnpluginBuilderVariant\n>(context: TContext): UnpluginFactory<TBuildVariant> {\n const ctx = context as unknown as UNSAFE_PluginContext;\n setParseImpl(ctx.parse);\n\n return () => {\n const log = extendLog(ctx.log, \"unplugin\");\n log(LogLevelLabel.DEBUG, \"Initializing Unplugin\");\n\n try {\n async function buildStart(this: UnpluginBuildContext) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n\n await ctx.$$internal.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n opts: {\n isEntry: boolean;\n } = { isEntry: false }\n ): Promise<string | ExternalIdResult | null | undefined> {\n let result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n id,\n importer,\n opts\n );\n if (result) {\n return result;\n }\n\n result = await ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n id,\n importer,\n opts\n );\n if (result) {\n return result;\n }\n\n result = await ctx.resolve(id, importer, opts);\n if (result) {\n return result;\n }\n\n return ctx.$$internal.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n id,\n importer,\n opts\n );\n }\n\n async function load(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n id\n );\n if (result) {\n return result;\n }\n\n result = await ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n id\n );\n if (result) {\n return result;\n }\n\n result = await ctx.load(id);\n if (result) {\n return result;\n }\n\n return ctx.$$internal.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n id\n );\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of ctx.$$internal.environment.selectHooks(\n \"transform\"\n )) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(ctx, this), [\n getString(transformed),\n id\n ]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin finishing...\");\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name: \"powerlines\",\n api: ctx.$$internal.api,\n resolveId: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: resolveId\n },\n load: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: load\n },\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/utilities/bundle.ts"],"names":["bundle","context","file","overrides","path","fs","resolve","existsSync","Error","result","build","defu","extractESBuildConfig","entryPoints","write","sourcemap","splitting","treeShaking","packages","platform","logLevel","plugins","createEsbuildPlugin","createUnplugin","errors","length","map","error","text","join","warnings","warn","warning","outputFiles","filter","Boolean"],"mappings":";;;;;;;AAoGA,eAAsBA,MAAAA,CACpBC,OAAAA,EACAC,IAAAA,EACAC,SAAAA,GAAiD,EAAC,EAAC;AAEnD,EAAA,MAAMC,IAAAA,GAAO,MAAMH,OAAAA,CAAQI,EAAAA,CAAGC,QAAQJ,IAAAA,CAAAA;AACtC,EAAA,IAAI,CAACE,IAAAA,IAAQ,CAACH,QAAQI,EAAAA,CAAGE,UAAAA,CAAWH,IAAAA,CAAAA,EAAO;AACzC,IAAA,MAAM,IAAII,KAAAA,CACR,CAAA,mBAAA,EAAsBN,IAAAA,CAAAA,uCAAAA,CAA6C,CAAA;AAEvE,EAAA;AAGA,EAAA,MAAMO,MAAAA,GAAS,MAAMC,KAAAA,CACnBC,IAAAA,CACE;AACE,IAAA,GAAGC,qBAAqBX,OAAAA,CAAAA;IACxBY,WAAAA,EAAa;AAACT,MAAAA;;IACdU,KAAAA,EAAO,KAAA;IACPC,SAAAA,EAAW,KAAA;IACXC,SAAAA,EAAW,KAAA;IACXC,WAAAA,EAAa,KAAA;IACbjB,MAAAA,EAAQ,IAAA;IACRkB,QAAAA,EAAU,QAAA;IACVC,QAAAA,EAAU,MAAA;IACVC,QAAAA,EAAU,QAAA;IACV,GAAGjB;GACL,EACA;IACEkB,OAAAA,EAAS;AAACC,MAAAA,mBAAAA,CAAoBC,cAAAA,CAAetB,OAAAA,CAAAA,CAAAA,CAAU,EAAC;;AAC1D,GAAA,CAAA,CAAA;AAGJ,EAAA,IAAIQ,MAAAA,CAAOe,MAAAA,CAAOC,MAAAA,GAAS,CAAA,EAAG;AAC5B,IAAA,MAAM,IAAIjB,KAAAA,CACR,CAAA,iBAAA,EAAoBN,IAAAA,CAAAA,EAAAA,EAASO,OAAOe,MAAAA,CACjCE,GAAAA,CAAIC,CAAAA,KAAAA,KAASA,MAAMC,IAAI,CAAA,CACvBC,IAAAA,CAAK,IAAA,CAAA,CAAA,CAAO,CAAA;AAEnB,EAAA;AACA,EAAA,IAAIpB,MAAAA,CAAOqB,QAAAA,CAASL,MAAAA,GAAS,CAAA,EAAG;AAC9BxB,IAAAA,OAAAA,CAAQ8B,IAAAA,CACN,CAAA,wBAAA,EAA2B7B,IAAAA,CAAAA,EAAAA,EAASO,OAAOqB,QAAAA,CACxCJ,GAAAA,CAAIM,CAAAA,OAAAA,KAAWA,QAAQJ,IAAI,CAAA,CAC3BC,IAAAA,CAAK,IAAA,CAAA,CAAA,CAAO,CAAA;AAEnB,EAAA;AACA,EAAA,IAAI,CAACpB,OAAOwB,WAAAA,IAAexB,MAAAA,CAAOwB,YAAYC,MAAAA,CAAOC,OAAAA,CAAAA,CAASV,MAAAA,KAAW,CAAA,EAAG;AAC1E,IAAA,MAAM,IAAIjB,KAAAA,CACR,CAAA,8BAAA,EACEN,IAAAA,CAAAA,+CAAAA,CAC+C,CAAA;AAErD,EAAA;AAEA,EAAA,OAAOO,MAAAA,CAAOwB,WAAAA,CAAYC,MAAAA,CAAOC,OAAAA,EAAS,CAAA,CAAA;AAC5C;AAxDsBnC,MAAAA,CAAAA,MAAAA,EAAAA,QAAAA,CAAAA","file":"chunk-VWV5EWZM.js","sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport defu from \"defu\";\nimport { build, BuildOptions, OutputFile } from \"esbuild\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport { ESBuildResolvedBuildConfig } from \"../../types/build\";\nimport { PluginContext } from \"../../types/context\";\nimport { extractESBuildConfig } from \"../build/esbuild\";\nimport { createUnplugin } from \"../unplugin/plugin\";\n\n// const externalBuiltinsPlugin = async (context: Context): Promise<Plugin> => {\n// const builtins = await context.getBuiltins();\n\n// return {\n// name: `powerlines:external-builtins`,\n// setup(build) {\n// build.onResolve(\n// {\n// filter: new RegExp(`^${context.config.framework || \"powerlines\"}:.*`)\n// },\n// async (args: OnResolveArgs) => {\n// const found = builtins.find(\n// builtin =>\n// builtin.id === args.path ||\n// builtin.id ===\n// args.path.replace(\n// new RegExp(`^${context.config.framework || \"powerlines\"}:`),\n// \"\"\n// ) ||\n// builtin.path === args.path\n// );\n// if (found) {\n// return {\n// path: found.id,\n// external: false,\n// namespace: \"powerlines\"\n// };\n// }\n\n// return { external: true };\n// }\n// );\n// build.onLoad(\n// {\n// filter: /.*/,\n// namespace: \"powerlines\"\n// },\n// async (args: OnLoadArgs) => {\n// const found = builtins.find(\n// builtin =>\n// builtin.id === args.path ||\n// builtin.id ===\n// args.path.replace(\n// new RegExp(`^${context.config.framework || \"powerlines\"}:`),\n// \"\"\n// ) ||\n// builtin.path === args.path\n// );\n// if (!found) {\n// context.warn(\n// `Failed to load builtin module: \"${\n// args.path\n// }\" during bundling - this should not happen since the \\`onResolve\\` hook resolves all existing built-in modules. Please ensure the built-in module \"${\n// args.path\n// }\" was generated.`\n// );\n// return { contents: \"\", loader: \"ts\" };\n// }\n\n// return { contents: found?.code || \"\", loader: \"ts\" };\n// }\n// );\n// }\n// };\n// };\n\n/**\n * Bundle a type definition to a module.\n *\n * @param context - The context object containing the environment paths.\n * @param file - The file path to bundle.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the bundled module.\n */\nexport async function bundle(\n context: PluginContext,\n file: string,\n overrides: Partial<ESBuildResolvedBuildConfig> = {}\n): Promise<OutputFile> {\n const path = await context.fs.resolve(file);\n if (!path || !context.fs.existsSync(path)) {\n throw new Error(\n `Module not found: \"${file}\". Please check the path and try again.`\n );\n }\n\n // const plugin = await externalBuiltinsPlugin(context);\n const result = await build(\n defu(\n {\n ...extractESBuildConfig(context),\n entryPoints: [path],\n write: false,\n sourcemap: false,\n splitting: false,\n treeShaking: false,\n bundle: true,\n packages: \"bundle\",\n platform: \"node\",\n logLevel: \"silent\",\n ...overrides\n } as BuildOptions,\n {\n plugins: [createEsbuildPlugin(createUnplugin(context))({})]\n }\n )\n );\n if (result.errors.length > 0) {\n throw new Error(\n `Failed to bundle ${file}: ${result.errors\n .map(error => error.text)\n .join(\", \")}`\n );\n }\n if (result.warnings.length > 0) {\n context.warn(\n `Warnings while bundling ${file}: ${result.warnings\n .map(warning => warning.text)\n .join(\", \")}`\n );\n }\n if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) {\n throw new Error(\n `No output files generated for ${\n file\n }. Please check the configuration and try again.`\n );\n }\n\n return result.outputFiles.filter(Boolean)[0]!;\n}\n"]}