@weapp-tailwindcss/postcss 1.0.13-beta.0 → 1.0.13-beta.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.
@@ -0,0 +1,13 @@
1
+ import { PluginCreator } from 'postcss';
2
+
3
+ interface IOptions {
4
+ /** 当前编译平台 */
5
+ platform?: string;
6
+ /** 设置是否去除 cursor 相关样式 (h5默认值:true) */
7
+ removeCursorStyle?: boolean;
8
+ /** 是否移除 * 相关样式 */
9
+ removeUniversal?: boolean;
10
+ }
11
+ declare const postcssHtmlTransform: PluginCreator<IOptions>;
12
+
13
+ export { type IOptions, postcssHtmlTransform as default };
@@ -0,0 +1,15 @@
1
+ import { PluginCreator } from 'postcss';
2
+
3
+ interface IOptions {
4
+ /** 当前编译平台 */
5
+ platform?: string;
6
+ /** 设置是否去除 cursor 相关样式 (h5默认值:true) */
7
+ removeCursorStyle?: boolean;
8
+ /** 是否移除 * 相关样式 */
9
+ removeUniversal?: boolean;
10
+ }
11
+ declare const postcssHtmlTransform: PluginCreator<IOptions>;
12
+
13
+ // @ts-ignore
14
+ export = postcssHtmlTransform;
15
+ export type { IOptions };
@@ -0,0 +1,58 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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/html-transform.ts
2
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
3
+ var _shared = require('@weapp-tailwindcss/shared');
4
+ var htmlTags = ["html", "body", "a", "audio", "button", "canvas", "form", "iframe", "img", "input", "label", "progress", "select", "slot", "textarea", "video", "abbr", "area", "b", "bdi", "big", "br", "cite", "code", "data", "datalist", "del", "dfn", "em", "i", "ins", "kbd", "map", "mark", "meter", "output", "picture", "q", "s", "samp", "small", "span", "strong", "sub", "sup", "td", "template", "th", "time", "tt", "u", "var", "wbr", "address", "article", "aside", "blockquote", "caption", "dd", "details", "dialog", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "legend", "li", "main", "nav", "ol", "p", "pre", "section", "summary", "table", "tbody", "tfoot", "thead", "tr", "ul", "svg"];
5
+ var miniAppTags = ["cover-image", "cover-view", "match-media", "movable-area", "movable-view", "page-container", "scroll-view", "share-element", "swiper", "swiper-item", "view", "icon", "progress", "rich-text", "text", "button", "checkbox", "checkbox-group", "editor", "form", "input", "keyboard-accessory", "label", "picker", "picker-view", "picker-view-column", "radio", "radio-group", "slider", "switch", "textarea", "functional-page-navigator", "navigator", "audio", "camera", "image", "live-player", "live-pusher", "video", "voip-room", "map", "canvas", "web-view", "ad", "ad-custom", "official-account", "open-data", "navigation-bar", "page-meta"];
6
+ var tags2Rgx = (tags = []) => new RegExp(`(^| |\\+|,|~|>|\\n)(${tags.join("|")})\\b(?=$| |\\.|\\+|,|~|:|\\[)`, "g");
7
+ var postcssHtmlTransform = (opts = {}) => {
8
+ const options = _shared.defu.call(void 0, opts, {
9
+ platform: _process2.default.env.TARO_ENV
10
+ });
11
+ let selectorFilter;
12
+ let walkRules;
13
+ switch (options.platform) {
14
+ case "h5": {
15
+ selectorFilter = tags2Rgx(miniAppTags);
16
+ walkRules = (rule) => {
17
+ rule.selector = rule.selector.replace(selectorFilter, "$1taro-$2-core");
18
+ };
19
+ break;
20
+ }
21
+ case "rn": {
22
+ break;
23
+ }
24
+ case "quickapp": {
25
+ break;
26
+ }
27
+ default: {
28
+ const selector = tags2Rgx(htmlTags);
29
+ walkRules = (rule) => {
30
+ if (options.removeUniversal && /(?:^| )\*(?![=/*])/.test(rule.selector)) {
31
+ rule.remove();
32
+ return;
33
+ }
34
+ rule.selector = rule.selector.replace(selector, "$1.h5-$2");
35
+ };
36
+ }
37
+ }
38
+ return {
39
+ postcssPlugin: "postcss-html-transform",
40
+ Rule(rule) {
41
+ _optionalChain([walkRules, 'optionalCall', _ => _(rule)]);
42
+ },
43
+ Declaration(decl) {
44
+ if (_optionalChain([options, 'optionalAccess', _2 => _2.removeCursorStyle])) {
45
+ if (decl.prop === "cursor") {
46
+ decl.remove();
47
+ }
48
+ }
49
+ }
50
+ };
51
+ };
52
+ postcssHtmlTransform.postcss = true;
53
+ var html_transform_default = postcssHtmlTransform;
54
+
55
+
56
+ exports.default = html_transform_default;
57
+
58
+ module.exports = exports.default;
@@ -0,0 +1,56 @@
1
+ // src/html-transform.ts
2
+ import process from "process";
3
+ import { defu } from "@weapp-tailwindcss/shared";
4
+ var htmlTags = ["html", "body", "a", "audio", "button", "canvas", "form", "iframe", "img", "input", "label", "progress", "select", "slot", "textarea", "video", "abbr", "area", "b", "bdi", "big", "br", "cite", "code", "data", "datalist", "del", "dfn", "em", "i", "ins", "kbd", "map", "mark", "meter", "output", "picture", "q", "s", "samp", "small", "span", "strong", "sub", "sup", "td", "template", "th", "time", "tt", "u", "var", "wbr", "address", "article", "aside", "blockquote", "caption", "dd", "details", "dialog", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "legend", "li", "main", "nav", "ol", "p", "pre", "section", "summary", "table", "tbody", "tfoot", "thead", "tr", "ul", "svg"];
5
+ var miniAppTags = ["cover-image", "cover-view", "match-media", "movable-area", "movable-view", "page-container", "scroll-view", "share-element", "swiper", "swiper-item", "view", "icon", "progress", "rich-text", "text", "button", "checkbox", "checkbox-group", "editor", "form", "input", "keyboard-accessory", "label", "picker", "picker-view", "picker-view-column", "radio", "radio-group", "slider", "switch", "textarea", "functional-page-navigator", "navigator", "audio", "camera", "image", "live-player", "live-pusher", "video", "voip-room", "map", "canvas", "web-view", "ad", "ad-custom", "official-account", "open-data", "navigation-bar", "page-meta"];
6
+ var tags2Rgx = (tags = []) => new RegExp(`(^| |\\+|,|~|>|\\n)(${tags.join("|")})\\b(?=$| |\\.|\\+|,|~|:|\\[)`, "g");
7
+ var postcssHtmlTransform = (opts = {}) => {
8
+ const options = defu(opts, {
9
+ platform: process.env.TARO_ENV
10
+ });
11
+ let selectorFilter;
12
+ let walkRules;
13
+ switch (options.platform) {
14
+ case "h5": {
15
+ selectorFilter = tags2Rgx(miniAppTags);
16
+ walkRules = (rule) => {
17
+ rule.selector = rule.selector.replace(selectorFilter, "$1taro-$2-core");
18
+ };
19
+ break;
20
+ }
21
+ case "rn": {
22
+ break;
23
+ }
24
+ case "quickapp": {
25
+ break;
26
+ }
27
+ default: {
28
+ const selector = tags2Rgx(htmlTags);
29
+ walkRules = (rule) => {
30
+ if (options.removeUniversal && /(?:^| )\*(?![=/*])/.test(rule.selector)) {
31
+ rule.remove();
32
+ return;
33
+ }
34
+ rule.selector = rule.selector.replace(selector, "$1.h5-$2");
35
+ };
36
+ }
37
+ }
38
+ return {
39
+ postcssPlugin: "postcss-html-transform",
40
+ Rule(rule) {
41
+ walkRules?.(rule);
42
+ },
43
+ Declaration(decl) {
44
+ if (options?.removeCursorStyle) {
45
+ if (decl.prop === "cursor") {
46
+ decl.remove();
47
+ }
48
+ }
49
+ }
50
+ };
51
+ };
52
+ postcssHtmlTransform.postcss = true;
53
+ var html_transform_default = postcssHtmlTransform;
54
+ export {
55
+ html_transform_default as default
56
+ };
package/dist/index.js CHANGED
@@ -613,12 +613,12 @@ var nodes = [
613
613
  property("--tw-border-style", "solid"),
614
614
  property("--tw-divide-x-reverse", "0"),
615
615
  property("--tw-divide-y-reverse", "0"),
616
- property("--tw-gradient-position"),
616
+ property("--tw-gradient-position", "initial"),
617
617
  property("--tw-gradient-from", "#0000", "<color>"),
618
618
  property("--tw-gradient-via", "#0000", "<color>"),
619
619
  property("--tw-gradient-to", "#0000", "<color>"),
620
- property("--tw-gradient-stops"),
621
- property("--tw-gradient-via-stops"),
620
+ property("--tw-gradient-stops", "initial"),
621
+ property("--tw-gradient-via-stops", "initial"),
622
622
  property("--tw-gradient-from-position", "0%", "<length-percentage>"),
623
623
  property("--tw-gradient-via-position", "50%", "<length-percentage>"),
624
624
  property("--tw-gradient-to-position", "100%", "<length-percentage>"),
@@ -669,8 +669,8 @@ var nodes = [
669
669
  property("--tw-backdrop-opacity"),
670
670
  property("--tw-backdrop-saturate"),
671
671
  property("--tw-backdrop-sepia"),
672
- property("--tw-duration"),
673
- property("--tw-ease"),
672
+ property("--tw-duration", "initial"),
673
+ property("--tw-ease", "initial"),
674
674
  property("--tw-content", '""'),
675
675
  property("--tw-contain-size"),
676
676
  property("--tw-contain-layout"),
@@ -684,13 +684,13 @@ var nodes = [
684
684
  property("--tw-numeric-spacing"),
685
685
  property("--tw-numeric-fraction"),
686
686
  property("--tw-outline-style", "solid"),
687
- property("--tw-text-shadow-color"),
687
+ property("--tw-text-shadow-color", "initial"),
688
688
  property("--tw-text-shadow-alpha", "100%", "<percentage>"),
689
689
  property("--tw-shadow", nullShadow),
690
- property("--tw-shadow-color"),
690
+ property("--tw-shadow-color", "initial"),
691
691
  property("--tw-shadow-alpha", "100%", "<percentage>"),
692
692
  property("--tw-inset-shadow", nullShadow),
693
- property("--tw-inset-shadow-color"),
693
+ property("--tw-inset-shadow-color", "initial"),
694
694
  property("--tw-inset-shadow-alpha", "100%", "<percentage>"),
695
695
  property("--tw-ring-color"),
696
696
  property("--tw-ring-shadow", nullShadow),
package/dist/index.mjs CHANGED
@@ -613,12 +613,12 @@ var nodes = [
613
613
  property("--tw-border-style", "solid"),
614
614
  property("--tw-divide-x-reverse", "0"),
615
615
  property("--tw-divide-y-reverse", "0"),
616
- property("--tw-gradient-position"),
616
+ property("--tw-gradient-position", "initial"),
617
617
  property("--tw-gradient-from", "#0000", "<color>"),
618
618
  property("--tw-gradient-via", "#0000", "<color>"),
619
619
  property("--tw-gradient-to", "#0000", "<color>"),
620
- property("--tw-gradient-stops"),
621
- property("--tw-gradient-via-stops"),
620
+ property("--tw-gradient-stops", "initial"),
621
+ property("--tw-gradient-via-stops", "initial"),
622
622
  property("--tw-gradient-from-position", "0%", "<length-percentage>"),
623
623
  property("--tw-gradient-via-position", "50%", "<length-percentage>"),
624
624
  property("--tw-gradient-to-position", "100%", "<length-percentage>"),
@@ -669,8 +669,8 @@ var nodes = [
669
669
  property("--tw-backdrop-opacity"),
670
670
  property("--tw-backdrop-saturate"),
671
671
  property("--tw-backdrop-sepia"),
672
- property("--tw-duration"),
673
- property("--tw-ease"),
672
+ property("--tw-duration", "initial"),
673
+ property("--tw-ease", "initial"),
674
674
  property("--tw-content", '""'),
675
675
  property("--tw-contain-size"),
676
676
  property("--tw-contain-layout"),
@@ -684,13 +684,13 @@ var nodes = [
684
684
  property("--tw-numeric-spacing"),
685
685
  property("--tw-numeric-fraction"),
686
686
  property("--tw-outline-style", "solid"),
687
- property("--tw-text-shadow-color"),
687
+ property("--tw-text-shadow-color", "initial"),
688
688
  property("--tw-text-shadow-alpha", "100%", "<percentage>"),
689
689
  property("--tw-shadow", nullShadow),
690
- property("--tw-shadow-color"),
690
+ property("--tw-shadow-color", "initial"),
691
691
  property("--tw-shadow-alpha", "100%", "<percentage>"),
692
692
  property("--tw-inset-shadow", nullShadow),
693
- property("--tw-inset-shadow-color"),
693
+ property("--tw-inset-shadow-color", "initial"),
694
694
  property("--tw-inset-shadow-alpha", "100%", "<percentage>"),
695
695
  property("--tw-ring-color"),
696
696
  property("--tw-ring-shadow", nullShadow),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/postcss",
3
- "version": "1.0.13-beta.0",
3
+ "version": "1.0.13-beta.1",
4
4
  "description": "@weapp-tailwindcss/postcss",
5
5
  "author": "ice breaker <1324318532@qq.com>",
6
6
  "license": "MIT",
@@ -24,7 +24,13 @@
24
24
  "types": "./dist/types.d.ts",
25
25
  "import": "./dist/types.mjs",
26
26
  "require": "./dist/types.js"
27
- }
27
+ },
28
+ "./html-transform": {
29
+ "types": "./dist/html-transform.d.ts",
30
+ "import": "./dist/html-transform.mjs",
31
+ "require": "./dist/html-transform.js"
32
+ },
33
+ "./package.json": "./package.json"
28
34
  },
29
35
  "main": "./dist/index.js",
30
36
  "module": "./dist/index.mjs",