@rip-lang/print 1.1.49 → 1.1.50

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.
Files changed (2) hide show
  1. package/hljs-rip.js +74 -11
  2. package/package.json +2 -2
package/hljs-rip.js CHANGED
@@ -1,27 +1,52 @@
1
1
  // highlight.js language definition for Rip
2
- // Derived from the Monarch grammar in docs/index.html
2
+ // https://github.com/nicholasgasior/ghljs
3
3
 
4
4
  export default function(hljs) {
5
5
  const KEYWORDS = [
6
- 'if', 'else', 'unless', 'then', 'switch', 'when', 'for', 'while', 'until',
7
- 'loop', 'do', 'return', 'break', 'continue', 'throw', 'try', 'catch', 'finally',
8
- 'yield', 'await', 'import', 'export', 'from', 'default', 'delete', 'typeof',
9
- 'instanceof', 'new', 'super', 'debugger', 'use', 'own', 'extends', 'in', 'of',
10
- 'by', 'as', 'class', 'def', 'enum', 'interface', 'component', 'render',
6
+ // Control flow
7
+ 'if', 'else', 'unless', 'then', 'switch', 'when',
8
+ 'for', 'while', 'until', 'loop', 'do',
9
+ 'return', 'break', 'continue', 'throw',
10
+ 'try', 'catch', 'finally',
11
+ 'yield', 'await',
12
+ // Modules
13
+ 'import', 'export', 'from', 'default',
14
+ // Operators as keywords
15
+ 'delete', 'typeof', 'instanceof', 'new', 'super',
11
16
  'and', 'or', 'not', 'is', 'isnt',
17
+ // Declarations
18
+ 'class', 'def', 'enum', 'interface', 'extends', 'own',
19
+ // Iteration
20
+ 'in', 'of', 'by', 'as',
21
+ // Component system
22
+ 'component', 'render', 'slot', 'offer', 'accept',
23
+ // Other
24
+ 'use', 'debugger', 'it',
12
25
  ];
13
26
 
14
27
  const LITERALS = [
15
28
  'true', 'false', 'yes', 'no', 'on', 'off',
16
- 'null', 'undefined', 'NaN', 'Infinity',
29
+ 'null', 'undefined', 'NaN', 'Infinity', 'this',
17
30
  ];
18
31
 
19
32
  const BUILT_INS = [
20
33
  'console', 'process', 'require', 'module', 'exports',
21
34
  'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
35
+ 'requestAnimationFrame', 'cancelAnimationFrame',
22
36
  'Promise', 'Array', 'Object', 'String', 'Number', 'Boolean',
23
- 'Math', 'Date', 'RegExp', 'Error', 'JSON', 'Map', 'Set',
24
- 'Symbol', 'Buffer', 'Bun',
37
+ 'Math', 'Date', 'RegExp', 'Error', 'TypeError', 'RangeError',
38
+ 'JSON', 'Map', 'Set', 'WeakMap', 'WeakSet',
39
+ 'Symbol', 'Proxy', 'Reflect',
40
+ 'Buffer', 'Bun',
41
+ 'document', 'window', 'globalThis', 'navigator',
42
+ 'fetch', 'URL', 'URLSearchParams', 'FormData',
43
+ 'Event', 'CustomEvent', 'EventSource',
44
+ 'HTMLElement', 'Node', 'NodeList', 'Element',
45
+ 'DocumentFragment', 'MutationObserver', 'ResizeObserver',
46
+ 'IntersectionObserver',
47
+ // Rip stdlib
48
+ 'p', 'pp', 'abort', 'assert', 'exit', 'kind', 'noop',
49
+ 'raise', 'rand', 'sleep', 'todo', 'warn', 'zip',
25
50
  ];
26
51
 
27
52
  const INTERPOLATION = {
@@ -90,6 +115,11 @@ export default function(hljs) {
90
115
  begin: /@[a-zA-Z_$][\w$]*/,
91
116
  };
92
117
 
118
+ const SIGIL_ATTR = {
119
+ className: 'attribute',
120
+ begin: /\$[a-zA-Z_][\w]*/,
121
+ };
122
+
93
123
  const CLASS_NAME = {
94
124
  className: 'title.class',
95
125
  begin: /[A-Z][\w]*/,
@@ -106,6 +136,24 @@ export default function(hljs) {
106
136
  ],
107
137
  };
108
138
 
139
+ const METHOD_DEF = {
140
+ className: 'function',
141
+ match: /[a-zA-Z_$][\w$]*[!?]?(?=\s*:\s*(?:\([^)]*\)\s*)?[-=]>)/,
142
+ contains: [
143
+ { className: 'title.function', begin: /[a-zA-Z_$][\w$]*[!?]?/ },
144
+ ],
145
+ };
146
+
147
+ const COMPONENT_DEF = {
148
+ className: 'class',
149
+ begin: /\b(?:export\s+)?[A-Z][\w]*\s*=\s*component\b/,
150
+ returnBegin: true,
151
+ keywords: { keyword: ['export', 'component'] },
152
+ contains: [
153
+ { className: 'title.class', begin: /[A-Z][\w]*/ },
154
+ ],
155
+ };
156
+
109
157
  const CLASS_DEF = {
110
158
  className: 'class',
111
159
  beginKeywords: 'class',
@@ -118,7 +166,19 @@ export default function(hljs) {
118
166
 
119
167
  const OPERATORS = {
120
168
  className: 'operator',
121
- begin: /\|>|::=|::|:=|~=|~>|<=>|=!|!\?|=~|\?\?|\?\.|\.\.\.|\.\.|=>|->|\*\*|\/\/|%%|===|!==|==|!=|<=|>=|&&|\|\||[+\-*\/%&|^~<>=!?]/,
169
+ begin: /\|>|::=|::|:=|~=|~>|<=>|\.=|=!|!\?|\?!|=~|\?\?=|\?\?|\?\.|\.\.\.|\.\.|=>|->|\*\*|\/\/|%%|===|!==|==|!=|<=|>=|&&|\|\||[+\-*\/%&|^~<>=!?]/,
170
+ relevance: 0,
171
+ };
172
+
173
+ const TYPE_ANNOTATION = {
174
+ className: 'type',
175
+ begin: /::=?\s*/,
176
+ end: /$/,
177
+ excludeBegin: true,
178
+ contains: [
179
+ { className: 'type', begin: /\b(?:number|string|boolean|void|any|never|unknown|object|symbol|bigint)\b/ },
180
+ { className: 'title.class', begin: /[A-Z][\w]*/ },
181
+ ],
122
182
  relevance: 0,
123
183
  };
124
184
 
@@ -144,13 +204,16 @@ export default function(hljs) {
144
204
  STRING_SINGLE,
145
205
  HEREGEX,
146
206
  REGEX,
207
+ COMPONENT_DEF,
147
208
  FUNCTION_DEF,
209
+ METHOD_DEF,
148
210
  CLASS_DEF,
149
211
  NUMBER,
150
212
  INSTANCE_VAR,
213
+ SIGIL_ATTR,
151
214
  TYPE_KEYWORDS,
152
215
  OPERATORS,
153
- { // inline JS
216
+ { // inline JS (backtick)
154
217
  className: 'string',
155
218
  begin: /`[^`]*`/,
156
219
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/print",
3
- "version": "1.1.49",
3
+ "version": "1.1.50",
4
4
  "description": "Syntax-highlighted source code printer - highlight.js-powered, serves once, auto-opens browser",
5
5
  "type": "module",
6
6
  "main": "print.rip",
@@ -29,7 +29,7 @@
29
29
  "author": "Steve Shreeve <steve.shreeve@gmail.com>",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "rip-lang": ">=3.13.69",
32
+ "rip-lang": ">=3.13.70",
33
33
  "highlight.js": "^11.11.1"
34
34
  },
35
35
  "files": [