jslike 1.3.1 → 1.4.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/bin/jslike.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { readFileSync } from 'fs';
4
4
  import { resolve } from 'path';
5
- import { execute } from '../src/index.js';
5
+ import { execute } from '../dist/index.js';
6
6
 
7
7
  const args = process.argv.slice(2);
8
8
 
@@ -0,0 +1,239 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/editor/monaco/index.js
20
+ var monaco_exports = {};
21
+ __export(monaco_exports, {
22
+ registerWangLanguage: () => registerWangLanguage,
23
+ wangLanguage: () => wangLanguage
24
+ });
25
+ module.exports = __toCommonJS(monaco_exports);
26
+ var wangLanguage = {
27
+ defaultToken: "invalid",
28
+ tokenPostfix: ".wang",
29
+ keywords: [
30
+ "let",
31
+ "const",
32
+ "var",
33
+ "if",
34
+ "else",
35
+ "for",
36
+ "while",
37
+ "do",
38
+ "break",
39
+ "continue",
40
+ "return",
41
+ "function",
42
+ "class",
43
+ "extends",
44
+ "constructor",
45
+ "async",
46
+ "await",
47
+ "import",
48
+ "export",
49
+ "from",
50
+ "as",
51
+ "try",
52
+ "catch",
53
+ "finally",
54
+ "throw",
55
+ "this",
56
+ "super",
57
+ "new",
58
+ "typeof",
59
+ "instanceof",
60
+ "in",
61
+ "of"
62
+ ],
63
+ typeKeywords: [],
64
+ operators: [
65
+ "=>",
66
+ "+=",
67
+ "-=",
68
+ "*=",
69
+ "/=",
70
+ "===",
71
+ "!==",
72
+ "==",
73
+ "!=",
74
+ "<=",
75
+ ">=",
76
+ "<<",
77
+ ">>",
78
+ ">>>",
79
+ "&&",
80
+ "||",
81
+ "??",
82
+ "?.",
83
+ "...",
84
+ "++",
85
+ "--",
86
+ "**",
87
+ "+",
88
+ "-",
89
+ "*",
90
+ "/",
91
+ "%",
92
+ "&",
93
+ "|",
94
+ "^",
95
+ "~",
96
+ "!",
97
+ "?",
98
+ ":",
99
+ "=",
100
+ "<",
101
+ ">"
102
+ ],
103
+ symbols: /[=><!~?:&|+\-*\/\^%]+/,
104
+ escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
105
+ tokenizer: {
106
+ root: [
107
+ // Identifiers and keywords
108
+ [
109
+ /[a-zA-Z_$][\w$]*/,
110
+ {
111
+ cases: {
112
+ "@keywords": "keyword",
113
+ "true|false|null|undefined": "constant",
114
+ "@default": "identifier"
115
+ }
116
+ }
117
+ ],
118
+ // Whitespace
119
+ { include: "@whitespace" },
120
+ // Delimiters and operators
121
+ [/[{}()\[\]]/, "@brackets"],
122
+ [/[<>](?!@symbols)/, "@brackets"],
123
+ [
124
+ /@symbols/,
125
+ {
126
+ cases: {
127
+ "@operators": "operator",
128
+ "@default": ""
129
+ }
130
+ }
131
+ ],
132
+ // Numbers
133
+ [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"],
134
+ [/0[xX][0-9a-fA-F]+/, "number.hex"],
135
+ [/\d+/, "number"],
136
+ // Delimiter
137
+ [/[;,.]/, "delimiter"],
138
+ // Strings
139
+ [/"([^"\\]|\\.)*$/, "string.invalid"],
140
+ [/'([^'\\]|\\.)*$/, "string.invalid"],
141
+ [/"/, "string", "@string_double"],
142
+ [/'/, "string", "@string_single"],
143
+ // Template literals
144
+ [/`/, "string.template", "@template"],
145
+ // Regular expressions
146
+ [/\/(?=([^\/\\]|\\.)+\/)/, "regexp", "@regexp"]
147
+ ],
148
+ whitespace: [
149
+ [/[ \t\r\n]+/, ""],
150
+ [/\/\*/, "comment", "@comment"],
151
+ [/\/\/.*$/, "comment"]
152
+ ],
153
+ comment: [
154
+ [/[^\/*]+/, "comment"],
155
+ [/\*\//, "comment", "@pop"],
156
+ [/[\/*]/, "comment"]
157
+ ],
158
+ string_double: [
159
+ [/[^\\"]+/, "string"],
160
+ [/@escapes/, "string.escape"],
161
+ [/\\./, "string.escape.invalid"],
162
+ [/"/, "string", "@pop"]
163
+ ],
164
+ string_single: [
165
+ [/[^\\']+/, "string"],
166
+ [/@escapes/, "string.escape"],
167
+ [/\\./, "string.escape.invalid"],
168
+ [/'/, "string", "@pop"]
169
+ ],
170
+ template: [
171
+ [/[^`\\$]+/, "string.template"],
172
+ [/@escapes/, "string.escape"],
173
+ [/\\./, "string.escape.invalid"],
174
+ [/\${/, { token: "delimiter.bracket", next: "@templateExpression" }],
175
+ [/`/, "string.template", "@pop"]
176
+ ],
177
+ templateExpression: [[/}/, { token: "delimiter.bracket", next: "@pop" }], { include: "root" }],
178
+ regexp: [
179
+ [
180
+ /(\{)(\d+(?:,\d*)?)(\})/,
181
+ ["regexp.escape.control", "regexp.escape.control", "regexp.escape.control"]
182
+ ],
183
+ [/(\[)([^\]\\]|\\.)*(\])/, "regexp.escape.control"],
184
+ [/(\()(\?:|\?=|\?!)/, ["regexp.escape.control", "regexp.escape.control"]],
185
+ [/[()]/, "regexp.escape.control"],
186
+ [/@escapes/, "regexp.escape"],
187
+ [/\\./, "regexp.escape"],
188
+ [/\/[gimsuy]*/, { token: "regexp", bracket: "@close", next: "@pop" }],
189
+ [/./, "regexp"]
190
+ ]
191
+ }
192
+ };
193
+ function registerWangLanguage(monaco) {
194
+ monaco.languages.register({ id: "wang" });
195
+ monaco.languages.setMonarchTokensProvider("wang", wangLanguage);
196
+ monaco.languages.setLanguageConfiguration("wang", {
197
+ comments: {
198
+ lineComment: "//",
199
+ blockComment: ["/*", "*/"]
200
+ },
201
+ brackets: [
202
+ ["{", "}"],
203
+ ["[", "]"],
204
+ ["(", ")"]
205
+ ],
206
+ autoClosingPairs: [
207
+ { open: "{", close: "}" },
208
+ { open: "[", close: "]" },
209
+ { open: "(", close: ")" },
210
+ { open: '"', close: '"', notIn: ["string"] },
211
+ { open: "'", close: "'", notIn: ["string"] },
212
+ { open: "`", close: "`", notIn: ["string"] },
213
+ { open: "/*", close: "*/" }
214
+ ],
215
+ surroundingPairs: [
216
+ { open: "{", close: "}" },
217
+ { open: "[", close: "]" },
218
+ { open: "(", close: ")" },
219
+ { open: '"', close: '"' },
220
+ { open: "'", close: "'" },
221
+ { open: "`", close: "`" }
222
+ ],
223
+ folding: {
224
+ markers: {
225
+ start: new RegExp("^\\s*//\\s*#?region\\b"),
226
+ end: new RegExp("^\\s*//\\s*#?endregion\\b")
227
+ }
228
+ },
229
+ indentationRules: {
230
+ increaseIndentPattern: new RegExp("^.*(\\{[^}]*|\\([^)]*|\\[[^\\]]*)$"),
231
+ decreaseIndentPattern: new RegExp("^\\s*(\\}|\\)|\\])")
232
+ }
233
+ });
234
+ }
235
+ // Annotate the CommonJS export names for ESM import in node:
236
+ 0 && (module.exports = {
237
+ registerWangLanguage,
238
+ wangLanguage
239
+ });
@@ -1,5 +1,5 @@
1
1
  // Wang Language Definition for Monaco Editor
2
- export const wangLanguage = {
2
+ const wangLanguage = {
3
3
  defaultToken: 'invalid',
4
4
  tokenPostfix: '.wang',
5
5
 
@@ -188,7 +188,7 @@ export const wangLanguage = {
188
188
  };
189
189
 
190
190
  // Register the language with Monaco
191
- export function registerWangLanguage(monaco) {
191
+ function registerWangLanguage(monaco) {
192
192
  monaco.languages.register({ id: 'wang' });
193
193
  monaco.languages.setMonarchTokensProvider('wang', wangLanguage);
194
194
 
@@ -232,3 +232,5 @@ export function registerWangLanguage(monaco) {
232
232
  },
233
233
  });
234
234
  }
235
+
236
+ export { registerWangLanguage, wangLanguage };
@@ -0,0 +1,236 @@
1
+ // Wang Language Definition for Monaco Editor
2
+ const wangLanguage = {
3
+ defaultToken: 'invalid',
4
+ tokenPostfix: '.wang',
5
+
6
+ keywords: [
7
+ 'let',
8
+ 'const',
9
+ 'var',
10
+ 'if',
11
+ 'else',
12
+ 'for',
13
+ 'while',
14
+ 'do',
15
+ 'break',
16
+ 'continue',
17
+ 'return',
18
+ 'function',
19
+ 'class',
20
+ 'extends',
21
+ 'constructor',
22
+ 'async',
23
+ 'await',
24
+ 'import',
25
+ 'export',
26
+ 'from',
27
+ 'as',
28
+ 'try',
29
+ 'catch',
30
+ 'finally',
31
+ 'throw',
32
+ 'this',
33
+ 'super',
34
+ 'new',
35
+ 'typeof',
36
+ 'instanceof',
37
+ 'in',
38
+ 'of',
39
+ ],
40
+
41
+ typeKeywords: [],
42
+
43
+ operators: [
44
+ '=>',
45
+ '+=',
46
+ '-=',
47
+ '*=',
48
+ '/=',
49
+ '===',
50
+ '!==',
51
+ '==',
52
+ '!=',
53
+ '<=',
54
+ '>=',
55
+ '<<',
56
+ '>>',
57
+ '>>>',
58
+ '&&',
59
+ '||',
60
+ '??',
61
+ '?.',
62
+ '...',
63
+ '++',
64
+ '--',
65
+ '**',
66
+ '+',
67
+ '-',
68
+ '*',
69
+ '/',
70
+ '%',
71
+ '&',
72
+ '|',
73
+ '^',
74
+ '~',
75
+ '!',
76
+ '?',
77
+ ':',
78
+ '=',
79
+ '<',
80
+ '>',
81
+ ],
82
+
83
+ symbols: /[=><!~?:&|+\-*\/\^%]+/,
84
+
85
+ escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
86
+
87
+ tokenizer: {
88
+ root: [
89
+ // Identifiers and keywords
90
+ [
91
+ /[a-zA-Z_$][\w$]*/,
92
+ {
93
+ cases: {
94
+ '@keywords': 'keyword',
95
+ 'true|false|null|undefined': 'constant',
96
+ '@default': 'identifier',
97
+ },
98
+ },
99
+ ],
100
+
101
+ // Whitespace
102
+ { include: '@whitespace' },
103
+
104
+ // Delimiters and operators
105
+ [/[{}()\[\]]/, '@brackets'],
106
+ [/[<>](?!@symbols)/, '@brackets'],
107
+ [
108
+ /@symbols/,
109
+ {
110
+ cases: {
111
+ '@operators': 'operator',
112
+ '@default': '',
113
+ },
114
+ },
115
+ ],
116
+
117
+ // Numbers
118
+ [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
119
+ [/0[xX][0-9a-fA-F]+/, 'number.hex'],
120
+ [/\d+/, 'number'],
121
+
122
+ // Delimiter
123
+ [/[;,.]/, 'delimiter'],
124
+
125
+ // Strings
126
+ [/"([^"\\]|\\.)*$/, 'string.invalid'],
127
+ [/'([^'\\]|\\.)*$/, 'string.invalid'],
128
+ [/"/, 'string', '@string_double'],
129
+ [/'/, 'string', '@string_single'],
130
+
131
+ // Template literals
132
+ [/`/, 'string.template', '@template'],
133
+
134
+ // Regular expressions
135
+ [/\/(?=([^\/\\]|\\.)+\/)/, 'regexp', '@regexp'],
136
+ ],
137
+
138
+ whitespace: [
139
+ [/[ \t\r\n]+/, ''],
140
+ [/\/\*/, 'comment', '@comment'],
141
+ [/\/\/.*$/, 'comment'],
142
+ ],
143
+
144
+ comment: [
145
+ [/[^\/*]+/, 'comment'],
146
+ [/\*\//, 'comment', '@pop'],
147
+ [/[\/*]/, 'comment'],
148
+ ],
149
+
150
+ string_double: [
151
+ [/[^\\"]+/, 'string'],
152
+ [/@escapes/, 'string.escape'],
153
+ [/\\./, 'string.escape.invalid'],
154
+ [/"/, 'string', '@pop'],
155
+ ],
156
+
157
+ string_single: [
158
+ [/[^\\']+/, 'string'],
159
+ [/@escapes/, 'string.escape'],
160
+ [/\\./, 'string.escape.invalid'],
161
+ [/'/, 'string', '@pop'],
162
+ ],
163
+
164
+ template: [
165
+ [/[^`\\$]+/, 'string.template'],
166
+ [/@escapes/, 'string.escape'],
167
+ [/\\./, 'string.escape.invalid'],
168
+ [/\${/, { token: 'delimiter.bracket', next: '@templateExpression' }],
169
+ [/`/, 'string.template', '@pop'],
170
+ ],
171
+
172
+ templateExpression: [[/}/, { token: 'delimiter.bracket', next: '@pop' }], { include: 'root' }],
173
+
174
+ regexp: [
175
+ [
176
+ /(\{)(\d+(?:,\d*)?)(\})/,
177
+ ['regexp.escape.control', 'regexp.escape.control', 'regexp.escape.control'],
178
+ ],
179
+ [/(\[)([^\]\\]|\\.)*(\])/, 'regexp.escape.control'],
180
+ [/(\()(\?:|\?=|\?!)/, ['regexp.escape.control', 'regexp.escape.control']],
181
+ [/[()]/, 'regexp.escape.control'],
182
+ [/@escapes/, 'regexp.escape'],
183
+ [/\\./, 'regexp.escape'],
184
+ [/\/[gimsuy]*/, { token: 'regexp', bracket: '@close', next: '@pop' }],
185
+ [/./, 'regexp'],
186
+ ],
187
+ },
188
+ };
189
+
190
+ // Register the language with Monaco
191
+ function registerWangLanguage(monaco) {
192
+ monaco.languages.register({ id: 'wang' });
193
+ monaco.languages.setMonarchTokensProvider('wang', wangLanguage);
194
+
195
+ // Configuration for brackets and auto-closing
196
+ monaco.languages.setLanguageConfiguration('wang', {
197
+ comments: {
198
+ lineComment: '//',
199
+ blockComment: ['/*', '*/'],
200
+ },
201
+ brackets: [
202
+ ['{', '}'],
203
+ ['[', ']'],
204
+ ['(', ')'],
205
+ ],
206
+ autoClosingPairs: [
207
+ { open: '{', close: '}' },
208
+ { open: '[', close: ']' },
209
+ { open: '(', close: ')' },
210
+ { open: '"', close: '"', notIn: ['string'] },
211
+ { open: "'", close: "'", notIn: ['string'] },
212
+ { open: '`', close: '`', notIn: ['string'] },
213
+ { open: '/*', close: '*/' },
214
+ ],
215
+ surroundingPairs: [
216
+ { open: '{', close: '}' },
217
+ { open: '[', close: ']' },
218
+ { open: '(', close: ')' },
219
+ { open: '"', close: '"' },
220
+ { open: "'", close: "'" },
221
+ { open: '`', close: '`' },
222
+ ],
223
+ folding: {
224
+ markers: {
225
+ start: new RegExp('^\\s*//\\s*#?region\\b'),
226
+ end: new RegExp('^\\s*//\\s*#?endregion\\b'),
227
+ },
228
+ },
229
+ indentationRules: {
230
+ increaseIndentPattern: new RegExp('^.*(\\{[^}]*|\\([^)]*|\\[[^\\]]*)$'),
231
+ decreaseIndentPattern: new RegExp('^\\s*(\\}|\\)|\\])'),
232
+ },
233
+ });
234
+ }
235
+
236
+ export { registerWangLanguage, wangLanguage };