@flint.fyi/vue-language 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +20 -0
- package/README.md +7 -43
- package/lib/extractTemplateDirectives.d.ts +4 -0
- package/lib/extractTemplateDirectives.js +38 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/language.d.ts +20 -0
- package/lib/language.js +50 -0
- package/lib/vueParsingErrorsToLanguageReports.d.ts +4 -0
- package/lib/vueParsingErrorsToLanguageReports.js +19 -0
- package/package.json +47 -8
package/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center"><code>@flint.fyi/vue-language</code></h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
[Experimental] Vue.js language for Flint.
|
|
5
|
+
❤️🔥
|
|
6
|
+
</p>
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
This package exists to:
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@flint.fyi/vue-language`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|
|
8
|
+
This is an internal package for Flint.
|
|
9
|
+
Documentation will eventually be added.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExtractedDirective } from "@flint.fyi/typescript-language";
|
|
2
|
+
import { type RootNode } from "@vue/compiler-dom";
|
|
3
|
+
export declare function extractTemplateDirectives(ast: RootNode): ExtractedDirective[];
|
|
4
|
+
//# sourceMappingURL=extractTemplateDirectives.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { nullThrows } from "@flint.fyi/utils";
|
|
2
|
+
import { NodeTypes } from "@vue/compiler-dom";
|
|
3
|
+
//#region src/extractTemplateDirectives.ts
|
|
4
|
+
function extractTemplateDirectives(ast) {
|
|
5
|
+
const directives = [];
|
|
6
|
+
function visitTemplate(elem) {
|
|
7
|
+
if (elem.type === NodeTypes.ELEMENT) {
|
|
8
|
+
for (const child of elem.children) visitTemplate(child);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (elem.type !== NodeTypes.COMMENT) return;
|
|
12
|
+
const match = /\s*flint-(\S+)(?:\s+(.+))?/.exec(elem.content);
|
|
13
|
+
if (match == null) return;
|
|
14
|
+
const [, type, selection] = match;
|
|
15
|
+
directives.push({
|
|
16
|
+
range: {
|
|
17
|
+
begin: {
|
|
18
|
+
column: elem.loc.start.column - 1,
|
|
19
|
+
line: elem.loc.start.line - 1,
|
|
20
|
+
raw: elem.loc.start.offset
|
|
21
|
+
},
|
|
22
|
+
end: {
|
|
23
|
+
column: elem.loc.end.column - 1,
|
|
24
|
+
line: elem.loc.end.line - 1,
|
|
25
|
+
raw: elem.loc.end.offset
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
selection: nullThrows(selection, "Expected RegExp to provide second capturing group"),
|
|
29
|
+
type: nullThrows(type, "Expected RegExp to provide first capturing group")
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
for (const child of ast.children) visitTemplate(child);
|
|
33
|
+
return directives;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { extractTemplateDirectives };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=extractTemplateDirectives.js.map
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as _flint_fyi_volar_language0 from "@flint.fyi/volar-language";
|
|
2
|
+
import { RootNode } from "@vue/compiler-dom";
|
|
3
|
+
import { VueVirtualCode, tsCodegen } from "@vue/language-core";
|
|
4
|
+
import * as _flint_fyi_typescript_language0 from "@flint.fyi/typescript-language";
|
|
5
|
+
import { Mapper } from "@volar/language-core";
|
|
6
|
+
|
|
7
|
+
//#region src/language.d.ts
|
|
8
|
+
interface VueServices {
|
|
9
|
+
vue: {
|
|
10
|
+
codegen: VueCodegen;
|
|
11
|
+
map: Mapper;
|
|
12
|
+
sfc: RootNode;
|
|
13
|
+
virtualCode: VueVirtualCode;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
type VueCodegen = typeof tsCodegen extends WeakMap<WeakKey, infer V> ? V : never;
|
|
17
|
+
declare const vueLanguage: _flint_fyi_volar_language0.Language<_flint_fyi_typescript_language0.TypeScriptNodesByName, Partial<VueServices> & _flint_fyi_typescript_language0.TypeScriptFileServices>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { vueLanguage };
|
|
20
|
+
//# sourceMappingURL=language.d.ts.map
|
package/lib/language.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { extractTemplateDirectives } from "./extractTemplateDirectives.js";
|
|
2
|
+
import { vueParsingErrorsToLanguageReports } from "./vueParsingErrorsToLanguageReports.js";
|
|
3
|
+
import { setTSExtraSupportedExtensions } from "@flint.fyi/ts-patch";
|
|
4
|
+
import { assert, nullThrows } from "@flint.fyi/utils";
|
|
5
|
+
import { createVolarBasedLanguage } from "@flint.fyi/volar-language";
|
|
6
|
+
import { NodeTypes, parse } from "@vue/compiler-dom";
|
|
7
|
+
import { VueVirtualCode, createParsedCommandLine, createParsedCommandLineByJson, createVueLanguagePlugin, tsCodegen } from "@vue/language-core";
|
|
8
|
+
//#region src/language.ts
|
|
9
|
+
setTSExtraSupportedExtensions([".vue"]);
|
|
10
|
+
const vueLanguage = createVolarBasedLanguage((ts, options) => {
|
|
11
|
+
const { configFilePath } = options.options;
|
|
12
|
+
const host = options.host ? {
|
|
13
|
+
...options.host,
|
|
14
|
+
useCaseSensitiveFileNames: options.host.useCaseSensitiveFileNames()
|
|
15
|
+
} : ts.sys;
|
|
16
|
+
const vueCompilerOptions = (typeof configFilePath === "string" ? createParsedCommandLine(ts, host, configFilePath.replaceAll("\\", "/")) : createParsedCommandLineByJson(ts, host, host.getCurrentDirectory(), {})).vueOptions;
|
|
17
|
+
return {
|
|
18
|
+
createFile({ data, serviceScript, sourceFile, sourceScript, volarLanguage }) {
|
|
19
|
+
const sourceText = sourceScript.snapshot.getText(0, sourceScript.snapshot.getLength());
|
|
20
|
+
const virtualCode = sourceScript.generated.root;
|
|
21
|
+
assert(virtualCode instanceof VueVirtualCode, "Expected sourceScript.generated.root to be VueServiceCode");
|
|
22
|
+
const codegen = nullThrows(tsCodegen.get(virtualCode.sfc), `tsCodegen for ${data.filePathAbsolute} is undefined`);
|
|
23
|
+
const map = volarLanguage.maps.get(serviceScript.code, sourceScript);
|
|
24
|
+
const sfcAst = parse(sourceText, {
|
|
25
|
+
comments: true,
|
|
26
|
+
expressionPlugins: ["typescript"],
|
|
27
|
+
onError: () => {},
|
|
28
|
+
parseMode: "html"
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
directives: extractTemplateDirectives(sfcAst),
|
|
32
|
+
extraContext: { vue: {
|
|
33
|
+
codegen,
|
|
34
|
+
map,
|
|
35
|
+
sfc: sfcAst,
|
|
36
|
+
virtualCode
|
|
37
|
+
} },
|
|
38
|
+
firstStatementPosition: sfcAst.children.find((c) => c.type !== NodeTypes.COMMENT)?.loc.start.offset ?? sourceText.length,
|
|
39
|
+
getLanguageReports() {
|
|
40
|
+
return vueParsingErrorsToLanguageReports(sourceFile.fileName.startsWith("./") ? sourceFile.fileName.slice(2) : sourceFile.fileName.slice(process.cwd().length + 1), virtualCode.vueSfc?.errors ?? []);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
languagePlugins: [createVueLanguagePlugin(ts, options.options, vueCompilerOptions, (id) => id)]
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
//#endregion
|
|
48
|
+
export { vueLanguage };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=language.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LanguageReports } from "@flint.fyi/core";
|
|
2
|
+
import type { CompilerError } from "@vue/compiler-dom";
|
|
3
|
+
export declare function vueParsingErrorsToLanguageReports(fileName: string, errors: (CompilerError | SyntaxError)[]): LanguageReports;
|
|
4
|
+
//# sourceMappingURL=vueParsingErrorsToLanguageReports.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/vueParsingErrorsToLanguageReports.ts
|
|
2
|
+
function vueParsingErrorsToLanguageReports(fileName, errors) {
|
|
3
|
+
return errors.map((error) => {
|
|
4
|
+
let code = "VUE";
|
|
5
|
+
let loc = "";
|
|
6
|
+
if ("code" in error) {
|
|
7
|
+
code += error.code.toString();
|
|
8
|
+
loc = error.loc != null ? `:${error.loc.start.line}:${error.loc.start.column}` : "";
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
code,
|
|
12
|
+
text: `${fileName}${loc} - ${code}: ${error.name} - ${error.message}`
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { vueParsingErrorsToLanguageReports };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=vueParsingErrorsToLanguageReports.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flint.fyi/vue-language",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
}
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "[Experimental] Vue.js language for Flint.",
|
|
5
|
+
"homepage": "https://flint.fyi",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/flint-fyi/flint.git",
|
|
9
|
+
"directory": "packages/vue-language"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "JoshuaKGoldberg",
|
|
14
|
+
"email": "npm@joshuakgoldberg.com"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": true,
|
|
17
|
+
"type": "module",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"lib/",
|
|
23
|
+
"!lib/**/*.map"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@volar/language-core": "2.4.28",
|
|
27
|
+
"@vue/compiler-dom": "^3.5.0",
|
|
28
|
+
"@vue/language-core": "3.2.1",
|
|
29
|
+
"typescript": "^5.9.0 || ^6.0.0",
|
|
30
|
+
"@flint.fyi/ts-patch": "^0.13.5",
|
|
31
|
+
"@flint.fyi/utils": "^0.14.1",
|
|
32
|
+
"@flint.fyi/typescript-language": "^0.18.0",
|
|
33
|
+
"@flint.fyi/volar-language": "^0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"tsdown": "0.21.0",
|
|
37
|
+
"vitest": "4.1.0",
|
|
38
|
+
"@flint.fyi/core": "^0.21.0"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=24.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"test": "vitest --project vue-language"
|
|
48
|
+
}
|
|
49
|
+
}
|