@volar/language-core 2.3.0-alpha.8 → 2.3.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/index.js +18 -15
- package/lib/types.d.ts +1 -1
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -142,30 +142,33 @@ function createLanguage(plugins, scriptRegistry, sync) {
|
|
|
142
142
|
},
|
|
143
143
|
},
|
|
144
144
|
maps: {
|
|
145
|
-
get(virtualCode) {
|
|
146
|
-
for (const map of this.forEach(virtualCode)) {
|
|
147
|
-
return map[2];
|
|
148
|
-
}
|
|
149
|
-
throw `no map found for ${virtualCode.id}`;
|
|
150
|
-
},
|
|
151
|
-
*forEach(virtualCode) {
|
|
145
|
+
get(virtualCode, sourceScript) {
|
|
152
146
|
let mapCache = virtualCodeToSourceMap.get(virtualCode.snapshot);
|
|
153
147
|
if (!mapCache) {
|
|
154
148
|
virtualCodeToSourceMap.set(virtualCode.snapshot, mapCache = new WeakMap());
|
|
155
149
|
}
|
|
156
|
-
const sourceScript = virtualCodeToSourceScriptMap.get(virtualCode);
|
|
157
150
|
if (!mapCache.has(sourceScript.snapshot)) {
|
|
158
|
-
|
|
151
|
+
const mappings = virtualCode.associatedScriptMappings?.get(sourceScript.id) ?? virtualCode.mappings;
|
|
152
|
+
mapCache.set(sourceScript.snapshot, new source_map_1.SourceMap(mappings));
|
|
159
153
|
}
|
|
160
|
-
|
|
154
|
+
return mapCache.get(sourceScript.snapshot);
|
|
155
|
+
},
|
|
156
|
+
*forEach(virtualCode) {
|
|
157
|
+
const sourceScript = virtualCodeToSourceScriptMap.get(virtualCode);
|
|
158
|
+
yield [
|
|
159
|
+
sourceScript.id,
|
|
160
|
+
sourceScript.snapshot,
|
|
161
|
+
this.get(virtualCode, sourceScript),
|
|
162
|
+
];
|
|
161
163
|
if (virtualCode.associatedScriptMappings) {
|
|
162
|
-
for (const [relatedScriptId
|
|
164
|
+
for (const [relatedScriptId] of virtualCode.associatedScriptMappings) {
|
|
163
165
|
const relatedSourceScript = scriptRegistry.get(relatedScriptId);
|
|
164
166
|
if (relatedSourceScript) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
yield [
|
|
168
|
+
relatedSourceScript.id,
|
|
169
|
+
relatedSourceScript.snapshot,
|
|
170
|
+
this.get(virtualCode, relatedSourceScript),
|
|
171
|
+
];
|
|
169
172
|
}
|
|
170
173
|
}
|
|
171
174
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface Language<T = unknown> {
|
|
|
10
10
|
fromVirtualCode(virtualCode: VirtualCode): SourceScript<T>;
|
|
11
11
|
};
|
|
12
12
|
maps: {
|
|
13
|
-
get(virtualCode: VirtualCode): SourceMap<CodeInformation>;
|
|
13
|
+
get(virtualCode: VirtualCode, sourceScript: SourceScript<T>): SourceMap<CodeInformation>;
|
|
14
14
|
forEach(virtualCode: VirtualCode): Generator<[id: T, snapshot: ts.IScriptSnapshot, map: SourceMap<CodeInformation>]>;
|
|
15
15
|
};
|
|
16
16
|
linkedCodeMaps: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-core",
|
|
3
|
-
"version": "2.3.0
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/language-core"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/source-map": "2.3.0
|
|
15
|
+
"@volar/source-map": "2.3.0"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "4f6488605e22e0f76ea877460848a443fd3e8762"
|
|
18
18
|
}
|