@fluid-app/fluid-cli-theme-dev 0.1.599 → 0.1.600
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/dist/index.mjs +97 -95
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1831,6 +1831,103 @@ function isRecord$5(entry) {
|
|
|
1831
1831
|
return typeof entry === "object" && entry !== null && !Array.isArray(entry);
|
|
1832
1832
|
}
|
|
1833
1833
|
//#endregion
|
|
1834
|
+
//#region ../../platform/theme-schema/src/liquid-blocks.ts
|
|
1835
|
+
const BLOCK_TAGS = new Map([
|
|
1836
|
+
["capture", "endcapture"],
|
|
1837
|
+
["case", "endcase"],
|
|
1838
|
+
["comment", "endcomment"],
|
|
1839
|
+
["for", "endfor"],
|
|
1840
|
+
["form", "endform"],
|
|
1841
|
+
["if", "endif"],
|
|
1842
|
+
["ifchanged", "endifchanged"],
|
|
1843
|
+
["javascript", "endjavascript"],
|
|
1844
|
+
["paginate", "endpaginate"],
|
|
1845
|
+
["raw", "endraw"],
|
|
1846
|
+
["schema", "endschema"],
|
|
1847
|
+
["style", "endstyle"],
|
|
1848
|
+
["stylesheet", "endstylesheet"],
|
|
1849
|
+
["tablerow", "endtablerow"],
|
|
1850
|
+
["unless", "endunless"]
|
|
1851
|
+
]);
|
|
1852
|
+
const CLOSING_TAGS = new Set(BLOCK_TAGS.values());
|
|
1853
|
+
const OPAQUE_BLOCK_TAGS = new Set([
|
|
1854
|
+
"comment",
|
|
1855
|
+
"javascript",
|
|
1856
|
+
"raw",
|
|
1857
|
+
"schema",
|
|
1858
|
+
"style",
|
|
1859
|
+
"stylesheet"
|
|
1860
|
+
]);
|
|
1861
|
+
/**
|
|
1862
|
+
* Find structurally unbalanced Liquid block tags such as an `{% if %}` with
|
|
1863
|
+
* no `{% endif %}`. This intentionally recognizes only established paired
|
|
1864
|
+
* tags; custom and inline tags are ignored rather than guessed at.
|
|
1865
|
+
*
|
|
1866
|
+
* Content inside raw/comment/schema/style/javascript blocks is opaque to
|
|
1867
|
+
* Liquid and therefore skipped until that block's matching close tag. This
|
|
1868
|
+
* prevents CSS, JSON, and examples containing Liquid-looking text from
|
|
1869
|
+
* producing false errors.
|
|
1870
|
+
*/
|
|
1871
|
+
function findLiquidBlockTagDiagnostics(content) {
|
|
1872
|
+
const stack = [];
|
|
1873
|
+
const diagnostics = [];
|
|
1874
|
+
let line = 1;
|
|
1875
|
+
let previousTagIndex = 0;
|
|
1876
|
+
const processTag = (name, tagLine) => {
|
|
1877
|
+
const open = stack.at(-1);
|
|
1878
|
+
if (open && OPAQUE_BLOCK_TAGS.has(open.name)) {
|
|
1879
|
+
if (name === open.expectedClose) stack.pop();
|
|
1880
|
+
return;
|
|
1881
|
+
}
|
|
1882
|
+
const expectedClose = BLOCK_TAGS.get(name);
|
|
1883
|
+
if (expectedClose) {
|
|
1884
|
+
stack.push({
|
|
1885
|
+
name,
|
|
1886
|
+
expectedClose,
|
|
1887
|
+
line: tagLine
|
|
1888
|
+
});
|
|
1889
|
+
return;
|
|
1890
|
+
}
|
|
1891
|
+
if (!CLOSING_TAGS.has(name)) return;
|
|
1892
|
+
if (!open) {
|
|
1893
|
+
diagnostics.push({
|
|
1894
|
+
severity: "error",
|
|
1895
|
+
message: `Unexpected Liquid tag '{% ${name} %}' on line ${tagLine}; there is no open block to close.`
|
|
1896
|
+
});
|
|
1897
|
+
return;
|
|
1898
|
+
}
|
|
1899
|
+
if (name !== open.expectedClose) {
|
|
1900
|
+
diagnostics.push({
|
|
1901
|
+
severity: "error",
|
|
1902
|
+
message: `Mismatched Liquid tag '{% ${name} %}' on line ${tagLine}; '{% ${open.name} %}' from line ${open.line} must close with '{% ${open.expectedClose} %}'.`
|
|
1903
|
+
});
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
stack.pop();
|
|
1907
|
+
};
|
|
1908
|
+
for (const match of content.matchAll(/\{%-?\s*([a-zA-Z_][\w-]*)\b(?:(?!\{%)[\s\S])*?-?%\}/g)) {
|
|
1909
|
+
const name = match[1]?.toLowerCase();
|
|
1910
|
+
if (!name) continue;
|
|
1911
|
+
const index = match.index ?? 0;
|
|
1912
|
+
for (let cursor = previousTagIndex; cursor < index; cursor++) if (content.charCodeAt(cursor) === 10) line += 1;
|
|
1913
|
+
previousTagIndex = index;
|
|
1914
|
+
const open = stack.at(-1);
|
|
1915
|
+
if (name === "liquid" && !(open && OPAQUE_BLOCK_TAGS.has(open.name))) {
|
|
1916
|
+
const statements = match[0].replace(/^\{%-?\s*liquid\b/i, "").replace(/-?%\}$/, "").split("\n");
|
|
1917
|
+
for (const [offset, statement] of statements.entries()) {
|
|
1918
|
+
const statementName = /^\s*([a-zA-Z_][\w-]*)\b/.exec(statement)?.[1];
|
|
1919
|
+
if (!statementName) continue;
|
|
1920
|
+
processTag(statementName.toLowerCase(), line + offset);
|
|
1921
|
+
}
|
|
1922
|
+
} else processTag(name, line);
|
|
1923
|
+
}
|
|
1924
|
+
for (const open of stack.reverse()) diagnostics.push({
|
|
1925
|
+
severity: "error",
|
|
1926
|
+
message: `Unclosed Liquid tag '{% ${open.name} %}' on line ${open.line}; expected '{% ${open.expectedClose} %}'.`
|
|
1927
|
+
});
|
|
1928
|
+
return diagnostics;
|
|
1929
|
+
}
|
|
1930
|
+
//#endregion
|
|
1834
1931
|
//#region src/theme/file.ts
|
|
1835
1932
|
const NON_TEMPLATE_DIRS = new Set([
|
|
1836
1933
|
"sections",
|
|
@@ -4276,101 +4373,6 @@ function hasUnbalancedLiquidDelimiters(content) {
|
|
|
4276
4373
|
}
|
|
4277
4374
|
return unclosedTags > 0 || unclosedOutputs > 0;
|
|
4278
4375
|
}
|
|
4279
|
-
const BLOCK_TAGS = new Map([
|
|
4280
|
-
["capture", "endcapture"],
|
|
4281
|
-
["case", "endcase"],
|
|
4282
|
-
["comment", "endcomment"],
|
|
4283
|
-
["for", "endfor"],
|
|
4284
|
-
["form", "endform"],
|
|
4285
|
-
["if", "endif"],
|
|
4286
|
-
["ifchanged", "endifchanged"],
|
|
4287
|
-
["javascript", "endjavascript"],
|
|
4288
|
-
["paginate", "endpaginate"],
|
|
4289
|
-
["raw", "endraw"],
|
|
4290
|
-
["schema", "endschema"],
|
|
4291
|
-
["style", "endstyle"],
|
|
4292
|
-
["stylesheet", "endstylesheet"],
|
|
4293
|
-
["tablerow", "endtablerow"],
|
|
4294
|
-
["unless", "endunless"]
|
|
4295
|
-
]);
|
|
4296
|
-
const CLOSING_TAGS = new Set(BLOCK_TAGS.values());
|
|
4297
|
-
const OPAQUE_BLOCK_TAGS = new Set([
|
|
4298
|
-
"comment",
|
|
4299
|
-
"javascript",
|
|
4300
|
-
"raw",
|
|
4301
|
-
"schema",
|
|
4302
|
-
"style",
|
|
4303
|
-
"stylesheet"
|
|
4304
|
-
]);
|
|
4305
|
-
/**
|
|
4306
|
-
* Find structurally unbalanced Liquid block tags such as an `{% if %}` with
|
|
4307
|
-
* no `{% endif %}`. This intentionally recognizes only established paired
|
|
4308
|
-
* tags; custom and inline tags are ignored rather than guessed at.
|
|
4309
|
-
*
|
|
4310
|
-
* Content inside raw/comment/schema/style/javascript blocks is opaque to
|
|
4311
|
-
* Liquid and therefore skipped until that block's matching close tag. This
|
|
4312
|
-
* prevents CSS, JSON, and examples containing Liquid-looking text from
|
|
4313
|
-
* producing false errors.
|
|
4314
|
-
*/
|
|
4315
|
-
function findLiquidBlockTagDiagnostics(content) {
|
|
4316
|
-
const stack = [];
|
|
4317
|
-
const diagnostics = [];
|
|
4318
|
-
let line = 1;
|
|
4319
|
-
let previousTagIndex = 0;
|
|
4320
|
-
const processTag = (name, tagLine) => {
|
|
4321
|
-
const open = stack.at(-1);
|
|
4322
|
-
if (open && OPAQUE_BLOCK_TAGS.has(open.name)) {
|
|
4323
|
-
if (name === open.expectedClose) stack.pop();
|
|
4324
|
-
return;
|
|
4325
|
-
}
|
|
4326
|
-
const expectedClose = BLOCK_TAGS.get(name);
|
|
4327
|
-
if (expectedClose) {
|
|
4328
|
-
stack.push({
|
|
4329
|
-
name,
|
|
4330
|
-
expectedClose,
|
|
4331
|
-
line: tagLine
|
|
4332
|
-
});
|
|
4333
|
-
return;
|
|
4334
|
-
}
|
|
4335
|
-
if (!CLOSING_TAGS.has(name)) return;
|
|
4336
|
-
if (!open) {
|
|
4337
|
-
diagnostics.push({
|
|
4338
|
-
severity: "error",
|
|
4339
|
-
message: `Unexpected Liquid tag '{% ${name} %}' on line ${tagLine}; there is no open block to close.`
|
|
4340
|
-
});
|
|
4341
|
-
return;
|
|
4342
|
-
}
|
|
4343
|
-
if (name !== open.expectedClose) {
|
|
4344
|
-
diagnostics.push({
|
|
4345
|
-
severity: "error",
|
|
4346
|
-
message: `Mismatched Liquid tag '{% ${name} %}' on line ${tagLine}; '{% ${open.name} %}' from line ${open.line} must close with '{% ${open.expectedClose} %}'.`
|
|
4347
|
-
});
|
|
4348
|
-
return;
|
|
4349
|
-
}
|
|
4350
|
-
stack.pop();
|
|
4351
|
-
};
|
|
4352
|
-
for (const match of content.matchAll(/\{%-?\s*([a-zA-Z_][\w-]*)\b(?:(?!\{%)[\s\S])*?-?%\}/g)) {
|
|
4353
|
-
const name = match[1]?.toLowerCase();
|
|
4354
|
-
if (!name) continue;
|
|
4355
|
-
const index = match.index ?? 0;
|
|
4356
|
-
for (let cursor = previousTagIndex; cursor < index; cursor++) if (content.charCodeAt(cursor) === 10) line += 1;
|
|
4357
|
-
previousTagIndex = index;
|
|
4358
|
-
const open = stack.at(-1);
|
|
4359
|
-
if (name === "liquid" && !(open && OPAQUE_BLOCK_TAGS.has(open.name))) {
|
|
4360
|
-
const statements = match[0].replace(/^\{%-?\s*liquid\b/i, "").replace(/-?%\}$/, "").split("\n");
|
|
4361
|
-
for (const [offset, statement] of statements.entries()) {
|
|
4362
|
-
const statementName = /^\s*([a-zA-Z_][\w-]*)\b/.exec(statement)?.[1];
|
|
4363
|
-
if (!statementName) continue;
|
|
4364
|
-
processTag(statementName.toLowerCase(), line + offset);
|
|
4365
|
-
}
|
|
4366
|
-
} else processTag(name, line);
|
|
4367
|
-
}
|
|
4368
|
-
for (const open of stack.reverse()) diagnostics.push({
|
|
4369
|
-
severity: "error",
|
|
4370
|
-
message: `Unclosed Liquid tag '{% ${open.name} %}' on line ${open.line}; expected '{% ${open.expectedClose} %}'.`
|
|
4371
|
-
});
|
|
4372
|
-
return diagnostics;
|
|
4373
|
-
}
|
|
4374
4376
|
//#endregion
|
|
4375
4377
|
//#region src/theme/dev-server/port-preflight.ts
|
|
4376
4378
|
/**
|