@teacss/astro 0.3.0

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2021-PRESENT Anthony Fu <https://github.com/antfu>
4
+ Copyright (c) 2026-PRESENT Billgo <hi@billgo.me>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @teacss/astro
2
+
3
+ **Astro integration for TeaCSS.**
4
+
5
+ ## Purpose
6
+
7
+ The integration registers the TeaCSS Vite plugin and injects the generated
8
+ stylesheet into Astro pages.
9
+
10
+ Use this package when an Astro application should configure TeaCSS through
11
+ Astro's `integrations` array. It owns the Astro lifecycle and page injection
12
+ around `@teacss/vite`; non-Astro Vite applications should use the Vite
13
+ integration directly.
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { defineConfig } from "astro/config";
19
+ import { pluginTeacss } from "teacss/astro";
20
+
21
+ export default defineConfig({
22
+ integrations: [pluginTeacss()],
23
+ });
24
+ ```
25
+
26
+ Use `injectEntry: false` when you want to import `virtual:teacss.css` yourself.
27
+ A string value fully replaces that default import, so it must import
28
+ `virtual:teacss.css` itself when the generated stylesheet is still needed.
29
+ Use `injectExtra` to keep the default and add other module statements:
30
+
31
+ ```ts
32
+ pluginTeacss({
33
+ injectExtra: ['import "./src/styles.css";', 'import "./src/fonts.css";'],
34
+ });
35
+ ```
36
+
37
+ All string values are complete module statements, not bare paths.
38
+
39
+ ## Status
40
+
41
+ Pre-1.0. Install `@teacss/astro` beside `teacss`, then use the stable
42
+ `teacss/astro` facade subpath in applications. Integration authors may import
43
+ `@teacss/astro` directly when they intentionally do not use the facade.
@@ -0,0 +1,24 @@
1
+ import { TeacssVitePluginConfig } from "@teacss/vite";
2
+ import { UserConfigDefaults } from "@teacss/core";
3
+ import { AstroIntegration } from "astro";
4
+ //#region src/index.d.ts
5
+ interface AstroIntegrationConfig<Theme extends object = object> extends TeacssVitePluginConfig<Theme> {
6
+ /**
7
+ * Inject the TeaCSS entry (`import "virtual:teacss.css"`) into every page.
8
+ * Pass complete module code to replace the default statement. A replacement
9
+ * must import `virtual:teacss.css` itself when the generated stylesheet is
10
+ * still needed; use `injectExtra` to add modules without replacing it.
11
+ *
12
+ * @default true
13
+ */
14
+ injectEntry?: boolean | string;
15
+ /**
16
+ * Extra module statements to inject into every page.
17
+ *
18
+ * @default []
19
+ */
20
+ injectExtra?: string[];
21
+ }
22
+ declare function pluginTeacss<Theme extends object>(options?: AstroIntegrationConfig<Theme>, defaults?: UserConfigDefaults): AstroIntegration;
23
+ //#endregion
24
+ export { AstroIntegrationConfig, pluginTeacss };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import{join as e}from"node:path";import{pluginTeacss as t}from"@teacss/vite";import{normalizePath as n}from"vite";const r=`teacss-astro`;function i(t){let i=t.join(`
2
+ `),a,o;return{name:`teacss:astro`,enforce:`pre`,configResolved(e){a=e.root;let t=e.plugins.find(e=>e.name===`teacss:api`)?.api;if(!t)throw Error(`[@teacss/astro] Unable to find TeaCSS Vite plugin API`);o=t.getContext()},async resolveId(t,i){if(t===r)return t;let{RESOLVED_ID_RE:s}=await o.getVMPRegexes();if(s.test(t))return this.resolve(n(e(a,t)),i,{skipSelf:!0})},load(e){if(e===r)return i}}}function a(e={},n={}){let{injectEntry:a=!0,injectExtra:o=[],...s}=e,c=Object.keys(s).length?s:void 0,l=[];return a&&l.push(typeof a==`string`?a:`import "virtual:teacss.css";`),l.push(...o),{name:`@teacss/astro`,hooks:{"astro:config:setup":({updateConfig:e,injectScript:a})=>{e({vite:{plugins:[...t(c,n),i(l)]}}),l.length&&a(`page-ssr`,`import ${JSON.stringify(r)}`)}}}}export{a as pluginTeacss};
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@teacss/astro",
3
+ "version": "0.3.0",
4
+ "description": "Astro integration for TeaCSS — registers the Vite plugin and injects the generated stylesheet.",
5
+ "homepage": "https://css.teasim.com",
6
+ "funding": "https://github.com/sponsors/billgo",
7
+ "license": "MIT",
8
+ "author": "Billgo <hi@billgo.me>",
9
+ "sideEffects": false,
10
+ "type": "module",
11
+ "exports": {
12
+ ".": "./dist/index.js",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "types": "./dist/index.d.ts",
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "bunx tsdown --config tsdown.config.mts",
22
+ "dev": "tsdown --watch"
23
+ },
24
+ "dependencies": {
25
+ "@teacss/core": "0.3.0",
26
+ "@teacss/vite": "0.3.0"
27
+ },
28
+ "devDependencies": {
29
+ "astro": "^7.1.3",
30
+ "vite": "^8.1.5"
31
+ },
32
+ "peerDependencies": {
33
+ "astro": ">=7.0.0",
34
+ "vite": ">=8.0.0"
35
+ },
36
+ "engines": {
37
+ "node": ">=22.12.0"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ }
42
+ }