diff --git a/CHANGELOG.md b/CHANGELOG.md index 9313a3ddb..f5c398741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Prism Changelog +## 1.29.0-fix.5 (09/17/2024) + +- Fixed subpath exports for CDNs like JSPM.io and TS errors with regexes. [#4](https://github.com/KonnorRogers/prism-esm/pull/4) + ## 1.29.0-fix.2 (11-28-2023) - Added `.d.ts` types. diff --git a/components/prism-cshtml.js b/components/prism-cshtml.js index 87a720160..b7436eb1d 100644 --- a/components/prism-cshtml.js +++ b/components/prism-cshtml.js @@ -83,11 +83,13 @@ export function loader (Prism, options) { /[^<]/.source + '|' + // all tags that are not the start tag + // @ts-expect-error // eslint-disable-next-line regexp/strict /<\/?(?!\1\b)/.source + tagContent + '|' + // nested start tag nested( + // @ts-expect-error // eslint-disable-next-line regexp/strict /<\1/.source + tagAttrs + /\s*>/.source + '(?:' + @@ -95,18 +97,21 @@ export function loader (Prism, options) { /[^<]/.source + '|' + // all tags that are not the start tag + // @ts-expect-error // eslint-disable-next-line regexp/strict /<\/?(?!\1\b)/.source + tagContent + '|' + '' ) + ')*' + + // @ts-expect-error // eslint-disable-next-line regexp/strict /<\/\1\s*>/.source, 2 ) ) + ')*' + + // @ts-expect-error // eslint-disable-next-line regexp/strict /<\/\1\s*>/.source + '|' + diff --git a/components/prism-cue.js b/components/prism-cue.js index a390fe3d4..c9050c47c 100644 --- a/components/prism-cue.js +++ b/components/prism-cue.js @@ -9,14 +9,19 @@ export function loader (Prism, options) { } // https://cuelang.org/docs/references/spec/ + // @ts-expect-error // eslint-disable-next-line regexp/strict var stringEscape = /\\(?:(?!\2)|\2(?:[^()\r\n]|\([^()]*\)))/.source; + // @ts-expect-error // eslint-disable-next-line regexp/strict var stringTypes = /"""(?:[^\\"]|"(?!""\2)|)*"""/.source + + // @ts-expect-error // eslint-disable-next-line regexp/strict '|' + /'''(?:[^\\']|'(?!''\2)|)*'''/.source + + // @ts-expect-error // eslint-disable-next-line regexp/strict '|' + /"(?:[^\\\r\n"]|"(?!\2)|)*"/.source + + // @ts-expect-error // eslint-disable-next-line regexp/strict '|' + /'(?:[^\\\r\n']|'(?!\2)|)*'/.source; var stringLiteral = '(?:' + stringTypes.replace(//g, stringEscape) + ')'; @@ -27,6 +32,7 @@ export function loader (Prism, options) { greedy: true }, 'string-literal': { + // @ts-expect-error // eslint-disable-next-line regexp/strict pattern: RegExp(/(^|[^#"'\\])(#*)/.source + stringLiteral + /(?!["'])\2/.source), lookbehind: true, diff --git a/components/prism-d.js b/components/prism-d.js index 2b62f05a7..b3698a67f 100644 --- a/components/prism-d.js +++ b/components/prism-d.js @@ -48,9 +48,11 @@ export function loader (Prism, options) { /\bq"((?!\d)\w+)$[\s\S]*?^\1"/.source, // q"//", q"||", etc. + // @ts-expect-error // eslint-disable-next-line regexp/strict /\bq"(.)[\s\S]*?\2"/.source, + // @ts-expect-error // eslint-disable-next-line regexp/strict /(["`])(?:\\[\s\S]|(?!\3)[^\\])*\3[cwd]?/.source ].join('|'), 'm'), diff --git a/components/prism-markdown.js b/components/prism-markdown.js index 3094cbc6e..f8584ee05 100644 --- a/components/prism-markdown.js +++ b/components/prism-markdown.js @@ -212,6 +212,7 @@ export function loader (Prism, options) { 'strike': { // ~~strike through~~ // ~strike~ + // @ts-expect-error // eslint-disable-next-line regexp/strict pattern: createInline(/(~~?)(?:(?!~))+\2/.source), lookbehind: true, diff --git a/components/prism-perl.js b/components/prism-perl.js index bf57ab768..af861a8e6 100644 --- a/components/prism-perl.js +++ b/components/prism-perl.js @@ -34,6 +34,7 @@ export function loader (Prism, options) { /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source, // q a...a + // @ts-expect-error // eslint-disable-next-line regexp/strict /([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source, @@ -71,6 +72,7 @@ export function loader (Prism, options) { /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source, // m a...a + // @ts-expect-error // eslint-disable-next-line regexp/strict /([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source, @@ -93,10 +95,12 @@ export function loader (Prism, options) { '(?:' + [ // s/.../.../ + // @ts-expect-error // eslint-disable-next-line regexp/strict /([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2/.source, // s a...a...a + // @ts-expect-error // eslint-disable-next-line regexp/strict /([a-zA-Z0-9])(?:(?!\3)[^\\]|\\[\s\S])*\3(?:(?!\3)[^\\]|\\[\s\S])*\3/.source, diff --git a/package-lock.json b/package-lock.json index bb099924d..9923c3ee2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "regexpp": "^3.2.0", "scslre": "^0.1.6", "simple-git": "^3.3.0", + "typescript": "^5.6.2", "webfont": "^9.0.0", "yargs": "^17.7.2" }, @@ -13952,6 +13953,19 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "node_modules/typescript": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/typical": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", @@ -25811,6 +25825,12 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typescript": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "dev": true + }, "typical": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", diff --git a/package.json b/package.json index 077879d4c..b51c6906d 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,10 @@ "engines": { "node": ">=6" }, + "exports": { + ".": "./prism.js", + "./*": "./*" + }, "files": [ "components/**/*.js", "components/**/*.d.ts", @@ -86,6 +90,7 @@ "regexpp": "^3.2.0", "scslre": "^0.1.6", "simple-git": "^3.3.0", + "typescript": "^5.6.2", "webfont": "^9.0.0", "yargs": "^17.7.2" }, @@ -106,4 +111,4 @@ "prism-core.d.ts" ] } -} +} \ No newline at end of file