forgecad 0.9.16 → 0.10.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/dist/assets/{AdminPage-CXvls4-J.js → AdminPage-DwYHz72L.js} +1 -1
- package/dist/assets/{BenchmarkPage-B27zk8xL.js → BenchmarkPage-a9_f-1US.js} +1 -1
- package/dist/assets/{BlogPage-CMAVvgQL.js → BlogPage-DodHpvmf.js} +1 -1
- package/dist/assets/{DocsPage-knf4I4h7.js → DocsPage-B5LePEuj.js} +8 -858
- package/dist/assets/EditorApp-QXsAISLR.js +16307 -0
- package/dist/assets/{EmbedViewer-D7ZGlFjx.js → EmbedViewer-DdEHGUMU.js} +2 -2
- package/dist/assets/{LandingPageProofDriven-CnevhTE8.js → LandingPageProofDriven-yhhOodbf.js} +1 -1
- package/dist/assets/{LegalPage-BPTUmqeg.js → LegalPage-5RbKRGYK.js} +1 -1
- package/dist/assets/{PricingPage-B0D4goG_.js → PricingPage-E3Rma7aV.js} +1 -1
- package/dist/assets/{SettingsPage-CFF-UgjI.js → SettingsPage-BJZcM97j.js} +1 -1
- package/dist/assets/{app-T0pDcSX4.js → app-DSYrDg0V.js} +733 -205
- package/dist/assets/cli/{render-C5pcIISc.js → render-ZMHR9HkV.js} +19 -46
- package/dist/assets/{constructionHistoryWorker-Ba2Hm58b.js → constructionHistoryWorker-AwMMWSxg.js} +1103 -349
- package/dist/assets/{evalWorker-vkx310U2.js → evalWorker-DbNs7Dkp.js} +3798 -1622
- package/dist/assets/{inspectWorker-BuTJDVX6.js → inspectWorker-CZsCFtQT.js} +1163 -409
- package/dist/assets/{jointPose-B_Cgedn9.js → jointPose-DO6mnXn_.js} +1 -1
- package/dist/assets/{manifold-BWgsjmAM.js → manifold-BGlQBBH9.js} +1 -1
- package/dist/assets/{manifold-rZexZI0G.js → manifold-BU-tJwQh.js} +1 -1
- package/dist/assets/{manifold-D6IFSkhH.js → manifold-fy2MV7K1.js} +2 -2
- package/dist/assets/{reportWorker-0AGij1Ru.js → reportWorker-DO6hcQbh.js} +7155 -2437
- package/dist/assets/{scalar-sampling-budget-J5cuzxT1.js → scalar-sampling-budget-o90NSNmF.js} +3940 -1742
- package/dist/assets/{scanProxyWorker-Vl4Wxa1y.js → scanProxyWorker-2GtDLk-R.js} +1 -1
- package/dist/assets/{javascript-1kQXfVaz.js → typescript-DBQ6RN5l.js} +874 -22
- package/dist/cli/render.html +1 -1
- package/dist/docs/index.html +3 -3
- package/dist/docs-raw/AI/usage.md +1 -1
- package/dist/docs-raw/CLI.md +63 -241
- package/dist/docs-raw/README.md +6 -0
- package/dist/docs-raw/component-model.md +17 -150
- package/dist/docs-raw/generated/assembly.md +139 -598
- package/dist/docs-raw/generated/concepts.md +245 -3501
- package/dist/docs-raw/generated/core.md +277 -1251
- package/dist/docs-raw/generated/curves.md +387 -1608
- package/dist/docs-raw/generated/legacy.md +162 -0
- package/dist/docs-raw/generated/lib.md +227 -85
- package/dist/docs-raw/generated/output.md +38 -73
- package/dist/docs-raw/generated/runtime-names.md +23 -23
- package/dist/docs-raw/generated/sdf.md +68 -284
- package/dist/docs-raw/generated/sheet-metal.md +68 -335
- package/dist/docs-raw/generated/sketch.md +240 -1161
- package/dist/docs-raw/generated/viewport.md +75 -316
- package/dist/docs-raw/generated/wood.md +21 -49
- package/dist/docs-raw/guides/coordinate-system.md +4 -42
- package/dist/docs-raw/guides/inspection-bundles.md +44 -442
- package/dist/docs-raw/guides/joint-design.md +18 -79
- package/dist/docs-raw/guides/positioning.md +21 -143
- package/dist/docs-raw/guides/scene-presentation.md +89 -0
- package/dist/docs-raw/skills/forgecad-3d-reconstruction.md +25 -111
- package/dist/docs-raw/skills/forgecad-blockout-model.md +20 -117
- package/dist/docs-raw/skills/forgecad-component-model.md +23 -107
- package/dist/docs-raw/skills/forgecad-high-level-spec.md +47 -155
- package/dist/docs-raw/skills/forgecad-image-replicator.md +26 -143
- package/dist/docs-raw/skills/forgecad-lld.md +19 -113
- package/dist/docs-raw/skills/forgecad-make-a-model.md +112 -532
- package/dist/docs-raw/skills/forgecad-model-grader.md +38 -108
- package/dist/docs-raw/skills/forgecad-prepare-prompt.md +24 -211
- package/dist/docs-raw/skills/forgecad-project.md +13 -131
- package/dist/docs-raw/skills/forgecad-reconstruction-benchmark.md +42 -134
- package/dist/docs-raw/skills/forgecad-render-inspect.md +27 -174
- package/dist/docs-raw/skills/forgecad-visual-spec.md +32 -112
- package/dist/docs-raw/skills/forgecad.md +19 -18
- package/dist/docs-raw/skills/index.md +2 -0
- package/dist/docs-raw/welcome.md +2 -2
- package/dist/index.html +1 -1
- package/dist/llms.txt +1 -2
- package/dist/sitemap.xml +13 -13
- package/dist-cli/{check-compiler-SYQ2PWOB.js → check-compiler-JTVBITCR.js} +1 -1
- package/dist-cli/{check-query-propagation-HIAGV62W.js → check-query-propagation-3FFLSMVN.js} +1 -1
- package/dist-cli/{chunk-SPZE3DUY.js → chunk-OAN5T4XD.js} +4412 -2212
- package/dist-cli/forgecad.js +507 -179
- package/dist-skill/CONTEXT.md +2172 -8377
- package/dist-skill/SKILL.md +15 -15
- package/dist-skill/docs/API/core/concepts.md +27 -157
- package/dist-skill/docs/CLI.md +63 -241
- package/dist-skill/docs/generated/assembly.md +138 -549
- package/dist-skill/docs/generated/core.md +277 -1251
- package/dist-skill/docs/generated/curves.md +387 -1609
- package/dist-skill/docs/generated/lib.md +227 -85
- package/dist-skill/docs/generated/output.md +38 -73
- package/dist-skill/docs/generated/runtime-names.md +16 -21
- package/dist-skill/docs/generated/sdf.md +68 -284
- package/dist-skill/docs/generated/sheet-metal.md +68 -335
- package/dist-skill/docs/generated/sketch.md +240 -1160
- package/dist-skill/docs/generated/viewport.md +75 -223
- package/dist-skill/docs/generated/wood.md +21 -49
- package/dist-skill/docs/guides/coordinate-system.md +4 -42
- package/dist-skill/docs/guides/inspection-bundles.md +44 -442
- package/dist-skill/docs/guides/joint-design.md +18 -79
- package/dist-skill/docs/guides/positioning.md +21 -143
- package/dist-skill/docs/guides/scene-presentation.md +89 -0
- package/dist-skill/docs/guides/surface-members.md +26 -0
- package/dist-skill/library/forgecad-3d-reconstruction/SKILL.md +23 -111
- package/dist-skill/library/forgecad-blockout-model/SKILL.md +18 -117
- package/dist-skill/library/forgecad-component-model/SKILL.md +21 -107
- package/dist-skill/library/forgecad-high-level-spec/SKILL.md +45 -155
- package/dist-skill/library/forgecad-image-replicator/SKILL.md +24 -143
- package/dist-skill/library/forgecad-lld/SKILL.md +17 -113
- package/dist-skill/library/forgecad-make-a-model/SKILL.md +110 -532
- package/dist-skill/library/forgecad-model-grader/SKILL.md +36 -108
- package/dist-skill/library/forgecad-prepare-prompt/SKILL.md +35 -224
- package/dist-skill/library/forgecad-prepare-prompt/references/default-profiles.md +43 -271
- package/dist-skill/library/forgecad-prepare-prompt/references/master-prompt.md +30 -99
- package/dist-skill/library/forgecad-project/SKILL.md +13 -133
- package/dist-skill/library/forgecad-reconstruction-benchmark/SKILL.md +29 -123
- package/dist-skill/library/forgecad-render-inspect/SKILL.md +25 -174
- package/dist-skill/library/forgecad-visual-spec/SKILL.md +30 -111
- package/dist-skill/website/skills/forgecad-3d-reconstruction.md +58 -0
- package/dist-skill/website/skills/forgecad-blockout-model.md +49 -0
- package/dist-skill/website/skills/forgecad-component-model.md +53 -0
- package/dist-skill/website/skills/forgecad-high-level-spec.md +101 -0
- package/dist-skill/website/skills/forgecad-image-replicator.md +63 -0
- package/dist-skill/website/skills/forgecad-lld.md +41 -0
- package/dist-skill/website/skills/forgecad-make-a-model.md +186 -0
- package/dist-skill/website/skills/forgecad-model-grader.md +82 -0
- package/dist-skill/website/skills/forgecad-prepare-prompt.md +63 -0
- package/dist-skill/website/skills/forgecad-project.md +26 -0
- package/dist-skill/website/skills/forgecad-reconstruction-benchmark.md +60 -0
- package/dist-skill/website/skills/forgecad-render-inspect.md +80 -0
- package/dist-skill/website/skills/forgecad-visual-spec.md +71 -0
- package/dist-skill/website/skills/forgecad.md +122 -0
- package/dist-skill/website/skills/index.md +26 -0
- package/examples/api/comparison-imported-sphere-candidate.forge.js +1 -1
- package/examples/api/conformal-product-ribbon.forge.js +1 -1
- package/examples/api/exact-sheet-shell-assembly.forge.js +1 -1
- package/examples/api/extrude-options.forge.js +4 -2
- package/examples/api/field-loft-drive-tip.forge.js +40 -0
- package/examples/api/guided-loft-olive-oil-bottle.forge.js +1 -1
- package/examples/api/highlight-debug.forge.js +10 -10
- package/examples/api/mesh-import-slats.forge.js +1 -1
- package/examples/api/real-product-curves.forge.js +1 -1
- package/examples/api/sculpt-box-circle-booleans.forge.js +1 -1
- package/examples/api/sdf-shapes.forge.js +2 -5
- package/examples/api/sketch-rounding-strategies.forge.js +6 -6
- package/examples/api/surface-member-bottle-cage.forge.js +3 -3
- package/examples/api/surface-member-conformal-product-ribbon.forge.js +3 -3
- package/examples/api/surface-member-razor-inlay.forge.js +1 -1
- package/examples/api/variable-sweep-test.forge.js +3 -3
- package/examples/mechanical/airplane-propeller.forge.js +74 -39
- package/examples/nurbs-surface.forge.js +1 -1
- package/examples/products/iphone.forge.js +1 -1
- package/package.json +1 -1
- package/dist/assets/EditorApp-BHMQlJ-D.js +0 -14686
- package/dist/docs-raw/guides/geometry-conventions.md +0 -52
- package/dist/docs-raw/guides/modeling-recipes.md +0 -78
- package/dist-skill/docs/guides/geometry-conventions.md +0 -52
- package/dist-skill/docs/guides/modeling-recipes.md +0 -78
- package/dist-skill/library/forgecad-visual-spec/references/prompt-template.md +0 -79
|
@@ -1540,6 +1540,743 @@ function requireCore() {
|
|
|
1540
1540
|
}
|
|
1541
1541
|
var coreExports = /* @__PURE__ */ requireCore();
|
|
1542
1542
|
const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(coreExports);
|
|
1543
|
+
function json(hljs) {
|
|
1544
|
+
const ATTRIBUTE = {
|
|
1545
|
+
className: "attr",
|
|
1546
|
+
begin: /"(\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
1547
|
+
relevance: 1.01
|
|
1548
|
+
};
|
|
1549
|
+
const PUNCTUATION = {
|
|
1550
|
+
match: /[{}[\],:]/,
|
|
1551
|
+
className: "punctuation",
|
|
1552
|
+
relevance: 0
|
|
1553
|
+
};
|
|
1554
|
+
const LITERALS2 = [
|
|
1555
|
+
"true",
|
|
1556
|
+
"false",
|
|
1557
|
+
"null"
|
|
1558
|
+
];
|
|
1559
|
+
const LITERALS_MODE = {
|
|
1560
|
+
scope: "literal",
|
|
1561
|
+
beginKeywords: LITERALS2.join(" ")
|
|
1562
|
+
};
|
|
1563
|
+
return {
|
|
1564
|
+
name: "JSON",
|
|
1565
|
+
aliases: ["jsonc"],
|
|
1566
|
+
keywords: {
|
|
1567
|
+
literal: LITERALS2
|
|
1568
|
+
},
|
|
1569
|
+
contains: [
|
|
1570
|
+
ATTRIBUTE,
|
|
1571
|
+
PUNCTUATION,
|
|
1572
|
+
hljs.QUOTE_STRING_MODE,
|
|
1573
|
+
LITERALS_MODE,
|
|
1574
|
+
hljs.C_NUMBER_MODE,
|
|
1575
|
+
hljs.C_LINE_COMMENT_MODE,
|
|
1576
|
+
hljs.C_BLOCK_COMMENT_MODE
|
|
1577
|
+
],
|
|
1578
|
+
illegal: "\\S"
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
const IDENT_RE$1 = "[A-Za-z$_][0-9A-Za-z$_]*";
|
|
1582
|
+
const KEYWORDS$1 = [
|
|
1583
|
+
"as",
|
|
1584
|
+
// for exports
|
|
1585
|
+
"in",
|
|
1586
|
+
"of",
|
|
1587
|
+
"if",
|
|
1588
|
+
"for",
|
|
1589
|
+
"while",
|
|
1590
|
+
"finally",
|
|
1591
|
+
"var",
|
|
1592
|
+
"new",
|
|
1593
|
+
"function",
|
|
1594
|
+
"do",
|
|
1595
|
+
"return",
|
|
1596
|
+
"void",
|
|
1597
|
+
"else",
|
|
1598
|
+
"break",
|
|
1599
|
+
"catch",
|
|
1600
|
+
"instanceof",
|
|
1601
|
+
"with",
|
|
1602
|
+
"throw",
|
|
1603
|
+
"case",
|
|
1604
|
+
"default",
|
|
1605
|
+
"try",
|
|
1606
|
+
"switch",
|
|
1607
|
+
"continue",
|
|
1608
|
+
"typeof",
|
|
1609
|
+
"delete",
|
|
1610
|
+
"let",
|
|
1611
|
+
"yield",
|
|
1612
|
+
"const",
|
|
1613
|
+
"class",
|
|
1614
|
+
// JS handles these with a special rule
|
|
1615
|
+
// "get",
|
|
1616
|
+
// "set",
|
|
1617
|
+
"debugger",
|
|
1618
|
+
"async",
|
|
1619
|
+
"await",
|
|
1620
|
+
"static",
|
|
1621
|
+
"import",
|
|
1622
|
+
"from",
|
|
1623
|
+
"export",
|
|
1624
|
+
"extends",
|
|
1625
|
+
// It's reached stage 3, which is "recommended for implementation":
|
|
1626
|
+
"using"
|
|
1627
|
+
];
|
|
1628
|
+
const LITERALS$1 = [
|
|
1629
|
+
"true",
|
|
1630
|
+
"false",
|
|
1631
|
+
"null",
|
|
1632
|
+
"undefined",
|
|
1633
|
+
"NaN",
|
|
1634
|
+
"Infinity"
|
|
1635
|
+
];
|
|
1636
|
+
const TYPES$1 = [
|
|
1637
|
+
// Fundamental objects
|
|
1638
|
+
"Object",
|
|
1639
|
+
"Function",
|
|
1640
|
+
"Boolean",
|
|
1641
|
+
"Symbol",
|
|
1642
|
+
// numbers and dates
|
|
1643
|
+
"Math",
|
|
1644
|
+
"Date",
|
|
1645
|
+
"Number",
|
|
1646
|
+
"BigInt",
|
|
1647
|
+
// text
|
|
1648
|
+
"String",
|
|
1649
|
+
"RegExp",
|
|
1650
|
+
// Indexed collections
|
|
1651
|
+
"Array",
|
|
1652
|
+
"Float32Array",
|
|
1653
|
+
"Float64Array",
|
|
1654
|
+
"Int8Array",
|
|
1655
|
+
"Uint8Array",
|
|
1656
|
+
"Uint8ClampedArray",
|
|
1657
|
+
"Int16Array",
|
|
1658
|
+
"Int32Array",
|
|
1659
|
+
"Uint16Array",
|
|
1660
|
+
"Uint32Array",
|
|
1661
|
+
"BigInt64Array",
|
|
1662
|
+
"BigUint64Array",
|
|
1663
|
+
// Keyed collections
|
|
1664
|
+
"Set",
|
|
1665
|
+
"Map",
|
|
1666
|
+
"WeakSet",
|
|
1667
|
+
"WeakMap",
|
|
1668
|
+
// Structured data
|
|
1669
|
+
"ArrayBuffer",
|
|
1670
|
+
"SharedArrayBuffer",
|
|
1671
|
+
"Atomics",
|
|
1672
|
+
"DataView",
|
|
1673
|
+
"JSON",
|
|
1674
|
+
// Control abstraction objects
|
|
1675
|
+
"Promise",
|
|
1676
|
+
"Generator",
|
|
1677
|
+
"GeneratorFunction",
|
|
1678
|
+
"AsyncFunction",
|
|
1679
|
+
// Reflection
|
|
1680
|
+
"Reflect",
|
|
1681
|
+
"Proxy",
|
|
1682
|
+
// Internationalization
|
|
1683
|
+
"Intl",
|
|
1684
|
+
// WebAssembly
|
|
1685
|
+
"WebAssembly"
|
|
1686
|
+
];
|
|
1687
|
+
const ERROR_TYPES$1 = [
|
|
1688
|
+
"Error",
|
|
1689
|
+
"EvalError",
|
|
1690
|
+
"InternalError",
|
|
1691
|
+
"RangeError",
|
|
1692
|
+
"ReferenceError",
|
|
1693
|
+
"SyntaxError",
|
|
1694
|
+
"TypeError",
|
|
1695
|
+
"URIError"
|
|
1696
|
+
];
|
|
1697
|
+
const BUILT_IN_GLOBALS$1 = [
|
|
1698
|
+
"setInterval",
|
|
1699
|
+
"setTimeout",
|
|
1700
|
+
"clearInterval",
|
|
1701
|
+
"clearTimeout",
|
|
1702
|
+
"require",
|
|
1703
|
+
"exports",
|
|
1704
|
+
"eval",
|
|
1705
|
+
"isFinite",
|
|
1706
|
+
"isNaN",
|
|
1707
|
+
"parseFloat",
|
|
1708
|
+
"parseInt",
|
|
1709
|
+
"decodeURI",
|
|
1710
|
+
"decodeURIComponent",
|
|
1711
|
+
"encodeURI",
|
|
1712
|
+
"encodeURIComponent",
|
|
1713
|
+
"escape",
|
|
1714
|
+
"unescape"
|
|
1715
|
+
];
|
|
1716
|
+
const BUILT_IN_VARIABLES$1 = [
|
|
1717
|
+
"arguments",
|
|
1718
|
+
"this",
|
|
1719
|
+
"super",
|
|
1720
|
+
"console",
|
|
1721
|
+
"window",
|
|
1722
|
+
"document",
|
|
1723
|
+
"localStorage",
|
|
1724
|
+
"sessionStorage",
|
|
1725
|
+
"module",
|
|
1726
|
+
"global"
|
|
1727
|
+
// Node.js
|
|
1728
|
+
];
|
|
1729
|
+
const BUILT_INS$1 = [].concat(
|
|
1730
|
+
BUILT_IN_GLOBALS$1,
|
|
1731
|
+
TYPES$1,
|
|
1732
|
+
ERROR_TYPES$1
|
|
1733
|
+
);
|
|
1734
|
+
function javascript$1(hljs) {
|
|
1735
|
+
const regex = hljs.regex;
|
|
1736
|
+
const hasClosingTag = (match, { after }) => {
|
|
1737
|
+
const tag = "</" + match[0].slice(1);
|
|
1738
|
+
const pos = match.input.indexOf(tag, after);
|
|
1739
|
+
return pos !== -1;
|
|
1740
|
+
};
|
|
1741
|
+
const IDENT_RE$1$1 = IDENT_RE$1;
|
|
1742
|
+
const FRAGMENT = {
|
|
1743
|
+
begin: "<>",
|
|
1744
|
+
end: "</>"
|
|
1745
|
+
};
|
|
1746
|
+
const XML_SELF_CLOSING = /<[A-Za-z0-9\\._:-]+\s*\/>/;
|
|
1747
|
+
const XML_TAG = {
|
|
1748
|
+
begin: /<[A-Za-z0-9\\._:-]+/,
|
|
1749
|
+
end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
|
|
1750
|
+
/**
|
|
1751
|
+
* @param {RegExpMatchArray} match
|
|
1752
|
+
* @param {CallbackResponse} response
|
|
1753
|
+
*/
|
|
1754
|
+
isTrulyOpeningTag: (match, response) => {
|
|
1755
|
+
const afterMatchIndex = match[0].length + match.index;
|
|
1756
|
+
const nextChar = match.input[afterMatchIndex];
|
|
1757
|
+
if (
|
|
1758
|
+
// HTML should not include another raw `<` inside a tag
|
|
1759
|
+
// nested type?
|
|
1760
|
+
// `<Array<Array<number>>`, etc.
|
|
1761
|
+
nextChar === "<" || // the , gives away that this is not HTML
|
|
1762
|
+
// `<T, A extends keyof T, V>`
|
|
1763
|
+
nextChar === ","
|
|
1764
|
+
) {
|
|
1765
|
+
response.ignoreMatch();
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
if (nextChar === ">") {
|
|
1769
|
+
if (!hasClosingTag(match, { after: afterMatchIndex })) {
|
|
1770
|
+
response.ignoreMatch();
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
let m;
|
|
1774
|
+
const afterMatch = match.input.substring(afterMatchIndex);
|
|
1775
|
+
if (m = afterMatch.match(/^\s*=/)) {
|
|
1776
|
+
response.ignoreMatch();
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
if (m = afterMatch.match(/^\s+extends\s+/)) {
|
|
1780
|
+
if (m.index === 0) {
|
|
1781
|
+
response.ignoreMatch();
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1787
|
+
const KEYWORDS$1$1 = {
|
|
1788
|
+
$pattern: IDENT_RE$1,
|
|
1789
|
+
keyword: KEYWORDS$1,
|
|
1790
|
+
literal: LITERALS$1,
|
|
1791
|
+
built_in: BUILT_INS$1,
|
|
1792
|
+
"variable.language": BUILT_IN_VARIABLES$1
|
|
1793
|
+
};
|
|
1794
|
+
const decimalDigits = "[0-9](_?[0-9])*";
|
|
1795
|
+
const frac = `\\.(${decimalDigits})`;
|
|
1796
|
+
const decimalInteger = `0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`;
|
|
1797
|
+
const NUMBER = {
|
|
1798
|
+
className: "number",
|
|
1799
|
+
variants: [
|
|
1800
|
+
// DecimalLiteral
|
|
1801
|
+
{ begin: `(\\b(${decimalInteger})((${frac})|\\.)?|(${frac}))[eE][+-]?(${decimalDigits})\\b` },
|
|
1802
|
+
{ begin: `\\b(${decimalInteger})\\b((${frac})\\b|\\.)?|(${frac})\\b` },
|
|
1803
|
+
// DecimalBigIntegerLiteral
|
|
1804
|
+
{ begin: `\\b(0|[1-9](_?[0-9])*)n\\b` },
|
|
1805
|
+
// NonDecimalIntegerLiteral
|
|
1806
|
+
{ begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
|
|
1807
|
+
{ begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
|
|
1808
|
+
{ begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
|
|
1809
|
+
// LegacyOctalIntegerLiteral (does not include underscore separators)
|
|
1810
|
+
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
|
|
1811
|
+
{ begin: "\\b0[0-7]+n?\\b" }
|
|
1812
|
+
],
|
|
1813
|
+
relevance: 0
|
|
1814
|
+
};
|
|
1815
|
+
const SUBST = {
|
|
1816
|
+
className: "subst",
|
|
1817
|
+
begin: "\\$\\{",
|
|
1818
|
+
end: "\\}",
|
|
1819
|
+
keywords: KEYWORDS$1$1,
|
|
1820
|
+
contains: []
|
|
1821
|
+
// defined later
|
|
1822
|
+
};
|
|
1823
|
+
const HTML_TEMPLATE = {
|
|
1824
|
+
begin: ".?html`",
|
|
1825
|
+
end: "",
|
|
1826
|
+
starts: {
|
|
1827
|
+
end: "`",
|
|
1828
|
+
returnEnd: false,
|
|
1829
|
+
contains: [
|
|
1830
|
+
hljs.BACKSLASH_ESCAPE,
|
|
1831
|
+
SUBST
|
|
1832
|
+
],
|
|
1833
|
+
subLanguage: "xml"
|
|
1834
|
+
}
|
|
1835
|
+
};
|
|
1836
|
+
const CSS_TEMPLATE = {
|
|
1837
|
+
begin: ".?css`",
|
|
1838
|
+
end: "",
|
|
1839
|
+
starts: {
|
|
1840
|
+
end: "`",
|
|
1841
|
+
returnEnd: false,
|
|
1842
|
+
contains: [
|
|
1843
|
+
hljs.BACKSLASH_ESCAPE,
|
|
1844
|
+
SUBST
|
|
1845
|
+
],
|
|
1846
|
+
subLanguage: "css"
|
|
1847
|
+
}
|
|
1848
|
+
};
|
|
1849
|
+
const GRAPHQL_TEMPLATE = {
|
|
1850
|
+
begin: ".?gql`",
|
|
1851
|
+
end: "",
|
|
1852
|
+
starts: {
|
|
1853
|
+
end: "`",
|
|
1854
|
+
returnEnd: false,
|
|
1855
|
+
contains: [
|
|
1856
|
+
hljs.BACKSLASH_ESCAPE,
|
|
1857
|
+
SUBST
|
|
1858
|
+
],
|
|
1859
|
+
subLanguage: "graphql"
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
const TEMPLATE_STRING = {
|
|
1863
|
+
className: "string",
|
|
1864
|
+
begin: "`",
|
|
1865
|
+
end: "`",
|
|
1866
|
+
contains: [
|
|
1867
|
+
hljs.BACKSLASH_ESCAPE,
|
|
1868
|
+
SUBST
|
|
1869
|
+
]
|
|
1870
|
+
};
|
|
1871
|
+
const JSDOC_COMMENT = hljs.COMMENT(
|
|
1872
|
+
/\/\*\*(?!\/)/,
|
|
1873
|
+
"\\*/",
|
|
1874
|
+
{
|
|
1875
|
+
relevance: 0,
|
|
1876
|
+
contains: [
|
|
1877
|
+
{
|
|
1878
|
+
begin: "(?=@[A-Za-z]+)",
|
|
1879
|
+
relevance: 0,
|
|
1880
|
+
contains: [
|
|
1881
|
+
{
|
|
1882
|
+
className: "doctag",
|
|
1883
|
+
begin: "@[A-Za-z]+"
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
className: "type",
|
|
1887
|
+
begin: "\\{",
|
|
1888
|
+
end: "\\}",
|
|
1889
|
+
excludeEnd: true,
|
|
1890
|
+
excludeBegin: true,
|
|
1891
|
+
relevance: 0
|
|
1892
|
+
},
|
|
1893
|
+
{
|
|
1894
|
+
className: "variable",
|
|
1895
|
+
begin: IDENT_RE$1$1 + "(?=\\s*(-)|$)",
|
|
1896
|
+
endsParent: true,
|
|
1897
|
+
relevance: 0
|
|
1898
|
+
},
|
|
1899
|
+
// eat spaces (not newlines) so we can find
|
|
1900
|
+
// types or variables
|
|
1901
|
+
{
|
|
1902
|
+
begin: /(?=[^\n])\s/,
|
|
1903
|
+
relevance: 0
|
|
1904
|
+
}
|
|
1905
|
+
]
|
|
1906
|
+
}
|
|
1907
|
+
]
|
|
1908
|
+
}
|
|
1909
|
+
);
|
|
1910
|
+
const COMMENT = {
|
|
1911
|
+
className: "comment",
|
|
1912
|
+
variants: [
|
|
1913
|
+
JSDOC_COMMENT,
|
|
1914
|
+
hljs.C_BLOCK_COMMENT_MODE,
|
|
1915
|
+
hljs.C_LINE_COMMENT_MODE
|
|
1916
|
+
]
|
|
1917
|
+
};
|
|
1918
|
+
const SUBST_INTERNALS = [
|
|
1919
|
+
hljs.APOS_STRING_MODE,
|
|
1920
|
+
hljs.QUOTE_STRING_MODE,
|
|
1921
|
+
HTML_TEMPLATE,
|
|
1922
|
+
CSS_TEMPLATE,
|
|
1923
|
+
GRAPHQL_TEMPLATE,
|
|
1924
|
+
TEMPLATE_STRING,
|
|
1925
|
+
// Skip numbers when they are part of a variable name
|
|
1926
|
+
{ match: /\$\d+/ },
|
|
1927
|
+
NUMBER
|
|
1928
|
+
// This is intentional:
|
|
1929
|
+
// See https://github.com/highlightjs/highlight.js/issues/3288
|
|
1930
|
+
// hljs.REGEXP_MODE
|
|
1931
|
+
];
|
|
1932
|
+
SUBST.contains = SUBST_INTERNALS.concat({
|
|
1933
|
+
// we need to pair up {} inside our subst to prevent
|
|
1934
|
+
// it from ending too early by matching another }
|
|
1935
|
+
begin: /\{/,
|
|
1936
|
+
end: /\}/,
|
|
1937
|
+
keywords: KEYWORDS$1$1,
|
|
1938
|
+
contains: [
|
|
1939
|
+
"self"
|
|
1940
|
+
].concat(SUBST_INTERNALS)
|
|
1941
|
+
});
|
|
1942
|
+
const SUBST_AND_COMMENTS = [].concat(COMMENT, SUBST.contains);
|
|
1943
|
+
const PARAMS_CONTAINS = SUBST_AND_COMMENTS.concat([
|
|
1944
|
+
// eat recursive parens in sub expressions
|
|
1945
|
+
{
|
|
1946
|
+
begin: /(\s*)\(/,
|
|
1947
|
+
end: /\)/,
|
|
1948
|
+
keywords: KEYWORDS$1$1,
|
|
1949
|
+
contains: ["self"].concat(SUBST_AND_COMMENTS)
|
|
1950
|
+
}
|
|
1951
|
+
]);
|
|
1952
|
+
const PARAMS = {
|
|
1953
|
+
className: "params",
|
|
1954
|
+
// convert this to negative lookbehind in v12
|
|
1955
|
+
begin: /(\s*)\(/,
|
|
1956
|
+
// to match the parms with
|
|
1957
|
+
end: /\)/,
|
|
1958
|
+
excludeBegin: true,
|
|
1959
|
+
excludeEnd: true,
|
|
1960
|
+
keywords: KEYWORDS$1$1,
|
|
1961
|
+
contains: PARAMS_CONTAINS
|
|
1962
|
+
};
|
|
1963
|
+
const CLASS_OR_EXTENDS = {
|
|
1964
|
+
variants: [
|
|
1965
|
+
// class Car extends vehicle
|
|
1966
|
+
{
|
|
1967
|
+
match: [
|
|
1968
|
+
/class/,
|
|
1969
|
+
/\s+/,
|
|
1970
|
+
IDENT_RE$1$1,
|
|
1971
|
+
/\s+/,
|
|
1972
|
+
/extends/,
|
|
1973
|
+
/\s+/,
|
|
1974
|
+
regex.concat(IDENT_RE$1$1, "(", regex.concat(/\./, IDENT_RE$1$1), ")*")
|
|
1975
|
+
],
|
|
1976
|
+
scope: {
|
|
1977
|
+
1: "keyword",
|
|
1978
|
+
3: "title.class",
|
|
1979
|
+
5: "keyword",
|
|
1980
|
+
7: "title.class.inherited"
|
|
1981
|
+
}
|
|
1982
|
+
},
|
|
1983
|
+
// class Car
|
|
1984
|
+
{
|
|
1985
|
+
match: [
|
|
1986
|
+
/class/,
|
|
1987
|
+
/\s+/,
|
|
1988
|
+
IDENT_RE$1$1
|
|
1989
|
+
],
|
|
1990
|
+
scope: {
|
|
1991
|
+
1: "keyword",
|
|
1992
|
+
3: "title.class"
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
]
|
|
1996
|
+
};
|
|
1997
|
+
const CLASS_REFERENCE = {
|
|
1998
|
+
relevance: 0,
|
|
1999
|
+
match: regex.either(
|
|
2000
|
+
// Hard coded exceptions
|
|
2001
|
+
/\bJSON/,
|
|
2002
|
+
// Float32Array, OutT
|
|
2003
|
+
/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,
|
|
2004
|
+
// CSSFactory, CSSFactoryT
|
|
2005
|
+
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,
|
|
2006
|
+
// FPs, FPsT
|
|
2007
|
+
/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/
|
|
2008
|
+
// P
|
|
2009
|
+
// single letters are not highlighted
|
|
2010
|
+
// BLAH
|
|
2011
|
+
// this will be flagged as a UPPER_CASE_CONSTANT instead
|
|
2012
|
+
),
|
|
2013
|
+
className: "title.class",
|
|
2014
|
+
keywords: {
|
|
2015
|
+
_: [
|
|
2016
|
+
// se we still get relevance credit for JS library classes
|
|
2017
|
+
...TYPES$1,
|
|
2018
|
+
...ERROR_TYPES$1
|
|
2019
|
+
]
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
const USE_STRICT = {
|
|
2023
|
+
label: "use_strict",
|
|
2024
|
+
className: "meta",
|
|
2025
|
+
relevance: 10,
|
|
2026
|
+
begin: /^\s*['"]use (strict|asm)['"]/
|
|
2027
|
+
};
|
|
2028
|
+
const FUNCTION_DEFINITION = {
|
|
2029
|
+
variants: [
|
|
2030
|
+
{
|
|
2031
|
+
match: [
|
|
2032
|
+
/function/,
|
|
2033
|
+
/\s+/,
|
|
2034
|
+
IDENT_RE$1$1,
|
|
2035
|
+
/(?=\s*\()/
|
|
2036
|
+
]
|
|
2037
|
+
},
|
|
2038
|
+
// anonymous function
|
|
2039
|
+
{
|
|
2040
|
+
match: [
|
|
2041
|
+
/function/,
|
|
2042
|
+
/\s*(?=\()/
|
|
2043
|
+
]
|
|
2044
|
+
}
|
|
2045
|
+
],
|
|
2046
|
+
className: {
|
|
2047
|
+
1: "keyword",
|
|
2048
|
+
3: "title.function"
|
|
2049
|
+
},
|
|
2050
|
+
label: "func.def",
|
|
2051
|
+
contains: [PARAMS],
|
|
2052
|
+
illegal: /%/
|
|
2053
|
+
};
|
|
2054
|
+
const UPPER_CASE_CONSTANT = {
|
|
2055
|
+
relevance: 0,
|
|
2056
|
+
match: /\b[A-Z][A-Z_0-9]+\b/,
|
|
2057
|
+
className: "variable.constant"
|
|
2058
|
+
};
|
|
2059
|
+
function noneOf(list) {
|
|
2060
|
+
return regex.concat("(?!", list.join("|"), ")");
|
|
2061
|
+
}
|
|
2062
|
+
const FUNCTION_CALL = {
|
|
2063
|
+
match: regex.concat(
|
|
2064
|
+
/\b/,
|
|
2065
|
+
noneOf([
|
|
2066
|
+
...BUILT_IN_GLOBALS$1,
|
|
2067
|
+
"super",
|
|
2068
|
+
"import"
|
|
2069
|
+
].map((x) => `${x}\\s*\\(`)),
|
|
2070
|
+
IDENT_RE$1$1,
|
|
2071
|
+
regex.lookahead(/\s*\(/)
|
|
2072
|
+
),
|
|
2073
|
+
className: "title.function",
|
|
2074
|
+
relevance: 0
|
|
2075
|
+
};
|
|
2076
|
+
const PROPERTY_ACCESS = {
|
|
2077
|
+
begin: regex.concat(/\./, regex.lookahead(
|
|
2078
|
+
regex.concat(IDENT_RE$1$1, /(?![0-9A-Za-z$_(])/)
|
|
2079
|
+
)),
|
|
2080
|
+
end: IDENT_RE$1$1,
|
|
2081
|
+
excludeBegin: true,
|
|
2082
|
+
keywords: "prototype",
|
|
2083
|
+
className: "property",
|
|
2084
|
+
relevance: 0
|
|
2085
|
+
};
|
|
2086
|
+
const GETTER_OR_SETTER = {
|
|
2087
|
+
match: [
|
|
2088
|
+
/get|set/,
|
|
2089
|
+
/\s+/,
|
|
2090
|
+
IDENT_RE$1$1,
|
|
2091
|
+
/(?=\()/
|
|
2092
|
+
],
|
|
2093
|
+
className: {
|
|
2094
|
+
1: "keyword",
|
|
2095
|
+
3: "title.function"
|
|
2096
|
+
},
|
|
2097
|
+
contains: [
|
|
2098
|
+
{
|
|
2099
|
+
// eat to avoid empty params
|
|
2100
|
+
begin: /\(\)/
|
|
2101
|
+
},
|
|
2102
|
+
PARAMS
|
|
2103
|
+
]
|
|
2104
|
+
};
|
|
2105
|
+
const FUNC_LEAD_IN_RE = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + hljs.UNDERSCORE_IDENT_RE + ")\\s*=>";
|
|
2106
|
+
const FUNCTION_VARIABLE = {
|
|
2107
|
+
match: [
|
|
2108
|
+
/const|var|let/,
|
|
2109
|
+
/\s+/,
|
|
2110
|
+
IDENT_RE$1$1,
|
|
2111
|
+
/\s*/,
|
|
2112
|
+
/=\s*/,
|
|
2113
|
+
/(async\s*)?/,
|
|
2114
|
+
// async is optional
|
|
2115
|
+
regex.lookahead(FUNC_LEAD_IN_RE)
|
|
2116
|
+
],
|
|
2117
|
+
keywords: "async",
|
|
2118
|
+
className: {
|
|
2119
|
+
1: "keyword",
|
|
2120
|
+
3: "title.function"
|
|
2121
|
+
},
|
|
2122
|
+
contains: [
|
|
2123
|
+
PARAMS
|
|
2124
|
+
]
|
|
2125
|
+
};
|
|
2126
|
+
return {
|
|
2127
|
+
name: "JavaScript",
|
|
2128
|
+
aliases: ["js", "jsx", "mjs", "cjs"],
|
|
2129
|
+
keywords: KEYWORDS$1$1,
|
|
2130
|
+
// this will be extended by TypeScript
|
|
2131
|
+
exports: { PARAMS_CONTAINS, CLASS_REFERENCE },
|
|
2132
|
+
illegal: /#(?![$_A-z])/,
|
|
2133
|
+
contains: [
|
|
2134
|
+
hljs.SHEBANG({
|
|
2135
|
+
label: "shebang",
|
|
2136
|
+
binary: "node",
|
|
2137
|
+
relevance: 5
|
|
2138
|
+
}),
|
|
2139
|
+
USE_STRICT,
|
|
2140
|
+
hljs.APOS_STRING_MODE,
|
|
2141
|
+
hljs.QUOTE_STRING_MODE,
|
|
2142
|
+
HTML_TEMPLATE,
|
|
2143
|
+
CSS_TEMPLATE,
|
|
2144
|
+
GRAPHQL_TEMPLATE,
|
|
2145
|
+
TEMPLATE_STRING,
|
|
2146
|
+
COMMENT,
|
|
2147
|
+
// Skip numbers when they are part of a variable name
|
|
2148
|
+
{ match: /\$\d+/ },
|
|
2149
|
+
NUMBER,
|
|
2150
|
+
CLASS_REFERENCE,
|
|
2151
|
+
{
|
|
2152
|
+
scope: "attr",
|
|
2153
|
+
match: IDENT_RE$1$1 + regex.lookahead(":"),
|
|
2154
|
+
relevance: 0
|
|
2155
|
+
},
|
|
2156
|
+
FUNCTION_VARIABLE,
|
|
2157
|
+
{
|
|
2158
|
+
// "value" container
|
|
2159
|
+
begin: "(" + hljs.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*",
|
|
2160
|
+
keywords: "return throw case",
|
|
2161
|
+
relevance: 0,
|
|
2162
|
+
contains: [
|
|
2163
|
+
COMMENT,
|
|
2164
|
+
hljs.REGEXP_MODE,
|
|
2165
|
+
{
|
|
2166
|
+
className: "function",
|
|
2167
|
+
// we have to count the parens to make sure we actually have the
|
|
2168
|
+
// correct bounding ( ) before the =>. There could be any number of
|
|
2169
|
+
// sub-expressions inside also surrounded by parens.
|
|
2170
|
+
begin: FUNC_LEAD_IN_RE,
|
|
2171
|
+
returnBegin: true,
|
|
2172
|
+
end: "\\s*=>",
|
|
2173
|
+
contains: [
|
|
2174
|
+
{
|
|
2175
|
+
className: "params",
|
|
2176
|
+
variants: [
|
|
2177
|
+
{
|
|
2178
|
+
begin: hljs.UNDERSCORE_IDENT_RE,
|
|
2179
|
+
relevance: 0
|
|
2180
|
+
},
|
|
2181
|
+
{
|
|
2182
|
+
className: null,
|
|
2183
|
+
begin: /\(\s*\)/,
|
|
2184
|
+
skip: true
|
|
2185
|
+
},
|
|
2186
|
+
{
|
|
2187
|
+
begin: /(\s*)\(/,
|
|
2188
|
+
end: /\)/,
|
|
2189
|
+
excludeBegin: true,
|
|
2190
|
+
excludeEnd: true,
|
|
2191
|
+
keywords: KEYWORDS$1$1,
|
|
2192
|
+
contains: PARAMS_CONTAINS
|
|
2193
|
+
}
|
|
2194
|
+
]
|
|
2195
|
+
}
|
|
2196
|
+
]
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
// could be a comma delimited list of params to a function call
|
|
2200
|
+
begin: /,/,
|
|
2201
|
+
relevance: 0
|
|
2202
|
+
},
|
|
2203
|
+
{
|
|
2204
|
+
match: /\s+/,
|
|
2205
|
+
relevance: 0
|
|
2206
|
+
},
|
|
2207
|
+
{
|
|
2208
|
+
// JSX
|
|
2209
|
+
variants: [
|
|
2210
|
+
{ begin: FRAGMENT.begin, end: FRAGMENT.end },
|
|
2211
|
+
{ match: XML_SELF_CLOSING },
|
|
2212
|
+
{
|
|
2213
|
+
begin: XML_TAG.begin,
|
|
2214
|
+
// we carefully check the opening tag to see if it truly
|
|
2215
|
+
// is a tag and not a false positive
|
|
2216
|
+
"on:begin": XML_TAG.isTrulyOpeningTag,
|
|
2217
|
+
end: XML_TAG.end
|
|
2218
|
+
}
|
|
2219
|
+
],
|
|
2220
|
+
subLanguage: "xml",
|
|
2221
|
+
contains: [
|
|
2222
|
+
{
|
|
2223
|
+
begin: XML_TAG.begin,
|
|
2224
|
+
end: XML_TAG.end,
|
|
2225
|
+
skip: true,
|
|
2226
|
+
contains: ["self"]
|
|
2227
|
+
}
|
|
2228
|
+
]
|
|
2229
|
+
}
|
|
2230
|
+
]
|
|
2231
|
+
},
|
|
2232
|
+
FUNCTION_DEFINITION,
|
|
2233
|
+
{
|
|
2234
|
+
// prevent this from getting swallowed up by function
|
|
2235
|
+
// since they appear "function like"
|
|
2236
|
+
beginKeywords: "while if switch catch for"
|
|
2237
|
+
},
|
|
2238
|
+
{
|
|
2239
|
+
// we have to count the parens to make sure we actually have the correct
|
|
2240
|
+
// bounding ( ). There could be any number of sub-expressions inside
|
|
2241
|
+
// also surrounded by parens.
|
|
2242
|
+
begin: "\\b(?!function)" + hljs.UNDERSCORE_IDENT_RE + "\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
|
|
2243
|
+
// end parens
|
|
2244
|
+
returnBegin: true,
|
|
2245
|
+
label: "func.def",
|
|
2246
|
+
contains: [
|
|
2247
|
+
PARAMS,
|
|
2248
|
+
hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$1$1, className: "title.function" })
|
|
2249
|
+
]
|
|
2250
|
+
},
|
|
2251
|
+
// catch ... so it won't trigger the property rule below
|
|
2252
|
+
{
|
|
2253
|
+
match: /\.\.\./,
|
|
2254
|
+
relevance: 0
|
|
2255
|
+
},
|
|
2256
|
+
PROPERTY_ACCESS,
|
|
2257
|
+
// hack: prevents detection of keywords in some circumstances
|
|
2258
|
+
// .keyword()
|
|
2259
|
+
// $keyword = x
|
|
2260
|
+
{
|
|
2261
|
+
match: "\\$" + IDENT_RE$1$1,
|
|
2262
|
+
relevance: 0
|
|
2263
|
+
},
|
|
2264
|
+
{
|
|
2265
|
+
match: [/\bconstructor(?=\s*\()/],
|
|
2266
|
+
className: { 1: "title.function" },
|
|
2267
|
+
contains: [PARAMS]
|
|
2268
|
+
},
|
|
2269
|
+
FUNCTION_CALL,
|
|
2270
|
+
UPPER_CASE_CONSTANT,
|
|
2271
|
+
CLASS_OR_EXTENDS,
|
|
2272
|
+
GETTER_OR_SETTER,
|
|
2273
|
+
{
|
|
2274
|
+
match: /\$[(.]/
|
|
2275
|
+
// relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
|
|
2276
|
+
}
|
|
2277
|
+
]
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
1543
2280
|
const IDENT_RE = "[A-Za-z$_][0-9A-Za-z$_]*";
|
|
1544
2281
|
const KEYWORDS = [
|
|
1545
2282
|
"as",
|
|
@@ -1700,7 +2437,7 @@ function javascript(hljs) {
|
|
|
1700
2437
|
const pos = match.input.indexOf(tag, after);
|
|
1701
2438
|
return pos !== -1;
|
|
1702
2439
|
};
|
|
1703
|
-
const IDENT_RE$
|
|
2440
|
+
const IDENT_RE$12 = IDENT_RE;
|
|
1704
2441
|
const FRAGMENT = {
|
|
1705
2442
|
begin: "<>",
|
|
1706
2443
|
end: "</>"
|
|
@@ -1746,7 +2483,7 @@ function javascript(hljs) {
|
|
|
1746
2483
|
}
|
|
1747
2484
|
}
|
|
1748
2485
|
};
|
|
1749
|
-
const KEYWORDS$
|
|
2486
|
+
const KEYWORDS$12 = {
|
|
1750
2487
|
$pattern: IDENT_RE,
|
|
1751
2488
|
keyword: KEYWORDS,
|
|
1752
2489
|
literal: LITERALS,
|
|
@@ -1778,7 +2515,7 @@ function javascript(hljs) {
|
|
|
1778
2515
|
className: "subst",
|
|
1779
2516
|
begin: "\\$\\{",
|
|
1780
2517
|
end: "\\}",
|
|
1781
|
-
keywords: KEYWORDS$
|
|
2518
|
+
keywords: KEYWORDS$12,
|
|
1782
2519
|
contains: []
|
|
1783
2520
|
// defined later
|
|
1784
2521
|
};
|
|
@@ -1854,7 +2591,7 @@ function javascript(hljs) {
|
|
|
1854
2591
|
},
|
|
1855
2592
|
{
|
|
1856
2593
|
className: "variable",
|
|
1857
|
-
begin: IDENT_RE$
|
|
2594
|
+
begin: IDENT_RE$12 + "(?=\\s*(-)|$)",
|
|
1858
2595
|
endsParent: true,
|
|
1859
2596
|
relevance: 0
|
|
1860
2597
|
},
|
|
@@ -1896,7 +2633,7 @@ function javascript(hljs) {
|
|
|
1896
2633
|
// it from ending too early by matching another }
|
|
1897
2634
|
begin: /\{/,
|
|
1898
2635
|
end: /\}/,
|
|
1899
|
-
keywords: KEYWORDS$
|
|
2636
|
+
keywords: KEYWORDS$12,
|
|
1900
2637
|
contains: [
|
|
1901
2638
|
"self"
|
|
1902
2639
|
].concat(SUBST_INTERNALS)
|
|
@@ -1907,7 +2644,7 @@ function javascript(hljs) {
|
|
|
1907
2644
|
{
|
|
1908
2645
|
begin: /(\s*)\(/,
|
|
1909
2646
|
end: /\)/,
|
|
1910
|
-
keywords: KEYWORDS$
|
|
2647
|
+
keywords: KEYWORDS$12,
|
|
1911
2648
|
contains: ["self"].concat(SUBST_AND_COMMENTS)
|
|
1912
2649
|
}
|
|
1913
2650
|
]);
|
|
@@ -1919,7 +2656,7 @@ function javascript(hljs) {
|
|
|
1919
2656
|
end: /\)/,
|
|
1920
2657
|
excludeBegin: true,
|
|
1921
2658
|
excludeEnd: true,
|
|
1922
|
-
keywords: KEYWORDS$
|
|
2659
|
+
keywords: KEYWORDS$12,
|
|
1923
2660
|
contains: PARAMS_CONTAINS
|
|
1924
2661
|
};
|
|
1925
2662
|
const CLASS_OR_EXTENDS = {
|
|
@@ -1929,11 +2666,11 @@ function javascript(hljs) {
|
|
|
1929
2666
|
match: [
|
|
1930
2667
|
/class/,
|
|
1931
2668
|
/\s+/,
|
|
1932
|
-
IDENT_RE$
|
|
2669
|
+
IDENT_RE$12,
|
|
1933
2670
|
/\s+/,
|
|
1934
2671
|
/extends/,
|
|
1935
2672
|
/\s+/,
|
|
1936
|
-
regex.concat(IDENT_RE$
|
|
2673
|
+
regex.concat(IDENT_RE$12, "(", regex.concat(/\./, IDENT_RE$12), ")*")
|
|
1937
2674
|
],
|
|
1938
2675
|
scope: {
|
|
1939
2676
|
1: "keyword",
|
|
@@ -1947,7 +2684,7 @@ function javascript(hljs) {
|
|
|
1947
2684
|
match: [
|
|
1948
2685
|
/class/,
|
|
1949
2686
|
/\s+/,
|
|
1950
|
-
IDENT_RE$
|
|
2687
|
+
IDENT_RE$12
|
|
1951
2688
|
],
|
|
1952
2689
|
scope: {
|
|
1953
2690
|
1: "keyword",
|
|
@@ -1993,7 +2730,7 @@ function javascript(hljs) {
|
|
|
1993
2730
|
match: [
|
|
1994
2731
|
/function/,
|
|
1995
2732
|
/\s+/,
|
|
1996
|
-
IDENT_RE$
|
|
2733
|
+
IDENT_RE$12,
|
|
1997
2734
|
/(?=\s*\()/
|
|
1998
2735
|
]
|
|
1999
2736
|
},
|
|
@@ -2029,7 +2766,7 @@ function javascript(hljs) {
|
|
|
2029
2766
|
"super",
|
|
2030
2767
|
"import"
|
|
2031
2768
|
].map((x) => `${x}\\s*\\(`)),
|
|
2032
|
-
IDENT_RE$
|
|
2769
|
+
IDENT_RE$12,
|
|
2033
2770
|
regex.lookahead(/\s*\(/)
|
|
2034
2771
|
),
|
|
2035
2772
|
className: "title.function",
|
|
@@ -2037,9 +2774,9 @@ function javascript(hljs) {
|
|
|
2037
2774
|
};
|
|
2038
2775
|
const PROPERTY_ACCESS = {
|
|
2039
2776
|
begin: regex.concat(/\./, regex.lookahead(
|
|
2040
|
-
regex.concat(IDENT_RE$
|
|
2777
|
+
regex.concat(IDENT_RE$12, /(?![0-9A-Za-z$_(])/)
|
|
2041
2778
|
)),
|
|
2042
|
-
end: IDENT_RE$
|
|
2779
|
+
end: IDENT_RE$12,
|
|
2043
2780
|
excludeBegin: true,
|
|
2044
2781
|
keywords: "prototype",
|
|
2045
2782
|
className: "property",
|
|
@@ -2049,7 +2786,7 @@ function javascript(hljs) {
|
|
|
2049
2786
|
match: [
|
|
2050
2787
|
/get|set/,
|
|
2051
2788
|
/\s+/,
|
|
2052
|
-
IDENT_RE$
|
|
2789
|
+
IDENT_RE$12,
|
|
2053
2790
|
/(?=\()/
|
|
2054
2791
|
],
|
|
2055
2792
|
className: {
|
|
@@ -2069,7 +2806,7 @@ function javascript(hljs) {
|
|
|
2069
2806
|
match: [
|
|
2070
2807
|
/const|var|let/,
|
|
2071
2808
|
/\s+/,
|
|
2072
|
-
IDENT_RE$
|
|
2809
|
+
IDENT_RE$12,
|
|
2073
2810
|
/\s*/,
|
|
2074
2811
|
/=\s*/,
|
|
2075
2812
|
/(async\s*)?/,
|
|
@@ -2088,7 +2825,7 @@ function javascript(hljs) {
|
|
|
2088
2825
|
return {
|
|
2089
2826
|
name: "JavaScript",
|
|
2090
2827
|
aliases: ["js", "jsx", "mjs", "cjs"],
|
|
2091
|
-
keywords: KEYWORDS$
|
|
2828
|
+
keywords: KEYWORDS$12,
|
|
2092
2829
|
// this will be extended by TypeScript
|
|
2093
2830
|
exports: { PARAMS_CONTAINS, CLASS_REFERENCE },
|
|
2094
2831
|
illegal: /#(?![$_A-z])/,
|
|
@@ -2112,7 +2849,7 @@ function javascript(hljs) {
|
|
|
2112
2849
|
CLASS_REFERENCE,
|
|
2113
2850
|
{
|
|
2114
2851
|
scope: "attr",
|
|
2115
|
-
match: IDENT_RE$
|
|
2852
|
+
match: IDENT_RE$12 + regex.lookahead(":"),
|
|
2116
2853
|
relevance: 0
|
|
2117
2854
|
},
|
|
2118
2855
|
FUNCTION_VARIABLE,
|
|
@@ -2150,7 +2887,7 @@ function javascript(hljs) {
|
|
|
2150
2887
|
end: /\)/,
|
|
2151
2888
|
excludeBegin: true,
|
|
2152
2889
|
excludeEnd: true,
|
|
2153
|
-
keywords: KEYWORDS$
|
|
2890
|
+
keywords: KEYWORDS$12,
|
|
2154
2891
|
contains: PARAMS_CONTAINS
|
|
2155
2892
|
}
|
|
2156
2893
|
]
|
|
@@ -2207,7 +2944,7 @@ function javascript(hljs) {
|
|
|
2207
2944
|
label: "func.def",
|
|
2208
2945
|
contains: [
|
|
2209
2946
|
PARAMS,
|
|
2210
|
-
hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$
|
|
2947
|
+
hljs.inherit(hljs.TITLE_MODE, { begin: IDENT_RE$12, className: "title.function" })
|
|
2211
2948
|
]
|
|
2212
2949
|
},
|
|
2213
2950
|
// catch ... so it won't trigger the property rule below
|
|
@@ -2220,7 +2957,7 @@ function javascript(hljs) {
|
|
|
2220
2957
|
// .keyword()
|
|
2221
2958
|
// $keyword = x
|
|
2222
2959
|
{
|
|
2223
|
-
match: "\\$" + IDENT_RE$
|
|
2960
|
+
match: "\\$" + IDENT_RE$12,
|
|
2224
2961
|
relevance: 0
|
|
2225
2962
|
},
|
|
2226
2963
|
{
|
|
@@ -2239,7 +2976,122 @@ function javascript(hljs) {
|
|
|
2239
2976
|
]
|
|
2240
2977
|
};
|
|
2241
2978
|
}
|
|
2979
|
+
function typescript(hljs) {
|
|
2980
|
+
const regex = hljs.regex;
|
|
2981
|
+
const tsLanguage = javascript(hljs);
|
|
2982
|
+
const IDENT_RE$12 = IDENT_RE;
|
|
2983
|
+
const TYPES2 = [
|
|
2984
|
+
"any",
|
|
2985
|
+
"void",
|
|
2986
|
+
"number",
|
|
2987
|
+
"boolean",
|
|
2988
|
+
"string",
|
|
2989
|
+
"object",
|
|
2990
|
+
"never",
|
|
2991
|
+
"symbol",
|
|
2992
|
+
"bigint",
|
|
2993
|
+
"unknown"
|
|
2994
|
+
];
|
|
2995
|
+
const NAMESPACE = {
|
|
2996
|
+
begin: [
|
|
2997
|
+
/namespace/,
|
|
2998
|
+
/\s+/,
|
|
2999
|
+
hljs.IDENT_RE
|
|
3000
|
+
],
|
|
3001
|
+
beginScope: {
|
|
3002
|
+
1: "keyword",
|
|
3003
|
+
3: "title.class"
|
|
3004
|
+
}
|
|
3005
|
+
};
|
|
3006
|
+
const INTERFACE = {
|
|
3007
|
+
beginKeywords: "interface",
|
|
3008
|
+
end: /\{/,
|
|
3009
|
+
excludeEnd: true,
|
|
3010
|
+
keywords: {
|
|
3011
|
+
keyword: "interface extends",
|
|
3012
|
+
built_in: TYPES2
|
|
3013
|
+
},
|
|
3014
|
+
contains: [tsLanguage.exports.CLASS_REFERENCE]
|
|
3015
|
+
};
|
|
3016
|
+
const USE_STRICT = {
|
|
3017
|
+
className: "meta",
|
|
3018
|
+
relevance: 10,
|
|
3019
|
+
begin: /^\s*['"]use strict['"]/
|
|
3020
|
+
};
|
|
3021
|
+
const TS_SPECIFIC_KEYWORDS = [
|
|
3022
|
+
"type",
|
|
3023
|
+
// "namespace",
|
|
3024
|
+
"interface",
|
|
3025
|
+
"public",
|
|
3026
|
+
"private",
|
|
3027
|
+
"protected",
|
|
3028
|
+
"implements",
|
|
3029
|
+
"declare",
|
|
3030
|
+
"abstract",
|
|
3031
|
+
"readonly",
|
|
3032
|
+
"enum",
|
|
3033
|
+
"override",
|
|
3034
|
+
"satisfies"
|
|
3035
|
+
];
|
|
3036
|
+
const KEYWORDS$12 = {
|
|
3037
|
+
$pattern: IDENT_RE,
|
|
3038
|
+
keyword: KEYWORDS.concat(TS_SPECIFIC_KEYWORDS),
|
|
3039
|
+
literal: LITERALS,
|
|
3040
|
+
built_in: BUILT_INS.concat(TYPES2),
|
|
3041
|
+
"variable.language": BUILT_IN_VARIABLES
|
|
3042
|
+
};
|
|
3043
|
+
const DECORATOR = {
|
|
3044
|
+
className: "meta",
|
|
3045
|
+
begin: "@" + IDENT_RE$12
|
|
3046
|
+
};
|
|
3047
|
+
const swapMode = (mode, label, replacement) => {
|
|
3048
|
+
const indx = mode.contains.findIndex((m) => m.label === label);
|
|
3049
|
+
if (indx === -1) {
|
|
3050
|
+
throw new Error("can not find mode to replace");
|
|
3051
|
+
}
|
|
3052
|
+
mode.contains.splice(indx, 1, replacement);
|
|
3053
|
+
};
|
|
3054
|
+
Object.assign(tsLanguage.keywords, KEYWORDS$12);
|
|
3055
|
+
tsLanguage.exports.PARAMS_CONTAINS.push(DECORATOR);
|
|
3056
|
+
const ATTRIBUTE_HIGHLIGHT = tsLanguage.contains.find((c) => c.scope === "attr");
|
|
3057
|
+
const OPTIONAL_KEY_OR_ARGUMENT = Object.assign(
|
|
3058
|
+
{},
|
|
3059
|
+
ATTRIBUTE_HIGHLIGHT,
|
|
3060
|
+
{ match: regex.concat(IDENT_RE$12, regex.lookahead(/\s*\?:/)) }
|
|
3061
|
+
);
|
|
3062
|
+
tsLanguage.exports.PARAMS_CONTAINS.push([
|
|
3063
|
+
tsLanguage.exports.CLASS_REFERENCE,
|
|
3064
|
+
// class reference for highlighting the params types
|
|
3065
|
+
ATTRIBUTE_HIGHLIGHT,
|
|
3066
|
+
// highlight the params key
|
|
3067
|
+
OPTIONAL_KEY_OR_ARGUMENT
|
|
3068
|
+
// Added for optional property assignment highlighting
|
|
3069
|
+
]);
|
|
3070
|
+
tsLanguage.contains = tsLanguage.contains.concat([
|
|
3071
|
+
DECORATOR,
|
|
3072
|
+
NAMESPACE,
|
|
3073
|
+
INTERFACE,
|
|
3074
|
+
OPTIONAL_KEY_OR_ARGUMENT
|
|
3075
|
+
// Added for optional property assignment highlighting
|
|
3076
|
+
]);
|
|
3077
|
+
swapMode(tsLanguage, "shebang", hljs.SHEBANG());
|
|
3078
|
+
swapMode(tsLanguage, "use_strict", USE_STRICT);
|
|
3079
|
+
const functionDeclaration = tsLanguage.contains.find((m) => m.label === "func.def");
|
|
3080
|
+
functionDeclaration.relevance = 0;
|
|
3081
|
+
Object.assign(tsLanguage, {
|
|
3082
|
+
name: "TypeScript",
|
|
3083
|
+
aliases: [
|
|
3084
|
+
"ts",
|
|
3085
|
+
"tsx",
|
|
3086
|
+
"mts",
|
|
3087
|
+
"cts"
|
|
3088
|
+
]
|
|
3089
|
+
});
|
|
3090
|
+
return tsLanguage;
|
|
3091
|
+
}
|
|
2242
3092
|
export {
|
|
2243
3093
|
HighlightJS as H,
|
|
2244
|
-
|
|
3094
|
+
json as a,
|
|
3095
|
+
javascript$1 as j,
|
|
3096
|
+
typescript as t
|
|
2245
3097
|
};
|