@powerlines/plugin-vite 0.14.58 → 0.14.60

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 (130) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +1 -0
  2. package/dist/helpers/index.cjs +1 -1
  3. package/dist/helpers/index.d.cts +1 -3
  4. package/dist/helpers/index.d.mts +1 -3
  5. package/dist/helpers/index.mjs +1 -1
  6. package/dist/helpers/unplugin.cjs +1 -1
  7. package/dist/helpers/unplugin.d.cts +6 -2
  8. package/dist/helpers/unplugin.d.mts +6 -2
  9. package/dist/helpers/unplugin.mjs +1 -1
  10. package/dist/index.cjs +1 -14
  11. package/dist/index.d.cts +3 -4
  12. package/dist/index.d.mts +5 -5
  13. package/dist/index.mjs +1 -14
  14. package/dist/powerlines/schemas/fs.cjs +1 -0
  15. package/dist/powerlines/schemas/fs.mjs +1 -0
  16. package/dist/powerlines/src/api.cjs +11 -0
  17. package/dist/powerlines/src/api.mjs +1 -0
  18. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +1 -0
  19. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +1 -0
  20. package/dist/powerlines/src/internal/helpers/environment.cjs +1 -0
  21. package/dist/powerlines/src/internal/helpers/environment.mjs +1 -0
  22. package/dist/powerlines/src/internal/helpers/generate-types.cjs +8 -0
  23. package/dist/powerlines/src/internal/helpers/generate-types.mjs +8 -0
  24. package/dist/powerlines/src/internal/helpers/hooks.cjs +1 -0
  25. package/dist/powerlines/src/internal/helpers/hooks.mjs +1 -0
  26. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +3 -0
  27. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +3 -0
  28. package/dist/powerlines/src/internal/helpers/install.cjs +1 -0
  29. package/dist/powerlines/src/internal/helpers/install.mjs +1 -0
  30. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +8 -0
  31. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +8 -0
  32. package/dist/powerlines/src/internal/helpers/resolver.cjs +1 -0
  33. package/dist/powerlines/src/internal/helpers/resolver.mjs +1 -0
  34. package/dist/powerlines/src/lib/build/esbuild.cjs +14 -0
  35. package/dist/powerlines/src/lib/build/esbuild.mjs +14 -0
  36. package/dist/powerlines/src/lib/build/vite.cjs +1 -0
  37. package/dist/powerlines/src/lib/build/vite.mjs +1 -0
  38. package/dist/powerlines/src/lib/config-file.cjs +1 -0
  39. package/dist/powerlines/src/lib/config-file.mjs +1 -0
  40. package/dist/powerlines/src/lib/contexts/api-context.cjs +1 -0
  41. package/dist/powerlines/src/lib/contexts/api-context.mjs +1 -0
  42. package/dist/powerlines/src/lib/contexts/context.cjs +1 -0
  43. package/dist/powerlines/src/lib/contexts/context.mjs +1 -0
  44. package/dist/powerlines/src/lib/contexts/environment-context.cjs +1 -0
  45. package/dist/powerlines/src/lib/contexts/environment-context.mjs +1 -0
  46. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +1 -0
  47. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +1 -0
  48. package/dist/powerlines/src/lib/entry.cjs +1 -0
  49. package/dist/powerlines/src/lib/entry.mjs +1 -0
  50. package/dist/powerlines/src/lib/fs/helpers.cjs +1 -0
  51. package/dist/powerlines/src/lib/fs/helpers.mjs +1 -0
  52. package/dist/powerlines/src/lib/fs/storage/base.cjs +1 -0
  53. package/dist/powerlines/src/lib/fs/storage/base.mjs +1 -0
  54. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +1 -0
  55. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +1 -0
  56. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +1 -0
  57. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +1 -0
  58. package/dist/powerlines/src/lib/fs/vfs.cjs +1 -0
  59. package/dist/powerlines/src/lib/fs/vfs.mjs +1 -0
  60. package/dist/powerlines/src/lib/logger.cjs +1 -0
  61. package/dist/powerlines/src/lib/logger.mjs +1 -0
  62. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +1 -0
  63. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +1 -0
  64. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +4 -0
  65. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +4 -0
  66. package/dist/powerlines/src/lib/unplugin/factory.cjs +1 -0
  67. package/dist/powerlines/src/lib/unplugin/factory.mjs +1 -0
  68. package/dist/powerlines/src/lib/unplugin/helpers.cjs +1 -0
  69. package/dist/powerlines/src/lib/unplugin/helpers.mjs +1 -0
  70. package/dist/powerlines/src/lib/unplugin/index.cjs +1 -0
  71. package/dist/powerlines/src/lib/unplugin/index.mjs +1 -0
  72. package/dist/powerlines/src/lib/unplugin/plugin.cjs +6 -0
  73. package/dist/powerlines/src/lib/unplugin/plugin.mjs +6 -0
  74. package/dist/powerlines/src/lib/utilities/file-header.cjs +10 -0
  75. package/dist/powerlines/src/lib/utilities/file-header.mjs +10 -0
  76. package/dist/powerlines/src/lib/utilities/meta.cjs +1 -0
  77. package/dist/powerlines/src/lib/utilities/meta.mjs +1 -0
  78. package/dist/powerlines/src/lib/utilities/source-file.cjs +1 -0
  79. package/dist/powerlines/src/lib/utilities/source-file.mjs +1 -0
  80. package/dist/powerlines/src/plugin-utils/helpers.cjs +1 -0
  81. package/dist/powerlines/src/plugin-utils/helpers.mjs +1 -0
  82. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
  83. package/dist/powerlines/src/plugin-utils/paths.mjs +1 -0
  84. package/dist/powerlines/src/types/babel.d.mts +4 -0
  85. package/dist/powerlines/src/types/build.d.cts +143 -0
  86. package/dist/powerlines/src/types/build.d.mts +143 -0
  87. package/dist/powerlines/src/types/commands.cjs +1 -0
  88. package/dist/powerlines/src/types/commands.d.cts +8 -0
  89. package/dist/powerlines/src/types/commands.d.mts +9 -0
  90. package/dist/powerlines/src/types/commands.mjs +1 -0
  91. package/dist/powerlines/src/types/config.d.cts +346 -0
  92. package/dist/powerlines/src/types/config.d.mts +348 -0
  93. package/dist/powerlines/src/types/context.d.cts +347 -0
  94. package/dist/powerlines/src/types/context.d.mts +349 -0
  95. package/dist/powerlines/src/types/fs.d.cts +458 -0
  96. package/dist/powerlines/src/types/fs.d.mts +458 -0
  97. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  98. package/dist/powerlines/src/types/plugin.cjs +1 -0
  99. package/dist/powerlines/src/types/plugin.d.cts +232 -0
  100. package/dist/powerlines/src/types/plugin.d.mts +232 -0
  101. package/dist/powerlines/src/types/plugin.mjs +1 -0
  102. package/dist/powerlines/src/types/resolved.d.cts +82 -0
  103. package/dist/powerlines/src/types/resolved.d.mts +82 -0
  104. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  105. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  106. package/dist/types/index.cjs +0 -1
  107. package/dist/types/index.d.cts +1 -2
  108. package/dist/types/index.d.mts +1 -2
  109. package/dist/types/index.mjs +1 -1
  110. package/dist/types/plugin.cjs +0 -1
  111. package/dist/types/plugin.d.cts +19 -1
  112. package/dist/types/plugin.d.mts +19 -1
  113. package/dist/types/plugin.mjs +1 -1
  114. package/package.json +10 -10
  115. package/dist/helpers-CRPRhztf.mjs +0 -1
  116. package/dist/helpers-LF26RHol.cjs +0 -0
  117. package/dist/index-9iG2qHLe.d.mts +0 -1
  118. package/dist/index-D4ELpJXS.d.cts +0 -1
  119. package/dist/index-D6CnpA_r.d.cts +0 -1
  120. package/dist/index-DL0uimUT.d.mts +0 -1
  121. package/dist/plugin-BjiGfRHE.mjs +0 -1
  122. package/dist/plugin-Bu9f0Vo1.d.mts +0 -1658
  123. package/dist/plugin-CeaU7BaT.d.cts +0 -1655
  124. package/dist/plugin-pBKbb5K9.cjs +0 -0
  125. package/dist/types-n6NgD0QK.mjs +0 -1
  126. package/dist/types-o3zWarRp.cjs +0 -0
  127. package/dist/unplugin-CQUvJGvc.d.mts +0 -7
  128. package/dist/unplugin-DD1hF9r3.mjs +0 -6
  129. package/dist/unplugin-DVT_2a_R.cjs +0 -44
  130. package/dist/unplugin-DtFSdCAn.d.cts +0 -7
