@kg-ui/kg-ui-plus 0.0.1 → 0.0.2
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/dist/es/KgCopilot/CopiContent/AnswerHead.vue.mjs +16 -0
- package/dist/es/KgCopilot/CopiContent/AnswerHead.vue2.mjs +4 -0
- package/dist/es/KgCopilot/CopiContent/UserHead.vue.mjs +26 -0
- package/dist/es/KgCopilot/CopiContent/UserHead.vue2.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue2.mjs +49 -0
- package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue2.mjs +94 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue2.mjs +33 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue2.mjs +140 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue2.mjs +131 -0
- package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiFooter/index.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiFooter/index.vue2.mjs +21 -0
- package/dist/es/KgCopilot/CopiFooter/index.vue3.mjs +4 -0
- package/dist/es/KgCopilot/dialogue.vue.mjs +7 -0
- package/dist/es/KgCopilot/dialogue.vue2.mjs +131 -0
- package/dist/es/KgCopilot/dialogue.vue3.mjs +4 -0
- package/dist/es/KgCopilot/index.vue.mjs +7 -0
- package/dist/es/KgCopilot/index.vue2.mjs +49 -0
- package/dist/es/KgCopilot/index.vue3.mjs +4 -0
- package/dist/es/KgCopilot/mdInCode.mjs +56 -0
- package/dist/es/KgCopilot/readMd.vue.mjs +7 -0
- package/dist/es/KgCopilot/readMd.vue2.mjs +87 -0
- package/dist/es/KgCopilot/readMd.vue3.mjs +4 -0
- package/dist/es/ReIcon/index.mjs +11 -0
- package/dist/es/ReIcon/src/iconfont.mjs +46 -0
- package/dist/es/ReIcon/src/iconifyIconOffline.mjs +30 -0
- package/dist/es/ReIcon/src/iconifyIconOnline.mjs +29 -0
- package/dist/es/_virtual/___vite-browser-external.mjs +6 -0
- package/dist/es/_virtual/__vite-browser-external.mjs +4 -0
- package/dist/es/_virtual/_commonjsHelpers.mjs +34 -0
- package/dist/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
- package/dist/es/_virtual/index.mjs +13 -0
- package/dist/es/api/project.mjs +51 -0
- package/dist/es/directives/heighlight/index.mjs +69 -0
- package/dist/es/directives/index.mjs +4 -0
- package/dist/es/home/LFilter/FilterArea.vue.mjs +7 -0
- package/dist/es/home/LFilter/FilterArea.vue2.mjs +507 -0
- package/dist/es/home/LFilter/FilterArea.vue3.mjs +4 -0
- package/dist/es/home/LFilter/FilterHead.vue.mjs +129 -0
- package/dist/es/home/LFilter/FilterHead.vue2.mjs +4 -0
- package/dist/es/home/LFilter/FilterItem.vue.mjs +7 -0
- package/dist/es/home/LFilter/FilterItem.vue2.mjs +114 -0
- package/dist/es/home/LFilter/FilterItem.vue3.mjs +4 -0
- package/dist/es/home/LFilter/FilterItemIcon.vue.mjs +7 -0
- package/dist/es/home/LFilter/FilterItemIcon.vue2.mjs +171 -0
- package/dist/es/home/LFilter/FilterItemIcon.vue3.mjs +4 -0
- package/dist/es/home/LFilter/index.vue.mjs +17 -0
- package/dist/es/home/LFilter/index.vue2.mjs +4 -0
- package/dist/es/home/LProject/index.vue.mjs +7 -0
- package/dist/es/home/LProject/index.vue2.mjs +70 -0
- package/dist/es/home/LProject/index.vue3.mjs +4 -0
- package/dist/es/home/index.vue.mjs +7 -0
- package/dist/es/home/index.vue2.mjs +80 -0
- package/dist/es/home/index.vue3.mjs +4 -0
- package/dist/es/index.mjs +36 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/check.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/circle-plus.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/close.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/microphone.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/paperclip.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/promotion.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/upload.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/copy-simple.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/speaker-high-light.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/thumbs-down-thin.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/thumbs-up-thin.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/warning-bold.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/add-line.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/arrow-down-s-line.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/arrow-up-s-line.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/check-fill.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/download-line.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/more-2-fill.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@iconify_vue@4.0.0_vue@3.2.45/node_modules/@iconify/vue/dist/iconify.mjs +1702 -0
- package/dist/es/node_modules/.pnpm/@iconify_vue@4.0.0_vue@3.2.45/node_modules/@iconify/vue/dist/offline.mjs +436 -0
- package/dist/es/node_modules/.pnpm/@pureadmin_utils@1.8.5_vue@3.2.45/node_modules/@pureadmin/utils/dist/index.mjs +70 -0
- package/dist/es/node_modules/.pnpm/call-bind@1.0.7/node_modules/call-bind/callBound.mjs +16 -0
- package/dist/es/node_modules/.pnpm/call-bind@1.0.7/node_modules/call-bind/index.mjs +36 -0
- package/dist/es/node_modules/.pnpm/define-data-property@1.1.4/node_modules/define-data-property/index.mjs +48 -0
- package/dist/es/node_modules/.pnpm/dompurify@3.0.10/node_modules/dompurify/dist/purify.es.mjs +949 -0
- package/dist/es/node_modules/.pnpm/es-define-property@1.0.0/node_modules/es-define-property/index.mjs +22 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/eval.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/ref.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/syntax.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.mjs +4 -0
- package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.mjs +4 -0
- package/dist/es/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.mjs +72 -0
- package/dist/es/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.mjs +6 -0
- package/dist/es/node_modules/.pnpm/get-intrinsic@1.2.4/node_modules/get-intrinsic/index.mjs +320 -0
- package/dist/es/node_modules/.pnpm/gopd@1.0.1/node_modules/gopd/index.mjs +14 -0
- package/dist/es/node_modules/.pnpm/has-property-descriptors@1.0.2/node_modules/has-property-descriptors/index.mjs +19 -0
- package/dist/es/node_modules/.pnpm/has-proto@1.0.3/node_modules/has-proto/index.mjs +11 -0
- package/dist/es/node_modules/.pnpm/has-symbols@1.0.3/node_modules/has-symbols/index.mjs +21 -0
- package/dist/es/node_modules/.pnpm/has-symbols@1.0.3/node_modules/has-symbols/shams.mjs +48 -0
- package/dist/es/node_modules/.pnpm/hasown@2.0.2/node_modules/hasown/index.mjs +8 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/core.mjs +5 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/apache.mjs +91 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/bash.mjs +377 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/basic.mjs +221 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/c.mjs +280 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/css.mjs +732 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dart.mjs +247 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/django.mjs +47 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dns.mjs +71 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dos.mjs +160 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dust.mjs +38 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/erlang.mjs +176 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/go.mjs +135 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/http.mjs +89 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/java.mjs +254 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/javascript.mjs +698 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/json.mjs +40 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/markdown.mjs +227 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/nginx.mjs +144 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/php.mjs +589 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/python.mjs +414 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/ruby.mjs +414 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/stylus.mjs +766 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/swift.mjs +832 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/typescript.mjs +788 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/xml.mjs +227 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/lib/core.mjs +1580 -0
- package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/styles/paraiso-light.css.mjs +4 -0
- package/dist/es/node_modules/.pnpm/marked@12.0.1/node_modules/marked/lib/marked.esm.mjs +2045 -0
- package/dist/es/node_modules/.pnpm/object-inspect@1.13.1/node_modules/object-inspect/index.mjs +514 -0
- package/dist/es/node_modules/.pnpm/pinyin-match@1.2.4/node_modules/pinyin-match/es/main.mjs +124 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/formats.mjs +22 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/index.mjs +14 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/parse.mjs +199 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/stringify.mjs +262 -0
- package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/utils.mjs +196 -0
- package/dist/es/node_modules/.pnpm/set-function-length@1.2.2/node_modules/set-function-length/index.mjs +54 -0
- package/dist/es/node_modules/.pnpm/side-channel@1.0.6/node_modules/side-channel/index.mjs +115 -0
- package/dist/es/store/index.mjs +8 -0
- package/dist/es/store/modules/copilot.mjs +108 -0
- package/dist/es/store/modules/filters.mjs +346 -0
- package/dist/es/store/modules/types.mjs +19 -0
- package/dist/es/style/index.scss.mjs +4 -0
- package/dist/es/style/tailwind.css.mjs +4 -0
- package/dist/es/style.css +1 -0
- package/dist/es/utils/home.mjs +129 -0
- package/dist/es/utils/http/index.mjs +90 -0
- package/dist/es/utils/message.mjs +42 -0
- package/package.json +1 -1
@@ -0,0 +1,832 @@
|
|
1
|
+
function source(re) {
|
2
|
+
if (!re)
|
3
|
+
return null;
|
4
|
+
if (typeof re === "string")
|
5
|
+
return re;
|
6
|
+
return re.source;
|
7
|
+
}
|
8
|
+
function lookahead(re) {
|
9
|
+
return concat("(?=", re, ")");
|
10
|
+
}
|
11
|
+
function concat(...args) {
|
12
|
+
const joined = args.map((x) => source(x)).join("");
|
13
|
+
return joined;
|
14
|
+
}
|
15
|
+
function stripOptionsFromArgs(args) {
|
16
|
+
const opts = args[args.length - 1];
|
17
|
+
if (typeof opts === "object" && opts.constructor === Object) {
|
18
|
+
args.splice(args.length - 1, 1);
|
19
|
+
return opts;
|
20
|
+
} else {
|
21
|
+
return {};
|
22
|
+
}
|
23
|
+
}
|
24
|
+
function either(...args) {
|
25
|
+
const opts = stripOptionsFromArgs(args);
|
26
|
+
const joined = "(" + (opts.capture ? "" : "?:") + args.map((x) => source(x)).join("|") + ")";
|
27
|
+
return joined;
|
28
|
+
}
|
29
|
+
const keywordWrapper = (keyword) => concat(
|
30
|
+
/\b/,
|
31
|
+
keyword,
|
32
|
+
/\w$/.test(keyword) ? /\b/ : /\B/
|
33
|
+
);
|
34
|
+
const dotKeywords = [
|
35
|
+
"Protocol",
|
36
|
+
// contextual
|
37
|
+
"Type"
|
38
|
+
// contextual
|
39
|
+
].map(keywordWrapper);
|
40
|
+
const optionalDotKeywords = [
|
41
|
+
"init",
|
42
|
+
"self"
|
43
|
+
].map(keywordWrapper);
|
44
|
+
const keywordTypes = [
|
45
|
+
"Any",
|
46
|
+
"Self"
|
47
|
+
];
|
48
|
+
const keywords = [
|
49
|
+
// strings below will be fed into the regular `keywords` engine while regex
|
50
|
+
// will result in additional modes being created to scan for those keywords to
|
51
|
+
// avoid conflicts with other rules
|
52
|
+
"actor",
|
53
|
+
"any",
|
54
|
+
// contextual
|
55
|
+
"associatedtype",
|
56
|
+
"async",
|
57
|
+
"await",
|
58
|
+
/as\?/,
|
59
|
+
// operator
|
60
|
+
/as!/,
|
61
|
+
// operator
|
62
|
+
"as",
|
63
|
+
// operator
|
64
|
+
"borrowing",
|
65
|
+
// contextual
|
66
|
+
"break",
|
67
|
+
"case",
|
68
|
+
"catch",
|
69
|
+
"class",
|
70
|
+
"consume",
|
71
|
+
// contextual
|
72
|
+
"consuming",
|
73
|
+
// contextual
|
74
|
+
"continue",
|
75
|
+
"convenience",
|
76
|
+
// contextual
|
77
|
+
"copy",
|
78
|
+
// contextual
|
79
|
+
"default",
|
80
|
+
"defer",
|
81
|
+
"deinit",
|
82
|
+
"didSet",
|
83
|
+
// contextual
|
84
|
+
"distributed",
|
85
|
+
"do",
|
86
|
+
"dynamic",
|
87
|
+
// contextual
|
88
|
+
"each",
|
89
|
+
"else",
|
90
|
+
"enum",
|
91
|
+
"extension",
|
92
|
+
"fallthrough",
|
93
|
+
/fileprivate\(set\)/,
|
94
|
+
"fileprivate",
|
95
|
+
"final",
|
96
|
+
// contextual
|
97
|
+
"for",
|
98
|
+
"func",
|
99
|
+
"get",
|
100
|
+
// contextual
|
101
|
+
"guard",
|
102
|
+
"if",
|
103
|
+
"import",
|
104
|
+
"indirect",
|
105
|
+
// contextual
|
106
|
+
"infix",
|
107
|
+
// contextual
|
108
|
+
/init\?/,
|
109
|
+
/init!/,
|
110
|
+
"inout",
|
111
|
+
/internal\(set\)/,
|
112
|
+
"internal",
|
113
|
+
"in",
|
114
|
+
"is",
|
115
|
+
// operator
|
116
|
+
"isolated",
|
117
|
+
// contextual
|
118
|
+
"nonisolated",
|
119
|
+
// contextual
|
120
|
+
"lazy",
|
121
|
+
// contextual
|
122
|
+
"let",
|
123
|
+
"macro",
|
124
|
+
"mutating",
|
125
|
+
// contextual
|
126
|
+
"nonmutating",
|
127
|
+
// contextual
|
128
|
+
/open\(set\)/,
|
129
|
+
// contextual
|
130
|
+
"open",
|
131
|
+
// contextual
|
132
|
+
"operator",
|
133
|
+
"optional",
|
134
|
+
// contextual
|
135
|
+
"override",
|
136
|
+
// contextual
|
137
|
+
"postfix",
|
138
|
+
// contextual
|
139
|
+
"precedencegroup",
|
140
|
+
"prefix",
|
141
|
+
// contextual
|
142
|
+
/private\(set\)/,
|
143
|
+
"private",
|
144
|
+
"protocol",
|
145
|
+
/public\(set\)/,
|
146
|
+
"public",
|
147
|
+
"repeat",
|
148
|
+
"required",
|
149
|
+
// contextual
|
150
|
+
"rethrows",
|
151
|
+
"return",
|
152
|
+
"set",
|
153
|
+
// contextual
|
154
|
+
"some",
|
155
|
+
// contextual
|
156
|
+
"static",
|
157
|
+
"struct",
|
158
|
+
"subscript",
|
159
|
+
"super",
|
160
|
+
"switch",
|
161
|
+
"throws",
|
162
|
+
"throw",
|
163
|
+
/try\?/,
|
164
|
+
// operator
|
165
|
+
/try!/,
|
166
|
+
// operator
|
167
|
+
"try",
|
168
|
+
// operator
|
169
|
+
"typealias",
|
170
|
+
/unowned\(safe\)/,
|
171
|
+
// contextual
|
172
|
+
/unowned\(unsafe\)/,
|
173
|
+
// contextual
|
174
|
+
"unowned",
|
175
|
+
// contextual
|
176
|
+
"var",
|
177
|
+
"weak",
|
178
|
+
// contextual
|
179
|
+
"where",
|
180
|
+
"while",
|
181
|
+
"willSet"
|
182
|
+
// contextual
|
183
|
+
];
|
184
|
+
const literals = [
|
185
|
+
"false",
|
186
|
+
"nil",
|
187
|
+
"true"
|
188
|
+
];
|
189
|
+
const precedencegroupKeywords = [
|
190
|
+
"assignment",
|
191
|
+
"associativity",
|
192
|
+
"higherThan",
|
193
|
+
"left",
|
194
|
+
"lowerThan",
|
195
|
+
"none",
|
196
|
+
"right"
|
197
|
+
];
|
198
|
+
const numberSignKeywords = [
|
199
|
+
"#colorLiteral",
|
200
|
+
"#column",
|
201
|
+
"#dsohandle",
|
202
|
+
"#else",
|
203
|
+
"#elseif",
|
204
|
+
"#endif",
|
205
|
+
"#error",
|
206
|
+
"#file",
|
207
|
+
"#fileID",
|
208
|
+
"#fileLiteral",
|
209
|
+
"#filePath",
|
210
|
+
"#function",
|
211
|
+
"#if",
|
212
|
+
"#imageLiteral",
|
213
|
+
"#keyPath",
|
214
|
+
"#line",
|
215
|
+
"#selector",
|
216
|
+
"#sourceLocation",
|
217
|
+
"#warning"
|
218
|
+
];
|
219
|
+
const builtIns = [
|
220
|
+
"abs",
|
221
|
+
"all",
|
222
|
+
"any",
|
223
|
+
"assert",
|
224
|
+
"assertionFailure",
|
225
|
+
"debugPrint",
|
226
|
+
"dump",
|
227
|
+
"fatalError",
|
228
|
+
"getVaList",
|
229
|
+
"isKnownUniquelyReferenced",
|
230
|
+
"max",
|
231
|
+
"min",
|
232
|
+
"numericCast",
|
233
|
+
"pointwiseMax",
|
234
|
+
"pointwiseMin",
|
235
|
+
"precondition",
|
236
|
+
"preconditionFailure",
|
237
|
+
"print",
|
238
|
+
"readLine",
|
239
|
+
"repeatElement",
|
240
|
+
"sequence",
|
241
|
+
"stride",
|
242
|
+
"swap",
|
243
|
+
"swift_unboxFromSwiftValueWithType",
|
244
|
+
"transcode",
|
245
|
+
"type",
|
246
|
+
"unsafeBitCast",
|
247
|
+
"unsafeDowncast",
|
248
|
+
"withExtendedLifetime",
|
249
|
+
"withUnsafeMutablePointer",
|
250
|
+
"withUnsafePointer",
|
251
|
+
"withVaList",
|
252
|
+
"withoutActuallyEscaping",
|
253
|
+
"zip"
|
254
|
+
];
|
255
|
+
const operatorHead = either(
|
256
|
+
/[/=\-+!*%<>&|^~?]/,
|
257
|
+
/[\u00A1-\u00A7]/,
|
258
|
+
/[\u00A9\u00AB]/,
|
259
|
+
/[\u00AC\u00AE]/,
|
260
|
+
/[\u00B0\u00B1]/,
|
261
|
+
/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,
|
262
|
+
/[\u2016-\u2017]/,
|
263
|
+
/[\u2020-\u2027]/,
|
264
|
+
/[\u2030-\u203E]/,
|
265
|
+
/[\u2041-\u2053]/,
|
266
|
+
/[\u2055-\u205E]/,
|
267
|
+
/[\u2190-\u23FF]/,
|
268
|
+
/[\u2500-\u2775]/,
|
269
|
+
/[\u2794-\u2BFF]/,
|
270
|
+
/[\u2E00-\u2E7F]/,
|
271
|
+
/[\u3001-\u3003]/,
|
272
|
+
/[\u3008-\u3020]/,
|
273
|
+
/[\u3030]/
|
274
|
+
);
|
275
|
+
const operatorCharacter = either(
|
276
|
+
operatorHead,
|
277
|
+
/[\u0300-\u036F]/,
|
278
|
+
/[\u1DC0-\u1DFF]/,
|
279
|
+
/[\u20D0-\u20FF]/,
|
280
|
+
/[\uFE00-\uFE0F]/,
|
281
|
+
/[\uFE20-\uFE2F]/
|
282
|
+
// TODO: The following characters are also allowed, but the regex isn't supported yet.
|
283
|
+
// /[\u{E0100}-\u{E01EF}]/u
|
284
|
+
);
|
285
|
+
const operator = concat(operatorHead, operatorCharacter, "*");
|
286
|
+
const identifierHead = either(
|
287
|
+
/[a-zA-Z_]/,
|
288
|
+
/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,
|
289
|
+
/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,
|
290
|
+
/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,
|
291
|
+
/[\u1E00-\u1FFF]/,
|
292
|
+
/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,
|
293
|
+
/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,
|
294
|
+
/[\u2C00-\u2DFF\u2E80-\u2FFF]/,
|
295
|
+
/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,
|
296
|
+
/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,
|
297
|
+
/[\uFE47-\uFEFE\uFF00-\uFFFD]/
|
298
|
+
// Should be /[\uFE47-\uFFFD]/, but we have to exclude FEFF.
|
299
|
+
// The following characters are also allowed, but the regexes aren't supported yet.
|
300
|
+
// /[\u{10000}-\u{1FFFD}\u{20000-\u{2FFFD}\u{30000}-\u{3FFFD}\u{40000}-\u{4FFFD}]/u,
|
301
|
+
// /[\u{50000}-\u{5FFFD}\u{60000-\u{6FFFD}\u{70000}-\u{7FFFD}\u{80000}-\u{8FFFD}]/u,
|
302
|
+
// /[\u{90000}-\u{9FFFD}\u{A0000-\u{AFFFD}\u{B0000}-\u{BFFFD}\u{C0000}-\u{CFFFD}]/u,
|
303
|
+
// /[\u{D0000}-\u{DFFFD}\u{E0000-\u{EFFFD}]/u
|
304
|
+
);
|
305
|
+
const identifierCharacter = either(
|
306
|
+
identifierHead,
|
307
|
+
/\d/,
|
308
|
+
/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/
|
309
|
+
);
|
310
|
+
const identifier = concat(identifierHead, identifierCharacter, "*");
|
311
|
+
const typeIdentifier = concat(/[A-Z]/, identifierCharacter, "*");
|
312
|
+
const keywordAttributes = [
|
313
|
+
"attached",
|
314
|
+
"autoclosure",
|
315
|
+
concat(/convention\(/, either("swift", "block", "c"), /\)/),
|
316
|
+
"discardableResult",
|
317
|
+
"dynamicCallable",
|
318
|
+
"dynamicMemberLookup",
|
319
|
+
"escaping",
|
320
|
+
"freestanding",
|
321
|
+
"frozen",
|
322
|
+
"GKInspectable",
|
323
|
+
"IBAction",
|
324
|
+
"IBDesignable",
|
325
|
+
"IBInspectable",
|
326
|
+
"IBOutlet",
|
327
|
+
"IBSegueAction",
|
328
|
+
"inlinable",
|
329
|
+
"main",
|
330
|
+
"nonobjc",
|
331
|
+
"NSApplicationMain",
|
332
|
+
"NSCopying",
|
333
|
+
"NSManaged",
|
334
|
+
concat(/objc\(/, identifier, /\)/),
|
335
|
+
"objc",
|
336
|
+
"objcMembers",
|
337
|
+
"propertyWrapper",
|
338
|
+
"requires_stored_property_inits",
|
339
|
+
"resultBuilder",
|
340
|
+
"Sendable",
|
341
|
+
"testable",
|
342
|
+
"UIApplicationMain",
|
343
|
+
"unchecked",
|
344
|
+
"unknown",
|
345
|
+
"usableFromInline",
|
346
|
+
"warn_unqualified_access"
|
347
|
+
];
|
348
|
+
const availabilityKeywords = [
|
349
|
+
"iOS",
|
350
|
+
"iOSApplicationExtension",
|
351
|
+
"macOS",
|
352
|
+
"macOSApplicationExtension",
|
353
|
+
"macCatalyst",
|
354
|
+
"macCatalystApplicationExtension",
|
355
|
+
"watchOS",
|
356
|
+
"watchOSApplicationExtension",
|
357
|
+
"tvOS",
|
358
|
+
"tvOSApplicationExtension",
|
359
|
+
"swift"
|
360
|
+
];
|
361
|
+
function swift(hljs) {
|
362
|
+
const WHITESPACE = {
|
363
|
+
match: /\s+/,
|
364
|
+
relevance: 0
|
365
|
+
};
|
366
|
+
const BLOCK_COMMENT = hljs.COMMENT(
|
367
|
+
"/\\*",
|
368
|
+
"\\*/",
|
369
|
+
{ contains: ["self"] }
|
370
|
+
);
|
371
|
+
const COMMENTS = [
|
372
|
+
hljs.C_LINE_COMMENT_MODE,
|
373
|
+
BLOCK_COMMENT
|
374
|
+
];
|
375
|
+
const DOT_KEYWORD = {
|
376
|
+
match: [
|
377
|
+
/\./,
|
378
|
+
either(...dotKeywords, ...optionalDotKeywords)
|
379
|
+
],
|
380
|
+
className: { 2: "keyword" }
|
381
|
+
};
|
382
|
+
const KEYWORD_GUARD = {
|
383
|
+
// Consume .keyword to prevent highlighting properties and methods as keywords.
|
384
|
+
match: concat(/\./, either(...keywords)),
|
385
|
+
relevance: 0
|
386
|
+
};
|
387
|
+
const PLAIN_KEYWORDS = keywords.filter((kw) => typeof kw === "string").concat(["_|0"]);
|
388
|
+
const REGEX_KEYWORDS = keywords.filter((kw) => typeof kw !== "string").concat(keywordTypes).map(keywordWrapper);
|
389
|
+
const KEYWORD = { variants: [
|
390
|
+
{
|
391
|
+
className: "keyword",
|
392
|
+
match: either(...REGEX_KEYWORDS, ...optionalDotKeywords)
|
393
|
+
}
|
394
|
+
] };
|
395
|
+
const KEYWORDS = {
|
396
|
+
$pattern: either(
|
397
|
+
/\b\w+/,
|
398
|
+
// regular keywords
|
399
|
+
/#\w+/
|
400
|
+
// number keywords
|
401
|
+
),
|
402
|
+
keyword: PLAIN_KEYWORDS.concat(numberSignKeywords),
|
403
|
+
literal: literals
|
404
|
+
};
|
405
|
+
const KEYWORD_MODES = [
|
406
|
+
DOT_KEYWORD,
|
407
|
+
KEYWORD_GUARD,
|
408
|
+
KEYWORD
|
409
|
+
];
|
410
|
+
const BUILT_IN_GUARD = {
|
411
|
+
// Consume .built_in to prevent highlighting properties and methods.
|
412
|
+
match: concat(/\./, either(...builtIns)),
|
413
|
+
relevance: 0
|
414
|
+
};
|
415
|
+
const BUILT_IN = {
|
416
|
+
className: "built_in",
|
417
|
+
match: concat(/\b/, either(...builtIns), /(?=\()/)
|
418
|
+
};
|
419
|
+
const BUILT_INS = [
|
420
|
+
BUILT_IN_GUARD,
|
421
|
+
BUILT_IN
|
422
|
+
];
|
423
|
+
const OPERATOR_GUARD = {
|
424
|
+
// Prevent -> from being highlighting as an operator.
|
425
|
+
match: /->/,
|
426
|
+
relevance: 0
|
427
|
+
};
|
428
|
+
const OPERATOR = {
|
429
|
+
className: "operator",
|
430
|
+
relevance: 0,
|
431
|
+
variants: [
|
432
|
+
{ match: operator },
|
433
|
+
{
|
434
|
+
// dot-operator: only operators that start with a dot are allowed to use dots as
|
435
|
+
// characters (..., ...<, .*, etc). So there rule here is: a dot followed by one or more
|
436
|
+
// characters that may also include dots.
|
437
|
+
match: `\\.(\\.|${operatorCharacter})+`
|
438
|
+
}
|
439
|
+
]
|
440
|
+
};
|
441
|
+
const OPERATORS = [
|
442
|
+
OPERATOR_GUARD,
|
443
|
+
OPERATOR
|
444
|
+
];
|
445
|
+
const decimalDigits = "([0-9]_*)+";
|
446
|
+
const hexDigits = "([0-9a-fA-F]_*)+";
|
447
|
+
const NUMBER = {
|
448
|
+
className: "number",
|
449
|
+
relevance: 0,
|
450
|
+
variants: [
|
451
|
+
// decimal floating-point-literal (subsumes decimal-literal)
|
452
|
+
{ match: `\\b(${decimalDigits})(\\.(${decimalDigits}))?([eE][+-]?(${decimalDigits}))?\\b` },
|
453
|
+
// hexadecimal floating-point-literal (subsumes hexadecimal-literal)
|
454
|
+
{ match: `\\b0x(${hexDigits})(\\.(${hexDigits}))?([pP][+-]?(${decimalDigits}))?\\b` },
|
455
|
+
// octal-literal
|
456
|
+
{ match: /\b0o([0-7]_*)+\b/ },
|
457
|
+
// binary-literal
|
458
|
+
{ match: /\b0b([01]_*)+\b/ }
|
459
|
+
]
|
460
|
+
};
|
461
|
+
const ESCAPED_CHARACTER = (rawDelimiter = "") => ({
|
462
|
+
className: "subst",
|
463
|
+
variants: [
|
464
|
+
{ match: concat(/\\/, rawDelimiter, /[0\\tnr"']/) },
|
465
|
+
{ match: concat(/\\/, rawDelimiter, /u\{[0-9a-fA-F]{1,8}\}/) }
|
466
|
+
]
|
467
|
+
});
|
468
|
+
const ESCAPED_NEWLINE = (rawDelimiter = "") => ({
|
469
|
+
className: "subst",
|
470
|
+
match: concat(/\\/, rawDelimiter, /[\t ]*(?:[\r\n]|\r\n)/)
|
471
|
+
});
|
472
|
+
const INTERPOLATION = (rawDelimiter = "") => ({
|
473
|
+
className: "subst",
|
474
|
+
label: "interpol",
|
475
|
+
begin: concat(/\\/, rawDelimiter, /\(/),
|
476
|
+
end: /\)/
|
477
|
+
});
|
478
|
+
const MULTILINE_STRING = (rawDelimiter = "") => ({
|
479
|
+
begin: concat(rawDelimiter, /"""/),
|
480
|
+
end: concat(/"""/, rawDelimiter),
|
481
|
+
contains: [
|
482
|
+
ESCAPED_CHARACTER(rawDelimiter),
|
483
|
+
ESCAPED_NEWLINE(rawDelimiter),
|
484
|
+
INTERPOLATION(rawDelimiter)
|
485
|
+
]
|
486
|
+
});
|
487
|
+
const SINGLE_LINE_STRING = (rawDelimiter = "") => ({
|
488
|
+
begin: concat(rawDelimiter, /"/),
|
489
|
+
end: concat(/"/, rawDelimiter),
|
490
|
+
contains: [
|
491
|
+
ESCAPED_CHARACTER(rawDelimiter),
|
492
|
+
INTERPOLATION(rawDelimiter)
|
493
|
+
]
|
494
|
+
});
|
495
|
+
const STRING = {
|
496
|
+
className: "string",
|
497
|
+
variants: [
|
498
|
+
MULTILINE_STRING(),
|
499
|
+
MULTILINE_STRING("#"),
|
500
|
+
MULTILINE_STRING("##"),
|
501
|
+
MULTILINE_STRING("###"),
|
502
|
+
SINGLE_LINE_STRING(),
|
503
|
+
SINGLE_LINE_STRING("#"),
|
504
|
+
SINGLE_LINE_STRING("##"),
|
505
|
+
SINGLE_LINE_STRING("###")
|
506
|
+
]
|
507
|
+
};
|
508
|
+
const REGEXP_CONTENTS = [
|
509
|
+
hljs.BACKSLASH_ESCAPE,
|
510
|
+
{
|
511
|
+
begin: /\[/,
|
512
|
+
end: /\]/,
|
513
|
+
relevance: 0,
|
514
|
+
contains: [hljs.BACKSLASH_ESCAPE]
|
515
|
+
}
|
516
|
+
];
|
517
|
+
const BARE_REGEXP_LITERAL = {
|
518
|
+
begin: /\/[^\s](?=[^/\n]*\/)/,
|
519
|
+
end: /\//,
|
520
|
+
contains: REGEXP_CONTENTS
|
521
|
+
};
|
522
|
+
const EXTENDED_REGEXP_LITERAL = (rawDelimiter) => {
|
523
|
+
const begin = concat(rawDelimiter, /\//);
|
524
|
+
const end = concat(/\//, rawDelimiter);
|
525
|
+
return {
|
526
|
+
begin,
|
527
|
+
end,
|
528
|
+
contains: [
|
529
|
+
...REGEXP_CONTENTS,
|
530
|
+
{
|
531
|
+
scope: "comment",
|
532
|
+
begin: `#(?!.*${end})`,
|
533
|
+
end: /$/
|
534
|
+
}
|
535
|
+
]
|
536
|
+
};
|
537
|
+
};
|
538
|
+
const REGEXP = {
|
539
|
+
scope: "regexp",
|
540
|
+
variants: [
|
541
|
+
EXTENDED_REGEXP_LITERAL("###"),
|
542
|
+
EXTENDED_REGEXP_LITERAL("##"),
|
543
|
+
EXTENDED_REGEXP_LITERAL("#"),
|
544
|
+
BARE_REGEXP_LITERAL
|
545
|
+
]
|
546
|
+
};
|
547
|
+
const QUOTED_IDENTIFIER = { match: concat(/`/, identifier, /`/) };
|
548
|
+
const IMPLICIT_PARAMETER = {
|
549
|
+
className: "variable",
|
550
|
+
match: /\$\d+/
|
551
|
+
};
|
552
|
+
const PROPERTY_WRAPPER_PROJECTION = {
|
553
|
+
className: "variable",
|
554
|
+
match: `\\$${identifierCharacter}+`
|
555
|
+
};
|
556
|
+
const IDENTIFIERS = [
|
557
|
+
QUOTED_IDENTIFIER,
|
558
|
+
IMPLICIT_PARAMETER,
|
559
|
+
PROPERTY_WRAPPER_PROJECTION
|
560
|
+
];
|
561
|
+
const AVAILABLE_ATTRIBUTE = {
|
562
|
+
match: /(@|#(un)?)available/,
|
563
|
+
scope: "keyword",
|
564
|
+
starts: { contains: [
|
565
|
+
{
|
566
|
+
begin: /\(/,
|
567
|
+
end: /\)/,
|
568
|
+
keywords: availabilityKeywords,
|
569
|
+
contains: [
|
570
|
+
...OPERATORS,
|
571
|
+
NUMBER,
|
572
|
+
STRING
|
573
|
+
]
|
574
|
+
}
|
575
|
+
] }
|
576
|
+
};
|
577
|
+
const KEYWORD_ATTRIBUTE = {
|
578
|
+
scope: "keyword",
|
579
|
+
match: concat(/@/, either(...keywordAttributes))
|
580
|
+
};
|
581
|
+
const USER_DEFINED_ATTRIBUTE = {
|
582
|
+
scope: "meta",
|
583
|
+
match: concat(/@/, identifier)
|
584
|
+
};
|
585
|
+
const ATTRIBUTES = [
|
586
|
+
AVAILABLE_ATTRIBUTE,
|
587
|
+
KEYWORD_ATTRIBUTE,
|
588
|
+
USER_DEFINED_ATTRIBUTE
|
589
|
+
];
|
590
|
+
const TYPE = {
|
591
|
+
match: lookahead(/\b[A-Z]/),
|
592
|
+
relevance: 0,
|
593
|
+
contains: [
|
594
|
+
{
|
595
|
+
// Common Apple frameworks, for relevance boost
|
596
|
+
className: "type",
|
597
|
+
match: concat(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/, identifierCharacter, "+")
|
598
|
+
},
|
599
|
+
{
|
600
|
+
// Type identifier
|
601
|
+
className: "type",
|
602
|
+
match: typeIdentifier,
|
603
|
+
relevance: 0
|
604
|
+
},
|
605
|
+
{
|
606
|
+
// Optional type
|
607
|
+
match: /[?!]+/,
|
608
|
+
relevance: 0
|
609
|
+
},
|
610
|
+
{
|
611
|
+
// Variadic parameter
|
612
|
+
match: /\.\.\./,
|
613
|
+
relevance: 0
|
614
|
+
},
|
615
|
+
{
|
616
|
+
// Protocol composition
|
617
|
+
match: concat(/\s+&\s+/, lookahead(typeIdentifier)),
|
618
|
+
relevance: 0
|
619
|
+
}
|
620
|
+
]
|
621
|
+
};
|
622
|
+
const GENERIC_ARGUMENTS = {
|
623
|
+
begin: /</,
|
624
|
+
end: />/,
|
625
|
+
keywords: KEYWORDS,
|
626
|
+
contains: [
|
627
|
+
...COMMENTS,
|
628
|
+
...KEYWORD_MODES,
|
629
|
+
...ATTRIBUTES,
|
630
|
+
OPERATOR_GUARD,
|
631
|
+
TYPE
|
632
|
+
]
|
633
|
+
};
|
634
|
+
TYPE.contains.push(GENERIC_ARGUMENTS);
|
635
|
+
const TUPLE_ELEMENT_NAME = {
|
636
|
+
match: concat(identifier, /\s*:/),
|
637
|
+
keywords: "_|0",
|
638
|
+
relevance: 0
|
639
|
+
};
|
640
|
+
const TUPLE = {
|
641
|
+
begin: /\(/,
|
642
|
+
end: /\)/,
|
643
|
+
relevance: 0,
|
644
|
+
keywords: KEYWORDS,
|
645
|
+
contains: [
|
646
|
+
"self",
|
647
|
+
TUPLE_ELEMENT_NAME,
|
648
|
+
...COMMENTS,
|
649
|
+
REGEXP,
|
650
|
+
...KEYWORD_MODES,
|
651
|
+
...BUILT_INS,
|
652
|
+
...OPERATORS,
|
653
|
+
NUMBER,
|
654
|
+
STRING,
|
655
|
+
...IDENTIFIERS,
|
656
|
+
...ATTRIBUTES,
|
657
|
+
TYPE
|
658
|
+
]
|
659
|
+
};
|
660
|
+
const GENERIC_PARAMETERS = {
|
661
|
+
begin: /</,
|
662
|
+
end: />/,
|
663
|
+
keywords: "repeat each",
|
664
|
+
contains: [
|
665
|
+
...COMMENTS,
|
666
|
+
TYPE
|
667
|
+
]
|
668
|
+
};
|
669
|
+
const FUNCTION_PARAMETER_NAME = {
|
670
|
+
begin: either(
|
671
|
+
lookahead(concat(identifier, /\s*:/)),
|
672
|
+
lookahead(concat(identifier, /\s+/, identifier, /\s*:/))
|
673
|
+
),
|
674
|
+
end: /:/,
|
675
|
+
relevance: 0,
|
676
|
+
contains: [
|
677
|
+
{
|
678
|
+
className: "keyword",
|
679
|
+
match: /\b_\b/
|
680
|
+
},
|
681
|
+
{
|
682
|
+
className: "params",
|
683
|
+
match: identifier
|
684
|
+
}
|
685
|
+
]
|
686
|
+
};
|
687
|
+
const FUNCTION_PARAMETERS = {
|
688
|
+
begin: /\(/,
|
689
|
+
end: /\)/,
|
690
|
+
keywords: KEYWORDS,
|
691
|
+
contains: [
|
692
|
+
FUNCTION_PARAMETER_NAME,
|
693
|
+
...COMMENTS,
|
694
|
+
...KEYWORD_MODES,
|
695
|
+
...OPERATORS,
|
696
|
+
NUMBER,
|
697
|
+
STRING,
|
698
|
+
...ATTRIBUTES,
|
699
|
+
TYPE,
|
700
|
+
TUPLE
|
701
|
+
],
|
702
|
+
endsParent: true,
|
703
|
+
illegal: /["']/
|
704
|
+
};
|
705
|
+
const FUNCTION_OR_MACRO = {
|
706
|
+
match: [
|
707
|
+
/(func|macro)/,
|
708
|
+
/\s+/,
|
709
|
+
either(QUOTED_IDENTIFIER.match, identifier, operator)
|
710
|
+
],
|
711
|
+
className: {
|
712
|
+
1: "keyword",
|
713
|
+
3: "title.function"
|
714
|
+
},
|
715
|
+
contains: [
|
716
|
+
GENERIC_PARAMETERS,
|
717
|
+
FUNCTION_PARAMETERS,
|
718
|
+
WHITESPACE
|
719
|
+
],
|
720
|
+
illegal: [
|
721
|
+
/\[/,
|
722
|
+
/%/
|
723
|
+
]
|
724
|
+
};
|
725
|
+
const INIT_SUBSCRIPT = {
|
726
|
+
match: [
|
727
|
+
/\b(?:subscript|init[?!]?)/,
|
728
|
+
/\s*(?=[<(])/
|
729
|
+
],
|
730
|
+
className: { 1: "keyword" },
|
731
|
+
contains: [
|
732
|
+
GENERIC_PARAMETERS,
|
733
|
+
FUNCTION_PARAMETERS,
|
734
|
+
WHITESPACE
|
735
|
+
],
|
736
|
+
illegal: /\[|%/
|
737
|
+
};
|
738
|
+
const OPERATOR_DECLARATION = {
|
739
|
+
match: [
|
740
|
+
/operator/,
|
741
|
+
/\s+/,
|
742
|
+
operator
|
743
|
+
],
|
744
|
+
className: {
|
745
|
+
1: "keyword",
|
746
|
+
3: "title"
|
747
|
+
}
|
748
|
+
};
|
749
|
+
const PRECEDENCEGROUP = {
|
750
|
+
begin: [
|
751
|
+
/precedencegroup/,
|
752
|
+
/\s+/,
|
753
|
+
typeIdentifier
|
754
|
+
],
|
755
|
+
className: {
|
756
|
+
1: "keyword",
|
757
|
+
3: "title"
|
758
|
+
},
|
759
|
+
contains: [TYPE],
|
760
|
+
keywords: [
|
761
|
+
...precedencegroupKeywords,
|
762
|
+
...literals
|
763
|
+
],
|
764
|
+
end: /}/
|
765
|
+
};
|
766
|
+
for (const variant of STRING.variants) {
|
767
|
+
const interpolation = variant.contains.find((mode) => mode.label === "interpol");
|
768
|
+
interpolation.keywords = KEYWORDS;
|
769
|
+
const submodes = [
|
770
|
+
...KEYWORD_MODES,
|
771
|
+
...BUILT_INS,
|
772
|
+
...OPERATORS,
|
773
|
+
NUMBER,
|
774
|
+
STRING,
|
775
|
+
...IDENTIFIERS
|
776
|
+
];
|
777
|
+
interpolation.contains = [
|
778
|
+
...submodes,
|
779
|
+
{
|
780
|
+
begin: /\(/,
|
781
|
+
end: /\)/,
|
782
|
+
contains: [
|
783
|
+
"self",
|
784
|
+
...submodes
|
785
|
+
]
|
786
|
+
}
|
787
|
+
];
|
788
|
+
}
|
789
|
+
return {
|
790
|
+
name: "Swift",
|
791
|
+
keywords: KEYWORDS,
|
792
|
+
contains: [
|
793
|
+
...COMMENTS,
|
794
|
+
FUNCTION_OR_MACRO,
|
795
|
+
INIT_SUBSCRIPT,
|
796
|
+
{
|
797
|
+
beginKeywords: "struct protocol class extension enum actor",
|
798
|
+
end: "\\{",
|
799
|
+
excludeEnd: true,
|
800
|
+
keywords: KEYWORDS,
|
801
|
+
contains: [
|
802
|
+
hljs.inherit(hljs.TITLE_MODE, {
|
803
|
+
className: "title.class",
|
804
|
+
begin: /[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/
|
805
|
+
}),
|
806
|
+
...KEYWORD_MODES
|
807
|
+
]
|
808
|
+
},
|
809
|
+
OPERATOR_DECLARATION,
|
810
|
+
PRECEDENCEGROUP,
|
811
|
+
{
|
812
|
+
beginKeywords: "import",
|
813
|
+
end: /$/,
|
814
|
+
contains: [...COMMENTS],
|
815
|
+
relevance: 0
|
816
|
+
},
|
817
|
+
REGEXP,
|
818
|
+
...KEYWORD_MODES,
|
819
|
+
...BUILT_INS,
|
820
|
+
...OPERATORS,
|
821
|
+
NUMBER,
|
822
|
+
STRING,
|
823
|
+
...IDENTIFIERS,
|
824
|
+
...ATTRIBUTES,
|
825
|
+
TYPE,
|
826
|
+
TUPLE
|
827
|
+
]
|
828
|
+
};
|
829
|
+
}
|
830
|
+
export {
|
831
|
+
swift as default
|
832
|
+
};
|