xhs-mp-sketch-loader 2.0.5 → 2.0.7-beta.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/dist/screenshot.js +1 -1
- package/package.json +12 -20
package/dist/screenshot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./consts.js"),t=require("postcss"),r=require("postcss-prefix-selector")
|
|
1
|
+
"use strict";var e=require("./consts.js"),t=require("postcss"),r=require("postcss-prefix-selector");function o(e){const t={};return Object.keys(e).forEach((r=>{if(!r.startsWith("xhs_")&&"is"!==r)return t[r]="style"===r?function(e){if(!e.includes("--ide-"))return e;const t=function(e){const t={};return e&&(e=(e=e.replace(/ /g," ").replace(/ /g," ").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")).replace(/url\([^)]+\)/gi,(e=>e.replace(/;/gi,":#||#:")))).split(";").forEach((e=>{if(!(e=e.trim()))return;const r=e.indexOf(":");if(-1===r)return;const o=e.substr(0,r).trim();t[o]=e.substr(r+1).replace(/:#\|\|#:/gi,";").trim()})),t}(e),r={},o={};Object.keys(t).forEach((e=>{e.startsWith("--ide-")?o[e.replace(/^--ide-/g,"")]=t[e]:r[e]=t[e]})),Object.assign(r,o);let n="";return Object.keys(r).forEach((e=>{n+=`${e}:${r[e]};`})),n}(e[r]):e[r]})),t}function n(){return{postcssPlugin:"postcss-revert-rpx",Root(e){e.walkRules((e=>{const t={};[".xhs_inner-loading","xhs-template","#xhs_inner_app","xhs-page"].includes(e.selector)?e.remove():(e.walkDecls((e=>{if(e.prop.startsWith("--ide-")){const r=e.prop.replace("--ide-","");t[r]={prop:r,value:e.value},e.remove()}})),e.walkDecls((e=>{t[e.prop]&&e.remove()})),Object.keys(t).forEach((r=>{e.append(t[r])})))}))}}}function i(t,r=0){var n;const s=" ".repeat(r);if(t.type===e.NodeType.Text&&t.textContent.trim())return s+t.textContent;if(t.type===e.NodeType.Element){const e=(null===(n=t.childNodes)||void 0===n?void 0:n.filter(Boolean))||[],l=function(e){return"div"===e?"view":e.replace(/^xhs-/g,"")}(t.tagName),c=Object.entries(o(t.attributes)).map((([e,t])=>"boolean"==typeof t?t?e:"":(null==t?void 0:t.includes('"'))?`${e}='${t}'`:`${e}="${t}"`)).join(" ");return e.length?[`${s}<${l} ${c}>`,e.map((e=>i(e,r+1))).filter(Boolean).join("\n"),`${s}</${l}>`].join("\n"):`${s}<${l} ${c} />`}return t.type===e.NodeType.Comment?`${s}\x3c!-- ${t.textContent} --\x3e`:void 0}n.postcss=!0,exports.build=function(o){return e.__awaiter(this,void 0,void 0,(function*(){var s,l;try{const c=o.flatMap((e=>e));let a=null===(s=c.find((t=>t.type&&t.type===e.NodeType.Root)))||void 0===s?void 0:s.childNodes.filter(Boolean);a=((null===(l=null==a?void 0:a.find((e=>e.tagName&&"xhs-page"===e.tagName)))||void 0===l?void 0:l.childNodes)||a).filter(Boolean);const p=null==a?void 0:a.map((e=>i(e,0))).filter(Boolean).join("\n"),u=c.filter((t=>t.type&&t.type!==e.NodeType.Root)).map((e=>e.textContent)).filter(Boolean).join("\n");return{ml:p,css:yield function(o){return e.__awaiter(this,void 0,void 0,(function*(){try{return(yield t([n(),r({prefix:"xhs",transform:(e,t)=>t.replace(/(^|\s|>)xhs((-[a-z]+)+)/g,((e,t,r)=>t+" "+r.replace(/^-/,""))).replace(/\s+/g," ").trim()})]).process(o,{from:void 0})).css}catch(e){return console.log(e),o}}))}(u)}}catch(e){return console.log(e),{error:e}}}))};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xhs-mp-sketch-loader",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7-beta.0",
|
|
4
4
|
"description": "sketch loader",
|
|
5
5
|
"category": "esm",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,20 +22,17 @@
|
|
|
22
22
|
"lodash": "^4.17.21",
|
|
23
23
|
"querystring": "0.2.1",
|
|
24
24
|
"source-map": "^0.6.1",
|
|
25
|
-
"xml2js": "^0.6.2"
|
|
25
|
+
"xml2js": "^0.6.2",
|
|
26
|
+
"postcss": "^8.2.15",
|
|
27
|
+
"postcss-prefix-selector": "^1.16.1"
|
|
26
28
|
},
|
|
27
29
|
"peerDependencies": {
|
|
28
30
|
"@swc/core": "^1.3.83",
|
|
29
31
|
"webpack": "^5.88.2",
|
|
30
|
-
"xhs-mp-pack": "2.0.
|
|
31
|
-
"xhs-mp-compiler-utils": "2.0.
|
|
32
|
-
"xhs-mp-shared": "2.0.
|
|
33
|
-
"xhs-mp-ml-parser": "2.0.
|
|
34
|
-
"postcss": "^8.2.15",
|
|
35
|
-
"postcss-import": "^14.1.0",
|
|
36
|
-
"postcss-prefix-selector": "^1.16.1",
|
|
37
|
-
"postcss-preset-env": "^6.7.2",
|
|
38
|
-
"prettier": "^3.0.3"
|
|
32
|
+
"xhs-mp-pack": "2.0.7-beta.0",
|
|
33
|
+
"xhs-mp-compiler-utils": "2.0.7-beta.0",
|
|
34
|
+
"xhs-mp-shared": "2.0.7-beta.0",
|
|
35
|
+
"xhs-mp-ml-parser": "2.0.7-beta.0"
|
|
39
36
|
},
|
|
40
37
|
"devDependencies": {
|
|
41
38
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
@@ -56,15 +53,10 @@
|
|
|
56
53
|
"tslib": "^2.6.2",
|
|
57
54
|
"typescript": "^5.4.3",
|
|
58
55
|
"webpack": "^5.88.2",
|
|
59
|
-
"xhs-mp-pack": "2.0.
|
|
60
|
-
"xhs-mp-compiler-utils": "2.0.
|
|
61
|
-
"xhs-mp-shared": "2.0.
|
|
62
|
-
"xhs-mp-ml-parser": "2.0.
|
|
63
|
-
"postcss": "^8.2.15",
|
|
64
|
-
"postcss-import": "^14.1.0",
|
|
65
|
-
"postcss-prefix-selector": "^1.16.1",
|
|
66
|
-
"postcss-preset-env": "^6.7.2",
|
|
67
|
-
"prettier": "^3.0.3"
|
|
56
|
+
"xhs-mp-pack": "2.0.7-beta.0",
|
|
57
|
+
"xhs-mp-compiler-utils": "2.0.7-beta.0",
|
|
58
|
+
"xhs-mp-shared": "2.0.7-beta.0",
|
|
59
|
+
"xhs-mp-ml-parser": "2.0.7-beta.0"
|
|
68
60
|
},
|
|
69
61
|
"scripts": {
|
|
70
62
|
"watch": "npm run prebuild && rollup -c -w --sourcemap true",
|