1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | function source(re) {
|
11 | if (!re) return null;
|
12 | if (typeof re === "string") return re;
|
13 |
|
14 | return re.source;
|
15 | }
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | function concat(...args) {
|
22 | const joined = args.map((x) => source(x)).join("");
|
23 | return joined;
|
24 | }
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | function stripOptionsFromArgs(args) {
|
31 | const opts = args[args.length - 1];
|
32 |
|
33 | if (typeof opts === 'object' && opts.constructor === Object) {
|
34 | args.splice(args.length - 1, 1);
|
35 | return opts;
|
36 | } else {
|
37 | return {};
|
38 | }
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | function either(...args) {
|
49 |
|
50 | const opts = stripOptionsFromArgs(args);
|
51 | const joined = '('
|
52 | + (opts.capture ? "" : "?:")
|
53 | + args.map((x) => source(x)).join("|") + ")";
|
54 | return joined;
|
55 | }
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | function nsis(hljs) {
|
65 | const LANGUAGE_CONSTANTS = [
|
66 | "ADMINTOOLS",
|
67 | "APPDATA",
|
68 | "CDBURN_AREA",
|
69 | "CMDLINE",
|
70 | "COMMONFILES32",
|
71 | "COMMONFILES64",
|
72 | "COMMONFILES",
|
73 | "COOKIES",
|
74 | "DESKTOP",
|
75 | "DOCUMENTS",
|
76 | "EXEDIR",
|
77 | "EXEFILE",
|
78 | "EXEPATH",
|
79 | "FAVORITES",
|
80 | "FONTS",
|
81 | "HISTORY",
|
82 | "HWNDPARENT",
|
83 | "INSTDIR",
|
84 | "INTERNET_CACHE",
|
85 | "LANGUAGE",
|
86 | "LOCALAPPDATA",
|
87 | "MUSIC",
|
88 | "NETHOOD",
|
89 | "OUTDIR",
|
90 | "PICTURES",
|
91 | "PLUGINSDIR",
|
92 | "PRINTHOOD",
|
93 | "PROFILE",
|
94 | "PROGRAMFILES32",
|
95 | "PROGRAMFILES64",
|
96 | "PROGRAMFILES",
|
97 | "QUICKLAUNCH",
|
98 | "RECENT",
|
99 | "RESOURCES_LOCALIZED",
|
100 | "RESOURCES",
|
101 | "SENDTO",
|
102 | "SMPROGRAMS",
|
103 | "SMSTARTUP",
|
104 | "STARTMENU",
|
105 | "SYSDIR",
|
106 | "TEMP",
|
107 | "TEMPLATES",
|
108 | "VIDEOS",
|
109 | "WINDIR"
|
110 | ];
|
111 |
|
112 | const PARAM_NAMES = [
|
113 | "ARCHIVE",
|
114 | "FILE_ATTRIBUTE_ARCHIVE",
|
115 | "FILE_ATTRIBUTE_NORMAL",
|
116 | "FILE_ATTRIBUTE_OFFLINE",
|
117 | "FILE_ATTRIBUTE_READONLY",
|
118 | "FILE_ATTRIBUTE_SYSTEM",
|
119 | "FILE_ATTRIBUTE_TEMPORARY",
|
120 | "HKCR",
|
121 | "HKCU",
|
122 | "HKDD",
|
123 | "HKEY_CLASSES_ROOT",
|
124 | "HKEY_CURRENT_CONFIG",
|
125 | "HKEY_CURRENT_USER",
|
126 | "HKEY_DYN_DATA",
|
127 | "HKEY_LOCAL_MACHINE",
|
128 | "HKEY_PERFORMANCE_DATA",
|
129 | "HKEY_USERS",
|
130 | "HKLM",
|
131 | "HKPD",
|
132 | "HKU",
|
133 | "IDABORT",
|
134 | "IDCANCEL",
|
135 | "IDIGNORE",
|
136 | "IDNO",
|
137 | "IDOK",
|
138 | "IDRETRY",
|
139 | "IDYES",
|
140 | "MB_ABORTRETRYIGNORE",
|
141 | "MB_DEFBUTTON1",
|
142 | "MB_DEFBUTTON2",
|
143 | "MB_DEFBUTTON3",
|
144 | "MB_DEFBUTTON4",
|
145 | "MB_ICONEXCLAMATION",
|
146 | "MB_ICONINFORMATION",
|
147 | "MB_ICONQUESTION",
|
148 | "MB_ICONSTOP",
|
149 | "MB_OK",
|
150 | "MB_OKCANCEL",
|
151 | "MB_RETRYCANCEL",
|
152 | "MB_RIGHT",
|
153 | "MB_RTLREADING",
|
154 | "MB_SETFOREGROUND",
|
155 | "MB_TOPMOST",
|
156 | "MB_USERICON",
|
157 | "MB_YESNO",
|
158 | "NORMAL",
|
159 | "OFFLINE",
|
160 | "READONLY",
|
161 | "SHCTX",
|
162 | "SHELL_CONTEXT",
|
163 | "SYSTEM|TEMPORARY",
|
164 | ];
|
165 |
|
166 | const COMPILER_FLAGS = [
|
167 | "addincludedir",
|
168 | "addplugindir",
|
169 | "appendfile",
|
170 | "cd",
|
171 | "define",
|
172 | "delfile",
|
173 | "echo",
|
174 | "else",
|
175 | "endif",
|
176 | "error",
|
177 | "execute",
|
178 | "finalize",
|
179 | "getdllversion",
|
180 | "gettlbversion",
|
181 | "if",
|
182 | "ifdef",
|
183 | "ifmacrodef",
|
184 | "ifmacrondef",
|
185 | "ifndef",
|
186 | "include",
|
187 | "insertmacro",
|
188 | "macro",
|
189 | "macroend",
|
190 | "makensis",
|
191 | "packhdr",
|
192 | "searchparse",
|
193 | "searchreplace",
|
194 | "system",
|
195 | "tempfile",
|
196 | "undef",
|
197 | "uninstfinalize",
|
198 | "verbose",
|
199 | "warning",
|
200 | ];
|
201 |
|
202 | const CONSTANTS = {
|
203 | className: 'variable.constant',
|
204 | begin: concat(/\$/, either(...LANGUAGE_CONSTANTS))
|
205 | };
|
206 |
|
207 | const DEFINES = {
|
208 |
|
209 | className: 'variable',
|
210 | begin: /\$+\{[\w.:-]+\}/
|
211 | };
|
212 |
|
213 | const VARIABLES = {
|
214 |
|
215 | className: 'variable',
|
216 | begin: /\$+\w+/,
|
217 | illegal: /\(\)\{\}/
|
218 | };
|
219 |
|
220 | const LANGUAGES = {
|
221 |
|
222 | className: 'variable',
|
223 | begin: /\$+\([\w^.:-]+\)/
|
224 | };
|
225 |
|
226 | const PARAMETERS = {
|
227 |
|
228 | className: 'params',
|
229 | begin: either(...PARAM_NAMES)
|
230 | };
|
231 |
|
232 | const COMPILER = {
|
233 |
|
234 | className: 'keyword',
|
235 | begin: concat(
|
236 | /!/,
|
237 | either(...COMPILER_FLAGS)
|
238 | )
|
239 | };
|
240 |
|
241 | const METACHARS = {
|
242 |
|
243 | className: 'meta',
|
244 | begin: /\$(\\[nrt]|\$)/
|
245 | };
|
246 |
|
247 | const PLUGINS = {
|
248 |
|
249 | className: 'title.function',
|
250 | begin: /\w+::\w+/
|
251 | };
|
252 |
|
253 | const STRING = {
|
254 | className: 'string',
|
255 | variants: [
|
256 | {
|
257 | begin: '"',
|
258 | end: '"'
|
259 | },
|
260 | {
|
261 | begin: '\'',
|
262 | end: '\''
|
263 | },
|
264 | {
|
265 | begin: '`',
|
266 | end: '`'
|
267 | }
|
268 | ],
|
269 | illegal: /\n/,
|
270 | contains: [
|
271 | METACHARS,
|
272 | CONSTANTS,
|
273 | DEFINES,
|
274 | VARIABLES,
|
275 | LANGUAGES
|
276 | ]
|
277 | };
|
278 |
|
279 | const KEYWORDS = [
|
280 | "Abort",
|
281 | "AddBrandingImage",
|
282 | "AddSize",
|
283 | "AllowRootDirInstall",
|
284 | "AllowSkipFiles",
|
285 | "AutoCloseWindow",
|
286 | "BGFont",
|
287 | "BGGradient",
|
288 | "BrandingText",
|
289 | "BringToFront",
|
290 | "Call",
|
291 | "CallInstDLL",
|
292 | "Caption",
|
293 | "ChangeUI",
|
294 | "CheckBitmap",
|
295 | "ClearErrors",
|
296 | "CompletedText",
|
297 | "ComponentText",
|
298 | "CopyFiles",
|
299 | "CRCCheck",
|
300 | "CreateDirectory",
|
301 | "CreateFont",
|
302 | "CreateShortCut",
|
303 | "Delete",
|
304 | "DeleteINISec",
|
305 | "DeleteINIStr",
|
306 | "DeleteRegKey",
|
307 | "DeleteRegValue",
|
308 | "DetailPrint",
|
309 | "DetailsButtonText",
|
310 | "DirText",
|
311 | "DirVar",
|
312 | "DirVerify",
|
313 | "EnableWindow",
|
314 | "EnumRegKey",
|
315 | "EnumRegValue",
|
316 | "Exch",
|
317 | "Exec",
|
318 | "ExecShell",
|
319 | "ExecShellWait",
|
320 | "ExecWait",
|
321 | "ExpandEnvStrings",
|
322 | "File",
|
323 | "FileBufSize",
|
324 | "FileClose",
|
325 | "FileErrorText",
|
326 | "FileOpen",
|
327 | "FileRead",
|
328 | "FileReadByte",
|
329 | "FileReadUTF16LE",
|
330 | "FileReadWord",
|
331 | "FileWriteUTF16LE",
|
332 | "FileSeek",
|
333 | "FileWrite",
|
334 | "FileWriteByte",
|
335 | "FileWriteWord",
|
336 | "FindClose",
|
337 | "FindFirst",
|
338 | "FindNext",
|
339 | "FindWindow",
|
340 | "FlushINI",
|
341 | "GetCurInstType",
|
342 | "GetCurrentAddress",
|
343 | "GetDlgItem",
|
344 | "GetDLLVersion",
|
345 | "GetDLLVersionLocal",
|
346 | "GetErrorLevel",
|
347 | "GetFileTime",
|
348 | "GetFileTimeLocal",
|
349 | "GetFullPathName",
|
350 | "GetFunctionAddress",
|
351 | "GetInstDirError",
|
352 | "GetKnownFolderPath",
|
353 | "GetLabelAddress",
|
354 | "GetTempFileName",
|
355 | "GetWinVer",
|
356 | "Goto",
|
357 | "HideWindow",
|
358 | "Icon",
|
359 | "IfAbort",
|
360 | "IfErrors",
|
361 | "IfFileExists",
|
362 | "IfRebootFlag",
|
363 | "IfRtlLanguage",
|
364 | "IfShellVarContextAll",
|
365 | "IfSilent",
|
366 | "InitPluginsDir",
|
367 | "InstallButtonText",
|
368 | "InstallColors",
|
369 | "InstallDir",
|
370 | "InstallDirRegKey",
|
371 | "InstProgressFlags",
|
372 | "InstType",
|
373 | "InstTypeGetText",
|
374 | "InstTypeSetText",
|
375 | "Int64Cmp",
|
376 | "Int64CmpU",
|
377 | "Int64Fmt",
|
378 | "IntCmp",
|
379 | "IntCmpU",
|
380 | "IntFmt",
|
381 | "IntOp",
|
382 | "IntPtrCmp",
|
383 | "IntPtrCmpU",
|
384 | "IntPtrOp",
|
385 | "IsWindow",
|
386 | "LangString",
|
387 | "LicenseBkColor",
|
388 | "LicenseData",
|
389 | "LicenseForceSelection",
|
390 | "LicenseLangString",
|
391 | "LicenseText",
|
392 | "LoadAndSetImage",
|
393 | "LoadLanguageFile",
|
394 | "LockWindow",
|
395 | "LogSet",
|
396 | "LogText",
|
397 | "ManifestDPIAware",
|
398 | "ManifestLongPathAware",
|
399 | "ManifestMaxVersionTested",
|
400 | "ManifestSupportedOS",
|
401 | "MessageBox",
|
402 | "MiscButtonText",
|
403 | "Name",
|
404 | "Nop",
|
405 | "OutFile",
|
406 | "Page",
|
407 | "PageCallbacks",
|
408 | "PEAddResource",
|
409 | "PEDllCharacteristics",
|
410 | "PERemoveResource",
|
411 | "PESubsysVer",
|
412 | "Pop",
|
413 | "Push",
|
414 | "Quit",
|
415 | "ReadEnvStr",
|
416 | "ReadINIStr",
|
417 | "ReadRegDWORD",
|
418 | "ReadRegStr",
|
419 | "Reboot",
|
420 | "RegDLL",
|
421 | "Rename",
|
422 | "RequestExecutionLevel",
|
423 | "ReserveFile",
|
424 | "Return",
|
425 | "RMDir",
|
426 | "SearchPath",
|
427 | "SectionGetFlags",
|
428 | "SectionGetInstTypes",
|
429 | "SectionGetSize",
|
430 | "SectionGetText",
|
431 | "SectionIn",
|
432 | "SectionSetFlags",
|
433 | "SectionSetInstTypes",
|
434 | "SectionSetSize",
|
435 | "SectionSetText",
|
436 | "SendMessage",
|
437 | "SetAutoClose",
|
438 | "SetBrandingImage",
|
439 | "SetCompress",
|
440 | "SetCompressor",
|
441 | "SetCompressorDictSize",
|
442 | "SetCtlColors",
|
443 | "SetCurInstType",
|
444 | "SetDatablockOptimize",
|
445 | "SetDateSave",
|
446 | "SetDetailsPrint",
|
447 | "SetDetailsView",
|
448 | "SetErrorLevel",
|
449 | "SetErrors",
|
450 | "SetFileAttributes",
|
451 | "SetFont",
|
452 | "SetOutPath",
|
453 | "SetOverwrite",
|
454 | "SetRebootFlag",
|
455 | "SetRegView",
|
456 | "SetShellVarContext",
|
457 | "SetSilent",
|
458 | "ShowInstDetails",
|
459 | "ShowUninstDetails",
|
460 | "ShowWindow",
|
461 | "SilentInstall",
|
462 | "SilentUnInstall",
|
463 | "Sleep",
|
464 | "SpaceTexts",
|
465 | "StrCmp",
|
466 | "StrCmpS",
|
467 | "StrCpy",
|
468 | "StrLen",
|
469 | "SubCaption",
|
470 | "Unicode",
|
471 | "UninstallButtonText",
|
472 | "UninstallCaption",
|
473 | "UninstallIcon",
|
474 | "UninstallSubCaption",
|
475 | "UninstallText",
|
476 | "UninstPage",
|
477 | "UnRegDLL",
|
478 | "Var",
|
479 | "VIAddVersionKey",
|
480 | "VIFileVersion",
|
481 | "VIProductVersion",
|
482 | "WindowIcon",
|
483 | "WriteINIStr",
|
484 | "WriteRegBin",
|
485 | "WriteRegDWORD",
|
486 | "WriteRegExpandStr",
|
487 | "WriteRegMultiStr",
|
488 | "WriteRegNone",
|
489 | "WriteRegStr",
|
490 | "WriteUninstaller",
|
491 | "XPStyle"
|
492 | ];
|
493 |
|
494 | const LITERALS = [
|
495 | "admin",
|
496 | "all",
|
497 | "auto",
|
498 | "both",
|
499 | "bottom",
|
500 | "bzip2",
|
501 | "colored",
|
502 | "components",
|
503 | "current",
|
504 | "custom",
|
505 | "directory",
|
506 | "false",
|
507 | "force",
|
508 | "hide",
|
509 | "highest",
|
510 | "ifdiff",
|
511 | "ifnewer",
|
512 | "instfiles",
|
513 | "lastused",
|
514 | "leave",
|
515 | "left",
|
516 | "license",
|
517 | "listonly",
|
518 | "lzma",
|
519 | "nevershow",
|
520 | "none",
|
521 | "normal",
|
522 | "notset",
|
523 | "off",
|
524 | "on",
|
525 | "open",
|
526 | "print",
|
527 | "right",
|
528 | "show",
|
529 | "silent",
|
530 | "silentlog",
|
531 | "smooth",
|
532 | "textonly",
|
533 | "top",
|
534 | "true",
|
535 | "try",
|
536 | "un.components",
|
537 | "un.custom",
|
538 | "un.directory",
|
539 | "un.instfiles",
|
540 | "un.license",
|
541 | "uninstConfirm",
|
542 | "user",
|
543 | "Win10",
|
544 | "Win7",
|
545 | "Win8",
|
546 | "WinVista",
|
547 | "zlib"
|
548 | ];
|
549 |
|
550 | const FUNCTION_DEF = {
|
551 | match: [
|
552 | /Function/,
|
553 | /\s+/,
|
554 | concat(/(\.)?/, hljs.IDENT_RE)
|
555 | ],
|
556 | scope: {
|
557 | 1: "keyword",
|
558 | 3: "title.function"
|
559 | }
|
560 | };
|
561 |
|
562 | return {
|
563 | name: 'NSIS',
|
564 | case_insensitive: true,
|
565 | keywords: {
|
566 | keyword: KEYWORDS,
|
567 | literal: LITERALS
|
568 | },
|
569 | contains: [
|
570 | hljs.HASH_COMMENT_MODE,
|
571 | hljs.C_BLOCK_COMMENT_MODE,
|
572 | hljs.COMMENT(
|
573 | ';',
|
574 | '$',
|
575 | {
|
576 | relevance: 0
|
577 | }
|
578 | ),
|
579 | FUNCTION_DEF,
|
580 | {
|
581 | beginKeywords: 'Function PageEx Section SectionGroup FunctionEnd SectionEnd',
|
582 | },
|
583 | STRING,
|
584 | COMPILER,
|
585 | DEFINES,
|
586 | VARIABLES,
|
587 | LANGUAGES,
|
588 | PARAMETERS,
|
589 | PLUGINS,
|
590 | hljs.NUMBER_MODE
|
591 | ]
|
592 | };
|
593 | }
|
594 |
|
595 | export { nsis as default };
|