@vue/language-plugin-pug 2.0.29 → 2.1.2
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/index.js +30 -10
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -23,24 +23,44 @@ const plugin = ({ modules }) => {
|
|
|
23
23
|
});
|
|
24
24
|
return createProxyObject(completed);
|
|
25
25
|
function createProxyObject(target) {
|
|
26
|
+
const proxys = new WeakMap();
|
|
26
27
|
return new Proxy(target, {
|
|
27
|
-
get(target, prop) {
|
|
28
|
+
get(target, prop, receiver) {
|
|
29
|
+
if (prop === 'getClassOffset') {
|
|
30
|
+
// div.foo#baz.bar
|
|
31
|
+
// ^^^ ^^^
|
|
32
|
+
// class=" foo bar"
|
|
33
|
+
// ^^^ ^^^
|
|
34
|
+
// NOTE: we need to expose source offset getter
|
|
35
|
+
return function (startOffset) {
|
|
36
|
+
return getOffset(target.offset + startOffset);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
28
39
|
if (prop === 'offset') {
|
|
29
|
-
|
|
30
|
-
const nums = [];
|
|
31
|
-
for (const mapped of map.toSourceLocation(htmlOffset)) {
|
|
32
|
-
nums.push(mapped[0]);
|
|
33
|
-
}
|
|
34
|
-
return Math.max(-1, ...nums);
|
|
40
|
+
return getOffset(target.offset);
|
|
35
41
|
}
|
|
36
|
-
const value = target
|
|
37
|
-
if (typeof value === 'object') {
|
|
38
|
-
|
|
42
|
+
const value = Reflect.get(target, prop, receiver);
|
|
43
|
+
if (typeof value === 'object' && value !== null) {
|
|
44
|
+
let proxyed = proxys.get(value);
|
|
45
|
+
if (proxyed) {
|
|
46
|
+
return proxyed;
|
|
47
|
+
}
|
|
48
|
+
proxyed = createProxyObject(value);
|
|
49
|
+
proxys.set(value, proxyed);
|
|
50
|
+
return proxyed;
|
|
39
51
|
}
|
|
40
52
|
return value;
|
|
41
53
|
}
|
|
42
54
|
});
|
|
43
55
|
}
|
|
56
|
+
function getOffset(offset) {
|
|
57
|
+
const htmlOffset = offset;
|
|
58
|
+
const nums = [];
|
|
59
|
+
for (const mapped of map.toSourceLocation(htmlOffset)) {
|
|
60
|
+
nums.push(mapped[0]);
|
|
61
|
+
}
|
|
62
|
+
return Math.max(-1, ...nums);
|
|
63
|
+
}
|
|
44
64
|
}
|
|
45
65
|
}
|
|
46
66
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-plugin-pug",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/node": "latest",
|
|
16
|
-
"@vue/language-core": "2.
|
|
16
|
+
"@vue/language-core": "2.1.2"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@volar/source-map": "~2.4.
|
|
20
|
-
"volar-service-pug": "0.0.
|
|
19
|
+
"@volar/source-map": "~2.4.1",
|
|
20
|
+
"volar-service-pug": "0.0.62"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "4e4b839ea20ae11a2aef7ee9206465cb60a4be53"
|
|
23
23
|
}
|