@wevu/compiler 0.0.4 → 0.0.6
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/index.d.mts +4 -1
- package/dist/index.mjs +35 -9
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -319,6 +319,9 @@ declare const CLASS_STYLE_WXS_MODULE = "__weapp_vite";
|
|
|
319
319
|
* class/style WXS 文件名(不含扩展名)。
|
|
320
320
|
*/
|
|
321
321
|
declare const CLASS_STYLE_WXS_FILE = "__weapp_vite_class_style";
|
|
322
|
+
interface ClassStyleWxsSourceOptions {
|
|
323
|
+
extension?: string;
|
|
324
|
+
}
|
|
322
325
|
/**
|
|
323
326
|
* 构建 class/style WXS 引用标签。
|
|
324
327
|
*/
|
|
@@ -337,7 +340,7 @@ declare function resolveClassStyleWxsLocation(options: {
|
|
|
337
340
|
/**
|
|
338
341
|
* 获取内置 class/style WXS 运行时代码。
|
|
339
342
|
*/
|
|
340
|
-
declare function getClassStyleWxsSource(): string;
|
|
343
|
+
declare function getClassStyleWxsSource(options?: ClassStyleWxsSourceOptions): string;
|
|
341
344
|
//#endregion
|
|
342
345
|
//#region src/plugins/vue/transform/classStyleComputed.d.ts
|
|
343
346
|
interface ClassStyleHelperNames {
|
package/dist/index.mjs
CHANGED
|
@@ -617,17 +617,31 @@ function resolveClassStyleWxsLocation(options) {
|
|
|
617
617
|
/**
|
|
618
618
|
* 获取内置 class/style WXS 运行时代码。
|
|
619
619
|
*/
|
|
620
|
-
function getClassStyleWxsSource() {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
"
|
|
624
|
-
"",
|
|
620
|
+
function getClassStyleWxsSource(options = {}) {
|
|
621
|
+
const isSjs = (options.extension?.startsWith(".") ? options.extension.slice(1) : options.extension) === "sjs";
|
|
622
|
+
const isArrayFunctionLines = isSjs ? [
|
|
623
|
+
"function isArray(value) {",
|
|
624
|
+
" if (!toString) {",
|
|
625
|
+
" return false",
|
|
626
|
+
" }",
|
|
627
|
+
" return toString.call(value) === '[object Array]'",
|
|
628
|
+
"}"
|
|
629
|
+
] : [
|
|
625
630
|
"function isArray(value) {",
|
|
626
631
|
" if (typeof Array !== 'undefined' && Array.isArray) {",
|
|
627
632
|
" return Array.isArray(value)",
|
|
628
633
|
" }",
|
|
629
634
|
" return value && typeof value.length === 'number' && typeof value.splice === 'function'",
|
|
630
|
-
"}"
|
|
635
|
+
"}"
|
|
636
|
+
];
|
|
637
|
+
const hyphenateUpperCaseLine = isSjs ? " res += str.charAt(i).toLowerCase()" : " res += String.fromCharCode(code + 32)";
|
|
638
|
+
const bodyLines = [
|
|
639
|
+
"var objectCtor = ({}).constructor",
|
|
640
|
+
"var objectProto = objectCtor ? objectCtor.prototype : null",
|
|
641
|
+
"var hasOwn = objectProto ? objectProto.hasOwnProperty : null",
|
|
642
|
+
"var toString = objectProto ? objectProto.toString : null",
|
|
643
|
+
"",
|
|
644
|
+
...isArrayFunctionLines,
|
|
631
645
|
"",
|
|
632
646
|
"function getObjectKeys(obj) {",
|
|
633
647
|
" if (!objectCtor || !objectCtor.keys) {",
|
|
@@ -661,7 +675,7 @@ function getClassStyleWxsSource() {
|
|
|
661
675
|
" if (i > 0 && isWordCharCode(str.charCodeAt(i - 1))) {",
|
|
662
676
|
" res += '-'",
|
|
663
677
|
" }",
|
|
664
|
-
|
|
678
|
+
hyphenateUpperCaseLine,
|
|
665
679
|
" continue",
|
|
666
680
|
" }",
|
|
667
681
|
" res += str.charAt(i)",
|
|
@@ -790,12 +804,24 @@ function getClassStyleWxsSource() {
|
|
|
790
804
|
" }",
|
|
791
805
|
" return ''",
|
|
792
806
|
"}",
|
|
793
|
-
""
|
|
807
|
+
""
|
|
808
|
+
];
|
|
809
|
+
const exportLines = isSjs ? [
|
|
810
|
+
"export default {",
|
|
811
|
+
" cls: normalizeClass,",
|
|
812
|
+
" style: normalizeStyle,",
|
|
813
|
+
" stylePair: stylePair,",
|
|
814
|
+
"}"
|
|
815
|
+
] : [
|
|
794
816
|
"module.exports = {",
|
|
795
817
|
" cls: normalizeClass,",
|
|
796
818
|
" style: normalizeStyle,",
|
|
797
819
|
" stylePair: stylePair,",
|
|
798
|
-
"}"
|
|
820
|
+
"}"
|
|
821
|
+
];
|
|
822
|
+
return [
|
|
823
|
+
...bodyLines,
|
|
824
|
+
...exportLines,
|
|
799
825
|
""
|
|
800
826
|
].join("\n");
|
|
801
827
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/compiler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@babel/generator": "^7.29.
|
|
44
|
+
"@babel/generator": "^7.29.1",
|
|
45
45
|
"@babel/parser": "^7.29.0",
|
|
46
46
|
"@babel/traverse": "^7.29.0",
|
|
47
47
|
"@babel/types": "^7.29.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"pathe": "^2.0.3",
|
|
55
55
|
"vue": "^3.5.27",
|
|
56
56
|
"@weapp-core/shared": "3.0.1",
|
|
57
|
-
"rolldown-require": "2.0.
|
|
57
|
+
"rolldown-require": "2.0.6"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public",
|