@torpor/unplugin 0.1.17 → 0.2.1
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/astro.d.ts +8 -6
- package/dist/astro.d.ts.map +1 -0
- package/dist/astro.js +11 -15
- package/dist/astro.js.map +1 -0
- package/dist/esbuild.d.ts +6 -4
- package/dist/esbuild.d.ts.map +1 -0
- package/dist/esbuild.js +8 -10
- package/dist/esbuild.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -11
- package/dist/nuxt.d.ts +7 -6
- package/dist/nuxt.d.ts.map +1 -0
- package/dist/nuxt.js +19 -25
- package/dist/nuxt.js.map +1 -0
- package/dist/rollup.d.ts +6 -4
- package/dist/rollup.d.ts.map +1 -0
- package/dist/rollup.js +8 -10
- package/dist/rollup.js.map +1 -0
- package/dist/rspack.d.ts +6 -4
- package/dist/rspack.d.ts.map +1 -0
- package/dist/rspack.js +8 -10
- package/dist/rspack.js.map +1 -0
- package/dist/src-DwW80l3g.js +66 -0
- package/dist/src-DwW80l3g.js.map +1 -0
- package/dist/types-ZsfXj8_y.d.ts +18 -0
- package/dist/types-ZsfXj8_y.d.ts.map +1 -0
- package/dist/types.d.ts +2 -12
- package/dist/types.js +1 -1
- package/dist/vite-CORCTD4q.js +10 -0
- package/dist/vite-CORCTD4q.js.map +1 -0
- package/dist/vite.d.ts +6 -4
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +4 -8
- package/dist/webpack-C7qBCJQK.js +10 -0
- package/dist/webpack-C7qBCJQK.js.map +1 -0
- package/dist/webpack.d.ts +6 -4
- package/dist/webpack.d.ts.map +1 -0
- package/dist/webpack.js +4 -8
- package/package.json +31 -42
- package/dist/astro.cjs +0 -21
- package/dist/astro.d.cts +0 -10
- package/dist/chunk-3FIENQ4I.js +0 -12
- package/dist/chunk-6F4PWJZI.js +0 -0
- package/dist/chunk-ERSKQZZT.js +0 -85
- package/dist/chunk-KXJKMIMY.cjs +0 -12
- package/dist/chunk-MX6XNLWQ.js +0 -12
- package/dist/chunk-RGTY2GPN.cjs +0 -12
- package/dist/chunk-WCGHWXKZ.cjs +0 -85
- package/dist/chunk-ZBPRDZS4.cjs +0 -1
- package/dist/esbuild.cjs +0 -15
- package/dist/esbuild.d.cts +0 -6
- package/dist/index.cjs +0 -12
- package/dist/index.d.cts +0 -9
- package/dist/nuxt.cjs +0 -32
- package/dist/nuxt.d.cts +0 -10
- package/dist/rollup.cjs +0 -15
- package/dist/rollup.d.cts +0 -6
- package/dist/rspack.cjs +0 -15
- package/dist/rspack.d.cts +0 -6
- package/dist/types.cjs +0 -2
- package/dist/types.d.cts +0 -12
- package/dist/vite.cjs +0 -11
- package/dist/vite.d.cts +0 -6
- package/dist/webpack.cjs +0 -11
- package/dist/webpack.d.cts +0 -6
package/dist/astro.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Options } from
|
|
1
|
+
import { t as Options } from "./types-ZsfXj8_y.js";
|
|
2
2
|
|
|
3
|
+
//#region src/astro.d.ts
|
|
3
4
|
declare const _default: (options: Options) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
name: string;
|
|
6
|
+
hooks: {
|
|
7
|
+
"astro:config:setup": (astro: any) => Promise<void>;
|
|
8
|
+
};
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
//#endregion
|
|
10
11
|
export { _default as default };
|
|
12
|
+
//# sourceMappingURL=astro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.d.ts","names":[],"sources":["../src/astro.ts"],"sourcesContent":[],"mappings":";;;cAGA,oBAAyB;;EAFA,KAEzB,EAAA;0CAG4C"}
|
package/dist/astro.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
index_default
|
|
3
|
-
} from "./chunk-ERSKQZZT.js";
|
|
4
|
-
import "./chunk-6F4PWJZI.js";
|
|
1
|
+
import { t as src_default } from "./src-DwW80l3g.js";
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
//#region src/astro.ts
|
|
7
4
|
var astro_default = (options) => ({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
}
|
|
5
|
+
name: "unplugin-torpor",
|
|
6
|
+
hooks: { "astro:config:setup": async (astro) => {
|
|
7
|
+
astro.config.vite.plugins ||= [];
|
|
8
|
+
astro.config.vite.plugins.push(src_default.vite(options));
|
|
9
|
+
} }
|
|
15
10
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { astro_default as default };
|
|
14
|
+
//# sourceMappingURL=astro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.js","names":["unplugin"],"sources":["../src/astro.ts"],"sourcesContent":["import unplugin from \".\";\nimport type Options from \"./types\";\n\nexport default (options: Options) => ({\n\tname: \"unplugin-torpor\",\n\thooks: {\n\t\t\"astro:config:setup\": async (astro: any): Promise<void> => {\n\t\t\tastro.config.vite.plugins ||= [];\n\t\t\tastro.config.vite.plugins.push(unplugin.vite(options));\n\t\t},\n\t},\n});\n"],"mappings":";;;AAGA,qBAAgB,aAAsB;CACrC,MAAM;CACN,OAAO,EACN,sBAAsB,OAAO,UAA8B;AAC1D,QAAM,OAAO,KAAK,YAAY,EAAE;AAChC,QAAM,OAAO,KAAK,QAAQ,KAAKA,YAAS,KAAK,QAAQ,CAAC;IAEvD;CACD"}
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const plugin: (options?: Options | undefined) => Plugin;
|
|
1
|
+
import { t as Options } from "./types-ZsfXj8_y.js";
|
|
2
|
+
import { Plugin } from "esbuild";
|
|
5
3
|
|
|
4
|
+
//#region src/esbuild.d.ts
|
|
5
|
+
declare const plugin: (options?: Options) => Plugin;
|
|
6
|
+
//#endregion
|
|
6
7
|
export { plugin as default };
|
|
8
|
+
//# sourceMappingURL=esbuild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.d.ts","names":["plugin: (options?: Options) => Plugin"],"sources":["../src/esbuild.ts"],"sourcesContent":[],"mappings":";;;;cAKMA,mBAAmB,YAAY"}
|
package/dist/esbuild.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
unpluginFactory
|
|
3
|
-
} from "./chunk-ERSKQZZT.js";
|
|
4
|
-
import "./chunk-6F4PWJZI.js";
|
|
5
|
-
|
|
6
|
-
// src/esbuild.ts
|
|
1
|
+
import { r as unpluginFactory } from "./src-DwW80l3g.js";
|
|
7
2
|
import { createEsbuildPlugin } from "unplugin";
|
|
8
|
-
|
|
3
|
+
|
|
4
|
+
//#region src/esbuild.ts
|
|
5
|
+
const plugin = createEsbuildPlugin(unpluginFactory);
|
|
9
6
|
var esbuild_default = plugin;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { esbuild_default as default };
|
|
10
|
+
//# sourceMappingURL=esbuild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.js","names":["plugin: (options?: Options) => Plugin"],"sources":["../src/esbuild.ts"],"sourcesContent":["import type { Plugin } from \"esbuild\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport { unpluginFactory } from \".\";\nimport type Options from \"./types\";\n\nconst plugin: (options?: Options) => Plugin = createEsbuildPlugin(unpluginFactory);\n\nexport default plugin;\n"],"mappings":";;;;AAKA,MAAMA,SAAwC,oBAAoB,gBAAgB;AAElF,sBAAe"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as Options } from "./types-ZsfXj8_y.js";
|
|
2
|
+
import { UnpluginFactory, UnpluginInstance } from "unplugin";
|
|
3
3
|
|
|
4
|
+
//#region src/index.d.ts
|
|
4
5
|
declare const unpluginFactory: UnpluginFactory<Options | undefined>;
|
|
5
6
|
declare const unplugin: UnpluginInstance<Options | undefined, boolean>;
|
|
6
|
-
|
|
7
|
+
//#endregion
|
|
7
8
|
export { unplugin as default, unplugin, unpluginFactory };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["unpluginFactory: UnpluginFactory<Options | undefined>","unplugin: UnpluginInstance<Options | undefined, boolean>"],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;cAQaA,iBAAiB,gBAAgB;cA6GjCC,UAAU,iBAAiB"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
unpluginFactory
|
|
5
|
-
} from "./chunk-ERSKQZZT.js";
|
|
6
|
-
import "./chunk-6F4PWJZI.js";
|
|
7
|
-
export {
|
|
8
|
-
index_default as default,
|
|
9
|
-
unplugin,
|
|
10
|
-
unpluginFactory
|
|
11
|
-
};
|
|
1
|
+
import { n as unplugin, r as unpluginFactory, t as src_default } from "./src-DwW80l3g.js";
|
|
2
|
+
|
|
3
|
+
export { src_default as default, unplugin, unpluginFactory };
|
package/dist/nuxt.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as Options } from "./types-ZsfXj8_y.js";
|
|
2
|
+
import { NuxtModule } from "@nuxt/schema";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
}
|
|
4
|
+
//#region src/nuxt.d.ts
|
|
5
|
+
interface ModuleOptions extends Options {}
|
|
6
6
|
declare const plugin: NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
7
|
-
|
|
8
|
-
export {
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ModuleOptions, plugin as default };
|
|
9
|
+
//# sourceMappingURL=nuxt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt.d.ts","names":["plugin: NuxtModule<ModuleOptions, ModuleOptions, false>"],"sources":["../src/nuxt.ts"],"sourcesContent":[],"mappings":";;;;UAOiB,aAAA,SAAsB;AAAvC,cAEMA,MAFW,EAEH,UAFyB,CAEd,aAFc,EAEC,aAFD,EAAA,KAAA,CAAA"}
|
package/dist/nuxt.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
} from "./
|
|
4
|
-
import {
|
|
5
|
-
vite_default
|
|
6
|
-
} from "./chunk-MX6XNLWQ.js";
|
|
7
|
-
import "./chunk-ERSKQZZT.js";
|
|
8
|
-
import "./chunk-6F4PWJZI.js";
|
|
9
|
-
|
|
10
|
-
// src/nuxt.ts
|
|
1
|
+
import "./src-DwW80l3g.js";
|
|
2
|
+
import { t as vite_default } from "./vite-CORCTD4q.js";
|
|
3
|
+
import { t as webpack_default } from "./webpack-C7qBCJQK.js";
|
|
11
4
|
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
|
|
12
5
|
import "@nuxt/schema";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
|
|
7
|
+
//#region src/nuxt.ts
|
|
8
|
+
const plugin = defineNuxtModule({
|
|
9
|
+
meta: {
|
|
10
|
+
name: "nuxt-unplugin-torpor",
|
|
11
|
+
configKey: "unpluginStarter"
|
|
12
|
+
},
|
|
13
|
+
defaults: {},
|
|
14
|
+
setup(options, _nuxt) {
|
|
15
|
+
addVitePlugin(() => vite_default(options));
|
|
16
|
+
addWebpackPlugin(() => webpack_default(options));
|
|
17
|
+
}
|
|
25
18
|
});
|
|
26
19
|
var nuxt_default = plugin;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { nuxt_default as default };
|
|
23
|
+
//# sourceMappingURL=nuxt.js.map
|
package/dist/nuxt.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt.js","names":["plugin: NuxtModule<ModuleOptions, ModuleOptions, false>","vite","webpack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from \"@nuxt/kit\";\nimport \"@nuxt/schema\";\nimport type { NuxtModule } from \"@nuxt/schema\";\nimport type Options from \"./types\";\nimport vite from \"./vite\";\nimport webpack from \"./webpack\";\n\nexport interface ModuleOptions extends Options {}\n\nconst plugin: NuxtModule<ModuleOptions, ModuleOptions, false> = defineNuxtModule<ModuleOptions>({\n\tmeta: {\n\t\tname: \"nuxt-unplugin-torpor\",\n\t\tconfigKey: \"unpluginStarter\",\n\t},\n\tdefaults: {\n\t\t// ...default options\n\t},\n\tsetup(options, _nuxt) {\n\t\taddVitePlugin(() => vite(options));\n\t\taddWebpackPlugin(() => webpack(options));\n\n\t\t// ...\n\t},\n});\n\nexport default plugin;\n"],"mappings":";;;;;;;AASA,MAAMA,SAA0D,iBAAgC;CAC/F,MAAM;EACL,MAAM;EACN,WAAW;EACX;CACD,UAAU,EAET;CACD,MAAM,SAAS,OAAO;AACrB,sBAAoBC,aAAK,QAAQ,CAAC;AAClC,yBAAuBC,gBAAQ,QAAQ,CAAC;;CAIzC,CAAC;AAEF,mBAAe"}
|
package/dist/rollup.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const plugin: (options?: Options | undefined) => Plugin<any> | Plugin<any>[];
|
|
1
|
+
import { t as Options } from "./types-ZsfXj8_y.js";
|
|
2
|
+
import { Plugin } from "rollup";
|
|
5
3
|
|
|
4
|
+
//#region src/rollup.d.ts
|
|
5
|
+
declare const plugin: (options?: Options) => Plugin<any> | Plugin<any>[];
|
|
6
|
+
//#endregion
|
|
6
7
|
export { plugin as default };
|
|
8
|
+
//# sourceMappingURL=rollup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup.d.ts","names":["plugin: (options?: Options) => Plugin<any> | Plugin<any>[]"],"sources":["../src/rollup.ts"],"sourcesContent":[],"mappings":";;;;cAKMA,mBAAmB,YAAY,cAAc"}
|
package/dist/rollup.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
unpluginFactory
|
|
3
|
-
} from "./chunk-ERSKQZZT.js";
|
|
4
|
-
import "./chunk-6F4PWJZI.js";
|
|
5
|
-
|
|
6
|
-
// src/rollup.ts
|
|
1
|
+
import { r as unpluginFactory } from "./src-DwW80l3g.js";
|
|
7
2
|
import { createRollupPlugin } from "unplugin";
|
|
8
|
-
|
|
3
|
+
|
|
4
|
+
//#region src/rollup.ts
|
|
5
|
+
const plugin = createRollupPlugin(unpluginFactory);
|
|
9
6
|
var rollup_default = plugin;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { rollup_default as default };
|
|
10
|
+
//# sourceMappingURL=rollup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup.js","names":["plugin: (options?: Options) => Plugin<any> | Plugin<any>[]"],"sources":["../src/rollup.ts"],"sourcesContent":["import type { Plugin } from \"rollup\";\nimport { createRollupPlugin } from \"unplugin\";\nimport { unpluginFactory } from \".\";\nimport type Options from \"./types\";\n\nconst plugin: (options?: Options) => Plugin<any> | Plugin<any>[] =\n\tcreateRollupPlugin(unpluginFactory);\n\nexport default plugin;\n"],"mappings":";;;;AAKA,MAAMA,SACL,mBAAmB,gBAAgB;AAEpC,qBAAe"}
|
package/dist/rspack.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const plugin: (options?: Options | undefined) => RspackPluginInstance;
|
|
1
|
+
import { t as Options } from "./types-ZsfXj8_y.js";
|
|
2
|
+
import { RspackPluginInstance } from "unplugin";
|
|
5
3
|
|
|
4
|
+
//#region src/rspack.d.ts
|
|
5
|
+
declare const plugin: (options?: Options) => RspackPluginInstance;
|
|
6
|
+
//#endregion
|
|
6
7
|
export { plugin as default };
|
|
8
|
+
//# sourceMappingURL=rspack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rspack.d.ts","names":["plugin: (options?: Options) => RspackPluginInstance"],"sources":["../src/rspack.ts"],"sourcesContent":[],"mappings":";;;;cAIMA,mBAAmB,YAAY"}
|
package/dist/rspack.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
unpluginFactory
|
|
3
|
-
} from "./chunk-ERSKQZZT.js";
|
|
4
|
-
import "./chunk-6F4PWJZI.js";
|
|
5
|
-
|
|
6
|
-
// src/rspack.ts
|
|
1
|
+
import { r as unpluginFactory } from "./src-DwW80l3g.js";
|
|
7
2
|
import { createRspackPlugin } from "unplugin";
|
|
8
|
-
|
|
3
|
+
|
|
4
|
+
//#region src/rspack.ts
|
|
5
|
+
const plugin = createRspackPlugin(unpluginFactory);
|
|
9
6
|
var rspack_default = plugin;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { rspack_default as default };
|
|
10
|
+
//# sourceMappingURL=rspack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rspack.js","names":["plugin: (options?: Options) => RspackPluginInstance"],"sources":["../src/rspack.ts"],"sourcesContent":["import { type RspackPluginInstance, createRspackPlugin } from \"unplugin\";\nimport { unpluginFactory } from \".\";\nimport type Options from \"./types\";\n\nconst plugin: (options?: Options) => RspackPluginInstance = createRspackPlugin(unpluginFactory);\n\nexport default plugin;\n"],"mappings":";;;;AAIA,MAAMA,SAAsD,mBAAmB,gBAAgB;AAE/F,qBAAe"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { build, parse } from "@torpor/view/compile";
|
|
2
|
+
import { createUnplugin } from "unplugin";
|
|
3
|
+
import { transformWithEsbuild } from "vite";
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
const styles = /* @__PURE__ */ new Map();
|
|
7
|
+
const unpluginFactory = (options) => ({
|
|
8
|
+
name: "unplugin-torpor",
|
|
9
|
+
resolveId(id) {
|
|
10
|
+
if (styles.has(id)) return id;
|
|
11
|
+
},
|
|
12
|
+
load(id) {
|
|
13
|
+
if (styles.has(id)) return styles.get(id);
|
|
14
|
+
},
|
|
15
|
+
transformInclude(id) {
|
|
16
|
+
return /\.torp\?*/.test(id);
|
|
17
|
+
},
|
|
18
|
+
transform(code, id, viteOptions) {
|
|
19
|
+
if (viteOptions && viteOptions.dev !== void 0) {
|
|
20
|
+
options ??= {};
|
|
21
|
+
options.dev = viteOptions.dev;
|
|
22
|
+
}
|
|
23
|
+
if (viteOptions && viteOptions.ssr !== void 0) {
|
|
24
|
+
options ??= {};
|
|
25
|
+
options.server = viteOptions.ssr;
|
|
26
|
+
}
|
|
27
|
+
if (options?.test) options.server = true;
|
|
28
|
+
let parsed = parse(code);
|
|
29
|
+
if (parsed.ok && parsed.template) return transform(parsed.template, id, options);
|
|
30
|
+
else {
|
|
31
|
+
let name = id.split(/[\\/]/).at(-1).replace(/\.torp$/, "");
|
|
32
|
+
let errorMessages = parsed.errors.map((e) => `${e.startLine + 1},${e.startChar}: ${e.message}`);
|
|
33
|
+
console.log(`\nERRORS: ${id}\n======\n${errorMessages.join("\n")}`);
|
|
34
|
+
let errorParsed = parse(`
|
|
35
|
+
export default function Error() {
|
|
36
|
+
@render {
|
|
37
|
+
<div style="background-color: #222; color: #f44"; font-size: 15px; line-height: 1.5;">
|
|
38
|
+
<p style="margin: 0; padding: 0;">
|
|
39
|
+
<strong>Error${parsed.errors.length === 1 ? "" : "s"} in ${name}:</strong>
|
|
40
|
+
</p>
|
|
41
|
+
<ul style="margin: 0; padding: 0 20px">
|
|
42
|
+
${errorMessages.map((e) => `<li>${e}</li>`).join("\n")}
|
|
43
|
+
</ul>
|
|
44
|
+
</div>
|
|
45
|
+
}
|
|
46
|
+
}`);
|
|
47
|
+
if (errorParsed.ok && errorParsed.template) return transform(errorParsed.template, id, options);
|
|
48
|
+
throw new Error(`Parse failed for ${id}, ${errorMessages.join("\n")}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
function transform(template, id, options) {
|
|
53
|
+
const built = build(template, options);
|
|
54
|
+
let transformed = built.code;
|
|
55
|
+
if (built.styles) for (let style of built.styles) {
|
|
56
|
+
transformed = `import '${style.hash}.css';\n` + transformed;
|
|
57
|
+
styles.set(style.hash + ".css", style.style);
|
|
58
|
+
}
|
|
59
|
+
return transformWithEsbuild(transformed, id, { loader: "ts" });
|
|
60
|
+
}
|
|
61
|
+
const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
62
|
+
var src_default = unplugin;
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { unplugin as n, unpluginFactory as r, src_default as t };
|
|
66
|
+
//# sourceMappingURL=src-DwW80l3g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-DwW80l3g.js","names":["unpluginFactory: UnpluginFactory<Options | undefined>","unplugin: UnpluginInstance<Options | undefined, boolean>"],"sources":["../src/index.ts"],"sourcesContent":["import { type Template, build, parse } from \"@torpor/view/compile\";\nimport { type UnpluginFactory, type UnpluginInstance } from \"unplugin\";\nimport { createUnplugin } from \"unplugin\";\nimport { transformWithEsbuild } from \"vite\";\nimport type Options from \"./types\";\n\nconst styles = new Map<string, string>();\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options) => ({\n\tname: \"unplugin-torpor\",\n\tresolveId(id /*, importer, options*/) {\n\t\tif (styles.has(id)) {\n\t\t\treturn id;\n\t\t}\n\t\treturn undefined;\n\t},\n\tload(id) {\n\t\tif (styles.has(id)) {\n\t\t\treturn styles.get(id);\n\t\t}\n\t\treturn undefined;\n\t},\n\ttransformInclude(id) {\n\t\t// Check for *.torp files\n\t\treturn /\\.torp\\?*/.test(id);\n\t},\n\t// @ts-ignore\n\ttransform(code, id, viteOptions) {\n\t\t// We may be in dev mode\n\t\tif (viteOptions && viteOptions.dev !== undefined) {\n\t\t\toptions ??= {};\n\t\t\toptions.dev = viteOptions.dev;\n\t\t}\n\n\t\t// Vite can override user server options\n\t\tif (viteOptions && viteOptions.ssr !== undefined) {\n\t\t\toptions ??= {};\n\t\t\toptions.server = viteOptions.ssr;\n\t\t}\n\n\t\t// But when testing we always generate for the server\n\t\tif (options?.test) {\n\t\t\toptions.server = true;\n\t\t}\n\n\t\t// Try to parse the code\n\t\tlet parsed = parse(code);\n\t\tif (parsed.ok && parsed.template) {\n\t\t\t// Transform for server or client\n\t\t\treturn transform(parsed.template, id, options);\n\t\t} else {\n\t\t\t// Show an error component\n\t\t\tlet name = id\n\t\t\t\t.split(/[\\\\/]/)\n\t\t\t\t.at(-1)\n\t\t\t\t.replace(/\\.torp$/, \"\")!;\n\t\t\tlet errorMessages = parsed.errors.map(\n\t\t\t\t(e) => `${e.startLine + 1},${e.startChar}: ${e.message}`,\n\t\t\t);\n\t\t\tconsole.log(`\\nERRORS: ${id}\\n======\\n${errorMessages.join(\"\\n\")}`);\n\t\t\tlet errorCode = `\nexport default function Error() {\n\t@render {\n\t\t<div style=\"background-color: #222; color: #f44\"; font-size: 15px; line-height: 1.5;\">\n\t\t\t<p style=\"margin: 0; padding: 0;\">\n\t\t\t\t<strong>Error${parsed.errors.length === 1 ? \"\" : \"s\"} in ${name}:</strong>\n\t\t\t</p>\n\t\t\t<ul style=\"margin: 0; padding: 0 20px\">\n\t\t\t\t${errorMessages.map((e) => `<li>${e}</li>`).join(\"\\n\")}\n\t\t\t</ul>\n\t\t</div>\n\t}\n}`;\n\t\t\tlet errorParsed = parse(errorCode);\n\t\t\tif (errorParsed.ok && errorParsed.template) {\n\t\t\t\treturn transform(errorParsed.template, id, options);\n\t\t\t}\n\t\t\t// This should never be reached, but just in case...\n\t\t\tthrow new Error(`Parse failed for ${id}, ${errorMessages.join(\"\\n\")}`);\n\t\t}\n\t},\n});\n\nfunction transform(template: Template, id: string, options?: Options) {\n\tconst built = build(template, options);\n\tlet transformed = built.code;\n\n\tif (built.styles) {\n\t\tfor (let style of built.styles) {\n\t\t\t// Add a dynamic import for the component's CSS with a name from\n\t\t\t// the hash and add the styles to a map. Then resolveId will\n\t\t\t// pass the CSS id onto load, which will load the the actual CSS\n\t\t\t// from the map\n\t\t\ttransformed = `import '${style.hash}.css';\\n` + transformed;\n\t\t\tstyles.set(style.hash + \".css\", style.style);\n\t\t}\n\t}\n\n\t//printTransformed(transformed);\n\n\t// TODO: Compile typescript only if script lang=\"ts\" or config.lang=\"ts\"\n\treturn transformWithEsbuild(transformed, id, {\n\t\tloader: \"ts\",\n\t});\n}\n\n/*\nfunction printTransformed(transformed: string) {\n\tconsole.log(\n\t\ttransformed\n\t\t\t.split(\"\\n\")\n\t\t\t.map((l, i) => `${(i + 1).toString().padEnd(3)} ${l}`)\n\t\t\t.join(\"\\n\"),\n\t);\n}\n*/\n\nexport const unplugin: UnpluginInstance<Options | undefined, boolean> =\n\t/* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;AAMA,MAAM,yBAAS,IAAI,KAAqB;AAExC,MAAaA,mBAAyD,aAAa;CAClF,MAAM;CACN,UAAU,IAA4B;AACrC,MAAI,OAAO,IAAI,GAAG,CACjB,QAAO;;CAIT,KAAK,IAAI;AACR,MAAI,OAAO,IAAI,GAAG,CACjB,QAAO,OAAO,IAAI,GAAG;;CAIvB,iBAAiB,IAAI;AAEpB,SAAO,YAAY,KAAK,GAAG;;CAG5B,UAAU,MAAM,IAAI,aAAa;AAEhC,MAAI,eAAe,YAAY,QAAQ,QAAW;AACjD,eAAY,EAAE;AACd,WAAQ,MAAM,YAAY;;AAI3B,MAAI,eAAe,YAAY,QAAQ,QAAW;AACjD,eAAY,EAAE;AACd,WAAQ,SAAS,YAAY;;AAI9B,MAAI,SAAS,KACZ,SAAQ,SAAS;EAIlB,IAAI,SAAS,MAAM,KAAK;AACxB,MAAI,OAAO,MAAM,OAAO,SAEvB,QAAO,UAAU,OAAO,UAAU,IAAI,QAAQ;OACxC;GAEN,IAAI,OAAO,GACT,MAAM,QAAQ,CACd,GAAG,GAAG,CACN,QAAQ,WAAW,GAAG;GACxB,IAAI,gBAAgB,OAAO,OAAO,KAChC,MAAM,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,IAAI,EAAE,UAC/C;AACD,WAAQ,IAAI,aAAa,GAAG,YAAY,cAAc,KAAK,KAAK,GAAG;GAcnE,IAAI,cAAc,MAbF;;;;;mBAKA,OAAO,OAAO,WAAW,IAAI,KAAK,IAAI,MAAM,KAAK;;;MAG9D,cAAc,KAAK,MAAM,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,CAAC;;;;GAKtB;AAClC,OAAI,YAAY,MAAM,YAAY,SACjC,QAAO,UAAU,YAAY,UAAU,IAAI,QAAQ;AAGpD,SAAM,IAAI,MAAM,oBAAoB,GAAG,IAAI,cAAc,KAAK,KAAK,GAAG;;;CAGxE;AAED,SAAS,UAAU,UAAoB,IAAY,SAAmB;CACrE,MAAM,QAAQ,MAAM,UAAU,QAAQ;CACtC,IAAI,cAAc,MAAM;AAExB,KAAI,MAAM,OACT,MAAK,IAAI,SAAS,MAAM,QAAQ;AAK/B,gBAAc,WAAW,MAAM,KAAK,YAAY;AAChD,SAAO,IAAI,MAAM,OAAO,QAAQ,MAAM,MAAM;;AAO9C,QAAO,qBAAqB,aAAa,IAAI,EAC5C,QAAQ,MACR,CAAC;;AAcH,MAAaC,WACI,+BAAe,gBAAgB;AAEhD,kBAAe"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
interface Options {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to generate server components which will render HTML
|
|
5
|
+
*/
|
|
6
|
+
server?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the plugin is running in a dev environment
|
|
9
|
+
*/
|
|
10
|
+
dev?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the plugin is running in a test context
|
|
13
|
+
*/
|
|
14
|
+
test?: boolean;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Options as t };
|
|
18
|
+
//# sourceMappingURL=types-ZsfXj8_y.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-ZsfXj8_y.d.ts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";UAAyB,OAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Whether to generate server components which will render HTML
|
|
4
|
-
*/
|
|
5
|
-
server?: boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Whether the plugin is running in a test context
|
|
8
|
-
*/
|
|
9
|
-
test?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type { Options };
|
|
1
|
+
import { t as Options } from "./types-ZsfXj8_y.js";
|
|
2
|
+
export { Options as default };
|
package/dist/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { r as unpluginFactory } from "./src-DwW80l3g.js";
|
|
2
|
+
import { createVitePlugin } from "unplugin";
|
|
3
|
+
|
|
4
|
+
//#region src/vite.ts
|
|
5
|
+
const plugin = createVitePlugin(unpluginFactory);
|
|
6
|
+
var vite_default = plugin;
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { vite_default as t };
|
|
10
|
+
//# sourceMappingURL=vite-CORCTD4q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-CORCTD4q.js","names":["plugin: (options?: Options) => Plugin<any> | Plugin<any>[]"],"sources":["../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from \"unplugin\";\nimport type { Plugin } from \"vite\";\nimport { unpluginFactory } from \".\";\nimport type Options from \"./types\";\n\nconst plugin: (options?: Options) => Plugin<any> | Plugin<any>[] =\n\tcreateVitePlugin(unpluginFactory);\n\nexport default plugin;\n"],"mappings":";;;;AAKA,MAAMA,SACL,iBAAiB,gBAAgB;AAElC,mBAAe"}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const plugin: (options?: Options | undefined) => Plugin<any> | Plugin<any>[];
|
|
1
|
+
import { t as Options } from "./types-ZsfXj8_y.js";
|
|
2
|
+
import { Plugin } from "vite";
|
|
5
3
|
|
|
4
|
+
//#region src/vite.d.ts
|
|
5
|
+
declare const plugin: (options?: Options) => Plugin<any> | Plugin<any>[];
|
|
6
|
+
//#endregion
|
|
6
7
|
export { plugin as default };
|
|
8
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","names":["plugin: (options?: Options) => Plugin<any> | Plugin<any>[]"],"sources":["../src/vite.ts"],"sourcesContent":[],"mappings":";;;;cAKMA,mBAAmB,YAAY,cAAc"}
|
package/dist/vite.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import "./chunk-6F4PWJZI.js";
|
|
6
|
-
export {
|
|
7
|
-
vite_default as default
|
|
8
|
-
};
|
|
1
|
+
import "./src-DwW80l3g.js";
|
|
2
|
+
import { t as vite_default } from "./vite-CORCTD4q.js";
|
|
3
|
+
|
|
4
|
+
export { vite_default as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { r as unpluginFactory } from "./src-DwW80l3g.js";
|
|
2
|
+
import { createWebpackPlugin } from "unplugin";
|
|
3
|
+
|
|
4
|
+
//#region src/webpack.ts
|
|
5
|
+
const plugin = createWebpackPlugin(unpluginFactory);
|
|
6
|
+
var webpack_default = plugin;
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { webpack_default as t };
|
|
10
|
+
//# sourceMappingURL=webpack-C7qBCJQK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack-C7qBCJQK.js","names":["plugin: (options?: Options) => WebpackPluginInstance"],"sources":["../src/webpack.ts"],"sourcesContent":["import { type WebpackPluginInstance, createWebpackPlugin } from \"unplugin\";\nimport { unpluginFactory } from \".\";\nimport type Options from \"./types\";\n\nconst plugin: (options?: Options) => WebpackPluginInstance = createWebpackPlugin(unpluginFactory);\n\nexport default plugin;\n"],"mappings":";;;;AAIA,MAAMA,SAAuD,oBAAoB,gBAAgB;AAEjG,sBAAe"}
|
package/dist/webpack.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const plugin: (options?: Options | undefined) => WebpackPluginInstance;
|
|
1
|
+
import { t as Options } from "./types-ZsfXj8_y.js";
|
|
2
|
+
import { WebpackPluginInstance } from "unplugin";
|
|
5
3
|
|
|
4
|
+
//#region src/webpack.d.ts
|
|
5
|
+
declare const plugin: (options?: Options) => WebpackPluginInstance;
|
|
6
|
+
//#endregion
|
|
6
7
|
export { plugin as default };
|
|
8
|
+
//# sourceMappingURL=webpack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","names":["plugin: (options?: Options) => WebpackPluginInstance"],"sources":["../src/webpack.ts"],"sourcesContent":[],"mappings":";;;;cAIMA,mBAAmB,YAAY"}
|
package/dist/webpack.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import "./chunk-6F4PWJZI.js";
|
|
6
|
-
export {
|
|
7
|
-
webpack_default as default
|
|
8
|
-
};
|
|
1
|
+
import "./src-DwW80l3g.js";
|
|
2
|
+
import { t as webpack_default } from "./webpack-C7qBCJQK.js";
|
|
3
|
+
|
|
4
|
+
export { webpack_default as default };
|
package/package.json
CHANGED
|
@@ -1,63 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@torpor/unplugin",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.1.17",
|
|
3
|
+
"version": "0.2.1",
|
|
5
4
|
"description": "Unplugin package to compile Torpor components for Vite, Rollup, and other bundlers",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"torpor",
|
|
8
7
|
"unplugin"
|
|
9
8
|
],
|
|
9
|
+
"type": "module",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.js"
|
|
14
|
-
"require": "./dist/index.cjs"
|
|
13
|
+
"import": "./dist/index.js"
|
|
15
14
|
},
|
|
16
15
|
"./astro": {
|
|
17
16
|
"types": "./dist/astro.d.ts",
|
|
18
|
-
"import": "./dist/astro.js"
|
|
19
|
-
"require": "./dist/astro.cjs"
|
|
17
|
+
"import": "./dist/astro.js"
|
|
20
18
|
},
|
|
21
19
|
"./rspack": {
|
|
22
20
|
"types": "./dist/rspack.d.ts",
|
|
23
|
-
"import": "./dist/rspack.js"
|
|
24
|
-
"require": "./dist/rspack.cjs"
|
|
21
|
+
"import": "./dist/rspack.js"
|
|
25
22
|
},
|
|
26
23
|
"./vite": {
|
|
27
24
|
"types": "./dist/vite.d.ts",
|
|
28
|
-
"import": "./dist/vite.js"
|
|
29
|
-
"require": "./dist/vite.cjs"
|
|
25
|
+
"import": "./dist/vite.js"
|
|
30
26
|
},
|
|
31
27
|
"./webpack": {
|
|
32
28
|
"types": "./dist/webpack.d.ts",
|
|
33
|
-
"import": "./dist/webpack.js"
|
|
34
|
-
"require": "./dist/webpack.cjs"
|
|
29
|
+
"import": "./dist/webpack.js"
|
|
35
30
|
},
|
|
36
31
|
"./rollup": {
|
|
37
32
|
"types": "./dist/rollup.d.ts",
|
|
38
|
-
"import": "./dist/rollup.js"
|
|
39
|
-
"require": "./dist/rollup.cjs"
|
|
33
|
+
"import": "./dist/rollup.js"
|
|
40
34
|
},
|
|
41
35
|
"./esbuild": {
|
|
42
36
|
"types": "./dist/esbuild.d.ts",
|
|
43
|
-
"import": "./dist/esbuild.js"
|
|
44
|
-
"require": "./dist/esbuild.cjs"
|
|
37
|
+
"import": "./dist/esbuild.js"
|
|
45
38
|
},
|
|
46
39
|
"./nuxt": {
|
|
47
40
|
"types": "./dist/nuxt.d.ts",
|
|
48
|
-
"import": "./dist/nuxt.js"
|
|
49
|
-
"require": "./dist/nuxt.cjs"
|
|
41
|
+
"import": "./dist/nuxt.js"
|
|
50
42
|
},
|
|
51
43
|
"./types": {
|
|
52
44
|
"types": "./dist/types.d.ts",
|
|
53
|
-
"import": "./dist/types.js"
|
|
54
|
-
"require": "./dist/types.cjs"
|
|
45
|
+
"import": "./dist/types.js"
|
|
55
46
|
},
|
|
56
47
|
"./*": "./*"
|
|
57
48
|
},
|
|
58
|
-
"main": "dist/index.cjs",
|
|
59
|
-
"module": "dist/index.js",
|
|
60
|
-
"types": "dist/index.d.ts",
|
|
61
49
|
"typesVersions": {
|
|
62
50
|
"*": {
|
|
63
51
|
"*": [
|
|
@@ -101,35 +89,36 @@
|
|
|
101
89
|
}
|
|
102
90
|
},
|
|
103
91
|
"dependencies": {
|
|
104
|
-
"unplugin": "^2.3.
|
|
105
|
-
"@torpor/view": "^0.
|
|
92
|
+
"unplugin": "^2.3.10",
|
|
93
|
+
"@torpor/view": "^0.4.0"
|
|
106
94
|
},
|
|
107
95
|
"devDependencies": {
|
|
108
|
-
"@antfu/eslint-config": "^
|
|
109
|
-
"@nuxt/kit": "^4.0
|
|
110
|
-
"@nuxt/schema": "^4.0
|
|
96
|
+
"@antfu/eslint-config": "^6.1.0",
|
|
97
|
+
"@nuxt/kit": "^4.2.0",
|
|
98
|
+
"@nuxt/schema": "^4.2.0",
|
|
111
99
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
112
|
-
"@types/node": "^24.2
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
100
|
+
"@types/node": "^24.9.2",
|
|
101
|
+
"@typescript/native-preview": "7.0.0-dev.20251027.1",
|
|
102
|
+
"bumpp": "^10.3.1",
|
|
103
|
+
"chalk": "^5.6.2",
|
|
104
|
+
"eslint": "^9.38.0",
|
|
116
105
|
"esno": "^4.8.0",
|
|
117
106
|
"fast-glob": "^3.3.3",
|
|
118
107
|
"nodemon": "^3.1.10",
|
|
108
|
+
"oxlint-tsgolint": "^0.3.0",
|
|
119
109
|
"prettier": "^3.6.2",
|
|
120
110
|
"rimraf": "^6.0.1",
|
|
121
|
-
"rollup": "^4.
|
|
122
|
-
"
|
|
123
|
-
"typescript": "^5.9.
|
|
124
|
-
"vite": "^7.1.
|
|
125
|
-
"vitest": "^
|
|
126
|
-
"webpack": "^5.
|
|
111
|
+
"rollup": "^4.52.5",
|
|
112
|
+
"tsdown": "^0.15.11",
|
|
113
|
+
"typescript": "^5.9.3",
|
|
114
|
+
"vite": "^7.1.12",
|
|
115
|
+
"vitest": "^4.0.4",
|
|
116
|
+
"webpack": "^5.102.1"
|
|
127
117
|
},
|
|
128
118
|
"scripts": {
|
|
129
|
-
"build": "
|
|
130
|
-
"build:watch": "
|
|
131
|
-
"
|
|
132
|
-
"check": "tsc --noEmit",
|
|
119
|
+
"build": "tsgo --noEmit && tsdown",
|
|
120
|
+
"build:watch": "tsdown --watch src",
|
|
121
|
+
"check": "tsgo --noEmit && pnpm dlx oxlint --type-aware",
|
|
133
122
|
"lint": "eslint .",
|
|
134
123
|
"play": "npm -C playground run dev",
|
|
135
124
|
"release": "bumpp && npm publish",
|
package/dist/astro.cjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkWCGHWXKZcjs = require('./chunk-WCGHWXKZ.cjs');
|
|
4
|
-
require('./chunk-ZBPRDZS4.cjs');
|
|
5
|
-
|
|
6
|
-
// src/astro.ts
|
|
7
|
-
var astro_default = (options) => ({
|
|
8
|
-
name: "unplugin-torpor",
|
|
9
|
-
hooks: {
|
|
10
|
-
"astro:config:setup": async (astro) => {
|
|
11
|
-
astro.config.vite.plugins ||= [];
|
|
12
|
-
astro.config.vite.plugins.push(_chunkWCGHWXKZcjs.index_default.vite(options));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
module.exports = astro_default;
|
|
19
|
-
|
|
20
|
-
module.exports = exports.default;
|
|
21
|
-
exports.default = module.exports;
|
package/dist/astro.d.cts
DELETED
package/dist/chunk-3FIENQ4I.js
DELETED
package/dist/chunk-6F4PWJZI.js
DELETED
|
File without changes
|
package/dist/chunk-ERSKQZZT.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import { build, parse } from "@torpor/view/compile";
|
|
3
|
-
import "unplugin";
|
|
4
|
-
import { createUnplugin } from "unplugin";
|
|
5
|
-
import { transformWithEsbuild } from "vite";
|
|
6
|
-
var styles = /* @__PURE__ */ new Map();
|
|
7
|
-
var unpluginFactory = (options) => ({
|
|
8
|
-
name: "unplugin-torpor",
|
|
9
|
-
resolveId(id) {
|
|
10
|
-
if (styles.has(id)) {
|
|
11
|
-
return id;
|
|
12
|
-
}
|
|
13
|
-
return void 0;
|
|
14
|
-
},
|
|
15
|
-
load(id) {
|
|
16
|
-
if (styles.has(id)) {
|
|
17
|
-
return styles.get(id);
|
|
18
|
-
}
|
|
19
|
-
return void 0;
|
|
20
|
-
},
|
|
21
|
-
transformInclude(id) {
|
|
22
|
-
return /\.torp\?*/.test(id);
|
|
23
|
-
},
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
transform(code, id, viteOptions) {
|
|
26
|
-
if (viteOptions && viteOptions.ssr !== void 0) {
|
|
27
|
-
options ??= {};
|
|
28
|
-
options.server = viteOptions.ssr;
|
|
29
|
-
}
|
|
30
|
-
if (options?.test) {
|
|
31
|
-
options.server = true;
|
|
32
|
-
}
|
|
33
|
-
let parsed = parse(code);
|
|
34
|
-
if (parsed.ok && parsed.template) {
|
|
35
|
-
return transform(parsed.template, id, options);
|
|
36
|
-
} else {
|
|
37
|
-
let name = id.split(/[\\\/]/).at(-1)?.replace(/\.torp$/, "");
|
|
38
|
-
let errorMessages = parsed.errors.map((e) => `${e.line},${e.column}: ${e.message}`);
|
|
39
|
-
console.log(`
|
|
40
|
-
ERRORS: ${id}
|
|
41
|
-
======
|
|
42
|
-
${errorMessages.join("\n")}`);
|
|
43
|
-
let errorCode = `
|
|
44
|
-
export default function Error() {
|
|
45
|
-
@render {
|
|
46
|
-
<div style="background-color: #222; color: #f44"; font-size: 15px; line-height: 1.5;">
|
|
47
|
-
<p style="margin: 0; padding: 0;">
|
|
48
|
-
<strong>Error${parsed.errors.length === 1 ? "" : "s"} in ${name}:</strong>
|
|
49
|
-
</p>
|
|
50
|
-
<ul style="margin: 0; padding: 0 20px">
|
|
51
|
-
${errorMessages.map((e) => `<li>${e}</li>`).join("\n")}
|
|
52
|
-
</ul>
|
|
53
|
-
</div>
|
|
54
|
-
}
|
|
55
|
-
}`;
|
|
56
|
-
let errorParsed = parse(errorCode);
|
|
57
|
-
if (errorParsed.ok && errorParsed.template) {
|
|
58
|
-
return transform(errorParsed.template, id, options);
|
|
59
|
-
}
|
|
60
|
-
throw new Error(`Parse failed for ${id}, ${errorMessages.join("\n")}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
function transform(template, id, options) {
|
|
65
|
-
const built = build(template, options);
|
|
66
|
-
let transformed = built.code;
|
|
67
|
-
if (built.styles) {
|
|
68
|
-
for (let style of built.styles) {
|
|
69
|
-
transformed = `import '${style.hash}.css';
|
|
70
|
-
` + transformed;
|
|
71
|
-
styles.set(style.hash + ".css", style.style);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return transformWithEsbuild(transformed, id, {
|
|
75
|
-
loader: "ts"
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
79
|
-
var index_default = unplugin;
|
|
80
|
-
|
|
81
|
-
export {
|
|
82
|
-
unpluginFactory,
|
|
83
|
-
unplugin,
|
|
84
|
-
index_default
|
|
85
|
-
};
|
package/dist/chunk-KXJKMIMY.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkWCGHWXKZcjs = require('./chunk-WCGHWXKZ.cjs');
|
|
4
|
-
|
|
5
|
-
// src/vite.ts
|
|
6
|
-
var _unplugin = require('unplugin');
|
|
7
|
-
var plugin = _unplugin.createVitePlugin.call(void 0, _chunkWCGHWXKZcjs.unpluginFactory);
|
|
8
|
-
var vite_default = plugin;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.vite_default = vite_default;
|
package/dist/chunk-MX6XNLWQ.js
DELETED
package/dist/chunk-RGTY2GPN.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkWCGHWXKZcjs = require('./chunk-WCGHWXKZ.cjs');
|
|
4
|
-
|
|
5
|
-
// src/webpack.ts
|
|
6
|
-
var _unplugin = require('unplugin');
|
|
7
|
-
var plugin = _unplugin.createWebpackPlugin.call(void 0, _chunkWCGHWXKZcjs.unpluginFactory);
|
|
8
|
-
var webpack_default = plugin;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.webpack_default = webpack_default;
|
package/dist/chunk-WCGHWXKZ.cjs
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/index.ts
|
|
2
|
-
var _compile = require('@torpor/view/compile');
|
|
3
|
-
var _unplugin = require('unplugin');
|
|
4
|
-
|
|
5
|
-
var _vite = require('vite');
|
|
6
|
-
var styles = /* @__PURE__ */ new Map();
|
|
7
|
-
var unpluginFactory = (options) => ({
|
|
8
|
-
name: "unplugin-torpor",
|
|
9
|
-
resolveId(id) {
|
|
10
|
-
if (styles.has(id)) {
|
|
11
|
-
return id;
|
|
12
|
-
}
|
|
13
|
-
return void 0;
|
|
14
|
-
},
|
|
15
|
-
load(id) {
|
|
16
|
-
if (styles.has(id)) {
|
|
17
|
-
return styles.get(id);
|
|
18
|
-
}
|
|
19
|
-
return void 0;
|
|
20
|
-
},
|
|
21
|
-
transformInclude(id) {
|
|
22
|
-
return /\.torp\?*/.test(id);
|
|
23
|
-
},
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
transform(code, id, viteOptions) {
|
|
26
|
-
if (viteOptions && viteOptions.ssr !== void 0) {
|
|
27
|
-
options ??= {};
|
|
28
|
-
options.server = viteOptions.ssr;
|
|
29
|
-
}
|
|
30
|
-
if (_optionalChain([options, 'optionalAccess', _ => _.test])) {
|
|
31
|
-
options.server = true;
|
|
32
|
-
}
|
|
33
|
-
let parsed = _compile.parse.call(void 0, code);
|
|
34
|
-
if (parsed.ok && parsed.template) {
|
|
35
|
-
return transform(parsed.template, id, options);
|
|
36
|
-
} else {
|
|
37
|
-
let name = _optionalChain([id, 'access', _2 => _2.split, 'call', _3 => _3(/[\\\/]/), 'access', _4 => _4.at, 'call', _5 => _5(-1), 'optionalAccess', _6 => _6.replace, 'call', _7 => _7(/\.torp$/, "")]);
|
|
38
|
-
let errorMessages = parsed.errors.map((e) => `${e.line},${e.column}: ${e.message}`);
|
|
39
|
-
console.log(`
|
|
40
|
-
ERRORS: ${id}
|
|
41
|
-
======
|
|
42
|
-
${errorMessages.join("\n")}`);
|
|
43
|
-
let errorCode = `
|
|
44
|
-
export default function Error() {
|
|
45
|
-
@render {
|
|
46
|
-
<div style="background-color: #222; color: #f44"; font-size: 15px; line-height: 1.5;">
|
|
47
|
-
<p style="margin: 0; padding: 0;">
|
|
48
|
-
<strong>Error${parsed.errors.length === 1 ? "" : "s"} in ${name}:</strong>
|
|
49
|
-
</p>
|
|
50
|
-
<ul style="margin: 0; padding: 0 20px">
|
|
51
|
-
${errorMessages.map((e) => `<li>${e}</li>`).join("\n")}
|
|
52
|
-
</ul>
|
|
53
|
-
</div>
|
|
54
|
-
}
|
|
55
|
-
}`;
|
|
56
|
-
let errorParsed = _compile.parse.call(void 0, errorCode);
|
|
57
|
-
if (errorParsed.ok && errorParsed.template) {
|
|
58
|
-
return transform(errorParsed.template, id, options);
|
|
59
|
-
}
|
|
60
|
-
throw new Error(`Parse failed for ${id}, ${errorMessages.join("\n")}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
function transform(template, id, options) {
|
|
65
|
-
const built = _compile.build.call(void 0, template, options);
|
|
66
|
-
let transformed = built.code;
|
|
67
|
-
if (built.styles) {
|
|
68
|
-
for (let style of built.styles) {
|
|
69
|
-
transformed = `import '${style.hash}.css';
|
|
70
|
-
` + transformed;
|
|
71
|
-
styles.set(style.hash + ".css", style.style);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return _vite.transformWithEsbuild.call(void 0, transformed, id, {
|
|
75
|
-
loader: "ts"
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
var unplugin = /* @__PURE__ */ _unplugin.createUnplugin.call(void 0, unpluginFactory);
|
|
79
|
-
var index_default = unplugin;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
exports.unpluginFactory = unpluginFactory; exports.unplugin = unplugin; exports.index_default = index_default;
|
package/dist/chunk-ZBPRDZS4.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/esbuild.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkWCGHWXKZcjs = require('./chunk-WCGHWXKZ.cjs');
|
|
4
|
-
require('./chunk-ZBPRDZS4.cjs');
|
|
5
|
-
|
|
6
|
-
// src/esbuild.ts
|
|
7
|
-
var _unplugin = require('unplugin');
|
|
8
|
-
var plugin = _unplugin.createEsbuildPlugin.call(void 0, _chunkWCGHWXKZcjs.unpluginFactory);
|
|
9
|
-
var esbuild_default = plugin;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
module.exports = esbuild_default;
|
|
13
|
-
|
|
14
|
-
module.exports = exports.default;
|
|
15
|
-
exports.default = module.exports;
|
package/dist/esbuild.d.cts
DELETED
package/dist/index.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunkWCGHWXKZcjs = require('./chunk-WCGHWXKZ.cjs');
|
|
6
|
-
require('./chunk-ZBPRDZS4.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module.exports = _chunkWCGHWXKZcjs.index_default; exports.unplugin = _chunkWCGHWXKZcjs.unplugin; exports.unpluginFactory = _chunkWCGHWXKZcjs.unpluginFactory;
|
|
12
|
-
exports.default = module.exports;
|
package/dist/index.d.cts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { UnpluginInstance, UnpluginFactory } from 'unplugin';
|
|
2
|
-
import { Options } from './types.cjs';
|
|
3
|
-
|
|
4
|
-
declare const unpluginFactory: UnpluginFactory<Options | undefined>;
|
|
5
|
-
declare const unplugin: UnpluginInstance<Options | undefined, boolean>;
|
|
6
|
-
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
export = unplugin;
|
|
9
|
-
export { unplugin, unpluginFactory };
|
package/dist/nuxt.cjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkRGTY2GPNcjs = require('./chunk-RGTY2GPN.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkKXJKMIMYcjs = require('./chunk-KXJKMIMY.cjs');
|
|
7
|
-
require('./chunk-WCGHWXKZ.cjs');
|
|
8
|
-
require('./chunk-ZBPRDZS4.cjs');
|
|
9
|
-
|
|
10
|
-
// src/nuxt.ts
|
|
11
|
-
var _kit = require('@nuxt/kit');
|
|
12
|
-
require('@nuxt/schema');
|
|
13
|
-
var plugin = _kit.defineNuxtModule.call(void 0, {
|
|
14
|
-
meta: {
|
|
15
|
-
name: "nuxt-unplugin-torpor",
|
|
16
|
-
configKey: "unpluginStarter"
|
|
17
|
-
},
|
|
18
|
-
defaults: {
|
|
19
|
-
// ...default options
|
|
20
|
-
},
|
|
21
|
-
setup(options, _nuxt) {
|
|
22
|
-
_kit.addVitePlugin.call(void 0, () => _chunkKXJKMIMYcjs.vite_default.call(void 0, options));
|
|
23
|
-
_kit.addWebpackPlugin.call(void 0, () => _chunkRGTY2GPNcjs.webpack_default.call(void 0, options));
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
var nuxt_default = plugin;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
module.exports = nuxt_default;
|
|
30
|
-
|
|
31
|
-
module.exports = exports.default;
|
|
32
|
-
exports.default = module.exports;
|
package/dist/nuxt.d.cts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
-
import { Options } from './types.cjs';
|
|
3
|
-
|
|
4
|
-
interface ModuleOptions extends Options {
|
|
5
|
-
}
|
|
6
|
-
declare const plugin: NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
7
|
-
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
export = plugin;
|
|
10
|
-
export type { ModuleOptions };
|
package/dist/rollup.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkWCGHWXKZcjs = require('./chunk-WCGHWXKZ.cjs');
|
|
4
|
-
require('./chunk-ZBPRDZS4.cjs');
|
|
5
|
-
|
|
6
|
-
// src/rollup.ts
|
|
7
|
-
var _unplugin = require('unplugin');
|
|
8
|
-
var plugin = _unplugin.createRollupPlugin.call(void 0, _chunkWCGHWXKZcjs.unpluginFactory);
|
|
9
|
-
var rollup_default = plugin;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
module.exports = rollup_default;
|
|
13
|
-
|
|
14
|
-
module.exports = exports.default;
|
|
15
|
-
exports.default = module.exports;
|
package/dist/rollup.d.cts
DELETED
package/dist/rspack.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkWCGHWXKZcjs = require('./chunk-WCGHWXKZ.cjs');
|
|
4
|
-
require('./chunk-ZBPRDZS4.cjs');
|
|
5
|
-
|
|
6
|
-
// src/rspack.ts
|
|
7
|
-
var _unplugin = require('unplugin');
|
|
8
|
-
var plugin = _unplugin.createRspackPlugin.call(void 0, _chunkWCGHWXKZcjs.unpluginFactory);
|
|
9
|
-
var rspack_default = plugin;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
module.exports = rspack_default;
|
|
13
|
-
|
|
14
|
-
module.exports = exports.default;
|
|
15
|
-
exports.default = module.exports;
|
package/dist/rspack.d.cts
DELETED
package/dist/types.cjs
DELETED
package/dist/types.d.cts
DELETED
package/dist/vite.cjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkKXJKMIMYcjs = require('./chunk-KXJKMIMY.cjs');
|
|
4
|
-
require('./chunk-WCGHWXKZ.cjs');
|
|
5
|
-
require('./chunk-ZBPRDZS4.cjs');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = _chunkKXJKMIMYcjs.vite_default;
|
|
9
|
-
|
|
10
|
-
module.exports = exports.default;
|
|
11
|
-
exports.default = module.exports;
|
package/dist/vite.d.cts
DELETED
package/dist/webpack.cjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkRGTY2GPNcjs = require('./chunk-RGTY2GPN.cjs');
|
|
4
|
-
require('./chunk-WCGHWXKZ.cjs');
|
|
5
|
-
require('./chunk-ZBPRDZS4.cjs');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = _chunkRGTY2GPNcjs.webpack_default;
|
|
9
|
-
|
|
10
|
-
module.exports = exports.default;
|
|
11
|
-
exports.default = module.exports;
|