sugar-high 0.8.3 → 0.9.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/lib/index.js CHANGED
@@ -659,20 +659,21 @@ function generate(tokens) {
659
659
  /** @type {Array<any>} */
660
660
  const lineTokens = (
661
661
  tokens
662
- .map(([type, value]) => (
663
- {
662
+ .map(([type, value]) => {
663
+ const tokenType = TokenTypes[type]
664
+ return {
664
665
  type: 'element',
665
666
  tagName: 'span',
666
667
  children: [{
667
- type, // token type
668
- value: value, // to encode
668
+ type: 'text', // text node
669
+ value, // to encode
669
670
  }],
670
671
  properties: {
671
- className: `sh__token--${TokenTypes[type]}`,
672
- style: { color: `var(--sh-${TokenTypes[type]})` },
672
+ className: `sh__token--${tokenType}`,
673
+ style: { color: `var(--sh-${tokenType})` },
673
674
  },
674
675
  }
675
- ))
676
+ })
676
677
  )
677
678
  lines.push(createLine(lineTokens))
678
679
  }
@@ -0,0 +1,9 @@
1
+ type LanguageConfig = {
2
+ keywords: Set<string>
3
+ onCommentStart(curr: string, next: string): 0 | 1 | 2
4
+ onCommentEnd(prev: string, curr: string): 0 | 1 | 2
5
+ }
6
+
7
+ export const css: LanguageConfig
8
+ export const rust: LanguageConfig
9
+ export const python: LanguageConfig
@@ -0,0 +1,3 @@
1
+ export * as css from './lang/css'
2
+ export * as rust from './lang/rust'
3
+ export * as python from './lang/python'
@@ -0,0 +1,14 @@
1
+ // @ts-check
2
+ export const keywords = new Set([
3
+ // css keywords like @media, @import, @keyframes, etc.
4
+ '@media', '@import', '@keyframes', '@font-face', '@supports', '@page', '@counter-style',
5
+ '@font-feature-values', '@viewport', '@counter-style', '@font-feature-values', '@document',
6
+ ])
7
+
8
+ export const onCommentStart = (currentChar, nextChar) => {
9
+ return '/*' === (currentChar + nextChar) ? 1 : 0
10
+ }
11
+
12
+ export const onCommentEnd = (prevChar, currChar) => {
13
+ return '*/' === (prevChar + currChar) ? 1 : 0
14
+ }
@@ -0,0 +1,14 @@
1
+ // @ts-check
2
+ export const keywords = new Set([
3
+ 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif',
4
+ 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda',
5
+ 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield',
6
+ ])
7
+
8
+ export const onCommentStart = (currentChar, _nextChar) => {
9
+ return currentChar === '#' ? 1 : 0
10
+ }
11
+
12
+ export const onCommentEnd = (_prevChar, currChar) => {
13
+ return currChar === '\n' ? 1 : 0
14
+ }
@@ -0,0 +1,8 @@
1
+ // @ts-check
2
+ export const keywords = new Set([
3
+ 'as', 'break', 'const', 'continue', 'crate', 'else', 'enum', 'extern', 'false', 'fn', 'for',
4
+ 'if', 'impl', 'in', 'let', 'loop', 'match', 'mod', 'move', 'mut', 'pub', 'ref', 'return', 'self',
5
+ 'Self', 'static', 'struct', 'super', 'trait', 'true', 'type', 'unsafe', 'use', 'where', 'while',
6
+ 'async', 'await', 'dyn', 'abstract', 'become', 'box', 'do', 'final', 'macro', 'override',
7
+ 'priv', 'typeof', 'unsized', 'virtual', 'yield', 'try',
8
+ ])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sugar-high",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "types": "./lib/index.d.ts",
6
6
  "main": "./lib/index.js",
@@ -17,7 +17,7 @@
17
17
  "devDependencies": {
18
18
  "@types/node": "22.10.7",
19
19
  "@types/react": "19.0.7",
20
- "codice": "^0.5.0",
20
+ "codice": "^1.0.0",
21
21
  "next": "15.1.5",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0",
@@ -25,5 +25,8 @@
25
25
  "typescript": "5.7.3",
26
26
  "vitest": "^3.0.2"
27
27
  },
28
+ "resolutions": {
29
+ "sugar-high": "link:./"
30
+ },
28
31
  "packageManager": "pnpm@8.7.1"
29
32
  }