Revamping to matrix style
This commit is contained in:
21
node_modules/@astrojs/check/LICENSE
generated
vendored
Normal file
21
node_modules/@astrojs/check/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 The Astro Technology Company
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1
node_modules/@astrojs/check/dist/bin.d.ts
generated
vendored
Normal file
1
node_modules/@astrojs/check/dist/bin.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
9
node_modules/@astrojs/check/dist/bin.js
generated
vendored
Executable file
9
node_modules/@astrojs/check/dist/bin.js
generated
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
import path from 'node:path';
|
||||
import { check, parseArgsAsCheckConfig } from './index.js';
|
||||
const args = parseArgsAsCheckConfig(process.argv);
|
||||
console.info(`Getting diagnostics for Astro files in ${path.resolve(args.root)}...`);
|
||||
const result = await check(args);
|
||||
if (typeof result === 'boolean') {
|
||||
process.exit(result ? 1 : 0);
|
||||
}
|
||||
//# sourceMappingURL=bin.js.map
|
||||
23
node_modules/@astrojs/check/dist/index.d.ts
generated
vendored
Normal file
23
node_modules/@astrojs/check/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { options } from './options.js';
|
||||
/**
|
||||
* Given a list of arguments from the command line (such as `process.argv`), return parsed and processed options
|
||||
*/
|
||||
export declare function parseArgsAsCheckConfig(args: string[]): {
|
||||
[x: string]: unknown;
|
||||
readonly root: string;
|
||||
readonly watch: boolean;
|
||||
readonly tsconfig: string | undefined;
|
||||
readonly minimumFailingSeverity: "error" | "warning" | "hint";
|
||||
readonly minimumSeverity: "error" | "warning" | "hint";
|
||||
readonly preserveWatchOutput: boolean;
|
||||
_: (string | number)[];
|
||||
$0: string;
|
||||
};
|
||||
export type Flags = Pick<ReturnType<typeof parseArgsAsCheckConfig>, keyof typeof options>;
|
||||
export declare function check(flags: Partial<Flags> & {
|
||||
watch: true;
|
||||
}): Promise<void>;
|
||||
export declare function check(flags: Partial<Flags> & {
|
||||
watch: false;
|
||||
}): Promise<boolean>;
|
||||
export declare function check(flags: Partial<Flags>): Promise<boolean | void>;
|
||||
99
node_modules/@astrojs/check/dist/index.js
generated
vendored
Normal file
99
node_modules/@astrojs/check/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import path from 'node:path';
|
||||
import { AstroCheck } from '@astrojs/language-server';
|
||||
import { watch } from 'chokidar';
|
||||
import { bold, dim, red, yellow } from 'kleur/colors';
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import { options } from './options.js';
|
||||
/**
|
||||
* Given a list of arguments from the command line (such as `process.argv`), return parsed and processed options
|
||||
*/
|
||||
export function parseArgsAsCheckConfig(args) {
|
||||
return yargs(hideBin(args)).options(options).parseSync();
|
||||
}
|
||||
/**
|
||||
* Print diagnostics according to the given flags, and return whether or not the program should exit with an error code.
|
||||
*/
|
||||
export async function check(flags) {
|
||||
const workspaceRoot = path.resolve(flags.root ?? process.cwd());
|
||||
const require = createRequire(import.meta.url);
|
||||
const checker = new AstroCheck(workspaceRoot, require.resolve('typescript'), flags.tsconfig);
|
||||
let req = 0;
|
||||
if (flags.watch) {
|
||||
function createWatcher(rootPath, extensions) {
|
||||
return watch(`${rootPath}/**/*{${extensions.join(',')}}`, {
|
||||
ignored: (ignoredPath) => ignoredPath.includes('node_modules'),
|
||||
ignoreInitial: true,
|
||||
});
|
||||
}
|
||||
// Dynamically get the list of extensions to watch from the files already included in the project
|
||||
const checkedExtensions = Array.from(new Set(checker.linter.languageHost.getScriptFileNames().map((fileName) => path.extname(fileName))));
|
||||
createWatcher(workspaceRoot, checkedExtensions)
|
||||
.on('add', (fileName) => {
|
||||
checker.linter.fileCreated(fileName);
|
||||
update();
|
||||
})
|
||||
.on('unlink', (fileName) => {
|
||||
checker.linter.fileDeleted(fileName);
|
||||
update();
|
||||
})
|
||||
.on('change', (fileName) => {
|
||||
checker.linter.fileUpdated(fileName);
|
||||
update();
|
||||
});
|
||||
}
|
||||
async function update() {
|
||||
if (!flags.preserveWatchOutput)
|
||||
process.stdout.write('\x1Bc');
|
||||
await lint();
|
||||
}
|
||||
async function lint() {
|
||||
const currentReq = ++req;
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
const isCanceled = () => currentReq !== req;
|
||||
if (isCanceled())
|
||||
return;
|
||||
const minimumSeverity = flags.minimumSeverity || 'hint';
|
||||
const result = await checker.lint({
|
||||
logErrors: {
|
||||
level: minimumSeverity,
|
||||
},
|
||||
cancel: isCanceled,
|
||||
});
|
||||
console.info([
|
||||
bold(`Result (${result.fileChecked} file${result.fileChecked === 1 ? '' : 's'}): `),
|
||||
['error', 'warning', 'hint'].includes(minimumSeverity)
|
||||
? bold(red(`${result.errors} ${result.errors === 1 ? 'error' : 'errors'}`))
|
||||
: undefined,
|
||||
['warning', 'hint'].includes(minimumSeverity)
|
||||
? bold(yellow(`${result.warnings} ${result.warnings === 1 ? 'warning' : 'warnings'}`))
|
||||
: undefined,
|
||||
['hint'].includes(minimumSeverity)
|
||||
? dim(`${result.hints} ${result.hints === 1 ? 'hint' : 'hints'}\n`)
|
||||
: undefined,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(`\n${dim('-')} `));
|
||||
if (flags.watch) {
|
||||
console.info('Watching for changes...');
|
||||
}
|
||||
else {
|
||||
switch (flags.minimumFailingSeverity) {
|
||||
case 'error':
|
||||
return result.errors > 0;
|
||||
case 'warning':
|
||||
return result.errors + result.warnings > 0;
|
||||
case 'hint':
|
||||
return result.errors + result.warnings + result.hints > 0;
|
||||
default:
|
||||
return result.errors > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Always lint on first run, even in watch mode.
|
||||
const lintResult = await lint();
|
||||
if (!flags.watch)
|
||||
return lintResult;
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
32
node_modules/@astrojs/check/dist/options.d.ts
generated
vendored
Normal file
32
node_modules/@astrojs/check/dist/options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
export declare const options: {
|
||||
readonly root: {
|
||||
readonly type: "string";
|
||||
readonly default: string;
|
||||
readonly description: "Manually specify a root dir to check in. By default, the current working directory is used.";
|
||||
};
|
||||
readonly watch: {
|
||||
readonly type: "boolean";
|
||||
readonly default: false;
|
||||
readonly alias: "w";
|
||||
};
|
||||
readonly tsconfig: {
|
||||
readonly type: "string";
|
||||
readonly description: "Manually specify a path to a `tsconfig.json` or `jsconfig.json` to use. If not specified, the program will attempt to find a config, if it cannot it'll attempt to automatically infer the project's configuration.";
|
||||
readonly default: undefined;
|
||||
};
|
||||
readonly minimumFailingSeverity: {
|
||||
readonly choices: readonly ["error", "warning", "hint"];
|
||||
readonly description: "Minimum error severity needed to exit with an error code. Choosing 'hint' will for example cause the program to exit with an error if there's any unfixed hints.";
|
||||
readonly default: "error";
|
||||
};
|
||||
readonly minimumSeverity: {
|
||||
readonly choices: readonly ["error", "warning", "hint"];
|
||||
readonly description: "Minimum diagnostic severity to show. Choosing `warning` will, for example, show both errors and warnings, but not hints. ";
|
||||
readonly default: "hint";
|
||||
};
|
||||
readonly preserveWatchOutput: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "If set to false, output won't be cleared between checks in watch mode.";
|
||||
readonly default: false;
|
||||
};
|
||||
};
|
||||
29
node_modules/@astrojs/check/dist/options.js
generated
vendored
Normal file
29
node_modules/@astrojs/check/dist/options.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
export const options = {
|
||||
root: {
|
||||
type: 'string',
|
||||
default: process.cwd(),
|
||||
description: 'Manually specify a root dir to check in. By default, the current working directory is used.',
|
||||
},
|
||||
watch: { type: 'boolean', default: false, alias: 'w' },
|
||||
tsconfig: {
|
||||
type: 'string',
|
||||
description: "Manually specify a path to a `tsconfig.json` or `jsconfig.json` to use. If not specified, the program will attempt to find a config, if it cannot it'll attempt to automatically infer the project's configuration.",
|
||||
default: undefined,
|
||||
},
|
||||
minimumFailingSeverity: {
|
||||
choices: ['error', 'warning', 'hint'],
|
||||
description: "Minimum error severity needed to exit with an error code. Choosing 'hint' will for example cause the program to exit with an error if there's any unfixed hints.",
|
||||
default: 'error',
|
||||
},
|
||||
minimumSeverity: {
|
||||
choices: ['error', 'warning', 'hint'],
|
||||
description: 'Minimum diagnostic severity to show. Choosing `warning` will, for example, show both errors and warnings, but not hints. ',
|
||||
default: 'hint',
|
||||
},
|
||||
preserveWatchOutput: {
|
||||
type: 'boolean',
|
||||
description: "If set to false, output won't be cleared between checks in watch mode.",
|
||||
default: false,
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=options.js.map
|
||||
47
node_modules/@astrojs/check/package.json
generated
vendored
Normal file
47
node_modules/@astrojs/check/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "@astrojs/check",
|
||||
"version": "0.5.10",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/language-tools",
|
||||
"directory": "packages/astro-check"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"bin": {
|
||||
"astro-check": "./dist/bin.js"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist/**/*.js",
|
||||
"dist/**/*.d.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"@astrojs/language-server": "^2.8.4",
|
||||
"chokidar": "^3.5.3",
|
||||
"fast-glob": "^3.3.1",
|
||||
"kleur": "^4.1.5",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.17.8",
|
||||
"@types/yargs": "^17.0.24",
|
||||
"@types/chai": "^4.3.5",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"chai": "^4.3.7",
|
||||
"mocha": "^10.2.0",
|
||||
"tsx": "^3.12.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"test": "mocha --timeout 50000 --require tsx test/**/*.test.ts",
|
||||
"test:match": "pnpm run test -g"
|
||||
}
|
||||
}
|
||||
53
node_modules/@astrojs/compiler/LICENSE
generated
vendored
Normal file
53
node_modules/@astrojs/compiler/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 [Astro contributors](https://github.com/withastro/compiler/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
This license applies to parts of the `internal/` subdirectory originating from
|
||||
the https://cs.opensource.google/go/x/net/+/master:html/ repository:
|
||||
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
66
node_modules/@astrojs/compiler/README.md
generated
vendored
Normal file
66
node_modules/@astrojs/compiler/README.md
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
# Astro Compiler
|
||||
|
||||
Astro’s [Go](https://golang.org/) + WASM compiler.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install @astrojs/compiler
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
#### Transform `.astro` to valid TypeScript
|
||||
|
||||
The Astro compiler can convert `.astro` syntax to a TypeScript Module whose default export generates HTML.
|
||||
|
||||
**Some notes**...
|
||||
|
||||
- TypeScript is valid `.astro` syntax! The output code may need an additional post-processing step to generate valid JavaScript.
|
||||
- `.astro` files rely on a server implementation exposed as `astro/runtime/server/index.js` in the Node ecosystem. Other runtimes currently need to bring their own rendering implementation and reference it via `internalURL`. This is a pain point we're looking into fixing.
|
||||
|
||||
```js
|
||||
import { transform, type TransformResult } from "@astrojs/compiler";
|
||||
|
||||
const result = await transform(source, {
|
||||
filename: "/Users/astro/Code/project/src/pages/index.astro",
|
||||
sourcemap: "both",
|
||||
internalURL: "astro/runtime/server/index.js",
|
||||
});
|
||||
```
|
||||
|
||||
#### Parse `.astro` and return an AST
|
||||
|
||||
The Astro compiler can emit an AST using the `parse` method.
|
||||
|
||||
**Some notes**...
|
||||
|
||||
- Position data is currently incomplete and in some cases incorrect. We're working on it!
|
||||
- A `TextNode` can represent both HTML `text` and JavaScript/TypeScript source code.
|
||||
- The `@astrojs/compiler/utils` entrypoint exposes a `walk` function that can be used to traverse the AST. It also exposes the `is` helper which can be used as guards to derive the proper types for each `node`.
|
||||
|
||||
```js
|
||||
import { parse } from "@astrojs/compiler";
|
||||
import { walk, is } from "@astrojs/compiler/utils";
|
||||
|
||||
const result = await parse(source, {
|
||||
position: false, // defaults to `true`
|
||||
});
|
||||
|
||||
walk(result.ast, (node) => {
|
||||
// `tag` nodes are `element` | `custom-element` | `component`
|
||||
if (is.tag(node)) {
|
||||
console.log(node.name);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Develop
|
||||
|
||||
### VSCode / CodeSpaces
|
||||
|
||||
A `devcontainer` configuration is available for use with VSCode's [Remote Development extension pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) and GitHub CodeSpaces.
|
||||
|
||||
## Contributing
|
||||
|
||||
[CONTRIBUTING.md](/CONTRIBUTING.md)
|
||||
BIN
node_modules/@astrojs/compiler/dist/astro.wasm
generated
vendored
Normal file
BIN
node_modules/@astrojs/compiler/dist/astro.wasm
generated
vendored
Normal file
Binary file not shown.
2
node_modules/@astrojs/compiler/dist/browser/index.cjs
generated
vendored
Normal file
2
node_modules/@astrojs/compiler/dist/browser/index.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
11
node_modules/@astrojs/compiler/dist/browser/index.d.ts
generated
vendored
Normal file
11
node_modules/@astrojs/compiler/dist/browser/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { transform as transform$1, parse as parse$1, convertToTSX as convertToTSX$1, teardown as teardown$1, initialize as initialize$1 } from '../shared/types.js';
|
||||
import '../shared/ast.js';
|
||||
import '../shared/diagnostics.js';
|
||||
|
||||
declare const transform: typeof transform$1;
|
||||
declare const parse: typeof parse$1;
|
||||
declare const convertToTSX: typeof convertToTSX$1;
|
||||
declare const teardown: typeof teardown$1;
|
||||
declare const initialize: typeof initialize$1;
|
||||
|
||||
export { convertToTSX, initialize, parse, teardown, transform };
|
||||
1
node_modules/@astrojs/compiler/dist/browser/index.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/browser/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{a as f}from"../chunk-QR6QDSEV.js";var u=(t,e)=>p().transform(t,e),S=(t,e)=>p().parse(t,e),v=(t,e)=>p().convertToTSX(t,e),a,i,h=()=>{a=void 0,i=void 0,globalThis["@astrojs/compiler"]=void 0},T=async t=>{let e=t.wasmURL;if(!e)throw new Error('Must provide the "wasmURL" option');e+="",a||(a=m(e).catch(n=>{throw a=void 0,n})),i=i||await a},p=()=>{if(!a)throw new Error('You need to call "initialize" before calling this');if(!i)throw new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this');return i},y=async(t,e)=>{let n;return WebAssembly.instantiateStreaming?n=await WebAssembly.instantiateStreaming(fetch(t),e):n=await(async()=>{let s=await fetch(t).then(o=>o.arrayBuffer());return WebAssembly.instantiate(s,e)})(),n},m=async t=>{let e=new f,n=await y(t,e.importObject);e.run(n.instance);let c=globalThis["@astrojs/compiler"];return{transform:(s,o)=>new Promise(r=>r(c.transform(s,o||{}))),convertToTSX:(s,o)=>new Promise(r=>r(c.convertToTSX(s,o||{}))).then(r=>({...r,map:JSON.parse(r.map)})),parse:(s,o)=>new Promise(r=>r(c.parse(s,o||{}))).then(r=>({...r,ast:JSON.parse(r.ast)}))}};export{v as convertToTSX,T as initialize,S as parse,h as teardown,u as transform};
|
||||
3
node_modules/@astrojs/compiler/dist/browser/utils.cjs
generated
vendored
Normal file
3
node_modules/@astrojs/compiler/dist/browser/utils.cjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var t in e)l(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!N.call(o,r)&&r!==t&&l(o,r,{get:()=>e[r],enumerable:!(a=d(e,r))||a.enumerable});return o};var h=o=>f(l({},"__esModule",{value:!0}),o);var v={};u(v,{is:()=>s,serialize:()=>g,walk:()=>y});module.exports=h(v);function n(o){return e=>e.type===o}var s={parent(o){return Array.isArray(o.children)},literal(o){return typeof o.value=="string"},tag(o){return o.type==="element"||o.type==="custom-element"||o.type==="component"||o.type==="fragment"},whitespace(o){return o.type==="text"&&o.value.trim().length===0},root:n("root"),element:n("element"),customElement:n("custom-element"),component:n("component"),fragment:n("fragment"),expression:n("expression"),text:n("text"),doctype:n("doctype"),comment:n("comment"),frontmatter:n("frontmatter")},m=class{constructor(e){this.callback=e}async visit(e,t,a){if(await this.callback(e,t,a),s.parent(e)){let r=[];for(let i=0;i<e.children.length;i++){let c=e.children[i];r.push(this.callback(c,e,i))}await Promise.all(r)}}};function y(o,e){new m(e).visit(o)}function x(o){let e="";for(let t of o.attributes)switch(e+=" ",t.kind){case"empty":{e+=`${t.name}`;break}case"expression":{e+=`${t.name}={${t.value}}`;break}case"quoted":{e+=`${t.name}=${t.raw}`;break}case"template-literal":{e+=`${t.name}=\`${t.value}\``;break}case"shorthand":{e+=`{${t.name}}`;break}case"spread":{e+=`{...${t.value}}`;break}}return e}function g(o,e={selfClose:!0}){let t="";function a(r){if(s.root(r))for(let i of r.children)a(i);else if(s.frontmatter(r))t+=`---${r.value}---
|
||||
|
||||
`;else if(s.comment(r))t+=`<!--${r.value}-->`;else if(s.expression(r)){t+="{";for(let i of r.children)a(i);t+="}"}else if(s.literal(r))t+=r.value;else if(s.tag(r))if(t+=`<${r.name}`,t+=x(r),r.children.length===0&&e.selfClose)t+=" />";else{t+=">";for(let i of r.children)a(i);t+=`</${r.name}>`}}return a(o),t}0&&(module.exports={is,serialize,walk});
|
||||
28
node_modules/@astrojs/compiler/dist/browser/utils.d.ts
generated
vendored
Normal file
28
node_modules/@astrojs/compiler/dist/browser/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Node, ParentNode, LiteralNode, TagLikeNode, TextNode, RootNode, ElementNode, CustomElementNode, ComponentNode, FragmentNode, ExpressionNode, DoctypeNode, CommentNode, FrontmatterNode } from '../shared/ast.js';
|
||||
|
||||
type Visitor = (node: Node, parent?: ParentNode, index?: number) => void | Promise<void>;
|
||||
declare const is: {
|
||||
parent(node: Node): node is ParentNode;
|
||||
literal(node: Node): node is LiteralNode;
|
||||
tag(node: Node): node is TagLikeNode;
|
||||
whitespace(node: Node): node is TextNode;
|
||||
root: (node: Node) => node is RootNode;
|
||||
element: (node: Node) => node is ElementNode;
|
||||
customElement: (node: Node) => node is CustomElementNode;
|
||||
component: (node: Node) => node is ComponentNode;
|
||||
fragment: (node: Node) => node is FragmentNode;
|
||||
expression: (node: Node) => node is ExpressionNode;
|
||||
text: (node: Node) => node is TextNode;
|
||||
doctype: (node: Node) => node is DoctypeNode;
|
||||
comment: (node: Node) => node is CommentNode;
|
||||
frontmatter: (node: Node) => node is FrontmatterNode;
|
||||
};
|
||||
declare function walk(node: ParentNode, callback: Visitor): void;
|
||||
interface SerializeOptions {
|
||||
selfClose: boolean;
|
||||
}
|
||||
/** @deprecated Please use `SerializeOptions` */
|
||||
type SerializeOtions = SerializeOptions;
|
||||
declare function serialize(root: Node, opts?: SerializeOptions): string;
|
||||
|
||||
export { SerializeOptions, SerializeOtions, Visitor, is, serialize, walk };
|
||||
3
node_modules/@astrojs/compiler/dist/browser/utils.js
generated
vendored
Normal file
3
node_modules/@astrojs/compiler/dist/browser/utils.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
function n(o){return t=>t.type===o}var a={parent(o){return Array.isArray(o.children)},literal(o){return typeof o.value=="string"},tag(o){return o.type==="element"||o.type==="custom-element"||o.type==="component"||o.type==="fragment"},whitespace(o){return o.type==="text"&&o.value.trim().length===0},root:n("root"),element:n("element"),customElement:n("custom-element"),component:n("component"),fragment:n("fragment"),expression:n("expression"),text:n("text"),doctype:n("doctype"),comment:n("comment"),frontmatter:n("frontmatter")},l=class{constructor(t){this.callback=t}async visit(t,e,s){if(await this.callback(t,e,s),a.parent(t)){let r=[];for(let i=0;i<t.children.length;i++){let m=t.children[i];r.push(this.callback(m,t,i))}await Promise.all(r)}}};function N(o,t){new l(t).visit(o)}function c(o){let t="";for(let e of o.attributes)switch(t+=" ",e.kind){case"empty":{t+=`${e.name}`;break}case"expression":{t+=`${e.name}={${e.value}}`;break}case"quoted":{t+=`${e.name}=${e.raw}`;break}case"template-literal":{t+=`${e.name}=\`${e.value}\``;break}case"shorthand":{t+=`{${e.name}}`;break}case"spread":{t+=`{...${e.value}}`;break}}return t}function u(o,t={selfClose:!0}){let e="";function s(r){if(a.root(r))for(let i of r.children)s(i);else if(a.frontmatter(r))e+=`---${r.value}---
|
||||
|
||||
`;else if(a.comment(r))e+=`<!--${r.value}-->`;else if(a.expression(r)){e+="{";for(let i of r.children)s(i);e+="}"}else if(a.literal(r))e+=r.value;else if(a.tag(r))if(e+=`<${r.name}`,e+=c(r),r.children.length===0&&t.selfClose)e+=" />";else{e+=">";for(let i of r.children)s(i);e+=`</${r.name}>`}}return s(o),e}export{a as is,u as serialize,N as walk};
|
||||
2
node_modules/@astrojs/compiler/dist/browser/wasm_exec.cjs
generated
vendored
Normal file
2
node_modules/@astrojs/compiler/dist/browser/wasm_exec.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
37
node_modules/@astrojs/compiler/dist/browser/wasm_exec.d.ts
generated
vendored
Normal file
37
node_modules/@astrojs/compiler/dist/browser/wasm_exec.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
declare class Go {
|
||||
importObject: {
|
||||
gojs: {
|
||||
'runtime.wasmExit': (sp: any) => void;
|
||||
'runtime.wasmWrite': (sp: any) => void;
|
||||
'runtime.resetMemoryDataView': (sp: any) => void;
|
||||
'runtime.nanotime1': (sp: any) => void;
|
||||
'runtime.walltime': (sp: any) => void;
|
||||
'runtime.scheduleTimeoutEvent': (sp: any) => void;
|
||||
'runtime.clearTimeoutEvent': (sp: any) => void;
|
||||
'runtime.getRandomData': (sp: any) => void;
|
||||
'syscall/js.finalizeRef': (sp: any) => void;
|
||||
'syscall/js.stringVal': (sp: any) => void;
|
||||
'syscall/js.valueGet': (sp: any) => void;
|
||||
'syscall/js.valueSet': (sp: any) => void;
|
||||
'syscall/js.valueDelete': (sp: any) => void;
|
||||
'syscall/js.valueIndex': (sp: any) => void;
|
||||
'syscall/js.valueSetIndex': (sp: any) => void;
|
||||
'syscall/js.valueCall': (sp: any) => void;
|
||||
'syscall/js.valueInvoke': (sp: any) => void;
|
||||
'syscall/js.valueNew': (sp: any) => void;
|
||||
'syscall/js.valueLength': (sp: any) => void;
|
||||
'syscall/js.valuePrepareString': (sp: any) => void;
|
||||
'syscall/js.valueLoadString': (sp: any) => void;
|
||||
'syscall/js.valueInstanceOf': (sp: any) => void;
|
||||
'syscall/js.copyBytesToGo': (sp: any) => void;
|
||||
'syscall/js.copyBytesToJS': (sp: any) => void;
|
||||
debug: (value: any) => void;
|
||||
};
|
||||
};
|
||||
constructor();
|
||||
run(instance: any): Promise<void>;
|
||||
private _resume;
|
||||
private _makeFuncWrapper;
|
||||
}
|
||||
|
||||
export { Go as default };
|
||||
1
node_modules/@astrojs/compiler/dist/browser/wasm_exec.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/browser/wasm_exec.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{a}from"../chunk-QR6QDSEV.js";export{a as default};
|
||||
2
node_modules/@astrojs/compiler/dist/chunk-QR6QDSEV.js
generated
vendored
Normal file
2
node_modules/@astrojs/compiler/dist/chunk-QR6QDSEV.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@astrojs/compiler/dist/chunk-W5DTLHV4.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/chunk-W5DTLHV4.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@astrojs/compiler/dist/node/index.cjs
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/node/index.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
node_modules/@astrojs/compiler/dist/node/index.d.ts
generated
vendored
Normal file
12
node_modules/@astrojs/compiler/dist/node/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { transform as transform$1, parse as parse$1, convertToTSX as convertToTSX$1, teardown as teardown$1 } from '../shared/types.js';
|
||||
export { HoistedScript, ParseOptions, ParseResult, PreprocessorResult, TransformOptions, TransformResult } from '../shared/types.js';
|
||||
import '../shared/ast.js';
|
||||
import '../shared/diagnostics.js';
|
||||
|
||||
declare const transform: typeof transform$1;
|
||||
declare const parse: typeof parse$1;
|
||||
declare const convertToTSX: typeof convertToTSX$1;
|
||||
declare const compile: (template: string) => Promise<string>;
|
||||
declare const teardown: typeof teardown$1;
|
||||
|
||||
export { compile, convertToTSX, parse, teardown, transform };
|
||||
1
node_modules/@astrojs/compiler/dist/node/index.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/node/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{a as c}from"../chunk-W5DTLHV4.js";import{promises as m}from"fs";import{fileURLToPath as f}from"url";var w=async(t,s)=>i().then(r=>r.transform(t,s)),l=async(t,s)=>i().then(r=>r.parse(t,s)),b=async(t,s)=>i().then(r=>r.convertToTSX(t,s)),P=async t=>{let{default:s}=await import(`data:text/javascript;charset=utf-8;base64,${Buffer.from(t).toString("base64")}`);return s},n,g=()=>{n=void 0,globalThis["@astrojs/compiler"]=void 0},i=()=>(n||(n=d().catch(t=>{throw n=void 0,t})),n),y=async(t,s)=>{let r;return r=await(async()=>{let o=await m.readFile(t).then(e=>e.buffer);return WebAssembly.instantiate(new Uint8Array(o),s)})(),r},d=async()=>{let t=new c,s=await y(f(new URL("../astro.wasm",import.meta.url)),t.importObject);t.run(s.instance);let r=globalThis["@astrojs/compiler"];return{transform:(a,o)=>new Promise(e=>{try{e(r.transform(a,o||{}))}catch(p){throw n=void 0,p}}),parse:(a,o)=>new Promise(e=>e(r.parse(a,o||{}))).catch(e=>{throw n=void 0,e}).then(e=>({...e,ast:JSON.parse(e.ast)})),convertToTSX:(a,o)=>new Promise(e=>e(r.convertToTSX(a,o||{}))).catch(e=>{throw n=void 0,e}).then(e=>({...e,map:JSON.parse(e.map)}))}};export{P as compile,b as convertToTSX,l as parse,g as teardown,w as transform};
|
||||
1
node_modules/@astrojs/compiler/dist/node/sync.cjs
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/node/sync.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
16
node_modules/@astrojs/compiler/dist/node/sync.d.ts
generated
vendored
Normal file
16
node_modules/@astrojs/compiler/dist/node/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TransformOptions, TransformResult, ParseOptions, ParseResult, ConvertToTSXOptions, TSXResult, transform as transform$1, parse as parse$1, convertToTSX as convertToTSX$1 } from '../shared/types.js';
|
||||
import '../shared/ast.js';
|
||||
import '../shared/diagnostics.js';
|
||||
|
||||
type UnwrappedPromise<T> = T extends (...params: any) => Promise<infer Return> ? (...params: Parameters<T>) => Return : T;
|
||||
interface Service {
|
||||
transform: UnwrappedPromise<typeof transform$1>;
|
||||
parse: UnwrappedPromise<typeof parse$1>;
|
||||
convertToTSX: UnwrappedPromise<typeof convertToTSX$1>;
|
||||
}
|
||||
declare const transform: (input: string, options: TransformOptions | undefined) => TransformResult;
|
||||
declare const parse: (input: string, options: ParseOptions | undefined) => ParseResult;
|
||||
declare const convertToTSX: (input: string, options: ConvertToTSXOptions | undefined) => TSXResult;
|
||||
declare function startRunningService(): Service;
|
||||
|
||||
export { convertToTSX, parse, startRunningService, transform };
|
||||
1
node_modules/@astrojs/compiler/dist/node/sync.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/node/sync.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{a as c}from"../chunk-W5DTLHV4.js";import{readFileSync as p}from"fs";import{fileURLToPath as m}from"url";function i(){return s||(s=f()),s}var s,l=(e,t)=>i().transform(e,t),w=(e,t)=>i().parse(e,t),h=(e,t)=>i().convertToTSX(e,t);function f(){let e=new c,t=v(m(new URL("../astro.wasm",import.meta.url)),e.importObject);e.run(t);let o=globalThis["@astrojs/compiler"];return{transform:(n,a)=>{try{return o.transform(n,a||{})}catch(r){throw s=void 0,r}},parse:(n,a)=>{try{let r=o.parse(n,a||{});return{...r,ast:JSON.parse(r.ast)}}catch(r){throw s=void 0,r}},convertToTSX:(n,a)=>{try{let r=o.convertToTSX(n,a||{});return{...r,map:JSON.parse(r.map)}}catch(r){throw s=void 0,r}}}}function v(e,t){let o=p(e);return new WebAssembly.Instance(new WebAssembly.Module(o),t)}export{h as convertToTSX,w as parse,f as startRunningService,l as transform};
|
||||
3
node_modules/@astrojs/compiler/dist/node/utils.cjs
generated
vendored
Normal file
3
node_modules/@astrojs/compiler/dist/node/utils.cjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var t in e)l(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!N.call(o,r)&&r!==t&&l(o,r,{get:()=>e[r],enumerable:!(a=d(e,r))||a.enumerable});return o};var h=o=>f(l({},"__esModule",{value:!0}),o);var k={};u(k,{is:()=>s,serialize:()=>g,walk:()=>y});module.exports=h(k);function n(o){return e=>e.type===o}var s={parent(o){return Array.isArray(o.children)},literal(o){return typeof o.value=="string"},tag(o){return o.type==="element"||o.type==="custom-element"||o.type==="component"||o.type==="fragment"},whitespace(o){return o.type==="text"&&o.value.trim().length===0},root:n("root"),element:n("element"),customElement:n("custom-element"),component:n("component"),fragment:n("fragment"),expression:n("expression"),text:n("text"),doctype:n("doctype"),comment:n("comment"),frontmatter:n("frontmatter")},m=class{constructor(e){this.callback=e}async visit(e,t,a){if(await this.callback(e,t,a),s.parent(e)){let r=[];for(let i=0;i<e.children.length;i++){let c=e.children[i];r.push(this.callback(c,e,i))}await Promise.all(r)}}};function y(o,e){new m(e).visit(o)}function x(o){let e="";for(let t of o.attributes)switch(e+=" ",t.kind){case"empty":{e+=`${t.name}`;break}case"expression":{e+=`${t.name}={${t.value}}`;break}case"quoted":{e+=`${t.name}=${t.raw}`;break}case"template-literal":{e+=`${t.name}=\`${t.value}\``;break}case"shorthand":{e+=`{${t.name}}`;break}case"spread":{e+=`{...${t.name}}`;break}}return e}function g(o,e={selfClose:!0}){let t="";function a(r){if(s.root(r))for(let i of r.children)a(i);else if(s.frontmatter(r))t+=`---${r.value}---
|
||||
|
||||
`;else if(s.comment(r))t+=`<!--${r.value}-->`;else if(s.expression(r)){t+="{";for(let i of r.children)a(i);t+="}"}else if(s.literal(r))t+=r.value;else if(s.tag(r))if(t+=`<${r.name}`,t+=x(r),r.children.length===0&&e.selfClose)t+=" />";else{t+=">";for(let i of r.children)a(i);t+=`</${r.name}>`}}return a(o),t}0&&(module.exports={is,serialize,walk});
|
||||
28
node_modules/@astrojs/compiler/dist/node/utils.d.ts
generated
vendored
Normal file
28
node_modules/@astrojs/compiler/dist/node/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Node, ParentNode, LiteralNode, TagLikeNode, TextNode, RootNode, ElementNode, CustomElementNode, ComponentNode, FragmentNode, ExpressionNode, DoctypeNode, CommentNode, FrontmatterNode } from '../shared/ast.js';
|
||||
|
||||
type Visitor = (node: Node, parent?: ParentNode, index?: number) => void | Promise<void>;
|
||||
declare const is: {
|
||||
parent(node: Node): node is ParentNode;
|
||||
literal(node: Node): node is LiteralNode;
|
||||
tag(node: Node): node is TagLikeNode;
|
||||
whitespace(node: Node): node is TextNode;
|
||||
root: (node: Node) => node is RootNode;
|
||||
element: (node: Node) => node is ElementNode;
|
||||
customElement: (node: Node) => node is CustomElementNode;
|
||||
component: (node: Node) => node is ComponentNode;
|
||||
fragment: (node: Node) => node is FragmentNode;
|
||||
expression: (node: Node) => node is ExpressionNode;
|
||||
text: (node: Node) => node is TextNode;
|
||||
doctype: (node: Node) => node is DoctypeNode;
|
||||
comment: (node: Node) => node is CommentNode;
|
||||
frontmatter: (node: Node) => node is FrontmatterNode;
|
||||
};
|
||||
declare function walk(node: ParentNode, callback: Visitor): void;
|
||||
interface SerializeOptions {
|
||||
selfClose: boolean;
|
||||
}
|
||||
/** @deprecated Please use `SerializeOptions` */
|
||||
type SerializeOtions = SerializeOptions;
|
||||
declare function serialize(root: Node, opts?: SerializeOptions): string;
|
||||
|
||||
export { SerializeOptions, SerializeOtions, Visitor, is, serialize, walk };
|
||||
3
node_modules/@astrojs/compiler/dist/node/utils.js
generated
vendored
Normal file
3
node_modules/@astrojs/compiler/dist/node/utils.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
function n(o){return t=>t.type===o}var a={parent(o){return Array.isArray(o.children)},literal(o){return typeof o.value=="string"},tag(o){return o.type==="element"||o.type==="custom-element"||o.type==="component"||o.type==="fragment"},whitespace(o){return o.type==="text"&&o.value.trim().length===0},root:n("root"),element:n("element"),customElement:n("custom-element"),component:n("component"),fragment:n("fragment"),expression:n("expression"),text:n("text"),doctype:n("doctype"),comment:n("comment"),frontmatter:n("frontmatter")},l=class{constructor(t){this.callback=t}async visit(t,e,s){if(await this.callback(t,e,s),a.parent(t)){let r=[];for(let i=0;i<t.children.length;i++){let m=t.children[i];r.push(this.callback(m,t,i))}await Promise.all(r)}}};function N(o,t){new l(t).visit(o)}function c(o){let t="";for(let e of o.attributes)switch(t+=" ",e.kind){case"empty":{t+=`${e.name}`;break}case"expression":{t+=`${e.name}={${e.value}}`;break}case"quoted":{t+=`${e.name}=${e.raw}`;break}case"template-literal":{t+=`${e.name}=\`${e.value}\``;break}case"shorthand":{t+=`{${e.name}}`;break}case"spread":{t+=`{...${e.name}}`;break}}return t}function u(o,t={selfClose:!0}){let e="";function s(r){if(a.root(r))for(let i of r.children)s(i);else if(a.frontmatter(r))e+=`---${r.value}---
|
||||
|
||||
`;else if(a.comment(r))e+=`<!--${r.value}-->`;else if(a.expression(r)){e+="{";for(let i of r.children)s(i);e+="}"}else if(a.literal(r))e+=r.value;else if(a.tag(r))if(e+=`<${r.name}`,e+=c(r),r.children.length===0&&t.selfClose)e+=" />";else{e+=">";for(let i of r.children)s(i);e+=`</${r.name}>`}}return s(o),e}export{a as is,u as serialize,N as walk};
|
||||
1
node_modules/@astrojs/compiler/dist/node/wasm_exec.cjs
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/node/wasm_exec.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
37
node_modules/@astrojs/compiler/dist/node/wasm_exec.d.ts
generated
vendored
Normal file
37
node_modules/@astrojs/compiler/dist/node/wasm_exec.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
declare class Go {
|
||||
importObject: {
|
||||
gojs: {
|
||||
'runtime.wasmExit': (sp: any) => void;
|
||||
'runtime.wasmWrite': (sp: any) => void;
|
||||
'runtime.resetMemoryDataView': (sp: any) => void;
|
||||
'runtime.nanotime1': (sp: any) => void;
|
||||
'runtime.walltime': (sp: any) => void;
|
||||
'runtime.scheduleTimeoutEvent': (sp: any) => void;
|
||||
'runtime.clearTimeoutEvent': (sp: any) => void;
|
||||
'runtime.getRandomData': (sp: any) => void;
|
||||
'syscall/js.finalizeRef': (sp: any) => void;
|
||||
'syscall/js.stringVal': (sp: any) => void;
|
||||
'syscall/js.valueGet': (sp: any) => void;
|
||||
'syscall/js.valueSet': (sp: any) => void;
|
||||
'syscall/js.valueDelete': (sp: any) => void;
|
||||
'syscall/js.valueIndex': (sp: any) => void;
|
||||
'syscall/js.valueSetIndex': (sp: any) => void;
|
||||
'syscall/js.valueCall': (sp: any) => void;
|
||||
'syscall/js.valueInvoke': (sp: any) => void;
|
||||
'syscall/js.valueNew': (sp: any) => void;
|
||||
'syscall/js.valueLength': (sp: any) => void;
|
||||
'syscall/js.valuePrepareString': (sp: any) => void;
|
||||
'syscall/js.valueLoadString': (sp: any) => void;
|
||||
'syscall/js.valueInstanceOf': (sp: any) => void;
|
||||
'syscall/js.copyBytesToGo': (sp: any) => void;
|
||||
'syscall/js.copyBytesToJS': (sp: any) => void;
|
||||
debug: (value: any) => void;
|
||||
};
|
||||
};
|
||||
constructor();
|
||||
run(instance: any): Promise<void>;
|
||||
private _resume;
|
||||
private _makeFuncWrapper;
|
||||
}
|
||||
|
||||
export { Go as default };
|
||||
1
node_modules/@astrojs/compiler/dist/node/wasm_exec.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/node/wasm_exec.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{a}from"../chunk-W5DTLHV4.js";export{a as default};
|
||||
1
node_modules/@astrojs/compiler/dist/shared/ast.cjs
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/shared/ast.cjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var p=(t,e,d,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of i(e))!N.call(t,o)&&o!==d&&r(t,o,{get:()=>e[o],enumerable:!(n=a(e,o))||n.enumerable});return t};var s=t=>p(r({},"__esModule",{value:!0}),t);var m={};module.exports=s(m);
|
||||
74
node_modules/@astrojs/compiler/dist/shared/ast.d.ts
generated
vendored
Normal file
74
node_modules/@astrojs/compiler/dist/shared/ast.d.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
type ParentNode = RootNode | ElementNode | ComponentNode | CustomElementNode | FragmentNode | ExpressionNode;
|
||||
type LiteralNode = TextNode | DoctypeNode | CommentNode | FrontmatterNode;
|
||||
type Node = RootNode | ElementNode | ComponentNode | CustomElementNode | FragmentNode | ExpressionNode | TextNode | FrontmatterNode | DoctypeNode | CommentNode;
|
||||
interface Position {
|
||||
start: Point;
|
||||
end?: Point;
|
||||
}
|
||||
interface Point {
|
||||
/** 1-based line number */
|
||||
line: number;
|
||||
/** 1-based column number, per-line */
|
||||
column: number;
|
||||
/** 0-based byte offset */
|
||||
offset: number;
|
||||
}
|
||||
interface BaseNode {
|
||||
type: string;
|
||||
position?: Position;
|
||||
}
|
||||
interface ParentLikeNode extends BaseNode {
|
||||
type: 'element' | 'component' | 'custom-element' | 'fragment' | 'expression' | 'root';
|
||||
children: Node[];
|
||||
}
|
||||
interface ValueNode extends BaseNode {
|
||||
value: string;
|
||||
}
|
||||
interface RootNode extends ParentLikeNode {
|
||||
type: 'root';
|
||||
}
|
||||
interface AttributeNode extends BaseNode {
|
||||
type: 'attribute';
|
||||
kind: 'quoted' | 'empty' | 'expression' | 'spread' | 'shorthand' | 'template-literal';
|
||||
name: string;
|
||||
value: string;
|
||||
raw?: string;
|
||||
}
|
||||
interface TextNode extends ValueNode {
|
||||
type: 'text';
|
||||
}
|
||||
interface ElementNode extends ParentLikeNode {
|
||||
type: 'element';
|
||||
name: string;
|
||||
attributes: AttributeNode[];
|
||||
}
|
||||
interface FragmentNode extends ParentLikeNode {
|
||||
type: 'fragment';
|
||||
name: string;
|
||||
attributes: AttributeNode[];
|
||||
}
|
||||
interface ComponentNode extends ParentLikeNode {
|
||||
type: 'component';
|
||||
name: string;
|
||||
attributes: AttributeNode[];
|
||||
}
|
||||
interface CustomElementNode extends ParentLikeNode {
|
||||
type: 'custom-element';
|
||||
name: string;
|
||||
attributes: AttributeNode[];
|
||||
}
|
||||
type TagLikeNode = ElementNode | FragmentNode | ComponentNode | CustomElementNode;
|
||||
interface DoctypeNode extends ValueNode {
|
||||
type: 'doctype';
|
||||
}
|
||||
interface CommentNode extends ValueNode {
|
||||
type: 'comment';
|
||||
}
|
||||
interface FrontmatterNode extends ValueNode {
|
||||
type: 'frontmatter';
|
||||
}
|
||||
interface ExpressionNode extends ParentLikeNode {
|
||||
type: 'expression';
|
||||
}
|
||||
|
||||
export { AttributeNode, BaseNode, CommentNode, ComponentNode, CustomElementNode, DoctypeNode, ElementNode, ExpressionNode, FragmentNode, FrontmatterNode, LiteralNode, Node, ParentLikeNode, ParentNode, Point, Position, RootNode, TagLikeNode, TextNode, ValueNode };
|
||||
0
node_modules/@astrojs/compiler/dist/shared/ast.js
generated
vendored
Normal file
0
node_modules/@astrojs/compiler/dist/shared/ast.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/shared/diagnostics.cjs
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/shared/diagnostics.cjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var I=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var U=(E,N)=>{for(var _ in N)I(E,_,{get:N[_],enumerable:!0})},H=(E,N,_,A)=>{if(N&&typeof N=="object"||typeof N=="function")for(let T of G(N))!S.call(E,T)&&T!==_&&I(E,T,{get:()=>N[T],enumerable:!(A=M(N,T))||A.enumerable});return E};var W=E=>H(I({},"__esModule",{value:!0}),E);var P={};U(P,{DiagnosticCode:()=>O});module.exports=W(P);var O=(R=>(R[R.ERROR=1e3]="ERROR",R[R.ERROR_UNTERMINATED_JS_COMMENT=1001]="ERROR_UNTERMINATED_JS_COMMENT",R[R.ERROR_FRAGMENT_SHORTHAND_ATTRS=1002]="ERROR_FRAGMENT_SHORTHAND_ATTRS",R[R.ERROR_UNMATCHED_IMPORT=1003]="ERROR_UNMATCHED_IMPORT",R[R.ERROR_UNSUPPORTED_SLOT_ATTRIBUTE=1004]="ERROR_UNSUPPORTED_SLOT_ATTRIBUTE",R[R.WARNING=2e3]="WARNING",R[R.WARNING_UNTERMINATED_HTML_COMMENT=2001]="WARNING_UNTERMINATED_HTML_COMMENT",R[R.WARNING_UNCLOSED_HTML_TAG=2002]="WARNING_UNCLOSED_HTML_TAG",R[R.WARNING_DEPRECATED_DIRECTIVE=2003]="WARNING_DEPRECATED_DIRECTIVE",R[R.WARNING_IGNORED_DIRECTIVE=2004]="WARNING_IGNORED_DIRECTIVE",R[R.WARNING_UNSUPPORTED_EXPRESSION=2005]="WARNING_UNSUPPORTED_EXPRESSION",R[R.WARNING_SET_WITH_CHILDREN=2006]="WARNING_SET_WITH_CHILDREN",R[R.INFO=3e3]="INFO",R[R.HINT=4e3]="HINT",R))(O||{});0&&(module.exports={DiagnosticCode});
|
||||
18
node_modules/@astrojs/compiler/dist/shared/diagnostics.d.ts
generated
vendored
Normal file
18
node_modules/@astrojs/compiler/dist/shared/diagnostics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
declare enum DiagnosticCode {
|
||||
ERROR = 1000,
|
||||
ERROR_UNTERMINATED_JS_COMMENT = 1001,
|
||||
ERROR_FRAGMENT_SHORTHAND_ATTRS = 1002,
|
||||
ERROR_UNMATCHED_IMPORT = 1003,
|
||||
ERROR_UNSUPPORTED_SLOT_ATTRIBUTE = 1004,
|
||||
WARNING = 2000,
|
||||
WARNING_UNTERMINATED_HTML_COMMENT = 2001,
|
||||
WARNING_UNCLOSED_HTML_TAG = 2002,
|
||||
WARNING_DEPRECATED_DIRECTIVE = 2003,
|
||||
WARNING_IGNORED_DIRECTIVE = 2004,
|
||||
WARNING_UNSUPPORTED_EXPRESSION = 2005,
|
||||
WARNING_SET_WITH_CHILDREN = 2006,
|
||||
INFO = 3000,
|
||||
HINT = 4000
|
||||
}
|
||||
|
||||
export { DiagnosticCode };
|
||||
1
node_modules/@astrojs/compiler/dist/shared/diagnostics.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/shared/diagnostics.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var N=(R=>(R[R.ERROR=1e3]="ERROR",R[R.ERROR_UNTERMINATED_JS_COMMENT=1001]="ERROR_UNTERMINATED_JS_COMMENT",R[R.ERROR_FRAGMENT_SHORTHAND_ATTRS=1002]="ERROR_FRAGMENT_SHORTHAND_ATTRS",R[R.ERROR_UNMATCHED_IMPORT=1003]="ERROR_UNMATCHED_IMPORT",R[R.ERROR_UNSUPPORTED_SLOT_ATTRIBUTE=1004]="ERROR_UNSUPPORTED_SLOT_ATTRIBUTE",R[R.WARNING=2e3]="WARNING",R[R.WARNING_UNTERMINATED_HTML_COMMENT=2001]="WARNING_UNTERMINATED_HTML_COMMENT",R[R.WARNING_UNCLOSED_HTML_TAG=2002]="WARNING_UNCLOSED_HTML_TAG",R[R.WARNING_DEPRECATED_DIRECTIVE=2003]="WARNING_DEPRECATED_DIRECTIVE",R[R.WARNING_IGNORED_DIRECTIVE=2004]="WARNING_IGNORED_DIRECTIVE",R[R.WARNING_UNSUPPORTED_EXPRESSION=2005]="WARNING_UNSUPPORTED_EXPRESSION",R[R.WARNING_SET_WITH_CHILDREN=2006]="WARNING_SET_WITH_CHILDREN",R[R.INFO=3e3]="INFO",R[R.HINT=4e3]="HINT",R))(N||{});export{N as DiagnosticCode};
|
||||
1
node_modules/@astrojs/compiler/dist/shared/types.cjs
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/shared/types.cjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(r,t)=>{for(var n in t)o(r,n,{get:t[n],enumerable:!0})},g=(r,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of p(t))!c.call(r,e)&&e!==n&&o(r,e,{get:()=>t[e],enumerable:!(s=a(t,e))||s.enumerable});return r};var d=r=>g(o({},"__esModule",{value:!0}),r);var m={};l(m,{DiagnosticSeverity:()=>i});module.exports=d(m);var i=(e=>(e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Information=3]="Information",e[e.Hint=4]="Hint",e))(i||{});0&&(module.exports={DiagnosticSeverity});
|
||||
160
node_modules/@astrojs/compiler/dist/shared/types.d.ts
generated
vendored
Normal file
160
node_modules/@astrojs/compiler/dist/shared/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
import { RootNode } from './ast.js';
|
||||
export { AttributeNode, BaseNode, CommentNode, ComponentNode, CustomElementNode, DoctypeNode, ElementNode, ExpressionNode, FragmentNode, FrontmatterNode, LiteralNode, Node, ParentLikeNode, ParentNode, Point, Position, TagLikeNode, TextNode, ValueNode } from './ast.js';
|
||||
import { DiagnosticCode } from './diagnostics.js';
|
||||
|
||||
interface PreprocessorResult {
|
||||
code: string;
|
||||
map?: string;
|
||||
}
|
||||
interface PreprocessorError {
|
||||
error: string;
|
||||
}
|
||||
interface ParseOptions {
|
||||
position?: boolean;
|
||||
}
|
||||
declare enum DiagnosticSeverity {
|
||||
Error = 1,
|
||||
Warning = 2,
|
||||
Information = 3,
|
||||
Hint = 4
|
||||
}
|
||||
interface DiagnosticMessage {
|
||||
severity: DiagnosticSeverity;
|
||||
code: DiagnosticCode;
|
||||
location: DiagnosticLocation;
|
||||
hint?: string;
|
||||
text: string;
|
||||
}
|
||||
interface DiagnosticLocation {
|
||||
file: string;
|
||||
line: number;
|
||||
column: number;
|
||||
length: number;
|
||||
}
|
||||
interface TransformOptions {
|
||||
internalURL?: string;
|
||||
filename?: string;
|
||||
normalizedFilename?: string;
|
||||
sourcemap?: boolean | 'inline' | 'external' | 'both';
|
||||
astroGlobalArgs?: string;
|
||||
compact?: boolean;
|
||||
resultScopedSlot?: boolean;
|
||||
scopedStyleStrategy?: 'where' | 'class' | 'attribute';
|
||||
/**
|
||||
* @deprecated "as" has been removed and no longer has any effect!
|
||||
*/
|
||||
as?: 'document' | 'fragment';
|
||||
transitionsAnimationURL?: string;
|
||||
resolvePath?: (specifier: string) => Promise<string> | string;
|
||||
preprocessStyle?: (content: string, attrs: Record<string, string>) => null | Promise<PreprocessorResult | PreprocessorError>;
|
||||
annotateSourceFile?: boolean;
|
||||
/**
|
||||
* Render script tags to be processed (e.g. script tags that have no attributes or only a `src` attribute)
|
||||
* using a `renderScript` function from `internalURL`, instead of stripping the script entirely.
|
||||
* @experimental
|
||||
*/
|
||||
renderScript?: boolean;
|
||||
experimentalScriptOrder?: boolean;
|
||||
}
|
||||
type ConvertToTSXOptions = Pick<TransformOptions, 'filename' | 'normalizedFilename' | 'sourcemap'> & {
|
||||
/** If set to true, script tags content will be included in the generated TSX
|
||||
* Scripts will be wrapped in an arrow function to be compatible with JSX's spec
|
||||
*/
|
||||
includeScripts?: boolean;
|
||||
/** If set to true, style tags content will be included in the generated TSX
|
||||
* Styles will be wrapped in a template literal to be compatible with JSX's spec
|
||||
*/
|
||||
includeStyles?: boolean;
|
||||
};
|
||||
type HoistedScript = {
|
||||
type: string;
|
||||
} & ({
|
||||
type: 'external';
|
||||
src: string;
|
||||
} | {
|
||||
type: 'inline';
|
||||
code: string;
|
||||
map: string;
|
||||
});
|
||||
interface HydratedComponent {
|
||||
exportName: string;
|
||||
localName: string;
|
||||
specifier: string;
|
||||
resolvedPath: string;
|
||||
}
|
||||
interface TransformResult {
|
||||
code: string;
|
||||
map: string;
|
||||
scope: string;
|
||||
styleError: string[];
|
||||
diagnostics: DiagnosticMessage[];
|
||||
css: string[];
|
||||
scripts: HoistedScript[];
|
||||
hydratedComponents: HydratedComponent[];
|
||||
clientOnlyComponents: HydratedComponent[];
|
||||
serverComponents: HydratedComponent[];
|
||||
containsHead: boolean;
|
||||
propagation: boolean;
|
||||
}
|
||||
interface SourceMap {
|
||||
file: string;
|
||||
mappings: string;
|
||||
names: string[];
|
||||
sources: string[];
|
||||
sourcesContent: string[];
|
||||
version: number;
|
||||
}
|
||||
/**
|
||||
* Represents a location in a TSX file.
|
||||
* Both the `start` and `end` properties are 0-based, and are based off utf-16 code units. (i.e. JavaScript's `String.prototype.length`)
|
||||
*/
|
||||
interface TSXLocation {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
interface TSXExtractedTag {
|
||||
position: TSXLocation;
|
||||
content: string;
|
||||
}
|
||||
interface TSXExtractedScript extends TSXExtractedTag {
|
||||
type: 'processed-module' | 'module' | 'inline' | 'event-attribute' | 'json' | 'raw' | 'unknown';
|
||||
}
|
||||
interface TSXExtractedStyle extends TSXExtractedTag {
|
||||
type: 'tag' | 'style-attribute';
|
||||
lang: 'css' | 'scss' | 'sass' | 'less' | 'stylus' | 'styl' | 'postcss' | 'pcss' | 'unknown' | (string & {});
|
||||
}
|
||||
interface TSXResult {
|
||||
code: string;
|
||||
map: SourceMap;
|
||||
diagnostics: DiagnosticMessage[];
|
||||
metaRanges: {
|
||||
frontmatter: TSXLocation;
|
||||
body: TSXLocation;
|
||||
scripts?: TSXExtractedScript[];
|
||||
styles?: TSXExtractedStyle[];
|
||||
};
|
||||
}
|
||||
interface ParseResult {
|
||||
ast: RootNode;
|
||||
diagnostics: DiagnosticMessage[];
|
||||
}
|
||||
declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>;
|
||||
declare function parse(input: string, options?: ParseOptions): Promise<ParseResult>;
|
||||
declare function convertToTSX(input: string, options?: ConvertToTSXOptions): Promise<TSXResult>;
|
||||
declare function initialize(options: InitializeOptions): Promise<void>;
|
||||
/**
|
||||
* When calling the core compiler APIs, e.g. `transform`, `parse`, etc, they
|
||||
* would automatically instantiate a WASM instance to process the input. When
|
||||
* done, you can call this to manually teardown the WASM instance.
|
||||
*
|
||||
* If the APIs are called again, they will automatically instantiate a new WASM
|
||||
* instance. In browsers, you have to call `initialize()` again before using the APIs.
|
||||
*
|
||||
* Note: Calling teardown is optional and exists mostly as an optimization only.
|
||||
*/
|
||||
declare function teardown(): void;
|
||||
interface InitializeOptions {
|
||||
wasmURL?: string;
|
||||
}
|
||||
|
||||
export { ConvertToTSXOptions, DiagnosticLocation, DiagnosticMessage, DiagnosticSeverity, HoistedScript, HydratedComponent, InitializeOptions, ParseOptions, ParseResult, PreprocessorError, PreprocessorResult, RootNode, SourceMap, TSXExtractedScript, TSXExtractedStyle, TSXExtractedTag, TSXLocation, TSXResult, TransformOptions, TransformResult, convertToTSX, initialize, parse, teardown, transform };
|
||||
1
node_modules/@astrojs/compiler/dist/shared/types.js
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/dist/shared/types.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var t=(e=>(e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Information=3]="Information",e[e.Hint=4]="Hint",e))(t||{});export{t as DiagnosticSeverity};
|
||||
58
node_modules/@astrojs/compiler/package.json
generated
vendored
Normal file
58
node_modules/@astrojs/compiler/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "@astrojs/compiler",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"bugs": "https://github.com/withastro/compiler/issues",
|
||||
"homepage": "https://astro.build",
|
||||
"version": "2.11.0",
|
||||
"main": "./dist/node/index.js",
|
||||
"types": "./dist/shared/types.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/compiler.git"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"types.d.ts",
|
||||
"utils.d.ts",
|
||||
"sync.d.ts"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/node/index.d.ts",
|
||||
"browser": "./dist/browser/index.js",
|
||||
"import": "./dist/node/index.js",
|
||||
"require": "./dist/node/index.cjs",
|
||||
"default": "./dist/browser/index.js"
|
||||
},
|
||||
"./sync": {
|
||||
"types": "./dist/node/sync.d.ts",
|
||||
"import": "./dist/node/sync.js",
|
||||
"require": "./dist/node/sync.cjs",
|
||||
"default": "./dist/node/sync.js"
|
||||
},
|
||||
"./utils": {
|
||||
"types": "./dist/node/utils.d.ts",
|
||||
"browser": "./dist/browser/utils.js",
|
||||
"import": "./dist/node/utils.js",
|
||||
"require": "./dist/node/utils.cjs",
|
||||
"default": "./dist/browser/utils.js"
|
||||
},
|
||||
"./astro.wasm": "./dist/astro.wasm",
|
||||
"./types": "./dist/shared/types.d.ts",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jridgewell/trace-mapping": "^0.3.16",
|
||||
"@types/node": "^18.15.11",
|
||||
"@types/sass": "^1.43.1",
|
||||
"acorn": "^8.8.1",
|
||||
"esbuild": "^0.17.17",
|
||||
"tsup": "^6.7.0",
|
||||
"typescript": "~5.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsup"
|
||||
}
|
||||
}
|
||||
1
node_modules/@astrojs/compiler/sync.d.ts
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/node/sync.js';
|
||||
1
node_modules/@astrojs/compiler/types.d.ts
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export type * from './dist/shared/types.js';
|
||||
1
node_modules/@astrojs/compiler/utils.d.ts
generated
vendored
Normal file
1
node_modules/@astrojs/compiler/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/node/utils.js';
|
||||
59
node_modules/@astrojs/internal-helpers/LICENSE
generated
vendored
Normal file
59
node_modules/@astrojs/internal-helpers/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Fred K. Schott
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
|
||||
|
||||
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
"""
|
||||
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"""
|
||||
15
node_modules/@astrojs/internal-helpers/dist/fs.d.ts
generated
vendored
Normal file
15
node_modules/@astrojs/internal-helpers/dist/fs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { PathLike } from 'node:fs';
|
||||
export declare function writeJson<T>(path: PathLike, data: T): Promise<void>;
|
||||
export declare function removeDir(dir: PathLike): Promise<void>;
|
||||
export declare function emptyDir(dir: PathLike): Promise<void>;
|
||||
export declare function getFilesFromFolder(dir: URL): Promise<URL[]>;
|
||||
/**
|
||||
* Copies files into a folder keeping the folder structure intact.
|
||||
* The resulting file tree will start at the common ancestor.
|
||||
*
|
||||
* @param {URL[]} files A list of files to copy (absolute path).
|
||||
* @param {URL} outDir Destination folder where to copy the files to (absolute path).
|
||||
* @param {URL[]} [exclude] A list of files to exclude (absolute path).
|
||||
* @returns {Promise<string>} The common ancestor of the copied files.
|
||||
*/
|
||||
export declare function copyFilesToFolder(files: URL[], outDir: URL, exclude?: URL[]): Promise<string>;
|
||||
66
node_modules/@astrojs/internal-helpers/dist/fs.js
generated
vendored
Normal file
66
node_modules/@astrojs/internal-helpers/dist/fs.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import * as fs from "node:fs/promises";
|
||||
import nodePath from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
async function writeJson(path, data) {
|
||||
await fs.writeFile(path, JSON.stringify(data, null, " "), { encoding: "utf-8" });
|
||||
}
|
||||
async function removeDir(dir) {
|
||||
await fs.rm(dir, { recursive: true, force: true, maxRetries: 3 });
|
||||
}
|
||||
async function emptyDir(dir) {
|
||||
await removeDir(dir);
|
||||
await fs.mkdir(dir, { recursive: true });
|
||||
}
|
||||
async function getFilesFromFolder(dir) {
|
||||
const data = await fs.readdir(dir, { withFileTypes: true });
|
||||
let files = [];
|
||||
for (const item of data) {
|
||||
if (item.isDirectory()) {
|
||||
const moreFiles = await getFilesFromFolder(new URL(`./${item.name}/`, dir));
|
||||
files = files.concat(moreFiles);
|
||||
} else {
|
||||
files.push(new URL(`./${item.name}`, dir));
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
async function copyFilesToFolder(files, outDir, exclude = []) {
|
||||
const excludeList = exclude.map(fileURLToPath);
|
||||
const fileList = files.map(fileURLToPath).filter((f) => !excludeList.includes(f));
|
||||
if (files.length === 0) throw new Error("No files found to copy");
|
||||
let commonAncestor = nodePath.dirname(fileList[0]);
|
||||
for (const file of fileList.slice(1)) {
|
||||
while (!file.startsWith(commonAncestor)) {
|
||||
commonAncestor = nodePath.dirname(commonAncestor);
|
||||
}
|
||||
}
|
||||
for (const origin of fileList) {
|
||||
const dest = new URL(nodePath.relative(commonAncestor, origin), outDir);
|
||||
const realpath = await fs.realpath(origin);
|
||||
const isSymlink = realpath !== origin;
|
||||
const isDir = (await fs.stat(origin)).isDirectory();
|
||||
if (isDir && !isSymlink) {
|
||||
await fs.mkdir(new URL("..", dest), { recursive: true });
|
||||
} else {
|
||||
await fs.mkdir(new URL(".", dest), { recursive: true });
|
||||
}
|
||||
if (isSymlink) {
|
||||
const realdest = fileURLToPath(new URL(nodePath.relative(commonAncestor, realpath), outDir));
|
||||
const target = nodePath.relative(fileURLToPath(new URL(".", dest)), realdest);
|
||||
if (!existsSync(dest)) {
|
||||
await fs.symlink(target, dest, isDir ? "dir" : "file");
|
||||
}
|
||||
} else if (!isDir) {
|
||||
await fs.copyFile(origin, dest);
|
||||
}
|
||||
}
|
||||
return commonAncestor;
|
||||
}
|
||||
export {
|
||||
copyFilesToFolder,
|
||||
emptyDir,
|
||||
getFilesFromFolder,
|
||||
removeDir,
|
||||
writeJson
|
||||
};
|
||||
23
node_modules/@astrojs/internal-helpers/dist/path.d.ts
generated
vendored
Normal file
23
node_modules/@astrojs/internal-helpers/dist/path.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* A set of common path utilities commonly used through the Astro core and integration
|
||||
* projects. These do things like ensure a forward slash prepends paths.
|
||||
*/
|
||||
export declare function appendExtension(path: string, extension: string): string;
|
||||
export declare function appendForwardSlash(path: string): string;
|
||||
export declare function prependForwardSlash(path: string): string;
|
||||
export declare function collapseDuplicateSlashes(path: string): string;
|
||||
export declare function removeTrailingForwardSlash(path: string): string;
|
||||
export declare function removeLeadingForwardSlash(path: string): string;
|
||||
export declare function removeLeadingForwardSlashWindows(path: string): string;
|
||||
export declare function trimSlashes(path: string): string;
|
||||
export declare function startsWithForwardSlash(path: string): boolean;
|
||||
export declare function startsWithDotDotSlash(path: string): boolean;
|
||||
export declare function startsWithDotSlash(path: string): boolean;
|
||||
export declare function isRelativePath(path: string): boolean;
|
||||
export declare function joinPaths(...paths: (string | undefined)[]): string;
|
||||
export declare function removeFileExtension(path: string): string;
|
||||
export declare function removeQueryString(path: string): string;
|
||||
export declare function isRemotePath(src: string): boolean;
|
||||
export declare function slash(path: string): string;
|
||||
export declare function fileExtension(path: string): string;
|
||||
export declare function removeBase(path: string, base: string): string;
|
||||
100
node_modules/@astrojs/internal-helpers/dist/path.js
generated
vendored
Normal file
100
node_modules/@astrojs/internal-helpers/dist/path.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
function appendExtension(path, extension) {
|
||||
return path + "." + extension;
|
||||
}
|
||||
function appendForwardSlash(path) {
|
||||
return path.endsWith("/") ? path : path + "/";
|
||||
}
|
||||
function prependForwardSlash(path) {
|
||||
return path[0] === "/" ? path : "/" + path;
|
||||
}
|
||||
function collapseDuplicateSlashes(path) {
|
||||
return path.replace(/(?<!:)\/{2,}/g, "/");
|
||||
}
|
||||
function removeTrailingForwardSlash(path) {
|
||||
return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
|
||||
}
|
||||
function removeLeadingForwardSlash(path) {
|
||||
return path.startsWith("/") ? path.substring(1) : path;
|
||||
}
|
||||
function removeLeadingForwardSlashWindows(path) {
|
||||
return path.startsWith("/") && path[2] === ":" ? path.substring(1) : path;
|
||||
}
|
||||
function trimSlashes(path) {
|
||||
return path.replace(/^\/|\/$/g, "");
|
||||
}
|
||||
function startsWithForwardSlash(path) {
|
||||
return path[0] === "/";
|
||||
}
|
||||
function startsWithDotDotSlash(path) {
|
||||
const c1 = path[0];
|
||||
const c2 = path[1];
|
||||
const c3 = path[2];
|
||||
return c1 === "." && c2 === "." && c3 === "/";
|
||||
}
|
||||
function startsWithDotSlash(path) {
|
||||
const c1 = path[0];
|
||||
const c2 = path[1];
|
||||
return c1 === "." && c2 === "/";
|
||||
}
|
||||
function isRelativePath(path) {
|
||||
return startsWithDotDotSlash(path) || startsWithDotSlash(path);
|
||||
}
|
||||
function isString(path) {
|
||||
return typeof path === "string" || path instanceof String;
|
||||
}
|
||||
function joinPaths(...paths) {
|
||||
return paths.filter(isString).map((path, i) => {
|
||||
if (i === 0) {
|
||||
return removeTrailingForwardSlash(path);
|
||||
} else if (i === paths.length - 1) {
|
||||
return removeLeadingForwardSlash(path);
|
||||
} else {
|
||||
return trimSlashes(path);
|
||||
}
|
||||
}).join("/");
|
||||
}
|
||||
function removeFileExtension(path) {
|
||||
let idx = path.lastIndexOf(".");
|
||||
return idx === -1 ? path : path.slice(0, idx);
|
||||
}
|
||||
function removeQueryString(path) {
|
||||
const index = path.lastIndexOf("?");
|
||||
return index > 0 ? path.substring(0, index) : path;
|
||||
}
|
||||
function isRemotePath(src) {
|
||||
return /^(?:http|ftp|https|ws):?\/\//.test(src) || src.startsWith("data:");
|
||||
}
|
||||
function slash(path) {
|
||||
return path.replace(/\\/g, "/");
|
||||
}
|
||||
function fileExtension(path) {
|
||||
const ext = path.split(".").pop();
|
||||
return ext !== path ? `.${ext}` : "";
|
||||
}
|
||||
function removeBase(path, base) {
|
||||
if (path.startsWith(base)) {
|
||||
return path.slice(removeTrailingForwardSlash(base).length);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
export {
|
||||
appendExtension,
|
||||
appendForwardSlash,
|
||||
collapseDuplicateSlashes,
|
||||
fileExtension,
|
||||
isRelativePath,
|
||||
isRemotePath,
|
||||
joinPaths,
|
||||
prependForwardSlash,
|
||||
removeBase,
|
||||
removeFileExtension,
|
||||
removeLeadingForwardSlash,
|
||||
removeLeadingForwardSlashWindows,
|
||||
removeQueryString,
|
||||
removeTrailingForwardSlash,
|
||||
slash,
|
||||
startsWithDotDotSlash,
|
||||
startsWithDotSlash,
|
||||
startsWithForwardSlash,
|
||||
trimSlashes
|
||||
};
|
||||
48
node_modules/@astrojs/internal-helpers/package.json
generated
vendored
Normal file
48
node_modules/@astrojs/internal-helpers/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "@astrojs/internal-helpers",
|
||||
"description": "Internal helpers used by core Astro packages.",
|
||||
"version": "0.4.1",
|
||||
"type": "module",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/astro.git",
|
||||
"directory": "packages/internal-helpers"
|
||||
},
|
||||
"bugs": "https://github.com/withastro/astro/issues",
|
||||
"exports": {
|
||||
"./path": "./dist/path.js",
|
||||
"./fs": "./dist/fs.js"
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"path": [
|
||||
"./dist/path.d.ts"
|
||||
],
|
||||
"fs": [
|
||||
"./dist/fs.d.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"devDependencies": {
|
||||
"astro-scripts": "0.0.14"
|
||||
},
|
||||
"keywords": [
|
||||
"astro",
|
||||
"astro-component"
|
||||
],
|
||||
"publishConfig": {
|
||||
"provenance": true
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "pnpm build",
|
||||
"build": "astro-scripts build \"src/**/*.ts\" && tsc -p tsconfig.json",
|
||||
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
||||
"postbuild": "astro-scripts copy \"src/**/*.js\"",
|
||||
"dev": "astro-scripts dev \"src/**/*.ts\""
|
||||
}
|
||||
}
|
||||
3
node_modules/@astrojs/internal-helpers/readme.md
generated
vendored
Normal file
3
node_modules/@astrojs/internal-helpers/readme.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# @astrojs/internal-helpers
|
||||
|
||||
These are internal helpers used by core Astro packages. This package does not follow semver and should not be used externally.
|
||||
35
node_modules/@astrojs/language-server/LICENSE
generated
vendored
Normal file
35
node_modules/@astrojs/language-server/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 The Astro Technology Company
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
|
||||
This license applies to code originating from the https://github.com/sveltejs/language-tools repository:
|
||||
|
||||
Copyright (c) 2020-Present [these people](https://github.com/sveltejs/language-tools/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
"""
|
||||
25
node_modules/@astrojs/language-server/README.md
generated
vendored
Normal file
25
node_modules/@astrojs/language-server/README.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# @astrojs/language-server
|
||||
|
||||
The Astro language server, implement the [language server protocol](https://microsoft.github.io/language-server-protocol/)
|
||||
|
||||
## Folder structure
|
||||
|
||||
```plaintext
|
||||
├── bin # .js file used to start the server
|
||||
├── dist # Compiled files, generated by TypeScript
|
||||
├── src # Source files
|
||||
│ ├── core # Core code such as .astro file parsing, configuration manager, document definition etc
|
||||
│ └── plugins # Modules for the different languages supported in .astro files
|
||||
├── test # Tests
|
||||
└── types # Types injected into Astro files by the language server under certain conditions
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Formatting does not work
|
||||
|
||||
> Using VS Code? This section does not apply to you, the VS Code extension includes both Prettier and the Astro plugin by default.
|
||||
|
||||
The Astro language server uses Prettier to format Astro files, but does not include `prettier` or `prettier-plugin-astro` by itself as dependencies in order to keep the dependency count low and allow users to better control the version of Prettier they want to use.
|
||||
|
||||
As such, if you want to use formatting, you'll need to install `prettier` and `prettier-plugin-astro` as dependencies in your project.
|
||||
7
node_modules/@astrojs/language-server/bin/nodeServer.js
generated
vendored
Executable file
7
node_modules/@astrojs/language-server/bin/nodeServer.js
generated
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
if (process.argv.includes('--version')) {
|
||||
const pkgJSON = require('../package.json');
|
||||
console.info(`${pkgJSON['version']}`);
|
||||
} else {
|
||||
require('../dist/nodeServer.js');
|
||||
}
|
||||
3
node_modules/@astrojs/language-server/dist/buildMappings.d.ts
generated
vendored
Normal file
3
node_modules/@astrojs/language-server/dist/buildMappings.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Mapping } from '@volar/language-core';
|
||||
import type { Segment } from 'muggle-string';
|
||||
export declare function buildMappings<T>(chunks: Segment<T>[]): Mapping<T>[];
|
||||
23
node_modules/@astrojs/language-server/dist/buildMappings.js
generated
vendored
Normal file
23
node_modules/@astrojs/language-server/dist/buildMappings.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.buildMappings = buildMappings;
|
||||
function buildMappings(chunks) {
|
||||
let length = 0;
|
||||
const mappings = [];
|
||||
for (const segment of chunks) {
|
||||
if (typeof segment === 'string') {
|
||||
length += segment.length;
|
||||
}
|
||||
else {
|
||||
mappings.push({
|
||||
sourceOffsets: [segment[2]],
|
||||
generatedOffsets: [length],
|
||||
lengths: [segment[0].length],
|
||||
data: segment[3],
|
||||
});
|
||||
length += segment[0].length;
|
||||
}
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
//# sourceMappingURL=buildMappings.js.map
|
||||
39
node_modules/@astrojs/language-server/dist/check.d.ts
generated
vendored
Normal file
39
node_modules/@astrojs/language-server/dist/check.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import * as kit from '@volar/kit';
|
||||
import { Diagnostic, DiagnosticSeverity } from '@volar/language-server';
|
||||
export { Diagnostic, DiagnosticSeverity };
|
||||
export interface CheckResult {
|
||||
status: 'completed' | 'cancelled' | undefined;
|
||||
fileChecked: number;
|
||||
errors: number;
|
||||
warnings: number;
|
||||
hints: number;
|
||||
fileResult: {
|
||||
errors: kit.Diagnostic[];
|
||||
fileUrl: URL;
|
||||
fileContent: string;
|
||||
text: string;
|
||||
}[];
|
||||
}
|
||||
export declare class AstroCheck {
|
||||
private readonly workspacePath;
|
||||
private readonly typescriptPath;
|
||||
private readonly tsconfigPath;
|
||||
private ts;
|
||||
linter: ReturnType<(typeof kit)['createTypeScriptChecker']>;
|
||||
constructor(workspacePath: string, typescriptPath: string | undefined, tsconfigPath: string | undefined);
|
||||
/**
|
||||
* Lint a list of files or the entire project and optionally log the errors found
|
||||
* @param fileNames List of files to lint, if undefined, all files included in the project will be linted
|
||||
* @param logErrors Whether to log errors by itself. This is disabled by default.
|
||||
* @return {CheckResult} The result of the lint, including a list of errors, the file's content and its file path.
|
||||
*/
|
||||
lint({ fileNames, cancel, logErrors, }: {
|
||||
fileNames?: string[] | undefined;
|
||||
cancel?: () => boolean;
|
||||
logErrors?: {
|
||||
level: 'error' | 'warning' | 'hint';
|
||||
} | undefined;
|
||||
}): Promise<CheckResult>;
|
||||
private initialize;
|
||||
private getTsconfig;
|
||||
}
|
||||
159
node_modules/@astrojs/language-server/dist/check.js
generated
vendored
Normal file
159
node_modules/@astrojs/language-server/dist/check.js
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AstroCheck = exports.DiagnosticSeverity = exports.Diagnostic = void 0;
|
||||
const node_fs_1 = require("node:fs");
|
||||
const node_os_1 = require("node:os");
|
||||
const node_path_1 = require("node:path");
|
||||
const node_url_1 = require("node:url");
|
||||
const kit = __importStar(require("@volar/kit"));
|
||||
const language_server_1 = require("@volar/language-server");
|
||||
Object.defineProperty(exports, "Diagnostic", { enumerable: true, get: function () { return language_server_1.Diagnostic; } });
|
||||
Object.defineProperty(exports, "DiagnosticSeverity", { enumerable: true, get: function () { return language_server_1.DiagnosticSeverity; } });
|
||||
const fast_glob_1 = __importDefault(require("fast-glob"));
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const index_js_1 = require("./core/index.js");
|
||||
const svelte_js_1 = require("./core/svelte.js");
|
||||
const vue_js_1 = require("./core/vue.js");
|
||||
const utils_js_1 = require("./utils.js");
|
||||
const astro_js_1 = require("./plugins/astro.js");
|
||||
const index_js_2 = require("./plugins/typescript/index.js");
|
||||
class AstroCheck {
|
||||
constructor(workspacePath, typescriptPath, tsconfigPath) {
|
||||
this.workspacePath = workspacePath;
|
||||
this.typescriptPath = typescriptPath;
|
||||
this.tsconfigPath = tsconfigPath;
|
||||
this.initialize();
|
||||
}
|
||||
/**
|
||||
* Lint a list of files or the entire project and optionally log the errors found
|
||||
* @param fileNames List of files to lint, if undefined, all files included in the project will be linted
|
||||
* @param logErrors Whether to log errors by itself. This is disabled by default.
|
||||
* @return {CheckResult} The result of the lint, including a list of errors, the file's content and its file path.
|
||||
*/
|
||||
async lint({ fileNames = undefined, cancel = () => false, logErrors = undefined, }) {
|
||||
let files = (fileNames !== undefined ? fileNames : this.linter.getRootFileNames()).filter((file) => {
|
||||
// We don't have the same understanding of Svelte and Vue files as their own respective tools (vue-tsc, svelte-check)
|
||||
// So we don't want to check them here
|
||||
return !file.endsWith('.vue') && !file.endsWith('.svelte');
|
||||
});
|
||||
const result = {
|
||||
status: undefined,
|
||||
fileChecked: 0,
|
||||
errors: 0,
|
||||
warnings: 0,
|
||||
hints: 0,
|
||||
fileResult: [],
|
||||
};
|
||||
for (const file of files) {
|
||||
if (cancel()) {
|
||||
result.status = 'cancelled';
|
||||
return result;
|
||||
}
|
||||
const fileDiagnostics = await this.linter.check(file);
|
||||
// Filter diagnostics based on the logErrors level
|
||||
const fileDiagnosticsToPrint = fileDiagnostics.filter((diag) => {
|
||||
const severity = diag.severity ?? language_server_1.DiagnosticSeverity.Error;
|
||||
switch (logErrors?.level ?? 'hint') {
|
||||
case 'error':
|
||||
return severity <= language_server_1.DiagnosticSeverity.Error;
|
||||
case 'warning':
|
||||
return severity <= language_server_1.DiagnosticSeverity.Warning;
|
||||
case 'hint':
|
||||
return severity <= language_server_1.DiagnosticSeverity.Hint;
|
||||
}
|
||||
});
|
||||
if (fileDiagnostics.length > 0) {
|
||||
const errorText = this.linter.printErrors(file, fileDiagnosticsToPrint);
|
||||
if (logErrors !== undefined && errorText) {
|
||||
console.info(errorText);
|
||||
}
|
||||
const fileSnapshot = this.linter.language.scripts.get(vscode_uri_1.URI.file(file))?.snapshot;
|
||||
const fileContent = fileSnapshot?.getText(0, fileSnapshot.getLength());
|
||||
result.fileResult.push({
|
||||
errors: fileDiagnostics,
|
||||
fileContent: fileContent ?? '',
|
||||
fileUrl: (0, node_url_1.pathToFileURL)(file),
|
||||
text: errorText,
|
||||
});
|
||||
result.errors += fileDiagnostics.filter((diag) => diag.severity === language_server_1.DiagnosticSeverity.Error).length;
|
||||
result.warnings += fileDiagnostics.filter((diag) => diag.severity === language_server_1.DiagnosticSeverity.Warning).length;
|
||||
result.hints += fileDiagnostics.filter((diag) => diag.severity === language_server_1.DiagnosticSeverity.Hint).length;
|
||||
}
|
||||
result.fileChecked += 1;
|
||||
}
|
||||
result.status = 'completed';
|
||||
return result;
|
||||
}
|
||||
initialize() {
|
||||
this.ts = this.typescriptPath ? require(this.typescriptPath) : require('typescript');
|
||||
const tsconfigPath = this.getTsconfig();
|
||||
const languagePlugins = [
|
||||
(0, index_js_1.getAstroLanguagePlugin)(),
|
||||
(0, svelte_js_1.getSvelteLanguagePlugin)(),
|
||||
(0, vue_js_1.getVueLanguagePlugin)(),
|
||||
];
|
||||
const services = [...(0, index_js_2.create)(this.ts), (0, astro_js_1.create)(this.ts)];
|
||||
if (tsconfigPath) {
|
||||
const includeProjectReference = false; // #920
|
||||
this.linter = kit.createTypeScriptChecker(languagePlugins, services, tsconfigPath, includeProjectReference, ({ project }) => {
|
||||
const { languageServiceHost } = project.typescript;
|
||||
const astroInstall = (0, utils_js_1.getAstroInstall)([this.workspacePath]);
|
||||
(0, index_js_1.addAstroTypes)(typeof astroInstall === 'string' ? undefined : astroInstall, this.ts, languageServiceHost);
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.linter = kit.createTypeScriptInferredChecker(languagePlugins, services, () => {
|
||||
return fast_glob_1.default.sync('**/*.astro', {
|
||||
cwd: this.workspacePath,
|
||||
ignore: ['node_modules'],
|
||||
absolute: true,
|
||||
});
|
||||
}, undefined, ({ project }) => {
|
||||
const { languageServiceHost } = project.typescript;
|
||||
const astroInstall = (0, utils_js_1.getAstroInstall)([this.workspacePath]);
|
||||
(0, index_js_1.addAstroTypes)(typeof astroInstall === 'string' ? undefined : astroInstall, this.ts, languageServiceHost);
|
||||
});
|
||||
}
|
||||
}
|
||||
getTsconfig() {
|
||||
if (this.tsconfigPath) {
|
||||
const tsconfig = (0, node_path_1.resolve)(this.workspacePath, this.tsconfigPath.replace(/^~/, (0, node_os_1.homedir)()));
|
||||
if (!(0, node_fs_1.existsSync)(tsconfig)) {
|
||||
throw new Error(`Specified tsconfig file \`${tsconfig}\` does not exist.`);
|
||||
}
|
||||
return tsconfig;
|
||||
}
|
||||
const searchPath = this.workspacePath;
|
||||
const tsconfig = this.ts.findConfigFile(searchPath, this.ts.sys.fileExists) ||
|
||||
this.ts.findConfigFile(searchPath, this.ts.sys.fileExists, 'jsconfig.json');
|
||||
return tsconfig;
|
||||
}
|
||||
}
|
||||
exports.AstroCheck = AstroCheck;
|
||||
//# sourceMappingURL=check.js.map
|
||||
59
node_modules/@astrojs/language-server/dist/core/astro2tsx.d.ts
generated
vendored
Normal file
59
node_modules/@astrojs/language-server/dist/core/astro2tsx.d.ts
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import type { ConvertToTSXOptions, TSXExtractedScript, TSXExtractedStyle, TSXResult } from '@astrojs/compiler/types';
|
||||
import type { VirtualCode } from '@volar/language-core';
|
||||
import { Range } from '@volar/language-server';
|
||||
export interface LSPTSXRanges {
|
||||
frontmatter: Range;
|
||||
body: Range;
|
||||
scripts: TSXExtractedScript[];
|
||||
styles: TSXExtractedStyle[];
|
||||
}
|
||||
export declare function safeConvertToTSX(content: string, options: ConvertToTSXOptions): TSXResult | {
|
||||
code: string;
|
||||
map: {
|
||||
file: string;
|
||||
sources: never[];
|
||||
sourcesContent: never[];
|
||||
names: never[];
|
||||
mappings: string;
|
||||
version: number;
|
||||
};
|
||||
diagnostics: {
|
||||
code: 1000;
|
||||
location: {
|
||||
file: string;
|
||||
line: number;
|
||||
column: number;
|
||||
length: number;
|
||||
};
|
||||
severity: 1;
|
||||
text: string;
|
||||
}[];
|
||||
metaRanges: {
|
||||
frontmatter: {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
body: {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
scripts: never[];
|
||||
styles: never[];
|
||||
};
|
||||
};
|
||||
export declare function getTSXRangesAsLSPRanges(tsx: TSXResult): LSPTSXRanges;
|
||||
export declare function astro2tsx(input: string, fileName: string): {
|
||||
virtualCode: VirtualCode;
|
||||
diagnostics: import("@astrojs/compiler").DiagnosticMessage[] | {
|
||||
code: 1000;
|
||||
location: {
|
||||
file: string;
|
||||
line: number;
|
||||
column: number;
|
||||
length: number;
|
||||
};
|
||||
severity: 1;
|
||||
text: string;
|
||||
}[];
|
||||
ranges: LSPTSXRanges;
|
||||
};
|
||||
144
node_modules/@astrojs/language-server/dist/core/astro2tsx.js
generated
vendored
Normal file
144
node_modules/@astrojs/language-server/dist/core/astro2tsx.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.safeConvertToTSX = safeConvertToTSX;
|
||||
exports.getTSXRangesAsLSPRanges = getTSXRangesAsLSPRanges;
|
||||
exports.astro2tsx = astro2tsx;
|
||||
const sync_1 = require("@astrojs/compiler/sync");
|
||||
const sourcemap_codec_1 = require("@jridgewell/sourcemap-codec");
|
||||
const language_server_1 = require("@volar/language-server");
|
||||
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
||||
const utils_js_1 = require("./utils.js");
|
||||
function safeConvertToTSX(content, options) {
|
||||
try {
|
||||
const tsx = (0, sync_1.convertToTSX)(content, {
|
||||
filename: options.filename,
|
||||
includeScripts: false,
|
||||
includeStyles: false,
|
||||
});
|
||||
return tsx;
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.`);
|
||||
return {
|
||||
code: '',
|
||||
map: {
|
||||
file: options.filename ?? '',
|
||||
sources: [],
|
||||
sourcesContent: [],
|
||||
names: [],
|
||||
mappings: '',
|
||||
version: 0,
|
||||
},
|
||||
diagnostics: [
|
||||
{
|
||||
code: 1000,
|
||||
location: { file: options.filename, line: 1, column: 1, length: content.length },
|
||||
severity: 1,
|
||||
text: `The Astro compiler encountered an unknown error while transform this file to TSX. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/language-tools/issues`,
|
||||
},
|
||||
],
|
||||
metaRanges: {
|
||||
frontmatter: {
|
||||
start: 0,
|
||||
end: 0,
|
||||
},
|
||||
body: {
|
||||
start: 0,
|
||||
end: 0,
|
||||
},
|
||||
scripts: [],
|
||||
styles: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
function getTSXRangesAsLSPRanges(tsx) {
|
||||
const textDocument = vscode_html_languageservice_1.TextDocument.create('', 'typescriptreact', 0, tsx.code);
|
||||
return {
|
||||
frontmatter: language_server_1.Range.create(textDocument.positionAt(tsx.metaRanges.frontmatter.start), textDocument.positionAt(tsx.metaRanges.frontmatter.end)),
|
||||
body: language_server_1.Range.create(textDocument.positionAt(tsx.metaRanges.body.start), textDocument.positionAt(tsx.metaRanges.body.end)),
|
||||
scripts: tsx.metaRanges.scripts ?? [],
|
||||
styles: tsx.metaRanges.styles ?? [],
|
||||
};
|
||||
}
|
||||
function astro2tsx(input, fileName) {
|
||||
const tsx = safeConvertToTSX(input, { filename: fileName });
|
||||
return {
|
||||
virtualCode: getVirtualCodeTSX(input, tsx, fileName),
|
||||
diagnostics: tsx.diagnostics,
|
||||
ranges: getTSXRangesAsLSPRanges(tsx),
|
||||
};
|
||||
}
|
||||
function getVirtualCodeTSX(input, tsx, fileName) {
|
||||
tsx.code = (0, utils_js_1.patchTSX)(tsx.code, fileName);
|
||||
const v3Mappings = (0, sourcemap_codec_1.decode)(tsx.map.mappings);
|
||||
const sourcedDoc = vscode_html_languageservice_1.TextDocument.create('', 'astro', 0, input);
|
||||
const genDoc = vscode_html_languageservice_1.TextDocument.create('', 'typescriptreact', 0, tsx.code);
|
||||
const mappings = [];
|
||||
let current;
|
||||
for (let genLine = 0; genLine < v3Mappings.length; genLine++) {
|
||||
for (const segment of v3Mappings[genLine]) {
|
||||
const genCharacter = segment[0];
|
||||
const genOffset = genDoc.offsetAt({ line: genLine, character: genCharacter });
|
||||
if (current) {
|
||||
let length = genOffset - current.genOffset;
|
||||
const sourceText = input.substring(current.sourceOffset, current.sourceOffset + length);
|
||||
const genText = tsx.code.substring(current.genOffset, current.genOffset + length);
|
||||
if (sourceText !== genText) {
|
||||
length = 0;
|
||||
for (let i = 0; i < genOffset - current.genOffset; i++) {
|
||||
if (sourceText[i] === genText[i]) {
|
||||
length = i + 1;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (length > 0) {
|
||||
const lastMapping = mappings.length ? mappings[mappings.length - 1] : undefined;
|
||||
if (lastMapping &&
|
||||
lastMapping.generatedOffsets[0] + lastMapping.lengths[0] === current.genOffset &&
|
||||
lastMapping.sourceOffsets[0] + lastMapping.lengths[0] === current.sourceOffset) {
|
||||
lastMapping.lengths[0] += length;
|
||||
}
|
||||
else {
|
||||
mappings.push({
|
||||
sourceOffsets: [current.sourceOffset],
|
||||
generatedOffsets: [current.genOffset],
|
||||
lengths: [length],
|
||||
data: {
|
||||
verification: true,
|
||||
completion: true,
|
||||
semantic: true,
|
||||
navigation: true,
|
||||
structure: true,
|
||||
format: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
current = undefined;
|
||||
}
|
||||
if (segment[2] !== undefined && segment[3] !== undefined) {
|
||||
const sourceOffset = sourcedDoc.offsetAt({ line: segment[2], character: segment[3] });
|
||||
current = {
|
||||
genOffset,
|
||||
sourceOffset,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
id: 'tsx',
|
||||
languageId: 'typescriptreact',
|
||||
snapshot: {
|
||||
getText: (start, end) => tsx.code.substring(start, end),
|
||||
getLength: () => tsx.code.length,
|
||||
getChangeRange: () => undefined,
|
||||
},
|
||||
mappings: mappings,
|
||||
embeddedCodes: [],
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=astro2tsx.js.map
|
||||
11
node_modules/@astrojs/language-server/dist/core/compilerUtils.d.ts
generated
vendored
Normal file
11
node_modules/@astrojs/language-server/dist/core/compilerUtils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { AttributeNode, Point } from '@astrojs/compiler';
|
||||
import { Position as LSPPosition } from '@volar/language-server';
|
||||
/**
|
||||
* Transform a Point from the Astro compiler to an LSP Position
|
||||
*/
|
||||
export declare function PointToPosition(point: Point): LSPPosition;
|
||||
type WithRequired<T, K extends keyof T> = T & {
|
||||
[P in K]-?: T[P];
|
||||
};
|
||||
export type AttributeNodeWithPosition = WithRequired<AttributeNode, 'position'>;
|
||||
export {};
|
||||
12
node_modules/@astrojs/language-server/dist/core/compilerUtils.js
generated
vendored
Normal file
12
node_modules/@astrojs/language-server/dist/core/compilerUtils.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PointToPosition = PointToPosition;
|
||||
const language_server_1 = require("@volar/language-server");
|
||||
/**
|
||||
* Transform a Point from the Astro compiler to an LSP Position
|
||||
*/
|
||||
function PointToPosition(point) {
|
||||
// Columns and lines are 0-based in LSP, but the compiler's Point are 1 based.
|
||||
return language_server_1.Position.create(point.line - 1, point.column - 1);
|
||||
}
|
||||
//# sourceMappingURL=compilerUtils.js.map
|
||||
38
node_modules/@astrojs/language-server/dist/core/frontmatterHolders.d.ts
generated
vendored
Normal file
38
node_modules/@astrojs/language-server/dist/core/frontmatterHolders.d.ts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { type CodeMapping, type LanguagePlugin, type VirtualCode } from '@volar/language-core';
|
||||
import type ts from 'typescript';
|
||||
import type { URI } from 'vscode-uri';
|
||||
export declare const SUPPORTED_FRONTMATTER_EXTENSIONS: {
|
||||
md: string;
|
||||
mdx: string;
|
||||
mdoc: string;
|
||||
};
|
||||
export declare const SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS: string[];
|
||||
export declare const frontmatterRE: RegExp;
|
||||
export type CollectionConfig = {
|
||||
reload: (folders: {
|
||||
uri: string;
|
||||
}[]) => void;
|
||||
configs: {
|
||||
folder: URI;
|
||||
config: CollectionConfigInstance;
|
||||
}[];
|
||||
};
|
||||
export type CollectionConfigInstance = {
|
||||
collections: {
|
||||
hasSchema: boolean;
|
||||
name: string;
|
||||
}[];
|
||||
entries: Record<string, string>;
|
||||
};
|
||||
export declare function getFrontmatterLanguagePlugin(collectionConfig: CollectionConfig): LanguagePlugin<URI, FrontmatterHolder>;
|
||||
export declare class FrontmatterHolder implements VirtualCode {
|
||||
fileName: string;
|
||||
languageId: string;
|
||||
snapshot: ts.IScriptSnapshot;
|
||||
collection: string | undefined;
|
||||
id: string;
|
||||
mappings: CodeMapping[];
|
||||
embeddedCodes: VirtualCode[];
|
||||
hasFrontmatter: boolean;
|
||||
constructor(fileName: string, languageId: string, snapshot: ts.IScriptSnapshot, collection: string | undefined);
|
||||
}
|
||||
119
node_modules/@astrojs/language-server/dist/core/frontmatterHolders.js
generated
vendored
Normal file
119
node_modules/@astrojs/language-server/dist/core/frontmatterHolders.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FrontmatterHolder = exports.frontmatterRE = exports.SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS = exports.SUPPORTED_FRONTMATTER_EXTENSIONS = void 0;
|
||||
exports.getFrontmatterLanguagePlugin = getFrontmatterLanguagePlugin;
|
||||
const yaml2ts_1 = require("@astrojs/yaml2ts");
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
exports.SUPPORTED_FRONTMATTER_EXTENSIONS = { md: 'markdown', mdx: 'mdx', mdoc: 'markdoc' };
|
||||
exports.SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS = Object.keys(exports.SUPPORTED_FRONTMATTER_EXTENSIONS);
|
||||
const SUPPORTED_FRONTMATTER_EXTENSIONS_VALUES = Object.values(exports.SUPPORTED_FRONTMATTER_EXTENSIONS);
|
||||
exports.frontmatterRE = /^---(.*?)^---/ms;
|
||||
function getCollectionName(collectionConfig, fileURI) {
|
||||
for (const collection of collectionConfig.configs) {
|
||||
if (collection.config.entries[fileURI]) {
|
||||
return collection.config.entries[fileURI];
|
||||
}
|
||||
}
|
||||
}
|
||||
function getFrontmatterLanguagePlugin(collectionConfig) {
|
||||
return {
|
||||
getLanguageId(scriptId) {
|
||||
const fileType = exports.SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS.find((ext) => scriptId.path.endsWith(`.${ext}`));
|
||||
if (fileType) {
|
||||
return exports.SUPPORTED_FRONTMATTER_EXTENSIONS[fileType];
|
||||
}
|
||||
},
|
||||
createVirtualCode(scriptId, languageId, snapshot) {
|
||||
if (SUPPORTED_FRONTMATTER_EXTENSIONS_VALUES.includes(languageId)) {
|
||||
return new FrontmatterHolder(scriptId.fsPath.replace(/\\/g, '/'), languageId, snapshot, getCollectionName(collectionConfig,
|
||||
// The scriptId here is encoded and somewhat normalized, as such we can't use it directly to compare with
|
||||
// the file URLs in the collection config entries that Astro generates.
|
||||
decodeURIComponent(scriptId.toString()).toLowerCase()));
|
||||
}
|
||||
},
|
||||
typescript: {
|
||||
extraFileExtensions: exports.SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS.map((ext) => ({
|
||||
extension: ext,
|
||||
isMixedContent: true,
|
||||
scriptKind: 7,
|
||||
})),
|
||||
getServiceScript(astroCode) {
|
||||
for (const code of (0, language_core_1.forEachEmbeddedCode)(astroCode)) {
|
||||
if (code.id === yaml2ts_1.VIRTUAL_CODE_ID) {
|
||||
return {
|
||||
code,
|
||||
extension: '.ts',
|
||||
scriptKind: 3,
|
||||
};
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
class FrontmatterHolder {
|
||||
constructor(fileName, languageId, snapshot, collection) {
|
||||
this.fileName = fileName;
|
||||
this.languageId = languageId;
|
||||
this.snapshot = snapshot;
|
||||
this.collection = collection;
|
||||
this.id = 'frontmatter-holder';
|
||||
this.hasFrontmatter = false;
|
||||
this.mappings = [
|
||||
{
|
||||
sourceOffsets: [0],
|
||||
generatedOffsets: [0],
|
||||
lengths: [this.snapshot.getLength()],
|
||||
data: {
|
||||
verification: true,
|
||||
completion: true,
|
||||
semantic: true,
|
||||
navigation: true,
|
||||
structure: true,
|
||||
format: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
this.embeddedCodes = [];
|
||||
this.snapshot = snapshot;
|
||||
// If the file is not part of a collection, we don't need to do anything
|
||||
if (!this.collection) {
|
||||
return;
|
||||
}
|
||||
const frontmatterContent = exports.frontmatterRE
|
||||
.exec(this.snapshot.getText(0, this.snapshot.getLength()))?.[0]
|
||||
.replaceAll('---', ' ') ?? '';
|
||||
this.hasFrontmatter = frontmatterContent.length > 0;
|
||||
this.embeddedCodes.push({
|
||||
id: `yaml_frontmatter_${this.collection}`,
|
||||
languageId: 'yaml',
|
||||
snapshot: {
|
||||
getText: (start, end) => frontmatterContent.substring(start, end),
|
||||
getLength: () => frontmatterContent.length,
|
||||
getChangeRange: () => undefined,
|
||||
},
|
||||
mappings: [
|
||||
{
|
||||
sourceOffsets: [0],
|
||||
generatedOffsets: [0],
|
||||
lengths: [frontmatterContent.length],
|
||||
data: {
|
||||
verification: true,
|
||||
completion: true,
|
||||
semantic: true,
|
||||
navigation: true,
|
||||
structure: true,
|
||||
format: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
if (this.hasFrontmatter) {
|
||||
const yaml2tsResult = (0, yaml2ts_1.yaml2ts)(frontmatterContent, this.collection);
|
||||
this.embeddedCodes.push(yaml2tsResult.virtualCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.FrontmatterHolder = FrontmatterHolder;
|
||||
//# sourceMappingURL=frontmatterHolders.js.map
|
||||
23
node_modules/@astrojs/language-server/dist/core/index.d.ts
generated
vendored
Normal file
23
node_modules/@astrojs/language-server/dist/core/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { DiagnosticMessage } from '@astrojs/compiler/types';
|
||||
import { type CodeMapping, type LanguagePlugin, type VirtualCode } from '@volar/language-core';
|
||||
import type ts from 'typescript';
|
||||
import type { HTMLDocument } from 'vscode-html-languageservice';
|
||||
import type { URI } from 'vscode-uri';
|
||||
import type { PackageInfo } from '../importPackage.js';
|
||||
import type { AstroMetadata } from './parseAstro';
|
||||
export declare function addAstroTypes(astroInstall: PackageInfo | undefined, ts: typeof import('typescript'), host: ts.LanguageServiceHost): void;
|
||||
export declare function getAstroLanguagePlugin(): LanguagePlugin<URI, AstroVirtualCode>;
|
||||
export declare class AstroVirtualCode implements VirtualCode {
|
||||
fileName: string;
|
||||
snapshot: ts.IScriptSnapshot;
|
||||
id: string;
|
||||
languageId: string;
|
||||
mappings: CodeMapping[];
|
||||
embeddedCodes: VirtualCode[];
|
||||
astroMeta: AstroMetadata;
|
||||
compilerDiagnostics: DiagnosticMessage[];
|
||||
htmlDocument: HTMLDocument;
|
||||
codegenStacks: never[];
|
||||
constructor(fileName: string, snapshot: ts.IScriptSnapshot);
|
||||
get hasCompilationErrors(): boolean;
|
||||
}
|
||||
175
node_modules/@astrojs/language-server/dist/core/index.js
generated
vendored
Normal file
175
node_modules/@astrojs/language-server/dist/core/index.js
generated
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AstroVirtualCode = void 0;
|
||||
exports.addAstroTypes = addAstroTypes;
|
||||
exports.getAstroLanguagePlugin = getAstroLanguagePlugin;
|
||||
const path = __importStar(require("node:path"));
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const utils_js_1 = require("../utils.js");
|
||||
const astro2tsx_1 = require("./astro2tsx");
|
||||
const parseAstro_1 = require("./parseAstro");
|
||||
const parseCSS_1 = require("./parseCSS");
|
||||
const parseHTML_1 = require("./parseHTML");
|
||||
const parseJS_js_1 = require("./parseJS.js");
|
||||
const decoratedHosts = new WeakSet();
|
||||
function addAstroTypes(astroInstall, ts, host) {
|
||||
if (decoratedHosts.has(host)) {
|
||||
return;
|
||||
}
|
||||
decoratedHosts.add(host);
|
||||
const getScriptFileNames = host.getScriptFileNames.bind(host);
|
||||
const getCompilationSettings = host.getCompilationSettings.bind(host);
|
||||
host.getScriptFileNames = () => {
|
||||
const languageServerTypesDirectory = (0, utils_js_1.getLanguageServerTypesDir)(ts);
|
||||
const fileNames = getScriptFileNames();
|
||||
const addedFileNames = [];
|
||||
if (astroInstall) {
|
||||
addedFileNames.push(...['./env.d.ts', './astro-jsx.d.ts'].map((filePath) => ts.sys.resolvePath(path.resolve(astroInstall.directory, filePath))));
|
||||
// If Astro version is < 4.0.8, add jsx-runtime-augment.d.ts to the files to fake `JSX` being available from "astro/jsx-runtime".
|
||||
// TODO: Remove this once a majority of users are on Astro 4.0.8+, erika - 2023-12-28
|
||||
if (astroInstall.version.major < 4 ||
|
||||
(astroInstall.version.major === 4 &&
|
||||
astroInstall.version.minor === 0 &&
|
||||
astroInstall.version.patch < 8)) {
|
||||
addedFileNames.push(...['./jsx-runtime-augment.d.ts'].map((filePath) => ts.sys.resolvePath(path.resolve(languageServerTypesDirectory, filePath))));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If we don't have an Astro installation, add the fallback types from the language server.
|
||||
// See the README in packages/language-server/types for more information.
|
||||
addedFileNames.push(...['./env.d.ts', './astro-jsx.d.ts', './jsx-runtime-fallback.d.ts'].map((f) => ts.sys.resolvePath(path.resolve(languageServerTypesDirectory, f))));
|
||||
}
|
||||
return [...fileNames, ...addedFileNames];
|
||||
};
|
||||
host.getCompilationSettings = () => {
|
||||
const baseCompilationSettings = getCompilationSettings();
|
||||
return {
|
||||
...baseCompilationSettings,
|
||||
module: ts.ModuleKind.ESNext ?? 99,
|
||||
target: ts.ScriptTarget.ESNext ?? 99,
|
||||
jsx: ts.JsxEmit.Preserve ?? 1,
|
||||
resolveJsonModule: true,
|
||||
allowJs: true, // Needed for inline scripts, which are virtual .js files
|
||||
isolatedModules: true,
|
||||
moduleResolution: baseCompilationSettings.moduleResolution === ts.ModuleResolutionKind.Classic ||
|
||||
!baseCompilationSettings.moduleResolution
|
||||
? ts.ModuleResolutionKind.Node10
|
||||
: baseCompilationSettings.moduleResolution,
|
||||
};
|
||||
};
|
||||
}
|
||||
function getAstroLanguagePlugin() {
|
||||
return {
|
||||
getLanguageId(uri) {
|
||||
if (uri.path.endsWith('.astro')) {
|
||||
return 'astro';
|
||||
}
|
||||
},
|
||||
createVirtualCode(uri, languageId, snapshot) {
|
||||
if (languageId === 'astro') {
|
||||
const fileName = uri.fsPath.replace(/\\/g, '/');
|
||||
return new AstroVirtualCode(fileName, snapshot);
|
||||
}
|
||||
},
|
||||
typescript: {
|
||||
extraFileExtensions: [{ extension: 'astro', isMixedContent: true, scriptKind: 7 }],
|
||||
getServiceScript(astroCode) {
|
||||
for (const code of (0, language_core_1.forEachEmbeddedCode)(astroCode)) {
|
||||
if (code.id === 'tsx') {
|
||||
return {
|
||||
code,
|
||||
extension: '.tsx',
|
||||
scriptKind: 4,
|
||||
};
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
getExtraServiceScripts(fileName, astroCode) {
|
||||
const result = [];
|
||||
for (const code of (0, language_core_1.forEachEmbeddedCode)(astroCode)) {
|
||||
if (code.id.endsWith('.mjs') || code.id.endsWith('.mts')) {
|
||||
const fileExtension = code.id.endsWith('.mjs') ? '.mjs' : '.mts';
|
||||
result.push({
|
||||
fileName: fileName + '.' + code.id,
|
||||
code,
|
||||
extension: fileExtension,
|
||||
scriptKind: fileExtension === '.mjs'
|
||||
? 1
|
||||
: 3,
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
class AstroVirtualCode {
|
||||
constructor(fileName, snapshot) {
|
||||
this.fileName = fileName;
|
||||
this.snapshot = snapshot;
|
||||
this.id = 'root';
|
||||
this.languageId = 'astro';
|
||||
this.codegenStacks = [];
|
||||
this.mappings = [
|
||||
{
|
||||
sourceOffsets: [0],
|
||||
generatedOffsets: [0],
|
||||
lengths: [this.snapshot.getLength()],
|
||||
data: {
|
||||
verification: true,
|
||||
completion: true,
|
||||
semantic: true,
|
||||
navigation: true,
|
||||
structure: true,
|
||||
format: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
const tsx = (0, astro2tsx_1.astro2tsx)(this.snapshot.getText(0, this.snapshot.getLength()), this.fileName);
|
||||
const astroMetadata = (0, parseAstro_1.getAstroMetadata)(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()));
|
||||
const { htmlDocument, virtualCode: htmlVirtualCode } = (0, parseHTML_1.parseHTML)(this.snapshot, astroMetadata.frontmatter.status === 'closed'
|
||||
? astroMetadata.frontmatter.position.end.offset
|
||||
: 0);
|
||||
this.htmlDocument = htmlDocument;
|
||||
htmlVirtualCode.embeddedCodes = [
|
||||
...(0, parseCSS_1.extractStylesheets)(tsx.ranges.styles),
|
||||
...(0, parseJS_js_1.extractScriptTags)(tsx.ranges.scripts),
|
||||
];
|
||||
this.astroMeta = { ...astroMetadata, tsxRanges: tsx.ranges };
|
||||
this.compilerDiagnostics = [...tsx.diagnostics, ...astroMetadata.diagnostics];
|
||||
this.embeddedCodes = [htmlVirtualCode, tsx.virtualCode];
|
||||
}
|
||||
get hasCompilationErrors() {
|
||||
return (
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
||||
this.compilerDiagnostics.filter((diag) => diag.severity === 1)
|
||||
.length > 0);
|
||||
}
|
||||
}
|
||||
exports.AstroVirtualCode = AstroVirtualCode;
|
||||
//# sourceMappingURL=index.js.map
|
||||
27
node_modules/@astrojs/language-server/dist/core/parseAstro.d.ts
generated
vendored
Normal file
27
node_modules/@astrojs/language-server/dist/core/parseAstro.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { ParseOptions, ParseResult, Point } from '@astrojs/compiler/types';
|
||||
import type { LSPTSXRanges } from './astro2tsx.js';
|
||||
export type AstroMetadata = ParseResult & {
|
||||
frontmatter: FrontmatterStatus;
|
||||
tsxRanges: LSPTSXRanges;
|
||||
};
|
||||
export declare function getAstroMetadata(fileName: string, input: string, options?: ParseOptions): Omit<AstroMetadata, 'tsxRanges'>;
|
||||
interface FrontmatterOpen {
|
||||
status: 'open';
|
||||
position: {
|
||||
start: Point;
|
||||
end: undefined;
|
||||
};
|
||||
}
|
||||
interface FrontmatterClosed {
|
||||
status: 'closed';
|
||||
position: {
|
||||
start: Point;
|
||||
end: Point;
|
||||
};
|
||||
}
|
||||
interface FrontmatterNull {
|
||||
status: 'doesnt-exist';
|
||||
position: undefined;
|
||||
}
|
||||
export type FrontmatterStatus = FrontmatterOpen | FrontmatterClosed | FrontmatterNull;
|
||||
export {};
|
||||
85
node_modules/@astrojs/language-server/dist/core/parseAstro.js
generated
vendored
Normal file
85
node_modules/@astrojs/language-server/dist/core/parseAstro.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAstroMetadata = getAstroMetadata;
|
||||
const sync_1 = require("@astrojs/compiler/sync");
|
||||
function getAstroMetadata(fileName, input, options = { position: true }) {
|
||||
const parseResult = safeParseAst(fileName, input, options);
|
||||
return {
|
||||
...parseResult,
|
||||
frontmatter: getFrontmatterStatus(parseResult.ast, input),
|
||||
};
|
||||
}
|
||||
function safeParseAst(fileName, input, parseOptions) {
|
||||
try {
|
||||
const parseResult = (0, sync_1.parse)(input, parseOptions);
|
||||
return parseResult;
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`There was an error parsing ${fileName}'s AST. An empty AST will be returned instead to avoid breaking the server. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.`);
|
||||
return {
|
||||
ast: {
|
||||
type: 'root',
|
||||
children: [],
|
||||
},
|
||||
diagnostics: [
|
||||
{
|
||||
code: 1000,
|
||||
location: {
|
||||
file: fileName,
|
||||
line: 1,
|
||||
column: 1,
|
||||
length: input.length,
|
||||
},
|
||||
severity: 1,
|
||||
text: `The Astro compiler encountered an unknown error while parsing this file's AST. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/language-tools/issues`,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
function getFrontmatterStatus(ast, text) {
|
||||
if (!ast.children || (ast.children && ast.children.length === 0)) {
|
||||
return {
|
||||
status: 'doesnt-exist',
|
||||
position: undefined,
|
||||
};
|
||||
}
|
||||
if (ast.children[0].type === 'frontmatter') {
|
||||
const frontmatter = ast.children[0];
|
||||
if (frontmatter.position) {
|
||||
if (frontmatter.position.end) {
|
||||
// HACK: The compiler as of 1.5.5 always return an ending position, even if there's only a frontmatter opening
|
||||
// This hack checks if the frontmatter's ending is the end of the file, and if so, checks if there's a `---`.
|
||||
// If there's not, it means the compiler returned the EOF with an opened frontmatter
|
||||
if (frontmatter.position.end.offset === text.length && !text.endsWith('---')) {
|
||||
return {
|
||||
status: 'open',
|
||||
position: {
|
||||
start: frontmatter.position.start,
|
||||
end: undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: 'closed',
|
||||
position: {
|
||||
start: frontmatter.position.start,
|
||||
end: frontmatter.position.end,
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: 'open',
|
||||
position: {
|
||||
start: frontmatter.position.start,
|
||||
end: undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
status: 'doesnt-exist',
|
||||
position: undefined,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=parseAstro.js.map
|
||||
3
node_modules/@astrojs/language-server/dist/core/parseCSS.d.ts
generated
vendored
Normal file
3
node_modules/@astrojs/language-server/dist/core/parseCSS.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { TSXExtractedStyle } from '@astrojs/compiler/types';
|
||||
import type { VirtualCode } from '@volar/language-core';
|
||||
export declare function extractStylesheets(styles: TSXExtractedStyle[]): VirtualCode[];
|
||||
63
node_modules/@astrojs/language-server/dist/core/parseCSS.js
generated
vendored
Normal file
63
node_modules/@astrojs/language-server/dist/core/parseCSS.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.extractStylesheets = extractStylesheets;
|
||||
const muggle_string_1 = require("muggle-string");
|
||||
const buildMappings_js_1 = require("../buildMappings.js");
|
||||
const SUPPORTED_LANGUAGES = ['css', 'scss', 'less'];
|
||||
function isSupportedLanguage(lang) {
|
||||
return SUPPORTED_LANGUAGES.includes(lang);
|
||||
}
|
||||
function extractStylesheets(styles) {
|
||||
return mergeCSSContextsByLanguage(styles);
|
||||
}
|
||||
function mergeCSSContextsByLanguage(inlineStyles) {
|
||||
const codes = {
|
||||
css: [],
|
||||
scss: [],
|
||||
less: [],
|
||||
};
|
||||
for (const cssContext of inlineStyles) {
|
||||
const currentCode = isSupportedLanguage(cssContext.lang) ? codes[cssContext.lang] : codes.css;
|
||||
const isStyleAttribute = cssContext.type === 'style-attribute';
|
||||
if (isStyleAttribute)
|
||||
currentCode.push('__ { ');
|
||||
currentCode.push([
|
||||
cssContext.content,
|
||||
undefined,
|
||||
cssContext.position.start,
|
||||
{
|
||||
verification: false,
|
||||
completion: true,
|
||||
semantic: true,
|
||||
navigation: true,
|
||||
structure: true,
|
||||
format: false,
|
||||
},
|
||||
]);
|
||||
if (isStyleAttribute)
|
||||
currentCode.push(' }\n');
|
||||
}
|
||||
let virtualCodes = [];
|
||||
for (const lang of SUPPORTED_LANGUAGES) {
|
||||
if (codes[lang].length) {
|
||||
virtualCodes.push(createVirtualCodeForLanguage(codes[lang], lang));
|
||||
}
|
||||
}
|
||||
return virtualCodes;
|
||||
}
|
||||
function createVirtualCodeForLanguage(code, lang) {
|
||||
const mappings = (0, buildMappings_js_1.buildMappings)(code);
|
||||
const text = (0, muggle_string_1.toString)(code);
|
||||
return {
|
||||
id: `style.${lang}`,
|
||||
languageId: lang,
|
||||
snapshot: {
|
||||
getText: (start, end) => text.substring(start, end),
|
||||
getLength: () => text.length,
|
||||
getChangeRange: () => undefined,
|
||||
},
|
||||
embeddedCodes: [],
|
||||
mappings,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=parseCSS.js.map
|
||||
11
node_modules/@astrojs/language-server/dist/core/parseHTML.d.ts
generated
vendored
Normal file
11
node_modules/@astrojs/language-server/dist/core/parseHTML.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { VirtualCode } from '@volar/language-core';
|
||||
import type ts from 'typescript';
|
||||
import * as html from 'vscode-html-languageservice';
|
||||
export declare function parseHTML(snapshot: ts.IScriptSnapshot, frontmatterEnd: number): {
|
||||
virtualCode: VirtualCode;
|
||||
htmlDocument: html.HTMLDocument;
|
||||
};
|
||||
/**
|
||||
* scan the text and remove any `>` or `<` that cause the tag to end short
|
||||
*/
|
||||
export declare function preprocessHTML(text: string, frontmatterEnd?: number): string;
|
||||
114
node_modules/@astrojs/language-server/dist/core/parseHTML.js
generated
vendored
Normal file
114
node_modules/@astrojs/language-server/dist/core/parseHTML.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseHTML = parseHTML;
|
||||
exports.preprocessHTML = preprocessHTML;
|
||||
const html = __importStar(require("vscode-html-languageservice"));
|
||||
const utils_1 = require("../plugins/utils");
|
||||
const htmlLs = html.getLanguageService();
|
||||
function parseHTML(snapshot, frontmatterEnd) {
|
||||
const htmlContent = preprocessHTML(snapshot.getText(0, snapshot.getLength()), frontmatterEnd);
|
||||
return {
|
||||
virtualCode: getHTMLVirtualCode(htmlContent),
|
||||
htmlDocument: getHTMLDocument(htmlContent),
|
||||
};
|
||||
}
|
||||
const createScanner = htmlLs.createScanner;
|
||||
/**
|
||||
* scan the text and remove any `>` or `<` that cause the tag to end short
|
||||
*/
|
||||
function preprocessHTML(text, frontmatterEnd) {
|
||||
let content = text.split('').fill(' ', 0, frontmatterEnd).join('');
|
||||
let scanner = createScanner(content);
|
||||
let token = scanner.scan();
|
||||
let currentStartTagStart = null;
|
||||
while (token !== html.TokenType.EOS) {
|
||||
const offset = scanner.getTokenOffset();
|
||||
if (token === html.TokenType.StartTagOpen) {
|
||||
currentStartTagStart = offset;
|
||||
}
|
||||
if (token === html.TokenType.StartTagClose) {
|
||||
if (shouldBlankStartOrEndTagLike(offset)) {
|
||||
blankStartOrEndTagLike(offset);
|
||||
}
|
||||
else {
|
||||
currentStartTagStart = null;
|
||||
}
|
||||
}
|
||||
if (token === html.TokenType.StartTagSelfClose) {
|
||||
currentStartTagStart = null;
|
||||
}
|
||||
// <Foo checked={a < 1}>
|
||||
// https://github.com/microsoft/vscode-html-languageservice/blob/71806ef57be07e1068ee40900ef8b0899c80e68a/src/parser/htmlScanner.ts#L327
|
||||
if (token === html.TokenType.Unknown &&
|
||||
scanner.getScannerState() === html.ScannerState.WithinTag &&
|
||||
scanner.getTokenText() === '<' &&
|
||||
shouldBlankStartOrEndTagLike(offset)) {
|
||||
blankStartOrEndTagLike(offset);
|
||||
}
|
||||
// TODO: Handle TypeScript generics inside expressions / Use the compiler to parse HTML instead?
|
||||
token = scanner.scan();
|
||||
}
|
||||
return content;
|
||||
function shouldBlankStartOrEndTagLike(offset) {
|
||||
// not null rather than falsy, otherwise it won't work on first tag(0)
|
||||
return (currentStartTagStart !== null && (0, utils_1.isInsideExpression)(content, currentStartTagStart, offset));
|
||||
}
|
||||
function blankStartOrEndTagLike(offset, state) {
|
||||
content = content.substring(0, offset) + ' ' + content.substring(offset + 1);
|
||||
scanner = createScanner(content, offset, state ?? html.ScannerState.WithinTag);
|
||||
}
|
||||
}
|
||||
function getHTMLVirtualCode(preprocessedHTML) {
|
||||
return {
|
||||
id: `html`,
|
||||
languageId: 'html',
|
||||
snapshot: {
|
||||
getText: (start, end) => preprocessedHTML.substring(start, end),
|
||||
getLength: () => preprocessedHTML.length,
|
||||
getChangeRange: () => undefined,
|
||||
},
|
||||
mappings: [
|
||||
{
|
||||
sourceOffsets: [0],
|
||||
generatedOffsets: [0],
|
||||
lengths: [preprocessedHTML.length],
|
||||
data: {
|
||||
verification: true,
|
||||
completion: true,
|
||||
semantic: true,
|
||||
navigation: true,
|
||||
structure: true,
|
||||
format: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
embeddedCodes: [],
|
||||
};
|
||||
}
|
||||
function getHTMLDocument(preprocessedHTML) {
|
||||
return htmlLs.parseHTMLDocument({ getText: () => preprocessedHTML });
|
||||
}
|
||||
//# sourceMappingURL=parseHTML.js.map
|
||||
3
node_modules/@astrojs/language-server/dist/core/parseJS.d.ts
generated
vendored
Normal file
3
node_modules/@astrojs/language-server/dist/core/parseJS.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { TSXExtractedScript } from '@astrojs/compiler/types';
|
||||
import type { VirtualCode } from '@volar/language-core';
|
||||
export declare function extractScriptTags(scripts: TSXExtractedScript[]): VirtualCode[];
|
||||
130
node_modules/@astrojs/language-server/dist/core/parseJS.js
generated
vendored
Normal file
130
node_modules/@astrojs/language-server/dist/core/parseJS.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.extractScriptTags = extractScriptTags;
|
||||
const muggle_string_1 = require("muggle-string");
|
||||
const buildMappings_1 = require("../buildMappings");
|
||||
function extractScriptTags(scripts) {
|
||||
const embeddedJSCodes = [];
|
||||
const moduleScripts = scripts
|
||||
.filter((script) => script.type === 'module' || script.type === 'processed-module')
|
||||
.map(moduleScriptToVirtualCode);
|
||||
const inlineScripts = scripts
|
||||
.filter((script) =>
|
||||
// TODO: Change this at some point so that unknown scripts are not included
|
||||
// We can't guarantee that they are JavaScript, so we shouldn't treat them as such, even if it might work in some cases
|
||||
// Perhaps we should make it so that the user has to specify the language of the script if it's not a known type (ex: lang="js"), not sure.
|
||||
script.type === 'event-attribute' || script.type === 'inline' || script.type === 'unknown')
|
||||
.sort((a, b) => a.position.start - b.position.start);
|
||||
embeddedJSCodes.push(...moduleScripts);
|
||||
const mergedJSContext = mergeJSContexts(inlineScripts);
|
||||
if (mergedJSContext) {
|
||||
embeddedJSCodes.push(mergedJSContext);
|
||||
}
|
||||
const JSONScripts = scripts
|
||||
.filter((script) => script.type === 'json')
|
||||
.map(jsonScriptToVirtualCode);
|
||||
embeddedJSCodes.push(...JSONScripts);
|
||||
return embeddedJSCodes;
|
||||
}
|
||||
function moduleScriptToVirtualCode(script, index) {
|
||||
let extension = 'mts';
|
||||
let languageId = 'typescript';
|
||||
if (script.type === 'module') {
|
||||
extension = 'mjs';
|
||||
languageId = 'javascript';
|
||||
}
|
||||
return {
|
||||
id: `${index}.${extension}`,
|
||||
languageId,
|
||||
snapshot: {
|
||||
getText: (start, end) => script.content.substring(start, end),
|
||||
getLength: () => script.content.length,
|
||||
getChangeRange: () => undefined,
|
||||
},
|
||||
mappings: [
|
||||
{
|
||||
sourceOffsets: [script.position.start],
|
||||
generatedOffsets: [0],
|
||||
lengths: [script.content.length],
|
||||
data: {
|
||||
verification: true,
|
||||
completion: true,
|
||||
semantic: true,
|
||||
navigation: true,
|
||||
structure: true,
|
||||
format: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
embeddedCodes: [],
|
||||
};
|
||||
}
|
||||
function jsonScriptToVirtualCode(script, index) {
|
||||
return {
|
||||
id: `${index}.json`,
|
||||
languageId: 'json',
|
||||
snapshot: {
|
||||
getText: (start, end) => script.content.substring(start, end),
|
||||
getLength: () => script.content.length,
|
||||
getChangeRange: () => undefined,
|
||||
},
|
||||
mappings: [
|
||||
{
|
||||
sourceOffsets: [script.position.start],
|
||||
generatedOffsets: [0],
|
||||
lengths: [script.content.length],
|
||||
// TODO: Support JSON features
|
||||
data: {
|
||||
verification: false,
|
||||
completion: false,
|
||||
semantic: false,
|
||||
navigation: false,
|
||||
structure: false,
|
||||
format: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
embeddedCodes: [],
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge all the inline and non-hoisted scripts into a single `.mjs` file
|
||||
*/
|
||||
function mergeJSContexts(inlineScripts) {
|
||||
if (inlineScripts.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
const codes = [];
|
||||
for (const javascriptContext of inlineScripts) {
|
||||
codes.push([
|
||||
// Add a semicolon to the end of the event attribute to attempt to prevent errors from spreading to the rest of the document
|
||||
// This is not perfect, but it's better than nothing
|
||||
// See: https://github.com/microsoft/vscode/blob/e8e04769ec817a3374c3eaa26a08d3ae491820d5/extensions/html-language-features/server/src/modes/embeddedSupport.ts#L192
|
||||
javascriptContext.content + ';',
|
||||
undefined,
|
||||
javascriptContext.position.start,
|
||||
{
|
||||
verification: true,
|
||||
completion: true,
|
||||
semantic: true,
|
||||
navigation: true,
|
||||
structure: true,
|
||||
format: false,
|
||||
},
|
||||
]);
|
||||
}
|
||||
const mappings = (0, buildMappings_1.buildMappings)(codes);
|
||||
const text = (0, muggle_string_1.toString)(codes);
|
||||
return {
|
||||
id: 'inline.mjs',
|
||||
languageId: 'javascript',
|
||||
snapshot: {
|
||||
getText: (start, end) => text.substring(start, end),
|
||||
getLength: () => text.length,
|
||||
getChangeRange: () => undefined,
|
||||
},
|
||||
embeddedCodes: [],
|
||||
mappings,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=parseJS.js.map
|
||||
15
node_modules/@astrojs/language-server/dist/core/svelte.d.ts
generated
vendored
Normal file
15
node_modules/@astrojs/language-server/dist/core/svelte.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { type CodeInformation, type LanguagePlugin, type Mapping, type VirtualCode } from '@volar/language-core';
|
||||
import type ts from 'typescript';
|
||||
import type { URI } from 'vscode-uri';
|
||||
export declare function getSvelteLanguagePlugin(): LanguagePlugin<URI, SvelteVirtualCode>;
|
||||
declare class SvelteVirtualCode implements VirtualCode {
|
||||
fileName: string;
|
||||
snapshot: ts.IScriptSnapshot;
|
||||
id: string;
|
||||
languageId: string;
|
||||
mappings: Mapping<CodeInformation>[];
|
||||
embeddedCodes: VirtualCode[];
|
||||
codegenStacks: never[];
|
||||
constructor(fileName: string, snapshot: ts.IScriptSnapshot);
|
||||
}
|
||||
export {};
|
||||
47
node_modules/@astrojs/language-server/dist/core/svelte.js
generated
vendored
Normal file
47
node_modules/@astrojs/language-server/dist/core/svelte.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getSvelteLanguagePlugin = getSvelteLanguagePlugin;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const utils_js_1 = require("./utils.js");
|
||||
function getSvelteLanguagePlugin() {
|
||||
return {
|
||||
getLanguageId(uri) {
|
||||
if (uri.path.endsWith('.svelte')) {
|
||||
return 'svelte';
|
||||
}
|
||||
},
|
||||
createVirtualCode(uri, languageId, snapshot) {
|
||||
if (languageId === 'svelte') {
|
||||
const fileName = uri.fsPath.replace(/\\/g, '/');
|
||||
return new SvelteVirtualCode(fileName, snapshot);
|
||||
}
|
||||
},
|
||||
typescript: {
|
||||
extraFileExtensions: [{ extension: 'svelte', isMixedContent: true, scriptKind: 7 }],
|
||||
getServiceScript(svelteCode) {
|
||||
for (const code of (0, language_core_1.forEachEmbeddedCode)(svelteCode)) {
|
||||
if (code.id === 'tsx') {
|
||||
return {
|
||||
code,
|
||||
extension: '.tsx',
|
||||
scriptKind: 4,
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
class SvelteVirtualCode {
|
||||
constructor(fileName, snapshot) {
|
||||
this.fileName = fileName;
|
||||
this.snapshot = snapshot;
|
||||
this.id = 'root';
|
||||
this.languageId = 'svelte';
|
||||
this.codegenStacks = [];
|
||||
this.mappings = [];
|
||||
this.embeddedCodes = [];
|
||||
this.embeddedCodes.push((0, utils_js_1.framework2tsx)(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()), 'svelte'));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=svelte.js.map
|
||||
4
node_modules/@astrojs/language-server/dist/core/utils.d.ts
generated
vendored
Normal file
4
node_modules/@astrojs/language-server/dist/core/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { VirtualCode } from '@volar/language-core';
|
||||
export declare function framework2tsx(filePath: string, sourceCode: string, framework: 'vue' | 'svelte'): VirtualCode;
|
||||
export declare function classNameFromFilename(filename: string): string;
|
||||
export declare function patchTSX(code: string, filePath: string): string;
|
||||
73
node_modules/@astrojs/language-server/dist/core/utils.js
generated
vendored
Normal file
73
node_modules/@astrojs/language-server/dist/core/utils.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.framework2tsx = framework2tsx;
|
||||
exports.classNameFromFilename = classNameFromFilename;
|
||||
exports.patchTSX = patchTSX;
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const importPackage_1 = require("../importPackage");
|
||||
function framework2tsx(filePath, sourceCode, framework) {
|
||||
const integrationEditorEntrypoint = framework === 'vue' ? (0, importPackage_1.importVueIntegration)(filePath) : (0, importPackage_1.importSvelteIntegration)(filePath);
|
||||
if (!integrationEditorEntrypoint) {
|
||||
const EMPTY_FILE = '';
|
||||
return getVirtualCode(EMPTY_FILE);
|
||||
}
|
||||
const className = classNameFromFilename(filePath);
|
||||
const tsx = patchTSX(integrationEditorEntrypoint.toTSX(sourceCode, className), filePath);
|
||||
return getVirtualCode(tsx);
|
||||
function getVirtualCode(content) {
|
||||
return {
|
||||
id: 'tsx',
|
||||
languageId: 'typescript',
|
||||
snapshot: {
|
||||
getText: (start, end) => content.substring(start, end),
|
||||
getLength: () => content.length,
|
||||
getChangeRange: () => undefined,
|
||||
},
|
||||
mappings: [],
|
||||
embeddedCodes: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Transform a string into PascalCase
|
||||
*/
|
||||
function toPascalCase(string) {
|
||||
return `${string}`
|
||||
.replace(new RegExp(/[-_]+/, 'g'), ' ')
|
||||
.replace(new RegExp(/[^\w\s]/, 'g'), '')
|
||||
.replace(new RegExp(/\s+(.)(\w*)/, 'g'), ($1, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}`)
|
||||
.replace(new RegExp(/\w/), (s) => s.toUpperCase());
|
||||
}
|
||||
function classNameFromFilename(filename) {
|
||||
const url = vscode_uri_1.URI.parse(filename);
|
||||
const withoutExtensions = vscode_uri_1.Utils.basename(url).slice(0, -vscode_uri_1.Utils.extname(url).length);
|
||||
const withoutInvalidCharacters = withoutExtensions
|
||||
.split('')
|
||||
// Although "-" is invalid, we leave it in, pascal-case-handling will throw it out later
|
||||
.filter((char) => /[\w$-]/.test(char))
|
||||
.join('');
|
||||
const firstValidCharIdx = withoutInvalidCharacters
|
||||
.split('')
|
||||
// Although _ and $ are valid first characters for classes, they are invalid first characters
|
||||
// for tag names. For a better import autocompletion experience, we therefore throw them out.
|
||||
.findIndex((char) => /[A-Za-z]/.test(char));
|
||||
const withoutLeadingInvalidCharacters = withoutInvalidCharacters.substring(firstValidCharIdx);
|
||||
const inPascalCase = toPascalCase(withoutLeadingInvalidCharacters);
|
||||
const finalName = firstValidCharIdx === -1 ? `A${inPascalCase}` : inPascalCase;
|
||||
return finalName;
|
||||
}
|
||||
// TODO: Patch the upstream packages with these changes
|
||||
function patchTSX(code, filePath) {
|
||||
const basename = filePath.split('/').pop();
|
||||
const isDynamic = basename.startsWith('[') && basename.endsWith(']');
|
||||
return code.replace(/\b(\S*)__AstroComponent_/g, (fullMatch, m1) => {
|
||||
// If we don't have a match here, it usually means the file has a weird name that couldn't be expressed with valid identifier characters
|
||||
if (!m1) {
|
||||
if (basename === '404')
|
||||
return 'FourOhFour';
|
||||
return fullMatch;
|
||||
}
|
||||
return isDynamic ? `_${m1}_` : m1[0].toUpperCase() + m1.slice(1);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=utils.js.map
|
||||
15
node_modules/@astrojs/language-server/dist/core/vue.d.ts
generated
vendored
Normal file
15
node_modules/@astrojs/language-server/dist/core/vue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { type CodeInformation, type LanguagePlugin, type Mapping, type VirtualCode } from '@volar/language-core';
|
||||
import type ts from 'typescript';
|
||||
import type { URI } from 'vscode-uri';
|
||||
export declare function getVueLanguagePlugin(): LanguagePlugin<URI, VueVirtualCode>;
|
||||
declare class VueVirtualCode implements VirtualCode {
|
||||
fileName: string;
|
||||
snapshot: ts.IScriptSnapshot;
|
||||
id: string;
|
||||
languageId: string;
|
||||
mappings: Mapping<CodeInformation>[];
|
||||
embeddedCodes: VirtualCode[];
|
||||
codegenStacks: never[];
|
||||
constructor(fileName: string, snapshot: ts.IScriptSnapshot);
|
||||
}
|
||||
export {};
|
||||
47
node_modules/@astrojs/language-server/dist/core/vue.js
generated
vendored
Normal file
47
node_modules/@astrojs/language-server/dist/core/vue.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getVueLanguagePlugin = getVueLanguagePlugin;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const utils_js_1 = require("./utils.js");
|
||||
function getVueLanguagePlugin() {
|
||||
return {
|
||||
getLanguageId(uri) {
|
||||
if (uri.path.endsWith('.vue')) {
|
||||
return 'vue';
|
||||
}
|
||||
},
|
||||
createVirtualCode(uri, languageId, snapshot) {
|
||||
if (languageId === 'vue') {
|
||||
const fileName = uri.fsPath.replace(/\\/g, '/');
|
||||
return new VueVirtualCode(fileName, snapshot);
|
||||
}
|
||||
},
|
||||
typescript: {
|
||||
extraFileExtensions: [{ extension: 'vue', isMixedContent: true, scriptKind: 7 }],
|
||||
getServiceScript(vueCode) {
|
||||
for (const code of (0, language_core_1.forEachEmbeddedCode)(vueCode)) {
|
||||
if (code.id === 'tsx') {
|
||||
return {
|
||||
code,
|
||||
extension: '.tsx',
|
||||
scriptKind: 4,
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
class VueVirtualCode {
|
||||
constructor(fileName, snapshot) {
|
||||
this.fileName = fileName;
|
||||
this.snapshot = snapshot;
|
||||
this.id = 'root';
|
||||
this.languageId = 'vue';
|
||||
this.codegenStacks = [];
|
||||
this.mappings = [];
|
||||
this.embeddedCodes = [];
|
||||
this.embeddedCodes.push((0, utils_js_1.framework2tsx)(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()), 'vue'));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=vue.js.map
|
||||
26
node_modules/@astrojs/language-server/dist/importPackage.d.ts
generated
vendored
Normal file
26
node_modules/@astrojs/language-server/dist/importPackage.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import type * as svelte from '@astrojs/svelte/dist/editor.cjs';
|
||||
import type * as vue from '@astrojs/vue/dist/editor.cjs';
|
||||
import type * as prettier from 'prettier';
|
||||
type PackageVersion = {
|
||||
full: string;
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
};
|
||||
export declare function setIsTrusted(_isTrusted: boolean): void;
|
||||
export type PackageInfo = {
|
||||
entrypoint: string;
|
||||
directory: string;
|
||||
version: PackageVersion;
|
||||
};
|
||||
/**
|
||||
* Get the path of a package's directory from the paths in `fromPath`, if `root` is set to false, it will return the path of the package's entry point
|
||||
*/
|
||||
export declare function getPackageInfo(packageName: string, fromPath: string[]): PackageInfo | undefined;
|
||||
export declare function importSvelteIntegration(fromPath: string): typeof svelte | undefined;
|
||||
export declare function importVueIntegration(fromPath: string): typeof vue | undefined;
|
||||
export declare function importPrettier(fromPath: string): typeof prettier | undefined;
|
||||
export declare function getPrettierPluginPath(fromPath: string): string | undefined;
|
||||
export declare function getWorkspacePnpPath(workspacePath: string): string | null;
|
||||
export declare function parsePackageVersion(version: string): PackageVersion;
|
||||
export {};
|
||||
106
node_modules/@astrojs/language-server/dist/importPackage.js
generated
vendored
Normal file
106
node_modules/@astrojs/language-server/dist/importPackage.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.setIsTrusted = setIsTrusted;
|
||||
exports.getPackageInfo = getPackageInfo;
|
||||
exports.importSvelteIntegration = importSvelteIntegration;
|
||||
exports.importVueIntegration = importVueIntegration;
|
||||
exports.importPrettier = importPrettier;
|
||||
exports.getPrettierPluginPath = getPrettierPluginPath;
|
||||
exports.getWorkspacePnpPath = getWorkspacePnpPath;
|
||||
exports.parsePackageVersion = parsePackageVersion;
|
||||
const node_path_1 = require("node:path");
|
||||
let isTrusted = true;
|
||||
function setIsTrusted(_isTrusted) {
|
||||
isTrusted = _isTrusted;
|
||||
}
|
||||
/**
|
||||
* Get the path of a package's directory from the paths in `fromPath`, if `root` is set to false, it will return the path of the package's entry point
|
||||
*/
|
||||
function getPackageInfo(packageName, fromPath) {
|
||||
const paths = [];
|
||||
if (isTrusted) {
|
||||
paths.unshift(...fromPath);
|
||||
}
|
||||
try {
|
||||
const packageJSON = require.resolve(packageName + '/package.json', { paths });
|
||||
return {
|
||||
directory: (0, node_path_1.dirname)(packageJSON),
|
||||
entrypoint: require.resolve(packageName, { paths }),
|
||||
version: parsePackageVersion(require(packageJSON).version),
|
||||
};
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function importEditorIntegration(packageName, fromPath) {
|
||||
const pkgPath = getPackageInfo(packageName, [fromPath])?.directory;
|
||||
if (pkgPath) {
|
||||
try {
|
||||
const main = (0, node_path_1.resolve)(pkgPath, 'dist', 'editor.cjs');
|
||||
return require(main);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`Couldn't load editor module from ${pkgPath}. Make sure you're using at least version v0.2.1 of the corresponding integration. Reason: ${e}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.info(`Couldn't find package ${packageName} (searching from ${fromPath}). Make sure it's installed. If you believe this to be an error, please open an issue.`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function importSvelteIntegration(fromPath) {
|
||||
return importEditorIntegration('@astrojs/svelte', fromPath);
|
||||
}
|
||||
function importVueIntegration(fromPath) {
|
||||
return importEditorIntegration('@astrojs/vue', fromPath);
|
||||
}
|
||||
function importPrettier(fromPath) {
|
||||
let prettierPkg = getPackageInfo('prettier', [fromPath, __dirname]);
|
||||
if (!prettierPkg) {
|
||||
return undefined;
|
||||
}
|
||||
if (prettierPkg.version.major < 3) {
|
||||
console.error(`Prettier version ${prettierPkg.version.full} from ${prettierPkg.directory} is not supported, please update to at least version 3.0.0. Falling back to bundled version to ensure formatting works correctly.`);
|
||||
prettierPkg = getPackageInfo('prettier', [__dirname]);
|
||||
if (!prettierPkg) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return require(prettierPkg.entrypoint);
|
||||
}
|
||||
function getPrettierPluginPath(fromPath) {
|
||||
const prettierPluginPath = getPackageInfo('prettier-plugin-astro', [
|
||||
fromPath,
|
||||
__dirname,
|
||||
])?.entrypoint;
|
||||
if (!prettierPluginPath) {
|
||||
return undefined;
|
||||
}
|
||||
return prettierPluginPath;
|
||||
}
|
||||
function getWorkspacePnpPath(workspacePath) {
|
||||
try {
|
||||
const possiblePath = (0, node_path_1.resolve)(workspacePath, '.pnp.cjs');
|
||||
require.resolve(possiblePath);
|
||||
return possiblePath;
|
||||
}
|
||||
catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function parsePackageVersion(version) {
|
||||
let [major, minor, patch] = version.split('.');
|
||||
if (patch.includes('-')) {
|
||||
const patchParts = patch.split('-');
|
||||
patch = patchParts[0];
|
||||
}
|
||||
return {
|
||||
full: version,
|
||||
major: Number(major),
|
||||
minor: Number(minor),
|
||||
patch: Number(patch),
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=importPackage.js.map
|
||||
1
node_modules/@astrojs/language-server/dist/index.d.ts
generated
vendored
Normal file
1
node_modules/@astrojs/language-server/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export { AstroCheck, CheckResult, Diagnostic, DiagnosticSeverity } from './check.js';
|
||||
8
node_modules/@astrojs/language-server/dist/index.js
generated
vendored
Normal file
8
node_modules/@astrojs/language-server/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DiagnosticSeverity = exports.Diagnostic = exports.AstroCheck = void 0;
|
||||
var check_js_1 = require("./check.js");
|
||||
Object.defineProperty(exports, "AstroCheck", { enumerable: true, get: function () { return check_js_1.AstroCheck; } });
|
||||
Object.defineProperty(exports, "Diagnostic", { enumerable: true, get: function () { return check_js_1.Diagnostic; } });
|
||||
Object.defineProperty(exports, "DiagnosticSeverity", { enumerable: true, get: function () { return check_js_1.DiagnosticSeverity; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
5
node_modules/@astrojs/language-server/dist/languageServerPlugin.d.ts
generated
vendored
Normal file
5
node_modules/@astrojs/language-server/dist/languageServerPlugin.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { type Connection, type LanguagePlugin } from '@volar/language-server/node';
|
||||
import { URI } from 'vscode-uri';
|
||||
import { type CollectionConfig } from './core/frontmatterHolders.js';
|
||||
export declare function getLanguagePlugins(collectionConfig: CollectionConfig): LanguagePlugin<URI, import("@volar/language-server/node").VirtualCode>[];
|
||||
export declare function getLanguageServicePlugins(connection: Connection, ts: typeof import('typescript'), collectionConfig: CollectionConfig): import("@volar/language-server/node").LanguageServicePlugin<any>[];
|
||||
116
node_modules/@astrojs/language-server/dist/languageServerPlugin.js
generated
vendored
Normal file
116
node_modules/@astrojs/language-server/dist/languageServerPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getLanguagePlugins = getLanguagePlugins;
|
||||
exports.getLanguageServicePlugins = getLanguageServicePlugins;
|
||||
const node_1 = require("@volar/language-server/node");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const core_1 = require("./core");
|
||||
const svelte_js_1 = require("./core/svelte.js");
|
||||
const vue_js_1 = require("./core/vue.js");
|
||||
const importPackage_js_1 = require("./importPackage.js");
|
||||
// Services
|
||||
const volar_service_css_1 = require("volar-service-css");
|
||||
const volar_service_emmet_1 = require("volar-service-emmet");
|
||||
const volar_service_prettier_1 = require("volar-service-prettier");
|
||||
const volar_service_typescript_twoslash_queries_1 = require("volar-service-typescript-twoslash-queries");
|
||||
const frontmatterHolders_js_1 = require("./core/frontmatterHolders.js");
|
||||
const astro_js_1 = require("./plugins/astro.js");
|
||||
const html_js_1 = require("./plugins/html.js");
|
||||
const index_js_1 = require("./plugins/typescript-addons/index.js");
|
||||
const index_js_2 = require("./plugins/typescript/index.js");
|
||||
const yaml_js_1 = require("./plugins/yaml.js");
|
||||
function getLanguagePlugins(collectionConfig) {
|
||||
const languagePlugins = [
|
||||
(0, core_1.getAstroLanguagePlugin)(),
|
||||
(0, vue_js_1.getVueLanguagePlugin)(),
|
||||
(0, svelte_js_1.getSvelteLanguagePlugin)(),
|
||||
(0, frontmatterHolders_js_1.getFrontmatterLanguagePlugin)(collectionConfig),
|
||||
];
|
||||
return languagePlugins;
|
||||
}
|
||||
function getLanguageServicePlugins(connection, ts, collectionConfig) {
|
||||
const LanguageServicePlugins = [
|
||||
(0, html_js_1.create)(),
|
||||
(0, volar_service_css_1.create)(),
|
||||
(0, volar_service_emmet_1.create)(),
|
||||
...(0, index_js_2.create)(ts),
|
||||
(0, volar_service_typescript_twoslash_queries_1.create)(ts),
|
||||
(0, index_js_1.create)(),
|
||||
(0, astro_js_1.create)(ts),
|
||||
getPrettierService(),
|
||||
(0, yaml_js_1.create)(collectionConfig),
|
||||
];
|
||||
return LanguageServicePlugins;
|
||||
function getPrettierService() {
|
||||
let prettier;
|
||||
let prettierPluginPath;
|
||||
let hasShownNotification = false;
|
||||
return (0, volar_service_prettier_1.create)((context) => {
|
||||
for (const workspaceFolder of context.env.workspaceFolders) {
|
||||
if (workspaceFolder.scheme === 'file') {
|
||||
prettier = (0, importPackage_js_1.importPrettier)(workspaceFolder.fsPath);
|
||||
prettierPluginPath = (0, importPackage_js_1.getPrettierPluginPath)(workspaceFolder.fsPath);
|
||||
if ((!prettier || !prettierPluginPath) && !hasShownNotification) {
|
||||
connection.sendNotification(node_1.ShowMessageNotification.type, {
|
||||
message: "Couldn't load `prettier` or `prettier-plugin-astro`. Formatting will not work. Please make sure those two packages are installed into your project and restart the language server.",
|
||||
type: node_1.MessageType.Warning,
|
||||
});
|
||||
hasShownNotification = true;
|
||||
}
|
||||
return prettier;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
documentSelector: ['astro'],
|
||||
getFormattingOptions: async (prettierInstance, document, formatOptions, context) => {
|
||||
const uri = vscode_uri_1.URI.parse(document.uri);
|
||||
const documentUri = context.decodeEmbeddedDocumentUri(uri)?.[0] ?? uri;
|
||||
const filePath = documentUri.fsPath;
|
||||
if (!filePath) {
|
||||
return {};
|
||||
}
|
||||
let configOptions = null;
|
||||
try {
|
||||
configOptions = await prettierInstance.resolveConfig(filePath, {
|
||||
// This seems to be broken since Prettier 3, and it'll always use its cumbersome cache. Hopefully it works one day.
|
||||
useCache: false,
|
||||
editorconfig: true,
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
connection.sendNotification(node_1.ShowMessageNotification.type, {
|
||||
message: `Failed to load Prettier config.\n\nError:\n${e}`,
|
||||
type: node_1.MessageType.Warning,
|
||||
});
|
||||
console.error('Failed to load Prettier config.', e);
|
||||
}
|
||||
const editorOptions = await context.env.getConfiguration?.('prettier', document.uri);
|
||||
// Return a config with the following cascade:
|
||||
// - Prettier config file should always win if it exists, if it doesn't:
|
||||
// - Prettier config from the VS Code extension is used, if it doesn't exist:
|
||||
// - Use the editor's basic configuration settings
|
||||
const resolvedConfig = {
|
||||
filepath: filePath,
|
||||
tabWidth: formatOptions.tabSize,
|
||||
useTabs: !formatOptions.insertSpaces,
|
||||
...editorOptions,
|
||||
...configOptions,
|
||||
};
|
||||
return {
|
||||
...resolvedConfig,
|
||||
plugins: [...(await getAstroPrettierPlugin()), ...(resolvedConfig.plugins ?? [])],
|
||||
parser: 'astro',
|
||||
};
|
||||
async function getAstroPrettierPlugin() {
|
||||
if (!prettier || !prettierPluginPath) {
|
||||
return [];
|
||||
}
|
||||
const hasPluginLoadedAlready = (await prettier.getSupportInfo()).languages.some((l) => l.name === 'astro') ||
|
||||
resolvedConfig.plugins?.includes('prettier-plugin-astro'); // getSupportInfo doesn't seems to work very well in Prettier 3 for plugins
|
||||
return hasPluginLoadedAlready ? [] : [prettierPluginPath];
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=languageServerPlugin.js.map
|
||||
1
node_modules/@astrojs/language-server/dist/nodeServer.d.ts
generated
vendored
Normal file
1
node_modules/@astrojs/language-server/dist/nodeServer.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
102
node_modules/@astrojs/language-server/dist/nodeServer.js
generated
vendored
Normal file
102
node_modules/@astrojs/language-server/dist/nodeServer.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const node_1 = require("@volar/language-server/node");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const frontmatterHolders_js_1 = require("./core/frontmatterHolders.js");
|
||||
const index_js_1 = require("./core/index.js");
|
||||
const languageServerPlugin_js_1 = require("./languageServerPlugin.js");
|
||||
const utils_js_1 = require("./utils.js");
|
||||
const connection = (0, node_1.createConnection)();
|
||||
const server = (0, node_1.createServer)(connection);
|
||||
let contentIntellisenseEnabled = false;
|
||||
connection.listen();
|
||||
connection.onInitialize((params) => {
|
||||
const tsdk = params.initializationOptions?.typescript?.tsdk;
|
||||
if (!tsdk) {
|
||||
throw new Error('The `typescript.tsdk` init option is required. It should point to a directory containing a `typescript.js` or `tsserverlibrary.js` file, such as `node_modules/typescript/lib`.');
|
||||
}
|
||||
const { typescript, diagnosticMessages } = (0, node_1.loadTsdkByPath)(tsdk, params.locale);
|
||||
contentIntellisenseEnabled = params.initializationOptions?.contentIntellisense ?? false;
|
||||
const collectionConfig = {
|
||||
reload(folders) {
|
||||
this.configs = loadCollectionConfig(folders);
|
||||
},
|
||||
configs: contentIntellisenseEnabled
|
||||
? loadCollectionConfig(
|
||||
// The vast majority of clients support workspaceFolders, but sometimes some unusual environments like tests don't
|
||||
params.workspaceFolders ?? (params.rootUri ? [{ uri: params.rootUri }] : []) ?? [])
|
||||
: [],
|
||||
};
|
||||
function loadCollectionConfig(folders) {
|
||||
return folders.flatMap((folder) => {
|
||||
try {
|
||||
const folderUri = vscode_uri_1.URI.parse(folder.uri);
|
||||
let config = server.fileSystem.readFile(vscode_uri_1.Utils.joinPath(folderUri, '.astro/collections/collections.json'));
|
||||
if (!config) {
|
||||
return [];
|
||||
}
|
||||
// `server.fs.readFile` can theoretically be async, but in practice it's always sync
|
||||
const collections = JSON.parse(config);
|
||||
return { folder: folderUri, config: collections };
|
||||
}
|
||||
catch (err) {
|
||||
// If the file doesn't exist, we don't really care, but if it's something else, we want to know
|
||||
if (err && err.code !== 'ENOENT')
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
return server.initialize(params, (0, node_1.createTypeScriptProject)(typescript, diagnosticMessages, ({ env }) => {
|
||||
return {
|
||||
languagePlugins: (0, languageServerPlugin_js_1.getLanguagePlugins)(collectionConfig),
|
||||
setup({ project }) {
|
||||
const { languageServiceHost, configFileName } = project.typescript;
|
||||
const rootPath = configFileName
|
||||
? configFileName.split('/').slice(0, -1).join('/')
|
||||
: env.workspaceFolders[0].fsPath;
|
||||
const nearestPackageJson = typescript.findConfigFile(rootPath, typescript.sys.fileExists, 'package.json');
|
||||
const astroInstall = (0, utils_js_1.getAstroInstall)([rootPath], {
|
||||
nearestPackageJson: nearestPackageJson,
|
||||
readDirectory: typescript.sys.readDirectory,
|
||||
});
|
||||
if (astroInstall === 'not-found') {
|
||||
connection.sendNotification(node_1.ShowMessageNotification.type, {
|
||||
message: `Couldn't find Astro in workspace "${rootPath}". Experience might be degraded. For the best experience, please make sure Astro is installed into your project and restart the language server.`,
|
||||
type: node_1.MessageType.Warning,
|
||||
});
|
||||
}
|
||||
(0, index_js_1.addAstroTypes)(typeof astroInstall === 'string' ? undefined : astroInstall, typescript, languageServiceHost);
|
||||
},
|
||||
};
|
||||
}), (0, languageServerPlugin_js_1.getLanguageServicePlugins)(connection, typescript, collectionConfig));
|
||||
});
|
||||
connection.onInitialized(() => {
|
||||
server.initialized();
|
||||
const extensions = [
|
||||
'js',
|
||||
'cjs',
|
||||
'mjs',
|
||||
'ts',
|
||||
'cts',
|
||||
'mts',
|
||||
'jsx',
|
||||
'tsx',
|
||||
'json',
|
||||
'astro',
|
||||
'vue',
|
||||
'svelte',
|
||||
];
|
||||
if (contentIntellisenseEnabled) {
|
||||
extensions.push(...frontmatterHolders_js_1.SUPPORTED_FRONTMATTER_EXTENSIONS_KEYS);
|
||||
server.fileWatcher.watchFiles(['**/*.schema.json', '**/collections.json']);
|
||||
server.fileWatcher.onDidChangeWatchedFiles(({ changes }) => {
|
||||
const shouldReload = changes.some((change) => change.uri.endsWith('.schema.json') || change.uri.endsWith('collections.json'));
|
||||
if (shouldReload) {
|
||||
server.project.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
server.fileWatcher.watchFiles([`**/*.{${extensions.join(',')}}`]);
|
||||
});
|
||||
//# sourceMappingURL=nodeServer.js.map
|
||||
2
node_modules/@astrojs/language-server/dist/plugins/astro.d.ts
generated
vendored
Normal file
2
node_modules/@astrojs/language-server/dist/plugins/astro.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { LanguageServicePlugin } from '@volar/language-server';
|
||||
export declare const create: (ts: typeof import("typescript")) => LanguageServicePlugin;
|
||||
155
node_modules/@astrojs/language-server/dist/plugins/astro.js
generated
vendored
Normal file
155
node_modules/@astrojs/language-server/dist/plugins/astro.js
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.create = void 0;
|
||||
const node_path_1 = require("node:path");
|
||||
const language_server_1 = require("@volar/language-server");
|
||||
const fast_glob_1 = __importDefault(require("fast-glob"));
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const index_js_1 = require("../core/index.js");
|
||||
const utils_js_1 = require("./utils.js");
|
||||
const create = (ts) => {
|
||||
return {
|
||||
capabilities: {
|
||||
completionProvider: {
|
||||
triggerCharacters: ['-'],
|
||||
},
|
||||
diagnosticProvider: {
|
||||
interFileDependencies: false,
|
||||
workspaceDiagnostics: false,
|
||||
},
|
||||
codeLensProvider: {},
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
provideCompletionItems(document, position, completionContext, token) {
|
||||
if (token.isCancellationRequested)
|
||||
return null;
|
||||
let items = [];
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (!(virtualCode instanceof index_js_1.AstroVirtualCode))
|
||||
return;
|
||||
if (completionContext.triggerCharacter === '-') {
|
||||
const frontmatterCompletion = getFrontmatterCompletion(virtualCode, document, position);
|
||||
if (frontmatterCompletion)
|
||||
items.push(frontmatterCompletion);
|
||||
}
|
||||
return {
|
||||
isIncomplete: false,
|
||||
items: items,
|
||||
};
|
||||
},
|
||||
provideDiagnostics(document, token) {
|
||||
if (token.isCancellationRequested)
|
||||
return [];
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (!(virtualCode instanceof index_js_1.AstroVirtualCode))
|
||||
return;
|
||||
return virtualCode.compilerDiagnostics.map(compilerMessageToDiagnostic);
|
||||
function compilerMessageToDiagnostic(message) {
|
||||
const start = language_server_1.Position.create(message.location.line - 1, message.location.column - 1);
|
||||
const end = document.positionAt(document.offsetAt(start) + message.location.length);
|
||||
return {
|
||||
message: message.text + (message.hint ? '\n\n' + message.hint : ''),
|
||||
range: language_server_1.Range.create(start, end),
|
||||
code: message.code,
|
||||
severity: message.severity,
|
||||
source: 'astro',
|
||||
};
|
||||
}
|
||||
},
|
||||
provideCodeLenses(document, token) {
|
||||
if (token.isCancellationRequested)
|
||||
return;
|
||||
if (!(0, utils_js_1.isJSDocument)(document.languageId))
|
||||
return;
|
||||
if (!context.project.typescript)
|
||||
return;
|
||||
const { uriConverter } = context.project.typescript;
|
||||
const languageService = context.inject('typescript/languageService');
|
||||
if (!languageService)
|
||||
return;
|
||||
const tsProgram = languageService.getProgram();
|
||||
if (!tsProgram)
|
||||
return;
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
||||
if (!decoded)
|
||||
return;
|
||||
const globcodeLens = [];
|
||||
const sourceFile = tsProgram.getSourceFile(decoded[0].fsPath);
|
||||
function walk() {
|
||||
return ts.forEachChild(sourceFile, function cb(node) {
|
||||
if (ts.isCallExpression(node) && node.expression.getText() === 'Astro.glob') {
|
||||
const globArgument = node.arguments.at(0);
|
||||
if (globArgument && decoded) {
|
||||
globcodeLens.push(getGlobResultAsCodeLens(globArgument.getText().slice(1, -1), (0, node_path_1.dirname)(uriConverter.asFileName(decoded[0])), document.positionAt(node.arguments.pos)));
|
||||
}
|
||||
}
|
||||
return ts.forEachChild(node, cb);
|
||||
});
|
||||
}
|
||||
walk();
|
||||
return globcodeLens;
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.create = create;
|
||||
function getGlobResultAsCodeLens(globText, dir, position) {
|
||||
const globResult = fast_glob_1.default.sync(globText, {
|
||||
cwd: dir,
|
||||
onlyFiles: true,
|
||||
});
|
||||
return {
|
||||
range: language_server_1.Range.create(position, position),
|
||||
command: { title: `Matches ${globResult.length} files`, command: '' },
|
||||
};
|
||||
}
|
||||
function getFrontmatterCompletion(file, document, position) {
|
||||
const base = {
|
||||
kind: language_server_1.CompletionItemKind.Snippet,
|
||||
label: '---',
|
||||
sortText: '\0',
|
||||
preselect: true,
|
||||
detail: 'Create component script block',
|
||||
insertTextFormat: language_server_1.InsertTextFormat.Snippet,
|
||||
commitCharacters: [],
|
||||
};
|
||||
const documentLines = document.getText().split(/\r?\n/);
|
||||
const { line, character } = document.positionAt(document.offsetAt(position));
|
||||
const prefix = documentLines[line].slice(0, character);
|
||||
if (file.astroMeta.frontmatter.status === 'doesnt-exist') {
|
||||
return {
|
||||
...base,
|
||||
insertText: '---\n$0\n---',
|
||||
textEdit: /^\s*-+/.test(prefix)
|
||||
? language_server_1.TextEdit.replace({ start: { ...position, character: 0 }, end: position }, '---\n$0\n---')
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
if (file.astroMeta.frontmatter.status === 'open') {
|
||||
let insertText = '---';
|
||||
// If the current line is a full component script starter/ender, the user expects a full frontmatter
|
||||
// completion and not just a completion for "---" on the same line (which result in, well, nothing)
|
||||
if (prefix === '---') {
|
||||
insertText = '---\n$0\n---';
|
||||
}
|
||||
return {
|
||||
...base,
|
||||
insertText,
|
||||
detail: insertText === '---' ? 'Close component script block' : 'Create component script block',
|
||||
textEdit: /^\s*-+/.test(prefix)
|
||||
? language_server_1.TextEdit.replace({ start: { ...position, character: 0 }, end: position }, insertText)
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//# sourceMappingURL=astro.js.map
|
||||
4
node_modules/@astrojs/language-server/dist/plugins/html-data.d.ts
generated
vendored
Normal file
4
node_modules/@astrojs/language-server/dist/plugins/html-data.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare const classListAttribute: import("vscode-html-languageservice").IHTMLDataProvider;
|
||||
export declare const astroElements: import("vscode-html-languageservice").IHTMLDataProvider;
|
||||
export declare const astroAttributes: import("vscode-html-languageservice").IHTMLDataProvider;
|
||||
export declare const astroDirectives: import("vscode-html-languageservice").IHTMLDataProvider;
|
||||
277
node_modules/@astrojs/language-server/dist/plugins/html-data.js
generated
vendored
Normal file
277
node_modules/@astrojs/language-server/dist/plugins/html-data.js
generated
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.astroDirectives = exports.astroAttributes = exports.astroElements = exports.classListAttribute = void 0;
|
||||
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
||||
const defaultProvider = (0, vscode_html_languageservice_1.getDefaultHTMLDataProvider)();
|
||||
const slotAttr = defaultProvider.provideAttributes('div').find((attr) => attr.name === 'slot');
|
||||
exports.classListAttribute = (0, vscode_html_languageservice_1.newHTMLDataProvider)('class-list', {
|
||||
version: 1,
|
||||
globalAttributes: [
|
||||
{
|
||||
name: 'class:list',
|
||||
description: 'Utility to provide a list of classes of the element. Takes an array of class values and converts them into a class string.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#classlist',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
exports.astroElements = (0, vscode_html_languageservice_1.newHTMLDataProvider)('astro-elements', {
|
||||
version: 1,
|
||||
tags: [
|
||||
{
|
||||
name: 'slot',
|
||||
description: 'The slot element is a placeholder for external HTML content, allowing you to inject (or “slot”) child elements from other files into your component template.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/core-concepts/astro-components/#slots',
|
||||
},
|
||||
],
|
||||
attributes: [
|
||||
{
|
||||
name: 'name',
|
||||
description: 'The name attribute allows you to pass only HTML elements with the corresponding slot name into a slot’s location.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/core-concepts/astro-components/#named-slots',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'script',
|
||||
attributes: [
|
||||
{
|
||||
// The VS Code tag definitions does not provide a description for the deprecated `charset` attribute on script tags
|
||||
// Which mean that since we get no hover info for this, we instead get JSX hover info. So we'll just specify a description ourselves for this specific case
|
||||
name: 'charset',
|
||||
description: "**Deprecated**\n\nIt's unnecessary to specify the charset attribute, because documents must use UTF-8, and the script element inherits its character encoding from the document.",
|
||||
},
|
||||
{
|
||||
name: 'define:vars',
|
||||
description: 'Passes serializable server-side variables into a client-side script element.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#definevars',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'hoist',
|
||||
description: '**Deprecated in Astro >= 0.26.0**\n\nBuilds, optimizes, and bundles your script with the other JavaScript on the page.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/core-concepts/astro-components/#using-hoisted-scripts',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'is:inline',
|
||||
description: 'Leave a script tag inline in the page template. No processing will be done on its content.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#isinline',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'data-astro-rerun',
|
||||
description: 'Force a script to be reexecuted when using <ViewTransitions/>. This will make your script is:inline as well.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/guides/view-transitions/#script-behavior',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
attributes: [
|
||||
{
|
||||
name: 'define:vars',
|
||||
description: 'Passes serializable server-side variables into a client-side style element.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#definevars',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'global',
|
||||
description: '**Deprecated in favor of `is:global` in >= Astro 0.26.0**\n\nOpts-out of automatic CSS scoping, all contents will be available globally.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#isglobal',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'is:global',
|
||||
description: 'Opts-out of automatic CSS scoping, all contents will be available globally.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#isglobal',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'is:inline',
|
||||
description: 'Leave a style tag inline in the page template. No processing will be done on its content.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#isinline',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
exports.astroAttributes = (0, vscode_html_languageservice_1.newHTMLDataProvider)('astro-attributes', {
|
||||
version: 1,
|
||||
globalAttributes: [
|
||||
{
|
||||
name: 'set:html',
|
||||
description: 'Inject unescaped HTML into this tag.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#sethtml',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'set:text',
|
||||
description: 'Inject escaped text into this tag.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#settext',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'is:raw',
|
||||
description: 'Instructs the Astro compiler to treat any children of this element as text.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#israw',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'transition:animate',
|
||||
description: 'Specifies an animation to use with this element on page transition.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/guides/view-transitions/#transition-directives',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'transition:name',
|
||||
description: 'Specifies a `view-transition-name` for this element. The name must be unique on the page.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/guides/view-transitions/#transition-directives',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'transition:persist',
|
||||
description: 'Marks this element to be moved to the next page during view transitions.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/guides/view-transitions/#transition-directives',
|
||||
},
|
||||
],
|
||||
},
|
||||
slotAttr,
|
||||
],
|
||||
});
|
||||
exports.astroDirectives = (0, vscode_html_languageservice_1.newHTMLDataProvider)('astro-directives', {
|
||||
version: 1,
|
||||
globalAttributes: [
|
||||
{
|
||||
name: 'client:load',
|
||||
description: 'Start importing the component JS at page load. Hydrate the component when import completes.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#clientload',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'client:idle',
|
||||
description: 'Start importing the component JS as soon as main thread is free (uses requestIdleCallback()). Hydrate the component when import completes.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#clientidle',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'client:visible',
|
||||
description: 'Start importing the component JS as soon as the element enters the viewport (uses IntersectionObserver). Hydrate the component when import completes. Useful for content lower down on the page.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#clientvisible',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'client:media',
|
||||
description: 'Start importing the component JS as soon as the browser matches the given media query (uses matchMedia). Hydrate the component when import completes. Useful for sidebar toggles, or other elements that should only display on mobile or desktop devices.',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#clientmedia',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'client:only',
|
||||
description: 'Start importing the component JS at page load and hydrate when the import completes, similar to client:load. The component will be skipped at build time, useful for components that are entirely dependent on client-side APIs. This is best avoided unless absolutely needed, in most cases it is best to render placeholder content on the server and delay any browser API calls until the component hydrates in the browser.',
|
||||
valueSet: 'v',
|
||||
references: [
|
||||
{
|
||||
name: 'Astro reference',
|
||||
url: 'https://docs.astro.build/en/reference/directives-reference/#clientonly',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
//# sourceMappingURL=html-data.js.map
|
||||
2
node_modules/@astrojs/language-server/dist/plugins/html.d.ts
generated
vendored
Normal file
2
node_modules/@astrojs/language-server/dist/plugins/html.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { LanguageServicePlugin } from '@volar/language-server';
|
||||
export declare const create: () => LanguageServicePlugin;
|
||||
93
node_modules/@astrojs/language-server/dist/plugins/html.js
generated
vendored
Normal file
93
node_modules/@astrojs/language-server/dist/plugins/html.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.create = void 0;
|
||||
const language_server_1 = require("@volar/language-server");
|
||||
const volar_service_html_1 = require("volar-service-html");
|
||||
const html = __importStar(require("vscode-html-languageservice"));
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const index_js_1 = require("../core/index.js");
|
||||
const html_data_js_1 = require("./html-data.js");
|
||||
const utils_js_1 = require("./utils.js");
|
||||
const create = () => {
|
||||
const htmlPlugin = (0, volar_service_html_1.create)({
|
||||
getCustomData: async (context) => {
|
||||
const customData = (await context.env.getConfiguration?.('html.customData')) ?? [];
|
||||
const newData = [];
|
||||
for (const customDataPath of customData) {
|
||||
for (const workspaceFolder of context.env.workspaceFolders) {
|
||||
const uri = vscode_uri_1.Utils.resolvePath(workspaceFolder, customDataPath);
|
||||
const json = await context.env.fs?.readFile?.(uri);
|
||||
if (json) {
|
||||
try {
|
||||
const data = JSON.parse(json);
|
||||
newData.push(html.newHTMLDataProvider(customDataPath, data));
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...newData, html_data_js_1.astroAttributes, html_data_js_1.astroElements, html_data_js_1.classListAttribute];
|
||||
},
|
||||
});
|
||||
return {
|
||||
...htmlPlugin,
|
||||
create(context) {
|
||||
const htmlPluginInstance = htmlPlugin.create(context);
|
||||
return {
|
||||
...htmlPluginInstance,
|
||||
async provideCompletionItems(document, position, completionContext, token) {
|
||||
if (document.languageId !== 'html')
|
||||
return;
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const root = sourceScript?.generated?.root;
|
||||
if (!(root instanceof index_js_1.AstroVirtualCode))
|
||||
return;
|
||||
// Don't return completions if the current node is a component
|
||||
if ((0, utils_js_1.isInComponentStartTag)(root.htmlDocument, document.offsetAt(position))) {
|
||||
return null;
|
||||
}
|
||||
const completions = await htmlPluginInstance.provideCompletionItems(document, position, completionContext, token);
|
||||
if (!completions) {
|
||||
return null;
|
||||
}
|
||||
// We don't want completions for file references, as they're mostly invalid for Astro
|
||||
completions.items = completions.items.filter((completion) => completion.kind !== language_server_1.CompletionItemKind.File);
|
||||
return completions;
|
||||
},
|
||||
// Document links provided by `vscode-html-languageservice` are invalid for Astro
|
||||
provideDocumentLinks() {
|
||||
return [];
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.create = create;
|
||||
//# sourceMappingURL=html.js.map
|
||||
2
node_modules/@astrojs/language-server/dist/plugins/typescript-addons/index.d.ts
generated
vendored
Normal file
2
node_modules/@astrojs/language-server/dist/plugins/typescript-addons/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { LanguageServicePlugin } from '@volar/language-server';
|
||||
export declare const create: () => LanguageServicePlugin;
|
||||
52
node_modules/@astrojs/language-server/dist/plugins/typescript-addons/index.js
generated
vendored
Normal file
52
node_modules/@astrojs/language-server/dist/plugins/typescript-addons/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.create = void 0;
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const index_js_1 = require("../../core/index.js");
|
||||
const utils_js_1 = require("../utils.js");
|
||||
const snippets_js_1 = require("./snippets.js");
|
||||
const create = () => {
|
||||
return {
|
||||
capabilities: {
|
||||
completionProvider: {
|
||||
resolveProvider: true,
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
isAdditionalCompletion: true,
|
||||
// Q: Why the empty transform and resolve functions?
|
||||
// A: Volar will skip mapping the completion items if those functions are defined, as such we can return the snippets
|
||||
// completions as-is, this is notably useful for snippets that insert to the frontmatter, since we don't need to map anything.
|
||||
transformCompletionItem(item) {
|
||||
return item;
|
||||
},
|
||||
provideCompletionItems(document, position, completionContext, token) {
|
||||
if (!context ||
|
||||
!utils_js_1.isJSDocument ||
|
||||
token.isCancellationRequested ||
|
||||
completionContext.triggerKind === 2)
|
||||
return null;
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const root = sourceScript?.generated?.root;
|
||||
if (!(root instanceof index_js_1.AstroVirtualCode))
|
||||
return undefined;
|
||||
if (!(0, utils_js_1.isInsideFrontmatter)(document.offsetAt(position), root.astroMeta.frontmatter))
|
||||
return null;
|
||||
const completionList = {
|
||||
items: [],
|
||||
isIncomplete: false,
|
||||
};
|
||||
completionList.items.push(...(0, snippets_js_1.getSnippetCompletions)(root.astroMeta.frontmatter));
|
||||
return completionList;
|
||||
},
|
||||
resolveCompletionItem(item) {
|
||||
return item;
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.create = create;
|
||||
//# sourceMappingURL=index.js.map
|
||||
3
node_modules/@astrojs/language-server/dist/plugins/typescript-addons/snippets.d.ts
generated
vendored
Normal file
3
node_modules/@astrojs/language-server/dist/plugins/typescript-addons/snippets.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type CompletionItem } from '@volar/language-server';
|
||||
import type { FrontmatterStatus } from '../../core/parseAstro.js';
|
||||
export declare function getSnippetCompletions(frontmatter: FrontmatterStatus): CompletionItem[];
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user