1 module spasm.bindings.url;
2 
3 import spasm.types;
4 import spasm.bindings.fileapi;
5 import spasm.bindings.mediasource;
6 
7 @safe:
8 nothrow:
9 
10 struct URL {
11   nothrow:
12   JsHandle handle;
13   alias handle this;
14   this(Handle h) {
15     this.handle = JsHandle(h);
16   }
17   void href()(string href) {
18     URL_href_Set(this.handle, href);
19   }
20   auto href()() {
21     return URL_href_Get(this.handle);
22   }
23   auto origin()() {
24     return URL_origin_Get(this.handle);
25   }
26   void protocol()(string protocol) {
27     URL_protocol_Set(this.handle, protocol);
28   }
29   auto protocol()() {
30     return URL_protocol_Get(this.handle);
31   }
32   void username()(string username) {
33     URL_username_Set(this.handle, username);
34   }
35   auto username()() {
36     return URL_username_Get(this.handle);
37   }
38   void password()(string password) {
39     URL_password_Set(this.handle, password);
40   }
41   auto password()() {
42     return URL_password_Get(this.handle);
43   }
44   void host()(string host) {
45     URL_host_Set(this.handle, host);
46   }
47   auto host()() {
48     return URL_host_Get(this.handle);
49   }
50   void hostname()(string hostname) {
51     URL_hostname_Set(this.handle, hostname);
52   }
53   auto hostname()() {
54     return URL_hostname_Get(this.handle);
55   }
56   void port()(string port) {
57     URL_port_Set(this.handle, port);
58   }
59   auto port()() {
60     return URL_port_Get(this.handle);
61   }
62   void pathname()(string pathname) {
63     URL_pathname_Set(this.handle, pathname);
64   }
65   auto pathname()() {
66     return URL_pathname_Get(this.handle);
67   }
68   void search()(string search) {
69     URL_search_Set(this.handle, search);
70   }
71   auto search()() {
72     return URL_search_Get(this.handle);
73   }
74   auto searchParams()() {
75     return URLSearchParams(URL_searchParams_Get(this.handle));
76   }
77   void hash()(string hash) {
78     URL_hash_Set(this.handle, hash);
79   }
80   auto hash()() {
81     return URL_hash_Get(this.handle);
82   }
83   auto toJSON()() {
84     return URL_toJSON(this.handle);
85   }
86   auto createObjectURL()(scope ref Blob blob) {
87     return URL_createObjectURL__Handle(this.handle, blob.handle);
88   }
89   void revokeObjectURL()(string url) {
90     URL_revokeObjectURL(this.handle, url);
91   }
92   auto createObjectURL()(scope ref MediaSource mediaSource) {
93     return URL_createObjectURL__Handle(this.handle, mediaSource._parent);
94   }
95 }
96 struct URLSearchParams {
97   nothrow:
98   JsHandle handle;
99   alias handle this;
100   this(Handle h) {
101     this.handle = JsHandle(h);
102   }
103   void append()(string name, string value) {
104     URLSearchParams_append(this.handle, name, value);
105   }
106   void delete_()(string name) {
107     URLSearchParams_delete(this.handle, name);
108   }
109   auto get()(string name) {
110     return URLSearchParams_get(this.handle, name);
111   }
112   auto getAll()(string name) {
113     return Sequence!(string)(URLSearchParams_getAll(this.handle, name));
114   }
115   auto has()(string name) {
116     return URLSearchParams_has(this.handle, name);
117   }
118   void set()(string name, string value) {
119     URLSearchParams_set(this.handle, name, value);
120   }
121   void sort()() {
122     URLSearchParams_sort(this.handle);
123   }
124 }
125 
126 
127 extern (C) void URL_href_Set(Handle, string);
128 extern (C) string URL_href_Get(Handle);
129 extern (C) string URL_origin_Get(Handle);
130 extern (C) void URL_protocol_Set(Handle, string);
131 extern (C) string URL_protocol_Get(Handle);
132 extern (C) void URL_username_Set(Handle, string);
133 extern (C) string URL_username_Get(Handle);
134 extern (C) void URL_password_Set(Handle, string);
135 extern (C) string URL_password_Get(Handle);
136 extern (C) void URL_host_Set(Handle, string);
137 extern (C) string URL_host_Get(Handle);
138 extern (C) void URL_hostname_Set(Handle, string);
139 extern (C) string URL_hostname_Get(Handle);
140 extern (C) void URL_port_Set(Handle, string);
141 extern (C) string URL_port_Get(Handle);
142 extern (C) void URL_pathname_Set(Handle, string);
143 extern (C) string URL_pathname_Get(Handle);
144 extern (C) void URL_search_Set(Handle, string);
145 extern (C) string URL_search_Get(Handle);
146 extern (C) Handle URL_searchParams_Get(Handle);
147 extern (C) void URL_hash_Set(Handle, string);
148 extern (C) string URL_hash_Get(Handle);
149 extern (C) string URL_toJSON(Handle);
150 extern (C) string URL_createObjectURL__Handle(Handle, Handle);
151 extern (C) void URL_revokeObjectURL(Handle, string);
152 extern (C) void URLSearchParams_append(Handle, string, string);
153 extern (C) void URLSearchParams_delete(Handle, string);
154 extern (C) Optional!(string) URLSearchParams_get(Handle, string);
155 extern (C) Handle URLSearchParams_getAll(Handle, string);
156 extern (C) bool URLSearchParams_has(Handle, string);
157 extern (C) void URLSearchParams_set(Handle, string, string);
158 extern (C) void URLSearchParams_sort(Handle);