@powerlines/plugin-tsdown 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/unplugin.cjs +1 -1
- package/dist/helpers/unplugin.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{unplugin-_gyLvyu7.mjs → unplugin-Bto10Tcc.mjs} +3 -3
- package/dist/{unplugin-_gyLvyu7.mjs.map → unplugin-Bto10Tcc.mjs.map} +1 -1
- package/dist/unplugin-mnISMi6f.cjs +44 -0
- package/package.json +5 -5
- package/dist/unplugin-B7DdMaXJ.cjs +0 -44
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../unplugin-
|
|
1
|
+
const e=require(`../unplugin-mnISMi6f.cjs`);require(`../helpers-LF26RHol.cjs`),exports.createTsdownPlugin=e.t;
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../unplugin-
|
|
1
|
+
import{t as e}from"../unplugin-Bto10Tcc.mjs";import"../helpers-CRPRhztf.mjs";export{e as createTsdownPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../unplugin-
|
|
1
|
+
const e=require(`../unplugin-mnISMi6f.cjs`);exports.createTsdownPlugin=e.t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../unplugin-
|
|
1
|
+
import{t as e}from"../unplugin-Bto10Tcc.mjs";export{e as createTsdownPlugin};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./unplugin-
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./unplugin-mnISMi6f.cjs`);require(`./helpers-LF26RHol.cjs`),require(`./plugin-pBKbb5K9.cjs`),require(`./types-o3zWarRp.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`defu`);n=e.n(n);let r=require(`@stryke/convert/parse-type-definition`),i=require(`@stryke/convert/to-array`),a=require(`@stryke/helpers/omit`),o=require(`@stryke/path/append`),s=require(`@stryke/path/replace`),c=require(`@stryke/type-checks/is-set-string`),l=require(`tsdown`);const u={platform:`neutral`,target:`esnext`,minify:!0,sourcemap:!1,cjsDefault:!0,unbundle:!0,dts:{parallel:!0,newContext:!0},shims:!0,silent:!0,treeshake:!0,fixedExtension:!0,nodeProtocol:!1};function d(e){return(0,i.toArray)(e).map(e=>{switch(e){case`cjs`:return`cjs`;case`iife`:return`iife`;case`esm`:default:return`es`}})}const f=(e,...t)=>t.filter(Boolean).join(` `).replace(RegExp(`\\[${e.config.name}\\]`,`g`),``).trim();function p(e){return(0,n.default)({entry:(0,c.isSetString)(e.config.entry)||Array.isArray(e.config.entry)&&e.config.entry.length>0?(0,i.toArray)(e.config.entry).map(e=>(0,r.parseTypeDefinition)(e)?.file).filter(Boolean):[`src/**.ts`,`src/**/*.tsx`],alias:e.builtins.reduce((t,n)=>{let r=e.fs.ids[n];return r&&(t[n]=r),t},{}),noExternal:e.builtins},e.config.build.variant===`tsdown`?e.config.build.override:{},e.config.build.variant===`tsdown`?(0,a.omit)(e.config.build,[`override`,`variant`]):{},{name:e.config.name,cwd:(0,o.appendPath)(e.config.projectRoot,e.workspaceConfig.workspaceRoot),outDir:(0,s.replacePath)((0,o.appendPath)(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),(0,o.appendPath)(e.config.projectRoot,e.workspaceConfig.workspaceRoot)),tsconfig:(0,o.appendPath)(e.tsconfig.tsconfigFilePath,e.workspaceConfig.workspaceRoot),format:d(e.config.output.format).filter(Boolean),mode:e.config.mode,treeshake:e.config.build.variant===`tsdown`||e.config.build.variant===`tsup`?e.config.build?.treeshake:e.config.build.variant===`esbuild`?e.config.build?.treeShaking:void 0,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`,debug:e.config.mode===`development`,silent:e.config.logLevel===null||e.config.mode===`production`,logLevel:e.config.logLevel===`trace`?`debug`:e.config.logLevel,customLogger:{level:e.config.logLevel===`trace`?`debug`:e.config.logLevel,info:(...t)=>(0,c.isSetString)(f(e,...t).replace(/\s+/g,``))&&e.info(f(e,...t)),warn:(...t)=>(0,c.isSetString)(f(e,...t).replace(/\s+/g,``))&&e.warn(f(e,...t)),warnOnce:(...t)=>(0,c.isSetString)(f(e,...t).replace(/\s+/g,``))&&e.warn(f(e,...t)),error:(...t)=>(0,c.isSetString)(f(e,...t).replace(/\s+/g,``))&&e.error(f(e,...t)),success:(...t)=>(0,c.isSetString)(f(e,...t).replace(/\s+/g,``))&&e.info(f(e,...t))}},u)}const m=(r={})=>({name:`tsdown`,config(){return this.log(t.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `tsdown` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...r,variant:`tsdown`}}},async build(){await(0,l.build)((0,n.default)({config:!1,plugins:[e.t(this)]},p(this)))}});var h=m;exports.createTsdownPlugin=e.t,exports.default=h,exports.plugin=m;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./unplugin-
|
|
1
|
+
import{t as e}from"./unplugin-Bto10Tcc.mjs";import"./helpers-CRPRhztf.mjs";import"./plugin-BjiGfRHE.mjs";import"./types-n6NgD0QK.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import n from"defu";import{parseTypeDefinition as r}from"@stryke/convert/parse-type-definition";import{toArray as i}from"@stryke/convert/to-array";import{omit as a}from"@stryke/helpers/omit";import{appendPath as o}from"@stryke/path/append";import{replacePath as s}from"@stryke/path/replace";import{isSetString as c}from"@stryke/type-checks/is-set-string";import{build as l}from"tsdown";const u={platform:`neutral`,target:`esnext`,minify:!0,sourcemap:!1,cjsDefault:!0,unbundle:!0,dts:{parallel:!0,newContext:!0},shims:!0,silent:!0,treeshake:!0,fixedExtension:!0,nodeProtocol:!1};function d(e){return i(e).map(e=>{switch(e){case`cjs`:return`cjs`;case`iife`:return`iife`;case`esm`:default:return`es`}})}const f=(e,...t)=>t.filter(Boolean).join(` `).replace(RegExp(`\\[${e.config.name}\\]`,`g`),``).trim();function p(e){return n({entry:c(e.config.entry)||Array.isArray(e.config.entry)&&e.config.entry.length>0?i(e.config.entry).map(e=>r(e)?.file).filter(Boolean):[`src/**.ts`,`src/**/*.tsx`],alias:e.builtins.reduce((t,n)=>{let r=e.fs.ids[n];return r&&(t[n]=r),t},{}),noExternal:e.builtins},e.config.build.variant===`tsdown`?e.config.build.override:{},e.config.build.variant===`tsdown`?a(e.config.build,[`override`,`variant`]):{},{name:e.config.name,cwd:o(e.config.projectRoot,e.workspaceConfig.workspaceRoot),outDir:s(o(e.config.output.buildPath,e.workspaceConfig.workspaceRoot),o(e.config.projectRoot,e.workspaceConfig.workspaceRoot)),tsconfig:o(e.tsconfig.tsconfigFilePath,e.workspaceConfig.workspaceRoot),format:d(e.config.output.format).filter(Boolean),mode:e.config.mode,treeshake:e.config.build.variant===`tsdown`||e.config.build.variant===`tsup`?e.config.build?.treeshake:e.config.build.variant===`esbuild`?e.config.build?.treeShaking:void 0,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`,debug:e.config.mode===`development`,silent:e.config.logLevel===null||e.config.mode===`production`,logLevel:e.config.logLevel===`trace`?`debug`:e.config.logLevel,customLogger:{level:e.config.logLevel===`trace`?`debug`:e.config.logLevel,info:(...t)=>c(f(e,...t).replace(/\s+/g,``))&&e.info(f(e,...t)),warn:(...t)=>c(f(e,...t).replace(/\s+/g,``))&&e.warn(f(e,...t)),warnOnce:(...t)=>c(f(e,...t).replace(/\s+/g,``))&&e.warn(f(e,...t)),error:(...t)=>c(f(e,...t).replace(/\s+/g,``))&&e.error(f(e,...t)),success:(...t)=>c(f(e,...t).replace(/\s+/g,``))&&e.info(f(e,...t))}},u)}const m=(r={})=>({name:`tsdown`,config(){return this.log(t.TRACE,"Providing default configuration for the Powerlines `tsdown` build plugin."),{output:{format:[`cjs`,`esm`]},build:{...r,variant:`tsdown`}}},async build(){await l(n({config:!1,plugins:[e(this)]},p(this)))}});var h=m;export{e as createTsdownPlugin,h as default,m as plugin};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["DEFAULT_TSDOWN_CONFIG: Partial<TsdownResolvedBuildConfig>","defu","defu"],"sources":["../../powerlines/src/lib/build/tsdown.ts","../src/index.ts"],"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 type { Format } from \"@storm-software/build-tools/types\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport defu from \"defu\";\nimport { Format as TsdownFormat } from \"tsdown\";\nimport {\n ESBuildBuildConfig,\n TsdownBuildConfig,\n TsdownResolvedBuildConfig,\n TsupBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\n\nexport const DEFAULT_TSDOWN_CONFIG: Partial<TsdownResolvedBuildConfig> = {\n platform: \"neutral\",\n target: \"esnext\",\n minify: true,\n sourcemap: false,\n cjsDefault: true,\n dts: {\n parallel: true,\n newContext: true\n },\n shims: true,\n silent: true,\n treeshake: true,\n fixedExtension: true,\n nodeProtocol: false\n} as const;\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveTsdownFormat(\n formats?: Format | Format[]\n): TsdownFormat[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n default:\n return \"esm\";\n }\n });\n}\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFromTsdownFormat(\n formats?: TsdownFormat | TsdownFormat[]\n): Format[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n case \"commonjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n case \"es\":\n case \"module\":\n case \"umd\":\n default:\n return \"esm\";\n }\n });\n}\n\nconst formatMessage = (context: Context, message: string) =>\n message.replace(new RegExp(`\\\\[${context.config.name}\\\\]`, \"g\"), \"\").trim();\n\n/**\n * Resolves the options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function extractTsdownConfig(\n context: Context\n): TsdownResolvedBuildConfig {\n return defu(\n {\n entry: toArray(context.config.entry)\n .map(entry => {\n const typeDef = parseTypeDefinition(entry);\n\n return typeDef?.file;\n })\n .filter(Boolean) as string[],\n alias: context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.ids[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n ),\n noExternal: context.builtins\n },\n context.config.build.variant === \"tsdown\"\n ? context.config.build.override\n : {},\n context.config.build.variant === \"tsdown\"\n ? omit(context.config.build, [\"override\", \"variant\"])\n : {},\n {\n name: context.config.name,\n cwd: appendPath(\n context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n ),\n outDir: replacePath(\n appendPath(\n context.config.output.buildPath,\n context.workspaceConfig.workspaceRoot\n ),\n appendPath(\n context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n )\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.workspaceConfig.workspaceRoot\n ),\n format: toArray(context.config.output.format)\n .map(format => (format === \"esm\" ? \"es\" : format))\n .filter(Boolean) as TsdownFormat[],\n mode: context.config.mode,\n treeshake:\n context.config.build.variant === \"tsdown\"\n ? (context.config.build as TsdownBuildConfig)?.treeshake\n : context.config.build.variant === \"tsup\"\n ? (context.config.build as TsupBuildConfig)?.treeshake\n : context.config.build.variant === \"esbuild\"\n ? (context.config.build as ESBuildBuildConfig)?.treeShaking\n : undefined,\n minify: context.config.mode !== \"development\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\",\n debug: context.config.mode === \"development\",\n silent:\n context.config.logLevel === null ||\n context.config.mode === \"production\",\n logLevel:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n customLogger: {\n level:\n context.config.logLevel === \"trace\"\n ? \"debug\"\n : context.config.logLevel,\n info: (message: string) =>\n formatMessage(context, message).replace(/\\s+/g, \"\").length > 5 &&\n context.info(formatMessage(context, message)),\n warn: (message: string) =>\n formatMessage(context, message).replace(/\\s+/g, \"\").length > 5 &&\n context.warn(formatMessage(context, message)),\n warnOnce: (message: string) =>\n formatMessage(context, message).replace(/\\s+/g, \"\").length > 5 &&\n context.warn(formatMessage(context, message)),\n error: (message: string) =>\n formatMessage(context, message).replace(/\\s+/g, \"\").length > 5 &&\n context.error(formatMessage(context, message)),\n success: (message: string) =>\n formatMessage(context, message).replace(/\\s+/g, \"\").length > 5 &&\n context.info(formatMessage(context, message))\n }\n } as TsdownResolvedBuildConfig,\n DEFAULT_TSDOWN_CONFIG\n );\n}\n","/* -------------------------------------------------------------------\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 defu from \"defu\";\nimport { extractTsdownConfig } from \"powerlines/lib/build/tsdown\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { build } from \"tsdown\";\nimport { createTsdownPlugin } from \"./helpers/unplugin\";\nimport {\n TsdownPluginContext,\n TsdownPluginOptions,\n TsdownPluginResolvedConfig\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to use Tsdown to build the project.\n */\nexport const plugin = <\n TContext extends TsdownPluginContext = TsdownPluginContext\n>(\n options: TsdownPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"tsdown\",\n config() {\n this.log(\n LogLevelLabel.TRACE,\n \"Providing default configuration for the Powerlines `tsdown` build plugin.\"\n );\n\n return {\n output: {\n format: [\"cjs\", \"esm\"]\n },\n build: {\n ...options,\n variant: \"tsdown\"\n }\n } as Partial<TsdownPluginResolvedConfig>;\n },\n async build() {\n await build(\n defu(\n {\n config: false,\n plugins: [createTsdownPlugin(this)]\n },\n extractTsdownConfig(this)\n )\n );\n }\n };\n};\n\nexport default plugin;\n"],"mappings":"2gBAkCA,MAAaA,EAA4D,CACvE,SAAU,UACV,OAAQ,SACR,OAAQ,GACR,UAAW,GACX,WAAY,GACZ,IAAK,CACH,SAAU,GACV,WAAY,GACb,CACD,MAAO,GACP,OAAQ,GACR,UAAW,GACX,eAAgB,GAChB,aAAc,GACf,CAkDK,GAAiB,EAAkB,IACvC,EAAQ,QAAY,OAAO,MAAM,EAAQ,OAAO,KAAK,K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ib/build/tsdown.ts","../src/index.ts"],"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 type { Format } from \"@storm-software/build-tools/types\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { Format as TsdownFormat } from \"tsdown\";\nimport {\n ESBuildBuildConfig,\n TsdownBuildConfig,\n TsdownResolvedBuildConfig,\n TsupBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\n\nexport const DEFAULT_TSDOWN_CONFIG: Partial<TsdownResolvedBuildConfig> = {\n platform: \"neutral\",\n target: \"esnext\",\n minify: true,\n sourcemap: false,\n cjsDefault: true,\n unbundle: true,\n dts: {\n parallel: true,\n newContext: true\n },\n shims: true,\n silent: true,\n treeshake: true,\n fixedExtension: true,\n nodeProtocol: false\n} as const;\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveTsdownFormat(\n formats?: Format | Format[]\n): TsdownFormat[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n default:\n return \"es\";\n }\n });\n}\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFromTsdownFormat(\n formats?: TsdownFormat | TsdownFormat[]\n): Format[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n case \"commonjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n case \"es\":\n case \"module\":\n case \"umd\":\n default:\n return \"esm\";\n }\n });\n}\n\nconst formatMessage = (context: Context, ...msgs: any[]) =>\n msgs\n .filter(Boolean)\n .join(\" \")\n .replace(new RegExp(`\\\\[${context.config.name}\\\\]`, \"g\"), \"\")\n .trim();\n\n/**\n * Resolves the options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function extractTsdownConfig(\n context: Context\n): TsdownResolvedBuildConfig {\n return defu(\n {\n entry:\n isSetString(context.config.entry) ||\n (Array.isArray(context.config.entry) && context.config.entry.length > 0)\n ? (toArray(context.config.entry)\n .map(entry => {\n const typeDef = parseTypeDefinition(entry);\n\n return typeDef?.file;\n })\n .filter(Boolean) as string[])\n : [\"src/**.ts\", \"src/**/*.tsx\"],\n alias: context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.ids[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n ),\n noExternal: context.builtins\n },\n context.config.build.variant === \"tsdown\"\n ? context.config.build.override\n : {},\n context.config.build.variant === \"tsdown\"\n ? omit(context.config.build, [\"override\", \"variant\"])\n : {},\n {\n name: context.config.name,\n cwd: appendPath(\n context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n ),\n outDir: replacePath(\n appendPath(\n context.config.output.buildPath,\n context.workspaceConfig.workspaceRoot\n ),\n appendPath(\n context.config.projectRoot,\n context.workspaceConfig.workspaceRoot\n )\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.workspaceConfig.workspaceRoot\n ),\n format: resolveTsdownFormat(context.config.output.format).filter(Boolean),\n mode: context.config.mode,\n treeshake:\n context.config.build.variant === \"tsdown\"\n ? (context.config.build as TsdownBuildConfig)?.treeshake\n : context.config.build.variant === \"tsup\"\n ? (context.config.build as TsupBuildConfig)?.treeshake\n : context.config.build.variant === \"esbuild\"\n ? (context.config.build as ESBuildBuildConfig)?.treeShaking\n : undefined,\n minify: context.config.mode !== \"development\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\",\n debug: context.config.mode === \"development\",\n silent:\n context.config.logLevel === null ||\n context.config.mode === \"production\",\n logLevel:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n customLogger: {\n level:\n context.config.logLevel === \"trace\"\n ? \"debug\"\n : context.config.logLevel,\n info: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.info(formatMessage(context, ...msgs)),\n warn: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n warnOnce: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n error: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.error(formatMessage(context, ...msgs)),\n success: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.info(formatMessage(context, ...msgs))\n }\n } as TsdownResolvedBuildConfig,\n DEFAULT_TSDOWN_CONFIG\n );\n}\n","/* -------------------------------------------------------------------\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 defu from \"defu\";\nimport { extractTsdownConfig } from \"powerlines/lib/build/tsdown\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { build } from \"tsdown\";\nimport { createTsdownPlugin } from \"./helpers/unplugin\";\nimport {\n TsdownPluginContext,\n TsdownPluginOptions,\n TsdownPluginResolvedConfig\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to use Tsdown to build the project.\n */\nexport const plugin = <\n TContext extends TsdownPluginContext = TsdownPluginContext\n>(\n options: TsdownPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"tsdown\",\n config() {\n this.log(\n LogLevelLabel.TRACE,\n \"Providing default configuration for the Powerlines `tsdown` build plugin.\"\n );\n\n return {\n output: {\n format: [\"cjs\", \"esm\"]\n },\n build: {\n ...options,\n variant: \"tsdown\"\n }\n } as Partial<TsdownPluginResolvedConfig>;\n },\n async build() {\n await build(\n defu(\n {\n config: false,\n plugins: [createTsdownPlugin(this)]\n },\n extractTsdownConfig(this)\n )\n );\n }\n };\n};\n\nexport default plugin;\n"],"mappings":"2kBAmCA,MAAaA,EAA4D,CACvE,SAAU,UACV,OAAQ,SACR,OAAQ,GACR,UAAW,GACX,WAAY,GACZ,SAAU,GACV,IAAK,CACH,SAAU,GACV,WAAY,GACb,CACD,MAAO,GACP,OAAQ,GACR,UAAW,GACX,eAAgB,GAChB,aAAc,GACf,CAQD,SAAgB,EACd,EACgB,CAChB,OAAO,EAAQ,EAAQ,CAAC,IAAI,GAAU,CACpC,OAAQ,EAAR,CACE,IAAK,MACH,MAAO,MACT,IAAK,OACH,MAAO,OACT,IAAK,MACL,QACE,MAAO,OAEX,CA6BJ,MAAM,GAAiB,EAAkB,GAAG,IAC1C,EACG,OAAO,QAAQ,CACf,KAAK,IAAI,CACT,QAAY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KAAK,CAAC,CACpC,CACD,EAAoB,KAAK,CAC1B,CACF,EAEJ,EAGH,IAAA,EAAe"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{LogLevelLabel as e}from"@storm-software/config-tools/types";import t,{createDefu as n,defu as r}from"defu";import{parseTypeDefinition as i}from"@stryke/convert/parse-type-definition";import{toArray as a}from"@stryke/convert/to-array";import{omit as o}from"@stryke/helpers/omit";import{appendPath as s}from"@stryke/path/append";import{replaceExtension as c,replacePath as l}from"@stryke/path/replace";import{relativeToWorkspaceRoot as ee}from"@stryke/fs/get-workspace-root";import{createRolldownPlugin as u,setParseImpl as d}from"unplugin";import{transformAsync as te}from"@babel/core";import{formatLogMessage as ne}from"@storm-software/config-tools/logger/console";import{createDirectory as re,createDirectorySync as f}from"@stryke/fs/helpers";import{install as p}from"@stryke/fs/install";import{listFiles as ie,listFilesSync as ae}from"@stryke/fs/list-files";import{doesPackageMatch as oe,getPackageListing as se,isPackageExists as ce,isPackageListed as le}from"@stryke/fs/package-fns";import{getResolutionCombinations as ue,resolve as de,resolvePackage as fe,resolveSync as pe}from"@stryke/fs/resolve";import{joinPaths as me}from"@stryke/path/join-paths";import{isError as he}from"@stryke/type-checks/is-error";import{isFunction as m}from"@stryke/type-checks/is-function";import{isNumber as ge}from"@stryke/type-checks/is-number";import{isObject as _e}from"@stryke/type-checks/is-object";import{isPromiseLike as ve}from"@stryke/type-checks/is-promise";import{isSet as ye}from"@stryke/type-checks/is-set";import{isSetObject as h}from"@stryke/type-checks/is-set-object";import{isSetString as g}from"@stryke/type-checks/is-set-string";import _ from"chalk";import be from"handlebars";import{declare as xe}from"@babel/helper-plugin-utils";import*as Se from"@babel/types";import Ce,{flattenDiagnosticMessageText as v}from"typescript";import{InMemoryFileSystemHost as y,Project as b}from"ts-morph";import{isString as x}from"@stryke/type-checks/is-string";import{getPackageName as S,getPackageVersion as C,hasPackageVersion as w}from"@stryke/string-format/package";import{getObjectDiff as T}from"@donedeal0/superdiff";import{readJsonFile as E,readJsonFileSync as D}from"@stryke/fs/json";import{StormJSON as O}from"@stryke/json/storm-json";import{findFileDotExtensionSafe as k,findFileName as A,findFilePath as we,hasFileExtension as Te,relativePath as Ee}from"@stryke/path/file-path-fns";import{titleCase as j}from"@stryke/string-format/title-case";import{exists as De,existsSync as Oe}from"@stryke/fs/exists";import{getWorkspaceConfig as ke}from"@storm-software/config-tools/get-config";import{loadConfig as Ae}from"c12";import{getEnvPaths as je}from"@stryke/env/get-env-paths";import{hashDirectory as Me}from"@stryke/hash/hash-files";import{murmurhash as Ne}from"@stryke/hash/murmurhash";import{getUnique as Pe,getUniqueBy as Fe}from"@stryke/helpers/get-unique";import{fetchRequest as Ie}from"@stryke/http/fetch";import{isAbsolute as Le,isAbsolutePath as Re}from"@stryke/path/is-type";import{joinPaths as ze}from"@stryke/path/join";import{isNull as Be}from"@stryke/type-checks/is-null";import{uuid as Ve}from"@stryke/unique-id/uuid";import{match as He,tsconfigPathsToRegExp as Ue}from"bundle-require";import{create as We}from"flat-cache";import{parse as Ge}from"oxc-parser";import{Agent as M,Response as Ke,interceptors as N,setGlobalDispatcher as P}from"undici";import{createJiti as qe}from"jiti";import{isUndefined as F}from"@stryke/type-checks/is-undefined";import{isDirectory as Je,isFile as Ye}from"@stryke/fs/is-file";import*as I from"@stryke/capnp";import{readFileBuffer as Xe,readFileBufferSync as Ze,writeFileBuffer as Qe}from"@stryke/fs/buffer";import{isParentPath as $e}from"@stryke/path/is-parent-path";import{prettyBytes as et}from"@stryke/string-format/pretty-bytes";import{Blob as tt}from"node:buffer";import{fileURLToPath as nt}from"node:url";import{format as rt,resolveConfig as it}from"prettier";import{getLogFn as at,getLogLevel as ot}from"@storm-software/config-tools/logger";import{getColor as st}from"@storm-software/config-tools/utilities/colors";import{noop as ct}from"@stryke/helpers/noop";import{correctPath as lt}from"@stryke/path/correct-path";import{slash as ut}from"@stryke/path/slash";import{readFile as dt,readFileSync as ft}from"@stryke/fs/read-file";import{writeFile as pt,writeFileSync as mt}from"@stryke/fs/write-file";import{unlinkSync as ht}from"node:fs";import{unlink as gt}from"node:fs/promises";import{resolve as _t}from"node:path";import"@stryke/fs/remove-file";import{kebabCase as L}from"@stryke/string-format/kebab-case";import"magic-string";n((e,t,n)=>x(e[t])&&x(n)?(e[t]=`${e[t]||``}\n${n||``}`.trim(),!0):!1);const R=[`new`,`clean`,`prepare`,`lint`,`test`,`build`,`docs`,`deploy`,`finalize`];function z(e){return h(e)&&`name`in e&&g(e.name)&&(F(e.applyToEnvironment)||`applyToEnvironment`in e&&m(e.applyToEnvironment))&&(F(e.dedupe)||`dedupe`in e&&m(e.dedupe))&&(F(e.dependsOn)||`dependsOn`in e&&Array.isArray(e.dependsOn)&&e.dependsOn.every(H))&&R.every(t=>F(e[t])||t in e&&(m(e[t])||h(e[t])&&`handler`in e[t]&&m(e[t].handler)))}function B(e){return h(e)&&`plugin`in e&&((g(e.plugin)||m(e.plugin))&&`options`in e&&h(e.options)||z(e.plugin))}function V(e){return Array.isArray(e)&&(e.length===1||e.length===2)&&((g(e[0])||m(e[0]))&&e.length>1&&h(e[1])||z(e[0]))}function H(e){return g(e)||m(e)||z(e)||B(e)||V(e)}var U=class extends I.Struct{static _capnp={displayName:`KeyValuePair`,id:`eabb26cf58b2a14c`,size:new I.ObjectSize(0,2)};get key(){return I.utils.getText(0,this)}set key(e){I.utils.setText(0,e,this)}get value(){return I.utils.getText(1,this)}set value(e){I.utils.setText(1,e,this)}toString(){return`FileMetadata_KeyValuePair_`+super.toString()}},W=class e extends I.Struct{static KeyValuePair=U;static _capnp={displayName:`FileMetadata`,id:`8e2cab5d7e28c7b3`,size:new I.ObjectSize(8,3),defaultType:`normal`};static _Properties;get id(){return I.utils.getText(0,this)}set id(e){I.utils.setText(0,e,this)}get type(){return I.utils.getText(1,this,e._capnp.defaultType)}set type(e){I.utils.setText(1,e,this)}get timestamp(){return I.utils.getUint32(0,this)}set timestamp(e){I.utils.setUint32(0,e,this)}_adoptProperties(e){I.utils.adopt(e,I.utils.getPointer(2,this))}_disownProperties(){return I.utils.disown(this.properties)}get properties(){return I.utils.getList(2,e._Properties,this)}_hasProperties(){return!I.utils.isNull(I.utils.getPointer(2,this))}_initProperties(t){return I.utils.initList(2,e._Properties,t,this)}set properties(e){I.utils.copyFrom(e,I.utils.getPointer(2,this))}toString(){return`FileMetadata_`+super.toString()}},G=class extends I.Struct{static _capnp={displayName:`FileId`,id:`990d6a471072f997`,size:new I.ObjectSize(0,2)};get id(){return I.utils.getText(0,this)}set id(e){I.utils.setText(0,e,this)}get path(){return I.utils.getText(1,this)}set path(e){I.utils.setText(1,e,this)}toString(){return`FileId_`+super.toString()}},K=class extends I.Struct{static _capnp={displayName:`FileStorage`,id:`9dca66ac858c9ebe`,size:new I.ObjectSize(0,2)};get path(){return I.utils.getText(0,this)}set path(e){I.utils.setText(0,e,this)}get code(){return I.utils.getText(1,this)}set code(e){I.utils.setText(1,e,this)}toString(){return`FileStorage_`+super.toString()}},q=class e extends I.Struct{static _capnp={displayName:`FileSystem`,id:`ae0c23d43e56abcf`,size:new I.ObjectSize(0,3)};static _Ids;static _Storage;static _Metadata;_adoptIds(e){I.utils.adopt(e,I.utils.getPointer(0,this))}_disownIds(){return I.utils.disown(this.ids)}get ids(){return I.utils.getList(0,e._Ids,this)}_hasIds(){return!I.utils.isNull(I.utils.getPointer(0,this))}_initIds(t){return I.utils.initList(0,e._Ids,t,this)}set ids(e){I.utils.copyFrom(e,I.utils.getPointer(0,this))}_adoptStorage(e){I.utils.adopt(e,I.utils.getPointer(1,this))}_disownStorage(){return I.utils.disown(this.storage)}get storage(){return I.utils.getList(1,e._Storage,this)}_hasStorage(){return!I.utils.isNull(I.utils.getPointer(1,this))}_initStorage(t){return I.utils.initList(1,e._Storage,t,this)}set storage(e){I.utils.copyFrom(e,I.utils.getPointer(1,this))}_adoptMetadata(e){I.utils.adopt(e,I.utils.getPointer(2,this))}_disownMetadata(){return I.utils.disown(this.metadata)}get metadata(){return I.utils.getList(2,e._Metadata,this)}_hasMetadata(){return!I.utils.isNull(I.utils.getPointer(2,this))}_initMetadata(t){return I.utils.initList(2,e._Metadata,t,this)}set metadata(e){I.utils.copyFrom(e,I.utils.getPointer(2,this))}toString(){return`FileSystem_`+super.toString()}};W._Properties=I.CompositeList(U),q._Ids=I.CompositeList(G),q._Storage=I.CompositeList(K),q._Metadata=I.CompositeList(W);const J=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],Y=(e,t)=>(n,...r)=>e(n,` ${_.inverse.hex(J[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%J.length]||J[0])(` ${j(t)} `)} ${r.join(` `)} `);Symbol.asyncDispose,Symbol.asyncDispose,P(new M({keepAliveTimeout:1e4}).compose(N.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0}))),Symbol.asyncDispose;function X(e){return e?x(e)?e:h(e)&&`code`in e?e.code:e.toString():``}function Z(e,t){return r(e,t)}function Q(t){let n=t;return d(n.parse),()=>{let t=Y(n.log,`unplugin`);t(e.DEBUG,`Initializing Unplugin`);try{async function r(){t(e.DEBUG,`Powerlines build plugin starting...`),await n.$$internal.callHook(`buildStart`,{sequential:!0})}async function i(e,t,r={isEntry:!1}){let i=await(async()=>{let i=await n.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`pre`},e,t,r);return i||(i=await n.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`normal`},e,t,r),i)||(i=await n.resolve(e,t,r),i)?i:n.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`post`},e,t,r)})();if(i&&r.isEntry&&n.config.build.polyfill&&n.config.build.polyfill.length>0){let e=n.entry.find(e=>e.file===(x(i)?i:i.id));if(e)return e.file=`${c(x(i)?i:i.id)}-polyfill.ts`,e.output||=e.output?.replace(A(e.output,{withExtension:!0}),e.file),await n.emitEntry(`
|
|
1
|
+
import{LogLevelLabel as e}from"@storm-software/config-tools/types";import t,{createDefu as n,defu as r}from"defu";import{parseTypeDefinition as i}from"@stryke/convert/parse-type-definition";import{toArray as a}from"@stryke/convert/to-array";import{omit as o}from"@stryke/helpers/omit";import{appendPath as s}from"@stryke/path/append";import{replaceExtension as c,replacePath as l}from"@stryke/path/replace";import{isSetString as u}from"@stryke/type-checks/is-set-string";import{relativeToWorkspaceRoot as ee}from"@stryke/fs/get-workspace-root";import{createRolldownPlugin as d,setParseImpl as f}from"unplugin";import{transformAsync as te}from"@babel/core";import{formatLogMessage as ne}from"@storm-software/config-tools/logger/console";import{createDirectory as p,createDirectorySync as m}from"@stryke/fs/helpers";import{install as re}from"@stryke/fs/install";import{listFiles as ie,listFilesSync as ae}from"@stryke/fs/list-files";import{doesPackageMatch as oe,getPackageListing as se,isPackageExists as ce,isPackageListed as le}from"@stryke/fs/package-fns";import{getResolutionCombinations as ue,resolve as de,resolvePackage as fe,resolveSync as pe}from"@stryke/fs/resolve";import{joinPaths as me}from"@stryke/path/join-paths";import{isError as he}from"@stryke/type-checks/is-error";import{isFunction as h}from"@stryke/type-checks/is-function";import{isNumber as ge}from"@stryke/type-checks/is-number";import{isObject as _e}from"@stryke/type-checks/is-object";import{isPromiseLike as ve}from"@stryke/type-checks/is-promise";import{isSet as ye}from"@stryke/type-checks/is-set";import{isSetObject as g}from"@stryke/type-checks/is-set-object";import _ from"chalk";import be from"handlebars";import{declare as xe}from"@babel/helper-plugin-utils";import*as Se from"@babel/types";import Ce,{flattenDiagnosticMessageText as v}from"typescript";import{InMemoryFileSystemHost as y,Project as b}from"ts-morph";import{isString as x}from"@stryke/type-checks/is-string";import{getPackageName as S,getPackageVersion as C,hasPackageVersion as w}from"@stryke/string-format/package";import{getObjectDiff as T}from"@donedeal0/superdiff";import{readJsonFile as E,readJsonFileSync as D}from"@stryke/fs/json";import{StormJSON as O}from"@stryke/json/storm-json";import{findFileDotExtensionSafe as k,findFileName as A,findFilePath as we,hasFileExtension as Te,relativePath as Ee}from"@stryke/path/file-path-fns";import{titleCase as j}from"@stryke/string-format/title-case";import{exists as De,existsSync as Oe}from"@stryke/fs/exists";import{getWorkspaceConfig as ke}from"@storm-software/config-tools/get-config";import{loadConfig as Ae}from"c12";import{getEnvPaths as je}from"@stryke/env/get-env-paths";import{hashDirectory as Me}from"@stryke/hash/hash-files";import{murmurhash as Ne}from"@stryke/hash/murmurhash";import{getUnique as Pe,getUniqueBy as Fe}from"@stryke/helpers/get-unique";import{fetchRequest as Ie}from"@stryke/http/fetch";import{isAbsolute as Le,isAbsolutePath as Re}from"@stryke/path/is-type";import{joinPaths as ze}from"@stryke/path/join";import{isNull as Be}from"@stryke/type-checks/is-null";import{uuid as Ve}from"@stryke/unique-id/uuid";import{match as He,tsconfigPathsToRegExp as Ue}from"bundle-require";import{create as We}from"flat-cache";import{parse as Ge}from"oxc-parser";import{Agent as M,Response as Ke,interceptors as N,setGlobalDispatcher as P}from"undici";import{createJiti as qe}from"jiti";import{isUndefined as F}from"@stryke/type-checks/is-undefined";import{isDirectory as Je,isFile as Ye}from"@stryke/fs/is-file";import*as I from"@stryke/capnp";import{readFileBuffer as Xe,readFileBufferSync as Ze,writeFileBuffer as Qe}from"@stryke/fs/buffer";import{isParentPath as $e}from"@stryke/path/is-parent-path";import{prettyBytes as et}from"@stryke/string-format/pretty-bytes";import{Blob as tt}from"node:buffer";import{fileURLToPath as nt}from"node:url";import{format as rt,resolveConfig as it}from"prettier";import{getLogFn as at,getLogLevel as ot}from"@storm-software/config-tools/logger";import{getColor as st}from"@storm-software/config-tools/utilities/colors";import{noop as ct}from"@stryke/helpers/noop";import{correctPath as lt}from"@stryke/path/correct-path";import{slash as ut}from"@stryke/path/slash";import{readFile as dt,readFileSync as ft}from"@stryke/fs/read-file";import{writeFile as pt,writeFileSync as mt}from"@stryke/fs/write-file";import{unlinkSync as ht}from"node:fs";import{unlink as gt}from"node:fs/promises";import{resolve as _t}from"node:path";import"@stryke/fs/remove-file";import{kebabCase as L}from"@stryke/string-format/kebab-case";import"magic-string";n((e,t,n)=>x(e[t])&&x(n)?(e[t]=`${e[t]||``}\n${n||``}`.trim(),!0):!1);const R=[`new`,`clean`,`prepare`,`lint`,`test`,`build`,`docs`,`deploy`,`finalize`];function z(e){return g(e)&&`name`in e&&u(e.name)&&(F(e.applyToEnvironment)||`applyToEnvironment`in e&&h(e.applyToEnvironment))&&(F(e.dedupe)||`dedupe`in e&&h(e.dedupe))&&(F(e.dependsOn)||`dependsOn`in e&&Array.isArray(e.dependsOn)&&e.dependsOn.every(H))&&R.every(t=>F(e[t])||t in e&&(h(e[t])||g(e[t])&&`handler`in e[t]&&h(e[t].handler)))}function B(e){return g(e)&&`plugin`in e&&((u(e.plugin)||h(e.plugin))&&`options`in e&&g(e.options)||z(e.plugin))}function V(e){return Array.isArray(e)&&(e.length===1||e.length===2)&&((u(e[0])||h(e[0]))&&e.length>1&&g(e[1])||z(e[0]))}function H(e){return u(e)||h(e)||z(e)||B(e)||V(e)}var U=class extends I.Struct{static _capnp={displayName:`KeyValuePair`,id:`eabb26cf58b2a14c`,size:new I.ObjectSize(0,2)};get key(){return I.utils.getText(0,this)}set key(e){I.utils.setText(0,e,this)}get value(){return I.utils.getText(1,this)}set value(e){I.utils.setText(1,e,this)}toString(){return`FileMetadata_KeyValuePair_`+super.toString()}},W=class e extends I.Struct{static KeyValuePair=U;static _capnp={displayName:`FileMetadata`,id:`8e2cab5d7e28c7b3`,size:new I.ObjectSize(8,3),defaultType:`normal`};static _Properties;get id(){return I.utils.getText(0,this)}set id(e){I.utils.setText(0,e,this)}get type(){return I.utils.getText(1,this,e._capnp.defaultType)}set type(e){I.utils.setText(1,e,this)}get timestamp(){return I.utils.getUint32(0,this)}set timestamp(e){I.utils.setUint32(0,e,this)}_adoptProperties(e){I.utils.adopt(e,I.utils.getPointer(2,this))}_disownProperties(){return I.utils.disown(this.properties)}get properties(){return I.utils.getList(2,e._Properties,this)}_hasProperties(){return!I.utils.isNull(I.utils.getPointer(2,this))}_initProperties(t){return I.utils.initList(2,e._Properties,t,this)}set properties(e){I.utils.copyFrom(e,I.utils.getPointer(2,this))}toString(){return`FileMetadata_`+super.toString()}},G=class extends I.Struct{static _capnp={displayName:`FileId`,id:`990d6a471072f997`,size:new I.ObjectSize(0,2)};get id(){return I.utils.getText(0,this)}set id(e){I.utils.setText(0,e,this)}get path(){return I.utils.getText(1,this)}set path(e){I.utils.setText(1,e,this)}toString(){return`FileId_`+super.toString()}},K=class extends I.Struct{static _capnp={displayName:`FileStorage`,id:`9dca66ac858c9ebe`,size:new I.ObjectSize(0,2)};get path(){return I.utils.getText(0,this)}set path(e){I.utils.setText(0,e,this)}get code(){return I.utils.getText(1,this)}set code(e){I.utils.setText(1,e,this)}toString(){return`FileStorage_`+super.toString()}},q=class e extends I.Struct{static _capnp={displayName:`FileSystem`,id:`ae0c23d43e56abcf`,size:new I.ObjectSize(0,3)};static _Ids;static _Storage;static _Metadata;_adoptIds(e){I.utils.adopt(e,I.utils.getPointer(0,this))}_disownIds(){return I.utils.disown(this.ids)}get ids(){return I.utils.getList(0,e._Ids,this)}_hasIds(){return!I.utils.isNull(I.utils.getPointer(0,this))}_initIds(t){return I.utils.initList(0,e._Ids,t,this)}set ids(e){I.utils.copyFrom(e,I.utils.getPointer(0,this))}_adoptStorage(e){I.utils.adopt(e,I.utils.getPointer(1,this))}_disownStorage(){return I.utils.disown(this.storage)}get storage(){return I.utils.getList(1,e._Storage,this)}_hasStorage(){return!I.utils.isNull(I.utils.getPointer(1,this))}_initStorage(t){return I.utils.initList(1,e._Storage,t,this)}set storage(e){I.utils.copyFrom(e,I.utils.getPointer(1,this))}_adoptMetadata(e){I.utils.adopt(e,I.utils.getPointer(2,this))}_disownMetadata(){return I.utils.disown(this.metadata)}get metadata(){return I.utils.getList(2,e._Metadata,this)}_hasMetadata(){return!I.utils.isNull(I.utils.getPointer(2,this))}_initMetadata(t){return I.utils.initList(2,e._Metadata,t,this)}set metadata(e){I.utils.copyFrom(e,I.utils.getPointer(2,this))}toString(){return`FileSystem_`+super.toString()}};W._Properties=I.CompositeList(U),q._Ids=I.CompositeList(G),q._Storage=I.CompositeList(K),q._Metadata=I.CompositeList(W);const J=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],Y=(e,t)=>(n,...r)=>e(n,` ${_.inverse.hex(J[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%J.length]||J[0])(` ${j(t)} `)} ${r.join(` `)} `);Symbol.asyncDispose,Symbol.asyncDispose,P(new M({keepAliveTimeout:1e4}).compose(N.retry({maxRetries:3,minTimeout:1e3,maxTimeout:1e4,timeoutFactor:2,retryAfter:!0}))),Symbol.asyncDispose;function X(e){return e?x(e)?e:g(e)&&`code`in e?e.code:e.toString():``}function Z(e,t){return r(e,t)}function Q(t){let n=t;return f(n.parse),()=>{let t=Y(n.log,`unplugin`);t(e.DEBUG,`Initializing Unplugin`);try{async function r(){t(e.DEBUG,`Powerlines build plugin starting...`),await n.$$internal.callHook(`buildStart`,{sequential:!0})}async function i(e,t,r={isEntry:!1}){let i=await(async()=>{let i=await n.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`pre`},e,t,r);return i||(i=await n.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`normal`},e,t,r),i)||(i=await n.resolve(e,t,r),i)?i:n.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`post`},e,t,r)})();if(i&&r.isEntry&&n.config.build.polyfill&&n.config.build.polyfill.length>0){let e=n.entry.find(e=>e.file===(x(i)?i:i.id));if(e)return e.file=`${c(x(i)?i:i.id)}-polyfill.ts`,e.output||=e.output?.replace(A(e.output,{withExtension:!0}),e.file),await n.emitEntry(`
|
|
2
2
|
${n.config.build.polyfill.map(e=>`import "${e}";`).join(`
|
|
3
3
|
`)}
|
|
4
4
|
|
|
5
5
|
export * from "${x(i)?i:i.id}";
|
|
6
|
-
`,e.file),e.file}return i}async function a(e){let t=await n.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`pre`},e);return t||(t=await n.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`normal`},e),t)||(t=await n.load(e),t)?t:n.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`post`},e)}async function o(e,t){let r=e;for(let e of n.$$internal.environment.selectHooks(`transform`)){let i=await e.handle.apply(Z(n,this),[X(r),t]);i&&(r=i)}return r}async function s(){return t(e.DEBUG,`Powerlines build plugin finishing...`),n.$$internal.callHook(`buildEnd`,{sequential:!0})}async function l(){return t(e.DEBUG,`Finalizing Powerlines project output...`),n.$$internal.callHook(`writeBundle`,{sequential:!0})}return{name:`powerlines`,api:n.$$internal.api,resolveId:{filter:{id:{include:[/.*/]}},handler:i},load:{filter:{id:{include:[/.*/]}},handler:a},transform:o,buildStart:r,buildEnd:s,writeBundle:l,vite:{sharedDuringBuild:!0}}}catch(n){throw t(e.FATAL,n?.message),n}}}function $(e){return
|
|
7
|
-
//# sourceMappingURL=unplugin-
|
|
6
|
+
`,e.file),e.file}return i}async function a(e){let t=await n.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`pre`},e);return t||(t=await n.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`normal`},e),t)||(t=await n.load(e),t)?t:n.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`post`},e)}async function o(e,t){let r=e;for(let e of n.$$internal.environment.selectHooks(`transform`)){let i=await e.handle.apply(Z(n,this),[X(r),t]);i&&(r=i)}return r}async function s(){return t(e.DEBUG,`Powerlines build plugin finishing...`),n.$$internal.callHook(`buildEnd`,{sequential:!0})}async function l(){return t(e.DEBUG,`Finalizing Powerlines project output...`),n.$$internal.callHook(`writeBundle`,{sequential:!0})}return{name:`powerlines`,api:n.$$internal.api,resolveId:{filter:{id:{include:[/.*/]}},handler:i},load:{filter:{id:{include:[/.*/]}},handler:a},transform:o,buildStart:r,buildEnd:s,writeBundle:l,vite:{sharedDuringBuild:!0}}}catch(n){throw t(e.FATAL,n?.message),n}}}function $(e){return d(Q(e))({})}export{$ as t};
|
|
7
|
+
//# sourceMappingURL=unplugin-Bto10Tcc.mjs.map
|