@vue/language-plugin-pug
Advanced tools
Comparing version 2.0.29 to 2.1.0
40
index.js
@@ -26,16 +26,28 @@ "use strict"; | ||
function createProxyObject(target) { | ||
const proxys = new WeakMap(); | ||
return new Proxy(target, { | ||
get(target, prop) { | ||
get(target, prop, receiver) { | ||
if (prop === 'getClassOffset') { | ||
// div.foo#baz.bar | ||
// ^^^ ^^^ | ||
// class=" foo bar" | ||
// ^^^ ^^^ | ||
// NOTE: we need to expose source offset getter | ||
return function (startOffset) { | ||
return getOffset(target.offset + startOffset); | ||
}; | ||
} | ||
if (prop === 'offset') { | ||
const htmlOffset = target.offset; | ||
const nums = []; | ||
for (const mapped of map.toSourceLocation(htmlOffset)) { | ||
nums.push(mapped[0]); | ||
return getOffset(target.offset); | ||
} | ||
const value = Reflect.get(target, prop, receiver); | ||
if (typeof value === 'object' && value !== null) { | ||
let proxyed = proxys.get(value); | ||
if (proxyed) { | ||
return proxyed; | ||
} | ||
return Math.max(-1, ...nums); | ||
proxyed = createProxyObject(value); | ||
proxys.set(value, proxyed); | ||
return proxyed; | ||
} | ||
const value = target[prop]; | ||
if (typeof value === 'object') { | ||
return createProxyObject(target[prop]); | ||
} | ||
return value; | ||
@@ -45,2 +57,10 @@ } | ||
} | ||
function getOffset(offset) { | ||
const htmlOffset = offset; | ||
const nums = []; | ||
for (const mapped of map.toSourceLocation(htmlOffset)) { | ||
nums.push(mapped[0]); | ||
} | ||
return Math.max(-1, ...nums); | ||
} | ||
} | ||
@@ -47,0 +67,0 @@ } |
{ | ||
"name": "@vue/language-plugin-pug", | ||
"version": "2.0.29", | ||
"version": "2.1.0", | ||
"license": "MIT", | ||
@@ -16,9 +16,9 @@ "files": [ | ||
"@types/node": "latest", | ||
"@vue/language-core": "2.0.29" | ||
"@vue/language-core": "2.1.0" | ||
}, | ||
"dependencies": { | ||
"@volar/source-map": "~2.4.0-alpha.18", | ||
"volar-service-pug": "0.0.59" | ||
"@volar/source-map": "~2.4.1", | ||
"volar-service-pug": "0.0.62" | ||
}, | ||
"gitHead": "49ad9563e6f2677595878a000179dfea83fb910c" | ||
"gitHead": "510063740b90b64caedaee1f0bde70974613a92c" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5231
72
+ Addedvolar-service-html@0.0.62(transitive)
+ Addedvolar-service-pug@0.0.62(transitive)
- Removedvolar-service-html@0.0.59(transitive)
- Removedvolar-service-pug@0.0.59(transitive)
Updated@volar/source-map@~2.4.1
Updatedvolar-service-pug@0.0.62