@scalar/code-highlight 0.3.2 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalar/code-highlight
2
2
 
3
+ ## 0.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#8735](https://github.com/scalar/scalar/pull/8735): fix: replace direct cjs mime and curl dependencies with local implementations
8
+
3
9
  ## 0.3.2
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,7 @@
1
+ import type { LanguageFn } from 'highlight.js';
2
+ /**
3
+ * cURL grammar adapted from highlightjs-curl to avoid a CJS dependency.
4
+ */
5
+ declare const curlLanguage: LanguageFn;
6
+ export default curlLanguage;
7
+ //# sourceMappingURL=curl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/languages/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C;;GAEG;AACH,QAAA,MAAM,YAAY,EAAE,UAyFnB,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * cURL grammar adapted from highlightjs-curl to avoid a CJS dependency.
3
+ */
4
+ const curlLanguage = (hljs) => {
5
+ const quoteString = {
6
+ className: 'string',
7
+ begin: /"/,
8
+ end: /"/,
9
+ contains: [
10
+ hljs.BACKSLASH_ESCAPE,
11
+ {
12
+ className: 'variable',
13
+ begin: /\$\(/,
14
+ end: /\)/,
15
+ contains: [hljs.BACKSLASH_ESCAPE],
16
+ },
17
+ ],
18
+ relevance: 0,
19
+ };
20
+ const optionRequest = {
21
+ className: 'literal',
22
+ begin: /(--request|-X)\s/,
23
+ contains: [
24
+ {
25
+ className: 'symbol',
26
+ begin: /(get|post|delete|options|head|put|patch|trace|connect)/,
27
+ end: /\s/,
28
+ returnEnd: true,
29
+ },
30
+ ],
31
+ returnEnd: true,
32
+ relevance: 10,
33
+ };
34
+ const option = {
35
+ className: 'literal',
36
+ begin: /--/,
37
+ end: /[\s"]/,
38
+ returnEnd: true,
39
+ relevance: 0,
40
+ };
41
+ const optionSingle = {
42
+ className: 'literal',
43
+ begin: /-\w/,
44
+ end: /[\s"]/,
45
+ returnEnd: true,
46
+ relevance: 0,
47
+ };
48
+ const escapedQuote = {
49
+ className: 'string',
50
+ begin: /\\"/,
51
+ relevance: 0,
52
+ };
53
+ const aposString = {
54
+ className: 'string',
55
+ begin: /'/,
56
+ end: /'/,
57
+ relevance: 0,
58
+ };
59
+ const number = {
60
+ className: 'number',
61
+ variants: [{ begin: hljs.C_NUMBER_RE }],
62
+ relevance: 0,
63
+ };
64
+ const pathMode = {
65
+ match: /(\/[a-z._-]+)+/,
66
+ };
67
+ return {
68
+ name: 'curl',
69
+ aliases: ['curl'],
70
+ keywords: 'curl',
71
+ case_insensitive: true,
72
+ contains: [
73
+ optionRequest,
74
+ option,
75
+ optionSingle,
76
+ quoteString,
77
+ escapedQuote,
78
+ aposString,
79
+ hljs.APOS_STRING_MODE,
80
+ hljs.QUOTE_STRING_MODE,
81
+ number,
82
+ pathMode,
83
+ ],
84
+ };
85
+ };
86
+ export default curlLanguage;
@@ -24,7 +24,7 @@ export declare const standardLanguages: {
24
24
  readonly cpp: LanguageFn;
25
25
  readonly csharp: LanguageFn;
26
26
  readonly css: LanguageFn;
27
- readonly curl: any;
27
+ readonly curl: LanguageFn;
28
28
  readonly dart: LanguageFn;
29
29
  readonly diff: LanguageFn;
30
30
  readonly docker: LanguageFn;
@@ -1 +1 @@
1
- {"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../../src/languages/standard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAiD9C;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDiB,CAAA"}
1
+ {"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../../src/languages/standard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAgD9C;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDiB,CAAA"}
@@ -43,8 +43,7 @@ import swift from 'highlight.js/lib/languages/swift';
43
43
  import typescript from 'highlight.js/lib/languages/typescript';
44
44
  import xml from 'highlight.js/lib/languages/xml';
45
45
  import yaml from 'highlight.js/lib/languages/yaml';
46
- // @ts-expect-error No types available
47
- import curl from 'highlightjs-curl';
46
+ import curl from './curl.js';
48
47
  /**
49
48
  * We group languages into three categories based on their popularity and usage.
50
49
  * This helps in optimizing the bundle size by allowing users to include only
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "lowlight",
17
17
  "highlightjs"
18
18
  ],
19
- "version": "0.3.2",
19
+ "version": "0.3.3",
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
@@ -73,7 +73,6 @@
73
73
  "dependencies": {
74
74
  "hast-util-to-text": "^4.0.2",
75
75
  "highlight.js": "^11.11.1",
76
- "highlightjs-curl": "^1.3.0",
77
76
  "lowlight": "^3.3.0",
78
77
  "rehype-external-links": "^3.0.0",
79
78
  "rehype-format": "^5.0.1",
@@ -93,12 +92,12 @@
93
92
  "@types/mdast": "^4.0.4",
94
93
  "vfile": "^6.0.3",
95
94
  "vite": "8.0.0",
96
- "@scalar/themes": "0.15.2"
95
+ "@scalar/themes": "0.15.3"
97
96
  },
98
97
  "scripts": {
99
- "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && cp -r src/css dist/css",
98
+ "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && shx cp -r src/css dist/css",
100
99
  "dev": "vite",
101
- "test": "vitest",
100
+ "test": "vitest --run",
102
101
  "types:check": "tsc --noEmit"
103
102
  }
104
103
  }