@health-samurai/react-components 0.0.0-alpha.3 → 0.0.0-alpha.5
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/bundle.css +687 -446
- package/dist/src/components/code-editor/http/grammar/http.d.ts +3 -0
- package/dist/src/components/code-editor/http/grammar/http.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.grammar +74 -0
- package/dist/src/components/code-editor/http/grammar/http.js +38 -0
- package/dist/src/components/code-editor/http/grammar/http.js.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.d.ts +2 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.js +4 -0
- package/dist/src/components/code-editor/http/grammar/http.terms.js.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.test.d.ts +2 -0
- package/dist/src/components/code-editor/http/grammar/http.test.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/grammar/http.test.js +80 -0
- package/dist/src/components/code-editor/http/grammar/http.test.js.map +1 -0
- package/dist/src/components/code-editor/http/index.d.ts +4 -0
- package/dist/src/components/code-editor/http/index.d.ts.map +1 -0
- package/dist/src/components/code-editor/http/index.js +66 -0
- package/dist/src/components/code-editor/http/index.js.map +1 -0
- package/dist/src/components/code-editor/index.d.ts +13 -2
- package/dist/src/components/code-editor/index.d.ts.map +1 -1
- package/dist/src/components/code-editor/index.js +161 -20
- package/dist/src/components/code-editor/index.js.map +1 -1
- package/dist/src/components/code-editor.stories.js +3 -1
- package/dist/src/components/code-editor.stories.js.map +1 -1
- package/dist/src/components/request-line-editor.d.ts +11 -35
- package/dist/src/components/request-line-editor.d.ts.map +1 -1
- package/dist/src/components/request-line-editor.js +51 -49
- package/dist/src/components/request-line-editor.js.map +1 -1
- package/dist/src/components/request-line-editor.stories.d.ts.map +1 -1
- package/dist/src/components/request-line-editor.stories.js +17 -53
- package/dist/src/components/request-line-editor.stories.js.map +1 -1
- package/dist/src/components/tree-view.d.ts +16 -0
- package/dist/src/components/tree-view.d.ts.map +1 -0
- package/dist/src/components/tree-view.js +67 -0
- package/dist/src/components/tree-view.js.map +1 -0
- package/dist/src/components/tree-view.stories.d.ts +13 -0
- package/dist/src/components/tree-view.stories.d.ts.map +1 -0
- package/dist/src/components/tree-view.stories.js +274 -0
- package/dist/src/components/tree-view.stories.js.map +1 -0
- package/dist/src/icons.d.ts +3 -0
- package/dist/src/icons.d.ts.map +1 -0
- package/dist/src/icons.js +47 -0
- package/dist/src/icons.js.map +1 -0
- package/dist/src/index.css +42 -3
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/shadcn/components/ui/accordion.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/accordion.js +23 -5
- package/dist/src/shadcn/components/ui/accordion.js.map +1 -1
- package/dist/src/shadcn/components/ui/alert.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/alert.js +12 -5
- package/dist/src/shadcn/components/ui/alert.js.map +1 -1
- package/dist/src/shadcn/components/ui/avatar.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/avatar.js +4 -3
- package/dist/src/shadcn/components/ui/avatar.js.map +1 -1
- package/dist/src/shadcn/components/ui/badge.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/badge.js +16 -5
- package/dist/src/shadcn/components/ui/badge.js.map +1 -1
- package/dist/src/shadcn/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/breadcrumb.js +6 -6
- package/dist/src/shadcn/components/ui/breadcrumb.js.map +1 -1
- package/dist/src/shadcn/components/ui/button.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/button.js +19 -11
- package/dist/src/shadcn/components/ui/button.js.map +1 -1
- package/dist/src/shadcn/components/ui/card.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/card.js +14 -6
- package/dist/src/shadcn/components/ui/card.js.map +1 -1
- package/dist/src/shadcn/components/ui/carousel.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/carousel.js +1 -0
- package/dist/src/shadcn/components/ui/carousel.js.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.js +20 -5
- package/dist/src/shadcn/components/ui/checkbox.js.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/checkbox.stories.js +44 -35
- package/dist/src/shadcn/components/ui/checkbox.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/combobox.d.ts +18 -0
- package/dist/src/shadcn/components/ui/combobox.d.ts.map +1 -0
- package/dist/src/shadcn/components/ui/combobox.js +121 -0
- package/dist/src/shadcn/components/ui/combobox.js.map +1 -0
- package/dist/src/shadcn/components/ui/combobox.stories.d.ts +11 -0
- package/dist/src/shadcn/components/ui/combobox.stories.d.ts.map +1 -0
- package/dist/src/shadcn/components/ui/combobox.stories.js +16 -0
- package/dist/src/shadcn/components/ui/combobox.stories.js.map +1 -0
- package/dist/src/shadcn/components/ui/command.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/command.js +73 -12
- package/dist/src/shadcn/components/ui/command.js.map +1 -1
- package/dist/src/shadcn/components/ui/command.stories.js +0 -1
- package/dist/src/shadcn/components/ui/command.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/dialog.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/dialog.js +35 -7
- package/dist/src/shadcn/components/ui/dialog.js.map +1 -1
- package/dist/src/shadcn/components/ui/drawer.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/drawer.js +26 -5
- package/dist/src/shadcn/components/ui/drawer.js.map +1 -1
- package/dist/src/shadcn/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/dropdown-menu.js +12 -1
- package/dist/src/shadcn/components/ui/dropdown-menu.js.map +1 -1
- package/dist/src/shadcn/components/ui/form.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/form.js +12 -4
- package/dist/src/shadcn/components/ui/form.js.map +1 -1
- package/dist/src/shadcn/components/ui/input-otp.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/input-otp.js +1 -0
- package/dist/src/shadcn/components/ui/input-otp.js.map +1 -1
- package/dist/src/shadcn/components/ui/input.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/input.js +87 -16
- package/dist/src/shadcn/components/ui/input.js.map +1 -1
- package/dist/src/shadcn/components/ui/label.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/label.js +8 -1
- package/dist/src/shadcn/components/ui/label.js.map +1 -1
- package/dist/src/shadcn/components/ui/menubar.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/menubar.js +35 -13
- package/dist/src/shadcn/components/ui/menubar.js.map +1 -1
- package/dist/src/shadcn/components/ui/pagination.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/pagination.js +6 -6
- package/dist/src/shadcn/components/ui/pagination.js.map +1 -1
- package/dist/src/shadcn/components/ui/popover.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/popover.js +12 -1
- package/dist/src/shadcn/components/ui/popover.js.map +1 -1
- package/dist/src/shadcn/components/ui/progress.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/progress.js +6 -2
- package/dist/src/shadcn/components/ui/progress.js.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.js +11 -6
- package/dist/src/shadcn/components/ui/radio-group.js.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/radio-group.stories.js +57 -34
- package/dist/src/shadcn/components/ui/radio-group.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/resizable.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/resizable.js +1 -0
- package/dist/src/shadcn/components/ui/resizable.js.map +1 -1
- package/dist/src/shadcn/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/scroll-area.js +9 -3
- package/dist/src/shadcn/components/ui/scroll-area.js.map +1 -1
- package/dist/src/shadcn/components/ui/select.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/select.js +49 -14
- package/dist/src/shadcn/components/ui/select.js.map +1 -1
- package/dist/src/shadcn/components/ui/select.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/select.stories.js +1 -4
- package/dist/src/shadcn/components/ui/select.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/separator.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/separator.js +7 -1
- package/dist/src/shadcn/components/ui/separator.js.map +1 -1
- package/dist/src/shadcn/components/ui/sidebar.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/sidebar.js +20 -6
- package/dist/src/shadcn/components/ui/sidebar.js.map +1 -1
- package/dist/src/shadcn/components/ui/skeleton.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/skeleton.js +3 -1
- package/dist/src/shadcn/components/ui/skeleton.js.map +1 -1
- package/dist/src/shadcn/components/ui/slider.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/slider.js +34 -4
- package/dist/src/shadcn/components/ui/slider.js.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.d.ts +16 -1
- package/dist/src/shadcn/components/ui/sonner.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.js +23 -3
- package/dist/src/shadcn/components/ui/sonner.js.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/sonner.stories.js +19 -11
- package/dist/src/shadcn/components/ui/sonner.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/switch.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/switch.js +18 -2
- package/dist/src/shadcn/components/ui/switch.js.map +1 -1
- package/dist/src/shadcn/components/ui/table.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/table.js +12 -8
- package/dist/src/shadcn/components/ui/table.js.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.d.ts +21 -3
- package/dist/src/shadcn/components/ui/tabs.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.js +314 -9
- package/dist/src/shadcn/components/ui/tabs.js.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.stories.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/tabs.stories.js +50 -1
- package/dist/src/shadcn/components/ui/tabs.stories.js.map +1 -1
- package/dist/src/shadcn/components/ui/textarea.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/textarea.js +15 -1
- package/dist/src/shadcn/components/ui/textarea.js.map +1 -1
- package/dist/src/shadcn/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/toggle-group.js +7 -2
- package/dist/src/shadcn/components/ui/toggle-group.js.map +1 -1
- package/dist/src/shadcn/components/ui/toggle.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/toggle.js +18 -6
- package/dist/src/shadcn/components/ui/toggle.js.map +1 -1
- package/dist/src/shadcn/components/ui/tooltip.d.ts.map +1 -1
- package/dist/src/shadcn/components/ui/tooltip.js +11 -1
- package/dist/src/shadcn/components/ui/tooltip.js.map +1 -1
- package/dist/src/shadcn/components/ui/tree.d.ts +20 -0
- package/dist/src/shadcn/components/ui/tree.d.ts.map +1 -0
- package/dist/src/shadcn/components/ui/tree.js +111 -0
- package/dist/src/shadcn/components/ui/tree.js.map +1 -0
- package/package.json +9 -2
- package/src/components/code-editor/http/grammar/http.grammar +74 -0
- package/src/components/code-editor/http/grammar/http.terms.ts +9 -0
- package/src/components/code-editor/http/grammar/http.test.ts +110 -0
- package/src/components/code-editor/http/grammar/http.ts +21 -0
- package/src/components/code-editor/http/index.ts +87 -0
- package/src/components/code-editor/index.tsx +182 -21
- package/src/components/code-editor.stories.tsx +1 -1
- package/src/components/request-line-editor.stories.tsx +17 -27
- package/src/components/request-line-editor.tsx +72 -61
- package/src/components/tree-view.stories.tsx +260 -0
- package/src/components/tree-view.tsx +101 -0
- package/src/icons.tsx +45 -0
- package/src/index.css +42 -3
- package/src/index.tsx +1 -1
- package/src/shadcn/components/ui/accordion.tsx +66 -8
- package/src/shadcn/components/ui/alert.tsx +53 -15
- package/src/shadcn/components/ui/avatar.tsx +17 -6
- package/src/shadcn/components/ui/badge.tsx +67 -18
- package/src/shadcn/components/ui/breadcrumb.tsx +35 -7
- package/src/shadcn/components/ui/button.tsx +118 -57
- package/src/shadcn/components/ui/card.tsx +44 -13
- package/src/shadcn/components/ui/carousel.tsx +1 -0
- package/src/shadcn/components/ui/checkbox.stories.tsx +20 -24
- package/src/shadcn/components/ui/checkbox.tsx +45 -4
- package/src/shadcn/components/ui/combobox.stories.tsx +19 -0
- package/src/shadcn/components/ui/combobox.tsx +142 -0
- package/src/shadcn/components/ui/command.stories.tsx +1 -1
- package/src/shadcn/components/ui/command.tsx +192 -36
- package/src/shadcn/components/ui/dialog.tsx +101 -13
- package/src/shadcn/components/ui/drawer.tsx +93 -18
- package/src/shadcn/components/ui/dropdown-menu.tsx +38 -9
- package/src/shadcn/components/ui/form.tsx +16 -4
- package/src/shadcn/components/ui/input-otp.tsx +1 -0
- package/src/shadcn/components/ui/input.tsx +281 -29
- package/src/shadcn/components/ui/label.tsx +21 -4
- package/src/shadcn/components/ui/menubar.tsx +188 -43
- package/src/shadcn/components/ui/pagination.tsx +12 -6
- package/src/shadcn/components/ui/popover.tsx +35 -4
- package/src/shadcn/components/ui/progress.tsx +21 -5
- package/src/shadcn/components/ui/radio-group.stories.tsx +22 -14
- package/src/shadcn/components/ui/radio-group.tsx +42 -5
- package/src/shadcn/components/ui/resizable.tsx +1 -0
- package/src/shadcn/components/ui/scroll-area.tsx +33 -5
- package/src/shadcn/components/ui/select.stories.tsx +0 -2
- package/src/shadcn/components/ui/select.tsx +184 -33
- package/src/shadcn/components/ui/separator.tsx +15 -5
- package/src/shadcn/components/ui/sidebar.tsx +68 -26
- package/src/shadcn/components/ui/skeleton.tsx +4 -1
- package/src/shadcn/components/ui/slider.tsx +82 -11
- package/src/shadcn/components/ui/sonner.stories.tsx +19 -15
- package/src/shadcn/components/ui/sonner.tsx +53 -3
- package/src/shadcn/components/ui/switch.tsx +53 -7
- package/src/shadcn/components/ui/table.tsx +38 -11
- package/src/shadcn/components/ui/tabs.stories.tsx +32 -0
- package/src/shadcn/components/ui/tabs.tsx +455 -17
- package/src/shadcn/components/ui/textarea.tsx +42 -4
- package/src/shadcn/components/ui/toggle-group.tsx +28 -5
- package/src/shadcn/components/ui/toggle.tsx +59 -18
- package/src/shadcn/components/ui/tooltip.tsx +33 -8
- package/src/shadcn/components/ui/tree.tsx +200 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../../src/components/code-editor/http/grammar/http.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,eAAO,MAAM,MAAM,UAkBjB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
@top Http {
|
|
2
|
+
httpRequest
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
@tokens {
|
|
6
|
+
eof { @eof }
|
|
7
|
+
|
|
8
|
+
lf { $[\n] }
|
|
9
|
+
notLf { ![\n] }
|
|
10
|
+
|
|
11
|
+
cr { $[\r] }
|
|
12
|
+
notCr { ![\r] }
|
|
13
|
+
|
|
14
|
+
colon { $[:] }
|
|
15
|
+
notColon { ![:] }
|
|
16
|
+
|
|
17
|
+
space { $[ \t] }
|
|
18
|
+
notSpace { ![ \t] }
|
|
19
|
+
|
|
20
|
+
headerNameChar { ![\n\r \t:] }
|
|
21
|
+
headerNameText { headerNameChar+ }
|
|
22
|
+
|
|
23
|
+
headerValueFirstChar { ![\n\r \t] }
|
|
24
|
+
headerValueChar { ![\n\r] }
|
|
25
|
+
headerValueLastChar { headerValueFirstChar }
|
|
26
|
+
headerValueText { headerValueFirstChar headerValueChar* headerValueLastChar | headerValueFirstChar }
|
|
27
|
+
|
|
28
|
+
methodChar { ![\n\r \t] }
|
|
29
|
+
methodText { methodChar+ }
|
|
30
|
+
|
|
31
|
+
pathChar { ![\n\r] }
|
|
32
|
+
firstPathChar { ![\n\r \t] }
|
|
33
|
+
pathText { firstPathChar pathChar* }
|
|
34
|
+
|
|
35
|
+
crlf { (cr lf) | cr | lf }
|
|
36
|
+
|
|
37
|
+
bodyChar { _ }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
HttpRequestMethod[group="Method"] {
|
|
41
|
+
methodText
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
HttpRequestPath {
|
|
45
|
+
pathText
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
httpRequestLine {
|
|
49
|
+
space* HttpRequestMethod space+ HttpRequestPath crlf
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
HttpHeaderName {
|
|
53
|
+
headerNameText
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
HttpHeaderValue {
|
|
57
|
+
headerValueText
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
HttpHeader {
|
|
61
|
+
space* HttpHeaderName space* colon space* HttpHeaderValue space* crlf
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
HttpHeaders {
|
|
65
|
+
HttpHeader+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
HttpBody {
|
|
69
|
+
bodyChar*
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
httpRequest {
|
|
73
|
+
httpRequestLine HttpHeaders? crlf HttpBody
|
|
74
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
2
|
+
import { LRParser } from "@lezer/lr";
|
|
3
|
+
export const parser = LRParser.deserialize({
|
|
4
|
+
version: 14,
|
|
5
|
+
states: "'zOQOPOOOOOO'#Ce'#CeOQOPO'#CjOOOO'#C^'#C^OYOPO'#CjO_OQO'#CiQOOOOOOOOO-E6c-E6cOYOPO,59UOjOSO,59UOrOQO'#CaOOOO'#Cb'#CbOzOQO'#CaOOOO'#Cf'#CfO!SOQO'#C`O!_OWO,59TO!gOPO,59TOjOSO1G.pOOOO'#C_'#C_O!lOPO1G.pO!qOQO,58{O!qOQO,58{O!yO`O,58{OOOO-E6d-E6dOOOO'#Cg'#CgO#ROWO'#CdOOOO1G.o1G.oO!_OWO1G.oO#ZOPO7+$[OOOO7+$[7+$[O#`OQO1G.gO!yO`O1G.gO!yO`O1G.gOOOO'#Cc'#CcO#hOPO1G.gOOOO-E6e-E6eOOOO7+$Z7+$ZOOOO<<Gv<<GvO!yO`O7+$RO!yO`O7+$RO#pOPO7+$RO#pOPO7+$ROOOO7+$R7+$RO!yO`O<<GmO#xOPO<<GmO#xOPO<<GmOOOO<<Gm<<GmO$QOPOAN=XO$QOPOAN=XOOOOAN=XAN=XO$YOPOG22sOOOOG22sG22sOOOOLD(_LD(_",
|
|
6
|
+
stateData: "$b~O_PO`RO~O_PO~O_POb_OcZO~O_POabO~O_POcZO~O_POdfO~O_POcZObSX~OfhO[WP~ObkO~ObmO~O_POdoO~O_POeqO~OfhO[WX~ObuO~O_POdvO~O_PObzO~O_POb!OO~O_POb!RO~O_POb!TO~O_POb!UO~O",
|
|
7
|
+
goto: "#|_PP`flosz!Y!`#i#oP#v#yQSORWQQcXRlaR`TT]T^S[T^RdYQrfSxopS|vwR!P{Qj_RtkQQOjVQXYaenpwy{}!Q!SQXSSYT^QaWQe[QndQpfQwoQyrQ{vQ}xQ!Q|R!S!PQ^TRg^Si_kRsiRUORTO",
|
|
8
|
+
nodeNames: "⚠ Http HttpRequestMethod HttpRequestPath HttpHeaders HttpHeader HttpHeaderName HttpHeaderValue HttpBody",
|
|
9
|
+
maxTerm: 22,
|
|
10
|
+
nodeProps: [
|
|
11
|
+
[
|
|
12
|
+
"group",
|
|
13
|
+
2,
|
|
14
|
+
"Method"
|
|
15
|
+
]
|
|
16
|
+
],
|
|
17
|
+
skippedNodes: [
|
|
18
|
+
0
|
|
19
|
+
],
|
|
20
|
+
repeatNodeCount: 3,
|
|
21
|
+
tokenData: "'xoR]OXzXY&VYZ&^Z]z]^&e^pzpq&Vq![z![!]&t!];'Sz;'S;=`'k;=`<%l's<%lOzo!XYfWcQe``PaSOX!wXY#rZ]!w^p!wpq#rq![!w![!]%W!];'S!w;'S;=`&P<%lO!wg#SYcQe``PaSOX!wXY#rZ]!w^p!wpq#rq![!w![!]%W!];'S!w;'S;=`&P<%lO!wd#wWaSOX$aXY#rZ]$a^p$apq#rq;'S$a;'S;=`%Q<%lO$ad$hWe`aSOX$aXY#rZ]$a^p$apq#rq;'S$a;'S;=`%Q<%lO$ad%TP;=`<%l$ae%aWe``PaSOX%WXY#rZ]%W^p%Wpq#rq;'S%W;'S;=`%y<%lO%We%|P;=`<%l%Wg&SP;=`<%l!wo&^OfW_gZ&eOfWbRZ&lPfWbRYZ&oR&tObRo'RWfWdQe``PaSOX%WXY#rZ]%W^p%Wpq#rq;'S%W;'S;=`%y<%lO%Wo'pPfW;=`<%lzW'xOfW",
|
|
22
|
+
tokenizers: [
|
|
23
|
+
0,
|
|
24
|
+
1,
|
|
25
|
+
2,
|
|
26
|
+
3,
|
|
27
|
+
4
|
|
28
|
+
],
|
|
29
|
+
topRules: {
|
|
30
|
+
Http: [
|
|
31
|
+
0,
|
|
32
|
+
1
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
tokenPrec: 0
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/code-editor/http/grammar/http.ts"],"sourcesContent":["// This file was generated by lezer-generator. You probably shouldn't edit it.\nimport { LRParser } from \"@lezer/lr\";\nexport const parser = LRParser.deserialize({\n\tversion: 14,\n\tstates:\n\t\t\"'zOQOPOOOOOO'#Ce'#CeOQOPO'#CjOOOO'#C^'#C^OYOPO'#CjO_OQO'#CiQOOOOOOOOO-E6c-E6cOYOPO,59UOjOSO,59UOrOQO'#CaOOOO'#Cb'#CbOzOQO'#CaOOOO'#Cf'#CfO!SOQO'#C`O!_OWO,59TO!gOPO,59TOjOSO1G.pOOOO'#C_'#C_O!lOPO1G.pO!qOQO,58{O!qOQO,58{O!yO`O,58{OOOO-E6d-E6dOOOO'#Cg'#CgO#ROWO'#CdOOOO1G.o1G.oO!_OWO1G.oO#ZOPO7+$[OOOO7+$[7+$[O#`OQO1G.gO!yO`O1G.gO!yO`O1G.gOOOO'#Cc'#CcO#hOPO1G.gOOOO-E6e-E6eOOOO7+$Z7+$ZOOOO<<Gv<<GvO!yO`O7+$RO!yO`O7+$RO#pOPO7+$RO#pOPO7+$ROOOO7+$R7+$RO!yO`O<<GmO#xOPO<<GmO#xOPO<<GmOOOO<<Gm<<GmO$QOPOAN=XO$QOPOAN=XOOOOAN=XAN=XO$YOPOG22sOOOOG22sG22sOOOOLD(_LD(_\",\n\tstateData:\n\t\t\"$b~O_PO`RO~O_PO~O_POb_OcZO~O_POabO~O_POcZO~O_POdfO~O_POcZObSX~OfhO[WP~ObkO~ObmO~O_POdoO~O_POeqO~OfhO[WX~ObuO~O_POdvO~O_PObzO~O_POb!OO~O_POb!RO~O_POb!TO~O_POb!UO~O\",\n\tgoto: \"#|_PP`flosz!Y!`#i#oP#v#yQSORWQQcXRlaR`TT]T^S[T^RdYQrfSxopS|vwR!P{Qj_RtkQQOjVQXYaenpwy{}!Q!SQXSSYT^QaWQe[QndQpfQwoQyrQ{vQ}xQ!Q|R!S!PQ^TRg^Si_kRsiRUORTO\",\n\tnodeNames:\n\t\t\"⚠ Http HttpRequestMethod HttpRequestPath HttpHeaders HttpHeader HttpHeaderName HttpHeaderValue HttpBody\",\n\tmaxTerm: 22,\n\tnodeProps: [[\"group\", 2, \"Method\"]],\n\tskippedNodes: [0],\n\trepeatNodeCount: 3,\n\ttokenData:\n\t\t\"'xoR]OXzXY&VYZ&^Z]z]^&e^pzpq&Vq![z![!]&t!];'Sz;'S;=`'k;=`<%l's<%lOzo!XYfWcQe``PaSOX!wXY#rZ]!w^p!wpq#rq![!w![!]%W!];'S!w;'S;=`&P<%lO!wg#SYcQe``PaSOX!wXY#rZ]!w^p!wpq#rq![!w![!]%W!];'S!w;'S;=`&P<%lO!wd#wWaSOX$aXY#rZ]$a^p$apq#rq;'S$a;'S;=`%Q<%lO$ad$hWe`aSOX$aXY#rZ]$a^p$apq#rq;'S$a;'S;=`%Q<%lO$ad%TP;=`<%l$ae%aWe``PaSOX%WXY#rZ]%W^p%Wpq#rq;'S%W;'S;=`%y<%lO%We%|P;=`<%l%Wg&SP;=`<%l!wo&^OfW_gZ&eOfWbRZ&lPfWbRYZ&oR&tObRo'RWfWdQe``PaSOX%WXY#rZ]%W^p%Wpq#rq;'S%W;'S;=`%y<%lO%Wo'pPfW;=`<%lzW'xOfW\",\n\ttokenizers: [0, 1, 2, 3, 4],\n\ttopRules: { Http: [0, 1] },\n\ttokenPrec: 0,\n});\n"],"names":["LRParser","parser","deserialize","version","states","stateData","goto","nodeNames","maxTerm","nodeProps","skippedNodes","repeatNodeCount","tokenData","tokenizers","topRules","Http","tokenPrec"],"mappings":"AAAA,8EAA8E;AAC9E,SAASA,QAAQ,QAAQ,YAAY;AACrC,OAAO,MAAMC,SAASD,SAASE,WAAW,CAAC;IAC1CC,SAAS;IACTC,QACC;IACDC,WACC;IACDC,MAAM;IACNC,WACC;IACDC,SAAS;IACTC,WAAW;QAAC;YAAC;YAAS;YAAG;SAAS;KAAC;IACnCC,cAAc;QAAC;KAAE;IACjBC,iBAAiB;IACjBC,WACC;IACDC,YAAY;QAAC;QAAG;QAAG;QAAG;QAAG;KAAE;IAC3BC,UAAU;QAAEC,MAAM;YAAC;YAAG;SAAE;IAAC;IACzBC,WAAW;AACZ,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.terms.d.ts","sourceRoot":"","sources":["../../../../../../src/components/code-editor/http/grammar/http.terms.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,IAAI,IAAI,EACpB,iBAAiB,IAAI,EACrB,eAAe,IAAI,EACnB,WAAW,IAAI,EACf,UAAU,IAAI,EACd,cAAc,IAAI,EAClB,eAAe,IAAI,EACnB,QAAQ,IAAI,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
2
|
+
export const Http = 1, HttpRequestMethod = 2, HttpRequestPath = 3, HttpHeaders = 4, HttpHeader = 5, HttpHeaderName = 6, HttpHeaderValue = 7, HttpBody = 8;
|
|
3
|
+
|
|
4
|
+
//# sourceMappingURL=http.terms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/code-editor/http/grammar/http.terms.ts"],"sourcesContent":["// This file was generated by lezer-generator. You probably shouldn't edit it.\nexport const Http = 1,\n\tHttpRequestMethod = 2,\n\tHttpRequestPath = 3,\n\tHttpHeaders = 4,\n\tHttpHeader = 5,\n\tHttpHeaderName = 6,\n\tHttpHeaderValue = 7,\n\tHttpBody = 8;\n"],"names":["Http","HttpRequestMethod","HttpRequestPath","HttpHeaders","HttpHeader","HttpHeaderName","HttpHeaderValue","HttpBody"],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,MAAMA,OAAO,GACnBC,oBAAoB,GACpBC,kBAAkB,GAClBC,cAAc,GACdC,aAAa,GACbC,iBAAiB,GACjBC,kBAAkB,GAClBC,WAAW,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.test.d.ts","sourceRoot":"","sources":["../../../../../../src/components/code-editor/http/grammar/http.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Tests for lezer Http grammar
|
|
2
|
+
import { testTree } from "@lezer/generator/test";
|
|
3
|
+
import { parser } from "./http.js";
|
|
4
|
+
function parseHttp(input) {
|
|
5
|
+
const stack = [];
|
|
6
|
+
parser.parse(input).iterate({
|
|
7
|
+
enter: (node)=>{
|
|
8
|
+
const nodeName = node.type.name;
|
|
9
|
+
const nodeFrom = node.from;
|
|
10
|
+
const nodeTo = node.to;
|
|
11
|
+
const value = input.slice(nodeFrom, nodeTo);
|
|
12
|
+
stack.push({
|
|
13
|
+
name: nodeName,
|
|
14
|
+
from: nodeFrom,
|
|
15
|
+
to: nodeTo,
|
|
16
|
+
value: value,
|
|
17
|
+
children: []
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
leave: ()=>{
|
|
21
|
+
const current = stack.pop();
|
|
22
|
+
if (current === undefined) {
|
|
23
|
+
throw "Stack underflow";
|
|
24
|
+
}
|
|
25
|
+
if (stack.length === 0) {
|
|
26
|
+
// Re-push root
|
|
27
|
+
stack.push(current);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const parent = stack[stack.length - 1];
|
|
31
|
+
if (parent === undefined) {
|
|
32
|
+
throw "Impossible";
|
|
33
|
+
}
|
|
34
|
+
parent.children.push(current);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const res = stack.pop();
|
|
38
|
+
if (res === undefined) {
|
|
39
|
+
throw "Stack underflow";
|
|
40
|
+
}
|
|
41
|
+
return res;
|
|
42
|
+
}
|
|
43
|
+
function transform(root) {
|
|
44
|
+
const tree = {
|
|
45
|
+
name: root.name,
|
|
46
|
+
children: []
|
|
47
|
+
};
|
|
48
|
+
let pos = root.from;
|
|
49
|
+
for (const child of root.children){
|
|
50
|
+
if (pos < child.from) {
|
|
51
|
+
const prefix = root.value.slice(pos - root.from, child.from - root.from);
|
|
52
|
+
tree.children.push(prefix);
|
|
53
|
+
}
|
|
54
|
+
tree.children.push(transform(child));
|
|
55
|
+
pos = child.to;
|
|
56
|
+
}
|
|
57
|
+
if (pos < root.to) {
|
|
58
|
+
tree.children.push(root.value.slice(pos - root.from));
|
|
59
|
+
}
|
|
60
|
+
return tree;
|
|
61
|
+
}
|
|
62
|
+
const tree = parser.parse("GET /\nAccept: text/yaml\n\nhello: world");
|
|
63
|
+
console.dir(parseHttp("GET /\nAccept: text/yaml\n\nhello: world\n\nagain"), {
|
|
64
|
+
depth: null
|
|
65
|
+
});
|
|
66
|
+
console.dir(transform(parseHttp("GET /\nAccept: text/yaml\n\nhello: world\n\nagain")), {
|
|
67
|
+
depth: null
|
|
68
|
+
});
|
|
69
|
+
console.log(tree);
|
|
70
|
+
tree.iterate({
|
|
71
|
+
enter: (node)=>{
|
|
72
|
+
console.log(`ENTER ${node.type.name}[${node.from}:${node.to}]`);
|
|
73
|
+
},
|
|
74
|
+
leave: (node)=>{
|
|
75
|
+
console.log(`LEAVE ${node.type.name}[${node.from}:${node.to}]`);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
testTree(tree, `Http`);
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=http.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/code-editor/http/grammar/http.test.ts"],"sourcesContent":["// Tests for lezer Http grammar\n\nimport { testTree } from \"@lezer/generator/test\";\nimport { parser } from \"./http\";\n\ntype StackEntry = {\n\tname: string;\n\tfrom: number;\n\tto: number;\n\tvalue: string;\n\tchildren: StackEntry[];\n\ttextNode?: boolean;\n};\n\nfunction parseHttp(input: string): StackEntry {\n\tconst stack: StackEntry[] = [];\n\tparser.parse(input).iterate({\n\t\tenter: (node) => {\n\t\t\tconst nodeName = node.type.name;\n\t\t\tconst nodeFrom = node.from;\n\t\t\tconst nodeTo = node.to;\n\t\t\tconst value = input.slice(nodeFrom, nodeTo);\n\n\t\t\tstack.push({\n\t\t\t\tname: nodeName,\n\t\t\t\tfrom: nodeFrom,\n\t\t\t\tto: nodeTo,\n\t\t\t\tvalue: value,\n\t\t\t\tchildren: [],\n\t\t\t});\n\t\t},\n\n\t\tleave: () => {\n\t\t\tconst current = stack.pop();\n\t\t\tif (current === undefined) {\n\t\t\t\tthrow \"Stack underflow\";\n\t\t\t}\n\n\t\t\tif (stack.length === 0) {\n\t\t\t\t// Re-push root\n\t\t\t\tstack.push(current);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst parent = stack[stack.length - 1];\n\t\t\tif (parent === undefined) {\n\t\t\t\tthrow \"Impossible\";\n\t\t\t}\n\n\t\t\tparent.children.push(current);\n\t\t},\n\t});\n\n\tconst res = stack.pop();\n\tif (res === undefined) {\n\t\tthrow \"Stack underflow\";\n\t}\n\treturn res;\n}\n\ntype Tree = TreeNode | string;\ntype TreeNode = {\n\tname: string;\n\tchildren: Tree[];\n};\n\nfunction transform(root: StackEntry): Tree {\n\tconst tree: Tree = {\n\t\tname: root.name,\n\t\tchildren: [],\n\t};\n\n\tlet pos = root.from;\n\tfor (const child of root.children) {\n\t\tif (pos < child.from) {\n\t\t\tconst prefix = root.value.slice(pos - root.from, child.from - root.from);\n\t\t\ttree.children.push(prefix);\n\t\t}\n\n\t\ttree.children.push(transform(child));\n\t\tpos = child.to;\n\t}\n\n\tif (pos < root.to) {\n\t\ttree.children.push(root.value.slice(pos - root.from));\n\t}\n\n\treturn tree;\n}\n\nconst tree = parser.parse(\"GET /\\nAccept: text/yaml\\n\\nhello: world\");\nconsole.dir(parseHttp(\"GET /\\nAccept: text/yaml\\n\\nhello: world\\n\\nagain\"), {\n\tdepth: null,\n});\nconsole.dir(\n\ttransform(parseHttp(\"GET /\\nAccept: text/yaml\\n\\nhello: world\\n\\nagain\")),\n\t{\n\t\tdepth: null,\n\t},\n);\nconsole.log(tree);\ntree.iterate({\n\tenter: (node) => {\n\t\tconsole.log(`ENTER ${node.type.name}[${node.from}:${node.to}]`);\n\t},\n\tleave: (node) => {\n\t\tconsole.log(`LEAVE ${node.type.name}[${node.from}:${node.to}]`);\n\t},\n});\ntestTree(tree, `Http`);\n"],"names":["testTree","parser","parseHttp","input","stack","parse","iterate","enter","node","nodeName","type","name","nodeFrom","from","nodeTo","to","value","slice","push","children","leave","current","pop","undefined","length","parent","res","transform","root","tree","pos","child","prefix","console","dir","depth","log"],"mappings":"AAAA,+BAA+B;AAE/B,SAASA,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,MAAM,QAAQ,YAAS;AAWhC,SAASC,UAAUC,KAAa;IAC/B,MAAMC,QAAsB,EAAE;IAC9BH,OAAOI,KAAK,CAACF,OAAOG,OAAO,CAAC;QAC3BC,OAAO,CAACC;YACP,MAAMC,WAAWD,KAAKE,IAAI,CAACC,IAAI;YAC/B,MAAMC,WAAWJ,KAAKK,IAAI;YAC1B,MAAMC,SAASN,KAAKO,EAAE;YACtB,MAAMC,QAAQb,MAAMc,KAAK,CAACL,UAAUE;YAEpCV,MAAMc,IAAI,CAAC;gBACVP,MAAMF;gBACNI,MAAMD;gBACNG,IAAID;gBACJE,OAAOA;gBACPG,UAAU,EAAE;YACb;QACD;QAEAC,OAAO;YACN,MAAMC,UAAUjB,MAAMkB,GAAG;YACzB,IAAID,YAAYE,WAAW;gBAC1B,MAAM;YACP;YAEA,IAAInB,MAAMoB,MAAM,KAAK,GAAG;gBACvB,eAAe;gBACfpB,MAAMc,IAAI,CAACG;gBACX;YACD;YAEA,MAAMI,SAASrB,KAAK,CAACA,MAAMoB,MAAM,GAAG,EAAE;YACtC,IAAIC,WAAWF,WAAW;gBACzB,MAAM;YACP;YAEAE,OAAON,QAAQ,CAACD,IAAI,CAACG;QACtB;IACD;IAEA,MAAMK,MAAMtB,MAAMkB,GAAG;IACrB,IAAII,QAAQH,WAAW;QACtB,MAAM;IACP;IACA,OAAOG;AACR;AAQA,SAASC,UAAUC,IAAgB;IAClC,MAAMC,OAAa;QAClBlB,MAAMiB,KAAKjB,IAAI;QACfQ,UAAU,EAAE;IACb;IAEA,IAAIW,MAAMF,KAAKf,IAAI;IACnB,KAAK,MAAMkB,SAASH,KAAKT,QAAQ,CAAE;QAClC,IAAIW,MAAMC,MAAMlB,IAAI,EAAE;YACrB,MAAMmB,SAASJ,KAAKZ,KAAK,CAACC,KAAK,CAACa,MAAMF,KAAKf,IAAI,EAAEkB,MAAMlB,IAAI,GAAGe,KAAKf,IAAI;YACvEgB,KAAKV,QAAQ,CAACD,IAAI,CAACc;QACpB;QAEAH,KAAKV,QAAQ,CAACD,IAAI,CAACS,UAAUI;QAC7BD,MAAMC,MAAMhB,EAAE;IACf;IAEA,IAAIe,MAAMF,KAAKb,EAAE,EAAE;QAClBc,KAAKV,QAAQ,CAACD,IAAI,CAACU,KAAKZ,KAAK,CAACC,KAAK,CAACa,MAAMF,KAAKf,IAAI;IACpD;IAEA,OAAOgB;AACR;AAEA,MAAMA,OAAO5B,OAAOI,KAAK,CAAC;AAC1B4B,QAAQC,GAAG,CAAChC,UAAU,sDAAsD;IAC3EiC,OAAO;AACR;AACAF,QAAQC,GAAG,CACVP,UAAUzB,UAAU,uDACpB;IACCiC,OAAO;AACR;AAEDF,QAAQG,GAAG,CAACP;AACZA,KAAKvB,OAAO,CAAC;IACZC,OAAO,CAACC;QACPyB,QAAQG,GAAG,CAAC,CAAC,MAAM,EAAE5B,KAAKE,IAAI,CAACC,IAAI,CAAC,CAAC,EAAEH,KAAKK,IAAI,CAAC,CAAC,EAAEL,KAAKO,EAAE,CAAC,CAAC,CAAC;IAC/D;IACAK,OAAO,CAACZ;QACPyB,QAAQG,GAAG,CAAC,CAAC,MAAM,EAAE5B,KAAKE,IAAI,CAACC,IAAI,CAAC,CAAC,EAAEH,KAAKK,IAAI,CAAC,CAAC,EAAEL,KAAKO,EAAE,CAAC,CAAC,CAAC;IAC/D;AACD;AACAf,SAAS6B,MAAM,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/code-editor/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,QAAQ,EACb,eAAe,EAEf,MAAM,sBAAsB,CAAC;AA0E9B,iBAAS,IAAI,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,QAAQ,GAAG,IAAI,mBAIpE;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { foldInside, foldNodeProp, LanguageSupport, LRLanguage } from "@codemirror/language";
|
|
2
|
+
import { parseMixed } from "@lezer/common";
|
|
3
|
+
import { styleTags, tags } from "@lezer/highlight";
|
|
4
|
+
import { parser } from "./grammar/http.js";
|
|
5
|
+
function makeParser(bodyLanguages) {
|
|
6
|
+
return parser.configure({
|
|
7
|
+
props: [
|
|
8
|
+
styleTags({
|
|
9
|
+
HttpHeaderName: tags.variableName,
|
|
10
|
+
HttpHeaderValue: tags.attributeValue
|
|
11
|
+
}),
|
|
12
|
+
foldNodeProp.add({
|
|
13
|
+
HttpHeaders: foldInside
|
|
14
|
+
})
|
|
15
|
+
],
|
|
16
|
+
wrap: parseMixed((node, input)=>{
|
|
17
|
+
if (node.name !== "HttpBody") {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const headers = node.node.prevSibling;
|
|
21
|
+
if (headers?.name !== "HttpHeaders") {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
let contentType = null;
|
|
25
|
+
for(let child = headers.firstChild; child !== null; child = child.nextSibling){
|
|
26
|
+
const headerNameNode = child.getChild("HttpHeaderName");
|
|
27
|
+
if (headerNameNode === null) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const headerName = input.read(headerNameNode.from, headerNameNode.to);
|
|
31
|
+
if (headerName.toLowerCase() !== "content-type") {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (contentType !== null) {
|
|
35
|
+
// Disallow multiple content types
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const headerValueNode = child.getChild("HttpHeaderValue");
|
|
39
|
+
if (headerValueNode === null) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
contentType = input.read(headerValueNode.from, headerValueNode.to);
|
|
43
|
+
}
|
|
44
|
+
if (contentType === null) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const language = bodyLanguages(contentType);
|
|
48
|
+
if (language === null) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
parser: language.parser
|
|
53
|
+
};
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function http(bodyLanguages) {
|
|
58
|
+
const parser = makeParser(bodyLanguages);
|
|
59
|
+
const language = LRLanguage.define({
|
|
60
|
+
parser: parser
|
|
61
|
+
});
|
|
62
|
+
return new LanguageSupport(language, []);
|
|
63
|
+
}
|
|
64
|
+
export { http };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/code-editor/http/index.ts"],"sourcesContent":["import {\n\tfoldInside,\n\tfoldNodeProp,\n\ttype Language,\n\tLanguageSupport,\n\tLRLanguage,\n} from \"@codemirror/language\";\nimport { parseMixed } from \"@lezer/common\";\nimport { styleTags, tags } from \"@lezer/highlight\";\nimport type { LRParser } from \"@lezer/lr\";\nimport { parser } from \"./grammar/http\";\n\nfunction makeParser(\n\tbodyLanguages: (contentType: string) => Language | null,\n): LRParser {\n\treturn parser.configure({\n\t\tprops: [\n\t\t\tstyleTags({\n\t\t\t\tHttpHeaderName: tags.variableName,\n\t\t\t\tHttpHeaderValue: tags.attributeValue,\n\t\t\t}),\n\n\t\t\tfoldNodeProp.add({\n\t\t\t\tHttpHeaders: foldInside,\n\t\t\t}),\n\t\t],\n\t\twrap: parseMixed((node, input) => {\n\t\t\tif (node.name !== \"HttpBody\") {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst headers = node.node.prevSibling;\n\t\t\tif (headers?.name !== \"HttpHeaders\") {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tlet contentType: string | null = null;\n\n\t\t\tfor (\n\t\t\t\tlet child = headers.firstChild;\n\t\t\t\tchild !== null;\n\t\t\t\tchild = child.nextSibling\n\t\t\t) {\n\t\t\t\tconst headerNameNode = child.getChild(\"HttpHeaderName\");\n\t\t\t\tif (headerNameNode === null) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst headerName = input.read(headerNameNode.from, headerNameNode.to);\n\t\t\t\tif (headerName.toLowerCase() !== \"content-type\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (contentType !== null) {\n\t\t\t\t\t// Disallow multiple content types\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst headerValueNode = child.getChild(\"HttpHeaderValue\");\n\t\t\t\tif (headerValueNode === null) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentType = input.read(headerValueNode.from, headerValueNode.to);\n\t\t\t}\n\n\t\t\tif (contentType === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst language = bodyLanguages(contentType);\n\t\t\tif (language === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn { parser: language.parser };\n\t\t}),\n\t});\n}\n\nfunction http(bodyLanguages: (contentType: string) => Language | null) {\n\tconst parser = makeParser(bodyLanguages);\n\tconst language = LRLanguage.define({ parser: parser });\n\treturn new LanguageSupport(language, []);\n}\n\nexport { http };\n"],"names":["foldInside","foldNodeProp","LanguageSupport","LRLanguage","parseMixed","styleTags","tags","parser","makeParser","bodyLanguages","configure","props","HttpHeaderName","variableName","HttpHeaderValue","attributeValue","add","HttpHeaders","wrap","node","input","name","headers","prevSibling","contentType","child","firstChild","nextSibling","headerNameNode","getChild","headerName","read","from","to","toLowerCase","headerValueNode","language","http","define"],"mappings":"AAAA,SACCA,UAAU,EACVC,YAAY,EAEZC,eAAe,EACfC,UAAU,QACJ,uBAAuB;AAC9B,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,SAAS,EAAEC,IAAI,QAAQ,mBAAmB;AAEnD,SAASC,MAAM,QAAQ,oBAAiB;AAExC,SAASC,WACRC,aAAuD;IAEvD,OAAOF,OAAOG,SAAS,CAAC;QACvBC,OAAO;YACNN,UAAU;gBACTO,gBAAgBN,KAAKO,YAAY;gBACjCC,iBAAiBR,KAAKS,cAAc;YACrC;YAEAd,aAAae,GAAG,CAAC;gBAChBC,aAAajB;YACd;SACA;QACDkB,MAAMd,WAAW,CAACe,MAAMC;YACvB,IAAID,KAAKE,IAAI,KAAK,YAAY;gBAC7B,OAAO;YACR;YAEA,MAAMC,UAAUH,KAAKA,IAAI,CAACI,WAAW;YACrC,IAAID,SAASD,SAAS,eAAe;gBACpC,OAAO;YACR;YAEA,IAAIG,cAA6B;YAEjC,IACC,IAAIC,QAAQH,QAAQI,UAAU,EAC9BD,UAAU,MACVA,QAAQA,MAAME,WAAW,CACxB;gBACD,MAAMC,iBAAiBH,MAAMI,QAAQ,CAAC;gBACtC,IAAID,mBAAmB,MAAM;oBAC5B;gBACD;gBAEA,MAAME,aAAaV,MAAMW,IAAI,CAACH,eAAeI,IAAI,EAAEJ,eAAeK,EAAE;gBACpE,IAAIH,WAAWI,WAAW,OAAO,gBAAgB;oBAChD;gBACD;gBAEA,IAAIV,gBAAgB,MAAM;oBACzB,kCAAkC;oBAClC,OAAO;gBACR;gBAEA,MAAMW,kBAAkBV,MAAMI,QAAQ,CAAC;gBACvC,IAAIM,oBAAoB,MAAM;oBAC7B;gBACD;gBAEAX,cAAcJ,MAAMW,IAAI,CAACI,gBAAgBH,IAAI,EAAEG,gBAAgBF,EAAE;YAClE;YAEA,IAAIT,gBAAgB,MAAM;gBACzB,OAAO;YACR;YAEA,MAAMY,WAAW3B,cAAce;YAC/B,IAAIY,aAAa,MAAM;gBACtB,OAAO;YACR;YAEA,OAAO;gBAAE7B,QAAQ6B,SAAS7B,MAAM;YAAC;QAClC;IACD;AACD;AAEA,SAAS8B,KAAK5B,aAAuD;IACpE,MAAMF,SAASC,WAAWC;IAC1B,MAAM2B,WAAWjC,WAAWmC,MAAM,CAAC;QAAE/B,QAAQA;IAAO;IACpD,OAAO,IAAIL,gBAAgBkC,UAAU,EAAE;AACxC;AAEA,SAASC,IAAI,GAAG"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { EditorView, type ViewUpdate } from "@codemirror/view";
|
|
2
|
+
type LanguageMode = "json" | "http";
|
|
3
|
+
type CodeEditorProps = {
|
|
4
|
+
readOnly?: boolean;
|
|
2
5
|
defaultValue?: string;
|
|
6
|
+
currentValue?: string;
|
|
3
7
|
onChange?: (value: string) => void;
|
|
4
|
-
|
|
8
|
+
onUpdate?: (update: ViewUpdate) => void;
|
|
9
|
+
id?: string;
|
|
10
|
+
mode?: LanguageMode;
|
|
11
|
+
viewCallback?: (view: EditorView) => void;
|
|
12
|
+
};
|
|
13
|
+
export type CodeEditorView = EditorView;
|
|
14
|
+
export declare function CodeEditor({ defaultValue, currentValue, onChange, onUpdate, viewCallback, readOnly, id, mode, }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
5
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/code-editor/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/code-editor/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAIN,UAAU,EAOV,KAAK,UAAU,EACf,MAAM,kBAAkB,CAAC;AA0F1B,KAAK,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAkBpC,KAAK,eAAe,GAAG;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC;AAExC,wBAAgB,UAAU,CAAC,EAC1B,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,QAAgB,EAChB,EAAE,EACF,IAAa,GACb,EAAE,eAAe,2CA8IjB"}
|
|
@@ -5,10 +5,11 @@ import { json, jsonParseLinter } from "@codemirror/lang-json";
|
|
|
5
5
|
import { bracketMatching, foldGutter, foldKeymap, HighlightStyle, indentOnInput, syntaxHighlighting } from "@codemirror/language";
|
|
6
6
|
import { linter, lintGutter, lintKeymap } from "@codemirror/lint";
|
|
7
7
|
import { highlightSelectionMatches, searchKeymap } from "@codemirror/search";
|
|
8
|
-
import { EditorState } from "@codemirror/state";
|
|
8
|
+
import { Compartment, EditorState } from "@codemirror/state";
|
|
9
9
|
import { crosshairCursor, drawSelection, dropCursor, EditorView, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, keymap, lineNumbers, rectangularSelection } from "@codemirror/view";
|
|
10
10
|
import { tags } from "@lezer/highlight";
|
|
11
11
|
import * as React from "react";
|
|
12
|
+
import { http } from "./http/index.js";
|
|
12
13
|
const baseTheme = EditorView.baseTheme({
|
|
13
14
|
"&": {
|
|
14
15
|
backgroundColor: "var(--color-bg-primary)",
|
|
@@ -46,6 +47,43 @@ const baseTheme = EditorView.baseTheme({
|
|
|
46
47
|
backgroundColor: "rgba(255, 255, 255, 0)"
|
|
47
48
|
}
|
|
48
49
|
});
|
|
50
|
+
const readOnlyTheme = EditorView.theme({
|
|
51
|
+
"&": {
|
|
52
|
+
backgroundColor: "var(--color-bg-secondary)",
|
|
53
|
+
height: "100%",
|
|
54
|
+
width: "100%",
|
|
55
|
+
fontSize: "14px",
|
|
56
|
+
paddingTop: "8px",
|
|
57
|
+
paddingBottom: "8px"
|
|
58
|
+
},
|
|
59
|
+
".cm-scroller": {
|
|
60
|
+
overflow: "auto"
|
|
61
|
+
},
|
|
62
|
+
".cm-content": {
|
|
63
|
+
fontFamily: "var(--font-family-mono)",
|
|
64
|
+
padding: "0"
|
|
65
|
+
},
|
|
66
|
+
"&.cm-focused": {
|
|
67
|
+
outline: "none"
|
|
68
|
+
},
|
|
69
|
+
".cm-gutter": {
|
|
70
|
+
fontFamily: "var(--font-family-mono)"
|
|
71
|
+
},
|
|
72
|
+
".cm-gutters": {
|
|
73
|
+
backgroundColor: "var(--color-bg-secondary)",
|
|
74
|
+
border: "none"
|
|
75
|
+
},
|
|
76
|
+
".cm-lineNumbers": {
|
|
77
|
+
paddingLeft: "16px"
|
|
78
|
+
},
|
|
79
|
+
".cm-activeLineGutter": {
|
|
80
|
+
backgroundColor: "var(--color-bg-secondary)",
|
|
81
|
+
color: "var(--color-text-primary)"
|
|
82
|
+
},
|
|
83
|
+
".cm-activeLine": {
|
|
84
|
+
backgroundColor: "rgba(255, 255, 255, 0)"
|
|
85
|
+
}
|
|
86
|
+
});
|
|
49
87
|
const customHighlightStyle = HighlightStyle.define([
|
|
50
88
|
{
|
|
51
89
|
tag: tags.propertyName,
|
|
@@ -68,17 +106,45 @@ const customHighlightStyle = HighlightStyle.define([
|
|
|
68
106
|
color: "#569cd6"
|
|
69
107
|
}
|
|
70
108
|
]);
|
|
71
|
-
|
|
72
|
-
|
|
109
|
+
function languageExtensions(mode) {
|
|
110
|
+
if (mode === "http") {
|
|
111
|
+
const jsonLang = json();
|
|
112
|
+
return [
|
|
113
|
+
http((ct)=>ct === "application/json" ? jsonLang.language : null),
|
|
114
|
+
syntaxHighlighting(customHighlightStyle)
|
|
115
|
+
];
|
|
116
|
+
} else {
|
|
117
|
+
return [
|
|
118
|
+
json(),
|
|
119
|
+
linter(jsonParseLinter(), {
|
|
120
|
+
delay: 300
|
|
121
|
+
}),
|
|
122
|
+
syntaxHighlighting(customHighlightStyle)
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function CodeEditor({ defaultValue, currentValue, onChange, onUpdate, viewCallback, readOnly = false, id, mode = "json" }) {
|
|
127
|
+
const domRef = React.useRef(null);
|
|
128
|
+
const [view, setView] = React.useState(null);
|
|
129
|
+
const initialValue = React.useRef(defaultValue ?? "");
|
|
130
|
+
const onChangeComparment = React.useRef(new Compartment());
|
|
131
|
+
const onUpdateComparment = React.useRef(new Compartment());
|
|
132
|
+
const languageCompartment = React.useRef(new Compartment());
|
|
133
|
+
const readOnlyCompartment = React.useRef(new Compartment());
|
|
134
|
+
const themeCompartment = React.useRef(new Compartment());
|
|
73
135
|
React.useEffect(()=>{
|
|
74
|
-
if (!
|
|
136
|
+
if (!domRef.current) {
|
|
75
137
|
return;
|
|
76
138
|
}
|
|
77
139
|
const view = new EditorView({
|
|
78
|
-
parent:
|
|
140
|
+
parent: domRef.current,
|
|
79
141
|
state: EditorState.create({
|
|
80
|
-
doc:
|
|
142
|
+
doc: initialValue.current,
|
|
81
143
|
extensions: [
|
|
144
|
+
EditorView.contentAttributes.of({
|
|
145
|
+
"data-gramm": "false"
|
|
146
|
+
}),
|
|
147
|
+
readOnlyCompartment.current.of(EditorState.readOnly.of(false)),
|
|
82
148
|
lineNumbers(),
|
|
83
149
|
foldGutter(),
|
|
84
150
|
highlightSpecialChars(),
|
|
@@ -87,8 +153,7 @@ export function CodeEditor({ defaultValue, onChange }) {
|
|
|
87
153
|
dropCursor(),
|
|
88
154
|
EditorState.allowMultipleSelections.of(true),
|
|
89
155
|
indentOnInput(),
|
|
90
|
-
|
|
91
|
-
syntaxHighlighting(customHighlightStyle),
|
|
156
|
+
languageCompartment.current.of([]),
|
|
92
157
|
bracketMatching(),
|
|
93
158
|
closeBrackets(),
|
|
94
159
|
autocompletion(),
|
|
@@ -97,7 +162,7 @@ export function CodeEditor({ defaultValue, onChange }) {
|
|
|
97
162
|
highlightActiveLine(),
|
|
98
163
|
highlightActiveLineGutter(),
|
|
99
164
|
highlightSelectionMatches(),
|
|
100
|
-
baseTheme,
|
|
165
|
+
themeCompartment.current.of(baseTheme),
|
|
101
166
|
keymap.of([
|
|
102
167
|
...closeBracketsKeymap,
|
|
103
168
|
...defaultKeymap,
|
|
@@ -107,26 +172,102 @@ export function CodeEditor({ defaultValue, onChange }) {
|
|
|
107
172
|
...completionKeymap,
|
|
108
173
|
...lintKeymap
|
|
109
174
|
]),
|
|
110
|
-
linter(jsonParseLinter(), {
|
|
111
|
-
delay: 300
|
|
112
|
-
}),
|
|
113
175
|
lintGutter(),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
onChange(update.view.state.doc.toString());
|
|
117
|
-
}
|
|
118
|
-
})
|
|
176
|
+
onChangeComparment.current.of([]),
|
|
177
|
+
onUpdateComparment.current.of([])
|
|
119
178
|
]
|
|
120
179
|
})
|
|
121
180
|
});
|
|
122
|
-
|
|
181
|
+
setView(()=>view);
|
|
182
|
+
return ()=>{
|
|
183
|
+
view.destroy();
|
|
184
|
+
setView(()=>null);
|
|
185
|
+
};
|
|
186
|
+
}, []);
|
|
187
|
+
React.useEffect(()=>{
|
|
188
|
+
if (viewCallback && view) {
|
|
189
|
+
viewCallback(view);
|
|
190
|
+
}
|
|
191
|
+
}, [
|
|
192
|
+
view,
|
|
193
|
+
viewCallback
|
|
194
|
+
]);
|
|
195
|
+
React.useEffect(()=>{
|
|
196
|
+
view?.dispatch({
|
|
197
|
+
effects: onChangeComparment.current.reconfigure([
|
|
198
|
+
EditorView.updateListener.of((update)=>{
|
|
199
|
+
if (update.docChanged && onChange) {
|
|
200
|
+
onChange(update.view.state.doc.toString());
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
])
|
|
204
|
+
});
|
|
123
205
|
}, [
|
|
124
|
-
|
|
206
|
+
view,
|
|
125
207
|
onChange
|
|
126
208
|
]);
|
|
209
|
+
React.useEffect(()=>{
|
|
210
|
+
view?.dispatch({
|
|
211
|
+
effects: onUpdateComparment.current.reconfigure([
|
|
212
|
+
EditorView.updateListener.of((update)=>{
|
|
213
|
+
if (onUpdate) {
|
|
214
|
+
onUpdate(update);
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
])
|
|
218
|
+
});
|
|
219
|
+
}, [
|
|
220
|
+
view,
|
|
221
|
+
onUpdate
|
|
222
|
+
]);
|
|
223
|
+
// FIXME: it is probably better to have CM manage its state.
|
|
224
|
+
React.useEffect(()=>{
|
|
225
|
+
if (!view || currentValue === undefined) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const currentDoc = view.state.doc.toString();
|
|
229
|
+
if (currentDoc !== currentValue) {
|
|
230
|
+
view.dispatch({
|
|
231
|
+
changes: {
|
|
232
|
+
from: 0,
|
|
233
|
+
to: currentDoc.length,
|
|
234
|
+
insert: currentValue
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}, [
|
|
239
|
+
currentValue,
|
|
240
|
+
view
|
|
241
|
+
]);
|
|
242
|
+
React.useEffect(()=>{
|
|
243
|
+
if (view === null) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
view.dispatch({
|
|
247
|
+
effects: languageCompartment.current.reconfigure(languageExtensions(mode))
|
|
248
|
+
});
|
|
249
|
+
}, [
|
|
250
|
+
mode,
|
|
251
|
+
view
|
|
252
|
+
]);
|
|
253
|
+
React.useEffect(()=>{
|
|
254
|
+
if (view === null) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
view.dispatch({
|
|
258
|
+
effects: [
|
|
259
|
+
readOnlyCompartment.current.reconfigure(EditorState.readOnly.of(readOnly)),
|
|
260
|
+
themeCompartment.current.reconfigure(readOnly ? readOnlyTheme : baseTheme)
|
|
261
|
+
]
|
|
262
|
+
});
|
|
263
|
+
}, [
|
|
264
|
+
readOnly,
|
|
265
|
+
view
|
|
266
|
+
]);
|
|
127
267
|
return /*#__PURE__*/ _jsx("div", {
|
|
128
268
|
className: "h-full w-full",
|
|
129
|
-
ref:
|
|
269
|
+
ref: domRef,
|
|
270
|
+
id: id
|
|
130
271
|
});
|
|
131
272
|
}
|
|
132
273
|
|