xhs-mp-sketch-loader 2.0.7-beta.0 → 2.0.7

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.
@@ -1 +1 @@
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(/&nbsp;/g," ").replace(/&ensp;/g," ").replace(/&emsp;/g," ").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/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}}}))};
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(/&nbsp;/g," ").replace(/&ensp;/g," ").replace(/&emsp;/g," ").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/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","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.7-beta.0",
3
+ "version": "2.0.7",
4
4
  "description": "sketch loader",
5
5
  "category": "esm",
6
6
  "main": "./dist/index.js",
@@ -29,10 +29,10 @@
29
29
  "peerDependencies": {
30
30
  "@swc/core": "^1.3.83",
31
31
  "webpack": "^5.88.2",
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"
32
+ "xhs-mp-pack": "2.0.7",
33
+ "xhs-mp-compiler-utils": "2.0.7",
34
+ "xhs-mp-shared": "2.0.7",
35
+ "xhs-mp-ml-parser": "2.0.7"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -53,10 +53,10 @@
53
53
  "tslib": "^2.6.2",
54
54
  "typescript": "^5.4.3",
55
55
  "webpack": "^5.88.2",
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"
56
+ "xhs-mp-pack": "2.0.7",
57
+ "xhs-mp-compiler-utils": "2.0.7",
58
+ "xhs-mp-shared": "2.0.7",
59
+ "xhs-mp-ml-parser": "2.0.7"
60
60
  },
61
61
  "scripts": {
62
62
  "watch": "npm run prebuild && rollup -c -w --sourcemap true",