@weapp-tailwindcss/lynx 0.1.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 ice breaker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @weapp-tailwindcss/lynx
2
+
3
+ ReactLynx + Rspeedy 的 Tailwind CSS v4 集成。它通过 Rspeedy 的 Rspack 生命周期调用 `weapp-tailwindcss` 生成 Lynx 可消费的普通 CSS,保留 ReactLynx 原生 `className`,不引入运行时样式表或 JSX 转换。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add @weapp-tailwindcss/lynx tailwindcss
9
+ ```
10
+
11
+ ## 配置
12
+
13
+ ```ts
14
+ // lynx.config.ts
15
+ import { defineConfig } from '@lynx-js/rspeedy'
16
+ import { pluginLynxTailwindcss } from '@weapp-tailwindcss/lynx'
17
+
18
+ export default defineConfig({
19
+ plugins: [pluginLynxTailwindcss()],
20
+ })
21
+ ```
22
+
23
+ 在应用 CSS 入口中保留 Tailwind v4 标准入口,并用 `@source` 指向实际源码:
24
+
25
+ ```css
26
+ @import "tailwindcss";
27
+ @source "./src";
28
+ ```
29
+
30
+ `pluginLynxTailwindcss` 固定使用 `platform: 'lynx'` 与 `generator.target: 'web'`。首版仅支持 ReactLynx + Rspeedy 与 Tailwind CSS v4;不覆盖 Rspeedy Web 输出、非 React Lynx 框架、Tailwind CSS v3 或 React Native 风格的运行时样式映射。
package/dist/index.cjs ADDED
@@ -0,0 +1,41 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let weapp_tailwindcss_rspack = require("weapp-tailwindcss/rspack");
3
+ //#region src/index.ts
4
+ const PLUGIN_NAME = "weapp-tailwindcss:lynx";
5
+ function normalizeOptions(options) {
6
+ const { rspack: _rspack, generator, ...rest } = options;
7
+ return {
8
+ ...rest,
9
+ platform: "lynx",
10
+ cssOptions: {
11
+ ...options.cssOptions,
12
+ platform: "lynx"
13
+ },
14
+ generator: {
15
+ ...generator === false ? {} : generator,
16
+ target: "web"
17
+ }
18
+ };
19
+ }
20
+ /**
21
+ * 为 ReactLynx + Rspeedy 注册 Tailwind CSS v4 构建链路。
22
+ *
23
+ * Lynx 原生支持 CSS class selector,因此不会改写 JSX `className` 或创建运行时样式表。
24
+ */
25
+ function pluginLynxTailwindcss(options = {}) {
26
+ const normalizedOptions = normalizeOptions(options);
27
+ return {
28
+ name: PLUGIN_NAME,
29
+ setup(api) {
30
+ const rsbuildApi = api;
31
+ rsbuildApi.modifyBundlerChain((chain) => {
32
+ chain.plugin(PLUGIN_NAME).use(weapp_tailwindcss_rspack.WeappTailwindcss, [normalizedOptions]);
33
+ return chain;
34
+ });
35
+ rsbuildApi.modifyRspackConfig((config) => (0, weapp_tailwindcss_rspack.patchRspackConfig)(config, options.rspack));
36
+ }
37
+ };
38
+ }
39
+ //#endregion
40
+ exports.PLUGIN_NAME = PLUGIN_NAME;
41
+ exports.pluginLynxTailwindcss = pluginLynxTailwindcss;
@@ -0,0 +1,22 @@
1
+ import { PatchRspackConfigOptions } from "weapp-tailwindcss/rspack";
2
+ import { RsbuildPlugin } from "@lynx-js/rspeedy";
3
+ import { WeappTailwindcssGeneratorOptions } from "weapp-tailwindcss/generator";
4
+ import { UserDefinedOptions } from "weapp-tailwindcss/types";
5
+ //#region src/index.d.ts
6
+ declare const PLUGIN_NAME = "weapp-tailwindcss:lynx";
7
+ interface LynxGeneratorOptions extends Omit<WeappTailwindcssGeneratorOptions, 'target'> {}
8
+ /** ReactLynx Rspeedy 适配配置。 */
9
+ interface LynxTailwindcssOptions extends Omit<UserDefinedOptions, 'platform' | 'generator'> {
10
+ /** 透传给 Rspack CSS 规则补丁的配置。 */
11
+ rspack?: PatchRspackConfigOptions | undefined;
12
+ /** Tailwind CSS v4 生成配置,目标固定为 Lynx 可消费的 web CSS。 */
13
+ generator?: LynxGeneratorOptions | false | undefined;
14
+ }
15
+ /**
16
+ * 为 ReactLynx + Rspeedy 注册 Tailwind CSS v4 构建链路。
17
+ *
18
+ * Lynx 原生支持 CSS class selector,因此不会改写 JSX `className` 或创建运行时样式表。
19
+ */
20
+ declare function pluginLynxTailwindcss(options?: LynxTailwindcssOptions): RsbuildPlugin;
21
+ //#endregion
22
+ export { LynxTailwindcssOptions, PLUGIN_NAME, pluginLynxTailwindcss };
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ import { WeappTailwindcss, patchRspackConfig } from "weapp-tailwindcss/rspack";
2
+ //#region src/index.ts
3
+ const PLUGIN_NAME = "weapp-tailwindcss:lynx";
4
+ function normalizeOptions(options) {
5
+ const { rspack: _rspack, generator, ...rest } = options;
6
+ return {
7
+ ...rest,
8
+ platform: "lynx",
9
+ cssOptions: {
10
+ ...options.cssOptions,
11
+ platform: "lynx"
12
+ },
13
+ generator: {
14
+ ...generator === false ? {} : generator,
15
+ target: "web"
16
+ }
17
+ };
18
+ }
19
+ /**
20
+ * 为 ReactLynx + Rspeedy 注册 Tailwind CSS v4 构建链路。
21
+ *
22
+ * Lynx 原生支持 CSS class selector,因此不会改写 JSX `className` 或创建运行时样式表。
23
+ */
24
+ function pluginLynxTailwindcss(options = {}) {
25
+ const normalizedOptions = normalizeOptions(options);
26
+ return {
27
+ name: PLUGIN_NAME,
28
+ setup(api) {
29
+ const rsbuildApi = api;
30
+ rsbuildApi.modifyBundlerChain((chain) => {
31
+ chain.plugin(PLUGIN_NAME).use(WeappTailwindcss, [normalizedOptions]);
32
+ return chain;
33
+ });
34
+ rsbuildApi.modifyRspackConfig((config) => patchRspackConfig(config, options.rspack));
35
+ }
36
+ };
37
+ }
38
+ //#endregion
39
+ export { PLUGIN_NAME, pluginLynxTailwindcss };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@weapp-tailwindcss/lynx",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "description": "Tailwind CSS 4 integration for ReactLynx and Rspeedy.",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/sonofmagic/weapp-tailwindcss.git",
10
+ "directory": "packages/lynx"
11
+ },
12
+ "sideEffects": false,
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "main": "./dist/index.cjs",
22
+ "module": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "engines": {
28
+ "node": ">=22.12.0"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "peerDependencies": {
34
+ "@lynx-js/rspeedy": ">=0.16.0",
35
+ "tailwindcss": ">=4.0.0"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "@lynx-js/rspeedy": {
39
+ "optional": true
40
+ },
41
+ "tailwindcss": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "dependencies": {
46
+ "weapp-tailwindcss": "^5.2.12"
47
+ },
48
+ "devDependencies": {
49
+ "@lynx-js/rspeedy": "^0.16.3",
50
+ "tailwindcss": "^4.3.3",
51
+ "vitest": "^4.1.0"
52
+ },
53
+ "scripts": {
54
+ "build": "tsdown",
55
+ "test": "vitest run",
56
+ "test:dev": "vitest",
57
+ "lint": "eslint .",
58
+ "release": "pnpm publish"
59
+ }
60
+ }