|
1 | 1 | /**
|
2 | 2 | * @typedef {import('vfile').VFile} VFile
|
3 |
| - * @typedef {import('vfile-location').Location} VFileLocation |
4 | 3 | * @typedef {import('property-information').Schema} Schema
|
5 | 4 | * @typedef {import('unist').Position} Position
|
6 | 5 | * @typedef {import('unist').Point} Point
|
|
45 | 44 |
|
46 | 45 | import {h, s} from 'hastscript'
|
47 | 46 | import {html, svg, find} from 'property-information'
|
48 |
| -import vfileLocation from 'vfile-location' |
| 47 | +import {location} from 'vfile-location' |
49 | 48 | import {webNamespaces} from 'web-namespaces'
|
50 | 49 |
|
51 | 50 | const own = {}.hasOwnProperty
|
@@ -118,7 +117,7 @@ function transform(ctx, ast) {
|
118 | 117 |
|
119 | 118 | if ('sourceCodeLocation' in ast && ast.sourceCodeLocation && ctx.file) {
|
120 | 119 | // @ts-expect-error It’s fine.
|
121 |
| - const position = location(ctx, result, ast.sourceCodeLocation) |
| 120 | + const position = createLocation(ctx, result, ast.sourceCodeLocation) |
122 | 121 |
|
123 | 122 | if (position) {
|
124 | 123 | ctx.location = true
|
@@ -170,10 +169,10 @@ function root(ctx, ast, children) {
|
170 | 169 |
|
171 | 170 | if (ctx.file && ctx.location) {
|
172 | 171 | const doc = String(ctx.file)
|
173 |
| - const location = vfileLocation(doc) |
| 172 | + const loc = location(doc) |
174 | 173 | result.position = {
|
175 |
| - start: location.toPoint(0), |
176 |
| - end: location.toPoint(doc.length) |
| 174 | + start: loc.toPoint(0), |
| 175 | + end: loc.toPoint(doc.length) |
177 | 176 | }
|
178 | 177 | }
|
179 | 178 |
|
@@ -262,7 +261,7 @@ function element(ctx, ast, children) {
|
262 | 261 | * @param {P5ElementLocation} location
|
263 | 262 | * @returns {Position|null}
|
264 | 263 | */
|
265 |
| -function location(ctx, node, location) { |
| 264 | +function createLocation(ctx, node, location) { |
266 | 265 | const result = position(location)
|
267 | 266 |
|
268 | 267 | if (node.type === 'element') {
|
|
0 commit comments