@@ -0,0 +1 @@
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/convert/to-array`),n=require(`@stryke/helpers/get-unique`),r=require(`@stryke/type-checks/is-set-string`),i=require(`@stryke/type-checks/is-error`),a=require(`@stryke/type-checks/is-set-object`),o=require(`@stryke/path/file-path-fns`),s=require(`@stryke/path/is-type`),c=require(`@stryke/path/join`),l=require(`@stryke/path/correct-path`),u=require(`@stryke/path/slash`);function d(e){return(0,i.isError)(e)&&`code`in e&&e.code}function f(e){return d(e)&&(e.code===`ENOENT`||e.code===`EISDIR`?null:e)}function p(e){return(0,l.correctPath)((0,u.slash)(e?.toString()||`.`).replace(/^file:\/\//,``))}function m(e,t=`powerlines`){return e.replace(/^\\0/,``).startsWith(`${t.replace(/:$/,``)}`)}function h(e,t=`powerlines`){return`${t.replace(/:$/,``)}:${p(e).replace(RegExp(`^${t.replace(/:$/,``)}:`),``).replace(/^\\0/,``).replace((0,o.findFileDotExtensionSafe)(p(e)),``)}`}function g(e,t,n=`powerlines`){return(0,s.isAbsolutePath)(e)?e:m(p(e),n)?h(p(e),n).replace(RegExp(`^${n.replace(/:$/,``)}:`),t):p(e)}function _(e,i){return(0,n.getUnique)((0,t.toArray)(i).map(t=>(0,a.isSetObject)(t)&&((0,r.isSetString)(t.input)||(0,r.isSetString)(t.glob))?(0,c.joinPaths)(t.input||e,t.glob||`**/*`):(0,r.isSetString)(t)?t:void 0).filter(r.isSetString))}exports.ignoreNotfound=f,exports.normalizeGlobPatterns=_,exports.normalizeId=h,exports.normalizePath=g;
@@ -0,0 +1 @@
1
+ import{toArray as e}from"@stryke/convert/to-array";import{getUnique as t}from"@stryke/helpers/get-unique";import{isSetString as n}from"@stryke/type-checks/is-set-string";import{isError as r}from"@stryke/type-checks/is-error";import{isSetObject as i}from"@stryke/type-checks/is-set-object";import{findFileDotExtensionSafe as a}from"@stryke/path/file-path-fns";import{isAbsolutePath as o}from"@stryke/path/is-type";import{joinPaths as s}from"@stryke/path/join";import{correctPath as c}from"@stryke/path/correct-path";import{slash as l}from"@stryke/path/slash";function u(e){return r(e)&&`code`in e&&e.code}function d(e){return u(e)&&(e.code===`ENOENT`||e.code===`EISDIR`?null:e)}function f(e){return c(l(e?.toString()||`.`).replace(/^file:\/\//,``))}function p(e,t=`powerlines`){return e.replace(/^\\0/,``).startsWith(`${t.replace(/:$/,``)}`)}function m(e,t=`powerlines`){return`${t.replace(/:$/,``)}:${f(e).replace(RegExp(`^${t.replace(/:$/,``)}:`),``).replace(/^\\0/,``).replace(a(f(e)),``)}`}function h(e,t,n=`powerlines`){return o(e)?e:p(f(e),n)?m(f(e),n).replace(RegExp(`^${n.replace(/:$/,``)}:`),t):f(e)}function g(r,a){return t(e(a).map(e=>i(e)&&(n(e.input)||n(e.glob))?s(e.input||r,e.glob||`**/*`):n(e)?e:void 0).filter(n))}export{d as ignoreNotfound,g as normalizeGlobPatterns,m as normalizeId,h as normalizePath};
@@ -0,0 +1 @@
1
+ const e=require(`../../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/append`),n=require(`@stryke/path/join`),r=require(`@stryke/path/correct-path`),i=require(`node:path`);var a=class{#e=!1;options;constructor(e={base:`/`}){this.options=e,this.options.base=(0,i.resolve)(e.base),this.options.isReadOnly=!!e.isReadOnly}async exists(e){return this.existsSync(e)}async get(e){return this.getSync(e)}async set(e,t){this.options.isReadOnly||this.setSync(e,t)}mkdirSync(e){}async mkdir(e){return Promise.resolve(this.mkdirSync(e))}async remove(e){this.options.isReadOnly||this.removeSync(e)}clearSync(e){if(!this.options.isReadOnly){let t=this.listSync(e||this.options.base);if(!t.length)return;t.map(t=>this.removeSync(e&&!t.startsWith(e)?(0,n.joinPaths)(e,t):t))}}async clear(e){if(!this.options.isReadOnly){let t=await this.list(e||this.options.base);if(!t.length)return;await Promise.all(t.map(async t=>this.remove(e&&!t.startsWith(e)?(0,n.joinPaths)(e,t):t)))}}async list(e){return this.listSync(e)}isDirectorySync(e){return!1}async isDirectory(e){return Promise.resolve(this.isDirectorySync(e))}isFileSync(e){return this.existsSync(e)&&!this.isDirectorySync(e)}async isFile(e){return Promise.resolve(this.isFileSync(e))}dispose(){return Promise.resolve()}async[Symbol.asyncDispose](){return this._dispose()}resolve(e=this.options.base){if(/\.\.:|\.\.$/.test(e))throw Error(`[${this.name}]: Invalid key: ${JSON.stringify(e)} provided to storage adapter.`);return(0,t.appendPath)((0,r.correctPath)(e).replace(/:/g,`/`),this.options.base)}async _dispose(){this.#e||=(await Promise.resolve(this.dispose()),!0)}};exports.BaseStorageAdapter=a;
@@ -0,0 +1 @@
1
+ import{appendPath as e}from"@stryke/path/append";import{joinPaths as t}from"@stryke/path/join";import{correctPath as n}from"@stryke/path/correct-path";import{resolve as r}from"node:path";var i=class{#e=!1;options;constructor(e={base:`/`}){this.options=e,this.options.base=r(e.base),this.options.isReadOnly=!!e.isReadOnly}async exists(e){return this.existsSync(e)}async get(e){return this.getSync(e)}async set(e,t){this.options.isReadOnly||this.setSync(e,t)}mkdirSync(e){}async mkdir(e){return Promise.resolve(this.mkdirSync(e))}async remove(e){this.options.isReadOnly||this.removeSync(e)}clearSync(e){if(!this.options.isReadOnly){let n=this.listSync(e||this.options.base);if(!n.length)return;n.map(n=>this.removeSync(e&&!n.startsWith(e)?t(e,n):n))}}async clear(e){if(!this.options.isReadOnly){let n=await this.list(e||this.options.base);if(!n.length)return;await Promise.all(n.map(async n=>this.remove(e&&!n.startsWith(e)?t(e,n):n)))}}async list(e){return this.listSync(e)}isDirectorySync(e){return!1}async isDirectory(e){return Promise.resolve(this.isDirectorySync(e))}isFileSync(e){return this.existsSync(e)&&!this.isDirectorySync(e)}async isFile(e){return Promise.resolve(this.isFileSync(e))}dispose(){return Promise.resolve()}async[Symbol.asyncDispose](){return this._dispose()}resolve(t=this.options.base){if(/\.\.:|\.\.$/.test(t))throw Error(`[${this.name}]: Invalid key: ${JSON.stringify(t)} provided to storage adapter.`);return e(n(t).replace(/:/g,`/`),this.options.base)}async _dispose(){this.#e||=(await Promise.resolve(this.dispose()),!0)}};export{i as BaseStorageAdapter};
@@ -0,0 +1 @@
1
+ const e=require(`../../../../../_virtual/rolldown_runtime.cjs`),t=require(`../helpers.cjs`),n=require(`./base.cjs`);let r=require(`@stryke/fs/is-file`),i=require(`@stryke/fs/list-files`),a=require(`@stryke/fs/helpers`),o=require(`@stryke/fs/exists`),s=require(`@stryke/fs/read-file`),c=require(`@stryke/fs/write-file`),l=require(`node:fs`),u=require(`node:fs/promises`);var d=class extends n.BaseStorageAdapter{name=`file-system`;constructor(e){super(e)}existsSync(e){return(0,o.existsSync)(this.resolve(e))}async exists(e){return(0,o.exists)(this.resolve(e))}getSync(e){return(0,s.readFileSync)(this.resolve(e))}async get(e){return(0,s.readFile)(this.resolve(e))}setSync(e,t){if(!this.options.isReadOnly)return(0,c.writeFileSync)(this.resolve(e),t)}async set(e,t){if(!this.options.isReadOnly)return(0,c.writeFile)(this.resolve(e),t)}removeSync(e){if(!this.options.isReadOnly)try{return(0,l.unlinkSync)(this.resolve(e))}catch(e){return t.ignoreNotfound(e)}}async remove(e){if(!this.options.isReadOnly)return(0,u.unlink)(this.resolve(e)).catch(t.ignoreNotfound)}mkdirSync(e){(0,a.createDirectorySync)(this.resolve(e))}async mkdir(e){await(0,a.createDirectory)(this.resolve(e))}listSync(e){try{return(0,i.listFilesSync)(this.resolve(e),{ignore:this.options.ignore})}catch(e){return t.ignoreNotfound(e)??[]}}async list(e){return(0,i.listFiles)(this.resolve(e),{ignore:this.options.ignore}).catch(t.ignoreNotfound).then(e=>e||[])}isDirectorySync(e){return(0,r.isDirectory)(this.resolve(e))}isFileSync(e){return!(0,r.isFile)(this.resolve(e))}};exports.FileSystemStorageAdapter=d;
@@ -0,0 +1 @@
1
+ import{ignoreNotfound as e}from"../helpers.mjs";import{BaseStorageAdapter as t}from"./base.mjs";import{isDirectory as n,isFile as r}from"@stryke/fs/is-file";import{listFiles as i,listFilesSync as a}from"@stryke/fs/list-files";import{createDirectory as o,createDirectorySync as s}from"@stryke/fs/helpers";import{exists as c,existsSync as l}from"@stryke/fs/exists";import{readFile as u,readFileSync as d}from"@stryke/fs/read-file";import{writeFile as f,writeFileSync as p}from"@stryke/fs/write-file";import{unlinkSync as m}from"node:fs";import{unlink as h}from"node:fs/promises";var g=class extends t{name=`file-system`;constructor(e){super(e)}existsSync(e){return l(this.resolve(e))}async exists(e){return c(this.resolve(e))}getSync(e){return d(this.resolve(e))}async get(e){return u(this.resolve(e))}setSync(e,t){if(!this.options.isReadOnly)return p(this.resolve(e),t)}async set(e,t){if(!this.options.isReadOnly)return f(this.resolve(e),t)}removeSync(t){if(!this.options.isReadOnly)try{return m(this.resolve(t))}catch(t){return e(t)}}async remove(t){if(!this.options.isReadOnly)return h(this.resolve(t)).catch(e)}mkdirSync(e){s(this.resolve(e))}async mkdir(e){await o(this.resolve(e))}listSync(t){try{return a(this.resolve(t),{ignore:this.options.ignore})}catch(t){return e(t)??[]}}async list(t){return i(this.resolve(t),{ignore:this.options.ignore}).catch(e).then(e=>e||[])}isDirectorySync(e){return n(this.resolve(e))}isFileSync(e){return!r(this.resolve(e))}};export{g as FileSystemStorageAdapter};
@@ -0,0 +1 @@
1
+ const e=require(`../../../../../_virtual/rolldown_runtime.cjs`),t=require(`./base.cjs`);let n=require(`@stryke/path/is-parent-path`);var r=class extends t.BaseStorageAdapter{name=`virtual`;data=new Map;constructor(e){super(e)}existsSync(e){return this.data.has(this.resolve(e))}getSync(e){return this.data.get(this.resolve(e))??null}setSync(e,t){this.options.isReadOnly||this.data.set(this.resolve(e),t)}removeSync(e){this.options.isReadOnly||this.data.delete(this.resolve(e))}listSync(e){return[...this.data.keys().filter(t=>e?(0,n.isParentPath)(t,this.resolve(e)):!0)]}async dispose(){return this.clear()}};exports.VirtualStorageAdapter=r;
@@ -0,0 +1 @@
1
+ import{BaseStorageAdapter as e}from"./base.mjs";import{isParentPath as t}from"@stryke/path/is-parent-path";var n=class extends e{name=`virtual`;data=new Map;constructor(e){super(e)}existsSync(e){return this.data.has(this.resolve(e))}getSync(e){return this.data.get(this.resolve(e))??null}setSync(e,t){this.options.isReadOnly||this.data.set(this.resolve(e),t)}removeSync(e){this.options.isReadOnly||this.data.delete(this.resolve(e))}listSync(e){return[...this.data.keys().filter(n=>e?t(n,this.resolve(e)):!0)]}async dispose(){return this.clear()}};export{n as VirtualStorageAdapter};
@@ -0,0 +1 @@
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../../plugin-utils/paths.cjs`),n=require(`../../../schemas/fs.cjs`),r=require(`../logger.cjs`),i=require(`./helpers.cjs`),a=require(`./storage/file-system.cjs`),o=require(`./storage/virtual.cjs`);let s=require(`@storm-software/config-tools/types`),c=require(`@stryke/path/join-paths`),l=require(`@stryke/path/replace`),u=require(`@stryke/type-checks/is-string`),d=require(`@stryke/convert/to-array`),f=require(`@stryke/hash/murmurhash`),p=require(`@stryke/helpers/get-unique`),m=require(`@stryke/path/append`),h=require(`@stryke/type-checks/is-set-string`),g=require(`@stryke/fs/resolve`),_=require(`@stryke/type-checks/is-set-object`),v=require(`@stryke/path/file-path-fns`),y=require(`@stryke/fs/exists`),b=require(`@stryke/path/is-type`),x=require(`flat-cache`),S=require(`@stryke/capnp`);S=e.__toESM(S);let C=require(`@stryke/fs/buffer`),w=require(`@stryke/path/is-parent-path`),T=require(`@stryke/string-format/pretty-bytes`),E=require(`node:buffer`),D=require(`node:url`),O=require(`prettier`);var k=class e{#e;#t;#n;#r={"":new a.FileSystemStorageAdapter};#i;#a=!1;#o;#s;#c(e){let t=e;return(0,w.isParentPath)(t,this.#o.builtinsPath)&&(t=(0,l.replacePath)(t,this.#o.builtinsPath)),i.normalizeId(t,this.#o.config.output.builtinPrefix)}#l(e){return i.normalizePath(e.includes(`{`)||e.includes(`}`)?t.replacePathTokens(this.#o,e):e,this.#o.builtinsPath,this.#o.config.output.builtinPrefix)}#u(e){let t=`::GLOBSTAR::`;return RegExp(`^${this.#l(e).replace(/\*\*/g,t).replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`).replace(/\?/g,`[^/]`).replace(new RegExp(t,`g`),`.*`)}$`)}#d(e){let t=this.resolveSync(this.#l(e))||e;for(let e of Object.keys(this.#r).filter(Boolean).sort().reverse())if((0,w.isParentPath)(t,e))return{base:e,relativeKey:(0,l.replacePath)(t,e),adapter:this.#r[e]};return{base:``,relativeKey:t,adapter:this.#r[``]}}#f(e=``,t=!1){return Object.keys(this.#r).sort().reverse().filter(n=>(0,w.isParentPath)(n,e)||t&&(0,w.isParentPath)(e,n)).map(t=>({relativeBase:e.length>t.length?e.slice(t.length):void 0,base:t,adapter:this.#r[t]}))}static async create(t){if(!t.config.skipCache&&(0,y.existsSync)((0,c.joinPaths)(t.dataPath,`fs.bin`))){let r=await(0,C.readFileBuffer)((0,c.joinPaths)(t.dataPath,`fs.bin`)),i=new S.Message(r,!1).getRoot(n.FileSystem),a=new e(t,i);i._hasStorage()&&i.storage.length>0&&await Promise.all(i.storage.values().map(async e=>{await a.write(e.path,e.code)}))}return new e(t,new S.Message().initRoot(n.FileSystem))}static createSync(t){if(!t.config.skipCache&&(0,y.existsSync)((0,c.joinPaths)(t.dataPath,`fs.bin`))){let r=(0,C.readFileBufferSync)((0,c.joinPaths)(t.dataPath,`fs.bin`)),i=new S.Message(r,!1).getRoot(n.FileSystem),a=new e(t,i);i._hasStorage()&&i.storage.length>0&&i.storage.values().map(e=>{a.writeSync(e.path,e.code)})}return new e(t,new S.Message().initRoot(n.FileSystem))}get metadata(){return new Proxy(this.#e,{get:(e,t)=>e[this.#c(t)]})}get ids(){return new Proxy(this.#n,{get:(e,t)=>e[this.#l(t)]})}get paths(){return new Proxy(this.#n,{get:(e,t)=>e[this.#c(t)]})}get resolverCache(){return this.#i||=(0,x.create)({cacheId:`module-resolution`,cacheDir:this.#o.cachePath,ttl:3600*1e3,lruSize:5e3,persistInterval:100}),this.#i}constructor(e,t){this.#o=e,(0,_.isSetObject)(this.#o.config.output.storage)&&(this.#r={...this.#r,...this.#o.config.output.storage}),this.#r.virtual??=new o.VirtualStorageAdapter({base:`/_virtual`}),this.#o.config.output.storage!==`fs`&&(this.#r[this.#o.artifactsPath]??=new o.VirtualStorageAdapter({base:this.#o.artifactsPath}),this.#r[this.#o.builtinsPath]??=new o.VirtualStorageAdapter({base:this.#o.builtinsPath}),this.#r[this.#o.entryPath]??=new o.VirtualStorageAdapter({base:this.#o.entryPath})),this.#e={},t._hasMetadata()&&(this.#e=t.metadata.values().reduce((e,t)=>(e[t.id]={id:t.id,type:t.type,timestamp:t.timestamp||Date.now(),properties:t._hasProperties()?t.properties.values().reduce((e,t)=>(e[t.key]=t.value,e),{}):{}},e),{})),this.#t={},this.#n={},t._hasIds()&&(this.#t=t.ids.values().reduce((e,t)=>(e[t.path]??=t.id,e),{}),this.#n=t.ids.values().reduce((e,t)=>(e[t.id]??=t.path,e),{})),this.#s=r.extendLog(this.#o.log,`file-system`)}async exists(e){let{relativeKey:t,adapter:n}=this.#d(e);return n.exists(t)}existsSync(e){let{relativeKey:t,adapter:n}=this.#d(e);return n.existsSync(t)}isVirtual(e){let t=this.resolveSync(e);return t?this.#d(t)?.adapter?.name===`virtual`:!1}isDirectorySync(e){let t=this.resolveSync(e);return t?!!(this.existsSync(t)&&this.#d(t)?.adapter?.isDirectorySync(t)):!1}async isDirectory(e){let t=await this.resolve(e);return t?!!(await this.exists(t)&&await this.#d(t)?.adapter?.isDirectory(t)):!1}isFileSync(e){let t=this.resolveSync(e);return t?this.#d(t)?.adapter?.isFileSync(t)??!1:!1}async isFile(e){let t=await this.resolve(e);return t?await this.#d(t)?.adapter?.isFile(t)??!1:!1}listSync(e){return(0,p.getUnique)(this.#f(e,!0).map(e=>e.adapter.listSync(e.relativeBase?e.base?(0,m.appendPath)(e.relativeBase,e.base):e.relativeBase:e.base)).flat())}async list(e){return(0,p.getUnique)((await Promise.all(this.#f(e,!0).map(async e=>e.adapter.list(e.relativeBase?e.base?(0,m.appendPath)(e.relativeBase,e.base):e.relativeBase:e.base)))).flat())}async remove(e){let t=this.#l(e);this.#s(s.LogLevelLabel.TRACE,`Removing file: ${t}`);let{relativeKey:n,adapter:r}=this.#d(t);(0,v.hasFileExtension)(t)?await r.remove(n):await r.clear(n);let i=this.#t[t];i&&this.#e[i]&&(delete this.#e[i],delete this.#t[t],delete this.#n[i])}removeSync(e){let t=this.#l(e);this.#s(s.LogLevelLabel.TRACE,`Removing file: ${t}`);let{relativeKey:n,adapter:r}=this.#d(t);(0,v.hasFileExtension)(t)?r.removeSync(n):r.clearSync(n);let i=this.#t[t];i&&this.#e[i]&&(delete this.#e[i],delete this.#t[t],delete this.#n[i])}async glob(e){let t=[];for(let n of i.normalizeGlobPatterns(this.#o.workspaceConfig.workspaceRoot,e)){let e=this.#l(n);if(!/[*?[\]{}]/.test(e)&&!e.includes(`**`)){if(this.isDirectorySync(e))t.push(...await this.list(e));else{let n=await this.resolve(e);n&&!t.includes(n)&&t.push(n)}continue}let r=(0,b.isAbsolutePath)(e)?e:this.#l((0,c.joinPaths)(this.#o.workspaceConfig.workspaceRoot,e)),i=r.search(/[*?[\]{}]/),a=i===-1?(0,v.findFilePath)(r):r.slice(0,Math.max(0,r.lastIndexOf(`/`,i)));await Promise.all((await this.list(a&&(0,b.isAbsolutePath)(a)?a:this.#o.workspaceConfig.workspaceRoot)).map(async e=>{if(this.#u(r).test(e)){let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}}))}return t}globSync(e){let t=[];for(let n of i.normalizeGlobPatterns(this.#o.workspaceConfig.workspaceRoot,e)){let e=this.#l(n);if(!/[*?[\]{}]/.test(e)&&!e.includes(`**`)){if(this.isDirectorySync(e))t.push(...this.listSync(e));else{let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}continue}let r=(0,b.isAbsolutePath)(e)?e:this.#l((0,c.joinPaths)(this.#o.workspaceConfig.workspaceRoot,e)),i=r.search(/[*?[\]{}]/),a=i===-1?(0,v.findFilePath)(r):r.slice(0,Math.max(0,r.lastIndexOf(`/`,i))),o=this.listSync(a&&(0,b.isAbsolutePath)(a)?a:this.#o.workspaceConfig.workspaceRoot);for(let e of o)if(this.#u(r).test(e)){let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}}return t}async copy(e,t){let n=e instanceof URL?(0,D.fileURLToPath)(e):e,r=t instanceof URL?(0,D.fileURLToPath)(t):t;if(!(0,h.isSetString)(n)&&(!(0,_.isSetObject)(n)||!(0,h.isSetString)(n.input))||!(0,h.isSetString)(r))return;let i=(0,u.isString)(n)?n:n.input?n.input:this.#o.workspaceConfig.workspaceRoot,a=await this.resolve(i);if(a)if(this.isDirectorySync(a)||(0,h.isSetString)(n)&&n.includes(`*`)||(0,_.isSetObject)(n)&&(0,h.isSetString)(n.glob))await Promise.all((await this.glob(n)).map(async e=>this.copy(e,(0,m.appendPath)((0,l.replacePath)(e,i),r))));else{let e=await this.read(a);e!==void 0&&await this.write(this.#l(r),e,{skipFormat:!0})}}copySync(e,t){let n=e instanceof URL?(0,D.fileURLToPath)(e):e,r=t instanceof URL?(0,D.fileURLToPath)(t):t;if(!(0,h.isSetString)(n)&&(!(0,_.isSetObject)(n)||!(0,h.isSetString)(n.input))||!(0,h.isSetString)(r))return;let i=(0,u.isString)(n)?n:n.input?n.input:this.#o.workspaceConfig.workspaceRoot,a=this.resolveSync(i);if(a)if(this.isDirectorySync(a)||(0,h.isSetString)(n)&&n.includes(`*`)||(0,_.isSetObject)(n)&&(0,h.isSetString)(n.glob))this.globSync(n).map(e=>this.copySync(e,(0,m.appendPath)((0,v.findFilePath)((0,l.replacePath)(e,i)),r)));else{let e=this.readSync(a);e!==void 0&&this.writeSync(this.#l((0,v.hasFileExtension)(r)?r:(0,m.appendPath)((0,v.findFileName)(a),r)),e,{skipFormat:!0})}}async move(e,t){(0,v.hasFileExtension)(e)?(await this.copy(e,t),await this.remove(e)):await Promise.all((await this.list(e)).map(async e=>{await this.copy(e,t),await this.remove(e)}))}moveSync(e,t){(0,v.hasFileExtension)(e)?(this.copySync(e,t),this.removeSync(e)):this.listSync(e).forEach(e=>{this.copySync(e,t),this.removeSync(e)})}async read(e){let t=await this.resolve(e);if(!t)return;let{relativeKey:n,adapter:r}=this.#d(t);return this.#s(s.LogLevelLabel.TRACE,`Reading ${r.name} file: ${t}`),await r.get(n)??void 0}readSync(e){let t=this.resolveSync(e);if(!t)return;let{relativeKey:n,adapter:r}=this.#d(t);return this.#s(s.LogLevelLabel.TRACE,`Reading ${r.name} file: ${t}`),r.getSync(n)??void 0}async write(e,t=``,n={}){let r=t;if(!n.skipFormat){let n=await(0,O.resolveConfig)(this.#l(e));n&&(r=await(0,O.format)(t,{absolutePath:this.#l(e),...n}))}let{relativeKey:i,adapter:a}=this.#d(e);this.#s(s.LogLevelLabel.TRACE,`Writing ${this.#l(i)} to ${a.name===`virtual`?`the virtual file system`:a.name===`file-system`?`the local file system`:a.name} (size: ${(0,T.prettyBytes)(new E.Blob((0,d.toArray)(r)).size)})`);let o=n?.meta?.id||this.#c(i);return this.#e[o]={variant:`normal`,timestamp:Date.now(),...n.meta??{}},this.#n[o]=this.#l(i),this.#t[this.#l(i)]=o,a.set(i,r)}writeSync(e,t=``,n={}){let{relativeKey:r,adapter:i}=this.#d(e);this.#s(s.LogLevelLabel.TRACE,`Writing ${this.#l(r)} file to ${i.name===`virtual`?`the virtual file system`:i.name===`file-system`?`the local file system`:i.name} (size: ${(0,T.prettyBytes)(new E.Blob((0,d.toArray)(t)).size)})`);let a=n?.meta?.id||this.#c(r);return this.#e[a]={variant:`normal`,timestamp:Date.now(),...n.meta??{}},this.#n[a]=this.#l(r),this.#t[this.#l(r)]=a,i.setSync(r,t)}mkdirSync(e){return this.#d(e)?.adapter?.mkdirSync(e)}async mkdir(e){return this.#d(e)?.adapter?.mkdir(e)}getMetadata(e){let t=this.resolveSync(e);if(t&&this.metadata[t])return this.metadata[t]}async resolve(e,n,r={}){let i=e;if((i.includes(`{`)||i.includes(`}`))&&(i=t.replacePathTokens(this.#o,i)),(0,b.isAbsolutePath)(i))return i;let a=(0,f.murmurhash)({path:this.#c(i),importer:n,options:r}),o;if(!this.#o.config.skipCache&&(o=this.resolverCache.get(a),o))return o;if(o=this.paths[this.#c(i)],!o){let e=r.paths??[];n&&!e.includes(n)&&e.push(n),e.push(this.#o.workspaceConfig.workspaceRoot),e.push((0,m.appendPath)(this.#o.config.projectRoot,this.#o.workspaceConfig.workspaceRoot)),e.push((0,m.appendPath)(this.#o.config.sourceRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(...Object.keys(this.#o.tsconfig?.options?.paths??{}).filter(e=>i.startsWith(e.replace(/\*$/,``))).map(e=>this.#o.tsconfig?.options?.paths?.[e]).flat().filter(Boolean).map(e=>(0,m.appendPath)(e,this.#o.workspaceConfig.workspaceRoot)));for(let t of(0,g.getResolutionCombinations)(i,{paths:e})){let{relativeKey:e,adapter:n}=this.#d(t);if(await n.exists(e)){o=t;break}}if(!o)try{o=await(0,g.resolve)(i,{...r,paths:e})}catch{}}return o&&!this.#o.config.skipCache&&this.resolverCache.set(a,o),o}resolveSync(e,n,r={}){let i=e;if((i.includes(`{`)||i.includes(`}`))&&(i=t.replacePathTokens(this.#o,i)),(0,b.isAbsolutePath)(i))return i;let a;if(!this.#o.config.skipCache&&(a=this.resolverCache.get(this.#c(i)),a))return a;if(a=this.paths[this.#c(i)],!a){let e=r.paths??[];n&&!e.includes(n)&&e.push(n),e.push(this.#o.workspaceConfig.workspaceRoot),e.push((0,m.appendPath)(this.#o.config.projectRoot,this.#o.workspaceConfig.workspaceRoot)),e.push((0,m.appendPath)(this.#o.config.sourceRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(...Object.keys(this.#o.tsconfig?.options?.paths??{}).filter(e=>i.startsWith(e.replace(/\*$/,``))).map(e=>this.#o.tsconfig?.options?.paths?.[e]).flat().filter(Boolean).map(e=>(0,m.appendPath)(e,this.#o.workspaceConfig.workspaceRoot)));for(let t of(0,g.getResolutionCombinations)(i,{paths:e})){let{relativeKey:e,adapter:n}=this.#d(t);if(n.existsSync(e)){a=t;break}}if(!a)try{a=(0,g.resolveSync)(i,{...r,paths:e})}catch{}}return a&&!this.#o.config.skipCache&&this.resolverCache.set(this.#c(i),a),a}async dispose(){if(!this.#a){this.#a=!0,this.#s(s.LogLevelLabel.DEBUG,`Disposing virtual file system...`),await this.remove((0,c.joinPaths)(this.#o.dataPath,`fs.bin`));let e=new S.Message,t=e.initRoot(n.FileSystem),r=await this.list(),i=t._initStorage(r.length);await Promise.all(r.map(async(e,t)=>{let n=await this.read(e),r=i.get(t);r.path=e,r.code=n||``}));let a=t._initIds(Object.keys(this.ids).length);Object.entries(this.ids).filter(([,e])=>e).forEach(([e,t],n)=>{let r=a.get(n);r.id=e,r.path=t});let o=t._initMetadata(Object.keys(this.metadata).length);Object.entries(this.metadata).filter(([,e])=>e).forEach(([e,t],n)=>{let r=o.get(n);if(r.id=e,r.type=t.type,r.timestamp=t.timestamp??BigInt(Date.now()),t.properties){let e=r._initProperties(Object.keys(t.properties).length);Object.entries(t.properties).forEach(([t,n],r)=>{let i=e.get(r);i.key=t,i.value=n})}}),await(0,C.writeFileBuffer)((0,c.joinPaths)(this.#o.dataPath,`fs.bin`),e.toArrayBuffer()),this.#o.config.skipCache||this.#i.save(!0),await Promise.all(this.#f().map(async e=>e.adapter.dispose())),this.#s(s.LogLevelLabel.TRACE,`Virtual file system has been disposed.`)}}async[Symbol.asyncDispose](){return this.dispose()}};exports.VirtualFileSystem=k;
@@ -0,0 +1 @@
1
+ import{replacePathTokens as e}from"../../plugin-utils/paths.mjs";import{FileSystem as t}from"../../../schemas/fs.mjs";import{extendLog as n}from"../logger.mjs";import{normalizeGlobPatterns as r,normalizeId as i,normalizePath as a}from"./helpers.mjs";import{FileSystemStorageAdapter as o}from"./storage/file-system.mjs";import{VirtualStorageAdapter as s}from"./storage/virtual.mjs";import{LogLevelLabel as c}from"@storm-software/config-tools/types";import{joinPaths as l}from"@stryke/path/join-paths";import{replacePath as u}from"@stryke/path/replace";import{isString as d}from"@stryke/type-checks/is-string";import{toArray as f}from"@stryke/convert/to-array";import{murmurhash as p}from"@stryke/hash/murmurhash";import{getUnique as m}from"@stryke/helpers/get-unique";import{appendPath as h}from"@stryke/path/append";import{isSetString as g}from"@stryke/type-checks/is-set-string";import{getResolutionCombinations as _,resolve as v,resolveSync as y}from"@stryke/fs/resolve";import{isSetObject as b}from"@stryke/type-checks/is-set-object";import{findFileName as x,findFilePath as S,hasFileExtension as C}from"@stryke/path/file-path-fns";import{existsSync as w}from"@stryke/fs/exists";import{isAbsolutePath as T}from"@stryke/path/is-type";import{create as E}from"flat-cache";import*as D from"@stryke/capnp";import{readFileBuffer as O,readFileBufferSync as k,writeFileBuffer as A}from"@stryke/fs/buffer";import{isParentPath as j}from"@stryke/path/is-parent-path";import{prettyBytes as M}from"@stryke/string-format/pretty-bytes";import{Blob as N}from"node:buffer";import{fileURLToPath as P}from"node:url";import{format as F,resolveConfig as I}from"prettier";var L=class L{#e;#t;#n;#r={"":new o};#i;#a=!1;#o;#s;#c(e){let t=e;return j(t,this.#o.builtinsPath)&&(t=u(t,this.#o.builtinsPath)),i(t,this.#o.config.output.builtinPrefix)}#l(t){return a(t.includes(`{`)||t.includes(`}`)?e(this.#o,t):t,this.#o.builtinsPath,this.#o.config.output.builtinPrefix)}#u(e){let t=`::GLOBSTAR::`;return RegExp(`^${this.#l(e).replace(/\*\*/g,t).replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`).replace(/\?/g,`[^/]`).replace(new RegExp(t,`g`),`.*`)}$`)}#d(e){let t=this.resolveSync(this.#l(e))||e;for(let e of Object.keys(this.#r).filter(Boolean).sort().reverse())if(j(t,e))return{base:e,relativeKey:u(t,e),adapter:this.#r[e]};return{base:``,relativeKey:t,adapter:this.#r[``]}}#f(e=``,t=!1){return Object.keys(this.#r).sort().reverse().filter(n=>j(n,e)||t&&j(e,n)).map(t=>({relativeBase:e.length>t.length?e.slice(t.length):void 0,base:t,adapter:this.#r[t]}))}static async create(e){if(!e.config.skipCache&&w(l(e.dataPath,`fs.bin`))){let n=await O(l(e.dataPath,`fs.bin`)),r=new D.Message(n,!1).getRoot(t),i=new L(e,r);r._hasStorage()&&r.storage.length>0&&await Promise.all(r.storage.values().map(async e=>{await i.write(e.path,e.code)}))}return new L(e,new D.Message().initRoot(t))}static createSync(e){if(!e.config.skipCache&&w(l(e.dataPath,`fs.bin`))){let n=k(l(e.dataPath,`fs.bin`)),r=new D.Message(n,!1).getRoot(t),i=new L(e,r);r._hasStorage()&&r.storage.length>0&&r.storage.values().map(e=>{i.writeSync(e.path,e.code)})}return new L(e,new D.Message().initRoot(t))}get metadata(){return new Proxy(this.#e,{get:(e,t)=>e[this.#c(t)]})}get ids(){return new Proxy(this.#n,{get:(e,t)=>e[this.#l(t)]})}get paths(){return new Proxy(this.#n,{get:(e,t)=>e[this.#c(t)]})}get resolverCache(){return this.#i||=E({cacheId:`module-resolution`,cacheDir:this.#o.cachePath,ttl:3600*1e3,lruSize:5e3,persistInterval:100}),this.#i}constructor(e,t){this.#o=e,b(this.#o.config.output.storage)&&(this.#r={...this.#r,...this.#o.config.output.storage}),this.#r.virtual??=new s({base:`/_virtual`}),this.#o.config.output.storage!==`fs`&&(this.#r[this.#o.artifactsPath]??=new s({base:this.#o.artifactsPath}),this.#r[this.#o.builtinsPath]??=new s({base:this.#o.builtinsPath}),this.#r[this.#o.entryPath]??=new s({base:this.#o.entryPath})),this.#e={},t._hasMetadata()&&(this.#e=t.metadata.values().reduce((e,t)=>(e[t.id]={id:t.id,type:t.type,timestamp:t.timestamp||Date.now(),properties:t._hasProperties()?t.properties.values().reduce((e,t)=>(e[t.key]=t.value,e),{}):{}},e),{})),this.#t={},this.#n={},t._hasIds()&&(this.#t=t.ids.values().reduce((e,t)=>(e[t.path]??=t.id,e),{}),this.#n=t.ids.values().reduce((e,t)=>(e[t.id]??=t.path,e),{})),this.#s=n(this.#o.log,`file-system`)}async exists(e){let{relativeKey:t,adapter:n}=this.#d(e);return n.exists(t)}existsSync(e){let{relativeKey:t,adapter:n}=this.#d(e);return n.existsSync(t)}isVirtual(e){let t=this.resolveSync(e);return t?this.#d(t)?.adapter?.name===`virtual`:!1}isDirectorySync(e){let t=this.resolveSync(e);return t?!!(this.existsSync(t)&&this.#d(t)?.adapter?.isDirectorySync(t)):!1}async isDirectory(e){let t=await this.resolve(e);return t?!!(await this.exists(t)&&await this.#d(t)?.adapter?.isDirectory(t)):!1}isFileSync(e){let t=this.resolveSync(e);return t?this.#d(t)?.adapter?.isFileSync(t)??!1:!1}async isFile(e){let t=await this.resolve(e);return t?await this.#d(t)?.adapter?.isFile(t)??!1:!1}listSync(e){return m(this.#f(e,!0).map(e=>e.adapter.listSync(e.relativeBase?e.base?h(e.relativeBase,e.base):e.relativeBase:e.base)).flat())}async list(e){return m((await Promise.all(this.#f(e,!0).map(async e=>e.adapter.list(e.relativeBase?e.base?h(e.relativeBase,e.base):e.relativeBase:e.base)))).flat())}async remove(e){let t=this.#l(e);this.#s(c.TRACE,`Removing file: ${t}`);let{relativeKey:n,adapter:r}=this.#d(t);C(t)?await r.remove(n):await r.clear(n);let i=this.#t[t];i&&this.#e[i]&&(delete this.#e[i],delete this.#t[t],delete this.#n[i])}removeSync(e){let t=this.#l(e);this.#s(c.TRACE,`Removing file: ${t}`);let{relativeKey:n,adapter:r}=this.#d(t);C(t)?r.removeSync(n):r.clearSync(n);let i=this.#t[t];i&&this.#e[i]&&(delete this.#e[i],delete this.#t[t],delete this.#n[i])}async glob(e){let t=[];for(let n of r(this.#o.workspaceConfig.workspaceRoot,e)){let e=this.#l(n);if(!/[*?[\]{}]/.test(e)&&!e.includes(`**`)){if(this.isDirectorySync(e))t.push(...await this.list(e));else{let n=await this.resolve(e);n&&!t.includes(n)&&t.push(n)}continue}let r=T(e)?e:this.#l(l(this.#o.workspaceConfig.workspaceRoot,e)),i=r.search(/[*?[\]{}]/),a=i===-1?S(r):r.slice(0,Math.max(0,r.lastIndexOf(`/`,i)));await Promise.all((await this.list(a&&T(a)?a:this.#o.workspaceConfig.workspaceRoot)).map(async e=>{if(this.#u(r).test(e)){let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}}))}return t}globSync(e){let t=[];for(let n of r(this.#o.workspaceConfig.workspaceRoot,e)){let e=this.#l(n);if(!/[*?[\]{}]/.test(e)&&!e.includes(`**`)){if(this.isDirectorySync(e))t.push(...this.listSync(e));else{let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}continue}let r=T(e)?e:this.#l(l(this.#o.workspaceConfig.workspaceRoot,e)),i=r.search(/[*?[\]{}]/),a=i===-1?S(r):r.slice(0,Math.max(0,r.lastIndexOf(`/`,i))),o=this.listSync(a&&T(a)?a:this.#o.workspaceConfig.workspaceRoot);for(let e of o)if(this.#u(r).test(e)){let n=this.resolveSync(e);n&&!t.includes(n)&&t.push(n)}}return t}async copy(e,t){let n=e instanceof URL?P(e):e,r=t instanceof URL?P(t):t;if(!g(n)&&(!b(n)||!g(n.input))||!g(r))return;let i=d(n)?n:n.input?n.input:this.#o.workspaceConfig.workspaceRoot,a=await this.resolve(i);if(a)if(this.isDirectorySync(a)||g(n)&&n.includes(`*`)||b(n)&&g(n.glob))await Promise.all((await this.glob(n)).map(async e=>this.copy(e,h(u(e,i),r))));else{let e=await this.read(a);e!==void 0&&await this.write(this.#l(r),e,{skipFormat:!0})}}copySync(e,t){let n=e instanceof URL?P(e):e,r=t instanceof URL?P(t):t;if(!g(n)&&(!b(n)||!g(n.input))||!g(r))return;let i=d(n)?n:n.input?n.input:this.#o.workspaceConfig.workspaceRoot,a=this.resolveSync(i);if(a)if(this.isDirectorySync(a)||g(n)&&n.includes(`*`)||b(n)&&g(n.glob))this.globSync(n).map(e=>this.copySync(e,h(S(u(e,i)),r)));else{let e=this.readSync(a);e!==void 0&&this.writeSync(this.#l(C(r)?r:h(x(a),r)),e,{skipFormat:!0})}}async move(e,t){C(e)?(await this.copy(e,t),await this.remove(e)):await Promise.all((await this.list(e)).map(async e=>{await this.copy(e,t),await this.remove(e)}))}moveSync(e,t){C(e)?(this.copySync(e,t),this.removeSync(e)):this.listSync(e).forEach(e=>{this.copySync(e,t),this.removeSync(e)})}async read(e){let t=await this.resolve(e);if(!t)return;let{relativeKey:n,adapter:r}=this.#d(t);return this.#s(c.TRACE,`Reading ${r.name} file: ${t}`),await r.get(n)??void 0}readSync(e){let t=this.resolveSync(e);if(!t)return;let{relativeKey:n,adapter:r}=this.#d(t);return this.#s(c.TRACE,`Reading ${r.name} file: ${t}`),r.getSync(n)??void 0}async write(e,t=``,n={}){let r=t;if(!n.skipFormat){let n=await I(this.#l(e));n&&(r=await F(t,{absolutePath:this.#l(e),...n}))}let{relativeKey:i,adapter:a}=this.#d(e);this.#s(c.TRACE,`Writing ${this.#l(i)} to ${a.name===`virtual`?`the virtual file system`:a.name===`file-system`?`the local file system`:a.name} (size: ${M(new N(f(r)).size)})`);let o=n?.meta?.id||this.#c(i);return this.#e[o]={variant:`normal`,timestamp:Date.now(),...n.meta??{}},this.#n[o]=this.#l(i),this.#t[this.#l(i)]=o,a.set(i,r)}writeSync(e,t=``,n={}){let{relativeKey:r,adapter:i}=this.#d(e);this.#s(c.TRACE,`Writing ${this.#l(r)} file to ${i.name===`virtual`?`the virtual file system`:i.name===`file-system`?`the local file system`:i.name} (size: ${M(new N(f(t)).size)})`);let a=n?.meta?.id||this.#c(r);return this.#e[a]={variant:`normal`,timestamp:Date.now(),...n.meta??{}},this.#n[a]=this.#l(r),this.#t[this.#l(r)]=a,i.setSync(r,t)}mkdirSync(e){return this.#d(e)?.adapter?.mkdirSync(e)}async mkdir(e){return this.#d(e)?.adapter?.mkdir(e)}getMetadata(e){let t=this.resolveSync(e);if(t&&this.metadata[t])return this.metadata[t]}async resolve(t,n,r={}){let i=t;if((i.includes(`{`)||i.includes(`}`))&&(i=e(this.#o,i)),T(i))return i;let a=p({path:this.#c(i),importer:n,options:r}),o;if(!this.#o.config.skipCache&&(o=this.resolverCache.get(a),o))return o;if(o=this.paths[this.#c(i)],!o){let e=r.paths??[];n&&!e.includes(n)&&e.push(n),e.push(this.#o.workspaceConfig.workspaceRoot),e.push(h(this.#o.config.projectRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(h(this.#o.config.sourceRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(...Object.keys(this.#o.tsconfig?.options?.paths??{}).filter(e=>i.startsWith(e.replace(/\*$/,``))).map(e=>this.#o.tsconfig?.options?.paths?.[e]).flat().filter(Boolean).map(e=>h(e,this.#o.workspaceConfig.workspaceRoot)));for(let t of _(i,{paths:e})){let{relativeKey:e,adapter:n}=this.#d(t);if(await n.exists(e)){o=t;break}}if(!o)try{o=await v(i,{...r,paths:e})}catch{}}return o&&!this.#o.config.skipCache&&this.resolverCache.set(a,o),o}resolveSync(t,n,r={}){let i=t;if((i.includes(`{`)||i.includes(`}`))&&(i=e(this.#o,i)),T(i))return i;let a;if(!this.#o.config.skipCache&&(a=this.resolverCache.get(this.#c(i)),a))return a;if(a=this.paths[this.#c(i)],!a){let e=r.paths??[];n&&!e.includes(n)&&e.push(n),e.push(this.#o.workspaceConfig.workspaceRoot),e.push(h(this.#o.config.projectRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(h(this.#o.config.sourceRoot,this.#o.workspaceConfig.workspaceRoot)),e.push(...Object.keys(this.#o.tsconfig?.options?.paths??{}).filter(e=>i.startsWith(e.replace(/\*$/,``))).map(e=>this.#o.tsconfig?.options?.paths?.[e]).flat().filter(Boolean).map(e=>h(e,this.#o.workspaceConfig.workspaceRoot)));for(let t of _(i,{paths:e})){let{relativeKey:e,adapter:n}=this.#d(t);if(n.existsSync(e)){a=t;break}}if(!a)try{a=y(i,{...r,paths:e})}catch{}}return a&&!this.#o.config.skipCache&&this.resolverCache.set(this.#c(i),a),a}async dispose(){if(!this.#a){this.#a=!0,this.#s(c.DEBUG,`Disposing virtual file system...`),await this.remove(l(this.#o.dataPath,`fs.bin`));let e=new D.Message,n=e.initRoot(t),r=await this.list(),i=n._initStorage(r.length);await Promise.all(r.map(async(e,t)=>{let n=await this.read(e),r=i.get(t);r.path=e,r.code=n||``}));let a=n._initIds(Object.keys(this.ids).length);Object.entries(this.ids).filter(([,e])=>e).forEach(([e,t],n)=>{let r=a.get(n);r.id=e,r.path=t});let o=n._initMetadata(Object.keys(this.metadata).length);Object.entries(this.metadata).filter(([,e])=>e).forEach(([e,t],n)=>{let r=o.get(n);if(r.id=e,r.type=t.type,r.timestamp=t.timestamp??BigInt(Date.now()),t.properties){let e=r._initProperties(Object.keys(t.properties).length);Object.entries(t.properties).forEach(([t,n],r)=>{let i=e.get(r);i.key=t,i.value=n})}}),await A(l(this.#o.dataPath,`fs.bin`),e.toArrayBuffer()),this.#o.config.skipCache||this.#i.save(!0),await Promise.all(this.#f().map(async e=>e.adapter.dispose())),this.#s(c.TRACE,`Virtual file system has been disposed.`)}}async[Symbol.asyncDispose](){return this.dispose()}};export{L as VirtualFileSystem};
@@ -0,0 +1 @@
1
+ const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`chalk`);n=e.__toESM(n);let r=require(`@stryke/string-format/title-case`),i=require(`@storm-software/config-tools/logger`),a=require(`@storm-software/config-tools/utilities/colors`),o=require(`@stryke/helpers/noop`);const s=(e,r={})=>{let s=r.logLevel===null?t.LogLevelLabel.SILENT:r.logLevel||t.LogLevelLabel.INFO;return s===t.LogLevelLabel.SILENT?o.noop:r.customLogger?r.customLogger:(t,...o)=>(0,i.getLogFn)((0,i.getLogLevel)(t),{...r,logLevel:s})(`${n.default.bold.hex((0,a.getColor)(`brand`,r))(`powerlines${e?`:${e}`:``}${r.name?` ${n.default.gray(`> `)}${r.name}`:``} ${n.default.gray(`> `)}`)}${o.join(` `)} `.trim())},c=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],l=(e,t)=>(i,...a)=>e(i,` ${n.default.inverse.hex(c[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%c.length]||c[0])(` ${(0,r.titleCase)(t)} `)} ${a.join(` `)} `);exports.createLog=s,exports.extendLog=l;
@@ -0,0 +1 @@
1
+ import{LogLevelLabel as e}from"@storm-software/config-tools/types";import t from"chalk";import{titleCase as n}from"@stryke/string-format/title-case";import{getLogFn as r,getLogLevel as i}from"@storm-software/config-tools/logger";import{getColor as a}from"@storm-software/config-tools/utilities/colors";import{noop as o}from"@stryke/helpers/noop";const s=(n,s={})=>{let c=s.logLevel===null?e.SILENT:s.logLevel||e.INFO;return c===e.SILENT?o:s.customLogger?s.customLogger:(e,...o)=>r(i(e),{...s,logLevel:c})(`${t.bold.hex(a(`brand`,s))(`powerlines${n?`:${n}`:``}${s.name?` ${t.gray(`> `)}${s.name}`:``} ${t.gray(`> `)}`)}${o.join(` `)} `.trim())},c=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],l=(e,r)=>(i,...a)=>e(i,` ${t.inverse.hex(c[r.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%c.length]||c[0])(` ${n(r)} `)} ${a.join(` `)} `);export{s as createLog,l as extendLog};
@@ -0,0 +1 @@
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`defu`);n=e.__toESM(n);let r=require(`ts-morph`);var i=class extends r.InMemoryFileSystemHost{#e;constructor(e){super(),this.#e=e}deleteSync(e){this.#e.fs.removeSync(e)}readDirSync(e){return this.#e.fs.isDirectorySync(e)?this.#e.fs.listSync(e).reduce((e,t)=>{let n=this.#e.fs.resolveSync(t);return n&&e.push({name:t,isDirectory:this.#e.fs.isDirectorySync(n),isFile:this.#e.fs.isFileSync(n),isSymlink:!1}),e},[]):[]}async readFile(e){return this.#e.fs.isFileSync(e)?await this.#e.fs.read(e):``}readFileSync(e){return this.#e.fs.isFileSync(e)?this.#e.fs.readSync(e):``}async writeFile(e,t){return this.#e.fs.write(e,t)}writeFileSync(e,t){this.#e.fs.writeSync(e,t)}async mkdir(e){await this.#e.fs.mkdir(e)}mkdirSync(e){this.#e.fs.mkdirSync(e)}async move(e,t){await this.#e.fs.move(e,t)}moveSync(e,t){this.#e.fs.moveSync(e,t)}async copy(e,t){await this.#e.fs.copy(e,t)}copySync(e,t){this.#e.fs.copySync(e,t)}async fileExists(e){return this.#e.fs.isFile(e)}fileExistsSync(e){return this.#e.fs.isFileSync(e)}async directoryExists(e){return this.#e.fs.isDirectory(e)}directoryExistsSync(e){return this.#e.fs.isDirectorySync(e)}realpathSync(e){return this.#e.fs.resolveSync(e)||e}getCurrentDirectory(){return this.#e.workspaceConfig.workspaceRoot}async glob(e){return this.#e.fs.glob(e)}globSync(e){return this.#e.fs.globSync(e)}};function a(e,a){return e.log(t.LogLevelLabel.TRACE,`Creating ts-morph Project instance with configuration from: ${e.tsconfig.tsconfigFilePath}.`),new r.Project((0,n.default)(a??{},{skipAddingFilesFromTsConfig:!1,tsConfigFilePath:e.tsconfig.tsconfigFilePath,fileSystem:new i(e),compilerOptions:(0,n.default)(e.tsconfig.options??{},{lib:[`lib.esnext.full.d.ts`]})}))}exports.createProgram=a;
@@ -0,0 +1 @@
1
+ import{LogLevelLabel as e}from"@storm-software/config-tools/types";import t from"defu";import{InMemoryFileSystemHost as n,Project as r}from"ts-morph";var i=class extends n{#e;constructor(e){super(),this.#e=e}deleteSync(e){this.#e.fs.removeSync(e)}readDirSync(e){return this.#e.fs.isDirectorySync(e)?this.#e.fs.listSync(e).reduce((e,t)=>{let n=this.#e.fs.resolveSync(t);return n&&e.push({name:t,isDirectory:this.#e.fs.isDirectorySync(n),isFile:this.#e.fs.isFileSync(n),isSymlink:!1}),e},[]):[]}async readFile(e){return this.#e.fs.isFileSync(e)?await this.#e.fs.read(e):``}readFileSync(e){return this.#e.fs.isFileSync(e)?this.#e.fs.readSync(e):``}async writeFile(e,t){return this.#e.fs.write(e,t)}writeFileSync(e,t){this.#e.fs.writeSync(e,t)}async mkdir(e){await this.#e.fs.mkdir(e)}mkdirSync(e){this.#e.fs.mkdirSync(e)}async move(e,t){await this.#e.fs.move(e,t)}moveSync(e,t){this.#e.fs.moveSync(e,t)}async copy(e,t){await this.#e.fs.copy(e,t)}copySync(e,t){this.#e.fs.copySync(e,t)}async fileExists(e){return this.#e.fs.isFile(e)}fileExistsSync(e){return this.#e.fs.isFileSync(e)}async directoryExists(e){return this.#e.fs.isDirectory(e)}directoryExistsSync(e){return this.#e.fs.isDirectorySync(e)}realpathSync(e){return this.#e.fs.resolveSync(e)||e}getCurrentDirectory(){return this.#e.workspaceConfig.workspaceRoot}async glob(e){return this.#e.fs.glob(e)}globSync(e){return this.#e.fs.globSync(e)}};function a(n,a){return n.log(e.TRACE,`Creating ts-morph Project instance with configuration from: ${n.tsconfig.tsconfigFilePath}.`),new r(t(a??{},{skipAddingFilesFromTsConfig:!1,tsConfigFilePath:n.tsconfig.tsconfigFilePath,fileSystem:new i(n),compilerOptions:t(n.tsconfig.options??{},{lib:[`lib.esnext.full.d.ts`]})}))}export{a as createProgram};
@@ -0,0 +1,4 @@
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/join-paths`),n=require(`defu`);n=e.__toESM(n);let r=require(`@stryke/path/append`),i=require(`typescript`);i=e.__toESM(i);let a=require(`@stryke/fs/json`),o=require(`@stryke/fs/exists`);function s(e,t,n){let r;if(n?r=c(e,t,n):(r=c(e,t,`tsconfig.app.json`),r||(r=c(e,t,`tsconfig.lib.json`),r||=c(e,t,`tsconfig.json`))),!r)throw Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${t}.`);return r}function c(e,t,n){let i=n;if(!(!(0,o.existsSync)(i)&&(i=(0,r.appendPath)(n,t),!(0,o.existsSync)(i)&&(i=(0,r.appendPath)(n,(0,r.appendPath)(t,e)),!(0,o.existsSync)(i)))))return i}function l(e,t,n=[`.ts`,`.tsx`,`.d.ts`]){return t.find(t=>e?.toString().toLowerCase()===t?.toString().toLowerCase()||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}`||`./${e?.toString().toLowerCase()}`===t?.toString().toLowerCase()||n.some(n=>`${e?.toString().toLowerCase()}${n}`===t?.toString().toLowerCase()||`${e?.toString().toLowerCase()}${n}`==`./${t?.toString().toLowerCase()}`||`${t?.toString().toLowerCase()}${n}`==`./${e?.toString().toLowerCase()}`||e?.toString().toLowerCase()===`${t?.toString().toLowerCase()}${n}`||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}${n}`||t?.toString().toLowerCase()===`./${e?.toString().toLowerCase()}${n}`))}function u(e,t){return l(e,t,`.ts,.tsx,.d.ts,.js,.jsx,.mjs,.cjs,.mts,.cts,/*.ts,/*.tsx,/*.d.ts,/*.js,/*.jsx,/*.mjs,/*.cjs,/*.mts,/*.cts,/**/*.ts,/**/*.tsx,/**/*.d.ts,/**/*.js,/**/*.jsx,/**/*.mjs,/**/*.cjs,/**/*.mts,/**/*.cts`.split(`,`))}function d(e,t){return u(e,t)!==void 0}function f(e,o,c,l={},u,d=i.default.sys){let f=s(e,o,c),p=(0,a.readJsonFileSync)(f);if(!p)throw Error(`Cannot find the \`tsconfig.json\` configuration file at ${(0,t.joinPaths)(o,c??`tsconfig.json`)}`);let m=i.default.parseJsonConfigFileContent((0,n.default)(l??{},p),d,(0,r.appendPath)(o,e));if(m.errors.length>0){let e=`Cannot parse the TypeScript compiler options. Please investigate the following issues:
2
+ ${m.errors.map(e=>`- ${(e.category!==void 0&&e.code?`[${e.category}-${e.code}]: `:``)+e.messageText.toString()}`).join(`
3
+ `)}
4
+ `;throw Error(e)}return{...m,originalTsconfigJson:u??p,tsconfigJson:p,tsconfigFilePath:f}}exports.getParsedTypeScriptConfig=f,exports.getTsconfigFilePath=s,exports.isIncludeMatchFound=d;
@@ -0,0 +1,4 @@
1
+ import{joinPaths as e}from"@stryke/path/join-paths";import t from"defu";import{appendPath as n}from"@stryke/path/append";import r from"typescript";import{readJsonFileSync as i}from"@stryke/fs/json";import{existsSync as a}from"@stryke/fs/exists";function o(e,t,n){let r;if(n?r=s(e,t,n):(r=s(e,t,`tsconfig.app.json`),r||(r=s(e,t,`tsconfig.lib.json`),r||=s(e,t,`tsconfig.json`))),!r)throw Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${t}.`);return r}function s(e,t,r){let i=r;if(!(!a(i)&&(i=n(r,t),!a(i)&&(i=n(r,n(t,e)),!a(i)))))return i}function c(e,t,n=[`.ts`,`.tsx`,`.d.ts`]){return t.find(t=>e?.toString().toLowerCase()===t?.toString().toLowerCase()||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}`||`./${e?.toString().toLowerCase()}`===t?.toString().toLowerCase()||n.some(n=>`${e?.toString().toLowerCase()}${n}`===t?.toString().toLowerCase()||`${e?.toString().toLowerCase()}${n}`==`./${t?.toString().toLowerCase()}`||`${t?.toString().toLowerCase()}${n}`==`./${e?.toString().toLowerCase()}`||e?.toString().toLowerCase()===`${t?.toString().toLowerCase()}${n}`||e?.toString().toLowerCase()===`./${t?.toString().toLowerCase()}${n}`||t?.toString().toLowerCase()===`./${e?.toString().toLowerCase()}${n}`))}function l(e,t){return c(e,t,`.ts,.tsx,.d.ts,.js,.jsx,.mjs,.cjs,.mts,.cts,/*.ts,/*.tsx,/*.d.ts,/*.js,/*.jsx,/*.mjs,/*.cjs,/*.mts,/*.cts,/**/*.ts,/**/*.tsx,/**/*.d.ts,/**/*.js,/**/*.jsx,/**/*.mjs,/**/*.cjs,/**/*.mts,/**/*.cts`.split(`,`))}function u(e,t){return l(e,t)!==void 0}function d(a,s,c,l={},u,d=r.sys){let f=o(a,s,c),p=i(f);if(!p)throw Error(`Cannot find the \`tsconfig.json\` configuration file at ${e(s,c??`tsconfig.json`)}`);let m=r.parseJsonConfigFileContent(t(l??{},p),d,n(s,a));if(m.errors.length>0){let e=`Cannot parse the TypeScript compiler options. Please investigate the following issues:
2
+ ${m.errors.map(e=>`- ${(e.category!==void 0&&e.code?`[${e.category}-${e.code}]: `:``)+e.messageText.toString()}`).join(`
3
+ `)}
4
+ `;throw Error(e)}return{...m,originalTsconfigJson:u??p,tsconfigJson:p,tsconfigFilePath:f}}export{d as getParsedTypeScriptConfig,o as getTsconfigFilePath,u as isIncludeMatchFound};
@@ -0,0 +1 @@
1
+ require(`../logger.cjs`),require(`../../api.cjs`),require(`../utilities/source-file.cjs`);let e=require(`@storm-software/config-tools/types`),t=require(`@stryke/fs/get-workspace-root`),n=require(`unplugin`);
@@ -0,0 +1 @@
1
+ import"../logger.mjs";import"../../api.mjs";import"../utilities/source-file.mjs";import{LogLevelLabel as e}from"@storm-software/config-tools/types";import"@stryke/fs/get-workspace-root";import{setParseImpl as t}from"unplugin";export{};
@@ -0,0 +1 @@
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`defu`);function n(e,n){return(0,t.defu)(e,n)}exports.combineContexts=n;
@@ -0,0 +1 @@
1
+ import{defu as e}from"defu";function t(t,n){return e(t,n)}export{t as combineContexts};
@@ -0,0 +1 @@
1
+ require(`./factory.cjs`);const e=require(`./helpers.cjs`),t=require(`./plugin.cjs`);
@@ -0,0 +1 @@
1
+ import"./factory.mjs";import{combineContexts as e}from"./helpers.mjs";import{createUnplugin as t}from"./plugin.mjs";export{};
@@ -0,0 +1,6 @@
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../logger.cjs`),n=require(`../utilities/source-file.cjs`),r=require(`./helpers.cjs`);let i=require(`@storm-software/config-tools/types`),a=require(`@stryke/path/replace`),o=require(`@stryke/type-checks/is-string`),s=require(`unplugin`),c=require(`@stryke/path/file-path-fns`);function l(e){let l=e;return(0,s.setParseImpl)(l.parse),()=>{let e=t.extendLog(l.log,`unplugin`);e(i.LogLevelLabel.DEBUG,`Initializing Unplugin`);try{async function t(){e(i.LogLevelLabel.DEBUG,`Powerlines build plugin starting...`),await l.$$internal.callHook(`buildStart`,{sequential:!0})}async function s(e,t,n={isEntry:!1}){let r=await(async()=>{let r=await l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`pre`},e,t,n);return r||(r=await l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`normal`},e,t,n),r)||(r=await l.resolve(e,t,n),r)?r:l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`post`},e,t,n)})();if(r&&n.isEntry&&l.config.build.polyfill&&l.config.build.polyfill.length>0){let e=l.entry.find(e=>e.file===((0,o.isString)(r)?r:r.id));if(e)return e.file=`${(0,a.replaceExtension)((0,o.isString)(r)?r:r.id)}-polyfill.ts`,e.output||=e.output?.replace((0,c.findFileName)(e.output,{withExtension:!0}),e.file),await l.emitEntry(`
2
+ ${l.config.build.polyfill.map(e=>`import "${e}";`).join(`
3
+ `)}
4
+
5
+ export * from "${(0,o.isString)(r)?r:r.id}";
6
+ `,e.file),e.file}return r}async function u(e){let t=await l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`pre`},e);return t||(t=await l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`normal`},e),t)||(t=await l.load(e),t)?t:l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`post`},e)}async function d(e,t){let i=e;for(let e of l.$$internal.environment.selectHooks(`transform`)){let a=await e.handle.apply(r.combineContexts(l,this),[n.getString(i),t]);a&&(i=a)}return i}async function f(){return e(i.LogLevelLabel.DEBUG,`Powerlines build plugin finishing...`),l.$$internal.callHook(`buildEnd`,{sequential:!0})}async function p(){return e(i.LogLevelLabel.DEBUG,`Finalizing Powerlines project output...`),l.$$internal.callHook(`writeBundle`,{sequential:!0})}return{name:`powerlines`,api:l.$$internal.api,resolveId:{filter:{id:{include:[/.*/]}},handler:s},load:{filter:{id:{include:[/.*/]}},handler:u},transform:d,buildStart:t,buildEnd:f,writeBundle:p,vite:{sharedDuringBuild:!0}}}catch(t){throw e(i.LogLevelLabel.FATAL,t?.message),t}}}exports.createUnplugin=l;
@@ -0,0 +1,6 @@
1
+ import{extendLog as e}from"../logger.mjs";import{getString as t}from"../utilities/source-file.mjs";import{combineContexts as n}from"./helpers.mjs";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import{replaceExtension as i}from"@stryke/path/replace";import{isString as a}from"@stryke/type-checks/is-string";import{setParseImpl as o}from"unplugin";import{findFileName as s}from"@stryke/path/file-path-fns";function c(c){let l=c;return o(l.parse),()=>{let o=e(l.log,`unplugin`);o(r.DEBUG,`Initializing Unplugin`);try{async function e(){o(r.DEBUG,`Powerlines build plugin starting...`),await l.$$internal.callHook(`buildStart`,{sequential:!0})}async function c(e,t,n={isEntry:!1}){let r=await(async()=>{let r=await l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`pre`},e,t,n);return r||(r=await l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`normal`},e,t,n),r)||(r=await l.resolve(e,t,n),r)?r:l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`post`},e,t,n)})();if(r&&n.isEntry&&l.config.build.polyfill&&l.config.build.polyfill.length>0){let e=l.entry.find(e=>e.file===(a(r)?r:r.id));if(e)return e.file=`${i(a(r)?r:r.id)}-polyfill.ts`,e.output||=e.output?.replace(s(e.output,{withExtension:!0}),e.file),await l.emitEntry(`
2
+ ${l.config.build.polyfill.map(e=>`import "${e}";`).join(`
3
+ `)}
4
+
5
+ export * from "${a(r)?r:r.id}";
6
+ `,e.file),e.file}return r}async function u(e){let t=await l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`pre`},e);return t||(t=await l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`normal`},e),t)||(t=await l.load(e),t)?t:l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`post`},e)}async function d(e,r){let i=e;for(let e of l.$$internal.environment.selectHooks(`transform`)){let a=await e.handle.apply(n(l,this),[t(i),r]);a&&(i=a)}return i}async function f(){return o(r.DEBUG,`Powerlines build plugin finishing...`),l.$$internal.callHook(`buildEnd`,{sequential:!0})}async function p(){return o(r.DEBUG,`Finalizing Powerlines project output...`),l.$$internal.callHook(`writeBundle`,{sequential:!0})}return{name:`powerlines`,api:l.$$internal.api,resolveId:{filter:{id:{include:[/.*/]}},handler:c},load:{filter:{id:{include:[/.*/]}},handler:u},transform:d,buildStart:e,buildEnd:f,writeBundle:p,vite:{sharedDuringBuild:!0}}}catch(e){throw o(r.FATAL,e?.message),e}}}export{c as createUnplugin};
@@ -0,0 +1,10 @@
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/string-format/title-case`);function n(e){return`
2
+ // Generated with ${(0,t.titleCase)(e.config.framework)}
3
+ // Note: Do not edit this file manually - it will be overwritten automatically
4
+ `}function r(e,t={}){let{directive:r=null,prettierIgnore:i=!1}=t;return`/* eslint-disable */
5
+ // biome-ignore lint: disable
6
+ ${i?`// prettier-ignore`:``}${r?`\n\n${r}\n`:`
7
+ `}
8
+ ${n(e)}
9
+
10
+ `}exports.getFileHeader=r;
@@ -0,0 +1,10 @@
1
+ import{titleCase as e}from"@stryke/string-format/title-case";function t(t){return`
2
+ // Generated with ${e(t.config.framework)}
3
+ // Note: Do not edit this file manually - it will be overwritten automatically
4
+ `}function n(e,n={}){let{directive:r=null,prettierIgnore:i=!1}=n;return`/* eslint-disable */
5
+ // biome-ignore lint: disable
6
+ ${i?`// prettier-ignore`:``}${r?`\n\n${r}\n`:`
7
+ `}
8
+ ${t(e)}
9
+
10
+ `}export{n as getFileHeader};
@@ -0,0 +1 @@
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`@stryke/path/join-paths`),r=require(`@stryke/fs/list-files`),i=require(`@stryke/helpers/get-unique`),a=require(`@stryke/fs/json`),o=require(`@stryke/path/file-path-fns`),s=require(`@stryke/fs/exists`);require(`@stryke/fs/remove-file`);let c=require(`@stryke/string-format/kebab-case`);const l=45,u=62;function d(e,t){let n=`${(0,c.kebabCase)(e)}_${t}`;return n.length>45?n.slice(0,45):n}async function f(e){let r=(0,n.joinPaths)(e.dataPath,`meta.json`);e.log(t.LogLevelLabel.DEBUG,`Writing runtime metadata to ${r}`),await e.fs.write(r,JSON.stringify(e.meta,null,2))}exports.CACHE_HASH_LENGTH=62,exports.PROJECT_ROOT_HASH_LENGTH=45,exports.getPrefixedProjectRootHash=d,exports.writeMetaFile=f;
@@ -0,0 +1 @@
1
+ import{LogLevelLabel as e}from"@storm-software/config-tools/types";import{joinPaths as t}from"@stryke/path/join-paths";import{listFiles as n}from"@stryke/fs/list-files";import{getUnique as r}from"@stryke/helpers/get-unique";import{readJsonFile as i}from"@stryke/fs/json";import{hasFileExtension as a}from"@stryke/path/file-path-fns";import{existsSync as o}from"@stryke/fs/exists";import"@stryke/fs/remove-file";import{kebabCase as s}from"@stryke/string-format/kebab-case";const c=45,l=62;function u(e,t){let n=`${s(e)}_${t}`;return n.length>45?n.slice(0,45):n}async function d(n){let r=t(n.dataPath,`meta.json`);n.log(e.DEBUG,`Writing runtime metadata to ${r}`),await n.fs.write(r,JSON.stringify(n.meta,null,2))}export{l as CACHE_HASH_LENGTH,c as PROJECT_ROOT_HASH_LENGTH,u as getPrefixedProjectRootHash,d as writeMetaFile};
@@ -0,0 +1 @@
1
+ const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/type-checks/is-string`),n=require(`@stryke/type-checks/is-set-object`),r=require(`@stryke/fs/read-file`);require(`magic-string`);function i(e){return e?(0,t.isString)(e)?e:(0,n.isSetObject)(e)&&`code`in e?e.code:e.toString():``}exports.getString=i;
@@ -0,0 +1 @@
1
+ import{isString as e}from"@stryke/type-checks/is-string";import{isSetObject as t}from"@stryke/type-checks/is-set-object";import"@stryke/fs/read-file";import"magic-string";function n(n){return n?e(n)?n:t(n)&&`code`in n?n.code:n.toString():``}export{n as getString};
@@ -0,0 +1 @@
1
+ const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../types/commands.cjs`);let n=require(`@stryke/type-checks/is-set-string`),r=require(`@stryke/type-checks/is-function`),i=require(`@stryke/type-checks/is-set-object`),a=require(`@stryke/type-checks/is-undefined`);function o(e){return(0,i.isSetObject)(e)&&`name`in e&&(0,n.isSetString)(e.name)&&((0,a.isUndefined)(e.applyToEnvironment)||`applyToEnvironment`in e&&(0,r.isFunction)(e.applyToEnvironment))&&((0,a.isUndefined)(e.dedupe)||`dedupe`in e&&(0,r.isFunction)(e.dedupe))&&((0,a.isUndefined)(e.dependsOn)||`dependsOn`in e&&Array.isArray(e.dependsOn)&&e.dependsOn.every(l))&&t.SUPPORTED_COMMANDS.every(t=>(0,a.isUndefined)(e[t])||t in e&&((0,r.isFunction)(e[t])||(0,i.isSetObject)(e[t])&&`handler`in e[t]&&(0,r.isFunction)(e[t].handler)))}function s(e){return(0,i.isSetObject)(e)&&`plugin`in e&&(((0,n.isSetString)(e.plugin)||(0,r.isFunction)(e.plugin))&&`options`in e&&(0,i.isSetObject)(e.options)||o(e.plugin))}function c(e){return Array.isArray(e)&&(e.length===1||e.length===2)&&(((0,n.isSetString)(e[0])||(0,r.isFunction)(e[0]))&&e.length>1&&(0,i.isSetObject)(e[1])||o(e[0]))}function l(e){return(0,n.isSetString)(e)||(0,r.isFunction)(e)||o(e)||s(e)||c(e)}function u(e){return(0,r.isFunction)(e)||(0,i.isSetObject)(e)&&`handler`in e&&(0,r.isFunction)(e.handler)}function d(e){return(0,i.isSetObject)(e)&&`handler`in e&&(0,r.isFunction)(e.handler)}function f(e){return u(e)||d(e)}function p(e){return(0,r.isFunction)(e)?e:e.handler}function m(e){return e.startsWith(`vite:`)||e.startsWith(`esbuild:`)||e.startsWith(`rolldown:`)||e.startsWith(`rollup:`)||e.startsWith(`webpack:`)||e.startsWith(`rspack:`)||e.startsWith(`farm:`)}function h(e,t){return e.dedupe===!1||t.some(t=>t.dedupe!==!1&&((0,r.isFunction)(t.dedupe)&&t.dedupe(e)||t.name===e.name))}function g(e,t,n,i){h(t,i.map(e=>e.plugin))||i.push((0,r.isFunction)(n)?{plugin:t,handler:p(n).bind(e)}:{plugin:t,...n,handler:p(n).bind(e)})}exports.addPluginHook=g,exports.checkDedupe=h,exports.getHookHandler=p,exports.isHookExternal=m,exports.isPlugin=o,exports.isPluginConfig=l,exports.isPluginConfigObject=s,exports.isPluginConfigTuple=c,exports.isPluginHook=f;
@@ -0,0 +1 @@
1
+ import{SUPPORTED_COMMANDS as e}from"../types/commands.mjs";import{isSetString as t}from"@stryke/type-checks/is-set-string";import{isFunction as n}from"@stryke/type-checks/is-function";import{isSetObject as r}from"@stryke/type-checks/is-set-object";import{isUndefined as i}from"@stryke/type-checks/is-undefined";function a(a){return r(a)&&`name`in a&&t(a.name)&&(i(a.applyToEnvironment)||`applyToEnvironment`in a&&n(a.applyToEnvironment))&&(i(a.dedupe)||`dedupe`in a&&n(a.dedupe))&&(i(a.dependsOn)||`dependsOn`in a&&Array.isArray(a.dependsOn)&&a.dependsOn.every(c))&&e.every(e=>i(a[e])||e in a&&(n(a[e])||r(a[e])&&`handler`in a[e]&&n(a[e].handler)))}function o(e){return r(e)&&`plugin`in e&&((t(e.plugin)||n(e.plugin))&&`options`in e&&r(e.options)||a(e.plugin))}function s(e){return Array.isArray(e)&&(e.length===1||e.length===2)&&((t(e[0])||n(e[0]))&&e.length>1&&r(e[1])||a(e[0]))}function c(e){return t(e)||n(e)||a(e)||o(e)||s(e)}function l(e){return n(e)||r(e)&&`handler`in e&&n(e.handler)}function u(e){return r(e)&&`handler`in e&&n(e.handler)}function d(e){return l(e)||u(e)}function f(e){return n(e)?e:e.handler}function p(e){return e.startsWith(`vite:`)||e.startsWith(`esbuild:`)||e.startsWith(`rolldown:`)||e.startsWith(`rollup:`)||e.startsWith(`webpack:`)||e.startsWith(`rspack:`)||e.startsWith(`farm:`)}function m(e,t){return e.dedupe===!1||t.some(t=>t.dedupe!==!1&&(n(t.dedupe)&&t.dedupe(e)||t.name===e.name))}function h(e,t,r,i){m(t,i.map(e=>e.plugin))||i.push(n(r)?{plugin:t,handler:f(r).bind(e)}:{plugin:t,...r,handler:f(r).bind(e)})}export{h as addPluginHook,m as checkDedupe,f as getHookHandler,p as isHookExternal,a as isPlugin,c as isPluginConfig,o as isPluginConfigObject,s as isPluginConfigTuple,d as isPluginHook};
@@ -0,0 +1 @@
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;
@@ -0,0 +1 @@
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};
@@ -0,0 +1,4 @@
1
+ import "./config.mjs";
2
+ import "./context.mjs";
3
+ import "@babel/core";
4
+ import "@babel/helper-plugin-utils";
@@ -0,0 +1,143 @@
1
+ import { UserConfig } from "vite";
2
+
3
+ //#region ../powerlines/src/types/build.d.ts
4
+
5
+ type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
6
+ interface BuildConfig {
7
+ /**
8
+ * The platform to build the project for
9
+ *
10
+ * @defaultValue "neutral"
11
+ */
12
+ platform?: "node" | "browser" | "neutral";
13
+ /**
14
+ * Array of strings indicating the polyfills to include for the build.
15
+ *
16
+ * @remarks
17
+ * This option allows you to specify which polyfills should be included in the build process to ensure compatibility with the target environment. The paths for the polyfills can use placeholder tokens (the `replacePathTokens` helper function will be used to resolve the actual values).
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * {
22
+ * polyfill: ['{projectRoot}/custom-polyfill.ts']
23
+ * }
24
+ * ```
25
+ */
26
+ polyfill?: string[];
27
+ /**
28
+ * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.
29
+ *
30
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
31
+ */
32
+ mainFields?: string[];
33
+ /**
34
+ * Array of strings indicating what conditions should be used for module resolution.
35
+ */
36
+ conditions?: string[];
37
+ /**
38
+ * Array of strings indicating what file extensions should be used for module resolution.
39
+ *
40
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
41
+ */
42
+ extensions?: string[];
43
+ /**
44
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
45
+ *
46
+ * @remarks
47
+ * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.
48
+ */
49
+ dedupe?: string[];
50
+ /**
51
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
52
+ */
53
+ builtins?: (string | RegExp)[];
54
+ /**
55
+ * Define global variable replacements.
56
+ *
57
+ * @remarks
58
+ * This option allows you to specify global constants that will be replaced in the code during the build process. It is similar to the `define` option in esbuild and Vite, enabling you to replace specific identifiers with constant expressions at build time.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * {
63
+ * define: {
64
+ * __VERSION__: '"1.0.0"',
65
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
66
+ * }
67
+ * }
68
+ * ```
69
+ *
70
+ * @see https://esbuild.github.io/api/#define
71
+ * @see https://vitejs.dev/config/build-options.html#define
72
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
73
+ */
74
+ define?: Record<string, any>;
75
+ /**
76
+ * Global variables that will have import statements injected where necessary
77
+ *
78
+ * @remarks
79
+ * This option allows you to specify global variables that should be automatically imported from specified modules whenever they are used in the code. This is particularly useful for polyfilling Node.js globals in a browser environment.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * {
84
+ * inject: {
85
+ * process: 'process/browser',
86
+ * Buffer: ['buffer', 'Buffer'],
87
+ * }
88
+ * }
89
+ * ```
90
+ *
91
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
92
+ */
93
+ inject?: Record<string, string | string[]>;
94
+ /**
95
+ * The alias mappings to use for module resolution during the build process.
96
+ *
97
+ * @remarks
98
+ * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * {
103
+ * alias: {
104
+ * "@utils": "./src/utils",
105
+ * "@components": "./src/components"
106
+ * }
107
+ * }
108
+ * ```
109
+ *
110
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
111
+ */
112
+ alias?: Record<string, string> | Array<{
113
+ find: string | RegExp;
114
+ replacement: string;
115
+ }>;
116
+ /**
117
+ * A list of modules that should not be bundled, even if they are external dependencies.
118
+ *
119
+ * @remarks
120
+ * This option is useful for excluding specific modules from the bundle, such as Node.js built-in modules or other libraries that should not be bundled.
121
+ */
122
+ external?: (string | RegExp)[];
123
+ /**
124
+ * A list of modules that should always be bundled, even if they are external dependencies.
125
+ */
126
+ noExternal?: (string | RegExp)[];
127
+ /**
128
+ * Should the Powerlines CLI processes skip bundling the `node_modules` directory?
129
+ */
130
+ skipNodeModulesBundle?: boolean;
131
+ /**
132
+ * An optional set of override options to apply to the selected build variant.
133
+ *
134
+ * @remarks
135
+ * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.
136
+ */
137
+ override?: Record<string, any>;
138
+ }
139
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
140
+ type ViteBuildConfig = Omit<UserConfig, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig;
141
+ type ViteResolvedBuildConfig = UserConfig & BuildResolvedConfig;
142
+ //#endregion
143
+ export { BuildConfig, BuildResolvedConfig, UnpluginBuildVariant, ViteBuildConfig, ViteResolvedBuildConfig };
@@ -0,0 +1,143 @@
1
+ import { UserConfig } from "vite";
2
+
3
+ //#region ../powerlines/src/types/build.d.ts
4
+
5
+ type UnpluginBuildVariant = "rollup" | "webpack" | "rspack" | "vite" | "esbuild" | "farm" | "unloader" | "rolldown";
6
+ interface BuildConfig {
7
+ /**
8
+ * The platform to build the project for
9
+ *
10
+ * @defaultValue "neutral"
11
+ */
12
+ platform?: "node" | "browser" | "neutral";
13
+ /**
14
+ * Array of strings indicating the polyfills to include for the build.
15
+ *
16
+ * @remarks
17
+ * This option allows you to specify which polyfills should be included in the build process to ensure compatibility with the target environment. The paths for the polyfills can use placeholder tokens (the `replacePathTokens` helper function will be used to resolve the actual values).
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * {
22
+ * polyfill: ['{projectRoot}/custom-polyfill.ts']
23
+ * }
24
+ * ```
25
+ */
26
+ polyfill?: string[];
27
+ /**
28
+ * Array of strings indicating the order in which fields in a package.json file should be resolved to determine the entry point for a module.
29
+ *
30
+ * @defaultValue `['browser', 'module', 'jsnext:main', 'jsnext']`
31
+ */
32
+ mainFields?: string[];
33
+ /**
34
+ * Array of strings indicating what conditions should be used for module resolution.
35
+ */
36
+ conditions?: string[];
37
+ /**
38
+ * Array of strings indicating what file extensions should be used for module resolution.
39
+ *
40
+ * @defaultValue `['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']`
41
+ */
42
+ extensions?: string[];
43
+ /**
44
+ * Array of strings indicating what modules should be deduplicated to a single version in the build.
45
+ *
46
+ * @remarks
47
+ * This option is useful for ensuring that only one version of a module is included in the bundle, which can help reduce bundle size and avoid conflicts.
48
+ */
49
+ dedupe?: string[];
50
+ /**
51
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
52
+ */
53
+ builtins?: (string | RegExp)[];
54
+ /**
55
+ * Define global variable replacements.
56
+ *
57
+ * @remarks
58
+ * This option allows you to specify global constants that will be replaced in the code during the build process. It is similar to the `define` option in esbuild and Vite, enabling you to replace specific identifiers with constant expressions at build time.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * {
63
+ * define: {
64
+ * __VERSION__: '"1.0.0"',
65
+ * __DEV__: 'process.env.NODE_ENV !== "production"'
66
+ * }
67
+ * }
68
+ * ```
69
+ *
70
+ * @see https://esbuild.github.io/api/#define
71
+ * @see https://vitejs.dev/config/build-options.html#define
72
+ * @see https://github.com/rollup/plugins/tree/master/packages/replace
73
+ */
74
+ define?: Record<string, any>;
75
+ /**
76
+ * Global variables that will have import statements injected where necessary
77
+ *
78
+ * @remarks
79
+ * This option allows you to specify global variables that should be automatically imported from specified modules whenever they are used in the code. This is particularly useful for polyfilling Node.js globals in a browser environment.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * {
84
+ * inject: {
85
+ * process: 'process/browser',
86
+ * Buffer: ['buffer', 'Buffer'],
87
+ * }
88
+ * }
89
+ * ```
90
+ *
91
+ * @see https://github.com/rollup/plugins/tree/master/packages/inject
92
+ */
93
+ inject?: Record<string, string | string[]>;
94
+ /**
95
+ * The alias mappings to use for module resolution during the build process.
96
+ *
97
+ * @remarks
98
+ * This option allows you to define custom path aliases for modules, which can be useful for simplifying imports and managing dependencies.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * {
103
+ * alias: {
104
+ * "@utils": "./src/utils",
105
+ * "@components": "./src/components"
106
+ * }
107
+ * }
108
+ * ```
109
+ *
110
+ * @see https://github.com/rollup/plugins/tree/master/packages/alias
111
+ */
112
+ alias?: Record<string, string> | Array<{
113
+ find: string | RegExp;
114
+ replacement: string;
115
+ }>;
116
+ /**
117
+ * A list of modules that should not be bundled, even if they are external dependencies.
118
+ *
119
+ * @remarks
120
+ * This option is useful for excluding specific modules from the bundle, such as Node.js built-in modules or other libraries that should not be bundled.
121
+ */
122
+ external?: (string | RegExp)[];
123
+ /**
124
+ * A list of modules that should always be bundled, even if they are external dependencies.
125
+ */
126
+ noExternal?: (string | RegExp)[];
127
+ /**
128
+ * Should the Powerlines CLI processes skip bundling the `node_modules` directory?
129
+ */
130
+ skipNodeModulesBundle?: boolean;
131
+ /**
132
+ * An optional set of override options to apply to the selected build variant.
133
+ *
134
+ * @remarks
135
+ * This option allows you to provide configuration options with the guarantee that they will **not** be overridden and will take precedence over other build configurations.
136
+ */
137
+ override?: Record<string, any>;
138
+ }
139
+ type BuildResolvedConfig = Omit<BuildConfig, "override">;
140
+ type ViteBuildConfig = Omit<UserConfig, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output"> & BuildConfig;
141
+ type ViteResolvedBuildConfig = UserConfig & BuildResolvedConfig;
142
+ //#endregion
143
+ export { BuildConfig, BuildResolvedConfig, UnpluginBuildVariant, ViteBuildConfig, ViteResolvedBuildConfig };
@@ -0,0 +1 @@
1
+ const e=[`new`,`clean`,`prepare`,`lint`,`test`,`build`,`docs`,`deploy`,`finalize`];exports.SUPPORTED_COMMANDS=e;
@@ -0,0 +1,8 @@
1
+ import { MaybePromise } from "@stryke/types/base";
2
+ import { ArrayValues } from "@stryke/types/array";
3
+
4
+ //#region ../powerlines/src/types/commands.d.ts
5
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
6
+ type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
7
+ //#endregion
8
+ export { CommandType };
@@ -0,0 +1,9 @@
1
+ import "./context.mjs";
2
+ import { MaybePromise } from "@stryke/types/base";
3
+ import { ArrayValues } from "@stryke/types/array";
4
+
5
+ //#region ../powerlines/src/types/commands.d.ts
6
+ declare const SUPPORTED_COMMANDS: readonly ["new", "clean", "prepare", "lint", "test", "build", "docs", "deploy", "finalize"];
7
+ type CommandType = ArrayValues<typeof SUPPORTED_COMMANDS>;
8
+ //#endregion
9
+ export { CommandType };
@@ -0,0 +1 @@
1
+ const e=[`new`,`clean`,`prepare`,`lint`,`test`,`build`,`docs`,`deploy`,`finalize`];export{e as SUPPORTED_COMMANDS};