Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusMorton committed Jan 19, 2025
2 parents 453c5ab + 8977c78 commit 6bd0576
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 49 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/language-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## 1.4.14

### Patch Changes

- [#338](https://github.com/marko-js/language-server/pull/338) [`7226d59`](https://github.com/marko-js/language-server/commit/7226d5922e4c61e367e9e1fad2625fb836170a75) Thanks [@DylanPiercey](https://github.com/DylanPiercey)! - Avoid outputting `component` related code when targeting tags api.

- Updated dependencies [[`7226d59`](https://github.com/marko-js/language-server/commit/7226d5922e4c61e367e9e1fad2625fb836170a75)]:
- @marko/language-tools@2.5.13

## 1.4.13

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@marko/language-server",
"description": "Marko Language Server",
"version": "1.4.13",
"version": "1.4.14",
"bin": {
"marko-language-server": "./bin.js"
},
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
"dependencies": {
"@luxass/strip-json-comments": "^1.3.2",
"@marko/language-tools": "^2.5.12",
"@marko/language-tools": "^2.5.13",
"@marko/babel-utils": "^6.6.3",
"@marko/compiler": "^5.39.6",
"htmljs-parser": "^5.5.3",
Expand Down
6 changes: 6 additions & 0 deletions packages/language-tools/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @marko/language-tools

## 2.5.13

### Patch Changes

- [#338](https://github.com/marko-js/language-server/pull/338) [`7226d59`](https://github.com/marko-js/language-server/commit/7226d5922e4c61e367e9e1fad2625fb836170a75) Thanks [@DylanPiercey](https://github.com/DylanPiercey)! - Avoid outputting `component` related code when targeting tags api.

## 2.5.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/language-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@marko/language-tools",
"description": "Marko Language Tools",
"version": "2.5.12",
"version": "2.5.13",
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
"peerDependencies": {
"@marko/compiler": "^5.28.4"
Expand Down
80 changes: 45 additions & 35 deletions packages/language-tools/src/extractors/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ class ScriptExtractor {
#writeProgram(program: Node.Program) {
this.#writeCommentPragmas(program);

const componentFileName = getComponentFilename(this.#filename);
const componentFileName =
this.#api !== RuntimeAPI.tags
? getComponentFilename(this.#filename)
: undefined;
const inputType = this.#getInputType(program);
let componentClassBody: Range | undefined;

Expand Down Expand Up @@ -267,39 +270,41 @@ class ScriptExtractor {
}
}

if (isExternalComponentFile) {
if (this.#scriptLang === ScriptLang.ts) {
this.#extractor.write(
`import type Component from "${stripExt(
relativeImportPath(this.#filename, componentFileName),
)}";\n`,
);
if (this.#api !== RuntimeAPI.tags) {
if (isExternalComponentFile) {
if (this.#scriptLang === ScriptLang.ts) {
this.#extractor.write(
`import type Component from "${stripExt(
relativeImportPath(this.#filename, componentFileName),
)}";\n`,
);
} else {
this.#extractor.write(
`/** @typedef {import("${stripExt(
relativeImportPath(this.#filename, componentFileName),
)}") extends infer Component ? Component extends { default: infer Component } ? Component : Component : never} Component */\n`,
);
}
} else {
this.#extractor.write(
`/** @typedef {import("${stripExt(
relativeImportPath(this.#filename, componentFileName),
)}") extends infer Component ? Component extends { default: infer Component } ? Component : Component : never} Component */\n`,
);
}
} else {
const body = componentClassBody || " {}";
const body = componentClassBody || " {}";

if (this.#scriptLang === ScriptLang.ts) {
this.#extractor
.write(
`abstract class Component${typeParamsStr} extends Marko.Component<Input${typeArgsStr}>`,
)
.copy(body)
.write("\nexport { type Component }\n");
} else {
this.#extractor.write(`/**${jsDocTemplateTagsStr}
* @extends {Marko.Component<Input${typeArgsStr}>}
* @abstract
*/\n`);
this.#extractor
.write(`export class Component extends Marko.Component`)
.copy(body)
.write("\n");
if (this.#scriptLang === ScriptLang.ts) {
this.#extractor
.write(
`abstract class Component${typeParamsStr} extends Marko.Component<Input${typeArgsStr}>`,
)
.copy(body)
.write("\nexport { type Component }\n");
} else {
this.#extractor.write(`/**${jsDocTemplateTagsStr}
* @extends {Marko.Component<Input${typeArgsStr}>}
* @abstract
*/\n`);
this.#extractor
.write(`export class Component extends Marko.Component`)
.copy(body)
.write("\n");
}
}
}

Expand All @@ -322,16 +327,20 @@ function ${templateName}() {\n`);
}

this.#extractor.write(`\
const input = ${this.#getCastedType(`Input${typeArgsStr}`)};
const input = ${this.#getCastedType(`Input${typeArgsStr}`)};${
this.#api !== RuntimeAPI.tags
? `
const component = ${this.#getCastedType(`Component${typeArgsStr}`)};
const state = ${varShared("state")}(component);
const out = ${varShared("out")};`
: ""
}
const $signal = ${this.#getCastedType("AbortSignal")};
const $global = ${varShared("getGlobal")}(
// @ts-expect-error We expect the compiler to error because we are checking if the MarkoRun.Context is defined.
(${varShared("error")}, ${this.#getCastedType("MarkoRun.Context")})
);
const out = ${varShared("out")};
${varShared("noop")}({ input, component, state, out, $global, $signal });\n`);
${varShared("noop")}({ ${this.#api !== RuntimeAPI.tags ? "component, state, out, " : ""}input, $global, $signal });\n`);

const body = this.#processBody(program); // TODO: handle top level attribute tags.

Expand Down Expand Up @@ -973,6 +982,7 @@ constructor(_?: Return) {}
this.#extractor.write('"').copy(name).write('": ');

if (
this.#api !== RuntimeAPI.tags &&
typeof name !== "string" &&
this.#read(name).startsWith("on")
) {
Expand Down
9 changes: 9 additions & 0 deletions packages/type-check/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @marko/type-check

## 1.3.13

### Patch Changes

- [#338](https://github.com/marko-js/language-server/pull/338) [`7226d59`](https://github.com/marko-js/language-server/commit/7226d5922e4c61e367e9e1fad2625fb836170a75) Thanks [@DylanPiercey](https://github.com/DylanPiercey)! - Avoid outputting `component` related code when targeting tags api.

- Updated dependencies [[`7226d59`](https://github.com/marko-js/language-server/commit/7226d5922e4c61e367e9e1fad2625fb836170a75)]:
- @marko/language-tools@2.5.13

## 1.3.12

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/type-check/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@marko/type-check",
"description": "A CLI to type check Marko projects",
"version": "1.3.12",
"version": "1.3.13",
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
"dependencies": {
"@babel/code-frame": "^7.26.2",
"@luxass/strip-json-comments": "^1.3.2",
"@marko/language-tools": "^2.5.12",
"@marko/language-tools": "^2.5.13",
"arg": "^5.0.2",
"kleur": "^4.1.5",
"typescript": "^5.7.2"
Expand Down
6 changes: 6 additions & 0 deletions packages/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 1.5.14

### Patch Changes

- [#338](https://github.com/marko-js/language-server/pull/338) [`7226d59`](https://github.com/marko-js/language-server/commit/7226d5922e4c61e367e9e1fad2625fb836170a75) Thanks [@DylanPiercey](https://github.com/DylanPiercey)! - Avoid outputting `component` related code when targeting tags api.

## 1.5.13

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "marko-vscode",
"description": "Marko Syntax Highlighting, Pretty-printing, TypeScript, IntelliSense, and more",
"version": "1.5.13",
"version": "1.5.14",
"activationEvents": [
"workspaceContains:**/*.marko"
],
Expand Down Expand Up @@ -107,7 +107,7 @@
}
},
"devDependencies": {
"@marko/language-server": "^1.4.13",
"@marko/language-server": "^1.4.14",
"@types/vscode": "^1.80.0",
"@vscode/test-electron": "^2.4.1",
"@vscode/vsce": "^3.2.1",
Expand Down

0 comments on commit 6bd0576

Please sign in to comment.