Skip to content

Commit

Permalink
chore(deps): update glimmer to v0.91.1 (#16171)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: fisker <lionkay@gmail.com>
  • Loading branch information
renovate[bot] and fisker committed May 6, 2024
1 parent 77d9bcf commit 36bdf95
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 101 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -34,7 +34,7 @@
"@babel/code-frame": "7.24.2",
"@babel/parser": "7.24.4",
"@babel/types": "7.24.0",
"@glimmer/syntax": "0.88.1",
"@glimmer/syntax": "0.91.1",
"@iarna/toml": "2.2.5",
"@prettier/is-es5-identifier-name": "0.2.0",
"@prettier/parse-srcset": "3.1.0",
Expand Down Expand Up @@ -109,7 +109,7 @@
"@babel/generator": "7.24.4",
"@eslint/eslintrc": "3.0.2",
"@eslint/js": "8.57.0",
"@glimmer/reference": "0.88.1",
"@glimmer/reference": "0.91.1",
"@stylistic/eslint-plugin-js": "1.7.0",
"@types/eslint__js": "8.42.3",
"@types/estree": "1.0.5",
Expand Down
9 changes: 8 additions & 1 deletion src/language-handlebars/clean.js
Expand Up @@ -12,13 +12,20 @@ function clean(original, cloned /*, parent*/) {

if (original.type === "ElementNode") {
delete cloned.startTag;
delete cloned.openTag;
delete cloned.parts;
delete cloned.endTag;
delete cloned.closeTag;
delete cloned.nameNode;
delete cloned.body;
delete cloned.blockParamNodes;
delete cloned.params;
delete cloned.path;
}

if (original.type === "Block" || original.type === "ElementNode") {
if (original.type === "Block") {
delete cloned.blockParamNodes;
delete cloned.params;
}

// `class` is reformatted
Expand Down
26 changes: 16 additions & 10 deletions src/language-handlebars/printer-glimmer.js
Expand Up @@ -449,13 +449,13 @@ function printStartingTagEndMarker(node) {
/* MustacheStatement print helpers */

function printOpeningMustache(node) {
const mustache = node.escaped === false ? "{{{" : "{{";
const mustache = node.trusting ? "{{{" : "{{";
const strip = node.strip?.open ? "~" : "";
return [mustache, strip];
}

function printClosingMustache(node) {
const mustache = node.escaped === false ? "}}}" : "}}";
const mustache = node.trusting ? "}}}" : "}}";
const strip = node.strip?.close ? "~" : "";
return [strip, mustache];
}
Expand Down Expand Up @@ -530,20 +530,25 @@ function printElseBlock(node, options) {
];
}

const isPathWithSameHead = (pathA, pathB) =>
pathA.head.type === "VarHead" &&
pathB.head.type === "VarHead" &&
pathA.head.name === pathB.head.name;

function isElseIfLike(path) {
const { grandparent, node } = path;
return (
grandparent?.inverse?.body.length === 1 &&
grandparent.inverse.body[0] === node &&
grandparent.inverse.body[0].path.parts[0] === grandparent.path.parts[0]
isPathWithSameHead(grandparent.inverse.body[0].path, grandparent.path)
);
}

function printElseIfLikeBlock(path, print) {
const { node, grandparent } = path;
return group([
printInverseBlockOpeningMustache(grandparent),
["else", " ", grandparent.inverse.body[0].path.parts[0]],
["else", " ", grandparent.inverse.body[0].path.head.name],
indent([
line,
group(printParams(path, print)),
Expand Down Expand Up @@ -591,7 +596,7 @@ function blockStatementHasElseIfLike(node) {
blockStatementHasElse(node) &&
node.inverse.body.length === 1 &&
node.inverse.body[0].type === "BlockStatement" &&
node.inverse.body[0].path.parts[0] === node.path.parts[0]
isPathWithSameHead(node.inverse.body[0].path, node.path)
);
}

Expand Down Expand Up @@ -781,17 +786,18 @@ const isPathExpressionPartNeedBrackets = (part, index) =>
Array.prototype.some.call(part, (character) =>
PATH_EXPRESSION_FORBIDDEN_CHARACTERS.has(character),
);
// TODO[@fisker]: Print `head` via `print`
function printPathExpression(node) {
if (node.data || (node.parts.length === 1 && node.original.includes("/"))) {
if (
node.head.type === "AtHead" ||
(node.tail.length === 0 && node.original.includes("/"))
) {
// check if node has data, or
// check if node is a legacy path expression (and leave it alone)
return node.original;
}

let { parts } = node;
if (node.this) {
parts = ["this", ...parts];
}
const parts = [node.head.original, ...node.tail];

return parts
.map((part, index) =>
Expand Down
21 changes: 7 additions & 14 deletions src/language-handlebars/visitor-keys.evaluate.js
@@ -1,18 +1,11 @@
import { visitorKeys as glimmerVisitorKeys } from "@glimmer/syntax";

const {
// These node types presents on `ElementNode`, but we don't care about them
// https://github.com/glimmerjs/glimmer-vm/pull/1553
ElementStartNode, // `ElementNode.startTag`
ElementPartNode, // `ElementNode.parts`
ElementEndNode, // `ElementNode.endTag`
ElementNameNode, // `ElementNode.nameNode`

// This presents on `{Block,ElementNode}.blockParamNodes`, but we don't care about them
// https://github.com/glimmerjs/glimmer-vm/pull/1552
BlockParam,

...visitorKeys
} = glimmerVisitorKeys;
const visitorKeys = {
VarHead: [],
ThisHead: [],
AtHead: [],
...glimmerVisitorKeys,
PathExpression: [...glimmerVisitorKeys.PathExpression, "head"],
};

export default visitorKeys;
Expand Up @@ -39,7 +39,6 @@ printWidth: 80
=====================================input======================================
<div>
{{array.[true]}}
{{[dot.]}}
{{array.2.[@#].[1]}}
{{array.2.[a b]}}
{{this.test}}
Expand All @@ -52,7 +51,6 @@ printWidth: 80
=====================================output=====================================
<div>
{{array.[true]}}
{{[dot.]}}
{{array.[2].[@#].[1]}}
{{array.[2].[a b]}}
{{this.test}}
Expand Down
@@ -1,6 +1,5 @@
<div>
{{array.[true]}}
{{[dot.]}}
{{array.2.[@#].[1]}}
{{array.2.[a b]}}
{{this.test}}
Expand Down
33 changes: 5 additions & 28 deletions tests/unit/__snapshots__/visitor-keys.js.snap
Expand Up @@ -1158,6 +1158,7 @@ exports[`visitor keys estree-json 1`] = `

exports[`visitor keys glimmer 1`] = `
{
"AtHead": [],
"AttrNode": [
"value",
],
Expand All @@ -1173,13 +1174,6 @@ exports[`visitor keys glimmer 1`] = `
],
"BooleanLiteral": [],
"CommentStatement": [],
"Component": [
"head",
"attributes",
"modifiers",
"children",
"comments",
],
"ConcatStatement": [
"parts",
],
Expand All @@ -1206,29 +1200,10 @@ exports[`visitor keys glimmer 1`] = `
"params",
"hash",
],
"NamedBlock": [
"attributes",
"modifiers",
"children",
"comments",
],
"NullLiteral": [],
"NumberLiteral": [],
"PartialStatement": [
"name",
"params",
"hash",
],
"PathExpression": [],
"PathHead": [],
"Program": [
"body",
],
"SimpleElement": [
"attributes",
"modifiers",
"children",
"comments",
"PathExpression": [
"head",
],
"StringLiteral": [],
"SubExpression": [
Expand All @@ -1240,7 +1215,9 @@ exports[`visitor keys glimmer 1`] = `
"body",
],
"TextNode": [],
"ThisHead": [],
"UndefinedLiteral": [],
"VarHead": [],
}
`;

Expand Down
86 changes: 43 additions & 43 deletions yarn.lock
Expand Up @@ -1138,77 +1138,77 @@ __metadata:
languageName: node
linkType: hard

"@glimmer/global-context@npm:^0.88.1":
version: 0.88.1
resolution: "@glimmer/global-context@npm:0.88.1"
checksum: 10/2785843ab8c8c70dbb1fa55b9d39e55945c1896c27be3f58d18f8a09c330d584681cbe5792fc74f72a5d348954803ed12d11cdfde55c4b4c248dcda347f5f6a2
"@glimmer/global-context@npm:^0.91.1":
version: 0.91.1
resolution: "@glimmer/global-context@npm:0.91.1"
checksum: 10/2d9c9ebedf3ac88ef2cb60cf1f2fc9848c169d3d62517164b315c53585334b85146335f00d64278333505d68cab81ebfe8eea0c6c515efe3b2b2aeaa3f667778
languageName: node
linkType: hard

"@glimmer/interfaces@npm:^0.88.1":
version: 0.88.1
resolution: "@glimmer/interfaces@npm:0.88.1"
"@glimmer/interfaces@npm:^0.91.1":
version: 0.91.1
resolution: "@glimmer/interfaces@npm:0.91.1"
dependencies:
"@simple-dom/interface": "npm:^1.4.0"
checksum: 10/94f74ae8487135c0109eddf20b03b7fdf16214872688dec4f891682d55255b04897f50495e70c21f3363d8f2da8d2dfc1e7003acb32ec9dabfacaeac81345fd7
checksum: 10/0ba49e922a3b17b57318b2625cae30d1194d5bf29e0503bd0e856b2b011e684da6dfb949f3fbc2b1d3434b5e23522086dc2cd56aab55d04400bbea0827d63612
languageName: node
linkType: hard

"@glimmer/reference@npm:0.88.1":
version: 0.88.1
resolution: "@glimmer/reference@npm:0.88.1"
"@glimmer/reference@npm:0.91.1":
version: 0.91.1
resolution: "@glimmer/reference@npm:0.91.1"
dependencies:
"@glimmer/env": "npm:^0.1.7"
"@glimmer/global-context": "npm:^0.88.1"
"@glimmer/interfaces": "npm:^0.88.1"
"@glimmer/util": "npm:^0.88.1"
"@glimmer/validator": "npm:^0.88.1"
checksum: 10/f9c066c346ed1558c8f4c8388ae83cb393878efc1de32d78654b6fea790f29ac6a466d0e73f2eed1c5bf0ca193779d8c49e3e2c9f9191fedf4dbc64bf1d8f19e
"@glimmer/global-context": "npm:^0.91.1"
"@glimmer/interfaces": "npm:^0.91.1"
"@glimmer/util": "npm:^0.91.1"
"@glimmer/validator": "npm:^0.91.1"
checksum: 10/b336b51ce8e69007bccc218ab0f9e8d540190aeb06746a1eba80033751a69fd0f67e96d0549115848ccc31f0e04e9ffa926ef4c459736e16fa185604c313d9b8
languageName: node
linkType: hard

"@glimmer/syntax@npm:0.88.1":
version: 0.88.1
resolution: "@glimmer/syntax@npm:0.88.1"
"@glimmer/syntax@npm:0.91.1":
version: 0.91.1
resolution: "@glimmer/syntax@npm:0.91.1"
dependencies:
"@glimmer/interfaces": "npm:^0.88.1"
"@glimmer/util": "npm:^0.88.1"
"@glimmer/wire-format": "npm:^0.88.1"
"@glimmer/interfaces": "npm:^0.91.1"
"@glimmer/util": "npm:^0.91.1"
"@glimmer/wire-format": "npm:^0.91.1"
"@handlebars/parser": "npm:~2.0.0"
simple-html-tokenizer: "npm:^0.5.11"
checksum: 10/896c9cdfe9a606809782c18fc77839aa9d544be1d8cc67706e7af717ab0117f664bc36cd9f1da34c6474a6ba49efc16b1e7552ec15c522e4a70be603fd429c98
checksum: 10/2f286a3f6a976b9c485925226576f78ac6174a8d964791e859034c5010d5800bad2d097e424ae5dc1096fb2ef62b10d822347387feda05edaad619fa33ffd5c1
languageName: node
linkType: hard

"@glimmer/util@npm:^0.88.1":
version: 0.88.1
resolution: "@glimmer/util@npm:0.88.1"
"@glimmer/util@npm:^0.91.1":
version: 0.91.1
resolution: "@glimmer/util@npm:0.91.1"
dependencies:
"@glimmer/env": "npm:0.1.7"
"@glimmer/interfaces": "npm:^0.88.1"
checksum: 10/06947142bd87cbc01aeb9b86a1317fea01b80a7f373b98b1ed4ef55316d82c70526a45dfb15e1ffd4fc9c1802ba0b8493e14978370786dcacd69c695664319ec
"@glimmer/interfaces": "npm:^0.91.1"
checksum: 10/b4717a5c709519825a6c189ccc8fc02a96f87825e9511c6c28c9d2d9903e160052e9796e22411b441d46d56e50e36ca2d9d8c00bbd7fdf9f48698d939e8ce357
languageName: node
linkType: hard

"@glimmer/validator@npm:^0.88.1":
version: 0.88.1
resolution: "@glimmer/validator@npm:0.88.1"
"@glimmer/validator@npm:^0.91.1":
version: 0.91.1
resolution: "@glimmer/validator@npm:0.91.1"
dependencies:
"@glimmer/env": "npm:^0.1.7"
"@glimmer/global-context": "npm:^0.88.1"
"@glimmer/interfaces": "npm:^0.88.1"
"@glimmer/util": "npm:^0.88.1"
checksum: 10/14d096ddd53362c479aa39437c6354c5b3fda90bbb89188c1cb7a45d5132303dea2c62c246f00499551df42bc1b0debe21d213a7ed5151ef7cd8fbd00927fea2
"@glimmer/global-context": "npm:^0.91.1"
"@glimmer/interfaces": "npm:^0.91.1"
"@glimmer/util": "npm:^0.91.1"
checksum: 10/866f51a7c25b2facf0269768fc0311c9d7757ad1c4730fa9ef71fe20c9b5ee519b2f92991837b2ec3de5b4e83b27a68008492d501f29842a41f936363aebc1dc
languageName: node
linkType: hard

"@glimmer/wire-format@npm:^0.88.1":
version: 0.88.1
resolution: "@glimmer/wire-format@npm:0.88.1"
"@glimmer/wire-format@npm:^0.91.1":
version: 0.91.1
resolution: "@glimmer/wire-format@npm:0.91.1"
dependencies:
"@glimmer/interfaces": "npm:^0.88.1"
"@glimmer/util": "npm:^0.88.1"
checksum: 10/7b01317cb84e2a51dbb9e7eb6cf29cb3740c0df59f9602e98393f727cb908ef8d08a575d2bb9d824722a6d0905dfd78fe9857ceb8b4e168fc0f5cbbca2e36bb4
"@glimmer/interfaces": "npm:^0.91.1"
"@glimmer/util": "npm:^0.91.1"
checksum: 10/e42f13cafc4953ff23d690acebfc677dc86bb2429bede12e558b181a43e8c3e670173f683b5d18c6d5b9b47d6c56130122c8e3a7f45f219ae00257611b0a8a4f
languageName: node
linkType: hard

Expand Down Expand Up @@ -7398,8 +7398,8 @@ __metadata:
"@babel/types": "npm:7.24.0"
"@eslint/eslintrc": "npm:3.0.2"
"@eslint/js": "npm:8.57.0"
"@glimmer/reference": "npm:0.88.1"
"@glimmer/syntax": "npm:0.88.1"
"@glimmer/reference": "npm:0.91.1"
"@glimmer/syntax": "npm:0.91.1"
"@iarna/toml": "npm:2.2.5"
"@prettier/is-es5-identifier-name": "npm:0.2.0"
"@prettier/parse-srcset": "npm:3.1.0"
Expand Down

0 comments on commit 36bdf95

Please sign in to comment.